@onedeskpro/chatbot-core 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -126,8 +126,17 @@ function p(e) {
126
126
  }
127
127
  return null;
128
128
  }
129
- function m(e) {
130
- return /^(https?:\/\/|blob:)/i.test(e);
129
+ var m = /* @__PURE__ */ new Set([
130
+ "https:",
131
+ "http:",
132
+ "blob:"
133
+ ]);
134
+ function ee(e) {
135
+ try {
136
+ return m.has(new URL(e).protocol.toLowerCase());
137
+ } catch {
138
+ return !1;
139
+ }
131
140
  }
132
141
  function h(e) {
133
142
  return typeof URL > "u" || typeof URL.createObjectURL != "function" ? "" : URL.createObjectURL(e);
@@ -135,7 +144,7 @@ function h(e) {
135
144
  function g(e) {
136
145
  e.startsWith("blob:") && typeof URL < "u" && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
137
146
  }
138
- function ee(e) {
147
+ function te(e) {
139
148
  return {
140
149
  type: e.type || "application/octet-stream",
141
150
  url: h(e),
@@ -143,10 +152,10 @@ function ee(e) {
143
152
  size: e.size
144
153
  };
145
154
  }
146
- function te(e) {
155
+ function ne(e) {
147
156
  return !Number.isFinite(e) || e < 0 ? "" : e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(+(e < 10240))} KB` : `${(e / 1048576).toFixed(1)} MB`;
148
157
  }
149
- function ne(e) {
158
+ function re(e) {
150
159
  if (!e || typeof e != "object") return [];
151
160
  let t = e, n = t.attachments;
152
161
  if (!Array.isArray(n) && t.message && typeof t.message == "object" && (n = t.message.attachments), !Array.isArray(n)) return [];
@@ -164,7 +173,7 @@ function ne(e) {
164
173
  }
165
174
  return r;
166
175
  }
167
- function re(e, t) {
176
+ function ie(e, t) {
168
177
  let n = e.trim();
169
178
  return n ? t.length === 0 ? !1 : t.some((e) => e.fileName === n) || /^\d+ files?$/.test(n) ? !0 : [
170
179
  "Image",
@@ -178,7 +187,7 @@ var _ = 16e3;
178
187
  function v(e) {
179
188
  return (e ?? "").split(";")[0].trim().toLowerCase() || "audio/webm";
180
189
  }
181
- function ie(e) {
190
+ function ae(e) {
182
191
  return e.includes("mpeg") || e.includes("mp3") ? "mp3" : e.includes("wav") ? "wav" : e.includes("mp4") || e.includes("m4a") ? "m4a" : e.includes("ogg") ? "ogg" : "webm";
183
192
  }
184
193
  function y(e) {
@@ -186,18 +195,18 @@ function y(e) {
186
195
  let t = Math.floor(e), n = Math.floor(t / 60), r = t % 60;
187
196
  return `${n}:${String(r).padStart(2, "0")}`;
188
197
  }
189
- function ae() {
198
+ function oe() {
190
199
  if (typeof window > "u") return null;
191
200
  let e = window;
192
201
  return e.AudioContext ?? e.webkitAudioContext ?? null;
193
202
  }
194
- function oe() {
203
+ function se() {
195
204
  if (typeof window > "u") return null;
196
205
  let e = window;
197
206
  return e.OfflineAudioContext ?? e.webkitOfflineAudioContext ?? null;
198
207
  }
199
- async function se(e) {
200
- let t = ae();
208
+ async function ce(e) {
209
+ let t = oe();
201
210
  if (!t) return null;
202
211
  let n = new t();
203
212
  try {
@@ -209,8 +218,8 @@ async function se(e) {
209
218
  await n.close().catch(() => void 0);
210
219
  }
211
220
  }
212
- async function ce(e) {
213
- let t = oe();
221
+ async function le(e) {
222
+ let t = se();
214
223
  if (t) try {
215
224
  let n = new t(1, Math.max(1, Math.ceil(e.duration * _)), _), r = n.createBufferSource();
216
225
  return r.buffer = e, r.connect(n.destination), r.start(0), {
@@ -223,7 +232,7 @@ async function ce(e) {
223
232
  sampleRate: e.sampleRate
224
233
  };
225
234
  }
226
- function le(e, t) {
235
+ function ue(e, t) {
227
236
  let n = e.length * 2, r = new ArrayBuffer(44 + n), i = new DataView(r), a = (e, t) => {
228
237
  for (let n = 0; n < t.length; n++) i.setUint8(e + n, t.charCodeAt(n));
229
238
  };
@@ -235,7 +244,7 @@ function le(e, t) {
235
244
  }
236
245
  return new Blob([r], { type: "audio/wav" });
237
246
  }
238
- function ue(e, t = 48) {
247
+ function de(e, t = 48) {
239
248
  if (e.length === 0) return [];
240
249
  let n = Math.max(1, Math.floor(e.length / t)), r = [], i = 0;
241
250
  for (let a = 0; a < t; a++) {
@@ -249,21 +258,21 @@ function ue(e, t = 48) {
249
258
  }
250
259
  return r.map((e) => i > 0 ? Math.max(8, Math.min(100, Math.round(e / i * 100))) : 8);
251
260
  }
252
- async function de(e) {
253
- let t = Date.now(), n = Math.max(1, Math.round(e.durationSeconds || 1)), r = v(e.mimeType ?? e.blob.type), i = await se(e.blob);
261
+ async function fe(e) {
262
+ let t = Date.now(), n = Math.max(1, Math.round(e.durationSeconds || 1)), r = v(e.mimeType ?? e.blob.type), i = await ce(e.blob);
254
263
  if (!i) return {
255
- file: new File([e.blob], `voice-message-${t}.${ie(r)}`, { type: r }),
264
+ file: new File([e.blob], `voice-message-${t}.${ae(r)}`, { type: r }),
256
265
  durationSeconds: n
257
266
  };
258
- let { samples: a, sampleRate: o } = await ce(i);
267
+ let { samples: a, sampleRate: o } = await le(i);
259
268
  return {
260
- file: new File([le(a, o)], `voice-message-${t}.wav`, { type: "audio/wav" }),
269
+ file: new File([ue(a, o)], `voice-message-${t}.wav`, { type: "audio/wav" }),
261
270
  durationSeconds: Math.max(1, Math.round(i.duration || n)),
262
- waveform: ue(a)
271
+ waveform: de(a)
263
272
  };
264
273
  }
265
274
  // src/event-emitter.ts
266
- var fe = class {
275
+ var pe = class {
267
276
  constructor() {
268
277
  this._listeners = {};
269
278
  }
@@ -287,10 +296,10 @@ var x = Object.create(null);
287
296
  Object.keys(b).forEach((e) => {
288
297
  x[b[e]] = e;
289
298
  });
290
- var pe = {
299
+ var S = {
291
300
  type: "error",
292
301
  data: "parser error"
293
- }, me = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", he = typeof ArrayBuffer == "function", ge = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, S = ({ type: e, data: t }, n, r) => me && t instanceof Blob ? n ? r(t) : _e(t, r) : he && (t instanceof ArrayBuffer || ge(t)) ? n ? r(t) : _e(new Blob([t]), r) : r(b[e] + (t || "")), _e = (e, t) => {
302
+ }, me = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", he = typeof ArrayBuffer == "function", ge = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, C = ({ type: e, data: t }, n, r) => me && t instanceof Blob ? n ? r(t) : _e(t, r) : he && (t instanceof ArrayBuffer || ge(t)) ? n ? r(t) : _e(new Blob([t]), r) : r(b[e] + (t || "")), _e = (e, t) => {
294
303
  let n = new FileReader();
295
304
  return n.onload = function() {
296
305
  let e = n.result.split(",")[1];
@@ -304,20 +313,20 @@ var ye;
304
313
  function be(e, t) {
305
314
  if (me && e.data instanceof Blob) return e.data.arrayBuffer().then(ve).then(t);
306
315
  if (he && (e.data instanceof ArrayBuffer || ge(e.data))) return t(ve(e.data));
307
- S(e, !1, (e) => {
316
+ C(e, !1, (e) => {
308
317
  ye ||= new TextEncoder(), t(ye.encode(e));
309
318
  });
310
319
  }
311
320
  // ../../node_modules/.pnpm/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js
312
- var xe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", C = typeof Uint8Array > "u" ? [] : /* @__PURE__ */ new Uint8Array(256);
313
- for (let e = 0; e < 64; e++) C[xe.charCodeAt(e)] = e;
321
+ var xe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", w = typeof Uint8Array > "u" ? [] : /* @__PURE__ */ new Uint8Array(256);
322
+ for (let e = 0; e < 64; e++) w[xe.charCodeAt(e)] = e;
314
323
  var Se = (e) => {
315
324
  let t = e.length * .75, n = e.length, r, i = 0, a, o, s, c;
316
325
  e[e.length - 1] === "=" && (t--, e[e.length - 2] === "=" && t--);
317
326
  let l = new ArrayBuffer(t), u = new Uint8Array(l);
318
- for (r = 0; r < n; r += 4) a = C[e.charCodeAt(r)], o = C[e.charCodeAt(r + 1)], s = C[e.charCodeAt(r + 2)], c = C[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
327
+ for (r = 0; r < n; r += 4) a = w[e.charCodeAt(r)], o = w[e.charCodeAt(r + 1)], s = w[e.charCodeAt(r + 2)], c = w[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
319
328
  return l;
320
- }, Ce = typeof ArrayBuffer == "function", w = (e, t) => {
329
+ }, Ce = typeof ArrayBuffer == "function", T = (e, t) => {
321
330
  if (typeof e != "string") return {
322
331
  type: "message",
323
332
  data: Te(e, t)
@@ -329,7 +338,7 @@ var Se = (e) => {
329
338
  } : x[n] ? e.length > 1 ? {
330
339
  type: x[n],
331
340
  data: e.substring(1)
332
- } : { type: x[n] } : pe;
341
+ } : { type: x[n] } : S;
333
342
  }, we = (e, t) => Ce ? Te(Se(e), t) : {
334
343
  base64: !0,
335
344
  data: e
@@ -341,14 +350,14 @@ var Se = (e) => {
341
350
  }, Ee = "", De = (e, t) => {
342
351
  let n = e.length, r = Array(n), i = 0;
343
352
  e.forEach((e, a) => {
344
- S(e, !1, (e) => {
353
+ C(e, !1, (e) => {
345
354
  r[a] = e, ++i === n && t(r.join(Ee));
346
355
  });
347
356
  });
348
357
  }, Oe = (e, t) => {
349
358
  let n = e.split(Ee), r = [];
350
359
  for (let e = 0; e < n.length; e++) {
351
- let i = w(n[e], t);
360
+ let i = T(n[e], t);
352
361
  if (r.push(i), i.type === "error") break;
353
362
  }
354
363
  return r;
@@ -372,10 +381,10 @@ function ke() {
372
381
  } });
373
382
  }
374
383
  var Ae;
375
- function T(e) {
384
+ function E(e) {
376
385
  return e.reduce((e, t) => e + t.length, 0);
377
386
  }
378
- function E(e, t) {
387
+ function D(e, t) {
379
388
  if (e[0].length === t) return e.shift();
380
389
  let n = new Uint8Array(t), r = 0;
381
390
  for (let i = 0; i < t; i++) n[i] = e[0][r++], r === e[0].length && (e.shift(), r = 0);
@@ -387,49 +396,49 @@ function je(e, t) {
387
396
  return new TransformStream({ transform(o, s) {
388
397
  for (n.push(o);;) {
389
398
  if (r === 0) {
390
- if (T(n) < 1) break;
391
- let e = E(n, 1);
399
+ if (E(n) < 1) break;
400
+ let e = D(n, 1);
392
401
  a = (e[0] & 128) == 128, i = e[0] & 127, r = i < 126 ? 3 : i === 126 ? 1 : 2;
393
402
  } else if (r === 1) {
394
- if (T(n) < 2) break;
395
- let e = E(n, 2);
403
+ if (E(n) < 2) break;
404
+ let e = D(n, 2);
396
405
  i = new DataView(e.buffer, e.byteOffset, e.length).getUint16(0), r = 3;
397
406
  } else if (r === 2) {
398
- if (T(n) < 8) break;
399
- let e = E(n, 8), t = new DataView(e.buffer, e.byteOffset, e.length), a = t.getUint32(0);
407
+ if (E(n) < 8) break;
408
+ let e = D(n, 8), t = new DataView(e.buffer, e.byteOffset, e.length), a = t.getUint32(0);
400
409
  if (a > 2 ** 21 - 1) {
401
- s.enqueue(pe);
410
+ s.enqueue(S);
402
411
  break;
403
412
  }
404
413
  i = a * 2 ** 32 + t.getUint32(4), r = 3;
405
414
  } else {
406
- if (T(n) < i) break;
407
- let e = E(n, i);
408
- s.enqueue(w(a ? e : Ae.decode(e), t)), r = 0;
415
+ if (E(n) < i) break;
416
+ let e = D(n, i);
417
+ s.enqueue(T(a ? e : Ae.decode(e), t)), r = 0;
409
418
  }
410
419
  if (i === 0 || i > e) {
411
- s.enqueue(pe);
420
+ s.enqueue(S);
412
421
  break;
413
422
  }
414
423
  }
415
424
  } });
416
425
  }
417
426
  // ../../node_modules/.pnpm/@socket.io+component-emitter@3.1.2/node_modules/@socket.io/component-emitter/lib/esm/index.js
418
- function D(e) {
427
+ function O(e) {
419
428
  if (e) return Me(e);
420
429
  }
421
430
  function Me(e) {
422
- for (var t in D.prototype) e[t] = D.prototype[t];
431
+ for (var t in O.prototype) e[t] = O.prototype[t];
423
432
  return e;
424
433
  }
425
- D.prototype.on = D.prototype.addEventListener = function(e, t) {
434
+ O.prototype.on = O.prototype.addEventListener = function(e, t) {
426
435
  return this._callbacks = this._callbacks || {}, (this._callbacks["$" + e] = this._callbacks["$" + e] || []).push(t), this;
427
- }, D.prototype.once = function(e, t) {
436
+ }, O.prototype.once = function(e, t) {
428
437
  function n() {
429
438
  this.off(e, n), t.apply(this, arguments);
430
439
  }
431
440
  return n.fn = t, this.on(e, n), this;
432
- }, D.prototype.off = D.prototype.removeListener = D.prototype.removeAllListeners = D.prototype.removeEventListener = function(e, t) {
441
+ }, O.prototype.off = O.prototype.removeListener = O.prototype.removeAllListeners = O.prototype.removeEventListener = function(e, t) {
433
442
  if (this._callbacks = this._callbacks || {}, arguments.length == 0) return this._callbacks = {}, this;
434
443
  var n = this._callbacks["$" + e];
435
444
  if (!n) return this;
@@ -439,7 +448,7 @@ D.prototype.on = D.prototype.addEventListener = function(e, t) {
439
448
  break;
440
449
  }
441
450
  return n.length === 0 && delete this._callbacks["$" + e], this;
442
- }, D.prototype.emit = function(e) {
451
+ }, O.prototype.emit = function(e) {
443
452
  this._callbacks = this._callbacks || {};
444
453
  for (var t = Array(arguments.length - 1), n = this._callbacks["$" + e], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r];
445
454
  if (n) {
@@ -447,20 +456,20 @@ D.prototype.on = D.prototype.addEventListener = function(e, t) {
447
456
  for (var r = 0, i = n.length; r < i; ++r) n[r].apply(this, t);
448
457
  }
449
458
  return this;
450
- }, D.prototype.emitReserved = D.prototype.emit, D.prototype.listeners = function(e) {
459
+ }, O.prototype.emitReserved = O.prototype.emit, O.prototype.listeners = function(e) {
451
460
  return this._callbacks = this._callbacks || {}, this._callbacks["$" + e] || [];
452
- }, D.prototype.hasListeners = function(e) {
461
+ }, O.prototype.hasListeners = function(e) {
453
462
  return !!this.listeners(e).length;
454
463
  };
455
464
  // ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/globals.js
456
- var O = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), k = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Ne = "arraybuffer";
465
+ var k = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), A = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Ne = "arraybuffer";
457
466
  // ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/util.js
458
467
  function Pe(e, ...t) {
459
468
  return t.reduce((t, n) => (e.hasOwnProperty(n) && (t[n] = e[n]), t), {});
460
469
  }
461
- var Fe = k.setTimeout, Ie = k.clearTimeout;
462
- function A(e, t) {
463
- t.useNativeTimers ? (e.setTimeoutFn = Fe.bind(k), e.clearTimeoutFn = Ie.bind(k)) : (e.setTimeoutFn = k.setTimeout.bind(k), e.clearTimeoutFn = k.clearTimeout.bind(k));
470
+ var Fe = A.setTimeout, Ie = A.clearTimeout;
471
+ function j(e, t) {
472
+ t.useNativeTimers ? (e.setTimeoutFn = Fe.bind(A), e.clearTimeoutFn = Ie.bind(A)) : (e.setTimeoutFn = A.setTimeout.bind(A), e.clearTimeoutFn = A.clearTimeout.bind(A));
464
473
  }
465
474
  var Le = 1.33;
466
475
  function Re(e) {
@@ -493,9 +502,9 @@ var Ue = class extends Error {
493
502
  constructor(e, t, n) {
494
503
  super(e), this.description = t, this.context = n, this.type = "TransportError";
495
504
  }
496
- }, j = class extends D {
505
+ }, M = class extends O {
497
506
  constructor(e) {
498
- super(), this.writable = !1, A(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
507
+ super(), this.writable = !1, j(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
499
508
  }
500
509
  onError(e, t, n) {
501
510
  return super.emitReserved("error", new Ue(e, t, n)), this;
@@ -513,7 +522,7 @@ var Ue = class extends Error {
513
522
  this.readyState = "open", this.writable = !0, super.emitReserved("open");
514
523
  }
515
524
  onData(e) {
516
- let t = w(e, this.socket.binaryType);
525
+ let t = T(e, this.socket.binaryType);
517
526
  this.onPacket(t);
518
527
  }
519
528
  onPacket(e) {
@@ -537,7 +546,7 @@ var Ue = class extends Error {
537
546
  let t = Ve(e);
538
547
  return t.length ? "?" + t : "";
539
548
  }
540
- }, We = class extends j {
549
+ }, We = class extends M {
541
550
  constructor() {
542
551
  super(...arguments), this._polling = !1;
543
552
  }
@@ -616,9 +625,9 @@ var Je = class extends We {
616
625
  this.onError("xhr poll error", e, t);
617
626
  }), this.pollXhr = e;
618
627
  }
619
- }, M = class e extends D {
628
+ }, N = class e extends O {
620
629
  constructor(e, t, n) {
621
- super(), this.createRequest = e, A(this, n), this._opts = n, this._method = n.method || "GET", this._uri = t, this._data = n.data === void 0 ? null : n.data, this._create();
630
+ super(), this.createRequest = e, j(this, n), this._opts = n, this._method = n.method || "GET", this._uri = t, this._data = n.data === void 0 ? null : n.data, this._create();
622
631
  }
623
632
  _create() {
624
633
  var t;
@@ -672,15 +681,15 @@ var Je = class extends We {
672
681
  this._cleanup();
673
682
  }
674
683
  };
675
- if (M.requestsCount = 0, M.requests = {}, typeof document < "u") {
684
+ if (N.requestsCount = 0, N.requests = {}, typeof document < "u") {
676
685
  if (typeof attachEvent == "function") attachEvent("onunload", Ye);
677
686
  else if (typeof addEventListener == "function") {
678
- let e = "onpagehide" in k ? "pagehide" : "unload";
687
+ let e = "onpagehide" in A ? "pagehide" : "unload";
679
688
  addEventListener(e, Ye, !1);
680
689
  }
681
690
  }
682
691
  function Ye() {
683
- for (let e in M.requests) M.requests.hasOwnProperty(e) && M.requests[e].abort();
692
+ for (let e in N.requests) N.requests.hasOwnProperty(e) && N.requests[e].abort();
684
693
  }
685
694
  var Xe = (function() {
686
695
  let e = Qe({ xdomain: !1 });
@@ -692,7 +701,7 @@ var Xe = (function() {
692
701
  this.supportsBinary = Xe && !t;
693
702
  }
694
703
  request(e = {}) {
695
- return Object.assign(e, { xd: this.xd }, this.opts), new M(Qe, this.uri(), e);
704
+ return Object.assign(e, { xd: this.xd }, this.opts), new N(Qe, this.uri(), e);
696
705
  }
697
706
  };
698
707
  function Qe(e) {
@@ -701,11 +710,11 @@ function Qe(e) {
701
710
  if (typeof XMLHttpRequest < "u" && (!t || Ke)) return new XMLHttpRequest();
702
711
  } catch {}
703
712
  if (!t) try {
704
- return new k.ActiveXObject("Microsoft.XMLHTTP");
713
+ return new A.ActiveXObject("Microsoft.XMLHTTP");
705
714
  } catch {}
706
715
  }
707
716
  // ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/transports/websocket.js
708
- var $e = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative", et = class extends j {
717
+ var $e = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative", et = class extends M {
709
718
  get name() {
710
719
  return "websocket";
711
720
  }
@@ -731,11 +740,11 @@ var $e = typeof navigator < "u" && typeof navigator.product == "string" && navig
731
740
  this.writable = !1;
732
741
  for (let t = 0; t < e.length; t++) {
733
742
  let n = e[t], r = t === e.length - 1;
734
- S(n, this.supportsBinary, (e) => {
743
+ C(n, this.supportsBinary, (e) => {
735
744
  try {
736
745
  this.doWrite(n, e);
737
746
  } catch {}
738
- r && O(() => {
747
+ r && k(() => {
739
748
  this.writable = !0, this.emitReserved("drain");
740
749
  }, this.setTimeoutFn);
741
750
  });
@@ -748,16 +757,16 @@ var $e = typeof navigator < "u" && typeof navigator.product == "string" && navig
748
757
  let e = this.opts.secure ? "wss" : "ws", t = this.query || {};
749
758
  return this.opts.timestampRequests && (t[this.opts.timestampParam] = Be()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
750
759
  }
751
- }, N = k.WebSocket || k.MozWebSocket, tt = {
760
+ }, P = A.WebSocket || A.MozWebSocket, tt = {
752
761
  websocket: class extends et {
753
762
  createSocket(e, t, n) {
754
- return $e ? new N(e, t, n) : t ? new N(e, t) : new N(e);
763
+ return $e ? new P(e, t, n) : t ? new P(e, t) : new P(e);
755
764
  }
756
765
  doWrite(e, t) {
757
766
  this.ws.send(t);
758
767
  }
759
768
  },
760
- webtransport: class extends j {
769
+ webtransport: class extends M {
761
770
  get name() {
762
771
  return "webtransport";
763
772
  }
@@ -791,7 +800,7 @@ var $e = typeof navigator < "u" && typeof navigator.product == "string" && navig
791
800
  for (let t = 0; t < e.length; t++) {
792
801
  let n = e[t], r = t === e.length - 1;
793
802
  this._writer.write(n).then(() => {
794
- r && O(() => {
803
+ r && k(() => {
795
804
  this.writable = !0, this.emitReserved("drain");
796
805
  }, this.setTimeoutFn);
797
806
  });
@@ -819,7 +828,7 @@ var $e = typeof navigator < "u" && typeof navigator.product == "string" && navig
819
828
  "query",
820
829
  "anchor"
821
830
  ];
822
- function P(e) {
831
+ function F(e) {
823
832
  if (e.length > 8e3) throw "URI too long";
824
833
  let t = e, n = e.indexOf("["), r = e.indexOf("]");
825
834
  n != -1 && r != -1 && (e = e.substring(0, n) + e.substring(n, r).replace(/:/g, ";") + e.substring(r, e.length));
@@ -838,17 +847,17 @@ function at(e, t) {
838
847
  }), n;
839
848
  }
840
849
  // ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/socket.js
841
- var F = typeof addEventListener == "function" && typeof removeEventListener == "function", I = [];
842
- F && addEventListener("offline", () => {
843
- I.forEach((e) => e());
850
+ var I = typeof addEventListener == "function" && typeof removeEventListener == "function", L = [];
851
+ I && addEventListener("offline", () => {
852
+ L.forEach((e) => e());
844
853
  }, !1);
845
- var L = class e extends D {
854
+ var R = class e extends O {
846
855
  constructor(e, t) {
847
856
  if (super(), this.binaryType = Ne, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = Infinity, e && typeof e == "object" && (t = e, e = null), e) {
848
- let n = P(e);
857
+ let n = F(e);
849
858
  t.hostname = n.host, t.secure = n.protocol === "https" || n.protocol === "wss", t.port = n.port, n.query && (t.query = n.query);
850
- } else t.host && (t.hostname = P(t.host).host);
851
- A(this, t), this.secure = t.secure == null ? typeof location < "u" && location.protocol === "https:" : t.secure, t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((e) => {
859
+ } else t.host && (t.hostname = F(t.host).host);
860
+ j(this, t), this.secure = t.secure == null ? typeof location < "u" && location.protocol === "https:" : t.secure, t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((e) => {
852
861
  let t = e.prototype.name;
853
862
  this.transports.push(t), this._transportsByName[t] = e;
854
863
  }), this.opts = Object.assign({
@@ -863,11 +872,11 @@ var L = class e extends D {
863
872
  perMessageDeflate: { threshold: 1024 },
864
873
  transportOptions: {},
865
874
  closeOnBeforeunload: !1
866
- }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = He(this.opts.query)), F && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
875
+ }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = He(this.opts.query)), I && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
867
876
  this.transport && (this.transport.removeAllListeners(), this.transport.close());
868
877
  }, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
869
878
  this._onClose("transport close", { description: "network connection lost" });
870
- }, I.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
879
+ }, L.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
871
880
  }
872
881
  createTransport(e) {
873
882
  let t = Object.assign({}, this.opts.query);
@@ -946,7 +955,7 @@ var L = class e extends D {
946
955
  _hasPingExpired() {
947
956
  if (!this._pingTimeoutTime) return !0;
948
957
  let e = Date.now() > this._pingTimeoutTime;
949
- return e && (this._pingTimeoutTime = 0, O(() => {
958
+ return e && (this._pingTimeoutTime = 0, k(() => {
950
959
  this._onClose("ping timeout");
951
960
  }, this.setTimeoutFn)), e;
952
961
  }
@@ -984,16 +993,16 @@ var L = class e extends D {
984
993
  }
985
994
  _onClose(e, t) {
986
995
  if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
987
- if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), F && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
988
- let e = I.indexOf(this._offlineEventListener);
989
- e !== -1 && I.splice(e, 1);
996
+ if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), I && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
997
+ let e = L.indexOf(this._offlineEventListener);
998
+ e !== -1 && L.splice(e, 1);
990
999
  }
991
1000
  this.readyState = "closed", this.id = null, this.emitReserved("close", e, t), this.writeBuffer = [], this._prevBufferLen = 0;
992
1001
  }
993
1002
  }
994
1003
  };
995
- L.protocol = 4;
996
- var ot = class extends L {
1004
+ R.protocol = 4;
1005
+ var ot = class extends R {
997
1006
  constructor() {
998
1007
  super(...arguments), this._upgrades = [];
999
1008
  }
@@ -1002,7 +1011,7 @@ var ot = class extends L {
1002
1011
  }
1003
1012
  _probe(e) {
1004
1013
  let t = this.createTransport(e), n = !1;
1005
- L.priorWebsocketSuccess = !1;
1014
+ R.priorWebsocketSuccess = !1;
1006
1015
  let r = () => {
1007
1016
  n || (t.send([{
1008
1017
  type: "ping",
@@ -1011,7 +1020,7 @@ var ot = class extends L {
1011
1020
  if (!n) {
1012
1021
  if (e.type === "pong" && e.data === "probe") {
1013
1022
  if (this.upgrading = !0, this.emitReserved("upgrading", t), !t) return;
1014
- L.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
1023
+ R.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
1015
1024
  n || this.readyState !== "closed" && (l(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
1016
1025
  });
1017
1026
  } else {
@@ -1066,37 +1075,37 @@ st.protocol;
1066
1075
  // ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/url.js
1067
1076
  function ct(e, t = "", n) {
1068
1077
  let r = e;
1069
- n ||= typeof location < "u" && location, e ??= n.protocol + "//" + n.host, typeof e == "string" && (e.charAt(0) === "/" && (e = e.charAt(1) === "/" ? n.protocol + e : n.host + e), /^(https?|wss?):\/\//.test(e) || (e = n === void 0 ? "https://" + e : n.protocol + "//" + e), r = P(e)), r.port || (/^(http|ws)$/.test(r.protocol) ? r.port = "80" : /^(http|ws)s$/.test(r.protocol) && (r.port = "443")), r.path = r.path || "/";
1078
+ n ||= typeof location < "u" && location, e ??= n.protocol + "//" + n.host, typeof e == "string" && (e.charAt(0) === "/" && (e = e.charAt(1) === "/" ? n.protocol + e : n.host + e), /^(https?|wss?):\/\//.test(e) || (e = n === void 0 ? "https://" + e : n.protocol + "//" + e), r = F(e)), r.port || (/^(http|ws)$/.test(r.protocol) ? r.port = "80" : /^(http|ws)s$/.test(r.protocol) && (r.port = "443")), r.path = r.path || "/";
1070
1079
  let i = r.host.indexOf(":") === -1 ? r.host : "[" + r.host + "]";
1071
1080
  return r.id = r.protocol + "://" + i + ":" + r.port + t, r.href = r.protocol + "://" + i + (n && n.port === r.port ? "" : ":" + r.port), r;
1072
1081
  }
1073
1082
  // ../../node_modules/.pnpm/socket.io-parser@4.2.7_supports-color@8.1.1/node_modules/socket.io-parser/build/esm/is-binary.js
1074
1083
  var lt = typeof ArrayBuffer == "function", ut = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e.buffer instanceof ArrayBuffer, dt = Object.prototype.toString, ft = typeof Blob == "function" || typeof Blob < "u" && dt.call(Blob) === "[object BlobConstructor]", pt = typeof File == "function" || typeof File < "u" && dt.call(File) === "[object FileConstructor]";
1075
- function R(e) {
1084
+ function z(e) {
1076
1085
  return lt && (e instanceof ArrayBuffer || ut(e)) || ft && e instanceof Blob || pt && e instanceof File;
1077
1086
  }
1078
- function z(e, t) {
1087
+ function B(e, t) {
1079
1088
  if (!e || typeof e != "object") return !1;
1080
1089
  if (Array.isArray(e)) {
1081
- for (let t = 0, n = e.length; t < n; t++) if (z(e[t])) return !0;
1090
+ for (let t = 0, n = e.length; t < n; t++) if (B(e[t])) return !0;
1082
1091
  return !1;
1083
1092
  }
1084
- if (R(e)) return !0;
1085
- if (e.toJSON && typeof e.toJSON == "function" && arguments.length === 1) return z(e.toJSON(), !0);
1086
- for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t) && z(e[t])) return !0;
1093
+ if (z(e)) return !0;
1094
+ if (e.toJSON && typeof e.toJSON == "function" && arguments.length === 1) return B(e.toJSON(), !0);
1095
+ for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t) && B(e[t])) return !0;
1087
1096
  return !1;
1088
1097
  }
1089
1098
  // ../../node_modules/.pnpm/socket.io-parser@4.2.7_supports-color@8.1.1/node_modules/socket.io-parser/build/esm/binary.js
1090
1099
  function mt(e) {
1091
1100
  let t = [], n = e.data, r = e;
1092
- return r.data = B(n, t), r.attachments = t.length, {
1101
+ return r.data = V(n, t), r.attachments = t.length, {
1093
1102
  packet: r,
1094
1103
  buffers: t
1095
1104
  };
1096
1105
  }
1097
- function B(e, t, n) {
1106
+ function V(e, t, n) {
1098
1107
  if (!e) return e;
1099
- if (R(e)) {
1108
+ if (z(e)) {
1100
1109
  let n = {
1101
1110
  _placeholder: !0,
1102
1111
  num: t.length
@@ -1105,35 +1114,35 @@ function B(e, t, n) {
1105
1114
  }
1106
1115
  if (Array.isArray(e)) {
1107
1116
  let n = Array(e.length);
1108
- for (let r = 0; r < e.length; r++) n[r] = B(e[r], t);
1117
+ for (let r = 0; r < e.length; r++) n[r] = V(e[r], t);
1109
1118
  return n;
1110
1119
  }
1111
1120
  if (typeof e == "object" && !(e instanceof Date)) {
1112
- if (e.toJSON && typeof e.toJSON == "function" && !n) return B(e.toJSON(), t, !0);
1121
+ if (e.toJSON && typeof e.toJSON == "function" && !n) return V(e.toJSON(), t, !0);
1113
1122
  let r = {};
1114
- for (let n in e) Object.prototype.hasOwnProperty.call(e, n) && (r[n] = B(e[n], t));
1123
+ for (let n in e) Object.prototype.hasOwnProperty.call(e, n) && (r[n] = V(e[n], t));
1115
1124
  return r;
1116
1125
  }
1117
1126
  return e;
1118
1127
  }
1119
1128
  function ht(e, t) {
1120
- return e.data = V(e.data, t), delete e.attachments, e;
1129
+ return e.data = H(e.data, t), delete e.attachments, e;
1121
1130
  }
1122
- function V(e, t) {
1131
+ function H(e, t) {
1123
1132
  if (!e) return e;
1124
1133
  if (e && e._placeholder === !0) {
1125
1134
  if (typeof e.num == "number" && e.num >= 0 && e.num < t.length) return t[e.num];
1126
1135
  throw Error("illegal attachments");
1127
1136
  }
1128
- if (Array.isArray(e)) for (let n = 0; n < e.length; n++) e[n] = V(e[n], t);
1129
- else if (typeof e == "object") for (let n in e) Object.prototype.hasOwnProperty.call(e, n) && (e[n] = V(e[n], t));
1137
+ if (Array.isArray(e)) for (let n = 0; n < e.length; n++) e[n] = H(e[n], t);
1138
+ else if (typeof e == "object") for (let n in e) Object.prototype.hasOwnProperty.call(e, n) && (e[n] = H(e[n], t));
1130
1139
  return e;
1131
1140
  }
1132
1141
  // ../../node_modules/.pnpm/socket.io-parser@4.2.7_supports-color@8.1.1/node_modules/socket.io-parser/build/esm/index.js
1133
1142
  var gt = /* @__PURE__ */ t({
1134
1143
  Decoder: () => yt,
1135
1144
  Encoder: () => vt,
1136
- PacketType: () => H,
1145
+ PacketType: () => U,
1137
1146
  isPacketValid: () => Tt,
1138
1147
  protocol: () => 5
1139
1148
  }), _t = [
@@ -1143,17 +1152,17 @@ var gt = /* @__PURE__ */ t({
1143
1152
  "disconnecting",
1144
1153
  "newListener",
1145
1154
  "removeListener"
1146
- ], H;
1155
+ ], U;
1147
1156
  (function(e) {
1148
1157
  e[e.CONNECT = 0] = "CONNECT", e[e.DISCONNECT = 1] = "DISCONNECT", e[e.EVENT = 2] = "EVENT", e[e.ACK = 3] = "ACK", e[e.CONNECT_ERROR = 4] = "CONNECT_ERROR", e[e.BINARY_EVENT = 5] = "BINARY_EVENT", e[e.BINARY_ACK = 6] = "BINARY_ACK";
1149
- })(H ||= {});
1158
+ })(U ||= {});
1150
1159
  var vt = class {
1151
1160
  constructor(e) {
1152
1161
  this.replacer = e;
1153
1162
  }
1154
1163
  encode(e) {
1155
- return (e.type === H.EVENT || e.type === H.ACK) && z(e) ? this.encodeAsBinary({
1156
- type: e.type === H.EVENT ? H.BINARY_EVENT : H.BINARY_ACK,
1164
+ return (e.type === U.EVENT || e.type === U.ACK) && B(e) ? this.encodeAsBinary({
1165
+ type: e.type === U.EVENT ? U.BINARY_EVENT : U.BINARY_ACK,
1157
1166
  nsp: e.nsp,
1158
1167
  data: e.data,
1159
1168
  id: e.id
@@ -1161,13 +1170,13 @@ var vt = class {
1161
1170
  }
1162
1171
  encodeAsString(e) {
1163
1172
  let t = "" + e.type;
1164
- return (e.type === H.BINARY_EVENT || e.type === H.BINARY_ACK) && (t += e.attachments + "-"), e.nsp && e.nsp !== "/" && (t += e.nsp + ","), e.id != null && (t += e.id), e.data != null && (t += JSON.stringify(e.data, this.replacer)), t;
1173
+ return (e.type === U.BINARY_EVENT || e.type === U.BINARY_ACK) && (t += e.attachments + "-"), e.nsp && e.nsp !== "/" && (t += e.nsp + ","), e.id != null && (t += e.id), e.data != null && (t += JSON.stringify(e.data, this.replacer)), t;
1165
1174
  }
1166
1175
  encodeAsBinary(e) {
1167
1176
  let t = mt(e), n = this.encodeAsString(t.packet), r = t.buffers;
1168
1177
  return r.unshift(n), r;
1169
1178
  }
1170
- }, yt = class e extends D {
1179
+ }, yt = class e extends O {
1171
1180
  constructor(e) {
1172
1181
  super(), this.opts = Object.assign({
1173
1182
  reviver: void 0,
@@ -1179,17 +1188,17 @@ var vt = class {
1179
1188
  if (typeof e == "string") {
1180
1189
  if (this.reconstructor) throw Error("got plaintext data when reconstructing a packet");
1181
1190
  t = this.decodeString(e);
1182
- let n = t.type === H.BINARY_EVENT;
1183
- n || t.type === H.BINARY_ACK ? (t.type = n ? H.EVENT : H.ACK, this.reconstructor = new bt(t)) : super.emitReserved("decoded", t);
1184
- } else if (R(e) || e.base64) {
1191
+ let n = t.type === U.BINARY_EVENT;
1192
+ n || t.type === U.BINARY_ACK ? (t.type = n ? U.EVENT : U.ACK, this.reconstructor = new bt(t)) : super.emitReserved("decoded", t);
1193
+ } else if (z(e) || e.base64) {
1185
1194
  if (this.reconstructor) t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
1186
1195
  else throw Error("got binary data when not reconstructing a packet");
1187
1196
  } else throw Error("Unknown type: " + e);
1188
1197
  }
1189
1198
  decodeString(t) {
1190
1199
  let n = 0, r = { type: Number(t.charAt(0)) };
1191
- if (H[r.type] === void 0) throw Error("unknown packet type " + r.type);
1192
- if (r.type === H.BINARY_EVENT || r.type === H.BINARY_ACK) {
1200
+ if (U[r.type] === void 0) throw Error("unknown packet type " + r.type);
1201
+ if (r.type === U.BINARY_EVENT || r.type === U.BINARY_ACK) {
1193
1202
  let e = n + 1;
1194
1203
  for (; t.charAt(++n) !== "-" && n != t.length;);
1195
1204
  let i = t.substring(e, n);
@@ -1233,13 +1242,13 @@ var vt = class {
1233
1242
  }
1234
1243
  static isPayloadValid(e, t) {
1235
1244
  switch (e) {
1236
- case H.CONNECT: return U(t);
1237
- case H.DISCONNECT: return t === void 0;
1238
- case H.CONNECT_ERROR: return typeof t == "string" || U(t);
1239
- case H.EVENT:
1240
- case H.BINARY_EVENT: return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && _t.indexOf(t[0]) === -1);
1241
- case H.ACK:
1242
- case H.BINARY_ACK: return Array.isArray(t);
1245
+ case U.CONNECT: return W(t);
1246
+ case U.DISCONNECT: return t === void 0;
1247
+ case U.CONNECT_ERROR: return typeof t == "string" || W(t);
1248
+ case U.EVENT:
1249
+ case U.BINARY_EVENT: return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && _t.indexOf(t[0]) === -1);
1250
+ case U.ACK:
1251
+ case U.BINARY_ACK: return Array.isArray(t);
1243
1252
  }
1244
1253
  }
1245
1254
  destroy() {
@@ -1269,16 +1278,16 @@ var St = Number.isInteger || function(e) {
1269
1278
  function Ct(e) {
1270
1279
  return e === void 0 || St(e);
1271
1280
  }
1272
- function U(e) {
1281
+ function W(e) {
1273
1282
  return Object.prototype.toString.call(e) === "[object Object]";
1274
1283
  }
1275
1284
  function wt(e, t) {
1276
1285
  switch (e) {
1277
- case H.CONNECT: return t === void 0 || U(t);
1278
- case H.DISCONNECT: return t === void 0;
1279
- case H.EVENT: return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && _t.indexOf(t[0]) === -1);
1280
- case H.ACK: return Array.isArray(t);
1281
- case H.CONNECT_ERROR: return typeof t == "string" || U(t);
1286
+ case U.CONNECT: return t === void 0 || W(t);
1287
+ case U.DISCONNECT: return t === void 0;
1288
+ case U.EVENT: return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && _t.indexOf(t[0]) === -1);
1289
+ case U.ACK: return Array.isArray(t);
1290
+ case U.CONNECT_ERROR: return typeof t == "string" || W(t);
1282
1291
  default: return !1;
1283
1292
  }
1284
1293
  }
@@ -1286,7 +1295,7 @@ function Tt(e) {
1286
1295
  return xt(e.nsp) && Ct(e.id) && wt(e.type, e.data);
1287
1296
  }
1288
1297
  // ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/on.js
1289
- function W(e, t, n) {
1298
+ function G(e, t, n) {
1290
1299
  return e.on(t, n), function() {
1291
1300
  e.off(t, n);
1292
1301
  };
@@ -1299,7 +1308,7 @@ var Et = Object.freeze({
1299
1308
  disconnecting: 1,
1300
1309
  newListener: 1,
1301
1310
  removeListener: 1
1302
- }), Dt = class extends D {
1311
+ }), Dt = class extends O {
1303
1312
  constructor(e, t, n) {
1304
1313
  super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = e, this.nsp = t, n && n.auth && (this.auth = n.auth), this._opts = Object.assign({}, n), this.io._autoConnect && this.open();
1305
1314
  }
@@ -1310,10 +1319,10 @@ var Et = Object.freeze({
1310
1319
  if (this.subs) return;
1311
1320
  let e = this.io;
1312
1321
  this.subs = [
1313
- W(e, "open", this.onopen.bind(this)),
1314
- W(e, "packet", this.onpacket.bind(this)),
1315
- W(e, "error", this.onerror.bind(this)),
1316
- W(e, "close", this.onclose.bind(this))
1322
+ G(e, "open", this.onopen.bind(this)),
1323
+ G(e, "packet", this.onpacket.bind(this)),
1324
+ G(e, "error", this.onerror.bind(this)),
1325
+ G(e, "close", this.onclose.bind(this))
1317
1326
  ];
1318
1327
  }
1319
1328
  get active() {
@@ -1332,7 +1341,7 @@ var Et = Object.freeze({
1332
1341
  if (Et.hasOwnProperty(e)) throw Error("\"" + e.toString() + "\" is a reserved event name");
1333
1342
  if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile) return this._addToQueue(t), this;
1334
1343
  let n = {
1335
- type: H.EVENT,
1344
+ type: U.EVENT,
1336
1345
  data: t
1337
1346
  };
1338
1347
  if (n.options = {}, n.options.compress = this.flags.compress !== !1, typeof t[t.length - 1] == "function") {
@@ -1390,7 +1399,7 @@ var Et = Object.freeze({
1390
1399
  }
1391
1400
  _sendConnectPacket(e) {
1392
1401
  this.packet({
1393
- type: H.CONNECT,
1402
+ type: U.CONNECT,
1394
1403
  data: this._pid ? Object.assign({
1395
1404
  pid: this._pid,
1396
1405
  offset: this._lastOffset
@@ -1413,21 +1422,21 @@ var Et = Object.freeze({
1413
1422
  }
1414
1423
  onpacket(e) {
1415
1424
  if (e.nsp === this.nsp) switch (e.type) {
1416
- case H.CONNECT:
1425
+ case U.CONNECT:
1417
1426
  e.data && e.data.sid ? this.onconnect(e.data.sid, e.data.pid) : this.emitReserved("connect_error", /* @__PURE__ */ Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
1418
1427
  break;
1419
- case H.EVENT:
1420
- case H.BINARY_EVENT:
1428
+ case U.EVENT:
1429
+ case U.BINARY_EVENT:
1421
1430
  this.onevent(e);
1422
1431
  break;
1423
- case H.ACK:
1424
- case H.BINARY_ACK:
1432
+ case U.ACK:
1433
+ case U.BINARY_ACK:
1425
1434
  this.onack(e);
1426
1435
  break;
1427
- case H.DISCONNECT:
1436
+ case U.DISCONNECT:
1428
1437
  this.ondisconnect();
1429
1438
  break;
1430
- case H.CONNECT_ERROR:
1439
+ case U.CONNECT_ERROR:
1431
1440
  this.destroy();
1432
1441
  let t = Error(e.data.message);
1433
1442
  t.data = e.data.data, this.emitReserved("connect_error", t);
@@ -1448,7 +1457,7 @@ var Et = Object.freeze({
1448
1457
  let t = this, n = !1;
1449
1458
  return function(...r) {
1450
1459
  n || (n = !0, t.packet({
1451
- type: H.ACK,
1460
+ type: U.ACK,
1452
1461
  id: e,
1453
1462
  data: r
1454
1463
  }));
@@ -1473,7 +1482,7 @@ var Et = Object.freeze({
1473
1482
  this.subs &&= (this.subs.forEach((e) => e()), void 0), this.io._destroy(this);
1474
1483
  }
1475
1484
  disconnect() {
1476
- return this.connected && this.packet({ type: H.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
1485
+ return this.connected && this.packet({ type: U.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
1477
1486
  }
1478
1487
  close() {
1479
1488
  return this.disconnect();
@@ -1529,29 +1538,29 @@ var Et = Object.freeze({
1529
1538
  }
1530
1539
  };
1531
1540
  // ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/contrib/backo2.js
1532
- function G(e) {
1541
+ function K(e) {
1533
1542
  e ||= {}, this.ms = e.min || 100, this.max = e.max || 1e4, this.factor = e.factor || 2, this.jitter = e.jitter > 0 && e.jitter <= 1 ? e.jitter : 0, this.attempts = 0;
1534
1543
  }
1535
- G.prototype.duration = function() {
1544
+ K.prototype.duration = function() {
1536
1545
  var e = this.ms * this.factor ** +this.attempts++;
1537
1546
  if (this.jitter) {
1538
1547
  var t = Math.random(), n = Math.floor(t * this.jitter * e);
1539
1548
  e = Math.floor(t * 10) & 1 ? e + n : e - n;
1540
1549
  }
1541
1550
  return Math.min(e, this.max) | 0;
1542
- }, G.prototype.reset = function() {
1551
+ }, K.prototype.reset = function() {
1543
1552
  this.attempts = 0;
1544
- }, G.prototype.setMin = function(e) {
1553
+ }, K.prototype.setMin = function(e) {
1545
1554
  this.ms = e;
1546
- }, G.prototype.setMax = function(e) {
1555
+ }, K.prototype.setMax = function(e) {
1547
1556
  this.max = e;
1548
- }, G.prototype.setJitter = function(e) {
1557
+ }, K.prototype.setJitter = function(e) {
1549
1558
  this.jitter = e;
1550
1559
  };
1551
1560
  // ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/manager.js
1552
- var K = class extends D {
1561
+ var q = class extends O {
1553
1562
  constructor(e, t) {
1554
- super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t, A(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || Infinity), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor(t.randomizationFactor ?? .5), this.backoff = new G({
1563
+ super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t, j(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || Infinity), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor(t.randomizationFactor ?? .5), this.backoff = new K({
1555
1564
  min: this.reconnectionDelay(),
1556
1565
  max: this.reconnectionDelayMax(),
1557
1566
  jitter: this.randomizationFactor()
@@ -1588,11 +1597,11 @@ var K = class extends D {
1588
1597
  this.engine = new st(this.uri, this.opts);
1589
1598
  let t = this.engine, n = this;
1590
1599
  this._readyState = "opening", this.skipReconnect = !1;
1591
- let r = W(t, "open", function() {
1600
+ let r = G(t, "open", function() {
1592
1601
  n.onopen(), e && e();
1593
1602
  }), i = (t) => {
1594
1603
  this.cleanup(), this._readyState = "closed", this.emitReserved("error", t), e ? e(t) : this.maybeReconnectOnOpen();
1595
- }, a = W(t, "error", i);
1604
+ }, a = G(t, "error", i);
1596
1605
  if (!1 !== this._timeout) {
1597
1606
  let e = this._timeout, n = this.setTimeoutFn(() => {
1598
1607
  r(), i(/* @__PURE__ */ Error("timeout")), t.close();
@@ -1609,7 +1618,7 @@ var K = class extends D {
1609
1618
  onopen() {
1610
1619
  this.cleanup(), this._readyState = "open", this.emitReserved("open");
1611
1620
  let e = this.engine;
1612
- this.subs.push(W(e, "ping", this.onping.bind(this)), W(e, "data", this.ondata.bind(this)), W(e, "error", this.onerror.bind(this)), W(e, "close", this.onclose.bind(this)), W(this.decoder, "decoded", this.ondecoded.bind(this)));
1621
+ this.subs.push(G(e, "ping", this.onping.bind(this)), G(e, "data", this.ondata.bind(this)), G(e, "error", this.onerror.bind(this)), G(e, "close", this.onclose.bind(this)), G(this.decoder, "decoded", this.ondecoded.bind(this)));
1613
1622
  }
1614
1623
  onping() {
1615
1624
  this.emitReserved("ping");
@@ -1622,7 +1631,7 @@ var K = class extends D {
1622
1631
  }
1623
1632
  }
1624
1633
  ondecoded(e) {
1625
- O(() => {
1634
+ k(() => {
1626
1635
  this.emitReserved("packet", e);
1627
1636
  }, this.setTimeoutFn);
1628
1637
  }
@@ -1676,17 +1685,17 @@ var K = class extends D {
1676
1685
  let e = this.backoff.attempts;
1677
1686
  this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", e);
1678
1687
  }
1679
- }, q = {};
1680
- function J(e, t) {
1688
+ }, J = {};
1689
+ function Y(e, t) {
1681
1690
  typeof e == "object" && (t = e, e = void 0), t ||= {};
1682
- let n = ct(e, t.path || "/socket.io"), r = n.source, i = n.id, a = n.path, o = q[i] && a in q[i].nsps, s = t.forceNew || t["force new connection"] || !1 === t.multiplex || o, c;
1683
- return s ? c = new K(r, t) : (q[i] || (q[i] = new K(r, t)), c = q[i]), n.query && !t.query && (t.query = n.queryKey), c.socket(n.path, t);
1691
+ let n = ct(e, t.path || "/socket.io"), r = n.source, i = n.id, a = n.path, o = J[i] && a in J[i].nsps, s = t.forceNew || t["force new connection"] || !1 === t.multiplex || o, c;
1692
+ return s ? c = new q(r, t) : (J[i] || (J[i] = new q(r, t)), c = J[i]), n.query && !t.query && (t.query = n.queryKey), c.socket(n.path, t);
1684
1693
  }
1685
- Object.assign(J, {
1686
- Manager: K,
1694
+ Object.assign(Y, {
1695
+ Manager: q,
1687
1696
  Socket: Dt,
1688
- io: J,
1689
- connect: J
1697
+ io: Y,
1698
+ connect: Y
1690
1699
  });
1691
1700
  // src/sdk-socket.ts
1692
1701
  function Ot(e) {
@@ -1707,7 +1716,7 @@ var kt = class {
1707
1716
  connect(e) {
1708
1717
  this.disconnect();
1709
1718
  let t = Ot(e.baseUrl);
1710
- this.socket = J(t, {
1719
+ this.socket = Y(t, {
1711
1720
  auth: {
1712
1721
  apiKey: e.apiKey,
1713
1722
  visitorToken: e.visitorToken
@@ -1730,54 +1739,54 @@ var kt = class {
1730
1739
  disconnect() {
1731
1740
  this.socket &&= (this.socket.removeAllListeners(), this.socket.disconnect(), null);
1732
1741
  }
1733
- }, Y = "onedeskpro_visitor_token";
1734
- function At(e) {
1742
+ }, At = "onedeskpro_visitor_token";
1743
+ function jt(e) {
1735
1744
  try {
1736
1745
  return typeof window < "u" ? window.localStorage.getItem(e) : null;
1737
1746
  } catch {
1738
1747
  return null;
1739
1748
  }
1740
1749
  }
1741
- function jt(e, t) {
1750
+ function Mt(e, t) {
1742
1751
  try {
1743
1752
  typeof window < "u" && window.localStorage.setItem(e, t);
1744
1753
  } catch {}
1745
1754
  }
1746
- function Mt(e) {
1755
+ function Nt(e) {
1747
1756
  try {
1748
1757
  typeof window < "u" && window.localStorage.removeItem(e);
1749
1758
  } catch {}
1750
1759
  }
1751
- var Nt = class {
1760
+ var Pt = class {
1752
1761
  constructor() {
1753
- this.token = null, this.storageKey = Y;
1762
+ this.token = null, this.storageKey = At;
1754
1763
  }
1755
1764
  setScope(e) {
1756
- this.storageKey = e?.trim() ? `${Y}:${e.trim()}` : Y, this.token = At(this.storageKey);
1765
+ this.storageKey = e?.trim() ? `${At}:${e.trim()}` : At, this.token = jt(this.storageKey);
1757
1766
  }
1758
1767
  get() {
1759
- return this.token ?? At(this.storageKey);
1768
+ return this.token ?? jt(this.storageKey);
1760
1769
  }
1761
1770
  set(e) {
1762
- this.token = e, jt(this.storageKey, e);
1771
+ this.token = e, Mt(this.storageKey, e);
1763
1772
  }
1764
1773
  clear() {
1765
- this.token = null, Mt(this.storageKey);
1774
+ this.token = null, Nt(this.storageKey);
1766
1775
  }
1767
- }, Pt = 300, Ft = 250, It = 100, Lt = [
1776
+ }, Ft = 300, It = 250, Lt = 100, Rt = [
1768
1777
  "audio/webm;codecs=opus",
1769
1778
  "audio/webm",
1770
1779
  "audio/mp4",
1771
1780
  "audio/ogg;codecs=opus"
1772
1781
  ];
1773
- function Rt() {
1774
- return typeof MediaRecorder > "u" || typeof MediaRecorder.isTypeSupported != "function" ? "audio/webm" : Lt.find((e) => MediaRecorder.isTypeSupported(e)) ?? "audio/webm";
1782
+ function zt() {
1783
+ return typeof MediaRecorder > "u" || typeof MediaRecorder.isTypeSupported != "function" ? "audio/webm" : Rt.find((e) => MediaRecorder.isTypeSupported(e)) ?? "audio/webm";
1775
1784
  }
1776
- function zt(e) {
1785
+ function Bt(e) {
1777
1786
  let t = e instanceof DOMException ? e.name : "";
1778
1787
  return t === "NotAllowedError" || t === "PermissionDeniedError" || t === "SecurityError" ? "Microphone access was denied." : t === "NotFoundError" || t === "DevicesNotFoundError" ? "No microphone was found." : "Could not start recording.";
1779
1788
  }
1780
- var Bt = class e {
1789
+ var Vt = class e {
1781
1790
  constructor(e, t = 300) {
1782
1791
  this.onChange = e, this.maxDurationSeconds = t, this.recorder = null, this.stream = null, this.chunks = [], this.mimeType = "audio/webm", this.startedAt = 0, this.tickTimer = null, this.levelTimer = null, this.maxTimer = null, this.audioContext = null, this.analyser = null, this.snapshot = {
1783
1792
  state: "idle",
@@ -1799,20 +1808,20 @@ var Bt = class e {
1799
1808
  try {
1800
1809
  t = await navigator.mediaDevices.getUserMedia({ audio: !0 });
1801
1810
  } catch (e) {
1802
- throw Error(zt(e));
1811
+ throw Error(Bt(e));
1803
1812
  }
1804
1813
  try {
1805
- this.mimeType = Rt();
1814
+ this.mimeType = zt();
1806
1815
  let e = new MediaRecorder(t, { mimeType: this.mimeType });
1807
1816
  e.ondataavailable = (e) => {
1808
1817
  e.data.size > 0 && this.chunks.push(e.data);
1809
1818
  }, this.stream = t, this.recorder = e, this.startedAt = Date.now(), e.start(200);
1810
1819
  } catch (e) {
1811
- throw t.getTracks().forEach((e) => e.stop()), this.stream = null, this.recorder = null, Error(zt(e));
1820
+ throw t.getTracks().forEach((e) => e.stop()), this.stream = null, this.recorder = null, Error(Bt(e));
1812
1821
  }
1813
1822
  this.startLevelMeter(t), this.tickTimer = setInterval(() => {
1814
1823
  this.update({ elapsedSeconds: Math.floor(this.elapsedMs() / 1e3) });
1815
- }, Ft), this.maxTimer = setTimeout(() => void this.stop(), this.maxDurationSeconds * 1e3), this.update({
1824
+ }, It), this.maxTimer = setTimeout(() => void this.stop(), this.maxDurationSeconds * 1e3), this.update({
1816
1825
  state: "recording",
1817
1826
  elapsedSeconds: 0,
1818
1827
  level: 0,
@@ -1887,7 +1896,7 @@ var Bt = class e {
1887
1896
  e += n * n;
1888
1897
  }
1889
1898
  this.update({ level: Math.min(1, Math.sqrt(e / i.length) * 3.2) });
1890
- }, It);
1899
+ }, Lt);
1891
1900
  } catch {}
1892
1901
  }
1893
1902
  clearTimers() {
@@ -1905,7 +1914,7 @@ var Bt = class e {
1905
1914
  }
1906
1915
  this.chunks = [], this.releaseMedia();
1907
1916
  }
1908
- }, X = [
1917
+ }, Ht = [
1909
1918
  {
1910
1919
  iso: "BD",
1911
1920
  name: "Bangladesh",
@@ -2272,8 +2281,8 @@ var Bt = class e {
2272
2281
  dial: "977",
2273
2282
  flag: "🇳🇵"
2274
2283
  }
2275
- ], Vt = X.find((e) => e.iso === "BD") ?? X[0];
2276
- function Ht(e, t) {
2284
+ ], Ut = Ht.find((e) => e.iso === "BD") ?? Ht[0];
2285
+ function Wt(e, t) {
2277
2286
  let n = t.trim();
2278
2287
  if (n.startsWith("+")) {
2279
2288
  let e = n.replace(/\D/g, "");
@@ -2283,8 +2292,8 @@ function Ht(e, t) {
2283
2292
  return !r || (r = r.replace(/^0+/, ""), !r) ? "" : `+${e}${r}`;
2284
2293
  }
2285
2294
  // src/widget/styles.ts
2286
- var Ut = "(max-width: 640px), (max-height: 500px) and (pointer: coarse)";
2287
- function Wt(e, t) {
2295
+ var Gt = "(max-width: 640px), (max-height: 500px) and (pointer: coarse)";
2296
+ function Kt(e, t) {
2288
2297
  let n = `
2289
2298
  --ttcb-bg: #ffffff;
2290
2299
  --ttcb-bg-secondary: #f3f4f6;
@@ -2950,7 +2959,7 @@ function Wt(e, t) {
2950
2959
 
2951
2960
  .ttcb-footer.hidden, .ttcb-messages.hidden { display: none; }
2952
2961
 
2953
- @media ${Ut} {
2962
+ @media ${Gt} {
2954
2963
  .ttcb-fab.bottom-right { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
2955
2964
  .ttcb-fab.bottom-left { left: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
2956
2965
  /* The open panel covers the launcher; its own close button takes over. */
@@ -3017,18 +3026,18 @@ function Wt(e, t) {
3017
3026
  `;
3018
3027
  }
3019
3028
  // src/widget/render.ts
3020
- function Gt(e) {
3029
+ function qt(e) {
3021
3030
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3022
3031
  }
3023
- function Kt(e) {
3032
+ function Jt(e) {
3024
3033
  let t = [], n = e.replace(/```[\w]*\n?([\s\S]*?)```/g, (e, n) => {
3025
3034
  let r = t.length;
3026
- return t.push(`<pre><code>${Gt(n.trim())}</code></pre>`), `\x04${r}\x05`;
3035
+ return t.push(`<pre><code>${qt(n.trim())}</code></pre>`), `\x04${r}\x05`;
3027
3036
  });
3028
3037
  n = n.replace(/`([^`\n]+)`/g, (e, n) => {
3029
3038
  let r = t.length;
3030
- return t.push(`<code>${Gt(n)}</code>`), `\x02${r}\x03`;
3031
- }), n = Gt(n);
3039
+ return t.push(`<code>${qt(n)}</code>`), `\x02${r}\x03`;
3040
+ }), n = qt(n);
3032
3041
  let r = n.split("\n"), i = [], a = "", o = () => {
3033
3042
  a &&= (i.push(`</${a}>`), "");
3034
3043
  };
@@ -3045,71 +3054,71 @@ function Kt(e) {
3045
3054
  }).join("") : "";
3046
3055
  }).filter(Boolean).join(""), n = n.replace(/\x04(\d+)\x05/g, (e, n) => t[+n] ?? "").replace(/\x02(\d+)\x03/g, (e, n) => t[+n] ?? ""), n;
3047
3056
  }
3048
- function qt() {
3057
+ function Yt() {
3049
3058
  return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"/>\n <line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"14\"/>\n <line x1=\"9\" y1=\"11\" x2=\"15\" y2=\"11\"/>\n </svg>";
3050
3059
  }
3051
- function Jt() {
3060
+ function Xt() {
3052
3061
  return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20 2H4C2.9 2 2 2.9 2 4v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z\"/>\n </svg>";
3053
3062
  }
3054
- function Yt() {
3063
+ function Zt() {
3055
3064
  return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\"/>\n </svg>";
3056
3065
  }
3057
- function Xt() {
3066
+ function Qt() {
3058
3067
  return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z\"/>\n </svg>";
3059
3068
  }
3060
- function Z() {
3069
+ function X() {
3061
3070
  return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20 9V7c0-1.1-.9-2-2-2h-3c0-1.66-1.34-3-3-3S9 3.34 9 5H6c-1.1 0-2 .9-2 2v2c-1.66 0-3 1.34-3 3s1.34 3 3 3v4c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-4c1.66 0 3-1.34 3-3s-1.34-3-3-3zm-2 10H6V7h12v12zm-9-6c-.83 0-1.5-.67-1.5-1.5S8.17 10 9 10s1.5.67 1.5 1.5S9.83 13 9 13zm6 0c-.83 0-1.5-.67-1.5-1.5S14.17 10 15 10s1.5.67 1.5 1.5S15.83 13 15 13z\"/>\n </svg>";
3062
3071
  }
3063
- function Zt() {
3072
+ function $t() {
3064
3073
  return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\"/>\n </svg>";
3065
3074
  }
3066
- function Qt() {
3075
+ function en() {
3067
3076
  return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2\"/>\n <circle cx=\"12\" cy=\"7\" r=\"4\"/>\n </svg>";
3068
3077
  }
3069
- function $t() {
3078
+ function tn() {
3070
3079
  return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z\"/>\n <polyline points=\"22,6 12,13 2,6\"/>\n </svg>";
3071
3080
  }
3072
- function en() {
3081
+ function nn() {
3073
3082
  return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <polyline points=\"6 9 12 15 18 9\"/>\n </svg>";
3074
3083
  }
3075
- function tn() {
3084
+ function rn() {
3076
3085
  return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/>\n <polyline points=\"12 5 19 12 12 19\"/>\n </svg>";
3077
3086
  }
3078
- function nn() {
3087
+ function an() {
3079
3088
  return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z\"/>\n <polyline points=\"9 12 11 14 15 10\"/>\n </svg>";
3080
3089
  }
3081
- function rn() {
3090
+ function on() {
3082
3091
  return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12\" cy=\"12\" r=\"10\" fill=\"currentColor\"/>\n <path d=\"M9 12l2 2 4-4\" fill=\"none\" stroke=\"#fff\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>";
3083
3092
  }
3084
- function an() {
3093
+ function sn() {
3085
3094
  return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path fill=\"#F59E0B\" d=\"M8 2.5l1.1 2.2 2.4.3-1.7 1.7.4 2.4L8 8l-2.2 1.1.4-2.4L4.5 5l2.4-.3L8 2.5z\"/>\n <path fill=\"#F59E0B\" d=\"M16 3.5l.8 1.6 1.8.2-1.3 1.3.3 1.8L16 7.5l-1.6.9.3-1.8-1.3-1.3 1.8-.2L16 3.5z\"/>\n <path fill=\"#FBBF24\" d=\"M12 11.5l1 2 2.2.3-1.6 1.6.4 2.2-2-1.1-2 1.1.4-2.2-1.6-1.6 2.2-.3 1-2z\"/>\n </svg>";
3086
3095
  }
3087
- function on() {
3096
+ function cn() {
3088
3097
  return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2\"/>\n <circle cx=\"9\" cy=\"7\" r=\"4\"/>\n <path d=\"M23 21v-2a4 4 0 0 0-3-3.87\"/>\n <path d=\"M16 3.13a4 4 0 0 1 0 7.75\"/>\n </svg>";
3089
3098
  }
3090
- function sn() {
3099
+ function ln() {
3091
3100
  return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"/>\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/>\n </svg>";
3092
3101
  }
3093
- function cn() {
3102
+ function un() {
3094
3103
  return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48\"/>\n </svg>";
3095
3104
  }
3096
- function ln() {
3105
+ function dn() {
3097
3106
  return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"/>\n <circle cx=\"8.5\" cy=\"8.5\" r=\"1.5\"/>\n <polyline points=\"21 15 16 10 5 21\"/>\n </svg>";
3098
3107
  }
3099
- function un() {
3108
+ function fn() {
3100
3109
  return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z\"/>\n <path d=\"M19 10v2a7 7 0 0 1-14 0v-2\"/>\n <line x1=\"12\" y1=\"19\" x2=\"12\" y2=\"23\"/>\n <line x1=\"8\" y1=\"23\" x2=\"16\" y2=\"23\"/>\n </svg>";
3101
3110
  }
3102
- function dn() {
3111
+ function pn() {
3103
3112
  return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"6\" y=\"6\" width=\"12\" height=\"12\" rx=\"2\" fill=\"currentColor\"/>\n </svg>";
3104
3113
  }
3105
- function fn() {
3114
+ function mn() {
3106
3115
  return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <polyline points=\"3 6 5 6 21 6\"/>\n <path d=\"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6\"/>\n <path d=\"M10 11v6\"/>\n <path d=\"M14 11v6\"/>\n <path d=\"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2\"/>\n </svg>";
3107
3116
  }
3108
- function pn() {
3117
+ function hn() {
3109
3118
  return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\"/>\n <polyline points=\"14 2 14 8 20 8\"/>\n </svg>";
3110
3119
  }
3111
- function mn(e) {
3112
- let t = m(e.url) ? e.url : "", n = e.type.toLowerCase();
3120
+ function gn(e) {
3121
+ let t = ee(e.url) ? e.url : "", n = e.type.toLowerCase();
3113
3122
  if (t && n.startsWith("image/")) {
3114
3123
  let n = document.createElement("a");
3115
3124
  n.className = "ttcb-attachment ttcb-attachment-image", n.href = t, n.target = "_blank", n.rel = "noopener noreferrer", n.setAttribute("aria-label", `Open ${e.fileName}`);
@@ -3133,23 +3142,23 @@ function mn(e) {
3133
3142
  let r = document.createElement(t ? "a" : "div");
3134
3143
  r.className = "ttcb-attachment ttcb-attachment-file", r instanceof HTMLAnchorElement && (r.href = t, r.target = "_blank", r.rel = "noopener noreferrer");
3135
3144
  let i = document.createElement("span");
3136
- i.className = "ttcb-attachment-icon", i.setAttribute("aria-hidden", "true"), i.innerHTML = pn();
3145
+ i.className = "ttcb-attachment-icon", i.setAttribute("aria-hidden", "true"), i.innerHTML = hn();
3137
3146
  let a = document.createElement("span");
3138
3147
  a.className = "ttcb-attachment-meta";
3139
3148
  let o = document.createElement("span");
3140
3149
  o.className = "ttcb-attachment-name", o.textContent = e.fileName, a.appendChild(o);
3141
- let s = te(e.size);
3150
+ let s = ne(e.size);
3142
3151
  if (s) {
3143
3152
  let e = document.createElement("span");
3144
3153
  e.className = "ttcb-attachment-size", e.textContent = s, a.appendChild(e);
3145
3154
  }
3146
3155
  return r.appendChild(i), r.appendChild(a), r;
3147
3156
  }
3148
- function hn(e) {
3157
+ function _n(e) {
3149
3158
  let { type: t, content: n } = e, r = e.attachments ?? [], i = document.createElement("div");
3150
3159
  i.className = `ttcb-msg ${t}`, e.pending && i.classList.add("ttcb-pending");
3151
3160
  let a = document.createElement("div");
3152
- a.className = "ttcb-msg-avatar", a.innerHTML = t === "human" ? Zt() : t === "agent" ? Qt() : Z();
3161
+ a.className = "ttcb-msg-avatar", a.innerHTML = t === "human" ? $t() : t === "agent" ? en() : X();
3153
3162
  let o = document.createElement("div");
3154
3163
  if (o.className = "ttcb-msg-body", t === "agent") {
3155
3164
  let e = document.createElement("span");
@@ -3158,12 +3167,12 @@ function hn(e) {
3158
3167
  if (r.length > 0) {
3159
3168
  let e = document.createElement("div");
3160
3169
  e.className = "ttcb-attachments";
3161
- for (let t of r) e.appendChild(mn(t));
3170
+ for (let t of r) e.appendChild(gn(t));
3162
3171
  o.appendChild(e);
3163
3172
  }
3164
- if (r.length === 0 || !re(n, r)) {
3173
+ if (r.length === 0 || !ie(n, r)) {
3165
3174
  let e = document.createElement("div");
3166
- e.className = "ttcb-bubble", t === "human" ? e.textContent = n : e.innerHTML = Kt(n), o.appendChild(e);
3175
+ e.className = "ttcb-bubble", t === "human" ? e.textContent = n : e.innerHTML = Jt(n), o.appendChild(e);
3167
3176
  }
3168
3177
  if (e.pending) {
3169
3178
  let e = document.createElement("span");
@@ -3171,29 +3180,29 @@ function hn(e) {
3171
3180
  }
3172
3181
  return i.appendChild(a), i.appendChild(o), i;
3173
3182
  }
3174
- function gn() {
3183
+ function vn() {
3175
3184
  let e = document.createElement("div");
3176
3185
  e.className = "ttcb-msg ai", e.id = "ttcb-typing";
3177
3186
  let t = document.createElement("div");
3178
- t.className = "ttcb-msg-avatar", t.innerHTML = Z();
3187
+ t.className = "ttcb-msg-avatar", t.innerHTML = X();
3179
3188
  let n = document.createElement("div");
3180
3189
  return n.className = "ttcb-typing", n.innerHTML = "<span></span><span></span><span></span>", e.appendChild(t), e.appendChild(n), e;
3181
3190
  }
3182
3191
  // src/widget/widget.ts
3183
- var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mpeg,audio/wav,audio/x-m4a,audio/aac,audio/opus,application/pdf,text/csv", vn = "image/jpeg,image/png,image/gif", yn = class {
3192
+ var yn = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mpeg,audio/wav,audio/x-m4a,audio/aac,audio/opus,application/pdf,text/csv", bn = "image/jpeg,image/png,image/gif", xn = class {
3184
3193
  constructor(e, t) {
3185
- this.stopViewportSync = null, this.confirmingNew = !1, this.actionPending = !1, this.ticketMode = "ai", this.pendingFiles = [], this.attachMenuOpen = !1, this.recorder = null, this.voicePreviewUrl = "", this.selectedCountry = Vt, this.countryOpen = !1, this.isOpen = !1, this.destroyed = !1, this.position = e.position ?? "bottom-right", this.callbacks = t, this.autoOpen = e.autoOpen === !0, this.mount(e);
3194
+ this.stopViewportSync = null, this.confirmingNew = !1, this.actionPending = !1, this.ticketMode = "ai", this.pendingFiles = [], this.attachMenuOpen = !1, this.recorder = null, this.voicePreviewUrl = "", this.selectedCountry = Ut, this.countryOpen = !1, this.isOpen = !1, this.destroyed = !1, this.position = e.position ?? "bottom-right", this.callbacks = t, this.autoOpen = e.autoOpen === !0, this.mount(e);
3186
3195
  }
3187
3196
  mount(e) {
3188
3197
  this.host = document.createElement("div"), this.host.id = "onedeskpro-chatbot-host", this.host.style.display = "none", this.shadow = this.host.attachShadow({ mode: "closed" });
3189
3198
  let t = document.createElement("style");
3190
- t.textContent = Wt(e.primaryColor ?? "#2563EB", e.theme ?? "auto"), this.shadow.appendChild(t), this.fab = document.createElement("button"), this.fab.className = `ttcb-fab ${this.position}`, this.fab.setAttribute("aria-label", "Open chat"), this.fab.innerHTML = Jt(), this.fab.addEventListener("click", () => this.toggle()), this.shadow.appendChild(this.fab), this.panel = document.createElement("div"), this.panel.className = `ttcb-panel ${this.position} hidden ttcb-mode-compact`, this.panel.tabIndex = -1, this.panel.setAttribute("role", "dialog"), this.panel.setAttribute("aria-modal", "true"), this.panel.setAttribute("aria-label", e.chatbotName ?? "AI Assistant"), this.panel.appendChild(this.buildHeader(e)), this.identifyContainer = document.createElement("div"), this.identifyContainer.className = "ttcb-identify", this.buildIdentifyForm(this.identifyContainer), this.panel.appendChild(this.identifyContainer), this.messagesContainer = document.createElement("div"), this.messagesContainer.className = "ttcb-messages", this.messagesContainer.setAttribute("aria-live", "polite"), this.messagesContainer.setAttribute("aria-label", "Chat messages"), this.panel.appendChild(this.messagesContainer), this.modeBanner = document.createElement("div"), this.modeBanner.className = "ttcb-mode-banner", this.modeBannerText = document.createElement("span"), this.modeBannerText.className = "ttcb-mode-banner-text", this.modeBannerText.setAttribute("role", "status"), this.cancelHumanBtn = this.buildBannerButton("Cancel request", () => {
3199
+ t.textContent = Kt(e.primaryColor ?? "#2563EB", e.theme ?? "auto"), this.shadow.appendChild(t), this.fab = document.createElement("button"), this.fab.className = `ttcb-fab ${this.position}`, this.fab.setAttribute("aria-label", "Open chat"), this.fab.innerHTML = Xt(), this.fab.addEventListener("click", () => this.toggle()), this.shadow.appendChild(this.fab), this.panel = document.createElement("div"), this.panel.className = `ttcb-panel ${this.position} hidden ttcb-mode-compact`, this.panel.tabIndex = -1, this.panel.setAttribute("role", "dialog"), this.panel.setAttribute("aria-modal", "true"), this.panel.setAttribute("aria-label", e.chatbotName ?? "AI Assistant"), this.panel.appendChild(this.buildHeader(e)), this.identifyContainer = document.createElement("div"), this.identifyContainer.className = "ttcb-identify", this.buildIdentifyForm(this.identifyContainer), this.panel.appendChild(this.identifyContainer), this.messagesContainer = document.createElement("div"), this.messagesContainer.className = "ttcb-messages", this.messagesContainer.setAttribute("aria-live", "polite"), this.messagesContainer.setAttribute("aria-label", "Chat messages"), this.panel.appendChild(this.messagesContainer), this.modeBanner = document.createElement("div"), this.modeBanner.className = "ttcb-mode-banner", this.modeBannerText = document.createElement("span"), this.modeBannerText.className = "ttcb-mode-banner-text", this.modeBannerText.setAttribute("role", "status"), this.cancelHumanBtn = this.buildBannerButton("Cancel request", () => {
3191
3200
  this.actionPending || this.callbacks.onCancelHumanRequest();
3192
3201
  }), this.cancelHumanBtn.classList.add("hidden"), this.modeBanner.appendChild(this.modeBannerText), this.modeBanner.appendChild(this.cancelHumanBtn), this.panel.appendChild(this.modeBanner), this.panel.appendChild(this.buildConfirmNewBar()), this.footer = document.createElement("div"), this.footer.className = "ttcb-footer", this.pendingTray = document.createElement("div"), this.pendingTray.className = "ttcb-pending-tray", this.pendingTray.setAttribute("role", "list"), this.pendingTray.setAttribute("aria-label", "Files to send"), this.footer.appendChild(this.pendingTray), this.composeError = document.createElement("p"), this.composeError.className = "ttcb-compose-error", this.composeError.setAttribute("role", "alert"), this.footer.appendChild(this.composeError), this.footer.appendChild(this.buildVoiceBar()), this.footer.appendChild(this.buildVoicePreview());
3193
3202
  let n = document.createElement("form");
3194
3203
  n.className = "ttcb-form", n.addEventListener("submit", (e) => {
3195
3204
  e.preventDefault(), this.handleSend();
3196
- }), this.composeForm = n, n.appendChild(this.buildAttachControls()), this.input = document.createElement("input"), this.input.type = "text", this.input.className = "ttcb-input", this.input.placeholder = e.placeholder ?? "Type your message…", this.input.setAttribute("aria-label", "Message input"), this.input.setAttribute("autocomplete", "off"), this.sendBtn = document.createElement("button"), this.sendBtn.type = "submit", this.sendBtn.className = "ttcb-send-btn", this.sendBtn.innerHTML = Xt(), this.sendBtn.setAttribute("aria-label", "Send message"), this.micBtn = document.createElement("button"), this.micBtn.type = "button", this.micBtn.className = "ttcb-mic-btn", this.micBtn.setAttribute("aria-label", "Record voice message"), this.micBtn.title = "Record voice message", this.micBtn.innerHTML = un(), this.micBtn.addEventListener("click", () => void this.startVoice()), n.appendChild(this.input), n.appendChild(this.micBtn), n.appendChild(this.sendBtn), this.footer.appendChild(n), this.panel.appendChild(this.footer), this.shadow.appendChild(this.panel), this.shadow.addEventListener("click", (e) => {
3205
+ }), this.composeForm = n, n.appendChild(this.buildAttachControls()), this.input = document.createElement("input"), this.input.type = "text", this.input.className = "ttcb-input", this.input.placeholder = e.placeholder ?? "Type your message…", this.input.setAttribute("aria-label", "Message input"), this.input.setAttribute("autocomplete", "off"), this.sendBtn = document.createElement("button"), this.sendBtn.type = "submit", this.sendBtn.className = "ttcb-send-btn", this.sendBtn.innerHTML = Qt(), this.sendBtn.setAttribute("aria-label", "Send message"), this.micBtn = document.createElement("button"), this.micBtn.type = "button", this.micBtn.className = "ttcb-mic-btn", this.micBtn.setAttribute("aria-label", "Record voice message"), this.micBtn.title = "Record voice message", this.micBtn.innerHTML = fn(), this.micBtn.addEventListener("click", () => void this.startVoice()), n.appendChild(this.input), n.appendChild(this.micBtn), n.appendChild(this.sendBtn), this.footer.appendChild(n), this.panel.appendChild(this.footer), this.shadow.appendChild(this.panel), this.shadow.addEventListener("click", (e) => {
3197
3206
  let t = e.target;
3198
3207
  this.attachMenuOpen && !(t && (this.attachBtn.contains(t) || this.attachMenu.contains(t))) && this.closeAttachMenu(), this.countryOpen && (t && (this.dialBtn.contains(t) || this.countryPopover.contains(t)) || this.closeCountryPopover());
3199
3208
  }), this.panel.addEventListener("keydown", (e) => {
@@ -3209,13 +3218,13 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3209
3218
  let n = document.createElement("div");
3210
3219
  n.className = "ttcb-avatar-wrap";
3211
3220
  let r = document.createElement("div");
3212
- r.className = "ttcb-avatar", r.innerHTML = Z(), n.appendChild(r);
3221
+ r.className = "ttcb-avatar", r.innerHTML = X(), n.appendChild(r);
3213
3222
  let i = document.createElement("div");
3214
3223
  i.className = "ttcb-header-main";
3215
3224
  let a = document.createElement("div");
3216
3225
  a.className = "ttcb-header-title-row", this.headerTitle = document.createElement("span"), this.headerTitle.className = "ttcb-header-title", this.headerTitle.textContent = e.chatbotName ?? "AI Assistant";
3217
3226
  let o = document.createElement("span");
3218
- o.className = "ttcb-verified", o.setAttribute("aria-label", "Verified"), o.innerHTML = rn(), a.appendChild(this.headerTitle), a.appendChild(o);
3227
+ o.className = "ttcb-verified", o.setAttribute("aria-label", "Verified"), o.innerHTML = on(), a.appendChild(this.headerTitle), a.appendChild(o);
3219
3228
  let s = document.createElement("div");
3220
3229
  s.className = "ttcb-header-meta";
3221
3230
  let c = document.createElement("span");
@@ -3223,13 +3232,13 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3223
3232
  let l = document.createElement("span");
3224
3233
  l.className = "ttcb-meta-sep", l.setAttribute("aria-hidden", "true");
3225
3234
  let u = document.createElement("span");
3226
- u.className = "ttcb-meta-replies", u.innerHTML = `${an()}<span>Replies instantly</span>`, s.appendChild(c), s.appendChild(l), s.appendChild(u), i.appendChild(a), i.appendChild(s);
3235
+ u.className = "ttcb-meta-replies", u.innerHTML = `${sn()}<span>Replies instantly</span>`, s.appendChild(c), s.appendChild(l), s.appendChild(u), i.appendChild(a), i.appendChild(s);
3227
3236
  let d = document.createElement("div");
3228
- d.className = "ttcb-header-actions", this.requestHumanBtn = document.createElement("button"), this.requestHumanBtn.type = "button", this.requestHumanBtn.className = "ttcb-request-human-btn hidden", this.requestHumanBtn.id = "ttcb-request-human-btn", this.requestHumanBtn.setAttribute("aria-label", "Request human agent"), this.requestHumanBtn.title = "Request human agent", this.requestHumanBtn.innerHTML = on(), this.requestHumanBtn.addEventListener("click", () => this.callbacks.onRequestHuman()), this.newSessionBtn = document.createElement("button"), this.newSessionBtn.type = "button", this.newSessionBtn.className = "ttcb-new-session-btn hidden", this.newSessionBtn.setAttribute("aria-label", "New conversation"), this.newSessionBtn.title = "New conversation", this.newSessionBtn.innerHTML = qt(), this.newSessionBtn.addEventListener("click", () => {
3237
+ d.className = "ttcb-header-actions", this.requestHumanBtn = document.createElement("button"), this.requestHumanBtn.type = "button", this.requestHumanBtn.className = "ttcb-request-human-btn hidden", this.requestHumanBtn.id = "ttcb-request-human-btn", this.requestHumanBtn.setAttribute("aria-label", "Request human agent"), this.requestHumanBtn.title = "Request human agent", this.requestHumanBtn.innerHTML = cn(), this.requestHumanBtn.addEventListener("click", () => this.callbacks.onRequestHuman()), this.newSessionBtn = document.createElement("button"), this.newSessionBtn.type = "button", this.newSessionBtn.className = "ttcb-new-session-btn hidden", this.newSessionBtn.setAttribute("aria-label", "New conversation"), this.newSessionBtn.title = "New conversation", this.newSessionBtn.innerHTML = Yt(), this.newSessionBtn.addEventListener("click", () => {
3229
3238
  this.actionPending || (this.ticketMode === "closed" ? this.callbacks.onNewConversation() : this.showConfirmNew());
3230
3239
  });
3231
3240
  let f = document.createElement("button");
3232
- return f.className = "ttcb-close-btn", f.setAttribute("aria-label", "Close chat"), f.innerHTML = Yt(), f.addEventListener("click", () => this.close()), d.appendChild(this.requestHumanBtn), d.appendChild(this.newSessionBtn), d.appendChild(f), t.appendChild(n), t.appendChild(i), t.appendChild(d), t;
3241
+ return f.className = "ttcb-close-btn", f.setAttribute("aria-label", "Close chat"), f.innerHTML = Zt(), f.addEventListener("click", () => this.close()), d.appendChild(this.requestHumanBtn), d.appendChild(this.newSessionBtn), d.appendChild(f), t.appendChild(n), t.appendChild(i), t.appendChild(d), t;
3233
3242
  }
3234
3243
  buildBannerButton(e, t) {
3235
3244
  let n = document.createElement("button");
@@ -3262,16 +3271,16 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3262
3271
  }
3263
3272
  buildAttachControls() {
3264
3273
  let e = document.createElement("div");
3265
- e.className = "ttcb-attach", this.attachBtn = document.createElement("button"), this.attachBtn.type = "button", this.attachBtn.className = "ttcb-attach-btn", this.attachBtn.setAttribute("aria-label", "Add attachment"), this.attachBtn.setAttribute("aria-haspopup", "menu"), this.attachBtn.setAttribute("aria-expanded", "false"), this.attachBtn.title = "Add attachment", this.attachBtn.innerHTML = sn(), this.attachBtn.addEventListener("click", (e) => {
3274
+ e.className = "ttcb-attach", this.attachBtn = document.createElement("button"), this.attachBtn.type = "button", this.attachBtn.className = "ttcb-attach-btn", this.attachBtn.setAttribute("aria-label", "Add attachment"), this.attachBtn.setAttribute("aria-haspopup", "menu"), this.attachBtn.setAttribute("aria-expanded", "false"), this.attachBtn.title = "Add attachment", this.attachBtn.innerHTML = ln(), this.attachBtn.addEventListener("click", (e) => {
3266
3275
  e.preventDefault(), e.stopPropagation(), this.toggleAttachMenu();
3267
- }), this.attachMenu = document.createElement("div"), this.attachMenu.className = "ttcb-attach-menu", this.attachMenu.setAttribute("role", "menu"), this.attachFileInput = this.createFileInput(_n, "Choose files"), this.attachPhotoInput = this.createFileInput(vn, "Choose photos");
3276
+ }), this.attachMenu = document.createElement("div"), this.attachMenu.className = "ttcb-attach-menu", this.attachMenu.setAttribute("role", "menu"), this.attachFileInput = this.createFileInput(yn, "Choose files"), this.attachPhotoInput = this.createFileInput(bn, "Choose photos");
3268
3277
  let t = [{
3269
3278
  label: "Attachment",
3270
- icon: cn(),
3279
+ icon: un(),
3271
3280
  input: this.attachFileInput
3272
3281
  }, {
3273
3282
  label: "Photo",
3274
- icon: ln(),
3283
+ icon: dn(),
3275
3284
  input: this.attachPhotoInput
3276
3285
  }];
3277
3286
  for (let e of t) {
@@ -3332,12 +3341,12 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3332
3341
  t.className = "ttcb-pending-thumb", t.src = e.previewUrl, t.alt = "", n.appendChild(t);
3333
3342
  } else {
3334
3343
  let e = document.createElement("span");
3335
- e.className = "ttcb-pending-icon", e.setAttribute("aria-hidden", "true"), e.innerHTML = pn(), n.appendChild(e);
3344
+ e.className = "ttcb-pending-icon", e.setAttribute("aria-hidden", "true"), e.innerHTML = hn(), n.appendChild(e);
3336
3345
  }
3337
3346
  let r = document.createElement("span");
3338
3347
  r.className = "ttcb-pending-name", r.textContent = e.file.name || "attachment", r.title = e.file.name, n.appendChild(r);
3339
3348
  let i = document.createElement("button");
3340
- i.type = "button", i.className = "ttcb-pending-remove", i.setAttribute("aria-label", `Remove ${e.file.name || "attachment"}`), i.innerHTML = Yt(), i.addEventListener("click", () => this.removePendingFile(t)), n.appendChild(i), this.pendingTray.appendChild(n);
3349
+ i.type = "button", i.className = "ttcb-pending-remove", i.setAttribute("aria-label", `Remove ${e.file.name || "attachment"}`), i.innerHTML = Zt(), i.addEventListener("click", () => this.removePendingFile(t)), n.appendChild(i), this.pendingTray.appendChild(n);
3341
3350
  });
3342
3351
  }
3343
3352
  buildVoiceBar() {
@@ -3345,10 +3354,10 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3345
3354
  let e = document.createElement("span");
3346
3355
  e.className = "ttcb-voice-dot", e.setAttribute("aria-hidden", "true"), this.voiceTime = document.createElement("span"), this.voiceTime.className = "ttcb-voice-time", this.voiceTime.setAttribute("role", "timer"), this.voiceTime.textContent = "0:00";
3347
3356
  let t = document.createElement("div");
3348
- return t.className = "ttcb-voice-meter", t.setAttribute("aria-hidden", "true"), this.voiceLevel = document.createElement("span"), this.voiceLevel.className = "ttcb-voice-level", t.appendChild(this.voiceLevel), this.voiceCancelBtn = this.createVoiceButton("Cancel recording", fn(), () => this.cancelVoice()), this.voiceStopBtn = this.createVoiceButton("Stop recording", dn(), () => void this.stopVoice()), this.voiceStopBtn.classList.add("primary"), this.voiceBar.appendChild(e), this.voiceBar.appendChild(this.voiceTime), this.voiceBar.appendChild(t), this.voiceBar.appendChild(this.voiceCancelBtn), this.voiceBar.appendChild(this.voiceStopBtn), this.voiceBar;
3357
+ return t.className = "ttcb-voice-meter", t.setAttribute("aria-hidden", "true"), this.voiceLevel = document.createElement("span"), this.voiceLevel.className = "ttcb-voice-level", t.appendChild(this.voiceLevel), this.voiceCancelBtn = this.createVoiceButton("Cancel recording", mn(), () => this.cancelVoice()), this.voiceStopBtn = this.createVoiceButton("Stop recording", pn(), () => void this.stopVoice()), this.voiceStopBtn.classList.add("primary"), this.voiceBar.appendChild(e), this.voiceBar.appendChild(this.voiceTime), this.voiceBar.appendChild(t), this.voiceBar.appendChild(this.voiceCancelBtn), this.voiceBar.appendChild(this.voiceStopBtn), this.voiceBar;
3349
3358
  }
3350
3359
  buildVoicePreview() {
3351
- return this.voicePreview = document.createElement("div"), this.voicePreview.className = "ttcb-voice-preview", this.voicePreview.setAttribute("role", "group"), this.voicePreview.setAttribute("aria-label", "Voice message preview"), this.voiceAudio = document.createElement("audio"), this.voiceAudio.className = "ttcb-voice-audio", this.voiceAudio.controls = !0, this.voiceAudio.preload = "metadata", this.voiceAudio.setAttribute("aria-label", "Recorded voice message"), this.voicePreviewTime = document.createElement("span"), this.voicePreviewTime.className = "ttcb-voice-time", this.voiceDiscardBtn = this.createVoiceButton("Discard voice message", fn(), () => this.cancelVoice()), this.voiceSendBtn = this.createVoiceButton("Send voice message", Xt(), () => this.sendVoice()), this.voiceSendBtn.classList.add("primary"), this.voicePreview.appendChild(this.voiceAudio), this.voicePreview.appendChild(this.voicePreviewTime), this.voicePreview.appendChild(this.voiceDiscardBtn), this.voicePreview.appendChild(this.voiceSendBtn), this.voicePreview;
3360
+ return this.voicePreview = document.createElement("div"), this.voicePreview.className = "ttcb-voice-preview", this.voicePreview.setAttribute("role", "group"), this.voicePreview.setAttribute("aria-label", "Voice message preview"), this.voiceAudio = document.createElement("audio"), this.voiceAudio.className = "ttcb-voice-audio", this.voiceAudio.controls = !0, this.voiceAudio.preload = "metadata", this.voiceAudio.setAttribute("aria-label", "Recorded voice message"), this.voicePreviewTime = document.createElement("span"), this.voicePreviewTime.className = "ttcb-voice-time", this.voiceDiscardBtn = this.createVoiceButton("Discard voice message", mn(), () => this.cancelVoice()), this.voiceSendBtn = this.createVoiceButton("Send voice message", Qt(), () => this.sendVoice()), this.voiceSendBtn.classList.add("primary"), this.voicePreview.appendChild(this.voiceAudio), this.voicePreview.appendChild(this.voicePreviewTime), this.voicePreview.appendChild(this.voiceDiscardBtn), this.voicePreview.appendChild(this.voiceSendBtn), this.voicePreview;
3352
3361
  }
3353
3362
  createVoiceButton(e, t, n) {
3354
3363
  let r = document.createElement("button");
@@ -3356,9 +3365,9 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3356
3365
  }
3357
3366
  async startVoice() {
3358
3367
  if (!this.micBtn.disabled) {
3359
- if (this.closeAttachMenu(), this.showComposeError(""), !Bt.isSupported()) this.showComposeError("Voice messages are not supported in this browser.");
3368
+ if (this.closeAttachMenu(), this.showComposeError(""), !Vt.isSupported()) this.showComposeError("Voice messages are not supported in this browser.");
3360
3369
  else {
3361
- this.recorder?.destroy(), this.recorder = new Bt((e) => this.renderVoice(e));
3370
+ this.recorder?.destroy(), this.recorder = new Vt((e) => this.renderVoice(e));
3362
3371
  try {
3363
3372
  await this.recorder.start();
3364
3373
  } catch (e) {
@@ -3410,7 +3419,7 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3410
3419
  placeholder: "Your name",
3411
3420
  type: "text",
3412
3421
  autocomplete: "name",
3413
- icon: Qt()
3422
+ icon: en()
3414
3423
  }), this.createPhoneField(t), this.emailInput = this.createIconField(t, {
3415
3424
  id: "email",
3416
3425
  label: "Email (optional)",
@@ -3419,10 +3428,10 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3419
3428
  placeholder: "Email (optional)",
3420
3429
  type: "email",
3421
3430
  autocomplete: "email",
3422
- icon: $t()
3423
- }), this.identifyError = document.createElement("p"), this.identifyError.className = "ttcb-identify-error", t.appendChild(this.identifyError), this.identifySubmit = document.createElement("button"), this.identifySubmit.type = "submit", this.identifySubmit.className = "ttcb-identify-submit", this.identifySubmit.innerHTML = `<span>Start Chatting</span>${tn()}`, t.appendChild(this.identifySubmit), e.appendChild(t);
3431
+ icon: tn()
3432
+ }), this.identifyError = document.createElement("p"), this.identifyError.className = "ttcb-identify-error", t.appendChild(this.identifyError), this.identifySubmit = document.createElement("button"), this.identifySubmit.type = "submit", this.identifySubmit.className = "ttcb-identify-submit", this.identifySubmit.innerHTML = `<span>Start Chatting</span>${rn()}`, t.appendChild(this.identifySubmit), e.appendChild(t);
3424
3433
  let n = document.createElement("div");
3425
- n.className = "ttcb-trust", n.innerHTML = `${nn()}<span>Encrypted connection • No spam, ever</span>`, e.appendChild(n);
3434
+ n.className = "ttcb-trust", n.innerHTML = `${an()}<span>Encrypted connection • No spam, ever</span>`, e.appendChild(n);
3426
3435
  }
3427
3436
  createIconField(e, t) {
3428
3437
  let n = document.createElement("div");
@@ -3452,7 +3461,7 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3452
3461
  let a = document.createElement("div");
3453
3462
  a.className = "ttcb-phone-row", a.id = "ttcb-phone-row", this.dialBtn = document.createElement("button"), this.dialBtn.type = "button", this.dialBtn.className = "ttcb-dial-btn", this.dialBtn.setAttribute("aria-label", "Select country code"), this.dialBtn.setAttribute("aria-haspopup", "listbox"), this.dialBtn.setAttribute("aria-expanded", "false"), this.dialFlag = document.createElement("span"), this.dialFlag.className = "ttcb-dial-flag", this.dialCode = document.createElement("span"), this.dialCode.className = "ttcb-dial-code", this.syncDialButton(), this.dialBtn.appendChild(this.dialFlag), this.dialBtn.appendChild(this.dialCode);
3454
3463
  let o = document.createElement("span");
3455
- o.setAttribute("aria-hidden", "true"), o.innerHTML = en(), this.dialBtn.appendChild(o), this.dialBtn.addEventListener("click", (e) => {
3464
+ o.setAttribute("aria-hidden", "true"), o.innerHTML = nn(), this.dialBtn.appendChild(o), this.dialBtn.addEventListener("click", (e) => {
3456
3465
  e.preventDefault(), e.stopPropagation(), this.toggleCountryPopover();
3457
3466
  }), this.phoneInput = document.createElement("input"), this.phoneInput.id = "ttcb-tel", this.phoneInput.name = "tel", this.phoneInput.type = "tel", this.phoneInput.className = "ttcb-phone-national", this.phoneInput.placeholder = "1712-345678", this.phoneInput.required = !0, this.phoneInput.autocomplete = "tel-national", this.phoneInput.setAttribute("inputmode", "tel"), a.appendChild(this.dialBtn), a.appendChild(this.phoneInput), this.countryPopover = document.createElement("div"), this.countryPopover.className = "ttcb-country-popover", this.countryPopover.setAttribute("role", "listbox"), this.countrySearch = document.createElement("input"), this.countrySearch.type = "search", this.countrySearch.className = "ttcb-country-search", this.countrySearch.placeholder = "Search country…", this.countrySearch.setAttribute("aria-label", "Search countries"), this.countrySearch.addEventListener("input", () => this.renderCountryList()), this.countryList = document.createElement("div"), this.countryList.className = "ttcb-country-list", this.countryPopover.appendChild(this.countrySearch), this.countryPopover.appendChild(this.countryList), this.renderCountryList(), t.appendChild(n), t.appendChild(a), t.appendChild(this.countryPopover), e.appendChild(t);
3458
3467
  }
@@ -3469,7 +3478,7 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3469
3478
  this.countryOpen = !1, this.countryPopover.classList.remove("open"), this.dialBtn.setAttribute("aria-expanded", "false");
3470
3479
  }
3471
3480
  renderCountryList() {
3472
- let e = this.countrySearch.value.trim().toLowerCase(), t = X.filter((t) => !e || t.name.toLowerCase().includes(e) || t.dial.includes(e) || t.iso.toLowerCase().includes(e) || `+${t.dial}`.includes(e));
3481
+ let e = this.countrySearch.value.trim().toLowerCase(), t = Ht.filter((t) => !e || t.name.toLowerCase().includes(e) || t.dial.includes(e) || t.iso.toLowerCase().includes(e) || `+${t.dial}`.includes(e));
3473
3482
  this.countryList.innerHTML = "";
3474
3483
  for (let e of t) {
3475
3484
  let t = document.createElement("button");
@@ -3501,7 +3510,7 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3501
3510
  let t = document.createElement("div");
3502
3511
  t.className = "ttcb-empty", t.id = "ttcb-empty";
3503
3512
  let n = document.createElement("div");
3504
- n.className = "ttcb-empty-icon", n.innerHTML = Z();
3513
+ n.className = "ttcb-empty-icon", n.innerHTML = X();
3505
3514
  let r = document.createElement("p"), i = document.createElement("strong");
3506
3515
  i.textContent = e, r.appendChild(document.createTextNode("Welcome to ")), r.appendChild(i);
3507
3516
  let a = document.createElement("p");
@@ -3521,7 +3530,7 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3521
3530
  }
3522
3531
  }
3523
3532
  handleIdentifySubmit() {
3524
- let e = this.nameInput.value.trim(), t = Ht(this.selectedCountry.dial, this.phoneInput.value), n = this.emailInput.value.trim();
3533
+ let e = this.nameInput.value.trim(), t = Wt(this.selectedCountry.dial, this.phoneInput.value), n = this.emailInput.value.trim();
3525
3534
  !e || !t ? this.showIdentifyError("Name and phone are required.") : (this.showIdentifyError(""), this.callbacks.onIdentify({
3526
3535
  name: e,
3527
3536
  phone: t,
@@ -3542,13 +3551,13 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3542
3551
  }
3543
3552
  buildMessage(e) {
3544
3553
  if ("message" in e) {
3545
- let t = hn({
3554
+ let t = _n({
3546
3555
  ...e.message,
3547
3556
  pending: e.pending
3548
3557
  });
3549
3558
  return t.dataset.msgId = String(e.id), t;
3550
3559
  }
3551
- return hn(e);
3560
+ return _n(e);
3552
3561
  }
3553
3562
  findMessageEl(e) {
3554
3563
  for (let t of this.messagesContainer.querySelectorAll(".ttcb-msg")) if (t.dataset.msgId === String(e)) return t;
@@ -3561,7 +3570,7 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3561
3570
  }
3562
3571
  }
3563
3572
  setLoading(e) {
3564
- if (this.sendBtn.disabled = e || this.input.disabled, this.attachBtn.disabled = e || this.input.disabled, this.micBtn.disabled = e || this.input.disabled, e) this.closeAttachMenu(), this.shadow.getElementById("ttcb-typing") || (this.messagesContainer.appendChild(gn()), this.scrollToBottom()), this.isFullScreen() || this.input.focus();
3573
+ if (this.sendBtn.disabled = e || this.input.disabled, this.attachBtn.disabled = e || this.input.disabled, this.micBtn.disabled = e || this.input.disabled, e) this.closeAttachMenu(), this.shadow.getElementById("ttcb-typing") || (this.messagesContainer.appendChild(vn()), this.scrollToBottom()), this.isFullScreen() || this.input.focus();
3565
3574
  else {
3566
3575
  let e = this.shadow.getElementById("ttcb-typing");
3567
3576
  e && e.remove(), !this.input.disabled && !this.isFullScreen() && this.input.focus();
@@ -3570,7 +3579,7 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3570
3579
  setIdentifyLoading(e) {
3571
3580
  this.identifySubmit.disabled = e, this.nameInput.disabled = e, this.phoneInput.disabled = e, this.emailInput.disabled = e, this.dialBtn.disabled = e, this.shadow.getElementById("ttcb-phone-row")?.classList.toggle("disabled", e);
3572
3581
  for (let t of this.identifyContainer.querySelectorAll(".ttcb-input-wrap")) t.classList.toggle("disabled", e);
3573
- this.identifySubmit.innerHTML = e ? "<span>Starting…</span>" : `<span>Start Chatting</span>${tn()}`, e && this.closeCountryPopover();
3582
+ this.identifySubmit.innerHTML = e ? "<span>Starting…</span>" : `<span>Start Chatting</span>${rn()}`, e && this.closeCountryPopover();
3574
3583
  }
3575
3584
  showIdentifyError(e) {
3576
3585
  this.identifyError.textContent = e;
@@ -3630,7 +3639,7 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3630
3639
  scrollToBottom() {
3631
3640
  this.messagesContainer.scrollTop = this.messagesContainer.scrollHeight;
3632
3641
  }
3633
- }, bn = {
3642
+ }, Sn = {
3634
3643
  apiBaseUrl: u,
3635
3644
  chatbotName: "AI Assistant",
3636
3645
  primaryColor: "#2563EB",
@@ -3642,23 +3651,23 @@ var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mp
3642
3651
  sessionId: "",
3643
3652
  requestTimeoutMs: n
3644
3653
  };
3645
- function xn(e) {
3654
+ function Cn(e) {
3646
3655
  return Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
3647
3656
  }
3648
- var Sn = [
3657
+ var wn = [
3649
3658
  5e3,
3650
3659
  15e3,
3651
3660
  3e4,
3652
3661
  6e4
3653
3662
  ];
3654
- function Cn(e) {
3663
+ function Tn(e) {
3655
3664
  return c(e) ? e.status === 0 || e.status >= 500 || e.apiError.code === "BAD_RESPONSE" : !1;
3656
3665
  }
3657
- function wn(e) {
3666
+ function En(e) {
3658
3667
  return c(e) ? e.apiError.message : e instanceof Error ? e.message : "Failed to load chatbot config.";
3659
3668
  }
3660
- var Tn = 0, Q = () => Date.now() * 1e3 + Tn++ % 1e3;
3661
- function En(e) {
3669
+ var Dn = 0, Z = () => Date.now() * 1e3 + Dn++ % 1e3;
3670
+ function On(e) {
3662
3671
  if (!e || typeof e != "object") return null;
3663
3672
  let t = e;
3664
3673
  if (typeof t.textMessage == "string" && t.textMessage.trim()) return t.textMessage.trim();
@@ -3670,11 +3679,11 @@ function En(e) {
3670
3679
  }
3671
3680
  return null;
3672
3681
  }
3673
- function Dn(e) {
3682
+ function Q(e) {
3674
3683
  let t = (e.attachments ?? []).map((e) => e.url).join("");
3675
3684
  return `${e.content}\u0000${t}`;
3676
3685
  }
3677
- function On(e) {
3686
+ function kn(e) {
3678
3687
  if (!e || typeof e != "object") return null;
3679
3688
  let t = e;
3680
3689
  if (typeof t.id == "string" && t.id) return t.id;
@@ -3684,9 +3693,9 @@ function On(e) {
3684
3693
  }
3685
3694
  return null;
3686
3695
  }
3687
- var kn = class {
3696
+ var An = class {
3688
3697
  constructor() {
3689
- this.emitter = new fe(), this.visitorTokens = new Nt(), this.widget = null, this.sdkSocket = null, this.callerSetName = !1, this.hasActiveTicket = !1, this.retryTimer = null, this.lastPushId = null, this.endedConversationId = null, this.initToken = 0, this._state = {
3698
+ this.emitter = new pe(), this.visitorTokens = new Pt(), this.widget = null, this.sdkSocket = null, this.callerSetName = !1, this.hasActiveTicket = !1, this.retryTimer = null, this.lastPushId = null, this.endedConversationId = null, this.initToken = 0, this._state = {
3690
3699
  isOpen: !1,
3691
3700
  isLoading: !1,
3692
3701
  isReady: !1,
@@ -3725,8 +3734,8 @@ var kn = class {
3725
3734
  if (!e.apiKey) throw Error("[onedeskpro-chatbot] `apiKey` is required to initialise the chatbot.");
3726
3735
  let t = ++this.initToken;
3727
3736
  this.clearRetry(), this.disconnectSdkSocket(), this.widget?.destroy(), this.widget = null, this.callerSetName = e.chatbotName !== void 0, this.options = {
3728
- ...bn,
3729
- ...xn(e)
3737
+ ...Sn,
3738
+ ...Cn(e)
3730
3739
  }, this.apiClient = new l({
3731
3740
  baseUrl: this.options.apiBaseUrl,
3732
3741
  apiKey: this.options.apiKey,
@@ -3748,13 +3757,13 @@ var kn = class {
3748
3757
  n = await this.apiClient.fetchConfig();
3749
3758
  } catch (n) {
3750
3759
  if (e !== this.initToken) return;
3751
- if (Cn(n)) {
3760
+ if (Tn(n)) {
3752
3761
  this.setState({
3753
3762
  isReady: !1,
3754
3763
  blockReason: "server-unavailable",
3755
- error: wn(n)
3764
+ error: En(n)
3756
3765
  });
3757
- let r = Sn[t];
3766
+ let r = wn[t];
3758
3767
  if (r !== void 0) {
3759
3768
  this.retryTimer = setTimeout(() => {
3760
3769
  this.retryTimer = null, this.checkReadiness(e, t + 1);
@@ -3775,7 +3784,7 @@ var kn = class {
3775
3784
  }), i ? (this.mountWidget(), this.visitorTokens.setScope(n.agentId), await this.resolveVisitorGate(e), e === this.initToken && (this.widget?.reveal(), this.emitter.emit("ready"))) : this.emitter.emit("ready");
3776
3785
  }
3777
3786
  mountWidget() {
3778
- typeof window < "u" && typeof document < "u" && (this.widget = new yn(this.options, {
3787
+ typeof window < "u" && typeof document < "u" && (this.widget = new xn(this.options, {
3779
3788
  onSend: (e) => void this.sendMessage(e),
3780
3789
  onSendAttachments: (e, t) => void this.sendAttachments(e, t),
3781
3790
  onSendVoice: (e) => void this.sendVoice(e),
@@ -3799,7 +3808,7 @@ var kn = class {
3799
3808
  this.setState({
3800
3809
  isReady: !1,
3801
3810
  blockReason: t,
3802
- error: wn(e)
3811
+ error: En(e)
3803
3812
  });
3804
3813
  }
3805
3814
  async resolveVisitorGate(e) {
@@ -3861,16 +3870,16 @@ var kn = class {
3861
3870
  }
3862
3871
  handleMessageReceive(e) {
3863
3872
  if (this._state.mode === "ai") return;
3864
- let t = En(e) ?? "", n = ne(e);
3873
+ let t = On(e) ?? "", n = re(e);
3865
3874
  if (!t && n.length === 0) return;
3866
- let r = On(e), i = this._state.messages[this._state.messages.length - 1];
3867
- if (i && Dn(i.message) === Dn({
3875
+ let r = kn(e), i = this._state.messages[this._state.messages.length - 1];
3876
+ if (i && Q(i.message) === Q({
3868
3877
  content: t,
3869
3878
  attachments: n
3870
3879
  }) && (i.message.type === "ai" || i.message.type === "agent" && (!r || r === this.lastPushId))) return;
3871
3880
  this.lastPushId = r;
3872
3881
  let a = this.visitorTokens.get() ?? this._state.visitorToken ?? "", o = {
3873
- id: Q(),
3882
+ id: Z(),
3874
3883
  sessionId: a,
3875
3884
  message: {
3876
3885
  type: "agent",
@@ -3992,7 +4001,7 @@ var kn = class {
3992
4001
  let n = e.trim();
3993
4002
  if (!n || this._state.isLoading || this._state.needsIdentify) return;
3994
4003
  let r = {
3995
- id: Q(),
4004
+ id: Z(),
3996
4005
  sessionId: t,
3997
4006
  message: {
3998
4007
  type: "human",
@@ -4018,7 +4027,7 @@ var kn = class {
4018
4027
  r ? this.rejectSend(r) : await this.uploadThenDeliver({
4019
4028
  visitorToken: n,
4020
4029
  files: e,
4021
- previews: e.map(ee),
4030
+ previews: e.map(te),
4022
4031
  caption: t.trim()
4023
4032
  });
4024
4033
  }
@@ -4031,7 +4040,7 @@ var kn = class {
4031
4040
  if (!e?.blob || e.blob.size === 0 || this._state.isLoading || this._state.needsIdentify) return;
4032
4041
  let n;
4033
4042
  try {
4034
- n = await de(e);
4043
+ n = await fe(e);
4035
4044
  } catch {
4036
4045
  this.rejectSend("Could not process the recording.");
4037
4046
  return;
@@ -4064,7 +4073,7 @@ var kn = class {
4064
4073
  }
4065
4074
  async uploadThenDeliver(e) {
4066
4075
  let { visitorToken: t, files: n, previews: r, caption: i } = e, a = {
4067
- id: Q(),
4076
+ id: Z(),
4068
4077
  sessionId: t,
4069
4078
  message: {
4070
4079
  type: "human",
@@ -4111,16 +4120,20 @@ var kn = class {
4111
4120
  try {
4112
4121
  let n = await this.apiClient.sendMessage(e);
4113
4122
  this.hasActiveTicket = !0, this.endedConversationId = null;
4114
- let r = n.mode ?? t, i = [...this._state.messages], a = (n.text ?? "").trim();
4115
- if (r !== t && (this.setState({ mode: r }), this.syncWidgetMode(r), this.emitter.emit("ticket-status", { mode: r })), a) {
4123
+ let r = n.mode ?? t, i = [...this._state.messages], a = (n.text ?? "").trim(), o = re(n);
4124
+ if (r !== t && (this.setState({ mode: r }), this.syncWidgetMode(r), this.emitter.emit("ticket-status", { mode: r })), a || o.length > 0) {
4116
4125
  let e = i[i.length - 1];
4117
- if (e?.message.type !== "agent" && e?.message.type !== "ai" || e.message.content !== a) {
4126
+ if (e?.message.type !== "agent" && e?.message.type !== "ai" || Q(e.message) !== Q({
4127
+ content: a,
4128
+ attachments: o
4129
+ })) {
4118
4130
  let e = {
4119
- id: Q(),
4131
+ id: Z(),
4120
4132
  sessionId: n.sessionId,
4121
4133
  message: {
4122
4134
  type: "ai",
4123
- content: a
4135
+ content: a,
4136
+ ...o.length > 0 ? { attachments: o } : {}
4124
4137
  }
4125
4138
  };
4126
4139
  i.push(e), this.widget?.appendMessage(e), this.emitter.emit("message", e);
@@ -4171,12 +4184,12 @@ var kn = class {
4171
4184
  needsIdentify: !0
4172
4185
  });
4173
4186
  }
4174
- }, $ = null, An = {
4187
+ }, $ = null, jn = {
4175
4188
  async init(e) {
4176
- return $ = new kn(), await $.init(e), $;
4189
+ return $ = new An(), await $.init(e), $;
4177
4190
  },
4178
4191
  getInstance() {
4179
4192
  return $;
4180
4193
  }
4181
4194
  };
4182
- export { l as ApiClient, kn as ChatbotCore, u as DEFAULT_API_BASE_URL, n as DEFAULT_REQUEST_TIMEOUT_MS, fe as EventEmitter, An as OnedeskProChatbot, f as SDK_CHAT_MAX_ATTACHMENTS, d as SDK_UPLOAD_MAX_BYTES, kt as SdkSocket, Nt as SessionManager, Pt as VOICE_MAX_DURATION_SECONDS, Bt as VoiceRecorder, c as isChatbotRequestError, Ot as resolveSdkSocketUrl };
4195
+ export { l as ApiClient, An as ChatbotCore, u as DEFAULT_API_BASE_URL, n as DEFAULT_REQUEST_TIMEOUT_MS, pe as EventEmitter, jn as OnedeskProChatbot, f as SDK_CHAT_MAX_ATTACHMENTS, d as SDK_UPLOAD_MAX_BYTES, kt as SdkSocket, Pt as SessionManager, Ft as VOICE_MAX_DURATION_SECONDS, Vt as VoiceRecorder, c as isChatbotRequestError, Ot as resolveSdkSocketUrl };