@opencx/widget-core 5.2.0 → 5.3.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.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { z as h } from "zod";
2
- import te from "openapi-fetch";
3
- import se from "lodash.isequal";
2
+ import se from "openapi-fetch";
3
+ import oe from "lodash.isequal";
4
4
  import { v4 as N } from "uuid";
5
- const Wa = (i) => i.type === "data-keepalive", $a = (i) => i.type === "data-turn-steered", L = h.object({ const: h.string(), title: h.string().optional() }), oe = h.object({
5
+ const Wa = (i) => i.type === "data-keepalive", $a = (i) => i.type === "data-turn-steered", L = h.object({ const: h.string(), title: h.string().optional() }), ne = h.object({
6
6
  type: h.enum(["string", "number", "integer", "boolean", "array"]),
7
7
  title: h.string().optional(),
8
8
  description: h.string().optional(),
@@ -20,7 +20,7 @@ const Wa = (i) => i.type === "data-keepalive", $a = (i) => i.type === "data-turn
20
20
  minLength: h.number().optional(),
21
21
  maxLength: h.number().optional(),
22
22
  format: h.string().optional()
23
- }), ne = h.array(
23
+ }), ie = h.array(
24
24
  h.object({
25
25
  id: h.string(),
26
26
  serverId: h.string(),
@@ -30,12 +30,12 @@ const Wa = (i) => i.type === "data-keepalive", $a = (i) => i.type === "data-turn
30
30
  form: h.object({
31
31
  message: h.string(),
32
32
  requestedSchema: h.object({
33
- properties: h.record(h.string(), oe),
33
+ properties: h.record(h.string(), ne),
34
34
  required: h.array(h.string()).optional()
35
35
  })
36
36
  })
37
37
  })
38
- ), ie = h.array(
38
+ ), re = h.array(
39
39
  h.object({
40
40
  key: h.string(),
41
41
  serverId: h.string(),
@@ -50,73 +50,73 @@ const Wa = (i) => i.type === "data-keepalive", $a = (i) => i.type === "data-turn
50
50
  error: (i, ...e) => {
51
51
  console.error(`${O} ${i}`, ...e);
52
52
  }
53
- }, re = (i) => {
54
- k.error("request failed", i.error);
55
53
  }, _e = (i) => {
56
- const e = te({
54
+ k.error("request failed", i.error);
55
+ }, le = (i) => {
56
+ const e = se({
57
57
  baseUrl: i.baseUrl
58
- }), t = {
58
+ }), a = {
59
59
  onRequest: i.onRequest,
60
60
  onResponse: i.onResponse,
61
- onError: i.onError || re
61
+ onError: i.onError || _e
62
62
  };
63
- return e.use(t), e;
63
+ return e.use(a), e;
64
64
  };
65
- class le extends Error {
65
+ class ce extends Error {
66
66
  constructor() {
67
67
  super("This connection request expired. Preparing a new request."), this.name = "ConnectionRequestExpiredError";
68
68
  }
69
69
  }
70
- class ce extends Error {
70
+ class pe extends Error {
71
71
  constructor() {
72
72
  super("This connection attempt is no longer available."), this.name = "ConnectionAttemptUnavailableError";
73
73
  }
74
74
  }
75
- const pe = "/backend/widget/v5/chat/stream", de = "/backend/widget/v5/chat/{sessionId}/stream", F = (i, e, t) => `${i.replace(/\/$/, "")}${t ? e.replace("{sessionId}", encodeURIComponent(t)) : e}`;
75
+ const de = "/backend/widget/v5/chat/stream", ue = "/backend/widget/v5/chat/{sessionId}/stream", F = (i, e, a) => `${i.replace(/\/$/, "")}${a ? e.replace("{sessionId}", encodeURIComponent(a)) : e}`;
76
76
  class U {
77
77
  constructor({ config: e }) {
78
78
  var r, c;
79
79
  this.userToken = null, this.constructClientOptions = (s) => {
80
- const a = this.config.apiUrl || "https://api.open.cx", n = {
80
+ const t = this.config.apiUrl || "https://api.open.cx", n = {
81
81
  "X-Bot-Token": this.config.token,
82
82
  "Content-Type": "application/json",
83
83
  Accept: "application/json",
84
84
  Authorization: s ? `Bearer ${s}` : void 0
85
85
  };
86
- return { baseUrl: a, headers: n };
86
+ return { baseUrl: t, headers: n };
87
87
  }, this.createOpenAPIClient = ({
88
88
  baseUrl: s,
89
- headers: a
90
- }) => _e({
89
+ headers: t
90
+ }) => le({
91
91
  baseUrl: s,
92
92
  onRequest: ({ request: n }) => {
93
- Object.entries(a).forEach(([l, d]) => {
93
+ Object.entries(t).forEach(([l, d]) => {
94
94
  d && n.headers.set(l, d);
95
95
  });
96
96
  }
97
97
  }), this.listApprovalPreferences = async () => {
98
- const { baseUrl: s, headers: a } = this.getStreamAuthContext(), n = await fetch(
98
+ const { baseUrl: s, headers: t } = this.getStreamAuthContext(), n = await fetch(
99
99
  `${s}/backend/widget/v5/connections/approval-preferences`,
100
- { headers: a }
100
+ { headers: t }
101
101
  );
102
102
  if (!n.ok) throw new Error("Could not load permissions.");
103
- return ie.parse(await n.json());
104
- }, this.revokeApprovalPreference = async (s, a) => {
103
+ return re.parse(await n.json());
104
+ }, this.revokeApprovalPreference = async (s, t) => {
105
105
  const { baseUrl: n, headers: l } = this.getStreamAuthContext();
106
106
  if (!(await fetch(
107
- `${n}/backend/widget/v5/connections/${encodeURIComponent(s)}/approval-preferences/${encodeURIComponent(a)}`,
107
+ `${n}/backend/widget/v5/connections/${encodeURIComponent(s)}/approval-preferences/${encodeURIComponent(t)}`,
108
108
  { method: "DELETE", headers: l }
109
109
  )).ok) throw new Error("Could not reset permission.");
110
- }, this.listElicitations = async (s, a) => {
110
+ }, this.listElicitations = async (s, t) => {
111
111
  const { baseUrl: n, headers: l } = this.getStreamAuthContext(), d = await fetch(
112
112
  `${n}/backend/widget/v5/connections/elicitation/${encodeURIComponent(s)}`,
113
- { headers: l, signal: a }
113
+ { headers: l, signal: t }
114
114
  );
115
115
  if (!d.ok) throw new Error("Could not load the request.");
116
- return ne.parse(await d.json());
117
- }, this.answerElicitation = async (s, a, n) => {
116
+ return ie.parse(await d.json());
117
+ }, this.answerElicitation = async (s, t, n) => {
118
118
  const { baseUrl: l, headers: d } = this.getStreamAuthContext(), _ = await fetch(
119
- `${l}/backend/widget/v5/connections/elicitation/${encodeURIComponent(s)}/${encodeURIComponent(a)}`,
119
+ `${l}/backend/widget/v5/connections/elicitation/${encodeURIComponent(s)}/${encodeURIComponent(t)}`,
120
120
  {
121
121
  method: "POST",
122
122
  headers: { ...d, "Content-Type": "application/json" },
@@ -128,89 +128,89 @@ class U {
128
128
  _.status === 400 ? "Check your answers and try again." : "This request has ended. Ask the agent to try again."
129
129
  );
130
130
  }, this.listConnections = async (s) => {
131
- const { data: a, error: n } = await this.client.GET(
131
+ const { data: t, error: n } = await this.client.GET(
132
132
  "/backend/widget/v5/connections",
133
133
  { signal: s }
134
134
  );
135
- if (n || !a)
135
+ if (n || !t)
136
136
  throw new Error("Could not load connections. Sign in and try again.");
137
- return a;
138
- }, this.startConnection = async (s, a, n) => {
137
+ return t;
138
+ }, this.startConnection = async (s, t, n) => {
139
139
  const { data: l, error: d, response: _ } = await this.client.POST(
140
140
  "/backend/widget/v5/connections/{serverId}/start",
141
141
  {
142
142
  params: { path: { serverId: s } },
143
- body: { request_id: a },
143
+ body: { request_id: t },
144
144
  signal: n
145
145
  }
146
146
  );
147
- if (_.status === 410) throw new le();
147
+ if (_.status === 410) throw new ce();
148
148
  if (_.status === 404)
149
149
  throw new Error("This connection request is no longer available.");
150
150
  if (d || !l)
151
151
  throw new Error("Could not start this connection. Please try again.");
152
152
  return l;
153
- }, this.getConnectionAttempt = async (s, a, n) => {
153
+ }, this.getConnectionAttempt = async (s, t, n) => {
154
154
  const { data: l, error: d, response: _ } = await this.client.GET(
155
155
  "/backend/widget/v5/connections/{serverId}/attempts/{attemptId}",
156
156
  {
157
- params: { path: { serverId: s, attemptId: a } },
157
+ params: { path: { serverId: s, attemptId: t } },
158
158
  signal: n
159
159
  }
160
160
  );
161
161
  if ([401, 403, 404].includes(_.status))
162
- throw new ce();
162
+ throw new pe();
163
163
  if (d || !l)
164
164
  throw new Error(`Could not check the connection (${_.status}).`);
165
165
  return l.status;
166
166
  }, this.disconnectConnection = async (s) => {
167
- const { error: a } = await this.client.DELETE(
167
+ const { error: t } = await this.client.DELETE(
168
168
  "/backend/widget/v5/connections/{serverId}",
169
169
  {
170
170
  params: { path: { serverId: s } }
171
171
  }
172
172
  );
173
- if (a) throw new Error("Could not disconnect. Please try again.");
173
+ if (t) throw new Error("Could not disconnect. Please try again.");
174
174
  }, this.setAuthToken = (s) => {
175
175
  this.userToken = s;
176
- const { baseUrl: a, headers: n } = this.constructClientOptions(s);
177
- this.client = this.createOpenAPIClient({ baseUrl: a, headers: n });
176
+ const { baseUrl: t, headers: n } = this.constructClientOptions(s);
177
+ this.client = this.createOpenAPIClient({ baseUrl: t, headers: n });
178
178
  }, this.getStreamAuthContext = () => {
179
- const { baseUrl: s, headers: a } = this.constructClientOptions(this.userToken), n = {};
180
- for (const [l, d] of Object.entries(a))
179
+ const { baseUrl: s, headers: t } = this.constructClientOptions(this.userToken), n = {};
180
+ for (const [l, d] of Object.entries(t))
181
181
  typeof d == "string" && (["content-type", "accept"].includes(l.toLowerCase()) || (n[l] = d));
182
182
  return { baseUrl: s, headers: n };
183
183
  }, this.getStreamTransportOptions = () => {
184
- const { baseUrl: s, headers: a } = this.getStreamAuthContext();
184
+ const { baseUrl: s, headers: t } = this.getStreamAuthContext();
185
185
  return {
186
- api: F(s, pe),
187
- reconnectApi: (n) => F(s, de, n),
188
- headers: a
186
+ api: F(s, de),
187
+ reconnectApi: (n) => F(s, ue, n),
188
+ headers: t
189
189
  };
190
190
  }, this.stopStream = async (s) => {
191
- const { response: a } = await this.client.POST(
191
+ const { response: t } = await this.client.POST(
192
192
  "/backend/widget/v5/chat/{sessionId}/stop",
193
193
  { params: { path: { sessionId: s } } }
194
194
  );
195
- if (!a.ok)
196
- throw new Error(`Failed to stop stream: ${a.status}`);
197
- }, this.sendPageReply = async (s, a) => {
195
+ if (!t.ok)
196
+ throw new Error(`Failed to stop stream: ${t.status}`);
197
+ }, this.sendPageReply = async (s, t) => {
198
198
  try {
199
199
  await this.client.POST("/backend/widget/v5/chat/{sessionId}/page-reply", {
200
200
  params: { path: { sessionId: s } },
201
- body: a
201
+ body: t
202
202
  });
203
203
  } catch {
204
204
  }
205
- }, this.getAgentTurnMessages = async (s, a) => {
205
+ }, this.getAgentTurnMessages = async (s, t) => {
206
206
  const { data: n, response: l } = await this.client.GET(
207
207
  "/backend/widget/v5/chat/{sessionId}/messages",
208
208
  {
209
209
  params: {
210
210
  path: { sessionId: s },
211
211
  query: {
212
- toolActivity: a == null ? void 0 : a.toolActivity,
213
- reasoning: (a == null ? void 0 : a.reasoning) === void 0 ? void 0 : a.reasoning ? "true" : "false"
212
+ toolActivity: t == null ? void 0 : t.toolActivity,
213
+ reasoning: (t == null ? void 0 : t.reasoning) === void 0 ? void 0 : t.reasoning ? "true" : "false"
214
214
  }
215
215
  }
216
216
  }
@@ -222,59 +222,59 @@ class U {
222
222
  }, this.createDictationSession = async ({
223
223
  language: s
224
224
  }) => {
225
- const { data: a, response: n } = await this.client.POST(
225
+ const { data: t, response: n } = await this.client.POST(
226
226
  "/backend/widget/v5/dictation/sessions",
227
227
  { body: s ? { language: s } : {} }
228
228
  );
229
- if (!a)
229
+ if (!t)
230
230
  throw new Error(`Failed to start dictation: ${n.status}`);
231
- return a;
231
+ return t;
232
232
  }, this.getExternalWidgetConfig = async () => await this.client.GET("/backend/widget/v2/config", {
233
233
  params: {
234
234
  header: { "x-bot-token": this.config.token }
235
235
  }
236
- }), this.sendMessage = async (s, a) => await this.client.POST("/backend/widget/v2/chat/send", {
236
+ }), this.sendMessage = async (s, t) => await this.client.POST("/backend/widget/v2/chat/send", {
237
237
  body: s,
238
- signal: a
238
+ signal: t
239
239
  }), this.createUnverifiedContact = async (s) => await this.client.POST(
240
240
  "/backend/widget/v2/contact/create-unverified",
241
241
  {
242
242
  params: { header: { "x-bot-token": this.config.token } },
243
243
  body: s
244
244
  }
245
- ), this.createSession = async (s, a) => await this.client.POST("/backend/widget/v2/create-session", {
245
+ ), this.createSession = async (s, t) => await this.client.POST("/backend/widget/v2/create-session", {
246
246
  body: s,
247
- signal: a
247
+ signal: t
248
248
  }), this.pollSessionAndHistory = async ({
249
249
  sessionId: s,
250
- abortSignal: a
250
+ abortSignal: t
251
251
  }) => await this.client.GET("/backend/widget/v2/poll/{sessionId}", {
252
252
  params: { path: { sessionId: s } },
253
- signal: a
253
+ signal: t
254
254
  }), this.getSessions = async ({
255
255
  cursor: s,
256
- filters: a,
256
+ filters: t,
257
257
  abortSignal: n
258
258
  }) => await this.client.GET("/backend/widget/v2/sessions", {
259
259
  params: {
260
260
  query: {
261
261
  offset: s,
262
- filters: JSON.stringify(a)
262
+ filters: JSON.stringify(t)
263
263
  }
264
264
  },
265
265
  signal: n
266
266
  }), this.uploadFile = async ({
267
267
  file: s,
268
- abortSignal: a,
268
+ abortSignal: t,
269
269
  onProgress: n
270
270
  }) => new Promise((l, d) => {
271
271
  var f;
272
272
  const _ = new FormData();
273
273
  _.append("file", s);
274
274
  const p = new XMLHttpRequest();
275
- if (a && (a.addEventListener("abort", () => {
275
+ if (t && (t.addEventListener("abort", () => {
276
276
  p.abort(), d(new DOMException("Aborted", "AbortError"));
277
- }), a.aborted)) {
277
+ }), t.aborted)) {
278
278
  d(new DOMException("Aborted", "AbortError"));
279
279
  return;
280
280
  }
@@ -300,45 +300,45 @@ class U {
300
300
  });
301
301
  const { baseUrl: u } = this.constructClientOptions(this.userToken), g = `${u}/backend/widget/v2/upload`;
302
302
  p.open("POST", g), p.setRequestHeader("X-Bot-Token", this.config.token), this.userToken ?? ((f = this.config.user) == null ? void 0 : f.token) ? p.setRequestHeader("Authorization", `Bearer ${this.userToken}`) : k.error("user token not set"), p.send(_);
303
- }), this.vote = async (s) => await this.client.POST("/backend/widget/v2/chat/vote", { body: s }), this.resolveSession = async (s, a) => await this.client.POST("/backend/widget/v2/session/resolve", {
303
+ }), this.vote = async (s) => await this.client.POST("/backend/widget/v2/chat/vote", { body: s }), this.resolveSession = async (s, t) => await this.client.POST("/backend/widget/v2/session/resolve", {
304
304
  body: s,
305
- signal: a
305
+ signal: t
306
306
  }), this.createStateCheckpoint = async (s) => await this.client.POST("/backend/widget/v2/checkpoint", {
307
307
  body: s
308
308
  }), this.submitCsat = async (s) => await this.client.POST("/backend/widget/v2/submit-csat", { body: s }), this.config = e, this.userToken = ((r = e.user) == null ? void 0 : r.token) || null;
309
- const { baseUrl: t, headers: o } = this.constructClientOptions(
309
+ const { baseUrl: a, headers: o } = this.constructClientOptions(
310
310
  (c = e.user) == null ? void 0 : c.token
311
311
  );
312
- this.client = this.createOpenAPIClient({ baseUrl: t, headers: o });
312
+ this.client = this.createOpenAPIClient({ baseUrl: a, headers: o });
313
313
  }
314
314
  }
315
- function ue(i, e) {
315
+ function me(i, e) {
316
316
  k.error(`missing case for ${i} in ${e}`);
317
317
  }
318
318
  class S {
319
319
  constructor(e) {
320
- this.subscribers = /* @__PURE__ */ new Set(), this.get = () => this.state, this.set = (t) => {
321
- se(this.state, t) || (this.state = t, this.notifySubscribers(t));
322
- }, this.setPartial = (t) => {
323
- if (t == null) return;
324
- const o = { ...this.state, ...t };
320
+ this.subscribers = /* @__PURE__ */ new Set(), this.get = () => this.state, this.set = (a) => {
321
+ oe(this.state, a) || (this.state = a, this.notifySubscribers(a));
322
+ }, this.setPartial = (a) => {
323
+ if (a == null) return;
324
+ const o = { ...this.state, ...a };
325
325
  this.set(o);
326
326
  }, this.reset = () => {
327
327
  this.set(this.initialState);
328
- }, this.notifySubscribers = (t) => {
328
+ }, this.notifySubscribers = (a) => {
329
329
  Array.from(this.subscribers).forEach((r) => {
330
330
  try {
331
- r(t);
331
+ r(a);
332
332
  } catch (c) {
333
333
  k.error("state subscriber threw", c);
334
334
  }
335
335
  });
336
- }, this.subscribe = (t) => (this.subscribers.add(t), () => {
337
- this.subscribers.delete(t);
336
+ }, this.subscribe = (a) => (this.subscribers.add(a), () => {
337
+ this.subscribers.delete(a);
338
338
  }), this.state = e, this.initialState = e;
339
339
  }
340
340
  }
341
- class Z {
341
+ class W {
342
342
  constructor() {
343
343
  this.state = new S({
344
344
  isPolling: !1,
@@ -346,7 +346,7 @@ class Z {
346
346
  }), this.abortController = new AbortController(), this.reset = () => {
347
347
  var e;
348
348
  this.abortController.abort("Resetting poller"), (e = this.stopPolling) == null || e.call(this), this.stopPolling = null;
349
- }, this.stopPolling = null, this.startPolling = (e, t) => {
349
+ }, this.stopPolling = null, this.startPolling = (e, a) => {
350
350
  if (this.stopPolling) return;
351
351
  const o = [], r = async () => {
352
352
  this.abortController = new AbortController(), this.state.setPartial({ isPolling: !0 });
@@ -359,7 +359,7 @@ class Z {
359
359
  } finally {
360
360
  this.state.setPartial({ isPolling: !1 });
361
361
  }
362
- this.abortController.signal.aborted || o.push(setTimeout(r, t));
362
+ this.abortController.signal.aborted || o.push(setTimeout(r, a));
363
363
  };
364
364
  r(), this.stopPolling = () => {
365
365
  o.forEach(clearTimeout), this.state.reset();
@@ -367,29 +367,29 @@ class Z {
367
367
  };
368
368
  }
369
369
  }
370
- function W(i) {
370
+ function $(i) {
371
371
  try {
372
372
  const e = i();
373
- return e instanceof Promise ? e.then((t) => ({ data: t })).catch((t) => ({ error: t })) : { data: e };
373
+ return e instanceof Promise ? e.then((a) => ({ data: a })).catch((a) => ({ error: a })) : { data: e };
374
374
  } catch (e) {
375
375
  return { error: e };
376
376
  }
377
377
  }
378
- class me {
378
+ class he {
379
379
  constructor({
380
380
  api: e,
381
- config: t,
381
+ config: a,
382
382
  sessionCtx: o,
383
383
  messageCtx: r,
384
384
  sessionPollingIntervalSeconds: c
385
385
  }) {
386
- this.poller = new Z(), this.fetchSessionAndFullHistoryAbortController = new AbortController(), this.reconcileAbortController = new AbortController(), this.subscriptions = [], this.reconcilingSessionId = null, this.registerPolling = () => {
386
+ this.poller = new W(), this.fetchSessionAndFullHistoryAbortController = new AbortController(), this.reconcileAbortController = new AbortController(), this.subscriptions = [], this.reconcilingSessionId = null, this.registerPolling = () => {
387
387
  this.subscriptions.push(
388
388
  this.sessionCtx.sessionState.subscribe(({ session: s }) => {
389
- s != null && s.id ? this.poller.startPolling(async (a) => {
389
+ s != null && s.id ? this.poller.startPolling(async (t) => {
390
390
  this.fetchSessionAndHistory({
391
391
  sessionId: s.id,
392
- abortSignal: a
392
+ abortSignal: t
393
393
  });
394
394
  }, this.sessionPollingIntervalSeconds * 1e3) : this.poller.reset();
395
395
  })
@@ -401,8 +401,8 @@ class me {
401
401
  sessionId: s.id,
402
402
  abortSignal: this.fetchSessionAndFullHistoryAbortController.signal
403
403
  });
404
- } catch (a) {
405
- this.fetchSessionAndFullHistoryAbortController.signal.aborted || k.error("failed to fetch session and full history", a);
404
+ } catch (t) {
405
+ this.fetchSessionAndFullHistoryAbortController.signal.aborted || k.error("failed to fetch session and full history", t);
406
406
  }
407
407
  else
408
408
  this.fetchSessionAndFullHistoryAbortController.abort();
@@ -416,24 +416,24 @@ class me {
416
416
  this.poller.reset(), this.fetchSessionAndFullHistoryAbortController.abort(), this.reconcileAbortController.abort(), this.reconcilingSessionId = null, this.subscriptions.forEach((s) => s()), this.subscriptions = [];
417
417
  }, this.reconcileAfterStream = async (s) => {
418
418
  this.reconcileAbortController.abort(), this.reconcileAbortController = new AbortController();
419
- const { signal: a } = this.reconcileAbortController;
419
+ const { signal: t } = this.reconcileAbortController;
420
420
  this.reconcilingSessionId = s;
421
421
  try {
422
- await this.fetchSessionAndHistory({ sessionId: s, abortSignal: a });
422
+ await this.fetchSessionAndHistory({ sessionId: s, abortSignal: t });
423
423
  } catch (n) {
424
- if (!a.aborted) throw n;
424
+ if (!t.aborted) throw n;
425
425
  } finally {
426
426
  this.reconcilingSessionId === s && (this.reconcilingSessionId = null);
427
427
  }
428
428
  }, this.fetchSessionAndHistory = async ({
429
429
  sessionId: s,
430
- abortSignal: a
430
+ abortSignal: t
431
431
  }) => {
432
432
  const n = this.messageCtx.state.get().messages.length === 0;
433
433
  n && this.messageCtx.state.setPartial({ isInitialFetchLoading: !0 });
434
434
  const { data: l } = await this.api.pollSessionAndHistory({
435
435
  sessionId: s,
436
- abortSignal: a
436
+ abortSignal: t
437
437
  });
438
438
  if (l != null && l.session && (this.sessionCtx.sessionState.setPartial({ session: l.session }), this.sessionCtx.setSessions([l.session])), l != null && l.history && l.history.length > 0) {
439
439
  this.reconcileOptionPicks(l.history);
@@ -453,30 +453,30 @@ class me {
453
453
  }
454
454
  this.messageCtx.state.get().isInitialFetchLoading && this.messageCtx.state.setPartial({ isInitialFetchLoading: !1 });
455
455
  }, this.reconcileOptionPicks = (s) => {
456
- var a;
456
+ var t;
457
457
  for (const n of s) {
458
- const l = (a = n.messageOptions) == null ? void 0 : a.pickedOptionId;
458
+ const l = (t = n.messageOptions) == null ? void 0 : t.pickedOptionId;
459
459
  l && this.messageCtx.setMessageOptionPick(n.publicId, l);
460
460
  }
461
461
  }, this.mapHistoryToMessage = (s) => {
462
462
  var n;
463
- const a = {
463
+ const t = {
464
464
  id: s.publicId,
465
465
  timestamp: s.sentAt || "",
466
466
  attachments: s.attachments || void 0
467
467
  };
468
468
  if (s.sender.kind === "user")
469
469
  return {
470
- ...a,
470
+ ...t,
471
471
  type: "USER",
472
- deliveredAt: a.timestamp,
472
+ deliveredAt: t.timestamp,
473
473
  content: s.content.text || "",
474
474
  // Backend field name (schema.ts) → widget vocabulary.
475
475
  markedElements: s.pickedElements
476
476
  };
477
477
  if (s.sender.kind === "agent")
478
478
  return {
479
- ...a,
479
+ ...t,
480
480
  type: "AGENT",
481
481
  component: "agent_message",
482
482
  data: {
@@ -497,7 +497,7 @@ class me {
497
497
  if (s.sender.kind === "ai") {
498
498
  const l = s.actionCalls && s.actionCalls.length > 0 ? s.actionCalls[s.actionCalls.length - 1] : void 0;
499
499
  return {
500
- ...a,
500
+ ...t,
501
501
  type: "AI",
502
502
  component: "bot_message",
503
503
  agent: {
@@ -525,10 +525,10 @@ class me {
525
525
  return null;
526
526
  }, this.constructReplyTo = (s) => {
527
527
  if (!s.replyTo) return {};
528
- const { publicId: a, text: n, sender: l } = s.replyTo;
528
+ const { publicId: t, text: n, sender: l } = s.replyTo;
529
529
  return {
530
530
  replyTo: {
531
- id: a,
531
+ id: t,
532
532
  text: n,
533
533
  sender: l
534
534
  }
@@ -571,26 +571,26 @@ class me {
571
571
  case "none":
572
572
  return null;
573
573
  default:
574
- return ue(
574
+ return me(
575
575
  s.systemMessagePayload,
576
576
  this.constructSystemMessage.name
577
577
  ), null;
578
578
  }
579
579
  }, this.extractActionResult = (s) => {
580
- const a = s.result;
581
- if (a === null || typeof a != "object") return a;
582
- if ("responseBodyText" in a && typeof a.responseBodyText == "string") {
583
- const n = a.responseBodyText, l = W(() => JSON.parse(n)).data;
580
+ const t = s.result;
581
+ if (t === null || typeof t != "object") return t;
582
+ if ("responseBodyText" in t && typeof t.responseBodyText == "string") {
583
+ const n = t.responseBodyText, l = $(() => JSON.parse(n)).data;
584
584
  if (l) return l;
585
585
  }
586
586
  return s.result;
587
- }, this.api = e, this.config = t, this.sessionCtx = o, this.messageCtx = r, this.sessionPollingIntervalSeconds = c, this.registerPolling();
587
+ }, this.api = e, this.config = a, this.sessionCtx = o, this.messageCtx = r, this.sessionPollingIntervalSeconds = c, this.registerPolling();
588
588
  }
589
589
  }
590
- class he {
590
+ class ge {
591
591
  constructor({
592
592
  config: e,
593
- api: t,
593
+ api: a,
594
594
  storageCtx: o
595
595
  }) {
596
596
  var r;
@@ -598,9 +598,9 @@ class he {
598
598
  var c;
599
599
  return !!(!((c = this.state.get().contact) != null && c.token) && this.config.collectUserData);
600
600
  }, this.autoCreateUnverifiedUserIfNotExists = async () => {
601
- var c, s, a, n, l, d, _, p, u, m, g, b, f, v;
601
+ var c, s, t, n, l, d, _, p, u, m, g, b, f, v;
602
602
  if (!((c = this.config.user) != null && c.token)) {
603
- if (this.config.collectUserData && !((a = (s = this.config.user) == null ? void 0 : s.data) != null && a.email)) {
603
+ if (this.config.collectUserData && !((t = (s = this.config.user) == null ? void 0 : s.data) != null && t.email)) {
604
604
  if ((n = this.config.extraDataCollectionFields) != null && n.length)
605
605
  return;
606
606
  const y = await ((l = this.storageCtx) == null ? void 0 : l.getContactToken());
@@ -627,21 +627,21 @@ class he {
627
627
  isCreatingUnverifiedContact: !0,
628
628
  isErrorCreatingUnverifiedContact: !1
629
629
  });
630
- const { data: a } = await this.api.createUnverifiedContact(c);
631
- a != null && a.token ? await this.setUnverifiedContact(a.token) : this.state.setPartial({ isErrorCreatingUnverifiedContact: !0 });
632
- } catch (a) {
630
+ const { data: t } = await this.api.createUnverifiedContact(c);
631
+ t != null && t.token ? await this.setUnverifiedContact(t.token) : this.state.setPartial({ isErrorCreatingUnverifiedContact: !0 });
632
+ } catch (t) {
633
633
  this.state.setPartial({ isErrorCreatingUnverifiedContact: !0 }), k.error("failed to create an unverified contact", {
634
- _e: a instanceof Error ? a.message : String(a)
634
+ _e: t instanceof Error ? t.message : String(t)
635
635
  });
636
636
  } finally {
637
637
  this.state.setPartial({ isCreatingUnverifiedContact: !1 });
638
638
  }
639
639
  }, this.recoverFromStaleToken = async () => {
640
- var c, s, a, n, l, d, _, p, u, m;
640
+ var c, s, t, n, l, d, _, p, u, m;
641
641
  if ((c = this.config.user) != null && c.token) return !1;
642
642
  this.api.setAuthToken(""), this.state.setPartial({ contact: null });
643
643
  try {
644
- await ((s = this.storageCtx) == null ? void 0 : s.clearContactToken()), await ((a = this.storageCtx) == null ? void 0 : a.clearActiveSessionId());
644
+ await ((s = this.storageCtx) == null ? void 0 : s.clearContactToken()), await ((t = this.storageCtx) == null ? void 0 : t.clearActiveSessionId());
645
645
  } catch (g) {
646
646
  k.warn("failed to clear a stale contact token", {
647
647
  error: g instanceof Error ? g.message : String(g)
@@ -654,9 +654,9 @@ class he {
654
654
  }), !!((m = this.state.get().contact) != null && m.token);
655
655
  }, this.setUnverifiedContact = async (c) => {
656
656
  var n, l, d, _;
657
- const s = await ((n = this.storageCtx) == null ? void 0 : n.getExternalContactId()), a = ((l = this.config.user) == null ? void 0 : l.externalId) || s || N();
658
- this.api.setAuthToken(c), await ((d = this.storageCtx) == null ? void 0 : d.setContactToken(c)), await ((_ = this.storageCtx) == null ? void 0 : _.setExternalContactId(a)), this.state.setPartial({ contact: { token: c, externalId: a } });
659
- }, this.config = e, this.storageCtx = o, this.api = t, this.state = new S({
657
+ const s = await ((n = this.storageCtx) == null ? void 0 : n.getExternalContactId()), t = ((l = this.config.user) == null ? void 0 : l.externalId) || s || N();
658
+ this.api.setAuthToken(c), await ((d = this.storageCtx) == null ? void 0 : d.setContactToken(c)), await ((_ = this.storageCtx) == null ? void 0 : _.setExternalContactId(t)), this.state.setPartial({ contact: { token: c, externalId: t } });
659
+ }, this.config = e, this.storageCtx = o, this.api = a, this.state = new S({
660
660
  contact: (r = e.user) != null && r.token ? {
661
661
  token: e.user.token,
662
662
  // Set optional externalId from config... not local storage
@@ -668,10 +668,10 @@ class he {
668
668
  }), this.autoCreateUnverifiedUserIfNotExists();
669
669
  }
670
670
  }
671
- class ge {
671
+ class ke {
672
672
  constructor(e) {
673
- this.api = e, this.state = new S([]), this.controllers = /* @__PURE__ */ new Map(), this.appendFiles = (t) => {
674
- const o = t.map(
673
+ this.api = e, this.state = new S([]), this.controllers = /* @__PURE__ */ new Map(), this.appendFiles = (a) => {
674
+ const o = a.map(
675
675
  (r) => ({
676
676
  file: r,
677
677
  id: N(),
@@ -680,25 +680,25 @@ class ge {
680
680
  })
681
681
  );
682
682
  this.state.set([...this.state.get(), ...o]), o.forEach((r) => void this.upload(r));
683
- }, this.cancel = (t) => {
683
+ }, this.cancel = (a) => {
684
684
  var o;
685
- (o = this.controllers.get(t)) == null || o.abort(), this.controllers.delete(t), this.state.set(this.state.get().filter((r) => r.id !== t));
685
+ (o = this.controllers.get(a)) == null || o.abort(), this.controllers.delete(a), this.state.set(this.state.get().filter((r) => r.id !== a));
686
686
  }, this.reset = () => {
687
- this.controllers.forEach((t) => t.abort()), this.controllers.clear(), this.state.reset();
687
+ this.controllers.forEach((a) => a.abort()), this.controllers.clear(), this.state.reset();
688
688
  };
689
689
  }
690
- update(e, t) {
690
+ update(e, a) {
691
691
  this.state.set(
692
- this.state.get().map((o) => o.id === e ? { ...o, ...t } : o)
692
+ this.state.get().map((o) => o.id === e ? { ...o, ...a } : o)
693
693
  );
694
694
  }
695
695
  async upload(e) {
696
- const t = new AbortController();
697
- this.controllers.set(e.id, t), this.update(e.id, { status: "uploading" });
696
+ const a = new AbortController();
697
+ this.controllers.set(e.id, a), this.update(e.id, { status: "uploading" });
698
698
  try {
699
699
  const o = await this.api.uploadFile({
700
700
  file: e.file,
701
- abortSignal: t.signal,
701
+ abortSignal: a.signal,
702
702
  onProgress: (r) => this.update(e.id, { progress: r })
703
703
  });
704
704
  this.update(e.id, {
@@ -707,7 +707,7 @@ class ge {
707
707
  progress: 100
708
708
  });
709
709
  } catch (o) {
710
- t.signal.aborted || this.update(e.id, {
710
+ a.signal.aborted || this.update(e.id, {
711
711
  status: "error",
712
712
  progress: 0,
713
713
  error: o instanceof Error ? o.message : "Upload failed"
@@ -720,10 +720,10 @@ class ge {
720
720
  function q() {
721
721
  return N();
722
722
  }
723
- class ke {
723
+ class be {
724
724
  constructor({
725
725
  api: e,
726
- sessionCtx: t,
726
+ sessionCtx: a,
727
727
  messageCtx: o
728
728
  }) {
729
729
  this.submitCsat = async (r) => {
@@ -749,16 +749,16 @@ class ke {
749
749
  }
750
750
  ]
751
751
  });
752
- const { data: a, error: n } = await this.api.submitCsat({
752
+ const { data: t, error: n } = await this.api.submitCsat({
753
753
  ...r,
754
754
  system_message_uuid: s,
755
755
  session_id: c
756
756
  });
757
- return { data: a, error: n };
758
- }, this.api = e, this.sessionCtx = t, this.messageCtx = o;
757
+ return { data: t, error: n };
758
+ }, this.api = e, this.sessionCtx = a, this.messageCtx = o;
759
759
  }
760
760
  }
761
- const be = [
761
+ const ve = [
762
762
  {
763
763
  action: "newparagraph",
764
764
  phrases: {
@@ -833,7 +833,7 @@ const be = [
833
833
  it: ["invia messaggio"]
834
834
  }
835
835
  }
836
- ], ve = [
836
+ ], fe = [
837
837
  "en",
838
838
  "es",
839
839
  "fr",
@@ -841,25 +841,25 @@ const be = [
841
841
  "pt",
842
842
  "it"
843
843
  ];
844
- function fe(i) {
845
- return ve.includes(i);
846
- }
847
844
  function ye(i) {
848
- return i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
845
+ return fe.includes(i);
849
846
  }
850
847
  function we(i) {
851
- const e = be.flatMap(
848
+ return i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
849
+ }
850
+ function je(i) {
851
+ const e = ve.flatMap(
852
852
  (r) => i.flatMap(
853
853
  (c) => r.phrases[c].map((s) => ({ phrase: s, action: r.action }))
854
854
  )
855
- ), t = e.map((r) => ye(r.phrase)).sort((r, c) => c.length - r.length).join("|"), o = String.raw`(?<=^\s{0,3}|[.!?\n]\s{0,3})`;
855
+ ), a = e.map((r) => we(r.phrase)).sort((r, c) => c.length - r.length).join("|"), o = String.raw`(?<=^\s{0,3}|[.!?\n]\s{0,3})`;
856
856
  return {
857
857
  regex: new RegExp(
858
- `${o}(${t})` + String.raw`([.,!?;:])(?=\s|$)`,
858
+ `${o}(${a})` + String.raw`([.,!?;:])(?=\s|$)`,
859
859
  "giu"
860
860
  ),
861
861
  finalRegex: new RegExp(
862
- `${o}(${t})` + String.raw`([.,!?;:]?)(?=\s|$)`,
862
+ `${o}(${a})` + String.raw`([.,!?;:]?)(?=\s|$)`,
863
863
  "giu"
864
864
  ),
865
865
  phraseToAction: new Map(
@@ -870,37 +870,37 @@ function we(i) {
870
870
  }
871
871
  const B = /* @__PURE__ */ new Map();
872
872
  function M(i) {
873
- const e = i && fe(i) && i !== "en" ? i : null, t = e ?? "en";
874
- let o = B.get(t);
875
- return o || (o = we(e ? ["en", e] : ["en"]), B.set(t, o)), o;
873
+ const e = i && ye(i) && i !== "en" ? i : null, a = e ?? "en";
874
+ let o = B.get(a);
875
+ return o || (o = je(e ? ["en", e] : ["en"]), B.set(a, o)), o;
876
876
  }
877
- function je(i) {
877
+ function Se(i) {
878
878
  const e = i.replace(/\s+$/, "");
879
879
  if (!e) return "";
880
- const t = e.replace(/[.!?]+$/, "");
880
+ const a = e.replace(/[.!?]+$/, "");
881
881
  let o = -1;
882
- for (let r = t.length - 1; r >= 0; r--) {
883
- const c = t[r];
882
+ for (let r = a.length - 1; r >= 0; r--) {
883
+ const c = a[r];
884
884
  if (c === "." || c === "!" || c === "?" || c === `
885
885
  `) {
886
886
  o = r + 1;
887
887
  break;
888
888
  }
889
889
  }
890
- return o === -1 ? "" : `${t.slice(0, o)} `.replace(/\n $/, `
890
+ return o === -1 ? "" : `${a.slice(0, o)} `.replace(/\n $/, `
891
891
  `);
892
892
  }
893
- const Se = new RegExp(
893
+ const ze = new RegExp(
894
894
  String.raw`(^- |\n(?:- )?)(\p{Ll})`,
895
895
  "gu"
896
896
  );
897
- function ze(i) {
897
+ function Ce(i) {
898
898
  return i.replace(
899
- Se,
900
- (e, t, o) => t + o.toUpperCase()
899
+ ze,
900
+ (e, a, o) => a + o.toUpperCase()
901
901
  );
902
902
  }
903
- function Ce(i) {
903
+ function xe(i) {
904
904
  return i.length <= 3 && /^\s*$/.test(i) ? !0 : /[.!?\n]\s{0,3}$/.test(i.slice(-6));
905
905
  }
906
906
  class E {
@@ -909,31 +909,31 @@ class E {
909
909
  * Pure and deterministic: always called with the entire raw string so the
910
910
  * result never depends on delta chunking.
911
911
  */
912
- static process(e, t) {
913
- const o = M(t == null ? void 0 : t.language), r = t != null && t.final ? "" : E.commandPrefixTail(e, t == null ? void 0 : t.language), c = e.slice(0, e.length - r.length), s = t != null && t.final ? o.finalRegex : o.regex;
914
- let a = "", n = null, l = 0;
912
+ static process(e, a) {
913
+ const o = M(a == null ? void 0 : a.language), r = a != null && a.final ? "" : E.commandPrefixTail(e, a == null ? void 0 : a.language), c = e.slice(0, e.length - r.length), s = a != null && a.final ? o.finalRegex : o.regex;
914
+ let t = "", n = null, l = 0;
915
915
  for (const _ of Array.from(c.matchAll(s))) {
916
916
  const [, p = ""] = _, u = o.phraseToAction.get(p.toLowerCase());
917
917
  if (u)
918
- if (a += c.slice(l, _.index), l = _.index + _[0].length, u === "newline") a = `${a.replace(/[ \t]+$/, "")}
918
+ if (t += c.slice(l, _.index), l = _.index + _[0].length, u === "newline") t = `${t.replace(/[ \t]+$/, "")}
919
919
  `;
920
920
  else if (u === "newparagraph")
921
- a = `${a.replace(/[ \t]+$/, "")}
921
+ t = `${t.replace(/[ \t]+$/, "")}
922
922
 
923
923
  `;
924
924
  else if (u === "bullet") {
925
- const m = a.replace(/[ \t]+$/, "");
926
- a = m === "" || m.endsWith(`
925
+ const m = t.replace(/[ \t]+$/, "");
926
+ t = m === "" || m.endsWith(`
927
927
  `) ? `${m}- ` : `${m}
928
928
  - `;
929
- } else if (u === "scratch") a = je(a);
929
+ } else if (u === "scratch") t = Se(t);
930
930
  else {
931
931
  n = u === "send" ? "send" : "stop";
932
932
  break;
933
933
  }
934
934
  }
935
- return n === null && (a += c.slice(l)), { text: ze(
936
- a.replace(/^\s+/, "").replace(/[ \t]+\n/g, `
935
+ return n === null && (t += c.slice(l)), { text: Ce(
936
+ t.replace(/^\s+/, "").replace(/[ \t]+\n/g, `
937
937
  `).replace(/\n[ \t]+/g, `
938
938
  `).replace(/(^|\n)- +/g, "$1- ").replace(/ {2,}/g, " ").replace(/\n{3,}/g, `
939
939
 
@@ -949,16 +949,16 @@ class E {
949
949
  * control command from an intermediate delta would stop or submit
950
950
  * mid-sentence.
951
951
  */
952
- static commandPrefixTail(e, t) {
953
- const o = M(t), r = Math.min(e.length, o.longestPhrase + 2);
952
+ static commandPrefixTail(e, a) {
953
+ const o = M(a), r = Math.min(e.length, o.longestPhrase + 2);
954
954
  for (let c = r; c > 0; c--) {
955
955
  const s = e.length - c;
956
- if (!Ce(e.slice(0, s))) continue;
957
- const a = e.slice(s).toLowerCase(), n = a.replace(/^\s+/, "");
956
+ if (!xe(e.slice(0, s))) continue;
957
+ const t = e.slice(s).toLowerCase(), n = t.replace(/^\s+/, "");
958
958
  if (n) {
959
959
  for (const l of Array.from(o.phraseToAction.keys()))
960
960
  if (l.startsWith(n))
961
- return e.slice(s + (a.length - n.length));
961
+ return e.slice(s + (t.length - n.length));
962
962
  }
963
963
  }
964
964
  return "";
@@ -968,12 +968,12 @@ class E {
968
968
  * prefix) — i.e. a silence pause would resolve it into a command. Used by
969
969
  * the manager's silence timer.
970
970
  */
971
- static pendingTailIsCompletePhrase(e, t) {
972
- const o = E.commandPrefixTail(e, t).trim().toLowerCase();
973
- return o ? M(t).phraseToAction.has(o) : !1;
971
+ static pendingTailIsCompletePhrase(e, a) {
972
+ const o = E.commandPrefixTail(e, a).trim().toLowerCase();
973
+ return o ? M(a).phraseToAction.has(o) : !1;
974
974
  }
975
975
  }
976
- const xe = 55, qe = 90;
976
+ const qe = 55, Ee = 90;
977
977
  class V {
978
978
  /**
979
979
  * Next paced step toward `processed`: normally one word per tick so text
@@ -983,28 +983,28 @@ class V {
983
983
  */
984
984
  static nextDripText({
985
985
  displayed: e,
986
- processed: t
986
+ processed: a
987
987
  }) {
988
- if (t.length <= e.length) return t;
989
- const o = t.length - e.length;
990
- if (o > qe)
991
- return t.slice(0, e.length + Math.ceil(o / 3));
988
+ if (a.length <= e.length) return a;
989
+ const o = a.length - e.length;
990
+ if (o > Ee)
991
+ return a.slice(0, e.length + Math.ceil(o / 3));
992
992
  let r = e.length;
993
- for (; r < t.length && /\s/.test(t.charAt(r)); ) r++;
994
- for (; r < t.length && !/\s/.test(t.charAt(r)); ) r++;
995
- return r - e.length > 12 && (r = e.length + 6), t.slice(0, Math.max(r, e.length + 1));
993
+ for (; r < a.length && /\s/.test(a.charAt(r)); ) r++;
994
+ for (; r < a.length && !/\s/.test(a.charAt(r)); ) r++;
995
+ return r - e.length > 12 && (r = e.length + 6), a.slice(0, Math.max(r, e.length + 1));
996
996
  }
997
997
  /** Normalize a BCP-47 browser locale into the hint OpenAI accepts. */
998
998
  static languageHint(e) {
999
999
  if (!e) return;
1000
- const t = e.toLowerCase();
1001
- if (/^zh-(cn|tw|hk)$/.test(t)) return t;
1002
- const o = t.split("-")[0];
1000
+ const a = e.toLowerCase();
1001
+ if (/^zh-(cn|tw|hk)$/.test(a)) return a;
1002
+ const o = a.split("-")[0];
1003
1003
  return o && /^[a-z]{2,3}$/.test(o) ? o : void 0;
1004
1004
  }
1005
1005
  }
1006
- const Ee = 2e4;
1007
- class Ae {
1006
+ const Ae = 2e4;
1007
+ class Pe {
1008
1008
  constructor() {
1009
1009
  this.cached = null, this.inflight = null;
1010
1010
  }
@@ -1012,15 +1012,15 @@ class Ae {
1012
1012
  get() {
1013
1013
  if (!this.cached) return null;
1014
1014
  const e = Date.parse(this.cached.expiresAt);
1015
- return Number.isNaN(e) || e - Date.now() < Ee ? (this.cached = null, null) : this.cached;
1015
+ return Number.isNaN(e) || e - Date.now() < Ae ? (this.cached = null, null) : this.cached;
1016
1016
  }
1017
1017
  /**
1018
1018
  * Resolve a mint, deduping concurrent requests (hover-prewarm racing a
1019
1019
  * click reuses the same in-flight promise instead of double-minting).
1020
1020
  */
1021
1021
  async resolve(e) {
1022
- const t = this.get();
1023
- return t || (this.inflight || (this.inflight = e().then((o) => (this.cached = o, o)).finally(() => {
1022
+ const a = this.get();
1023
+ return a || (this.inflight || (this.inflight = e().then((o) => (this.cached = o, o)).finally(() => {
1024
1024
  this.inflight = null;
1025
1025
  })), this.inflight);
1026
1026
  }
@@ -1032,7 +1032,7 @@ class Ae {
1032
1032
  function H(i) {
1033
1033
  return typeof i == "object" && i !== null && !Array.isArray(i);
1034
1034
  }
1035
- function Pe(i) {
1035
+ function Te(i) {
1036
1036
  if (!H(i) || typeof i.type != "string") return null;
1037
1037
  const e = H(i.error) ? i.error : null;
1038
1038
  return {
@@ -1041,43 +1041,43 @@ function Pe(i) {
1041
1041
  errorMessage: e && typeof e.message == "string" ? e.message : void 0
1042
1042
  };
1043
1043
  }
1044
- const Te = "https://api.openai.com/v1/realtime/calls", Ie = 600 * 1e3, Me = 15e3, De = 5e3;
1044
+ const Ie = "https://api.openai.com/v1/realtime/calls", Me = 600 * 1e3, De = 15e3, Ne = 5e3;
1045
1045
  class T extends Error {
1046
1046
  }
1047
- class Ne {
1047
+ class Re {
1048
1048
  constructor({
1049
1049
  mintToken: e,
1050
- onDelta: t,
1050
+ onDelta: a,
1051
1051
  onState: o,
1052
1052
  onError: r,
1053
1053
  onLevel: c
1054
1054
  }) {
1055
- this.state = "idle", this.pc = null, this.dc = null, this.stream = null, this.audioContext = null, this.levelRaf = 0, this.timers = [], this.loggedParseFailure = !1, this.mintToken = e, this.onDelta = t, this.onState = o, this.onError = r, this.onLevel = c;
1055
+ this.state = "idle", this.pc = null, this.dc = null, this.stream = null, this.audioContext = null, this.levelRaf = 0, this.timers = [], this.loggedParseFailure = !1, this.mintToken = e, this.onDelta = a, this.onState = o, this.onError = r, this.onLevel = c;
1056
1056
  }
1057
1057
  async start() {
1058
1058
  if (this.state === "idle") {
1059
1059
  this.setState("connecting"), this.timers.push(
1060
1060
  setTimeout(() => {
1061
1061
  this.state === "connecting" && this.fail("unavailable");
1062
- }, Me)
1063
- ), this.timers.push(setTimeout(() => this.stop(), Ie));
1062
+ }, De)
1063
+ ), this.timers.push(setTimeout(() => this.stop(), Me));
1064
1064
  try {
1065
1065
  const e = this.requestMicrophone();
1066
1066
  e.then((d) => {
1067
1067
  this.isTornDown() || this.stream && this.stream !== d ? d.getTracks().forEach((_) => _.stop()) : this.stream = d;
1068
1068
  }).catch(() => {
1069
1069
  });
1070
- const [t, o] = await Promise.all([e, this.mintToken()]);
1070
+ const [a, o] = await Promise.all([e, this.mintToken()]);
1071
1071
  if (this.isTornDown()) {
1072
- t.getTracks().forEach((d) => d.stop());
1072
+ a.getTracks().forEach((d) => d.stop());
1073
1073
  return;
1074
1074
  }
1075
- this.stream = t, this.startLevelMeter(t);
1075
+ this.stream = a, this.startLevelMeter(a);
1076
1076
  const r = new RTCPeerConnection();
1077
1077
  this.pc = r;
1078
- const [c] = t.getAudioTracks();
1078
+ const [c] = a.getAudioTracks();
1079
1079
  if (!c) throw new T("No audio track");
1080
- r.addTrack(c, t);
1080
+ r.addTrack(c, a);
1081
1081
  const s = r.createDataChannel("oai-events");
1082
1082
  this.dc = s, s.addEventListener(
1083
1083
  "message",
@@ -1092,18 +1092,18 @@ class Ne {
1092
1092
  r.connectionState === "disconnected" && this.timers.push(
1093
1093
  setTimeout(() => {
1094
1094
  this.pc === r && r.connectionState !== "connected" && this.fail("unavailable");
1095
- }, De)
1095
+ }, Ne)
1096
1096
  );
1097
1097
  });
1098
- const a = await r.createOffer();
1099
- if (this.isTornDown() || (await r.setLocalDescription(a), this.isTornDown())) return;
1100
- const n = await fetch(Te, {
1098
+ const t = await r.createOffer();
1099
+ if (this.isTornDown() || (await r.setLocalDescription(t), this.isTornDown())) return;
1100
+ const n = await fetch(Ie, {
1101
1101
  method: "POST",
1102
1102
  headers: {
1103
1103
  Authorization: `Bearer ${o.token}`,
1104
1104
  "Content-Type": "application/sdp"
1105
1105
  },
1106
- body: a.sdp
1106
+ body: t.sdp
1107
1107
  });
1108
1108
  if (!n.ok)
1109
1109
  throw new Error(`Realtime handshake failed (${n.status})`);
@@ -1132,24 +1132,24 @@ class Ne {
1132
1132
  autoGainControl: !0
1133
1133
  }
1134
1134
  });
1135
- } catch (t) {
1135
+ } catch (a) {
1136
1136
  throw new T(
1137
- t instanceof DOMException ? t.name : "Could not access the microphone"
1137
+ a instanceof DOMException ? a.name : "Could not access the microphone"
1138
1138
  );
1139
1139
  }
1140
1140
  }
1141
1141
  handleServerEvent(e) {
1142
1142
  if (typeof e != "string") return;
1143
- let t;
1143
+ let a;
1144
1144
  try {
1145
- t = JSON.parse(e);
1145
+ a = JSON.parse(e);
1146
1146
  } catch {
1147
1147
  this.loggedParseFailure || (this.loggedParseFailure = !0, k.error("dictation server event was not valid JSON", {
1148
1148
  snippet: e.slice(0, 120)
1149
1149
  }));
1150
1150
  return;
1151
1151
  }
1152
- const o = Pe(t);
1152
+ const o = Te(a);
1153
1153
  if (!o) return;
1154
1154
  const { type: r, delta: c } = o;
1155
1155
  if (r === "session.created" || r === "transcription_session.created") {
@@ -1167,25 +1167,25 @@ class Ne {
1167
1167
  startLevelMeter(e) {
1168
1168
  if (this.onLevel)
1169
1169
  try {
1170
- const t = new AudioContext();
1171
- this.audioContext = t;
1172
- const o = t.createMediaStreamSource(e), r = t.createAnalyser();
1170
+ const a = new AudioContext();
1171
+ this.audioContext = a;
1172
+ const o = a.createMediaStreamSource(e), r = a.createAnalyser();
1173
1173
  r.fftSize = 512, o.connect(r);
1174
1174
  const c = new Uint8Array(r.frequencyBinCount), s = () => {
1175
1175
  var l;
1176
1176
  r.getByteTimeDomainData(c);
1177
- let a = 0;
1177
+ let t = 0;
1178
1178
  for (let d = 0; d < c.length; d++) {
1179
1179
  const _ = ((c[d] ?? 128) - 128) / 128;
1180
- a += _ * _;
1180
+ t += _ * _;
1181
1181
  }
1182
- const n = Math.sqrt(a / c.length);
1182
+ const n = Math.sqrt(t / c.length);
1183
1183
  (l = this.onLevel) == null || l.call(this, Math.min(1, n * 4)), this.levelRaf = requestAnimationFrame(s);
1184
1184
  };
1185
1185
  this.levelRaf = requestAnimationFrame(s);
1186
- } catch (t) {
1186
+ } catch (a) {
1187
1187
  k.error("dictation level meter unavailable", {
1188
- _e: t instanceof Error ? t.message : String(t)
1188
+ _e: a instanceof Error ? a.message : String(a)
1189
1189
  });
1190
1190
  }
1191
1191
  }
@@ -1196,8 +1196,8 @@ class Ne {
1196
1196
  this.isTornDown() || (this.teardown(), this.setState("error"), this.onError(e));
1197
1197
  }
1198
1198
  teardown() {
1199
- var e, t, o, r;
1200
- this.timers.forEach((c) => clearTimeout(c)), this.timers = [], this.levelRaf && cancelAnimationFrame(this.levelRaf), this.levelRaf = 0, (e = this.dc) == null || e.close(), this.dc = null, (t = this.pc) == null || t.close(), this.pc = null, (o = this.stream) == null || o.getTracks().forEach((c) => c.stop()), this.stream = null, (r = this.audioContext) == null || r.close().catch((c) => {
1199
+ var e, a, o, r;
1200
+ this.timers.forEach((c) => clearTimeout(c)), this.timers = [], this.levelRaf && cancelAnimationFrame(this.levelRaf), this.levelRaf = 0, (e = this.dc) == null || e.close(), this.dc = null, (a = this.pc) == null || a.close(), this.pc = null, (o = this.stream) == null || o.getTracks().forEach((c) => c.stop()), this.stream = null, (r = this.audioContext) == null || r.close().catch((c) => {
1201
1201
  k.error("failed to close dictation audio context", {
1202
1202
  _e: String(c)
1203
1203
  });
@@ -1207,10 +1207,10 @@ class Ne {
1207
1207
  this.state !== e && (this.state = e, this.onState(e));
1208
1208
  }
1209
1209
  }
1210
- const Re = 1300, Ke = { status: "idle", error: null };
1211
- class Le {
1212
- constructor({ api: e, config: t }) {
1213
- this.state = new S(Ke), this.levelRef = { current: 0 }, this.mintCache = new Ae(), this.session = null, this.target = null, this.prefix = "", this.raw = "", this.processed = "", this.displayed = "", this.dripTimer = null, this.silenceTimer = null, this.isActive = () => this.session !== null, this.prewarm = () => {
1210
+ const Ke = 1300, Le = { status: "idle", error: null };
1211
+ class Oe {
1212
+ constructor({ api: e, config: a }) {
1213
+ this.state = new S(Le), this.levelRef = { current: 0 }, this.mintCache = new Pe(), this.session = null, this.target = null, this.prefix = "", this.raw = "", this.processed = "", this.displayed = "", this.dripTimer = null, this.silenceTimer = null, this.isActive = () => this.session !== null, this.prewarm = () => {
1214
1214
  this.mintToken().catch((o) => {
1215
1215
  this.mintCache.clear(), k.error("dictation token prewarm failed", {
1216
1216
  _e: o instanceof Error ? o.message : String(o)
@@ -1220,7 +1220,7 @@ class Le {
1220
1220
  this.session && this.teardown(), this.target = o, this.language = V.languageHint(
1221
1221
  this.config.language ?? navigator.language
1222
1222
  ), this.prefix = o.getValue(), this.raw = "", this.processed = "", this.displayed = "";
1223
- const r = new Ne({
1223
+ const r = new Re({
1224
1224
  mintToken: this.mintToken,
1225
1225
  onLevel: (c) => {
1226
1226
  this.levelRef.current = c;
@@ -1253,9 +1253,9 @@ class Le {
1253
1253
  ) && (this.silenceTimer = setTimeout(() => {
1254
1254
  if (r !== this.session) return;
1255
1255
  this.raw = `${this.raw}.`;
1256
- const a = this.ingest();
1257
- a === "stop" ? this.teardown() : a === "send" && this.teardown({ send: !0 });
1258
- }, Re));
1256
+ const t = this.ingest();
1257
+ t === "stop" ? this.teardown() : t === "send" && this.teardown({ send: !0 });
1258
+ }, Ke));
1259
1259
  }
1260
1260
  });
1261
1261
  this.session = r, this.state.set({ status: "connecting", error: null }), this.dripTimer = setInterval(() => {
@@ -1271,12 +1271,12 @@ class Le {
1271
1271
  })
1272
1272
  );
1273
1273
  }
1274
- }, xe), r.start();
1274
+ }, qe), r.start();
1275
1275
  }, this.stop = (o) => {
1276
1276
  this.session && this.teardown(o);
1277
1277
  }, this.mintToken = async () => this.mintCache.resolve(
1278
1278
  () => this.api.createDictationSession({ language: this.language })
1279
- ), this.api = e, this.config = t;
1279
+ ), this.api = e, this.config = a;
1280
1280
  }
1281
1281
  /** Applied text = prefix + dictated. A mismatch means the visitor edited. */
1282
1282
  isConsistent() {
@@ -1288,28 +1288,28 @@ class Le {
1288
1288
  /** Process the transcript and apply the outcome. Shared by the delta path,
1289
1289
  * the silence timer, and (with `final`) teardown. Returns the control. */
1290
1290
  ingest(e) {
1291
- const t = E.process(this.raw, {
1291
+ const a = E.process(this.raw, {
1292
1292
  language: this.language,
1293
1293
  final: e == null ? void 0 : e.final
1294
1294
  });
1295
- return this.processed = t.text, t.text.startsWith(this.displayed) || this.applyDisplayed(t.text), t.control;
1295
+ return this.processed = a.text, a.text.startsWith(this.displayed) || this.applyDisplayed(a.text), a.control;
1296
1296
  }
1297
1297
  stopSilenceTimer() {
1298
1298
  this.silenceTimer && clearTimeout(this.silenceTimer), this.silenceTimer = null;
1299
1299
  }
1300
1300
  teardown(e) {
1301
1301
  var c;
1302
- const t = this.session, o = this.target;
1302
+ const a = this.session, o = this.target;
1303
1303
  this.dripTimer && clearInterval(this.dripTimer), this.dripTimer = null, this.stopSilenceTimer();
1304
1304
  let r = (e == null ? void 0 : e.send) ?? !1;
1305
1305
  if (o && this.isConsistent()) {
1306
1306
  const s = this.ingest({ final: !0 });
1307
1307
  (e == null ? void 0 : e.executeFinalCommand) !== !1 && s === "send" && (r = !0), this.processed !== this.displayed && this.applyDisplayed(this.processed);
1308
1308
  }
1309
- this.session = null, this.target = null, t == null || t.stop(), this.levelRef.current = 0, this.state.set({ status: "idle", error: (e == null ? void 0 : e.error) ?? null }), r && ((c = o == null ? void 0 : o.onSend) == null || c.call(o));
1309
+ this.session = null, this.target = null, a == null || a.stop(), this.levelRef.current = 0, this.state.set({ status: "idle", error: (e == null ? void 0 : e.error) ?? null }), r && ((c = o == null ? void 0 : o.onSend) == null || c.call(o));
1310
1310
  }
1311
1311
  }
1312
- const Oe = {
1312
+ const Fe = {
1313
1313
  write_a_message_placeholder: "اكتب رسالة...",
1314
1314
  your_issue_has_been_resolved: "تم حل مشكلتك!",
1315
1315
  new_conversation: "محادثة جديدة",
@@ -1418,7 +1418,7 @@ const Oe = {
1418
1418
  zoom_out: "تصغير",
1419
1419
  reset_zoom: "إعادة تعيين التكبير",
1420
1420
  support_chat_aria_label: "دردشة الدعم"
1421
- }, Fe = {
1421
+ }, Ue = {
1422
1422
  write_a_message_placeholder: "একটি বার্তা লিখুন...",
1423
1423
  your_issue_has_been_resolved: "আপনার সমস্যা সমাধান হয়েছে!",
1424
1424
  new_conversation: "নতুন কথোপকথন",
@@ -1515,7 +1515,7 @@ const Oe = {
1515
1515
  zoom_out: "ছোট করুন",
1516
1516
  reset_zoom: "জুম রিসেট করুন",
1517
1517
  support_chat_aria_label: "সাপোর্ট চ্যাট"
1518
- }, Ue = {
1518
+ }, Be = {
1519
1519
  write_a_message_placeholder: "Напишете съобщение...",
1520
1520
  your_issue_has_been_resolved: "Вашият проблем е разрешен!",
1521
1521
  new_conversation: "Нов разговор",
@@ -1612,7 +1612,7 @@ const Oe = {
1612
1612
  zoom_out: "Намаляване",
1613
1613
  reset_zoom: "Нулиране на мащаба",
1614
1614
  support_chat_aria_label: "Чат за поддръжка"
1615
- }, Be = {
1615
+ }, Ve = {
1616
1616
  write_a_message_placeholder: "Napište zprávu...",
1617
1617
  your_issue_has_been_resolved: "Váš problém byl vyřešen!",
1618
1618
  new_conversation: "Nová konverzace",
@@ -1709,7 +1709,7 @@ const Oe = {
1709
1709
  zoom_out: "Oddálit",
1710
1710
  reset_zoom: "Obnovit přiblížení",
1711
1711
  support_chat_aria_label: "Chat podpory"
1712
- }, Ve = {
1712
+ }, He = {
1713
1713
  write_a_message_placeholder: "Skriv en besked...",
1714
1714
  your_issue_has_been_resolved: "Dit problem er løst!",
1715
1715
  new_conversation: "Ny samtale",
@@ -1806,7 +1806,7 @@ const Oe = {
1806
1806
  zoom_out: "Zoom ud",
1807
1807
  reset_zoom: "Nulstil zoom",
1808
1808
  support_chat_aria_label: "Supportchat"
1809
- }, He = {
1809
+ }, Ge = {
1810
1810
  write_a_message_placeholder: "Γράψτε ένα μήνυμα...",
1811
1811
  your_issue_has_been_resolved: "Το πρόβλημά σας επιλύθηκε!",
1812
1812
  new_conversation: "Νέα συνομιλία",
@@ -1903,7 +1903,7 @@ const Oe = {
1903
1903
  zoom_out: "Σμίκρυνση",
1904
1904
  reset_zoom: "Επαναφορά ζουμ",
1905
1905
  support_chat_aria_label: "Συνομιλία υποστήριξης"
1906
- }, Ge = {
1906
+ }, Ze = {
1907
1907
  write_a_message_placeholder: "Nachricht schreiben...",
1908
1908
  your_issue_has_been_resolved: "Ihr Problem wurde gelöst!",
1909
1909
  new_conversation: "Neue Konversation",
@@ -2000,7 +2000,7 @@ const Oe = {
2000
2000
  zoom_out: "Verkleinern",
2001
2001
  reset_zoom: "Zoom zurücksetzen",
2002
2002
  support_chat_aria_label: "Support-Chat"
2003
- }, $ = {
2003
+ }, J = {
2004
2004
  write_a_message_placeholder: "Write a message...",
2005
2005
  your_issue_has_been_resolved: "Your issue has been resolved!",
2006
2006
  new_conversation: "New conversation",
@@ -2109,7 +2109,7 @@ const Oe = {
2109
2109
  zoom_out: "Zoom out",
2110
2110
  reset_zoom: "Reset zoom",
2111
2111
  support_chat_aria_label: "Support chat"
2112
- }, Ze = {
2112
+ }, We = {
2113
2113
  write_a_message_placeholder: "Escribe un mensaje...",
2114
2114
  your_issue_has_been_resolved: "¡Tu problema fue resuelto!",
2115
2115
  new_conversation: "Nueva conversación",
@@ -2206,7 +2206,7 @@ const Oe = {
2206
2206
  zoom_out: "Alejar",
2207
2207
  reset_zoom: "Restablecer zoom",
2208
2208
  support_chat_aria_label: "Chat de soporte"
2209
- }, We = {
2209
+ }, $e = {
2210
2210
  write_a_message_placeholder: "Magsulat ng mensahe...",
2211
2211
  your_issue_has_been_resolved: "Nalutas na ang iyong isyu!",
2212
2212
  new_conversation: "Bagong usapan",
@@ -2303,7 +2303,7 @@ const Oe = {
2303
2303
  zoom_out: "Paliitin",
2304
2304
  reset_zoom: "I-reset ang zoom",
2305
2305
  support_chat_aria_label: "Chat ng suporta"
2306
- }, $e = {
2306
+ }, Je = {
2307
2307
  write_a_message_placeholder: "Kirjoita viesti...",
2308
2308
  your_issue_has_been_resolved: "Ongelmasi on ratkaistu!",
2309
2309
  new_conversation: "Uusi keskustelu",
@@ -2400,7 +2400,7 @@ const Oe = {
2400
2400
  zoom_out: "Loitonna",
2401
2401
  reset_zoom: "Palauta zoomaus",
2402
2402
  support_chat_aria_label: "Tukichat"
2403
- }, Je = {
2403
+ }, Ye = {
2404
2404
  write_a_message_placeholder: "Écrivez un message...",
2405
2405
  your_issue_has_been_resolved: "Votre problème a été résolu !",
2406
2406
  new_conversation: "Nouvelle conversation",
@@ -2497,7 +2497,7 @@ const Oe = {
2497
2497
  zoom_out: "Zoom arrière",
2498
2498
  reset_zoom: "Réinitialiser le zoom",
2499
2499
  support_chat_aria_label: "Chat de support"
2500
- }, Ye = {
2500
+ }, Xe = {
2501
2501
  write_a_message_placeholder: "एक संदेश लिखें...",
2502
2502
  your_issue_has_been_resolved: "आपकी समस्या हल हो गई है!",
2503
2503
  new_conversation: "नई बातचीत",
@@ -2594,7 +2594,7 @@ const Oe = {
2594
2594
  zoom_out: "ज़ूम आउट",
2595
2595
  reset_zoom: "ज़ूम रीसेट करें",
2596
2596
  support_chat_aria_label: "सहायता चैट"
2597
- }, Xe = {
2597
+ }, Qe = {
2598
2598
  write_a_message_placeholder: "Scrivi un messaggio...",
2599
2599
  your_issue_has_been_resolved: "Il tuo problema è stato risolto!",
2600
2600
  new_conversation: "Nuova conversazione",
@@ -2691,7 +2691,7 @@ const Oe = {
2691
2691
  zoom_out: "Riduci",
2692
2692
  reset_zoom: "Reimposta zoom",
2693
2693
  support_chat_aria_label: "Chat di supporto"
2694
- }, Qe = {
2694
+ }, ea = {
2695
2695
  write_a_message_placeholder: "メッセージを入力...",
2696
2696
  your_issue_has_been_resolved: "問題が解決しました!",
2697
2697
  new_conversation: "新しい会話",
@@ -2788,7 +2788,7 @@ const Oe = {
2788
2788
  zoom_out: "縮小",
2789
2789
  reset_zoom: "ズームをリセット",
2790
2790
  support_chat_aria_label: "サポートチャット"
2791
- }, ea = {
2791
+ }, aa = {
2792
2792
  write_a_message_placeholder: "메시지를 입력하세요...",
2793
2793
  your_issue_has_been_resolved: "문제가 해결되었습니다!",
2794
2794
  new_conversation: "새 대화",
@@ -2885,7 +2885,7 @@ const Oe = {
2885
2885
  zoom_out: "축소",
2886
2886
  reset_zoom: "확대/축소 초기화",
2887
2887
  support_chat_aria_label: "고객 지원 채팅"
2888
- }, aa = {
2888
+ }, ta = {
2889
2889
  write_a_message_placeholder: "Schrijf een bericht...",
2890
2890
  your_issue_has_been_resolved: "Uw probleem is opgelost!",
2891
2891
  new_conversation: "Nieuw gesprek",
@@ -2982,7 +2982,7 @@ const Oe = {
2982
2982
  zoom_out: "Uitzoomen",
2983
2983
  reset_zoom: "Zoom herstellen",
2984
2984
  support_chat_aria_label: "Supportchat"
2985
- }, ta = {
2985
+ }, sa = {
2986
2986
  write_a_message_placeholder: "Skriv en melding...",
2987
2987
  your_issue_has_been_resolved: "Problemet ditt er løst!",
2988
2988
  new_conversation: "Ny samtale",
@@ -3079,7 +3079,7 @@ const Oe = {
3079
3079
  zoom_out: "Zoom ut",
3080
3080
  reset_zoom: "Tilbakestill zoom",
3081
3081
  support_chat_aria_label: "Support-chat"
3082
- }, sa = {
3082
+ }, oa = {
3083
3083
  write_a_message_placeholder: "Napisz wiadomość...",
3084
3084
  your_issue_has_been_resolved: "Twój problem został rozwiązany!",
3085
3085
  new_conversation: "Nowa rozmowa",
@@ -3176,7 +3176,7 @@ const Oe = {
3176
3176
  zoom_out: "Pomniejsz",
3177
3177
  reset_zoom: "Resetuj powiększenie",
3178
3178
  support_chat_aria_label: "Czat pomocy"
3179
- }, oa = {
3179
+ }, na = {
3180
3180
  write_a_message_placeholder: "Escreva uma mensagem...",
3181
3181
  your_issue_has_been_resolved: "Seu problema foi resolvido!",
3182
3182
  new_conversation: "Nova conversa",
@@ -3273,7 +3273,7 @@ const Oe = {
3273
3273
  zoom_out: "Reduzir",
3274
3274
  reset_zoom: "Redefinir zoom",
3275
3275
  support_chat_aria_label: "Chat de suporte"
3276
- }, na = {
3276
+ }, ia = {
3277
3277
  write_a_message_placeholder: "Scrie un mesaj...",
3278
3278
  your_issue_has_been_resolved: "Problema ta a fost rezolvată!",
3279
3279
  new_conversation: "Conversație nouă",
@@ -3370,7 +3370,7 @@ const Oe = {
3370
3370
  zoom_out: "Micșorează",
3371
3371
  reset_zoom: "Resetează zoomul",
3372
3372
  support_chat_aria_label: "Chat de asistență"
3373
- }, ia = {
3373
+ }, ra = {
3374
3374
  write_a_message_placeholder: "Skriv ett meddelande...",
3375
3375
  your_issue_has_been_resolved: "Ditt problem har lösts!",
3376
3376
  new_conversation: "Ny konversation",
@@ -3467,7 +3467,7 @@ const Oe = {
3467
3467
  zoom_out: "Zooma ut",
3468
3468
  reset_zoom: "Återställ zoom",
3469
3469
  support_chat_aria_label: "Supportchatt"
3470
- }, ra = {
3470
+ }, _a = {
3471
3471
  write_a_message_placeholder: "Напишите сообщение...",
3472
3472
  your_issue_has_been_resolved: "Ваша проблема решена!",
3473
3473
  new_conversation: "Новый разговор",
@@ -3564,7 +3564,7 @@ const Oe = {
3564
3564
  zoom_out: "Уменьшить",
3565
3565
  reset_zoom: "Сбросить масштаб",
3566
3566
  support_chat_aria_label: "Чат поддержки"
3567
- }, _a = {
3567
+ }, la = {
3568
3568
  write_a_message_placeholder: "เขียนข้อความ...",
3569
3569
  your_issue_has_been_resolved: "ปัญหาของคุณได้รับการแก้ไขแล้ว!",
3570
3570
  new_conversation: "การสนทนาใหม่",
@@ -3661,7 +3661,7 @@ const Oe = {
3661
3661
  zoom_out: "ย่อ",
3662
3662
  reset_zoom: "รีเซ็ตการซูม",
3663
3663
  support_chat_aria_label: "แชทฝ่ายสนับสนุน"
3664
- }, la = {
3664
+ }, ca = {
3665
3665
  write_a_message_placeholder: "Bir mesaj yazın...",
3666
3666
  your_issue_has_been_resolved: "Sorununuz çözüldü!",
3667
3667
  new_conversation: "Yeni konuşma",
@@ -3758,7 +3758,7 @@ const Oe = {
3758
3758
  zoom_out: "Uzaklaştır",
3759
3759
  reset_zoom: "Yakınlaştırmayı sıfırla",
3760
3760
  support_chat_aria_label: "Destek sohbeti"
3761
- }, ca = {
3761
+ }, pa = {
3762
3762
  write_a_message_placeholder: "پیغام لکھیں...",
3763
3763
  your_issue_has_been_resolved: "آپ کا مسئلہ حل ہو گیا ہے!",
3764
3764
  new_conversation: "نئی گفتگو",
@@ -3855,7 +3855,7 @@ const Oe = {
3855
3855
  zoom_out: "زوم آؤٹ",
3856
3856
  reset_zoom: "زوم دوبارہ ترتیب دیں",
3857
3857
  support_chat_aria_label: "سپورٹ چیٹ"
3858
- }, pa = {
3858
+ }, da = {
3859
3859
  write_a_message_placeholder: "Viết tin nhắn...",
3860
3860
  your_issue_has_been_resolved: "Vấn đề của bạn đã được giải quyết!",
3861
3861
  new_conversation: "Cuộc trò chuyện mới",
@@ -3952,7 +3952,7 @@ const Oe = {
3952
3952
  zoom_out: "Thu nhỏ",
3953
3953
  reset_zoom: "Đặt lại thu phóng",
3954
3954
  support_chat_aria_label: "Trò chuyện hỗ trợ"
3955
- }, da = {
3955
+ }, ua = {
3956
3956
  write_a_message_placeholder: "写一条消息...",
3957
3957
  your_issue_has_been_resolved: "您的问题已解决!",
3958
3958
  new_conversation: "新对话",
@@ -4049,7 +4049,7 @@ const Oe = {
4049
4049
  zoom_out: "缩小",
4050
4050
  reset_zoom: "重置缩放",
4051
4051
  support_chat_aria_label: "支持对话"
4052
- }, ua = {
4052
+ }, ma = {
4053
4053
  write_a_message_placeholder: "Napišite poruku...",
4054
4054
  your_issue_has_been_resolved: "Vaš problem je riješen!",
4055
4055
  new_conversation: "Novi razgovor",
@@ -4146,7 +4146,7 @@ const Oe = {
4146
4146
  zoom_out: "Udalji",
4147
4147
  reset_zoom: "Poništi zumiranje",
4148
4148
  support_chat_aria_label: "Chat za podršku"
4149
- }, ma = {
4149
+ }, ha = {
4150
4150
  write_a_message_placeholder: "Kirjuta sõnum...",
4151
4151
  your_issue_has_been_resolved: "Teie probleem on lahendatud!",
4152
4152
  new_conversation: "Uus vestlus",
@@ -4243,7 +4243,7 @@ const Oe = {
4243
4243
  zoom_out: "Vähenda",
4244
4244
  reset_zoom: "Lähtesta suurendus",
4245
4245
  support_chat_aria_label: "Tugivestlus"
4246
- }, ha = {
4246
+ }, ga = {
4247
4247
  write_a_message_placeholder: "Írjon üzenetet...",
4248
4248
  your_issue_has_been_resolved: "A problémája megoldódott!",
4249
4249
  new_conversation: "Új beszélgetés",
@@ -4340,7 +4340,7 @@ const Oe = {
4340
4340
  zoom_out: "Kicsinyítés",
4341
4341
  reset_zoom: "Nagyítás visszaállítása",
4342
4342
  support_chat_aria_label: "Ügyfélszolgálati chat"
4343
- }, ga = {
4343
+ }, ka = {
4344
4344
  write_a_message_placeholder: "Skrifaðu skilaboð...",
4345
4345
  your_issue_has_been_resolved: "Málið þitt hefur verið leyst!",
4346
4346
  new_conversation: "Nýtt samtal",
@@ -4437,7 +4437,7 @@ const Oe = {
4437
4437
  zoom_out: "Minnka aðdrátt",
4438
4438
  reset_zoom: "Endurstilla aðdrátt",
4439
4439
  support_chat_aria_label: "Þjónustuspjall"
4440
- }, ka = {
4440
+ }, ba = {
4441
4441
  write_a_message_placeholder: "Rakstiet ziņojumu...",
4442
4442
  your_issue_has_been_resolved: "Jūsu problēma ir atrisināta!",
4443
4443
  new_conversation: "Jauna saruna",
@@ -4534,7 +4534,7 @@ const Oe = {
4534
4534
  zoom_out: "Attālināt",
4535
4535
  reset_zoom: "Atiestatīt tālummaiņu",
4536
4536
  support_chat_aria_label: "Atbalsta tērzēšana"
4537
- }, ba = {
4537
+ }, va = {
4538
4538
  write_a_message_placeholder: "Parašykite žinutę...",
4539
4539
  your_issue_has_been_resolved: "Jūsų problema išspręsta!",
4540
4540
  new_conversation: "Naujas pokalbis",
@@ -4631,7 +4631,7 @@ const Oe = {
4631
4631
  zoom_out: "Nutolinti",
4632
4632
  reset_zoom: "Atstatyti mastelį",
4633
4633
  support_chat_aria_label: "Pagalbos pokalbis"
4634
- }, va = {
4634
+ }, fa = {
4635
4635
  write_a_message_placeholder: "Schreift eng Noriicht...",
4636
4636
  your_issue_has_been_resolved: "Äert Problem gouf geléist!",
4637
4637
  new_conversation: "Nei Konversatioun",
@@ -4728,7 +4728,7 @@ const Oe = {
4728
4728
  zoom_out: "Erauszoomen",
4729
4729
  reset_zoom: "Zoom zrécksetzen",
4730
4730
  support_chat_aria_label: "Support-Chat"
4731
- }, fa = {
4731
+ }, ya = {
4732
4732
  write_a_message_placeholder: "Ikteb messaġġ...",
4733
4733
  your_issue_has_been_resolved: "Il-problema tiegħek ġiet riżolta!",
4734
4734
  new_conversation: "Konversazzjoni ġdida",
@@ -4825,7 +4825,7 @@ const Oe = {
4825
4825
  zoom_out: "Ċekken",
4826
4826
  reset_zoom: "Irrisettja ż-zoom",
4827
4827
  support_chat_aria_label: "Chat ta’ appoġġ"
4828
- }, ya = {
4828
+ }, wa = {
4829
4829
  write_a_message_placeholder: "Skriv en melding...",
4830
4830
  your_issue_has_been_resolved: "Saken din er løst!",
4831
4831
  new_conversation: "Ny samtale",
@@ -4922,7 +4922,7 @@ const Oe = {
4922
4922
  zoom_out: "Zoom ut",
4923
4923
  reset_zoom: "Tilbakestill zoom",
4924
4924
  support_chat_aria_label: "Support-chat"
4925
- }, wa = {
4925
+ }, ja = {
4926
4926
  write_a_message_placeholder: "Napíšte správu...",
4927
4927
  your_issue_has_been_resolved: "Váš problém bol vyriešený!",
4928
4928
  new_conversation: "Nová konverzácia",
@@ -5019,82 +5019,82 @@ const Oe = {
5019
5019
  zoom_out: "Oddialiť",
5020
5020
  reset_zoom: "Obnoviť priblíženie",
5021
5021
  support_chat_aria_label: "Chat podpory"
5022
- }, J = {
5023
- ar: Oe,
5024
- bn: Fe,
5025
- bg: Ue,
5026
- cs: Be,
5027
- da: Ve,
5028
- de: Ge,
5029
- el: He,
5030
- en: $,
5031
- es: Ze,
5032
- et: ma,
5033
- fi: $e,
5034
- fil: We,
5035
- fr: Je,
5036
- hi: Ye,
5037
- hr: ua,
5038
- hu: ha,
5039
- is: ga,
5040
- it: Xe,
5041
- ja: Qe,
5042
- ko: ea,
5043
- lb: va,
5044
- lt: ba,
5045
- lv: ka,
5046
- mt: fa,
5047
- nb: ya,
5048
- nl: aa,
5049
- no: ta,
5050
- pl: sa,
5051
- pt: oa,
5052
- ro: na,
5053
- ru: ra,
5054
- sk: wa,
5055
- sv: ia,
5056
- th: _a,
5057
- tr: la,
5058
- ur: ca,
5059
- vi: pa,
5060
- "zh-cn": da
5061
- }, ja = Object.keys(J);
5062
- function Sa(i) {
5063
- return ja.includes(i);
5022
+ }, Y = {
5023
+ ar: Fe,
5024
+ bn: Ue,
5025
+ bg: Be,
5026
+ cs: Ve,
5027
+ da: He,
5028
+ de: Ze,
5029
+ el: Ge,
5030
+ en: J,
5031
+ es: We,
5032
+ et: ha,
5033
+ fi: Je,
5034
+ fil: $e,
5035
+ fr: Ye,
5036
+ hi: Xe,
5037
+ hr: ma,
5038
+ hu: ga,
5039
+ is: ka,
5040
+ it: Qe,
5041
+ ja: ea,
5042
+ ko: aa,
5043
+ lb: fa,
5044
+ lt: va,
5045
+ lv: ba,
5046
+ mt: ya,
5047
+ nb: wa,
5048
+ nl: ta,
5049
+ no: sa,
5050
+ pl: oa,
5051
+ pt: na,
5052
+ ro: ia,
5053
+ ru: _a,
5054
+ sk: ja,
5055
+ sv: ra,
5056
+ th: la,
5057
+ tr: ca,
5058
+ ur: pa,
5059
+ vi: da,
5060
+ "zh-cn": ua
5061
+ }, Sa = Object.keys(Y);
5062
+ function za(i) {
5063
+ return Sa.includes(i);
5064
5064
  }
5065
- const za = /* @__PURE__ */ new Set(["ar", "ur"]);
5065
+ const Ca = /* @__PURE__ */ new Set(["ar", "ur"]);
5066
5066
  function Ja(i) {
5067
- return za.has(i);
5067
+ return Ca.has(i);
5068
5068
  }
5069
- function Ca(i) {
5070
- return Sa(i) ? i : "en";
5069
+ function xa(i) {
5070
+ return za(i) ? i : "en";
5071
5071
  }
5072
- function xa(i, e, t, o) {
5072
+ function qa(i, e, a, o) {
5073
5073
  var c;
5074
- const r = ((c = t == null ? void 0 : t[e]) == null ? void 0 : c[i]) || J[e][i] || $[i] || i;
5074
+ const r = ((c = a == null ? void 0 : a[e]) == null ? void 0 : c[i]) || Y[e][i] || J[i] || i;
5075
5075
  return o ? r.replace(
5076
5076
  /\{(\w+)\}/g,
5077
- (s, a) => a in o ? String(o[a]) : s
5077
+ (s, t) => t in o ? String(o[t]) : s
5078
5078
  ) : r;
5079
5079
  }
5080
- function qa(i, e, t) {
5081
- return xa(
5080
+ function Ea(i, e, a) {
5081
+ return qa(
5082
5082
  e,
5083
- Ca(i.language),
5083
+ xa(i.language),
5084
5084
  i.translationOverrides,
5085
- t
5085
+ a
5086
5086
  );
5087
5087
  }
5088
- class Ea {
5088
+ class Aa {
5089
5089
  constructor({
5090
5090
  config: e,
5091
- api: t,
5091
+ api: a,
5092
5092
  contactCtx: o,
5093
5093
  storageCtx: r,
5094
5094
  sessionsPollingIntervalSeconds: c,
5095
5095
  sharedSessions: s
5096
5096
  }) {
5097
- this.sessionsRefresher = new Z(), this.persistedSessionId = null, this.sessionAbortController = new AbortController(), this.sessionState = new S({
5097
+ this.sessionsRefresher = new W(), this.persistedSessionId = null, this.sessionAbortController = new AbortController(), this.sessionState = new S({
5098
5098
  session: null,
5099
5099
  isCreatingSession: !1,
5100
5100
  isResolvingSession: !1
@@ -5112,17 +5112,17 @@ class Ea {
5112
5112
  this.persistSession
5113
5113
  ));
5114
5114
  }, this.restoreActiveSessionTracking = () => {
5115
- var a;
5116
- (a = this.stopPersistingSession) == null || a.call(this), this.stopPersistingSession = void 0, this.registerActiveSessionPersistence();
5117
- }, this.trackActiveSession = (a) => {
5115
+ var t;
5116
+ (t = this.stopPersistingSession) == null || t.call(this), this.stopPersistingSession = void 0, this.registerActiveSessionPersistence();
5117
+ }, this.trackActiveSession = (t) => {
5118
5118
  var n;
5119
- (n = this.stopPersistingSession) == null || n.call(this), this.stopPersistingSession = a.sessionState.subscribe(
5119
+ (n = this.stopPersistingSession) == null || n.call(this), this.stopPersistingSession = t.sessionState.subscribe(
5120
5120
  this.persistSession
5121
- ), this.persistSession(a.sessionState.get());
5122
- }, this.persistSession = ({ session: a }) => {
5121
+ ), this.persistSession(t.sessionState.get());
5122
+ }, this.persistSession = ({ session: t }) => {
5123
5123
  const n = this.storageCtx;
5124
5124
  if (!n) return;
5125
- const l = a != null && a.isOpened ? a.id : null;
5125
+ const l = t != null && t.isOpened ? t.id : null;
5126
5126
  if (l === this.persistedSessionId || !l && this.persistedSessionId === null) return;
5127
5127
  this.persistedSessionId = l, (l ? n.setActiveSessionId(l) : n.clearActiveSessionId()).catch((_) => {
5128
5128
  k.warn("failed to persist the active session", {
@@ -5139,9 +5139,9 @@ class Ea {
5139
5139
  }, this.reset = async () => {
5140
5140
  this.sessionAbortController.abort(), this.sessionAbortController = new AbortController(), this.sessionState.reset();
5141
5141
  }, this.registerSessionsRefresherWrapper = () => {
5142
- var a;
5142
+ var t;
5143
5143
  // If the widget config was initially provided with a contact token, no state change would be triggered, so we just fetch
5144
- (a = this.contactCtx.state.get().contact) != null && a.token && !this.sessionsState.get().didStartInitialFetch ? this.registerSessionsRefresher() : this.stopWaitingForContact = this.contactCtx.state.subscribe(
5144
+ (t = this.contactCtx.state.get().contact) != null && t.token && !this.sessionsState.get().didStartInitialFetch ? this.registerSessionsRefresher() : this.stopWaitingForContact = this.contactCtx.state.subscribe(
5145
5145
  ({ contact: n }) => {
5146
5146
  n != null && n.token && !this.sessionsState.get().didStartInitialFetch && this.registerSessionsRefresher();
5147
5147
  }
@@ -5150,9 +5150,9 @@ class Ea {
5150
5150
  this.sessionsRefresher.startPolling(async () => {
5151
5151
  this.sessionsState.get().didStartInitialFetch === !1 && this.sessionsState.setPartial({ didStartInitialFetch: !0 }), await this.refreshSessions(), this.sessionsState.get().isInitialFetchLoading === !0 && this.sessionsState.setPartial({ isInitialFetchLoading: !1 });
5152
5152
  }, this.sessionsPollingIntervalSeconds * 1e3);
5153
- }, this.dispose = ({ clearActiveSession: a = !1 } = {}) => {
5153
+ }, this.dispose = ({ clearActiveSession: t = !1 } = {}) => {
5154
5154
  var n, l;
5155
- if (this.sessionsRefresher.reset(), this.sessionAbortController.abort(), (n = this.stopPersistingSession) == null || n.call(this), this.stopPersistingSession = void 0, (l = this.stopWaitingForContact) == null || l.call(this), this.stopWaitingForContact = void 0, this.sessionState.reset(), a && this.storageCtx)
5155
+ if (this.sessionsRefresher.reset(), this.sessionAbortController.abort(), (n = this.stopPersistingSession) == null || n.call(this), this.stopPersistingSession = void 0, (l = this.stopWaitingForContact) == null || l.call(this), this.stopWaitingForContact = void 0, this.sessionState.reset(), t && this.storageCtx)
5156
5156
  return this.persistedSessionId = null, this.storageCtx.clearActiveSessionId().catch((d) => {
5157
5157
  k.warn("failed to clear the replaced session", {
5158
5158
  error: d instanceof Error ? d.message : String(d)
@@ -5160,30 +5160,30 @@ class Ea {
5160
5160
  });
5161
5161
  }, this.getParsedCustomData = () => Object.fromEntries(
5162
5162
  Object.entries(this.config.sessionCustomData || {}).map(
5163
- ([a, n]) => {
5163
+ ([t, n]) => {
5164
5164
  var l;
5165
- return typeof n == "string" ? [a, n] : typeof n == "boolean" ? [a, n] : typeof n == "number" ? [a, n] : [a, ((l = W(() => JSON.stringify(n))) == null ? void 0 : l.data) || ""];
5165
+ return typeof n == "string" ? [t, n] : typeof n == "boolean" ? [t, n] : typeof n == "number" ? [t, n] : [t, ((l = $(() => JSON.stringify(n))) == null ? void 0 : l.data) || ""];
5166
5166
  }
5167
5167
  )
5168
5168
  ), this.createSession = async () => {
5169
- const { signal: a } = this.sessionAbortController;
5169
+ const { signal: t } = this.sessionAbortController;
5170
5170
  this.sessionState.setPartial({ session: null, isCreatingSession: !0 });
5171
5171
  try {
5172
- const n = await this.requestSession(a);
5173
- if (a.aborted) return null;
5172
+ const n = await this.requestSession(t);
5173
+ if (t.aborted) return null;
5174
5174
  if (n.session) return n.session;
5175
5175
  if (n.status === 401 && await this.contactCtx.recoverFromStaleToken()) {
5176
- if (a.aborted) return null;
5177
- const l = await this.requestSession(a);
5178
- return a.aborted ? null : l.session ? l.session : (k.error("failed to create session", l.error), null);
5176
+ if (t.aborted) return null;
5177
+ const l = await this.requestSession(t);
5178
+ return t.aborted ? null : l.session ? l.session : (k.error("failed to create session", l.error), null);
5179
5179
  }
5180
5180
  return k.error("failed to create session", n.error), null;
5181
5181
  } catch (n) {
5182
- return a.aborted || k.error("failed to create session", n), null;
5182
+ return t.aborted || k.error("failed to create session", n), null;
5183
5183
  } finally {
5184
- a.aborted || this.sessionState.setPartial({ isCreatingSession: !1 });
5184
+ t.aborted || this.sessionState.setPartial({ isCreatingSession: !1 });
5185
5185
  }
5186
- }, this.requestSession = async (a) => {
5186
+ }, this.requestSession = async (t) => {
5187
5187
  var u, m, g;
5188
5188
  const n = (u = this.contactCtx.state.get().contact) == null ? void 0 : u.externalId, l = {
5189
5189
  ...this.getParsedCustomData(),
@@ -5196,9 +5196,9 @@ class Ea {
5196
5196
  {
5197
5197
  customData: Object.keys(l).length > 0 ? l : void 0
5198
5198
  },
5199
- a
5199
+ t
5200
5200
  );
5201
- if (a.aborted || !d)
5201
+ if (t.aborted || !d)
5202
5202
  return { session: null, status: p == null ? void 0 : p.status, error: _ };
5203
5203
  this.sessionState.setPartial({ session: d });
5204
5204
  try {
@@ -5209,43 +5209,43 @@ class Ea {
5209
5209
  return { session: d, status: p.status, error: void 0 };
5210
5210
  }, this.loadMoreSessions = async () => {
5211
5211
  if (this.sessionsState.get().isLastPage) return;
5212
- const { data: a } = await this.getSessions({
5212
+ const { data: t } = await this.getSessions({
5213
5213
  cursor: this.sessionsState.get().cursor
5214
5214
  });
5215
- if (a) {
5216
- const l = [...this.sessionsState.get().data, ...a.items].filter(
5215
+ if (t) {
5216
+ const l = [...this.sessionsState.get().data, ...t.items].filter(
5217
5217
  (d, _, p) => _ === p.findIndex((u) => d.id === u.id)
5218
5218
  );
5219
5219
  this.sessionsState.setPartial({
5220
5220
  data: l,
5221
- cursor: a.next || void 0,
5222
- isLastPage: a.next === null
5221
+ cursor: t.next || void 0,
5222
+ isLastPage: t.next === null
5223
5223
  });
5224
5224
  }
5225
- }, this.getSessions = async ({ cursor: a }) => {
5225
+ }, this.getSessions = async ({ cursor: t }) => {
5226
5226
  var l, d;
5227
5227
  if (!((l = this.contactCtx.state.get().contact) != null && l.token)) return { data: null };
5228
5228
  const n = (d = this.contactCtx.state.get().contact) == null ? void 0 : d.externalId;
5229
5229
  return await this.api.getSessions({
5230
- cursor: a,
5230
+ cursor: t,
5231
5231
  filters: n ? {
5232
5232
  external_id: n
5233
5233
  } : {}
5234
5234
  });
5235
- }, this.setSessions = (a) => {
5236
- const n = [...a, ...this.sessionsState.get().data].filter(
5235
+ }, this.setSessions = (t) => {
5236
+ const n = [...t, ...this.sessionsState.get().data].filter(
5237
5237
  (l, d, _) => d === _.findIndex((p) => l.id === p.id)
5238
5238
  );
5239
5239
  this.sessionsState.setPartial({ data: n });
5240
5240
  }, this.refreshSessions = async () => {
5241
- const { data: a } = await this.getSessions({ cursor: void 0 });
5242
- a && this.setSessions(a.items);
5241
+ const { data: t } = await this.getSessions({ cursor: void 0 });
5242
+ t && this.setSessions(t.items);
5243
5243
  }, this.resolveSession = async () => {
5244
- const a = this.sessionState.get().session;
5245
- if (!a || !a.isOpened)
5244
+ const t = this.sessionState.get().session;
5245
+ if (!t || !t.isOpened)
5246
5246
  return { success: !1, error: "Session is not opened" };
5247
5247
  this.sessionState.setPartial({ isResolvingSession: !0 });
5248
- const { signal: n } = this.sessionAbortController, l = await this.api.resolveSession({ session_id: a.id }, n).catch((p) => {
5248
+ const { signal: n } = this.sessionAbortController, l = await this.api.resolveSession({ session_id: t.id }, n).catch((p) => {
5249
5249
  if (n.aborted) return null;
5250
5250
  throw p;
5251
5251
  });
@@ -5253,39 +5253,39 @@ class Ea {
5253
5253
  return { success: !1, error: "Session was reset" };
5254
5254
  const { data: d, error: _ } = l;
5255
5255
  return d ? (this.sessionState.setPartial({ session: d, isResolvingSession: !1 }), { success: !0, data: d }) : (this.sessionState.setPartial({ isResolvingSession: !1 }), { success: !1, error: _ });
5256
- }, this.createStateCheckpoint = async (a) => {
5256
+ }, this.createStateCheckpoint = async (t) => {
5257
5257
  var d;
5258
5258
  const n = (d = this.sessionState.get().session) == null ? void 0 : d.id;
5259
5259
  if (!n) return;
5260
5260
  const { data: l } = await this.api.createStateCheckpoint({
5261
5261
  session_id: n,
5262
- payload: a
5262
+ payload: t
5263
5263
  });
5264
5264
  return l != null && l.success ? { success: !0 } : { success: !1 };
5265
- }, this.config = e, this.api = t, this.contactCtx = o, this.storageCtx = r, this.sessionsPollingIntervalSeconds = c, s ? this.sessionsState = s : this.registerSessionsRefresherWrapper(), this.registerActiveSessionPersistence();
5265
+ }, this.config = e, this.api = a, this.contactCtx = o, this.storageCtx = r, this.sessionsPollingIntervalSeconds = c, s ? this.sessionsState = s : this.registerSessionsRefresherWrapper(), this.registerActiveSessionPersistence();
5266
5266
  }
5267
5267
  }
5268
- const Aa = (i, e, { sendsPageContext: t }) => {
5269
- const o = Ia(i), r = t && e.mentions && e.mentions.length > 0 ? { mentions: e.mentions.map(Pa) } : void 0, c = t && (e.clientContext || r) ? { ...o, ...e.clientContext, ...r } : o, s = e.connectionRequestId ? {
5268
+ const Pa = (i, e, { sendsPageContext: a }) => {
5269
+ const o = Ma(i), r = a && e.mentions && e.mentions.length > 0 ? { mentions: e.mentions.map(Ta) } : void 0, c = a && (e.clientContext || r) ? { ...o, ...e.clientContext, ...r } : o, s = e.connectionRequestId ? {
5270
5270
  ...c,
5271
5271
  opencx__connection_request_id: e.connectionRequestId
5272
- } : c, a = e.withPageEntity === !1 && s && "entity" in s ? Ta(s, "entity") : s;
5272
+ } : c, t = e.withPageEntity === !1 && s && "entity" in s ? Ia(s, "entity") : s;
5273
5273
  return {
5274
- clientContext: e.background ? { ...a, opencx__background: !0 } : a,
5274
+ clientContext: e.background ? { ...t, opencx__background: !0 } : t,
5275
5275
  custom_data: {
5276
5276
  ...i.messageCustomData || {},
5277
5277
  ...e.customData || {}
5278
5278
  }
5279
5279
  };
5280
- }, Pa = ({ type: i, id: e, title: t, meta: o }) => ({
5280
+ }, Ta = ({ type: i, id: e, title: a, meta: o }) => ({
5281
5281
  type: i,
5282
5282
  id: e,
5283
- title: t,
5283
+ title: a,
5284
5284
  ...o ? { meta: o } : {}
5285
- }), Ta = (i, e) => {
5286
- const { [e]: t, ...o } = i;
5285
+ }), Ia = (i, e) => {
5286
+ const { [e]: a, ...o } = i;
5287
5287
  return Object.keys(o).length > 0 ? o : void 0;
5288
- }, Ia = (i) => {
5288
+ }, Ma = (i) => {
5289
5289
  if (typeof i.context != "function") return i.context;
5290
5290
  try {
5291
5291
  return i.context();
@@ -5293,25 +5293,25 @@ const Aa = (i, e, { sendsPageContext: t }) => {
5293
5293
  k.error("context getter threw; sending without context", e);
5294
5294
  return;
5295
5295
  }
5296
- }, Ma = (i) => {
5297
- const e = i.features, t = {
5296
+ }, Da = (i) => {
5297
+ const e = i.features, a = {
5298
5298
  page_context: (e == null ? void 0 : e.pageContext) === !0,
5299
5299
  client_tools: (e == null ? void 0 : e.pageContext) === !0 && (e == null ? void 0 : e.clientTools) === !0,
5300
5300
  page_actions: (e == null ? void 0 : e.pageContext) === !0 && (e == null ? void 0 : e.clientTools) === !0 && (e == null ? void 0 : e.pageActions) === !0
5301
5301
  };
5302
- return e && (e.preamble !== void 0 && (t.preamble = e.preamble), e.inlineUi !== void 0 && (t.inline_ui = e.inlineUi)), t;
5303
- }, Da = ({
5302
+ return e && (e.preamble !== void 0 && (a.preamble = e.preamble), e.inlineUi !== void 0 && (a.inline_ui = e.inlineUi)), a;
5303
+ }, Na = ({
5304
5304
  config: i,
5305
5305
  input: e,
5306
- uuid: t,
5306
+ uuid: a,
5307
5307
  sessionId: o,
5308
5308
  content: r,
5309
5309
  initialMessages: c,
5310
5310
  sendsPageContext: s
5311
5311
  }) => {
5312
- var a, n, l, d;
5312
+ var t, n, l, d;
5313
5313
  return {
5314
- uuid: t,
5314
+ uuid: a,
5315
5315
  bot_token: i.token,
5316
5316
  headers: i.headers,
5317
5317
  query_params: i.queryParams,
@@ -5319,12 +5319,12 @@ const Aa = (i, e, { sendsPageContext: t }) => {
5319
5319
  session_id: o,
5320
5320
  content: r,
5321
5321
  attachments: e.attachments,
5322
- ...Aa(i, e, { sendsPageContext: s }),
5322
+ ...Pa(i, e, { sendsPageContext: s }),
5323
5323
  language: i.language,
5324
- features: Ma(i),
5324
+ features: Da(i),
5325
5325
  presentation: i.presentation,
5326
5326
  capabilities: {
5327
- connections: ((a = i.capabilities) == null ? void 0 : a.connections) === !0,
5327
+ connections: ((t = i.capabilities) == null ? void 0 : t.connections) === !0,
5328
5328
  structured_questions: (n = i.capabilities) == null ? void 0 : n.structuredQuestions,
5329
5329
  rich_replies: (l = i.capabilities) == null ? void 0 : l.richReplies,
5330
5330
  page_effects: (d = i.capabilities) == null ? void 0 : d.pageEffects
@@ -5339,12 +5339,12 @@ const Aa = (i, e, { sendsPageContext: t }) => {
5339
5339
  }, x = class x {
5340
5340
  constructor({
5341
5341
  config: e,
5342
- api: t,
5342
+ api: a,
5343
5343
  sessionCtx: o,
5344
5344
  contactCtx: r,
5345
5345
  streaming: c,
5346
5346
  sendsPageContext: s,
5347
- getClientCapabilities: a,
5347
+ getClientCapabilities: t,
5348
5348
  getRequestConfig: n,
5349
5349
  isStreaming: l,
5350
5350
  getSendsPageContext: d
@@ -5498,8 +5498,8 @@ const Aa = (i, e, { sendsPageContext: t }) => {
5498
5498
  }
5499
5499
  let p;
5500
5500
  try {
5501
- const v = this.sessionCtx.sessionState.get().session, z = (v == null ? void 0 : v.assignee.kind) === "ai", X = this.state.get().isSendingMessageToAI, A = this.state.get().messages.at(-1);
5502
- if (this.blocksSendWhileAwaitingReply && (X || // If last message is from user, then bot response did not arrive yet
5501
+ const v = this.sessionCtx.sessionState.get().session, z = (v == null ? void 0 : v.assignee.kind) === "ai", Q = this.state.get().isSendingMessageToAI, A = this.state.get().messages.at(-1);
5502
+ if (this.blocksSendWhileAwaitingReply && (Q || // If last message is from user, then bot response did not arrive yet
5503
5503
  z && (A == null ? void 0 : A.type) === "USER" && A.id !== this.state.get().settledAgentUserMessageId)) {
5504
5504
  k.warn("cannot send messages while awaiting AI response");
5505
5505
  return;
@@ -5511,19 +5511,19 @@ const Aa = (i, e, { sendsPageContext: t }) => {
5511
5511
  });
5512
5512
  const R = await this.stageUserTurn(_, { pending: !1 });
5513
5513
  if (!R) return;
5514
- const { sessionId: Q, userMessage: K, initialMessages: ee } = R;
5514
+ const { sessionId: ee, userMessage: K, initialMessages: ae } = R;
5515
5515
  this.notifySendAccepted(_);
5516
5516
  const { data: w } = await this.api.sendMessage(
5517
- Da({
5517
+ Na({
5518
5518
  config: {
5519
5519
  ...this.getRequestConfig(),
5520
5520
  capabilities: this.getClientCapabilities()
5521
5521
  },
5522
5522
  input: _,
5523
5523
  uuid: K.id,
5524
- sessionId: Q,
5524
+ sessionId: ee,
5525
5525
  content: K.content,
5526
- initialMessages: ee,
5526
+ initialMessages: ae,
5527
5527
  sendsPageContext: this.sendsPageContext
5528
5528
  }),
5529
5529
  p.signal
@@ -5533,7 +5533,7 @@ const Aa = (i, e, { sendsPageContext: t }) => {
5533
5533
  if (C) {
5534
5534
  const P = this.state.get().messages;
5535
5535
  if (!!P.some(
5536
- (ae) => ae.id === C.id
5536
+ (te) => te.id === C.id
5537
5537
  )) {
5538
5538
  this.state.setPartial({
5539
5539
  lastAIResMightSolveUserIssue: ((u = w.autopilotResponse) == null ? void 0 : u.mightSolveUserIssue) || ((m = w.uiResponse) == null ? void 0 : m.mightSolveUserIssue)
@@ -5549,7 +5549,7 @@ const Aa = (i, e, { sendsPageContext: t }) => {
5549
5549
  } else {
5550
5550
  this.releaseFailedOptionPick(_);
5551
5551
  const C = this.toBotErrorMessage(
5552
- ((f = w == null ? void 0 : w.error) == null ? void 0 : f.message) || qa(this.config, "turn_failed_message")
5552
+ ((f = w == null ? void 0 : w.error) == null ? void 0 : f.message) || Ea(this.config, "turn_failed_message")
5553
5553
  ), P = this.state.get().messages;
5554
5554
  this.state.setPartial({
5555
5555
  messages: [...P, C]
@@ -5614,7 +5614,7 @@ ${_}` : _;
5614
5614
  variant: "error",
5615
5615
  action: void 0
5616
5616
  }
5617
- }), this.config = e, this.getClientCapabilities = a ?? (() => this.getRequestConfig().capabilities), this.api = t, this.sessionCtx = o, this.contactCtx = r, this.isStreaming = l ?? (() => c), this.getRequestConfig = n ?? (() => this.config), this.getSendsPageContext = d ?? (() => s);
5617
+ }), this.config = e, this.getClientCapabilities = t ?? (() => this.getRequestConfig().capabilities), this.api = a, this.sessionCtx = o, this.contactCtx = r, this.isStreaming = l ?? (() => c), this.getRequestConfig = n ?? (() => this.config), this.getSendsPageContext = d ?? (() => s);
5618
5618
  }
5619
5619
  /**
5620
5620
  * Current transport choice. The org or this embed may request polling
@@ -5627,9 +5627,9 @@ ${_}` : _;
5627
5627
  return this.getSendsPageContext();
5628
5628
  }
5629
5629
  /** Hand a send to the streaming engine; its failure can never propagate. */
5630
- static dispatchToEngine(e, t) {
5630
+ static dispatchToEngine(e, a) {
5631
5631
  try {
5632
- Promise.resolve(e.send(t)).catch((o) => {
5632
+ Promise.resolve(e.send(a)).catch((o) => {
5633
5633
  k.error("streaming send failed", o);
5634
5634
  });
5635
5635
  } catch (o) {
@@ -5637,8 +5637,8 @@ ${_}` : _;
5637
5637
  }
5638
5638
  }
5639
5639
  get hasPendingAgentWork() {
5640
- var e, t;
5641
- return this.bufferedAgentSends.length > 0 || (((t = (e = this.agentHandlers) == null ? void 0 : e.hasPendingWork) == null ? void 0 : t.call(e)) ?? !1);
5640
+ var e, a;
5641
+ return this.bufferedAgentSends.length > 0 || (((a = (e = this.agentHandlers) == null ? void 0 : e.hasPendingWork) == null ? void 0 : a.call(e)) ?? !1);
5642
5642
  }
5643
5643
  /**
5644
5644
  * Defensive read of `clientContext.page_marks` → the user bubble's context
@@ -5648,16 +5648,16 @@ ${_}` : _;
5648
5648
  * without a usable name are dropped.
5649
5649
  */
5650
5650
  static markedElementNames(e) {
5651
- const t = e == null ? void 0 : e.page_marks;
5652
- if (!Array.isArray(t)) return;
5653
- const o = t.flatMap((r) => {
5651
+ const a = e == null ? void 0 : e.page_marks;
5652
+ if (!Array.isArray(a)) return;
5653
+ const o = a.flatMap((r) => {
5654
5654
  if (typeof r != "object" || r === null) return [];
5655
- const c = r.elements, s = Array.isArray(c) ? c[0] : void 0, a = typeof s == "object" && s !== null && "name" in s ? s.name : void 0;
5656
- if (typeof a != "string" || a.length === 0) return [];
5655
+ const c = r.elements, s = Array.isArray(c) ? c[0] : void 0, t = typeof s == "object" && s !== null && "name" in s ? s.name : void 0;
5656
+ if (typeof t != "string" || t.length === 0) return [];
5657
5657
  const n = r.note, l = r.snapshotUrl;
5658
5658
  return [
5659
5659
  {
5660
- name: a,
5660
+ name: t,
5661
5661
  ...typeof n == "string" && n.length > 0 ? { note: n } : {},
5662
5662
  ...typeof l == "string" && l.length > 0 ? { snapshotUrl: l } : {},
5663
5663
  mark: r
@@ -5676,9 +5676,9 @@ ${_}` : _;
5676
5676
  };
5677
5677
  x.SENT_TEXT_HISTORY_MAX = 50;
5678
5678
  let D = x;
5679
- class Na {
5679
+ class Ra {
5680
5680
  constructor(e) {
5681
- var t, o;
5681
+ var a, o;
5682
5682
  this.widget = e, this.subscriptions = [], this.disposed = !1, this.restorableSessionId = null, this.didReadStoredSession = !1, this.readStoredSession = () => {
5683
5683
  if (!this.shouldRestoreLastSession) {
5684
5684
  this.didReadStoredSession = !0;
@@ -5704,7 +5704,7 @@ class Na {
5704
5704
  isInitialFetchLoading: r,
5705
5705
  data: c
5706
5706
  }) => {
5707
- var s, a, n, l, d;
5707
+ var s, t, n, l, d;
5708
5708
  if (!(this.disposed || !this.didReadStoredSession)) {
5709
5709
  if (this.restorableSessionId && !((s = this.sessionCtx.sessionState.get().session) != null && s.id)) {
5710
5710
  const _ = c.find(
@@ -5717,7 +5717,7 @@ class Na {
5717
5717
  if (r) return;
5718
5718
  this.restorableSessionId = null;
5719
5719
  }
5720
- if ((a = this.config.router) != null && a.chatScreenOnly && // Do not route to a chat if we are currently inside one already
5720
+ if ((t = this.config.router) != null && t.chatScreenOnly && // Do not route to a chat if we are currently inside one already
5721
5721
  // This also applies to newly created sessions; the new session will be in `sessionState` before it is refreshed and included in `sessionsState`
5722
5722
  !((n = this.sessionCtx.sessionState.get().session) != null && n.id)) {
5723
5723
  const _ = (l = c.find((p) => p.isOpened)) == null ? void 0 : l.id;
@@ -5730,7 +5730,7 @@ class Na {
5730
5730
  }, this.toSessionsScreen = () => {
5731
5731
  this.navigateConversation || this.resetChat(), this.state.setPartial({ screen: "sessions" });
5732
5732
  }, this.toChatScreen = (r) => {
5733
- var s, a;
5733
+ var s, t;
5734
5734
  if (this.navigateConversation) return this.navigateConversation(r);
5735
5735
  this.resetChat();
5736
5736
  let c;
@@ -5738,16 +5738,16 @@ class Na {
5738
5738
  if (c = this.sessionCtx.sessionsState.get().data.find((n) => n.id === r), !c) return;
5739
5739
  this.sessionCtx.sessionState.setPartial({ session: c });
5740
5740
  }
5741
- return this.state.setPartial({ screen: "chat" }), (a = (s = this.config.hooks) == null ? void 0 : s.onNavigateToChat) == null || a.call(s, { session: c }), this.widget;
5741
+ return this.state.setPartial({ screen: "chat" }), (t = (s = this.config.hooks) == null ? void 0 : s.onNavigateToChat) == null || t.call(s, { session: c }), this.widget;
5742
5742
  }, this.config = e.config, this.contactCtx = e.contactCtx, this.sessionCtx = e.sessionCtx, this.resetChat = e.resetChat, this.state = new S({
5743
- screen: this.contactCtx.shouldCollectData() ? "welcome" : (t = this.config.router) != null && t.chatScreenOnly ? "chat" : "sessions"
5743
+ screen: this.contactCtx.shouldCollectData() ? "welcome" : (a = this.config.router) != null && a.chatScreenOnly ? "chat" : "sessions"
5744
5744
  }), this.shouldRestoreLastSession = ((o = this.config.router) == null ? void 0 : o.restoreLastSession) ?? !1, this.readStoredSession(), this.registerRoutingListener();
5745
5745
  }
5746
5746
  }
5747
- class Ra {
5747
+ class Ka {
5748
5748
  constructor({
5749
5749
  storage: e,
5750
- config: t
5750
+ config: a
5751
5751
  }) {
5752
5752
  this.KEYS = {
5753
5753
  contactToken: (o) => `opencx-widget:org-token-${o}:contact-token`,
@@ -5788,10 +5788,10 @@ class Ra {
5788
5788
  return o === "docked" || o === "floating" ? o : null;
5789
5789
  }, this.setCompanionSidebarMode = async (o) => {
5790
5790
  await this.storage.set(this.companionKey("sidebar-mode"), o);
5791
- }, this.storage = e, this.config = t;
5791
+ }, this.storage = e, this.config = a;
5792
5792
  }
5793
5793
  }
5794
- function Ka({
5794
+ function La({
5795
5795
  org: i,
5796
5796
  agent: e
5797
5797
  }) {
@@ -5820,33 +5820,36 @@ function Ka({
5820
5820
  }
5821
5821
  };
5822
5822
  }
5823
- function La(i, e) {
5823
+ function G(i, e) {
5824
5824
  return i && e !== !1;
5825
5825
  }
5826
5826
  function Oa(i, e) {
5827
- const t = e.features;
5827
+ const a = e.features;
5828
5828
  return {
5829
- dictation: La(i.features.dictation, t == null ? void 0 : t.dictation),
5830
- attachments: i.features.attachments,
5831
- pageContext: i.features.pageContext && (t == null ? void 0 : t.pageContext) === !0,
5832
- clientTools: i.features.clientTools && i.features.pageContext && (t == null ? void 0 : t.pageContext) === !0 && (t == null ? void 0 : t.clientTools) === !0,
5833
- pageActions: i.features.pageActions && i.features.clientTools && i.features.pageContext && (t == null ? void 0 : t.pageContext) === !0 && (t == null ? void 0 : t.clientTools) === !0 && (t == null ? void 0 : t.pageActions) === !0
5829
+ dictation: G(i.features.dictation, a == null ? void 0 : a.dictation),
5830
+ attachments: G(
5831
+ i.features.attachments,
5832
+ a == null ? void 0 : a.attachments
5833
+ ),
5834
+ pageContext: i.features.pageContext && (a == null ? void 0 : a.pageContext) === !0,
5835
+ clientTools: i.features.clientTools && i.features.pageContext && (a == null ? void 0 : a.pageContext) === !0 && (a == null ? void 0 : a.clientTools) === !0,
5836
+ pageActions: i.features.pageActions && i.features.clientTools && i.features.pageContext && (a == null ? void 0 : a.pageContext) === !0 && (a == null ? void 0 : a.clientTools) === !0 && (a == null ? void 0 : a.pageActions) === !0
5834
5837
  };
5835
5838
  }
5836
5839
  class Fa extends Error {
5837
- constructor(e, t, o) {
5838
- super(t), this.name = "WidgetInitializationError", this.code = e, this.details = o;
5840
+ constructor(e, a, o) {
5841
+ super(a), this.name = "WidgetInitializationError", this.code = e, this.details = o;
5839
5842
  }
5840
5843
  }
5841
5844
  const j = class j {
5842
5845
  constructor({
5843
5846
  config: e,
5844
- storage: t,
5847
+ storage: a,
5845
5848
  getClientCapabilities: o,
5846
5849
  getRequestConfig: r,
5847
5850
  modes: c,
5848
5851
  org: s,
5849
- agent: a,
5852
+ agent: t,
5850
5853
  parent: n
5851
5854
  }) {
5852
5855
  if (this.modes = [], this.disposed = !1, this.createConversation = () => {
@@ -5881,11 +5884,11 @@ const j = class j {
5881
5884
  throw Error(
5882
5885
  "Widget polling values are not defined, did you call WidgetCtx.initialize()"
5883
5886
  );
5884
- this.config = e, this.getRequestConfig = r ?? (() => this.config), this.getClientCapabilities = o, this.org = s, this.agent = a, this.api = (n == null ? void 0 : n.api) ?? new U({ config: e }), this.storageCtx = (n == null ? void 0 : n.storageCtx) ?? (t ? new Ra({ storage: t, config: e }) : void 0), this.modes = c, this.contactCtx = (n == null ? void 0 : n.contactCtx) ?? new he({
5887
+ this.config = e, this.getRequestConfig = r ?? (() => this.config), this.getClientCapabilities = o, this.org = s, this.agent = t, this.api = (n == null ? void 0 : n.api) ?? new U({ config: e }), this.storageCtx = (n == null ? void 0 : n.storageCtx) ?? (a ? new Ka({ storage: a, config: e }) : void 0), this.modes = c, this.contactCtx = (n == null ? void 0 : n.contactCtx) ?? new ge({
5885
5888
  api: this.api,
5886
5889
  config: this.config,
5887
5890
  storageCtx: this.storageCtx
5888
- }), this.sessionCtx = new Ea({
5891
+ }), this.sessionCtx = new Aa({
5889
5892
  config: this.config,
5890
5893
  api: this.api,
5891
5894
  contactCtx: this.contactCtx,
@@ -5906,24 +5909,24 @@ const j = class j {
5906
5909
  getSendsPageContext: () => this.features.pageContext,
5907
5910
  getClientCapabilities: o,
5908
5911
  getRequestConfig: r
5909
- }), this.uploadCtx = new ge(this.api), this.csatCtx = new ke({
5912
+ }), this.uploadCtx = new ke(this.api), this.csatCtx = new be({
5910
5913
  api: this.api,
5911
5914
  sessionCtx: this.sessionCtx,
5912
5915
  messageCtx: this.messageCtx
5913
- }), this.dictationCtx = new Le({
5916
+ }), this.dictationCtx = new Oe({
5914
5917
  api: this.api,
5915
5918
  config: this.config
5916
- }), this.activeSessionPollingCtx = new me({
5919
+ }), this.activeSessionPollingCtx = new he({
5917
5920
  api: this.api,
5918
5921
  config: this.config,
5919
5922
  sessionCtx: this.sessionCtx,
5920
5923
  messageCtx: this.messageCtx,
5921
5924
  sessionPollingIntervalSeconds: j.pollingIntervalsSeconds.session
5922
- }), this.routerCtx = new Na(this);
5925
+ }), this.routerCtx = new Ra(this);
5923
5926
  }
5924
5927
  get streaming() {
5925
- var e, t;
5926
- return (e = this.messageCtx) != null && e.hasPendingAgentWork ? !0 : (t = this.messageCtx) != null && t.state.get().isSendingMessage ? !1 : this.agent.streaming && this.getRequestConfig().streaming === !0;
5928
+ var e, a;
5929
+ return (e = this.messageCtx) != null && e.hasPendingAgentWork ? !0 : (a = this.messageCtx) != null && a.state.get().isSendingMessage ? !1 : this.agent.streaming && this.getRequestConfig().streaming === !0;
5927
5930
  }
5928
5931
  /**
5929
5932
  * The org's features narrowed by this embed's `config.features` — the
@@ -5935,11 +5938,11 @@ const j = class j {
5935
5938
  };
5936
5939
  j.pollingIntervalsSeconds = null, j.initialize = async ({
5937
5940
  config: e,
5938
- storage: t,
5941
+ storage: a,
5939
5942
  getClientCapabilities: o,
5940
5943
  getRequestConfig: r
5941
5944
  }) => {
5942
- var s, a;
5945
+ var s, t;
5943
5946
  const c = await new U({
5944
5947
  config: e
5945
5948
  }).getExternalWidgetConfig();
@@ -5951,10 +5954,10 @@ j.pollingIntervalsSeconds = null, j.initialize = async ({
5951
5954
  );
5952
5955
  return j.pollingIntervalsSeconds = {
5953
5956
  session: ((s = c.data) == null ? void 0 : s.sessionPollingIntervalSeconds) || 10,
5954
- sessions: ((a = c.data) == null ? void 0 : a.sessionsPollingIntervalSeconds) || 60
5957
+ sessions: ((t = c.data) == null ? void 0 : t.sessionsPollingIntervalSeconds) || 60
5955
5958
  }, new j({
5956
5959
  config: e,
5957
- storage: t,
5960
+ storage: a,
5958
5961
  getClientCapabilities: o,
5959
5962
  getRequestConfig: r,
5960
5963
  modes: c.data.modes || [],
@@ -5962,10 +5965,10 @@ j.pollingIntervalsSeconds = null, j.initialize = async ({
5962
5965
  id: c.data.org.id,
5963
5966
  name: c.data.org.name
5964
5967
  },
5965
- agent: Ka(c.data)
5968
+ agent: La(c.data)
5966
5969
  });
5967
5970
  };
5968
- let G = j;
5971
+ let Z = j;
5969
5972
  function Ya(i, e) {
5970
5973
  return i ? {
5971
5974
  streaming: i.streaming && (e == null ? void 0 : e.streaming) !== !1,
@@ -5974,8 +5977,8 @@ function Ya(i, e) {
5974
5977
  } : e;
5975
5978
  }
5976
5979
  class Xa {
5977
- constructor({ attack: e, release: t }) {
5978
- this.value = 0, this.attack = e, this.release = t;
5980
+ constructor({ attack: e, release: a }) {
5981
+ this.value = 0, this.attack = e, this.release = a;
5979
5982
  }
5980
5983
  next(e) {
5981
5984
  return this.value += (e - this.value) * (e > this.value ? this.attack : this.release), this.value;
@@ -5991,18 +5994,18 @@ const I = [
5991
5994
  ], Ua = new Set(
5992
5995
  I
5993
5996
  );
5994
- function Y(i) {
5997
+ function X(i) {
5995
5998
  return Ua.has(i);
5996
5999
  }
5997
6000
  function Qa(i) {
5998
6001
  if (!Array.isArray(i)) return I;
5999
- const e = [], t = /* @__PURE__ */ new Set();
6002
+ const e = [], a = /* @__PURE__ */ new Set();
6000
6003
  for (const o of i)
6001
- !Y(o) || t.has(o) || (t.add(o), e.push(o));
6004
+ !X(o) || a.has(o) || (a.add(o), e.push(o));
6002
6005
  return e.length > 0 ? e : I;
6003
6006
  }
6004
6007
  function et(i, e) {
6005
- return Y(i) && e.includes(i) ? i : e[0] ?? I[0];
6008
+ return X(i) && e.includes(i) ? i : e[0] ?? I[0];
6006
6009
  }
6007
6010
  function at(i, e) {
6008
6011
  return i === "left" || i === "right" ? i : e === "rtl" ? "left" : "right";
@@ -6011,29 +6014,29 @@ function tt(i) {
6011
6014
  return i === "docked" ? "docked" : "floating";
6012
6015
  }
6013
6016
  export {
6014
- ce as ConnectionAttemptUnavailableError,
6015
- le as ConnectionRequestExpiredError,
6017
+ pe as ConnectionAttemptUnavailableError,
6018
+ ce as ConnectionRequestExpiredError,
6016
6019
  Xa as DictationLevelSmoother,
6017
6020
  S as PrimitiveState,
6018
- G as WidgetCtx,
6021
+ Z as WidgetCtx,
6019
6022
  Fa as WidgetInitializationError,
6020
- Da as buildSendMessageBody,
6023
+ Na as buildSendMessageBody,
6021
6024
  q as genUuid,
6022
- xa as getTranslation,
6025
+ qa as getTranslation,
6023
6026
  Wa as isAgentStreamKeepalive,
6024
- ue as isExhaustive,
6027
+ me as isExhaustive,
6025
6028
  H as isRecord,
6026
6029
  Ja as isRtlLanguage,
6027
- Sa as isSupportedLanguage,
6030
+ za as isSupportedLanguage,
6028
6031
  $a as isTurnSteeredPart,
6029
6032
  k as log,
6030
6033
  Qa as normalizeCompanionLayouts,
6031
6034
  Ya as resolveClientPresentation,
6032
6035
  et as resolveCompanionDefaultLayout,
6033
- Ia as resolveConfigContext,
6034
- Ca as resolveLanguage,
6036
+ Ma as resolveConfigContext,
6037
+ xa as resolveLanguage,
6035
6038
  tt as resolveSidebarMode,
6036
6039
  at as resolveSidebarSide,
6037
- qa as translate
6040
+ Ea as translate
6038
6041
  };
6039
6042
  //# sourceMappingURL=index.js.map