@trillet-ai/web-sdk 1.10.0 → 1.11.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.
@@ -5,20 +5,232 @@ import {
5
5
  apiUrl
6
6
  } from "../chunk-CVTVHUNZ.js";
7
7
 
8
- // src/widget/config.ts
9
- var DEFAULT_COPY = {
10
- startCallText: "Start a call",
11
- endCallText: "End call",
12
- messageText: "Message",
13
- switchToTextText: "Switch to text mode",
14
- switchToVoiceText: "Switch to voice mode",
15
- listeningText: "Listening\u2026",
16
- speakingText: "Speaking\u2026",
17
- expandText: "Expand",
18
- collapseText: "Collapse",
19
- recaptchaText: "Verify you are human to start",
20
- inputPlaceholder: "Type a message\u2026"
8
+ // src/widget/i18n.ts
9
+ var WIDGET_LANGUAGES = ["en", "de", "fr", "it"];
10
+ var WIDGET_COPY = {
11
+ en: {
12
+ startCallText: "Start a call",
13
+ startChatText: "Start chat",
14
+ endCallText: "End call",
15
+ endChatText: "End chat",
16
+ endConversationText: "End conversation",
17
+ messageText: "Message",
18
+ callLabel: "Call",
19
+ chatLabel: "Chat",
20
+ switchToTextText: "Switch to text mode",
21
+ switchToVoiceText: "Switch to voice mode",
22
+ listeningText: "Listening\u2026",
23
+ speakingText: "Speaking\u2026",
24
+ expandText: "Expand",
25
+ collapseText: "Collapse",
26
+ recaptchaText: "Verify you are human to start",
27
+ inputPlaceholder: "Type a message\u2026",
28
+ askAnything: "Ask anything\u2026",
29
+ askNamed: "Ask {name} anything\u2026",
30
+ chooseModePrompt: "How would you like to talk?",
31
+ talkToUs: "Talk to us now",
32
+ connecting: "Connecting\u2026",
33
+ online: "Online",
34
+ callEnded: "Call ended",
35
+ chatEnded: "This chat has ended.",
36
+ startNewChat: "Start a new chat",
37
+ backToChat: "Back to chat",
38
+ chatWithNamed: "Chat with {name}",
39
+ chat: "Chat",
40
+ send: "Send",
41
+ close: "Close",
42
+ typing: "Typing",
43
+ muteMic: "Mute microphone",
44
+ unmuteMic: "Unmute microphone",
45
+ terms: "Terms",
46
+ termsTitle: "Before we start",
47
+ termsAccept: "Agree and continue",
48
+ termsDecline: "Not now",
49
+ feedbackQuestion: "How was this conversation?",
50
+ feedbackThanks: "Thanks for the feedback.",
51
+ errorNotEnabled: "Chat is not enabled on this website.",
52
+ errorUnavailable: "Chat is not available right now.",
53
+ errorTooMany: "Too many chats right now. Please try again shortly.",
54
+ errorGeneric: "Could not connect. Please try again.",
55
+ feedbackGood: "Good",
56
+ feedbackBad: "Not good",
57
+ openChat: "Open the chat",
58
+ minimize: "Minimize",
59
+ typeInstead: "Type instead",
60
+ showConversation: "Show the conversation",
61
+ talkInstead: "Talk instead"
62
+ },
63
+ de: {
64
+ startCallText: "Anruf starten",
65
+ startChatText: "Chat starten",
66
+ endCallText: "Anruf beenden",
67
+ endChatText: "Chat beenden",
68
+ endConversationText: "Gespr\xE4ch beenden",
69
+ messageText: "Nachricht",
70
+ callLabel: "Anrufen",
71
+ chatLabel: "Chat",
72
+ switchToTextText: "Zum Textmodus wechseln",
73
+ switchToVoiceText: "Zum Sprachmodus wechseln",
74
+ listeningText: "H\xF6rt zu\u2026",
75
+ speakingText: "Spricht\u2026",
76
+ expandText: "Erweitern",
77
+ collapseText: "Verkleinern",
78
+ recaptchaText: "Bitte best\xE4tigen Sie, dass Sie ein Mensch sind",
79
+ inputPlaceholder: "Nachricht eingeben\u2026",
80
+ askAnything: "Stellen Sie Ihre Frage\u2026",
81
+ askNamed: "Ihre Frage an {name}\u2026",
82
+ chooseModePrompt: "Wie m\xF6chten Sie mit uns sprechen?",
83
+ talkToUs: "Jetzt mit uns sprechen",
84
+ connecting: "Verbindung wird hergestellt\u2026",
85
+ online: "Online",
86
+ callEnded: "Anruf beendet",
87
+ chatEnded: "Dieser Chat wurde beendet.",
88
+ startNewChat: "Neuen Chat starten",
89
+ backToChat: "Zur\xFCck zum Chat",
90
+ chatWithNamed: "Chat mit {name}",
91
+ chat: "Chat",
92
+ send: "Senden",
93
+ close: "Ausblenden",
94
+ typing: "Schreibt",
95
+ muteMic: "Mikrofon stummschalten",
96
+ unmuteMic: "Mikrofon einschalten",
97
+ terms: "Nutzungsbedingungen",
98
+ termsTitle: "Bevor wir beginnen",
99
+ termsAccept: "Zustimmen und fortfahren",
100
+ termsDecline: "Nicht jetzt",
101
+ feedbackQuestion: "Wie war dieses Gespr\xE4ch?",
102
+ feedbackThanks: "Danke f\xFCr Ihr Feedback.",
103
+ errorNotEnabled: "Der Chat ist auf dieser Website nicht aktiviert.",
104
+ errorUnavailable: "Der Chat ist im Moment nicht verf\xFCgbar.",
105
+ errorTooMany: "Gerade sind zu viele Chats aktiv. Bitte versuchen Sie es gleich nochmals.",
106
+ errorGeneric: "Verbindung fehlgeschlagen. Bitte versuchen Sie es nochmals.",
107
+ feedbackGood: "Gut",
108
+ feedbackBad: "Nicht gut",
109
+ openChat: "Chat \xF6ffnen",
110
+ minimize: "Minimieren",
111
+ typeInstead: "Lieber schreiben",
112
+ showConversation: "Gespr\xE4ch anzeigen",
113
+ talkInstead: "Lieber sprechen"
114
+ },
115
+ fr: {
116
+ startCallText: "D\xE9marrer un appel",
117
+ startChatText: "D\xE9marrer le chat",
118
+ endCallText: "Terminer l'appel",
119
+ endChatText: "Terminer le chat",
120
+ endConversationText: "Terminer la conversation",
121
+ messageText: "Message",
122
+ callLabel: "Appeler",
123
+ chatLabel: "Chat",
124
+ switchToTextText: "Passer au mode texte",
125
+ switchToVoiceText: "Passer au mode vocal",
126
+ listeningText: "\xC9coute\u2026",
127
+ speakingText: "Parle\u2026",
128
+ expandText: "Agrandir",
129
+ collapseText: "R\xE9duire",
130
+ recaptchaText: "Veuillez confirmer que vous \xEAtes humain",
131
+ inputPlaceholder: "\xC9crivez un message\u2026",
132
+ askAnything: "Posez votre question\u2026",
133
+ askNamed: "Votre question pour {name}\u2026",
134
+ chooseModePrompt: "Comment souhaitez-vous \xE9changer ?",
135
+ talkToUs: "Parlez-nous maintenant",
136
+ connecting: "Connexion\u2026",
137
+ online: "En ligne",
138
+ callEnded: "Appel termin\xE9",
139
+ chatEnded: "Ce chat est termin\xE9.",
140
+ startNewChat: "D\xE9marrer un nouveau chat",
141
+ backToChat: "Retour au chat",
142
+ chatWithNamed: "Chat avec {name}",
143
+ chat: "Chat",
144
+ send: "Envoyer",
145
+ close: "Fermer",
146
+ typing: "En train d'\xE9crire",
147
+ muteMic: "Couper le micro",
148
+ unmuteMic: "Activer le micro",
149
+ terms: "Conditions",
150
+ termsTitle: "Avant de commencer",
151
+ termsAccept: "Accepter et continuer",
152
+ termsDecline: "Pas maintenant",
153
+ feedbackQuestion: "Comment s\u2019est pass\xE9e cette conversation ?",
154
+ feedbackThanks: "Merci pour votre retour.",
155
+ errorNotEnabled: "Le chat n'est pas activ\xE9 sur ce site.",
156
+ errorUnavailable: "Le chat n'est pas disponible pour le moment.",
157
+ errorTooMany: "Trop de chats en cours. Veuillez r\xE9essayer dans un instant.",
158
+ errorGeneric: "Connexion impossible. Veuillez r\xE9essayer.",
159
+ feedbackGood: "Bien",
160
+ feedbackBad: "Pas bien",
161
+ openChat: "Ouvrir le chat",
162
+ minimize: "R\xE9duire",
163
+ typeInstead: "\xC9crire plut\xF4t",
164
+ showConversation: "Afficher la conversation",
165
+ talkInstead: "Parler plut\xF4t"
166
+ },
167
+ it: {
168
+ startCallText: "Avvia una chiamata",
169
+ startChatText: "Avvia la chat",
170
+ endCallText: "Termina la chiamata",
171
+ endChatText: "Termina la chat",
172
+ endConversationText: "Termina la conversazione",
173
+ messageText: "Messaggio",
174
+ callLabel: "Chiama",
175
+ chatLabel: "Chat",
176
+ switchToTextText: "Passa alla modalit\xE0 testo",
177
+ switchToVoiceText: "Passa alla modalit\xE0 vocale",
178
+ listeningText: "In ascolto\u2026",
179
+ speakingText: "Sta parlando\u2026",
180
+ expandText: "Espandi",
181
+ collapseText: "Riduci",
182
+ recaptchaText: "Confermi di non essere un robot",
183
+ inputPlaceholder: "Scriva un messaggio\u2026",
184
+ askAnything: "Faccia la sua domanda\u2026",
185
+ askNamed: "La sua domanda per {name}\u2026",
186
+ chooseModePrompt: "Come preferisce comunicare?",
187
+ talkToUs: "Parli con noi ora",
188
+ connecting: "Connessione in corso\u2026",
189
+ online: "Online",
190
+ callEnded: "Chiamata terminata",
191
+ chatEnded: "Questa chat \xE8 terminata.",
192
+ startNewChat: "Avvia una nuova chat",
193
+ backToChat: "Torna alla chat",
194
+ chatWithNamed: "Chat con {name}",
195
+ chat: "Chat",
196
+ send: "Invia",
197
+ close: "Chiudi",
198
+ typing: "Sta scrivendo",
199
+ muteMic: "Disattiva microfono",
200
+ unmuteMic: "Attiva microfono",
201
+ terms: "Condizioni",
202
+ termsTitle: "Prima di iniziare",
203
+ termsAccept: "Accetta e continua",
204
+ termsDecline: "Non ora",
205
+ feedbackQuestion: "Com\u2019\xE8 andata questa conversazione?",
206
+ feedbackThanks: "Grazie per il feedback.",
207
+ errorNotEnabled: "La chat non \xE8 attiva su questo sito.",
208
+ errorUnavailable: "La chat non \xE8 disponibile al momento.",
209
+ errorTooMany: "Troppe chat in corso. Riprovi tra poco.",
210
+ errorGeneric: "Connessione non riuscita. Riprovi.",
211
+ feedbackGood: "Bene",
212
+ feedbackBad: "Non bene",
213
+ openChat: "Apri la chat",
214
+ minimize: "Riduci a icona",
215
+ typeInstead: "Preferisco scrivere",
216
+ showConversation: "Mostra la conversazione",
217
+ talkInstead: "Preferisco parlare"
218
+ }
21
219
  };
220
+ function normalizeLanguage(tag) {
221
+ if (!tag) return null;
222
+ const base = tag.trim().toLowerCase().split(/[-_]/)[0];
223
+ return WIDGET_LANGUAGES.includes(base) ? base : null;
224
+ }
225
+ function resolveLanguage(attr, remote, pageLang) {
226
+ var _a, _b, _c;
227
+ return (_c = (_b = (_a = normalizeLanguage(attr)) != null ? _a : normalizeLanguage(remote)) != null ? _b : normalizeLanguage(pageLang)) != null ? _c : "en";
228
+ }
229
+ function fillName(template, name) {
230
+ return template.replace("{name}", name);
231
+ }
232
+
233
+ // src/widget/config.ts
22
234
  var OBSERVED_ATTRIBUTES = [
23
235
  "agent-id",
24
236
  "signed-url-endpoint",
@@ -50,6 +262,8 @@ var OBSERVED_ATTRIBUTES = [
50
262
  "action-text",
51
263
  "start-call-text",
52
264
  "end-call-text",
265
+ "end-chat-text",
266
+ "language",
53
267
  "message-text",
54
268
  "call-label",
55
269
  "chat-label",
@@ -131,7 +345,7 @@ function resolveVariant(raw) {
131
345
  }
132
346
  }
133
347
  function configFromElement(el, remote) {
134
- var _a, _b;
348
+ var _a, _b, _c;
135
349
  const r = remote || {};
136
350
  const get = (name, fallback) => {
137
351
  var _a2;
@@ -142,9 +356,12 @@ function configFromElement(el, remote) {
142
356
  const mode = modeRaw === "text" ? "text" : modeRaw === "both" ? "both" : "voice";
143
357
  const placementRaw = get("placement", r.placement);
144
358
  const placement = PLACEMENTS.includes(placementRaw) ? placementRaw : "bottom-right";
359
+ const pageLang = typeof document !== "undefined" ? (_a = document.documentElement) == null ? void 0 : _a.lang : null;
360
+ const language = resolveLanguage(el.getAttribute("language"), r.language, pageLang);
361
+ const copy = WIDGET_COPY[language];
145
362
  const isText = mode === "text";
146
- const startDefault = r.startCallText || (isText ? "Start chat" : DEFAULT_COPY.startCallText);
147
- const endDefault = isText ? "End chat" : DEFAULT_COPY.endCallText;
363
+ const startDefault = r.startCallText || (isText ? copy.startChatText : copy.startCallText);
364
+ const endDefault = isText ? get("end-chat-text") || copy.endChatText : copy.endCallText;
148
365
  const brand = {};
149
366
  const brandLogo = get("brand-logo", r.brandLogo);
150
367
  const brandColor = get("brand-color", r.brandColor);
@@ -176,22 +393,24 @@ function configFromElement(el, remote) {
176
393
  variant,
177
394
  placement,
178
395
  dismissible: parseBoolAttr(get("dismissible")),
396
+ language,
397
+ copy,
179
398
  actionText: get("action-text", r.launcherText) || void 0,
180
399
  startCallText: get("start-call-text") || startDefault,
181
400
  endCallText: get("end-call-text") || endDefault,
182
- messageText: get("message-text", r.messageText) || DEFAULT_COPY.messageText,
183
- callLabel: get("call-label") || "Call",
184
- chatLabel: get("chat-label") || "Chat",
185
- switchToTextText: get("switch-to-text-text") || DEFAULT_COPY.switchToTextText,
186
- switchToVoiceText: get("switch-to-voice-text") || DEFAULT_COPY.switchToVoiceText,
187
- listeningText: get("listening-text") || DEFAULT_COPY.listeningText,
188
- speakingText: get("speaking-text") || DEFAULT_COPY.speakingText,
189
- expandText: get("expand-text") || DEFAULT_COPY.expandText,
190
- collapseText: get("collapse-text") || DEFAULT_COPY.collapseText,
191
- recaptchaText: get("recaptcha-text") || DEFAULT_COPY.recaptchaText,
401
+ messageText: get("message-text", r.messageText) || copy.messageText,
402
+ callLabel: get("call-label") || copy.callLabel,
403
+ chatLabel: get("chat-label") || copy.chatLabel,
404
+ switchToTextText: get("switch-to-text-text") || copy.switchToTextText,
405
+ switchToVoiceText: get("switch-to-voice-text") || copy.switchToVoiceText,
406
+ listeningText: get("listening-text") || copy.listeningText,
407
+ speakingText: get("speaking-text") || copy.speakingText,
408
+ expandText: get("expand-text") || copy.expandText,
409
+ collapseText: get("collapse-text") || copy.collapseText,
410
+ recaptchaText: get("recaptcha-text") || copy.recaptchaText,
192
411
  greeting: get("greeting", r.greeting) || void 0,
193
- inputPlaceholder: get("input-placeholder", r.inputPlaceholder) || DEFAULT_COPY.inputPlaceholder,
194
- suggestedPrompts: (_b = (_a = parsePromptsAttr(el.getAttribute("suggested-prompts"))) != null ? _a : r.suggestedPrompts) != null ? _b : [],
412
+ inputPlaceholder: get("input-placeholder", r.inputPlaceholder) || copy.inputPlaceholder,
413
+ suggestedPrompts: (_c = (_b = parsePromptsAttr(el.getAttribute("suggested-prompts"))) != null ? _b : r.suggestedPrompts) != null ? _c : [],
195
414
  theme: get("theme", r.theme) === "dark" ? "dark" : "light",
196
415
  backgroundColor: hexOrUndefined(get("bg-color", r.backgroundColor)),
197
416
  textColor: hexOrUndefined(get("text-color", r.textColor)),
@@ -1252,7 +1471,7 @@ var TrilletWidgetElement = class extends HTMLElement {
1252
1471
  }
1253
1472
  handleError(error) {
1254
1473
  const err = error instanceof Error ? error : new Error(String(error));
1255
- this.errorText = friendlyError(err);
1474
+ this.errorText = friendlyError(err, this.config.copy);
1256
1475
  this.clearDurationTimer();
1257
1476
  this.speaking = false;
1258
1477
  this.switching = false;
@@ -1330,13 +1549,13 @@ var TrilletWidgetElement = class extends HTMLElement {
1330
1549
  }
1331
1550
  /** The line under the agent's name in the header. */
1332
1551
  statusText() {
1333
- if (this.state === "connecting") return "Connecting\u2026";
1552
+ if (this.state === "connecting") return this.config.copy.connecting;
1334
1553
  if (this.state === "live" && this.resolvedMode() === "voice") {
1335
1554
  const activity = this.speaking ? this.config.speakingText : this.config.listeningText;
1336
1555
  return `${activity} ${this.timerText()}`.trim();
1337
1556
  }
1338
- if (this.state === "live") return "Online";
1339
- return this.config.brand.name || "Online";
1557
+ if (this.state === "live") return this.config.copy.online;
1558
+ return this.config.brand.name || this.config.copy.online;
1340
1559
  }
1341
1560
  renderStatus() {
1342
1561
  const statusEl = this.root.querySelector(".tw-status");
@@ -1445,10 +1664,10 @@ var TrilletWidgetElement = class extends HTMLElement {
1445
1664
  const card = document.createElement("div");
1446
1665
  card.className = "tw-card tw-terms";
1447
1666
  card.setAttribute("role", "dialog");
1448
- card.setAttribute("aria-label", "Terms");
1667
+ card.setAttribute("aria-label", this.config.copy.terms);
1449
1668
  const title = document.createElement("div");
1450
1669
  title.className = "tw-card-title";
1451
- title.textContent = "Before we start";
1670
+ title.textContent = this.config.copy.termsTitle;
1452
1671
  card.appendChild(title);
1453
1672
  const body = document.createElement("div");
1454
1673
  body.className = "tw-terms-body tw-md";
@@ -1459,7 +1678,7 @@ var TrilletWidgetElement = class extends HTMLElement {
1459
1678
  const accept = document.createElement("button");
1460
1679
  accept.type = "button";
1461
1680
  accept.className = "tw-pill";
1462
- accept.textContent = "Agree and continue";
1681
+ accept.textContent = this.config.copy.termsAccept;
1463
1682
  accept.addEventListener("click", () => {
1464
1683
  try {
1465
1684
  window.localStorage.setItem(this.termsKey(), "1");
@@ -1475,7 +1694,7 @@ var TrilletWidgetElement = class extends HTMLElement {
1475
1694
  const decline = document.createElement("button");
1476
1695
  decline.type = "button";
1477
1696
  decline.className = "tw-secondary-btn";
1478
- decline.textContent = "Not now";
1697
+ decline.textContent = this.config.copy.termsDecline;
1479
1698
  decline.addEventListener("click", () => {
1480
1699
  this.showTerms = false;
1481
1700
  this.pendingStart = null;
@@ -1493,11 +1712,11 @@ var TrilletWidgetElement = class extends HTMLElement {
1493
1712
  const row = document.createElement("div");
1494
1713
  row.className = "tw-feedback";
1495
1714
  if (this.feedbackState === "sent") {
1496
- row.textContent = "Thanks for the feedback.";
1715
+ row.textContent = this.config.copy.feedbackThanks;
1497
1716
  return row;
1498
1717
  }
1499
1718
  const label = document.createElement("span");
1500
- label.textContent = "How was this conversation?";
1719
+ label.textContent = this.config.copy.feedbackQuestion;
1501
1720
  row.appendChild(label);
1502
1721
  const send = (rating) => {
1503
1722
  this.feedbackState = "sent";
@@ -1509,8 +1728,8 @@ var TrilletWidgetElement = class extends HTMLElement {
1509
1728
  }).catch(() => void 0);
1510
1729
  this.dispatch("feedback", rating);
1511
1730
  };
1512
- row.appendChild(this.iconButton(ICONS.thumbUp, "Good", () => send("up")));
1513
- row.appendChild(this.iconButton(ICONS.thumbDown, "Not good", () => send("down")));
1731
+ row.appendChild(this.iconButton(ICONS.thumbUp, this.config.copy.feedbackGood, () => send("up")));
1732
+ row.appendChild(this.iconButton(ICONS.thumbDown, this.config.copy.feedbackBad, () => send("down")));
1514
1733
  return row;
1515
1734
  }
1516
1735
  /**
@@ -1550,10 +1769,10 @@ var TrilletWidgetElement = class extends HTMLElement {
1550
1769
  const back = document.createElement("button");
1551
1770
  back.type = "button";
1552
1771
  back.className = "tw-ask-label";
1553
- back.textContent = name ? `Chat with ${name}` : "Back to chat";
1772
+ back.textContent = name ? fillName(this.config.copy.chatWithNamed, name) : this.config.copy.backToChat;
1554
1773
  back.addEventListener("click", () => this.openPanel());
1555
1774
  bar.appendChild(back);
1556
- bar.appendChild(this.iconButton(ICONS.chat, "Open the chat", () => this.openPanel(), "tw-sq tw-sq-accent"));
1775
+ bar.appendChild(this.iconButton(ICONS.chat, this.config.copy.openChat, () => this.openPanel(), "tw-sq tw-sq-accent"));
1557
1776
  stack.appendChild(bar);
1558
1777
  return stack;
1559
1778
  }
@@ -1578,11 +1797,11 @@ var TrilletWidgetElement = class extends HTMLElement {
1578
1797
  const input = document.createElement("input");
1579
1798
  input.className = "tw-ask-input";
1580
1799
  input.type = "text";
1581
- input.placeholder = this.config.greeting || (name ? `Ask ${name} anything\u2026` : "Ask anything\u2026");
1800
+ input.placeholder = this.config.greeting || (name ? fillName(this.config.copy.askNamed, name) : this.config.copy.askAnything);
1582
1801
  input.setAttribute("aria-label", input.placeholder);
1583
1802
  input.value = this.draft;
1584
1803
  input.disabled = gated;
1585
- const send = this.iconButton(ICONS.send, "Send", () => void 0, "tw-sq tw-sq-accent");
1804
+ const send = this.iconButton(ICONS.send, this.config.copy.send, () => void 0, "tw-sq tw-sq-accent");
1586
1805
  send.type = "submit";
1587
1806
  const sync = () => {
1588
1807
  send.disabled = gated || !input.value.trim();
@@ -1674,7 +1893,7 @@ var TrilletWidgetElement = class extends HTMLElement {
1674
1893
  const panel = document.createElement("div");
1675
1894
  panel.className = `tw-panel${this.config.variant === "expanded" ? " tw-expanded" : ""}`;
1676
1895
  panel.setAttribute("role", "dialog");
1677
- panel.setAttribute("aria-label", this.headerTitle() || "Chat");
1896
+ panel.setAttribute("aria-label", this.headerTitle() || this.config.copy.chat);
1678
1897
  panel.appendChild(this.renderHeader());
1679
1898
  panel.appendChild(this.renderBody());
1680
1899
  return panel;
@@ -1722,14 +1941,14 @@ var TrilletWidgetElement = class extends HTMLElement {
1722
1941
  const actions = document.createElement("div");
1723
1942
  actions.className = "tw-header-actions";
1724
1943
  actions.appendChild(
1725
- this.iconButton(ICONS.minimize, "Minimize", () => {
1944
+ this.iconButton(ICONS.minimize, this.config.copy.minimize, () => {
1726
1945
  this.open = false;
1727
1946
  this.render();
1728
1947
  })
1729
1948
  );
1730
1949
  if (this.config.dismissible) {
1731
1950
  actions.appendChild(
1732
- this.iconButton(ICONS.close, "Close", () => {
1951
+ this.iconButton(ICONS.close, this.config.copy.close, () => {
1733
1952
  if (this.state === "live" || this.state === "connecting") this.endConversation();
1734
1953
  this.open = false;
1735
1954
  this.render();
@@ -1850,7 +2069,7 @@ var TrilletWidgetElement = class extends HTMLElement {
1850
2069
  body.appendChild(this.buildAvatar("lg"));
1851
2070
  const prompt = document.createElement("p");
1852
2071
  prompt.className = "tw-prompt";
1853
- prompt.textContent = this.config.greeting || "How would you like to talk?";
2072
+ prompt.textContent = this.config.greeting || this.config.copy.chooseModePrompt;
1854
2073
  body.appendChild(prompt);
1855
2074
  const choices = document.createElement("div");
1856
2075
  choices.className = "tw-choices";
@@ -1879,10 +2098,10 @@ var TrilletWidgetElement = class extends HTMLElement {
1879
2098
  body.appendChild(this.buildAvatar("lg"));
1880
2099
  const status = document.createElement("p");
1881
2100
  status.className = "tw-prompt";
1882
- if (this.state === "connecting") status.textContent = "Connecting\u2026";
2101
+ if (this.state === "connecting") status.textContent = this.config.copy.connecting;
1883
2102
  else if (this.state === "live") status.textContent = this.speaking ? this.config.speakingText : this.config.listeningText;
1884
- else if (this.state === "ended") status.textContent = (_a = this.errorText) != null ? _a : "Call ended";
1885
- else status.textContent = this.config.actionText || "Talk to us now";
2103
+ else if (this.state === "ended") status.textContent = (_a = this.errorText) != null ? _a : this.config.copy.callEnded;
2104
+ else status.textContent = this.config.actionText || this.config.copy.talkToUs;
1886
2105
  if (this.errorText && this.state !== "live") status.classList.add("tw-error-text");
1887
2106
  body.appendChild(status);
1888
2107
  const timer = document.createElement("div");
@@ -1914,13 +2133,13 @@ var TrilletWidgetElement = class extends HTMLElement {
1914
2133
  const footer2 = document.createElement("div");
1915
2134
  footer2.className = "tw-chat-ended";
1916
2135
  const status = document.createElement("span");
1917
- status.textContent = (_a = this.errorText) != null ? _a : "This chat has ended.";
2136
+ status.textContent = (_a = this.errorText) != null ? _a : this.config.copy.chatEnded;
1918
2137
  if (this.errorText) status.classList.add("tw-error-text");
1919
2138
  footer2.appendChild(status);
1920
2139
  const restart = document.createElement("button");
1921
2140
  restart.type = "button";
1922
2141
  restart.className = "tw-secondary-btn tw-small";
1923
- restart.textContent = "Start a new chat";
2142
+ restart.textContent = this.config.copy.startNewChat;
1924
2143
  restart.addEventListener("click", () => {
1925
2144
  this.transcripts = [];
1926
2145
  void this.beginCall("text");
@@ -1945,7 +2164,7 @@ var TrilletWidgetElement = class extends HTMLElement {
1945
2164
  const endBtn = document.createElement("button");
1946
2165
  endBtn.className = "tw-link-btn tw-end-chat";
1947
2166
  endBtn.type = "button";
1948
- endBtn.textContent = this.config.mode === "text" ? this.config.endCallText : "End conversation";
2167
+ endBtn.textContent = this.config.mode === "text" ? this.config.endCallText : this.config.copy.endConversationText;
1949
2168
  endBtn.disabled = this.state === "connecting";
1950
2169
  endBtn.addEventListener("click", () => this.endConversation());
1951
2170
  footer.appendChild(endBtn);
@@ -1978,7 +2197,7 @@ var TrilletWidgetElement = class extends HTMLElement {
1978
2197
  const isText = this.resolvedMode() === "text";
1979
2198
  startBtn.innerHTML = isText ? ICONS.chat : ICONS.phone;
1980
2199
  const span = document.createElement("span");
1981
- span.textContent = isText ? "Start chat" : this.config.startCallText;
2200
+ span.textContent = isText ? this.config.copy.startChatText : this.config.startCallText;
1982
2201
  startBtn.appendChild(span);
1983
2202
  startBtn.addEventListener("click", () => {
1984
2203
  void this.beginCall();
@@ -1989,7 +2208,7 @@ var TrilletWidgetElement = class extends HTMLElement {
1989
2208
  if (this.resolvedMode() === "voice") {
1990
2209
  const micBtn = this.iconButton(
1991
2210
  this.micEnabled ? ICONS.mic : ICONS.micOff,
1992
- this.micEnabled ? "Mute microphone" : "Unmute microphone",
2211
+ this.micEnabled ? this.config.copy.muteMic : this.config.copy.unmuteMic,
1993
2212
  () => {
1994
2213
  var _a;
1995
2214
  this.micEnabled = !this.micEnabled;
@@ -2022,7 +2241,7 @@ var TrilletWidgetElement = class extends HTMLElement {
2022
2241
  text.className = "tw-callbar-text";
2023
2242
  const activity = document.createElement("div");
2024
2243
  activity.className = "tw-callbar-activity";
2025
- activity.textContent = connecting ? "Connecting\u2026" : this.speaking ? this.config.speakingText : this.config.listeningText;
2244
+ activity.textContent = connecting ? this.config.copy.connecting : this.speaking ? this.config.speakingText : this.config.listeningText;
2026
2245
  const meta = document.createElement("div");
2027
2246
  meta.className = "tw-callbar-meta tw-timer";
2028
2247
  const name = this.speakerName();
@@ -2032,7 +2251,7 @@ var TrilletWidgetElement = class extends HTMLElement {
2032
2251
  bar.appendChild(text);
2033
2252
  const mute = this.iconButton(
2034
2253
  this.micEnabled ? ICONS.mic : ICONS.micOff,
2035
- this.micEnabled ? "Mute microphone" : "Unmute microphone",
2254
+ this.micEnabled ? this.config.copy.muteMic : this.config.copy.unmuteMic,
2036
2255
  () => {
2037
2256
  var _a;
2038
2257
  this.micEnabled = !this.micEnabled;
@@ -2044,12 +2263,12 @@ var TrilletWidgetElement = class extends HTMLElement {
2044
2263
  mute.disabled = connecting;
2045
2264
  bar.appendChild(mute);
2046
2265
  if (inPanel) {
2047
- const back = this.iconButton(ICONS.keyboard, "Type instead", () => void this.switchModality(), "tw-sq tw-sq-quiet");
2266
+ const back = this.iconButton(ICONS.keyboard, this.config.copy.typeInstead, () => void this.switchModality(), "tw-sq tw-sq-quiet");
2048
2267
  back.disabled = this.switchingSide || connecting;
2049
2268
  bar.appendChild(back);
2050
2269
  } else if (this.config.mode === "both") {
2051
2270
  bar.appendChild(
2052
- this.iconButton(ICONS.chat, "Show the conversation", () => {
2271
+ this.iconButton(ICONS.chat, this.config.copy.showConversation, () => {
2053
2272
  this.open = true;
2054
2273
  this.render();
2055
2274
  }, "tw-sq tw-sq-quiet")
@@ -2071,7 +2290,7 @@ var TrilletWidgetElement = class extends HTMLElement {
2071
2290
  const sendBtn = document.createElement("button");
2072
2291
  sendBtn.className = "tw-send-btn";
2073
2292
  sendBtn.type = "submit";
2074
- sendBtn.setAttribute("aria-label", "Send");
2293
+ sendBtn.setAttribute("aria-label", this.config.copy.send);
2075
2294
  sendBtn.innerHTML = ICONS.send;
2076
2295
  const syncState = () => {
2077
2296
  sendBtn.disabled = this.state !== "live" || !input.value.trim();
@@ -2103,7 +2322,7 @@ var TrilletWidgetElement = class extends HTMLElement {
2103
2322
  });
2104
2323
  row.appendChild(input);
2105
2324
  if (this.config.mode === "both") {
2106
- const mic = this.iconButton(ICONS.phone, "Talk instead", () => void this.switchModality(), "tw-composer-mic");
2325
+ const mic = this.iconButton(ICONS.phone, this.config.copy.talkInstead, () => void this.switchModality(), "tw-composer-mic");
2107
2326
  mic.disabled = this.state !== "live" || this.switchingSide;
2108
2327
  row.appendChild(mic);
2109
2328
  }
@@ -2163,7 +2382,7 @@ var TrilletWidgetElement = class extends HTMLElement {
2163
2382
  } else if (this.isAwaitingReply()) {
2164
2383
  const typing = document.createElement("div");
2165
2384
  typing.className = "tw-msg tw-assistant tw-typing";
2166
- typing.setAttribute("aria-label", "Typing");
2385
+ typing.setAttribute("aria-label", this.config.copy.typing);
2167
2386
  typing.innerHTML = "<span></span><span></span><span></span>";
2168
2387
  wrap.appendChild(typing);
2169
2388
  }
@@ -2204,13 +2423,13 @@ var TrilletWidgetElement = class extends HTMLElement {
2204
2423
  return wrap;
2205
2424
  }
2206
2425
  };
2207
- function friendlyError(err) {
2426
+ function friendlyError(err, copy) {
2208
2427
  const msg = err.message || "";
2209
- if (/Origin not allowed/i.test(msg)) return "Chat is not enabled on this website.";
2210
- if (/Public access/i.test(msg)) return "Chat is not available right now.";
2211
- if (/Too many/i.test(msg)) return "Too many chats right now. Please try again shortly.";
2212
- if (/Insufficient funds/i.test(msg)) return "Chat is not available right now.";
2213
- return "Could not connect. Please try again.";
2428
+ if (/Origin not allowed/i.test(msg)) return copy.errorNotEnabled;
2429
+ if (/Public access/i.test(msg)) return copy.errorUnavailable;
2430
+ if (/Too many/i.test(msg)) return copy.errorTooMany;
2431
+ if (/Insufficient funds/i.test(msg)) return copy.errorUnavailable;
2432
+ return copy.errorGeneric;
2214
2433
  }
2215
2434
  var DEFAULT_ACCENT = "#0062e9";
2216
2435
  function readableOn(hex) {
@@ -2294,6 +2513,8 @@ var TrilletWidget = (props) => {
2294
2513
  setAttr(el, "action-text", props.actionText);
2295
2514
  setAttr(el, "start-call-text", props.startCallText);
2296
2515
  setAttr(el, "end-call-text", props.endCallText);
2516
+ setAttr(el, "end-chat-text", props.endChatText);
2517
+ setAttr(el, "language", props.language);
2297
2518
  setAttr(el, "message-text", props.messageText);
2298
2519
  setAttr(el, "switch-to-text-text", props.switchToTextText);
2299
2520
  setAttr(el, "switch-to-voice-text", props.switchToVoiceText);