@liforma/client 0.4.4 → 0.4.5

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/next/index.js +462 -377
  3. package/dist/next/index.js.map +1 -1
  4. package/dist/next/next/createLiformaSessionRouteHandler.d.ts +8 -0
  5. package/dist/next/next/createLiformaSessionRouteHandler.d.ts.map +1 -1
  6. package/dist/next/next/index.d.ts +8 -1
  7. package/dist/next/next/index.d.ts.map +1 -1
  8. package/dist/next/v2/api/captureAttribution.d.ts +10 -0
  9. package/dist/next/v2/api/captureAttribution.d.ts.map +1 -0
  10. package/dist/next/v2/api/mintPublicSession.d.ts +1 -0
  11. package/dist/next/v2/api/mintPublicSession.d.ts.map +1 -1
  12. package/dist/next/v2/api/sessionEndpointRequest.d.ts +1 -0
  13. package/dist/next/v2/api/sessionEndpointRequest.d.ts.map +1 -1
  14. package/dist/next/v2/embed/fullWindowHost.d.ts +20 -0
  15. package/dist/next/v2/embed/fullWindowHost.d.ts.map +1 -0
  16. package/dist/next/v2/embed/iframeHost.d.ts +2 -0
  17. package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
  18. package/dist/next/v2/embed/protocol.d.ts +14 -0
  19. package/dist/next/v2/embed/protocol.d.ts.map +1 -1
  20. package/dist/next/v2/experience.d.ts +8 -1
  21. package/dist/next/v2/experience.d.ts.map +1 -1
  22. package/dist/next/v2/types/sessionInteraction.d.ts +19 -0
  23. package/dist/next/v2/types/sessionInteraction.d.ts.map +1 -1
  24. package/dist/npm/index.js +554 -475
  25. package/dist/npm/index.js.map +1 -1
  26. package/dist/npm/v2/api/captureAttribution.d.ts +10 -0
  27. package/dist/npm/v2/api/captureAttribution.d.ts.map +1 -0
  28. package/dist/npm/v2/api/mintPublicSession.d.ts +1 -0
  29. package/dist/npm/v2/api/mintPublicSession.d.ts.map +1 -1
  30. package/dist/npm/v2/api/sessionEndpointRequest.d.ts +1 -0
  31. package/dist/npm/v2/api/sessionEndpointRequest.d.ts.map +1 -1
  32. package/dist/npm/v2/embed/fullWindowHost.d.ts +20 -0
  33. package/dist/npm/v2/embed/fullWindowHost.d.ts.map +1 -0
  34. package/dist/npm/v2/embed/iframeHost.d.ts +2 -0
  35. package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
  36. package/dist/npm/v2/embed/protocol.d.ts +14 -0
  37. package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
  38. package/dist/npm/v2/experience.d.ts +8 -1
  39. package/dist/npm/v2/experience.d.ts.map +1 -1
  40. package/dist/npm/v2/index.d.ts +1 -1
  41. package/dist/npm/v2/index.d.ts.map +1 -1
  42. package/dist/npm/v2/npm.d.ts +2 -1
  43. package/dist/npm/v2/npm.d.ts.map +1 -1
  44. package/dist/npm/v2/types/sessionInteraction.d.ts +19 -0
  45. package/dist/npm/v2/types/sessionInteraction.d.ts.map +1 -1
  46. package/dist/npm/v2/types/sessionManifestSchema.d.ts +9 -0
  47. package/dist/npm/v2/types/sessionManifestSchema.d.ts.map +1 -1
  48. package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
  49. package/dist/react/component/experienceComponentTypes.d.ts +2 -0
  50. package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
  51. package/dist/react/index.js +671 -588
  52. package/dist/react/index.js.map +1 -1
  53. package/dist/react/react/Experience.d.ts.map +1 -1
  54. package/dist/react/v2/api/captureAttribution.d.ts +10 -0
  55. package/dist/react/v2/api/captureAttribution.d.ts.map +1 -0
  56. package/dist/react/v2/api/mintPublicSession.d.ts +1 -0
  57. package/dist/react/v2/api/mintPublicSession.d.ts.map +1 -1
  58. package/dist/react/v2/api/sessionEndpointRequest.d.ts +1 -0
  59. package/dist/react/v2/api/sessionEndpointRequest.d.ts.map +1 -1
  60. package/dist/react/v2/embed/fullWindowHost.d.ts +20 -0
  61. package/dist/react/v2/embed/fullWindowHost.d.ts.map +1 -0
  62. package/dist/react/v2/embed/iframeHost.d.ts +2 -0
  63. package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
  64. package/dist/react/v2/embed/protocol.d.ts +14 -0
  65. package/dist/react/v2/embed/protocol.d.ts.map +1 -1
  66. package/dist/react/v2/experience.d.ts +8 -1
  67. package/dist/react/v2/experience.d.ts.map +1 -1
  68. package/dist/react/v2/types/sessionInteraction.d.ts +19 -0
  69. package/dist/react/v2/types/sessionInteraction.d.ts.map +1 -1
  70. package/dist/sdk/v2/client.js +6 -6
  71. package/dist/sdk/v2/client.js.map +1 -1
  72. package/dist/svelte/Experience.svelte +8 -0
  73. package/dist/svelte/Experience.svelte.d.ts +1 -0
  74. package/package.json +1 -1
package/dist/npm/index.js CHANGED
@@ -128,20 +128,20 @@ function S(e) {
128
128
  }
129
129
  //#endregion
130
130
  //#region src/thumbnail/lazyLoad.ts
