@liforma/client 0.4.12 → 0.4.14
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 +23 -0
- package/README.md +4 -4
- package/dist/next/index.js +585 -491
- package/dist/next/index.js.map +1 -1
- package/dist/next/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/next/thumbnail/index.d.ts +1 -0
- package/dist/next/thumbnail/index.d.ts.map +1 -1
- package/dist/next/thumbnail/locationPlate.d.ts +3 -3
- package/dist/next/thumbnail/locationPlate.d.ts.map +1 -1
- package/dist/next/thumbnail/plateDelivery.d.ts +18 -0
- package/dist/next/thumbnail/plateDelivery.d.ts.map +1 -0
- package/dist/next/thumbnail/plateDelivery.test.d.ts +2 -0
- package/dist/next/thumbnail/plateDelivery.test.d.ts.map +1 -0
- package/dist/next/thumbnail/toGalleryThumbUrl.d.ts +1 -1
- package/dist/next/thumbnail.js +147 -91
- package/dist/next/thumbnail.js.map +1 -1
- package/dist/next/v2/embed/iframeHost.d.ts +4 -8
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +29 -2
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +14 -0
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts +4 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/npm/index.js +223 -185
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/thumbnail/index.d.ts +1 -0
- package/dist/npm/thumbnail/index.d.ts.map +1 -1
- package/dist/npm/thumbnail/index.js +106 -70
- package/dist/npm/thumbnail/index.js.map +1 -1
- package/dist/npm/thumbnail/locationPlate.d.ts +3 -3
- package/dist/npm/thumbnail/locationPlate.d.ts.map +1 -1
- package/dist/npm/thumbnail/plateDelivery.d.ts +18 -0
- package/dist/npm/thumbnail/plateDelivery.d.ts.map +1 -0
- package/dist/npm/thumbnail/toGalleryThumbUrl.d.ts +1 -1
- package/dist/npm/v2/embed/iframeHost.d.ts +4 -8
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +29 -2
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +14 -0
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/liforma-experience-thumbnail.d.ts.map +1 -1
- package/dist/npm/v2/shims/embedBaseUrl.d.ts +4 -1
- package/dist/npm/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentRuntime.d.ts +3 -0
- package/dist/react/component/experienceComponentRuntime.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +12 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +689 -573
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/react/thumbnail/index.d.ts +1 -0
- package/dist/react/thumbnail/index.d.ts.map +1 -1
- package/dist/react/thumbnail/locationPlate.d.ts +3 -3
- package/dist/react/thumbnail/locationPlate.d.ts.map +1 -1
- package/dist/react/thumbnail/plateDelivery.d.ts +18 -0
- package/dist/react/thumbnail/plateDelivery.d.ts.map +1 -0
- package/dist/react/thumbnail/plateDelivery.test.d.ts +2 -0
- package/dist/react/thumbnail/plateDelivery.test.d.ts.map +1 -0
- package/dist/react/thumbnail/toGalleryThumbUrl.d.ts +1 -1
- package/dist/react/thumbnail.js +147 -91
- package/dist/react/thumbnail.js.map +1 -1
- package/dist/react/v2/embed/iframeHost.d.ts +4 -8
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +29 -2
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +14 -0
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/shims/embedBaseUrl.d.ts +4 -1
- package/dist/react/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +2 -2
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/sdk/v2/thumbnail.js +3 -3
- package/dist/sdk/v2/thumbnail.js.map +1 -1
- package/dist/svelte/Experience.svelte +30 -0
- package/dist/svelte/Experience.svelte.d.ts +1 -0
- package/dist/svelte/ExperienceThumbnail.svelte +49 -8
- package/package.json +4 -1
package/dist/next/index.js
CHANGED
|
@@ -107,9 +107,9 @@ function y(e) {
|
|
|
107
107
|
}
|
|
108
108
|
//#endregion
|
|
109
109
|
//#region src/thumbnail/locationPlate.ts
|
|
110
|
-
var b = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
|
|
110
|
+
var b = /(-)(\d+x\d+)(\.(?:webp|avif))(\?|$)/i;
|
|
111
111
|
function x(e, t) {
|
|
112
|
-
return !Number.isFinite(e) || !Number.isFinite(t) || e < 1 || t < 1 || e <= t ? "256x256" : e > 800 || t > 450 ? "1672x941" : "800x450";
|
|
112
|
+
return !Number.isFinite(e) || !Number.isFinite(t) || e < 1 || t < 1 || e <= t ? "256x256" : t <= 225 ? "400x225" : e > 800 || t > 450 ? "1672x941" : "800x450";
|
|
113
113
|
}
|
|
114
114
|
function S(e, t) {
|
|
115
115
|
let n = e.trim();
|
|
@@ -123,7 +123,7 @@ function C(e, t) {
|
|
|
123
123
|
let r = new ResizeObserver(n);
|
|
124
124
|
return r.observe(e), () => r.disconnect();
|
|
125
125
|
}
|
|
126
|
-
var w = /-(256x256|400x450|800x450|836x971|1672x941|167x94)$/i;
|
|
126
|
+
var w = /-(256x256|400x225|400x450|800x450|836x971|1672x941|167x94)$/i;
|
|
127
127
|
function T(e) {
|
|
128
128
|
return e?.trim().replace(/\/$/, "") || "https://cdn.liforma.ai";
|
|
129
129
|
}
|
|
@@ -328,33 +328,33 @@ function he() {
|
|
|
328
328
|
n.bottom < -64 || n.top > e + 64 || t.onParallax(H(n, e));
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function G() {
|
|
332
332
|
W === 0 && (W = requestAnimationFrame(he));
|
|
333
333
|
}
|
|
334
|
-
function
|
|
335
|
-
U || typeof window > "u" || (U = !0, window.addEventListener("scroll",
|
|
334
|
+
function K() {
|
|
335
|
+
U || typeof window > "u" || (U = !0, window.addEventListener("scroll", G, { passive: !0 }), window.addEventListener("resize", G, { passive: !0 }));
|
|
336
336
|
}
|
|
337
|
-
function
|
|
338
|
-
me.size > 0 || !U || typeof window > "u" || (U = !1, W !== 0 && (cancelAnimationFrame(W), W = 0), window.removeEventListener("scroll",
|
|
337
|
+
function ge() {
|
|
338
|
+
me.size > 0 || !U || typeof window > "u" || (U = !1, W !== 0 && (cancelAnimationFrame(W), W = 0), window.removeEventListener("scroll", G), window.removeEventListener("resize", G));
|
|
339
339
|
}
|
|
340
|
-
function
|
|
340
|
+
function _e(e, t) {
|
|
341
341
|
if (!pe()) return () => {};
|
|
342
342
|
let n = {
|
|
343
343
|
element: e,
|
|
344
344
|
onParallax: t.onParallax,
|
|
345
345
|
pointerActive: t.pointerActive
|
|
346
346
|
};
|
|
347
|
-
return me.add(n),
|
|
348
|
-
me.delete(n),
|
|
347
|
+
return me.add(n), K(), n.pointerActive?.() || t.onParallax(H(e.getBoundingClientRect(), window.innerHeight)), () => {
|
|
348
|
+
me.delete(n), ge();
|
|
349
349
|
};
|
|
350
350
|
}
|
|
351
351
|
//#endregion
|
|
352
352
|
//#region src/thumbnail/attachThumbnailParallax.ts
|
|
353
|
-
function
|
|
353
|
+
function ve(e) {
|
|
354
354
|
let t = 0, n = 0, r = !1, i = !1, a = !1, o = () => {
|
|
355
355
|
let a = r || i;
|
|
356
356
|
e.classList.toggle("liforma-et--parallax", a), e.classList.toggle("liforma-et--scroll-parallax", i), e.style.setProperty("--liforma-et-parallax-x", String(t)), e.style.setProperty("--liforma-et-parallax-y", String(n));
|
|
357
|
-
}, s =
|
|
357
|
+
}, s = _e(e, {
|
|
358
358
|
onParallax: (e) => {
|
|
359
359
|
i = !0, a || (t = e, n = 0, o());
|
|
360
360
|
},
|
|
@@ -379,22 +379,57 @@ function ye(e) {
|
|
|
379
379
|
}
|
|
380
380
|
//#endregion
|
|
381
381
|
//#region src/thumbnail/styles.ts
|
|
382
|
-
var
|
|
383
|
-
function
|
|
384
|
-
if (typeof document > "u" ||
|
|
382
|
+
var ye = ":host {\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n}\n\n.liforma-et {\n --liforma-et-parallax-x: 0;\n --liforma-et-parallax-y: 0;\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n --liforma-et-reveal-duration: 420ms;\n\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 0;\n overflow: hidden;\n background: #111;\n color: inherit;\n text-decoration: none;\n cursor: inherit;\n -webkit-tap-highlight-color: transparent;\n}\n\na.liforma-et,\nbutton.liforma-et {\n cursor: pointer;\n}\n\nbutton.liforma-et {\n font: inherit;\n appearance: none;\n}\n\n.liforma-et__placeholder {\n position: absolute;\n inset: 0;\n z-index: 0;\n background:\n radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 58%),\n linear-gradient(180deg, #1a1a1a 0%, #101010 100%);\n opacity: 1;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et--revealed .liforma-et__placeholder {\n opacity: 0;\n}\n\n.liforma-et__media {\n opacity: 0;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et__media--ready {\n opacity: 1;\n}\n\n.liforma-et__background {\n position: absolute;\n inset: 0;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-bg-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-bg-shift))\n )\n scale(var(--liforma-et-bg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et__avatar {\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n object-position: center bottom;\n transform: scale(var(--liforma-et-avatar-scale))\n translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-avatar-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-avatar-shift))\n );\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n/* Gallery plates are typically square in a square tile — contain vs cover is a no-op\n without a zoom. Scale the whole scene from the upper third so Face matches\n player fit (location + avatar crop together). */\n.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n}\n\n.liforma-et--fit-face .liforma-et__avatar,\n.liforma-et--fit-face .liforma-et__background,\n.liforma-et--fit-face .liforma-et__foreground {\n transform-origin: 50% 18%;\n}\n\n.liforma-et--fit-face .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 18%;\n}\n\n/* Bust / medium: less zoom than face so upper chest stays in frame (player 3.75H window). */\n.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.35;\n --liforma-et-bg-scale: 1.35;\n --liforma-et-fg-scale: 1.35;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar,\n.liforma-et--fit-medium .liforma-et__background,\n.liforma-et--fit-medium .liforma-et__foreground {\n transform-origin: 50% 28%;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 28%;\n}\n\n.liforma-et__foreground {\n position: absolute;\n inset: 0;\n z-index: 3;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n pointer-events: none;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-fg-shift) * -1),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-fg-shift) * -1)\n )\n scale(var(--liforma-et-fg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et--parallax {\n --liforma-et-bg-scale: 1.08;\n --liforma-et-fg-scale: 1.05;\n --liforma-et-avatar-scale: 1.08;\n --liforma-et-bg-shift: 10px;\n --liforma-et-fg-shift: 4px;\n --liforma-et-avatar-shift: 4px;\n}\n\n/* Promote layers only while parallax is active — avoids N compositor surfaces on galleries. */\n.liforma-et--parallax .liforma-et__background,\n.liforma-et--parallax .liforma-et__foreground,\n.liforma-et--parallax .liforma-et__avatar {\n will-change: transform;\n}\n\n.liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.95;\n --liforma-et-bg-scale: 1.95;\n --liforma-et-fg-scale: 1.95;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--parallax.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.42;\n --liforma-et-bg-scale: 1.42;\n --liforma-et-fg-scale: 1.42;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--scroll-parallax .liforma-et__background,\n.liforma-et--scroll-parallax .liforma-et__foreground,\n.liforma-et--scroll-parallax .liforma-et__avatar {\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-et {\n --liforma-et-reveal-duration: 0ms;\n }\n\n .liforma-et--parallax {\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n }\n\n .liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n }\n\n .liforma-et__background,\n .liforma-et__foreground,\n .liforma-et__avatar {\n transition: none;\n }\n}", be = !1;
|
|
383
|
+
function xe(e) {
|
|
384
|
+
if (typeof document > "u" || be) return;
|
|
385
385
|
if (document.querySelector("style[data-liforma-et]")) {
|
|
386
|
-
|
|
386
|
+
be = !0;
|
|
387
387
|
return;
|
|
388
388
|
}
|
|
389
389
|
let t = document.createElement("style");
|
|
390
|
-
t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t),
|
|
390
|
+
t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t), be = !0;
|
|
391
|
+
}
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region src/thumbnail/plateDelivery.ts
|
|
394
|
+
var Se = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=", Ce = null;
|
|
395
|
+
function we(e) {
|
|
396
|
+
let t = e.trim();
|
|
397
|
+
if (!t || t.startsWith("blob:") || t.startsWith("data:")) return !1;
|
|
398
|
+
let n = t.split(/[?#]/)[0] ?? t, r = /\/avatars\//i.test(n), i = /\/locations\//i.test(n);
|
|
399
|
+
return !r && !i || /\.depth\.webp$/i.test(n) ? !1 : /\.webp$/i.test(n);
|
|
400
|
+
}
|
|
401
|
+
function Te(e) {
|
|
402
|
+
if (!we(e)) return null;
|
|
403
|
+
let t = e.search(/[?#]/);
|
|
404
|
+
if (t < 0) return e.replace(/\.webp$/i, ".avif");
|
|
405
|
+
let n = e.slice(0, t), r = e.slice(t);
|
|
406
|
+
return `${n.replace(/\.webp$/i, ".avif")}${r}`;
|
|
407
|
+
}
|
|
408
|
+
function Ee() {
|
|
409
|
+
return typeof Image > "u" ? Promise.resolve(!1) : (Ce ||= new Promise((e) => {
|
|
410
|
+
let t = new Image();
|
|
411
|
+
t.onload = () => e(t.naturalWidth > 0 && t.naturalHeight > 0), t.onerror = () => e(!1), t.src = Se;
|
|
412
|
+
}), Ce);
|
|
413
|
+
}
|
|
414
|
+
function De(e, t) {
|
|
415
|
+
return t ? Te(e) ?? e : e;
|
|
416
|
+
}
|
|
417
|
+
function Oe(e) {
|
|
418
|
+
let t = e.trim(), n = t.search(/[?#]/), r = n < 0 ? t : t.slice(0, n);
|
|
419
|
+
if (!/\.avif$/i.test(r)) return null;
|
|
420
|
+
let i = r.replace(/\.avif$/i, ".webp");
|
|
421
|
+
return n < 0 ? i : `${i}${t.slice(n)}`;
|
|
422
|
+
}
|
|
423
|
+
function ke(e) {
|
|
424
|
+
let t = e.trim();
|
|
425
|
+
return /-400x225\.(webp|avif)(?:$|[?#])/i.test(t) ? t.replace(/-400x225\.(webp|avif)/i, "-800x450.$1") : null;
|
|
391
426
|
}
|
|
392
427
|
//#endregion
|
|
393
428
|
//#region src/react/ExperienceThumbnail.tsx
|
|
394
|
-
function
|
|
429
|
+
function Ae(e, t) {
|
|
395
430
|
return `${e} liforma-et__media${t ? " liforma-et__media--ready" : ""}`;
|
|
396
431
|
}
|
|
397
|
-
function
|
|
432
|
+
function je(s) {
|
|
398
433
|
let { galleryThumb: c, avatarImage: l, backgroundImage: u, foregroundImage: d, alt: f, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: b, parallax: S = !0, fit: w = "full", lazy: T = !0, className: E = "", fallbackImage: D, normalizeUrls: O = !0, cdnBaseUrl: k } = s, A = n(null), j = n(!1), [M, ee] = r(0), [N, P] = r(0), te = x(M, N), I = t(() => F({
|
|
399
434
|
galleryThumb: c,
|
|
400
435
|
avatarImage: l,
|
|
@@ -417,11 +452,13 @@ function we(s) {
|
|
|
417
452
|
href: m,
|
|
418
453
|
hasClickHandler: typeof _ == "function",
|
|
419
454
|
experienceId: p
|
|
420
|
-
}), re = L === "anchor" && !m?.trim() && !!p?.trim(), ie = !!I?.backgroundImage, z = S !== !1, [B, ae] = r(!T), [oe, se] = r(!1), [ce, le] = r(!1), [V, ue] = r(
|
|
455
|
+
}), re = L === "anchor" && !m?.trim() && !!p?.trim(), ie = !!I?.backgroundImage, z = S !== !1, [B, ae] = r(!T), [oe, se] = r(!1), [ce, le] = r(!1), [V, ue] = r(!1), [de, pe] = r(!1), [me, U] = r(!1), [W, he] = r(!1), [G, K] = r(!1), [ge, ve] = r(0), [be, Se] = r(0), [Ce, we] = r(!1), [Te, je] = r(!1), [Me, Ne] = r(!1), [Pe, Fe] = r(!1), [q, Ie] = r(), Le = I ? Ce && I.fallbackImage ? I.fallbackImage : I.avatarImage : "";
|
|
421
456
|
e(() => {
|
|
422
|
-
|
|
457
|
+
xe(ye), Ee().then((e) => {
|
|
458
|
+
se(e), le(!0);
|
|
459
|
+
});
|
|
423
460
|
}, []), e(() => {
|
|
424
|
-
|
|
461
|
+
Ie(R({
|
|
425
462
|
href: m,
|
|
426
463
|
experienceId: p,
|
|
427
464
|
returnUrl: v,
|
|
@@ -435,17 +472,17 @@ function we(s) {
|
|
|
435
472
|
b,
|
|
436
473
|
re
|
|
437
474
|
]), e(() => {
|
|
438
|
-
|
|
475
|
+
je(!1), Ne(!1), Fe(!1), we(!1), ue(!1), pe(!1), U(!1);
|
|
439
476
|
}, [
|
|
440
477
|
I?.backgroundImage,
|
|
441
478
|
I?.foregroundImage,
|
|
442
|
-
|
|
479
|
+
Le
|
|
443
480
|
]), e(() => {
|
|
444
481
|
let e = A.current;
|
|
445
482
|
if (e) return C(e, (e, t) => {
|
|
446
483
|
ee(e), P(t);
|
|
447
484
|
});
|
|
448
|
-
}, [L,
|
|
485
|
+
}, [L, q]), e(() => {
|
|
449
486
|
let e = A.current;
|
|
450
487
|
if (e) {
|
|
451
488
|
if (!T) {
|
|
@@ -460,12 +497,12 @@ function we(s) {
|
|
|
460
497
|
T,
|
|
461
498
|
I,
|
|
462
499
|
L,
|
|
463
|
-
|
|
500
|
+
q
|
|
464
501
|
]), e(() => {
|
|
465
502
|
let e = A.current;
|
|
466
|
-
if (!(!e || !z)) return
|
|
503
|
+
if (!(!e || !z)) return _e(e, {
|
|
467
504
|
onParallax: (e) => {
|
|
468
|
-
|
|
505
|
+
K(!0), j.current || (ve(e), Se(0));
|
|
469
506
|
},
|
|
470
507
|
pointerActive: () => j.current
|
|
471
508
|
});
|
|
@@ -473,23 +510,23 @@ function we(s) {
|
|
|
473
510
|
z,
|
|
474
511
|
I,
|
|
475
512
|
L,
|
|
476
|
-
|
|
513
|
+
q
|
|
477
514
|
]);
|
|
478
|
-
let
|
|
479
|
-
if (!z ||
|
|
515
|
+
let Re = (e) => {
|
|
516
|
+
if (!z || G) return;
|
|
480
517
|
let t = e.currentTarget.getBoundingClientRect();
|
|
481
|
-
t.width <= 0 || t.height <= 0 || (
|
|
482
|
-
},
|
|
518
|
+
t.width <= 0 || t.height <= 0 || (ve(((e.clientX - t.left) / t.width - .5) * 2), Se(((e.clientY - t.top) / t.height - .5) * 2));
|
|
519
|
+
}, ze = (e) => {
|
|
483
520
|
let t = j.current;
|
|
484
|
-
j.current = !1,
|
|
485
|
-
},
|
|
521
|
+
j.current = !1, he(!1), G && t ? (ve(H(e.getBoundingClientRect(), window.innerHeight)), Se(0)) : G || (ve(0), Se(0));
|
|
522
|
+
}, J = (e) => {
|
|
486
523
|
if (!z) return;
|
|
487
|
-
j.current = !0, e.pointerType === "mouse" &&
|
|
524
|
+
j.current = !0, e.pointerType === "mouse" && he(!0);
|
|
488
525
|
let t = e.currentTarget, n = () => {
|
|
489
|
-
|
|
526
|
+
ze(t), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n);
|
|
490
527
|
};
|
|
491
528
|
window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n);
|
|
492
|
-
},
|
|
529
|
+
}, Be = (e) => {
|
|
493
530
|
if (_?.(e), !e.defaultPrevented && re && !v?.trim()) {
|
|
494
531
|
let t = R({
|
|
495
532
|
experienceId: p,
|
|
@@ -500,134 +537,153 @@ function we(s) {
|
|
|
500
537
|
}
|
|
501
538
|
};
|
|
502
539
|
if (!I) return null;
|
|
503
|
-
let
|
|
540
|
+
let Ve = z && (W || G), He = B && ce && (Me || Te || Pe), Ue = [
|
|
504
541
|
"liforma-et",
|
|
505
542
|
ie ? "liforma-et--scene" : "",
|
|
506
543
|
y(w),
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
B && !
|
|
510
|
-
|
|
544
|
+
Ve ? "liforma-et--parallax" : "",
|
|
545
|
+
G ? "liforma-et--scroll-parallax" : "",
|
|
546
|
+
B && !He ? "liforma-et--loading" : "",
|
|
547
|
+
He ? "liforma-et--revealed" : "",
|
|
511
548
|
E
|
|
512
|
-
].filter(Boolean).join(" "),
|
|
513
|
-
"--liforma-et-parallax-x":
|
|
514
|
-
"--liforma-et-parallax-y":
|
|
515
|
-
},
|
|
549
|
+
].filter(Boolean).join(" "), Y = {
|
|
550
|
+
"--liforma-et-parallax-x": ge,
|
|
551
|
+
"--liforma-et-parallax-y": be
|
|
552
|
+
}, We = (e, t) => {
|
|
516
553
|
e.complete && t(!0);
|
|
517
|
-
},
|
|
554
|
+
}, Ge = /* @__PURE__ */ o(i, { children: [
|
|
518
555
|
/* @__PURE__ */ a("span", {
|
|
519
556
|
className: "liforma-et__placeholder",
|
|
520
557
|
"aria-hidden": "true"
|
|
521
558
|
}),
|
|
522
|
-
B && I.backgroundImage ? /* @__PURE__ */ a("img", {
|
|
523
|
-
className:
|
|
524
|
-
src: I.backgroundImage,
|
|
559
|
+
B && ce && I.backgroundImage ? /* @__PURE__ */ a("img", {
|
|
560
|
+
className: Ae("liforma-et__background", Te),
|
|
561
|
+
src: De(I.backgroundImage, oe),
|
|
525
562
|
alt: "",
|
|
526
563
|
decoding: "async",
|
|
527
564
|
ref: (e) => {
|
|
528
|
-
e &&
|
|
565
|
+
e && We(e, je);
|
|
529
566
|
},
|
|
530
|
-
onLoad: () =>
|
|
531
|
-
onError: () =>
|
|
567
|
+
onLoad: () => je(!0),
|
|
568
|
+
onError: (e) => {
|
|
569
|
+
let t = e.currentTarget, n = ke(t.src);
|
|
570
|
+
if (n && !V) {
|
|
571
|
+
ue(!0), t.src = n;
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
je(!0);
|
|
575
|
+
}
|
|
532
576
|
}) : null,
|
|
533
|
-
B &&
|
|
534
|
-
className:
|
|
535
|
-
src:
|
|
577
|
+
B && ce && Le ? /* @__PURE__ */ a("img", {
|
|
578
|
+
className: Ae("liforma-et__avatar", Me),
|
|
579
|
+
src: De(Le, oe),
|
|
536
580
|
alt: "",
|
|
537
581
|
decoding: "async",
|
|
538
582
|
ref: (e) => {
|
|
539
|
-
e &&
|
|
583
|
+
e && We(e, Ne);
|
|
540
584
|
},
|
|
541
|
-
onLoad: () =>
|
|
542
|
-
onError: () => {
|
|
543
|
-
|
|
585
|
+
onLoad: () => Ne(!0),
|
|
586
|
+
onError: (e) => {
|
|
587
|
+
let t = e.currentTarget, n = Oe(t.src);
|
|
588
|
+
if (n && !me) {
|
|
589
|
+
U(!0), t.src = n;
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
I.fallbackImage ? we(!0) : Ne(!0);
|
|
544
593
|
}
|
|
545
594
|
}) : null,
|
|
546
|
-
B && I.foregroundImage ? /* @__PURE__ */ a("img", {
|
|
547
|
-
className:
|
|
548
|
-
src: I.foregroundImage,
|
|
595
|
+
B && ce && I.foregroundImage ? /* @__PURE__ */ a("img", {
|
|
596
|
+
className: Ae("liforma-et__foreground", Pe),
|
|
597
|
+
src: De(I.foregroundImage, oe),
|
|
549
598
|
alt: "",
|
|
550
599
|
decoding: "async",
|
|
551
600
|
ref: (e) => {
|
|
552
|
-
e &&
|
|
601
|
+
e && We(e, Fe);
|
|
553
602
|
},
|
|
554
|
-
onLoad: () =>
|
|
555
|
-
onError: () =>
|
|
603
|
+
onLoad: () => Fe(!0),
|
|
604
|
+
onError: (e) => {
|
|
605
|
+
let t = e.currentTarget, n = ke(t.src);
|
|
606
|
+
if (n && !de) {
|
|
607
|
+
pe(!0), t.src = n;
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
Fe(!0);
|
|
611
|
+
}
|
|
556
612
|
}) : null
|
|
557
|
-
] }),
|
|
558
|
-
onPointerDown:
|
|
559
|
-
onPointerUp: (e) =>
|
|
560
|
-
onPointerCancel: (e) =>
|
|
613
|
+
] }), Ke = {
|
|
614
|
+
onPointerDown: J,
|
|
615
|
+
onPointerUp: (e) => ze(e.currentTarget),
|
|
616
|
+
onPointerCancel: (e) => ze(e.currentTarget),
|
|
561
617
|
onPointerEnter: (e) => {
|
|
562
|
-
z && e.pointerType === "mouse" &&
|
|
618
|
+
z && e.pointerType === "mouse" && he(!0);
|
|
563
619
|
},
|
|
564
|
-
onPointerMove:
|
|
620
|
+
onPointerMove: Re,
|
|
565
621
|
onPointerLeave: () => {
|
|
566
|
-
j.current || (
|
|
622
|
+
j.current || (he(!1), G || (ve(0), Se(0)));
|
|
567
623
|
}
|
|
568
|
-
},
|
|
624
|
+
}, qe = (e) => {
|
|
569
625
|
A.current = e;
|
|
570
626
|
};
|
|
571
|
-
return L === "anchor" &&
|
|
572
|
-
ref:
|
|
573
|
-
className:
|
|
574
|
-
style:
|
|
575
|
-
href:
|
|
627
|
+
return L === "anchor" && q ? /* @__PURE__ */ a("a", {
|
|
628
|
+
ref: qe,
|
|
629
|
+
className: Ue,
|
|
630
|
+
style: Y,
|
|
631
|
+
href: q,
|
|
576
632
|
target: h,
|
|
577
633
|
rel: g,
|
|
578
634
|
"aria-label": f,
|
|
579
|
-
onClick:
|
|
580
|
-
...
|
|
581
|
-
children:
|
|
635
|
+
onClick: Be,
|
|
636
|
+
...Ke,
|
|
637
|
+
children: Ge
|
|
582
638
|
}) : L === "button" ? /* @__PURE__ */ a("button", {
|
|
583
639
|
type: "button",
|
|
584
|
-
ref:
|
|
585
|
-
className:
|
|
586
|
-
style:
|
|
640
|
+
ref: qe,
|
|
641
|
+
className: Ue,
|
|
642
|
+
style: Y,
|
|
587
643
|
"aria-label": f,
|
|
588
|
-
onClick:
|
|
589
|
-
...
|
|
590
|
-
children:
|
|
644
|
+
onClick: Be,
|
|
645
|
+
...Ke,
|
|
646
|
+
children: Ge
|
|
591
647
|
}) : /* @__PURE__ */ a("div", {
|
|
592
|
-
ref:
|
|
593
|
-
className:
|
|
594
|
-
style:
|
|
648
|
+
ref: qe,
|
|
649
|
+
className: Ue,
|
|
650
|
+
style: Y,
|
|
595
651
|
role: f ? "img" : void 0,
|
|
596
652
|
"aria-label": f || void 0,
|
|
597
653
|
"aria-hidden": f ? void 0 : !0,
|
|
598
|
-
...
|
|
599
|
-
children:
|
|
654
|
+
...Ke,
|
|
655
|
+
children: Ge
|
|
600
656
|
});
|
|
601
657
|
}
|
|
602
658
|
//#endregion
|
|
603
659
|
//#region src/widget/styles.ts
|
|
604
|
-
var Te = "\n.liforma-ew {\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n}\n\n/* Optional self-positioned FAB (position=bottom-right|bottom-left).\n * Cap at 50vmin so small phones don't get an oversized thumb (desktop 224px stays). */\n.liforma-ew[data-position='bottom-right'],\n.liforma-ew[data-position='bottom-left'] {\n position: fixed;\n width: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n height: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n bottom: var(--liforma-ew-offset, 16px);\n z-index: 2147482900;\n}\n\n.liforma-ew[data-position='bottom-right'] {\n right: var(--liforma-ew-offset, 16px);\n left: auto;\n}\n\n.liforma-ew[data-position='bottom-left'] {\n left: var(--liforma-ew-offset, 16px);\n right: auto;\n}\n\n/* While open, collapse the FAB box so a corner hole / thumb never remains. */\n.liforma-ew[data-position='bottom-right'][data-state='expanded'],\n.liforma-ew[data-position='bottom-right'][data-state='docked'],\n.liforma-ew[data-position='bottom-left'][data-state='expanded'],\n.liforma-ew[data-position='bottom-left'][data-state='docked'] {\n width: 0;\n height: 0;\n min-width: 0;\n min-height: 0;\n overflow: visible;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='expanded'] .liforma-ew__overlay,\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar,\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__hit {\n box-sizing: border-box;\n display: block;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n font: inherit;\n appearance: none;\n -webkit-tap-highlight-color: transparent;\n transform: scale(1);\n transform-origin: center center;\n transition:\n transform 180ms ease,\n filter 180ms ease;\n will-change: transform;\n}\n\n/* Author display must not defeat the HTML hidden attribute. */\n.liforma-ew__hit[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 3px;\n border-radius: 0.75rem;\n}\n\n@media (hover: hover) and (pointer: fine) {\n /* Scale the thumb whenever the collapsed FAB is hovered — including via the warm iframe hit layer. */\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: scale(1.06);\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover .liforma-et,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-et {\n box-shadow: 0 12px 36px rgba(0, 0, 0, 0.34);\n }\n}\n\n.liforma-ew__face {\n width: 100%;\n height: 100%;\n min-height: 0;\n position: relative;\n}\n\n.liforma-ew__face-status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 0.5rem;\n text-align: center;\n font: 600 0.75rem/1.3 system-ui, sans-serif;\n color: #e8ecf4;\n background: rgba(10, 12, 18, 0.72);\n border-radius: 0.75rem;\n pointer-events: none;\n}\n\n.liforma-ew__face-status[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:disabled {\n cursor: default;\n opacity: 0.85;\n}\n\n.liforma-ew__face .liforma-et {\n border-radius: 0.75rem;\n box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);\n transition: box-shadow 180ms ease;\n}\n\n.liforma-ew__warm {\n box-sizing: border-box;\n position: absolute;\n inset: 0;\n z-index: 2;\n border-radius: 0.75rem;\n overflow: hidden;\n background: transparent;\n pointer-events: none;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n/*\n * Collapsed: keep the warm iframe as an invisible hit target only.\n * Painting it over the thumb causes a “ghost enlarge” (face scales under a static iframe).\n */\n.liforma-ew[data-state='collapsed'] .liforma-ew__warm {\n opacity: 0;\n transition: none;\n}\n\n.liforma-ew[data-warm='true'] .liforma-ew__warm {\n pointer-events: auto;\n}\n\n.liforma-ew[data-warm='true']:not([data-live='true']) .liforma-ew__hit {\n pointer-events: none;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__hit {\n pointer-events: auto;\n}\n\n.liforma-ew[data-live='true'] .liforma-ew__warm,\n.liforma-ew[data-live='true'] .liforma-ew__stage {\n /* Hidden under the thumb / until post-resize fade-in (matches cold avatar reveal). */\n opacity: 0;\n}\n\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__stage,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__stage {\n opacity: 1;\n}\n\n.liforma-ew--session-concealing .liforma-ew__warm,\n.liforma-ew--session-concealing .liforma-ew__stage {\n transition-duration: 280ms;\n}\n\n/* Instant hide while dock/maximize geometry settles (player morph resize ~160ms). */\n.liforma-ew--layout-settling .liforma-ew__warm,\n.liforma-ew--layout-settling .liforma-ew__stage {\n opacity: 0 !important;\n transition: none !important;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__warm {\n /* Keep the live iframe under the thumb; FAB click resumes the shell. */\n pointer-events: none;\n opacity: 0;\n /* Instant hide when collapsed so the FAB never shows a resized live mesh. */\n transition: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm {\n position: fixed;\n /* Match overlay panel inset so the warm iframe fills the conversation shell. */\n inset: clamp(12px, 3vw, 28px);\n z-index: 2147483001;\n width: auto;\n height: auto;\n border-radius: 16px;\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__warm {\n position: fixed;\n inset: auto;\n z-index: 2147483001;\n border-radius: 16px;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew__toolbar {\n display: none;\n position: fixed;\n z-index: 2147483002;\n pointer-events: auto;\n box-sizing: border-box;\n align-items: center;\n gap: 0.35rem;\n padding: 0.35rem 0.4rem;\n border-radius: 999px;\n background: rgba(12, 14, 20, 0.72);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n display: flex;\n top: calc(clamp(12px, 3vw, 28px) + 10px);\n right: calc(clamp(12px, 3vw, 28px) + 10px);\n left: auto;\n cursor: default;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n display: flex;\n /* left/top set inline to track the panel; strip remains a drag handle */\n cursor: grab;\n touch-action: none;\n user-select: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__stage {\n /* Player also reports surface drags via postMessage when docked. */\n cursor: grab;\n touch-action: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar.liforma-ew__toolbar--dragging,\n.liforma-ew--dock-dragging,\n.liforma-ew--dock-dragging .liforma-ew__toolbar,\n.liforma-ew--dock-dragging .liforma-ew__panel,\n.liforma-ew--dock-dragging .liforma-ew__warm,\n.liforma-ew--dock-dragging .liforma-ew__stage {\n cursor: grabbing;\n}\n\n\n.liforma-ew__toolbar[hidden] {\n display: none !important;\n}\n\n.liforma-ew__icon-btn {\n appearance: none;\n box-sizing: border-box;\n display: inline-grid;\n place-items: center;\n width: 2rem;\n height: 2rem;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 999px;\n color: #f5f7fb;\n background: transparent;\n cursor: pointer;\n}\n\n.liforma-ew__icon-btn:hover {\n background: rgba(255, 255, 255, 0.12);\n}\n\n.liforma-ew__icon-btn[aria-pressed='true'] {\n background: rgba(255, 255, 255, 0.2);\n}\n\n.liforma-ew__icon-btn:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 2px;\n}\n\n.liforma-ew__icon-btn svg {\n width: 1.05rem;\n height: 1.05rem;\n display: block;\n}\n\n.liforma-ew__drag-grip {\n display: none;\n width: 0.85rem;\n height: 1.25rem;\n margin: 0 0.15rem 0 0.25rem;\n background:\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0 0 / 0.35rem 0.35rem,\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0.35rem 0 / 0.35rem 0.35rem;\n background-repeat: repeat-y;\n opacity: 0.55;\n color: #f5f7fb;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__drag-grip {\n display: block;\n}\n\n.liforma-ew__dock-toggle[hidden] {\n display: none !important;\n}\n\n.liforma-ew__overlay {\n position: fixed;\n inset: 0;\n z-index: 2147483000;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: clamp(12px, 3vw, 28px);\n box-sizing: border-box;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n padding: 0;\n align-items: stretch;\n justify-content: stretch;\n pointer-events: none;\n background: transparent;\n}\n\n.liforma-ew__overlay[hidden] {\n display: none !important;\n}\n\n.liforma-ew__backdrop {\n position: absolute;\n inset: 0;\n border: 0;\n padding: 0;\n margin: 0;\n background: rgba(6, 8, 14, 0.62);\n cursor: pointer;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__backdrop {\n display: none !important;\n}\n\n.liforma-ew__panel {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: column;\n /* Fill the overlay so player loading / start UI centers in the visible window. */\n width: var(--liforma-ew-max-w, 100%);\n height: var(--liforma-ew-max-h, 100%);\n max-width: 100%;\n max-height: 100%;\n border-radius: 16px;\n overflow: hidden;\n background: #030508;\n box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);\n /* Warm iframe sits above as a sibling; keep panel as chrome shell. */\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n position: fixed;\n inset: auto;\n max-width: none;\n max-height: none;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew:not([data-warm='true']) .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__stage {\n position: relative;\n flex: 1;\n min-height: 0;\n width: 100%;\n height: 100%;\n background: #030508;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n.liforma-ew__status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 1.5rem;\n text-align: center;\n color: #d7dde8;\n font: 500 0.9375rem/1.45 system-ui, sans-serif;\n background: rgba(3, 5, 8, 0.92);\n pointer-events: none;\n}\n\n.liforma-ew__status[hidden] {\n display: none !important;\n}\n\n/* Mobile expanded: ~90% viewport, no reduce control. */\n@media (max-width: 767px) {\n .liforma-ew[data-state='expanded'] .liforma-ew__overlay {\n padding: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__panel {\n width: 90vw;\n height: 90vh;\n max-width: 90vw;\n max-height: 90vh;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__warm {\n inset: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n top: calc(5vh + 10px);\n right: calc(5vw + 10px);\n }\n\n .liforma-ew__dock-toggle {\n display: none !important;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-ew__hit {\n transition: none;\n will-change: auto;\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: none;\n }\n\n .liforma-ew__face .liforma-et {\n box-shadow: none;\n transition: none;\n }\n\n .liforma-ew__warm,\n .liforma-ew__stage {\n transition: none;\n }\n}\n", Ee = "liforma-experience-widget-styles";
|
|
605
|
-
function
|
|
660
|
+
var Me = "\n.liforma-ew {\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n}\n\n/* Optional self-positioned FAB (position=bottom-right|bottom-left).\n * Cap at 50vmin so small phones don't get an oversized thumb (desktop 224px stays). */\n.liforma-ew[data-position='bottom-right'],\n.liforma-ew[data-position='bottom-left'] {\n position: fixed;\n width: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n height: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n bottom: var(--liforma-ew-offset, 16px);\n z-index: 2147482900;\n}\n\n.liforma-ew[data-position='bottom-right'] {\n right: var(--liforma-ew-offset, 16px);\n left: auto;\n}\n\n.liforma-ew[data-position='bottom-left'] {\n left: var(--liforma-ew-offset, 16px);\n right: auto;\n}\n\n/* While open, collapse the FAB box so a corner hole / thumb never remains. */\n.liforma-ew[data-position='bottom-right'][data-state='expanded'],\n.liforma-ew[data-position='bottom-right'][data-state='docked'],\n.liforma-ew[data-position='bottom-left'][data-state='expanded'],\n.liforma-ew[data-position='bottom-left'][data-state='docked'] {\n width: 0;\n height: 0;\n min-width: 0;\n min-height: 0;\n overflow: visible;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='expanded'] .liforma-ew__overlay,\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar,\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__hit {\n box-sizing: border-box;\n display: block;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n font: inherit;\n appearance: none;\n -webkit-tap-highlight-color: transparent;\n transform: scale(1);\n transform-origin: center center;\n transition:\n transform 180ms ease,\n filter 180ms ease;\n will-change: transform;\n}\n\n/* Author display must not defeat the HTML hidden attribute. */\n.liforma-ew__hit[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 3px;\n border-radius: 0.75rem;\n}\n\n@media (hover: hover) and (pointer: fine) {\n /* Scale the thumb whenever the collapsed FAB is hovered — including via the warm iframe hit layer. */\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: scale(1.06);\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover .liforma-et,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-et {\n box-shadow: 0 12px 36px rgba(0, 0, 0, 0.34);\n }\n}\n\n.liforma-ew__face {\n width: 100%;\n height: 100%;\n min-height: 0;\n position: relative;\n}\n\n.liforma-ew__face-status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 0.5rem;\n text-align: center;\n font: 600 0.75rem/1.3 system-ui, sans-serif;\n color: #e8ecf4;\n background: rgba(10, 12, 18, 0.72);\n border-radius: 0.75rem;\n pointer-events: none;\n}\n\n.liforma-ew__face-status[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:disabled {\n cursor: default;\n opacity: 0.85;\n}\n\n.liforma-ew__face .liforma-et {\n border-radius: 0.75rem;\n box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);\n transition: box-shadow 180ms ease;\n}\n\n.liforma-ew__warm {\n box-sizing: border-box;\n position: absolute;\n inset: 0;\n z-index: 2;\n border-radius: 0.75rem;\n overflow: hidden;\n background: transparent;\n pointer-events: none;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n/*\n * Collapsed: keep the warm iframe as an invisible hit target only.\n * Painting it over the thumb causes a “ghost enlarge” (face scales under a static iframe).\n */\n.liforma-ew[data-state='collapsed'] .liforma-ew__warm {\n opacity: 0;\n transition: none;\n}\n\n.liforma-ew[data-warm='true'] .liforma-ew__warm {\n pointer-events: auto;\n}\n\n.liforma-ew[data-warm='true']:not([data-live='true']) .liforma-ew__hit {\n pointer-events: none;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__hit {\n pointer-events: auto;\n}\n\n.liforma-ew[data-live='true'] .liforma-ew__warm,\n.liforma-ew[data-live='true'] .liforma-ew__stage {\n /* Hidden under the thumb / until post-resize fade-in (matches cold avatar reveal). */\n opacity: 0;\n}\n\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__stage,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__stage {\n opacity: 1;\n}\n\n.liforma-ew--session-concealing .liforma-ew__warm,\n.liforma-ew--session-concealing .liforma-ew__stage {\n transition-duration: 280ms;\n}\n\n/* Instant hide while dock/maximize geometry settles (player morph resize ~160ms). */\n.liforma-ew--layout-settling .liforma-ew__warm,\n.liforma-ew--layout-settling .liforma-ew__stage {\n opacity: 0 !important;\n transition: none !important;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__warm {\n /* Keep the live iframe under the thumb; FAB click resumes the shell. */\n pointer-events: none;\n opacity: 0;\n /* Instant hide when collapsed so the FAB never shows a resized live mesh. */\n transition: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm {\n position: fixed;\n /* Match overlay panel inset so the warm iframe fills the conversation shell. */\n inset: clamp(12px, 3vw, 28px);\n z-index: 2147483001;\n width: auto;\n height: auto;\n border-radius: 16px;\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__warm {\n position: fixed;\n inset: auto;\n z-index: 2147483001;\n border-radius: 16px;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew__toolbar {\n display: none;\n position: fixed;\n z-index: 2147483002;\n pointer-events: auto;\n box-sizing: border-box;\n align-items: center;\n gap: 0.35rem;\n padding: 0.35rem 0.4rem;\n border-radius: 999px;\n background: rgba(12, 14, 20, 0.72);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n display: flex;\n top: calc(clamp(12px, 3vw, 28px) + 10px);\n right: calc(clamp(12px, 3vw, 28px) + 10px);\n left: auto;\n cursor: default;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n display: flex;\n /* left/top set inline to track the panel; strip remains a drag handle */\n cursor: grab;\n touch-action: none;\n user-select: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__stage {\n /* Player also reports surface drags via postMessage when docked. */\n cursor: grab;\n touch-action: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar.liforma-ew__toolbar--dragging,\n.liforma-ew--dock-dragging,\n.liforma-ew--dock-dragging .liforma-ew__toolbar,\n.liforma-ew--dock-dragging .liforma-ew__panel,\n.liforma-ew--dock-dragging .liforma-ew__warm,\n.liforma-ew--dock-dragging .liforma-ew__stage {\n cursor: grabbing;\n}\n\n\n.liforma-ew__toolbar[hidden] {\n display: none !important;\n}\n\n.liforma-ew__icon-btn {\n appearance: none;\n box-sizing: border-box;\n display: inline-grid;\n place-items: center;\n width: 2rem;\n height: 2rem;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 999px;\n color: #f5f7fb;\n background: transparent;\n cursor: pointer;\n}\n\n.liforma-ew__icon-btn:hover {\n background: rgba(255, 255, 255, 0.12);\n}\n\n.liforma-ew__icon-btn[aria-pressed='true'] {\n background: rgba(255, 255, 255, 0.2);\n}\n\n.liforma-ew__icon-btn:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 2px;\n}\n\n.liforma-ew__icon-btn svg {\n width: 1.05rem;\n height: 1.05rem;\n display: block;\n}\n\n.liforma-ew__drag-grip {\n display: none;\n width: 0.85rem;\n height: 1.25rem;\n margin: 0 0.15rem 0 0.25rem;\n background:\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0 0 / 0.35rem 0.35rem,\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0.35rem 0 / 0.35rem 0.35rem;\n background-repeat: repeat-y;\n opacity: 0.55;\n color: #f5f7fb;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__drag-grip {\n display: block;\n}\n\n.liforma-ew__dock-toggle[hidden] {\n display: none !important;\n}\n\n.liforma-ew__overlay {\n position: fixed;\n inset: 0;\n z-index: 2147483000;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: clamp(12px, 3vw, 28px);\n box-sizing: border-box;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n padding: 0;\n align-items: stretch;\n justify-content: stretch;\n pointer-events: none;\n background: transparent;\n}\n\n.liforma-ew__overlay[hidden] {\n display: none !important;\n}\n\n.liforma-ew__backdrop {\n position: absolute;\n inset: 0;\n border: 0;\n padding: 0;\n margin: 0;\n background: rgba(6, 8, 14, 0.62);\n cursor: pointer;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__backdrop {\n display: none !important;\n}\n\n.liforma-ew__panel {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: column;\n /* Fill the overlay so player loading / start UI centers in the visible window. */\n width: var(--liforma-ew-max-w, 100%);\n height: var(--liforma-ew-max-h, 100%);\n max-width: 100%;\n max-height: 100%;\n border-radius: 16px;\n overflow: hidden;\n background: #030508;\n box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);\n /* Warm iframe sits above as a sibling; keep panel as chrome shell. */\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n position: fixed;\n inset: auto;\n max-width: none;\n max-height: none;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew:not([data-warm='true']) .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__stage {\n position: relative;\n flex: 1;\n min-height: 0;\n width: 100%;\n height: 100%;\n background: #030508;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n.liforma-ew__status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 1.5rem;\n text-align: center;\n color: #d7dde8;\n font: 500 0.9375rem/1.45 system-ui, sans-serif;\n background: rgba(3, 5, 8, 0.92);\n pointer-events: none;\n}\n\n.liforma-ew__status[hidden] {\n display: none !important;\n}\n\n/* Mobile expanded: ~90% viewport, no reduce control. */\n@media (max-width: 767px) {\n .liforma-ew[data-state='expanded'] .liforma-ew__overlay {\n padding: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__panel {\n width: 90vw;\n height: 90vh;\n max-width: 90vw;\n max-height: 90vh;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__warm {\n inset: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n top: calc(5vh + 10px);\n right: calc(5vw + 10px);\n }\n\n .liforma-ew__dock-toggle {\n display: none !important;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-ew__hit {\n transition: none;\n will-change: auto;\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: none;\n }\n\n .liforma-ew__face .liforma-et {\n box-shadow: none;\n transition: none;\n }\n\n .liforma-ew__warm,\n .liforma-ew__stage {\n transition: none;\n }\n}\n", Ne = "liforma-experience-widget-styles";
|
|
661
|
+
function Pe(e = Me) {
|
|
606
662
|
if (typeof document > "u") return;
|
|
607
|
-
let t = document.getElementById(
|
|
663
|
+
let t = document.getElementById(Ne);
|
|
608
664
|
if (t) {
|
|
609
665
|
t.textContent = e;
|
|
610
666
|
return;
|
|
611
667
|
}
|
|
612
668
|
let n = document.createElement("style");
|
|
613
|
-
n.id =
|
|
669
|
+
n.id = Ne, n.textContent = e, document.head.append(n);
|
|
614
670
|
}
|
|
615
671
|
//#endregion
|
|
616
672
|
//#region src/shims/apiBaseUrl.ts
|
|
617
|
-
var
|
|
618
|
-
function
|
|
673
|
+
var Fe = "https://api.liforma.ai", q = "http://localhost:3001";
|
|
674
|
+
function Ie() {
|
|
619
675
|
let e = globalThis.__LIFORMA_API_BASE_URL;
|
|
620
676
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
621
677
|
if (typeof document > "u") return null;
|
|
622
678
|
let t = (document.querySelector("script[data-liforma-sdk][src*=\"client.js\"]") ?? document.querySelector("script[src*=\"/sdk/v2/client.js\"]"))?.getAttribute("data-api-base-url")?.trim();
|
|
623
679
|
return t ? t.replace(/\/$/, "") : null;
|
|
624
680
|
}
|
|
625
|
-
function
|
|
626
|
-
return
|
|
681
|
+
function Le() {
|
|
682
|
+
return Ie() || (te() ? q : Fe);
|
|
627
683
|
}
|
|
628
684
|
//#endregion
|
|
629
685
|
//#region src/v2/api/fetchExperiencePreview.ts
|
|
630
|
-
function
|
|
686
|
+
function Re(e) {
|
|
631
687
|
if (!e || typeof e != "object") return null;
|
|
632
688
|
let t = e, n = typeof t.avatarImage == "string" ? t.avatarImage.trim() : "";
|
|
633
689
|
return n ? {
|
|
@@ -636,10 +692,10 @@ function je(e) {
|
|
|
636
692
|
...typeof t.foregroundImage == "string" && t.foregroundImage.trim() ? { foregroundImage: t.foregroundImage.trim() } : {}
|
|
637
693
|
} : null;
|
|
638
694
|
}
|
|
639
|
-
async function
|
|
695
|
+
async function ze(e, t) {
|
|
640
696
|
let n = e.trim();
|
|
641
697
|
if (!n) throw Error("Experience preview requires experienceId.");
|
|
642
|
-
let r = (t?.apiBaseUrl ??
|
|
698
|
+
let r = (t?.apiBaseUrl ?? Le()).replace(/\/$/, ""), i = await fetch(`${r}/v1/experiences/${encodeURIComponent(n)}/preview`, {
|
|
643
699
|
method: "GET",
|
|
644
700
|
headers: { Accept: "application/json" },
|
|
645
701
|
signal: t?.signal
|
|
@@ -659,7 +715,7 @@ async function Me(e, t) {
|
|
|
659
715
|
throw Error("Experience preview returned invalid JSON.");
|
|
660
716
|
}
|
|
661
717
|
if (!a || typeof a != "object") throw Error("Experience preview returned an invalid payload.");
|
|
662
|
-
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l =
|
|
718
|
+
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l = Re(o.galleryThumb);
|
|
663
719
|
if (!l) throw Error("Experience preview is missing gallery thumb images.");
|
|
664
720
|
return {
|
|
665
721
|
experienceId: s || n,
|
|
@@ -669,7 +725,7 @@ async function Me(e, t) {
|
|
|
669
725
|
}
|
|
670
726
|
//#endregion
|
|
671
727
|
//#region src/v2/errors/LiformaError.ts
|
|
672
|
-
var
|
|
728
|
+
var J = class extends Error {
|
|
673
729
|
code;
|
|
674
730
|
requestId;
|
|
675
731
|
status;
|
|
@@ -678,16 +734,16 @@ var q = class extends Error {
|
|
|
678
734
|
super(e, t?.cause === void 0 ? void 0 : { cause: t.cause }), this.name = "LiformaError", this.code = t?.code?.trim() || "UNKNOWN", this.requestId = t?.requestId?.trim() || void 0, this.status = t?.status, this.details = t?.details;
|
|
679
735
|
}
|
|
680
736
|
};
|
|
681
|
-
function
|
|
737
|
+
function Be(e) {
|
|
682
738
|
if (!(!e || typeof e != "object" || Array.isArray(e))) return e;
|
|
683
739
|
}
|
|
684
|
-
function
|
|
740
|
+
function Ve(e, t, n) {
|
|
685
741
|
let r = n?.get("Liforma-Request-Id")?.trim() || void 0, i;
|
|
686
742
|
try {
|
|
687
743
|
i = JSON.parse(t);
|
|
688
744
|
} catch {}
|
|
689
|
-
let a = i?.error && typeof i.error == "object" ? i.error : void 0, o = a?.code ?? i?.code, s = a?.message ?? i?.message, c = a?.requestId ?? i?.requestId ?? r, l = typeof o == "string" && o.trim() ? o.trim() : "HTTP_ERROR", u = typeof s == "string" && s.trim() ? s.trim() : t.trim().slice(0, 500) || `Request failed (${e})`, d = typeof c == "string" && c.trim() ? c.trim() : r, { code: f, message: p, requestId: m, ...h } =
|
|
690
|
-
return new
|
|
745
|
+
let a = i?.error && typeof i.error == "object" ? i.error : void 0, o = a?.code ?? i?.code, s = a?.message ?? i?.message, c = a?.requestId ?? i?.requestId ?? r, l = typeof o == "string" && o.trim() ? o.trim() : "HTTP_ERROR", u = typeof s == "string" && s.trim() ? s.trim() : t.trim().slice(0, 500) || `Request failed (${e})`, d = typeof c == "string" && c.trim() ? c.trim() : r, { code: f, message: p, requestId: m, ...h } = Be(a) ?? Be(i) ?? {};
|
|
746
|
+
return new J(u, {
|
|
691
747
|
code: l,
|
|
692
748
|
requestId: d,
|
|
693
749
|
status: e,
|
|
@@ -696,37 +752,37 @@ function Pe(e, t, n) {
|
|
|
696
752
|
}
|
|
697
753
|
//#endregion
|
|
698
754
|
//#region src/v2/api/captureAttribution.ts
|
|
699
|
-
var
|
|
700
|
-
function
|
|
755
|
+
var He = 128, Ue = /[\u0000-\u001f\u007f]/g;
|
|
756
|
+
function Y(e) {
|
|
701
757
|
if (!e) return;
|
|
702
|
-
let t = e.replace(
|
|
703
|
-
if (t) return t.slice(0,
|
|
758
|
+
let t = e.replace(Ue, "").trim();
|
|
759
|
+
if (t) return t.slice(0, He);
|
|
704
760
|
}
|
|
705
|
-
function
|
|
761
|
+
function We(e) {
|
|
706
762
|
let t = new URLSearchParams((e ?? "").startsWith("?") ? (e ?? "").slice(1) : e ?? "");
|
|
707
763
|
return {
|
|
708
|
-
...
|
|
709
|
-
...
|
|
710
|
-
...
|
|
711
|
-
...
|
|
712
|
-
...
|
|
764
|
+
...Y(t.get("utm_source")) ? { utmSource: Y(t.get("utm_source")) } : {},
|
|
765
|
+
...Y(t.get("utm_medium")) ? { utmMedium: Y(t.get("utm_medium")) } : {},
|
|
766
|
+
...Y(t.get("utm_campaign")) ? { utmCampaign: Y(t.get("utm_campaign")) } : {},
|
|
767
|
+
...Y(t.get("utm_content")) ? { utmContent: Y(t.get("utm_content")) } : {},
|
|
768
|
+
...Y(t.get("utm_term")) ? { utmTerm: Y(t.get("utm_term")) } : {}
|
|
713
769
|
};
|
|
714
770
|
}
|
|
715
|
-
function
|
|
771
|
+
function Ge(e) {
|
|
716
772
|
if (e === !1) return;
|
|
717
773
|
if (e && typeof e == "object") {
|
|
718
774
|
let t = {
|
|
719
|
-
...
|
|
720
|
-
...
|
|
721
|
-
...
|
|
722
|
-
...
|
|
723
|
-
...
|
|
724
|
-
...
|
|
775
|
+
...Y(e.utmSource) ? { utmSource: Y(e.utmSource) } : {},
|
|
776
|
+
...Y(e.utmMedium) ? { utmMedium: Y(e.utmMedium) } : {},
|
|
777
|
+
...Y(e.utmCampaign) ? { utmCampaign: Y(e.utmCampaign) } : {},
|
|
778
|
+
...Y(e.utmContent) ? { utmContent: Y(e.utmContent) } : {},
|
|
779
|
+
...Y(e.utmTerm) ? { utmTerm: Y(e.utmTerm) } : {},
|
|
780
|
+
...Y(e.referrer) ? { referrer: Y(e.referrer) } : {}
|
|
725
781
|
};
|
|
726
782
|
return Object.keys(t).length ? t : void 0;
|
|
727
783
|
}
|
|
728
784
|
if (typeof window > "u") return;
|
|
729
|
-
let t =
|
|
785
|
+
let t = We(window.location?.search), n = Y(document.referrer || void 0), r = {
|
|
730
786
|
...t,
|
|
731
787
|
...n ? { referrer: n } : {}
|
|
732
788
|
};
|
|
@@ -734,19 +790,19 @@ function Re(e) {
|
|
|
734
790
|
}
|
|
735
791
|
//#endregion
|
|
736
792
|
//#region src/v2/api/sessionEndpointRequest.ts
|
|
737
|
-
function
|
|
793
|
+
function Ke(e) {
|
|
738
794
|
let t = e.locale?.trim();
|
|
739
795
|
if (t) return t;
|
|
740
796
|
let n = e.language?.trim();
|
|
741
797
|
if (n) return n;
|
|
742
798
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
743
799
|
}
|
|
744
|
-
function
|
|
800
|
+
function qe(e) {
|
|
745
801
|
let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
|
|
746
802
|
if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
|
|
747
803
|
return t || n || void 0;
|
|
748
804
|
}
|
|
749
|
-
function
|
|
805
|
+
function Je(e, t) {
|
|
750
806
|
let n = e.trim();
|
|
751
807
|
if (!n) throw Error("sessionEndpoint must not be empty.");
|
|
752
808
|
if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
|
|
@@ -754,7 +810,7 @@ function Ve(e, t) {
|
|
|
754
810
|
if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
|
|
755
811
|
let i = t.experienceId.trim();
|
|
756
812
|
if (!i) throw Error("sessionEndpoint requires experienceId.");
|
|
757
|
-
let a =
|
|
813
|
+
let a = Ke(t), o = qe(t), s = t.idempotencyKey?.trim();
|
|
758
814
|
return {
|
|
759
815
|
url: r.toString(),
|
|
760
816
|
init: {
|
|
@@ -773,7 +829,7 @@ function Ve(e, t) {
|
|
|
773
829
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
774
830
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
775
831
|
...(() => {
|
|
776
|
-
let e =
|
|
832
|
+
let e = Ge(t.attribution);
|
|
777
833
|
return e ? { attribution: e } : {};
|
|
778
834
|
})(),
|
|
779
835
|
...t.alreadyConverted?.length ? { alreadyConverted: [...t.alreadyConverted] } : {}
|
|
@@ -783,16 +839,16 @@ function Ve(e, t) {
|
|
|
783
839
|
}
|
|
784
840
|
//#endregion
|
|
785
841
|
//#region src/v2/types/sessionLaunch.ts
|
|
786
|
-
function
|
|
842
|
+
function Ye(e) {
|
|
787
843
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
788
844
|
}
|
|
789
845
|
function X(e) {
|
|
790
846
|
return typeof e == "boolean";
|
|
791
847
|
}
|
|
792
|
-
function
|
|
793
|
-
if (!
|
|
848
|
+
function Xe(e) {
|
|
849
|
+
if (!Ye(e)) return null;
|
|
794
850
|
let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
|
|
795
|
-
return !
|
|
851
|
+
return !Ye(t) || !Ye(n) || !Ye(r) || !Ye(i) || !X(t.input) || !X(t.output) || !X(t.externalAudio) || !X(n.managed) || !X(r.enabled) || !X(i.enabled) ? null : {
|
|
796
852
|
speech: {
|
|
797
853
|
input: t.input,
|
|
798
854
|
output: t.output,
|
|
@@ -803,8 +859,8 @@ function He(e) {
|
|
|
803
859
|
tools: { enabled: i.enabled }
|
|
804
860
|
};
|
|
805
861
|
}
|
|
806
|
-
function
|
|
807
|
-
return !
|
|
862
|
+
function Ze(e) {
|
|
863
|
+
return !Ye(e) || !X(e.avatar) || !X(e.speechInput) || !X(e.speechOutput) || !X(e.tools) || !X(e.externalAudio) ? null : {
|
|
808
864
|
speech: {
|
|
809
865
|
input: e.speechInput,
|
|
810
866
|
output: e.speechOutput,
|
|
@@ -815,12 +871,12 @@ function Ue(e) {
|
|
|
815
871
|
tools: { enabled: e.tools }
|
|
816
872
|
};
|
|
817
873
|
}
|
|
818
|
-
function
|
|
819
|
-
return
|
|
874
|
+
function Qe(e) {
|
|
875
|
+
return Xe(e) ?? Ze(e);
|
|
820
876
|
}
|
|
821
|
-
function
|
|
822
|
-
if (!
|
|
823
|
-
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 =
|
|
877
|
+
function $e(e) {
|
|
878
|
+
if (!Ye(e)) throw Error("Session Launch response is missing session.");
|
|
879
|
+
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 = Qe(e.capabilities), l = et(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;
|
|
824
880
|
if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
|
|
825
881
|
return {
|
|
826
882
|
id: t,
|
|
@@ -836,11 +892,11 @@ function Ge(e) {
|
|
|
836
892
|
...d ? { createdAt: d } : {}
|
|
837
893
|
};
|
|
838
894
|
}
|
|
839
|
-
function
|
|
895
|
+
function et(e) {
|
|
840
896
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
841
897
|
let t = [];
|
|
842
898
|
for (let n of e) {
|
|
843
|
-
if (!
|
|
899
|
+
if (!Ye(n)) continue;
|
|
844
900
|
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() : "";
|
|
845
901
|
!e || !r || !i || n.reason !== "voice_unsupported" || t.push({
|
|
846
902
|
axis: e,
|
|
@@ -851,104 +907,104 @@ function Ke(e) {
|
|
|
851
907
|
}
|
|
852
908
|
return t.length > 0 ? t : void 0;
|
|
853
909
|
}
|
|
854
|
-
function
|
|
910
|
+
function tt(e) {
|
|
855
911
|
let t = e.localeVoiceFallbacks;
|
|
856
912
|
if (t?.length) for (let e of t) {
|
|
857
913
|
let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
|
|
858
914
|
console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
|
|
859
915
|
}
|
|
860
916
|
}
|
|
861
|
-
function
|
|
862
|
-
if (!
|
|
917
|
+
function nt(e) {
|
|
918
|
+
if (!Ye(e)) throw Error("Session Launch response must be a JSON object.");
|
|
863
919
|
let t = typeof e.launch == "string" ? e.launch.trim() : "";
|
|
864
920
|
if (!t) throw Error("Session Launch response is missing launch.");
|
|
865
|
-
let n =
|
|
866
|
-
return
|
|
921
|
+
let n = $e(e.session);
|
|
922
|
+
return tt(n), {
|
|
867
923
|
session: n,
|
|
868
924
|
launch: t
|
|
869
925
|
};
|
|
870
926
|
}
|
|
871
927
|
//#endregion
|
|
872
928
|
//#region src/v2/api/mintPublicSession.ts
|
|
873
|
-
function
|
|
929
|
+
function rt() {
|
|
874
930
|
try {
|
|
875
931
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
876
932
|
} catch {}
|
|
877
933
|
}
|
|
878
|
-
function
|
|
934
|
+
function it(e) {
|
|
879
935
|
return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
|
|
880
936
|
}
|
|
881
|
-
function
|
|
882
|
-
let n =
|
|
937
|
+
function at(e, t) {
|
|
938
|
+
let n = rt(), r = it(t.code), i = t.message.trim(), a = t.details ?? {};
|
|
883
939
|
if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
|
|
884
940
|
if (i.includes(e) && i.includes("allowed origin")) return t;
|
|
885
941
|
let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
|
|
886
|
-
return new
|
|
942
|
+
return new J(`Your origin ${r} is not an allowed origin for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, add ${r} to the list of allowed origins, and ensure “Allow public client-only embeds” is enabled.`, {
|
|
887
943
|
code: "ORIGIN_NOT_ALLOWED",
|
|
888
944
|
requestId: t.requestId,
|
|
889
945
|
status: t.status,
|
|
890
946
|
details: a
|
|
891
947
|
});
|
|
892
948
|
}
|
|
893
|
-
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new
|
|
949
|
+
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new J(`Browser embeds are not enabled for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, and enable “Allow public client-only embeds”.`, {
|
|
894
950
|
code: "BROWSER_EMBEDS_DISABLED",
|
|
895
951
|
requestId: t.requestId,
|
|
896
952
|
status: t.status,
|
|
897
953
|
details: a
|
|
898
|
-
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new
|
|
954
|
+
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new J(`No playable experience found for “${e}”. Check that the experience id is correct (it should look like exp_…), and that the experience exists and is published in the Liforma developer portal (app.liforma.ai). Deleted, archived, and unpublished experiences cannot be started from a browser embed.`, {
|
|
899
955
|
code: "EXPERIENCE_UNAVAILABLE",
|
|
900
956
|
requestId: t.requestId,
|
|
901
957
|
status: t.status,
|
|
902
958
|
details: a
|
|
903
959
|
}) : t;
|
|
904
960
|
}
|
|
905
|
-
function
|
|
961
|
+
function ot(e) {
|
|
906
962
|
let t = e?.locale?.trim();
|
|
907
963
|
if (t) return t;
|
|
908
964
|
let n = e?.language?.trim();
|
|
909
965
|
if (n) return n;
|
|
910
966
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
911
967
|
}
|
|
912
|
-
function
|
|
968
|
+
function st(e) {
|
|
913
969
|
let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
|
|
914
|
-
if (t && n && t !== n) throw new
|
|
970
|
+
if (t && n && t !== n) throw new J("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
|
|
915
971
|
return t || n || void 0;
|
|
916
972
|
}
|
|
917
|
-
function
|
|
918
|
-
let n = { experienceId: e }, r =
|
|
973
|
+
function ct(e, t) {
|
|
974
|
+
let n = { experienceId: e }, r = ot(t);
|
|
919
975
|
r && (n.locale = r);
|
|
920
|
-
let i =
|
|
976
|
+
let i = st(t);
|
|
921
977
|
i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly);
|
|
922
|
-
let a =
|
|
978
|
+
let a = Ge(t?.attribution);
|
|
923
979
|
return a && (n.attribution = a), t?.alreadyConverted?.length && (n.alreadyConverted = [...t.alreadyConverted]), n;
|
|
924
980
|
}
|
|
925
|
-
async function
|
|
926
|
-
let n =
|
|
981
|
+
async function lt(e, t) {
|
|
982
|
+
let n = Le(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
|
|
927
983
|
method: "POST",
|
|
928
984
|
headers: {
|
|
929
985
|
"Content-Type": "application/json",
|
|
930
986
|
...r ? { "Idempotency-Key": r } : {}
|
|
931
987
|
},
|
|
932
|
-
body: JSON.stringify(
|
|
988
|
+
body: JSON.stringify(ct(e, t))
|
|
933
989
|
});
|
|
934
990
|
if (!i.ok) {
|
|
935
991
|
let t = await i.text();
|
|
936
|
-
throw
|
|
992
|
+
throw at(e, Ve(i.status, t, i.headers));
|
|
937
993
|
}
|
|
938
994
|
let a;
|
|
939
995
|
try {
|
|
940
996
|
a = await i.json();
|
|
941
997
|
} catch {
|
|
942
|
-
throw new
|
|
998
|
+
throw new J("Browser session mint returned invalid JSON.", {
|
|
943
999
|
code: "INVALID_RESPONSE",
|
|
944
1000
|
status: i.status,
|
|
945
1001
|
requestId: i.headers.get("Liforma-Request-Id") ?? void 0
|
|
946
1002
|
});
|
|
947
1003
|
}
|
|
948
|
-
return
|
|
1004
|
+
return nt(a);
|
|
949
1005
|
}
|
|
950
|
-
async function
|
|
951
|
-
let n =
|
|
1006
|
+
async function ut(e, t) {
|
|
1007
|
+
let n = Je(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
|
|
952
1008
|
t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
|
|
953
1009
|
let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
|
|
954
1010
|
try {
|
|
@@ -961,9 +1017,9 @@ async function nt(e, t) {
|
|
|
961
1017
|
}
|
|
962
1018
|
if (!o.ok) {
|
|
963
1019
|
let e = await o.text();
|
|
964
|
-
throw
|
|
1020
|
+
throw Ve(o.status, e, o.headers);
|
|
965
1021
|
}
|
|
966
|
-
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new
|
|
1022
|
+
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new J("Session endpoint must return a JSON Session Launch response.", {
|
|
967
1023
|
code: "INVALID_RESPONSE",
|
|
968
1024
|
status: o.status,
|
|
969
1025
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
@@ -972,20 +1028,20 @@ async function nt(e, t) {
|
|
|
972
1028
|
try {
|
|
973
1029
|
s = await o.json();
|
|
974
1030
|
} catch {
|
|
975
|
-
throw new
|
|
1031
|
+
throw new J("Session endpoint returned invalid JSON.", {
|
|
976
1032
|
code: "INVALID_RESPONSE",
|
|
977
1033
|
status: o.status,
|
|
978
1034
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
979
1035
|
});
|
|
980
1036
|
}
|
|
981
|
-
return
|
|
1037
|
+
return nt(s);
|
|
982
1038
|
}
|
|
983
1039
|
//#endregion
|
|
984
1040
|
//#region src/v2/conversationProcessor.ts
|
|
985
|
-
function
|
|
1041
|
+
function dt(e) {
|
|
986
1042
|
return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
|
|
987
1043
|
}
|
|
988
|
-
function
|
|
1044
|
+
function ft(e) {
|
|
989
1045
|
if (typeof e == "string") {
|
|
990
1046
|
let t = e.trim();
|
|
991
1047
|
if (!t) throw Error("conversationProcessor returned empty text.");
|
|
@@ -999,24 +1055,24 @@ function it(e) {
|
|
|
999
1055
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
1000
1056
|
};
|
|
1001
1057
|
}
|
|
1002
|
-
async function
|
|
1058
|
+
async function pt(e, t) {
|
|
1003
1059
|
let n = await e(t);
|
|
1004
|
-
return
|
|
1060
|
+
return dt(n) ? {
|
|
1005
1061
|
kind: "stream",
|
|
1006
1062
|
stream: n
|
|
1007
1063
|
} : {
|
|
1008
1064
|
kind: "complete",
|
|
1009
|
-
speech:
|
|
1065
|
+
speech: ft(n)
|
|
1010
1066
|
};
|
|
1011
1067
|
}
|
|
1012
1068
|
//#endregion
|
|
1013
1069
|
//#region src/v2/embed/playerReachability.ts
|
|
1014
|
-
var
|
|
1015
|
-
function
|
|
1070
|
+
var mt = "3002";
|
|
1071
|
+
function ht(e) {
|
|
1016
1072
|
let t = new URL(e);
|
|
1017
|
-
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 ||
|
|
1073
|
+
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 || mt}. 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.`;
|
|
1018
1074
|
}
|
|
1019
|
-
async function
|
|
1075
|
+
async function gt(e, t) {
|
|
1020
1076
|
try {
|
|
1021
1077
|
await fetch(e, {
|
|
1022
1078
|
method: "GET",
|
|
@@ -1024,27 +1080,27 @@ async function ct(e, t) {
|
|
|
1024
1080
|
signal: AbortSignal.timeout(8e3)
|
|
1025
1081
|
});
|
|
1026
1082
|
} catch {
|
|
1027
|
-
throw Error(
|
|
1083
|
+
throw Error(ht(t));
|
|
1028
1084
|
}
|
|
1029
1085
|
}
|
|
1030
|
-
function
|
|
1086
|
+
function _t(e, t, n, r) {
|
|
1031
1087
|
try {
|
|
1032
1088
|
r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
|
|
1033
1089
|
} catch (e) {
|
|
1034
|
-
throw e instanceof DOMException && e.name === "SecurityError" ? Error(
|
|
1090
|
+
throw e instanceof DOMException && e.name === "SecurityError" ? Error(ht(n), { cause: e }) : e;
|
|
1035
1091
|
}
|
|
1036
1092
|
}
|
|
1037
|
-
var
|
|
1038
|
-
function
|
|
1039
|
-
return typeof e == "number" &&
|
|
1093
|
+
var vt = new Set([1, 2]);
|
|
1094
|
+
function yt(e) {
|
|
1095
|
+
return typeof e == "number" && vt.has(e);
|
|
1040
1096
|
}
|
|
1041
|
-
var
|
|
1042
|
-
function
|
|
1097
|
+
var bt = 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.theatre.interactionChange".split("."));
|
|
1098
|
+
function xt(e) {
|
|
1043
1099
|
if (!e || typeof e != "object") return null;
|
|
1044
1100
|
let t = e;
|
|
1045
|
-
if (!
|
|
1101
|
+
if (!yt(t.schemaVersion) || !t.type || !bt.has(t.type)) return null;
|
|
1046
1102
|
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
1047
|
-
if (t.type === "fullWindow") {
|
|
1103
|
+
if (t.type === "fullWindow" || t.type === "theatre") {
|
|
1048
1104
|
let e = t.payload;
|
|
1049
1105
|
return !e || typeof e != "object" || typeof e.active != "boolean" ? null : t;
|
|
1050
1106
|
}
|
|
@@ -1065,10 +1121,10 @@ function pt(e) {
|
|
|
1065
1121
|
let n = t.payload;
|
|
1066
1122
|
return !n || typeof n != "object" ? null : t;
|
|
1067
1123
|
}
|
|
1068
|
-
function
|
|
1124
|
+
function St(e, t, n) {
|
|
1069
1125
|
let r = e.trim();
|
|
1070
1126
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
1071
|
-
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction;
|
|
1127
|
+
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction, c = n?.theatreButton, l = n?.theatre;
|
|
1072
1128
|
return {
|
|
1073
1129
|
type: "launch",
|
|
1074
1130
|
schemaVersion: 2,
|
|
@@ -1078,34 +1134,43 @@ function mt(e, t, n) {
|
|
|
1078
1134
|
...i ? { startButton: i } : {},
|
|
1079
1135
|
...a ? { theme: a } : {},
|
|
1080
1136
|
...o === void 0 ? {} : { showFeedback: o },
|
|
1081
|
-
...s ? { interaction: s } : {}
|
|
1137
|
+
...s ? { interaction: s } : {},
|
|
1138
|
+
...c ? { theatreButton: !0 } : {},
|
|
1139
|
+
...l === void 0 ? {} : { theatre: l }
|
|
1082
1140
|
}
|
|
1083
1141
|
};
|
|
1084
1142
|
}
|
|
1085
|
-
function
|
|
1143
|
+
function Ct() {
|
|
1086
1144
|
return {
|
|
1087
1145
|
type: "parentHello",
|
|
1088
1146
|
schemaVersion: 2
|
|
1089
1147
|
};
|
|
1090
1148
|
}
|
|
1091
|
-
function
|
|
1149
|
+
function wt(e) {
|
|
1092
1150
|
return {
|
|
1093
1151
|
type: "widgetSetChrome",
|
|
1094
1152
|
schemaVersion: 2,
|
|
1095
1153
|
payload: { mode: e }
|
|
1096
1154
|
};
|
|
1097
1155
|
}
|
|
1098
|
-
function
|
|
1156
|
+
function Tt() {
|
|
1099
1157
|
return {
|
|
1100
1158
|
type: "widgetToggleAudioSettings",
|
|
1101
1159
|
schemaVersion: 2,
|
|
1102
1160
|
payload: {}
|
|
1103
1161
|
};
|
|
1104
1162
|
}
|
|
1163
|
+
function Et(e) {
|
|
1164
|
+
return {
|
|
1165
|
+
type: "setTheatre",
|
|
1166
|
+
schemaVersion: 2,
|
|
1167
|
+
payload: { active: e }
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1105
1170
|
//#endregion
|
|
1106
1171
|
//#region src/v2/embed/fullWindowHost.ts
|
|
1107
|
-
var
|
|
1108
|
-
function
|
|
1172
|
+
var Dt = "2147483000";
|
|
1173
|
+
function Ot(e) {
|
|
1109
1174
|
let { style: t } = e;
|
|
1110
1175
|
return {
|
|
1111
1176
|
position: t.position,
|
|
@@ -1123,11 +1188,11 @@ function yt(e) {
|
|
|
1123
1188
|
maxHeight: t.maxHeight
|
|
1124
1189
|
};
|
|
1125
1190
|
}
|
|
1126
|
-
function
|
|
1191
|
+
function kt(e) {
|
|
1127
1192
|
let { style: t } = e;
|
|
1128
|
-
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 =
|
|
1193
|
+
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 = Dt, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
|
|
1129
1194
|
}
|
|
1130
|
-
function
|
|
1195
|
+
function At(e, t) {
|
|
1131
1196
|
if (delete e.dataset.liformaFullWindow, !t) {
|
|
1132
1197
|
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 = "";
|
|
1133
1198
|
return;
|
|
@@ -1137,20 +1202,20 @@ function xt(e, t) {
|
|
|
1137
1202
|
}
|
|
1138
1203
|
//#endregion
|
|
1139
1204
|
//#region src/v2/embed/iframeHost.ts
|
|
1140
|
-
function
|
|
1205
|
+
function jt(e) {
|
|
1141
1206
|
return e;
|
|
1142
1207
|
}
|
|
1143
1208
|
function Z() {
|
|
1144
1209
|
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)}`;
|
|
1145
1210
|
}
|
|
1146
|
-
var
|
|
1147
|
-
function
|
|
1211
|
+
var Mt = 3e4;
|
|
1212
|
+
function Nt(e) {
|
|
1148
1213
|
let t = e.container;
|
|
1149
1214
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
1150
1215
|
let n = document.createElement("iframe");
|
|
1151
|
-
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");
|
|
1152
|
-
let r = !1, i = !1, a = null, o =
|
|
1153
|
-
i !==
|
|
1216
|
+
n.src = e.src, n.title = "Liforma experience", n.setAttribute("allow", "microphone; autoplay; clipboard-read; clipboard-write; fullscreen"), n.setAttribute("allowfullscreen", ""), 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"), n.setAttribute("fetchpriority", "high"), "fetchPriority" in n && (n.fetchPriority = "high");
|
|
1217
|
+
let r = !1, i = !1, a = null, o = null, s = (r) => {
|
|
1218
|
+
i !== r && (i = r, r ? (a = Ot(n), o = document.body.style.overflow, document.body.append(n), kt(n), document.body.style.overflow = "hidden") : (t.append(n), At(n, a), a = null, o !== null && (document.body.style.overflow = o, o = null)), e.onFullWindowChange?.(r));
|
|
1154
1219
|
}, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
|
|
1155
1220
|
p = e, m = t;
|
|
1156
1221
|
}), g = () => {
|
|
@@ -1161,10 +1226,10 @@ function wt(e) {
|
|
|
1161
1226
|
let i = Date.now();
|
|
1162
1227
|
if (d > 0 && i - d < 250) return;
|
|
1163
1228
|
d = i, g();
|
|
1164
|
-
let a =
|
|
1229
|
+
let a = St(t.launch, t.session, t.chrome), o = () => {
|
|
1165
1230
|
if (r) return;
|
|
1166
1231
|
let t = n.contentWindow;
|
|
1167
|
-
t &&
|
|
1232
|
+
t && _t(t, a, e.playerOrigin);
|
|
1168
1233
|
};
|
|
1169
1234
|
o();
|
|
1170
1235
|
for (let e = 1; e <= 12; e += 1) f.push(window.setTimeout(o, e * 75));
|
|
@@ -1172,17 +1237,17 @@ function wt(e) {
|
|
|
1172
1237
|
r || !l || _(l);
|
|
1173
1238
|
}, y = () => {
|
|
1174
1239
|
if (u += 1, u === 1) {
|
|
1175
|
-
|
|
1240
|
+
gt(e.src, e.playerOrigin).then(() => p?.(), (e) => m?.(e instanceof Error ? e : Error(String(e))));
|
|
1176
1241
|
return;
|
|
1177
1242
|
}
|
|
1178
1243
|
d = 0, v();
|
|
1179
1244
|
}, b = () => {
|
|
1180
|
-
u > 0 || m?.(Error(
|
|
1245
|
+
u > 0 || m?.(Error(ht(e.playerOrigin)));
|
|
1181
1246
|
};
|
|
1182
1247
|
n.addEventListener("load", y), n.addEventListener("error", b);
|
|
1183
1248
|
let x = (t) => {
|
|
1184
1249
|
if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
|
|
1185
|
-
let i =
|
|
1250
|
+
let i = xt(t.data);
|
|
1186
1251
|
if (i) switch (i.type) {
|
|
1187
1252
|
case "close":
|
|
1188
1253
|
e.onClose?.(i.payload);
|
|
@@ -1221,7 +1286,7 @@ function wt(e) {
|
|
|
1221
1286
|
e.onUserSpeechEnded?.(i.payload);
|
|
1222
1287
|
break;
|
|
1223
1288
|
case "modeChange":
|
|
1224
|
-
e.onActivityChange?.(
|
|
1289
|
+
e.onActivityChange?.(jt(i.payload.mode));
|
|
1225
1290
|
break;
|
|
1226
1291
|
case "activityChange":
|
|
1227
1292
|
e.onActivityChange?.(i.payload.activity);
|
|
@@ -1265,6 +1330,9 @@ function wt(e) {
|
|
|
1265
1330
|
case "fullWindow":
|
|
1266
1331
|
s(i.payload.active);
|
|
1267
1332
|
break;
|
|
1333
|
+
case "theatre":
|
|
1334
|
+
e.onTheatreChange?.(i.payload.active);
|
|
1335
|
+
break;
|
|
1268
1336
|
case "interactionChange":
|
|
1269
1337
|
e.onInteractionChange?.(i.payload.interaction);
|
|
1270
1338
|
break;
|
|
@@ -1277,8 +1345,8 @@ function wt(e) {
|
|
|
1277
1345
|
let S = (t, i) => {
|
|
1278
1346
|
if (r) return;
|
|
1279
1347
|
let a = n.contentWindow;
|
|
1280
|
-
if (!a) throw Error(
|
|
1281
|
-
|
|
1348
|
+
if (!a) throw Error(ht(e.playerOrigin));
|
|
1349
|
+
_t(a, t, e.playerOrigin, i);
|
|
1282
1350
|
}, C = (e, t = 12e4, n) => {
|
|
1283
1351
|
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Z();
|
|
1284
1352
|
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((i, a) => {
|
|
@@ -1295,7 +1363,7 @@ function wt(e) {
|
|
|
1295
1363
|
return h;
|
|
1296
1364
|
},
|
|
1297
1365
|
postParentHello() {
|
|
1298
|
-
S(
|
|
1366
|
+
S(Ct());
|
|
1299
1367
|
},
|
|
1300
1368
|
postLaunch(e, t, n) {
|
|
1301
1369
|
r || (l = {
|
|
@@ -1317,10 +1385,13 @@ function wt(e) {
|
|
|
1317
1385
|
throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
|
|
1318
1386
|
},
|
|
1319
1387
|
postWidgetSetChrome(e) {
|
|
1320
|
-
S(
|
|
1388
|
+
S(wt(e));
|
|
1321
1389
|
},
|
|
1322
1390
|
postWidgetToggleAudioSettings() {
|
|
1323
|
-
S(
|
|
1391
|
+
S(Tt());
|
|
1392
|
+
},
|
|
1393
|
+
postSetTheatre(e) {
|
|
1394
|
+
S(Et(e));
|
|
1324
1395
|
},
|
|
1325
1396
|
speak(e) {
|
|
1326
1397
|
return C({
|
|
@@ -1442,7 +1513,7 @@ function wt(e) {
|
|
|
1442
1513
|
audio: e.audio,
|
|
1443
1514
|
byteLength: e.byteLength
|
|
1444
1515
|
}
|
|
1445
|
-
},
|
|
1516
|
+
}, Mt, [e.audio]);
|
|
1446
1517
|
},
|
|
1447
1518
|
speechUtteranceSetTranscript(e) {
|
|
1448
1519
|
return C({
|
|
@@ -1604,7 +1675,7 @@ function wt(e) {
|
|
|
1604
1675
|
}
|
|
1605
1676
|
//#endregion
|
|
1606
1677
|
//#region src/v2/embed/readyGate.ts
|
|
1607
|
-
function
|
|
1678
|
+
function Pt(e) {
|
|
1608
1679
|
let t, n = !1, r = !1, i = () => {
|
|
1609
1680
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
1610
1681
|
};
|
|
@@ -1619,9 +1690,9 @@ function Tt(e) {
|
|
|
1619
1690
|
}
|
|
1620
1691
|
//#endregion
|
|
1621
1692
|
//#region src/v2/sdkRelease.ts
|
|
1622
|
-
var
|
|
1693
|
+
var Ft = `sdk@${{
|
|
1623
1694
|
name: "@liforma/client",
|
|
1624
|
-
version: "0.4.
|
|
1695
|
+
version: "0.4.14",
|
|
1625
1696
|
type: "module",
|
|
1626
1697
|
description: "Liforma browser SDK — Experience sessions, speech API, and Svelte embed component.",
|
|
1627
1698
|
license: "MIT",
|
|
@@ -1782,6 +1853,8 @@ var Et = `sdk@${{
|
|
|
1782
1853
|
"generate:location-discontinuities": "node scripts/generate-location-discontinuities.mjs",
|
|
1783
1854
|
"build:locations": "node scripts/build-locations.mjs",
|
|
1784
1855
|
"publish:locations": "node scripts/publish-locations.mjs",
|
|
1856
|
+
"publish:location-400x225": "node scripts/build-location-400x225.mjs",
|
|
1857
|
+
"test:location-400x225": "node scripts/test-location-400x225.mjs",
|
|
1785
1858
|
"verify:locations": "node scripts/verify-location-sources.mjs",
|
|
1786
1859
|
"publish:models": "node scripts/publish-models.mjs",
|
|
1787
1860
|
"publish:models:krea-int8": "node scripts/_upload-model-prefix.mjs text-to-image/lf-t2i-turbo-int8",
|
|
@@ -1811,6 +1884,7 @@ var Et = `sdk@${{
|
|
|
1811
1884
|
"preview:test": "npm run build && npm run preview"
|
|
1812
1885
|
},
|
|
1813
1886
|
dependencies: {
|
|
1887
|
+
"@jsquash/avif": "^1.3.0",
|
|
1814
1888
|
"@jsquash/webp": "^1.5.0",
|
|
1815
1889
|
zod: "^4.4.3"
|
|
1816
1890
|
},
|
|
@@ -1840,50 +1914,54 @@ var Et = `sdk@${{
|
|
|
1840
1914
|
vitest: "^4.1.10",
|
|
1841
1915
|
wrangler: "^4.101.0"
|
|
1842
1916
|
}
|
|
1843
|
-
}.version}`,
|
|
1844
|
-
function
|
|
1917
|
+
}.version}`, It = "https://player.liforma.ai/embed", Lt = "http://localhost:3002/embed";
|
|
1918
|
+
function Rt() {
|
|
1845
1919
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1846
1920
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1847
1921
|
if (typeof document > "u") return null;
|
|
1848
1922
|
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();
|
|
1849
1923
|
return t ? t.replace(/\/$/, "") : null;
|
|
1850
1924
|
}
|
|
1851
|
-
function
|
|
1852
|
-
let e =
|
|
1853
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` : te() ?
|
|
1925
|
+
function zt() {
|
|
1926
|
+
let e = Rt();
|
|
1927
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : te() ? Lt : It;
|
|
1854
1928
|
}
|
|
1855
|
-
function
|
|
1929
|
+
function Bt(e, t) {
|
|
1856
1930
|
return e?.trim() || t?.trim() || void 0;
|
|
1857
1931
|
}
|
|
1858
|
-
function
|
|
1859
|
-
let
|
|
1860
|
-
|
|
1861
|
-
let
|
|
1862
|
-
|
|
1932
|
+
function Vt(e, t, n, r, i, a, o, s, c, l, u, d, f) {
|
|
1933
|
+
let p = (e ?? zt()).replace(/\/$/, ""), m = p.endsWith("/embed") ? p : `${p}/embed`, h = new URL(m), g = n?.trim();
|
|
1934
|
+
g && h.searchParams.set("backdropId", g);
|
|
1935
|
+
let _ = r?.trim();
|
|
1936
|
+
_ && h.searchParams.set("avatarId", _);
|
|
1937
|
+
let v = d?.trim();
|
|
1938
|
+
v && h.searchParams.set("previewBg", v);
|
|
1939
|
+
let y = f?.trim();
|
|
1940
|
+
return y && h.searchParams.set("previewFg", y), (i === "face" || i === "medium") && h.searchParams.set("fit", i), c === "pip" && h.searchParams.set("stage", "pip"), l === "set" && h.searchParams.set("pipBackground", "set"), u === !1 && h.searchParams.set("pipShadow", "0"), a === "widget" && h.searchParams.set("ui", "widget"), o && h.searchParams.set("close", "1"), t && h.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && h.searchParams.set("cast", String(s)), Ht(h.toString());
|
|
1863
1941
|
}
|
|
1864
|
-
function
|
|
1942
|
+
function Ht(e) {
|
|
1865
1943
|
if (typeof location > "u") return e;
|
|
1866
1944
|
let t = new URL(e);
|
|
1867
1945
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1868
1946
|
}
|
|
1869
|
-
function
|
|
1947
|
+
function Ut(e) {
|
|
1870
1948
|
return new URL(e).origin;
|
|
1871
1949
|
}
|
|
1872
1950
|
//#endregion
|
|
1873
1951
|
//#region src/v2/experienceEvents.ts
|
|
1874
|
-
function
|
|
1952
|
+
function Wt() {
|
|
1875
1953
|
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)}`;
|
|
1876
1954
|
}
|
|
1877
|
-
function
|
|
1955
|
+
function Gt(e, t, n) {
|
|
1878
1956
|
return {
|
|
1879
|
-
id:
|
|
1957
|
+
id: Wt(),
|
|
1880
1958
|
type: e,
|
|
1881
1959
|
sessionId: t,
|
|
1882
1960
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1883
1961
|
data: n
|
|
1884
1962
|
};
|
|
1885
1963
|
}
|
|
1886
|
-
function
|
|
1964
|
+
function Kt() {
|
|
1887
1965
|
return {
|
|
1888
1966
|
ready: /* @__PURE__ */ new Set(),
|
|
1889
1967
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1904,39 +1982,39 @@ function Lt() {
|
|
|
1904
1982
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1905
1983
|
};
|
|
1906
1984
|
}
|
|
1907
|
-
function
|
|
1985
|
+
function qt(e, t, n) {
|
|
1908
1986
|
return e[t].add(n), () => e[t].delete(n);
|
|
1909
1987
|
}
|
|
1910
|
-
function
|
|
1988
|
+
function Jt(e, t, n) {
|
|
1911
1989
|
for (let r of e[t]) r(n);
|
|
1912
1990
|
}
|
|
1913
|
-
function
|
|
1991
|
+
function Yt(e) {
|
|
1914
1992
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1915
1993
|
}
|
|
1916
1994
|
//#endregion
|
|
1917
1995
|
//#region src/v2/speech/types.ts
|
|
1918
|
-
function
|
|
1996
|
+
function Xt(e) {
|
|
1919
1997
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1920
1998
|
}
|
|
1921
|
-
function
|
|
1999
|
+
function Zt(e) {
|
|
1922
2000
|
return "url" in e && typeof e.url == "string";
|
|
1923
2001
|
}
|
|
1924
|
-
function
|
|
2002
|
+
function Qt(e) {
|
|
1925
2003
|
if (!("track" in e)) return !1;
|
|
1926
2004
|
let t = e.track;
|
|
1927
2005
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1928
2006
|
}
|
|
1929
|
-
function
|
|
1930
|
-
return !
|
|
2007
|
+
function $t(e) {
|
|
2008
|
+
return !Xt(e) && !Zt(e) && !Qt(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1931
2009
|
}
|
|
1932
|
-
var
|
|
2010
|
+
var en = [
|
|
1933
2011
|
8e3,
|
|
1934
2012
|
16e3,
|
|
1935
2013
|
22050,
|
|
1936
2014
|
24e3,
|
|
1937
2015
|
44100,
|
|
1938
2016
|
48e3
|
|
1939
|
-
],
|
|
2017
|
+
], tn = {
|
|
1940
2018
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1941
2019
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1942
2020
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1947,14 +2025,14 @@ var Gt = [
|
|
|
1947
2025
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1948
2026
|
MAX_PENDING_WRITES: 8,
|
|
1949
2027
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1950
|
-
},
|
|
2028
|
+
}, nn = class extends Error {
|
|
1951
2029
|
operation;
|
|
1952
2030
|
requiredCapability;
|
|
1953
2031
|
name = "UnsupportedSpeechOperationError";
|
|
1954
2032
|
constructor(e, t) {
|
|
1955
2033
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1956
2034
|
}
|
|
1957
|
-
},
|
|
2035
|
+
}, rn = class extends Error {
|
|
1958
2036
|
name = "SpeechUtteranceClosedError";
|
|
1959
2037
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1960
2038
|
super(e);
|
|
@@ -1964,72 +2042,72 @@ var Gt = [
|
|
|
1964
2042
|
constructor(e, t) {
|
|
1965
2043
|
super(e, t);
|
|
1966
2044
|
}
|
|
1967
|
-
},
|
|
2045
|
+
}, an = class extends Error {
|
|
1968
2046
|
name = "SpeechBufferTimeoutError";
|
|
1969
2047
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1970
2048
|
super(e);
|
|
1971
2049
|
}
|
|
1972
2050
|
};
|
|
1973
|
-
function
|
|
2051
|
+
function on(e = "none") {
|
|
1974
2052
|
return {
|
|
1975
2053
|
mode: e,
|
|
1976
2054
|
trackedDurationMs: 0,
|
|
1977
2055
|
fallbackDurationMs: 0
|
|
1978
2056
|
};
|
|
1979
2057
|
}
|
|
1980
|
-
function
|
|
1981
|
-
return
|
|
2058
|
+
function sn(e) {
|
|
2059
|
+
return en.includes(e);
|
|
1982
2060
|
}
|
|
1983
|
-
function
|
|
2061
|
+
function cn(e) {
|
|
1984
2062
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
1985
2063
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
1986
|
-
if (!
|
|
2064
|
+
if (!sn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1987
2065
|
}
|
|
1988
|
-
function
|
|
1989
|
-
if (
|
|
1990
|
-
|
|
2066
|
+
function ln(e) {
|
|
2067
|
+
if (Xt(e)) {
|
|
2068
|
+
cn(e.format);
|
|
1991
2069
|
return;
|
|
1992
2070
|
}
|
|
1993
|
-
if (
|
|
2071
|
+
if (Zt(e)) {
|
|
1994
2072
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
1995
|
-
if (e.sampleRate !== void 0 && !
|
|
2073
|
+
if (e.sampleRate !== void 0 && !sn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1996
2074
|
return;
|
|
1997
2075
|
}
|
|
1998
|
-
if (
|
|
2076
|
+
if (Qt(e)) {
|
|
1999
2077
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
2000
|
-
if (e.sampleRate !== void 0 && !
|
|
2078
|
+
if (e.sampleRate !== void 0 && !sn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2001
2079
|
return;
|
|
2002
2080
|
}
|
|
2003
|
-
if (
|
|
2081
|
+
if ($t(e)) {
|
|
2004
2082
|
let t = e.encoding.trim().toLowerCase();
|
|
2005
2083
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
2006
2084
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
2007
|
-
if (e.sampleRate !== void 0 && !
|
|
2085
|
+
if (e.sampleRate !== void 0 && !sn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2008
2086
|
return;
|
|
2009
2087
|
}
|
|
2010
2088
|
throw new Q("Unsupported speech.play audio shape.");
|
|
2011
2089
|
}
|
|
2012
|
-
function
|
|
2013
|
-
if (e.format) return
|
|
2090
|
+
function un(e) {
|
|
2091
|
+
if (e.format) return cn(e.format), e.format;
|
|
2014
2092
|
if (e.track) {
|
|
2015
2093
|
let t = {
|
|
2016
2094
|
encoding: "pcm_s16le",
|
|
2017
2095
|
sampleRate: e.sampleRate ?? 24e3,
|
|
2018
2096
|
channels: 1
|
|
2019
2097
|
};
|
|
2020
|
-
return
|
|
2098
|
+
return cn(t), t;
|
|
2021
2099
|
}
|
|
2022
2100
|
throw new Q("createUtterance requires format or track.");
|
|
2023
2101
|
}
|
|
2024
|
-
function
|
|
2102
|
+
function dn(e) {
|
|
2025
2103
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
2026
2104
|
}
|
|
2027
|
-
function
|
|
2105
|
+
function fn(e) {
|
|
2028
2106
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
2029
2107
|
}
|
|
2030
2108
|
//#endregion
|
|
2031
2109
|
//#region src/byo/pcm.ts
|
|
2032
|
-
function
|
|
2110
|
+
function pn(e) {
|
|
2033
2111
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
2034
2112
|
for (let t = 0; t < e.length; t++) {
|
|
2035
2113
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -2039,11 +2117,11 @@ function rn(e) {
|
|
|
2039
2117
|
}
|
|
2040
2118
|
//#endregion
|
|
2041
2119
|
//#region src/byo/resample.ts
|
|
2042
|
-
function
|
|
2120
|
+
function mn(e, t, n, r, i) {
|
|
2043
2121
|
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;
|
|
2044
2122
|
return ((a * i + o) * i + s) * i + c;
|
|
2045
2123
|
}
|
|
2046
|
-
function
|
|
2124
|
+
function hn(e, t) {
|
|
2047
2125
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
2048
2126
|
if (e === t) return {
|
|
2049
2127
|
fromRate: e,
|
|
@@ -2066,7 +2144,7 @@ function on(e, t) {
|
|
|
2066
2144
|
let a = [];
|
|
2067
2145
|
for (; i + 2 < r.length - 1;) {
|
|
2068
2146
|
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);
|
|
2069
|
-
a.push(
|
|
2147
|
+
a.push(mn(r[o], r[e], r[s], r[c], t)), i += n;
|
|
2070
2148
|
}
|
|
2071
2149
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
2072
2150
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -2078,7 +2156,7 @@ function on(e, t) {
|
|
|
2078
2156
|
}
|
|
2079
2157
|
//#endregion
|
|
2080
2158
|
//#region src/byo/audioCapture.ts
|
|
2081
|
-
var
|
|
2159
|
+
var gn = "liforma-pcm-capture", _n = `
|
|
2082
2160
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
2083
2161
|
process(inputs) {
|
|
2084
2162
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -2090,29 +2168,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
2090
2168
|
return true;
|
|
2091
2169
|
}
|
|
2092
2170
|
}
|
|
2093
|
-
registerProcessor('${
|
|
2094
|
-
`,
|
|
2095
|
-
function
|
|
2096
|
-
return
|
|
2171
|
+
registerProcessor('${gn}', LiformaPcmCaptureProcessor);
|
|
2172
|
+
`, vn = null;
|
|
2173
|
+
function yn() {
|
|
2174
|
+
return vn ||= URL.createObjectURL(new Blob([_n], { type: "application/javascript" })), vn;
|
|
2097
2175
|
}
|
|
2098
|
-
function
|
|
2176
|
+
function bn() {
|
|
2099
2177
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
2100
2178
|
}
|
|
2101
|
-
async function
|
|
2102
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
2179
|
+
async function xn(e) {
|
|
2180
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = bn();
|
|
2103
2181
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
2104
2182
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
2105
2183
|
l.gain.value = 0;
|
|
2106
|
-
let u = s.sampleRate, d =
|
|
2184
|
+
let u = s.sampleRate, d = hn(u, n), f = !1, p = !1, m = (e) => {
|
|
2107
2185
|
if (f || i && !i()) return;
|
|
2108
2186
|
let t = d.push(e);
|
|
2109
|
-
t.length !== 0 && r(
|
|
2187
|
+
t.length !== 0 && r(pn(t));
|
|
2110
2188
|
}, h = () => void 0;
|
|
2111
2189
|
return await (async () => {
|
|
2112
2190
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
2113
2191
|
try {
|
|
2114
|
-
await s.audioWorklet.addModule(
|
|
2115
|
-
let e = new AudioWorkletNode(s,
|
|
2192
|
+
await s.audioWorklet.addModule(yn());
|
|
2193
|
+
let e = new AudioWorkletNode(s, gn, {
|
|
2116
2194
|
numberOfInputs: 1,
|
|
2117
2195
|
numberOfOutputs: 1,
|
|
2118
2196
|
outputChannelCount: [1]
|
|
@@ -2162,7 +2240,7 @@ async function fn(e) {
|
|
|
2162
2240
|
}
|
|
2163
2241
|
//#endregion
|
|
2164
2242
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
2165
|
-
async function
|
|
2243
|
+
async function Sn(e) {
|
|
2166
2244
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
2167
2245
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
2168
2246
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -2171,18 +2249,18 @@ async function pn(e) {
|
|
|
2171
2249
|
s || (s = !0, c?.stop(), c = null);
|
|
2172
2250
|
};
|
|
2173
2251
|
try {
|
|
2174
|
-
c = await
|
|
2252
|
+
c = await xn({
|
|
2175
2253
|
mediaStream: a,
|
|
2176
2254
|
targetSampleRate: r,
|
|
2177
2255
|
shouldSend: () => !s && !i?.aborted,
|
|
2178
2256
|
onPcm: (e) => {
|
|
2179
2257
|
if (s || i?.aborted) return;
|
|
2180
|
-
let t =
|
|
2258
|
+
let t = dn(e);
|
|
2181
2259
|
o = o.then(async () => {
|
|
2182
2260
|
if (s || i?.aborted) return;
|
|
2183
2261
|
let e = 0;
|
|
2184
2262
|
for (; e < t.byteLength;) {
|
|
2185
|
-
let r = Math.min(e +
|
|
2263
|
+
let r = Math.min(e + tn.MAX_CHUNK_BYTES, t.byteLength);
|
|
2186
2264
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
2187
2265
|
let i = t.subarray(e, r);
|
|
2188
2266
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -2206,10 +2284,10 @@ async function pn(e) {
|
|
|
2206
2284
|
}
|
|
2207
2285
|
//#endregion
|
|
2208
2286
|
//#region src/v2/speech/speechController.ts
|
|
2209
|
-
async function
|
|
2210
|
-
if (
|
|
2211
|
-
if (
|
|
2212
|
-
let t =
|
|
2287
|
+
async function Cn(e, t) {
|
|
2288
|
+
if (Qt(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
2289
|
+
if (Xt(e)) {
|
|
2290
|
+
let t = dn(e.data);
|
|
2213
2291
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
2214
2292
|
return {
|
|
2215
2293
|
kind: "pcm",
|
|
@@ -2217,17 +2295,17 @@ async function mn(e, t) {
|
|
|
2217
2295
|
format: e.format
|
|
2218
2296
|
};
|
|
2219
2297
|
}
|
|
2220
|
-
if (
|
|
2298
|
+
if (Zt(e)) return {
|
|
2221
2299
|
kind: "url",
|
|
2222
2300
|
url: e.url.trim(),
|
|
2223
2301
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2224
2302
|
};
|
|
2225
|
-
if (
|
|
2303
|
+
if (!$t(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
2226
2304
|
let n;
|
|
2227
2305
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
2228
2306
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2229
2307
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
2230
|
-
} else n =
|
|
2308
|
+
} else n = dn(e.data);
|
|
2231
2309
|
return {
|
|
2232
2310
|
kind: "encoded",
|
|
2233
2311
|
data: n.slice().buffer,
|
|
@@ -2235,10 +2313,10 @@ async function mn(e, t) {
|
|
|
2235
2313
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2236
2314
|
};
|
|
2237
2315
|
}
|
|
2238
|
-
function
|
|
2316
|
+
function wn() {
|
|
2239
2317
|
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)}`;
|
|
2240
2318
|
}
|
|
2241
|
-
function
|
|
2319
|
+
function Tn(e, t = "completed") {
|
|
2242
2320
|
return {
|
|
2243
2321
|
utteranceId: e.speechId,
|
|
2244
2322
|
characterId: e.characterId,
|
|
@@ -2252,13 +2330,13 @@ function gn(e, t = "completed") {
|
|
|
2252
2330
|
}
|
|
2253
2331
|
};
|
|
2254
2332
|
}
|
|
2255
|
-
function
|
|
2333
|
+
function En(e) {
|
|
2256
2334
|
return e instanceof Error ? e : new Q(String(e));
|
|
2257
2335
|
}
|
|
2258
|
-
function
|
|
2336
|
+
function Dn(e) {
|
|
2259
2337
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
2260
2338
|
}
|
|
2261
|
-
var
|
|
2339
|
+
var On = class {
|
|
2262
2340
|
id;
|
|
2263
2341
|
characterId;
|
|
2264
2342
|
result;
|
|
@@ -2287,29 +2365,29 @@ var yn = class {
|
|
|
2287
2365
|
queue: e.queue,
|
|
2288
2366
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
2289
2367
|
}).catch((e) => {
|
|
2290
|
-
throw this.fail(
|
|
2368
|
+
throw this.fail(En(e)), En(e);
|
|
2291
2369
|
}), this.signal?.addEventListener("abort", () => {
|
|
2292
2370
|
this.cancel();
|
|
2293
2371
|
}, { once: !0 });
|
|
2294
2372
|
}
|
|
2295
2373
|
async write(e, t) {
|
|
2296
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2297
|
-
let n =
|
|
2374
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new rn();
|
|
2375
|
+
let n = dn(e);
|
|
2298
2376
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
2299
|
-
if (n.byteLength >
|
|
2377
|
+
if (n.byteLength > tn.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${tn.MAX_CHUNK_BYTES}).`);
|
|
2300
2378
|
if (n.byteLength === 0) return;
|
|
2301
|
-
let r = t?.timeoutMs ??
|
|
2379
|
+
let r = t?.timeoutMs ?? tn.DEFAULT_WRITE_TIMEOUT_MS;
|
|
2302
2380
|
await this.acquireWriteSlot(r);
|
|
2303
2381
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
2304
|
-
if (this.bufferedMs + i >
|
|
2382
|
+
if (this.bufferedMs + i > tn.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
2305
2383
|
let a = async () => {
|
|
2306
|
-
if (this.closed || this.settled) throw new
|
|
2384
|
+
if (this.closed || this.settled) throw new rn();
|
|
2307
2385
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
2308
2386
|
utteranceId: this.id,
|
|
2309
2387
|
audio: t.buffer,
|
|
2310
2388
|
byteLength: t.byteLength
|
|
2311
2389
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
2312
|
-
setTimeout(() => t(new
|
|
2390
|
+
setTimeout(() => t(new an()), r);
|
|
2313
2391
|
})]);
|
|
2314
2392
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
2315
2393
|
}, o = this.writeChain.then(a, a);
|
|
@@ -2321,7 +2399,7 @@ var yn = class {
|
|
|
2321
2399
|
}
|
|
2322
2400
|
}
|
|
2323
2401
|
async setTranscript(e) {
|
|
2324
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2402
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new rn();
|
|
2325
2403
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
2326
2404
|
utteranceId: this.id,
|
|
2327
2405
|
transcript: e
|
|
@@ -2338,7 +2416,7 @@ var yn = class {
|
|
|
2338
2416
|
});
|
|
2339
2417
|
return this.resolve(t), t;
|
|
2340
2418
|
} catch (e) {
|
|
2341
|
-
let t =
|
|
2419
|
+
let t = En(e);
|
|
2342
2420
|
throw this.fail(t), t;
|
|
2343
2421
|
}
|
|
2344
2422
|
}
|
|
@@ -2356,11 +2434,11 @@ var yn = class {
|
|
|
2356
2434
|
characterId: this.characterId,
|
|
2357
2435
|
status: "cancelled",
|
|
2358
2436
|
durationMs: 0,
|
|
2359
|
-
animation:
|
|
2437
|
+
animation: on("none")
|
|
2360
2438
|
};
|
|
2361
2439
|
return this.resolve(t), t;
|
|
2362
2440
|
} catch (e) {
|
|
2363
|
-
let t =
|
|
2441
|
+
let t = En(e);
|
|
2364
2442
|
throw this.fail(t), t;
|
|
2365
2443
|
}
|
|
2366
2444
|
}
|
|
@@ -2373,19 +2451,19 @@ var yn = class {
|
|
|
2373
2451
|
return e;
|
|
2374
2452
|
}
|
|
2375
2453
|
resolve(e) {
|
|
2376
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2454
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new rn()));
|
|
2377
2455
|
}
|
|
2378
2456
|
fail(e) {
|
|
2379
2457
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
2380
2458
|
}
|
|
2381
2459
|
async acquireWriteSlot(e) {
|
|
2382
|
-
if (this.pendingWriteCount <
|
|
2460
|
+
if (this.pendingWriteCount < tn.MAX_PENDING_WRITES) {
|
|
2383
2461
|
this.pendingWriteCount += 1;
|
|
2384
2462
|
return;
|
|
2385
2463
|
}
|
|
2386
2464
|
await new Promise((t, n) => {
|
|
2387
2465
|
let r = setTimeout(() => {
|
|
2388
|
-
n(new
|
|
2466
|
+
n(new an());
|
|
2389
2467
|
}, e);
|
|
2390
2468
|
this.pendingWriteWaiters.push({
|
|
2391
2469
|
resolve: () => {
|
|
@@ -2404,13 +2482,13 @@ var yn = class {
|
|
|
2404
2482
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2405
2483
|
}
|
|
2406
2484
|
};
|
|
2407
|
-
function
|
|
2485
|
+
function kn(e) {
|
|
2408
2486
|
let t = null, n = (t, n) => {
|
|
2409
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2487
|
+
if (!e.getCapabilities()[n]) throw new nn(t, n);
|
|
2410
2488
|
}, r = {
|
|
2411
2489
|
async speak(r) {
|
|
2412
2490
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2413
|
-
let i =
|
|
2491
|
+
let i = fn(r.queue ?? "append");
|
|
2414
2492
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2415
2493
|
let a = e.getIframeHost();
|
|
2416
2494
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -2430,41 +2508,41 @@ function bn(e) {
|
|
|
2430
2508
|
return;
|
|
2431
2509
|
}
|
|
2432
2510
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2433
|
-
t.removeEventListener("abort", s), n(
|
|
2511
|
+
t.removeEventListener("abort", s), n(Tn(e, "completed"));
|
|
2434
2512
|
}, (a) => {
|
|
2435
|
-
if (t.removeEventListener("abort", s),
|
|
2513
|
+
if (t.removeEventListener("abort", s), Dn(a)) {
|
|
2436
2514
|
n({
|
|
2437
2515
|
utteranceId: "utt_interrupted",
|
|
2438
2516
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2439
2517
|
status: "interrupted",
|
|
2440
2518
|
durationMs: 0,
|
|
2441
2519
|
transcript: r.text,
|
|
2442
|
-
animation:
|
|
2520
|
+
animation: on("none")
|
|
2443
2521
|
});
|
|
2444
2522
|
return;
|
|
2445
2523
|
}
|
|
2446
|
-
i(
|
|
2524
|
+
i(En(a));
|
|
2447
2525
|
});
|
|
2448
2526
|
});
|
|
2449
2527
|
}
|
|
2450
2528
|
try {
|
|
2451
|
-
return
|
|
2529
|
+
return Tn(await o, "completed");
|
|
2452
2530
|
} catch (t) {
|
|
2453
|
-
if (
|
|
2531
|
+
if (Dn(t)) return {
|
|
2454
2532
|
utteranceId: "utt_interrupted",
|
|
2455
2533
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2456
2534
|
status: "interrupted",
|
|
2457
2535
|
durationMs: 0,
|
|
2458
2536
|
transcript: r.text,
|
|
2459
|
-
animation:
|
|
2537
|
+
animation: on("none")
|
|
2460
2538
|
};
|
|
2461
|
-
throw
|
|
2539
|
+
throw En(t);
|
|
2462
2540
|
}
|
|
2463
2541
|
},
|
|
2464
2542
|
async play(i) {
|
|
2465
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2543
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), ln(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2466
2544
|
let a = i.queue ?? "append";
|
|
2467
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2545
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), Qt(i.audio)) {
|
|
2468
2546
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2469
2547
|
return r.createUtterance({
|
|
2470
2548
|
format: {
|
|
@@ -2480,7 +2558,7 @@ function bn(e) {
|
|
|
2480
2558
|
}
|
|
2481
2559
|
let o = e.getIframeHost();
|
|
2482
2560
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2483
|
-
let s = await
|
|
2561
|
+
let s = await Cn(i.audio, i.signal);
|
|
2484
2562
|
return o.speechPlay({
|
|
2485
2563
|
source: s,
|
|
2486
2564
|
characterId: i.characterId,
|
|
@@ -2492,13 +2570,13 @@ function bn(e) {
|
|
|
2492
2570
|
},
|
|
2493
2571
|
createUtterance(r) {
|
|
2494
2572
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2495
|
-
let i =
|
|
2573
|
+
let i = un(r);
|
|
2496
2574
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2497
2575
|
let a = r.queue ?? "replace-active";
|
|
2498
2576
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2499
2577
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2500
|
-
let o = new
|
|
2501
|
-
id:
|
|
2578
|
+
let o = new On({
|
|
2579
|
+
id: wn(),
|
|
2502
2580
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2503
2581
|
format: i,
|
|
2504
2582
|
queue: a,
|
|
@@ -2510,7 +2588,7 @@ function bn(e) {
|
|
|
2510
2588
|
t === o && (t = null);
|
|
2511
2589
|
}), r.track && (async () => {
|
|
2512
2590
|
try {
|
|
2513
|
-
if (await
|
|
2591
|
+
if (await Sn({
|
|
2514
2592
|
track: r.track,
|
|
2515
2593
|
utterance: o,
|
|
2516
2594
|
sampleRate: i.sampleRate,
|
|
@@ -2538,16 +2616,16 @@ function bn(e) {
|
|
|
2538
2616
|
}
|
|
2539
2617
|
//#endregion
|
|
2540
2618
|
//#region src/v2/types/sessionInteraction.ts
|
|
2541
|
-
function
|
|
2619
|
+
function An(e) {
|
|
2542
2620
|
let t = e?.trim();
|
|
2543
2621
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2544
2622
|
}
|
|
2545
2623
|
//#endregion
|
|
2546
2624
|
//#region src/v2/experience.ts
|
|
2547
|
-
function
|
|
2625
|
+
function jn(e) {
|
|
2548
2626
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2549
2627
|
}
|
|
2550
|
-
var
|
|
2628
|
+
var Mn = class e {
|
|
2551
2629
|
bootstrap;
|
|
2552
2630
|
conversationProcessor;
|
|
2553
2631
|
iframeHost = null;
|
|
@@ -2564,19 +2642,20 @@ var Cn = class e {
|
|
|
2564
2642
|
pendingStage = null;
|
|
2565
2643
|
pendingPipBackground = null;
|
|
2566
2644
|
pendingPipShadow = null;
|
|
2645
|
+
pendingTheatre = null;
|
|
2567
2646
|
lastInteraction = null;
|
|
2568
2647
|
closeHandlers = [];
|
|
2569
|
-
eventRegistry =
|
|
2648
|
+
eventRegistry = Kt();
|
|
2570
2649
|
readyEnvelope = null;
|
|
2571
2650
|
startedEnvelope = null;
|
|
2572
2651
|
sessionMintedEnvelope = null;
|
|
2573
2652
|
conversationCache = [];
|
|
2574
2653
|
speech;
|
|
2575
2654
|
constructor(e) {
|
|
2576
|
-
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 =
|
|
2655
|
+
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 = kn({
|
|
2577
2656
|
getIframeHost: () => this.iframeHost,
|
|
2578
2657
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2579
|
-
getCapabilities: () =>
|
|
2658
|
+
getCapabilities: () => Nn(this.resolvedSession),
|
|
2580
2659
|
getActiveCharacterId: () => "character_unknown",
|
|
2581
2660
|
onProcessorInterrupt: () => {
|
|
2582
2661
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2597,6 +2676,8 @@ var Cn = class e {
|
|
|
2597
2676
|
embedBaseUrl: t.embedBaseUrl,
|
|
2598
2677
|
debug: t.debug,
|
|
2599
2678
|
speechOnly: t.speechOnly,
|
|
2679
|
+
previewBackground: t.previewBackground,
|
|
2680
|
+
previewForeground: t.previewForeground,
|
|
2600
2681
|
ui: t.ui,
|
|
2601
2682
|
onStart: t.onStart,
|
|
2602
2683
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2620,6 +2701,8 @@ var Cn = class e {
|
|
|
2620
2701
|
mode: t.mode,
|
|
2621
2702
|
speechInputMode: t.speechInputMode,
|
|
2622
2703
|
speechOnly: t.speechOnly,
|
|
2704
|
+
previewBackground: t.previewBackground,
|
|
2705
|
+
previewForeground: t.previewForeground,
|
|
2623
2706
|
attribution: t.attribution,
|
|
2624
2707
|
alreadyConverted: t.alreadyConverted,
|
|
2625
2708
|
ui: t.ui,
|
|
@@ -2643,6 +2726,8 @@ var Cn = class e {
|
|
|
2643
2726
|
mode: t.mode,
|
|
2644
2727
|
speechInputMode: t.speechInputMode,
|
|
2645
2728
|
speechOnly: t.speechOnly,
|
|
2729
|
+
previewBackground: t.previewBackground,
|
|
2730
|
+
previewForeground: t.previewForeground,
|
|
2646
2731
|
attribution: t.attribution,
|
|
2647
2732
|
alreadyConverted: t.alreadyConverted,
|
|
2648
2733
|
ui: t.ui,
|
|
@@ -2659,7 +2744,7 @@ var Cn = class e {
|
|
|
2659
2744
|
return null;
|
|
2660
2745
|
}
|
|
2661
2746
|
on(e, t) {
|
|
2662
|
-
let n =
|
|
2747
|
+
let n = qt(this.eventRegistry, e, t);
|
|
2663
2748
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), e === "sessionMinted" && this.sessionMintedEnvelope && queueMicrotask(() => t(this.sessionMintedEnvelope)), n;
|
|
2664
2749
|
}
|
|
2665
2750
|
async attach(e) {
|
|
@@ -2673,13 +2758,13 @@ var Cn = class e {
|
|
|
2673
2758
|
if (this.closed) throw Error("Session has ended.");
|
|
2674
2759
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2675
2760
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2676
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2761
|
+
let t = this.bootstrap.embedBaseUrl ?? zt(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = Vt(t, n, r ? void 0 : Bt(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, jn(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize, e.stage, e.pipBackground, e.pipShadow, r ? void 0 : this.bootstrap.previewBackground, r ? void 0 : this.bootstrap.previewForeground), a = Ut(i), o = null, s = new Promise((e) => {
|
|
2677
2762
|
o = e;
|
|
2678
2763
|
}), c = null, l = new Promise((e) => {
|
|
2679
2764
|
c = e;
|
|
2680
|
-
}), u =
|
|
2765
|
+
}), u = Pt((e) => {
|
|
2681
2766
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
2682
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2767
|
+
}), d = this.bootstrap.onUserTranscript, f = Nt({
|
|
2683
2768
|
container: e.container,
|
|
2684
2769
|
src: i,
|
|
2685
2770
|
playerOrigin: a,
|
|
@@ -2742,10 +2827,11 @@ var Cn = class e {
|
|
|
2742
2827
|
onWidgetAudioSettings: (t) => e.onWidgetAudioSettings?.(t),
|
|
2743
2828
|
onWidgetDragStart: (t) => e.onWidgetDragStart?.(t),
|
|
2744
2829
|
onWidgetDragMove: (t) => e.onWidgetDragMove?.(t),
|
|
2745
|
-
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
2830
|
+
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t),
|
|
2831
|
+
onTheatreChange: (t) => e.onTheatreChange?.(t)
|
|
2746
2832
|
});
|
|
2747
2833
|
this.iframeHost = f;
|
|
2748
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
2834
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), ut(this.bootstrap.sessionEndpoint, {
|
|
2749
2835
|
experienceId: this.bootstrap.experienceId,
|
|
2750
2836
|
locale: this.bootstrap.locale,
|
|
2751
2837
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -2757,7 +2843,7 @@ var Cn = class e {
|
|
|
2757
2843
|
attribution: this.bootstrap.attribution,
|
|
2758
2844
|
alreadyConverted: this.bootstrap.alreadyConverted,
|
|
2759
2845
|
signal: this.endpointAbortController.signal
|
|
2760
|
-
})) : this.bootstrap.kind === "public" ?
|
|
2846
|
+
})) : this.bootstrap.kind === "public" ? lt(this.bootstrap.experienceId, {
|
|
2761
2847
|
locale: this.bootstrap.locale,
|
|
2762
2848
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
2763
2849
|
learningLocale: this.bootstrap.learningLocale,
|
|
@@ -2781,7 +2867,7 @@ var Cn = class e {
|
|
|
2781
2867
|
operation: "attach",
|
|
2782
2868
|
message: e instanceof Error ? e.message : String(e),
|
|
2783
2869
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2784
|
-
release:
|
|
2870
|
+
release: Ft
|
|
2785
2871
|
});
|
|
2786
2872
|
} catch {}
|
|
2787
2873
|
throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), e;
|
|
@@ -2793,16 +2879,20 @@ var Cn = class e {
|
|
|
2793
2879
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
2794
2880
|
this.launchToken = g;
|
|
2795
2881
|
let v = _ ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
2796
|
-
return v && !this.sessionMintedEnvelope && (this.resolvedSession = v, this.sessionMintedEnvelope = this.emitWrapped("sessionMinted", { session: v })), _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" &&
|
|
2882
|
+
return v && !this.sessionMintedEnvelope && (this.resolvedSession = v, this.sessionMintedEnvelope = this.emitWrapped("sessionMinted", { session: v })), _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && tt(_), f.postLaunch(g, _, {
|
|
2797
2883
|
startButton: e.startButton,
|
|
2798
2884
|
theme: e.theme,
|
|
2799
2885
|
showFeedback: e.showFeedback,
|
|
2800
|
-
interaction: e.interaction
|
|
2886
|
+
interaction: e.interaction,
|
|
2887
|
+
...e.theatreButton ? { theatreButton: !0 } : {},
|
|
2888
|
+
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
2801
2889
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
2802
2890
|
startButton: e.startButton,
|
|
2803
2891
|
theme: e.theme,
|
|
2804
2892
|
showFeedback: e.showFeedback,
|
|
2805
|
-
interaction: e.interaction
|
|
2893
|
+
interaction: e.interaction,
|
|
2894
|
+
...e.theatreButton ? { theatreButton: !0 } : {},
|
|
2895
|
+
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
2806
2896
|
}), await Promise.race([s, new Promise((e, t) => {
|
|
2807
2897
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
2808
2898
|
})]).catch((e) => {
|
|
@@ -2813,7 +2903,7 @@ var Cn = class e {
|
|
|
2813
2903
|
operation: "attach",
|
|
2814
2904
|
message: e instanceof Error ? e.message : String(e),
|
|
2815
2905
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2816
|
-
release:
|
|
2906
|
+
release: Ft
|
|
2817
2907
|
});
|
|
2818
2908
|
} catch {}
|
|
2819
2909
|
throw e;
|
|
@@ -2827,11 +2917,11 @@ var Cn = class e {
|
|
|
2827
2917
|
operation: "attach",
|
|
2828
2918
|
message: e instanceof Error ? e.message : String(e),
|
|
2829
2919
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2830
|
-
release:
|
|
2920
|
+
release: Ft
|
|
2831
2921
|
});
|
|
2832
2922
|
} catch {}
|
|
2833
2923
|
throw e;
|
|
2834
|
-
}), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.pendingStage && await f.setStage(this.pendingStage), this.pendingPipBackground && await f.setPipBackground(this.pendingPipBackground), this.pendingPipShadow !== null && await f.setPipShadow(this.pendingPipShadow), this.createPlayerFacade();
|
|
2924
|
+
}), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.pendingStage && await f.setStage(this.pendingStage), this.pendingPipBackground && await f.setPipBackground(this.pendingPipBackground), this.pendingPipShadow !== null && await f.setPipShadow(this.pendingPipShadow), this.pendingTheatre !== null && f.postSetTheatre(this.pendingTheatre), this.createPlayerFacade();
|
|
2835
2925
|
}
|
|
2836
2926
|
async startListening() {
|
|
2837
2927
|
this.assertSessionStarted(), await this.iframeHost.startListening();
|
|
@@ -2845,6 +2935,10 @@ var Cn = class e {
|
|
|
2845
2935
|
getConversation() {
|
|
2846
2936
|
return this.conversationCache;
|
|
2847
2937
|
}
|
|
2938
|
+
setTheatre(e) {
|
|
2939
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2940
|
+
this.pendingTheatre = e, this.iframeHost?.postSetTheatre(e);
|
|
2941
|
+
}
|
|
2848
2942
|
setWidgetChrome(e) {
|
|
2849
2943
|
this.iframeHost?.postWidgetSetChrome(e);
|
|
2850
2944
|
}
|
|
@@ -2855,7 +2949,7 @@ var Cn = class e {
|
|
|
2855
2949
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2856
2950
|
}
|
|
2857
2951
|
async setFit(e) {
|
|
2858
|
-
let t =
|
|
2952
|
+
let t = An(e);
|
|
2859
2953
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2860
2954
|
if (this.closed) throw Error("Session has ended.");
|
|
2861
2955
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
@@ -2905,7 +2999,7 @@ var Cn = class e {
|
|
|
2905
2999
|
this.close();
|
|
2906
3000
|
}
|
|
2907
3001
|
destroy() {
|
|
2908
|
-
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,
|
|
3002
|
+
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, Yt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.lastInteraction = null, this.attached = !1);
|
|
2909
3003
|
}
|
|
2910
3004
|
resolveMintInteraction() {
|
|
2911
3005
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2917,8 +3011,8 @@ var Cn = class e {
|
|
|
2917
3011
|
return this.resolvedSession?.id ?? "";
|
|
2918
3012
|
}
|
|
2919
3013
|
emitWrapped(e, t) {
|
|
2920
|
-
let n =
|
|
2921
|
-
return
|
|
3014
|
+
let n = Gt(e, this.getSessionId(), t);
|
|
3015
|
+
return Jt(this.eventRegistry, e, n), n;
|
|
2922
3016
|
}
|
|
2923
3017
|
queueProcessorTurn(e) {
|
|
2924
3018
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2927,7 +3021,7 @@ var Cn = class e {
|
|
|
2927
3021
|
let n = this.processorAbortController.signal;
|
|
2928
3022
|
this.processorChain = this.processorChain.then(async () => {
|
|
2929
3023
|
if (!n.aborted) try {
|
|
2930
|
-
let r = await
|
|
3024
|
+
let r = await pt(t, {
|
|
2931
3025
|
utteranceId: e.utteranceId,
|
|
2932
3026
|
text: e.text,
|
|
2933
3027
|
conversation: this.conversationCache,
|
|
@@ -2977,7 +3071,7 @@ var Cn = class e {
|
|
|
2977
3071
|
};
|
|
2978
3072
|
}
|
|
2979
3073
|
};
|
|
2980
|
-
function
|
|
3074
|
+
function Nn(e) {
|
|
2981
3075
|
return e ? {
|
|
2982
3076
|
textSpeech: e.capabilities.speech.output,
|
|
2983
3077
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2988,41 +3082,41 @@ function wn(e) {
|
|
|
2988
3082
|
}
|
|
2989
3083
|
//#endregion
|
|
2990
3084
|
//#region src/widget/dockGeometry.ts
|
|
2991
|
-
var
|
|
2992
|
-
function
|
|
3085
|
+
var Pn = "(min-width: 768px)", Fn = 24, In = .5, Ln = 1200, Rn = .85, zn = 9 / 16;
|
|
3086
|
+
function Bn() {
|
|
2993
3087
|
if (typeof window > "u") return 800;
|
|
2994
3088
|
let e = window.screen?.availHeight;
|
|
2995
3089
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2996
3090
|
}
|
|
2997
|
-
function
|
|
2998
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2999
|
-
return s > a && (s = a, o = s /
|
|
3091
|
+
function Vn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Fn, r = typeof window < "u" ? Bn() : 800) {
|
|
3092
|
+
let i = Math.max(160, Math.min(t - n * 2, t * Rn)), a = Math.max(120, e - n * 2), o = Math.min(r * In, Ln, i), s = o * zn;
|
|
3093
|
+
return s > a && (s = a, o = s / zn, o > i && (o = i, s = o * zn)), {
|
|
3000
3094
|
width: Math.round(s),
|
|
3001
3095
|
height: Math.round(o)
|
|
3002
3096
|
};
|
|
3003
3097
|
}
|
|
3004
|
-
function
|
|
3098
|
+
function Hn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Fn) {
|
|
3005
3099
|
return {
|
|
3006
3100
|
left: Math.max(r, t - e.width - r),
|
|
3007
3101
|
top: Math.max(r, n - e.height - r)
|
|
3008
3102
|
};
|
|
3009
3103
|
}
|
|
3010
|
-
function
|
|
3104
|
+
function Un(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Fn) {
|
|
3011
3105
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
3012
3106
|
return {
|
|
3013
3107
|
left: Math.min(Math.max(a, e), o),
|
|
3014
3108
|
top: Math.min(Math.max(a, t), s)
|
|
3015
3109
|
};
|
|
3016
3110
|
}
|
|
3017
|
-
function
|
|
3018
|
-
return e(
|
|
3111
|
+
function Wn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
3112
|
+
return e(Pn).matches;
|
|
3019
3113
|
}
|
|
3020
3114
|
//#endregion
|
|
3021
3115
|
//#region src/widget/mountExperienceWidget.ts
|
|
3022
|
-
function
|
|
3116
|
+
function Gn(e) {
|
|
3023
3117
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
3024
3118
|
}
|
|
3025
|
-
function
|
|
3119
|
+
function Kn(e) {
|
|
3026
3120
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
3027
3121
|
let t = typeof e == "string" ? e.trim() : "";
|
|
3028
3122
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -3030,9 +3124,9 @@ function Ln(e) {
|
|
|
3030
3124
|
function $(e) {
|
|
3031
3125
|
return e === "expanded" || e === "docked";
|
|
3032
3126
|
}
|
|
3033
|
-
var
|
|
3034
|
-
function
|
|
3035
|
-
|
|
3127
|
+
var qn = "<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>", Jn = "<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>", Yn = "<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>", Xn = "<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>";
|
|
3128
|
+
function Zn(e, t, n) {
|
|
3129
|
+
xe(ye);
|
|
3036
3130
|
let r = F({
|
|
3037
3131
|
galleryThumb: t.galleryThumb,
|
|
3038
3132
|
avatarImage: t.avatarImage,
|
|
@@ -3059,9 +3153,9 @@ function Hn(e, t, n) {
|
|
|
3059
3153
|
let e = document.createElement("img");
|
|
3060
3154
|
e.className = "liforma-et__foreground liforma-et__media", e.alt = "", e.decoding = "async", e.src = r.foregroundImage, e.addEventListener("load", () => o(e), { once: !0 }), i.append(e);
|
|
3061
3155
|
}
|
|
3062
|
-
return e.replaceChildren(i), n?.parallax === !1 ? () => {} :
|
|
3156
|
+
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ve(i);
|
|
3063
3157
|
}
|
|
3064
|
-
function
|
|
3158
|
+
function Qn(e) {
|
|
3065
3159
|
return e.startButton ? {
|
|
3066
3160
|
...e.startButton,
|
|
3067
3161
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -3073,7 +3167,7 @@ function Un(e) {
|
|
|
3073
3167
|
variant: "primary"
|
|
3074
3168
|
};
|
|
3075
3169
|
}
|
|
3076
|
-
function
|
|
3170
|
+
function $n(e) {
|
|
3077
3171
|
let t = !1, n = () => {
|
|
3078
3172
|
t || e();
|
|
3079
3173
|
}, r = () => {
|
|
@@ -3093,12 +3187,12 @@ function Wn(e) {
|
|
|
3093
3187
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
3094
3188
|
};
|
|
3095
3189
|
}
|
|
3096
|
-
function
|
|
3097
|
-
|
|
3190
|
+
function er(e, t) {
|
|
3191
|
+
Pe(Me);
|
|
3098
3192
|
let n = t.experienceId?.trim();
|
|
3099
3193
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
3100
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
3101
|
-
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",
|
|
3194
|
+
let r = t.prefetch ?? "onExpand", i = Gn(t.position), a = document.createElement("div");
|
|
3195
|
+
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", Kn(t.offset));
|
|
3102
3196
|
let o = document.createElement("button");
|
|
3103
3197
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
3104
3198
|
let s = document.createElement("div");
|
|
@@ -3118,11 +3212,11 @@ function Gn(e, t) {
|
|
|
3118
3212
|
let m = document.createElement("span");
|
|
3119
3213
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
3120
3214
|
let h = document.createElement("button");
|
|
3121
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
3215
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = Yn, h.setAttribute("aria-label", "Reduce");
|
|
3122
3216
|
let g = document.createElement("button");
|
|
3123
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
3217
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = qn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
3124
3218
|
let _ = document.createElement("button");
|
|
3125
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
3219
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = Jn, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
3126
3220
|
let v = document.createElement("div");
|
|
3127
3221
|
v.className = "liforma-ew__stage";
|
|
3128
3222
|
let y = document.createElement("div");
|
|
@@ -3150,11 +3244,11 @@ function Gn(e, t) {
|
|
|
3150
3244
|
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";
|
|
3151
3245
|
}, se = (e, t) => {
|
|
3152
3246
|
if (R() !== "docked") return;
|
|
3153
|
-
let n =
|
|
3247
|
+
let n = Vn(), r = Un(e - te, t - I, n);
|
|
3154
3248
|
N = r.left, P = r.top, oe(r.left, r.top, n.width, n.height);
|
|
3155
3249
|
}, ce = (e, t) => {
|
|
3156
3250
|
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
3157
|
-
let n =
|
|
3251
|
+
let n = Vn(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = Un(r + e, i + t, n);
|
|
3158
3252
|
N = a.left, P = a.top, oe(a.left, a.top, n.width, n.height);
|
|
3159
3253
|
}, le = (e) => {
|
|
3160
3254
|
L === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), se(e.clientX, e.clientY)));
|
|
@@ -3163,12 +3257,12 @@ function Gn(e, t) {
|
|
|
3163
3257
|
let t = L;
|
|
3164
3258
|
F = null, L = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && ne && (ne = !1, window.removeEventListener("pointermove", le), window.removeEventListener("pointerup", V), window.removeEventListener("pointercancel", V));
|
|
3165
3259
|
}, ue = (e, t, n) => {
|
|
3166
|
-
if (S || R() !== "docked" || !
|
|
3260
|
+
if (S || R() !== "docked" || !Wn() || F !== null) return;
|
|
3167
3261
|
F = n, L = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3168
3262
|
let r = f.getBoundingClientRect();
|
|
3169
3263
|
te = e - r.left, I = t - r.top, ne || (ne = !0, window.addEventListener("pointermove", le), window.addEventListener("pointerup", V), window.addEventListener("pointercancel", V));
|
|
3170
3264
|
}, de = (e) => {
|
|
3171
|
-
if (S || R() !== "docked" || !
|
|
3265
|
+
if (S || R() !== "docked" || !Wn() || F !== null) return;
|
|
3172
3266
|
F = e.pointerId, L = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3173
3267
|
let t = f.getBoundingClientRect();
|
|
3174
3268
|
N = t.left, P = t.top;
|
|
@@ -3177,15 +3271,15 @@ function Gn(e, t) {
|
|
|
3177
3271
|
}, pe = (e) => {
|
|
3178
3272
|
L === "player" && (F === null || e.pointerId !== F || V());
|
|
3179
3273
|
}, H = () => {
|
|
3180
|
-
let e =
|
|
3274
|
+
let e = Wn(), t = R();
|
|
3181
3275
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
3182
3276
|
h.hidden = !0;
|
|
3183
3277
|
return;
|
|
3184
3278
|
}
|
|
3185
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
3279
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = Xn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = Yn, h.setAttribute("aria-label", "Reduce"));
|
|
3186
3280
|
}, me = (e) => {
|
|
3187
|
-
let t =
|
|
3188
|
-
n =
|
|
3281
|
+
let t = Vn(), n = e && N !== null && P !== null ? Un(N, P, t) : Hn(t);
|
|
3282
|
+
n = Un(n.left, n.top, t), N = n.left, P = n.top, oe(n.left, n.top, t.width, t.height), H();
|
|
3189
3283
|
}, U = () => {
|
|
3190
3284
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
3191
3285
|
requestAnimationFrame(() => {
|
|
@@ -3208,48 +3302,48 @@ function Gn(e, t) {
|
|
|
3208
3302
|
z(), M = setTimeout(() => {
|
|
3209
3303
|
M = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
3210
3304
|
}, 280);
|
|
3211
|
-
})),
|
|
3305
|
+
})), G = {
|
|
3212
3306
|
galleryThumb: t.galleryThumb,
|
|
3213
3307
|
avatarImage: t.avatarImage,
|
|
3214
3308
|
backgroundImage: t.backgroundImage,
|
|
3215
3309
|
foregroundImage: t.foregroundImage,
|
|
3216
3310
|
fallbackImage: t.fallbackImage
|
|
3217
|
-
},
|
|
3311
|
+
}, K = (e) => {
|
|
3218
3312
|
if (!e) {
|
|
3219
3313
|
y.hidden = !0, y.textContent = "";
|
|
3220
3314
|
return;
|
|
3221
3315
|
}
|
|
3222
3316
|
y.hidden = !1, y.textContent = e;
|
|
3223
|
-
},
|
|
3317
|
+
}, ge = (e) => {
|
|
3224
3318
|
if (!e) {
|
|
3225
3319
|
c.hidden = !0, c.textContent = "";
|
|
3226
3320
|
return;
|
|
3227
3321
|
}
|
|
3228
3322
|
c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
|
|
3323
|
+
}, _e = () => {
|
|
3324
|
+
C = !0, o.disabled = !1, ge(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
3229
3325
|
}, ve = () => {
|
|
3230
|
-
C = !0, o.disabled = !1, _e(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
3231
|
-
}, ye = () => {
|
|
3232
3326
|
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
3233
|
-
},
|
|
3327
|
+
}, ye = (e) => {
|
|
3234
3328
|
A?.(), A = null;
|
|
3235
|
-
let t =
|
|
3329
|
+
let t = Zn(s, e, { parallax: ie });
|
|
3236
3330
|
return t ? (A = t, !0) : !1;
|
|
3237
|
-
},
|
|
3238
|
-
if (
|
|
3239
|
-
|
|
3331
|
+
}, be = () => {
|
|
3332
|
+
if (ye(G)) {
|
|
3333
|
+
_e();
|
|
3240
3334
|
return;
|
|
3241
3335
|
}
|
|
3242
|
-
|
|
3336
|
+
ge("Loading…"), ze(n, { signal: re.signal }).then((e) => {
|
|
3243
3337
|
if (!S) {
|
|
3244
|
-
if (!
|
|
3245
|
-
|
|
3338
|
+
if (!ye({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
|
|
3339
|
+
_e();
|
|
3246
3340
|
}
|
|
3247
3341
|
}).catch((e) => {
|
|
3248
3342
|
if (S || re.signal.aborted) return;
|
|
3249
3343
|
let n = e instanceof Error ? e : Error(String(e));
|
|
3250
|
-
|
|
3344
|
+
ge("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
|
|
3251
3345
|
});
|
|
3252
|
-
},
|
|
3346
|
+
}, xe = () => ({
|
|
3253
3347
|
experienceId: n,
|
|
3254
3348
|
ui: "widget",
|
|
3255
3349
|
...t.sessionEndpoint ? { sessionEndpoint: t.sessionEndpoint } : {},
|
|
@@ -3262,77 +3356,77 @@ function Gn(e, t) {
|
|
|
3262
3356
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
3263
3357
|
...t.alreadyConverted?.length ? { alreadyConverted: t.alreadyConverted } : {},
|
|
3264
3358
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
3265
|
-
}),
|
|
3359
|
+
}), Se = () => ({
|
|
3266
3360
|
...t.fit ? { fit: t.fit } : {},
|
|
3267
|
-
startButton:
|
|
3361
|
+
startButton: Qn(t),
|
|
3268
3362
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback },
|
|
3269
3363
|
...t.interaction ? { interaction: t.interaction } : {}
|
|
3270
|
-
}),
|
|
3271
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ae(), a.dataset.state = "expanded",
|
|
3272
|
-
},
|
|
3273
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked",
|
|
3274
|
-
},
|
|
3364
|
+
}), Ce = (e = !0) => {
|
|
3365
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ae(), a.dataset.state = "expanded", K(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), H(), e && t.onExpanded?.();
|
|
3366
|
+
}, we = () => {
|
|
3367
|
+
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), me(!0), H(), b?.setWidgetChrome("docked");
|
|
3368
|
+
}, Te = (e) => {
|
|
3275
3369
|
e.on("started", () => {
|
|
3276
|
-
S || (D = !0, a.dataset.live = "true",
|
|
3370
|
+
S || (D = !0, a.dataset.live = "true", K(null), t.onStarted?.(), $(a.dataset.state) && U());
|
|
3277
3371
|
}), e.on("feedback", (e) => {
|
|
3278
3372
|
S || t.onFeedback?.(e);
|
|
3279
3373
|
}), e.on("feedbackFailed", (e) => {
|
|
3280
3374
|
S || t.onFeedbackFailed?.(e);
|
|
3281
3375
|
});
|
|
3282
|
-
},
|
|
3283
|
-
B(), u.hidden = !0, p.hidden = !0, ae(), 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),
|
|
3284
|
-
},
|
|
3376
|
+
}, Ee = () => {
|
|
3377
|
+
B(), u.hidden = !0, p.hidden = !0, ae(), 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), H();
|
|
3378
|
+
}, De = () => {
|
|
3285
3379
|
z(), B(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
|
|
3286
3380
|
let e = b;
|
|
3287
3381
|
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");
|
|
3288
|
-
},
|
|
3382
|
+
}, Oe = () => {
|
|
3289
3383
|
if (!S && $(a.dataset.state)) {
|
|
3290
3384
|
if (V(), x = !1, b && E) {
|
|
3291
3385
|
let e = b;
|
|
3292
3386
|
(async () => {
|
|
3293
|
-
D && (await he(), S || b !== e) || (w && e.setWidgetChrome("collapsed"),
|
|
3387
|
+
D && (await he(), S || b !== e) || (w && e.setWidgetChrome("collapsed"), Ee(), D ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : w && ve(), t.onCollapsed?.(), t.onClose?.());
|
|
3294
3388
|
})();
|
|
3295
3389
|
return;
|
|
3296
3390
|
}
|
|
3297
|
-
|
|
3391
|
+
De(), Ee(), t.onCollapsed?.(), t.onClose?.();
|
|
3298
3392
|
}
|
|
3299
|
-
},
|
|
3300
|
-
S ||
|
|
3301
|
-
|
|
3393
|
+
}, ke = () => {
|
|
3394
|
+
S || Wn() && R() === "expanded" && W(() => {
|
|
3395
|
+
we();
|
|
3302
3396
|
});
|
|
3303
|
-
},
|
|
3397
|
+
}, Ae = () => {
|
|
3304
3398
|
S || R() === "docked" && (V(), W(() => {
|
|
3305
|
-
ae(),
|
|
3399
|
+
ae(), Ce(!1), b?.setWidgetChrome("expanded");
|
|
3306
3400
|
}));
|
|
3401
|
+
}, je = () => {
|
|
3402
|
+
!b || !D || (z(), a.classList.remove("liforma-ew--session-revealed"), Ce(), b.setWidgetChrome("expanded"), x = !1, U());
|
|
3307
3403
|
}, Ne = () => {
|
|
3308
|
-
!b || !D || (z(), a.classList.remove("liforma-ew--session-revealed"),
|
|
3309
|
-
}, Pe = () => {
|
|
3310
|
-
!b || !E || D || (z(), a.classList.remove("liforma-ew--session-revealed"), we(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
3404
|
+
!b || !E || D || (z(), a.classList.remove("liforma-ew--session-revealed"), Ce(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
3311
3405
|
}, Fe = (e) => {
|
|
3312
|
-
S || e !== O && !D || (z(), a.classList.remove("liforma-ew--session-revealed"),
|
|
3313
|
-
},
|
|
3406
|
+
S || e !== O && !D || (z(), a.classList.remove("liforma-ew--session-revealed"), Ce(), x = !1, D && U());
|
|
3407
|
+
}, q = () => {
|
|
3314
3408
|
if (S || T || w || b || $(a.dataset.state)) return;
|
|
3315
3409
|
T = !0;
|
|
3316
3410
|
let e = O;
|
|
3317
3411
|
l.hidden = !1, (async () => {
|
|
3318
3412
|
try {
|
|
3319
|
-
let t = await
|
|
3413
|
+
let t = await Mn.startSession(xe());
|
|
3320
3414
|
if (S || e !== O) {
|
|
3321
3415
|
t.destroy();
|
|
3322
3416
|
return;
|
|
3323
3417
|
}
|
|
3324
|
-
b = t,
|
|
3418
|
+
b = t, Te(t);
|
|
3325
3419
|
let n = await t.attach({
|
|
3326
3420
|
container: l,
|
|
3327
|
-
...
|
|
3421
|
+
...Se(),
|
|
3328
3422
|
onWidgetReady: () => {
|
|
3329
|
-
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") :
|
|
3423
|
+
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : ve());
|
|
3330
3424
|
},
|
|
3331
3425
|
onWidgetExpand: () => {
|
|
3332
3426
|
Fe(e);
|
|
3333
3427
|
},
|
|
3334
3428
|
onWidgetAudioSettings: (e) => {
|
|
3335
|
-
S ||
|
|
3429
|
+
S || J(e);
|
|
3336
3430
|
},
|
|
3337
3431
|
onWidgetDragStart: (e) => {
|
|
3338
3432
|
S || de(e);
|
|
@@ -3344,7 +3438,7 @@ function Gn(e, t) {
|
|
|
3344
3438
|
S || pe(e);
|
|
3345
3439
|
},
|
|
3346
3440
|
onPlayerStatusChange: (e) => {
|
|
3347
|
-
S || e === "error" && $(a.dataset.state) &&
|
|
3441
|
+
S || e === "error" && $(a.dataset.state) && K("Could not load the experience.");
|
|
3348
3442
|
}
|
|
3349
3443
|
});
|
|
3350
3444
|
if (S || e !== O) {
|
|
@@ -3352,7 +3446,7 @@ function Gn(e, t) {
|
|
|
3352
3446
|
return;
|
|
3353
3447
|
}
|
|
3354
3448
|
n.on("close", () => {
|
|
3355
|
-
S ||
|
|
3449
|
+
S || Oe();
|
|
3356
3450
|
});
|
|
3357
3451
|
} catch (n) {
|
|
3358
3452
|
if (S || e !== O) return;
|
|
@@ -3361,31 +3455,31 @@ function Gn(e, t) {
|
|
|
3361
3455
|
t.onError?.(r), console.error("[ExperienceWidget] warm prefetch failed", r);
|
|
3362
3456
|
}
|
|
3363
3457
|
})();
|
|
3364
|
-
},
|
|
3458
|
+
}, Ie = () => {
|
|
3365
3459
|
if (S || x || !C || $(a.dataset.state)) return;
|
|
3366
3460
|
if (b && D) {
|
|
3367
|
-
|
|
3461
|
+
je();
|
|
3368
3462
|
return;
|
|
3369
3463
|
}
|
|
3370
3464
|
if (b && E) {
|
|
3371
|
-
|
|
3465
|
+
Ne();
|
|
3372
3466
|
return;
|
|
3373
3467
|
}
|
|
3374
3468
|
let e = ++O;
|
|
3375
3469
|
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 () => {
|
|
3376
3470
|
try {
|
|
3377
|
-
|
|
3378
|
-
let t = await
|
|
3471
|
+
Ce();
|
|
3472
|
+
let t = await Mn.startSession(xe());
|
|
3379
3473
|
if (S || e !== O) {
|
|
3380
3474
|
t.destroy();
|
|
3381
3475
|
return;
|
|
3382
3476
|
}
|
|
3383
|
-
b = t,
|
|
3477
|
+
b = t, Te(t);
|
|
3384
3478
|
let n = await t.attach({
|
|
3385
3479
|
container: v,
|
|
3386
|
-
...
|
|
3480
|
+
...Se(),
|
|
3387
3481
|
onWidgetAudioSettings: (e) => {
|
|
3388
|
-
S ||
|
|
3482
|
+
S || J(e);
|
|
3389
3483
|
},
|
|
3390
3484
|
onWidgetDragStart: (e) => {
|
|
3391
3485
|
S || de(e);
|
|
@@ -3397,7 +3491,7 @@ function Gn(e, t) {
|
|
|
3397
3491
|
S || pe(e);
|
|
3398
3492
|
},
|
|
3399
3493
|
onPlayerStatusChange: (e) => {
|
|
3400
|
-
S || (e === "error" ?
|
|
3494
|
+
S || (e === "error" ? K("Could not load the experience.") : $(a.dataset.state) && K(null));
|
|
3401
3495
|
}
|
|
3402
3496
|
});
|
|
3403
3497
|
if (S || e !== O) {
|
|
@@ -3405,12 +3499,12 @@ function Gn(e, t) {
|
|
|
3405
3499
|
return;
|
|
3406
3500
|
}
|
|
3407
3501
|
E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
3408
|
-
S ||
|
|
3502
|
+
S || Oe();
|
|
3409
3503
|
});
|
|
3410
3504
|
} catch (n) {
|
|
3411
3505
|
if (S || e !== O) return;
|
|
3412
3506
|
let r = n instanceof Error ? n : Error(String(n));
|
|
3413
|
-
|
|
3507
|
+
K(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
|
|
3414
3508
|
} finally {
|
|
3415
3509
|
e === O && (x = !1);
|
|
3416
3510
|
}
|
|
@@ -3418,38 +3512,38 @@ function Gn(e, t) {
|
|
|
3418
3512
|
}, Le = () => {
|
|
3419
3513
|
if (!(S || $(a.dataset.state))) {
|
|
3420
3514
|
if (b && D) {
|
|
3421
|
-
|
|
3515
|
+
je();
|
|
3422
3516
|
return;
|
|
3423
3517
|
}
|
|
3424
3518
|
if (b && E) {
|
|
3425
|
-
|
|
3519
|
+
Ne();
|
|
3426
3520
|
return;
|
|
3427
3521
|
}
|
|
3428
3522
|
if (T || b) {
|
|
3429
|
-
|
|
3523
|
+
Ce();
|
|
3430
3524
|
return;
|
|
3431
3525
|
}
|
|
3432
|
-
|
|
3526
|
+
Ie();
|
|
3433
3527
|
}
|
|
3434
3528
|
}, Re = (e) => {
|
|
3435
3529
|
if (e.stopPropagation(), R() === "expanded") {
|
|
3436
|
-
|
|
3530
|
+
ke();
|
|
3437
3531
|
return;
|
|
3438
3532
|
}
|
|
3439
|
-
R() === "docked" &&
|
|
3440
|
-
},
|
|
3533
|
+
R() === "docked" && Ae();
|
|
3534
|
+
}, J = (e) => {
|
|
3441
3535
|
g.setAttribute("aria-pressed", e ? "true" : "false");
|
|
3442
3536
|
}, Be = (e) => {
|
|
3443
3537
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
3444
3538
|
}, Ve = (e) => {
|
|
3445
|
-
R() === "docked" &&
|
|
3446
|
-
},
|
|
3447
|
-
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(),
|
|
3448
|
-
},
|
|
3539
|
+
R() === "docked" && Wn() && (e.target?.closest("button") || (e.preventDefault(), ue(e.clientX, e.clientY, e.pointerId)));
|
|
3540
|
+
}, He = (e) => {
|
|
3541
|
+
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), Oe());
|
|
3542
|
+
}, Ue = () => {
|
|
3449
3543
|
if (!S) {
|
|
3450
3544
|
if (R() === "docked") {
|
|
3451
|
-
if (!
|
|
3452
|
-
|
|
3545
|
+
if (!Wn()) {
|
|
3546
|
+
Ae();
|
|
3453
3547
|
return;
|
|
3454
3548
|
}
|
|
3455
3549
|
D ? W(() => {
|
|
@@ -3459,47 +3553,47 @@ function Gn(e, t) {
|
|
|
3459
3553
|
}
|
|
3460
3554
|
H();
|
|
3461
3555
|
}
|
|
3462
|
-
},
|
|
3556
|
+
}, Y = typeof window < "u" ? window.matchMedia(Pn) : null, We = () => {
|
|
3463
3557
|
if (!S) {
|
|
3464
|
-
if (R() === "docked" && !
|
|
3465
|
-
|
|
3558
|
+
if (R() === "docked" && !Wn()) {
|
|
3559
|
+
Ae();
|
|
3466
3560
|
return;
|
|
3467
3561
|
}
|
|
3468
3562
|
H();
|
|
3469
3563
|
}
|
|
3470
3564
|
};
|
|
3471
|
-
return o.addEventListener("click", Le), d.addEventListener("click",
|
|
3472
|
-
e.stopPropagation(),
|
|
3473
|
-
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown",
|
|
3474
|
-
S ||
|
|
3475
|
-
}) : r === "idle" && (j =
|
|
3476
|
-
S ||
|
|
3565
|
+
return o.addEventListener("click", Le), d.addEventListener("click", Oe), _.addEventListener("click", (e) => {
|
|
3566
|
+
e.stopPropagation(), Oe();
|
|
3567
|
+
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), Y?.addEventListener("change", We), be(), H(), r === "eager" ? queueMicrotask(() => {
|
|
3568
|
+
S || q();
|
|
3569
|
+
}) : r === "idle" && (j = $n(() => {
|
|
3570
|
+
S || q();
|
|
3477
3571
|
})), {
|
|
3478
3572
|
root: a,
|
|
3479
3573
|
expand: Le,
|
|
3480
|
-
collapse:
|
|
3481
|
-
dock:
|
|
3482
|
-
maximize:
|
|
3574
|
+
collapse: Oe,
|
|
3575
|
+
dock: ke,
|
|
3576
|
+
maximize: Ae,
|
|
3483
3577
|
prefetch() {
|
|
3484
3578
|
if (r === "onExpand") {
|
|
3485
|
-
|
|
3579
|
+
q();
|
|
3486
3580
|
return;
|
|
3487
3581
|
}
|
|
3488
|
-
|
|
3582
|
+
q();
|
|
3489
3583
|
},
|
|
3490
3584
|
destroy() {
|
|
3491
|
-
S || (S = !0, V(), j?.(), j = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown",
|
|
3585
|
+
S || (S = !0, V(), j?.(), j = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown", He), window.removeEventListener("resize", Ue), Y?.removeEventListener("change", We), De(), Ee(), e.replaceChildren());
|
|
3492
3586
|
}
|
|
3493
3587
|
};
|
|
3494
3588
|
}
|
|
3495
3589
|
//#endregion
|
|
3496
3590
|
//#region src/react/ExperienceWidget.tsx
|
|
3497
|
-
function
|
|
3591
|
+
function tr(t) {
|
|
3498
3592
|
let r = n(null), { experienceId: i, alt: o, galleryThumb: s, avatarImage: c, backgroundImage: l, foregroundImage: u, fallbackImage: d, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, locale: _, secondaryLocale: v, learningLocale: y, language: b, mode: x, speechInputMode: S, speechOnly: C, fit: w, embedBaseUrl: T, expandedMaxWidth: E, expandedMaxHeight: D, startButtonLabel: O, startButton: k, showFeedback: A, className: j = "", onExpanded: M, onCollapsed: ee, onStarted: N, onClose: P, onError: F, onPrefetchReady: te, onFeedback: I, onFeedbackFailed: L } = t, ne = m === "bottom-right" || m === "bottom-left";
|
|
3499
3593
|
return e(() => {
|
|
3500
3594
|
let e = r.current;
|
|
3501
3595
|
if (!e || !i.trim()) return;
|
|
3502
|
-
let t =
|
|
3596
|
+
let t = er(e, {
|
|
3503
3597
|
experienceId: i,
|
|
3504
3598
|
alt: o,
|
|
3505
3599
|
galleryThumb: s,
|
|
@@ -3583,11 +3677,11 @@ function Kn(t) {
|
|
|
3583
3677
|
}
|
|
3584
3678
|
//#endregion
|
|
3585
3679
|
//#region src/next/index.ts
|
|
3586
|
-
function
|
|
3680
|
+
function nr(e = {}) {
|
|
3587
3681
|
let t = v(e);
|
|
3588
3682
|
return { POST: ({ request: e }) => t(e) };
|
|
3589
3683
|
}
|
|
3590
3684
|
//#endregion
|
|
3591
|
-
export {
|
|
3685
|
+
export { je as ExperienceThumbnail, tr as ExperienceWidget, v as createLiformaSessionRouteHandler, nr as createLiformaSvelteKitSessionHandler };
|
|
3592
3686
|
|
|
3593
3687
|
//# sourceMappingURL=index.js.map
|