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