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