@liforma/client 0.4.4 → 0.4.6
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 +24 -0
- package/dist/next/index.js +467 -379
- package/dist/next/index.js.map +1 -1
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts +8 -0
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts.map +1 -1
- package/dist/next/next/index.d.ts +8 -1
- package/dist/next/next/index.d.ts.map +1 -1
- package/dist/next/v2/api/captureAttribution.d.ts +10 -0
- package/dist/next/v2/api/captureAttribution.d.ts.map +1 -0
- package/dist/next/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/next/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/next/v2/api/sessionEndpointRequest.d.ts +1 -0
- package/dist/next/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/next/v2/embed/fullWindowHost.d.ts +20 -0
- package/dist/next/v2/embed/fullWindowHost.d.ts.map +1 -0
- package/dist/next/v2/embed/iframeHost.d.ts +4 -1
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +18 -1
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +14 -2
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/types/sessionInteraction.d.ts +49 -0
- package/dist/next/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/npm/index.js +559 -477
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/v2/api/captureAttribution.d.ts +10 -0
- package/dist/npm/v2/api/captureAttribution.d.ts.map +1 -0
- package/dist/npm/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/npm/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/npm/v2/api/sessionEndpointRequest.d.ts +1 -0
- package/dist/npm/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/npm/v2/embed/fullWindowHost.d.ts +20 -0
- package/dist/npm/v2/embed/fullWindowHost.d.ts.map +1 -0
- package/dist/npm/v2/embed/iframeHost.d.ts +4 -1
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +18 -1
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +14 -2
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/index.d.ts +1 -1
- package/dist/npm/v2/index.d.ts.map +1 -1
- package/dist/npm/v2/npm.d.ts +2 -1
- package/dist/npm/v2/npm.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionInteraction.d.ts +49 -0
- package/dist/npm/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts +9 -0
- package/dist/npm/v2/types/sessionManifestSchema.d.ts.map +1 -1
- package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentRuntime.d.ts +1 -0
- package/dist/react/component/experienceComponentRuntime.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +7 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +710 -621
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/v2/api/captureAttribution.d.ts +10 -0
- package/dist/react/v2/api/captureAttribution.d.ts.map +1 -0
- package/dist/react/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/react/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/react/v2/api/sessionEndpointRequest.d.ts +1 -0
- package/dist/react/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/react/v2/embed/fullWindowHost.d.ts +20 -0
- package/dist/react/v2/embed/fullWindowHost.d.ts.map +1 -0
- package/dist/react/v2/embed/iframeHost.d.ts +4 -1
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +18 -1
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +14 -2
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/types/sessionInteraction.d.ts +49 -0
- package/dist/react/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +6 -6
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +10 -0
- package/dist/svelte/Experience.svelte.d.ts +1 -0
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -49,6 +49,7 @@ function _(e) {
|
|
|
49
49
|
mode: e.mode,
|
|
50
50
|
speechInputMode: e.speechInputMode,
|
|
51
51
|
speechOnly: e.speechOnly,
|
|
52
|
+
attribution: e.attribution,
|
|
52
53
|
conversationProcessor: e.conversationProcessor
|
|
53
54
|
};
|
|
54
55
|
if (e.experienceId) return {
|
|
@@ -66,6 +67,7 @@ function _(e) {
|
|
|
66
67
|
mode: e.mode,
|
|
67
68
|
speechInputMode: e.speechInputMode,
|
|
68
69
|
speechOnly: e.speechOnly,
|
|
70
|
+
attribution: e.attribution,
|
|
69
71
|
conversationProcessor: e.conversationProcessor
|
|
70
72
|
};
|
|
71
73
|
throw Error("Experience requires experienceId, sessionEndpoint, or launch.");
|
|
@@ -82,6 +84,7 @@ function v(e) {
|
|
|
82
84
|
e.speechInputMode,
|
|
83
85
|
e.conversationProcessor ? g(e.conversationProcessor) : 0,
|
|
84
86
|
e.speechOnly,
|
|
87
|
+
e.attribution === !1 ? !1 : e.attribution,
|
|
85
88
|
e.avatarId,
|
|
86
89
|
e.backdropId,
|
|
87
90
|
e.locationId,
|
|
@@ -101,14 +104,14 @@ function S() {
|
|
|
101
104
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
102
105
|
} catch {}
|
|
103
106
|
}
|
|
104
|
-
function
|
|
107
|
+
function C(e) {
|
|
105
108
|
return y.exec(e)?.[1];
|
|
106
109
|
}
|
|
107
|
-
function
|
|
110
|
+
function w(e) {
|
|
108
111
|
return b.exec(e)?.[1];
|
|
109
112
|
}
|
|
110
|
-
function
|
|
111
|
-
let n = x(e).trim() || "Unknown error", r = t?.experienceId?.trim() ||
|
|
113
|
+
function T(e, t) {
|
|
114
|
+
let n = x(e).trim() || "Unknown error", r = t?.experienceId?.trim() || C(n) || void 0, i = t?.origin?.trim() || w(n) || S() || void 0;
|
|
112
115
|
return /No playable experience found/i.test(n) || /^Experience is not available\.?$/i.test(n) || /^Unknown experience\.?$/i.test(n) || /experience_unavailable/i.test(n) ? {
|
|
113
116
|
kind: "not_found",
|
|
114
117
|
title: "The application tried to load an avatar experience that doesn’t exist.",
|
|
@@ -141,7 +144,7 @@ function w(e, t) {
|
|
|
141
144
|
}
|
|
142
145
|
//#endregion
|
|
143
146
|
//#region src/component/experienceComponentRuntime.ts
|
|
144
|
-
function
|
|
147
|
+
function E() {
|
|
145
148
|
let e, t, n = new Promise((n, r) => {
|
|
146
149
|
e = n, t = r;
|
|
147
150
|
});
|
|
@@ -151,29 +154,29 @@ function T() {
|
|
|
151
154
|
reject: t
|
|
152
155
|
};
|
|
153
156
|
}
|
|
154
|
-
function
|
|
157
|
+
function D() {
|
|
155
158
|
return new DOMException("Aborted", "AbortError");
|
|
156
159
|
}
|
|
157
|
-
function
|
|
160
|
+
function O(e) {
|
|
158
161
|
return e instanceof DOMException || e instanceof Error ? e : Error(String(e));
|
|
159
162
|
}
|
|
160
|
-
function
|
|
163
|
+
function k(e) {
|
|
161
164
|
return e instanceof DOMException && e.name === "AbortError";
|
|
162
165
|
}
|
|
163
|
-
function
|
|
166
|
+
function A(e) {
|
|
164
167
|
!e.instance || e.instanceDestroyed || (e.instanceDestroyed = !0, e.instance.destroy());
|
|
165
168
|
}
|
|
166
|
-
function
|
|
169
|
+
function j(e, t, n, r) {
|
|
167
170
|
e.unsubscribers.push(t.on(n, r));
|
|
168
171
|
}
|
|
169
|
-
function
|
|
170
|
-
|
|
172
|
+
function M(e, t, n) {
|
|
173
|
+
j(e, t, "ready", (t) => {
|
|
171
174
|
e.destroyed || (e.ready.resolve(t), n().onReady?.(t));
|
|
172
|
-
}),
|
|
175
|
+
}), j(e, t, "started", (t) => {
|
|
173
176
|
e.destroyed || (e.started.resolve(t), n().onStarted?.(t));
|
|
174
|
-
}),
|
|
177
|
+
}), j(e, t, "userTranscript", (e) => n().onUserTranscript?.(e)), j(e, t, "userSpeechStarted", (e) => n().onUserSpeechStarted?.(e)), j(e, t, "userSpeechEnded", (e) => n().onUserSpeechEnded?.(e)), j(e, t, "characterSpeechStarted", (e) => n().onCharacterSpeechStarted?.(e)), j(e, t, "characterSpeechEnded", (e) => n().onCharacterSpeechEnded?.(e)), j(e, t, "characterFocusChanged", (e) => n().onCharacterFocusChanged?.(e)), j(e, t, "conversationUpdate", (e) => n().onConversationUpdate?.(e)), j(e, t, "message", (e) => n().onMessage?.(e)), j(e, t, "listeningState", (e) => n().onListeningState?.(e)), j(e, t, "activityChange", (e) => n().onActivityChange?.(e)), j(e, t, "feedback", (e) => n().onFeedback?.(e)), j(e, t, "feedbackFailed", (e) => n().onFeedbackFailed?.(e)), j(e, t, "conversationProcessorError", (e) => n().onConversationProcessorError?.(e));
|
|
175
178
|
}
|
|
176
|
-
function
|
|
179
|
+
function N(e = () => ({}), t = () => ({})) {
|
|
177
180
|
let n = 0, r = null;
|
|
178
181
|
function i(e) {
|
|
179
182
|
if (e) {
|
|
@@ -188,22 +191,22 @@ function M(e = () => ({}), t = () => ({})) {
|
|
|
188
191
|
}
|
|
189
192
|
}
|
|
190
193
|
function a(e, t, n, a, o = !1, s) {
|
|
191
|
-
let c =
|
|
192
|
-
return !
|
|
194
|
+
let c = O(e);
|
|
195
|
+
return !k(c) && r === t && !t.destroyed && (o && a?.(T(c, { experienceId: i(s) })), t.reportedErrors.has(c) || (t.reportedErrors.add(c), console.error("[Experience]", c), n.onError?.(c))), c;
|
|
193
196
|
}
|
|
194
197
|
function o() {
|
|
195
|
-
if (!r || r.destroyed) throw
|
|
198
|
+
if (!r || r.destroyed) throw D();
|
|
196
199
|
return r;
|
|
197
200
|
}
|
|
198
201
|
function s(e) {
|
|
199
|
-
if (e.destroyed || r !== e) throw
|
|
202
|
+
if (e.destroyed || r !== e) throw D();
|
|
200
203
|
}
|
|
201
204
|
function u() {
|
|
202
205
|
return {
|
|
203
206
|
id: ++n,
|
|
204
|
-
session:
|
|
205
|
-
ready:
|
|
206
|
-
started:
|
|
207
|
+
session: E(),
|
|
208
|
+
ready: E(),
|
|
209
|
+
started: E(),
|
|
207
210
|
unsubscribers: [],
|
|
208
211
|
reportedErrors: /* @__PURE__ */ new Set(),
|
|
209
212
|
instance: null,
|
|
@@ -214,23 +217,24 @@ function M(e = () => ({}), t = () => ({})) {
|
|
|
214
217
|
function d(e) {
|
|
215
218
|
if (e.destroyed) return;
|
|
216
219
|
e.destroyed = !0;
|
|
217
|
-
let t =
|
|
220
|
+
let t = D();
|
|
218
221
|
e.session.reject(t), e.ready.reject(t), e.started.reject(t);
|
|
219
222
|
for (let t of e.unsubscribers.splice(0)) t();
|
|
220
|
-
|
|
223
|
+
A(e), r === e && (r = null);
|
|
221
224
|
}
|
|
222
225
|
async function f(e, n, i, o, u, d) {
|
|
223
226
|
try {
|
|
224
227
|
let a = await c.startSession(i);
|
|
225
228
|
if (e.instance = a, e.destroyed || r !== e) {
|
|
226
|
-
|
|
229
|
+
A(e);
|
|
227
230
|
return;
|
|
228
231
|
}
|
|
229
|
-
|
|
232
|
+
M(e, a, o);
|
|
230
233
|
let d = t(), f = d.returnUrl?.trim() || u?.trim(), p = await a.attach({
|
|
231
234
|
container: n,
|
|
232
235
|
fit: d.fit,
|
|
233
236
|
startButton: d.startButton,
|
|
237
|
+
theme: d.theme,
|
|
234
238
|
showFeedback: d.showFeedback,
|
|
235
239
|
closeButton: d.closeButton,
|
|
236
240
|
returnUrl: f,
|
|
@@ -253,7 +257,7 @@ function M(e = () => ({}), t = () => ({})) {
|
|
|
253
257
|
});
|
|
254
258
|
} catch (t) {
|
|
255
259
|
let n = a(t, e, o(), d, !0, i);
|
|
256
|
-
e.session.reject(n), e.ready.reject(n), e.started.reject(n),
|
|
260
|
+
e.session.reject(n), e.ready.reject(n), e.started.reject(n), A(e);
|
|
257
261
|
}
|
|
258
262
|
}
|
|
259
263
|
function p(t, n, i, o) {
|
|
@@ -283,17 +287,17 @@ function M(e = () => ({}), t = () => ({})) {
|
|
|
283
287
|
}
|
|
284
288
|
//#endregion
|
|
285
289
|
//#region src/svelte/experienceLoadErrorStyles.ts
|
|
286
|
-
var
|
|
287
|
-
function
|
|
290
|
+
var P = "liforma-experience-load-error-styles";
|
|
291
|
+
function F() {
|
|
288
292
|
if (typeof document > "u" || document.getElementById("liforma-experience-load-error-styles")) return;
|
|
289
293
|
let e = document.createElement("style");
|
|
290
|
-
e.id =
|
|
294
|
+
e.id = P, e.textContent = I, document.head.append(e);
|
|
291
295
|
}
|
|
292
|
-
var
|
|
296
|
+
var I = "\n .liforma-loading-screen {\n inset: 0;\n z-index: 20;\n box-sizing: border-box;\n overflow-x: clip;\n width: 100%;\n height: 100%;\n max-width: 100vw;\n background:\n radial-gradient(circle at 50% 60%, rgba(79, 126, 196, 0.18), transparent 38%),\n #030508;\n font-family: system-ui, -apple-system, sans-serif;\n color: #e8f0ff;\n text-align: center;\n }\n .liforma-loading-screen-absolute {\n position: absolute;\n }\n .liforma-loading-card {\n position: absolute;\n left: 50%;\n top: 60%;\n transform: translate(-50%, -50%);\n width: min(22rem, calc(100% - 2.5rem));\n max-width: calc(100% - max(1.25rem, env(safe-area-inset-left, 0px)) - max(1.25rem, env(safe-area-inset-right, 0px)));\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n box-shadow: none;\n }\n .liforma-loading-card-error {\n display: block;\n text-align: center;\n padding: 1rem 1.05rem;\n border-radius: 14px;\n border: 1px solid rgba(255, 154, 154, 0.28);\n background:\n linear-gradient(180deg, rgba(21, 29, 42, 0.92), rgba(9, 13, 20, 0.92));\n }\n .liforma-loading-kicker {\n margin: 0 0 0.18rem;\n color: #8ba4c5;\n font-size: 0.68rem;\n font-weight: 700;\n text-transform: uppercase;\n letter-spacing: 0.08em;\n }\n .liforma-loading-error {\n margin: 0;\n max-width: 28rem;\n color: #ffb4b4;\n font-size: 0.92rem;\n line-height: 1.4;\n }\n .liforma-loading-error-title {\n margin: 0;\n color: #f6ebe8;\n font-size: 0.98rem;\n font-weight: 650;\n line-height: 1.35;\n }\n .liforma-loading-error-advanced {\n margin: 0.85rem 0 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: #9eb7d8;\n font: inherit;\n font-size: 0.78rem;\n font-weight: 650;\n letter-spacing: 0.02em;\n text-decoration: underline;\n text-underline-offset: 0.18em;\n cursor: pointer;\n }\n .liforma-loading-error-advanced:hover,\n .liforma-loading-error-advanced:focus-visible {\n color: #d7e6ff;\n outline: none;\n }\n .liforma-loading-error-detail {\n margin: 0.7rem 0 0;\n padding: 0.65rem 0.7rem;\n border-radius: 10px;\n border: 1px solid rgba(158, 191, 255, 0.16);\n background: rgba(3, 5, 8, 0.45);\n color: #c6d4e8;\n font-size: 0.78rem;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n line-height: 1.4;\n text-align: left;\n word-break: break-word;\n }\n .liforma-loading-error-detail[hidden] {\n display: none;\n }\n";
|
|
293
297
|
//#endregion
|
|
294
298
|
//#region src/svelte/experienceLoadErrorOverlay.ts
|
|
295
|
-
function
|
|
296
|
-
|
|
299
|
+
function ee(e, t) {
|
|
300
|
+
F();
|
|
297
301
|
let n = t, r = !1, i = document.createElement("div");
|
|
298
302
|
i.className = "liforma-loading-screen liforma-loading-screen-absolute", i.setAttribute("role", "alert"), i.setAttribute("aria-live", "assertive");
|
|
299
303
|
let a = document.createElement("div");
|
|
@@ -323,52 +327,54 @@ function te(e, t) {
|
|
|
323
327
|
}
|
|
324
328
|
//#endregion
|
|
325
329
|
//#region src/react/Experience.tsx
|
|
326
|
-
var
|
|
327
|
-
let { returnUrl: c, fit: l, startButton: u,
|
|
330
|
+
var te = e(function(e, a) {
|
|
331
|
+
let { returnUrl: c, fit: l, startButton: u, theme: p, showFeedback: m, closeButton: h, onReady: g, onStarted: y, onUserTranscript: b, onUserSpeechStarted: x, onUserSpeechEnded: S, onCharacterSpeechStarted: C, onCharacterSpeechEnded: w, onCharacterFocusChanged: T, onConversationUpdate: E, onMessage: k, onListeningState: A, onActivityChange: j, onFeedback: M, onFeedbackFailed: P, onConversationProcessorError: F, onPlayerStatusChange: I, onStateUpdate: te, onClose: ne, onError: L } = e, re = o({}), ie = o({
|
|
328
332
|
fit: l,
|
|
329
333
|
startButton: u,
|
|
330
|
-
|
|
331
|
-
|
|
334
|
+
theme: p,
|
|
335
|
+
showFeedback: m,
|
|
336
|
+
closeButton: h,
|
|
332
337
|
returnUrl: c
|
|
333
|
-
}), R = o(
|
|
334
|
-
|
|
338
|
+
}), R = o(N(() => re.current, () => ie.current)), z = o(null), [B, ae] = s(!1), [V, oe] = s(null), se = o(null), ce = o(null), H = v(e);
|
|
339
|
+
ie.current = {
|
|
335
340
|
fit: l,
|
|
336
341
|
startButton: u,
|
|
337
|
-
|
|
338
|
-
|
|
342
|
+
theme: p,
|
|
343
|
+
showFeedback: m,
|
|
344
|
+
closeButton: h,
|
|
339
345
|
returnUrl: c
|
|
340
|
-
},
|
|
341
|
-
onReady:
|
|
342
|
-
onStarted:
|
|
343
|
-
onUserTranscript:
|
|
344
|
-
onUserSpeechStarted:
|
|
345
|
-
onUserSpeechEnded:
|
|
346
|
-
onCharacterSpeechStarted:
|
|
347
|
-
onCharacterSpeechEnded:
|
|
348
|
-
onCharacterFocusChanged:
|
|
349
|
-
onConversationUpdate:
|
|
350
|
-
onMessage:
|
|
351
|
-
onListeningState:
|
|
352
|
-
onActivityChange:
|
|
353
|
-
onFeedback:
|
|
354
|
-
onFeedbackFailed:
|
|
355
|
-
onConversationProcessorError:
|
|
356
|
-
onPlayerStatusChange:
|
|
357
|
-
onStateUpdate:
|
|
346
|
+
}, re.current = {
|
|
347
|
+
onReady: g,
|
|
348
|
+
onStarted: y,
|
|
349
|
+
onUserTranscript: b,
|
|
350
|
+
onUserSpeechStarted: x,
|
|
351
|
+
onUserSpeechEnded: S,
|
|
352
|
+
onCharacterSpeechStarted: C,
|
|
353
|
+
onCharacterSpeechEnded: w,
|
|
354
|
+
onCharacterFocusChanged: T,
|
|
355
|
+
onConversationUpdate: E,
|
|
356
|
+
onMessage: k,
|
|
357
|
+
onListeningState: A,
|
|
358
|
+
onActivityChange: j,
|
|
359
|
+
onFeedback: M,
|
|
360
|
+
onFeedbackFailed: P,
|
|
361
|
+
onConversationProcessorError: F,
|
|
362
|
+
onPlayerStatusChange: I,
|
|
363
|
+
onStateUpdate: te,
|
|
358
364
|
onClose: ne,
|
|
359
|
-
onError:
|
|
365
|
+
onError: L
|
|
360
366
|
};
|
|
361
|
-
let
|
|
367
|
+
let le = t((e) => {
|
|
362
368
|
se.current = e, ae(e !== null);
|
|
363
369
|
}, []);
|
|
364
370
|
return r(a, () => ({
|
|
365
371
|
ready: () => {
|
|
366
372
|
let e = z.current;
|
|
367
|
-
return !e || e.destroyed ? Promise.reject(
|
|
373
|
+
return !e || e.destroyed ? Promise.reject(D()) : e.ready.promise;
|
|
368
374
|
},
|
|
369
375
|
started: () => {
|
|
370
376
|
let e = z.current;
|
|
371
|
-
return !e || e.destroyed ? Promise.reject(
|
|
377
|
+
return !e || e.destroyed ? Promise.reject(D()) : e.started.promise;
|
|
372
378
|
},
|
|
373
379
|
speech: {
|
|
374
380
|
speak: (e) => R.current.withSession((t) => t.speech.speak(e)),
|
|
@@ -388,32 +394,33 @@ var ne = e(function(e, a) {
|
|
|
388
394
|
getConversation: () => R.current.getActiveInstance()?.getConversation() ?? [],
|
|
389
395
|
focusCharacter: (e) => R.current.withSession((t) => t.focusCharacter(e)),
|
|
390
396
|
setFit: (e) => R.current.withSession((t) => t.setFit(e)),
|
|
397
|
+
conversion: (e) => R.current.withSession((t) => t.conversion(e)),
|
|
391
398
|
end: () => R.current.withSession((e) => e.end())
|
|
392
399
|
}), []), i(() => {
|
|
393
|
-
if (!
|
|
400
|
+
if (!B || !se.current) return;
|
|
394
401
|
let t = se.current, n = R.current, r;
|
|
395
402
|
try {
|
|
396
403
|
r = { options: _(e) };
|
|
397
404
|
} catch (e) {
|
|
398
|
-
r = { error:
|
|
405
|
+
r = { error: O(e) };
|
|
399
406
|
}
|
|
400
407
|
let i = n.activateGeneration(t, r, c, oe);
|
|
401
408
|
return z.current = i, () => {
|
|
402
409
|
n.cancelGeneration(i), z.current === i && (z.current = null);
|
|
403
410
|
};
|
|
404
411
|
}, [
|
|
405
|
-
|
|
406
|
-
|
|
412
|
+
B,
|
|
413
|
+
H,
|
|
407
414
|
c
|
|
408
415
|
]), n(() => {
|
|
409
416
|
let e = R.current.getActiveInstance();
|
|
410
417
|
e && e.setFit(l ?? "full");
|
|
411
418
|
}, [l]), n(() => {
|
|
412
419
|
let e = ce.current;
|
|
413
|
-
if (!e || (e.replaceChildren(), !
|
|
414
|
-
let t =
|
|
420
|
+
if (!e || (e.replaceChildren(), !V)) return;
|
|
421
|
+
let t = ee(e, V);
|
|
415
422
|
return () => t.remove();
|
|
416
|
-
}, [
|
|
423
|
+
}, [V]), /* @__PURE__ */ f("div", {
|
|
417
424
|
className: "liforma-experience-shell",
|
|
418
425
|
style: {
|
|
419
426
|
position: "relative",
|
|
@@ -424,15 +431,15 @@ var ne = e(function(e, a) {
|
|
|
424
431
|
children: [/* @__PURE__ */ d("div", {
|
|
425
432
|
ref: ce,
|
|
426
433
|
className: "liforma-experience-error-host",
|
|
427
|
-
"aria-hidden":
|
|
434
|
+
"aria-hidden": V ? void 0 : !0,
|
|
428
435
|
style: {
|
|
429
436
|
position: "absolute",
|
|
430
437
|
inset: 0,
|
|
431
438
|
zIndex: 20,
|
|
432
|
-
pointerEvents:
|
|
439
|
+
pointerEvents: V ? "auto" : "none"
|
|
433
440
|
}
|
|
434
441
|
}), /* @__PURE__ */ d("div", {
|
|
435
|
-
ref:
|
|
442
|
+
ref: le,
|
|
436
443
|
className: "liforma-experience-host",
|
|
437
444
|
style: {
|
|
438
445
|
position: "absolute",
|
|
@@ -444,32 +451,32 @@ var ne = e(function(e, a) {
|
|
|
444
451
|
});
|
|
445
452
|
//#endregion
|
|
446
453
|
//#region src/thumbnail/types.ts
|
|
447
|
-
function
|
|
454
|
+
function ne(e) {
|
|
448
455
|
return e === "face" ? "liforma-et--fit-face" : e === "medium" ? "liforma-et--fit-medium" : "";
|
|
449
456
|
}
|
|
450
457
|
//#endregion
|
|
451
458
|
//#region src/thumbnail/toGalleryThumbUrl.ts
|
|
452
|
-
var L = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, re = /_CH(\.webp)/i,
|
|
453
|
-
function
|
|
459
|
+
var L = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, re = /_CH(\.webp)/i, ie = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
|
|
460
|
+
function R(e) {
|
|
454
461
|
let t = e.trim();
|
|
455
462
|
if (!t) return t;
|
|
456
463
|
let n = t.replace(L, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`);
|
|
457
|
-
return n = n.replace(re, "_neutral$1"), n = n.replace(
|
|
464
|
+
return n = n.replace(re, "_neutral$1"), n = n.replace(ie, (e, t, n, r, i) => n === "256x256" ? `${t}${n}${r}${i}` : `${t}256x256${r}${i}`), n;
|
|
458
465
|
}
|
|
459
|
-
function
|
|
466
|
+
function z(e) {
|
|
460
467
|
let t = e.avatarImage?.trim() || e.galleryThumb?.avatarImage?.trim() || "";
|
|
461
468
|
if (!t) return null;
|
|
462
469
|
let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "";
|
|
463
470
|
return {
|
|
464
|
-
avatarImage:
|
|
465
|
-
...n ? { backgroundImage:
|
|
466
|
-
...r ? { foregroundImage:
|
|
467
|
-
...i ? { fallbackImage:
|
|
471
|
+
avatarImage: R(t),
|
|
472
|
+
...n ? { backgroundImage: R(n) } : {},
|
|
473
|
+
...r ? { foregroundImage: R(r) } : {},
|
|
474
|
+
...i ? { fallbackImage: R(i) } : {}
|
|
468
475
|
};
|
|
469
476
|
}
|
|
470
477
|
//#endregion
|
|
471
478
|
//#region src/shims/localStack.ts
|
|
472
|
-
function
|
|
479
|
+
function B() {
|
|
473
480
|
if (globalThis.__LIFORMA_STACK === "local") return !0;
|
|
474
481
|
if (typeof location > "u") return !1;
|
|
475
482
|
try {
|
|
@@ -480,70 +487,70 @@ function ae() {
|
|
|
480
487
|
}
|
|
481
488
|
//#endregion
|
|
482
489
|
//#region src/thumbnail/hostedLaunchUrl.ts
|
|
483
|
-
var
|
|
484
|
-
function
|
|
490
|
+
var ae = "https://player.liforma.ai", V = "http://localhost:3002";
|
|
491
|
+
function oe(e) {
|
|
485
492
|
return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
|
|
486
493
|
}
|
|
487
|
-
function
|
|
494
|
+
function se(e) {
|
|
488
495
|
let t = e?.trim();
|
|
489
|
-
return t ? t.replace(/\/$/, "") :
|
|
496
|
+
return t ? t.replace(/\/$/, "") : B() ? V : ae;
|
|
490
497
|
}
|
|
491
|
-
function
|
|
492
|
-
let t = e.experienceId.trim(), n =
|
|
498
|
+
function ce(e) {
|
|
499
|
+
let t = e.experienceId.trim(), n = se(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
|
|
493
500
|
return i && r.searchParams.set("returnUrl", i), r.toString();
|
|
494
501
|
}
|
|
495
|
-
function
|
|
502
|
+
function H(e) {
|
|
496
503
|
let t = e.href?.trim();
|
|
497
504
|
if (t) return t;
|
|
498
505
|
let n = e.experienceId?.trim();
|
|
499
506
|
if (!n) return;
|
|
500
507
|
let r = e.returnUrl?.trim();
|
|
501
|
-
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href),
|
|
508
|
+
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href), ce({
|
|
502
509
|
experienceId: n,
|
|
503
510
|
...r ? { returnUrl: r } : {},
|
|
504
511
|
playerBaseUrl: e.playerBaseUrl
|
|
505
512
|
});
|
|
506
513
|
}
|
|
507
|
-
function
|
|
514
|
+
function le() {
|
|
508
515
|
return typeof window > "u" ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
509
516
|
}
|
|
510
|
-
var
|
|
517
|
+
var U = 0, ue = [];
|
|
511
518
|
function de() {
|
|
512
|
-
return
|
|
519
|
+
return le() ? 4 : Infinity;
|
|
513
520
|
}
|
|
514
521
|
function W() {
|
|
515
|
-
return
|
|
522
|
+
return le() ? 160 : 0;
|
|
516
523
|
}
|
|
517
524
|
function fe() {
|
|
518
525
|
let e = de();
|
|
519
|
-
for (;
|
|
520
|
-
let e =
|
|
526
|
+
for (; U < e && ue.length > 0;) {
|
|
527
|
+
let e = ue.shift();
|
|
521
528
|
if (!e || e.cancelled) continue;
|
|
522
|
-
|
|
529
|
+
U += 1, e.start();
|
|
523
530
|
let t = W();
|
|
524
531
|
if (t <= 0) {
|
|
525
|
-
|
|
532
|
+
U = Math.max(0, U - 1);
|
|
526
533
|
continue;
|
|
527
534
|
}
|
|
528
535
|
window.setTimeout(() => {
|
|
529
|
-
|
|
536
|
+
U = Math.max(0, U - 1), fe();
|
|
530
537
|
}, t);
|
|
531
538
|
}
|
|
532
539
|
}
|
|
533
540
|
function pe(e) {
|
|
534
|
-
if (!
|
|
541
|
+
if (!le()) return e(), () => {};
|
|
535
542
|
let t = {
|
|
536
543
|
start: e,
|
|
537
544
|
cancelled: !1
|
|
538
545
|
};
|
|
539
|
-
return
|
|
546
|
+
return ue.push(t), fe(), () => {
|
|
540
547
|
t.cancelled = !0;
|
|
541
548
|
};
|
|
542
549
|
}
|
|
543
550
|
//#endregion
|
|
544
551
|
//#region src/thumbnail/lazyLoad.ts
|
|
545
552
|
function me() {
|
|
546
|
-
return
|
|
553
|
+
return le() ? "96px 0px" : "280px 0px";
|
|
547
554
|
}
|
|
548
555
|
function he(e) {
|
|
549
556
|
let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
|
|
@@ -667,92 +674,92 @@ function ke(e, t) {
|
|
|
667
674
|
return `${e} liforma-et__media${t ? " liforma-et__media--ready" : ""}`;
|
|
668
675
|
}
|
|
669
676
|
function Ae(e) {
|
|
670
|
-
let { galleryThumb: t, avatarImage: r, backgroundImage: i, foregroundImage: c, alt: l, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: y, parallax: b = !0, fit: x = "full", lazy: S = !0, className:
|
|
677
|
+
let { galleryThumb: t, avatarImage: r, backgroundImage: i, foregroundImage: c, alt: l, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: y, parallax: b = !0, fit: x = "full", lazy: S = !0, className: C = "", fallbackImage: w } = e, T = a(() => z({
|
|
671
678
|
galleryThumb: t,
|
|
672
679
|
avatarImage: r,
|
|
673
680
|
backgroundImage: i,
|
|
674
681
|
foregroundImage: c,
|
|
675
|
-
fallbackImage:
|
|
682
|
+
fallbackImage: w
|
|
676
683
|
}), [
|
|
677
684
|
t,
|
|
678
685
|
r,
|
|
679
686
|
i,
|
|
680
687
|
c,
|
|
681
|
-
|
|
682
|
-
]),
|
|
688
|
+
w
|
|
689
|
+
]), E = oe({
|
|
683
690
|
href: m,
|
|
684
691
|
hasClickHandler: typeof _ == "function",
|
|
685
692
|
experienceId: p
|
|
686
|
-
}),
|
|
693
|
+
}), D = E === "anchor" && !m?.trim() && !!p?.trim(), O = !!T?.backgroundImage, k = b !== !1, A = o(null), j = o(!1), [M, N] = s(!S), [P, F] = s(!1), [I, ee] = s(!1), [te, L] = s(0), [re, ie] = s(0), [R, B] = s(!1), [ae, V] = s(!1), [se, ce] = s(!1), [le, U] = s(!1), [ue, de] = s(), W = T ? R && T.fallbackImage ? T.fallbackImage : T.avatarImage : "";
|
|
687
694
|
n(() => {
|
|
688
695
|
Oe(Ee);
|
|
689
696
|
}, []), n(() => {
|
|
690
|
-
de(
|
|
697
|
+
de(H({
|
|
691
698
|
href: m,
|
|
692
699
|
experienceId: p,
|
|
693
700
|
returnUrl: v,
|
|
694
701
|
playerBaseUrl: y,
|
|
695
|
-
useCurrentPageAsReturnUrl:
|
|
702
|
+
useCurrentPageAsReturnUrl: D && !v?.trim()
|
|
696
703
|
}));
|
|
697
704
|
}, [
|
|
698
705
|
m,
|
|
699
706
|
p,
|
|
700
707
|
v,
|
|
701
708
|
y,
|
|
702
|
-
|
|
709
|
+
D
|
|
703
710
|
]), n(() => {
|
|
704
|
-
|
|
711
|
+
V(!1), ce(!1), U(!1), B(!1);
|
|
705
712
|
}, [
|
|
706
|
-
|
|
707
|
-
|
|
713
|
+
T?.backgroundImage,
|
|
714
|
+
T?.foregroundImage,
|
|
708
715
|
W
|
|
709
716
|
]), n(() => {
|
|
710
|
-
let e =
|
|
717
|
+
let e = A.current;
|
|
711
718
|
if (e) {
|
|
712
719
|
if (!S) {
|
|
713
|
-
|
|
720
|
+
N(!0);
|
|
714
721
|
return;
|
|
715
722
|
}
|
|
716
723
|
return _e(e, { onVisibleChange: (e) => {
|
|
717
|
-
e &&
|
|
724
|
+
e && N(!0);
|
|
718
725
|
} });
|
|
719
726
|
}
|
|
720
727
|
}, [
|
|
721
728
|
S,
|
|
722
|
-
w,
|
|
723
729
|
T,
|
|
724
|
-
|
|
730
|
+
E,
|
|
731
|
+
ue
|
|
725
732
|
]), n(() => {
|
|
726
|
-
let e =
|
|
727
|
-
if (!(!e || !
|
|
733
|
+
let e = A.current;
|
|
734
|
+
if (!(!e || !k)) return we(e, {
|
|
728
735
|
onParallax: (e) => {
|
|
729
|
-
|
|
736
|
+
ee(!0), j.current || (L(e), ie(0));
|
|
730
737
|
},
|
|
731
|
-
pointerActive: () =>
|
|
738
|
+
pointerActive: () => j.current
|
|
732
739
|
});
|
|
733
740
|
}, [
|
|
734
|
-
|
|
735
|
-
w,
|
|
741
|
+
k,
|
|
736
742
|
T,
|
|
737
|
-
|
|
743
|
+
E,
|
|
744
|
+
ue
|
|
738
745
|
]);
|
|
739
746
|
let fe = (e) => {
|
|
740
|
-
if (!
|
|
747
|
+
if (!k || I) return;
|
|
741
748
|
let t = e.currentTarget.getBoundingClientRect();
|
|
742
|
-
t.width <= 0 || t.height <= 0 || (L(((e.clientX - t.left) / t.width - .5) * 2),
|
|
749
|
+
t.width <= 0 || t.height <= 0 || (L(((e.clientX - t.left) / t.width - .5) * 2), ie(((e.clientY - t.top) / t.height - .5) * 2));
|
|
743
750
|
}, pe = (e) => {
|
|
744
|
-
let t =
|
|
745
|
-
|
|
751
|
+
let t = j.current;
|
|
752
|
+
j.current = !1, F(!1), I && t ? (L(ye(e.getBoundingClientRect(), window.innerHeight)), ie(0)) : I || (L(0), ie(0));
|
|
746
753
|
}, me = (e) => {
|
|
747
|
-
if (!
|
|
748
|
-
|
|
754
|
+
if (!k) return;
|
|
755
|
+
j.current = !0, e.pointerType === "mouse" && F(!0);
|
|
749
756
|
let t = e.currentTarget, n = () => {
|
|
750
757
|
pe(t), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n);
|
|
751
758
|
};
|
|
752
759
|
window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n);
|
|
753
760
|
}, he = (e) => {
|
|
754
|
-
if (_?.(e), !e.defaultPrevented &&
|
|
755
|
-
let t =
|
|
761
|
+
if (_?.(e), !e.defaultPrevented && D && !v?.trim()) {
|
|
762
|
+
let t = H({
|
|
756
763
|
experienceId: p,
|
|
757
764
|
playerBaseUrl: y,
|
|
758
765
|
useCurrentPageAsReturnUrl: !0
|
|
@@ -760,18 +767,18 @@ function Ae(e) {
|
|
|
760
767
|
t && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && (e.preventDefault(), window.location.assign(t));
|
|
761
768
|
}
|
|
762
769
|
};
|
|
763
|
-
if (!
|
|
764
|
-
let ge =
|
|
770
|
+
if (!T) return null;
|
|
771
|
+
let ge = k && (P || I), ve = M && (se || ae || le), G = [
|
|
765
772
|
"liforma-et",
|
|
766
|
-
|
|
767
|
-
|
|
773
|
+
O ? "liforma-et--scene" : "",
|
|
774
|
+
ne(x),
|
|
768
775
|
ge ? "liforma-et--parallax" : "",
|
|
769
|
-
|
|
770
|
-
|
|
776
|
+
I ? "liforma-et--scroll-parallax" : "",
|
|
777
|
+
M && !ve ? "liforma-et--loading" : "",
|
|
771
778
|
ve ? "liforma-et--revealed" : "",
|
|
772
|
-
|
|
779
|
+
C
|
|
773
780
|
].filter(Boolean).join(" "), be = {
|
|
774
|
-
"--liforma-et-parallax-x":
|
|
781
|
+
"--liforma-et-parallax-x": te,
|
|
775
782
|
"--liforma-et-parallax-y": re
|
|
776
783
|
}, K = (e, t) => {
|
|
777
784
|
e.complete && t(!0);
|
|
@@ -780,67 +787,67 @@ function Ae(e) {
|
|
|
780
787
|
className: "liforma-et__placeholder",
|
|
781
788
|
"aria-hidden": "true"
|
|
782
789
|
}),
|
|
783
|
-
|
|
784
|
-
className: ke("liforma-et__background",
|
|
785
|
-
src:
|
|
790
|
+
M && T.backgroundImage ? /* @__PURE__ */ d("img", {
|
|
791
|
+
className: ke("liforma-et__background", ae),
|
|
792
|
+
src: T.backgroundImage,
|
|
786
793
|
alt: "",
|
|
787
794
|
decoding: "async",
|
|
788
795
|
ref: (e) => {
|
|
789
|
-
e && K(e,
|
|
796
|
+
e && K(e, V);
|
|
790
797
|
},
|
|
791
|
-
onLoad: () =>
|
|
792
|
-
onError: () =>
|
|
798
|
+
onLoad: () => V(!0),
|
|
799
|
+
onError: () => V(!0)
|
|
793
800
|
}) : null,
|
|
794
|
-
|
|
795
|
-
className: ke("liforma-et__avatar",
|
|
801
|
+
M && W ? /* @__PURE__ */ d("img", {
|
|
802
|
+
className: ke("liforma-et__avatar", se),
|
|
796
803
|
src: W,
|
|
797
804
|
alt: "",
|
|
798
805
|
decoding: "async",
|
|
799
806
|
ref: (e) => {
|
|
800
|
-
e && K(e,
|
|
807
|
+
e && K(e, ce);
|
|
801
808
|
},
|
|
802
|
-
onLoad: () =>
|
|
809
|
+
onLoad: () => ce(!0),
|
|
803
810
|
onError: () => {
|
|
804
|
-
|
|
811
|
+
T.fallbackImage ? B(!0) : ce(!0);
|
|
805
812
|
}
|
|
806
813
|
}) : null,
|
|
807
|
-
|
|
808
|
-
className: ke("liforma-et__foreground",
|
|
809
|
-
src:
|
|
814
|
+
M && T.foregroundImage ? /* @__PURE__ */ d("img", {
|
|
815
|
+
className: ke("liforma-et__foreground", le),
|
|
816
|
+
src: T.foregroundImage,
|
|
810
817
|
alt: "",
|
|
811
818
|
decoding: "async",
|
|
812
819
|
ref: (e) => {
|
|
813
|
-
e && K(e,
|
|
820
|
+
e && K(e, U);
|
|
814
821
|
},
|
|
815
|
-
onLoad: () =>
|
|
816
|
-
onError: () =>
|
|
822
|
+
onLoad: () => U(!0),
|
|
823
|
+
onError: () => U(!0)
|
|
817
824
|
}) : null
|
|
818
825
|
] }), Se = {
|
|
819
826
|
onPointerDown: me,
|
|
820
827
|
onPointerUp: (e) => pe(e.currentTarget),
|
|
821
828
|
onPointerCancel: (e) => pe(e.currentTarget),
|
|
822
829
|
onPointerEnter: (e) => {
|
|
823
|
-
|
|
830
|
+
k && e.pointerType === "mouse" && F(!0);
|
|
824
831
|
},
|
|
825
832
|
onPointerMove: fe,
|
|
826
833
|
onPointerLeave: () => {
|
|
827
|
-
|
|
834
|
+
j.current || (F(!1), I || (L(0), ie(0)));
|
|
828
835
|
}
|
|
829
836
|
}, q = (e) => {
|
|
830
|
-
|
|
837
|
+
A.current = e;
|
|
831
838
|
};
|
|
832
|
-
return
|
|
839
|
+
return E === "anchor" && ue ? /* @__PURE__ */ d("a", {
|
|
833
840
|
ref: q,
|
|
834
841
|
className: G,
|
|
835
842
|
style: be,
|
|
836
|
-
href:
|
|
843
|
+
href: ue,
|
|
837
844
|
target: h,
|
|
838
845
|
rel: g,
|
|
839
846
|
"aria-label": l,
|
|
840
847
|
onClick: he,
|
|
841
848
|
...Se,
|
|
842
849
|
children: xe
|
|
843
|
-
}) :
|
|
850
|
+
}) : E === "button" ? /* @__PURE__ */ d("button", {
|
|
844
851
|
type: "button",
|
|
845
852
|
ref: q,
|
|
846
853
|
className: G,
|
|
@@ -884,7 +891,7 @@ function Ie() {
|
|
|
884
891
|
return t ? t.replace(/\/$/, "") : null;
|
|
885
892
|
}
|
|
886
893
|
function Le() {
|
|
887
|
-
return Ie() || (
|
|
894
|
+
return Ie() || (B() ? Fe : Pe);
|
|
888
895
|
}
|
|
889
896
|
//#endregion
|
|
890
897
|
//#region src/v2/api/fetchExperiencePreview.ts
|
|
@@ -956,20 +963,58 @@ function Ve(e, t, n) {
|
|
|
956
963
|
});
|
|
957
964
|
}
|
|
958
965
|
//#endregion
|
|
966
|
+
//#region src/v2/api/captureAttribution.ts
|
|
967
|
+
var He = 128, Ue = /[\u0000-\u001f\u007f]/g;
|
|
968
|
+
function Y(e) {
|
|
969
|
+
if (!e) return;
|
|
970
|
+
let t = e.replace(Ue, "").trim();
|
|
971
|
+
if (t) return t.slice(0, He);
|
|
972
|
+
}
|
|
973
|
+
function We(e) {
|
|
974
|
+
let t = new URLSearchParams((e ?? "").startsWith("?") ? (e ?? "").slice(1) : e ?? "");
|
|
975
|
+
return {
|
|
976
|
+
...Y(t.get("utm_source")) ? { utmSource: Y(t.get("utm_source")) } : {},
|
|
977
|
+
...Y(t.get("utm_medium")) ? { utmMedium: Y(t.get("utm_medium")) } : {},
|
|
978
|
+
...Y(t.get("utm_campaign")) ? { utmCampaign: Y(t.get("utm_campaign")) } : {},
|
|
979
|
+
...Y(t.get("utm_content")) ? { utmContent: Y(t.get("utm_content")) } : {},
|
|
980
|
+
...Y(t.get("utm_term")) ? { utmTerm: Y(t.get("utm_term")) } : {}
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
function Ge(e) {
|
|
984
|
+
if (e === !1) return;
|
|
985
|
+
if (e && typeof e == "object") {
|
|
986
|
+
let t = {
|
|
987
|
+
...Y(e.utmSource) ? { utmSource: Y(e.utmSource) } : {},
|
|
988
|
+
...Y(e.utmMedium) ? { utmMedium: Y(e.utmMedium) } : {},
|
|
989
|
+
...Y(e.utmCampaign) ? { utmCampaign: Y(e.utmCampaign) } : {},
|
|
990
|
+
...Y(e.utmContent) ? { utmContent: Y(e.utmContent) } : {},
|
|
991
|
+
...Y(e.utmTerm) ? { utmTerm: Y(e.utmTerm) } : {},
|
|
992
|
+
...Y(e.referrer) ? { referrer: Y(e.referrer) } : {}
|
|
993
|
+
};
|
|
994
|
+
return Object.keys(t).length ? t : void 0;
|
|
995
|
+
}
|
|
996
|
+
if (typeof window > "u") return;
|
|
997
|
+
let t = We(window.location?.search), n = Y(document.referrer || void 0), r = {
|
|
998
|
+
...t,
|
|
999
|
+
...n ? { referrer: n } : {}
|
|
1000
|
+
};
|
|
1001
|
+
return Object.keys(r).length ? r : void 0;
|
|
1002
|
+
}
|
|
1003
|
+
//#endregion
|
|
959
1004
|
//#region src/v2/api/sessionEndpointRequest.ts
|
|
960
|
-
function
|
|
1005
|
+
function Ke(e) {
|
|
961
1006
|
let t = e.locale?.trim();
|
|
962
1007
|
if (t) return t;
|
|
963
1008
|
let n = e.language?.trim();
|
|
964
1009
|
if (n) return n;
|
|
965
1010
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
966
1011
|
}
|
|
967
|
-
function
|
|
1012
|
+
function qe(e) {
|
|
968
1013
|
let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
|
|
969
1014
|
if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
|
|
970
1015
|
return t || n || void 0;
|
|
971
1016
|
}
|
|
972
|
-
function
|
|
1017
|
+
function Je(e, t) {
|
|
973
1018
|
let n = e.trim();
|
|
974
1019
|
if (!n) throw Error("sessionEndpoint must not be empty.");
|
|
975
1020
|
if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
|
|
@@ -977,7 +1022,7 @@ function We(e, t) {
|
|
|
977
1022
|
if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
|
|
978
1023
|
let i = t.experienceId.trim();
|
|
979
1024
|
if (!i) throw Error("sessionEndpoint requires experienceId.");
|
|
980
|
-
let a =
|
|
1025
|
+
let a = Ke(t), o = qe(t), s = t.idempotencyKey?.trim();
|
|
981
1026
|
return {
|
|
982
1027
|
url: r.toString(),
|
|
983
1028
|
init: {
|
|
@@ -994,23 +1039,27 @@ function We(e, t) {
|
|
|
994
1039
|
...o ? { secondaryLocale: o } : {},
|
|
995
1040
|
...t.mode ? { mode: t.mode } : {},
|
|
996
1041
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
997
|
-
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly }
|
|
1042
|
+
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
1043
|
+
...(() => {
|
|
1044
|
+
let e = Ge(t.attribution);
|
|
1045
|
+
return e ? { attribution: e } : {};
|
|
1046
|
+
})()
|
|
998
1047
|
})
|
|
999
1048
|
}
|
|
1000
1049
|
};
|
|
1001
1050
|
}
|
|
1002
1051
|
//#endregion
|
|
1003
1052
|
//#region src/v2/types/sessionLaunch.ts
|
|
1004
|
-
function
|
|
1053
|
+
function Ye(e) {
|
|
1005
1054
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
1006
1055
|
}
|
|
1007
1056
|
function X(e) {
|
|
1008
1057
|
return typeof e == "boolean";
|
|
1009
1058
|
}
|
|
1010
|
-
function
|
|
1011
|
-
if (!
|
|
1059
|
+
function Xe(e) {
|
|
1060
|
+
if (!Ye(e)) return null;
|
|
1012
1061
|
let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
|
|
1013
|
-
return !
|
|
1062
|
+
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 : {
|
|
1014
1063
|
speech: {
|
|
1015
1064
|
input: t.input,
|
|
1016
1065
|
output: t.output,
|
|
@@ -1021,8 +1070,8 @@ function Ge(e) {
|
|
|
1021
1070
|
tools: { enabled: i.enabled }
|
|
1022
1071
|
};
|
|
1023
1072
|
}
|
|
1024
|
-
function
|
|
1025
|
-
return !
|
|
1073
|
+
function Ze(e) {
|
|
1074
|
+
return !Ye(e) || !X(e.avatar) || !X(e.speechInput) || !X(e.speechOutput) || !X(e.tools) || !X(e.externalAudio) ? null : {
|
|
1026
1075
|
speech: {
|
|
1027
1076
|
input: e.speechInput,
|
|
1028
1077
|
output: e.speechOutput,
|
|
@@ -1033,12 +1082,12 @@ function Ke(e) {
|
|
|
1033
1082
|
tools: { enabled: e.tools }
|
|
1034
1083
|
};
|
|
1035
1084
|
}
|
|
1036
|
-
function
|
|
1037
|
-
return
|
|
1085
|
+
function Qe(e) {
|
|
1086
|
+
return Xe(e) ?? Ze(e);
|
|
1038
1087
|
}
|
|
1039
|
-
function
|
|
1040
|
-
if (!
|
|
1041
|
-
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 =
|
|
1088
|
+
function $e(e) {
|
|
1089
|
+
if (!Ye(e)) throw Error("Session Launch response is missing session.");
|
|
1090
|
+
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;
|
|
1042
1091
|
if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
|
|
1043
1092
|
return {
|
|
1044
1093
|
id: t,
|
|
@@ -1054,11 +1103,11 @@ function Je(e) {
|
|
|
1054
1103
|
...d ? { createdAt: d } : {}
|
|
1055
1104
|
};
|
|
1056
1105
|
}
|
|
1057
|
-
function
|
|
1106
|
+
function et(e) {
|
|
1058
1107
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
1059
1108
|
let t = [];
|
|
1060
1109
|
for (let n of e) {
|
|
1061
|
-
if (!
|
|
1110
|
+
if (!Ye(n)) continue;
|
|
1062
1111
|
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() : "";
|
|
1063
1112
|
!e || !r || !i || n.reason !== "voice_unsupported" || t.push({
|
|
1064
1113
|
axis: e,
|
|
@@ -1069,35 +1118,35 @@ function Ye(e) {
|
|
|
1069
1118
|
}
|
|
1070
1119
|
return t.length > 0 ? t : void 0;
|
|
1071
1120
|
}
|
|
1072
|
-
function
|
|
1121
|
+
function tt(e) {
|
|
1073
1122
|
let t = e.localeVoiceFallbacks;
|
|
1074
1123
|
if (t?.length) for (let e of t) {
|
|
1075
1124
|
let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
|
|
1076
1125
|
console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
|
|
1077
1126
|
}
|
|
1078
1127
|
}
|
|
1079
|
-
function
|
|
1080
|
-
if (!
|
|
1128
|
+
function nt(e) {
|
|
1129
|
+
if (!Ye(e)) throw Error("Session Launch response must be a JSON object.");
|
|
1081
1130
|
let t = typeof e.launch == "string" ? e.launch.trim() : "";
|
|
1082
1131
|
if (!t) throw Error("Session Launch response is missing launch.");
|
|
1083
|
-
let n =
|
|
1084
|
-
return
|
|
1132
|
+
let n = $e(e.session);
|
|
1133
|
+
return tt(n), {
|
|
1085
1134
|
session: n,
|
|
1086
1135
|
launch: t
|
|
1087
1136
|
};
|
|
1088
1137
|
}
|
|
1089
1138
|
//#endregion
|
|
1090
1139
|
//#region src/v2/api/mintPublicSession.ts
|
|
1091
|
-
function
|
|
1140
|
+
function rt() {
|
|
1092
1141
|
try {
|
|
1093
1142
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
1094
1143
|
} catch {}
|
|
1095
1144
|
}
|
|
1096
|
-
function
|
|
1145
|
+
function it(e) {
|
|
1097
1146
|
return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
|
|
1098
1147
|
}
|
|
1099
|
-
function
|
|
1100
|
-
let n =
|
|
1148
|
+
function at(e, t) {
|
|
1149
|
+
let n = rt(), r = it(t.code), i = t.message.trim(), a = t.details ?? {};
|
|
1101
1150
|
if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
|
|
1102
1151
|
if (i.includes(e) && i.includes("allowed origin")) return t;
|
|
1103
1152
|
let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
|
|
@@ -1120,36 +1169,38 @@ function et(e, t) {
|
|
|
1120
1169
|
details: a
|
|
1121
1170
|
}) : t;
|
|
1122
1171
|
}
|
|
1123
|
-
function
|
|
1172
|
+
function ot(e) {
|
|
1124
1173
|
let t = e?.locale?.trim();
|
|
1125
1174
|
if (t) return t;
|
|
1126
1175
|
let n = e?.language?.trim();
|
|
1127
1176
|
if (n) return n;
|
|
1128
1177
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
1129
1178
|
}
|
|
1130
|
-
function
|
|
1179
|
+
function st(e) {
|
|
1131
1180
|
let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
|
|
1132
1181
|
if (t && n && t !== n) throw new J("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
|
|
1133
1182
|
return t || n || void 0;
|
|
1134
1183
|
}
|
|
1135
|
-
function
|
|
1136
|
-
let n = { experienceId: e }, r =
|
|
1184
|
+
function ct(e, t) {
|
|
1185
|
+
let n = { experienceId: e }, r = ot(t);
|
|
1137
1186
|
r && (n.locale = r);
|
|
1138
|
-
let i =
|
|
1139
|
-
|
|
1187
|
+
let i = st(t);
|
|
1188
|
+
i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly);
|
|
1189
|
+
let a = Ge(t?.attribution);
|
|
1190
|
+
return a && (n.attribution = a), n;
|
|
1140
1191
|
}
|
|
1141
|
-
async function
|
|
1192
|
+
async function lt(e, t) {
|
|
1142
1193
|
let n = Le(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
|
|
1143
1194
|
method: "POST",
|
|
1144
1195
|
headers: {
|
|
1145
1196
|
"Content-Type": "application/json",
|
|
1146
1197
|
...r ? { "Idempotency-Key": r } : {}
|
|
1147
1198
|
},
|
|
1148
|
-
body: JSON.stringify(
|
|
1199
|
+
body: JSON.stringify(ct(e, t))
|
|
1149
1200
|
});
|
|
1150
1201
|
if (!i.ok) {
|
|
1151
1202
|
let t = await i.text();
|
|
1152
|
-
throw
|
|
1203
|
+
throw at(e, Ve(i.status, t, i.headers));
|
|
1153
1204
|
}
|
|
1154
1205
|
let a;
|
|
1155
1206
|
try {
|
|
@@ -1161,10 +1212,10 @@ async function it(e, t) {
|
|
|
1161
1212
|
requestId: i.headers.get("Liforma-Request-Id") ?? void 0
|
|
1162
1213
|
});
|
|
1163
1214
|
}
|
|
1164
|
-
return
|
|
1215
|
+
return nt(a);
|
|
1165
1216
|
}
|
|
1166
|
-
async function
|
|
1167
|
-
let n =
|
|
1217
|
+
async function ut(e, t) {
|
|
1218
|
+
let n = Je(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
|
|
1168
1219
|
t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
|
|
1169
1220
|
let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
|
|
1170
1221
|
try {
|
|
@@ -1194,14 +1245,14 @@ async function at(e, t) {
|
|
|
1194
1245
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
1195
1246
|
});
|
|
1196
1247
|
}
|
|
1197
|
-
return
|
|
1248
|
+
return nt(s);
|
|
1198
1249
|
}
|
|
1199
1250
|
//#endregion
|
|
1200
1251
|
//#region src/v2/conversationProcessor.ts
|
|
1201
|
-
function
|
|
1252
|
+
function dt(e) {
|
|
1202
1253
|
return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
|
|
1203
1254
|
}
|
|
1204
|
-
function
|
|
1255
|
+
function ft(e) {
|
|
1205
1256
|
if (typeof e == "string") {
|
|
1206
1257
|
let t = e.trim();
|
|
1207
1258
|
if (!t) throw Error("conversationProcessor returned empty text.");
|
|
@@ -1215,24 +1266,24 @@ function st(e) {
|
|
|
1215
1266
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
1216
1267
|
};
|
|
1217
1268
|
}
|
|
1218
|
-
async function
|
|
1269
|
+
async function pt(e, t) {
|
|
1219
1270
|
let n = await e(t);
|
|
1220
|
-
return
|
|
1271
|
+
return dt(n) ? {
|
|
1221
1272
|
kind: "stream",
|
|
1222
1273
|
stream: n
|
|
1223
1274
|
} : {
|
|
1224
1275
|
kind: "complete",
|
|
1225
|
-
speech:
|
|
1276
|
+
speech: ft(n)
|
|
1226
1277
|
};
|
|
1227
1278
|
}
|
|
1228
1279
|
//#endregion
|
|
1229
1280
|
//#region src/v2/embed/playerReachability.ts
|
|
1230
|
-
var
|
|
1231
|
-
function
|
|
1281
|
+
var mt = "3002";
|
|
1282
|
+
function ht(e) {
|
|
1232
1283
|
let t = new URL(e);
|
|
1233
|
-
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 ||
|
|
1284
|
+
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.`;
|
|
1234
1285
|
}
|
|
1235
|
-
async function
|
|
1286
|
+
async function gt(e, t) {
|
|
1236
1287
|
try {
|
|
1237
1288
|
await fetch(e, {
|
|
1238
1289
|
method: "GET",
|
|
@@ -1240,52 +1291,30 @@ async function dt(e, t) {
|
|
|
1240
1291
|
signal: AbortSignal.timeout(8e3)
|
|
1241
1292
|
});
|
|
1242
1293
|
} catch {
|
|
1243
|
-
throw Error(
|
|
1294
|
+
throw Error(ht(t));
|
|
1244
1295
|
}
|
|
1245
1296
|
}
|
|
1246
|
-
function
|
|
1297
|
+
function _t(e, t, n, r) {
|
|
1247
1298
|
try {
|
|
1248
1299
|
r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
|
|
1249
1300
|
} catch (e) {
|
|
1250
|
-
throw e instanceof DOMException && e.name === "SecurityError" ? Error(
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
var
|
|
1254
|
-
function
|
|
1255
|
-
return typeof e == "number" &&
|
|
1256
|
-
}
|
|
1257
|
-
var
|
|
1258
|
-
|
|
1259
|
-
"stateUpdate",
|
|
1260
|
-
"commandResult",
|
|
1261
|
-
"userTranscript",
|
|
1262
|
-
"characterSpeechStarted",
|
|
1263
|
-
"characterSpeechEnded",
|
|
1264
|
-
"characterFocusChanged",
|
|
1265
|
-
"conversationUpdate",
|
|
1266
|
-
"listeningState",
|
|
1267
|
-
"userSpeechStarted",
|
|
1268
|
-
"userSpeechEnded",
|
|
1269
|
-
"modeChange",
|
|
1270
|
-
"activityChange",
|
|
1271
|
-
"feedback",
|
|
1272
|
-
"feedbackFailed",
|
|
1273
|
-
"message",
|
|
1274
|
-
"started",
|
|
1275
|
-
"embedReady",
|
|
1276
|
-
"widgetReady",
|
|
1277
|
-
"widgetExpand",
|
|
1278
|
-
"widgetCollapse",
|
|
1279
|
-
"widgetAudioSettings",
|
|
1280
|
-
"widgetDragStart",
|
|
1281
|
-
"widgetDragMove",
|
|
1282
|
-
"widgetDragEnd"
|
|
1283
|
-
]);
|
|
1284
|
-
function gt(e) {
|
|
1301
|
+
throw e instanceof DOMException && e.name === "SecurityError" ? Error(ht(n), { cause: e }) : e;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
var vt = new Set([1, 2]);
|
|
1305
|
+
function yt(e) {
|
|
1306
|
+
return typeof e == "number" && vt.has(e);
|
|
1307
|
+
}
|
|
1308
|
+
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".split("."));
|
|
1309
|
+
function xt(e) {
|
|
1285
1310
|
if (!e || typeof e != "object") return null;
|
|
1286
1311
|
let t = e;
|
|
1287
|
-
if (!
|
|
1312
|
+
if (!yt(t.schemaVersion) || !t.type || !bt.has(t.type)) return null;
|
|
1288
1313
|
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
1314
|
+
if (t.type === "fullWindow") {
|
|
1315
|
+
let e = t.payload;
|
|
1316
|
+
return !e || typeof e != "object" || typeof e.active != "boolean" ? null : t;
|
|
1317
|
+
}
|
|
1289
1318
|
if (t.type === "widgetAudioSettings") {
|
|
1290
1319
|
let e = t.payload;
|
|
1291
1320
|
return !e || typeof e != "object" || typeof e.open != "boolean" ? null : t;
|
|
@@ -1303,10 +1332,10 @@ function gt(e) {
|
|
|
1303
1332
|
let n = t.payload;
|
|
1304
1333
|
return !n || typeof n != "object" ? null : t;
|
|
1305
1334
|
}
|
|
1306
|
-
function
|
|
1335
|
+
function St(e, t, n) {
|
|
1307
1336
|
let r = e.trim();
|
|
1308
1337
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
1309
|
-
let i = n?.startButton, a = n?.showFeedback;
|
|
1338
|
+
let i = n?.startButton, a = n?.theme, o = n?.showFeedback;
|
|
1310
1339
|
return {
|
|
1311
1340
|
type: "launch",
|
|
1312
1341
|
schemaVersion: 2,
|
|
@@ -1314,24 +1343,25 @@ function _t(e, t, n) {
|
|
|
1314
1343
|
launch: r,
|
|
1315
1344
|
...t === void 0 ? {} : { session: t },
|
|
1316
1345
|
...i ? { startButton: i } : {},
|
|
1317
|
-
...a
|
|
1346
|
+
...a ? { theme: a } : {},
|
|
1347
|
+
...o === void 0 ? {} : { showFeedback: o }
|
|
1318
1348
|
}
|
|
1319
1349
|
};
|
|
1320
1350
|
}
|
|
1321
|
-
function
|
|
1351
|
+
function Ct() {
|
|
1322
1352
|
return {
|
|
1323
1353
|
type: "parentHello",
|
|
1324
1354
|
schemaVersion: 2
|
|
1325
1355
|
};
|
|
1326
1356
|
}
|
|
1327
|
-
function
|
|
1357
|
+
function wt(e) {
|
|
1328
1358
|
return {
|
|
1329
1359
|
type: "widgetSetChrome",
|
|
1330
1360
|
schemaVersion: 2,
|
|
1331
1361
|
payload: { mode: e }
|
|
1332
1362
|
};
|
|
1333
1363
|
}
|
|
1334
|
-
function
|
|
1364
|
+
function Tt() {
|
|
1335
1365
|
return {
|
|
1336
1366
|
type: "widgetToggleAudioSettings",
|
|
1337
1367
|
schemaVersion: 2,
|
|
@@ -1339,108 +1369,143 @@ function bt() {
|
|
|
1339
1369
|
};
|
|
1340
1370
|
}
|
|
1341
1371
|
//#endregion
|
|
1372
|
+
//#region src/v2/embed/fullWindowHost.ts
|
|
1373
|
+
var Et = "2147483000";
|
|
1374
|
+
function Dt(e) {
|
|
1375
|
+
let { style: t } = e;
|
|
1376
|
+
return {
|
|
1377
|
+
position: t.position,
|
|
1378
|
+
top: t.top,
|
|
1379
|
+
right: t.right,
|
|
1380
|
+
bottom: t.bottom,
|
|
1381
|
+
left: t.left,
|
|
1382
|
+
inset: t.inset,
|
|
1383
|
+
width: t.width,
|
|
1384
|
+
height: t.height,
|
|
1385
|
+
zIndex: t.zIndex,
|
|
1386
|
+
margin: t.margin,
|
|
1387
|
+
borderRadius: t.borderRadius,
|
|
1388
|
+
maxWidth: t.maxWidth,
|
|
1389
|
+
maxHeight: t.maxHeight
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
function Ot(e) {
|
|
1393
|
+
let { style: t } = e;
|
|
1394
|
+
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 = Et, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
|
|
1395
|
+
}
|
|
1396
|
+
function kt(e, t) {
|
|
1397
|
+
if (delete e.dataset.liformaFullWindow, !t) {
|
|
1398
|
+
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 = "";
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
let { style: n } = e;
|
|
1402
|
+
n.position = t.position, n.top = t.top, n.right = t.right, n.bottom = t.bottom, n.left = t.left, n.inset = t.inset, n.width = t.width, n.height = t.height, n.zIndex = t.zIndex, n.margin = t.margin, n.borderRadius = t.borderRadius, n.maxWidth = t.maxWidth, n.maxHeight = t.maxHeight;
|
|
1403
|
+
}
|
|
1404
|
+
//#endregion
|
|
1342
1405
|
//#region src/v2/embed/iframeHost.ts
|
|
1343
|
-
function
|
|
1406
|
+
function At(e) {
|
|
1344
1407
|
return e;
|
|
1345
1408
|
}
|
|
1346
1409
|
function Z() {
|
|
1347
1410
|
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)}`;
|
|
1348
1411
|
}
|
|
1349
|
-
var
|
|
1350
|
-
function
|
|
1412
|
+
var jt = 3e4;
|
|
1413
|
+
function Mt(e) {
|
|
1351
1414
|
let t = e.container;
|
|
1352
1415
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
1353
1416
|
let n = document.createElement("iframe");
|
|
1354
1417
|
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");
|
|
1355
|
-
let r = !1, i =
|
|
1356
|
-
|
|
1357
|
-
}), f = () => {
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1418
|
+
let r = !1, i = !1, a = null, o = t.closest(".liforma-experience-shell") instanceof HTMLElement ? t.closest(".liforma-experience-shell") : t, s = (t) => {
|
|
1419
|
+
i !== t && (i = t, t ? (a = Dt(o), Ot(o)) : (kt(o, a), a = null), e.onFullWindowChange?.(t));
|
|
1420
|
+
}, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
|
|
1421
|
+
p = e, m = t;
|
|
1422
|
+
}), g = () => {
|
|
1423
|
+
for (let e of f) window.clearTimeout(e);
|
|
1424
|
+
f.length = 0;
|
|
1425
|
+
}, _ = (t) => {
|
|
1361
1426
|
if (r) return;
|
|
1362
1427
|
let i = Date.now();
|
|
1363
|
-
if (
|
|
1364
|
-
|
|
1365
|
-
let a =
|
|
1428
|
+
if (d > 0 && i - d < 250) return;
|
|
1429
|
+
d = i, g();
|
|
1430
|
+
let a = St(t.launch, t.session, t.chrome), o = () => {
|
|
1366
1431
|
if (r) return;
|
|
1367
1432
|
let t = n.contentWindow;
|
|
1368
|
-
t &&
|
|
1433
|
+
t && _t(t, a, e.playerOrigin);
|
|
1369
1434
|
};
|
|
1370
1435
|
o();
|
|
1371
|
-
for (let e = 1; e <= 12; e += 1)
|
|
1372
|
-
},
|
|
1373
|
-
r || !
|
|
1374
|
-
},
|
|
1375
|
-
if (
|
|
1376
|
-
|
|
1436
|
+
for (let e = 1; e <= 12; e += 1) f.push(window.setTimeout(o, e * 75));
|
|
1437
|
+
}, v = () => {
|
|
1438
|
+
r || !l || _(l);
|
|
1439
|
+
}, y = () => {
|
|
1440
|
+
if (u += 1, u === 1) {
|
|
1441
|
+
gt(e.src, e.playerOrigin).then(() => p?.(), (e) => m?.(e instanceof Error ? e : Error(String(e))));
|
|
1377
1442
|
return;
|
|
1378
1443
|
}
|
|
1379
|
-
|
|
1380
|
-
},
|
|
1381
|
-
|
|
1444
|
+
d = 0, v();
|
|
1445
|
+
}, b = () => {
|
|
1446
|
+
u > 0 || m?.(Error(ht(e.playerOrigin)));
|
|
1382
1447
|
};
|
|
1383
|
-
n.addEventListener("load",
|
|
1384
|
-
let
|
|
1448
|
+
n.addEventListener("load", y), n.addEventListener("error", b);
|
|
1449
|
+
let x = (t) => {
|
|
1385
1450
|
if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
|
|
1386
|
-
let
|
|
1387
|
-
if (
|
|
1451
|
+
let i = xt(t.data);
|
|
1452
|
+
if (i) switch (i.type) {
|
|
1388
1453
|
case "close":
|
|
1389
|
-
e.onClose?.(
|
|
1454
|
+
e.onClose?.(i.payload);
|
|
1390
1455
|
break;
|
|
1391
1456
|
case "stateUpdate":
|
|
1392
|
-
e.onPlayerStatusChange?.(
|
|
1457
|
+
e.onPlayerStatusChange?.(i.payload.state), e.onStateUpdate?.(i.payload.state);
|
|
1393
1458
|
break;
|
|
1394
1459
|
case "commandResult": {
|
|
1395
|
-
let e =
|
|
1460
|
+
let e = c.get(i.payload.correlationId);
|
|
1396
1461
|
if (!e) return;
|
|
1397
|
-
|
|
1462
|
+
c.delete(i.payload.correlationId), i.payload.ok ? e.resolve(i.payload.result) : e.reject(Error(i.payload.error ?? "Command failed."));
|
|
1398
1463
|
break;
|
|
1399
1464
|
}
|
|
1400
1465
|
case "userTranscript":
|
|
1401
|
-
e.onUserTranscript?.(
|
|
1466
|
+
e.onUserTranscript?.(i.payload);
|
|
1402
1467
|
break;
|
|
1403
1468
|
case "characterSpeechStarted":
|
|
1404
|
-
e.onCharacterSpeechStarted?.(
|
|
1469
|
+
e.onCharacterSpeechStarted?.(i.payload);
|
|
1405
1470
|
break;
|
|
1406
1471
|
case "characterSpeechEnded":
|
|
1407
|
-
e.onCharacterSpeechEnded?.(
|
|
1472
|
+
e.onCharacterSpeechEnded?.(i.payload);
|
|
1408
1473
|
break;
|
|
1409
1474
|
case "characterFocusChanged":
|
|
1410
|
-
e.onCharacterFocusChanged?.(
|
|
1475
|
+
e.onCharacterFocusChanged?.(i.payload);
|
|
1411
1476
|
break;
|
|
1412
1477
|
case "conversationUpdate":
|
|
1413
|
-
e.onConversationUpdate?.(
|
|
1478
|
+
e.onConversationUpdate?.(i.payload.conversation);
|
|
1414
1479
|
break;
|
|
1415
1480
|
case "listeningState":
|
|
1416
|
-
e.onListeningState?.(
|
|
1481
|
+
e.onListeningState?.(i.payload.listening);
|
|
1417
1482
|
break;
|
|
1418
1483
|
case "userSpeechStarted":
|
|
1419
|
-
e.onUserSpeechStarted?.(
|
|
1484
|
+
e.onUserSpeechStarted?.(i.payload);
|
|
1420
1485
|
break;
|
|
1421
1486
|
case "userSpeechEnded":
|
|
1422
|
-
e.onUserSpeechEnded?.(
|
|
1487
|
+
e.onUserSpeechEnded?.(i.payload);
|
|
1423
1488
|
break;
|
|
1424
1489
|
case "modeChange":
|
|
1425
|
-
e.onActivityChange?.(
|
|
1490
|
+
e.onActivityChange?.(At(i.payload.mode));
|
|
1426
1491
|
break;
|
|
1427
1492
|
case "activityChange":
|
|
1428
|
-
e.onActivityChange?.(
|
|
1493
|
+
e.onActivityChange?.(i.payload.activity);
|
|
1429
1494
|
break;
|
|
1430
1495
|
case "feedback":
|
|
1431
|
-
e.onFeedback?.(
|
|
1496
|
+
e.onFeedback?.(i.payload);
|
|
1432
1497
|
break;
|
|
1433
1498
|
case "feedbackFailed":
|
|
1434
|
-
e.onFeedbackFailed?.(
|
|
1499
|
+
e.onFeedbackFailed?.(i.payload);
|
|
1435
1500
|
break;
|
|
1436
1501
|
case "message":
|
|
1437
|
-
e.onMessage?.(
|
|
1502
|
+
e.onMessage?.(i.payload);
|
|
1438
1503
|
break;
|
|
1439
1504
|
case "started":
|
|
1440
|
-
e.onStarted?.(
|
|
1505
|
+
e.onStarted?.(i.payload);
|
|
1441
1506
|
break;
|
|
1442
1507
|
case "embedReady":
|
|
1443
|
-
|
|
1508
|
+
v();
|
|
1444
1509
|
break;
|
|
1445
1510
|
case "widgetReady":
|
|
1446
1511
|
e.onWidgetReady?.();
|
|
@@ -1452,52 +1517,55 @@ function Ct(e) {
|
|
|
1452
1517
|
e.onWidgetCollapse?.();
|
|
1453
1518
|
break;
|
|
1454
1519
|
case "widgetAudioSettings":
|
|
1455
|
-
e.onWidgetAudioSettings?.(
|
|
1520
|
+
e.onWidgetAudioSettings?.(i.payload.open);
|
|
1456
1521
|
break;
|
|
1457
1522
|
case "widgetDragStart":
|
|
1458
|
-
e.onWidgetDragStart?.(
|
|
1523
|
+
e.onWidgetDragStart?.(i.payload);
|
|
1459
1524
|
break;
|
|
1460
1525
|
case "widgetDragMove":
|
|
1461
|
-
e.onWidgetDragMove?.(
|
|
1526
|
+
e.onWidgetDragMove?.(i.payload);
|
|
1462
1527
|
break;
|
|
1463
1528
|
case "widgetDragEnd":
|
|
1464
|
-
e.onWidgetDragEnd?.(
|
|
1529
|
+
e.onWidgetDragEnd?.(i.payload);
|
|
1530
|
+
break;
|
|
1531
|
+
case "fullWindow":
|
|
1532
|
+
s(i.payload.active);
|
|
1465
1533
|
break;
|
|
1466
1534
|
}
|
|
1467
1535
|
};
|
|
1468
|
-
if (window.addEventListener("message",
|
|
1536
|
+
if (window.addEventListener("message", x), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
|
|
1469
1537
|
let e = getComputedStyle(t).minHeight;
|
|
1470
1538
|
(e === "0px" || e === "auto") && (t.style.minHeight = "480px");
|
|
1471
1539
|
}
|
|
1472
|
-
let
|
|
1540
|
+
let S = (t, i) => {
|
|
1473
1541
|
if (r) return;
|
|
1474
1542
|
let a = n.contentWindow;
|
|
1475
|
-
if (!a) throw Error(
|
|
1476
|
-
|
|
1477
|
-
},
|
|
1543
|
+
if (!a) throw Error(ht(e.playerOrigin));
|
|
1544
|
+
_t(a, t, e.playerOrigin, i);
|
|
1545
|
+
}, C = (e, t = 12e4, n) => {
|
|
1478
1546
|
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Z();
|
|
1479
|
-
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((
|
|
1480
|
-
|
|
1481
|
-
resolve: (e) =>
|
|
1482
|
-
reject:
|
|
1483
|
-
}),
|
|
1484
|
-
|
|
1547
|
+
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((i, a) => {
|
|
1548
|
+
c.set(r, {
|
|
1549
|
+
resolve: (e) => i(e),
|
|
1550
|
+
reject: a
|
|
1551
|
+
}), S(e, n), setTimeout(() => {
|
|
1552
|
+
c.has(r) && (c.delete(r), a(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
|
|
1485
1553
|
}, t);
|
|
1486
1554
|
});
|
|
1487
1555
|
};
|
|
1488
1556
|
return {
|
|
1489
1557
|
waitForLoad() {
|
|
1490
|
-
return
|
|
1558
|
+
return h;
|
|
1491
1559
|
},
|
|
1492
1560
|
postParentHello() {
|
|
1493
|
-
|
|
1561
|
+
S(Ct());
|
|
1494
1562
|
},
|
|
1495
1563
|
postLaunch(e, t, n) {
|
|
1496
|
-
r || (
|
|
1564
|
+
r || (l = {
|
|
1497
1565
|
launch: e,
|
|
1498
1566
|
session: t,
|
|
1499
1567
|
chrome: n
|
|
1500
|
-
},
|
|
1568
|
+
}, d = 0, _(l));
|
|
1501
1569
|
},
|
|
1502
1570
|
postManifest(e) {
|
|
1503
1571
|
if (typeof e == "string") {
|
|
@@ -1512,13 +1580,13 @@ function Ct(e) {
|
|
|
1512
1580
|
throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
|
|
1513
1581
|
},
|
|
1514
1582
|
postWidgetSetChrome(e) {
|
|
1515
|
-
|
|
1583
|
+
S(wt(e));
|
|
1516
1584
|
},
|
|
1517
1585
|
postWidgetToggleAudioSettings() {
|
|
1518
|
-
|
|
1586
|
+
S(Tt());
|
|
1519
1587
|
},
|
|
1520
1588
|
speak(e) {
|
|
1521
|
-
return
|
|
1589
|
+
return C({
|
|
1522
1590
|
type: "speak",
|
|
1523
1591
|
schemaVersion: 2,
|
|
1524
1592
|
payload: {
|
|
@@ -1530,21 +1598,21 @@ function Ct(e) {
|
|
|
1530
1598
|
});
|
|
1531
1599
|
},
|
|
1532
1600
|
startListening() {
|
|
1533
|
-
return
|
|
1601
|
+
return C({
|
|
1534
1602
|
type: "startListening",
|
|
1535
1603
|
schemaVersion: 2,
|
|
1536
1604
|
payload: { correlationId: Z() }
|
|
1537
1605
|
});
|
|
1538
1606
|
},
|
|
1539
1607
|
stopListening() {
|
|
1540
|
-
return
|
|
1608
|
+
return C({
|
|
1541
1609
|
type: "stopListening",
|
|
1542
1610
|
schemaVersion: 2,
|
|
1543
1611
|
payload: { correlationId: Z() }
|
|
1544
1612
|
});
|
|
1545
1613
|
},
|
|
1546
1614
|
listenOnce(e) {
|
|
1547
|
-
return
|
|
1615
|
+
return C({
|
|
1548
1616
|
type: "listenOnce",
|
|
1549
1617
|
schemaVersion: 2,
|
|
1550
1618
|
payload: {
|
|
@@ -1554,7 +1622,7 @@ function Ct(e) {
|
|
|
1554
1622
|
});
|
|
1555
1623
|
},
|
|
1556
1624
|
async speakProcessorStream(e, t) {
|
|
1557
|
-
let n = Z(), r = Z(), i = (await
|
|
1625
|
+
let n = Z(), r = Z(), i = (await C({
|
|
1558
1626
|
type: "speakStreamStart",
|
|
1559
1627
|
schemaVersion: 2,
|
|
1560
1628
|
payload: {
|
|
@@ -1566,7 +1634,7 @@ function Ct(e) {
|
|
|
1566
1634
|
try {
|
|
1567
1635
|
for await (let n of e) {
|
|
1568
1636
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
1569
|
-
n &&
|
|
1637
|
+
n && S({
|
|
1570
1638
|
type: "speakStreamChunk",
|
|
1571
1639
|
schemaVersion: 2,
|
|
1572
1640
|
payload: {
|
|
@@ -1576,7 +1644,7 @@ function Ct(e) {
|
|
|
1576
1644
|
});
|
|
1577
1645
|
}
|
|
1578
1646
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
1579
|
-
return await
|
|
1647
|
+
return await C({
|
|
1580
1648
|
type: "speakStreamEnd",
|
|
1581
1649
|
schemaVersion: 2,
|
|
1582
1650
|
payload: {
|
|
@@ -1586,7 +1654,7 @@ function Ct(e) {
|
|
|
1586
1654
|
});
|
|
1587
1655
|
} catch (e) {
|
|
1588
1656
|
try {
|
|
1589
|
-
await
|
|
1657
|
+
await C({
|
|
1590
1658
|
type: "speakStreamEnd",
|
|
1591
1659
|
schemaVersion: 2,
|
|
1592
1660
|
payload: {
|
|
@@ -1600,7 +1668,7 @@ function Ct(e) {
|
|
|
1600
1668
|
},
|
|
1601
1669
|
speechPlay(e) {
|
|
1602
1670
|
let t = Z(), n = [];
|
|
1603
|
-
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data),
|
|
1671
|
+
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), C({
|
|
1604
1672
|
type: "speechPlay",
|
|
1605
1673
|
schemaVersion: 2,
|
|
1606
1674
|
payload: {
|
|
@@ -1614,7 +1682,7 @@ function Ct(e) {
|
|
|
1614
1682
|
}, 12e4, n);
|
|
1615
1683
|
},
|
|
1616
1684
|
speechUtteranceBegin(e) {
|
|
1617
|
-
return
|
|
1685
|
+
return C({
|
|
1618
1686
|
type: "speechUtteranceBegin",
|
|
1619
1687
|
schemaVersion: 2,
|
|
1620
1688
|
payload: {
|
|
@@ -1628,7 +1696,7 @@ function Ct(e) {
|
|
|
1628
1696
|
});
|
|
1629
1697
|
},
|
|
1630
1698
|
speechUtteranceWrite(e) {
|
|
1631
|
-
return
|
|
1699
|
+
return C({
|
|
1632
1700
|
type: "speechUtteranceWrite",
|
|
1633
1701
|
schemaVersion: 2,
|
|
1634
1702
|
payload: {
|
|
@@ -1637,10 +1705,10 @@ function Ct(e) {
|
|
|
1637
1705
|
audio: e.audio,
|
|
1638
1706
|
byteLength: e.byteLength
|
|
1639
1707
|
}
|
|
1640
|
-
},
|
|
1708
|
+
}, jt, [e.audio]);
|
|
1641
1709
|
},
|
|
1642
1710
|
speechUtteranceSetTranscript(e) {
|
|
1643
|
-
return
|
|
1711
|
+
return C({
|
|
1644
1712
|
type: "speechUtteranceSetTranscript",
|
|
1645
1713
|
schemaVersion: 2,
|
|
1646
1714
|
payload: {
|
|
@@ -1651,7 +1719,7 @@ function Ct(e) {
|
|
|
1651
1719
|
});
|
|
1652
1720
|
},
|
|
1653
1721
|
speechUtteranceClose(e) {
|
|
1654
|
-
return
|
|
1722
|
+
return C({
|
|
1655
1723
|
type: "speechUtteranceClose",
|
|
1656
1724
|
schemaVersion: 2,
|
|
1657
1725
|
payload: {
|
|
@@ -1663,7 +1731,7 @@ function Ct(e) {
|
|
|
1663
1731
|
});
|
|
1664
1732
|
},
|
|
1665
1733
|
speechUtteranceCancel(e) {
|
|
1666
|
-
return
|
|
1734
|
+
return C({
|
|
1667
1735
|
type: "speechUtteranceCancel",
|
|
1668
1736
|
schemaVersion: 2,
|
|
1669
1737
|
payload: {
|
|
@@ -1673,7 +1741,7 @@ function Ct(e) {
|
|
|
1673
1741
|
});
|
|
1674
1742
|
},
|
|
1675
1743
|
speechInterrupt(e) {
|
|
1676
|
-
return
|
|
1744
|
+
return C({
|
|
1677
1745
|
type: "speechInterrupt",
|
|
1678
1746
|
schemaVersion: 2,
|
|
1679
1747
|
payload: {
|
|
@@ -1683,14 +1751,14 @@ function Ct(e) {
|
|
|
1683
1751
|
});
|
|
1684
1752
|
},
|
|
1685
1753
|
getConversation() {
|
|
1686
|
-
return
|
|
1754
|
+
return C({
|
|
1687
1755
|
type: "getConversation",
|
|
1688
1756
|
schemaVersion: 2,
|
|
1689
1757
|
payload: { correlationId: Z() }
|
|
1690
1758
|
});
|
|
1691
1759
|
},
|
|
1692
1760
|
focusCharacter(e) {
|
|
1693
|
-
return
|
|
1761
|
+
return C({
|
|
1694
1762
|
type: "focusCharacter",
|
|
1695
1763
|
schemaVersion: 2,
|
|
1696
1764
|
payload: {
|
|
@@ -1700,7 +1768,7 @@ function Ct(e) {
|
|
|
1700
1768
|
});
|
|
1701
1769
|
},
|
|
1702
1770
|
setFit(e) {
|
|
1703
|
-
return
|
|
1771
|
+
return C({
|
|
1704
1772
|
type: "setFit",
|
|
1705
1773
|
schemaVersion: 2,
|
|
1706
1774
|
payload: {
|
|
@@ -1709,18 +1777,28 @@ function Ct(e) {
|
|
|
1709
1777
|
}
|
|
1710
1778
|
});
|
|
1711
1779
|
},
|
|
1780
|
+
conversion(e) {
|
|
1781
|
+
return C({
|
|
1782
|
+
type: "conversion",
|
|
1783
|
+
schemaVersion: 2,
|
|
1784
|
+
payload: {
|
|
1785
|
+
correlationId: Z(),
|
|
1786
|
+
key: e
|
|
1787
|
+
}
|
|
1788
|
+
});
|
|
1789
|
+
},
|
|
1712
1790
|
destroy() {
|
|
1713
1791
|
if (!r) {
|
|
1714
|
-
r = !0;
|
|
1715
|
-
for (let e of
|
|
1716
|
-
|
|
1792
|
+
r = !0, i && s(!1);
|
|
1793
|
+
for (let e of c.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
|
|
1794
|
+
c.clear(), g(), l = null, n.removeEventListener("load", y), n.removeEventListener("error", b), window.removeEventListener("message", x), n.remove();
|
|
1717
1795
|
}
|
|
1718
1796
|
}
|
|
1719
1797
|
};
|
|
1720
1798
|
}
|
|
1721
1799
|
//#endregion
|
|
1722
1800
|
//#region src/v2/embed/readyGate.ts
|
|
1723
|
-
function
|
|
1801
|
+
function Nt(e) {
|
|
1724
1802
|
let t, n = !1, r = !1, i = () => {
|
|
1725
1803
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
1726
1804
|
};
|
|
@@ -1735,50 +1813,50 @@ function wt(e) {
|
|
|
1735
1813
|
}
|
|
1736
1814
|
//#endregion
|
|
1737
1815
|
//#region src/v2/shims/embedBaseUrl.ts
|
|
1738
|
-
var
|
|
1739
|
-
function
|
|
1816
|
+
var Pt = "https://player.liforma.ai/embed", Ft = "http://localhost:3002/embed";
|
|
1817
|
+
function It() {
|
|
1740
1818
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1741
1819
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1742
1820
|
if (typeof document > "u") return null;
|
|
1743
1821
|
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();
|
|
1744
1822
|
return t ? t.replace(/\/$/, "") : null;
|
|
1745
1823
|
}
|
|
1746
|
-
function
|
|
1747
|
-
let e =
|
|
1748
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` :
|
|
1824
|
+
function Lt() {
|
|
1825
|
+
let e = It();
|
|
1826
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : B() ? Ft : Pt;
|
|
1749
1827
|
}
|
|
1750
|
-
function
|
|
1828
|
+
function Rt(e, t) {
|
|
1751
1829
|
return e?.trim() || t?.trim() || void 0;
|
|
1752
1830
|
}
|
|
1753
|
-
function
|
|
1754
|
-
let c = (e ??
|
|
1831
|
+
function zt(e, t, n, r, i, a, o, s) {
|
|
1832
|
+
let c = (e ?? Lt()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
|
|
1755
1833
|
d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
|
|
1756
1834
|
let f = r?.trim();
|
|
1757
|
-
return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)),
|
|
1835
|
+
return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)), Bt(u.toString());
|
|
1758
1836
|
}
|
|
1759
|
-
function
|
|
1837
|
+
function Bt(e) {
|
|
1760
1838
|
if (typeof location > "u") return e;
|
|
1761
1839
|
let t = new URL(e);
|
|
1762
1840
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1763
1841
|
}
|
|
1764
|
-
function
|
|
1842
|
+
function Vt(e) {
|
|
1765
1843
|
return new URL(e).origin;
|
|
1766
1844
|
}
|
|
1767
1845
|
//#endregion
|
|
1768
1846
|
//#region src/v2/experienceEvents.ts
|
|
1769
|
-
function
|
|
1847
|
+
function Ht() {
|
|
1770
1848
|
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)}`;
|
|
1771
1849
|
}
|
|
1772
|
-
function
|
|
1850
|
+
function Ut(e, t, n) {
|
|
1773
1851
|
return {
|
|
1774
|
-
id:
|
|
1852
|
+
id: Ht(),
|
|
1775
1853
|
type: e,
|
|
1776
1854
|
sessionId: t,
|
|
1777
1855
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1778
1856
|
data: n
|
|
1779
1857
|
};
|
|
1780
1858
|
}
|
|
1781
|
-
function
|
|
1859
|
+
function Wt() {
|
|
1782
1860
|
return {
|
|
1783
1861
|
ready: /* @__PURE__ */ new Set(),
|
|
1784
1862
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1797,39 +1875,39 @@ function Ft() {
|
|
|
1797
1875
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1798
1876
|
};
|
|
1799
1877
|
}
|
|
1800
|
-
function
|
|
1878
|
+
function Gt(e, t, n) {
|
|
1801
1879
|
return e[t].add(n), () => e[t].delete(n);
|
|
1802
1880
|
}
|
|
1803
|
-
function
|
|
1881
|
+
function Kt(e, t, n) {
|
|
1804
1882
|
for (let r of e[t]) r(n);
|
|
1805
1883
|
}
|
|
1806
|
-
function
|
|
1884
|
+
function qt(e) {
|
|
1807
1885
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1808
1886
|
}
|
|
1809
1887
|
//#endregion
|
|
1810
1888
|
//#region src/v2/speech/types.ts
|
|
1811
|
-
function
|
|
1889
|
+
function Jt(e) {
|
|
1812
1890
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1813
1891
|
}
|
|
1814
|
-
function
|
|
1892
|
+
function Yt(e) {
|
|
1815
1893
|
return "url" in e && typeof e.url == "string";
|
|
1816
1894
|
}
|
|
1817
|
-
function
|
|
1895
|
+
function Xt(e) {
|
|
1818
1896
|
if (!("track" in e)) return !1;
|
|
1819
1897
|
let t = e.track;
|
|
1820
1898
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1821
1899
|
}
|
|
1822
|
-
function
|
|
1823
|
-
return !
|
|
1900
|
+
function Zt(e) {
|
|
1901
|
+
return !Jt(e) && !Yt(e) && !Xt(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1824
1902
|
}
|
|
1825
|
-
var
|
|
1903
|
+
var Qt = [
|
|
1826
1904
|
8e3,
|
|
1827
1905
|
16e3,
|
|
1828
1906
|
22050,
|
|
1829
1907
|
24e3,
|
|
1830
1908
|
44100,
|
|
1831
1909
|
48e3
|
|
1832
|
-
],
|
|
1910
|
+
], $t = {
|
|
1833
1911
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1834
1912
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1835
1913
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1840,14 +1918,14 @@ var Ut = [
|
|
|
1840
1918
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1841
1919
|
MAX_PENDING_WRITES: 8,
|
|
1842
1920
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1843
|
-
},
|
|
1921
|
+
}, en = class extends Error {
|
|
1844
1922
|
operation;
|
|
1845
1923
|
requiredCapability;
|
|
1846
1924
|
name = "UnsupportedSpeechOperationError";
|
|
1847
1925
|
constructor(e, t) {
|
|
1848
1926
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1849
1927
|
}
|
|
1850
|
-
},
|
|
1928
|
+
}, tn = class extends Error {
|
|
1851
1929
|
name = "SpeechUtteranceClosedError";
|
|
1852
1930
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1853
1931
|
super(e);
|
|
@@ -1857,72 +1935,72 @@ var Ut = [
|
|
|
1857
1935
|
constructor(e, t) {
|
|
1858
1936
|
super(e, t);
|
|
1859
1937
|
}
|
|
1860
|
-
},
|
|
1938
|
+
}, nn = class extends Error {
|
|
1861
1939
|
name = "SpeechBufferTimeoutError";
|
|
1862
1940
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1863
1941
|
super(e);
|
|
1864
1942
|
}
|
|
1865
1943
|
};
|
|
1866
|
-
function
|
|
1944
|
+
function rn(e = "none") {
|
|
1867
1945
|
return {
|
|
1868
1946
|
mode: e,
|
|
1869
1947
|
trackedDurationMs: 0,
|
|
1870
1948
|
fallbackDurationMs: 0
|
|
1871
1949
|
};
|
|
1872
1950
|
}
|
|
1873
|
-
function
|
|
1874
|
-
return
|
|
1951
|
+
function an(e) {
|
|
1952
|
+
return Qt.includes(e);
|
|
1875
1953
|
}
|
|
1876
|
-
function
|
|
1954
|
+
function on(e) {
|
|
1877
1955
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
1878
1956
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
1879
|
-
if (!
|
|
1957
|
+
if (!an(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1880
1958
|
}
|
|
1881
|
-
function
|
|
1882
|
-
if (
|
|
1883
|
-
|
|
1959
|
+
function sn(e) {
|
|
1960
|
+
if (Jt(e)) {
|
|
1961
|
+
on(e.format);
|
|
1884
1962
|
return;
|
|
1885
1963
|
}
|
|
1886
|
-
if (
|
|
1964
|
+
if (Yt(e)) {
|
|
1887
1965
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
1888
|
-
if (e.sampleRate !== void 0 && !
|
|
1966
|
+
if (e.sampleRate !== void 0 && !an(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1889
1967
|
return;
|
|
1890
1968
|
}
|
|
1891
|
-
if (
|
|
1969
|
+
if (Xt(e)) {
|
|
1892
1970
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
1893
|
-
if (e.sampleRate !== void 0 && !
|
|
1971
|
+
if (e.sampleRate !== void 0 && !an(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1894
1972
|
return;
|
|
1895
1973
|
}
|
|
1896
|
-
if (
|
|
1974
|
+
if (Zt(e)) {
|
|
1897
1975
|
let t = e.encoding.trim().toLowerCase();
|
|
1898
1976
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
1899
1977
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1900
|
-
if (e.sampleRate !== void 0 && !
|
|
1978
|
+
if (e.sampleRate !== void 0 && !an(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1901
1979
|
return;
|
|
1902
1980
|
}
|
|
1903
1981
|
throw new Q("Unsupported speech.play audio shape.");
|
|
1904
1982
|
}
|
|
1905
|
-
function
|
|
1906
|
-
if (e.format) return
|
|
1983
|
+
function cn(e) {
|
|
1984
|
+
if (e.format) return on(e.format), e.format;
|
|
1907
1985
|
if (e.track) {
|
|
1908
1986
|
let t = {
|
|
1909
1987
|
encoding: "pcm_s16le",
|
|
1910
1988
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1911
1989
|
channels: 1
|
|
1912
1990
|
};
|
|
1913
|
-
return
|
|
1991
|
+
return on(t), t;
|
|
1914
1992
|
}
|
|
1915
1993
|
throw new Q("createUtterance requires format or track.");
|
|
1916
1994
|
}
|
|
1917
|
-
function
|
|
1995
|
+
function ln(e) {
|
|
1918
1996
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1919
1997
|
}
|
|
1920
|
-
function
|
|
1998
|
+
function un(e) {
|
|
1921
1999
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1922
2000
|
}
|
|
1923
2001
|
//#endregion
|
|
1924
2002
|
//#region src/byo/pcm.ts
|
|
1925
|
-
function
|
|
2003
|
+
function dn(e) {
|
|
1926
2004
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1927
2005
|
for (let t = 0; t < e.length; t++) {
|
|
1928
2006
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1932,11 +2010,11 @@ function tn(e) {
|
|
|
1932
2010
|
}
|
|
1933
2011
|
//#endregion
|
|
1934
2012
|
//#region src/byo/resample.ts
|
|
1935
|
-
function
|
|
2013
|
+
function fn(e, t, n, r, i) {
|
|
1936
2014
|
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;
|
|
1937
2015
|
return ((a * i + o) * i + s) * i + c;
|
|
1938
2016
|
}
|
|
1939
|
-
function
|
|
2017
|
+
function pn(e, t) {
|
|
1940
2018
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1941
2019
|
if (e === t) return {
|
|
1942
2020
|
fromRate: e,
|
|
@@ -1959,7 +2037,7 @@ function rn(e, t) {
|
|
|
1959
2037
|
let a = [];
|
|
1960
2038
|
for (; i + 2 < r.length - 1;) {
|
|
1961
2039
|
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);
|
|
1962
|
-
a.push(
|
|
2040
|
+
a.push(fn(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1963
2041
|
}
|
|
1964
2042
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1965
2043
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1971,7 +2049,7 @@ function rn(e, t) {
|
|
|
1971
2049
|
}
|
|
1972
2050
|
//#endregion
|
|
1973
2051
|
//#region src/byo/audioCapture.ts
|
|
1974
|
-
var
|
|
2052
|
+
var mn = "liforma-pcm-capture", hn = `
|
|
1975
2053
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1976
2054
|
process(inputs) {
|
|
1977
2055
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1983,29 +2061,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1983
2061
|
return true;
|
|
1984
2062
|
}
|
|
1985
2063
|
}
|
|
1986
|
-
registerProcessor('${
|
|
1987
|
-
`,
|
|
1988
|
-
function
|
|
1989
|
-
return
|
|
2064
|
+
registerProcessor('${mn}', LiformaPcmCaptureProcessor);
|
|
2065
|
+
`, gn = null;
|
|
2066
|
+
function _n() {
|
|
2067
|
+
return gn ||= URL.createObjectURL(new Blob([hn], { type: "application/javascript" })), gn;
|
|
1990
2068
|
}
|
|
1991
|
-
function
|
|
2069
|
+
function vn() {
|
|
1992
2070
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1993
2071
|
}
|
|
1994
|
-
async function
|
|
1995
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
2072
|
+
async function yn(e) {
|
|
2073
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = vn();
|
|
1996
2074
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1997
2075
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1998
2076
|
l.gain.value = 0;
|
|
1999
|
-
let u = s.sampleRate, d =
|
|
2077
|
+
let u = s.sampleRate, d = pn(u, n), f = !1, p = !1, m = (e) => {
|
|
2000
2078
|
if (f || i && !i()) return;
|
|
2001
2079
|
let t = d.push(e);
|
|
2002
|
-
t.length !== 0 && r(
|
|
2080
|
+
t.length !== 0 && r(dn(t));
|
|
2003
2081
|
}, h = () => void 0;
|
|
2004
2082
|
return await (async () => {
|
|
2005
2083
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
2006
2084
|
try {
|
|
2007
|
-
await s.audioWorklet.addModule(
|
|
2008
|
-
let e = new AudioWorkletNode(s,
|
|
2085
|
+
await s.audioWorklet.addModule(_n());
|
|
2086
|
+
let e = new AudioWorkletNode(s, mn, {
|
|
2009
2087
|
numberOfInputs: 1,
|
|
2010
2088
|
numberOfOutputs: 1,
|
|
2011
2089
|
outputChannelCount: [1]
|
|
@@ -2055,7 +2133,7 @@ async function un(e) {
|
|
|
2055
2133
|
}
|
|
2056
2134
|
//#endregion
|
|
2057
2135
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
2058
|
-
async function
|
|
2136
|
+
async function bn(e) {
|
|
2059
2137
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
2060
2138
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
2061
2139
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -2064,18 +2142,18 @@ async function dn(e) {
|
|
|
2064
2142
|
s || (s = !0, c?.stop(), c = null);
|
|
2065
2143
|
};
|
|
2066
2144
|
try {
|
|
2067
|
-
c = await
|
|
2145
|
+
c = await yn({
|
|
2068
2146
|
mediaStream: a,
|
|
2069
2147
|
targetSampleRate: r,
|
|
2070
2148
|
shouldSend: () => !s && !i?.aborted,
|
|
2071
2149
|
onPcm: (e) => {
|
|
2072
2150
|
if (s || i?.aborted) return;
|
|
2073
|
-
let t =
|
|
2151
|
+
let t = ln(e);
|
|
2074
2152
|
o = o.then(async () => {
|
|
2075
2153
|
if (s || i?.aborted) return;
|
|
2076
2154
|
let e = 0;
|
|
2077
2155
|
for (; e < t.byteLength;) {
|
|
2078
|
-
let r = Math.min(e +
|
|
2156
|
+
let r = Math.min(e + $t.MAX_CHUNK_BYTES, t.byteLength);
|
|
2079
2157
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
2080
2158
|
let i = t.subarray(e, r);
|
|
2081
2159
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -2099,10 +2177,10 @@ async function dn(e) {
|
|
|
2099
2177
|
}
|
|
2100
2178
|
//#endregion
|
|
2101
2179
|
//#region src/v2/speech/speechController.ts
|
|
2102
|
-
async function
|
|
2103
|
-
if (
|
|
2104
|
-
if (
|
|
2105
|
-
let t =
|
|
2180
|
+
async function xn(e, t) {
|
|
2181
|
+
if (Xt(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
2182
|
+
if (Jt(e)) {
|
|
2183
|
+
let t = ln(e.data);
|
|
2106
2184
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
2107
2185
|
return {
|
|
2108
2186
|
kind: "pcm",
|
|
@@ -2110,17 +2188,17 @@ async function fn(e, t) {
|
|
|
2110
2188
|
format: e.format
|
|
2111
2189
|
};
|
|
2112
2190
|
}
|
|
2113
|
-
if (
|
|
2191
|
+
if (Yt(e)) return {
|
|
2114
2192
|
kind: "url",
|
|
2115
2193
|
url: e.url.trim(),
|
|
2116
2194
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2117
2195
|
};
|
|
2118
|
-
if (!
|
|
2196
|
+
if (!Zt(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
2119
2197
|
let n;
|
|
2120
2198
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
2121
2199
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2122
2200
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
2123
|
-
} else n =
|
|
2201
|
+
} else n = ln(e.data);
|
|
2124
2202
|
return {
|
|
2125
2203
|
kind: "encoded",
|
|
2126
2204
|
data: n.slice().buffer,
|
|
@@ -2128,10 +2206,10 @@ async function fn(e, t) {
|
|
|
2128
2206
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2129
2207
|
};
|
|
2130
2208
|
}
|
|
2131
|
-
function
|
|
2209
|
+
function Sn() {
|
|
2132
2210
|
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)}`;
|
|
2133
2211
|
}
|
|
2134
|
-
function
|
|
2212
|
+
function Cn(e, t = "completed") {
|
|
2135
2213
|
return {
|
|
2136
2214
|
utteranceId: e.speechId,
|
|
2137
2215
|
characterId: e.characterId,
|
|
@@ -2145,13 +2223,13 @@ function mn(e, t = "completed") {
|
|
|
2145
2223
|
}
|
|
2146
2224
|
};
|
|
2147
2225
|
}
|
|
2148
|
-
function
|
|
2226
|
+
function wn(e) {
|
|
2149
2227
|
return e instanceof Error ? e : new Q(String(e));
|
|
2150
2228
|
}
|
|
2151
|
-
function
|
|
2229
|
+
function Tn(e) {
|
|
2152
2230
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
2153
2231
|
}
|
|
2154
|
-
var
|
|
2232
|
+
var En = class {
|
|
2155
2233
|
id;
|
|
2156
2234
|
characterId;
|
|
2157
2235
|
result;
|
|
@@ -2180,29 +2258,29 @@ var _n = class {
|
|
|
2180
2258
|
queue: e.queue,
|
|
2181
2259
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
2182
2260
|
}).catch((e) => {
|
|
2183
|
-
throw this.fail(
|
|
2261
|
+
throw this.fail(wn(e)), wn(e);
|
|
2184
2262
|
}), this.signal?.addEventListener("abort", () => {
|
|
2185
2263
|
this.cancel();
|
|
2186
2264
|
}, { once: !0 });
|
|
2187
2265
|
}
|
|
2188
2266
|
async write(e, t) {
|
|
2189
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2190
|
-
let n =
|
|
2267
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new tn();
|
|
2268
|
+
let n = ln(e);
|
|
2191
2269
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
2192
|
-
if (n.byteLength >
|
|
2270
|
+
if (n.byteLength > $t.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${$t.MAX_CHUNK_BYTES}).`);
|
|
2193
2271
|
if (n.byteLength === 0) return;
|
|
2194
|
-
let r = t?.timeoutMs ??
|
|
2272
|
+
let r = t?.timeoutMs ?? $t.DEFAULT_WRITE_TIMEOUT_MS;
|
|
2195
2273
|
await this.acquireWriteSlot(r);
|
|
2196
2274
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
2197
|
-
if (this.bufferedMs + i >
|
|
2275
|
+
if (this.bufferedMs + i > $t.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
2198
2276
|
let a = async () => {
|
|
2199
|
-
if (this.closed || this.settled) throw new
|
|
2277
|
+
if (this.closed || this.settled) throw new tn();
|
|
2200
2278
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
2201
2279
|
utteranceId: this.id,
|
|
2202
2280
|
audio: t.buffer,
|
|
2203
2281
|
byteLength: t.byteLength
|
|
2204
2282
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
2205
|
-
setTimeout(() => t(new
|
|
2283
|
+
setTimeout(() => t(new nn()), r);
|
|
2206
2284
|
})]);
|
|
2207
2285
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
2208
2286
|
}, o = this.writeChain.then(a, a);
|
|
@@ -2214,7 +2292,7 @@ var _n = class {
|
|
|
2214
2292
|
}
|
|
2215
2293
|
}
|
|
2216
2294
|
async setTranscript(e) {
|
|
2217
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2295
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new tn();
|
|
2218
2296
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
2219
2297
|
utteranceId: this.id,
|
|
2220
2298
|
transcript: e
|
|
@@ -2231,7 +2309,7 @@ var _n = class {
|
|
|
2231
2309
|
});
|
|
2232
2310
|
return this.resolve(t), t;
|
|
2233
2311
|
} catch (e) {
|
|
2234
|
-
let t =
|
|
2312
|
+
let t = wn(e);
|
|
2235
2313
|
throw this.fail(t), t;
|
|
2236
2314
|
}
|
|
2237
2315
|
}
|
|
@@ -2249,11 +2327,11 @@ var _n = class {
|
|
|
2249
2327
|
characterId: this.characterId,
|
|
2250
2328
|
status: "cancelled",
|
|
2251
2329
|
durationMs: 0,
|
|
2252
|
-
animation:
|
|
2330
|
+
animation: rn("none")
|
|
2253
2331
|
};
|
|
2254
2332
|
return this.resolve(t), t;
|
|
2255
2333
|
} catch (e) {
|
|
2256
|
-
let t =
|
|
2334
|
+
let t = wn(e);
|
|
2257
2335
|
throw this.fail(t), t;
|
|
2258
2336
|
}
|
|
2259
2337
|
}
|
|
@@ -2266,19 +2344,19 @@ var _n = class {
|
|
|
2266
2344
|
return e;
|
|
2267
2345
|
}
|
|
2268
2346
|
resolve(e) {
|
|
2269
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2347
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new tn()));
|
|
2270
2348
|
}
|
|
2271
2349
|
fail(e) {
|
|
2272
2350
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
2273
2351
|
}
|
|
2274
2352
|
async acquireWriteSlot(e) {
|
|
2275
|
-
if (this.pendingWriteCount <
|
|
2353
|
+
if (this.pendingWriteCount < $t.MAX_PENDING_WRITES) {
|
|
2276
2354
|
this.pendingWriteCount += 1;
|
|
2277
2355
|
return;
|
|
2278
2356
|
}
|
|
2279
2357
|
await new Promise((t, n) => {
|
|
2280
2358
|
let r = setTimeout(() => {
|
|
2281
|
-
n(new
|
|
2359
|
+
n(new nn());
|
|
2282
2360
|
}, e);
|
|
2283
2361
|
this.pendingWriteWaiters.push({
|
|
2284
2362
|
resolve: () => {
|
|
@@ -2297,13 +2375,13 @@ var _n = class {
|
|
|
2297
2375
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2298
2376
|
}
|
|
2299
2377
|
};
|
|
2300
|
-
function
|
|
2378
|
+
function Dn(e) {
|
|
2301
2379
|
let t = null, n = (t, n) => {
|
|
2302
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2380
|
+
if (!e.getCapabilities()[n]) throw new en(t, n);
|
|
2303
2381
|
}, r = {
|
|
2304
2382
|
async speak(r) {
|
|
2305
2383
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2306
|
-
let i =
|
|
2384
|
+
let i = un(r.queue ?? "append");
|
|
2307
2385
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2308
2386
|
let a = e.getIframeHost();
|
|
2309
2387
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -2323,41 +2401,41 @@ function vn(e) {
|
|
|
2323
2401
|
return;
|
|
2324
2402
|
}
|
|
2325
2403
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2326
|
-
t.removeEventListener("abort", s), n(
|
|
2404
|
+
t.removeEventListener("abort", s), n(Cn(e, "completed"));
|
|
2327
2405
|
}, (a) => {
|
|
2328
|
-
if (t.removeEventListener("abort", s),
|
|
2406
|
+
if (t.removeEventListener("abort", s), Tn(a)) {
|
|
2329
2407
|
n({
|
|
2330
2408
|
utteranceId: "utt_interrupted",
|
|
2331
2409
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2332
2410
|
status: "interrupted",
|
|
2333
2411
|
durationMs: 0,
|
|
2334
2412
|
transcript: r.text,
|
|
2335
|
-
animation:
|
|
2413
|
+
animation: rn("none")
|
|
2336
2414
|
});
|
|
2337
2415
|
return;
|
|
2338
2416
|
}
|
|
2339
|
-
i(
|
|
2417
|
+
i(wn(a));
|
|
2340
2418
|
});
|
|
2341
2419
|
});
|
|
2342
2420
|
}
|
|
2343
2421
|
try {
|
|
2344
|
-
return
|
|
2422
|
+
return Cn(await o, "completed");
|
|
2345
2423
|
} catch (t) {
|
|
2346
|
-
if (
|
|
2424
|
+
if (Tn(t)) return {
|
|
2347
2425
|
utteranceId: "utt_interrupted",
|
|
2348
2426
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2349
2427
|
status: "interrupted",
|
|
2350
2428
|
durationMs: 0,
|
|
2351
2429
|
transcript: r.text,
|
|
2352
|
-
animation:
|
|
2430
|
+
animation: rn("none")
|
|
2353
2431
|
};
|
|
2354
|
-
throw
|
|
2432
|
+
throw wn(t);
|
|
2355
2433
|
}
|
|
2356
2434
|
},
|
|
2357
2435
|
async play(i) {
|
|
2358
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2436
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), sn(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2359
2437
|
let a = i.queue ?? "append";
|
|
2360
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2438
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), Xt(i.audio)) {
|
|
2361
2439
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2362
2440
|
return r.createUtterance({
|
|
2363
2441
|
format: {
|
|
@@ -2373,7 +2451,7 @@ function vn(e) {
|
|
|
2373
2451
|
}
|
|
2374
2452
|
let o = e.getIframeHost();
|
|
2375
2453
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2376
|
-
let s = await
|
|
2454
|
+
let s = await xn(i.audio, i.signal);
|
|
2377
2455
|
return o.speechPlay({
|
|
2378
2456
|
source: s,
|
|
2379
2457
|
characterId: i.characterId,
|
|
@@ -2385,13 +2463,13 @@ function vn(e) {
|
|
|
2385
2463
|
},
|
|
2386
2464
|
createUtterance(r) {
|
|
2387
2465
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2388
|
-
let i =
|
|
2466
|
+
let i = cn(r);
|
|
2389
2467
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2390
2468
|
let a = r.queue ?? "replace-active";
|
|
2391
2469
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2392
2470
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2393
|
-
let o = new
|
|
2394
|
-
id:
|
|
2471
|
+
let o = new En({
|
|
2472
|
+
id: Sn(),
|
|
2395
2473
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2396
2474
|
format: i,
|
|
2397
2475
|
queue: a,
|
|
@@ -2403,7 +2481,7 @@ function vn(e) {
|
|
|
2403
2481
|
t === o && (t = null);
|
|
2404
2482
|
}), r.track && (async () => {
|
|
2405
2483
|
try {
|
|
2406
|
-
if (await
|
|
2484
|
+
if (await bn({
|
|
2407
2485
|
track: r.track,
|
|
2408
2486
|
utterance: o,
|
|
2409
2487
|
sampleRate: i.sampleRate,
|
|
@@ -2431,16 +2509,16 @@ function vn(e) {
|
|
|
2431
2509
|
}
|
|
2432
2510
|
//#endregion
|
|
2433
2511
|
//#region src/v2/types/sessionInteraction.ts
|
|
2434
|
-
function
|
|
2512
|
+
function On(e) {
|
|
2435
2513
|
let t = e?.trim();
|
|
2436
2514
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2437
2515
|
}
|
|
2438
2516
|
//#endregion
|
|
2439
2517
|
//#region src/v2/experience.ts
|
|
2440
|
-
function
|
|
2518
|
+
function kn(e) {
|
|
2441
2519
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2442
2520
|
}
|
|
2443
|
-
var
|
|
2521
|
+
var An = class e {
|
|
2444
2522
|
bootstrap;
|
|
2445
2523
|
conversationProcessor;
|
|
2446
2524
|
iframeHost = null;
|
|
@@ -2455,16 +2533,16 @@ var xn = class e {
|
|
|
2455
2533
|
attached = !1;
|
|
2456
2534
|
pendingFit = null;
|
|
2457
2535
|
closeHandlers = [];
|
|
2458
|
-
eventRegistry =
|
|
2536
|
+
eventRegistry = Wt();
|
|
2459
2537
|
readyEnvelope = null;
|
|
2460
2538
|
startedEnvelope = null;
|
|
2461
2539
|
conversationCache = [];
|
|
2462
2540
|
speech;
|
|
2463
2541
|
constructor(e) {
|
|
2464
|
-
this.bootstrap = e, this.conversationProcessor = e.conversationProcessor ?? null, this.resolvedSession = e.kind === "launch" ? e.session ?? null : null, this.launchToken = e.kind === "launch" ? e.launch : null, this.speech =
|
|
2542
|
+
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 = Dn({
|
|
2465
2543
|
getIframeHost: () => this.iframeHost,
|
|
2466
2544
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2467
|
-
getCapabilities: () =>
|
|
2545
|
+
getCapabilities: () => jn(this.resolvedSession),
|
|
2468
2546
|
getActiveCharacterId: () => "character_unknown",
|
|
2469
2547
|
onProcessorInterrupt: () => {
|
|
2470
2548
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2508,6 +2586,7 @@ var xn = class e {
|
|
|
2508
2586
|
mode: t.mode,
|
|
2509
2587
|
speechInputMode: t.speechInputMode,
|
|
2510
2588
|
speechOnly: t.speechOnly,
|
|
2589
|
+
attribution: t.attribution,
|
|
2511
2590
|
ui: t.ui,
|
|
2512
2591
|
onStart: t.onStart,
|
|
2513
2592
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2529,6 +2608,7 @@ var xn = class e {
|
|
|
2529
2608
|
mode: t.mode,
|
|
2530
2609
|
speechInputMode: t.speechInputMode,
|
|
2531
2610
|
speechOnly: t.speechOnly,
|
|
2611
|
+
attribution: t.attribution,
|
|
2532
2612
|
ui: t.ui,
|
|
2533
2613
|
onStart: t.onStart,
|
|
2534
2614
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2543,7 +2623,7 @@ var xn = class e {
|
|
|
2543
2623
|
return null;
|
|
2544
2624
|
}
|
|
2545
2625
|
on(e, t) {
|
|
2546
|
-
let n =
|
|
2626
|
+
let n = Gt(this.eventRegistry, e, t);
|
|
2547
2627
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
|
|
2548
2628
|
}
|
|
2549
2629
|
async attach(e) {
|
|
@@ -2557,13 +2637,13 @@ var xn = class e {
|
|
|
2557
2637
|
if (this.closed) throw Error("Session has ended.");
|
|
2558
2638
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2559
2639
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2560
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2640
|
+
let t = this.bootstrap.embedBaseUrl ?? Lt(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = zt(t, n, r ? void 0 : Rt(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, kn(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = Vt(i), o = null, s = new Promise((e) => {
|
|
2561
2641
|
o = e;
|
|
2562
2642
|
}), c = null, l = new Promise((e) => {
|
|
2563
2643
|
c = e;
|
|
2564
|
-
}), u =
|
|
2644
|
+
}), u = Nt((e) => {
|
|
2565
2645
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
2566
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2646
|
+
}), d = this.bootstrap.onUserTranscript, f = Mt({
|
|
2567
2647
|
container: e.container,
|
|
2568
2648
|
src: i,
|
|
2569
2649
|
playerOrigin: a,
|
|
@@ -2626,7 +2706,7 @@ var xn = class e {
|
|
|
2626
2706
|
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
2627
2707
|
});
|
|
2628
2708
|
this.iframeHost = f;
|
|
2629
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
2709
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), ut(this.bootstrap.sessionEndpoint, {
|
|
2630
2710
|
experienceId: this.bootstrap.experienceId,
|
|
2631
2711
|
locale: this.bootstrap.locale,
|
|
2632
2712
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -2635,15 +2715,17 @@ var xn = class e {
|
|
|
2635
2715
|
mode: p.mode,
|
|
2636
2716
|
speechInputMode: p.speechInputMode,
|
|
2637
2717
|
speechOnly: this.bootstrap.speechOnly,
|
|
2718
|
+
attribution: this.bootstrap.attribution,
|
|
2638
2719
|
signal: this.endpointAbortController.signal
|
|
2639
|
-
})) : this.bootstrap.kind === "public" ?
|
|
2720
|
+
})) : this.bootstrap.kind === "public" ? lt(this.bootstrap.experienceId, {
|
|
2640
2721
|
locale: this.bootstrap.locale,
|
|
2641
2722
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
2642
2723
|
learningLocale: this.bootstrap.learningLocale,
|
|
2643
2724
|
language: this.bootstrap.language,
|
|
2644
2725
|
mode: p.mode,
|
|
2645
2726
|
speechInputMode: p.speechInputMode,
|
|
2646
|
-
speechOnly: this.bootstrap.speechOnly
|
|
2727
|
+
speechOnly: this.bootstrap.speechOnly,
|
|
2728
|
+
attribution: this.bootstrap.attribution
|
|
2647
2729
|
}) : Promise.resolve(this.bootstrap.session ? {
|
|
2648
2730
|
session: this.bootstrap.session,
|
|
2649
2731
|
launch: this.bootstrap.launch
|
|
@@ -2658,11 +2740,13 @@ var xn = class e {
|
|
|
2658
2740
|
f.postParentHello();
|
|
2659
2741
|
let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
2660
2742
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
2661
|
-
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" &&
|
|
2743
|
+
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && tt(_), f.postLaunch(g, _, {
|
|
2662
2744
|
startButton: e.startButton,
|
|
2745
|
+
theme: e.theme,
|
|
2663
2746
|
showFeedback: e.showFeedback
|
|
2664
2747
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
2665
2748
|
startButton: e.startButton,
|
|
2749
|
+
theme: e.theme,
|
|
2666
2750
|
showFeedback: e.showFeedback
|
|
2667
2751
|
}), await Promise.race([s, new Promise((e, t) => {
|
|
2668
2752
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
@@ -2692,11 +2776,16 @@ var xn = class e {
|
|
|
2692
2776
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2693
2777
|
}
|
|
2694
2778
|
async setFit(e) {
|
|
2695
|
-
let t =
|
|
2779
|
+
let t = On(e);
|
|
2696
2780
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2697
2781
|
if (this.closed) throw Error("Session has ended.");
|
|
2698
2782
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
2699
2783
|
}
|
|
2784
|
+
async conversion(e) {
|
|
2785
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2786
|
+
if (!this.iframeHost) throw Error("conversion() requires attach() first.");
|
|
2787
|
+
await this.iframeHost.conversion(e);
|
|
2788
|
+
}
|
|
2700
2789
|
getLastTurn() {
|
|
2701
2790
|
if (this.conversationCache.length === 0) return [];
|
|
2702
2791
|
let e = this.conversationCache[this.conversationCache.length - 1].turnId;
|
|
@@ -2706,7 +2795,7 @@ var xn = class e {
|
|
|
2706
2795
|
this.close();
|
|
2707
2796
|
}
|
|
2708
2797
|
destroy() {
|
|
2709
|
-
this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null,
|
|
2798
|
+
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, qt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
|
|
2710
2799
|
}
|
|
2711
2800
|
resolveMintInteraction() {
|
|
2712
2801
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2718,8 +2807,8 @@ var xn = class e {
|
|
|
2718
2807
|
return this.resolvedSession?.id ?? "";
|
|
2719
2808
|
}
|
|
2720
2809
|
emitWrapped(e, t) {
|
|
2721
|
-
let n =
|
|
2722
|
-
return
|
|
2810
|
+
let n = Ut(e, this.getSessionId(), t);
|
|
2811
|
+
return Kt(this.eventRegistry, e, n), n;
|
|
2723
2812
|
}
|
|
2724
2813
|
queueProcessorTurn(e) {
|
|
2725
2814
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2728,7 +2817,7 @@ var xn = class e {
|
|
|
2728
2817
|
let n = this.processorAbortController.signal;
|
|
2729
2818
|
this.processorChain = this.processorChain.then(async () => {
|
|
2730
2819
|
if (!n.aborted) try {
|
|
2731
|
-
let r = await
|
|
2820
|
+
let r = await pt(t, {
|
|
2732
2821
|
utteranceId: e.utteranceId,
|
|
2733
2822
|
text: e.text,
|
|
2734
2823
|
conversation: this.conversationCache,
|
|
@@ -2778,7 +2867,7 @@ var xn = class e {
|
|
|
2778
2867
|
};
|
|
2779
2868
|
}
|
|
2780
2869
|
};
|
|
2781
|
-
function
|
|
2870
|
+
function jn(e) {
|
|
2782
2871
|
return e ? {
|
|
2783
2872
|
textSpeech: e.capabilities.speech.output,
|
|
2784
2873
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2789,41 +2878,41 @@ function Sn(e) {
|
|
|
2789
2878
|
}
|
|
2790
2879
|
//#endregion
|
|
2791
2880
|
//#region src/widget/dockGeometry.ts
|
|
2792
|
-
var
|
|
2793
|
-
function
|
|
2881
|
+
var Mn = "(min-width: 768px)", Nn = 24, Pn = .5, Fn = 1200, In = .85, Ln = 9 / 16;
|
|
2882
|
+
function Rn() {
|
|
2794
2883
|
if (typeof window > "u") return 800;
|
|
2795
2884
|
let e = window.screen?.availHeight;
|
|
2796
2885
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2797
2886
|
}
|
|
2798
|
-
function
|
|
2799
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2800
|
-
return s > a && (s = a, o = s /
|
|
2887
|
+
function zn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Nn, r = typeof window < "u" ? Rn() : 800) {
|
|
2888
|
+
let i = Math.max(160, Math.min(t - n * 2, t * In)), a = Math.max(120, e - n * 2), o = Math.min(r * Pn, Fn, i), s = o * Ln;
|
|
2889
|
+
return s > a && (s = a, o = s / Ln, o > i && (o = i, s = o * Ln)), {
|
|
2801
2890
|
width: Math.round(s),
|
|
2802
2891
|
height: Math.round(o)
|
|
2803
2892
|
};
|
|
2804
2893
|
}
|
|
2805
|
-
function
|
|
2894
|
+
function Bn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Nn) {
|
|
2806
2895
|
return {
|
|
2807
2896
|
left: Math.max(r, t - e.width - r),
|
|
2808
2897
|
top: Math.max(r, n - e.height - r)
|
|
2809
2898
|
};
|
|
2810
2899
|
}
|
|
2811
|
-
function
|
|
2900
|
+
function Vn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Nn) {
|
|
2812
2901
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2813
2902
|
return {
|
|
2814
2903
|
left: Math.min(Math.max(a, e), o),
|
|
2815
2904
|
top: Math.min(Math.max(a, t), s)
|
|
2816
2905
|
};
|
|
2817
2906
|
}
|
|
2818
|
-
function
|
|
2819
|
-
return e(
|
|
2907
|
+
function Hn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2908
|
+
return e(Mn).matches;
|
|
2820
2909
|
}
|
|
2821
2910
|
//#endregion
|
|
2822
2911
|
//#region src/widget/mountExperienceWidget.ts
|
|
2823
|
-
function
|
|
2912
|
+
function Un(e) {
|
|
2824
2913
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2825
2914
|
}
|
|
2826
|
-
function
|
|
2915
|
+
function Wn(e) {
|
|
2827
2916
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2828
2917
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2829
2918
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2831,10 +2920,10 @@ function Fn(e) {
|
|
|
2831
2920
|
function $(e) {
|
|
2832
2921
|
return e === "expanded" || e === "docked";
|
|
2833
2922
|
}
|
|
2834
|
-
var
|
|
2835
|
-
function
|
|
2923
|
+
var Gn = "<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>", Kn = "<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>", 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=\"M18 10h-4V6m6-2l-6 6m-8 4h4v4m0-4l-6 6\"/></svg>", Jn = "<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>";
|
|
2924
|
+
function Yn(e, t, n) {
|
|
2836
2925
|
Oe(Ee);
|
|
2837
|
-
let r =
|
|
2926
|
+
let r = z({
|
|
2838
2927
|
galleryThumb: t.galleryThumb,
|
|
2839
2928
|
avatarImage: t.avatarImage,
|
|
2840
2929
|
backgroundImage: t.backgroundImage,
|
|
@@ -2862,7 +2951,7 @@ function Bn(e, t, n) {
|
|
|
2862
2951
|
}
|
|
2863
2952
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : Te(i);
|
|
2864
2953
|
}
|
|
2865
|
-
function
|
|
2954
|
+
function Xn(e) {
|
|
2866
2955
|
return e.startButton ? {
|
|
2867
2956
|
...e.startButton,
|
|
2868
2957
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2874,7 +2963,7 @@ function Vn(e) {
|
|
|
2874
2963
|
variant: "primary"
|
|
2875
2964
|
};
|
|
2876
2965
|
}
|
|
2877
|
-
function
|
|
2966
|
+
function Zn(e) {
|
|
2878
2967
|
let t = !1, n = () => {
|
|
2879
2968
|
t || e();
|
|
2880
2969
|
}, r = () => {
|
|
@@ -2894,12 +2983,12 @@ function Hn(e) {
|
|
|
2894
2983
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2895
2984
|
};
|
|
2896
2985
|
}
|
|
2897
|
-
function
|
|
2986
|
+
function Qn(e, t) {
|
|
2898
2987
|
Ne(je);
|
|
2899
2988
|
let n = t.experienceId?.trim();
|
|
2900
2989
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
2901
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
2902
|
-
a.className = "liforma-ew", a.dataset.state = "collapsed", a.dataset.prefetch = r, a.dataset.position = i, a.style.setProperty("--liforma-ew-max-w", t.expandedMaxWidth ?? "100%"), a.style.setProperty("--liforma-ew-max-h", t.expandedMaxHeight ?? "100%"), i !== "static" && a.style.setProperty("--liforma-ew-offset",
|
|
2990
|
+
let r = t.prefetch ?? "onExpand", i = Un(t.position), a = document.createElement("div");
|
|
2991
|
+
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", Wn(t.offset));
|
|
2903
2992
|
let o = document.createElement("button");
|
|
2904
2993
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2905
2994
|
let s = document.createElement("div");
|
|
@@ -2919,74 +3008,74 @@ function Un(e, t) {
|
|
|
2919
3008
|
let m = document.createElement("span");
|
|
2920
3009
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2921
3010
|
let h = document.createElement("button");
|
|
2922
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
3011
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = qn, h.setAttribute("aria-label", "Reduce");
|
|
2923
3012
|
let g = document.createElement("button");
|
|
2924
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
3013
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Gn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
2925
3014
|
let _ = document.createElement("button");
|
|
2926
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
3015
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = Kn, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
2927
3016
|
let v = document.createElement("div");
|
|
2928
3017
|
v.className = "liforma-ew__stage";
|
|
2929
3018
|
let y = document.createElement("div");
|
|
2930
3019
|
y.className = "liforma-ew__status", y.hidden = !0, f.append(v, y), u.append(d, f), a.append(o, l, u, p), e.replaceChildren(a);
|
|
2931
|
-
let b = null, x = !1, S = !1,
|
|
3020
|
+
let b = null, x = !1, S = !1, C = !1, w = !1, T = !1, E = !1, D = !1, O = 0, k = "", A = null, j = null, M = null, N = null, P = null, F = null, I = null, ee = 0, te = 0, ne = null, L = !1, re = new AbortController(), ie = t.parallax !== !1, R = () => {
|
|
2932
3021
|
let e = a.dataset.state;
|
|
2933
3022
|
return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
|
|
2934
|
-
},
|
|
2935
|
-
|
|
2936
|
-
}, ae = () => {
|
|
2937
|
-
M !== null && (clearTimeout(M), M = null), a.classList.remove("liforma-ew--layout-settling");
|
|
3023
|
+
}, z = () => {
|
|
3024
|
+
M !== null && (clearTimeout(M), M = null);
|
|
2938
3025
|
}, B = () => {
|
|
3026
|
+
N !== null && (clearTimeout(N), N = null), a.classList.remove("liforma-ew--layout-settling");
|
|
3027
|
+
}, ae = () => {
|
|
2939
3028
|
for (let e of [
|
|
2940
3029
|
f,
|
|
2941
3030
|
l,
|
|
2942
3031
|
p
|
|
2943
3032
|
]) e.style.removeProperty("left"), e.style.removeProperty("top"), e.style.removeProperty("width"), e.style.removeProperty("height"), e.style.removeProperty("right"), e.style.removeProperty("bottom");
|
|
2944
3033
|
p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging");
|
|
2945
|
-
},
|
|
3034
|
+
}, V = (e, t, n, r) => {
|
|
2946
3035
|
let i = (i) => {
|
|
2947
3036
|
i.style.left = `${e}px`, i.style.top = `${t}px`, i.style.width = `${n}px`, i.style.height = `${r}px`, i.style.right = "auto", i.style.bottom = "auto";
|
|
2948
3037
|
};
|
|
2949
3038
|
i(f), i(l);
|
|
2950
3039
|
let a = p.offsetWidth || 120;
|
|
2951
3040
|
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";
|
|
3041
|
+
}, oe = (e, t) => {
|
|
3042
|
+
if (R() !== "docked") return;
|
|
3043
|
+
let n = zn(), r = Vn(e - ee, t - te, n);
|
|
3044
|
+
P = r.left, F = r.top, V(r.left, r.top, n.width, n.height);
|
|
2952
3045
|
}, se = (e, t) => {
|
|
2953
|
-
if (
|
|
2954
|
-
let n =
|
|
2955
|
-
|
|
2956
|
-
}, ce = (e
|
|
2957
|
-
|
|
2958
|
-
let n = An(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = Mn(r + e, i + t, n);
|
|
2959
|
-
N = a.left, P = a.top, oe(a.left, a.top, n.width, n.height);
|
|
2960
|
-
}, le = (e) => {
|
|
2961
|
-
I === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), se(e.clientX, e.clientY)));
|
|
2962
|
-
}, V = (e) => {
|
|
2963
|
-
if (F === null || e && e.pointerId !== F) return;
|
|
2964
|
-
let t = I;
|
|
2965
|
-
F = null, I = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && L && (L = !1, window.removeEventListener("pointermove", le), window.removeEventListener("pointerup", V), window.removeEventListener("pointercancel", V));
|
|
2966
|
-
}, ue = (e, t, n) => {
|
|
2967
|
-
if (S || z() !== "docked" || !Nn() || F !== null) return;
|
|
2968
|
-
F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2969
|
-
let r = f.getBoundingClientRect();
|
|
2970
|
-
te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", le), window.addEventListener("pointerup", V), window.addEventListener("pointercancel", V));
|
|
3046
|
+
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
3047
|
+
let n = zn(), r = P ?? f.getBoundingClientRect().left, i = F ?? f.getBoundingClientRect().top, a = Vn(r + e, i + t, n);
|
|
3048
|
+
P = a.left, F = a.top, V(a.left, a.top, n.width, n.height);
|
|
3049
|
+
}, ce = (e) => {
|
|
3050
|
+
ne === "toolbar" && (I === null || e.pointerId !== I || (e.preventDefault(), oe(e.clientX, e.clientY)));
|
|
2971
3051
|
}, H = (e) => {
|
|
2972
|
-
if (
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
3052
|
+
if (I === null || e && e.pointerId !== I) return;
|
|
3053
|
+
let t = ne;
|
|
3054
|
+
I = null, ne = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && L && (L = !1, window.removeEventListener("pointermove", ce), window.removeEventListener("pointerup", H), window.removeEventListener("pointercancel", H));
|
|
3055
|
+
}, le = (e, t, n) => {
|
|
3056
|
+
if (S || R() !== "docked" || !Hn() || I !== null) return;
|
|
3057
|
+
I = n, ne = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3058
|
+
let r = f.getBoundingClientRect();
|
|
3059
|
+
ee = e - r.left, te = t - r.top, L || (L = !0, window.addEventListener("pointermove", ce), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H));
|
|
2976
3060
|
}, U = (e) => {
|
|
2977
|
-
|
|
3061
|
+
if (S || R() !== "docked" || !Hn() || I !== null) return;
|
|
3062
|
+
I = e.pointerId, ne = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3063
|
+
let t = f.getBoundingClientRect();
|
|
3064
|
+
P = t.left, F = t.top;
|
|
3065
|
+
}, ue = (e) => {
|
|
3066
|
+
ne === "player" && (I === null || e.pointerId !== I || se(e.dx, e.dy));
|
|
2978
3067
|
}, de = (e) => {
|
|
2979
|
-
|
|
3068
|
+
ne === "player" && (I === null || e.pointerId !== I || H());
|
|
2980
3069
|
}, W = () => {
|
|
2981
|
-
let e =
|
|
3070
|
+
let e = Hn(), t = R();
|
|
2982
3071
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
2983
3072
|
h.hidden = !0;
|
|
2984
3073
|
return;
|
|
2985
3074
|
}
|
|
2986
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
3075
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = Jn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = qn, h.setAttribute("aria-label", "Reduce"));
|
|
2987
3076
|
}, fe = (e) => {
|
|
2988
|
-
let t =
|
|
2989
|
-
n =
|
|
3077
|
+
let t = zn(), n = e && P !== null && F !== null ? Vn(P, F, t) : Bn(t);
|
|
3078
|
+
n = Vn(n.left, n.top, t), P = n.left, F = n.top, V(n.left, n.top, t.width, t.height), W();
|
|
2990
3079
|
}, pe = () => {
|
|
2991
3080
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2992
3081
|
requestAnimationFrame(() => {
|
|
@@ -2994,20 +3083,20 @@ function Un(e, t) {
|
|
|
2994
3083
|
});
|
|
2995
3084
|
});
|
|
2996
3085
|
}, me = (e) => {
|
|
2997
|
-
if (
|
|
3086
|
+
if (B(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !D) {
|
|
2998
3087
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2999
3088
|
return;
|
|
3000
3089
|
}
|
|
3001
|
-
|
|
3002
|
-
if (
|
|
3090
|
+
N = setTimeout(() => {
|
|
3091
|
+
if (N = null, S || !$(a.dataset.state)) {
|
|
3003
3092
|
a.classList.remove("liforma-ew--layout-settling");
|
|
3004
3093
|
return;
|
|
3005
3094
|
}
|
|
3006
3095
|
a.classList.remove("liforma-ew--layout-settling"), pe();
|
|
3007
3096
|
}, 220);
|
|
3008
3097
|
}, he = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
3009
|
-
|
|
3010
|
-
|
|
3098
|
+
z(), M = setTimeout(() => {
|
|
3099
|
+
M = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
3011
3100
|
}, 280);
|
|
3012
3101
|
})), ge = {
|
|
3013
3102
|
galleryThumb: t.galleryThumb,
|
|
@@ -3028,13 +3117,13 @@ function Un(e, t) {
|
|
|
3028
3117
|
}
|
|
3029
3118
|
c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
|
|
3030
3119
|
}, ye = () => {
|
|
3031
|
-
|
|
3120
|
+
C = !0, o.disabled = !1, ve(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
3032
3121
|
}, G = () => {
|
|
3033
|
-
|
|
3122
|
+
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
3034
3123
|
}, be = (e) => {
|
|
3035
|
-
|
|
3036
|
-
let t =
|
|
3037
|
-
return t ? (
|
|
3124
|
+
A?.(), A = null;
|
|
3125
|
+
let t = Yn(s, e, { parallax: ie });
|
|
3126
|
+
return t ? (A = t, !0) : !1;
|
|
3038
3127
|
}, K = () => {
|
|
3039
3128
|
if (be(ge)) {
|
|
3040
3129
|
ye();
|
|
@@ -3062,59 +3151,59 @@ function Un(e, t) {
|
|
|
3062
3151
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
3063
3152
|
}), Se = () => ({
|
|
3064
3153
|
...t.fit ? { fit: t.fit } : {},
|
|
3065
|
-
startButton:
|
|
3154
|
+
startButton: Xn(t),
|
|
3066
3155
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
|
|
3067
3156
|
}), q = (e = !0) => {
|
|
3068
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"),
|
|
3157
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ae(), a.dataset.state = "expanded", _e(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
|
|
3069
3158
|
}, Ce = () => {
|
|
3070
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", _e(null), typeof document < "u" && (document.body.style.overflow =
|
|
3159
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", _e(null), typeof document < "u" && (document.body.style.overflow = k), fe(!0), W(), b?.setWidgetChrome("docked");
|
|
3071
3160
|
}, we = (e) => {
|
|
3072
3161
|
e.on("started", () => {
|
|
3073
|
-
S || (
|
|
3162
|
+
S || (D = !0, a.dataset.live = "true", _e(null), t.onStarted?.(), $(a.dataset.state) && pe());
|
|
3074
3163
|
}), e.on("feedback", (e) => {
|
|
3075
3164
|
S || t.onFeedback?.(e);
|
|
3076
3165
|
}), e.on("feedbackFailed", (e) => {
|
|
3077
3166
|
S || t.onFeedbackFailed?.(e);
|
|
3078
3167
|
});
|
|
3079
3168
|
}, Te = () => {
|
|
3080
|
-
|
|
3169
|
+
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), _e(null), typeof document < "u" && (document.body.style.overflow = k), W();
|
|
3081
3170
|
}, Ee = () => {
|
|
3082
|
-
|
|
3171
|
+
z(), B(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
|
|
3083
3172
|
let e = b;
|
|
3084
3173
|
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");
|
|
3085
3174
|
}, De = () => {
|
|
3086
3175
|
if (!S && $(a.dataset.state)) {
|
|
3087
|
-
if (
|
|
3176
|
+
if (H(), x = !1, b && E) {
|
|
3088
3177
|
let e = b;
|
|
3089
3178
|
(async () => {
|
|
3090
|
-
|
|
3179
|
+
D && (await he(), S || b !== e) || (w && e.setWidgetChrome("collapsed"), Te(), D ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : w && G(), t.onCollapsed?.(), t.onClose?.());
|
|
3091
3180
|
})();
|
|
3092
3181
|
return;
|
|
3093
3182
|
}
|
|
3094
3183
|
Ee(), Te(), t.onCollapsed?.(), t.onClose?.();
|
|
3095
3184
|
}
|
|
3096
3185
|
}, Oe = () => {
|
|
3097
|
-
S ||
|
|
3186
|
+
S || Hn() && R() === "expanded" && me(() => {
|
|
3098
3187
|
Ce();
|
|
3099
3188
|
});
|
|
3100
3189
|
}, ke = () => {
|
|
3101
|
-
S ||
|
|
3102
|
-
|
|
3190
|
+
S || R() === "docked" && (H(), me(() => {
|
|
3191
|
+
ae(), q(!1), b?.setWidgetChrome("expanded");
|
|
3103
3192
|
}));
|
|
3104
3193
|
}, Ae = () => {
|
|
3105
|
-
!b || !
|
|
3194
|
+
!b || !D || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), b.setWidgetChrome("expanded"), x = !1, pe());
|
|
3106
3195
|
}, Me = () => {
|
|
3107
|
-
!b || !
|
|
3196
|
+
!b || !E || D || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
3108
3197
|
}, Pe = (e) => {
|
|
3109
|
-
S || e !==
|
|
3198
|
+
S || e !== O && !D || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, D && pe());
|
|
3110
3199
|
}, Fe = () => {
|
|
3111
|
-
if (S ||
|
|
3112
|
-
|
|
3113
|
-
let e =
|
|
3200
|
+
if (S || T || w || b || $(a.dataset.state)) return;
|
|
3201
|
+
T = !0;
|
|
3202
|
+
let e = O;
|
|
3114
3203
|
l.hidden = !1, (async () => {
|
|
3115
3204
|
try {
|
|
3116
|
-
let t = await
|
|
3117
|
-
if (S || e !==
|
|
3205
|
+
let t = await An.startSession(xe());
|
|
3206
|
+
if (S || e !== O) {
|
|
3118
3207
|
t.destroy();
|
|
3119
3208
|
return;
|
|
3120
3209
|
}
|
|
@@ -3123,7 +3212,7 @@ function Un(e, t) {
|
|
|
3123
3212
|
container: l,
|
|
3124
3213
|
...Se(),
|
|
3125
3214
|
onWidgetReady: () => {
|
|
3126
|
-
S || e !==
|
|
3215
|
+
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : G());
|
|
3127
3216
|
},
|
|
3128
3217
|
onWidgetExpand: () => {
|
|
3129
3218
|
Pe(e);
|
|
@@ -3132,10 +3221,10 @@ function Un(e, t) {
|
|
|
3132
3221
|
S || J(e);
|
|
3133
3222
|
},
|
|
3134
3223
|
onWidgetDragStart: (e) => {
|
|
3135
|
-
S ||
|
|
3224
|
+
S || U(e);
|
|
3136
3225
|
},
|
|
3137
3226
|
onWidgetDragMove: (e) => {
|
|
3138
|
-
S ||
|
|
3227
|
+
S || ue(e);
|
|
3139
3228
|
},
|
|
3140
3229
|
onWidgetDragEnd: (e) => {
|
|
3141
3230
|
S || de(e);
|
|
@@ -3144,7 +3233,7 @@ function Un(e, t) {
|
|
|
3144
3233
|
S || e === "error" && $(a.dataset.state) && _e("Could not load the experience.");
|
|
3145
3234
|
}
|
|
3146
3235
|
});
|
|
3147
|
-
if (S || e !==
|
|
3236
|
+
if (S || e !== O) {
|
|
3148
3237
|
t.destroy(), b === t && (b = null);
|
|
3149
3238
|
return;
|
|
3150
3239
|
}
|
|
@@ -3152,28 +3241,28 @@ function Un(e, t) {
|
|
|
3152
3241
|
S || De();
|
|
3153
3242
|
});
|
|
3154
3243
|
} catch (n) {
|
|
3155
|
-
if (S || e !==
|
|
3156
|
-
|
|
3244
|
+
if (S || e !== O) return;
|
|
3245
|
+
T = !1, l.hidden = !0, l.replaceChildren(), b = null;
|
|
3157
3246
|
let r = n instanceof Error ? n : Error(String(n));
|
|
3158
3247
|
t.onError?.(r), console.error("[ExperienceWidget] warm prefetch failed", r);
|
|
3159
3248
|
}
|
|
3160
3249
|
})();
|
|
3161
3250
|
}, Ie = () => {
|
|
3162
|
-
if (S || x || !
|
|
3163
|
-
if (b &&
|
|
3251
|
+
if (S || x || !C || $(a.dataset.state)) return;
|
|
3252
|
+
if (b && D) {
|
|
3164
3253
|
Ae();
|
|
3165
3254
|
return;
|
|
3166
3255
|
}
|
|
3167
|
-
if (b &&
|
|
3256
|
+
if (b && E) {
|
|
3168
3257
|
Me();
|
|
3169
3258
|
return;
|
|
3170
3259
|
}
|
|
3171
|
-
let e = ++
|
|
3172
|
-
x = !0,
|
|
3260
|
+
let e = ++O;
|
|
3261
|
+
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 () => {
|
|
3173
3262
|
try {
|
|
3174
3263
|
q();
|
|
3175
|
-
let t = await
|
|
3176
|
-
if (S || e !==
|
|
3264
|
+
let t = await An.startSession(xe());
|
|
3265
|
+
if (S || e !== O) {
|
|
3177
3266
|
t.destroy();
|
|
3178
3267
|
return;
|
|
3179
3268
|
}
|
|
@@ -3185,10 +3274,10 @@ function Un(e, t) {
|
|
|
3185
3274
|
S || J(e);
|
|
3186
3275
|
},
|
|
3187
3276
|
onWidgetDragStart: (e) => {
|
|
3188
|
-
S ||
|
|
3277
|
+
S || U(e);
|
|
3189
3278
|
},
|
|
3190
3279
|
onWidgetDragMove: (e) => {
|
|
3191
|
-
S ||
|
|
3280
|
+
S || ue(e);
|
|
3192
3281
|
},
|
|
3193
3282
|
onWidgetDragEnd: (e) => {
|
|
3194
3283
|
S || de(e);
|
|
@@ -3197,68 +3286,68 @@ function Un(e, t) {
|
|
|
3197
3286
|
S || (e === "error" ? _e("Could not load the experience.") : $(a.dataset.state) && _e(null));
|
|
3198
3287
|
}
|
|
3199
3288
|
});
|
|
3200
|
-
if (S || e !==
|
|
3289
|
+
if (S || e !== O) {
|
|
3201
3290
|
t.destroy(), b === t && (b = null);
|
|
3202
3291
|
return;
|
|
3203
3292
|
}
|
|
3204
|
-
|
|
3293
|
+
E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
3205
3294
|
S || De();
|
|
3206
3295
|
});
|
|
3207
3296
|
} catch (n) {
|
|
3208
|
-
if (S || e !==
|
|
3297
|
+
if (S || e !== O) return;
|
|
3209
3298
|
let r = n instanceof Error ? n : Error(String(n));
|
|
3210
3299
|
_e(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
|
|
3211
3300
|
} finally {
|
|
3212
|
-
e ===
|
|
3301
|
+
e === O && (x = !1);
|
|
3213
3302
|
}
|
|
3214
3303
|
})();
|
|
3215
3304
|
}, Le = () => {
|
|
3216
3305
|
if (!(S || $(a.dataset.state))) {
|
|
3217
|
-
if (b &&
|
|
3306
|
+
if (b && D) {
|
|
3218
3307
|
Ae();
|
|
3219
3308
|
return;
|
|
3220
3309
|
}
|
|
3221
|
-
if (b &&
|
|
3310
|
+
if (b && E) {
|
|
3222
3311
|
Me();
|
|
3223
3312
|
return;
|
|
3224
3313
|
}
|
|
3225
|
-
if (
|
|
3314
|
+
if (T || b) {
|
|
3226
3315
|
q();
|
|
3227
3316
|
return;
|
|
3228
3317
|
}
|
|
3229
3318
|
Ie();
|
|
3230
3319
|
}
|
|
3231
3320
|
}, Re = (e) => {
|
|
3232
|
-
if (e.stopPropagation(),
|
|
3321
|
+
if (e.stopPropagation(), R() === "expanded") {
|
|
3233
3322
|
Oe();
|
|
3234
3323
|
return;
|
|
3235
3324
|
}
|
|
3236
|
-
|
|
3325
|
+
R() === "docked" && ke();
|
|
3237
3326
|
}, J = (e) => {
|
|
3238
3327
|
g.setAttribute("aria-pressed", e ? "true" : "false");
|
|
3239
3328
|
}, Be = (e) => {
|
|
3240
3329
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
3241
3330
|
}, Ve = (e) => {
|
|
3242
|
-
|
|
3331
|
+
R() === "docked" && Hn() && (e.target?.closest("button") || (e.preventDefault(), le(e.clientX, e.clientY, e.pointerId)));
|
|
3243
3332
|
}, He = (e) => {
|
|
3244
3333
|
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), De());
|
|
3245
3334
|
}, Ue = () => {
|
|
3246
3335
|
if (!S) {
|
|
3247
|
-
if (
|
|
3248
|
-
if (!
|
|
3336
|
+
if (R() === "docked") {
|
|
3337
|
+
if (!Hn()) {
|
|
3249
3338
|
ke();
|
|
3250
3339
|
return;
|
|
3251
3340
|
}
|
|
3252
|
-
|
|
3341
|
+
D ? me(() => {
|
|
3253
3342
|
fe(!0);
|
|
3254
3343
|
}) : fe(!0);
|
|
3255
3344
|
return;
|
|
3256
3345
|
}
|
|
3257
3346
|
W();
|
|
3258
3347
|
}
|
|
3259
|
-
},
|
|
3348
|
+
}, Y = typeof window < "u" ? window.matchMedia(Mn) : null, We = () => {
|
|
3260
3349
|
if (!S) {
|
|
3261
|
-
if (
|
|
3350
|
+
if (R() === "docked" && !Hn()) {
|
|
3262
3351
|
ke();
|
|
3263
3352
|
return;
|
|
3264
3353
|
}
|
|
@@ -3267,9 +3356,9 @@ function Un(e, t) {
|
|
|
3267
3356
|
};
|
|
3268
3357
|
return o.addEventListener("click", Le), d.addEventListener("click", De), _.addEventListener("click", (e) => {
|
|
3269
3358
|
e.stopPropagation(), De();
|
|
3270
|
-
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue),
|
|
3359
|
+
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), Y?.addEventListener("change", We), K(), W(), r === "eager" ? queueMicrotask(() => {
|
|
3271
3360
|
S || Fe();
|
|
3272
|
-
}) : r === "idle" && (
|
|
3361
|
+
}) : r === "idle" && (j = Zn(() => {
|
|
3273
3362
|
S || Fe();
|
|
3274
3363
|
})), {
|
|
3275
3364
|
root: a,
|
|
@@ -3285,18 +3374,18 @@ function Un(e, t) {
|
|
|
3285
3374
|
Fe();
|
|
3286
3375
|
},
|
|
3287
3376
|
destroy() {
|
|
3288
|
-
S || (S = !0,
|
|
3377
|
+
S || (S = !0, H(), j?.(), j = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown", He), window.removeEventListener("resize", Ue), Y?.removeEventListener("change", We), Ee(), Te(), e.replaceChildren());
|
|
3289
3378
|
}
|
|
3290
3379
|
};
|
|
3291
3380
|
}
|
|
3292
3381
|
//#endregion
|
|
3293
3382
|
//#region src/react/ExperienceWidget.tsx
|
|
3294
|
-
function
|
|
3295
|
-
let t = o(null), { experienceId: r, alt: i, galleryThumb: a, avatarImage: s, backgroundImage: c, foregroundImage: l, fallbackImage: u, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, language: _, mode: v, speechInputMode: y, speechOnly: b, fit: x, embedBaseUrl: S, expandedMaxWidth:
|
|
3383
|
+
function $n(e) {
|
|
3384
|
+
let t = o(null), { experienceId: r, alt: i, galleryThumb: a, avatarImage: s, backgroundImage: c, foregroundImage: l, fallbackImage: u, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, language: _, mode: v, speechInputMode: y, speechOnly: b, fit: x, embedBaseUrl: S, expandedMaxWidth: C, expandedMaxHeight: w, startButtonLabel: T, startButton: E, showFeedback: D, className: O = "", onExpanded: k, onCollapsed: A, onStarted: j, onClose: M, onError: N, onPrefetchReady: P, onFeedback: F, onFeedbackFailed: I } = e, ee = m === "bottom-right" || m === "bottom-left";
|
|
3296
3385
|
return n(() => {
|
|
3297
3386
|
let e = t.current;
|
|
3298
3387
|
if (!e || !r.trim()) return;
|
|
3299
|
-
let n =
|
|
3388
|
+
let n = Qn(e, {
|
|
3300
3389
|
experienceId: r,
|
|
3301
3390
|
alt: i,
|
|
3302
3391
|
galleryThumb: a,
|
|
@@ -3315,19 +3404,19 @@ function Wn(e) {
|
|
|
3315
3404
|
speechOnly: b,
|
|
3316
3405
|
fit: x,
|
|
3317
3406
|
embedBaseUrl: S,
|
|
3318
|
-
expandedMaxWidth:
|
|
3319
|
-
expandedMaxHeight:
|
|
3320
|
-
startButtonLabel:
|
|
3321
|
-
startButton:
|
|
3322
|
-
showFeedback:
|
|
3323
|
-
onFeedback:
|
|
3324
|
-
onFeedbackFailed:
|
|
3325
|
-
onExpanded:
|
|
3326
|
-
onCollapsed:
|
|
3327
|
-
onStarted:
|
|
3328
|
-
onClose:
|
|
3329
|
-
onError:
|
|
3330
|
-
onPrefetchReady:
|
|
3407
|
+
expandedMaxWidth: C,
|
|
3408
|
+
expandedMaxHeight: w,
|
|
3409
|
+
startButtonLabel: T,
|
|
3410
|
+
startButton: E,
|
|
3411
|
+
showFeedback: D,
|
|
3412
|
+
onFeedback: F,
|
|
3413
|
+
onFeedbackFailed: I,
|
|
3414
|
+
onExpanded: k,
|
|
3415
|
+
onCollapsed: A,
|
|
3416
|
+
onStarted: j,
|
|
3417
|
+
onClose: M,
|
|
3418
|
+
onError: N,
|
|
3419
|
+
onPrefetchReady: P
|
|
3331
3420
|
});
|
|
3332
3421
|
return () => n.destroy();
|
|
3333
3422
|
}, [
|
|
@@ -3349,23 +3438,23 @@ function Wn(e) {
|
|
|
3349
3438
|
b,
|
|
3350
3439
|
x,
|
|
3351
3440
|
S,
|
|
3352
|
-
ee,
|
|
3353
3441
|
C,
|
|
3354
3442
|
w,
|
|
3355
3443
|
T,
|
|
3356
3444
|
E,
|
|
3357
|
-
|
|
3445
|
+
D,
|
|
3358
3446
|
F,
|
|
3359
|
-
|
|
3447
|
+
I,
|
|
3360
3448
|
k,
|
|
3361
3449
|
A,
|
|
3362
3450
|
j,
|
|
3363
3451
|
M,
|
|
3364
|
-
N
|
|
3452
|
+
N,
|
|
3453
|
+
P
|
|
3365
3454
|
]), /* @__PURE__ */ d("div", {
|
|
3366
3455
|
ref: t,
|
|
3367
|
-
className:
|
|
3368
|
-
style:
|
|
3456
|
+
className: O,
|
|
3457
|
+
style: ee ? { display: "contents" } : {
|
|
3369
3458
|
width: "100%",
|
|
3370
3459
|
height: "100%",
|
|
3371
3460
|
minHeight: "inherit"
|
|
@@ -3373,6 +3462,6 @@ function Wn(e) {
|
|
|
3373
3462
|
});
|
|
3374
3463
|
}
|
|
3375
3464
|
//#endregion
|
|
3376
|
-
export {
|
|
3465
|
+
export { te as Experience, Ae as ExperienceThumbnail, $n as ExperienceWidget };
|
|
3377
3466
|
|
|
3378
3467
|
//# sourceMappingURL=index.js.map
|