131
- function ee() {
131
+ function C() {
132
132
  return g() ? "96px 0px" : "280px 0px";
133
133
  }
134
- function C(e) {
134
+ function w(e) {
135
135
  let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
136
136
  return Number.isFinite(n) ? Math.abs(n) : 280;
137
137
  }
138
- function w(e, t) {
138
+ function T(e, t) {
139
139
  if (typeof window > "u") return !1;
140
140
  let n = e.getBoundingClientRect();
141
141
  return n.bottom >= -t && n.top <= window.innerHeight + t;
142
142
  }
143
- function T(e, t) {
144
- let { onVisibleChange: n } = t, r = t.rootMargin ?? ee(), i = C(r), a = !1, o = !1, s = null, c = () => {
143
+ function E(e, t) {
144
+ let { onVisibleChange: n } = t, r = t.rootMargin ?? C(), i = w(r), a = !1, o = !1, s = null, c = () => {
145
145
  o || (s?.(), s = S(() => {
146
146
  s = null, o = !0, n(!0);
147
147
  }));
@@ -164,11 +164,11 @@ function T(e, t) {
164
164
  rootMargin: r,
165
165
  threshold: 0
166
166
  });
167
- return u.observe(e), w(e, i) && l(!0), () => {
167
+ return u.observe(e), T(e, i) && l(!0), () => {
168
168
  s?.(), s = null, u.disconnect();
169
169
  };
170
170
  }
171
- function E(e, t) {
171
+ function D(e, t) {
172
172
  let n = () => t();
173
173
  return e.complete ? queueMicrotask(n) : (e.addEventListener("load", n, { once: !0 }), e.addEventListener("error", n, { once: !0 })), () => {
174
174
  e.removeEventListener("load", n), e.removeEventListener("error", n);
@@ -176,40 +176,40 @@ function E(e, t) {
176
176
  }
177
177
  //#endregion
178
178
  //#region src/thumbnail/scrollParallax.ts
179
- function D() {
179
+ function O() {
180
180
  return typeof window > "u" || window.matchMedia("(prefers-reduced-motion: reduce)").matches ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
181
181
  }
182
- function O(e, t) {
182
+ function k(e, t) {
183
183
  return ((e.top + e.height / 2) / Math.max(t, 1) - .5) * 2;
184
184
  }
185
- var k = /* @__PURE__ */ new Set(), A = !1, j = 0;
186
- function M() {
187
- if (j = 0, k.size === 0 || typeof window > "u") return;
185
+ var A = /* @__PURE__ */ new Set(), j = !1, M = 0;
186
+ function ee() {
187
+ if (M = 0, A.size === 0 || typeof window > "u") return;
188
188
  let e = window.innerHeight;
189
- for (let t of k) {
189
+ for (let t of A) {
190
190
  if (t.pointerActive?.()) continue;
191
191
  let n = t.element.getBoundingClientRect();
192
- n.bottom < -64 || n.top > e + 64 || t.onParallax(O(n, e));
192
+ n.bottom < -64 || n.top > e + 64 || t.onParallax(k(n, e));
193
193
  }
194
194
  }
195
195
  function N() {
196
- j === 0 && (j = requestAnimationFrame(M));
196
+ M === 0 && (M = requestAnimationFrame(ee));
197
197
  }
198
198
  function P() {
199
- A || typeof window > "u" || (A = !0, window.addEventListener("scroll", N, { passive: !0 }), window.addEventListener("resize", N, { passive: !0 }));
199
+ j || typeof window > "u" || (j = !0, window.addEventListener("scroll", N, { passive: !0 }), window.addEventListener("resize", N, { passive: !0 }));
200
200
  }
201
201
  function F() {
202
- k.size > 0 || !A || typeof window > "u" || (A = !1, j !== 0 && (cancelAnimationFrame(j), j = 0), window.removeEventListener("scroll", N), window.removeEventListener("resize", N));
202
+ A.size > 0 || !j || typeof window > "u" || (j = !1, M !== 0 && (cancelAnimationFrame(M), M = 0), window.removeEventListener("scroll", N), window.removeEventListener("resize", N));
203
203
  }
204
204
  function te(e, t) {
205
- if (!D()) return () => {};
205
+ if (!O()) return () => {};
206
206
  let n = {
207
207
  element: e,
208
208
  onParallax: t.onParallax,
209
209
  pointerActive: t.pointerActive
210
210
  };
211
- return k.add(n), P(), n.pointerActive?.() || t.onParallax(O(e.getBoundingClientRect(), window.innerHeight)), () => {
212
- k.delete(n), F();
211
+ return A.add(n), P(), n.pointerActive?.() || t.onParallax(k(e.getBoundingClientRect(), window.innerHeight)), () => {
212
+ A.delete(n), F();
213
213
  };
214
214
  }
215
215
  //#endregion
@@ -231,7 +231,7 @@ function ne(e) {
231
231
  a = !0, e.pointerType === "mouse" && (r = !0), o();
232
232
  }, u = () => {
233
233
  let s = a;
234
- a = !1, r = !1, i && s ? (t = O(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
234
+ a = !1, r = !1, i && s ? (t = k(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
235
235
  }, d = (e) => {
236
236
  e.pointerType === "mouse" && (r = !0, o());
237
237
  }, f = () => {
@@ -349,20 +349,58 @@ function fe(e, t, n) {
349
349
  });
350
350
  }
351
351
  //#endregion
352
+ //#region src/v2/api/captureAttribution.ts
353
+ var V = 128, pe = /[\u0000-\u001f\u007f]/g;
354
+ function H(e) {
355
+ if (!e) return;
356
+ let t = e.replace(pe, "").trim();
357
+ if (t) return t.slice(0, V);
358
+ }
359
+ function me(e) {
360
+ let t = new URLSearchParams((e ?? "").startsWith("?") ? (e ?? "").slice(1) : e ?? "");
361
+ return {
362
+ ...H(t.get("utm_source")) ? { utmSource: H(t.get("utm_source")) } : {},
363
+ ...H(t.get("utm_medium")) ? { utmMedium: H(t.get("utm_medium")) } : {},
364
+ ...H(t.get("utm_campaign")) ? { utmCampaign: H(t.get("utm_campaign")) } : {},
365
+ ...H(t.get("utm_content")) ? { utmContent: H(t.get("utm_content")) } : {},
366
+ ...H(t.get("utm_term")) ? { utmTerm: H(t.get("utm_term")) } : {}
367
+ };
368
+ }
369
+ function he(e) {
370
+ if (e === !1) return;
371
+ if (e && typeof e == "object") {
372
+ let t = {
373
+ ...H(e.utmSource) ? { utmSource: H(e.utmSource) } : {},
374
+ ...H(e.utmMedium) ? { utmMedium: H(e.utmMedium) } : {},
375
+ ...H(e.utmCampaign) ? { utmCampaign: H(e.utmCampaign) } : {},
376
+ ...H(e.utmContent) ? { utmContent: H(e.utmContent) } : {},
377
+ ...H(e.utmTerm) ? { utmTerm: H(e.utmTerm) } : {},
378
+ ...H(e.referrer) ? { referrer: H(e.referrer) } : {}
379
+ };
380
+ return Object.keys(t).length ? t : void 0;
381
+ }
382
+ if (typeof window > "u") return;
383
+ let t = me(window.location?.search), n = H(document.referrer || void 0), r = {
384
+ ...t,
385
+ ...n ? { referrer: n } : {}
386
+ };
387
+ return Object.keys(r).length ? r : void 0;
388
+ }
389
+ //#endregion
352
390
  //#region src/v2/api/sessionEndpointRequest.ts
353
- function V(e) {
391
+ function U(e) {
354
392
  let t = e.locale?.trim();
355
393
  if (t) return t;
356
394
  let n = e.language?.trim();
357
395
  if (n) return n;
358
396
  if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
359
397
  }
360
- function pe(e) {
398
+ function ge(e) {
361
399
  let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
362
400
  if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
363
401
  return t || n || void 0;
364
402
  }
365
- function me(e, t) {
403
+ function _e(e, t) {
366
404
  let n = e.trim();
367
405
  if (!n) throw Error("sessionEndpoint must not be empty.");
368
406
  if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
@@ -370,7 +408,7 @@ function me(e, t) {
370
408
  if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
371
409
  let i = t.experienceId.trim();
372
410
  if (!i) throw Error("sessionEndpoint requires experienceId.");
373
- let a = V(t), o = pe(t), s = t.idempotencyKey?.trim();
411
+ let a = U(t), o = ge(t), s = t.idempotencyKey?.trim();
374
412
  return {
375
413
  url: r.toString(),
376
414
  init: {
@@ -387,23 +425,27 @@ function me(e, t) {
387
425
  ...o ? { secondaryLocale: o } : {},
388
426
  ...t.mode ? { mode: t.mode } : {},
389
427
  ...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
390
- ...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly }
428
+ ...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
429
+ ...(() => {
430
+ let e = he(t.attribution);
431
+ return e ? { attribution: e } : {};
432
+ })()
391
433
  })
392
434
  }
393
435
  };
394
436
  }
395
437
  //#endregion
396
438
  //#region src/v2/types/sessionLaunch.ts
397
- function H(e) {
439
+ function W(e) {
398
440
  return !!e && typeof e == "object" && !Array.isArray(e);
399
441
  }
400
- function U(e) {
442
+ function G(e) {
401
443
  return typeof e == "boolean";
402
444
  }
403
- function W(e) {
404
- if (!H(e)) return null;
445
+ function ve(e) {
446
+ if (!W(e)) return null;
405
447
  let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
406
- return !H(t) || !H(n) || !H(r) || !H(i) || !U(t.input) || !U(t.output) || !U(t.externalAudio) || !U(n.managed) || !U(r.enabled) || !U(i.enabled) ? null : {
448
+ return !W(t) || !W(n) || !W(r) || !W(i) || !G(t.input) || !G(t.output) || !G(t.externalAudio) || !G(n.managed) || !G(r.enabled) || !G(i.enabled) ? null : {
407
449
  speech: {
408
450
  input: t.input,
409
451
  output: t.output,
@@ -414,8 +456,8 @@ function W(e) {
414
456
  tools: { enabled: i.enabled }
415
457
  };
416
458
  }
417
- function he(e) {
418
- return !H(e) || !U(e.avatar) || !U(e.speechInput) || !U(e.speechOutput) || !U(e.tools) || !U(e.externalAudio) ? null : {
459
+ function K(e) {
460
+ return !W(e) || !G(e.avatar) || !G(e.speechInput) || !G(e.speechOutput) || !G(e.tools) || !G(e.externalAudio) ? null : {
419
461
  speech: {
420
462
  input: e.speechInput,
421
463
  output: e.speechOutput,
@@ -426,12 +468,12 @@ function he(e) {
426
468
  tools: { enabled: e.tools }
427
469
  };
428
470
  }
429
- function ge(e) {
430
- return W(e) ?? he(e);
471
+ function ye(e) {
472
+ return ve(e) ?? K(e);
431
473
  }
432
- function _e(e) {
433
- if (!H(e)) throw Error("Session Launch response is missing session.");
434
- let t = typeof e.id == "string" ? e.id.trim() : "", n = typeof e.experienceId == "string" ? e.experienceId.trim() : "", r = typeof e.experienceRevisionId == "string" ? e.experienceRevisionId.trim() : "", i = typeof e.expiresAt == "string" ? e.expiresAt.trim() : "", a = typeof e.locale == "string" ? e.locale.trim() : "", o = typeof e.secondaryLocale == "string" && e.secondaryLocale.trim() ? e.secondaryLocale.trim() : void 0, s = e.mode === "conversation" || e.mode === "presenter" ? e.mode : null, c = ge(e.capabilities), l = ve(e.localeVoiceFallbacks), u = e.status === "active" || e.status === "ended" ? e.status : void 0, d = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt.trim() : void 0;
474
+ function be(e) {
475
+ if (!W(e)) throw Error("Session Launch response is missing session.");
476
+ let t = typeof e.id == "string" ? e.id.trim() : "", n = typeof e.experienceId == "string" ? e.experienceId.trim() : "", r = typeof e.experienceRevisionId == "string" ? e.experienceRevisionId.trim() : "", i = typeof e.expiresAt == "string" ? e.expiresAt.trim() : "", a = typeof e.locale == "string" ? e.locale.trim() : "", o = typeof e.secondaryLocale == "string" && e.secondaryLocale.trim() ? e.secondaryLocale.trim() : void 0, s = e.mode === "conversation" || e.mode === "presenter" ? e.mode : null, c = ye(e.capabilities), l = xe(e.localeVoiceFallbacks), u = e.status === "active" || e.status === "ended" ? e.status : void 0, d = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt.trim() : void 0;
435
477
  if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
436
478
  return {
437
479
  id: t,
@@ -447,11 +489,11 @@ function _e(e) {
447
489
  ...d ? { createdAt: d } : {}
448
490
  };
449
491
  }
450
- function ve(e) {
492
+ function xe(e) {
451
493
  if (!Array.isArray(e) || e.length === 0) return;
452
494
  let t = [];
453
495
  for (let n of e) {
454
- if (!H(n)) continue;
496
+ if (!W(n)) continue;
455
497
  let e = n.axis === "locale" || n.axis === "secondaryLocale" ? n.axis : null, r = typeof n.requested == "string" ? n.requested.trim() : "", i = typeof n.resolved == "string" ? n.resolved.trim() : "";
456
498
  !e || !r || !i || n.reason !== "voice_unsupported" || t.push({
457
499
  axis: e,
@@ -462,35 +504,35 @@ function ve(e) {
462
504
  }
463
505
  return t.length > 0 ? t : void 0;
464
506
  }
465
- function ye(e) {
507
+ function Se(e) {
466
508
  let t = e.localeVoiceFallbacks;
467
509
  if (t?.length) for (let e of t) {
468
510
  let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
469
511
  console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
470
512
  }
471
513
  }
472
- function G(e) {
473
- if (!H(e)) throw Error("Session Launch response must be a JSON object.");
514
+ function Ce(e) {
515
+ if (!W(e)) throw Error("Session Launch response must be a JSON object.");
474
516
  let t = typeof e.launch == "string" ? e.launch.trim() : "";
475
517
  if (!t) throw Error("Session Launch response is missing launch.");
476
- let n = _e(e.session);
477
- return ye(n), {
518
+ let n = be(e.session);
519
+ return Se(n), {
478
520
  session: n,
479
521
  launch: t
480
522
  };
481
523
  }
482
524
  //#endregion
483
525
  //#region src/v2/api/mintPublicSession.ts
484
- function be() {
526
+ function we() {
485
527
  try {
486
528
  if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
487
529
  } catch {}
488
530
  }
489
- function xe(e) {
531
+ function Te(e) {
490
532
  return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
491
533
  }
492
- function Se(e, t) {
493
- let n = be(), r = xe(t.code), i = t.message.trim(), a = t.details ?? {};
534
+ function q(e, t) {
535
+ let n = we(), r = Te(t.code), i = t.message.trim(), a = t.details ?? {};
494
536
  if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
495
537
  if (i.includes(e) && i.includes("allowed origin")) return t;
496
538
  let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
@@ -513,36 +555,38 @@ function Se(e, t) {
513
555
  details: a
514
556
  }) : t;
515
557
  }
516
- function Ce(e) {
558
+ function Ee(e) {
517
559
  let t = e?.locale?.trim();
518
560
  if (t) return t;
519
561
  let n = e?.language?.trim();
520
562
  if (n) return n;
521
563
  if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
522
564
  }
523
- function we(e) {
565
+ function De(e) {
524
566
  let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
525
567
  if (t && n && t !== n) throw new B("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
526
568
  return t || n || void 0;
527
569
  }
528
- function Te(e, t) {
529
- let n = { experienceId: e }, r = Ce(t);
570
+ function Oe(e, t) {
571
+ let n = { experienceId: e }, r = Ee(t);
530
572
  r && (n.locale = r);
531
- let i = we(t);
532
- return i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly), n;
573
+ let i = De(t);
574
+ i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly);
575
+ let a = he(t?.attribution);
576
+ return a && (n.attribution = a), n;
533
577
  }
534
- async function Ee(e, t) {
578
+ async function ke(e, t) {
535
579
  let n = ce(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
536
580
  method: "POST",
537
581
  headers: {
538
582
  "Content-Type": "application/json",
539
583
  ...r ? { "Idempotency-Key": r } : {}
540
584
  },
541
- body: JSON.stringify(Te(e, t))
585
+ body: JSON.stringify(Oe(e, t))
542
586
  });
543
587
  if (!i.ok) {
544
588
  let t = await i.text();
545
- throw Se(e, fe(i.status, t, i.headers));
589
+ throw q(e, fe(i.status, t, i.headers));
546
590
  }
547
591
  let a;
548
592
  try {
@@ -554,10 +598,10 @@ async function Ee(e, t) {
554
598
  requestId: i.headers.get("Liforma-Request-Id") ?? void 0
555
599
  });
556
600
  }
557
- return G(a);
601
+ return Ce(a);
558
602
  }
559
- async function K(e, t) {
560
- let n = me(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
603
+ async function J(e, t) {
604
+ let n = _e(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
561
605
  t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
562
606
  let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
563
607
  try {
@@ -587,14 +631,14 @@ async function K(e, t) {
587
631
  requestId: o.headers.get("Liforma-Request-Id") ?? void 0
588
632
  });
589
633
  }
590
- return G(s);
634
+ return Ce(s);
591
635
  }
592
636
  //#endregion
593
637
  //#region src/v2/conversationProcessor.ts
594
- function De(e) {
638
+ function Ae(e) {
595
639
  return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
596
640
  }
597
- function Oe(e) {
641
+ function je(e) {
598
642
  if (typeof e == "string") {
599
643
  let t = e.trim();
600
644
  if (!t) throw Error("conversationProcessor returned empty text.");
@@ -608,24 +652,24 @@ function Oe(e) {
608
652
  ...e.behavior ? { behavior: e.behavior } : {}
609
653
  };
610
654
  }
611
- async function ke(e, t) {
655
+ async function Me(e, t) {
612
656
  let n = await e(t);
613
- return De(n) ? {
657
+ return Ae(n) ? {
614
658
  kind: "stream",
615
659
  stream: n
616
660
  } : {
617
661
  kind: "complete",
618
- speech: Oe(n)
662
+ speech: je(n)
619
663
  };
620
664
  }
621
665
  //#endregion
622
666
  //#region src/v2/embed/playerReachability.ts
623
- var Ae = "3002";
624
- function q(e) {
667
+ var Ne = "3002";
668
+ function Pe(e) {
625
669
  let t = new URL(e);
626
- return t.hostname === "localhost" || t.hostname === "127.0.0.1" ? `Cannot connect to the Liforma player at ${e} — nothing is listening on port ${t.port || Ae}. Start the player dev server in player.liforma.ai (npm run dev).` : `Cannot connect to the Liforma player at ${e}. The embed did not load; check your network connection and player URL configuration.`;
670
+ return t.hostname === "localhost" || t.hostname === "127.0.0.1" ? `Cannot connect to the Liforma player at ${e} — nothing is listening on port ${t.port || Ne}. Start the player dev server in player.liforma.ai (npm run dev).` : `Cannot connect to the Liforma player at ${e}. The embed did not load; check your network connection and player URL configuration.`;
627
671
  }
628
- async function je(e, t) {
672
+ async function Fe(e, t) {
629
673
  try {
630
674
  await fetch(e, {
631
675
  method: "GET",
@@ -633,52 +677,30 @@ async function je(e, t) {
633
677
  signal: AbortSignal.timeout(8e3)
634
678
  });
635
679
  } catch {
636
- throw Error(q(t));
680
+ throw Error(Pe(t));
637
681
  }
638
682
  }
639
- function J(e, t, n, r) {
683
+ function Ie(e, t, n, r) {
640
684
  try {
641
685
  r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
642
686
  } catch (e) {
643
- throw e instanceof DOMException && e.name === "SecurityError" ? Error(q(n), { cause: e }) : e;
644
- }
645
- }
646
- var Me = new Set([1, 2]);
647
- function Ne(e) {
648
- return typeof e == "number" && Me.has(e);
649
- }
650
- var Pe = new Set([
651
- "close",
652
- "stateUpdate",
653
- "commandResult",
654
- "userTranscript",
655
- "characterSpeechStarted",
656
- "characterSpeechEnded",
657
- "characterFocusChanged",
658
- "conversationUpdate",
659
- "listeningState",
660
- "userSpeechStarted",
661
- "userSpeechEnded",
662
- "modeChange",
663
- "activityChange",
664
- "feedback",
665
- "feedbackFailed",
666
- "message",
667
- "started",
668
- "embedReady",
669
- "widgetReady",
670
- "widgetExpand",
671
- "widgetCollapse",
672
- "widgetAudioSettings",
673
- "widgetDragStart",
674
- "widgetDragMove",
675
- "widgetDragEnd"
676
- ]);
677
- function Fe(e) {
687
+ throw e instanceof DOMException && e.name === "SecurityError" ? Error(Pe(n), { cause: e }) : e;
688
+ }
689
+ }
690
+ var Le = new Set([1, 2]);
691
+ function Re(e) {
692
+ return typeof e == "number" && Le.has(e);
693
+ }
694
+ var ze = new Set(/* @__PURE__ */ "close.stateUpdate.commandResult.userTranscript.characterSpeechStarted.characterSpeechEnded.characterFocusChanged.conversationUpdate.listeningState.userSpeechStarted.userSpeechEnded.modeChange.activityChange.feedback.feedbackFailed.message.started.embedReady.widgetReady.widgetExpand.widgetCollapse.widgetAudioSettings.widgetDragStart.widgetDragMove.widgetDragEnd.fullWindow".split("."));
695
+ function Be(e) {
678
696
  if (!e || typeof e != "object") return null;
679
697
  let t = e;
680
- if (!Ne(t.schemaVersion) || !t.type || !Pe.has(t.type)) return null;
698
+ if (!Re(t.schemaVersion) || !t.type || !ze.has(t.type)) return null;
681
699
  if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
700
+ if (t.type === "fullWindow") {
701
+ let e = t.payload;
702
+ return !e || typeof e != "object" || typeof e.active != "boolean" ? null : t;
703
+ }
682
704
  if (t.type === "widgetAudioSettings") {
683
705
  let e = t.payload;
684
706
  return !e || typeof e != "object" || typeof e.open != "boolean" ? null : t;
@@ -696,7 +718,7 @@ function Fe(e) {
696
718
  let n = t.payload;
697
719
  return !n || typeof n != "object" ? null : t;
698
720
  }
699
- function Ie(e, t, n) {
721
+ function Ve(e, t, n) {
700
722
  let r = e.trim();
701
723
  if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
702
724
  let i = n?.startButton, a = n?.showFeedback;
@@ -711,20 +733,20 @@ function Ie(e, t, n) {
711
733
  }
712
734
  };
713
735
  }
714
- function Le() {
736
+ function He() {
715
737
  return {
716
738
  type: "parentHello",
717
739
  schemaVersion: 2
718
740
  };
719
741
  }
720
- function Re(e) {
742
+ function Ue(e) {
721
743
  return {
722
744
  type: "widgetSetChrome",
723
745
  schemaVersion: 2,
724
746
  payload: { mode: e }
725
747
  };
726
748
  }
727
- function ze() {
749
+ function We() {
728
750
  return {
729
751
  type: "widgetToggleAudioSettings",
730
752
  schemaVersion: 2,
@@ -732,108 +754,143 @@ function ze() {
732
754
  };
733
755
  }
734
756
  //#endregion
757
+ //#region src/v2/embed/fullWindowHost.ts
758
+ var Ge = "2147483000";
759
+ function Ke(e) {
760
+ let { style: t } = e;
761
+ return {
762
+ position: t.position,
763
+ top: t.top,
764
+ right: t.right,
765
+ bottom: t.bottom,
766
+ left: t.left,
767
+ inset: t.inset,
768
+ width: t.width,
769
+ height: t.height,
770
+ zIndex: t.zIndex,
771
+ margin: t.margin,
772
+ borderRadius: t.borderRadius,
773
+ maxWidth: t.maxWidth,
774
+ maxHeight: t.maxHeight
775
+ };
776
+ }
777
+ function qe(e) {
778
+ let { style: t } = e;
779
+ t.position = "fixed", t.top = "0", t.right = "0", t.bottom = "0", t.left = "0", t.inset = "0", t.width = "100vw", t.width = "100dvw", t.height = "100vh", t.height = "100dvh", t.zIndex = Ge, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
780
+ }
781
+ function Je(e, t) {
782
+ if (delete e.dataset.liformaFullWindow, !t) {
783
+ e.style.position = "", e.style.top = "", e.style.right = "", e.style.bottom = "", e.style.left = "", e.style.inset = "", e.style.width = "", e.style.height = "", e.style.zIndex = "", e.style.margin = "", e.style.borderRadius = "", e.style.maxWidth = "", e.style.maxHeight = "";
784
+ return;
785
+ }
786
+ let { style: n } = e;
787
+ n.position = t.position, n.top = t.top, n.right = t.right, n.bottom = t.bottom, n.left = t.left, n.inset = t.inset, n.width = t.width, n.height = t.height, n.zIndex = t.zIndex, n.margin = t.margin, n.borderRadius = t.borderRadius, n.maxWidth = t.maxWidth, n.maxHeight = t.maxHeight;
788
+ }
789
+ //#endregion
735
790
  //#region src/v2/embed/iframeHost.ts
736
- function Be(e) {
791
+ function Ye(e) {
737
792
  return e;
738
793
  }
739
794
  function Y() {
740
795
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `cmd_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}` : `cmd_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
741
796
  }
742
- var Ve = 3e4;
743
- function He(e) {
797
+ var Xe = 3e4;
798
+ function Ze(e) {
744
799
  let t = e.container;
745
800
  getComputedStyle(t).position === "static" && (t.style.position = "relative");
746
801
  let n = document.createElement("iframe");
747
802
  n.src = e.src, n.title = "Liforma experience", n.setAttribute("allow", "microphone; autoplay; clipboard-read; clipboard-write"), n.style.cssText = e.transparent ? "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent;" : "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:#030508;", e.transparent && n.setAttribute("allowtransparency", "true");
748
- let r = !1, i = /* @__PURE__ */ new Map(), a = null, o = 0, s = 0, c = [], l = null, u = null, d = new Promise((e, t) => {
749
- l = e, u = t;
750
- }), f = () => {
751
- for (let e of c) window.clearTimeout(e);
752
- c.length = 0;
753
- }, p = (t) => {
803
+ let r = !1, i = !1, a = null, o = t.closest(".liforma-experience-shell") instanceof HTMLElement ? t.closest(".liforma-experience-shell") : t, s = (t) => {
804
+ i !== t && (i = t, t ? (a = Ke(o), qe(o)) : (Je(o, a), a = null), e.onFullWindowChange?.(t));
805
+ }, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
806
+ p = e, m = t;
807
+ }), g = () => {
808
+ for (let e of f) window.clearTimeout(e);
809
+ f.length = 0;
810
+ }, _ = (t) => {
754
811
  if (r) return;
755
812
  let i = Date.now();
756
- if (s > 0 && i - s < 250) return;
757
- s = i, f();
758
- let a = Ie(t.launch, t.session, t.chrome), o = () => {
813
+ if (d > 0 && i - d < 250) return;
814
+ d = i, g();
815
+ let a = Ve(t.launch, t.session, t.chrome), o = () => {
759
816
  if (r) return;
760
817
  let t = n.contentWindow;
761
- t && J(t, a, e.playerOrigin);
818
+ t && Ie(t, a, e.playerOrigin);
762
819
  };
763
820
  o();
764
- for (let e = 1; e <= 12; e += 1) c.push(window.setTimeout(o, e * 75));
765
- }, m = () => {
766
- r || !a || p(a);
767
- }, h = () => {
768
- if (o += 1, o === 1) {
769
- je(e.src, e.playerOrigin).then(() => l?.(), (e) => u?.(e instanceof Error ? e : Error(String(e))));
821
+ for (let e = 1; e <= 12; e += 1) f.push(window.setTimeout(o, e * 75));
822
+ }, v = () => {
823
+ r || !l || _(l);
824
+ }, y = () => {
825
+ if (u += 1, u === 1) {
826
+ Fe(e.src, e.playerOrigin).then(() => p?.(), (e) => m?.(e instanceof Error ? e : Error(String(e))));
770
827
  return;
771
828
  }
772
- s = 0, m();
773
- }, g = () => {
774
- o > 0 || u?.(Error(q(e.playerOrigin)));
829
+ d = 0, v();
830
+ }, b = () => {
831
+ u > 0 || m?.(Error(Pe(e.playerOrigin)));
775
832
  };
776
- n.addEventListener("load", h), n.addEventListener("error", g);
777
- let _ = (t) => {
833
+ n.addEventListener("load", y), n.addEventListener("error", b);
834
+ let x = (t) => {
778
835
  if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
779
- let a = Fe(t.data);
780
- if (a) switch (a.type) {
836
+ let i = Be(t.data);
837
+ if (i) switch (i.type) {
781
838
  case "close":
782
- e.onClose?.(a.payload);
839
+ e.onClose?.(i.payload);
783
840
  break;
784
841
  case "stateUpdate":
785
- e.onPlayerStatusChange?.(a.payload.state), e.onStateUpdate?.(a.payload.state);
842
+ e.onPlayerStatusChange?.(i.payload.state), e.onStateUpdate?.(i.payload.state);
786
843
  break;
787
844
  case "commandResult": {
788
- let e = i.get(a.payload.correlationId);
845
+ let e = c.get(i.payload.correlationId);
789
846
  if (!e) return;
790
- i.delete(a.payload.correlationId), a.payload.ok ? e.resolve(a.payload.result) : e.reject(Error(a.payload.error ?? "Command failed."));
847
+ c.delete(i.payload.correlationId), i.payload.ok ? e.resolve(i.payload.result) : e.reject(Error(i.payload.error ?? "Command failed."));
791
848
  break;
792
849
  }
793
850
  case "userTranscript":
794
- e.onUserTranscript?.(a.payload);
851
+ e.onUserTranscript?.(i.payload);
795
852
  break;
796
853
  case "characterSpeechStarted":
797
- e.onCharacterSpeechStarted?.(a.payload);
854
+ e.onCharacterSpeechStarted?.(i.payload);
798
855
  break;
799
856
  case "characterSpeechEnded":
800
- e.onCharacterSpeechEnded?.(a.payload);
857
+ e.onCharacterSpeechEnded?.(i.payload);
801
858
  break;
802
859
  case "characterFocusChanged":
803
- e.onCharacterFocusChanged?.(a.payload);
860
+ e.onCharacterFocusChanged?.(i.payload);
804
861
  break;
805
862
  case "conversationUpdate":
806
- e.onConversationUpdate?.(a.payload.conversation);
863
+ e.onConversationUpdate?.(i.payload.conversation);
807
864
  break;
808
865
  case "listeningState":
809
- e.onListeningState?.(a.payload.listening);
866
+ e.onListeningState?.(i.payload.listening);
810
867
  break;
811
868
  case "userSpeechStarted":
812
- e.onUserSpeechStarted?.(a.payload);
869
+ e.onUserSpeechStarted?.(i.payload);
813
870
  break;
814
871
  case "userSpeechEnded":
815
- e.onUserSpeechEnded?.(a.payload);
872
+ e.onUserSpeechEnded?.(i.payload);
816
873
  break;
817
874
  case "modeChange":
818
- e.onActivityChange?.(Be(a.payload.mode));
875
+ e.onActivityChange?.(Ye(i.payload.mode));
819
876
  break;
820
877
  case "activityChange":
821
- e.onActivityChange?.(a.payload.activity);
878
+ e.onActivityChange?.(i.payload.activity);
822
879
  break;
823
880
  case "feedback":
824
- e.onFeedback?.(a.payload);
881
+ e.onFeedback?.(i.payload);
825
882
  break;
826
883
  case "feedbackFailed":
827
- e.onFeedbackFailed?.(a.payload);
884
+ e.onFeedbackFailed?.(i.payload);
828
885
  break;
829
886
  case "message":
830
- e.onMessage?.(a.payload);
887
+ e.onMessage?.(i.payload);
831
888
  break;
832
889
  case "started":
833
- e.onStarted?.(a.payload);
890
+ e.onStarted?.(i.payload);
834
891
  break;
835
892
  case "embedReady":
836
- m();
893
+ v();
837
894
  break;
838
895
  case "widgetReady":
839
896
  e.onWidgetReady?.();
@@ -845,52 +902,55 @@ function He(e) {
845
902
  e.onWidgetCollapse?.();
846
903
  break;
847
904
  case "widgetAudioSettings":
848
- e.onWidgetAudioSettings?.(a.payload.open);
905
+ e.onWidgetAudioSettings?.(i.payload.open);
849
906
  break;
850
907
  case "widgetDragStart":
851
- e.onWidgetDragStart?.(a.payload);
908
+ e.onWidgetDragStart?.(i.payload);
852
909
  break;
853
910
  case "widgetDragMove":
854
- e.onWidgetDragMove?.(a.payload);
911
+ e.onWidgetDragMove?.(i.payload);
855
912
  break;
856
913
  case "widgetDragEnd":
857
- e.onWidgetDragEnd?.(a.payload);
914
+ e.onWidgetDragEnd?.(i.payload);
915
+ break;
916
+ case "fullWindow":
917
+ s(i.payload.active);
858
918
  break;
859
919
  }
860
920
  };
861
- if (window.addEventListener("message", _), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
921
+ if (window.addEventListener("message", x), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
862
922
  let e = getComputedStyle(t).minHeight;
863
923
  (e === "0px" || e === "auto") && (t.style.minHeight = "480px");
864
924
  }
865
- let v = (t, i) => {
925
+ let S = (t, i) => {
866
926
  if (r) return;
867
927
  let a = n.contentWindow;
868
- if (!a) throw Error(q(e.playerOrigin));
869
- J(a, t, e.playerOrigin, i);
870
- }, y = (e, t = 12e4, n) => {
928
+ if (!a) throw Error(Pe(e.playerOrigin));
929
+ Ie(a, t, e.playerOrigin, i);
930
+ }, C = (e, t = 12e4, n) => {
871
931
  let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Y();
872
- return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((a, o) => {
873
- i.set(r, {
874
- resolve: (e) => a(e),
875
- reject: o
876
- }), v(e, n), setTimeout(() => {
877
- i.has(r) && (i.delete(r), o(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
932
+ return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((i, a) => {
933
+ c.set(r, {
934
+ resolve: (e) => i(e),
935
+ reject: a
936
+ }), S(e, n), setTimeout(() => {
937
+ c.has(r) && (c.delete(r), a(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
878
938
  }, t);
879
939
  });
880
940
  };
881
941
  return {
882
942
  waitForLoad() {
883
- return d;
943
+ return h;
884
944
  },
885
945
  postParentHello() {
886
- v(Le());
946
+ S(He());
887
947
  },
888
948
  postLaunch(e, t, n) {
889
- r || (a = {
949
+ r || (l = {
890
950
  launch: e,
891
951
  session: t,
892
952
  chrome: n
893
- }, s = 0, p(a));
953
+ }, d = 0, _(l));
894
954
  },
895
955
  postManifest(e) {
896
956
  if (typeof e == "string") {
@@ -905,13 +965,13 @@ function He(e) {
905
965
  throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
906
966
  },
907
967
  postWidgetSetChrome(e) {
908
- v(Re(e));
968
+ S(Ue(e));
909
969
  },
910
970
  postWidgetToggleAudioSettings() {
911
- v(ze());
971
+ S(We());
912
972
  },
913
973
  speak(e) {
914
- return y({
974
+ return C({
915
975
  type: "speak",
916
976
  schemaVersion: 2,
917
977
  payload: {
@@ -923,21 +983,21 @@ function He(e) {
923
983
  });
924
984
  },
925
985
  startListening() {
926
- return y({
986
+ return C({
927
987
  type: "startListening",
928
988
  schemaVersion: 2,
929
989
  payload: { correlationId: Y() }
930
990
  });
931
991
  },
932
992
  stopListening() {
933
- return y({
993
+ return C({
934
994
  type: "stopListening",
935
995
  schemaVersion: 2,
936
996
  payload: { correlationId: Y() }
937
997
  });
938
998
  },
939
999
  listenOnce(e) {
940
- return y({
1000
+ return C({
941
1001
  type: "listenOnce",
942
1002
  schemaVersion: 2,
943
1003
  payload: {
@@ -947,7 +1007,7 @@ function He(e) {
947
1007
  });
948
1008
  },
949
1009
  async speakProcessorStream(e, t) {
950
- let n = Y(), r = Y(), i = (await y({
1010
+ let n = Y(), r = Y(), i = (await C({
951
1011
  type: "speakStreamStart",
952
1012
  schemaVersion: 2,
953
1013
  payload: {
@@ -959,7 +1019,7 @@ function He(e) {
959
1019
  try {
960
1020
  for await (let n of e) {
961
1021
  if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
962
- n && v({
1022
+ n && S({
963
1023
  type: "speakStreamChunk",
964
1024
  schemaVersion: 2,
965
1025
  payload: {
@@ -969,7 +1029,7 @@ function He(e) {
969
1029
  });
970
1030
  }
971
1031
  if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
972
- return await y({
1032
+ return await C({
973
1033
  type: "speakStreamEnd",
974
1034
  schemaVersion: 2,
975
1035
  payload: {
@@ -979,7 +1039,7 @@ function He(e) {
979
1039
  });
980
1040
  } catch (e) {
981
1041
  try {
982
- await y({
1042
+ await C({
983
1043
  type: "speakStreamEnd",
984
1044
  schemaVersion: 2,
985
1045
  payload: {
@@ -993,7 +1053,7 @@ function He(e) {
993
1053
  },
994
1054
  speechPlay(e) {
995
1055
  let t = Y(), n = [];
996
- return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), y({
1056
+ return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), C({
997
1057
  type: "speechPlay",
998
1058
  schemaVersion: 2,
999
1059
  payload: {
@@ -1007,7 +1067,7 @@ function He(e) {
1007
1067
  }, 12e4, n);
1008
1068
  },
1009
1069
  speechUtteranceBegin(e) {
1010
- return y({
1070
+ return C({
1011
1071
  type: "speechUtteranceBegin",
1012
1072
  schemaVersion: 2,
1013
1073
  payload: {
@@ -1021,7 +1081,7 @@ function He(e) {
1021
1081
  });
1022
1082
  },
1023
1083
  speechUtteranceWrite(e) {
1024
- return y({
1084
+ return C({
1025
1085
  type: "speechUtteranceWrite",
1026
1086
  schemaVersion: 2,
1027
1087
  payload: {
@@ -1030,10 +1090,10 @@ function He(e) {
1030
1090
  audio: e.audio,
1031
1091
  byteLength: e.byteLength
1032
1092
  }
1033
- }, Ve, [e.audio]);
1093
+ }, Xe, [e.audio]);
1034
1094
  },
1035
1095
  speechUtteranceSetTranscript(e) {
1036
- return y({
1096
+ return C({
1037
1097
  type: "speechUtteranceSetTranscript",
1038
1098
  schemaVersion: 2,
1039
1099
  payload: {
@@ -1044,7 +1104,7 @@ function He(e) {
1044
1104
  });
1045
1105
  },
1046
1106
  speechUtteranceClose(e) {
1047
- return y({
1107
+ return C({
1048
1108
  type: "speechUtteranceClose",
1049
1109
  schemaVersion: 2,
1050
1110
  payload: {
@@ -1056,7 +1116,7 @@ function He(e) {
1056
1116
  });
1057
1117
  },
1058
1118
  speechUtteranceCancel(e) {
1059
- return y({
1119
+ return C({
1060
1120
  type: "speechUtteranceCancel",
1061
1121
  schemaVersion: 2,
1062
1122
  payload: {
@@ -1066,7 +1126,7 @@ function He(e) {
1066
1126
  });
1067
1127
  },
1068
1128
  speechInterrupt(e) {
1069
- return y({
1129
+ return C({
1070
1130
  type: "speechInterrupt",
1071
1131
  schemaVersion: 2,
1072
1132
  payload: {
@@ -1076,14 +1136,14 @@ function He(e) {
1076
1136
  });
1077
1137
  },
1078
1138
  getConversation() {
1079
- return y({
1139
+ return C({
1080
1140
  type: "getConversation",
1081
1141
  schemaVersion: 2,
1082
1142
  payload: { correlationId: Y() }
1083
1143
  });
1084
1144
  },
1085
1145
  focusCharacter(e) {
1086
- return y({
1146
+ return C({
1087
1147
  type: "focusCharacter",
1088
1148
  schemaVersion: 2,
1089
1149
  payload: {
@@ -1093,7 +1153,7 @@ function He(e) {
1093
1153
  });
1094
1154
  },
1095
1155
  setFit(e) {
1096
- return y({
1156
+ return C({
1097
1157
  type: "setFit",
1098
1158
  schemaVersion: 2,
1099
1159
  payload: {
@@ -1102,18 +1162,28 @@ function He(e) {
1102
1162
  }
1103
1163
  });
1104
1164
  },
1165
+ conversion(e) {
1166
+ return C({
1167
+ type: "conversion",
1168
+ schemaVersion: 2,
1169
+ payload: {
1170
+ correlationId: Y(),
1171
+ key: e
1172
+ }
1173
+ });
1174
+ },
1105
1175
  destroy() {
1106
1176
  if (!r) {
1107
- r = !0;
1108
- for (let e of i.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
1109
- i.clear(), f(), a = null, n.removeEventListener("load", h), n.removeEventListener("error", g), window.removeEventListener("message", _), n.remove();
1177
+ r = !0, i && s(!1);
1178
+ for (let e of c.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
1179
+ c.clear(), g(), l = null, n.removeEventListener("load", y), n.removeEventListener("error", b), window.removeEventListener("message", x), n.remove();
1110
1180
  }
1111
1181
  }
1112
1182
  };
1113
1183
  }
1114
1184
  //#endregion
1115
1185
  //#region src/v2/embed/readyGate.ts
1116
- function Ue(e) {
1186
+ function Qe(e) {
1117
1187
  let t, n = !1, r = !1, i = () => {
1118
1188
  r || !n || t === void 0 || (r = !0, e(t));
1119
1189
  };
@@ -1128,50 +1198,50 @@ function Ue(e) {
1128
1198
  }
1129
1199
  //#endregion
1130
1200
  //#region src/v2/shims/embedBaseUrl.ts
1131
- var We = "https://player.liforma.ai/embed", Ge = "http://localhost:3002/embed";
1132
- function Ke() {
1201
+ var $e = "https://player.liforma.ai/embed", et = "http://localhost:3002/embed";
1202
+ function tt() {
1133
1203
  let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
1134
1204
  if (e?.trim()) return e.trim().replace(/\/$/, "");
1135
1205
  if (typeof document > "u") return null;
1136
1206
  let t = (document.querySelector("script[data-liforma-sdk][src*=\"client.js\"]") ?? document.querySelector("script[src*=\"/sdk/v2/client.js\"]"))?.getAttribute("data-player-embed-url")?.trim();
1137
1207
  return t ? t.replace(/\/$/, "") : null;
1138
1208
  }
1139
- function qe() {
1140
- let e = Ke();
1141
- return e ? e.endsWith("/embed") ? e : `${e}/embed` : l() ? Ge : We;
1209
+ function nt() {
1210
+ let e = tt();
1211
+ return e ? e.endsWith("/embed") ? e : `${e}/embed` : l() ? et : $e;
1142
1212
  }
1143
- function Je(e, t) {
1213
+ function rt(e, t) {
1144
1214
  return e?.trim() || t?.trim() || void 0;
1145
1215
  }
1146
- function Ye(e, t, n, r, i, a, o, s) {
1147
- let c = (e ?? qe()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
1216
+ function it(e, t, n, r, i, a, o, s) {
1217
+ let c = (e ?? nt()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
1148
1218
  d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
1149
1219
  let f = r?.trim();
1150
- return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)), Xe(u.toString());
1220
+ return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)), at(u.toString());
1151
1221
  }
1152
- function Xe(e) {
1222
+ function at(e) {
1153
1223
  if (typeof location > "u") return e;
1154
1224
  let t = new URL(e);
1155
1225
  return t.searchParams.set("parentOrigin", location.origin), t.toString();
1156
1226
  }
1157
- function Ze(e) {
1227
+ function ot(e) {
1158
1228
  return new URL(e).origin;
1159
1229
  }
1160
1230
  //#endregion
1161
1231
  //#region src/v2/experienceEvents.ts
1162
- function Qe() {
1232
+ function st() {
1163
1233
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `evt_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}` : `evt_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
1164
1234
  }
1165
- function $e(e, t, n) {
1235
+ function ct(e, t, n) {
1166
1236
  return {
1167
- id: Qe(),
1237
+ id: st(),
1168
1238
  type: e,
1169
1239
  sessionId: t,
1170
1240
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1171
1241
  data: n
1172
1242
  };
1173
1243
  }
1174
- function et() {
1244
+ function lt() {
1175
1245
  return {
1176
1246
  ready: /* @__PURE__ */ new Set(),
1177
1247
  started: /* @__PURE__ */ new Set(),
@@ -1190,32 +1260,32 @@ function et() {
1190
1260
  conversationProcessorError: /* @__PURE__ */ new Set()
1191
1261
  };
1192
1262
  }
1193
- function tt(e, t, n) {
1263
+ function ut(e, t, n) {
1194
1264
  return e[t].add(n), () => e[t].delete(n);
1195
1265
  }
1196
- function nt(e, t, n) {
1266
+ function dt(e, t, n) {
1197
1267
  for (let r of e[t]) r(n);
1198
1268
  }
1199
- function rt(e) {
1269
+ function ft(e) {
1200
1270
  for (let t of Object.keys(e)) e[t].clear();
1201
1271
  }
1202
1272
  //#endregion
1203
1273
  //#region src/v2/speech/types.ts
1204
- function it(e) {
1274
+ function pt(e) {
1205
1275
  return "data" in e && "format" in e && e.format != null && !("track" in e);
1206
1276
  }
1207
- function at(e) {
1277
+ function mt(e) {
1208
1278
  return "url" in e && typeof e.url == "string";
1209
1279
  }
1210
- function ot(e) {
1280
+ function ht(e) {
1211
1281
  if (!("track" in e)) return !1;
1212
1282
  let t = e.track;
1213
1283
  return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
1214
1284
  }
1215
- function st(e) {
1216
- return !it(e) && !at(e) && !ot(e) && "encoding" in e && typeof e.encoding == "string";
1285
+ function gt(e) {
1286
+ return !pt(e) && !mt(e) && !ht(e) && "encoding" in e && typeof e.encoding == "string";
1217
1287
  }
1218
- var ct = [
1288
+ var _t = [
1219
1289
  8e3,
1220
1290
  16e3,
1221
1291
  22050,
@@ -1233,14 +1303,14 @@ var ct = [
1233
1303
  MAX_UTTERANCE_DURATION_MS: 9e4,
1234
1304
  MAX_PENDING_WRITES: 8,
1235
1305
  DEFAULT_WRITE_TIMEOUT_MS: 5e3
1236
- }, lt = class extends Error {
1306
+ }, vt = class extends Error {
1237
1307
  operation;
1238
1308
  requiredCapability;
1239
1309
  name = "UnsupportedSpeechOperationError";
1240
1310
  constructor(e, t) {
1241
1311
  super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
1242
1312
  }
1243
- }, ut = class extends Error {
1313
+ }, yt = class extends Error {
1244
1314
  name = "SpeechUtteranceClosedError";
1245
1315
  constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
1246
1316
  super(e);
@@ -1250,72 +1320,72 @@ var ct = [
1250
1320
  constructor(e, t) {
1251
1321
  super(e, t);
1252
1322
  }
1253
- }, dt = class extends Error {
1323
+ }, bt = class extends Error {
1254
1324
  name = "SpeechBufferTimeoutError";
1255
1325
  constructor(e = "Timed out waiting for speech buffer capacity.") {
1256
1326
  super(e);
1257
1327
  }
1258
1328
  };
1259
- function ft(e = "none") {
1329
+ function xt(e = "none") {
1260
1330
  return {
1261
1331
  mode: e,
1262
1332
  trackedDurationMs: 0,
1263
1333
  fallbackDurationMs: 0
1264
1334
  };
1265
1335
  }
1266
- function pt(e) {
1267
- return ct.includes(e);
1336
+ function St(e) {
1337
+ return _t.includes(e);
1268
1338
  }
1269
- function mt(e) {
1339
+ function Ct(e) {
1270
1340
  if (e.encoding !== "pcm_s16le") throw new Z(`Unsupported audio encoding: ${e.encoding}`);
1271
1341
  if (e.channels !== 1) throw new Z(`Unsupported channel count: ${e.channels}`);
1272
- if (!pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1342
+ if (!St(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1273
1343
  }
1274
- function ht(e) {
1275
- if (it(e)) {
1276
- mt(e.format);
1344
+ function wt(e) {
1345
+ if (pt(e)) {
1346
+ Ct(e.format);
1277
1347
  return;
1278
1348
  }
1279
- if (at(e)) {
1349
+ if (mt(e)) {
1280
1350
  if (!e.url.trim()) throw new Z("Audio URL must be non-empty.");
1281
- if (e.sampleRate !== void 0 && !pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1351
+ if (e.sampleRate !== void 0 && !St(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1282
1352
  return;
1283
1353
  }
1284
- if (ot(e)) {
1354
+ if (ht(e)) {
1285
1355
  if (e.track.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
1286
- if (e.sampleRate !== void 0 && !pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1356
+ if (e.sampleRate !== void 0 && !St(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1287
1357
  return;
1288
1358
  }
1289
- if (st(e)) {
1359
+ if (gt(e)) {
1290
1360
  let t = e.encoding.trim().toLowerCase();
1291
1361
  if (!t) throw new Z("Encoded audio MIME type is required.");
1292
1362
  if (t === "pcm_s16le") throw new Z("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
1293
- if (e.sampleRate !== void 0 && !pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1363
+ if (e.sampleRate !== void 0 && !St(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1294
1364
  return;
1295
1365
  }
1296
1366
  throw new Z("Unsupported speech.play audio shape.");
1297
1367
  }
1298
- function gt(e) {
1299
- if (e.format) return mt(e.format), e.format;
1368
+ function Tt(e) {
1369
+ if (e.format) return Ct(e.format), e.format;
1300
1370
  if (e.track) {
1301
1371
  let t = {
1302
1372
  encoding: "pcm_s16le",
1303
1373
  sampleRate: e.sampleRate ?? 24e3,
1304
1374
  channels: 1
1305
1375
  };
1306
- return mt(t), t;
1376
+ return Ct(t), t;
1307
1377
  }
1308
1378
  throw new Z("createUtterance requires format or track.");
1309
1379
  }
1310
- function _t(e) {
1380
+ function Et(e) {
1311
1381
  return e instanceof Uint8Array ? e : new Uint8Array(e);
1312
1382
  }
1313
- function vt(e) {
1383
+ function Dt(e) {
1314
1384
  return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
1315
1385
  }
1316
1386
  //#endregion
1317
1387
  //#region src/byo/pcm.ts
1318
- function yt(e) {
1388
+ function Ot(e) {
1319
1389
  let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
1320
1390
  for (let t = 0; t < e.length; t++) {
1321
1391
  let r = Math.max(-1, Math.min(1, e[t]));
@@ -1325,11 +1395,11 @@ function yt(e) {
1325
1395
  }
1326
1396
  //#endregion
1327
1397
  //#region src/byo/resample.ts
1328
- function bt(e, t, n, r, i) {
1398
+ function kt(e, t, n, r, i) {
1329
1399
  let a = -.5 * e + 1.5 * t - 1.5 * n + .5 * r, o = e - 2.5 * t + 2 * n - .5 * r, s = -.5 * e + .5 * n, c = t;
1330
1400
  return ((a * i + o) * i + s) * i + c;
1331
1401
  }
1332
- function xt(e, t) {
1402
+ function At(e, t) {
1333
1403
  if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
1334
1404
  if (e === t) return {
1335
1405
  fromRate: e,
@@ -1352,7 +1422,7 @@ function xt(e, t) {
1352
1422
  let a = [];
1353
1423
  for (; i + 2 < r.length - 1;) {
1354
1424
  let e = Math.floor(i), t = i - e, o = Math.max(0, e - 1), s = Math.min(r.length - 1, e + 1), c = Math.min(r.length - 1, e + 2);
1355
- a.push(bt(r[o], r[e], r[s], r[c], t)), i += n;
1425
+ a.push(kt(r[o], r[e], r[s], r[c], t)), i += n;
1356
1426
  }
1357
1427
  let o = Math.max(0, Math.floor(i) - 1);
1358
1428
  return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
@@ -1364,7 +1434,7 @@ function xt(e, t) {
1364
1434
  }
1365
1435
  //#endregion
1366
1436
  //#region src/byo/audioCapture.ts
1367
- var St = "liforma-pcm-capture", Ct = `
1437
+ var jt = "liforma-pcm-capture", Mt = `
1368
1438
  class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
1369
1439
  process(inputs) {
1370
1440
  const ch = inputs[0] && inputs[0][0];
@@ -1376,29 +1446,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
1376
1446
  return true;
1377
1447
  }
1378
1448
  }
1379
- registerProcessor('${St}', LiformaPcmCaptureProcessor);
1380
- `, wt = null;
1381
- function Tt() {
1382
- return wt ||= URL.createObjectURL(new Blob([Ct], { type: "application/javascript" })), wt;
1449
+ registerProcessor('${jt}', LiformaPcmCaptureProcessor);
1450
+ `, Nt = null;
1451
+ function Pt() {
1452
+ return Nt ||= URL.createObjectURL(new Blob([Mt], { type: "application/javascript" })), Nt;
1383
1453
  }
1384
- function Et() {
1454
+ function Ft() {
1385
1455
  return window.AudioContext || window.webkitAudioContext || null;
1386
1456
  }
1387
- async function Dt(e) {
1388
- let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Et();
1457
+ async function It(e) {
1458
+ let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Ft();
1389
1459
  if (!o) throw Error("Web Audio is required for audio capture");
1390
1460
  let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
1391
1461
  l.gain.value = 0;
1392
- let u = s.sampleRate, d = xt(u, n), f = !1, p = !1, m = (e) => {
1462
+ let u = s.sampleRate, d = At(u, n), f = !1, p = !1, m = (e) => {
1393
1463
  if (f || i && !i()) return;
1394
1464
  let t = d.push(e);
1395
- t.length !== 0 && r(yt(t));
1465
+ t.length !== 0 && r(Ot(t));
1396
1466
  }, h = () => void 0;
1397
1467
  return await (async () => {
1398
1468
  if (typeof s.audioWorklet?.addModule != "function") return !1;
1399
1469
  try {
1400
- await s.audioWorklet.addModule(Tt());
1401
- let e = new AudioWorkletNode(s, St, {
1470
+ await s.audioWorklet.addModule(Pt());
1471
+ let e = new AudioWorkletNode(s, jt, {
1402
1472
  numberOfInputs: 1,
1403
1473
  numberOfOutputs: 1,
1404
1474
  outputChannelCount: [1]
@@ -1448,7 +1518,7 @@ async function Dt(e) {
1448
1518
  }
1449
1519
  //#endregion
1450
1520
  //#region src/v2/speech/captureMediaStreamTrack.ts
1451
- async function Ot(e) {
1521
+ async function Lt(e) {
1452
1522
  let { track: t, utterance: n, sampleRate: r, signal: i } = e;
1453
1523
  if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Z("MediaStreamTrack is not available in this environment.");
1454
1524
  if (t.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
@@ -1457,13 +1527,13 @@ async function Ot(e) {
1457
1527
  s || (s = !0, c?.stop(), c = null);
1458
1528
  };
1459
1529
  try {
1460
- c = await Dt({
1530
+ c = await It({
1461
1531
  mediaStream: a,
1462
1532
  targetSampleRate: r,
1463
1533
  shouldSend: () => !s && !i?.aborted,
1464
1534
  onPcm: (e) => {
1465
1535
  if (s || i?.aborted) return;
1466
- let t = _t(e);
1536
+ let t = Et(e);
1467
1537
  o = o.then(async () => {
1468
1538
  if (s || i?.aborted) return;
1469
1539
  let e = 0;
@@ -1492,10 +1562,10 @@ async function Ot(e) {
1492
1562
  }
1493
1563
  //#endregion
1494
1564
  //#region src/v2/speech/speechController.ts
1495
- async function kt(e, t) {
1496
- if (ot(e)) throw new Z("MediaStreamTrack play is handled on the host before embed.");
1497
- if (it(e)) {
1498
- let t = _t(e.data);
1565
+ async function Rt(e, t) {
1566
+ if (ht(e)) throw new Z("MediaStreamTrack play is handled on the host before embed.");
1567
+ if (pt(e)) {
1568
+ let t = Et(e.data);
1499
1569
  if (t.byteLength & 1) throw new Z("PCM byte length must be even.");
1500
1570
  return {
1501
1571
  kind: "pcm",
@@ -1503,17 +1573,17 @@ async function kt(e, t) {
1503
1573
  format: e.format
1504
1574
  };
1505
1575
  }
1506
- if (at(e)) return {
1576
+ if (mt(e)) return {
1507
1577
  kind: "url",
1508
1578
  url: e.url.trim(),
1509
1579
  ...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
1510
1580
  };
1511
- if (!st(e)) throw new Z("Unsupported speech.play audio shape.");
1581
+ if (!gt(e)) throw new Z("Unsupported speech.play audio shape.");
1512
1582
  let n;
1513
1583
  if (typeof Blob < "u" && e.data instanceof Blob) {
1514
1584
  if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
1515
1585
  n = new Uint8Array(await e.data.arrayBuffer());
1516
- } else n = _t(e.data);
1586
+ } else n = Et(e.data);
1517
1587
  return {
1518
1588
  kind: "encoded",
1519
1589
  data: n.slice().buffer,
@@ -1521,10 +1591,10 @@ async function kt(e, t) {
1521
1591
  ...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
1522
1592
  };
1523
1593
  }
1524
- function At() {
1594
+ function zt() {
1525
1595
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `utt_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}` : `utt_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
1526
1596
  }
1527
- function jt(e, t = "completed") {
1597
+ function Bt(e, t = "completed") {
1528
1598
  return {
1529
1599
  utteranceId: e.speechId,
1530
1600
  characterId: e.characterId,
@@ -1538,13 +1608,13 @@ function jt(e, t = "completed") {
1538
1608
  }
1539
1609
  };
1540
1610
  }
1541
- function Mt(e) {
1611
+ function Vt(e) {
1542
1612
  return e instanceof Error ? e : new Z(String(e));
1543
1613
  }
1544
- function Nt(e) {
1614
+ function Ht(e) {
1545
1615
  return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
1546
1616
  }
1547
- var Pt = class {
1617
+ var Ut = class {
1548
1618
  id;
1549
1619
  characterId;
1550
1620
  result;
@@ -1573,14 +1643,14 @@ var Pt = class {
1573
1643
  queue: e.queue,
1574
1644
  ...e.transcript === void 0 ? {} : { transcript: e.transcript }
1575
1645
  }).catch((e) => {
1576
- throw this.fail(Mt(e)), Mt(e);
1646
+ throw this.fail(Vt(e)), Vt(e);
1577
1647
  }), this.signal?.addEventListener("abort", () => {
1578
1648
  this.cancel();
1579
1649
  }, { once: !0 });
1580
1650
  }
1581
1651
  async write(e, t) {
1582
- if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new ut();
1583
- let n = _t(e);
1652
+ if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new yt();
1653
+ let n = Et(e);
1584
1654
  if (n.byteLength & 1) throw new Z("PCM chunk byte length must be even (complete s16 samples).");
1585
1655
  if (n.byteLength > X.MAX_CHUNK_BYTES) throw new Z(`PCM chunk exceeds MAX_CHUNK_BYTES (${X.MAX_CHUNK_BYTES}).`);
1586
1656
  if (n.byteLength === 0) return;
@@ -1589,13 +1659,13 @@ var Pt = class {
1589
1659
  let i = n.byteLength / 2 / this.sampleRate * 1e3;
1590
1660
  if (this.bufferedMs + i > X.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Z("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
1591
1661
  let a = async () => {
1592
- if (this.closed || this.settled) throw new ut();
1662
+ if (this.closed || this.settled) throw new yt();
1593
1663
  let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
1594
1664
  utteranceId: this.id,
1595
1665
  audio: t.buffer,
1596
1666
  byteLength: t.byteLength
1597
1667
  }), a = await Promise.race([i, new Promise((e, t) => {
1598
- setTimeout(() => t(new dt()), r);
1668
+ setTimeout(() => t(new bt()), r);
1599
1669
  })]);
1600
1670
  this.bufferedMs = Math.max(0, a.bufferedMs);
1601
1671
  }, o = this.writeChain.then(a, a);
@@ -1607,7 +1677,7 @@ var Pt = class {
1607
1677
  }
1608
1678
  }
1609
1679
  async setTranscript(e) {
1610
- if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new ut();
1680
+ if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new yt();
1611
1681
  await this.requireHost().speechUtteranceSetTranscript({
1612
1682
  utteranceId: this.id,
1613
1683
  transcript: e
@@ -1624,7 +1694,7 @@ var Pt = class {
1624
1694
  });
1625
1695
  return this.resolve(t), t;
1626
1696
  } catch (e) {
1627
- let t = Mt(e);
1697
+ let t = Vt(e);
1628
1698
  throw this.fail(t), t;
1629
1699
  }
1630
1700
  }
@@ -1642,11 +1712,11 @@ var Pt = class {
1642
1712
  characterId: this.characterId,
1643
1713
  status: "cancelled",
1644
1714
  durationMs: 0,
1645
- animation: ft("none")
1715
+ animation: xt("none")
1646
1716
  };
1647
1717
  return this.resolve(t), t;
1648
1718
  } catch (e) {
1649
- let t = Mt(e);
1719
+ let t = Vt(e);
1650
1720
  throw this.fail(t), t;
1651
1721
  }
1652
1722
  }
@@ -1659,7 +1729,7 @@ var Pt = class {
1659
1729
  return e;
1660
1730
  }
1661
1731
  resolve(e) {
1662
- this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new ut()));
1732
+ this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new yt()));
1663
1733
  }
1664
1734
  fail(e) {
1665
1735
  this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
@@ -1671,7 +1741,7 @@ var Pt = class {
1671
1741
  }
1672
1742
  await new Promise((t, n) => {
1673
1743
  let r = setTimeout(() => {
1674
- n(new dt());
1744
+ n(new bt());
1675
1745
  }, e);
1676
1746
  this.pendingWriteWaiters.push({
1677
1747
  resolve: () => {
@@ -1690,13 +1760,13 @@ var Pt = class {
1690
1760
  for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
1691
1761
  }
1692
1762
  };
1693
- function Ft(e) {
1763
+ function Wt(e) {
1694
1764
  let t = null, n = (t, n) => {
1695
- if (!e.getCapabilities()[n]) throw new lt(t, n);
1765
+ if (!e.getCapabilities()[n]) throw new vt(t, n);
1696
1766
  }, r = {
1697
1767
  async speak(r) {
1698
1768
  if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
1699
- let i = vt(r.queue ?? "append");
1769
+ let i = Dt(r.queue ?? "append");
1700
1770
  i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
1701
1771
  let a = e.getIframeHost();
1702
1772
  if (!a) throw new Z("Speech session is not attached.");
@@ -1716,41 +1786,41 @@ function Ft(e) {
1716
1786
  return;
1717
1787
  }
1718
1788
  t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
1719
- t.removeEventListener("abort", s), n(jt(e, "completed"));
1789
+ t.removeEventListener("abort", s), n(Bt(e, "completed"));
1720
1790
  }, (a) => {
1721
- if (t.removeEventListener("abort", s), Nt(a)) {
1791
+ if (t.removeEventListener("abort", s), Ht(a)) {
1722
1792
  n({
1723
1793
  utteranceId: "utt_interrupted",
1724
1794
  characterId: r.characterId ?? e.getActiveCharacterId(),
1725
1795
  status: "interrupted",
1726
1796
  durationMs: 0,
1727
1797
  transcript: r.text,
1728
- animation: ft("none")
1798
+ animation: xt("none")
1729
1799
  });
1730
1800
  return;
1731
1801
  }
1732
- i(Mt(a));
1802
+ i(Vt(a));
1733
1803
  });
1734
1804
  });
1735
1805
  }
1736
1806
  try {
1737
- return jt(await o, "completed");
1807
+ return Bt(await o, "completed");
1738
1808
  } catch (t) {
1739
- if (Nt(t)) return {
1809
+ if (Ht(t)) return {
1740
1810
  utteranceId: "utt_interrupted",
1741
1811
  characterId: r.characterId ?? e.getActiveCharacterId(),
1742
1812
  status: "interrupted",
1743
1813
  durationMs: 0,
1744
1814
  transcript: r.text,
1745
- animation: ft("none")
1815
+ animation: xt("none")
1746
1816
  };
1747
- throw Mt(t);
1817
+ throw Vt(t);
1748
1818
  }
1749
1819
  },
1750
1820
  async play(i) {
1751
- if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), ht(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
1821
+ if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), wt(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
1752
1822
  let a = i.queue ?? "append";
1753
- if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), ot(i.audio)) {
1823
+ if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), ht(i.audio)) {
1754
1824
  let e = i.audio.sampleRate ?? 24e3;
1755
1825
  return r.createUtterance({
1756
1826
  format: {
@@ -1766,7 +1836,7 @@ function Ft(e) {
1766
1836
  }
1767
1837
  let o = e.getIframeHost();
1768
1838
  if (!o) throw new Z("Speech session is not attached.");
1769
- let s = await kt(i.audio, i.signal);
1839
+ let s = await Rt(i.audio, i.signal);
1770
1840
  return o.speechPlay({
1771
1841
  source: s,
1772
1842
  characterId: i.characterId,
@@ -1778,13 +1848,13 @@ function Ft(e) {
1778
1848
  },
1779
1849
  createUtterance(r) {
1780
1850
  e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
1781
- let i = gt(r);
1851
+ let i = Tt(r);
1782
1852
  if (r.track && r.track.kind !== "audio") throw new Z("createUtterance track must be an audio MediaStreamTrack.");
1783
1853
  let a = r.queue ?? "replace-active";
1784
1854
  if (a !== "replace-active" && a !== "replace-all") throw new Z("createUtterance queue must be replace-active or replace-all.");
1785
1855
  e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
1786
- let o = new Pt({
1787
- id: At(),
1856
+ let o = new Ut({
1857
+ id: zt(),
1788
1858
  characterId: r.characterId ?? e.getActiveCharacterId(),
1789
1859
  format: i,
1790
1860
  queue: a,
@@ -1796,7 +1866,7 @@ function Ft(e) {
1796
1866
  t === o && (t = null);
1797
1867
  }), r.track && (async () => {
1798
1868
  try {
1799
- if (await Ot({
1869
+ if (await Lt({
1800
1870
  track: r.track,
1801
1871
  utterance: o,
1802
1872
  sampleRate: i.sampleRate,
@@ -1824,16 +1894,16 @@ function Ft(e) {
1824
1894
  }
1825
1895
  //#endregion
1826
1896
  //#region src/v2/types/sessionInteraction.ts
1827
- function It(e) {
1897
+ function Gt(e) {
1828
1898
  let t = e?.trim();
1829
1899
  return t === "full" || t === "face" || t === "medium" ? t : void 0;
1830
1900
  }
1831
1901
  //#endregion
1832
1902
  //#region src/v2/experience.ts
1833
- function Lt(e) {
1903
+ function Kt(e) {
1834
1904
  return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
1835
1905
  }
1836
- var Rt = class e {
1906
+ var qt = class e {
1837
1907
  bootstrap;
1838
1908
  conversationProcessor;
1839
1909
  iframeHost = null;
@@ -1848,16 +1918,16 @@ var Rt = class e {
1848
1918
  attached = !1;
1849
1919
  pendingFit = null;
1850
1920
  closeHandlers = [];
1851
- eventRegistry = et();
1921
+ eventRegistry = lt();
1852
1922
  readyEnvelope = null;
1853
1923
  startedEnvelope = null;
1854
1924
  conversationCache = [];
1855
1925
  speech;
1856
1926
  constructor(e) {
1857
- this.bootstrap = e, this.conversationProcessor = e.conversationProcessor ?? null, this.resolvedSession = e.kind === "launch" ? e.session ?? null : null, this.launchToken = e.kind === "launch" ? e.launch : null, this.speech = Ft({
1927
+ this.bootstrap = e, this.conversationProcessor = e.conversationProcessor ?? null, this.resolvedSession = e.kind === "launch" ? e.session ?? null : null, this.launchToken = e.kind === "launch" ? e.launch : null, this.speech = Wt({
1858
1928
  getIframeHost: () => this.iframeHost,
1859
1929
  assertSessionStarted: () => this.assertSessionStarted(),
1860
- getCapabilities: () => zt(this.resolvedSession),
1930
+ getCapabilities: () => Jt(this.resolvedSession),
1861
1931
  getActiveCharacterId: () => "character_unknown",
1862
1932
  onProcessorInterrupt: () => {
1863
1933
  this.processorAbortController?.abort(), this.processorAbortController = null;
@@ -1901,6 +1971,7 @@ var Rt = class e {
1901
1971
  mode: t.mode,
1902
1972
  speechInputMode: t.speechInputMode,
1903
1973
  speechOnly: t.speechOnly,
1974
+ attribution: t.attribution,
1904
1975
  ui: t.ui,
1905
1976
  onStart: t.onStart,
1906
1977
  onUserTranscript: t.onUserTranscript,
@@ -1922,6 +1993,7 @@ var Rt = class e {
1922
1993
  mode: t.mode,
1923
1994
  speechInputMode: t.speechInputMode,
1924
1995
  speechOnly: t.speechOnly,
1996
+ attribution: t.attribution,
1925
1997
  ui: t.ui,
1926
1998
  onStart: t.onStart,
1927
1999
  onUserTranscript: t.onUserTranscript,
@@ -1936,7 +2008,7 @@ var Rt = class e {
1936
2008
  return null;
1937
2009
  }
1938
2010
  on(e, t) {
1939
- let n = tt(this.eventRegistry, e, t);
2011
+ let n = ut(this.eventRegistry, e, t);
1940
2012
  return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
1941
2013
  }
1942
2014
  async attach(e) {
@@ -1950,13 +2022,13 @@ var Rt = class e {
1950
2022
  if (this.closed) throw Error("Session has ended.");
1951
2023
  if (this.attached && this.iframeHost) return this.createPlayerFacade();
1952
2024
  this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
1953
- let t = this.bootstrap.embedBaseUrl ?? qe(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = Ye(t, n, r ? void 0 : Je(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, Lt(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = Ze(i), o = null, s = new Promise((e) => {
2025
+ let t = this.bootstrap.embedBaseUrl ?? nt(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = it(t, n, r ? void 0 : rt(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, Kt(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = ot(i), o = null, s = new Promise((e) => {
1954
2026
  o = e;
1955
2027
  }), c = null, l = new Promise((e) => {
1956
2028
  c = e;
1957
- }), u = Ue((e) => {
2029
+ }), u = Qe((e) => {
1958
2030
  this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
1959
- }), d = this.bootstrap.onUserTranscript, f = He({
2031
+ }), d = this.bootstrap.onUserTranscript, f = Ze({
1960
2032
  container: e.container,
1961
2033
  src: i,
1962
2034
  playerOrigin: a,
@@ -2019,7 +2091,7 @@ var Rt = class e {
2019
2091
  onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
2020
2092
  });
2021
2093
  this.iframeHost = f;
2022
- let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), K(this.bootstrap.sessionEndpoint, {
2094
+ let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), J(this.bootstrap.sessionEndpoint, {
2023
2095
  experienceId: this.bootstrap.experienceId,
2024
2096
  locale: this.bootstrap.locale,
2025
2097
  secondaryLocale: this.bootstrap.secondaryLocale,
@@ -2028,15 +2100,17 @@ var Rt = class e {
2028
2100
  mode: p.mode,
2029
2101
  speechInputMode: p.speechInputMode,
2030
2102
  speechOnly: this.bootstrap.speechOnly,
2103
+ attribution: this.bootstrap.attribution,
2031
2104
  signal: this.endpointAbortController.signal
2032
- })) : this.bootstrap.kind === "public" ? Ee(this.bootstrap.experienceId, {
2105
+ })) : this.bootstrap.kind === "public" ? ke(this.bootstrap.experienceId, {
2033
2106
  locale: this.bootstrap.locale,
2034
2107
  secondaryLocale: this.bootstrap.secondaryLocale,
2035
2108
  learningLocale: this.bootstrap.learningLocale,
2036
2109
  language: this.bootstrap.language,
2037
2110
  mode: p.mode,
2038
2111
  speechInputMode: p.speechInputMode,
2039
- speechOnly: this.bootstrap.speechOnly
2112
+ speechOnly: this.bootstrap.speechOnly,
2113
+ attribution: this.bootstrap.attribution
2040
2114
  }) : Promise.resolve(this.bootstrap.session ? {
2041
2115
  session: this.bootstrap.session,
2042
2116
  launch: this.bootstrap.launch
@@ -2051,7 +2125,7 @@ var Rt = class e {
2051
2125
  f.postParentHello();
2052
2126
  let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
2053
2127
  if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
2054
- return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && ye(_), f.postLaunch(g, _, {
2128
+ return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && Se(_), f.postLaunch(g, _, {
2055
2129
  startButton: e.startButton,
2056
2130
  showFeedback: e.showFeedback
2057
2131
  }), u.setValue(_)) : f.postLaunch(g, void 0, {
@@ -2085,11 +2159,16 @@ var Rt = class e {
2085
2159
  this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
2086
2160
  }
2087
2161
  async setFit(e) {
2088
- let t = It(e);
2162
+ let t = Gt(e);
2089
2163
  if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
2090
2164
  if (this.closed) throw Error("Session has ended.");
2091
2165
  this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
2092
2166
  }
2167
+ async conversion(e) {
2168
+ if (this.closed) throw Error("Session has ended.");
2169
+ if (!this.iframeHost) throw Error("conversion() requires attach() first.");
2170
+ await this.iframeHost.conversion(e);
2171
+ }
2093
2172
  getLastTurn() {
2094
2173
  if (this.conversationCache.length === 0) return [];
2095
2174
  let e = this.conversationCache[this.conversationCache.length - 1].turnId;
@@ -2099,7 +2178,7 @@ var Rt = class e {
2099
2178
  this.close();
2100
2179
  }
2101
2180
  destroy() {
2102
- this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null, rt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
2181
+ this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null, ft(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
2103
2182
  }
2104
2183
  resolveMintInteraction() {
2105
2184
  return this.bootstrap.kind === "launch" ? {} : {
@@ -2111,8 +2190,8 @@ var Rt = class e {
2111
2190
  return this.resolvedSession?.id ?? "";
2112
2191
  }
2113
2192
  emitWrapped(e, t) {
2114
- let n = $e(e, this.getSessionId(), t);
2115
- return nt(this.eventRegistry, e, n), n;
2193
+ let n = ct(e, this.getSessionId(), t);
2194
+ return dt(this.eventRegistry, e, n), n;
2116
2195
  }
2117
2196
  queueProcessorTurn(e) {
2118
2197
  if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
@@ -2121,7 +2200,7 @@ var Rt = class e {
2121
2200
  let n = this.processorAbortController.signal;
2122
2201
  this.processorChain = this.processorChain.then(async () => {
2123
2202
  if (!n.aborted) try {
2124
- let r = await ke(t, {
2203
+ let r = await Me(t, {
2125
2204
  utteranceId: e.utteranceId,
2126
2205
  text: e.text,
2127
2206
  conversation: this.conversationCache,
@@ -2171,7 +2250,7 @@ var Rt = class e {
2171
2250
  };
2172
2251
  }
2173
2252
  };
2174
- function zt(e) {
2253
+ function Jt(e) {
2175
2254
  return e ? {
2176
2255
  textSpeech: e.capabilities.speech.output,
2177
2256
  externalSpeechAudio: e.capabilities.speech.externalAudio
@@ -2182,26 +2261,26 @@ function zt(e) {
2182
2261
  }
2183
2262
  //#endregion
2184
2263
  //#region src/widget/dockGeometry.ts
2185
- var Bt = "(min-width: 768px)", Vt = 24, Ht = .5, Ut = 1200, Wt = .85, Gt = 9 / 16;
2186
- function Kt() {
2264
+ var Yt = "(min-width: 768px)", Xt = 24, Zt = .5, Qt = 1200, $t = .85, en = 9 / 16;
2265
+ function tn() {
2187
2266
  if (typeof window > "u") return 800;
2188
2267
  let e = window.screen?.availHeight;
2189
2268
  return typeof e == "number" && e > 0 ? e : window.innerHeight;
2190
2269
  }
2191
- function qt(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Vt, r = typeof window < "u" ? Kt() : 800) {
2192
- let i = Math.max(160, Math.min(t - n * 2, t * Wt)), a = Math.max(120, e - n * 2), o = Math.min(r * Ht, Ut, i), s = o * Gt;
2193
- return s > a && (s = a, o = s / Gt, o > i && (o = i, s = o * Gt)), {
2270
+ function nn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Xt, r = typeof window < "u" ? tn() : 800) {
2271
+ let i = Math.max(160, Math.min(t - n * 2, t * $t)), a = Math.max(120, e - n * 2), o = Math.min(r * Zt, Qt, i), s = o * en;
2272
+ return s > a && (s = a, o = s / en, o > i && (o = i, s = o * en)), {
2194
2273
  width: Math.round(s),
2195
2274
  height: Math.round(o)
2196
2275
  };
2197
2276
  }
2198
- function Jt(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Vt) {
2277
+ function rn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Xt) {
2199
2278
  return {
2200
2279
  left: Math.max(r, t - e.width - r),
2201
2280
  top: Math.max(r, n - e.height - r)
2202
2281
  };
2203
2282
  }
2204
- function Yt(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Vt) {
2283
+ function an(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Xt) {
2205
2284
  let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
2206
2285
  return {
2207
2286
  left: Math.min(Math.max(a, e), o),
@@ -2209,14 +2288,14 @@ function Yt(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typ
2209
2288
  };
2210
2289
  }
2211
2290
  function Q(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
2212
- return e(Bt).matches;
2291
+ return e(Yt).matches;
2213
2292
  }
2214
2293
  //#endregion
2215
2294
  //#region src/widget/mountExperienceWidget.ts
2216
- function Xt(e) {
2295
+ function on(e) {
2217
2296
  return e === "bottom-right" || e === "bottom-left" ? e : "static";
2218
2297
  }
2219
- function Zt(e) {
2298
+ function sn(e) {
2220
2299
  if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
2221
2300
  let t = typeof e == "string" ? e.trim() : "";
2222
2301
  return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
@@ -2224,8 +2303,8 @@ function Zt(e) {
2224
2303
  function $(e) {
2225
2304
  return e === "expanded" || e === "docked";
2226
2305
  }
2227
- var Qt = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065\"/><path d=\"M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0\"/></svg>", $t = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7A1 1 0 0 0 5.7 7.11L10.59 12l-4.9 4.89a1 1 0 1 0 1.42 1.42L12 13.41l4.89 4.9a1 1 0 0 0 1.42-1.42L13.41 12l4.9-4.89a1 1 0 0 0-.01-1.4Z\"/></svg>", en = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 10h-4V6m6-2l-6 6m-8 4h4v4m0-4l-6 6\"/></svg>", tn = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16 4h4v4m-6 2l6-6M8 20H4v-4m0 4l6-6\"/></svg>";
2228
- function nn(e, t, n) {
2306
+ var cn = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065\"/><path d=\"M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0\"/></svg>", ln = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7A1 1 0 0 0 5.7 7.11L10.59 12l-4.9 4.89a1 1 0 1 0 1.42 1.42L12 13.41l4.89 4.9a1 1 0 0 0 1.42-1.42L13.41 12l4.9-4.89a1 1 0 0 0-.01-1.4Z\"/></svg>", un = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 10h-4V6m6-2l-6 6m-8 4h4v4m0-4l-6 6\"/></svg>", dn = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16 4h4v4m-6 2l6-6M8 20H4v-4m0 4l6-6\"/></svg>";
2307
+ function fn(e, t, n) {
2229
2308
  re(I);
2230
2309
  let r = c({
2231
2310
  galleryThumb: t.galleryThumb,
@@ -2255,7 +2334,7 @@ function nn(e, t, n) {
2255
2334
  }
2256
2335
  return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ne(i);
2257
2336
  }
2258
- function rn(e) {
2337
+ function pn(e) {
2259
2338
  return e.startButton ? {
2260
2339
  ...e.startButton,
2261
2340
  label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
@@ -2267,7 +2346,7 @@ function rn(e) {
2267
2346
  variant: "primary"
2268
2347
  };
2269
2348
  }
2270
- function an(e) {
2349
+ function mn(e) {
2271
2350
  let t = !1, n = () => {
2272
2351
  t || e();
2273
2352
  }, r = () => {
@@ -2287,12 +2366,12 @@ function an(e) {
2287
2366
  t = !0, window.removeEventListener("load", r), i?.();
2288
2367
  };
2289
2368
  }
2290
- function on(e, t) {
2369
+ function hn(e, t) {
2291
2370
  oe(ie);
2292
2371
  let n = t.experienceId?.trim();
2293
2372
  if (!n) throw Error("ExperienceWidget requires experienceId.");
2294
- let r = t.prefetch ?? "onExpand", i = Xt(t.position), a = document.createElement("div");
2295
- a.className = "liforma-ew", a.dataset.state = "collapsed", a.dataset.prefetch = r, a.dataset.position = i, a.style.setProperty("--liforma-ew-max-w", t.expandedMaxWidth ?? "100%"), a.style.setProperty("--liforma-ew-max-h", t.expandedMaxHeight ?? "100%"), i !== "static" && a.style.setProperty("--liforma-ew-offset", Zt(t.offset));
2373
+ let r = t.prefetch ?? "onExpand", i = on(t.position), a = document.createElement("div");
2374
+ a.className = "liforma-ew", a.dataset.state = "collapsed", a.dataset.prefetch = r, a.dataset.position = i, a.style.setProperty("--liforma-ew-max-w", t.expandedMaxWidth ?? "100%"), a.style.setProperty("--liforma-ew-max-h", t.expandedMaxHeight ?? "100%"), i !== "static" && a.style.setProperty("--liforma-ew-offset", sn(t.offset));
2296
2375
  let o = document.createElement("button");
2297
2376
  o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
2298
2377
  let s = document.createElement("div");
@@ -2312,22 +2391,22 @@ function on(e, t) {
2312
2391
  let m = document.createElement("span");
2313
2392
  m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
2314
2393
  let h = document.createElement("button");
2315
- h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = en, h.setAttribute("aria-label", "Reduce");
2394
+ h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = un, h.setAttribute("aria-label", "Reduce");
2316
2395
  let g = document.createElement("button");
2317
- g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Qt, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
2396
+ g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = cn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
2318
2397
  let _ = document.createElement("button");
2319
- _.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = $t, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
2398
+ _.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = ln, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
2320
2399
  let v = document.createElement("div");
2321
2400
  v.className = "liforma-ew__stage";
2322
2401
  let y = document.createElement("div");
2323
2402
  y.className = "liforma-ew__status", y.hidden = !0, f.append(v, y), u.append(d, f), a.append(o, l, u, p), e.replaceChildren(a);
2324
- let b = null, x = !1, S = !1, ee = !1, C = !1, w = !1, T = !1, E = !1, D = 0, O = "", k = null, A = null, j = null, M = null, N = null, P = null, F = null, te = 0, ne = 0, I = null, L = !1, re = new AbortController(), ae = t.parallax !== !1, R = () => {
2403
+ let b = null, x = !1, S = !1, C = !1, w = !1, T = !1, E = !1, D = !1, O = 0, k = "", A = null, j = null, M = null, ee = null, N = null, P = null, F = null, te = 0, ne = 0, I = null, L = !1, re = new AbortController(), ae = t.parallax !== !1, R = () => {
2325
2404
  let e = a.dataset.state;
2326
2405
  return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
2327
2406
  }, z = () => {
2328
- j !== null && (clearTimeout(j), j = null);
2407
+ M !== null && (clearTimeout(M), M = null);
2329
2408
  }, se = () => {
2330
- M !== null && (clearTimeout(M), M = null), a.classList.remove("liforma-ew--layout-settling");
2409
+ ee !== null && (clearTimeout(ee), ee = null), a.classList.remove("liforma-ew--layout-settling");
2331
2410
  }, ce = () => {
2332
2411
  for (let e of [
2333
2412
  f,
@@ -2344,11 +2423,11 @@ function on(e, t) {
2344
2423
  p.style.left = `${e + n - a - 10}px`, p.style.top = `${t + 10}px`, p.style.right = "auto", p.style.bottom = "auto", p.style.width = "auto", p.style.height = "auto";
2345
2424
  }, B = (e, t) => {
2346
2425
  if (R() !== "docked") return;
2347
- let n = qt(), r = Yt(e - te, t - ne, n);
2426
+ let n = nn(), r = an(e - te, t - ne, n);
2348
2427
  N = r.left, P = r.top, le(r.left, r.top, n.width, n.height);
2349
2428
  }, de = (e, t) => {
2350
2429
  if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
2351
- let n = qt(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = Yt(r + e, i + t, n);
2430
+ let n = nn(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = an(r + e, i + t, n);
2352
2431
  N = a.left, P = a.top, le(a.left, a.top, n.width, n.height);
2353
2432
  }, fe = (e) => {
2354
2433
  I === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), B(e.clientX, e.clientY)));
@@ -2361,89 +2440,89 @@ function on(e, t) {
2361
2440
  F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
2362
2441
  let r = f.getBoundingClientRect();
2363
2442
  te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", fe), window.addEventListener("pointerup", V), window.addEventListener("pointercancel", V));
2364
- }, me = (e) => {
2443
+ }, H = (e) => {
2365
2444
  if (S || R() !== "docked" || !Q() || F !== null) return;
2366
2445
  F = e.pointerId, I = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
2367
2446
  let t = f.getBoundingClientRect();
2368
2447
  N = t.left, P = t.top;
2369
- }, H = (e) => {
2448
+ }, me = (e) => {
2370
2449
  I === "player" && (F === null || e.pointerId !== F || de(e.dx, e.dy));
2371
- }, U = (e) => {
2450
+ }, he = (e) => {
2372
2451
  I === "player" && (F === null || e.pointerId !== F || V());
2373
- }, W = () => {
2452
+ }, U = () => {
2374
2453
  let e = Q(), t = R();
2375
2454
  if (!e || t !== "expanded" && t !== "docked") {
2376
2455
  h.hidden = !0;
2377
2456
  return;
2378
2457
  }
2379
- h.hidden = !1, t === "docked" ? (h.innerHTML = tn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = en, h.setAttribute("aria-label", "Reduce"));
2380
- }, he = (e) => {
2381
- let t = qt(), n = e && N !== null && P !== null ? Yt(N, P, t) : Jt(t);
2382
- n = Yt(n.left, n.top, t), N = n.left, P = n.top, le(n.left, n.top, t.width, t.height), W();
2383
- }, ge = () => {
2458
+ h.hidden = !1, t === "docked" ? (h.innerHTML = dn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = un, h.setAttribute("aria-label", "Reduce"));
2459
+ }, ge = (e) => {
2460
+ let t = nn(), n = e && N !== null && P !== null ? an(N, P, t) : rn(t);
2461
+ n = an(n.left, n.top, t), N = n.left, P = n.top, le(n.left, n.top, t.width, t.height), U();
2462
+ }, _e = () => {
2384
2463
  a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
2385
2464
  requestAnimationFrame(() => {
2386
2465
  S || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
2387
2466
  });
2388
2467
  });
2389
- }, _e = (e) => {
2390
- if (se(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !E) {
2468
+ }, W = (e) => {
2469
+ if (se(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !D) {
2391
2470
  a.classList.remove("liforma-ew--layout-settling");
2392
2471
  return;
2393
2472
  }
2394
- M = setTimeout(() => {
2395
- if (M = null, S || !$(a.dataset.state)) {
2473
+ ee = setTimeout(() => {
2474
+ if (ee = null, S || !$(a.dataset.state)) {
2396
2475
  a.classList.remove("liforma-ew--layout-settling");
2397
2476
  return;
2398
2477
  }
2399
- a.classList.remove("liforma-ew--layout-settling"), ge();
2478
+ a.classList.remove("liforma-ew--layout-settling"), _e();
2400
2479
  }, 220);
2401
- }, ve = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
2402
- z(), j = setTimeout(() => {
2403
- j = null, a.classList.remove("liforma-ew--session-concealing"), e();
2480
+ }, G = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
2481
+ z(), M = setTimeout(() => {
2482
+ M = null, a.classList.remove("liforma-ew--session-concealing"), e();
2404
2483
  }, 280);
2405
- })), ye = {
2484
+ })), ve = {
2406
2485
  galleryThumb: t.galleryThumb,
2407
2486
  avatarImage: t.avatarImage,
2408
2487
  backgroundImage: t.backgroundImage,
2409
2488
  foregroundImage: t.foregroundImage,
2410
2489
  fallbackImage: t.fallbackImage
2411
- }, G = (e) => {
2490
+ }, K = (e) => {
2412
2491
  if (!e) {
2413
2492
  y.hidden = !0, y.textContent = "";
2414
2493
  return;
2415
2494
  }
2416
2495
  y.hidden = !1, y.textContent = e;
2417
- }, be = (e) => {
2496
+ }, ye = (e) => {
2418
2497
  if (!e) {
2419
2498
  c.hidden = !0, c.textContent = "";
2420
2499
  return;
2421
2500
  }
2422
2501
  c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
2502
+ }, be = () => {
2503
+ C = !0, o.disabled = !1, ye(null), r === "onExpand" && t.onPrefetchReady?.();
2423
2504
  }, xe = () => {
2424
- ee = !0, o.disabled = !1, be(null), r === "onExpand" && t.onPrefetchReady?.();
2425
- }, Se = () => {
2426
- C = !0, a.dataset.warm = "true", l.hidden = !1, E || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
2427
- }, Ce = (e) => {
2428
- k?.(), k = null;
2429
- let t = nn(s, e, { parallax: ae });
2430
- return t ? (k = t, !0) : !1;
2431
- }, we = () => {
2432
- if (Ce(ye)) {
2433
- xe();
2505
+ w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
2506
+ }, Se = (e) => {
2507
+ A?.(), A = null;
2508
+ let t = fn(s, e, { parallax: ae });
2509
+ return t ? (A = t, !0) : !1;
2510
+ }, Ce = () => {
2511
+ if (Se(ve)) {
2512
+ be();
2434
2513
  return;
2435
2514
  }
2436
- be("Loading…"), ue(n, { signal: re.signal }).then((e) => {
2515
+ ye("Loading…"), ue(n, { signal: re.signal }).then((e) => {
2437
2516
  if (!S) {
2438
- if (!Ce({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
2439
- xe();
2517
+ if (!Se({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
2518
+ be();
2440
2519
  }
2441
2520
  }).catch((e) => {
2442
2521
  if (S || re.signal.aborted) return;
2443
2522
  let n = e instanceof Error ? e : Error(String(e));
2444
- be("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
2523
+ ye("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
2445
2524
  });
2446
- }, Te = () => ({
2525
+ }, we = () => ({
2447
2526
  experienceId: n,
2448
2527
  ui: "widget",
2449
2528
  ...t.sessionEndpoint ? { sessionEndpoint: t.sessionEndpoint } : {},
@@ -2453,70 +2532,70 @@ function on(e, t) {
2453
2532
  ...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
2454
2533
  ...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
2455
2534
  ...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
2456
- }), Ee = () => ({
2535
+ }), Te = () => ({
2457
2536
  ...t.fit ? { fit: t.fit } : {},
2458
- startButton: rn(t),
2537
+ startButton: pn(t),
2459
2538
  ...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
2460
- }), K = (e = !0) => {
2461
- o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ce(), a.dataset.state = "expanded", G(null), typeof document < "u" && (O = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
2462
- }, De = () => {
2463
- o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", G(null), typeof document < "u" && (document.body.style.overflow = O), he(!0), W(), b?.setWidgetChrome("docked");
2464
- }, Oe = (e) => {
2539
+ }), q = (e = !0) => {
2540
+ o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ce(), a.dataset.state = "expanded", K(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), U(), e && t.onExpanded?.();
2541
+ }, Ee = () => {
2542
+ o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", K(null), typeof document < "u" && (document.body.style.overflow = k), ge(!0), U(), b?.setWidgetChrome("docked");
2543
+ }, De = (e) => {
2465
2544
  e.on("started", () => {
2466
- S || (E = !0, a.dataset.live = "true", G(null), t.onStarted?.(), $(a.dataset.state) && ge());
2545
+ S || (D = !0, a.dataset.live = "true", K(null), t.onStarted?.(), $(a.dataset.state) && _e());
2467
2546
  }), e.on("feedback", (e) => {
2468
2547
  S || t.onFeedback?.(e);
2469
2548
  }), e.on("feedbackFailed", (e) => {
2470
2549
  S || t.onFeedbackFailed?.(e);
2471
2550
  });
2551
+ }, Oe = () => {
2552
+ se(), u.hidden = !0, p.hidden = !0, ce(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), C && (o.disabled = !1), K(null), typeof document < "u" && (document.body.style.overflow = k), U();
2472
2553
  }, ke = () => {
2473
- se(), u.hidden = !0, p.hidden = !0, ce(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), ee && (o.disabled = !1), G(null), typeof document < "u" && (document.body.style.overflow = O), W();
2474
- }, Ae = () => {
2475
- z(), se(), D += 1, x = !1, C = !1, w = !1, T = !1, E = !1;
2554
+ z(), se(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
2476
2555
  let e = b;
2477
2556
  b = null, e?.destroy(), v.replaceChildren(), l.replaceChildren(), l.hidden = !0, delete a.dataset.warm, delete a.dataset.live, a.classList.remove("liforma-ew--session-revealed");
2478
- }, q = () => {
2557
+ }, J = () => {
2479
2558
  if (!S && $(a.dataset.state)) {
2480
- if (V(), x = !1, b && T) {
2559
+ if (V(), x = !1, b && E) {
2481
2560
  let e = b;
2482
2561
  (async () => {
2483
- E && (await ve(), S || b !== e) || (C && e.setWidgetChrome("collapsed"), ke(), E ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : C && Se(), t.onCollapsed?.(), t.onClose?.());
2562
+ D && (await G(), S || b !== e) || (w && e.setWidgetChrome("collapsed"), Oe(), D ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : w && xe(), t.onCollapsed?.(), t.onClose?.());
2484
2563
  })();
2485
2564
  return;
2486
2565
  }
2487
- Ae(), ke(), t.onCollapsed?.(), t.onClose?.();
2566
+ ke(), Oe(), t.onCollapsed?.(), t.onClose?.();
2488
2567
  }
2489
- }, je = () => {
2490
- S || Q() && R() === "expanded" && _e(() => {
2491
- De();
2568
+ }, Ae = () => {
2569
+ S || Q() && R() === "expanded" && W(() => {
2570
+ Ee();
2492
2571
  });
2493
- }, J = () => {
2494
- S || R() === "docked" && (V(), _e(() => {
2495
- ce(), K(!1), b?.setWidgetChrome("expanded");
2572
+ }, je = () => {
2573
+ S || R() === "docked" && (V(), W(() => {
2574
+ ce(), q(!1), b?.setWidgetChrome("expanded");
2496
2575
  }));
2497
2576
  }, Me = () => {
2498
- !b || !E || (z(), a.classList.remove("liforma-ew--session-revealed"), K(), b.setWidgetChrome("expanded"), x = !1, ge());
2577
+ !b || !D || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), b.setWidgetChrome("expanded"), x = !1, _e());
2499
2578
  }, Ne = () => {
2500
- !b || !T || E || (z(), a.classList.remove("liforma-ew--session-revealed"), K(), x = !1, C || b.setWidgetChrome("expanded"));
2579
+ !b || !E || D || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, w || b.setWidgetChrome("expanded"));
2501
2580
  }, Pe = (e) => {
2502
- S || e !== D && !E || (z(), a.classList.remove("liforma-ew--session-revealed"), K(), x = !1, E && ge());
2581
+ S || e !== O && !D || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, D && _e());
2503
2582
  }, Fe = () => {
2504
- if (S || w || C || b || $(a.dataset.state)) return;
2505
- w = !0;
2506
- let e = D;
2583
+ if (S || T || w || b || $(a.dataset.state)) return;
2584
+ T = !0;
2585
+ let e = O;
2507
2586
  l.hidden = !1, (async () => {
2508
2587
  try {
2509
- let t = await Rt.startSession(Te());
2510
- if (S || e !== D) {
2588
+ let t = await qt.startSession(we());
2589
+ if (S || e !== O) {
2511
2590
  t.destroy();
2512
2591
  return;
2513
2592
  }
2514
- b = t, Oe(t);
2593
+ b = t, De(t);
2515
2594
  let n = await t.attach({
2516
2595
  container: l,
2517
- ...Ee(),
2596
+ ...Te(),
2518
2597
  onWidgetReady: () => {
2519
- S || e !== D || (w = !1, T = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : Se());
2598
+ S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : xe());
2520
2599
  },
2521
2600
  onWidgetExpand: () => {
2522
2601
  Pe(e);
@@ -2525,151 +2604,151 @@ function on(e, t) {
2525
2604
  S || ze(e);
2526
2605
  },
2527
2606
  onWidgetDragStart: (e) => {
2528
- S || me(e);
2607
+ S || H(e);
2529
2608
  },
2530
2609
  onWidgetDragMove: (e) => {
2531
- S || H(e);
2610
+ S || me(e);
2532
2611
  },
2533
2612
  onWidgetDragEnd: (e) => {
2534
- S || U(e);
2613
+ S || he(e);
2535
2614
  },
2536
2615
  onPlayerStatusChange: (e) => {
2537
- S || e === "error" && $(a.dataset.state) && G("Could not load the experience.");
2616
+ S || e === "error" && $(a.dataset.state) && K("Could not load the experience.");
2538
2617
  }
2539
2618
  });
2540
- if (S || e !== D) {
2619
+ if (S || e !== O) {
2541
2620
  t.destroy(), b === t && (b = null);
2542
2621
  return;
2543
2622
  }
2544
2623
  n.on("close", () => {
2545
- S || q();
2624
+ S || J();
2546
2625
  });
2547
2626
  } catch (n) {
2548
- if (S || e !== D) return;
2549
- w = !1, l.hidden = !0, l.replaceChildren(), b = null;
2627
+ if (S || e !== O) return;
2628
+ T = !1, l.hidden = !0, l.replaceChildren(), b = null;
2550
2629
  let r = n instanceof Error ? n : Error(String(n));
2551
2630
  t.onError?.(r), console.error("[ExperienceWidget] warm prefetch failed", r);
2552
2631
  }
2553
2632
  })();
2554
2633
  }, Ie = () => {
2555
- if (S || x || !ee || $(a.dataset.state)) return;
2556
- if (b && E) {
2634
+ if (S || x || !C || $(a.dataset.state)) return;
2635
+ if (b && D) {
2557
2636
  Me();
2558
2637
  return;
2559
2638
  }
2560
- if (b && T) {
2639
+ if (b && E) {
2561
2640
  Ne();
2562
2641
  return;
2563
2642
  }
2564
- let e = ++D;
2565
- x = !0, C = !1, w = !1, T = !1, E = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), b &&= (b.destroy(), null), (async () => {
2643
+ let e = ++O;
2644
+ x = !0, w = !1, T = !1, E = !1, D = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), b &&= (b.destroy(), null), (async () => {
2566
2645
  try {
2567
- K();
2568
- let t = await Rt.startSession(Te());
2569
- if (S || e !== D) {
2646
+ q();
2647
+ let t = await qt.startSession(we());
2648
+ if (S || e !== O) {
2570
2649
  t.destroy();
2571
2650
  return;
2572
2651
  }
2573
- b = t, Oe(t);
2652
+ b = t, De(t);
2574
2653
  let n = await t.attach({
2575
2654
  container: v,
2576
- ...Ee(),
2655
+ ...Te(),
2577
2656
  onWidgetAudioSettings: (e) => {
2578
2657
  S || ze(e);
2579
2658
  },
2580
2659
  onWidgetDragStart: (e) => {
2581
- S || me(e);
2660
+ S || H(e);
2582
2661
  },
2583
2662
  onWidgetDragMove: (e) => {
2584
- S || H(e);
2663
+ S || me(e);
2585
2664
  },
2586
2665
  onWidgetDragEnd: (e) => {
2587
- S || U(e);
2666
+ S || he(e);
2588
2667
  },
2589
2668
  onPlayerStatusChange: (e) => {
2590
- S || (e === "error" ? G("Could not load the experience.") : $(a.dataset.state) && G(null));
2669
+ S || (e === "error" ? K("Could not load the experience.") : $(a.dataset.state) && K(null));
2591
2670
  }
2592
2671
  });
2593
- if (S || e !== D) {
2672
+ if (S || e !== O) {
2594
2673
  t.destroy(), b === t && (b = null);
2595
2674
  return;
2596
2675
  }
2597
- T = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
2598
- S || q();
2676
+ E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
2677
+ S || J();
2599
2678
  });
2600
2679
  } catch (n) {
2601
- if (S || e !== D) return;
2680
+ if (S || e !== O) return;
2602
2681
  let r = n instanceof Error ? n : Error(String(n));
2603
- G(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
2682
+ K(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
2604
2683
  } finally {
2605
- e === D && (x = !1);
2684
+ e === O && (x = !1);
2606
2685
  }
2607
2686
  })();
2608
2687
  }, Le = () => {
2609
2688
  if (!(S || $(a.dataset.state))) {
2610
- if (b && E) {
2689
+ if (b && D) {
2611
2690
  Me();
2612
2691
  return;
2613
2692
  }
2614
- if (b && T) {
2693
+ if (b && E) {
2615
2694
  Ne();
2616
2695
  return;
2617
2696
  }
2618
- if (w || b) {
2619
- K();
2697
+ if (T || b) {
2698
+ q();
2620
2699
  return;
2621
2700
  }
2622
2701
  Ie();
2623
2702
  }
2624
2703
  }, Re = (e) => {
2625
2704
  if (e.stopPropagation(), R() === "expanded") {
2626
- je();
2705
+ Ae();
2627
2706
  return;
2628
2707
  }
2629
- R() === "docked" && J();
2708
+ R() === "docked" && je();
2630
2709
  }, ze = (e) => {
2631
2710
  g.setAttribute("aria-pressed", e ? "true" : "false");
2632
2711
  }, Be = (e) => {
2633
2712
  e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
2634
- }, Y = (e) => {
2635
- R() === "docked" && Q() && (e.target?.closest("button") || (e.preventDefault(), pe(e.clientX, e.clientY, e.pointerId)));
2636
2713
  }, Ve = (e) => {
2637
- e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), q());
2638
- }, He = () => {
2714
+ R() === "docked" && Q() && (e.target?.closest("button") || (e.preventDefault(), pe(e.clientX, e.clientY, e.pointerId)));
2715
+ }, He = (e) => {
2716
+ e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), J());
2717
+ }, Ue = () => {
2639
2718
  if (!S) {
2640
2719
  if (R() === "docked") {
2641
2720
  if (!Q()) {
2642
- J();
2721
+ je();
2643
2722
  return;
2644
2723
  }
2645
- E ? _e(() => {
2646
- he(!0);
2647
- }) : he(!0);
2724
+ D ? W(() => {
2725
+ ge(!0);
2726
+ }) : ge(!0);
2648
2727
  return;
2649
2728
  }
2650
- W();
2729
+ U();
2651
2730
  }
2652
- }, Ue = typeof window < "u" ? window.matchMedia(Bt) : null, We = () => {
2731
+ }, We = typeof window < "u" ? window.matchMedia(Yt) : null, Ge = () => {
2653
2732
  if (!S) {
2654
2733
  if (R() === "docked" && !Q()) {
2655
- J();
2734
+ je();
2656
2735
  return;
2657
2736
  }
2658
- W();
2737
+ U();
2659
2738
  }
2660
2739
  };
2661
- return o.addEventListener("click", Le), d.addEventListener("click", q), _.addEventListener("click", (e) => {
2662
- e.stopPropagation(), q();
2663
- }), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Y), window.addEventListener("keydown", Ve), window.addEventListener("resize", He), Ue?.addEventListener("change", We), we(), W(), r === "eager" ? queueMicrotask(() => {
2740
+ return o.addEventListener("click", Le), d.addEventListener("click", J), _.addEventListener("click", (e) => {
2741
+ e.stopPropagation(), J();
2742
+ }), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), We?.addEventListener("change", Ge), Ce(), U(), r === "eager" ? queueMicrotask(() => {
2664
2743
  S || Fe();
2665
- }) : r === "idle" && (A = an(() => {
2744
+ }) : r === "idle" && (j = mn(() => {
2666
2745
  S || Fe();
2667
2746
  })), {
2668
2747
  root: a,
2669
2748
  expand: Le,
2670
- collapse: q,
2671
- dock: je,
2672
- maximize: J,
2749
+ collapse: J,
2750
+ dock: Ae,
2751
+ maximize: je,
2673
2752
  prefetch() {
2674
2753
  if (r === "onExpand") {
2675
2754
  Fe();
@@ -2678,11 +2757,11 @@ function on(e, t) {
2678
2757
  Fe();
2679
2758
  },
2680
2759
  destroy() {
2681
- S || (S = !0, V(), A?.(), A = null, re.abort(), k?.(), k = null, window.removeEventListener("keydown", Ve), window.removeEventListener("resize", He), Ue?.removeEventListener("change", We), Ae(), ke(), e.replaceChildren());
2760
+ S || (S = !0, V(), j?.(), j = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown", He), window.removeEventListener("resize", Ue), We?.removeEventListener("change", Ge), ke(), Oe(), e.replaceChildren());
2682
2761
  }
2683
2762
  };
2684
2763
  }
2685
2764
  //#endregion
2686
- export { I as EXPERIENCE_THUMBNAIL_CSS, ie as EXPERIENCE_WIDGET_CSS, Rt as Experience, B as LiformaError, X as SPEECH_LIMITS, dt as SpeechBufferTimeoutError, Z as SpeechRuntimeError, ut as SpeechUtteranceClosedError, lt as UnsupportedSpeechOperationError, E as attachImageReady, T as attachLazyThumb, te as attachScrollLinkedParallax, m as buildHostedLaunchUrl, re as ensureExperienceThumbnailStyles, oe as ensureExperienceWidgetStyles, ue as fetchExperiencePreview, ee as getDefaultLazyRootMargin, O as horizontalParallaxFromViewportY, fe as liformaErrorFromResponse, on as mountExperienceWidget, n as navigateOnExperienceClose, h as resolveThumbnailHref, f as resolveThumbnailInteraction, c as resolveThumbnailLayers, r as thumbnailFitClass, s as toGalleryThumbUrl, ye as warnLocaleVoiceFallbacks };
2765
+ export { I as EXPERIENCE_THUMBNAIL_CSS, ie as EXPERIENCE_WIDGET_CSS, qt as Experience, B as LiformaError, X as SPEECH_LIMITS, bt as SpeechBufferTimeoutError, Z as SpeechRuntimeError, yt as SpeechUtteranceClosedError, vt as UnsupportedSpeechOperationError, D as attachImageReady, E as attachLazyThumb, te as attachScrollLinkedParallax, m as buildHostedLaunchUrl, re as ensureExperienceThumbnailStyles, oe as ensureExperienceWidgetStyles, ue as fetchExperiencePreview, C as getDefaultLazyRootMargin, k as horizontalParallaxFromViewportY, fe as liformaErrorFromResponse, hn as mountExperienceWidget, n as navigateOnExperienceClose, h as resolveThumbnailHref, f as resolveThumbnailInteraction, c as resolveThumbnailLayers, r as thumbnailFitClass, s as toGalleryThumbUrl, Se as warnLocaleVoiceFallbacks };
2687
2766
 
2688
2767
  //# sourceMappingURL=index.js.map