@liforma/client 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/next/index.js +169 -161
- package/dist/next/index.js.map +1 -1
- package/dist/next/v2/experience.d.ts +8 -0
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/experienceEvents.d.ts +5 -0
- package/dist/next/v2/experienceEvents.d.ts.map +1 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts +3 -2
- package/dist/next/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/next/v2/types/sessionManifest.d.ts +12 -0
- package/dist/next/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/npm/index.js +153 -145
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/v2/experience.d.ts +8 -0
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/experienceEvents.d.ts +5 -0
- package/dist/npm/v2/experienceEvents.d.ts.map +1 -1
- package/dist/npm/v2/shims/embedBaseUrl.d.ts +3 -2
- package/dist/npm/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/npm/v2/speechOnlyManifest.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifest.d.ts +12 -0
- package/dist/npm/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts +19 -0
- package/dist/npm/v2/types/sessionManifestSchema.d.ts.map +1 -1
- package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +2 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +320 -306
- package/dist/react/index.js.map +1 -1
- package/dist/react/v2/experience.d.ts +8 -0
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/experienceEvents.d.ts +5 -0
- package/dist/react/v2/experienceEvents.d.ts.map +1 -1
- package/dist/react/v2/shims/embedBaseUrl.d.ts +3 -2
- package/dist/react/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/react/v2/types/sessionManifest.d.ts +12 -0
- package/dist/react/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +6 -6
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +7 -0
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -25,6 +25,9 @@ function _(e) {
|
|
|
25
25
|
if (n && e.launch) return {
|
|
26
26
|
launch: e.launch,
|
|
27
27
|
session: e.session,
|
|
28
|
+
backdropId: e.backdropId,
|
|
29
|
+
locationId: e.locationId,
|
|
30
|
+
avatarId: e.avatarId,
|
|
28
31
|
embedBaseUrl: e.embedBaseUrl,
|
|
29
32
|
debug: e.debug,
|
|
30
33
|
speechOnly: e.speechOnly,
|
|
@@ -37,6 +40,7 @@ function _(e) {
|
|
|
37
40
|
secondaryLocale: e.secondaryLocale,
|
|
38
41
|
learningLocale: e.learningLocale,
|
|
39
42
|
language: e.language,
|
|
43
|
+
backdropId: e.backdropId,
|
|
40
44
|
locationId: e.locationId,
|
|
41
45
|
avatarId: e.avatarId,
|
|
42
46
|
castSize: e.castSize,
|
|
@@ -53,6 +57,7 @@ function _(e) {
|
|
|
53
57
|
secondaryLocale: e.secondaryLocale,
|
|
54
58
|
learningLocale: e.learningLocale,
|
|
55
59
|
language: e.language,
|
|
60
|
+
backdropId: e.backdropId,
|
|
56
61
|
locationId: e.locationId,
|
|
57
62
|
avatarId: e.avatarId,
|
|
58
63
|
castSize: e.castSize,
|
|
@@ -78,6 +83,7 @@ function v(e) {
|
|
|
78
83
|
e.conversationProcessor ? g(e.conversationProcessor) : 0,
|
|
79
84
|
e.speechOnly,
|
|
80
85
|
e.avatarId,
|
|
86
|
+
e.backdropId,
|
|
81
87
|
e.locationId,
|
|
82
88
|
e.castSize,
|
|
83
89
|
e.embedBaseUrl,
|
|
@@ -318,20 +324,20 @@ function te(e, t) {
|
|
|
318
324
|
//#endregion
|
|
319
325
|
//#region src/react/Experience.tsx
|
|
320
326
|
var ne = e(function(e, a) {
|
|
321
|
-
let { returnUrl: c, fit: l, startButton: u, showFeedback: p, closeButton: m, onReady: h, onStarted: g, onUserTranscript: y, onUserSpeechStarted: b, onUserSpeechEnded: x, onCharacterSpeechStarted: S, onCharacterSpeechEnded: ee, onCharacterFocusChanged: C, onConversationUpdate: w, onMessage: T, onListeningState: O, onActivityChange: k, onFeedback: A, onFeedbackFailed: j, onConversationProcessorError: N, onPlayerStatusChange: P, onStateUpdate: F, onClose: ne, onError:
|
|
327
|
+
let { returnUrl: c, fit: l, startButton: u, showFeedback: p, closeButton: m, onReady: h, onStarted: g, onUserTranscript: y, onUserSpeechStarted: b, onUserSpeechEnded: x, onCharacterSpeechStarted: S, onCharacterSpeechEnded: ee, onCharacterFocusChanged: C, onConversationUpdate: w, onMessage: T, onListeningState: O, onActivityChange: k, onFeedback: A, onFeedbackFailed: j, onConversationProcessorError: N, onPlayerStatusChange: P, onStateUpdate: F, onClose: ne, onError: I } = e, L = o({}), re = o({
|
|
322
328
|
fit: l,
|
|
323
329
|
startButton: u,
|
|
324
330
|
showFeedback: p,
|
|
325
331
|
closeButton: m,
|
|
326
332
|
returnUrl: c
|
|
327
|
-
}),
|
|
328
|
-
|
|
333
|
+
}), R = o(M(() => L.current, () => re.current)), z = o(null), [ie, ae] = s(!1), [B, oe] = s(null), se = o(null), ce = o(null), le = v(e);
|
|
334
|
+
re.current = {
|
|
329
335
|
fit: l,
|
|
330
336
|
startButton: u,
|
|
331
337
|
showFeedback: p,
|
|
332
338
|
closeButton: m,
|
|
333
339
|
returnUrl: c
|
|
334
|
-
},
|
|
340
|
+
}, L.current = {
|
|
335
341
|
onReady: h,
|
|
336
342
|
onStarted: g,
|
|
337
343
|
onUserTranscript: y,
|
|
@@ -350,64 +356,64 @@ var ne = e(function(e, a) {
|
|
|
350
356
|
onPlayerStatusChange: P,
|
|
351
357
|
onStateUpdate: F,
|
|
352
358
|
onClose: ne,
|
|
353
|
-
onError:
|
|
359
|
+
onError: I
|
|
354
360
|
};
|
|
355
|
-
let
|
|
356
|
-
|
|
361
|
+
let V = t((e) => {
|
|
362
|
+
se.current = e, ae(e !== null);
|
|
357
363
|
}, []);
|
|
358
364
|
return r(a, () => ({
|
|
359
365
|
ready: () => {
|
|
360
|
-
let e =
|
|
366
|
+
let e = z.current;
|
|
361
367
|
return !e || e.destroyed ? Promise.reject(E()) : e.ready.promise;
|
|
362
368
|
},
|
|
363
369
|
started: () => {
|
|
364
|
-
let e =
|
|
370
|
+
let e = z.current;
|
|
365
371
|
return !e || e.destroyed ? Promise.reject(E()) : e.started.promise;
|
|
366
372
|
},
|
|
367
373
|
speech: {
|
|
368
|
-
speak: (e) =>
|
|
369
|
-
play: (e) =>
|
|
374
|
+
speak: (e) => R.current.withSession((t) => t.speech.speak(e)),
|
|
375
|
+
play: (e) => R.current.withSession((t) => t.speech.play(e)),
|
|
370
376
|
createUtterance: (e) => {
|
|
371
|
-
let t =
|
|
377
|
+
let t = R.current.getActiveInstance();
|
|
372
378
|
if (!t) throw Error("Session has not started. Wait for the player start button and the started event before using speech APIs.");
|
|
373
379
|
return t.speech.createUtterance(e);
|
|
374
380
|
},
|
|
375
|
-
interrupt: (e) =>
|
|
381
|
+
interrupt: (e) => R.current.withSession((t) => t.speech.interrupt(e))
|
|
376
382
|
},
|
|
377
|
-
startListening: () =>
|
|
378
|
-
stopListening: () =>
|
|
379
|
-
listenOnce: (e) =>
|
|
380
|
-
getSession: () =>
|
|
381
|
-
getManifest: () =>
|
|
382
|
-
getConversation: () =>
|
|
383
|
-
focusCharacter: (e) =>
|
|
384
|
-
setFit: (e) =>
|
|
385
|
-
end: () =>
|
|
383
|
+
startListening: () => R.current.withSession((e) => e.startListening()),
|
|
384
|
+
stopListening: () => R.current.withSession((e) => e.stopListening()),
|
|
385
|
+
listenOnce: (e) => R.current.withSession((t) => t.listenOnce(e)),
|
|
386
|
+
getSession: () => R.current.getActiveInstance()?.getSession() ?? null,
|
|
387
|
+
getManifest: () => R.current.getActiveInstance()?.getManifest() ?? null,
|
|
388
|
+
getConversation: () => R.current.getActiveInstance()?.getConversation() ?? [],
|
|
389
|
+
focusCharacter: (e) => R.current.withSession((t) => t.focusCharacter(e)),
|
|
390
|
+
setFit: (e) => R.current.withSession((t) => t.setFit(e)),
|
|
391
|
+
end: () => R.current.withSession((e) => e.end())
|
|
386
392
|
}), []), i(() => {
|
|
387
|
-
if (!
|
|
388
|
-
let t =
|
|
393
|
+
if (!ie || !se.current) return;
|
|
394
|
+
let t = se.current, n = R.current, r;
|
|
389
395
|
try {
|
|
390
396
|
r = { options: _(e) };
|
|
391
397
|
} catch (e) {
|
|
392
398
|
r = { error: D(e) };
|
|
393
399
|
}
|
|
394
|
-
let i = n.activateGeneration(t, r, c,
|
|
395
|
-
return
|
|
396
|
-
n.cancelGeneration(i),
|
|
400
|
+
let i = n.activateGeneration(t, r, c, oe);
|
|
401
|
+
return z.current = i, () => {
|
|
402
|
+
n.cancelGeneration(i), z.current === i && (z.current = null);
|
|
397
403
|
};
|
|
398
404
|
}, [
|
|
399
|
-
|
|
400
|
-
|
|
405
|
+
ie,
|
|
406
|
+
le,
|
|
401
407
|
c
|
|
402
408
|
]), n(() => {
|
|
403
|
-
let e =
|
|
409
|
+
let e = R.current.getActiveInstance();
|
|
404
410
|
e && e.setFit(l ?? "full");
|
|
405
411
|
}, [l]), n(() => {
|
|
406
|
-
let e =
|
|
407
|
-
if (!e || (e.replaceChildren(), !
|
|
408
|
-
let t = te(e,
|
|
412
|
+
let e = ce.current;
|
|
413
|
+
if (!e || (e.replaceChildren(), !B)) return;
|
|
414
|
+
let t = te(e, B);
|
|
409
415
|
return () => t.remove();
|
|
410
|
-
}, [
|
|
416
|
+
}, [B]), /* @__PURE__ */ f("div", {
|
|
411
417
|
className: "liforma-experience-shell",
|
|
412
418
|
style: {
|
|
413
419
|
position: "relative",
|
|
@@ -416,17 +422,17 @@ var ne = e(function(e, a) {
|
|
|
416
422
|
minHeight: "inherit"
|
|
417
423
|
},
|
|
418
424
|
children: [/* @__PURE__ */ d("div", {
|
|
419
|
-
ref:
|
|
425
|
+
ref: ce,
|
|
420
426
|
className: "liforma-experience-error-host",
|
|
421
|
-
"aria-hidden":
|
|
427
|
+
"aria-hidden": B ? void 0 : !0,
|
|
422
428
|
style: {
|
|
423
429
|
position: "absolute",
|
|
424
430
|
inset: 0,
|
|
425
431
|
zIndex: 20,
|
|
426
|
-
pointerEvents:
|
|
432
|
+
pointerEvents: B ? "auto" : "none"
|
|
427
433
|
}
|
|
428
434
|
}), /* @__PURE__ */ d("div", {
|
|
429
|
-
ref:
|
|
435
|
+
ref: V,
|
|
430
436
|
className: "liforma-experience-host",
|
|
431
437
|
style: {
|
|
432
438
|
position: "absolute",
|
|
@@ -438,32 +444,32 @@ var ne = e(function(e, a) {
|
|
|
438
444
|
});
|
|
439
445
|
//#endregion
|
|
440
446
|
//#region src/thumbnail/types.ts
|
|
441
|
-
function
|
|
447
|
+
function I(e) {
|
|
442
448
|
return e === "face" ? "liforma-et--fit-face" : e === "medium" ? "liforma-et--fit-medium" : "";
|
|
443
449
|
}
|
|
444
450
|
//#endregion
|
|
445
451
|
//#region src/thumbnail/toGalleryThumbUrl.ts
|
|
446
|
-
var
|
|
447
|
-
function
|
|
452
|
+
var L = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, re = /_CH(\.webp)/i, R = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
|
|
453
|
+
function z(e) {
|
|
448
454
|
let t = e.trim();
|
|
449
455
|
if (!t) return t;
|
|
450
|
-
let n = t.replace(
|
|
451
|
-
return n = n.replace(
|
|
456
|
+
let n = t.replace(L, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`);
|
|
457
|
+
return n = n.replace(re, "_neutral$1"), n = n.replace(R, (e, t, n, r, i) => n === "256x256" ? `${t}${n}${r}${i}` : `${t}256x256${r}${i}`), n;
|
|
452
458
|
}
|
|
453
|
-
function
|
|
459
|
+
function ie(e) {
|
|
454
460
|
let t = e.avatarImage?.trim() || e.galleryThumb?.avatarImage?.trim() || "";
|
|
455
461
|
if (!t) return null;
|
|
456
462
|
let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "";
|
|
457
463
|
return {
|
|
458
|
-
avatarImage:
|
|
459
|
-
...n ? { backgroundImage:
|
|
460
|
-
...r ? { foregroundImage:
|
|
461
|
-
...i ? { fallbackImage:
|
|
464
|
+
avatarImage: z(t),
|
|
465
|
+
...n ? { backgroundImage: z(n) } : {},
|
|
466
|
+
...r ? { foregroundImage: z(r) } : {},
|
|
467
|
+
...i ? { fallbackImage: z(i) } : {}
|
|
462
468
|
};
|
|
463
469
|
}
|
|
464
470
|
//#endregion
|
|
465
471
|
//#region src/shims/localStack.ts
|
|
466
|
-
function
|
|
472
|
+
function ae() {
|
|
467
473
|
if (globalThis.__LIFORMA_STACK === "local") return !0;
|
|
468
474
|
if (typeof location > "u") return !1;
|
|
469
475
|
try {
|
|
@@ -474,70 +480,70 @@ function B() {
|
|
|
474
480
|
}
|
|
475
481
|
//#endregion
|
|
476
482
|
//#region src/thumbnail/hostedLaunchUrl.ts
|
|
477
|
-
var
|
|
478
|
-
function
|
|
483
|
+
var B = "https://player.liforma.ai", oe = "http://localhost:3002";
|
|
484
|
+
function se(e) {
|
|
479
485
|
return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
|
|
480
486
|
}
|
|
481
|
-
function
|
|
487
|
+
function ce(e) {
|
|
482
488
|
let t = e?.trim();
|
|
483
|
-
return t ? t.replace(/\/$/, "") :
|
|
489
|
+
return t ? t.replace(/\/$/, "") : ae() ? oe : B;
|
|
484
490
|
}
|
|
485
|
-
function
|
|
486
|
-
let t = e.experienceId.trim(), n =
|
|
491
|
+
function le(e) {
|
|
492
|
+
let t = e.experienceId.trim(), n = ce(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
|
|
487
493
|
return i && r.searchParams.set("returnUrl", i), r.toString();
|
|
488
494
|
}
|
|
489
|
-
function
|
|
495
|
+
function V(e) {
|
|
490
496
|
let t = e.href?.trim();
|
|
491
497
|
if (t) return t;
|
|
492
498
|
let n = e.experienceId?.trim();
|
|
493
499
|
if (!n) return;
|
|
494
500
|
let r = e.returnUrl?.trim();
|
|
495
|
-
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href),
|
|
501
|
+
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href), le({
|
|
496
502
|
experienceId: n,
|
|
497
503
|
...r ? { returnUrl: r } : {},
|
|
498
504
|
playerBaseUrl: e.playerBaseUrl
|
|
499
505
|
});
|
|
500
506
|
}
|
|
501
|
-
function
|
|
507
|
+
function ue() {
|
|
502
508
|
return typeof window > "u" ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
503
509
|
}
|
|
504
|
-
var
|
|
510
|
+
var H = 0, U = [];
|
|
505
511
|
function de() {
|
|
506
|
-
return
|
|
512
|
+
return ue() ? 4 : Infinity;
|
|
507
513
|
}
|
|
508
514
|
function W() {
|
|
509
|
-
return
|
|
515
|
+
return ue() ? 160 : 0;
|
|
510
516
|
}
|
|
511
517
|
function fe() {
|
|
512
518
|
let e = de();
|
|
513
|
-
for (;
|
|
514
|
-
let e =
|
|
519
|
+
for (; H < e && U.length > 0;) {
|
|
520
|
+
let e = U.shift();
|
|
515
521
|
if (!e || e.cancelled) continue;
|
|
516
|
-
|
|
522
|
+
H += 1, e.start();
|
|
517
523
|
let t = W();
|
|
518
524
|
if (t <= 0) {
|
|
519
|
-
|
|
525
|
+
H = Math.max(0, H - 1);
|
|
520
526
|
continue;
|
|
521
527
|
}
|
|
522
528
|
window.setTimeout(() => {
|
|
523
|
-
|
|
529
|
+
H = Math.max(0, H - 1), fe();
|
|
524
530
|
}, t);
|
|
525
531
|
}
|
|
526
532
|
}
|
|
527
533
|
function pe(e) {
|
|
528
|
-
if (!
|
|
534
|
+
if (!ue()) return e(), () => {};
|
|
529
535
|
let t = {
|
|
530
536
|
start: e,
|
|
531
537
|
cancelled: !1
|
|
532
538
|
};
|
|
533
|
-
return
|
|
539
|
+
return U.push(t), fe(), () => {
|
|
534
540
|
t.cancelled = !0;
|
|
535
541
|
};
|
|
536
542
|
}
|
|
537
543
|
//#endregion
|
|
538
544
|
//#region src/thumbnail/lazyLoad.ts
|
|
539
545
|
function me() {
|
|
540
|
-
return
|
|
546
|
+
return ue() ? "96px 0px" : "280px 0px";
|
|
541
547
|
}
|
|
542
548
|
function he(e) {
|
|
543
549
|
let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
|
|
@@ -661,7 +667,7 @@ function ke(e, t) {
|
|
|
661
667
|
return `${e} liforma-et__media${t ? " liforma-et__media--ready" : ""}`;
|
|
662
668
|
}
|
|
663
669
|
function Ae(e) {
|
|
664
|
-
let { galleryThumb: t, avatarImage: r, backgroundImage: i, foregroundImage: c, alt: l, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: y, parallax: b = !0, fit: x = "full", lazy: S = !0, className: ee = "", fallbackImage: C } = e, w = a(() =>
|
|
670
|
+
let { galleryThumb: t, avatarImage: r, backgroundImage: i, foregroundImage: c, alt: l, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: y, parallax: b = !0, fit: x = "full", lazy: S = !0, className: ee = "", fallbackImage: C } = e, w = a(() => ie({
|
|
665
671
|
galleryThumb: t,
|
|
666
672
|
avatarImage: r,
|
|
667
673
|
backgroundImage: i,
|
|
@@ -673,15 +679,15 @@ function Ae(e) {
|
|
|
673
679
|
i,
|
|
674
680
|
c,
|
|
675
681
|
C
|
|
676
|
-
]), T =
|
|
682
|
+
]), T = se({
|
|
677
683
|
href: m,
|
|
678
684
|
hasClickHandler: typeof _ == "function",
|
|
679
685
|
experienceId: p
|
|
680
|
-
}), E = T === "anchor" && !m?.trim() && !!p?.trim(), D = !!w?.backgroundImage, O = b !== !1, k = o(null), A = o(!1), [j, M] = s(!S), [N, P] = s(!1), [F, te] = s(!1), [ne,
|
|
686
|
+
}), E = T === "anchor" && !m?.trim() && !!p?.trim(), D = !!w?.backgroundImage, O = b !== !1, k = o(null), A = o(!1), [j, M] = s(!S), [N, P] = s(!1), [F, te] = s(!1), [ne, L] = s(0), [re, R] = s(0), [z, ae] = s(!1), [B, oe] = s(!1), [ce, le] = s(!1), [ue, H] = s(!1), [U, de] = s(), W = w ? z && w.fallbackImage ? w.fallbackImage : w.avatarImage : "";
|
|
681
687
|
n(() => {
|
|
682
688
|
Oe(Ee);
|
|
683
689
|
}, []), n(() => {
|
|
684
|
-
de(
|
|
690
|
+
de(V({
|
|
685
691
|
href: m,
|
|
686
692
|
experienceId: p,
|
|
687
693
|
returnUrl: v,
|
|
@@ -695,7 +701,7 @@ function Ae(e) {
|
|
|
695
701
|
y,
|
|
696
702
|
E
|
|
697
703
|
]), n(() => {
|
|
698
|
-
|
|
704
|
+
oe(!1), le(!1), H(!1), ae(!1);
|
|
699
705
|
}, [
|
|
700
706
|
w?.backgroundImage,
|
|
701
707
|
w?.foregroundImage,
|
|
@@ -715,12 +721,12 @@ function Ae(e) {
|
|
|
715
721
|
S,
|
|
716
722
|
w,
|
|
717
723
|
T,
|
|
718
|
-
|
|
724
|
+
U
|
|
719
725
|
]), n(() => {
|
|
720
726
|
let e = k.current;
|
|
721
727
|
if (!(!e || !O)) return we(e, {
|
|
722
728
|
onParallax: (e) => {
|
|
723
|
-
te(!0), A.current || (
|
|
729
|
+
te(!0), A.current || (L(e), R(0));
|
|
724
730
|
},
|
|
725
731
|
pointerActive: () => A.current
|
|
726
732
|
});
|
|
@@ -728,15 +734,15 @@ function Ae(e) {
|
|
|
728
734
|
O,
|
|
729
735
|
w,
|
|
730
736
|
T,
|
|
731
|
-
|
|
737
|
+
U
|
|
732
738
|
]);
|
|
733
739
|
let fe = (e) => {
|
|
734
740
|
if (!O || F) return;
|
|
735
741
|
let t = e.currentTarget.getBoundingClientRect();
|
|
736
|
-
t.width <= 0 || t.height <= 0 || (
|
|
742
|
+
t.width <= 0 || t.height <= 0 || (L(((e.clientX - t.left) / t.width - .5) * 2), R(((e.clientY - t.top) / t.height - .5) * 2));
|
|
737
743
|
}, pe = (e) => {
|
|
738
744
|
let t = A.current;
|
|
739
|
-
A.current = !1, P(!1), F && t ? (
|
|
745
|
+
A.current = !1, P(!1), F && t ? (L(ye(e.getBoundingClientRect(), window.innerHeight)), R(0)) : F || (L(0), R(0));
|
|
740
746
|
}, me = (e) => {
|
|
741
747
|
if (!O) return;
|
|
742
748
|
A.current = !0, e.pointerType === "mouse" && P(!0);
|
|
@@ -746,7 +752,7 @@ function Ae(e) {
|
|
|
746
752
|
window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n);
|
|
747
753
|
}, he = (e) => {
|
|
748
754
|
if (_?.(e), !e.defaultPrevented && E && !v?.trim()) {
|
|
749
|
-
let t =
|
|
755
|
+
let t = V({
|
|
750
756
|
experienceId: p,
|
|
751
757
|
playerBaseUrl: y,
|
|
752
758
|
useCurrentPageAsReturnUrl: !0
|
|
@@ -755,10 +761,10 @@ function Ae(e) {
|
|
|
755
761
|
}
|
|
756
762
|
};
|
|
757
763
|
if (!w) return null;
|
|
758
|
-
let ge = O && (N || F), ve = j && (
|
|
764
|
+
let ge = O && (N || F), ve = j && (ce || B || ue), G = [
|
|
759
765
|
"liforma-et",
|
|
760
766
|
D ? "liforma-et--scene" : "",
|
|
761
|
-
|
|
767
|
+
I(x),
|
|
762
768
|
ge ? "liforma-et--parallax" : "",
|
|
763
769
|
F ? "liforma-et--scroll-parallax" : "",
|
|
764
770
|
j && !ve ? "liforma-et--loading" : "",
|
|
@@ -766,7 +772,7 @@ function Ae(e) {
|
|
|
766
772
|
ee
|
|
767
773
|
].filter(Boolean).join(" "), be = {
|
|
768
774
|
"--liforma-et-parallax-x": ne,
|
|
769
|
-
"--liforma-et-parallax-y":
|
|
775
|
+
"--liforma-et-parallax-y": re
|
|
770
776
|
}, K = (e, t) => {
|
|
771
777
|
e.complete && t(!0);
|
|
772
778
|
}, xe = /* @__PURE__ */ f(u, { children: [
|
|
@@ -775,39 +781,39 @@ function Ae(e) {
|
|
|
775
781
|
"aria-hidden": "true"
|
|
776
782
|
}),
|
|
777
783
|
j && w.backgroundImage ? /* @__PURE__ */ d("img", {
|
|
778
|
-
className: ke("liforma-et__background",
|
|
784
|
+
className: ke("liforma-et__background", B),
|
|
779
785
|
src: w.backgroundImage,
|
|
780
786
|
alt: "",
|
|
781
787
|
decoding: "async",
|
|
782
788
|
ref: (e) => {
|
|
783
|
-
e && K(e,
|
|
789
|
+
e && K(e, oe);
|
|
784
790
|
},
|
|
785
|
-
onLoad: () =>
|
|
786
|
-
onError: () =>
|
|
791
|
+
onLoad: () => oe(!0),
|
|
792
|
+
onError: () => oe(!0)
|
|
787
793
|
}) : null,
|
|
788
794
|
j && W ? /* @__PURE__ */ d("img", {
|
|
789
|
-
className: ke("liforma-et__avatar",
|
|
795
|
+
className: ke("liforma-et__avatar", ce),
|
|
790
796
|
src: W,
|
|
791
797
|
alt: "",
|
|
792
798
|
decoding: "async",
|
|
793
799
|
ref: (e) => {
|
|
794
|
-
e && K(e,
|
|
800
|
+
e && K(e, le);
|
|
795
801
|
},
|
|
796
|
-
onLoad: () =>
|
|
802
|
+
onLoad: () => le(!0),
|
|
797
803
|
onError: () => {
|
|
798
|
-
w.fallbackImage ?
|
|
804
|
+
w.fallbackImage ? ae(!0) : le(!0);
|
|
799
805
|
}
|
|
800
806
|
}) : null,
|
|
801
807
|
j && w.foregroundImage ? /* @__PURE__ */ d("img", {
|
|
802
|
-
className: ke("liforma-et__foreground",
|
|
808
|
+
className: ke("liforma-et__foreground", ue),
|
|
803
809
|
src: w.foregroundImage,
|
|
804
810
|
alt: "",
|
|
805
811
|
decoding: "async",
|
|
806
812
|
ref: (e) => {
|
|
807
|
-
e && K(e,
|
|
813
|
+
e && K(e, H);
|
|
808
814
|
},
|
|
809
|
-
onLoad: () =>
|
|
810
|
-
onError: () =>
|
|
815
|
+
onLoad: () => H(!0),
|
|
816
|
+
onError: () => H(!0)
|
|
811
817
|
}) : null
|
|
812
818
|
] }), Se = {
|
|
813
819
|
onPointerDown: me,
|
|
@@ -818,16 +824,16 @@ function Ae(e) {
|
|
|
818
824
|
},
|
|
819
825
|
onPointerMove: fe,
|
|
820
826
|
onPointerLeave: () => {
|
|
821
|
-
A.current || (P(!1), F || (
|
|
827
|
+
A.current || (P(!1), F || (L(0), R(0)));
|
|
822
828
|
}
|
|
823
829
|
}, q = (e) => {
|
|
824
830
|
k.current = e;
|
|
825
831
|
};
|
|
826
|
-
return T === "anchor" &&
|
|
832
|
+
return T === "anchor" && U ? /* @__PURE__ */ d("a", {
|
|
827
833
|
ref: q,
|
|
828
834
|
className: G,
|
|
829
835
|
style: be,
|
|
830
|
-
href:
|
|
836
|
+
href: U,
|
|
831
837
|
target: h,
|
|
832
838
|
rel: g,
|
|
833
839
|
"aria-label": l,
|
|
@@ -878,7 +884,7 @@ function Ie() {
|
|
|
878
884
|
return t ? t.replace(/\/$/, "") : null;
|
|
879
885
|
}
|
|
880
886
|
function Le() {
|
|
881
|
-
return Ie() || (
|
|
887
|
+
return Ie() || (ae() ? Fe : Pe);
|
|
882
888
|
}
|
|
883
889
|
//#endregion
|
|
884
890
|
//#region src/v2/api/fetchExperiencePreview.ts
|
|
@@ -1739,37 +1745,40 @@ function Dt() {
|
|
|
1739
1745
|
}
|
|
1740
1746
|
function Ot() {
|
|
1741
1747
|
let e = Dt();
|
|
1742
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` :
|
|
1748
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : ae() ? Et : Tt;
|
|
1749
|
+
}
|
|
1750
|
+
function kt(e, t) {
|
|
1751
|
+
return e?.trim() || t?.trim() || void 0;
|
|
1743
1752
|
}
|
|
1744
|
-
function
|
|
1753
|
+
function At(e, t, n, r, i, a, o, s) {
|
|
1745
1754
|
let c = (e ?? Ot()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
|
|
1746
|
-
d && u.searchParams.set("locationId", d);
|
|
1755
|
+
d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
|
|
1747
1756
|
let f = r?.trim();
|
|
1748
|
-
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)),
|
|
1757
|
+
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)), jt(u.toString());
|
|
1749
1758
|
}
|
|
1750
|
-
function
|
|
1759
|
+
function jt(e) {
|
|
1751
1760
|
if (typeof location > "u") return e;
|
|
1752
1761
|
let t = new URL(e);
|
|
1753
1762
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1754
1763
|
}
|
|
1755
|
-
function
|
|
1764
|
+
function Mt(e) {
|
|
1756
1765
|
return new URL(e).origin;
|
|
1757
1766
|
}
|
|
1758
1767
|
//#endregion
|
|
1759
1768
|
//#region src/v2/experienceEvents.ts
|
|
1760
|
-
function
|
|
1769
|
+
function Nt() {
|
|
1761
1770
|
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)}`;
|
|
1762
1771
|
}
|
|
1763
|
-
function
|
|
1772
|
+
function Pt(e, t, n) {
|
|
1764
1773
|
return {
|
|
1765
|
-
id:
|
|
1774
|
+
id: Nt(),
|
|
1766
1775
|
type: e,
|
|
1767
1776
|
sessionId: t,
|
|
1768
1777
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1769
1778
|
data: n
|
|
1770
1779
|
};
|
|
1771
1780
|
}
|
|
1772
|
-
function
|
|
1781
|
+
function Ft() {
|
|
1773
1782
|
return {
|
|
1774
1783
|
ready: /* @__PURE__ */ new Set(),
|
|
1775
1784
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1788,39 +1797,39 @@ function Pt() {
|
|
|
1788
1797
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1789
1798
|
};
|
|
1790
1799
|
}
|
|
1791
|
-
function
|
|
1800
|
+
function It(e, t, n) {
|
|
1792
1801
|
return e[t].add(n), () => e[t].delete(n);
|
|
1793
1802
|
}
|
|
1794
|
-
function
|
|
1803
|
+
function Lt(e, t, n) {
|
|
1795
1804
|
for (let r of e[t]) r(n);
|
|
1796
1805
|
}
|
|
1797
|
-
function
|
|
1806
|
+
function Rt(e) {
|
|
1798
1807
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1799
1808
|
}
|
|
1800
1809
|
//#endregion
|
|
1801
1810
|
//#region src/v2/speech/types.ts
|
|
1802
|
-
function
|
|
1811
|
+
function zt(e) {
|
|
1803
1812
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1804
1813
|
}
|
|
1805
|
-
function
|
|
1814
|
+
function Bt(e) {
|
|
1806
1815
|
return "url" in e && typeof e.url == "string";
|
|
1807
1816
|
}
|
|
1808
|
-
function
|
|
1817
|
+
function Vt(e) {
|
|
1809
1818
|
if (!("track" in e)) return !1;
|
|
1810
1819
|
let t = e.track;
|
|
1811
1820
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1812
1821
|
}
|
|
1813
|
-
function
|
|
1814
|
-
return !
|
|
1822
|
+
function Ht(e) {
|
|
1823
|
+
return !zt(e) && !Bt(e) && !Vt(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1815
1824
|
}
|
|
1816
|
-
var
|
|
1825
|
+
var Ut = [
|
|
1817
1826
|
8e3,
|
|
1818
1827
|
16e3,
|
|
1819
1828
|
22050,
|
|
1820
1829
|
24e3,
|
|
1821
1830
|
44100,
|
|
1822
1831
|
48e3
|
|
1823
|
-
],
|
|
1832
|
+
], Wt = {
|
|
1824
1833
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1825
1834
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1826
1835
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1831,14 +1840,14 @@ var Ht = [
|
|
|
1831
1840
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1832
1841
|
MAX_PENDING_WRITES: 8,
|
|
1833
1842
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1834
|
-
},
|
|
1843
|
+
}, Gt = class extends Error {
|
|
1835
1844
|
operation;
|
|
1836
1845
|
requiredCapability;
|
|
1837
1846
|
name = "UnsupportedSpeechOperationError";
|
|
1838
1847
|
constructor(e, t) {
|
|
1839
1848
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1840
1849
|
}
|
|
1841
|
-
},
|
|
1850
|
+
}, Kt = class extends Error {
|
|
1842
1851
|
name = "SpeechUtteranceClosedError";
|
|
1843
1852
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1844
1853
|
super(e);
|
|
@@ -1848,72 +1857,72 @@ var Ht = [
|
|
|
1848
1857
|
constructor(e, t) {
|
|
1849
1858
|
super(e, t);
|
|
1850
1859
|
}
|
|
1851
|
-
},
|
|
1860
|
+
}, qt = class extends Error {
|
|
1852
1861
|
name = "SpeechBufferTimeoutError";
|
|
1853
1862
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1854
1863
|
super(e);
|
|
1855
1864
|
}
|
|
1856
1865
|
};
|
|
1857
|
-
function
|
|
1866
|
+
function Jt(e = "none") {
|
|
1858
1867
|
return {
|
|
1859
1868
|
mode: e,
|
|
1860
1869
|
trackedDurationMs: 0,
|
|
1861
1870
|
fallbackDurationMs: 0
|
|
1862
1871
|
};
|
|
1863
1872
|
}
|
|
1864
|
-
function Jt(e) {
|
|
1865
|
-
return Ht.includes(e);
|
|
1866
|
-
}
|
|
1867
1873
|
function Yt(e) {
|
|
1874
|
+
return Ut.includes(e);
|
|
1875
|
+
}
|
|
1876
|
+
function Xt(e) {
|
|
1868
1877
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
1869
1878
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
1870
|
-
if (!
|
|
1879
|
+
if (!Yt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1871
1880
|
}
|
|
1872
|
-
function
|
|
1873
|
-
if (
|
|
1874
|
-
|
|
1881
|
+
function Zt(e) {
|
|
1882
|
+
if (zt(e)) {
|
|
1883
|
+
Xt(e.format);
|
|
1875
1884
|
return;
|
|
1876
1885
|
}
|
|
1877
|
-
if (
|
|
1886
|
+
if (Bt(e)) {
|
|
1878
1887
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
1879
|
-
if (e.sampleRate !== void 0 && !
|
|
1888
|
+
if (e.sampleRate !== void 0 && !Yt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1880
1889
|
return;
|
|
1881
1890
|
}
|
|
1882
|
-
if (
|
|
1891
|
+
if (Vt(e)) {
|
|
1883
1892
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
1884
|
-
if (e.sampleRate !== void 0 && !
|
|
1893
|
+
if (e.sampleRate !== void 0 && !Yt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1885
1894
|
return;
|
|
1886
1895
|
}
|
|
1887
|
-
if (
|
|
1896
|
+
if (Ht(e)) {
|
|
1888
1897
|
let t = e.encoding.trim().toLowerCase();
|
|
1889
1898
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
1890
1899
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1891
|
-
if (e.sampleRate !== void 0 && !
|
|
1900
|
+
if (e.sampleRate !== void 0 && !Yt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1892
1901
|
return;
|
|
1893
1902
|
}
|
|
1894
1903
|
throw new Q("Unsupported speech.play audio shape.");
|
|
1895
1904
|
}
|
|
1896
|
-
function
|
|
1897
|
-
if (e.format) return
|
|
1905
|
+
function Qt(e) {
|
|
1906
|
+
if (e.format) return Xt(e.format), e.format;
|
|
1898
1907
|
if (e.track) {
|
|
1899
1908
|
let t = {
|
|
1900
1909
|
encoding: "pcm_s16le",
|
|
1901
1910
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1902
1911
|
channels: 1
|
|
1903
1912
|
};
|
|
1904
|
-
return
|
|
1913
|
+
return Xt(t), t;
|
|
1905
1914
|
}
|
|
1906
1915
|
throw new Q("createUtterance requires format or track.");
|
|
1907
1916
|
}
|
|
1908
|
-
function
|
|
1917
|
+
function $t(e) {
|
|
1909
1918
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1910
1919
|
}
|
|
1911
|
-
function
|
|
1920
|
+
function en(e) {
|
|
1912
1921
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1913
1922
|
}
|
|
1914
1923
|
//#endregion
|
|
1915
1924
|
//#region src/byo/pcm.ts
|
|
1916
|
-
function
|
|
1925
|
+
function tn(e) {
|
|
1917
1926
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1918
1927
|
for (let t = 0; t < e.length; t++) {
|
|
1919
1928
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1923,11 +1932,11 @@ function en(e) {
|
|
|
1923
1932
|
}
|
|
1924
1933
|
//#endregion
|
|
1925
1934
|
//#region src/byo/resample.ts
|
|
1926
|
-
function
|
|
1935
|
+
function nn(e, t, n, r, i) {
|
|
1927
1936
|
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;
|
|
1928
1937
|
return ((a * i + o) * i + s) * i + c;
|
|
1929
1938
|
}
|
|
1930
|
-
function
|
|
1939
|
+
function rn(e, t) {
|
|
1931
1940
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1932
1941
|
if (e === t) return {
|
|
1933
1942
|
fromRate: e,
|
|
@@ -1950,7 +1959,7 @@ function nn(e, t) {
|
|
|
1950
1959
|
let a = [];
|
|
1951
1960
|
for (; i + 2 < r.length - 1;) {
|
|
1952
1961
|
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);
|
|
1953
|
-
a.push(
|
|
1962
|
+
a.push(nn(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1954
1963
|
}
|
|
1955
1964
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1956
1965
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1962,7 +1971,7 @@ function nn(e, t) {
|
|
|
1962
1971
|
}
|
|
1963
1972
|
//#endregion
|
|
1964
1973
|
//#region src/byo/audioCapture.ts
|
|
1965
|
-
var
|
|
1974
|
+
var an = "liforma-pcm-capture", on = `
|
|
1966
1975
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1967
1976
|
process(inputs) {
|
|
1968
1977
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1974,29 +1983,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1974
1983
|
return true;
|
|
1975
1984
|
}
|
|
1976
1985
|
}
|
|
1977
|
-
registerProcessor('${
|
|
1978
|
-
`,
|
|
1979
|
-
function sn() {
|
|
1980
|
-
return on ||= URL.createObjectURL(new Blob([an], { type: "application/javascript" })), on;
|
|
1981
|
-
}
|
|
1986
|
+
registerProcessor('${an}', LiformaPcmCaptureProcessor);
|
|
1987
|
+
`, sn = null;
|
|
1982
1988
|
function cn() {
|
|
1989
|
+
return sn ||= URL.createObjectURL(new Blob([on], { type: "application/javascript" })), sn;
|
|
1990
|
+
}
|
|
1991
|
+
function ln() {
|
|
1983
1992
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1984
1993
|
}
|
|
1985
|
-
async function
|
|
1986
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
1994
|
+
async function un(e) {
|
|
1995
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = ln();
|
|
1987
1996
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1988
1997
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1989
1998
|
l.gain.value = 0;
|
|
1990
|
-
let u = s.sampleRate, d =
|
|
1999
|
+
let u = s.sampleRate, d = rn(u, n), f = !1, p = !1, m = (e) => {
|
|
1991
2000
|
if (f || i && !i()) return;
|
|
1992
2001
|
let t = d.push(e);
|
|
1993
|
-
t.length !== 0 && r(
|
|
2002
|
+
t.length !== 0 && r(tn(t));
|
|
1994
2003
|
}, h = () => void 0;
|
|
1995
2004
|
return await (async () => {
|
|
1996
2005
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
1997
2006
|
try {
|
|
1998
|
-
await s.audioWorklet.addModule(
|
|
1999
|
-
let e = new AudioWorkletNode(s,
|
|
2007
|
+
await s.audioWorklet.addModule(cn());
|
|
2008
|
+
let e = new AudioWorkletNode(s, an, {
|
|
2000
2009
|
numberOfInputs: 1,
|
|
2001
2010
|
numberOfOutputs: 1,
|
|
2002
2011
|
outputChannelCount: [1]
|
|
@@ -2046,7 +2055,7 @@ async function ln(e) {
|
|
|
2046
2055
|
}
|
|
2047
2056
|
//#endregion
|
|
2048
2057
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
2049
|
-
async function
|
|
2058
|
+
async function dn(e) {
|
|
2050
2059
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
2051
2060
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
2052
2061
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -2055,18 +2064,18 @@ async function un(e) {
|
|
|
2055
2064
|
s || (s = !0, c?.stop(), c = null);
|
|
2056
2065
|
};
|
|
2057
2066
|
try {
|
|
2058
|
-
c = await
|
|
2067
|
+
c = await un({
|
|
2059
2068
|
mediaStream: a,
|
|
2060
2069
|
targetSampleRate: r,
|
|
2061
2070
|
shouldSend: () => !s && !i?.aborted,
|
|
2062
2071
|
onPcm: (e) => {
|
|
2063
2072
|
if (s || i?.aborted) return;
|
|
2064
|
-
let t =
|
|
2073
|
+
let t = $t(e);
|
|
2065
2074
|
o = o.then(async () => {
|
|
2066
2075
|
if (s || i?.aborted) return;
|
|
2067
2076
|
let e = 0;
|
|
2068
2077
|
for (; e < t.byteLength;) {
|
|
2069
|
-
let r = Math.min(e +
|
|
2078
|
+
let r = Math.min(e + Wt.MAX_CHUNK_BYTES, t.byteLength);
|
|
2070
2079
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
2071
2080
|
let i = t.subarray(e, r);
|
|
2072
2081
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -2090,10 +2099,10 @@ async function un(e) {
|
|
|
2090
2099
|
}
|
|
2091
2100
|
//#endregion
|
|
2092
2101
|
//#region src/v2/speech/speechController.ts
|
|
2093
|
-
async function
|
|
2094
|
-
if (
|
|
2095
|
-
if (
|
|
2096
|
-
let t =
|
|
2102
|
+
async function fn(e, t) {
|
|
2103
|
+
if (Vt(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
2104
|
+
if (zt(e)) {
|
|
2105
|
+
let t = $t(e.data);
|
|
2097
2106
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
2098
2107
|
return {
|
|
2099
2108
|
kind: "pcm",
|
|
@@ -2101,17 +2110,17 @@ async function dn(e, t) {
|
|
|
2101
2110
|
format: e.format
|
|
2102
2111
|
};
|
|
2103
2112
|
}
|
|
2104
|
-
if (
|
|
2113
|
+
if (Bt(e)) return {
|
|
2105
2114
|
kind: "url",
|
|
2106
2115
|
url: e.url.trim(),
|
|
2107
2116
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2108
2117
|
};
|
|
2109
|
-
if (!
|
|
2118
|
+
if (!Ht(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
2110
2119
|
let n;
|
|
2111
2120
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
2112
2121
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2113
2122
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
2114
|
-
} else n =
|
|
2123
|
+
} else n = $t(e.data);
|
|
2115
2124
|
return {
|
|
2116
2125
|
kind: "encoded",
|
|
2117
2126
|
data: n.slice().buffer,
|
|
@@ -2119,10 +2128,10 @@ async function dn(e, t) {
|
|
|
2119
2128
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2120
2129
|
};
|
|
2121
2130
|
}
|
|
2122
|
-
function
|
|
2131
|
+
function pn() {
|
|
2123
2132
|
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)}`;
|
|
2124
2133
|
}
|
|
2125
|
-
function
|
|
2134
|
+
function mn(e, t = "completed") {
|
|
2126
2135
|
return {
|
|
2127
2136
|
utteranceId: e.speechId,
|
|
2128
2137
|
characterId: e.characterId,
|
|
@@ -2136,13 +2145,13 @@ function pn(e, t = "completed") {
|
|
|
2136
2145
|
}
|
|
2137
2146
|
};
|
|
2138
2147
|
}
|
|
2139
|
-
function
|
|
2148
|
+
function hn(e) {
|
|
2140
2149
|
return e instanceof Error ? e : new Q(String(e));
|
|
2141
2150
|
}
|
|
2142
|
-
function
|
|
2151
|
+
function gn(e) {
|
|
2143
2152
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
2144
2153
|
}
|
|
2145
|
-
var
|
|
2154
|
+
var _n = class {
|
|
2146
2155
|
id;
|
|
2147
2156
|
characterId;
|
|
2148
2157
|
result;
|
|
@@ -2171,29 +2180,29 @@ var gn = class {
|
|
|
2171
2180
|
queue: e.queue,
|
|
2172
2181
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
2173
2182
|
}).catch((e) => {
|
|
2174
|
-
throw this.fail(
|
|
2183
|
+
throw this.fail(hn(e)), hn(e);
|
|
2175
2184
|
}), this.signal?.addEventListener("abort", () => {
|
|
2176
2185
|
this.cancel();
|
|
2177
2186
|
}, { once: !0 });
|
|
2178
2187
|
}
|
|
2179
2188
|
async write(e, t) {
|
|
2180
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2181
|
-
let n =
|
|
2189
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Kt();
|
|
2190
|
+
let n = $t(e);
|
|
2182
2191
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
2183
|
-
if (n.byteLength >
|
|
2192
|
+
if (n.byteLength > Wt.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${Wt.MAX_CHUNK_BYTES}).`);
|
|
2184
2193
|
if (n.byteLength === 0) return;
|
|
2185
|
-
let r = t?.timeoutMs ??
|
|
2194
|
+
let r = t?.timeoutMs ?? Wt.DEFAULT_WRITE_TIMEOUT_MS;
|
|
2186
2195
|
await this.acquireWriteSlot(r);
|
|
2187
2196
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
2188
|
-
if (this.bufferedMs + i >
|
|
2197
|
+
if (this.bufferedMs + i > Wt.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
2189
2198
|
let a = async () => {
|
|
2190
|
-
if (this.closed || this.settled) throw new
|
|
2199
|
+
if (this.closed || this.settled) throw new Kt();
|
|
2191
2200
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
2192
2201
|
utteranceId: this.id,
|
|
2193
2202
|
audio: t.buffer,
|
|
2194
2203
|
byteLength: t.byteLength
|
|
2195
2204
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
2196
|
-
setTimeout(() => t(new
|
|
2205
|
+
setTimeout(() => t(new qt()), r);
|
|
2197
2206
|
})]);
|
|
2198
2207
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
2199
2208
|
}, o = this.writeChain.then(a, a);
|
|
@@ -2205,7 +2214,7 @@ var gn = class {
|
|
|
2205
2214
|
}
|
|
2206
2215
|
}
|
|
2207
2216
|
async setTranscript(e) {
|
|
2208
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2217
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Kt();
|
|
2209
2218
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
2210
2219
|
utteranceId: this.id,
|
|
2211
2220
|
transcript: e
|
|
@@ -2222,7 +2231,7 @@ var gn = class {
|
|
|
2222
2231
|
});
|
|
2223
2232
|
return this.resolve(t), t;
|
|
2224
2233
|
} catch (e) {
|
|
2225
|
-
let t =
|
|
2234
|
+
let t = hn(e);
|
|
2226
2235
|
throw this.fail(t), t;
|
|
2227
2236
|
}
|
|
2228
2237
|
}
|
|
@@ -2240,11 +2249,11 @@ var gn = class {
|
|
|
2240
2249
|
characterId: this.characterId,
|
|
2241
2250
|
status: "cancelled",
|
|
2242
2251
|
durationMs: 0,
|
|
2243
|
-
animation:
|
|
2252
|
+
animation: Jt("none")
|
|
2244
2253
|
};
|
|
2245
2254
|
return this.resolve(t), t;
|
|
2246
2255
|
} catch (e) {
|
|
2247
|
-
let t =
|
|
2256
|
+
let t = hn(e);
|
|
2248
2257
|
throw this.fail(t), t;
|
|
2249
2258
|
}
|
|
2250
2259
|
}
|
|
@@ -2257,19 +2266,19 @@ var gn = class {
|
|
|
2257
2266
|
return e;
|
|
2258
2267
|
}
|
|
2259
2268
|
resolve(e) {
|
|
2260
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2269
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new Kt()));
|
|
2261
2270
|
}
|
|
2262
2271
|
fail(e) {
|
|
2263
2272
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
2264
2273
|
}
|
|
2265
2274
|
async acquireWriteSlot(e) {
|
|
2266
|
-
if (this.pendingWriteCount <
|
|
2275
|
+
if (this.pendingWriteCount < Wt.MAX_PENDING_WRITES) {
|
|
2267
2276
|
this.pendingWriteCount += 1;
|
|
2268
2277
|
return;
|
|
2269
2278
|
}
|
|
2270
2279
|
await new Promise((t, n) => {
|
|
2271
2280
|
let r = setTimeout(() => {
|
|
2272
|
-
n(new
|
|
2281
|
+
n(new qt());
|
|
2273
2282
|
}, e);
|
|
2274
2283
|
this.pendingWriteWaiters.push({
|
|
2275
2284
|
resolve: () => {
|
|
@@ -2288,13 +2297,13 @@ var gn = class {
|
|
|
2288
2297
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2289
2298
|
}
|
|
2290
2299
|
};
|
|
2291
|
-
function
|
|
2300
|
+
function vn(e) {
|
|
2292
2301
|
let t = null, n = (t, n) => {
|
|
2293
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2302
|
+
if (!e.getCapabilities()[n]) throw new Gt(t, n);
|
|
2294
2303
|
}, r = {
|
|
2295
2304
|
async speak(r) {
|
|
2296
2305
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2297
|
-
let i =
|
|
2306
|
+
let i = en(r.queue ?? "append");
|
|
2298
2307
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2299
2308
|
let a = e.getIframeHost();
|
|
2300
2309
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -2314,41 +2323,41 @@ function _n(e) {
|
|
|
2314
2323
|
return;
|
|
2315
2324
|
}
|
|
2316
2325
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2317
|
-
t.removeEventListener("abort", s), n(
|
|
2326
|
+
t.removeEventListener("abort", s), n(mn(e, "completed"));
|
|
2318
2327
|
}, (a) => {
|
|
2319
|
-
if (t.removeEventListener("abort", s),
|
|
2328
|
+
if (t.removeEventListener("abort", s), gn(a)) {
|
|
2320
2329
|
n({
|
|
2321
2330
|
utteranceId: "utt_interrupted",
|
|
2322
2331
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2323
2332
|
status: "interrupted",
|
|
2324
2333
|
durationMs: 0,
|
|
2325
2334
|
transcript: r.text,
|
|
2326
|
-
animation:
|
|
2335
|
+
animation: Jt("none")
|
|
2327
2336
|
});
|
|
2328
2337
|
return;
|
|
2329
2338
|
}
|
|
2330
|
-
i(
|
|
2339
|
+
i(hn(a));
|
|
2331
2340
|
});
|
|
2332
2341
|
});
|
|
2333
2342
|
}
|
|
2334
2343
|
try {
|
|
2335
|
-
return
|
|
2344
|
+
return mn(await o, "completed");
|
|
2336
2345
|
} catch (t) {
|
|
2337
|
-
if (
|
|
2346
|
+
if (gn(t)) return {
|
|
2338
2347
|
utteranceId: "utt_interrupted",
|
|
2339
2348
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2340
2349
|
status: "interrupted",
|
|
2341
2350
|
durationMs: 0,
|
|
2342
2351
|
transcript: r.text,
|
|
2343
|
-
animation:
|
|
2352
|
+
animation: Jt("none")
|
|
2344
2353
|
};
|
|
2345
|
-
throw
|
|
2354
|
+
throw hn(t);
|
|
2346
2355
|
}
|
|
2347
2356
|
},
|
|
2348
2357
|
async play(i) {
|
|
2349
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2358
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), Zt(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2350
2359
|
let a = i.queue ?? "append";
|
|
2351
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2360
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), Vt(i.audio)) {
|
|
2352
2361
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2353
2362
|
return r.createUtterance({
|
|
2354
2363
|
format: {
|
|
@@ -2364,7 +2373,7 @@ function _n(e) {
|
|
|
2364
2373
|
}
|
|
2365
2374
|
let o = e.getIframeHost();
|
|
2366
2375
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2367
|
-
let s = await
|
|
2376
|
+
let s = await fn(i.audio, i.signal);
|
|
2368
2377
|
return o.speechPlay({
|
|
2369
2378
|
source: s,
|
|
2370
2379
|
characterId: i.characterId,
|
|
@@ -2376,13 +2385,13 @@ function _n(e) {
|
|
|
2376
2385
|
},
|
|
2377
2386
|
createUtterance(r) {
|
|
2378
2387
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2379
|
-
let i =
|
|
2388
|
+
let i = Qt(r);
|
|
2380
2389
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2381
2390
|
let a = r.queue ?? "replace-active";
|
|
2382
2391
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2383
2392
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2384
|
-
let o = new
|
|
2385
|
-
id:
|
|
2393
|
+
let o = new _n({
|
|
2394
|
+
id: pn(),
|
|
2386
2395
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2387
2396
|
format: i,
|
|
2388
2397
|
queue: a,
|
|
@@ -2394,7 +2403,7 @@ function _n(e) {
|
|
|
2394
2403
|
t === o && (t = null);
|
|
2395
2404
|
}), r.track && (async () => {
|
|
2396
2405
|
try {
|
|
2397
|
-
if (await
|
|
2406
|
+
if (await dn({
|
|
2398
2407
|
track: r.track,
|
|
2399
2408
|
utterance: o,
|
|
2400
2409
|
sampleRate: i.sampleRate,
|
|
@@ -2422,16 +2431,16 @@ function _n(e) {
|
|
|
2422
2431
|
}
|
|
2423
2432
|
//#endregion
|
|
2424
2433
|
//#region src/v2/types/sessionInteraction.ts
|
|
2425
|
-
function
|
|
2434
|
+
function yn(e) {
|
|
2426
2435
|
let t = e?.trim();
|
|
2427
2436
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2428
2437
|
}
|
|
2429
2438
|
//#endregion
|
|
2430
2439
|
//#region src/v2/experience.ts
|
|
2431
|
-
function
|
|
2440
|
+
function bn(e) {
|
|
2432
2441
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2433
2442
|
}
|
|
2434
|
-
var
|
|
2443
|
+
var xn = class e {
|
|
2435
2444
|
bootstrap;
|
|
2436
2445
|
conversationProcessor;
|
|
2437
2446
|
iframeHost = null;
|
|
@@ -2446,16 +2455,16 @@ var bn = class e {
|
|
|
2446
2455
|
attached = !1;
|
|
2447
2456
|
pendingFit = null;
|
|
2448
2457
|
closeHandlers = [];
|
|
2449
|
-
eventRegistry =
|
|
2458
|
+
eventRegistry = Ft();
|
|
2450
2459
|
readyEnvelope = null;
|
|
2451
2460
|
startedEnvelope = null;
|
|
2452
2461
|
conversationCache = [];
|
|
2453
2462
|
speech;
|
|
2454
2463
|
constructor(e) {
|
|
2455
|
-
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 =
|
|
2464
|
+
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 = vn({
|
|
2456
2465
|
getIframeHost: () => this.iframeHost,
|
|
2457
2466
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2458
|
-
getCapabilities: () =>
|
|
2467
|
+
getCapabilities: () => Sn(this.resolvedSession),
|
|
2459
2468
|
getActiveCharacterId: () => "character_unknown",
|
|
2460
2469
|
onProcessorInterrupt: () => {
|
|
2461
2470
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2470,6 +2479,9 @@ var bn = class e {
|
|
|
2470
2479
|
kind: "launch",
|
|
2471
2480
|
launch: n,
|
|
2472
2481
|
session: t.session,
|
|
2482
|
+
backdropId: t.backdropId,
|
|
2483
|
+
locationId: t.locationId,
|
|
2484
|
+
avatarId: t.avatarId,
|
|
2473
2485
|
embedBaseUrl: t.embedBaseUrl,
|
|
2474
2486
|
debug: t.debug,
|
|
2475
2487
|
speechOnly: t.speechOnly,
|
|
@@ -2487,6 +2499,7 @@ var bn = class e {
|
|
|
2487
2499
|
secondaryLocale: t.secondaryLocale,
|
|
2488
2500
|
learningLocale: t.learningLocale,
|
|
2489
2501
|
language: t.language,
|
|
2502
|
+
backdropId: t.backdropId,
|
|
2490
2503
|
locationId: t.locationId,
|
|
2491
2504
|
avatarId: t.avatarId,
|
|
2492
2505
|
castSize: t.castSize,
|
|
@@ -2507,6 +2520,7 @@ var bn = class e {
|
|
|
2507
2520
|
secondaryLocale: t.secondaryLocale,
|
|
2508
2521
|
learningLocale: t.learningLocale,
|
|
2509
2522
|
language: t.language,
|
|
2523
|
+
backdropId: t.backdropId,
|
|
2510
2524
|
locationId: t.locationId,
|
|
2511
2525
|
avatarId: t.avatarId,
|
|
2512
2526
|
castSize: t.castSize,
|
|
@@ -2529,7 +2543,7 @@ var bn = class e {
|
|
|
2529
2543
|
return null;
|
|
2530
2544
|
}
|
|
2531
2545
|
on(e, t) {
|
|
2532
|
-
let n =
|
|
2546
|
+
let n = It(this.eventRegistry, e, t);
|
|
2533
2547
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
|
|
2534
2548
|
}
|
|
2535
2549
|
async attach(e) {
|
|
@@ -2543,7 +2557,7 @@ var bn = class e {
|
|
|
2543
2557
|
if (this.closed) throw Error("Session has ended.");
|
|
2544
2558
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2545
2559
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2546
|
-
let t = this.bootstrap.embedBaseUrl ?? Ot(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i =
|
|
2560
|
+
let t = this.bootstrap.embedBaseUrl ?? Ot(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = At(t, n, r ? void 0 : kt(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, bn(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = Mt(i), o = null, s = new Promise((e) => {
|
|
2547
2561
|
o = e;
|
|
2548
2562
|
}), c = null, l = new Promise((e) => {
|
|
2549
2563
|
c = e;
|
|
@@ -2678,7 +2692,7 @@ var bn = class e {
|
|
|
2678
2692
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2679
2693
|
}
|
|
2680
2694
|
async setFit(e) {
|
|
2681
|
-
let t =
|
|
2695
|
+
let t = yn(e);
|
|
2682
2696
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2683
2697
|
if (this.closed) throw Error("Session has ended.");
|
|
2684
2698
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
@@ -2692,7 +2706,7 @@ var bn = class e {
|
|
|
2692
2706
|
this.close();
|
|
2693
2707
|
}
|
|
2694
2708
|
destroy() {
|
|
2695
|
-
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,
|
|
2709
|
+
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);
|
|
2696
2710
|
}
|
|
2697
2711
|
resolveMintInteraction() {
|
|
2698
2712
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2704,8 +2718,8 @@ var bn = class e {
|
|
|
2704
2718
|
return this.resolvedSession?.id ?? "";
|
|
2705
2719
|
}
|
|
2706
2720
|
emitWrapped(e, t) {
|
|
2707
|
-
let n =
|
|
2708
|
-
return
|
|
2721
|
+
let n = Pt(e, this.getSessionId(), t);
|
|
2722
|
+
return Lt(this.eventRegistry, e, n), n;
|
|
2709
2723
|
}
|
|
2710
2724
|
queueProcessorTurn(e) {
|
|
2711
2725
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2764,7 +2778,7 @@ var bn = class e {
|
|
|
2764
2778
|
};
|
|
2765
2779
|
}
|
|
2766
2780
|
};
|
|
2767
|
-
function
|
|
2781
|
+
function Sn(e) {
|
|
2768
2782
|
return e ? {
|
|
2769
2783
|
textSpeech: e.capabilities.speech.output,
|
|
2770
2784
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2775,41 +2789,41 @@ function xn(e) {
|
|
|
2775
2789
|
}
|
|
2776
2790
|
//#endregion
|
|
2777
2791
|
//#region src/widget/dockGeometry.ts
|
|
2778
|
-
var
|
|
2779
|
-
function
|
|
2792
|
+
var Cn = "(min-width: 768px)", wn = 24, Tn = .5, En = 1200, Dn = .85, On = 9 / 16;
|
|
2793
|
+
function kn() {
|
|
2780
2794
|
if (typeof window > "u") return 800;
|
|
2781
2795
|
let e = window.screen?.availHeight;
|
|
2782
2796
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2783
2797
|
}
|
|
2784
|
-
function
|
|
2785
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2786
|
-
return s > a && (s = a, o = s /
|
|
2798
|
+
function An(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = wn, r = typeof window < "u" ? kn() : 800) {
|
|
2799
|
+
let i = Math.max(160, Math.min(t - n * 2, t * Dn)), a = Math.max(120, e - n * 2), o = Math.min(r * Tn, En, i), s = o * On;
|
|
2800
|
+
return s > a && (s = a, o = s / On, o > i && (o = i, s = o * On)), {
|
|
2787
2801
|
width: Math.round(s),
|
|
2788
2802
|
height: Math.round(o)
|
|
2789
2803
|
};
|
|
2790
2804
|
}
|
|
2791
|
-
function
|
|
2805
|
+
function jn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = wn) {
|
|
2792
2806
|
return {
|
|
2793
2807
|
left: Math.max(r, t - e.width - r),
|
|
2794
2808
|
top: Math.max(r, n - e.height - r)
|
|
2795
2809
|
};
|
|
2796
2810
|
}
|
|
2797
|
-
function
|
|
2811
|
+
function Mn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = wn) {
|
|
2798
2812
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2799
2813
|
return {
|
|
2800
2814
|
left: Math.min(Math.max(a, e), o),
|
|
2801
2815
|
top: Math.min(Math.max(a, t), s)
|
|
2802
2816
|
};
|
|
2803
2817
|
}
|
|
2804
|
-
function
|
|
2805
|
-
return e(
|
|
2818
|
+
function Nn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2819
|
+
return e(Cn).matches;
|
|
2806
2820
|
}
|
|
2807
2821
|
//#endregion
|
|
2808
2822
|
//#region src/widget/mountExperienceWidget.ts
|
|
2809
|
-
function
|
|
2823
|
+
function Pn(e) {
|
|
2810
2824
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2811
2825
|
}
|
|
2812
|
-
function
|
|
2826
|
+
function Fn(e) {
|
|
2813
2827
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2814
2828
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2815
2829
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2817,10 +2831,10 @@ function Pn(e) {
|
|
|
2817
2831
|
function $(e) {
|
|
2818
2832
|
return e === "expanded" || e === "docked";
|
|
2819
2833
|
}
|
|
2820
|
-
var
|
|
2821
|
-
function
|
|
2834
|
+
var In = "<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>", Rn = "<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>", zn = "<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>";
|
|
2835
|
+
function Bn(e, t, n) {
|
|
2822
2836
|
Oe(Ee);
|
|
2823
|
-
let r =
|
|
2837
|
+
let r = ie({
|
|
2824
2838
|
galleryThumb: t.galleryThumb,
|
|
2825
2839
|
avatarImage: t.avatarImage,
|
|
2826
2840
|
backgroundImage: t.backgroundImage,
|
|
@@ -2848,7 +2862,7 @@ function zn(e, t, n) {
|
|
|
2848
2862
|
}
|
|
2849
2863
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : Te(i);
|
|
2850
2864
|
}
|
|
2851
|
-
function
|
|
2865
|
+
function Vn(e) {
|
|
2852
2866
|
return e.startButton ? {
|
|
2853
2867
|
...e.startButton,
|
|
2854
2868
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2860,7 +2874,7 @@ function Bn(e) {
|
|
|
2860
2874
|
variant: "primary"
|
|
2861
2875
|
};
|
|
2862
2876
|
}
|
|
2863
|
-
function
|
|
2877
|
+
function Hn(e) {
|
|
2864
2878
|
let t = !1, n = () => {
|
|
2865
2879
|
t || e();
|
|
2866
2880
|
}, r = () => {
|
|
@@ -2880,12 +2894,12 @@ function Vn(e) {
|
|
|
2880
2894
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2881
2895
|
};
|
|
2882
2896
|
}
|
|
2883
|
-
function
|
|
2897
|
+
function Un(e, t) {
|
|
2884
2898
|
Ne(je);
|
|
2885
2899
|
let n = t.experienceId?.trim();
|
|
2886
2900
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
2887
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
2888
|
-
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",
|
|
2901
|
+
let r = t.prefetch ?? "onExpand", i = Pn(t.position), a = document.createElement("div");
|
|
2902
|
+
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", Fn(t.offset));
|
|
2889
2903
|
let o = document.createElement("button");
|
|
2890
2904
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2891
2905
|
let s = document.createElement("div");
|
|
@@ -2905,74 +2919,74 @@ function Hn(e, t) {
|
|
|
2905
2919
|
let m = document.createElement("span");
|
|
2906
2920
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2907
2921
|
let h = document.createElement("button");
|
|
2908
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
2922
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = Rn, h.setAttribute("aria-label", "Reduce");
|
|
2909
2923
|
let g = document.createElement("button");
|
|
2910
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
2924
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = In, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
2911
2925
|
let _ = document.createElement("button");
|
|
2912
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
2926
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = Ln, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
2913
2927
|
let v = document.createElement("div");
|
|
2914
2928
|
v.className = "liforma-ew__stage";
|
|
2915
2929
|
let y = document.createElement("div");
|
|
2916
2930
|
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);
|
|
2917
|
-
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,
|
|
2931
|
+
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(), R = t.parallax !== !1, z = () => {
|
|
2918
2932
|
let e = a.dataset.state;
|
|
2919
2933
|
return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
|
|
2920
|
-
},
|
|
2934
|
+
}, ie = () => {
|
|
2921
2935
|
j !== null && (clearTimeout(j), j = null);
|
|
2922
|
-
},
|
|
2936
|
+
}, ae = () => {
|
|
2923
2937
|
M !== null && (clearTimeout(M), M = null), a.classList.remove("liforma-ew--layout-settling");
|
|
2924
|
-
},
|
|
2938
|
+
}, B = () => {
|
|
2925
2939
|
for (let e of [
|
|
2926
2940
|
f,
|
|
2927
2941
|
l,
|
|
2928
2942
|
p
|
|
2929
2943
|
]) e.style.removeProperty("left"), e.style.removeProperty("top"), e.style.removeProperty("width"), e.style.removeProperty("height"), e.style.removeProperty("right"), e.style.removeProperty("bottom");
|
|
2930
2944
|
p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging");
|
|
2931
|
-
},
|
|
2945
|
+
}, oe = (e, t, n, r) => {
|
|
2932
2946
|
let i = (i) => {
|
|
2933
2947
|
i.style.left = `${e}px`, i.style.top = `${t}px`, i.style.width = `${n}px`, i.style.height = `${r}px`, i.style.right = "auto", i.style.bottom = "auto";
|
|
2934
2948
|
};
|
|
2935
2949
|
i(f), i(l);
|
|
2936
2950
|
let a = p.offsetWidth || 120;
|
|
2937
2951
|
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";
|
|
2938
|
-
}, oe = (e, t) => {
|
|
2939
|
-
if (R() !== "docked") return;
|
|
2940
|
-
let n = kn(), r = jn(e - te, t - ne, n);
|
|
2941
|
-
N = r.left, P = r.top, ae(r.left, r.top, n.width, n.height);
|
|
2942
2952
|
}, se = (e, t) => {
|
|
2943
|
-
if (
|
|
2944
|
-
let n =
|
|
2945
|
-
N =
|
|
2946
|
-
}, ce = (e) => {
|
|
2947
|
-
|
|
2948
|
-
|
|
2953
|
+
if (z() !== "docked") return;
|
|
2954
|
+
let n = An(), r = Mn(e - te, t - ne, n);
|
|
2955
|
+
N = r.left, P = r.top, oe(r.left, r.top, n.width, n.height);
|
|
2956
|
+
}, ce = (e, t) => {
|
|
2957
|
+
if (z() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2958
|
+
let n = An(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = Mn(r + e, i + t, n);
|
|
2959
|
+
N = a.left, P = a.top, oe(a.left, a.top, n.width, n.height);
|
|
2960
|
+
}, le = (e) => {
|
|
2961
|
+
I === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), se(e.clientX, e.clientY)));
|
|
2962
|
+
}, V = (e) => {
|
|
2949
2963
|
if (F === null || e && e.pointerId !== F) return;
|
|
2950
|
-
let t =
|
|
2951
|
-
F = null,
|
|
2952
|
-
},
|
|
2953
|
-
if (S ||
|
|
2954
|
-
F = n,
|
|
2964
|
+
let t = I;
|
|
2965
|
+
F = null, I = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && L && (L = !1, window.removeEventListener("pointermove", le), window.removeEventListener("pointerup", V), window.removeEventListener("pointercancel", V));
|
|
2966
|
+
}, ue = (e, t, n) => {
|
|
2967
|
+
if (S || z() !== "docked" || !Nn() || F !== null) return;
|
|
2968
|
+
F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2955
2969
|
let r = f.getBoundingClientRect();
|
|
2956
|
-
te = e - r.left, ne = t - r.top,
|
|
2957
|
-
},
|
|
2958
|
-
if (S ||
|
|
2959
|
-
F = e.pointerId,
|
|
2970
|
+
te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", le), window.addEventListener("pointerup", V), window.addEventListener("pointercancel", V));
|
|
2971
|
+
}, H = (e) => {
|
|
2972
|
+
if (S || z() !== "docked" || !Nn() || F !== null) return;
|
|
2973
|
+
F = e.pointerId, I = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2960
2974
|
let t = f.getBoundingClientRect();
|
|
2961
2975
|
N = t.left, P = t.top;
|
|
2962
|
-
},
|
|
2963
|
-
|
|
2976
|
+
}, U = (e) => {
|
|
2977
|
+
I === "player" && (F === null || e.pointerId !== F || ce(e.dx, e.dy));
|
|
2964
2978
|
}, de = (e) => {
|
|
2965
|
-
|
|
2979
|
+
I === "player" && (F === null || e.pointerId !== F || V());
|
|
2966
2980
|
}, W = () => {
|
|
2967
|
-
let e =
|
|
2981
|
+
let e = Nn(), t = z();
|
|
2968
2982
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
2969
2983
|
h.hidden = !0;
|
|
2970
2984
|
return;
|
|
2971
2985
|
}
|
|
2972
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
2986
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = zn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = Rn, h.setAttribute("aria-label", "Reduce"));
|
|
2973
2987
|
}, fe = (e) => {
|
|
2974
|
-
let t =
|
|
2975
|
-
n =
|
|
2988
|
+
let t = An(), n = e && N !== null && P !== null ? Mn(N, P, t) : jn(t);
|
|
2989
|
+
n = Mn(n.left, n.top, t), N = n.left, P = n.top, oe(n.left, n.top, t.width, t.height), W();
|
|
2976
2990
|
}, pe = () => {
|
|
2977
2991
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2978
2992
|
requestAnimationFrame(() => {
|
|
@@ -2980,7 +2994,7 @@ function Hn(e, t) {
|
|
|
2980
2994
|
});
|
|
2981
2995
|
});
|
|
2982
2996
|
}, me = (e) => {
|
|
2983
|
-
if (
|
|
2997
|
+
if (ae(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !E) {
|
|
2984
2998
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2985
2999
|
return;
|
|
2986
3000
|
}
|
|
@@ -2992,7 +3006,7 @@ function Hn(e, t) {
|
|
|
2992
3006
|
a.classList.remove("liforma-ew--layout-settling"), pe();
|
|
2993
3007
|
}, 220);
|
|
2994
3008
|
}, he = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
2995
|
-
|
|
3009
|
+
ie(), j = setTimeout(() => {
|
|
2996
3010
|
j = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
2997
3011
|
}, 280);
|
|
2998
3012
|
})), ge = {
|
|
@@ -3019,20 +3033,20 @@ function Hn(e, t) {
|
|
|
3019
3033
|
C = !0, a.dataset.warm = "true", l.hidden = !1, E || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
3020
3034
|
}, be = (e) => {
|
|
3021
3035
|
k?.(), k = null;
|
|
3022
|
-
let t =
|
|
3036
|
+
let t = Bn(s, e, { parallax: R });
|
|
3023
3037
|
return t ? (k = t, !0) : !1;
|
|
3024
3038
|
}, K = () => {
|
|
3025
3039
|
if (be(ge)) {
|
|
3026
3040
|
ye();
|
|
3027
3041
|
return;
|
|
3028
3042
|
}
|
|
3029
|
-
ve("Loading…"), ze(n, { signal:
|
|
3043
|
+
ve("Loading…"), ze(n, { signal: re.signal }).then((e) => {
|
|
3030
3044
|
if (!S) {
|
|
3031
3045
|
if (!be({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
|
|
3032
3046
|
ye();
|
|
3033
3047
|
}
|
|
3034
3048
|
}).catch((e) => {
|
|
3035
|
-
if (S ||
|
|
3049
|
+
if (S || re.signal.aborted) return;
|
|
3036
3050
|
let n = e instanceof Error ? e : Error(String(e));
|
|
3037
3051
|
ve("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
|
|
3038
3052
|
});
|
|
@@ -3048,10 +3062,10 @@ function Hn(e, t) {
|
|
|
3048
3062
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
3049
3063
|
}), Se = () => ({
|
|
3050
3064
|
...t.fit ? { fit: t.fit } : {},
|
|
3051
|
-
startButton:
|
|
3065
|
+
startButton: Vn(t),
|
|
3052
3066
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
|
|
3053
3067
|
}), q = (e = !0) => {
|
|
3054
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"),
|
|
3068
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), B(), a.dataset.state = "expanded", _e(null), typeof document < "u" && (O = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
|
|
3055
3069
|
}, Ce = () => {
|
|
3056
3070
|
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", _e(null), typeof document < "u" && (document.body.style.overflow = O), fe(!0), W(), b?.setWidgetChrome("docked");
|
|
3057
3071
|
}, we = (e) => {
|
|
@@ -3063,14 +3077,14 @@ function Hn(e, t) {
|
|
|
3063
3077
|
S || t.onFeedbackFailed?.(e);
|
|
3064
3078
|
});
|
|
3065
3079
|
}, Te = () => {
|
|
3066
|
-
|
|
3080
|
+
ae(), u.hidden = !0, p.hidden = !0, B(), 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), _e(null), typeof document < "u" && (document.body.style.overflow = O), W();
|
|
3067
3081
|
}, Ee = () => {
|
|
3068
|
-
|
|
3082
|
+
ie(), ae(), D += 1, x = !1, C = !1, w = !1, T = !1, E = !1;
|
|
3069
3083
|
let e = b;
|
|
3070
3084
|
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");
|
|
3071
3085
|
}, De = () => {
|
|
3072
3086
|
if (!S && $(a.dataset.state)) {
|
|
3073
|
-
if (
|
|
3087
|
+
if (V(), x = !1, b && T) {
|
|
3074
3088
|
let e = b;
|
|
3075
3089
|
(async () => {
|
|
3076
3090
|
E && (await he(), S || b !== e) || (C && e.setWidgetChrome("collapsed"), Te(), E ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : C && G(), t.onCollapsed?.(), t.onClose?.());
|
|
@@ -3080,26 +3094,26 @@ function Hn(e, t) {
|
|
|
3080
3094
|
Ee(), Te(), t.onCollapsed?.(), t.onClose?.();
|
|
3081
3095
|
}
|
|
3082
3096
|
}, Oe = () => {
|
|
3083
|
-
S ||
|
|
3097
|
+
S || Nn() && z() === "expanded" && me(() => {
|
|
3084
3098
|
Ce();
|
|
3085
3099
|
});
|
|
3086
3100
|
}, ke = () => {
|
|
3087
|
-
S ||
|
|
3088
|
-
|
|
3101
|
+
S || z() === "docked" && (V(), me(() => {
|
|
3102
|
+
B(), q(!1), b?.setWidgetChrome("expanded");
|
|
3089
3103
|
}));
|
|
3090
3104
|
}, Ae = () => {
|
|
3091
|
-
!b || !E || (
|
|
3105
|
+
!b || !E || (ie(), a.classList.remove("liforma-ew--session-revealed"), q(), b.setWidgetChrome("expanded"), x = !1, pe());
|
|
3092
3106
|
}, Me = () => {
|
|
3093
|
-
!b || !T || E || (
|
|
3107
|
+
!b || !T || E || (ie(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, C || b.setWidgetChrome("expanded"));
|
|
3094
3108
|
}, Pe = (e) => {
|
|
3095
|
-
S || e !== D && !E || (
|
|
3109
|
+
S || e !== D && !E || (ie(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, E && pe());
|
|
3096
3110
|
}, Fe = () => {
|
|
3097
3111
|
if (S || w || C || b || $(a.dataset.state)) return;
|
|
3098
3112
|
w = !0;
|
|
3099
3113
|
let e = D;
|
|
3100
3114
|
l.hidden = !1, (async () => {
|
|
3101
3115
|
try {
|
|
3102
|
-
let t = await
|
|
3116
|
+
let t = await xn.startSession(xe());
|
|
3103
3117
|
if (S || e !== D) {
|
|
3104
3118
|
t.destroy();
|
|
3105
3119
|
return;
|
|
@@ -3118,10 +3132,10 @@ function Hn(e, t) {
|
|
|
3118
3132
|
S || J(e);
|
|
3119
3133
|
},
|
|
3120
3134
|
onWidgetDragStart: (e) => {
|
|
3121
|
-
S ||
|
|
3135
|
+
S || H(e);
|
|
3122
3136
|
},
|
|
3123
3137
|
onWidgetDragMove: (e) => {
|
|
3124
|
-
S ||
|
|
3138
|
+
S || U(e);
|
|
3125
3139
|
},
|
|
3126
3140
|
onWidgetDragEnd: (e) => {
|
|
3127
3141
|
S || de(e);
|
|
@@ -3158,7 +3172,7 @@ function Hn(e, t) {
|
|
|
3158
3172
|
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 () => {
|
|
3159
3173
|
try {
|
|
3160
3174
|
q();
|
|
3161
|
-
let t = await
|
|
3175
|
+
let t = await xn.startSession(xe());
|
|
3162
3176
|
if (S || e !== D) {
|
|
3163
3177
|
t.destroy();
|
|
3164
3178
|
return;
|
|
@@ -3171,10 +3185,10 @@ function Hn(e, t) {
|
|
|
3171
3185
|
S || J(e);
|
|
3172
3186
|
},
|
|
3173
3187
|
onWidgetDragStart: (e) => {
|
|
3174
|
-
S ||
|
|
3188
|
+
S || H(e);
|
|
3175
3189
|
},
|
|
3176
3190
|
onWidgetDragMove: (e) => {
|
|
3177
|
-
S ||
|
|
3191
|
+
S || U(e);
|
|
3178
3192
|
},
|
|
3179
3193
|
onWidgetDragEnd: (e) => {
|
|
3180
3194
|
S || de(e);
|
|
@@ -3215,23 +3229,23 @@ function Hn(e, t) {
|
|
|
3215
3229
|
Ie();
|
|
3216
3230
|
}
|
|
3217
3231
|
}, Re = (e) => {
|
|
3218
|
-
if (e.stopPropagation(),
|
|
3232
|
+
if (e.stopPropagation(), z() === "expanded") {
|
|
3219
3233
|
Oe();
|
|
3220
3234
|
return;
|
|
3221
3235
|
}
|
|
3222
|
-
|
|
3236
|
+
z() === "docked" && ke();
|
|
3223
3237
|
}, J = (e) => {
|
|
3224
3238
|
g.setAttribute("aria-pressed", e ? "true" : "false");
|
|
3225
3239
|
}, Be = (e) => {
|
|
3226
3240
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
3227
3241
|
}, Ve = (e) => {
|
|
3228
|
-
|
|
3242
|
+
z() === "docked" && Nn() && (e.target?.closest("button") || (e.preventDefault(), ue(e.clientX, e.clientY, e.pointerId)));
|
|
3229
3243
|
}, He = (e) => {
|
|
3230
3244
|
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), De());
|
|
3231
3245
|
}, Ue = () => {
|
|
3232
3246
|
if (!S) {
|
|
3233
|
-
if (
|
|
3234
|
-
if (!
|
|
3247
|
+
if (z() === "docked") {
|
|
3248
|
+
if (!Nn()) {
|
|
3235
3249
|
ke();
|
|
3236
3250
|
return;
|
|
3237
3251
|
}
|
|
@@ -3242,9 +3256,9 @@ function Hn(e, t) {
|
|
|
3242
3256
|
}
|
|
3243
3257
|
W();
|
|
3244
3258
|
}
|
|
3245
|
-
}, We = typeof window < "u" ? window.matchMedia(
|
|
3259
|
+
}, We = typeof window < "u" ? window.matchMedia(Cn) : null, Y = () => {
|
|
3246
3260
|
if (!S) {
|
|
3247
|
-
if (
|
|
3261
|
+
if (z() === "docked" && !Nn()) {
|
|
3248
3262
|
ke();
|
|
3249
3263
|
return;
|
|
3250
3264
|
}
|
|
@@ -3255,7 +3269,7 @@ function Hn(e, t) {
|
|
|
3255
3269
|
e.stopPropagation(), De();
|
|
3256
3270
|
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), We?.addEventListener("change", Y), K(), W(), r === "eager" ? queueMicrotask(() => {
|
|
3257
3271
|
S || Fe();
|
|
3258
|
-
}) : r === "idle" && (A =
|
|
3272
|
+
}) : r === "idle" && (A = Hn(() => {
|
|
3259
3273
|
S || Fe();
|
|
3260
3274
|
})), {
|
|
3261
3275
|
root: a,
|
|
@@ -3271,18 +3285,18 @@ function Hn(e, t) {
|
|
|
3271
3285
|
Fe();
|
|
3272
3286
|
},
|
|
3273
3287
|
destroy() {
|
|
3274
|
-
S || (S = !0,
|
|
3288
|
+
S || (S = !0, V(), A?.(), A = null, re.abort(), k?.(), k = null, window.removeEventListener("keydown", He), window.removeEventListener("resize", Ue), We?.removeEventListener("change", Y), Ee(), Te(), e.replaceChildren());
|
|
3275
3289
|
}
|
|
3276
3290
|
};
|
|
3277
3291
|
}
|
|
3278
3292
|
//#endregion
|
|
3279
3293
|
//#region src/react/ExperienceWidget.tsx
|
|
3280
|
-
function
|
|
3294
|
+
function Wn(e) {
|
|
3281
3295
|
let t = o(null), { experienceId: r, alt: i, galleryThumb: a, avatarImage: s, backgroundImage: c, foregroundImage: l, fallbackImage: u, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, language: _, mode: v, speechInputMode: y, speechOnly: b, fit: x, embedBaseUrl: S, expandedMaxWidth: ee, expandedMaxHeight: C, startButtonLabel: w, startButton: T, showFeedback: E, className: D = "", onExpanded: O, onCollapsed: k, onStarted: A, onClose: j, onError: M, onPrefetchReady: N, onFeedback: P, onFeedbackFailed: F } = e, te = m === "bottom-right" || m === "bottom-left";
|
|
3282
3296
|
return n(() => {
|
|
3283
3297
|
let e = t.current;
|
|
3284
3298
|
if (!e || !r.trim()) return;
|
|
3285
|
-
let n =
|
|
3299
|
+
let n = Un(e, {
|
|
3286
3300
|
experienceId: r,
|
|
3287
3301
|
alt: i,
|
|
3288
3302
|
galleryThumb: a,
|
|
@@ -3359,6 +3373,6 @@ function Un(e) {
|
|
|
3359
3373
|
});
|
|
3360
3374
|
}
|
|
3361
3375
|
//#endregion
|
|
3362
|
-
export { ne as Experience, Ae as ExperienceThumbnail,
|
|
3376
|
+
export { ne as Experience, Ae as ExperienceThumbnail, Wn as ExperienceWidget };
|
|
3363
3377
|
|
|
3364
3378
|
//# sourceMappingURL=index.js.map
|