@liforma/client 0.4.8 → 0.4.10
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 +25 -0
- package/dist/next/index.js +516 -185
- package/dist/next/index.js.map +1 -1
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts +4 -0
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts.map +1 -1
- 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 +4 -0
- package/dist/next/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/next/v2/embed/iframeHost.d.ts +13 -1
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +35 -1
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +17 -2
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/experienceEvents.d.ts +3 -1
- package/dist/next/v2/experienceEvents.d.ts.map +1 -1
- package/dist/next/v2/sdkRelease.d.ts +3 -0
- package/dist/next/v2/sdkRelease.d.ts.map +1 -0
- package/dist/next/v2/types/sessionInteraction.d.ts +29 -0
- package/dist/next/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/next/v2/types/sessionManifest.d.ts +1 -0
- package/dist/next/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/next/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/next/widget/types.d.ts +5 -0
- package/dist/next/widget/types.d.ts.map +1 -1
- package/dist/npm/index.js +542 -225
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/svelte/experienceLoadError.d.ts.map +1 -1
- package/dist/npm/svelte/experienceLoadErrorStyles.d.ts +1 -1
- package/dist/npm/svelte/experienceLoadErrorStyles.d.ts.map +1 -1
- 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 +4 -0
- package/dist/npm/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/npm/v2/embed/iframeHost.d.ts +13 -1
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +35 -1
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +17 -2
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/experienceEvents.d.ts +3 -1
- package/dist/npm/v2/experienceEvents.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/liforma-experience.d.ts +2 -0
- package/dist/npm/v2/liforma-experience.d.ts.map +1 -1
- package/dist/npm/v2/npm.d.ts +1 -1
- package/dist/npm/v2/npm.d.ts.map +1 -1
- package/dist/npm/v2/sdkRelease.d.ts +3 -0
- package/dist/npm/v2/sdkRelease.d.ts.map +1 -0
- package/dist/npm/v2/types/sessionInteraction.d.ts +29 -0
- package/dist/npm/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifest.d.ts +1 -0
- package/dist/npm/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts +17 -0
- package/dist/npm/v2/types/sessionManifestSchema.d.ts.map +1 -1
- package/dist/npm/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/npm/widget/types.d.ts +5 -0
- package/dist/npm/widget/types.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 +977 -642
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/svelte/experienceLoadError.d.ts.map +1 -1
- package/dist/react/svelte/experienceLoadErrorStyles.d.ts +1 -1
- package/dist/react/svelte/experienceLoadErrorStyles.d.ts.map +1 -1
- 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 +4 -0
- package/dist/react/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/react/v2/embed/iframeHost.d.ts +13 -1
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +35 -1
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +17 -2
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/experienceEvents.d.ts +3 -1
- package/dist/react/v2/experienceEvents.d.ts.map +1 -1
- package/dist/react/v2/sdkRelease.d.ts +3 -0
- package/dist/react/v2/sdkRelease.d.ts.map +1 -0
- package/dist/react/v2/types/sessionInteraction.d.ts +29 -0
- package/dist/react/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/react/v2/types/sessionManifest.d.ts +1 -0
- package/dist/react/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/react/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/react/widget/types.d.ts +5 -0
- package/dist/react/widget/types.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +2 -2
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +6 -0
- package/dist/svelte/experienceLoadError.js +37 -15
- package/dist/svelte/experienceLoadError.test.js +8 -0
- package/dist/svelte/experienceLoadErrorOverlay.js +1 -1
- package/dist/svelte/experienceLoadErrorStyles.d.ts +1 -1
- package/dist/svelte/experienceLoadErrorStyles.js +1 -0
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -50,6 +50,7 @@ function _(e) {
|
|
|
50
50
|
speechInputMode: e.speechInputMode,
|
|
51
51
|
speechOnly: e.speechOnly,
|
|
52
52
|
attribution: e.attribution,
|
|
53
|
+
alreadyConverted: e.alreadyConverted,
|
|
53
54
|
conversationProcessor: e.conversationProcessor
|
|
54
55
|
};
|
|
55
56
|
if (e.experienceId) return {
|
|
@@ -68,6 +69,7 @@ function _(e) {
|
|
|
68
69
|
speechInputMode: e.speechInputMode,
|
|
69
70
|
speechOnly: e.speechOnly,
|
|
70
71
|
attribution: e.attribution,
|
|
72
|
+
alreadyConverted: e.alreadyConverted,
|
|
71
73
|
conversationProcessor: e.conversationProcessor
|
|
72
74
|
};
|
|
73
75
|
throw Error("Experience requires experienceId, sessionEndpoint, or launch.");
|
|
@@ -85,6 +87,7 @@ function v(e) {
|
|
|
85
87
|
e.conversationProcessor ? g(e.conversationProcessor) : 0,
|
|
86
88
|
e.speechOnly,
|
|
87
89
|
e.attribution === !1 ? !1 : e.attribution,
|
|
90
|
+
e.alreadyConverted,
|
|
88
91
|
e.avatarId,
|
|
89
92
|
e.backdropId,
|
|
90
93
|
e.locationId,
|
|
@@ -99,52 +102,64 @@ var y = /\b(exp_[A-Za-z0-9][A-Za-z0-9_-]{2,127})\b/, b = /(?:Your origin|origin)
|
|
|
99
102
|
function x(e) {
|
|
100
103
|
return e instanceof Error ? e.message : String(e);
|
|
101
104
|
}
|
|
102
|
-
function S() {
|
|
105
|
+
function S(e) {
|
|
106
|
+
if (!e || typeof e != "object") return {};
|
|
107
|
+
let t = e;
|
|
108
|
+
return {
|
|
109
|
+
code: typeof t.code == "string" && t.code.trim() && t.code.trim() !== "UNKNOWN" ? t.code.trim() : void 0,
|
|
110
|
+
requestId: typeof t.requestId == "string" && t.requestId.trim() ? t.requestId.trim() : void 0
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function C(e, t) {
|
|
114
|
+
let n = [e];
|
|
115
|
+
return t.code && n.push(`Code: ${t.code}`), t.requestId && n.push(`Request id: ${t.requestId}`), n.join("\n");
|
|
116
|
+
}
|
|
117
|
+
function w() {
|
|
103
118
|
try {
|
|
104
119
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
105
120
|
} catch {}
|
|
106
121
|
}
|
|
107
|
-
function
|
|
122
|
+
function T(e) {
|
|
108
123
|
return y.exec(e)?.[1];
|
|
109
124
|
}
|
|
110
|
-
function
|
|
125
|
+
function E(e) {
|
|
111
126
|
return b.exec(e)?.[1];
|
|
112
127
|
}
|
|
113
|
-
function
|
|
114
|
-
let n = x(e).trim() || "Unknown error", r = t?.experienceId?.trim() ||
|
|
128
|
+
function D(e, t) {
|
|
129
|
+
let n = x(e).trim() || "Unknown error", r = S(e), i = C(n, r), a = t?.experienceId?.trim() || T(n) || void 0, o = t?.origin?.trim() || E(n) || w() || void 0;
|
|
115
130
|
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) ? {
|
|
116
131
|
kind: "not_found",
|
|
117
132
|
title: "The application tried to load an avatar experience that doesn’t exist.",
|
|
118
|
-
detail: `Experience with id ${
|
|
119
|
-
technicalMessage:
|
|
120
|
-
experienceId:
|
|
121
|
-
origin:
|
|
133
|
+
detail: C(`Experience with id ${a ?? "the requested experience"} does not exist`, r),
|
|
134
|
+
technicalMessage: i,
|
|
135
|
+
experienceId: a,
|
|
136
|
+
origin: o
|
|
122
137
|
} : /origin_not_allowed/i.test(n) || /is not an allowed origin/i.test(n) || /^Origin not allowed/i.test(n) ? {
|
|
123
138
|
kind: "origin_not_allowed",
|
|
124
139
|
title: "The application tried to load an avatar experience from a website that isn’t allowed.",
|
|
125
|
-
detail: `Origin ${
|
|
126
|
-
technicalMessage:
|
|
127
|
-
experienceId:
|
|
128
|
-
origin:
|
|
140
|
+
detail: C(`Origin ${o ?? "this page"} is not allowed for experience ${a ?? "the requested experience"}`, r),
|
|
141
|
+
technicalMessage: i,
|
|
142
|
+
experienceId: a,
|
|
143
|
+
origin: o
|
|
129
144
|
} : /browser_embeds_disabled/i.test(n) || /^Browser embeds are not enabled/i.test(n) ? {
|
|
130
145
|
kind: "browser_embeds_disabled",
|
|
131
146
|
title: "The application tried to load an avatar experience that isn’t enabled for browser embeds.",
|
|
132
|
-
detail: `Browser embeds are not enabled for experience ${
|
|
133
|
-
technicalMessage:
|
|
134
|
-
experienceId:
|
|
135
|
-
origin:
|
|
147
|
+
detail: C(`Browser embeds are not enabled for experience ${a ?? "the requested experience"}`, r),
|
|
148
|
+
technicalMessage: i,
|
|
149
|
+
experienceId: a,
|
|
150
|
+
origin: o
|
|
136
151
|
} : {
|
|
137
152
|
kind: "generic",
|
|
138
153
|
title: "This avatar experience couldn’t be started.",
|
|
139
|
-
detail:
|
|
140
|
-
technicalMessage:
|
|
141
|
-
experienceId:
|
|
142
|
-
origin:
|
|
154
|
+
detail: i,
|
|
155
|
+
technicalMessage: i,
|
|
156
|
+
experienceId: a,
|
|
157
|
+
origin: o
|
|
143
158
|
};
|
|
144
159
|
}
|
|
145
160
|
//#endregion
|
|
146
161
|
//#region src/component/experienceComponentRuntime.ts
|
|
147
|
-
function
|
|
162
|
+
function O() {
|
|
148
163
|
let e, t, n = new Promise((n, r) => {
|
|
149
164
|
e = n, t = r;
|
|
150
165
|
});
|
|
@@ -154,29 +169,29 @@ function E() {
|
|
|
154
169
|
reject: t
|
|
155
170
|
};
|
|
156
171
|
}
|
|
157
|
-
function
|
|
172
|
+
function k() {
|
|
158
173
|
return new DOMException("Aborted", "AbortError");
|
|
159
174
|
}
|
|
160
|
-
function
|
|
175
|
+
function A(e) {
|
|
161
176
|
return e instanceof DOMException || e instanceof Error ? e : Error(String(e));
|
|
162
177
|
}
|
|
163
|
-
function
|
|
178
|
+
function j(e) {
|
|
164
179
|
return e instanceof DOMException && e.name === "AbortError";
|
|
165
180
|
}
|
|
166
|
-
function
|
|
181
|
+
function M(e) {
|
|
167
182
|
!e.instance || e.instanceDestroyed || (e.instanceDestroyed = !0, e.instance.destroy());
|
|
168
183
|
}
|
|
169
|
-
function
|
|
184
|
+
function N(e, t, n, r) {
|
|
170
185
|
e.unsubscribers.push(t.on(n, r));
|
|
171
186
|
}
|
|
172
|
-
function
|
|
173
|
-
|
|
187
|
+
function P(e, t, n) {
|
|
188
|
+
N(e, t, "ready", (t) => {
|
|
174
189
|
e.destroyed || (e.ready.resolve(t), n().onReady?.(t));
|
|
175
|
-
}),
|
|
190
|
+
}), N(e, t, "started", (t) => {
|
|
176
191
|
e.destroyed || (e.started.resolve(t), n().onStarted?.(t));
|
|
177
|
-
}),
|
|
192
|
+
}), N(e, t, "userTranscript", (e) => n().onUserTranscript?.(e)), N(e, t, "userSpeechStarted", (e) => n().onUserSpeechStarted?.(e)), N(e, t, "userSpeechEnded", (e) => n().onUserSpeechEnded?.(e)), N(e, t, "characterSpeechStarted", (e) => n().onCharacterSpeechStarted?.(e)), N(e, t, "characterSpeechEnded", (e) => n().onCharacterSpeechEnded?.(e)), N(e, t, "characterFocusChanged", (e) => n().onCharacterFocusChanged?.(e)), N(e, t, "conversationUpdate", (e) => n().onConversationUpdate?.(e)), N(e, t, "message", (e) => n().onMessage?.(e)), N(e, t, "listeningState", (e) => n().onListeningState?.(e)), N(e, t, "activityChange", (e) => n().onActivityChange?.(e)), N(e, t, "feedback", (e) => n().onFeedback?.(e)), N(e, t, "feedbackFailed", (e) => n().onFeedbackFailed?.(e)), N(e, t, "conversationProcessorError", (e) => n().onConversationProcessorError?.(e));
|
|
178
193
|
}
|
|
179
|
-
function
|
|
194
|
+
function F(e = () => ({}), t = () => ({})) {
|
|
180
195
|
let n = 0, r = null;
|
|
181
196
|
function i(e) {
|
|
182
197
|
if (e) {
|
|
@@ -191,22 +206,22 @@ function N(e = () => ({}), t = () => ({})) {
|
|
|
191
206
|
}
|
|
192
207
|
}
|
|
193
208
|
function a(e, t, n, a, o = !1, s) {
|
|
194
|
-
let c =
|
|
195
|
-
return !
|
|
209
|
+
let c = A(e);
|
|
210
|
+
return !j(c) && r === t && !t.destroyed && (o && a?.(D(c, { experienceId: i(s) })), t.reportedErrors.has(c) || (t.reportedErrors.add(c), console.error("[Experience]", c), n.onError?.(c))), c;
|
|
196
211
|
}
|
|
197
212
|
function o() {
|
|
198
|
-
if (!r || r.destroyed) throw
|
|
213
|
+
if (!r || r.destroyed) throw k();
|
|
199
214
|
return r;
|
|
200
215
|
}
|
|
201
216
|
function s(e) {
|
|
202
|
-
if (e.destroyed || r !== e) throw
|
|
217
|
+
if (e.destroyed || r !== e) throw k();
|
|
203
218
|
}
|
|
204
219
|
function u() {
|
|
205
220
|
return {
|
|
206
221
|
id: ++n,
|
|
207
|
-
session:
|
|
208
|
-
ready:
|
|
209
|
-
started:
|
|
222
|
+
session: O(),
|
|
223
|
+
ready: O(),
|
|
224
|
+
started: O(),
|
|
210
225
|
unsubscribers: [],
|
|
211
226
|
reportedErrors: /* @__PURE__ */ new Set(),
|
|
212
227
|
instance: null,
|
|
@@ -217,25 +232,26 @@ function N(e = () => ({}), t = () => ({})) {
|
|
|
217
232
|
function d(e) {
|
|
218
233
|
if (e.destroyed) return;
|
|
219
234
|
e.destroyed = !0;
|
|
220
|
-
let t =
|
|
235
|
+
let t = k();
|
|
221
236
|
e.session.reject(t), e.ready.reject(t), e.started.reject(t);
|
|
222
237
|
for (let t of e.unsubscribers.splice(0)) t();
|
|
223
|
-
|
|
238
|
+
M(e), r === e && (r = null);
|
|
224
239
|
}
|
|
225
240
|
async function f(e, n, i, o, u, d) {
|
|
226
241
|
try {
|
|
227
242
|
let a = await c.startSession(i);
|
|
228
243
|
if (e.instance = a, e.destroyed || r !== e) {
|
|
229
|
-
|
|
244
|
+
M(e);
|
|
230
245
|
return;
|
|
231
246
|
}
|
|
232
|
-
|
|
247
|
+
P(e, a, o);
|
|
233
248
|
let d = t(), f = d.returnUrl?.trim() || u?.trim(), p = await a.attach({
|
|
234
249
|
container: n,
|
|
235
250
|
fit: d.fit,
|
|
236
251
|
startButton: d.startButton,
|
|
237
252
|
theme: d.theme,
|
|
238
253
|
showFeedback: d.showFeedback,
|
|
254
|
+
interaction: d.interaction,
|
|
239
255
|
closeButton: d.closeButton,
|
|
240
256
|
returnUrl: f,
|
|
241
257
|
showClose: !!(o().onClose || f || d.closeButton === !0 || d.closeButton && typeof d.closeButton == "object" && d.closeButton.visible !== !1),
|
|
@@ -257,7 +273,7 @@ function N(e = () => ({}), t = () => ({})) {
|
|
|
257
273
|
});
|
|
258
274
|
} catch (t) {
|
|
259
275
|
let n = a(t, e, o(), d, !0, i);
|
|
260
|
-
e.session.reject(n), e.ready.reject(n), e.started.reject(n),
|
|
276
|
+
e.session.reject(n), e.ready.reject(n), e.started.reject(n), M(e);
|
|
261
277
|
}
|
|
262
278
|
}
|
|
263
279
|
function p(t, n, i, o) {
|
|
@@ -287,17 +303,17 @@ function N(e = () => ({}), t = () => ({})) {
|
|
|
287
303
|
}
|
|
288
304
|
//#endregion
|
|
289
305
|
//#region src/svelte/experienceLoadErrorStyles.ts
|
|
290
|
-
var
|
|
291
|
-
function
|
|
306
|
+
var I = "liforma-experience-load-error-styles";
|
|
307
|
+
function ee() {
|
|
292
308
|
if (typeof document > "u" || document.getElementById("liforma-experience-load-error-styles")) return;
|
|
293
309
|
let e = document.createElement("style");
|
|
294
|
-
e.id =
|
|
310
|
+
e.id = I, e.textContent = te, document.head.append(e);
|
|
295
311
|
}
|
|
296
|
-
var
|
|
312
|
+
var te = "\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 white-space: pre-wrap;\n word-break: break-word;\n }\n .liforma-loading-error-detail[hidden] {\n display: none;\n }\n";
|
|
297
313
|
//#endregion
|
|
298
314
|
//#region src/svelte/experienceLoadErrorOverlay.ts
|
|
299
|
-
function
|
|
300
|
-
|
|
315
|
+
function L(e, t) {
|
|
316
|
+
ee();
|
|
301
317
|
let n = t, r = !1, i = document.createElement("div");
|
|
302
318
|
i.className = "liforma-loading-screen liforma-loading-screen-absolute", i.setAttribute("role", "alert"), i.setAttribute("aria-live", "assertive");
|
|
303
319
|
let a = document.createElement("div");
|
|
@@ -313,7 +329,7 @@ function ee(e, t) {
|
|
|
313
329
|
r = !r, u();
|
|
314
330
|
}), a.append(o, s, c, l), i.append(a), e.append(i);
|
|
315
331
|
function u() {
|
|
316
|
-
s.textContent = n.title, l.textContent = n.detail, l.hidden = !r, c.textContent = r ? "Hide details" : "
|
|
332
|
+
s.textContent = n.title, l.textContent = n.detail, l.hidden = !r, c.textContent = r ? "Hide details" : "Show details", c.setAttribute("aria-expanded", r ? "true" : "false");
|
|
317
333
|
}
|
|
318
334
|
return u(), {
|
|
319
335
|
root: i,
|
|
@@ -327,101 +343,103 @@ function ee(e, t) {
|
|
|
327
343
|
}
|
|
328
344
|
//#endregion
|
|
329
345
|
//#region src/react/Experience.tsx
|
|
330
|
-
var
|
|
331
|
-
let { returnUrl: c, fit: l, startButton: u, theme: p, showFeedback: m,
|
|
346
|
+
var ne = e(function(e, a) {
|
|
347
|
+
let { returnUrl: c, fit: l, startButton: u, theme: p, showFeedback: m, interaction: h, closeButton: g, onReady: y, onStarted: b, onUserTranscript: x, onUserSpeechStarted: S, onUserSpeechEnded: C, onCharacterSpeechStarted: w, onCharacterSpeechEnded: T, onCharacterFocusChanged: E, onConversationUpdate: D, onMessage: O, onListeningState: j, onActivityChange: M, onFeedback: N, onFeedbackFailed: P, onConversationProcessorError: I, onPlayerStatusChange: ee, onStateUpdate: te, onClose: ne, onError: re } = e, ie = o({}), R = o({
|
|
332
348
|
fit: l,
|
|
333
349
|
startButton: u,
|
|
334
350
|
theme: p,
|
|
335
351
|
showFeedback: m,
|
|
336
|
-
|
|
352
|
+
interaction: h,
|
|
353
|
+
closeButton: g,
|
|
337
354
|
returnUrl: c
|
|
338
|
-
}),
|
|
339
|
-
|
|
355
|
+
}), z = o(F(() => ie.current, () => R.current)), B = o(null), [ae, V] = s(!1), [H, oe] = s(null), se = o(null), U = o(null), ce = v(e);
|
|
356
|
+
R.current = {
|
|
340
357
|
fit: l,
|
|
341
358
|
startButton: u,
|
|
342
359
|
theme: p,
|
|
343
360
|
showFeedback: m,
|
|
344
|
-
|
|
361
|
+
interaction: h,
|
|
362
|
+
closeButton: g,
|
|
345
363
|
returnUrl: c
|
|
346
|
-
},
|
|
347
|
-
onReady:
|
|
348
|
-
onStarted:
|
|
349
|
-
onUserTranscript:
|
|
350
|
-
onUserSpeechStarted:
|
|
351
|
-
onUserSpeechEnded:
|
|
352
|
-
onCharacterSpeechStarted:
|
|
353
|
-
onCharacterSpeechEnded:
|
|
354
|
-
onCharacterFocusChanged:
|
|
355
|
-
onConversationUpdate:
|
|
356
|
-
onMessage:
|
|
357
|
-
onListeningState:
|
|
358
|
-
onActivityChange:
|
|
359
|
-
onFeedback:
|
|
364
|
+
}, ie.current = {
|
|
365
|
+
onReady: y,
|
|
366
|
+
onStarted: b,
|
|
367
|
+
onUserTranscript: x,
|
|
368
|
+
onUserSpeechStarted: S,
|
|
369
|
+
onUserSpeechEnded: C,
|
|
370
|
+
onCharacterSpeechStarted: w,
|
|
371
|
+
onCharacterSpeechEnded: T,
|
|
372
|
+
onCharacterFocusChanged: E,
|
|
373
|
+
onConversationUpdate: D,
|
|
374
|
+
onMessage: O,
|
|
375
|
+
onListeningState: j,
|
|
376
|
+
onActivityChange: M,
|
|
377
|
+
onFeedback: N,
|
|
360
378
|
onFeedbackFailed: P,
|
|
361
|
-
onConversationProcessorError:
|
|
362
|
-
onPlayerStatusChange:
|
|
379
|
+
onConversationProcessorError: I,
|
|
380
|
+
onPlayerStatusChange: ee,
|
|
363
381
|
onStateUpdate: te,
|
|
364
382
|
onClose: ne,
|
|
365
|
-
onError:
|
|
383
|
+
onError: re
|
|
366
384
|
};
|
|
367
385
|
let le = t((e) => {
|
|
368
|
-
se.current = e,
|
|
386
|
+
se.current = e, V(e !== null);
|
|
369
387
|
}, []);
|
|
370
388
|
return r(a, () => ({
|
|
371
389
|
ready: () => {
|
|
372
|
-
let e =
|
|
373
|
-
return !e || e.destroyed ? Promise.reject(
|
|
390
|
+
let e = B.current;
|
|
391
|
+
return !e || e.destroyed ? Promise.reject(k()) : e.ready.promise;
|
|
374
392
|
},
|
|
375
393
|
started: () => {
|
|
376
|
-
let e =
|
|
377
|
-
return !e || e.destroyed ? Promise.reject(
|
|
394
|
+
let e = B.current;
|
|
395
|
+
return !e || e.destroyed ? Promise.reject(k()) : e.started.promise;
|
|
378
396
|
},
|
|
379
397
|
speech: {
|
|
380
|
-
speak: (e) =>
|
|
381
|
-
play: (e) =>
|
|
398
|
+
speak: (e) => z.current.withSession((t) => t.speech.speak(e)),
|
|
399
|
+
play: (e) => z.current.withSession((t) => t.speech.play(e)),
|
|
382
400
|
createUtterance: (e) => {
|
|
383
|
-
let t =
|
|
401
|
+
let t = z.current.getActiveInstance();
|
|
384
402
|
if (!t) throw Error("Session has not started. Wait for the player start button and the started event before using speech APIs.");
|
|
385
403
|
return t.speech.createUtterance(e);
|
|
386
404
|
},
|
|
387
|
-
interrupt: (e) =>
|
|
405
|
+
interrupt: (e) => z.current.withSession((t) => t.speech.interrupt(e))
|
|
388
406
|
},
|
|
389
|
-
startListening: () =>
|
|
390
|
-
stopListening: () =>
|
|
391
|
-
listenOnce: (e) =>
|
|
392
|
-
getSession: () =>
|
|
393
|
-
getManifest: () =>
|
|
394
|
-
getConversation: () =>
|
|
395
|
-
focusCharacter: (e) =>
|
|
396
|
-
setFit: (e) =>
|
|
397
|
-
conversion: (e) =>
|
|
398
|
-
engage: () =>
|
|
399
|
-
end: () =>
|
|
407
|
+
startListening: () => z.current.withSession((e) => e.startListening()),
|
|
408
|
+
stopListening: () => z.current.withSession((e) => e.stopListening()),
|
|
409
|
+
listenOnce: (e) => z.current.withSession((t) => t.listenOnce(e)),
|
|
410
|
+
getSession: () => z.current.getActiveInstance()?.getSession() ?? null,
|
|
411
|
+
getManifest: () => z.current.getActiveInstance()?.getManifest() ?? null,
|
|
412
|
+
getConversation: () => z.current.getActiveInstance()?.getConversation() ?? [],
|
|
413
|
+
focusCharacter: (e) => z.current.withSession((t) => t.focusCharacter(e)),
|
|
414
|
+
setFit: (e) => z.current.withSession((t) => t.setFit(e)),
|
|
415
|
+
conversion: (e) => z.current.withSession((t) => t.conversion(e)),
|
|
416
|
+
engage: () => z.current.withSession((e) => e.engage()),
|
|
417
|
+
end: () => z.current.withSession((e) => e.end())
|
|
400
418
|
}), []), i(() => {
|
|
401
|
-
if (!
|
|
402
|
-
let t = se.current, n =
|
|
419
|
+
if (!ae || !se.current) return;
|
|
420
|
+
let t = se.current, n = z.current, r;
|
|
403
421
|
try {
|
|
404
422
|
r = { options: _(e) };
|
|
405
423
|
} catch (e) {
|
|
406
|
-
r = { error:
|
|
424
|
+
r = { error: A(e) };
|
|
407
425
|
}
|
|
408
426
|
let i = n.activateGeneration(t, r, c, oe);
|
|
409
|
-
return
|
|
410
|
-
n.cancelGeneration(i),
|
|
427
|
+
return B.current = i, () => {
|
|
428
|
+
n.cancelGeneration(i), B.current === i && (B.current = null);
|
|
411
429
|
};
|
|
412
430
|
}, [
|
|
413
|
-
|
|
414
|
-
|
|
431
|
+
ae,
|
|
432
|
+
ce,
|
|
415
433
|
c
|
|
416
434
|
]), n(() => {
|
|
417
|
-
let e =
|
|
435
|
+
let e = z.current.getActiveInstance();
|
|
418
436
|
e && e.setFit(l ?? "full");
|
|
419
437
|
}, [l]), n(() => {
|
|
420
|
-
let e =
|
|
421
|
-
if (!e || (e.replaceChildren(), !
|
|
422
|
-
let t =
|
|
438
|
+
let e = U.current;
|
|
439
|
+
if (!e || (e.replaceChildren(), !H)) return;
|
|
440
|
+
let t = L(e, H);
|
|
423
441
|
return () => t.remove();
|
|
424
|
-
}, [
|
|
442
|
+
}, [H]), /* @__PURE__ */ f("div", {
|
|
425
443
|
className: "liforma-experience-shell",
|
|
426
444
|
style: {
|
|
427
445
|
position: "relative",
|
|
@@ -430,14 +448,14 @@ var te = e(function(e, a) {
|
|
|
430
448
|
minHeight: "inherit"
|
|
431
449
|
},
|
|
432
450
|
children: [/* @__PURE__ */ d("div", {
|
|
433
|
-
ref:
|
|
451
|
+
ref: U,
|
|
434
452
|
className: "liforma-experience-error-host",
|
|
435
|
-
"aria-hidden":
|
|
453
|
+
"aria-hidden": H ? void 0 : !0,
|
|
436
454
|
style: {
|
|
437
455
|
position: "absolute",
|
|
438
456
|
inset: 0,
|
|
439
457
|
zIndex: 20,
|
|
440
|
-
pointerEvents:
|
|
458
|
+
pointerEvents: H ? "auto" : "none"
|
|
441
459
|
}
|
|
442
460
|
}), /* @__PURE__ */ d("div", {
|
|
443
461
|
ref: le,
|
|
@@ -452,32 +470,32 @@ var te = e(function(e, a) {
|
|
|
452
470
|
});
|
|
453
471
|
//#endregion
|
|
454
472
|
//#region src/thumbnail/types.ts
|
|
455
|
-
function
|
|
473
|
+
function re(e) {
|
|
456
474
|
return e === "face" ? "liforma-et--fit-face" : e === "medium" ? "liforma-et--fit-medium" : "";
|
|
457
475
|
}
|
|
458
476
|
//#endregion
|
|
459
477
|
//#region src/thumbnail/toGalleryThumbUrl.ts
|
|
460
|
-
var
|
|
461
|
-
function
|
|
478
|
+
var ie = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, R = /_CH(\.webp)/i, z = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
|
|
479
|
+
function B(e) {
|
|
462
480
|
let t = e.trim();
|
|
463
481
|
if (!t) return t;
|
|
464
|
-
let n = t.replace(
|
|
465
|
-
return n = n.replace(
|
|
482
|
+
let n = t.replace(ie, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`);
|
|
483
|
+
return n = n.replace(R, "_neutral$1"), n = n.replace(z, (e, t, n, r, i) => n === "256x256" ? `${t}${n}${r}${i}` : `${t}256x256${r}${i}`), n;
|
|
466
484
|
}
|
|
467
|
-
function
|
|
485
|
+
function ae(e) {
|
|
468
486
|
let t = e.avatarImage?.trim() || e.galleryThumb?.avatarImage?.trim() || "";
|
|
469
487
|
if (!t) return null;
|
|
470
488
|
let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "";
|
|
471
489
|
return {
|
|
472
|
-
avatarImage:
|
|
473
|
-
...n ? { backgroundImage:
|
|
474
|
-
...r ? { foregroundImage:
|
|
475
|
-
...i ? { fallbackImage:
|
|
490
|
+
avatarImage: B(t),
|
|
491
|
+
...n ? { backgroundImage: B(n) } : {},
|
|
492
|
+
...r ? { foregroundImage: B(r) } : {},
|
|
493
|
+
...i ? { fallbackImage: B(i) } : {}
|
|
476
494
|
};
|
|
477
495
|
}
|
|
478
496
|
//#endregion
|
|
479
497
|
//#region src/shims/localStack.ts
|
|
480
|
-
function
|
|
498
|
+
function V() {
|
|
481
499
|
if (globalThis.__LIFORMA_STACK === "local") return !0;
|
|
482
500
|
if (typeof location > "u") return !1;
|
|
483
501
|
try {
|
|
@@ -488,19 +506,19 @@ function B() {
|
|
|
488
506
|
}
|
|
489
507
|
//#endregion
|
|
490
508
|
//#region src/thumbnail/hostedLaunchUrl.ts
|
|
491
|
-
var
|
|
492
|
-
function
|
|
509
|
+
var H = "https://player.liforma.ai", oe = "http://localhost:3002";
|
|
510
|
+
function se(e) {
|
|
493
511
|
return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
|
|
494
512
|
}
|
|
495
|
-
function
|
|
513
|
+
function U(e) {
|
|
496
514
|
let t = e?.trim();
|
|
497
|
-
return t ? t.replace(/\/$/, "") :
|
|
515
|
+
return t ? t.replace(/\/$/, "") : V() ? oe : H;
|
|
498
516
|
}
|
|
499
517
|
function ce(e) {
|
|
500
|
-
let t = e.experienceId.trim(), n =
|
|
518
|
+
let t = e.experienceId.trim(), n = U(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
|
|
501
519
|
return i && r.searchParams.set("returnUrl", i), r.toString();
|
|
502
520
|
}
|
|
503
|
-
function
|
|
521
|
+
function le(e) {
|
|
504
522
|
let t = e.href?.trim();
|
|
505
523
|
if (t) return t;
|
|
506
524
|
let n = e.experienceId?.trim();
|
|
@@ -512,48 +530,48 @@ function H(e) {
|
|
|
512
530
|
playerBaseUrl: e.playerBaseUrl
|
|
513
531
|
});
|
|
514
532
|
}
|
|
515
|
-
function
|
|
533
|
+
function W() {
|
|
516
534
|
return typeof window > "u" ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
517
535
|
}
|
|
518
|
-
var
|
|
536
|
+
var ue = 0, G = [];
|
|
519
537
|
function de() {
|
|
520
|
-
return
|
|
521
|
-
}
|
|
522
|
-
function W() {
|
|
523
|
-
return le() ? 160 : 0;
|
|
538
|
+
return W() ? 4 : Infinity;
|
|
524
539
|
}
|
|
525
540
|
function fe() {
|
|
541
|
+
return W() ? 160 : 0;
|
|
542
|
+
}
|
|
543
|
+
function pe() {
|
|
526
544
|
let e = de();
|
|
527
|
-
for (;
|
|
528
|
-
let e =
|
|
545
|
+
for (; ue < e && G.length > 0;) {
|
|
546
|
+
let e = G.shift();
|
|
529
547
|
if (!e || e.cancelled) continue;
|
|
530
|
-
|
|
531
|
-
let t =
|
|
548
|
+
ue += 1, e.start();
|
|
549
|
+
let t = fe();
|
|
532
550
|
if (t <= 0) {
|
|
533
|
-
|
|
551
|
+
ue = Math.max(0, ue - 1);
|
|
534
552
|
continue;
|
|
535
553
|
}
|
|
536
554
|
window.setTimeout(() => {
|
|
537
|
-
|
|
555
|
+
ue = Math.max(0, ue - 1), pe();
|
|
538
556
|
}, t);
|
|
539
557
|
}
|
|
540
558
|
}
|
|
541
|
-
function
|
|
542
|
-
if (!
|
|
559
|
+
function me(e) {
|
|
560
|
+
if (!W()) return e(), () => {};
|
|
543
561
|
let t = {
|
|
544
562
|
start: e,
|
|
545
563
|
cancelled: !1
|
|
546
564
|
};
|
|
547
|
-
return
|
|
565
|
+
return G.push(t), pe(), () => {
|
|
548
566
|
t.cancelled = !0;
|
|
549
567
|
};
|
|
550
568
|
}
|
|
551
569
|
//#endregion
|
|
552
570
|
//#region src/thumbnail/lazyLoad.ts
|
|
553
|
-
function
|
|
554
|
-
return
|
|
571
|
+
function he() {
|
|
572
|
+
return W() ? "96px 0px" : "280px 0px";
|
|
555
573
|
}
|
|
556
|
-
function
|
|
574
|
+
function K(e) {
|
|
557
575
|
let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
|
|
558
576
|
return Number.isFinite(n) ? Math.abs(n) : 280;
|
|
559
577
|
}
|
|
@@ -563,8 +581,8 @@ function ge(e, t) {
|
|
|
563
581
|
return n.bottom >= -t && n.top <= window.innerHeight + t;
|
|
564
582
|
}
|
|
565
583
|
function _e(e, t) {
|
|
566
|
-
let { onVisibleChange: n } = t, r = t.rootMargin ??
|
|
567
|
-
o || (s?.(), s =
|
|
584
|
+
let { onVisibleChange: n } = t, r = t.rootMargin ?? he(), i = K(r), a = !1, o = !1, s = null, c = () => {
|
|
585
|
+
o || (s?.(), s = me(() => {
|
|
568
586
|
s = null, o = !0, n(!0);
|
|
569
587
|
}));
|
|
570
588
|
}, l = (e) => {
|
|
@@ -598,43 +616,43 @@ function ve() {
|
|
|
598
616
|
function ye(e, t) {
|
|
599
617
|
return ((e.top + e.height / 2) / Math.max(t, 1) - .5) * 2;
|
|
600
618
|
}
|
|
601
|
-
var
|
|
602
|
-
function
|
|
603
|
-
if (
|
|
619
|
+
var be = /* @__PURE__ */ new Set(), xe = !1, q = 0;
|
|
620
|
+
function J() {
|
|
621
|
+
if (q = 0, be.size === 0 || typeof window > "u") return;
|
|
604
622
|
let e = window.innerHeight;
|
|
605
|
-
for (let t of
|
|
623
|
+
for (let t of be) {
|
|
606
624
|
if (t.pointerActive?.()) continue;
|
|
607
625
|
let n = t.element.getBoundingClientRect();
|
|
608
626
|
n.bottom < -64 || n.top > e + 64 || t.onParallax(ye(n, e));
|
|
609
627
|
}
|
|
610
628
|
}
|
|
611
629
|
function Se() {
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
function q() {
|
|
615
|
-
be || typeof window > "u" || (be = !0, window.addEventListener("scroll", Se, { passive: !0 }), window.addEventListener("resize", Se, { passive: !0 }));
|
|
630
|
+
q === 0 && (q = requestAnimationFrame(J));
|
|
616
631
|
}
|
|
617
632
|
function Ce() {
|
|
618
|
-
|
|
633
|
+
xe || typeof window > "u" || (xe = !0, window.addEventListener("scroll", Se, { passive: !0 }), window.addEventListener("resize", Se, { passive: !0 }));
|
|
619
634
|
}
|
|
620
|
-
function we(
|
|
635
|
+
function we() {
|
|
636
|
+
be.size > 0 || !xe || typeof window > "u" || (xe = !1, q !== 0 && (cancelAnimationFrame(q), q = 0), window.removeEventListener("scroll", Se), window.removeEventListener("resize", Se));
|
|
637
|
+
}
|
|
638
|
+
function Te(e, t) {
|
|
621
639
|
if (!ve()) return () => {};
|
|
622
640
|
let n = {
|
|
623
641
|
element: e,
|
|
624
642
|
onParallax: t.onParallax,
|
|
625
643
|
pointerActive: t.pointerActive
|
|
626
644
|
};
|
|
627
|
-
return
|
|
628
|
-
|
|
645
|
+
return be.add(n), Ce(), n.pointerActive?.() || t.onParallax(ye(e.getBoundingClientRect(), window.innerHeight)), () => {
|
|
646
|
+
be.delete(n), we();
|
|
629
647
|
};
|
|
630
648
|
}
|
|
631
649
|
//#endregion
|
|
632
650
|
//#region src/thumbnail/attachThumbnailParallax.ts
|
|
633
|
-
function
|
|
651
|
+
function Ee(e) {
|
|
634
652
|
let t = 0, n = 0, r = !1, i = !1, a = !1, o = () => {
|
|
635
653
|
let a = r || i;
|
|
636
654
|
e.classList.toggle("liforma-et--parallax", a), e.classList.toggle("liforma-et--scroll-parallax", i), e.style.setProperty("--liforma-et-parallax-x", String(t)), e.style.setProperty("--liforma-et-parallax-y", String(n));
|
|
637
|
-
}, s =
|
|
655
|
+
}, s = Te(e, {
|
|
638
656
|
onParallax: (e) => {
|
|
639
657
|
i = !0, a || (t = e, n = 0, o());
|
|
640
658
|
},
|
|
@@ -659,23 +677,23 @@ function Te(e) {
|
|
|
659
677
|
}
|
|
660
678
|
//#endregion
|
|
661
679
|
//#region src/thumbnail/styles.ts
|
|
662
|
-
var
|
|
663
|
-
function
|
|
664
|
-
if (typeof document > "u" ||
|
|
680
|
+
var De = ".liforma-et {\n --liforma-et-parallax-x: 0;\n --liforma-et-parallax-y: 0;\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n --liforma-et-reveal-duration: 420ms;\n\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 0.65rem;\n overflow: hidden;\n background: #111;\n color: inherit;\n text-decoration: none;\n cursor: inherit;\n -webkit-tap-highlight-color: transparent;\n}\n\na.liforma-et,\nbutton.liforma-et {\n cursor: pointer;\n}\n\nbutton.liforma-et {\n font: inherit;\n appearance: none;\n}\n\n.liforma-et__placeholder {\n position: absolute;\n inset: 0;\n z-index: 0;\n background:\n radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 58%),\n linear-gradient(180deg, #1a1a1a 0%, #101010 100%);\n opacity: 1;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et--revealed .liforma-et__placeholder {\n opacity: 0;\n}\n\n.liforma-et__media {\n opacity: 0;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et__media--ready {\n opacity: 1;\n}\n\n.liforma-et__background {\n position: absolute;\n inset: 0;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-bg-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-bg-shift))\n )\n scale(var(--liforma-et-bg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et__avatar {\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n object-position: center bottom;\n transform: scale(var(--liforma-et-avatar-scale))\n translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-avatar-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-avatar-shift))\n );\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n/* Gallery plates are typically square in a square tile — contain vs cover is a no-op\n without a zoom. Scale the whole scene from the upper third so Face matches\n player fit (location + avatar crop together). */\n.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n}\n\n.liforma-et--fit-face .liforma-et__avatar,\n.liforma-et--fit-face .liforma-et__background,\n.liforma-et--fit-face .liforma-et__foreground {\n transform-origin: 50% 18%;\n}\n\n.liforma-et--fit-face .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 18%;\n}\n\n/* Bust / medium: less zoom than face so upper chest stays in frame (player 3.75H window). */\n.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.35;\n --liforma-et-bg-scale: 1.35;\n --liforma-et-fg-scale: 1.35;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar,\n.liforma-et--fit-medium .liforma-et__background,\n.liforma-et--fit-medium .liforma-et__foreground {\n transform-origin: 50% 28%;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 28%;\n}\n\n.liforma-et__foreground {\n position: absolute;\n inset: 0;\n z-index: 3;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n pointer-events: none;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-fg-shift) * -1),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-fg-shift) * -1)\n )\n scale(var(--liforma-et-fg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et--parallax {\n --liforma-et-bg-scale: 1.08;\n --liforma-et-fg-scale: 1.05;\n --liforma-et-avatar-scale: 1.08;\n --liforma-et-bg-shift: 10px;\n --liforma-et-fg-shift: 4px;\n --liforma-et-avatar-shift: 4px;\n}\n\n/* Promote layers only while parallax is active — avoids N compositor surfaces on galleries. */\n.liforma-et--parallax .liforma-et__background,\n.liforma-et--parallax .liforma-et__foreground,\n.liforma-et--parallax .liforma-et__avatar {\n will-change: transform;\n}\n\n.liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.95;\n --liforma-et-bg-scale: 1.95;\n --liforma-et-fg-scale: 1.95;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--parallax.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.42;\n --liforma-et-bg-scale: 1.42;\n --liforma-et-fg-scale: 1.42;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--scroll-parallax .liforma-et__background,\n.liforma-et--scroll-parallax .liforma-et__foreground,\n.liforma-et--scroll-parallax .liforma-et__avatar {\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-et {\n --liforma-et-reveal-duration: 0ms;\n }\n\n .liforma-et--parallax {\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n }\n\n .liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n }\n\n .liforma-et__background,\n .liforma-et__foreground,\n .liforma-et__avatar {\n transition: none;\n }\n}", Oe = !1;
|
|
681
|
+
function ke(e) {
|
|
682
|
+
if (typeof document > "u" || Oe) return;
|
|
665
683
|
if (document.querySelector("style[data-liforma-et]")) {
|
|
666
|
-
|
|
684
|
+
Oe = !0;
|
|
667
685
|
return;
|
|
668
686
|
}
|
|
669
687
|
let t = document.createElement("style");
|
|
670
|
-
t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t),
|
|
688
|
+
t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t), Oe = !0;
|
|
671
689
|
}
|
|
672
690
|
//#endregion
|
|
673
691
|
//#region src/react/ExperienceThumbnail.tsx
|
|
674
|
-
function
|
|
692
|
+
function Ae(e, t) {
|
|
675
693
|
return `${e} liforma-et__media${t ? " liforma-et__media--ready" : ""}`;
|
|
676
694
|
}
|
|
677
|
-
function
|
|
678
|
-
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(() =>
|
|
695
|
+
function je(e) {
|
|
696
|
+
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(() => ae({
|
|
679
697
|
galleryThumb: t,
|
|
680
698
|
avatarImage: r,
|
|
681
699
|
backgroundImage: i,
|
|
@@ -687,15 +705,15 @@ function Ae(e) {
|
|
|
687
705
|
i,
|
|
688
706
|
c,
|
|
689
707
|
w
|
|
690
|
-
]), E =
|
|
708
|
+
]), E = se({
|
|
691
709
|
href: m,
|
|
692
710
|
hasClickHandler: typeof _ == "function",
|
|
693
711
|
experienceId: p
|
|
694
|
-
}), 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), [
|
|
712
|
+
}), 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), [ne, ie] = s(0), [R, z] = s(!1), [B, V] = s(!1), [H, oe] = s(!1), [U, ce] = s(!1), [W, ue] = s(), G = T ? R && T.fallbackImage ? T.fallbackImage : T.avatarImage : "";
|
|
695
713
|
n(() => {
|
|
696
|
-
|
|
714
|
+
ke(De);
|
|
697
715
|
}, []), n(() => {
|
|
698
|
-
|
|
716
|
+
ue(le({
|
|
699
717
|
href: m,
|
|
700
718
|
experienceId: p,
|
|
701
719
|
returnUrl: v,
|
|
@@ -709,11 +727,11 @@ function Ae(e) {
|
|
|
709
727
|
y,
|
|
710
728
|
D
|
|
711
729
|
]), n(() => {
|
|
712
|
-
V(!1),
|
|
730
|
+
V(!1), oe(!1), ce(!1), z(!1);
|
|
713
731
|
}, [
|
|
714
732
|
T?.backgroundImage,
|
|
715
733
|
T?.foregroundImage,
|
|
716
|
-
|
|
734
|
+
G
|
|
717
735
|
]), n(() => {
|
|
718
736
|
let e = A.current;
|
|
719
737
|
if (e) {
|
|
@@ -729,10 +747,10 @@ function Ae(e) {
|
|
|
729
747
|
S,
|
|
730
748
|
T,
|
|
731
749
|
E,
|
|
732
|
-
|
|
750
|
+
W
|
|
733
751
|
]), n(() => {
|
|
734
752
|
let e = A.current;
|
|
735
|
-
if (!(!e || !k)) return
|
|
753
|
+
if (!(!e || !k)) return Te(e, {
|
|
736
754
|
onParallax: (e) => {
|
|
737
755
|
ee(!0), j.current || (L(e), ie(0));
|
|
738
756
|
},
|
|
@@ -742,25 +760,25 @@ function Ae(e) {
|
|
|
742
760
|
k,
|
|
743
761
|
T,
|
|
744
762
|
E,
|
|
745
|
-
|
|
763
|
+
W
|
|
746
764
|
]);
|
|
747
|
-
let
|
|
765
|
+
let de = (e) => {
|
|
748
766
|
if (!k || I) return;
|
|
749
767
|
let t = e.currentTarget.getBoundingClientRect();
|
|
750
768
|
t.width <= 0 || t.height <= 0 || (L(((e.clientX - t.left) / t.width - .5) * 2), ie(((e.clientY - t.top) / t.height - .5) * 2));
|
|
751
|
-
},
|
|
769
|
+
}, fe = (e) => {
|
|
752
770
|
let t = j.current;
|
|
753
771
|
j.current = !1, F(!1), I && t ? (L(ye(e.getBoundingClientRect(), window.innerHeight)), ie(0)) : I || (L(0), ie(0));
|
|
754
|
-
},
|
|
772
|
+
}, pe = (e) => {
|
|
755
773
|
if (!k) return;
|
|
756
774
|
j.current = !0, e.pointerType === "mouse" && F(!0);
|
|
757
775
|
let t = e.currentTarget, n = () => {
|
|
758
|
-
|
|
776
|
+
fe(t), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n);
|
|
759
777
|
};
|
|
760
778
|
window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n);
|
|
761
|
-
},
|
|
779
|
+
}, me = (e) => {
|
|
762
780
|
if (_?.(e), !e.defaultPrevented && D && !v?.trim()) {
|
|
763
|
-
let t =
|
|
781
|
+
let t = le({
|
|
764
782
|
experienceId: p,
|
|
765
783
|
playerBaseUrl: y,
|
|
766
784
|
useCurrentPageAsReturnUrl: !0
|
|
@@ -769,19 +787,19 @@ function Ae(e) {
|
|
|
769
787
|
}
|
|
770
788
|
};
|
|
771
789
|
if (!T) return null;
|
|
772
|
-
let
|
|
790
|
+
let he = k && (P || I), K = M && (H || B || U), ge = [
|
|
773
791
|
"liforma-et",
|
|
774
792
|
O ? "liforma-et--scene" : "",
|
|
775
|
-
|
|
776
|
-
|
|
793
|
+
re(x),
|
|
794
|
+
he ? "liforma-et--parallax" : "",
|
|
777
795
|
I ? "liforma-et--scroll-parallax" : "",
|
|
778
|
-
M && !
|
|
779
|
-
|
|
796
|
+
M && !K ? "liforma-et--loading" : "",
|
|
797
|
+
K ? "liforma-et--revealed" : "",
|
|
780
798
|
C
|
|
781
|
-
].filter(Boolean).join(" "),
|
|
799
|
+
].filter(Boolean).join(" "), ve = {
|
|
782
800
|
"--liforma-et-parallax-x": te,
|
|
783
|
-
"--liforma-et-parallax-y":
|
|
784
|
-
},
|
|
801
|
+
"--liforma-et-parallax-y": ne
|
|
802
|
+
}, be = (e, t) => {
|
|
785
803
|
e.complete && t(!0);
|
|
786
804
|
}, xe = /* @__PURE__ */ f(u, { children: [
|
|
787
805
|
/* @__PURE__ */ d("span", {
|
|
@@ -789,114 +807,114 @@ function Ae(e) {
|
|
|
789
807
|
"aria-hidden": "true"
|
|
790
808
|
}),
|
|
791
809
|
M && T.backgroundImage ? /* @__PURE__ */ d("img", {
|
|
792
|
-
className:
|
|
810
|
+
className: Ae("liforma-et__background", B),
|
|
793
811
|
src: T.backgroundImage,
|
|
794
812
|
alt: "",
|
|
795
813
|
decoding: "async",
|
|
796
814
|
ref: (e) => {
|
|
797
|
-
e &&
|
|
815
|
+
e && be(e, V);
|
|
798
816
|
},
|
|
799
817
|
onLoad: () => V(!0),
|
|
800
818
|
onError: () => V(!0)
|
|
801
819
|
}) : null,
|
|
802
|
-
M &&
|
|
803
|
-
className:
|
|
804
|
-
src:
|
|
820
|
+
M && G ? /* @__PURE__ */ d("img", {
|
|
821
|
+
className: Ae("liforma-et__avatar", H),
|
|
822
|
+
src: G,
|
|
805
823
|
alt: "",
|
|
806
824
|
decoding: "async",
|
|
807
825
|
ref: (e) => {
|
|
808
|
-
e &&
|
|
826
|
+
e && be(e, oe);
|
|
809
827
|
},
|
|
810
|
-
onLoad: () =>
|
|
828
|
+
onLoad: () => oe(!0),
|
|
811
829
|
onError: () => {
|
|
812
|
-
T.fallbackImage ?
|
|
830
|
+
T.fallbackImage ? z(!0) : oe(!0);
|
|
813
831
|
}
|
|
814
832
|
}) : null,
|
|
815
833
|
M && T.foregroundImage ? /* @__PURE__ */ d("img", {
|
|
816
|
-
className:
|
|
834
|
+
className: Ae("liforma-et__foreground", U),
|
|
817
835
|
src: T.foregroundImage,
|
|
818
836
|
alt: "",
|
|
819
837
|
decoding: "async",
|
|
820
838
|
ref: (e) => {
|
|
821
|
-
e &&
|
|
839
|
+
e && be(e, ce);
|
|
822
840
|
},
|
|
823
|
-
onLoad: () =>
|
|
824
|
-
onError: () =>
|
|
841
|
+
onLoad: () => ce(!0),
|
|
842
|
+
onError: () => ce(!0)
|
|
825
843
|
}) : null
|
|
826
|
-
] }),
|
|
827
|
-
onPointerDown:
|
|
828
|
-
onPointerUp: (e) =>
|
|
829
|
-
onPointerCancel: (e) =>
|
|
844
|
+
] }), q = {
|
|
845
|
+
onPointerDown: pe,
|
|
846
|
+
onPointerUp: (e) => fe(e.currentTarget),
|
|
847
|
+
onPointerCancel: (e) => fe(e.currentTarget),
|
|
830
848
|
onPointerEnter: (e) => {
|
|
831
849
|
k && e.pointerType === "mouse" && F(!0);
|
|
832
850
|
},
|
|
833
|
-
onPointerMove:
|
|
851
|
+
onPointerMove: de,
|
|
834
852
|
onPointerLeave: () => {
|
|
835
853
|
j.current || (F(!1), I || (L(0), ie(0)));
|
|
836
854
|
}
|
|
837
|
-
},
|
|
855
|
+
}, J = (e) => {
|
|
838
856
|
A.current = e;
|
|
839
857
|
};
|
|
840
|
-
return E === "anchor" &&
|
|
841
|
-
ref:
|
|
842
|
-
className:
|
|
843
|
-
style:
|
|
844
|
-
href:
|
|
858
|
+
return E === "anchor" && W ? /* @__PURE__ */ d("a", {
|
|
859
|
+
ref: J,
|
|
860
|
+
className: ge,
|
|
861
|
+
style: ve,
|
|
862
|
+
href: W,
|
|
845
863
|
target: h,
|
|
846
864
|
rel: g,
|
|
847
865
|
"aria-label": l,
|
|
848
|
-
onClick:
|
|
849
|
-
...
|
|
866
|
+
onClick: me,
|
|
867
|
+
...q,
|
|
850
868
|
children: xe
|
|
851
869
|
}) : E === "button" ? /* @__PURE__ */ d("button", {
|
|
852
870
|
type: "button",
|
|
853
|
-
ref:
|
|
854
|
-
className:
|
|
855
|
-
style:
|
|
871
|
+
ref: J,
|
|
872
|
+
className: ge,
|
|
873
|
+
style: ve,
|
|
856
874
|
"aria-label": l,
|
|
857
|
-
onClick:
|
|
858
|
-
...
|
|
875
|
+
onClick: me,
|
|
876
|
+
...q,
|
|
859
877
|
children: xe
|
|
860
878
|
}) : /* @__PURE__ */ d("div", {
|
|
861
|
-
ref:
|
|
862
|
-
className:
|
|
863
|
-
style:
|
|
879
|
+
ref: J,
|
|
880
|
+
className: ge,
|
|
881
|
+
style: ve,
|
|
864
882
|
role: l ? "img" : void 0,
|
|
865
883
|
"aria-label": l || void 0,
|
|
866
884
|
"aria-hidden": l ? void 0 : !0,
|
|
867
|
-
...
|
|
885
|
+
...q,
|
|
868
886
|
children: xe
|
|
869
887
|
});
|
|
870
888
|
}
|
|
871
889
|
//#endregion
|
|
872
890
|
//#region src/widget/styles.ts
|
|
873
|
-
var je = "\n.liforma-ew {\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n}\n\n/* Optional self-positioned FAB (position=bottom-right|bottom-left).\n * Cap at 50vmin so small phones don't get an oversized thumb (desktop 224px stays). */\n.liforma-ew[data-position='bottom-right'],\n.liforma-ew[data-position='bottom-left'] {\n position: fixed;\n width: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n height: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n bottom: var(--liforma-ew-offset, 16px);\n z-index: 2147482900;\n}\n\n.liforma-ew[data-position='bottom-right'] {\n right: var(--liforma-ew-offset, 16px);\n left: auto;\n}\n\n.liforma-ew[data-position='bottom-left'] {\n left: var(--liforma-ew-offset, 16px);\n right: auto;\n}\n\n/* While open, collapse the FAB box so a corner hole / thumb never remains. */\n.liforma-ew[data-position='bottom-right'][data-state='expanded'],\n.liforma-ew[data-position='bottom-right'][data-state='docked'],\n.liforma-ew[data-position='bottom-left'][data-state='expanded'],\n.liforma-ew[data-position='bottom-left'][data-state='docked'] {\n width: 0;\n height: 0;\n min-width: 0;\n min-height: 0;\n overflow: visible;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='expanded'] .liforma-ew__overlay,\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar,\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__hit {\n box-sizing: border-box;\n display: block;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n font: inherit;\n appearance: none;\n -webkit-tap-highlight-color: transparent;\n transform: scale(1);\n transform-origin: center center;\n transition:\n transform 180ms ease,\n filter 180ms ease;\n will-change: transform;\n}\n\n/* Author display must not defeat the HTML hidden attribute. */\n.liforma-ew__hit[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 3px;\n border-radius: 0.75rem;\n}\n\n@media (hover: hover) and (pointer: fine) {\n /* Scale the thumb whenever the collapsed FAB is hovered — including via the warm iframe hit layer. */\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: scale(1.06);\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover .liforma-et,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-et {\n box-shadow: 0 12px 36px rgba(0, 0, 0, 0.34);\n }\n}\n\n.liforma-ew__face {\n width: 100%;\n height: 100%;\n min-height: 0;\n position: relative;\n}\n\n.liforma-ew__face-status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 0.5rem;\n text-align: center;\n font: 600 0.75rem/1.3 system-ui, sans-serif;\n color: #e8ecf4;\n background: rgba(10, 12, 18, 0.72);\n border-radius: 0.75rem;\n pointer-events: none;\n}\n\n.liforma-ew__face-status[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:disabled {\n cursor: default;\n opacity: 0.85;\n}\n\n.liforma-ew__face .liforma-et {\n border-radius: 0.75rem;\n box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);\n transition: box-shadow 180ms ease;\n}\n\n.liforma-ew__warm {\n box-sizing: border-box;\n position: absolute;\n inset: 0;\n z-index: 2;\n border-radius: 0.75rem;\n overflow: hidden;\n background: transparent;\n pointer-events: none;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n/*\n * Collapsed: keep the warm iframe as an invisible hit target only.\n * Painting it over the thumb causes a “ghost enlarge” (face scales under a static iframe).\n */\n.liforma-ew[data-state='collapsed'] .liforma-ew__warm {\n opacity: 0;\n transition: none;\n}\n\n.liforma-ew[data-warm='true'] .liforma-ew__warm {\n pointer-events: auto;\n}\n\n.liforma-ew[data-warm='true']:not([data-live='true']) .liforma-ew__hit {\n pointer-events: none;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__hit {\n pointer-events: auto;\n}\n\n.liforma-ew[data-live='true'] .liforma-ew__warm,\n.liforma-ew[data-live='true'] .liforma-ew__stage {\n /* Hidden under the thumb / until post-resize fade-in (matches cold avatar reveal). */\n opacity: 0;\n}\n\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__stage,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__stage {\n opacity: 1;\n}\n\n.liforma-ew--session-concealing .liforma-ew__warm,\n.liforma-ew--session-concealing .liforma-ew__stage {\n transition-duration: 280ms;\n}\n\n/* Instant hide while dock/maximize geometry settles (player morph resize ~160ms). */\n.liforma-ew--layout-settling .liforma-ew__warm,\n.liforma-ew--layout-settling .liforma-ew__stage {\n opacity: 0 !important;\n transition: none !important;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__warm {\n /* Keep the live iframe under the thumb; FAB click resumes the shell. */\n pointer-events: none;\n opacity: 0;\n /* Instant hide when collapsed so the FAB never shows a resized live mesh. */\n transition: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm {\n position: fixed;\n /* Match overlay panel inset so the warm iframe fills the conversation shell. */\n inset: clamp(12px, 3vw, 28px);\n z-index: 2147483001;\n width: auto;\n height: auto;\n border-radius: 16px;\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__warm {\n position: fixed;\n inset: auto;\n z-index: 2147483001;\n border-radius: 16px;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew__toolbar {\n display: none;\n position: fixed;\n z-index: 2147483002;\n pointer-events: auto;\n box-sizing: border-box;\n align-items: center;\n gap: 0.35rem;\n padding: 0.35rem 0.4rem;\n border-radius: 999px;\n background: rgba(12, 14, 20, 0.72);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n display: flex;\n top: calc(clamp(12px, 3vw, 28px) + 10px);\n right: calc(clamp(12px, 3vw, 28px) + 10px);\n left: auto;\n cursor: default;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n display: flex;\n /* left/top set inline to track the panel; strip remains a drag handle */\n cursor: grab;\n touch-action: none;\n user-select: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__stage {\n /* Player also reports surface drags via postMessage when docked. */\n cursor: grab;\n touch-action: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar.liforma-ew__toolbar--dragging,\n.liforma-ew--dock-dragging,\n.liforma-ew--dock-dragging .liforma-ew__toolbar,\n.liforma-ew--dock-dragging .liforma-ew__panel,\n.liforma-ew--dock-dragging .liforma-ew__warm,\n.liforma-ew--dock-dragging .liforma-ew__stage {\n cursor: grabbing;\n}\n\n\n.liforma-ew__toolbar[hidden] {\n display: none !important;\n}\n\n.liforma-ew__icon-btn {\n appearance: none;\n box-sizing: border-box;\n display: inline-grid;\n place-items: center;\n width: 2rem;\n height: 2rem;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 999px;\n color: #f5f7fb;\n background: transparent;\n cursor: pointer;\n}\n\n.liforma-ew__icon-btn:hover {\n background: rgba(255, 255, 255, 0.12);\n}\n\n.liforma-ew__icon-btn[aria-pressed='true'] {\n background: rgba(255, 255, 255, 0.2);\n}\n\n.liforma-ew__icon-btn:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 2px;\n}\n\n.liforma-ew__icon-btn svg {\n width: 1.05rem;\n height: 1.05rem;\n display: block;\n}\n\n.liforma-ew__drag-grip {\n display: none;\n width: 0.85rem;\n height: 1.25rem;\n margin: 0 0.15rem 0 0.25rem;\n background:\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0 0 / 0.35rem 0.35rem,\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0.35rem 0 / 0.35rem 0.35rem;\n background-repeat: repeat-y;\n opacity: 0.55;\n color: #f5f7fb;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__drag-grip {\n display: block;\n}\n\n.liforma-ew__dock-toggle[hidden] {\n display: none !important;\n}\n\n.liforma-ew__overlay {\n position: fixed;\n inset: 0;\n z-index: 2147483000;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: clamp(12px, 3vw, 28px);\n box-sizing: border-box;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n padding: 0;\n align-items: stretch;\n justify-content: stretch;\n pointer-events: none;\n background: transparent;\n}\n\n.liforma-ew__overlay[hidden] {\n display: none !important;\n}\n\n.liforma-ew__backdrop {\n position: absolute;\n inset: 0;\n border: 0;\n padding: 0;\n margin: 0;\n background: rgba(6, 8, 14, 0.62);\n cursor: pointer;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__backdrop {\n display: none !important;\n}\n\n.liforma-ew__panel {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: column;\n /* Fill the overlay so player loading / start UI centers in the visible window. */\n width: var(--liforma-ew-max-w, 100%);\n height: var(--liforma-ew-max-h, 100%);\n max-width: 100%;\n max-height: 100%;\n border-radius: 16px;\n overflow: hidden;\n background: #030508;\n box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);\n /* Warm iframe sits above as a sibling; keep panel as chrome shell. */\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n position: fixed;\n inset: auto;\n max-width: none;\n max-height: none;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew:not([data-warm='true']) .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__stage {\n position: relative;\n flex: 1;\n min-height: 0;\n width: 100%;\n height: 100%;\n background: #030508;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n.liforma-ew__status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 1.5rem;\n text-align: center;\n color: #d7dde8;\n font: 500 0.9375rem/1.45 system-ui, sans-serif;\n background: rgba(3, 5, 8, 0.92);\n pointer-events: none;\n}\n\n.liforma-ew__status[hidden] {\n display: none !important;\n}\n\n/* Mobile expanded: ~90% viewport, no reduce control. */\n@media (max-width: 767px) {\n .liforma-ew[data-state='expanded'] .liforma-ew__overlay {\n padding: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__panel {\n width: 90vw;\n height: 90vh;\n max-width: 90vw;\n max-height: 90vh;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__warm {\n inset: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n top: calc(5vh + 10px);\n right: calc(5vw + 10px);\n }\n\n .liforma-ew__dock-toggle {\n display: none !important;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-ew__hit {\n transition: none;\n will-change: auto;\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: none;\n }\n\n .liforma-ew__face .liforma-et {\n box-shadow: none;\n transition: none;\n }\n\n .liforma-ew__warm,\n .liforma-ew__stage {\n transition: none;\n }\n}\n", Me = "liforma-experience-widget-styles";
|
|
874
|
-
function
|
|
891
|
+
var Me = "\n.liforma-ew {\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n}\n\n/* Optional self-positioned FAB (position=bottom-right|bottom-left).\n * Cap at 50vmin so small phones don't get an oversized thumb (desktop 224px stays). */\n.liforma-ew[data-position='bottom-right'],\n.liforma-ew[data-position='bottom-left'] {\n position: fixed;\n width: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n height: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n bottom: var(--liforma-ew-offset, 16px);\n z-index: 2147482900;\n}\n\n.liforma-ew[data-position='bottom-right'] {\n right: var(--liforma-ew-offset, 16px);\n left: auto;\n}\n\n.liforma-ew[data-position='bottom-left'] {\n left: var(--liforma-ew-offset, 16px);\n right: auto;\n}\n\n/* While open, collapse the FAB box so a corner hole / thumb never remains. */\n.liforma-ew[data-position='bottom-right'][data-state='expanded'],\n.liforma-ew[data-position='bottom-right'][data-state='docked'],\n.liforma-ew[data-position='bottom-left'][data-state='expanded'],\n.liforma-ew[data-position='bottom-left'][data-state='docked'] {\n width: 0;\n height: 0;\n min-width: 0;\n min-height: 0;\n overflow: visible;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='expanded'] .liforma-ew__overlay,\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar,\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__hit {\n box-sizing: border-box;\n display: block;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n font: inherit;\n appearance: none;\n -webkit-tap-highlight-color: transparent;\n transform: scale(1);\n transform-origin: center center;\n transition:\n transform 180ms ease,\n filter 180ms ease;\n will-change: transform;\n}\n\n/* Author display must not defeat the HTML hidden attribute. */\n.liforma-ew__hit[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 3px;\n border-radius: 0.75rem;\n}\n\n@media (hover: hover) and (pointer: fine) {\n /* Scale the thumb whenever the collapsed FAB is hovered — including via the warm iframe hit layer. */\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: scale(1.06);\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover .liforma-et,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-et {\n box-shadow: 0 12px 36px rgba(0, 0, 0, 0.34);\n }\n}\n\n.liforma-ew__face {\n width: 100%;\n height: 100%;\n min-height: 0;\n position: relative;\n}\n\n.liforma-ew__face-status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 0.5rem;\n text-align: center;\n font: 600 0.75rem/1.3 system-ui, sans-serif;\n color: #e8ecf4;\n background: rgba(10, 12, 18, 0.72);\n border-radius: 0.75rem;\n pointer-events: none;\n}\n\n.liforma-ew__face-status[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:disabled {\n cursor: default;\n opacity: 0.85;\n}\n\n.liforma-ew__face .liforma-et {\n border-radius: 0.75rem;\n box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);\n transition: box-shadow 180ms ease;\n}\n\n.liforma-ew__warm {\n box-sizing: border-box;\n position: absolute;\n inset: 0;\n z-index: 2;\n border-radius: 0.75rem;\n overflow: hidden;\n background: transparent;\n pointer-events: none;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n/*\n * Collapsed: keep the warm iframe as an invisible hit target only.\n * Painting it over the thumb causes a “ghost enlarge” (face scales under a static iframe).\n */\n.liforma-ew[data-state='collapsed'] .liforma-ew__warm {\n opacity: 0;\n transition: none;\n}\n\n.liforma-ew[data-warm='true'] .liforma-ew__warm {\n pointer-events: auto;\n}\n\n.liforma-ew[data-warm='true']:not([data-live='true']) .liforma-ew__hit {\n pointer-events: none;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__hit {\n pointer-events: auto;\n}\n\n.liforma-ew[data-live='true'] .liforma-ew__warm,\n.liforma-ew[data-live='true'] .liforma-ew__stage {\n /* Hidden under the thumb / until post-resize fade-in (matches cold avatar reveal). */\n opacity: 0;\n}\n\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__stage,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__stage {\n opacity: 1;\n}\n\n.liforma-ew--session-concealing .liforma-ew__warm,\n.liforma-ew--session-concealing .liforma-ew__stage {\n transition-duration: 280ms;\n}\n\n/* Instant hide while dock/maximize geometry settles (player morph resize ~160ms). */\n.liforma-ew--layout-settling .liforma-ew__warm,\n.liforma-ew--layout-settling .liforma-ew__stage {\n opacity: 0 !important;\n transition: none !important;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__warm {\n /* Keep the live iframe under the thumb; FAB click resumes the shell. */\n pointer-events: none;\n opacity: 0;\n /* Instant hide when collapsed so the FAB never shows a resized live mesh. */\n transition: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm {\n position: fixed;\n /* Match overlay panel inset so the warm iframe fills the conversation shell. */\n inset: clamp(12px, 3vw, 28px);\n z-index: 2147483001;\n width: auto;\n height: auto;\n border-radius: 16px;\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__warm {\n position: fixed;\n inset: auto;\n z-index: 2147483001;\n border-radius: 16px;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew__toolbar {\n display: none;\n position: fixed;\n z-index: 2147483002;\n pointer-events: auto;\n box-sizing: border-box;\n align-items: center;\n gap: 0.35rem;\n padding: 0.35rem 0.4rem;\n border-radius: 999px;\n background: rgba(12, 14, 20, 0.72);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n display: flex;\n top: calc(clamp(12px, 3vw, 28px) + 10px);\n right: calc(clamp(12px, 3vw, 28px) + 10px);\n left: auto;\n cursor: default;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n display: flex;\n /* left/top set inline to track the panel; strip remains a drag handle */\n cursor: grab;\n touch-action: none;\n user-select: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__stage {\n /* Player also reports surface drags via postMessage when docked. */\n cursor: grab;\n touch-action: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar.liforma-ew__toolbar--dragging,\n.liforma-ew--dock-dragging,\n.liforma-ew--dock-dragging .liforma-ew__toolbar,\n.liforma-ew--dock-dragging .liforma-ew__panel,\n.liforma-ew--dock-dragging .liforma-ew__warm,\n.liforma-ew--dock-dragging .liforma-ew__stage {\n cursor: grabbing;\n}\n\n\n.liforma-ew__toolbar[hidden] {\n display: none !important;\n}\n\n.liforma-ew__icon-btn {\n appearance: none;\n box-sizing: border-box;\n display: inline-grid;\n place-items: center;\n width: 2rem;\n height: 2rem;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 999px;\n color: #f5f7fb;\n background: transparent;\n cursor: pointer;\n}\n\n.liforma-ew__icon-btn:hover {\n background: rgba(255, 255, 255, 0.12);\n}\n\n.liforma-ew__icon-btn[aria-pressed='true'] {\n background: rgba(255, 255, 255, 0.2);\n}\n\n.liforma-ew__icon-btn:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 2px;\n}\n\n.liforma-ew__icon-btn svg {\n width: 1.05rem;\n height: 1.05rem;\n display: block;\n}\n\n.liforma-ew__drag-grip {\n display: none;\n width: 0.85rem;\n height: 1.25rem;\n margin: 0 0.15rem 0 0.25rem;\n background:\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0 0 / 0.35rem 0.35rem,\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0.35rem 0 / 0.35rem 0.35rem;\n background-repeat: repeat-y;\n opacity: 0.55;\n color: #f5f7fb;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__drag-grip {\n display: block;\n}\n\n.liforma-ew__dock-toggle[hidden] {\n display: none !important;\n}\n\n.liforma-ew__overlay {\n position: fixed;\n inset: 0;\n z-index: 2147483000;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: clamp(12px, 3vw, 28px);\n box-sizing: border-box;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n padding: 0;\n align-items: stretch;\n justify-content: stretch;\n pointer-events: none;\n background: transparent;\n}\n\n.liforma-ew__overlay[hidden] {\n display: none !important;\n}\n\n.liforma-ew__backdrop {\n position: absolute;\n inset: 0;\n border: 0;\n padding: 0;\n margin: 0;\n background: rgba(6, 8, 14, 0.62);\n cursor: pointer;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__backdrop {\n display: none !important;\n}\n\n.liforma-ew__panel {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: column;\n /* Fill the overlay so player loading / start UI centers in the visible window. */\n width: var(--liforma-ew-max-w, 100%);\n height: var(--liforma-ew-max-h, 100%);\n max-width: 100%;\n max-height: 100%;\n border-radius: 16px;\n overflow: hidden;\n background: #030508;\n box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);\n /* Warm iframe sits above as a sibling; keep panel as chrome shell. */\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n position: fixed;\n inset: auto;\n max-width: none;\n max-height: none;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew:not([data-warm='true']) .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__stage {\n position: relative;\n flex: 1;\n min-height: 0;\n width: 100%;\n height: 100%;\n background: #030508;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n.liforma-ew__status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 1.5rem;\n text-align: center;\n color: #d7dde8;\n font: 500 0.9375rem/1.45 system-ui, sans-serif;\n background: rgba(3, 5, 8, 0.92);\n pointer-events: none;\n}\n\n.liforma-ew__status[hidden] {\n display: none !important;\n}\n\n/* Mobile expanded: ~90% viewport, no reduce control. */\n@media (max-width: 767px) {\n .liforma-ew[data-state='expanded'] .liforma-ew__overlay {\n padding: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__panel {\n width: 90vw;\n height: 90vh;\n max-width: 90vw;\n max-height: 90vh;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__warm {\n inset: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n top: calc(5vh + 10px);\n right: calc(5vw + 10px);\n }\n\n .liforma-ew__dock-toggle {\n display: none !important;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-ew__hit {\n transition: none;\n will-change: auto;\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: none;\n }\n\n .liforma-ew__face .liforma-et {\n box-shadow: none;\n transition: none;\n }\n\n .liforma-ew__warm,\n .liforma-ew__stage {\n transition: none;\n }\n}\n", Ne = "liforma-experience-widget-styles";
|
|
892
|
+
function Pe(e = Me) {
|
|
875
893
|
if (typeof document > "u") return;
|
|
876
|
-
let t = document.getElementById(
|
|
894
|
+
let t = document.getElementById(Ne);
|
|
877
895
|
if (t) {
|
|
878
896
|
t.textContent = e;
|
|
879
897
|
return;
|
|
880
898
|
}
|
|
881
899
|
let n = document.createElement("style");
|
|
882
|
-
n.id =
|
|
900
|
+
n.id = Ne, n.textContent = e, document.head.append(n);
|
|
883
901
|
}
|
|
884
902
|
//#endregion
|
|
885
903
|
//#region src/shims/apiBaseUrl.ts
|
|
886
|
-
var
|
|
887
|
-
function
|
|
904
|
+
var Fe = "https://api.liforma.ai", Ie = "http://localhost:3001";
|
|
905
|
+
function Le() {
|
|
888
906
|
let e = globalThis.__LIFORMA_API_BASE_URL;
|
|
889
907
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
890
908
|
if (typeof document > "u") return null;
|
|
891
909
|
let t = (document.querySelector("script[data-liforma-sdk][src*=\"client.js\"]") ?? document.querySelector("script[src*=\"/sdk/v2/client.js\"]"))?.getAttribute("data-api-base-url")?.trim();
|
|
892
910
|
return t ? t.replace(/\/$/, "") : null;
|
|
893
911
|
}
|
|
894
|
-
function
|
|
895
|
-
return
|
|
912
|
+
function Re() {
|
|
913
|
+
return Le() || (V() ? Ie : Fe);
|
|
896
914
|
}
|
|
897
915
|
//#endregion
|
|
898
916
|
//#region src/v2/api/fetchExperiencePreview.ts
|
|
899
|
-
function
|
|
917
|
+
function ze(e) {
|
|
900
918
|
if (!e || typeof e != "object") return null;
|
|
901
919
|
let t = e, n = typeof t.avatarImage == "string" ? t.avatarImage.trim() : "";
|
|
902
920
|
return n ? {
|
|
@@ -905,10 +923,10 @@ function Re(e) {
|
|
|
905
923
|
...typeof t.foregroundImage == "string" && t.foregroundImage.trim() ? { foregroundImage: t.foregroundImage.trim() } : {}
|
|
906
924
|
} : null;
|
|
907
925
|
}
|
|
908
|
-
async function
|
|
926
|
+
async function Be(e, t) {
|
|
909
927
|
let n = e.trim();
|
|
910
928
|
if (!n) throw Error("Experience preview requires experienceId.");
|
|
911
|
-
let r = (t?.apiBaseUrl ??
|
|
929
|
+
let r = (t?.apiBaseUrl ?? Re()).replace(/\/$/, ""), i = await fetch(`${r}/v1/experiences/${encodeURIComponent(n)}/preview`, {
|
|
912
930
|
method: "GET",
|
|
913
931
|
headers: { Accept: "application/json" },
|
|
914
932
|
signal: t?.signal
|
|
@@ -928,7 +946,7 @@ async function ze(e, t) {
|
|
|
928
946
|
throw Error("Experience preview returned invalid JSON.");
|
|
929
947
|
}
|
|
930
948
|
if (!a || typeof a != "object") throw Error("Experience preview returned an invalid payload.");
|
|
931
|
-
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l =
|
|
949
|
+
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l = ze(o.galleryThumb);
|
|
932
950
|
if (!l) throw Error("Experience preview is missing gallery thumb images.");
|
|
933
951
|
return {
|
|
934
952
|
experienceId: s || n,
|
|
@@ -938,7 +956,7 @@ async function ze(e, t) {
|
|
|
938
956
|
}
|
|
939
957
|
//#endregion
|
|
940
958
|
//#region src/v2/errors/LiformaError.ts
|
|
941
|
-
var
|
|
959
|
+
var Ve = class extends Error {
|
|
942
960
|
code;
|
|
943
961
|
requestId;
|
|
944
962
|
status;
|
|
@@ -947,16 +965,16 @@ var J = class extends Error {
|
|
|
947
965
|
super(e, t?.cause === void 0 ? void 0 : { cause: t.cause }), this.name = "LiformaError", this.code = t?.code?.trim() || "UNKNOWN", this.requestId = t?.requestId?.trim() || void 0, this.status = t?.status, this.details = t?.details;
|
|
948
966
|
}
|
|
949
967
|
};
|
|
950
|
-
function
|
|
968
|
+
function He(e) {
|
|
951
969
|
if (!(!e || typeof e != "object" || Array.isArray(e))) return e;
|
|
952
970
|
}
|
|
953
|
-
function
|
|
971
|
+
function Ue(e, t, n) {
|
|
954
972
|
let r = n?.get("Liforma-Request-Id")?.trim() || void 0, i;
|
|
955
973
|
try {
|
|
956
974
|
i = JSON.parse(t);
|
|
957
975
|
} catch {}
|
|
958
|
-
let a = i?.error && typeof i.error == "object" ? i.error : void 0, o = a?.code ?? i?.code, s = a?.message ?? i?.message, c = a?.requestId ?? i?.requestId ?? r, l = typeof o == "string" && o.trim() ? o.trim() : "HTTP_ERROR", u = typeof s == "string" && s.trim() ? s.trim() : t.trim().slice(0, 500) || `Request failed (${e})`, d = typeof c == "string" && c.trim() ? c.trim() : r, { code: f, message: p, requestId: m, ...h } =
|
|
959
|
-
return new
|
|
976
|
+
let a = i?.error && typeof i.error == "object" ? i.error : void 0, o = a?.code ?? i?.code, s = a?.message ?? i?.message, c = a?.requestId ?? i?.requestId ?? r, l = typeof o == "string" && o.trim() ? o.trim() : "HTTP_ERROR", u = typeof s == "string" && s.trim() ? s.trim() : t.trim().slice(0, 500) || `Request failed (${e})`, d = typeof c == "string" && c.trim() ? c.trim() : r, { code: f, message: p, requestId: m, ...h } = He(a) ?? He(i) ?? {};
|
|
977
|
+
return new Ve(u, {
|
|
960
978
|
code: l,
|
|
961
979
|
requestId: d,
|
|
962
980
|
status: e,
|
|
@@ -965,13 +983,13 @@ function Ve(e, t, n) {
|
|
|
965
983
|
}
|
|
966
984
|
//#endregion
|
|
967
985
|
//#region src/v2/api/captureAttribution.ts
|
|
968
|
-
var
|
|
986
|
+
var We = 128, Ge = /[\u0000-\u001f\u007f]/g;
|
|
969
987
|
function Y(e) {
|
|
970
988
|
if (!e) return;
|
|
971
|
-
let t = e.replace(
|
|
972
|
-
if (t) return t.slice(0,
|
|
989
|
+
let t = e.replace(Ge, "").trim();
|
|
990
|
+
if (t) return t.slice(0, We);
|
|
973
991
|
}
|
|
974
|
-
function
|
|
992
|
+
function Ke(e) {
|
|
975
993
|
let t = new URLSearchParams((e ?? "").startsWith("?") ? (e ?? "").slice(1) : e ?? "");
|
|
976
994
|
return {
|
|
977
995
|
...Y(t.get("utm_source")) ? { utmSource: Y(t.get("utm_source")) } : {},
|
|
@@ -981,7 +999,7 @@ function We(e) {
|
|
|
981
999
|
...Y(t.get("utm_term")) ? { utmTerm: Y(t.get("utm_term")) } : {}
|
|
982
1000
|
};
|
|
983
1001
|
}
|
|
984
|
-
function
|
|
1002
|
+
function qe(e) {
|
|
985
1003
|
if (e === !1) return;
|
|
986
1004
|
if (e && typeof e == "object") {
|
|
987
1005
|
let t = {
|
|
@@ -995,7 +1013,7 @@ function Ge(e) {
|
|
|
995
1013
|
return Object.keys(t).length ? t : void 0;
|
|
996
1014
|
}
|
|
997
1015
|
if (typeof window > "u") return;
|
|
998
|
-
let t =
|
|
1016
|
+
let t = Ke(window.location?.search), n = Y(document.referrer || void 0), r = {
|
|
999
1017
|
...t,
|
|
1000
1018
|
...n ? { referrer: n } : {}
|
|
1001
1019
|
};
|
|
@@ -1003,19 +1021,19 @@ function Ge(e) {
|
|
|
1003
1021
|
}
|
|
1004
1022
|
//#endregion
|
|
1005
1023
|
//#region src/v2/api/sessionEndpointRequest.ts
|
|
1006
|
-
function
|
|
1024
|
+
function Je(e) {
|
|
1007
1025
|
let t = e.locale?.trim();
|
|
1008
1026
|
if (t) return t;
|
|
1009
1027
|
let n = e.language?.trim();
|
|
1010
1028
|
if (n) return n;
|
|
1011
1029
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
1012
1030
|
}
|
|
1013
|
-
function
|
|
1031
|
+
function Ye(e) {
|
|
1014
1032
|
let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
|
|
1015
1033
|
if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
|
|
1016
1034
|
return t || n || void 0;
|
|
1017
1035
|
}
|
|
1018
|
-
function
|
|
1036
|
+
function Xe(e, t) {
|
|
1019
1037
|
let n = e.trim();
|
|
1020
1038
|
if (!n) throw Error("sessionEndpoint must not be empty.");
|
|
1021
1039
|
if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
|
|
@@ -1023,7 +1041,7 @@ function Je(e, t) {
|
|
|
1023
1041
|
if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
|
|
1024
1042
|
let i = t.experienceId.trim();
|
|
1025
1043
|
if (!i) throw Error("sessionEndpoint requires experienceId.");
|
|
1026
|
-
let a =
|
|
1044
|
+
let a = Je(t), o = Ye(t), s = t.idempotencyKey?.trim();
|
|
1027
1045
|
return {
|
|
1028
1046
|
url: r.toString(),
|
|
1029
1047
|
init: {
|
|
@@ -1042,25 +1060,26 @@ function Je(e, t) {
|
|
|
1042
1060
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
1043
1061
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
1044
1062
|
...(() => {
|
|
1045
|
-
let e =
|
|
1063
|
+
let e = qe(t.attribution);
|
|
1046
1064
|
return e ? { attribution: e } : {};
|
|
1047
|
-
})()
|
|
1065
|
+
})(),
|
|
1066
|
+
...t.alreadyConverted?.length ? { alreadyConverted: [...t.alreadyConverted] } : {}
|
|
1048
1067
|
})
|
|
1049
1068
|
}
|
|
1050
1069
|
};
|
|
1051
1070
|
}
|
|
1052
1071
|
//#endregion
|
|
1053
1072
|
//#region src/v2/types/sessionLaunch.ts
|
|
1054
|
-
function
|
|
1073
|
+
function Ze(e) {
|
|
1055
1074
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
1056
1075
|
}
|
|
1057
1076
|
function X(e) {
|
|
1058
1077
|
return typeof e == "boolean";
|
|
1059
1078
|
}
|
|
1060
|
-
function
|
|
1061
|
-
if (!
|
|
1079
|
+
function Qe(e) {
|
|
1080
|
+
if (!Ze(e)) return null;
|
|
1062
1081
|
let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
|
|
1063
|
-
return !
|
|
1082
|
+
return !Ze(t) || !Ze(n) || !Ze(r) || !Ze(i) || !X(t.input) || !X(t.output) || !X(t.externalAudio) || !X(n.managed) || !X(r.enabled) || !X(i.enabled) ? null : {
|
|
1064
1083
|
speech: {
|
|
1065
1084
|
input: t.input,
|
|
1066
1085
|
output: t.output,
|
|
@@ -1071,8 +1090,8 @@ function Xe(e) {
|
|
|
1071
1090
|
tools: { enabled: i.enabled }
|
|
1072
1091
|
};
|
|
1073
1092
|
}
|
|
1074
|
-
function
|
|
1075
|
-
return !
|
|
1093
|
+
function $e(e) {
|
|
1094
|
+
return !Ze(e) || !X(e.avatar) || !X(e.speechInput) || !X(e.speechOutput) || !X(e.tools) || !X(e.externalAudio) ? null : {
|
|
1076
1095
|
speech: {
|
|
1077
1096
|
input: e.speechInput,
|
|
1078
1097
|
output: e.speechOutput,
|
|
@@ -1083,12 +1102,12 @@ function Ze(e) {
|
|
|
1083
1102
|
tools: { enabled: e.tools }
|
|
1084
1103
|
};
|
|
1085
1104
|
}
|
|
1086
|
-
function
|
|
1087
|
-
return
|
|
1105
|
+
function et(e) {
|
|
1106
|
+
return Qe(e) ?? $e(e);
|
|
1088
1107
|
}
|
|
1089
|
-
function
|
|
1090
|
-
if (!
|
|
1091
|
-
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 =
|
|
1108
|
+
function tt(e) {
|
|
1109
|
+
if (!Ze(e)) throw Error("Session Launch response is missing session.");
|
|
1110
|
+
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 = et(e.capabilities), l = nt(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;
|
|
1092
1111
|
if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
|
|
1093
1112
|
return {
|
|
1094
1113
|
id: t,
|
|
@@ -1104,11 +1123,11 @@ function $e(e) {
|
|
|
1104
1123
|
...d ? { createdAt: d } : {}
|
|
1105
1124
|
};
|
|
1106
1125
|
}
|
|
1107
|
-
function
|
|
1126
|
+
function nt(e) {
|
|
1108
1127
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
1109
1128
|
let t = [];
|
|
1110
1129
|
for (let n of e) {
|
|
1111
|
-
if (!
|
|
1130
|
+
if (!Ze(n)) continue;
|
|
1112
1131
|
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() : "";
|
|
1113
1132
|
!e || !r || !i || n.reason !== "voice_unsupported" || t.push({
|
|
1114
1133
|
axis: e,
|
|
@@ -1119,104 +1138,104 @@ function et(e) {
|
|
|
1119
1138
|
}
|
|
1120
1139
|
return t.length > 0 ? t : void 0;
|
|
1121
1140
|
}
|
|
1122
|
-
function
|
|
1141
|
+
function rt(e) {
|
|
1123
1142
|
let t = e.localeVoiceFallbacks;
|
|
1124
1143
|
if (t?.length) for (let e of t) {
|
|
1125
1144
|
let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
|
|
1126
1145
|
console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
|
|
1127
1146
|
}
|
|
1128
1147
|
}
|
|
1129
|
-
function
|
|
1130
|
-
if (!
|
|
1148
|
+
function it(e) {
|
|
1149
|
+
if (!Ze(e)) throw Error("Session Launch response must be a JSON object.");
|
|
1131
1150
|
let t = typeof e.launch == "string" ? e.launch.trim() : "";
|
|
1132
1151
|
if (!t) throw Error("Session Launch response is missing launch.");
|
|
1133
|
-
let n =
|
|
1134
|
-
return
|
|
1152
|
+
let n = tt(e.session);
|
|
1153
|
+
return rt(n), {
|
|
1135
1154
|
session: n,
|
|
1136
1155
|
launch: t
|
|
1137
1156
|
};
|
|
1138
1157
|
}
|
|
1139
1158
|
//#endregion
|
|
1140
1159
|
//#region src/v2/api/mintPublicSession.ts
|
|
1141
|
-
function
|
|
1160
|
+
function at() {
|
|
1142
1161
|
try {
|
|
1143
1162
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
1144
1163
|
} catch {}
|
|
1145
1164
|
}
|
|
1146
|
-
function
|
|
1165
|
+
function ot(e) {
|
|
1147
1166
|
return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
|
|
1148
1167
|
}
|
|
1149
|
-
function
|
|
1150
|
-
let n =
|
|
1168
|
+
function st(e, t) {
|
|
1169
|
+
let n = at(), r = ot(t.code), i = t.message.trim(), a = t.details ?? {};
|
|
1151
1170
|
if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
|
|
1152
1171
|
if (i.includes(e) && i.includes("allowed origin")) return t;
|
|
1153
1172
|
let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
|
|
1154
|
-
return new
|
|
1173
|
+
return new Ve(`Your origin ${r} is not an allowed origin for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, add ${r} to the list of allowed origins, and ensure “Allow public client-only embeds” is enabled.`, {
|
|
1155
1174
|
code: "ORIGIN_NOT_ALLOWED",
|
|
1156
1175
|
requestId: t.requestId,
|
|
1157
1176
|
status: t.status,
|
|
1158
1177
|
details: a
|
|
1159
1178
|
});
|
|
1160
1179
|
}
|
|
1161
|
-
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new
|
|
1180
|
+
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new Ve(`Browser embeds are not enabled for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, and enable “Allow public client-only embeds”.`, {
|
|
1162
1181
|
code: "BROWSER_EMBEDS_DISABLED",
|
|
1163
1182
|
requestId: t.requestId,
|
|
1164
1183
|
status: t.status,
|
|
1165
1184
|
details: a
|
|
1166
|
-
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new
|
|
1185
|
+
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new Ve(`No playable experience found for “${e}”. Check that the experience id is correct (it should look like exp_…), and that the experience exists and is published in the Liforma developer portal (app.liforma.ai). Deleted, archived, and unpublished experiences cannot be started from a browser embed.`, {
|
|
1167
1186
|
code: "EXPERIENCE_UNAVAILABLE",
|
|
1168
1187
|
requestId: t.requestId,
|
|
1169
1188
|
status: t.status,
|
|
1170
1189
|
details: a
|
|
1171
1190
|
}) : t;
|
|
1172
1191
|
}
|
|
1173
|
-
function
|
|
1192
|
+
function ct(e) {
|
|
1174
1193
|
let t = e?.locale?.trim();
|
|
1175
1194
|
if (t) return t;
|
|
1176
1195
|
let n = e?.language?.trim();
|
|
1177
1196
|
if (n) return n;
|
|
1178
1197
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
1179
1198
|
}
|
|
1180
|
-
function
|
|
1199
|
+
function lt(e) {
|
|
1181
1200
|
let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
|
|
1182
|
-
if (t && n && t !== n) throw new
|
|
1201
|
+
if (t && n && t !== n) throw new Ve("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
|
|
1183
1202
|
return t || n || void 0;
|
|
1184
1203
|
}
|
|
1185
|
-
function
|
|
1186
|
-
let n = { experienceId: e }, r =
|
|
1204
|
+
function ut(e, t) {
|
|
1205
|
+
let n = { experienceId: e }, r = ct(t);
|
|
1187
1206
|
r && (n.locale = r);
|
|
1188
|
-
let i =
|
|
1207
|
+
let i = lt(t);
|
|
1189
1208
|
i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly);
|
|
1190
|
-
let a =
|
|
1191
|
-
return a && (n.attribution = a), n;
|
|
1209
|
+
let a = qe(t?.attribution);
|
|
1210
|
+
return a && (n.attribution = a), t?.alreadyConverted?.length && (n.alreadyConverted = [...t.alreadyConverted]), n;
|
|
1192
1211
|
}
|
|
1193
|
-
async function
|
|
1194
|
-
let n =
|
|
1212
|
+
async function dt(e, t) {
|
|
1213
|
+
let n = Re(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
|
|
1195
1214
|
method: "POST",
|
|
1196
1215
|
headers: {
|
|
1197
1216
|
"Content-Type": "application/json",
|
|
1198
1217
|
...r ? { "Idempotency-Key": r } : {}
|
|
1199
1218
|
},
|
|
1200
|
-
body: JSON.stringify(
|
|
1219
|
+
body: JSON.stringify(ut(e, t))
|
|
1201
1220
|
});
|
|
1202
1221
|
if (!i.ok) {
|
|
1203
1222
|
let t = await i.text();
|
|
1204
|
-
throw
|
|
1223
|
+
throw st(e, Ue(i.status, t, i.headers));
|
|
1205
1224
|
}
|
|
1206
1225
|
let a;
|
|
1207
1226
|
try {
|
|
1208
1227
|
a = await i.json();
|
|
1209
1228
|
} catch {
|
|
1210
|
-
throw new
|
|
1229
|
+
throw new Ve("Browser session mint returned invalid JSON.", {
|
|
1211
1230
|
code: "INVALID_RESPONSE",
|
|
1212
1231
|
status: i.status,
|
|
1213
1232
|
requestId: i.headers.get("Liforma-Request-Id") ?? void 0
|
|
1214
1233
|
});
|
|
1215
1234
|
}
|
|
1216
|
-
return
|
|
1235
|
+
return it(a);
|
|
1217
1236
|
}
|
|
1218
|
-
async function
|
|
1219
|
-
let n =
|
|
1237
|
+
async function ft(e, t) {
|
|
1238
|
+
let n = Xe(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
|
|
1220
1239
|
t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
|
|
1221
1240
|
let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
|
|
1222
1241
|
try {
|
|
@@ -1229,9 +1248,9 @@ async function ut(e, t) {
|
|
|
1229
1248
|
}
|
|
1230
1249
|
if (!o.ok) {
|
|
1231
1250
|
let e = await o.text();
|
|
1232
|
-
throw
|
|
1251
|
+
throw Ue(o.status, e, o.headers);
|
|
1233
1252
|
}
|
|
1234
|
-
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new
|
|
1253
|
+
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new Ve("Session endpoint must return a JSON Session Launch response.", {
|
|
1235
1254
|
code: "INVALID_RESPONSE",
|
|
1236
1255
|
status: o.status,
|
|
1237
1256
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
@@ -1240,20 +1259,20 @@ async function ut(e, t) {
|
|
|
1240
1259
|
try {
|
|
1241
1260
|
s = await o.json();
|
|
1242
1261
|
} catch {
|
|
1243
|
-
throw new
|
|
1262
|
+
throw new Ve("Session endpoint returned invalid JSON.", {
|
|
1244
1263
|
code: "INVALID_RESPONSE",
|
|
1245
1264
|
status: o.status,
|
|
1246
1265
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
1247
1266
|
});
|
|
1248
1267
|
}
|
|
1249
|
-
return
|
|
1268
|
+
return it(s);
|
|
1250
1269
|
}
|
|
1251
1270
|
//#endregion
|
|
1252
1271
|
//#region src/v2/conversationProcessor.ts
|
|
1253
|
-
function
|
|
1272
|
+
function pt(e) {
|
|
1254
1273
|
return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
|
|
1255
1274
|
}
|
|
1256
|
-
function
|
|
1275
|
+
function mt(e) {
|
|
1257
1276
|
if (typeof e == "string") {
|
|
1258
1277
|
let t = e.trim();
|
|
1259
1278
|
if (!t) throw Error("conversationProcessor returned empty text.");
|
|
@@ -1267,24 +1286,24 @@ function ft(e) {
|
|
|
1267
1286
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
1268
1287
|
};
|
|
1269
1288
|
}
|
|
1270
|
-
async function
|
|
1289
|
+
async function ht(e, t) {
|
|
1271
1290
|
let n = await e(t);
|
|
1272
|
-
return
|
|
1291
|
+
return pt(n) ? {
|
|
1273
1292
|
kind: "stream",
|
|
1274
1293
|
stream: n
|
|
1275
1294
|
} : {
|
|
1276
1295
|
kind: "complete",
|
|
1277
|
-
speech:
|
|
1296
|
+
speech: mt(n)
|
|
1278
1297
|
};
|
|
1279
1298
|
}
|
|
1280
1299
|
//#endregion
|
|
1281
1300
|
//#region src/v2/embed/playerReachability.ts
|
|
1282
|
-
var
|
|
1283
|
-
function
|
|
1301
|
+
var gt = "3002";
|
|
1302
|
+
function _t(e) {
|
|
1284
1303
|
let t = new URL(e);
|
|
1285
|
-
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 ||
|
|
1304
|
+
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 || gt}. 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.`;
|
|
1286
1305
|
}
|
|
1287
|
-
async function
|
|
1306
|
+
async function vt(e, t) {
|
|
1288
1307
|
try {
|
|
1289
1308
|
await fetch(e, {
|
|
1290
1309
|
method: "GET",
|
|
@@ -1292,25 +1311,25 @@ async function gt(e, t) {
|
|
|
1292
1311
|
signal: AbortSignal.timeout(8e3)
|
|
1293
1312
|
});
|
|
1294
1313
|
} catch {
|
|
1295
|
-
throw Error(
|
|
1314
|
+
throw Error(_t(t));
|
|
1296
1315
|
}
|
|
1297
1316
|
}
|
|
1298
|
-
function
|
|
1317
|
+
function yt(e, t, n, r) {
|
|
1299
1318
|
try {
|
|
1300
1319
|
r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
|
|
1301
1320
|
} catch (e) {
|
|
1302
|
-
throw e instanceof DOMException && e.name === "SecurityError" ? Error(
|
|
1321
|
+
throw e instanceof DOMException && e.name === "SecurityError" ? Error(_t(n), { cause: e }) : e;
|
|
1303
1322
|
}
|
|
1304
1323
|
}
|
|
1305
|
-
var
|
|
1306
|
-
function yt(e) {
|
|
1307
|
-
return typeof e == "number" && vt.has(e);
|
|
1308
|
-
}
|
|
1309
|
-
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("."));
|
|
1324
|
+
var bt = new Set([1, 2]);
|
|
1310
1325
|
function xt(e) {
|
|
1326
|
+
return typeof e == "number" && bt.has(e);
|
|
1327
|
+
}
|
|
1328
|
+
var St = 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.interactionChange".split("."));
|
|
1329
|
+
function Ct(e) {
|
|
1311
1330
|
if (!e || typeof e != "object") return null;
|
|
1312
1331
|
let t = e;
|
|
1313
|
-
if (!
|
|
1332
|
+
if (!xt(t.schemaVersion) || !t.type || !St.has(t.type)) return null;
|
|
1314
1333
|
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
1315
1334
|
if (t.type === "fullWindow") {
|
|
1316
1335
|
let e = t.payload;
|
|
@@ -1333,10 +1352,10 @@ function xt(e) {
|
|
|
1333
1352
|
let n = t.payload;
|
|
1334
1353
|
return !n || typeof n != "object" ? null : t;
|
|
1335
1354
|
}
|
|
1336
|
-
function
|
|
1355
|
+
function wt(e, t, n) {
|
|
1337
1356
|
let r = e.trim();
|
|
1338
1357
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
1339
|
-
let i = n?.startButton, a = n?.theme, o = n?.showFeedback;
|
|
1358
|
+
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction;
|
|
1340
1359
|
return {
|
|
1341
1360
|
type: "launch",
|
|
1342
1361
|
schemaVersion: 2,
|
|
@@ -1345,24 +1364,25 @@ function St(e, t, n) {
|
|
|
1345
1364
|
...t === void 0 ? {} : { session: t },
|
|
1346
1365
|
...i ? { startButton: i } : {},
|
|
1347
1366
|
...a ? { theme: a } : {},
|
|
1348
|
-
...o === void 0 ? {} : { showFeedback: o }
|
|
1367
|
+
...o === void 0 ? {} : { showFeedback: o },
|
|
1368
|
+
...s ? { interaction: s } : {}
|
|
1349
1369
|
}
|
|
1350
1370
|
};
|
|
1351
1371
|
}
|
|
1352
|
-
function
|
|
1372
|
+
function Tt() {
|
|
1353
1373
|
return {
|
|
1354
1374
|
type: "parentHello",
|
|
1355
1375
|
schemaVersion: 2
|
|
1356
1376
|
};
|
|
1357
1377
|
}
|
|
1358
|
-
function
|
|
1378
|
+
function Et(e) {
|
|
1359
1379
|
return {
|
|
1360
1380
|
type: "widgetSetChrome",
|
|
1361
1381
|
schemaVersion: 2,
|
|
1362
1382
|
payload: { mode: e }
|
|
1363
1383
|
};
|
|
1364
1384
|
}
|
|
1365
|
-
function
|
|
1385
|
+
function Dt() {
|
|
1366
1386
|
return {
|
|
1367
1387
|
type: "widgetToggleAudioSettings",
|
|
1368
1388
|
schemaVersion: 2,
|
|
@@ -1371,8 +1391,8 @@ function Tt() {
|
|
|
1371
1391
|
}
|
|
1372
1392
|
//#endregion
|
|
1373
1393
|
//#region src/v2/embed/fullWindowHost.ts
|
|
1374
|
-
var
|
|
1375
|
-
function
|
|
1394
|
+
var Ot = "2147483000";
|
|
1395
|
+
function kt(e) {
|
|
1376
1396
|
let { style: t } = e;
|
|
1377
1397
|
return {
|
|
1378
1398
|
position: t.position,
|
|
@@ -1390,11 +1410,11 @@ function Dt(e) {
|
|
|
1390
1410
|
maxHeight: t.maxHeight
|
|
1391
1411
|
};
|
|
1392
1412
|
}
|
|
1393
|
-
function
|
|
1413
|
+
function At(e) {
|
|
1394
1414
|
let { style: t } = e;
|
|
1395
|
-
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 =
|
|
1415
|
+
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 = Ot, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
|
|
1396
1416
|
}
|
|
1397
|
-
function
|
|
1417
|
+
function jt(e, t) {
|
|
1398
1418
|
if (delete e.dataset.liformaFullWindow, !t) {
|
|
1399
1419
|
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 = "";
|
|
1400
1420
|
return;
|
|
@@ -1404,20 +1424,20 @@ function kt(e, t) {
|
|
|
1404
1424
|
}
|
|
1405
1425
|
//#endregion
|
|
1406
1426
|
//#region src/v2/embed/iframeHost.ts
|
|
1407
|
-
function
|
|
1427
|
+
function Mt(e) {
|
|
1408
1428
|
return e;
|
|
1409
1429
|
}
|
|
1410
1430
|
function Z() {
|
|
1411
1431
|
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)}`;
|
|
1412
1432
|
}
|
|
1413
|
-
var
|
|
1414
|
-
function
|
|
1433
|
+
var Nt = 3e4;
|
|
1434
|
+
function Pt(e) {
|
|
1415
1435
|
let t = e.container;
|
|
1416
1436
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
1417
1437
|
let n = document.createElement("iframe");
|
|
1418
1438
|
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");
|
|
1419
1439
|
let r = !1, i = !1, a = null, o = t.closest(".liforma-experience-shell") instanceof HTMLElement ? t.closest(".liforma-experience-shell") : t, s = (t) => {
|
|
1420
|
-
i !== t && (i = t, t ? (a =
|
|
1440
|
+
i !== t && (i = t, t ? (a = kt(o), At(o)) : (jt(o, a), a = null), e.onFullWindowChange?.(t));
|
|
1421
1441
|
}, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
|
|
1422
1442
|
p = e, m = t;
|
|
1423
1443
|
}), g = () => {
|
|
@@ -1428,10 +1448,10 @@ function Mt(e) {
|
|
|
1428
1448
|
let i = Date.now();
|
|
1429
1449
|
if (d > 0 && i - d < 250) return;
|
|
1430
1450
|
d = i, g();
|
|
1431
|
-
let a =
|
|
1451
|
+
let a = wt(t.launch, t.session, t.chrome), o = () => {
|
|
1432
1452
|
if (r) return;
|
|
1433
1453
|
let t = n.contentWindow;
|
|
1434
|
-
t &&
|
|
1454
|
+
t && yt(t, a, e.playerOrigin);
|
|
1435
1455
|
};
|
|
1436
1456
|
o();
|
|
1437
1457
|
for (let e = 1; e <= 12; e += 1) f.push(window.setTimeout(o, e * 75));
|
|
@@ -1439,17 +1459,17 @@ function Mt(e) {
|
|
|
1439
1459
|
r || !l || _(l);
|
|
1440
1460
|
}, y = () => {
|
|
1441
1461
|
if (u += 1, u === 1) {
|
|
1442
|
-
|
|
1462
|
+
vt(e.src, e.playerOrigin).then(() => p?.(), (e) => m?.(e instanceof Error ? e : Error(String(e))));
|
|
1443
1463
|
return;
|
|
1444
1464
|
}
|
|
1445
1465
|
d = 0, v();
|
|
1446
1466
|
}, b = () => {
|
|
1447
|
-
u > 0 || m?.(Error(
|
|
1467
|
+
u > 0 || m?.(Error(_t(e.playerOrigin)));
|
|
1448
1468
|
};
|
|
1449
1469
|
n.addEventListener("load", y), n.addEventListener("error", b);
|
|
1450
1470
|
let x = (t) => {
|
|
1451
1471
|
if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
|
|
1452
|
-
let i =
|
|
1472
|
+
let i = Ct(t.data);
|
|
1453
1473
|
if (i) switch (i.type) {
|
|
1454
1474
|
case "close":
|
|
1455
1475
|
e.onClose?.(i.payload);
|
|
@@ -1488,7 +1508,7 @@ function Mt(e) {
|
|
|
1488
1508
|
e.onUserSpeechEnded?.(i.payload);
|
|
1489
1509
|
break;
|
|
1490
1510
|
case "modeChange":
|
|
1491
|
-
e.onActivityChange?.(
|
|
1511
|
+
e.onActivityChange?.(Mt(i.payload.mode));
|
|
1492
1512
|
break;
|
|
1493
1513
|
case "activityChange":
|
|
1494
1514
|
e.onActivityChange?.(i.payload.activity);
|
|
@@ -1532,6 +1552,9 @@ function Mt(e) {
|
|
|
1532
1552
|
case "fullWindow":
|
|
1533
1553
|
s(i.payload.active);
|
|
1534
1554
|
break;
|
|
1555
|
+
case "interactionChange":
|
|
1556
|
+
e.onInteractionChange?.(i.payload.interaction);
|
|
1557
|
+
break;
|
|
1535
1558
|
}
|
|
1536
1559
|
};
|
|
1537
1560
|
if (window.addEventListener("message", x), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
|
|
@@ -1541,8 +1564,8 @@ function Mt(e) {
|
|
|
1541
1564
|
let S = (t, i) => {
|
|
1542
1565
|
if (r) return;
|
|
1543
1566
|
let a = n.contentWindow;
|
|
1544
|
-
if (!a) throw Error(
|
|
1545
|
-
|
|
1567
|
+
if (!a) throw Error(_t(e.playerOrigin));
|
|
1568
|
+
yt(a, t, e.playerOrigin, i);
|
|
1546
1569
|
}, C = (e, t = 12e4, n) => {
|
|
1547
1570
|
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Z();
|
|
1548
1571
|
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((i, a) => {
|
|
@@ -1559,7 +1582,7 @@ function Mt(e) {
|
|
|
1559
1582
|
return h;
|
|
1560
1583
|
},
|
|
1561
1584
|
postParentHello() {
|
|
1562
|
-
S(
|
|
1585
|
+
S(Tt());
|
|
1563
1586
|
},
|
|
1564
1587
|
postLaunch(e, t, n) {
|
|
1565
1588
|
r || (l = {
|
|
@@ -1581,10 +1604,10 @@ function Mt(e) {
|
|
|
1581
1604
|
throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
|
|
1582
1605
|
},
|
|
1583
1606
|
postWidgetSetChrome(e) {
|
|
1584
|
-
S(
|
|
1607
|
+
S(Et(e));
|
|
1585
1608
|
},
|
|
1586
1609
|
postWidgetToggleAudioSettings() {
|
|
1587
|
-
S(
|
|
1610
|
+
S(Dt());
|
|
1588
1611
|
},
|
|
1589
1612
|
speak(e) {
|
|
1590
1613
|
return C({
|
|
@@ -1706,7 +1729,7 @@ function Mt(e) {
|
|
|
1706
1729
|
audio: e.audio,
|
|
1707
1730
|
byteLength: e.byteLength
|
|
1708
1731
|
}
|
|
1709
|
-
},
|
|
1732
|
+
}, Nt, [e.audio]);
|
|
1710
1733
|
},
|
|
1711
1734
|
speechUtteranceSetTranscript(e) {
|
|
1712
1735
|
return C({
|
|
@@ -1778,6 +1801,23 @@ function Mt(e) {
|
|
|
1778
1801
|
}
|
|
1779
1802
|
});
|
|
1780
1803
|
},
|
|
1804
|
+
setInteraction(e) {
|
|
1805
|
+
return C({
|
|
1806
|
+
type: "setInteraction",
|
|
1807
|
+
schemaVersion: 2,
|
|
1808
|
+
payload: {
|
|
1809
|
+
correlationId: Z(),
|
|
1810
|
+
interaction: e
|
|
1811
|
+
}
|
|
1812
|
+
});
|
|
1813
|
+
},
|
|
1814
|
+
getInteraction() {
|
|
1815
|
+
return C({
|
|
1816
|
+
type: "getInteraction",
|
|
1817
|
+
schemaVersion: 2,
|
|
1818
|
+
payload: { correlationId: Z() }
|
|
1819
|
+
});
|
|
1820
|
+
},
|
|
1781
1821
|
conversion(e) {
|
|
1782
1822
|
return C({
|
|
1783
1823
|
type: "conversion",
|
|
@@ -1795,6 +1835,21 @@ function Mt(e) {
|
|
|
1795
1835
|
payload: { correlationId: Z() }
|
|
1796
1836
|
});
|
|
1797
1837
|
},
|
|
1838
|
+
reportSdkError(e) {
|
|
1839
|
+
return C({
|
|
1840
|
+
type: "reportSdkError",
|
|
1841
|
+
schemaVersion: 2,
|
|
1842
|
+
payload: {
|
|
1843
|
+
correlationId: Z(),
|
|
1844
|
+
errorCode: e.errorCode,
|
|
1845
|
+
message: e.message,
|
|
1846
|
+
stack: e.stack,
|
|
1847
|
+
severity: e.severity,
|
|
1848
|
+
operation: e.operation,
|
|
1849
|
+
release: e.release
|
|
1850
|
+
}
|
|
1851
|
+
});
|
|
1852
|
+
},
|
|
1798
1853
|
destroy() {
|
|
1799
1854
|
if (!r) {
|
|
1800
1855
|
r = !0, i && s(!1);
|
|
@@ -1806,7 +1861,7 @@ function Mt(e) {
|
|
|
1806
1861
|
}
|
|
1807
1862
|
//#endregion
|
|
1808
1863
|
//#region src/v2/embed/readyGate.ts
|
|
1809
|
-
function
|
|
1864
|
+
function Ft(e) {
|
|
1810
1865
|
let t, n = !1, r = !1, i = () => {
|
|
1811
1866
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
1812
1867
|
};
|
|
@@ -1820,51 +1875,272 @@ function Nt(e) {
|
|
|
1820
1875
|
};
|
|
1821
1876
|
}
|
|
1822
1877
|
//#endregion
|
|
1823
|
-
//#region src/v2/
|
|
1824
|
-
var
|
|
1825
|
-
|
|
1878
|
+
//#region src/v2/sdkRelease.ts
|
|
1879
|
+
var It = `sdk@${{
|
|
1880
|
+
name: "@liforma/client",
|
|
1881
|
+
version: "0.4.10",
|
|
1882
|
+
type: "module",
|
|
1883
|
+
description: "Liforma browser SDK — Experience sessions, speech API, and Svelte embed component.",
|
|
1884
|
+
license: "MIT",
|
|
1885
|
+
homepage: "https://docs.liforma.ai",
|
|
1886
|
+
repository: {
|
|
1887
|
+
type: "git",
|
|
1888
|
+
url: "git+https://github.com/LiformaLtd/cdn.liforma.ai.git"
|
|
1889
|
+
},
|
|
1890
|
+
bugs: { url: "https://github.com/LiformaLtd/cdn.liforma.ai/issues" },
|
|
1891
|
+
publishConfig: { access: "public" },
|
|
1892
|
+
sideEffects: !1,
|
|
1893
|
+
exports: {
|
|
1894
|
+
".": {
|
|
1895
|
+
types: "./dist/npm/v2/npm.d.ts",
|
|
1896
|
+
import: "./dist/npm/index.js"
|
|
1897
|
+
},
|
|
1898
|
+
"./svelte": {
|
|
1899
|
+
types: "./dist/svelte/index.d.ts",
|
|
1900
|
+
import: "./dist/svelte/index.js",
|
|
1901
|
+
svelte: "./dist/svelte/index.js"
|
|
1902
|
+
},
|
|
1903
|
+
"./svelte/thumbnail": {
|
|
1904
|
+
types: "./dist/svelte/thumbnail.d.ts",
|
|
1905
|
+
import: "./dist/svelte/thumbnail.js",
|
|
1906
|
+
svelte: "./dist/svelte/thumbnail.js"
|
|
1907
|
+
},
|
|
1908
|
+
"./thumbnail": {
|
|
1909
|
+
types: "./dist/npm/thumbnail/index.d.ts",
|
|
1910
|
+
import: "./dist/npm/thumbnail/index.js"
|
|
1911
|
+
},
|
|
1912
|
+
"./react": {
|
|
1913
|
+
types: "./dist/react/react/index.d.ts",
|
|
1914
|
+
import: "./dist/react/index.js"
|
|
1915
|
+
},
|
|
1916
|
+
"./react/thumbnail": {
|
|
1917
|
+
types: "./dist/react/react/thumbnail.d.ts",
|
|
1918
|
+
import: "./dist/react/thumbnail.js"
|
|
1919
|
+
},
|
|
1920
|
+
"./next": {
|
|
1921
|
+
types: "./dist/next/next/index.d.ts",
|
|
1922
|
+
import: "./dist/next/index.js"
|
|
1923
|
+
},
|
|
1924
|
+
"./next/thumbnail": {
|
|
1925
|
+
types: "./dist/next/next/thumbnail.d.ts",
|
|
1926
|
+
import: "./dist/next/thumbnail.js"
|
|
1927
|
+
},
|
|
1928
|
+
"./byo": {
|
|
1929
|
+
types: "./dist/byo/index.d.ts",
|
|
1930
|
+
import: "./dist/byo/index.js"
|
|
1931
|
+
},
|
|
1932
|
+
"./elevenlabs": {
|
|
1933
|
+
types: "./dist/elevenlabs/index.d.ts",
|
|
1934
|
+
import: "./dist/elevenlabs/index.js"
|
|
1935
|
+
},
|
|
1936
|
+
"./openai": {
|
|
1937
|
+
types: "./dist/openai/index.d.ts",
|
|
1938
|
+
import: "./dist/openai/index.js"
|
|
1939
|
+
},
|
|
1940
|
+
"./deepgram": {
|
|
1941
|
+
types: "./dist/deepgram/index.d.ts",
|
|
1942
|
+
import: "./dist/deepgram/index.js"
|
|
1943
|
+
},
|
|
1944
|
+
"./google": {
|
|
1945
|
+
types: "./dist/google/index.d.ts",
|
|
1946
|
+
import: "./dist/google/index.js"
|
|
1947
|
+
},
|
|
1948
|
+
"./livekit": {
|
|
1949
|
+
types: "./dist/livekit/index.d.ts",
|
|
1950
|
+
import: "./dist/livekit/index.js"
|
|
1951
|
+
}
|
|
1952
|
+
},
|
|
1953
|
+
files: [
|
|
1954
|
+
"dist/npm",
|
|
1955
|
+
"dist/svelte",
|
|
1956
|
+
"dist/react",
|
|
1957
|
+
"dist/next",
|
|
1958
|
+
"dist/byo",
|
|
1959
|
+
"dist/elevenlabs",
|
|
1960
|
+
"dist/openai",
|
|
1961
|
+
"dist/deepgram",
|
|
1962
|
+
"dist/google",
|
|
1963
|
+
"dist/livekit",
|
|
1964
|
+
"dist/sdk",
|
|
1965
|
+
"README.md",
|
|
1966
|
+
"CHANGELOG.md",
|
|
1967
|
+
"LICENSE"
|
|
1968
|
+
],
|
|
1969
|
+
peerDependencies: {
|
|
1970
|
+
"@elevenlabs/client": ">=1.0.0",
|
|
1971
|
+
"livekit-client": ">=2.0.0",
|
|
1972
|
+
react: "^18.0.0 || ^19.0.0",
|
|
1973
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
1974
|
+
svelte: "^5.0.0"
|
|
1975
|
+
},
|
|
1976
|
+
peerDependenciesMeta: {
|
|
1977
|
+
svelte: { optional: !0 },
|
|
1978
|
+
react: { optional: !0 },
|
|
1979
|
+
"react-dom": { optional: !0 },
|
|
1980
|
+
"@elevenlabs/client": { optional: !0 },
|
|
1981
|
+
"livekit-client": { optional: !0 }
|
|
1982
|
+
},
|
|
1983
|
+
scripts: {
|
|
1984
|
+
build: "npm run build:v2 && npm run build:npm && npm run build:svelte && npm run build:react && npm run build:next && npm run build:byo && npm run build:elevenlabs && npm run build:openai && npm run build:deepgram && npm run build:google && npm run build:livekit && npm run copy:preview",
|
|
1985
|
+
"build:react": "vite build --config vite.config.react.ts && vite build --config vite.config.react-thumbnail.ts && tsc -p tsconfig.react.json",
|
|
1986
|
+
"build:next": "vite build --config vite.config.next.ts && vite build --config vite.config.next-thumbnail.ts && tsc -p tsconfig.next.json",
|
|
1987
|
+
"build:byo": "vite build --config vite.config.byo.ts && tsc -p tsconfig.byo.json",
|
|
1988
|
+
"build:elevenlabs": "vite build --config vite.config.elevenlabs.ts && tsc -p tsconfig.elevenlabs.json",
|
|
1989
|
+
"build:openai": "vite build --config vite.config.openai.ts && tsc -p tsconfig.openai.json",
|
|
1990
|
+
"build:deepgram": "vite build --config vite.config.deepgram.ts && tsc -p tsconfig.deepgram.json",
|
|
1991
|
+
"build:google": "vite build --config vite.config.google.ts && tsc -p tsconfig.google.json",
|
|
1992
|
+
"build:livekit": "vite build --config vite.config.livekit.ts && tsc -p tsconfig.livekit.json",
|
|
1993
|
+
"copy:preview": "mkdir -p dist/preview && cp preview/v2-embed-test.html dist/preview/ && cp preview/v2-embed-test-redirect.html dist/preview/",
|
|
1994
|
+
"build:v2": "vite build --config vite.config.v2.ts && vite build --config vite.config.v2-thumbnail.ts",
|
|
1995
|
+
"build:npm": "vite build --config vite.config.npm.ts && vite build --config vite.config.thumbnail.ts && tsc -p tsconfig.npm.json",
|
|
1996
|
+
"build:svelte": "svelte-package -i src/svelte -o dist/svelte && vite build --config vite.config.svelte.ts",
|
|
1997
|
+
"check:consumer": "svelte-check --workspace test/consumer --tsconfig ./tsconfig.json",
|
|
1998
|
+
test: "vitest run",
|
|
1999
|
+
preview: "node scripts/preview-local.mjs",
|
|
2000
|
+
"dev:sdk": "npm run build:v2 && npm run copy:preview && npm run preview",
|
|
2001
|
+
dev: "npm run build && npm run preview",
|
|
2002
|
+
"publish:sdk": "node scripts/publish-sdk.mjs",
|
|
2003
|
+
"publish:npm": "node scripts/publish-npm.mjs",
|
|
2004
|
+
"publish:avatar": "node scripts/publish-avatar.mjs",
|
|
2005
|
+
"publish:avatars-dist": "node scripts/publish-avatars.mjs",
|
|
2006
|
+
"publish:avatars": "node scripts/republish-avatars.mjs",
|
|
2007
|
+
"build:avatars": "node scripts/build-avatars.mjs",
|
|
2008
|
+
"republish:avatars": "node scripts/republish-avatars.mjs",
|
|
2009
|
+
"catalogue:avatars": "node ../labs.liforma.ai/scripts/generate-avatar-index.mjs",
|
|
2010
|
+
"verify:avatars-dist": "node scripts/verify-avatars-dist.mjs",
|
|
2011
|
+
"verify:avatar-pack": "node scripts/verify-avatar-pack.mjs",
|
|
2012
|
+
"repair:render-plate-metadata": "node scripts/repair-render-plate-metadata.mjs",
|
|
2013
|
+
"verify:render-plate-crop": "node scripts/verify-render-plate-crop.mjs",
|
|
2014
|
+
"migrate:avatar-render-prep": "npm run migrate:avatar-render-prep --prefix ../labs.liforma.ai --",
|
|
2015
|
+
"convert:avatar-teeth": "node scripts/convert-avatar-teeth-webp.mjs",
|
|
2016
|
+
"warm:avatar-composites": "node scripts/warm-avatar-composites.mjs",
|
|
2017
|
+
"test:compose-costume": "node scripts/test-compose-costume-layers.mjs",
|
|
2018
|
+
"test:compose-costume-wasm": "node scripts/test-compose-costume-wasm.mjs",
|
|
2019
|
+
"test:parse-composite-filename": "node scripts/test-parse-composite-filename.mjs",
|
|
2020
|
+
"test:avatar-composite-rendered-path": "node scripts/test-avatar-composite-rendered-path.mjs",
|
|
2021
|
+
"test:avatar-compose-worker-cors": "node scripts/test-avatar-compose-worker-cors.mjs",
|
|
2022
|
+
"test:experience-thumb-url": "node scripts/test-experience-thumb-url.mjs",
|
|
2023
|
+
"test:compose-experience-thumb": "node scripts/test-compose-experience-thumb.mjs",
|
|
2024
|
+
"test:location-depth-paths": "node scripts/test-location-depth-paths.mjs",
|
|
2025
|
+
"test:location-binary-assets": "node scripts/test-location-binary-assets.mjs",
|
|
2026
|
+
"test:location-da3-depth": "node scripts/test-location-da3-depth.mjs",
|
|
2027
|
+
"test:location-interactions": "node scripts/test-location-interactions.mjs",
|
|
2028
|
+
"test:render-plate-chroma-key": "node scripts/test-render-plate-chroma-key.mjs",
|
|
2029
|
+
"test:sparse-plate": "node scripts/test-sparse-plate.mjs",
|
|
2030
|
+
"test:face-meshes-publish-depth": "node scripts/test-face-meshes-publish-depth.mjs",
|
|
2031
|
+
"test:avatar-avif-sibling": "node scripts/test-avatar-avif-sibling.mjs",
|
|
2032
|
+
"test:screen-chroma-key": "node scripts/test-screen-chroma-key.mjs",
|
|
2033
|
+
"pull:sources": "node scripts/sync-authoring-sources.mjs",
|
|
2034
|
+
"push:sources": "node scripts/sync-authoring-sources.mjs",
|
|
2035
|
+
"catalogue:locations": "node scripts/catalogue-locations.mjs",
|
|
2036
|
+
"generate:location-interactions": "node scripts/generate-location-interactions.mjs",
|
|
2037
|
+
"generate:location-depth": "node scripts/generate-location-depth.mjs",
|
|
2038
|
+
"generate:location-depth16-da3": "node scripts/generate-location-depth16-da3.mjs",
|
|
2039
|
+
"generate:location-discontinuities": "node scripts/generate-location-discontinuities.mjs",
|
|
2040
|
+
"build:locations": "node scripts/build-locations.mjs",
|
|
2041
|
+
"publish:locations": "node scripts/publish-locations.mjs",
|
|
2042
|
+
"verify:locations": "node scripts/verify-location-sources.mjs",
|
|
2043
|
+
"publish:models": "node scripts/publish-models.mjs",
|
|
2044
|
+
"publish:models:krea-int8": "node scripts/_upload-model-prefix.mjs text-to-image/lf-t2i-turbo-int8",
|
|
2045
|
+
"publish:models:ltx-int8": "node scripts/_upload-model-prefix.mjs text-to-video/lf-t2v-distill-int8",
|
|
2046
|
+
"publish:models:video-omni": "node scripts/_upload-model-prefix.mjs text-to-video/lf-video-omni-v1",
|
|
2047
|
+
"fetch:depth-anything-v2": "node scripts/fetch-depth-anything-v2.mjs",
|
|
2048
|
+
"fetch:video-depth-anything": "node scripts/fetch-video-depth-anything.mjs",
|
|
2049
|
+
"fetch:depth-pro": "node scripts/fetch-depth-pro.mjs",
|
|
2050
|
+
"fetch:face-landmarker": "node scripts/fetch-face-landmarker.mjs",
|
|
2051
|
+
"fetch:anime-face-detector": "node scripts/fetch-anime-face-detector.mjs",
|
|
2052
|
+
"fetch:face-parsing": "node scripts/fetch-face-parsing.mjs",
|
|
2053
|
+
"fetch:vitmatte": "node scripts/fetch-vitmatte.mjs",
|
|
2054
|
+
"fetch:liveportrait-mlx": "node scripts/fetch-liveportrait-mlx.mjs",
|
|
2055
|
+
"fetch:wav2vec-phoneme-ctc": "node scripts/fetch-wav2vec-phoneme-ctc.mjs",
|
|
2056
|
+
"fetch:lf-sta": "node scripts/fetch-wav2vec-phoneme-ctc.mjs",
|
|
2057
|
+
"fetch:supertonic-3": "node scripts/fetch-supertonic-3.mjs",
|
|
2058
|
+
"fetch:lf-tts": "node scripts/fetch-supertonic-3.mjs",
|
|
2059
|
+
"fetch:lf-t2i-turbo": "python3 ../tools/krea-2-salad/scripts/fetch_cdn_snapshot.py",
|
|
2060
|
+
"fetch:models": "npm run fetch:depth-anything-v2 && npm run fetch:video-depth-anything && npm run fetch:depth-pro && npm run fetch:face-landmarker && npm run fetch:anime-face-detector && npm run fetch:face-parsing && npm run fetch:vitmatte && npm run fetch:lf-sta && npm run fetch:lf-tts",
|
|
2061
|
+
locations: "npm run catalogue:locations && npm run build:locations",
|
|
2062
|
+
"configure:cors": "node scripts/configure-r2-cors.mjs",
|
|
2063
|
+
"verify:cors": "node scripts/verify-cdn-cors.mjs",
|
|
2064
|
+
"deploy:worker:avatar-compose": "node scripts/deploy-avatar-compose-worker.mjs",
|
|
2065
|
+
"deploy:worker:experience-thumb": "node scripts/deploy-experience-thumb-worker.mjs",
|
|
2066
|
+
deploy: "npm run build && npm run publish:sdk",
|
|
2067
|
+
verify: "npm run build && node scripts/check-sdk-size.mjs && node scripts/verify-thumbnail-light.mjs && node scripts/test-embed-protocol.mjs && node scripts/test-manifest-embed-url.mjs && node scripts/test-player-reachability.mjs && node scripts/test-session-endpoint.mjs && node scripts/verify-package.mjs",
|
|
2068
|
+
"preview:test": "npm run build && npm run preview"
|
|
2069
|
+
},
|
|
2070
|
+
dependencies: {
|
|
2071
|
+
"@jsquash/webp": "^1.5.0",
|
|
2072
|
+
zod: "^4.4.3"
|
|
2073
|
+
},
|
|
2074
|
+
devDependencies: {
|
|
2075
|
+
"@aws-sdk/client-s3": "^3.1000.0",
|
|
2076
|
+
"@aws-sdk/lib-storage": "^3.1110.0",
|
|
2077
|
+
"@elevenlabs/client": "^1.17.0",
|
|
2078
|
+
"@sveltejs/package": "^2.5.8",
|
|
2079
|
+
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
2080
|
+
"@testing-library/react": "^16.3.0",
|
|
2081
|
+
"@testing-library/svelte": "^5.4.2",
|
|
2082
|
+
"@types/node": "^25.9.3",
|
|
2083
|
+
"@types/react": "^19.1.12",
|
|
2084
|
+
"@types/react-dom": "^19.1.9",
|
|
2085
|
+
"@vitejs/plugin-react": "^5.0.2",
|
|
2086
|
+
"@webgpu/types": "^0.1.70",
|
|
2087
|
+
dotenv: "^17.2.3",
|
|
2088
|
+
jsdom: "^30.0.1",
|
|
2089
|
+
"livekit-client": "^2.21.0",
|
|
2090
|
+
react: "^19.1.1",
|
|
2091
|
+
"react-dom": "^19.1.1",
|
|
2092
|
+
sharp: "^0.34.2",
|
|
2093
|
+
svelte: "^5.55.2",
|
|
2094
|
+
"svelte-check": "^4.7.4",
|
|
2095
|
+
typescript: "^6.0.3",
|
|
2096
|
+
vite: "^8.0.16",
|
|
2097
|
+
vitest: "^4.1.10",
|
|
2098
|
+
wrangler: "^4.101.0"
|
|
2099
|
+
}
|
|
2100
|
+
}.version}`, Lt = "https://player.liforma.ai/embed", Rt = "http://localhost:3002/embed";
|
|
2101
|
+
function zt() {
|
|
1826
2102
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1827
2103
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1828
2104
|
if (typeof document > "u") return null;
|
|
1829
2105
|
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();
|
|
1830
2106
|
return t ? t.replace(/\/$/, "") : null;
|
|
1831
2107
|
}
|
|
1832
|
-
function
|
|
1833
|
-
let e =
|
|
1834
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` :
|
|
2108
|
+
function Bt() {
|
|
2109
|
+
let e = zt();
|
|
2110
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : V() ? Rt : Lt;
|
|
1835
2111
|
}
|
|
1836
|
-
function
|
|
2112
|
+
function Vt(e, t) {
|
|
1837
2113
|
return e?.trim() || t?.trim() || void 0;
|
|
1838
2114
|
}
|
|
1839
|
-
function
|
|
1840
|
-
let c = (e ??
|
|
2115
|
+
function Ht(e, t, n, r, i, a, o, s) {
|
|
2116
|
+
let c = (e ?? Bt()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
|
|
1841
2117
|
d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
|
|
1842
2118
|
let f = r?.trim();
|
|
1843
|
-
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)),
|
|
2119
|
+
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)), Ut(u.toString());
|
|
1844
2120
|
}
|
|
1845
|
-
function
|
|
2121
|
+
function Ut(e) {
|
|
1846
2122
|
if (typeof location > "u") return e;
|
|
1847
2123
|
let t = new URL(e);
|
|
1848
2124
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1849
2125
|
}
|
|
1850
|
-
function
|
|
2126
|
+
function Wt(e) {
|
|
1851
2127
|
return new URL(e).origin;
|
|
1852
2128
|
}
|
|
1853
2129
|
//#endregion
|
|
1854
2130
|
//#region src/v2/experienceEvents.ts
|
|
1855
|
-
function
|
|
2131
|
+
function Gt() {
|
|
1856
2132
|
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)}`;
|
|
1857
2133
|
}
|
|
1858
|
-
function
|
|
2134
|
+
function Kt(e, t, n) {
|
|
1859
2135
|
return {
|
|
1860
|
-
id:
|
|
2136
|
+
id: Gt(),
|
|
1861
2137
|
type: e,
|
|
1862
2138
|
sessionId: t,
|
|
1863
2139
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1864
2140
|
data: n
|
|
1865
2141
|
};
|
|
1866
2142
|
}
|
|
1867
|
-
function
|
|
2143
|
+
function qt() {
|
|
1868
2144
|
return {
|
|
1869
2145
|
ready: /* @__PURE__ */ new Set(),
|
|
1870
2146
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1879,44 +2155,45 @@ function Wt() {
|
|
|
1879
2155
|
message: /* @__PURE__ */ new Set(),
|
|
1880
2156
|
listeningState: /* @__PURE__ */ new Set(),
|
|
1881
2157
|
activityChange: /* @__PURE__ */ new Set(),
|
|
2158
|
+
interactionChange: /* @__PURE__ */ new Set(),
|
|
1882
2159
|
feedback: /* @__PURE__ */ new Set(),
|
|
1883
2160
|
feedbackFailed: /* @__PURE__ */ new Set(),
|
|
1884
2161
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1885
2162
|
};
|
|
1886
2163
|
}
|
|
1887
|
-
function
|
|
2164
|
+
function Jt(e, t, n) {
|
|
1888
2165
|
return e[t].add(n), () => e[t].delete(n);
|
|
1889
2166
|
}
|
|
1890
|
-
function
|
|
2167
|
+
function Yt(e, t, n) {
|
|
1891
2168
|
for (let r of e[t]) r(n);
|
|
1892
2169
|
}
|
|
1893
|
-
function
|
|
2170
|
+
function Xt(e) {
|
|
1894
2171
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1895
2172
|
}
|
|
1896
2173
|
//#endregion
|
|
1897
2174
|
//#region src/v2/speech/types.ts
|
|
1898
|
-
function
|
|
2175
|
+
function Zt(e) {
|
|
1899
2176
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1900
2177
|
}
|
|
1901
|
-
function
|
|
2178
|
+
function Qt(e) {
|
|
1902
2179
|
return "url" in e && typeof e.url == "string";
|
|
1903
2180
|
}
|
|
1904
|
-
function
|
|
2181
|
+
function $t(e) {
|
|
1905
2182
|
if (!("track" in e)) return !1;
|
|
1906
2183
|
let t = e.track;
|
|
1907
2184
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1908
2185
|
}
|
|
1909
|
-
function
|
|
1910
|
-
return !
|
|
2186
|
+
function en(e) {
|
|
2187
|
+
return !Zt(e) && !Qt(e) && !$t(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1911
2188
|
}
|
|
1912
|
-
var
|
|
2189
|
+
var tn = [
|
|
1913
2190
|
8e3,
|
|
1914
2191
|
16e3,
|
|
1915
2192
|
22050,
|
|
1916
2193
|
24e3,
|
|
1917
2194
|
44100,
|
|
1918
2195
|
48e3
|
|
1919
|
-
],
|
|
2196
|
+
], nn = {
|
|
1920
2197
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1921
2198
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1922
2199
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1927,14 +2204,14 @@ var Qt = [
|
|
|
1927
2204
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1928
2205
|
MAX_PENDING_WRITES: 8,
|
|
1929
2206
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1930
|
-
},
|
|
2207
|
+
}, rn = class extends Error {
|
|
1931
2208
|
operation;
|
|
1932
2209
|
requiredCapability;
|
|
1933
2210
|
name = "UnsupportedSpeechOperationError";
|
|
1934
2211
|
constructor(e, t) {
|
|
1935
2212
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1936
2213
|
}
|
|
1937
|
-
},
|
|
2214
|
+
}, an = class extends Error {
|
|
1938
2215
|
name = "SpeechUtteranceClosedError";
|
|
1939
2216
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1940
2217
|
super(e);
|
|
@@ -1944,72 +2221,72 @@ var Qt = [
|
|
|
1944
2221
|
constructor(e, t) {
|
|
1945
2222
|
super(e, t);
|
|
1946
2223
|
}
|
|
1947
|
-
},
|
|
2224
|
+
}, on = class extends Error {
|
|
1948
2225
|
name = "SpeechBufferTimeoutError";
|
|
1949
2226
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1950
2227
|
super(e);
|
|
1951
2228
|
}
|
|
1952
2229
|
};
|
|
1953
|
-
function
|
|
2230
|
+
function sn(e = "none") {
|
|
1954
2231
|
return {
|
|
1955
2232
|
mode: e,
|
|
1956
2233
|
trackedDurationMs: 0,
|
|
1957
2234
|
fallbackDurationMs: 0
|
|
1958
2235
|
};
|
|
1959
2236
|
}
|
|
1960
|
-
function
|
|
1961
|
-
return
|
|
2237
|
+
function cn(e) {
|
|
2238
|
+
return tn.includes(e);
|
|
1962
2239
|
}
|
|
1963
|
-
function
|
|
2240
|
+
function ln(e) {
|
|
1964
2241
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
1965
2242
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
1966
|
-
if (!
|
|
2243
|
+
if (!cn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1967
2244
|
}
|
|
1968
|
-
function
|
|
1969
|
-
if (
|
|
1970
|
-
|
|
2245
|
+
function un(e) {
|
|
2246
|
+
if (Zt(e)) {
|
|
2247
|
+
ln(e.format);
|
|
1971
2248
|
return;
|
|
1972
2249
|
}
|
|
1973
|
-
if (
|
|
2250
|
+
if (Qt(e)) {
|
|
1974
2251
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
1975
|
-
if (e.sampleRate !== void 0 && !
|
|
2252
|
+
if (e.sampleRate !== void 0 && !cn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1976
2253
|
return;
|
|
1977
2254
|
}
|
|
1978
|
-
if (
|
|
2255
|
+
if ($t(e)) {
|
|
1979
2256
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
1980
|
-
if (e.sampleRate !== void 0 && !
|
|
2257
|
+
if (e.sampleRate !== void 0 && !cn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1981
2258
|
return;
|
|
1982
2259
|
}
|
|
1983
|
-
if (
|
|
2260
|
+
if (en(e)) {
|
|
1984
2261
|
let t = e.encoding.trim().toLowerCase();
|
|
1985
2262
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
1986
2263
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1987
|
-
if (e.sampleRate !== void 0 && !
|
|
2264
|
+
if (e.sampleRate !== void 0 && !cn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1988
2265
|
return;
|
|
1989
2266
|
}
|
|
1990
2267
|
throw new Q("Unsupported speech.play audio shape.");
|
|
1991
2268
|
}
|
|
1992
|
-
function
|
|
1993
|
-
if (e.format) return
|
|
2269
|
+
function dn(e) {
|
|
2270
|
+
if (e.format) return ln(e.format), e.format;
|
|
1994
2271
|
if (e.track) {
|
|
1995
2272
|
let t = {
|
|
1996
2273
|
encoding: "pcm_s16le",
|
|
1997
2274
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1998
2275
|
channels: 1
|
|
1999
2276
|
};
|
|
2000
|
-
return
|
|
2277
|
+
return ln(t), t;
|
|
2001
2278
|
}
|
|
2002
2279
|
throw new Q("createUtterance requires format or track.");
|
|
2003
2280
|
}
|
|
2004
|
-
function
|
|
2281
|
+
function fn(e) {
|
|
2005
2282
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
2006
2283
|
}
|
|
2007
|
-
function
|
|
2284
|
+
function pn(e) {
|
|
2008
2285
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
2009
2286
|
}
|
|
2010
2287
|
//#endregion
|
|
2011
2288
|
//#region src/byo/pcm.ts
|
|
2012
|
-
function
|
|
2289
|
+
function mn(e) {
|
|
2013
2290
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
2014
2291
|
for (let t = 0; t < e.length; t++) {
|
|
2015
2292
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -2019,11 +2296,11 @@ function dn(e) {
|
|
|
2019
2296
|
}
|
|
2020
2297
|
//#endregion
|
|
2021
2298
|
//#region src/byo/resample.ts
|
|
2022
|
-
function
|
|
2299
|
+
function hn(e, t, n, r, i) {
|
|
2023
2300
|
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;
|
|
2024
2301
|
return ((a * i + o) * i + s) * i + c;
|
|
2025
2302
|
}
|
|
2026
|
-
function
|
|
2303
|
+
function gn(e, t) {
|
|
2027
2304
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
2028
2305
|
if (e === t) return {
|
|
2029
2306
|
fromRate: e,
|
|
@@ -2046,7 +2323,7 @@ function pn(e, t) {
|
|
|
2046
2323
|
let a = [];
|
|
2047
2324
|
for (; i + 2 < r.length - 1;) {
|
|
2048
2325
|
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);
|
|
2049
|
-
a.push(
|
|
2326
|
+
a.push(hn(r[o], r[e], r[s], r[c], t)), i += n;
|
|
2050
2327
|
}
|
|
2051
2328
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
2052
2329
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -2058,7 +2335,7 @@ function pn(e, t) {
|
|
|
2058
2335
|
}
|
|
2059
2336
|
//#endregion
|
|
2060
2337
|
//#region src/byo/audioCapture.ts
|
|
2061
|
-
var
|
|
2338
|
+
var _n = "liforma-pcm-capture", vn = `
|
|
2062
2339
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
2063
2340
|
process(inputs) {
|
|
2064
2341
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -2070,29 +2347,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
2070
2347
|
return true;
|
|
2071
2348
|
}
|
|
2072
2349
|
}
|
|
2073
|
-
registerProcessor('${
|
|
2074
|
-
`,
|
|
2075
|
-
function
|
|
2076
|
-
return
|
|
2350
|
+
registerProcessor('${_n}', LiformaPcmCaptureProcessor);
|
|
2351
|
+
`, yn = null;
|
|
2352
|
+
function bn() {
|
|
2353
|
+
return yn ||= URL.createObjectURL(new Blob([vn], { type: "application/javascript" })), yn;
|
|
2077
2354
|
}
|
|
2078
|
-
function
|
|
2355
|
+
function xn() {
|
|
2079
2356
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
2080
2357
|
}
|
|
2081
|
-
async function
|
|
2082
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
2358
|
+
async function Sn(e) {
|
|
2359
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = xn();
|
|
2083
2360
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
2084
2361
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
2085
2362
|
l.gain.value = 0;
|
|
2086
|
-
let u = s.sampleRate, d =
|
|
2363
|
+
let u = s.sampleRate, d = gn(u, n), f = !1, p = !1, m = (e) => {
|
|
2087
2364
|
if (f || i && !i()) return;
|
|
2088
2365
|
let t = d.push(e);
|
|
2089
|
-
t.length !== 0 && r(
|
|
2366
|
+
t.length !== 0 && r(mn(t));
|
|
2090
2367
|
}, h = () => void 0;
|
|
2091
2368
|
return await (async () => {
|
|
2092
2369
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
2093
2370
|
try {
|
|
2094
|
-
await s.audioWorklet.addModule(
|
|
2095
|
-
let e = new AudioWorkletNode(s,
|
|
2371
|
+
await s.audioWorklet.addModule(bn());
|
|
2372
|
+
let e = new AudioWorkletNode(s, _n, {
|
|
2096
2373
|
numberOfInputs: 1,
|
|
2097
2374
|
numberOfOutputs: 1,
|
|
2098
2375
|
outputChannelCount: [1]
|
|
@@ -2142,7 +2419,7 @@ async function yn(e) {
|
|
|
2142
2419
|
}
|
|
2143
2420
|
//#endregion
|
|
2144
2421
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
2145
|
-
async function
|
|
2422
|
+
async function Cn(e) {
|
|
2146
2423
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
2147
2424
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
2148
2425
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -2151,18 +2428,18 @@ async function bn(e) {
|
|
|
2151
2428
|
s || (s = !0, c?.stop(), c = null);
|
|
2152
2429
|
};
|
|
2153
2430
|
try {
|
|
2154
|
-
c = await
|
|
2431
|
+
c = await Sn({
|
|
2155
2432
|
mediaStream: a,
|
|
2156
2433
|
targetSampleRate: r,
|
|
2157
2434
|
shouldSend: () => !s && !i?.aborted,
|
|
2158
2435
|
onPcm: (e) => {
|
|
2159
2436
|
if (s || i?.aborted) return;
|
|
2160
|
-
let t =
|
|
2437
|
+
let t = fn(e);
|
|
2161
2438
|
o = o.then(async () => {
|
|
2162
2439
|
if (s || i?.aborted) return;
|
|
2163
2440
|
let e = 0;
|
|
2164
2441
|
for (; e < t.byteLength;) {
|
|
2165
|
-
let r = Math.min(e +
|
|
2442
|
+
let r = Math.min(e + nn.MAX_CHUNK_BYTES, t.byteLength);
|
|
2166
2443
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
2167
2444
|
let i = t.subarray(e, r);
|
|
2168
2445
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -2186,10 +2463,10 @@ async function bn(e) {
|
|
|
2186
2463
|
}
|
|
2187
2464
|
//#endregion
|
|
2188
2465
|
//#region src/v2/speech/speechController.ts
|
|
2189
|
-
async function
|
|
2190
|
-
if (
|
|
2191
|
-
if (
|
|
2192
|
-
let t =
|
|
2466
|
+
async function wn(e, t) {
|
|
2467
|
+
if ($t(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
2468
|
+
if (Zt(e)) {
|
|
2469
|
+
let t = fn(e.data);
|
|
2193
2470
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
2194
2471
|
return {
|
|
2195
2472
|
kind: "pcm",
|
|
@@ -2197,17 +2474,17 @@ async function xn(e, t) {
|
|
|
2197
2474
|
format: e.format
|
|
2198
2475
|
};
|
|
2199
2476
|
}
|
|
2200
|
-
if (
|
|
2477
|
+
if (Qt(e)) return {
|
|
2201
2478
|
kind: "url",
|
|
2202
2479
|
url: e.url.trim(),
|
|
2203
2480
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2204
2481
|
};
|
|
2205
|
-
if (!
|
|
2482
|
+
if (!en(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
2206
2483
|
let n;
|
|
2207
2484
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
2208
2485
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2209
2486
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
2210
|
-
} else n =
|
|
2487
|
+
} else n = fn(e.data);
|
|
2211
2488
|
return {
|
|
2212
2489
|
kind: "encoded",
|
|
2213
2490
|
data: n.slice().buffer,
|
|
@@ -2215,10 +2492,10 @@ async function xn(e, t) {
|
|
|
2215
2492
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2216
2493
|
};
|
|
2217
2494
|
}
|
|
2218
|
-
function
|
|
2495
|
+
function Tn() {
|
|
2219
2496
|
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)}`;
|
|
2220
2497
|
}
|
|
2221
|
-
function
|
|
2498
|
+
function En(e, t = "completed") {
|
|
2222
2499
|
return {
|
|
2223
2500
|
utteranceId: e.speechId,
|
|
2224
2501
|
characterId: e.characterId,
|
|
@@ -2232,13 +2509,13 @@ function Cn(e, t = "completed") {
|
|
|
2232
2509
|
}
|
|
2233
2510
|
};
|
|
2234
2511
|
}
|
|
2235
|
-
function
|
|
2512
|
+
function Dn(e) {
|
|
2236
2513
|
return e instanceof Error ? e : new Q(String(e));
|
|
2237
2514
|
}
|
|
2238
|
-
function
|
|
2515
|
+
function On(e) {
|
|
2239
2516
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
2240
2517
|
}
|
|
2241
|
-
var
|
|
2518
|
+
var kn = class {
|
|
2242
2519
|
id;
|
|
2243
2520
|
characterId;
|
|
2244
2521
|
result;
|
|
@@ -2267,29 +2544,29 @@ var En = class {
|
|
|
2267
2544
|
queue: e.queue,
|
|
2268
2545
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
2269
2546
|
}).catch((e) => {
|
|
2270
|
-
throw this.fail(
|
|
2547
|
+
throw this.fail(Dn(e)), Dn(e);
|
|
2271
2548
|
}), this.signal?.addEventListener("abort", () => {
|
|
2272
2549
|
this.cancel();
|
|
2273
2550
|
}, { once: !0 });
|
|
2274
2551
|
}
|
|
2275
2552
|
async write(e, t) {
|
|
2276
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2277
|
-
let n =
|
|
2553
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new an();
|
|
2554
|
+
let n = fn(e);
|
|
2278
2555
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
2279
|
-
if (n.byteLength >
|
|
2556
|
+
if (n.byteLength > nn.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${nn.MAX_CHUNK_BYTES}).`);
|
|
2280
2557
|
if (n.byteLength === 0) return;
|
|
2281
|
-
let r = t?.timeoutMs ??
|
|
2558
|
+
let r = t?.timeoutMs ?? nn.DEFAULT_WRITE_TIMEOUT_MS;
|
|
2282
2559
|
await this.acquireWriteSlot(r);
|
|
2283
2560
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
2284
|
-
if (this.bufferedMs + i >
|
|
2561
|
+
if (this.bufferedMs + i > nn.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
2285
2562
|
let a = async () => {
|
|
2286
|
-
if (this.closed || this.settled) throw new
|
|
2563
|
+
if (this.closed || this.settled) throw new an();
|
|
2287
2564
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
2288
2565
|
utteranceId: this.id,
|
|
2289
2566
|
audio: t.buffer,
|
|
2290
2567
|
byteLength: t.byteLength
|
|
2291
2568
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
2292
|
-
setTimeout(() => t(new
|
|
2569
|
+
setTimeout(() => t(new on()), r);
|
|
2293
2570
|
})]);
|
|
2294
2571
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
2295
2572
|
}, o = this.writeChain.then(a, a);
|
|
@@ -2301,7 +2578,7 @@ var En = class {
|
|
|
2301
2578
|
}
|
|
2302
2579
|
}
|
|
2303
2580
|
async setTranscript(e) {
|
|
2304
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2581
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new an();
|
|
2305
2582
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
2306
2583
|
utteranceId: this.id,
|
|
2307
2584
|
transcript: e
|
|
@@ -2318,7 +2595,7 @@ var En = class {
|
|
|
2318
2595
|
});
|
|
2319
2596
|
return this.resolve(t), t;
|
|
2320
2597
|
} catch (e) {
|
|
2321
|
-
let t =
|
|
2598
|
+
let t = Dn(e);
|
|
2322
2599
|
throw this.fail(t), t;
|
|
2323
2600
|
}
|
|
2324
2601
|
}
|
|
@@ -2336,11 +2613,11 @@ var En = class {
|
|
|
2336
2613
|
characterId: this.characterId,
|
|
2337
2614
|
status: "cancelled",
|
|
2338
2615
|
durationMs: 0,
|
|
2339
|
-
animation:
|
|
2616
|
+
animation: sn("none")
|
|
2340
2617
|
};
|
|
2341
2618
|
return this.resolve(t), t;
|
|
2342
2619
|
} catch (e) {
|
|
2343
|
-
let t =
|
|
2620
|
+
let t = Dn(e);
|
|
2344
2621
|
throw this.fail(t), t;
|
|
2345
2622
|
}
|
|
2346
2623
|
}
|
|
@@ -2353,19 +2630,19 @@ var En = class {
|
|
|
2353
2630
|
return e;
|
|
2354
2631
|
}
|
|
2355
2632
|
resolve(e) {
|
|
2356
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2633
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new an()));
|
|
2357
2634
|
}
|
|
2358
2635
|
fail(e) {
|
|
2359
2636
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
2360
2637
|
}
|
|
2361
2638
|
async acquireWriteSlot(e) {
|
|
2362
|
-
if (this.pendingWriteCount <
|
|
2639
|
+
if (this.pendingWriteCount < nn.MAX_PENDING_WRITES) {
|
|
2363
2640
|
this.pendingWriteCount += 1;
|
|
2364
2641
|
return;
|
|
2365
2642
|
}
|
|
2366
2643
|
await new Promise((t, n) => {
|
|
2367
2644
|
let r = setTimeout(() => {
|
|
2368
|
-
n(new
|
|
2645
|
+
n(new on());
|
|
2369
2646
|
}, e);
|
|
2370
2647
|
this.pendingWriteWaiters.push({
|
|
2371
2648
|
resolve: () => {
|
|
@@ -2384,13 +2661,13 @@ var En = class {
|
|
|
2384
2661
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2385
2662
|
}
|
|
2386
2663
|
};
|
|
2387
|
-
function
|
|
2664
|
+
function An(e) {
|
|
2388
2665
|
let t = null, n = (t, n) => {
|
|
2389
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2666
|
+
if (!e.getCapabilities()[n]) throw new rn(t, n);
|
|
2390
2667
|
}, r = {
|
|
2391
2668
|
async speak(r) {
|
|
2392
2669
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2393
|
-
let i =
|
|
2670
|
+
let i = pn(r.queue ?? "append");
|
|
2394
2671
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2395
2672
|
let a = e.getIframeHost();
|
|
2396
2673
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -2410,41 +2687,41 @@ function Dn(e) {
|
|
|
2410
2687
|
return;
|
|
2411
2688
|
}
|
|
2412
2689
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2413
|
-
t.removeEventListener("abort", s), n(
|
|
2690
|
+
t.removeEventListener("abort", s), n(En(e, "completed"));
|
|
2414
2691
|
}, (a) => {
|
|
2415
|
-
if (t.removeEventListener("abort", s),
|
|
2692
|
+
if (t.removeEventListener("abort", s), On(a)) {
|
|
2416
2693
|
n({
|
|
2417
2694
|
utteranceId: "utt_interrupted",
|
|
2418
2695
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2419
2696
|
status: "interrupted",
|
|
2420
2697
|
durationMs: 0,
|
|
2421
2698
|
transcript: r.text,
|
|
2422
|
-
animation:
|
|
2699
|
+
animation: sn("none")
|
|
2423
2700
|
});
|
|
2424
2701
|
return;
|
|
2425
2702
|
}
|
|
2426
|
-
i(
|
|
2703
|
+
i(Dn(a));
|
|
2427
2704
|
});
|
|
2428
2705
|
});
|
|
2429
2706
|
}
|
|
2430
2707
|
try {
|
|
2431
|
-
return
|
|
2708
|
+
return En(await o, "completed");
|
|
2432
2709
|
} catch (t) {
|
|
2433
|
-
if (
|
|
2710
|
+
if (On(t)) return {
|
|
2434
2711
|
utteranceId: "utt_interrupted",
|
|
2435
2712
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2436
2713
|
status: "interrupted",
|
|
2437
2714
|
durationMs: 0,
|
|
2438
2715
|
transcript: r.text,
|
|
2439
|
-
animation:
|
|
2716
|
+
animation: sn("none")
|
|
2440
2717
|
};
|
|
2441
|
-
throw
|
|
2718
|
+
throw Dn(t);
|
|
2442
2719
|
}
|
|
2443
2720
|
},
|
|
2444
2721
|
async play(i) {
|
|
2445
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2722
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), un(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2446
2723
|
let a = i.queue ?? "append";
|
|
2447
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2724
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), $t(i.audio)) {
|
|
2448
2725
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2449
2726
|
return r.createUtterance({
|
|
2450
2727
|
format: {
|
|
@@ -2460,7 +2737,7 @@ function Dn(e) {
|
|
|
2460
2737
|
}
|
|
2461
2738
|
let o = e.getIframeHost();
|
|
2462
2739
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2463
|
-
let s = await
|
|
2740
|
+
let s = await wn(i.audio, i.signal);
|
|
2464
2741
|
return o.speechPlay({
|
|
2465
2742
|
source: s,
|
|
2466
2743
|
characterId: i.characterId,
|
|
@@ -2472,13 +2749,13 @@ function Dn(e) {
|
|
|
2472
2749
|
},
|
|
2473
2750
|
createUtterance(r) {
|
|
2474
2751
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2475
|
-
let i =
|
|
2752
|
+
let i = dn(r);
|
|
2476
2753
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2477
2754
|
let a = r.queue ?? "replace-active";
|
|
2478
2755
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2479
2756
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2480
|
-
let o = new
|
|
2481
|
-
id:
|
|
2757
|
+
let o = new kn({
|
|
2758
|
+
id: Tn(),
|
|
2482
2759
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2483
2760
|
format: i,
|
|
2484
2761
|
queue: a,
|
|
@@ -2490,7 +2767,7 @@ function Dn(e) {
|
|
|
2490
2767
|
t === o && (t = null);
|
|
2491
2768
|
}), r.track && (async () => {
|
|
2492
2769
|
try {
|
|
2493
|
-
if (await
|
|
2770
|
+
if (await Cn({
|
|
2494
2771
|
track: r.track,
|
|
2495
2772
|
utterance: o,
|
|
2496
2773
|
sampleRate: i.sampleRate,
|
|
@@ -2518,16 +2795,16 @@ function Dn(e) {
|
|
|
2518
2795
|
}
|
|
2519
2796
|
//#endregion
|
|
2520
2797
|
//#region src/v2/types/sessionInteraction.ts
|
|
2521
|
-
function
|
|
2798
|
+
function jn(e) {
|
|
2522
2799
|
let t = e?.trim();
|
|
2523
2800
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2524
2801
|
}
|
|
2525
2802
|
//#endregion
|
|
2526
2803
|
//#region src/v2/experience.ts
|
|
2527
|
-
function
|
|
2804
|
+
function Mn(e) {
|
|
2528
2805
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2529
2806
|
}
|
|
2530
|
-
var
|
|
2807
|
+
var Nn = class e {
|
|
2531
2808
|
bootstrap;
|
|
2532
2809
|
conversationProcessor;
|
|
2533
2810
|
iframeHost = null;
|
|
@@ -2541,18 +2818,19 @@ var An = class e {
|
|
|
2541
2818
|
closed = !1;
|
|
2542
2819
|
attached = !1;
|
|
2543
2820
|
pendingFit = null;
|
|
2821
|
+
lastInteraction = null;
|
|
2544
2822
|
closeHandlers = [];
|
|
2545
|
-
eventRegistry =
|
|
2823
|
+
eventRegistry = qt();
|
|
2546
2824
|
readyEnvelope = null;
|
|
2547
2825
|
startedEnvelope = null;
|
|
2548
2826
|
sessionMintedEnvelope = null;
|
|
2549
2827
|
conversationCache = [];
|
|
2550
2828
|
speech;
|
|
2551
2829
|
constructor(e) {
|
|
2552
|
-
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 =
|
|
2830
|
+
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 = An({
|
|
2553
2831
|
getIframeHost: () => this.iframeHost,
|
|
2554
2832
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2555
|
-
getCapabilities: () =>
|
|
2833
|
+
getCapabilities: () => Pn(this.resolvedSession),
|
|
2556
2834
|
getActiveCharacterId: () => "character_unknown",
|
|
2557
2835
|
onProcessorInterrupt: () => {
|
|
2558
2836
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2597,6 +2875,7 @@ var An = class e {
|
|
|
2597
2875
|
speechInputMode: t.speechInputMode,
|
|
2598
2876
|
speechOnly: t.speechOnly,
|
|
2599
2877
|
attribution: t.attribution,
|
|
2878
|
+
alreadyConverted: t.alreadyConverted,
|
|
2600
2879
|
ui: t.ui,
|
|
2601
2880
|
onStart: t.onStart,
|
|
2602
2881
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2619,6 +2898,7 @@ var An = class e {
|
|
|
2619
2898
|
speechInputMode: t.speechInputMode,
|
|
2620
2899
|
speechOnly: t.speechOnly,
|
|
2621
2900
|
attribution: t.attribution,
|
|
2901
|
+
alreadyConverted: t.alreadyConverted,
|
|
2622
2902
|
ui: t.ui,
|
|
2623
2903
|
onStart: t.onStart,
|
|
2624
2904
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2633,7 +2913,7 @@ var An = class e {
|
|
|
2633
2913
|
return null;
|
|
2634
2914
|
}
|
|
2635
2915
|
on(e, t) {
|
|
2636
|
-
let n =
|
|
2916
|
+
let n = Jt(this.eventRegistry, e, t);
|
|
2637
2917
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), e === "sessionMinted" && this.sessionMintedEnvelope && queueMicrotask(() => t(this.sessionMintedEnvelope)), n;
|
|
2638
2918
|
}
|
|
2639
2919
|
async attach(e) {
|
|
@@ -2647,13 +2927,13 @@ var An = class e {
|
|
|
2647
2927
|
if (this.closed) throw Error("Session has ended.");
|
|
2648
2928
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2649
2929
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2650
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2930
|
+
let t = this.bootstrap.embedBaseUrl ?? Bt(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = Ht(t, n, r ? void 0 : Vt(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, Mn(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = Wt(i), o = null, s = new Promise((e) => {
|
|
2651
2931
|
o = e;
|
|
2652
2932
|
}), c = null, l = new Promise((e) => {
|
|
2653
2933
|
c = e;
|
|
2654
|
-
}), u =
|
|
2934
|
+
}), u = Ft((e) => {
|
|
2655
2935
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
2656
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2936
|
+
}), d = this.bootstrap.onUserTranscript, f = Pt({
|
|
2657
2937
|
container: e.container,
|
|
2658
2938
|
src: i,
|
|
2659
2939
|
playerOrigin: a,
|
|
@@ -2692,6 +2972,9 @@ var An = class e {
|
|
|
2692
2972
|
onActivityChange: (e) => {
|
|
2693
2973
|
this.emitWrapped("activityChange", e);
|
|
2694
2974
|
},
|
|
2975
|
+
onInteractionChange: (e) => {
|
|
2976
|
+
this.lastInteraction = e, this.emitWrapped("interactionChange", e);
|
|
2977
|
+
},
|
|
2695
2978
|
onFeedback: (e) => {
|
|
2696
2979
|
this.emitWrapped("feedback", e);
|
|
2697
2980
|
},
|
|
@@ -2716,7 +2999,7 @@ var An = class e {
|
|
|
2716
2999
|
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
2717
3000
|
});
|
|
2718
3001
|
this.iframeHost = f;
|
|
2719
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
3002
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), ft(this.bootstrap.sessionEndpoint, {
|
|
2720
3003
|
experienceId: this.bootstrap.experienceId,
|
|
2721
3004
|
locale: this.bootstrap.locale,
|
|
2722
3005
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -2726,8 +3009,9 @@ var An = class e {
|
|
|
2726
3009
|
speechInputMode: p.speechInputMode,
|
|
2727
3010
|
speechOnly: this.bootstrap.speechOnly,
|
|
2728
3011
|
attribution: this.bootstrap.attribution,
|
|
3012
|
+
alreadyConverted: this.bootstrap.alreadyConverted,
|
|
2729
3013
|
signal: this.endpointAbortController.signal
|
|
2730
|
-
})) : this.bootstrap.kind === "public" ?
|
|
3014
|
+
})) : this.bootstrap.kind === "public" ? dt(this.bootstrap.experienceId, {
|
|
2731
3015
|
locale: this.bootstrap.locale,
|
|
2732
3016
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
2733
3017
|
learningLocale: this.bootstrap.learningLocale,
|
|
@@ -2735,7 +3019,8 @@ var An = class e {
|
|
|
2735
3019
|
mode: p.mode,
|
|
2736
3020
|
speechInputMode: p.speechInputMode,
|
|
2737
3021
|
speechOnly: this.bootstrap.speechOnly,
|
|
2738
|
-
attribution: this.bootstrap.attribution
|
|
3022
|
+
attribution: this.bootstrap.attribution,
|
|
3023
|
+
alreadyConverted: this.bootstrap.alreadyConverted
|
|
2739
3024
|
}) : Promise.resolve(this.bootstrap.session ? {
|
|
2740
3025
|
session: this.bootstrap.session,
|
|
2741
3026
|
launch: this.bootstrap.launch
|
|
@@ -2743,6 +3028,16 @@ var An = class e {
|
|
|
2743
3028
|
try {
|
|
2744
3029
|
[, h] = await Promise.all([f.waitForLoad(), m]);
|
|
2745
3030
|
} catch (e) {
|
|
3031
|
+
try {
|
|
3032
|
+
f.reportSdkError({
|
|
3033
|
+
errorCode: "sdk.session.attach_failed",
|
|
3034
|
+
severity: "error",
|
|
3035
|
+
operation: "attach",
|
|
3036
|
+
message: e instanceof Error ? e.message : String(e),
|
|
3037
|
+
stack: e instanceof Error ? e.stack : void 0,
|
|
3038
|
+
release: It
|
|
3039
|
+
});
|
|
3040
|
+
} catch {}
|
|
2746
3041
|
throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), e;
|
|
2747
3042
|
} finally {
|
|
2748
3043
|
this.endpointAbortController = null;
|
|
@@ -2752,19 +3047,45 @@ var An = class e {
|
|
|
2752
3047
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
2753
3048
|
this.launchToken = g;
|
|
2754
3049
|
let v = _ ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
2755
|
-
return v && !this.sessionMintedEnvelope && (this.resolvedSession = v, this.sessionMintedEnvelope = this.emitWrapped("sessionMinted", { session: v })), _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" &&
|
|
3050
|
+
return v && !this.sessionMintedEnvelope && (this.resolvedSession = v, this.sessionMintedEnvelope = this.emitWrapped("sessionMinted", { session: v })), _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && rt(_), f.postLaunch(g, _, {
|
|
2756
3051
|
startButton: e.startButton,
|
|
2757
3052
|
theme: e.theme,
|
|
2758
|
-
showFeedback: e.showFeedback
|
|
3053
|
+
showFeedback: e.showFeedback,
|
|
3054
|
+
interaction: e.interaction
|
|
2759
3055
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
2760
3056
|
startButton: e.startButton,
|
|
2761
3057
|
theme: e.theme,
|
|
2762
|
-
showFeedback: e.showFeedback
|
|
3058
|
+
showFeedback: e.showFeedback,
|
|
3059
|
+
interaction: e.interaction
|
|
2763
3060
|
}), await Promise.race([s, new Promise((e, t) => {
|
|
2764
3061
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
2765
|
-
})])
|
|
3062
|
+
})]).catch((e) => {
|
|
3063
|
+
try {
|
|
3064
|
+
f.reportSdkError({
|
|
3065
|
+
errorCode: "sdk.session.attach_failed",
|
|
3066
|
+
severity: "error",
|
|
3067
|
+
operation: "attach",
|
|
3068
|
+
message: e instanceof Error ? e.message : String(e),
|
|
3069
|
+
stack: e instanceof Error ? e.stack : void 0,
|
|
3070
|
+
release: It
|
|
3071
|
+
});
|
|
3072
|
+
} catch {}
|
|
3073
|
+
throw e;
|
|
3074
|
+
}), await Promise.race([l, new Promise((e, t) => {
|
|
2766
3075
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player ready state.")), 12e4);
|
|
2767
|
-
})])
|
|
3076
|
+
})]).catch((e) => {
|
|
3077
|
+
try {
|
|
3078
|
+
f.reportSdkError({
|
|
3079
|
+
errorCode: "sdk.session.attach_failed",
|
|
3080
|
+
severity: "error",
|
|
3081
|
+
operation: "attach",
|
|
3082
|
+
message: e instanceof Error ? e.message : String(e),
|
|
3083
|
+
stack: e instanceof Error ? e.stack : void 0,
|
|
3084
|
+
release: It
|
|
3085
|
+
});
|
|
3086
|
+
} catch {}
|
|
3087
|
+
throw e;
|
|
3088
|
+
}), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.createPlayerFacade();
|
|
2768
3089
|
}
|
|
2769
3090
|
async startListening() {
|
|
2770
3091
|
this.assertSessionStarted(), await this.iframeHost.startListening();
|
|
@@ -2788,11 +3109,23 @@ var An = class e {
|
|
|
2788
3109
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2789
3110
|
}
|
|
2790
3111
|
async setFit(e) {
|
|
2791
|
-
let t =
|
|
3112
|
+
let t = jn(e);
|
|
2792
3113
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2793
3114
|
if (this.closed) throw Error("Session has ended.");
|
|
2794
3115
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
2795
3116
|
}
|
|
3117
|
+
async setInteraction(e) {
|
|
3118
|
+
if (this.closed) throw Error("Session has ended.");
|
|
3119
|
+
if (!this.iframeHost) throw Error("setInteraction() requires attach() first.");
|
|
3120
|
+
let t = await this.iframeHost.setInteraction(e);
|
|
3121
|
+
return this.lastInteraction = t, t;
|
|
3122
|
+
}
|
|
3123
|
+
async getInteraction() {
|
|
3124
|
+
if (this.closed) throw Error("Session has ended.");
|
|
3125
|
+
if (!this.iframeHost) throw Error("getInteraction() requires attach() first.");
|
|
3126
|
+
let e = await this.iframeHost.getInteraction();
|
|
3127
|
+
return this.lastInteraction = e, e;
|
|
3128
|
+
}
|
|
2796
3129
|
async conversion(e) {
|
|
2797
3130
|
if (this.closed) throw Error("Session has ended.");
|
|
2798
3131
|
if (!this.iframeHost) throw Error("conversion() requires attach() first.");
|
|
@@ -2812,7 +3145,7 @@ var An = class e {
|
|
|
2812
3145
|
this.close();
|
|
2813
3146
|
}
|
|
2814
3147
|
destroy() {
|
|
2815
|
-
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,
|
|
3148
|
+
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, Xt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.lastInteraction = null, this.attached = !1);
|
|
2816
3149
|
}
|
|
2817
3150
|
resolveMintInteraction() {
|
|
2818
3151
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2824,8 +3157,8 @@ var An = class e {
|
|
|
2824
3157
|
return this.resolvedSession?.id ?? "";
|
|
2825
3158
|
}
|
|
2826
3159
|
emitWrapped(e, t) {
|
|
2827
|
-
let n =
|
|
2828
|
-
return
|
|
3160
|
+
let n = Kt(e, this.getSessionId(), t);
|
|
3161
|
+
return Yt(this.eventRegistry, e, n), n;
|
|
2829
3162
|
}
|
|
2830
3163
|
queueProcessorTurn(e) {
|
|
2831
3164
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2834,7 +3167,7 @@ var An = class e {
|
|
|
2834
3167
|
let n = this.processorAbortController.signal;
|
|
2835
3168
|
this.processorChain = this.processorChain.then(async () => {
|
|
2836
3169
|
if (!n.aborted) try {
|
|
2837
|
-
let r = await
|
|
3170
|
+
let r = await ht(t, {
|
|
2838
3171
|
utteranceId: e.utteranceId,
|
|
2839
3172
|
text: e.text,
|
|
2840
3173
|
conversation: this.conversationCache,
|
|
@@ -2884,7 +3217,7 @@ var An = class e {
|
|
|
2884
3217
|
};
|
|
2885
3218
|
}
|
|
2886
3219
|
};
|
|
2887
|
-
function
|
|
3220
|
+
function Pn(e) {
|
|
2888
3221
|
return e ? {
|
|
2889
3222
|
textSpeech: e.capabilities.speech.output,
|
|
2890
3223
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2895,41 +3228,41 @@ function jn(e) {
|
|
|
2895
3228
|
}
|
|
2896
3229
|
//#endregion
|
|
2897
3230
|
//#region src/widget/dockGeometry.ts
|
|
2898
|
-
var
|
|
2899
|
-
function
|
|
3231
|
+
var Fn = "(min-width: 768px)", In = 24, Ln = .5, Rn = 1200, zn = .85, Bn = 9 / 16;
|
|
3232
|
+
function Vn() {
|
|
2900
3233
|
if (typeof window > "u") return 800;
|
|
2901
3234
|
let e = window.screen?.availHeight;
|
|
2902
3235
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2903
3236
|
}
|
|
2904
|
-
function
|
|
2905
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2906
|
-
return s > a && (s = a, o = s /
|
|
3237
|
+
function Hn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = In, r = typeof window < "u" ? Vn() : 800) {
|
|
3238
|
+
let i = Math.max(160, Math.min(t - n * 2, t * zn)), a = Math.max(120, e - n * 2), o = Math.min(r * Ln, Rn, i), s = o * Bn;
|
|
3239
|
+
return s > a && (s = a, o = s / Bn, o > i && (o = i, s = o * Bn)), {
|
|
2907
3240
|
width: Math.round(s),
|
|
2908
3241
|
height: Math.round(o)
|
|
2909
3242
|
};
|
|
2910
3243
|
}
|
|
2911
|
-
function
|
|
3244
|
+
function Un(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = In) {
|
|
2912
3245
|
return {
|
|
2913
3246
|
left: Math.max(r, t - e.width - r),
|
|
2914
3247
|
top: Math.max(r, n - e.height - r)
|
|
2915
3248
|
};
|
|
2916
3249
|
}
|
|
2917
|
-
function
|
|
3250
|
+
function Wn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = In) {
|
|
2918
3251
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2919
3252
|
return {
|
|
2920
3253
|
left: Math.min(Math.max(a, e), o),
|
|
2921
3254
|
top: Math.min(Math.max(a, t), s)
|
|
2922
3255
|
};
|
|
2923
3256
|
}
|
|
2924
|
-
function
|
|
2925
|
-
return e(
|
|
3257
|
+
function Gn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
3258
|
+
return e(Fn).matches;
|
|
2926
3259
|
}
|
|
2927
3260
|
//#endregion
|
|
2928
3261
|
//#region src/widget/mountExperienceWidget.ts
|
|
2929
|
-
function
|
|
3262
|
+
function Kn(e) {
|
|
2930
3263
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2931
3264
|
}
|
|
2932
|
-
function
|
|
3265
|
+
function qn(e) {
|
|
2933
3266
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2934
3267
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2935
3268
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2937,10 +3270,10 @@ function Wn(e) {
|
|
|
2937
3270
|
function $(e) {
|
|
2938
3271
|
return e === "expanded" || e === "docked";
|
|
2939
3272
|
}
|
|
2940
|
-
var
|
|
2941
|
-
function
|
|
2942
|
-
|
|
2943
|
-
let r =
|
|
3273
|
+
var 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=\"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>", Yn = "<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>", Xn = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 10h-4V6m6-2l-6 6m-8 4h4v4m0-4l-6 6\"/></svg>", Zn = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16 4h4v4m-6 2l6-6M8 20H4v-4m0 4l6-6\"/></svg>";
|
|
3274
|
+
function Qn(e, t, n) {
|
|
3275
|
+
ke(De);
|
|
3276
|
+
let r = ae({
|
|
2944
3277
|
galleryThumb: t.galleryThumb,
|
|
2945
3278
|
avatarImage: t.avatarImage,
|
|
2946
3279
|
backgroundImage: t.backgroundImage,
|
|
@@ -2966,9 +3299,9 @@ function Yn(e, t, n) {
|
|
|
2966
3299
|
let e = document.createElement("img");
|
|
2967
3300
|
e.className = "liforma-et__foreground liforma-et__media", e.alt = "", e.decoding = "async", e.src = r.foregroundImage, e.addEventListener("load", () => o(e), { once: !0 }), i.append(e);
|
|
2968
3301
|
}
|
|
2969
|
-
return e.replaceChildren(i), n?.parallax === !1 ? () => {} :
|
|
3302
|
+
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : Ee(i);
|
|
2970
3303
|
}
|
|
2971
|
-
function
|
|
3304
|
+
function $n(e) {
|
|
2972
3305
|
return e.startButton ? {
|
|
2973
3306
|
...e.startButton,
|
|
2974
3307
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2980,7 +3313,7 @@ function Xn(e) {
|
|
|
2980
3313
|
variant: "primary"
|
|
2981
3314
|
};
|
|
2982
3315
|
}
|
|
2983
|
-
function
|
|
3316
|
+
function er(e) {
|
|
2984
3317
|
let t = !1, n = () => {
|
|
2985
3318
|
t || e();
|
|
2986
3319
|
}, r = () => {
|
|
@@ -3000,12 +3333,12 @@ function Zn(e) {
|
|
|
3000
3333
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
3001
3334
|
};
|
|
3002
3335
|
}
|
|
3003
|
-
function
|
|
3004
|
-
|
|
3336
|
+
function tr(e, t) {
|
|
3337
|
+
Pe(Me);
|
|
3005
3338
|
let n = t.experienceId?.trim();
|
|
3006
3339
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
3007
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
3008
|
-
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",
|
|
3340
|
+
let r = t.prefetch ?? "onExpand", i = Kn(t.position), a = document.createElement("div");
|
|
3341
|
+
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", qn(t.offset));
|
|
3009
3342
|
let o = document.createElement("button");
|
|
3010
3343
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
3011
3344
|
let s = document.createElement("div");
|
|
@@ -3025,16 +3358,16 @@ function Qn(e, t) {
|
|
|
3025
3358
|
let m = document.createElement("span");
|
|
3026
3359
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
3027
3360
|
let h = document.createElement("button");
|
|
3028
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
3361
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = Xn, h.setAttribute("aria-label", "Reduce");
|
|
3029
3362
|
let g = document.createElement("button");
|
|
3030
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
3363
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Jn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
3031
3364
|
let _ = document.createElement("button");
|
|
3032
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
3365
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = Yn, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
3033
3366
|
let v = document.createElement("div");
|
|
3034
3367
|
v.className = "liforma-ew__stage";
|
|
3035
3368
|
let y = document.createElement("div");
|
|
3036
3369
|
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);
|
|
3037
|
-
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,
|
|
3370
|
+
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, L = null, ne = !1, re = new AbortController(), ie = t.parallax !== !1, R = () => {
|
|
3038
3371
|
let e = a.dataset.state;
|
|
3039
3372
|
return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
|
|
3040
3373
|
}, z = () => {
|
|
@@ -3055,51 +3388,51 @@ function Qn(e, t) {
|
|
|
3055
3388
|
i(f), i(l);
|
|
3056
3389
|
let a = p.offsetWidth || 120;
|
|
3057
3390
|
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";
|
|
3058
|
-
},
|
|
3391
|
+
}, H = (e, t) => {
|
|
3059
3392
|
if (R() !== "docked") return;
|
|
3060
|
-
let n =
|
|
3393
|
+
let n = Hn(), r = Wn(e - ee, t - te, n);
|
|
3061
3394
|
P = r.left, F = r.top, V(r.left, r.top, n.width, n.height);
|
|
3062
|
-
},
|
|
3395
|
+
}, oe = (e, t) => {
|
|
3063
3396
|
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
3064
|
-
let n =
|
|
3397
|
+
let n = Hn(), r = P ?? f.getBoundingClientRect().left, i = F ?? f.getBoundingClientRect().top, a = Wn(r + e, i + t, n);
|
|
3065
3398
|
P = a.left, F = a.top, V(a.left, a.top, n.width, n.height);
|
|
3066
|
-
},
|
|
3067
|
-
|
|
3068
|
-
},
|
|
3399
|
+
}, se = (e) => {
|
|
3400
|
+
L === "toolbar" && (I === null || e.pointerId !== I || (e.preventDefault(), H(e.clientX, e.clientY)));
|
|
3401
|
+
}, U = (e) => {
|
|
3069
3402
|
if (I === null || e && e.pointerId !== I) return;
|
|
3070
|
-
let t =
|
|
3071
|
-
I = null,
|
|
3072
|
-
},
|
|
3073
|
-
if (S || R() !== "docked" || !
|
|
3074
|
-
I = n,
|
|
3403
|
+
let t = L;
|
|
3404
|
+
I = null, L = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && ne && (ne = !1, window.removeEventListener("pointermove", se), window.removeEventListener("pointerup", U), window.removeEventListener("pointercancel", U));
|
|
3405
|
+
}, ce = (e, t, n) => {
|
|
3406
|
+
if (S || R() !== "docked" || !Gn() || I !== null) return;
|
|
3407
|
+
I = n, L = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3075
3408
|
let r = f.getBoundingClientRect();
|
|
3076
|
-
ee = e - r.left, te = t - r.top,
|
|
3077
|
-
},
|
|
3078
|
-
if (S || R() !== "docked" || !
|
|
3079
|
-
I = e.pointerId,
|
|
3409
|
+
ee = e - r.left, te = t - r.top, ne || (ne = !0, window.addEventListener("pointermove", se), window.addEventListener("pointerup", U), window.addEventListener("pointercancel", U));
|
|
3410
|
+
}, le = (e) => {
|
|
3411
|
+
if (S || R() !== "docked" || !Gn() || I !== null) return;
|
|
3412
|
+
I = e.pointerId, L = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3080
3413
|
let t = f.getBoundingClientRect();
|
|
3081
3414
|
P = t.left, F = t.top;
|
|
3415
|
+
}, W = (e) => {
|
|
3416
|
+
L === "player" && (I === null || e.pointerId !== I || oe(e.dx, e.dy));
|
|
3082
3417
|
}, ue = (e) => {
|
|
3083
|
-
|
|
3084
|
-
},
|
|
3085
|
-
|
|
3086
|
-
}, W = () => {
|
|
3087
|
-
let e = Hn(), t = R();
|
|
3418
|
+
L === "player" && (I === null || e.pointerId !== I || U());
|
|
3419
|
+
}, G = () => {
|
|
3420
|
+
let e = Gn(), t = R();
|
|
3088
3421
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
3089
3422
|
h.hidden = !0;
|
|
3090
3423
|
return;
|
|
3091
3424
|
}
|
|
3092
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
3093
|
-
},
|
|
3094
|
-
let t =
|
|
3095
|
-
n =
|
|
3096
|
-
},
|
|
3425
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = Zn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = Xn, h.setAttribute("aria-label", "Reduce"));
|
|
3426
|
+
}, de = (e) => {
|
|
3427
|
+
let t = Hn(), n = e && P !== null && F !== null ? Wn(P, F, t) : Un(t);
|
|
3428
|
+
n = Wn(n.left, n.top, t), P = n.left, F = n.top, V(n.left, n.top, t.width, t.height), G();
|
|
3429
|
+
}, fe = () => {
|
|
3097
3430
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
3098
3431
|
requestAnimationFrame(() => {
|
|
3099
3432
|
S || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
|
|
3100
3433
|
});
|
|
3101
3434
|
});
|
|
3102
|
-
},
|
|
3435
|
+
}, pe = (e) => {
|
|
3103
3436
|
if (B(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !D) {
|
|
3104
3437
|
a.classList.remove("liforma-ew--layout-settling");
|
|
3105
3438
|
return;
|
|
@@ -3109,52 +3442,52 @@ function Qn(e, t) {
|
|
|
3109
3442
|
a.classList.remove("liforma-ew--layout-settling");
|
|
3110
3443
|
return;
|
|
3111
3444
|
}
|
|
3112
|
-
a.classList.remove("liforma-ew--layout-settling"),
|
|
3445
|
+
a.classList.remove("liforma-ew--layout-settling"), fe();
|
|
3113
3446
|
}, 220);
|
|
3114
|
-
},
|
|
3447
|
+
}, me = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
3115
3448
|
z(), M = setTimeout(() => {
|
|
3116
3449
|
M = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
3117
3450
|
}, 280);
|
|
3118
|
-
})),
|
|
3451
|
+
})), he = {
|
|
3119
3452
|
galleryThumb: t.galleryThumb,
|
|
3120
3453
|
avatarImage: t.avatarImage,
|
|
3121
3454
|
backgroundImage: t.backgroundImage,
|
|
3122
3455
|
foregroundImage: t.foregroundImage,
|
|
3123
3456
|
fallbackImage: t.fallbackImage
|
|
3124
|
-
},
|
|
3457
|
+
}, K = (e) => {
|
|
3125
3458
|
if (!e) {
|
|
3126
3459
|
y.hidden = !0, y.textContent = "";
|
|
3127
3460
|
return;
|
|
3128
3461
|
}
|
|
3129
3462
|
y.hidden = !1, y.textContent = e;
|
|
3130
|
-
},
|
|
3463
|
+
}, ge = (e) => {
|
|
3131
3464
|
if (!e) {
|
|
3132
3465
|
c.hidden = !0, c.textContent = "";
|
|
3133
3466
|
return;
|
|
3134
3467
|
}
|
|
3135
3468
|
c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
|
|
3136
|
-
},
|
|
3137
|
-
C = !0, o.disabled = !1,
|
|
3138
|
-
},
|
|
3469
|
+
}, _e = () => {
|
|
3470
|
+
C = !0, o.disabled = !1, ge(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
3471
|
+
}, ve = () => {
|
|
3139
3472
|
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
3140
|
-
},
|
|
3473
|
+
}, ye = (e) => {
|
|
3141
3474
|
A?.(), A = null;
|
|
3142
|
-
let t =
|
|
3475
|
+
let t = Qn(s, e, { parallax: ie });
|
|
3143
3476
|
return t ? (A = t, !0) : !1;
|
|
3144
|
-
},
|
|
3145
|
-
if (
|
|
3146
|
-
|
|
3477
|
+
}, be = () => {
|
|
3478
|
+
if (ye(he)) {
|
|
3479
|
+
_e();
|
|
3147
3480
|
return;
|
|
3148
3481
|
}
|
|
3149
|
-
|
|
3482
|
+
ge("Loading…"), Be(n, { signal: re.signal }).then((e) => {
|
|
3150
3483
|
if (!S) {
|
|
3151
|
-
if (!
|
|
3152
|
-
|
|
3484
|
+
if (!ye({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
|
|
3485
|
+
_e();
|
|
3153
3486
|
}
|
|
3154
3487
|
}).catch((e) => {
|
|
3155
3488
|
if (S || re.signal.aborted) return;
|
|
3156
3489
|
let n = e instanceof Error ? e : Error(String(e));
|
|
3157
|
-
|
|
3490
|
+
ge("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
|
|
3158
3491
|
});
|
|
3159
3492
|
}, xe = () => ({
|
|
3160
3493
|
experienceId: n,
|
|
@@ -3165,89 +3498,91 @@ function Qn(e, t) {
|
|
|
3165
3498
|
...t.mode ? { mode: t.mode } : {},
|
|
3166
3499
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
3167
3500
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
3501
|
+
...t.alreadyConverted?.length ? { alreadyConverted: t.alreadyConverted } : {},
|
|
3168
3502
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
3169
|
-
}),
|
|
3503
|
+
}), q = () => ({
|
|
3170
3504
|
...t.fit ? { fit: t.fit } : {},
|
|
3171
|
-
startButton:
|
|
3172
|
-
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3505
|
+
startButton: $n(t),
|
|
3506
|
+
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback },
|
|
3507
|
+
...t.interaction ? { interaction: t.interaction } : {}
|
|
3508
|
+
}), J = (e = !0) => {
|
|
3509
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ae(), a.dataset.state = "expanded", K(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), G(), e && t.onExpanded?.();
|
|
3510
|
+
}, Se = () => {
|
|
3511
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", K(null), typeof document < "u" && (document.body.style.overflow = k), de(!0), G(), b?.setWidgetChrome("docked");
|
|
3512
|
+
}, Ce = (e) => {
|
|
3178
3513
|
e.on("started", () => {
|
|
3179
|
-
S || (D = !0, a.dataset.live = "true",
|
|
3514
|
+
S || (D = !0, a.dataset.live = "true", K(null), t.onStarted?.(), $(a.dataset.state) && fe());
|
|
3180
3515
|
}), e.on("feedback", (e) => {
|
|
3181
3516
|
S || t.onFeedback?.(e);
|
|
3182
3517
|
}), e.on("feedbackFailed", (e) => {
|
|
3183
3518
|
S || t.onFeedbackFailed?.(e);
|
|
3184
3519
|
});
|
|
3520
|
+
}, we = () => {
|
|
3521
|
+
B(), u.hidden = !0, p.hidden = !0, ae(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), C && (o.disabled = !1), K(null), typeof document < "u" && (document.body.style.overflow = k), G();
|
|
3185
3522
|
}, Te = () => {
|
|
3186
|
-
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();
|
|
3187
|
-
}, Ee = () => {
|
|
3188
3523
|
z(), B(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
|
|
3189
3524
|
let e = b;
|
|
3190
3525
|
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");
|
|
3191
|
-
},
|
|
3526
|
+
}, Ee = () => {
|
|
3192
3527
|
if (!S && $(a.dataset.state)) {
|
|
3193
|
-
if (
|
|
3528
|
+
if (U(), x = !1, b && E) {
|
|
3194
3529
|
let e = b;
|
|
3195
3530
|
(async () => {
|
|
3196
|
-
D && (await
|
|
3531
|
+
D && (await me(), S || b !== e) || (w && e.setWidgetChrome("collapsed"), we(), D ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : w && ve(), t.onCollapsed?.(), t.onClose?.());
|
|
3197
3532
|
})();
|
|
3198
3533
|
return;
|
|
3199
3534
|
}
|
|
3200
|
-
|
|
3535
|
+
Te(), we(), t.onCollapsed?.(), t.onClose?.();
|
|
3201
3536
|
}
|
|
3202
|
-
},
|
|
3203
|
-
S ||
|
|
3204
|
-
|
|
3537
|
+
}, De = () => {
|
|
3538
|
+
S || Gn() && R() === "expanded" && pe(() => {
|
|
3539
|
+
Se();
|
|
3205
3540
|
});
|
|
3206
|
-
},
|
|
3207
|
-
S || R() === "docked" && (
|
|
3208
|
-
ae(),
|
|
3541
|
+
}, Oe = () => {
|
|
3542
|
+
S || R() === "docked" && (U(), pe(() => {
|
|
3543
|
+
ae(), J(!1), b?.setWidgetChrome("expanded");
|
|
3209
3544
|
}));
|
|
3545
|
+
}, ke = () => {
|
|
3546
|
+
!b || !D || (z(), a.classList.remove("liforma-ew--session-revealed"), J(), b.setWidgetChrome("expanded"), x = !1, fe());
|
|
3210
3547
|
}, Ae = () => {
|
|
3211
|
-
!b || !D || (z(), a.classList.remove("liforma-ew--session-revealed"),
|
|
3212
|
-
},
|
|
3213
|
-
|
|
3214
|
-
},
|
|
3215
|
-
S || e !== O && !D || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, D && pe());
|
|
3216
|
-
}, Fe = () => {
|
|
3548
|
+
!b || !E || D || (z(), a.classList.remove("liforma-ew--session-revealed"), J(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
3549
|
+
}, je = (e) => {
|
|
3550
|
+
S || e !== O && !D || (z(), a.classList.remove("liforma-ew--session-revealed"), J(), x = !1, D && fe());
|
|
3551
|
+
}, Ne = () => {
|
|
3217
3552
|
if (S || T || w || b || $(a.dataset.state)) return;
|
|
3218
3553
|
T = !0;
|
|
3219
3554
|
let e = O;
|
|
3220
3555
|
l.hidden = !1, (async () => {
|
|
3221
3556
|
try {
|
|
3222
|
-
let t = await
|
|
3557
|
+
let t = await Nn.startSession(xe());
|
|
3223
3558
|
if (S || e !== O) {
|
|
3224
3559
|
t.destroy();
|
|
3225
3560
|
return;
|
|
3226
3561
|
}
|
|
3227
|
-
b = t,
|
|
3562
|
+
b = t, Ce(t);
|
|
3228
3563
|
let n = await t.attach({
|
|
3229
3564
|
container: l,
|
|
3230
|
-
...
|
|
3565
|
+
...q(),
|
|
3231
3566
|
onWidgetReady: () => {
|
|
3232
|
-
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") :
|
|
3567
|
+
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : ve());
|
|
3233
3568
|
},
|
|
3234
3569
|
onWidgetExpand: () => {
|
|
3235
|
-
|
|
3570
|
+
je(e);
|
|
3236
3571
|
},
|
|
3237
3572
|
onWidgetAudioSettings: (e) => {
|
|
3238
|
-
S ||
|
|
3573
|
+
S || Re(e);
|
|
3239
3574
|
},
|
|
3240
3575
|
onWidgetDragStart: (e) => {
|
|
3241
|
-
S ||
|
|
3576
|
+
S || le(e);
|
|
3242
3577
|
},
|
|
3243
3578
|
onWidgetDragMove: (e) => {
|
|
3244
|
-
S ||
|
|
3579
|
+
S || W(e);
|
|
3245
3580
|
},
|
|
3246
3581
|
onWidgetDragEnd: (e) => {
|
|
3247
|
-
S ||
|
|
3582
|
+
S || ue(e);
|
|
3248
3583
|
},
|
|
3249
3584
|
onPlayerStatusChange: (e) => {
|
|
3250
|
-
S || e === "error" && $(a.dataset.state) &&
|
|
3585
|
+
S || e === "error" && $(a.dataset.state) && K("Could not load the experience.");
|
|
3251
3586
|
}
|
|
3252
3587
|
});
|
|
3253
3588
|
if (S || e !== O) {
|
|
@@ -3255,7 +3590,7 @@ function Qn(e, t) {
|
|
|
3255
3590
|
return;
|
|
3256
3591
|
}
|
|
3257
3592
|
n.on("close", () => {
|
|
3258
|
-
S ||
|
|
3593
|
+
S || Ee();
|
|
3259
3594
|
});
|
|
3260
3595
|
} catch (n) {
|
|
3261
3596
|
if (S || e !== O) return;
|
|
@@ -3264,43 +3599,43 @@ function Qn(e, t) {
|
|
|
3264
3599
|
t.onError?.(r), console.error("[ExperienceWidget] warm prefetch failed", r);
|
|
3265
3600
|
}
|
|
3266
3601
|
})();
|
|
3267
|
-
},
|
|
3602
|
+
}, Fe = () => {
|
|
3268
3603
|
if (S || x || !C || $(a.dataset.state)) return;
|
|
3269
3604
|
if (b && D) {
|
|
3270
|
-
|
|
3605
|
+
ke();
|
|
3271
3606
|
return;
|
|
3272
3607
|
}
|
|
3273
3608
|
if (b && E) {
|
|
3274
|
-
|
|
3609
|
+
Ae();
|
|
3275
3610
|
return;
|
|
3276
3611
|
}
|
|
3277
3612
|
let e = ++O;
|
|
3278
3613
|
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 () => {
|
|
3279
3614
|
try {
|
|
3280
|
-
|
|
3281
|
-
let t = await
|
|
3615
|
+
J();
|
|
3616
|
+
let t = await Nn.startSession(xe());
|
|
3282
3617
|
if (S || e !== O) {
|
|
3283
3618
|
t.destroy();
|
|
3284
3619
|
return;
|
|
3285
3620
|
}
|
|
3286
|
-
b = t,
|
|
3621
|
+
b = t, Ce(t);
|
|
3287
3622
|
let n = await t.attach({
|
|
3288
3623
|
container: v,
|
|
3289
|
-
...
|
|
3624
|
+
...q(),
|
|
3290
3625
|
onWidgetAudioSettings: (e) => {
|
|
3291
|
-
S ||
|
|
3626
|
+
S || Re(e);
|
|
3292
3627
|
},
|
|
3293
3628
|
onWidgetDragStart: (e) => {
|
|
3294
|
-
S ||
|
|
3629
|
+
S || le(e);
|
|
3295
3630
|
},
|
|
3296
3631
|
onWidgetDragMove: (e) => {
|
|
3297
|
-
S ||
|
|
3632
|
+
S || W(e);
|
|
3298
3633
|
},
|
|
3299
3634
|
onWidgetDragEnd: (e) => {
|
|
3300
|
-
S ||
|
|
3635
|
+
S || ue(e);
|
|
3301
3636
|
},
|
|
3302
3637
|
onPlayerStatusChange: (e) => {
|
|
3303
|
-
S || (e === "error" ?
|
|
3638
|
+
S || (e === "error" ? K("Could not load the experience.") : $(a.dataset.state) && K(null));
|
|
3304
3639
|
}
|
|
3305
3640
|
});
|
|
3306
3641
|
if (S || e !== O) {
|
|
@@ -3308,101 +3643,101 @@ function Qn(e, t) {
|
|
|
3308
3643
|
return;
|
|
3309
3644
|
}
|
|
3310
3645
|
E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
3311
|
-
S ||
|
|
3646
|
+
S || Ee();
|
|
3312
3647
|
});
|
|
3313
3648
|
} catch (n) {
|
|
3314
3649
|
if (S || e !== O) return;
|
|
3315
3650
|
let r = n instanceof Error ? n : Error(String(n));
|
|
3316
|
-
|
|
3651
|
+
K(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
|
|
3317
3652
|
} finally {
|
|
3318
3653
|
e === O && (x = !1);
|
|
3319
3654
|
}
|
|
3320
3655
|
})();
|
|
3321
|
-
},
|
|
3656
|
+
}, Ie = () => {
|
|
3322
3657
|
if (!(S || $(a.dataset.state))) {
|
|
3323
3658
|
if (b && D) {
|
|
3324
|
-
|
|
3659
|
+
ke();
|
|
3325
3660
|
return;
|
|
3326
3661
|
}
|
|
3327
3662
|
if (b && E) {
|
|
3328
|
-
|
|
3663
|
+
Ae();
|
|
3329
3664
|
return;
|
|
3330
3665
|
}
|
|
3331
3666
|
if (T || b) {
|
|
3332
|
-
|
|
3667
|
+
J();
|
|
3333
3668
|
return;
|
|
3334
3669
|
}
|
|
3335
|
-
|
|
3670
|
+
Fe();
|
|
3336
3671
|
}
|
|
3337
|
-
},
|
|
3672
|
+
}, Le = (e) => {
|
|
3338
3673
|
if (e.stopPropagation(), R() === "expanded") {
|
|
3339
|
-
|
|
3674
|
+
De();
|
|
3340
3675
|
return;
|
|
3341
3676
|
}
|
|
3342
|
-
R() === "docked" &&
|
|
3343
|
-
},
|
|
3677
|
+
R() === "docked" && Oe();
|
|
3678
|
+
}, Re = (e) => {
|
|
3344
3679
|
g.setAttribute("aria-pressed", e ? "true" : "false");
|
|
3345
|
-
},
|
|
3680
|
+
}, ze = (e) => {
|
|
3346
3681
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
3347
3682
|
}, Ve = (e) => {
|
|
3348
|
-
R() === "docked" &&
|
|
3683
|
+
R() === "docked" && Gn() && (e.target?.closest("button") || (e.preventDefault(), ce(e.clientX, e.clientY, e.pointerId)));
|
|
3349
3684
|
}, He = (e) => {
|
|
3350
|
-
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(),
|
|
3685
|
+
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), Ee());
|
|
3351
3686
|
}, Ue = () => {
|
|
3352
3687
|
if (!S) {
|
|
3353
3688
|
if (R() === "docked") {
|
|
3354
|
-
if (!
|
|
3355
|
-
|
|
3689
|
+
if (!Gn()) {
|
|
3690
|
+
Oe();
|
|
3356
3691
|
return;
|
|
3357
3692
|
}
|
|
3358
|
-
D ?
|
|
3359
|
-
|
|
3360
|
-
}) :
|
|
3693
|
+
D ? pe(() => {
|
|
3694
|
+
de(!0);
|
|
3695
|
+
}) : de(!0);
|
|
3361
3696
|
return;
|
|
3362
3697
|
}
|
|
3363
|
-
|
|
3698
|
+
G();
|
|
3364
3699
|
}
|
|
3365
|
-
},
|
|
3700
|
+
}, We = typeof window < "u" ? window.matchMedia(Fn) : null, Ge = () => {
|
|
3366
3701
|
if (!S) {
|
|
3367
|
-
if (R() === "docked" && !
|
|
3368
|
-
|
|
3702
|
+
if (R() === "docked" && !Gn()) {
|
|
3703
|
+
Oe();
|
|
3369
3704
|
return;
|
|
3370
3705
|
}
|
|
3371
|
-
|
|
3706
|
+
G();
|
|
3372
3707
|
}
|
|
3373
3708
|
};
|
|
3374
|
-
return o.addEventListener("click",
|
|
3375
|
-
e.stopPropagation(),
|
|
3376
|
-
}), h.addEventListener("click",
|
|
3377
|
-
S ||
|
|
3378
|
-
}) : r === "idle" && (j =
|
|
3379
|
-
S ||
|
|
3709
|
+
return o.addEventListener("click", Ie), d.addEventListener("click", Ee), _.addEventListener("click", (e) => {
|
|
3710
|
+
e.stopPropagation(), Ee();
|
|
3711
|
+
}), h.addEventListener("click", Le), g.addEventListener("click", ze), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), We?.addEventListener("change", Ge), be(), G(), r === "eager" ? queueMicrotask(() => {
|
|
3712
|
+
S || Ne();
|
|
3713
|
+
}) : r === "idle" && (j = er(() => {
|
|
3714
|
+
S || Ne();
|
|
3380
3715
|
})), {
|
|
3381
3716
|
root: a,
|
|
3382
|
-
expand:
|
|
3383
|
-
collapse:
|
|
3384
|
-
dock:
|
|
3385
|
-
maximize:
|
|
3717
|
+
expand: Ie,
|
|
3718
|
+
collapse: Ee,
|
|
3719
|
+
dock: De,
|
|
3720
|
+
maximize: Oe,
|
|
3386
3721
|
prefetch() {
|
|
3387
3722
|
if (r === "onExpand") {
|
|
3388
|
-
|
|
3723
|
+
Ne();
|
|
3389
3724
|
return;
|
|
3390
3725
|
}
|
|
3391
|
-
|
|
3726
|
+
Ne();
|
|
3392
3727
|
},
|
|
3393
3728
|
destroy() {
|
|
3394
|
-
S || (S = !0,
|
|
3729
|
+
S || (S = !0, U(), j?.(), j = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown", He), window.removeEventListener("resize", Ue), We?.removeEventListener("change", Ge), Te(), we(), e.replaceChildren());
|
|
3395
3730
|
}
|
|
3396
3731
|
};
|
|
3397
3732
|
}
|
|
3398
3733
|
//#endregion
|
|
3399
3734
|
//#region src/react/ExperienceWidget.tsx
|
|
3400
|
-
function
|
|
3735
|
+
function nr(e) {
|
|
3401
3736
|
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";
|
|
3402
3737
|
return n(() => {
|
|
3403
3738
|
let e = t.current;
|
|
3404
3739
|
if (!e || !r.trim()) return;
|
|
3405
|
-
let n =
|
|
3740
|
+
let n = tr(e, {
|
|
3406
3741
|
experienceId: r,
|
|
3407
3742
|
alt: i,
|
|
3408
3743
|
galleryThumb: a,
|
|
@@ -3479,6 +3814,6 @@ function $n(e) {
|
|
|
3479
3814
|
});
|
|
3480
3815
|
}
|
|
3481
3816
|
//#endregion
|
|
3482
|
-
export {
|
|
3817
|
+
export { ne as Experience, je as ExperienceThumbnail, nr as ExperienceWidget };
|
|
3483
3818
|
|
|
3484
3819
|
//# sourceMappingURL=index.js.map
|