@wix/web5-embed 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hostChrome.d.ts +56 -11
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +227 -189
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
1
|
+
const m = "__web5InputFocusShortcut__", L = 'input, textarea, [contenteditable=""], [contenteditable="true"]', M = '[role="dialog"][aria-modal="true"]';
|
|
2
|
+
function F(e) {
|
|
3
3
|
if (e.hasAttribute("inert")) return !1;
|
|
4
4
|
if (typeof e.checkVisibility == "function")
|
|
5
5
|
return e.checkVisibility({
|
|
@@ -9,54 +9,54 @@ function E(e) {
|
|
|
9
9
|
const t = getComputedStyle(e);
|
|
10
10
|
return !(t.visibility === "hidden" || t.display === "none" || parseFloat(t.opacity) === 0);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function x(e) {
|
|
13
13
|
const t = e.composedPath();
|
|
14
14
|
for (const n of t)
|
|
15
|
-
if (n instanceof Element && typeof n.matches == "function" && n.matches(
|
|
15
|
+
if (n instanceof Element && typeof n.matches == "function" && n.matches(L))
|
|
16
16
|
return !0;
|
|
17
17
|
return !1;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function re() {
|
|
20
20
|
const e = window;
|
|
21
|
-
if (e[
|
|
21
|
+
if (e[m]) return e[m];
|
|
22
22
|
const t = [];
|
|
23
23
|
let n = !1;
|
|
24
|
-
const
|
|
24
|
+
const r = (i) => {
|
|
25
25
|
if (i.defaultPrevented || i.isComposing) return;
|
|
26
26
|
const c = i.key === "/" && !i.metaKey && !i.ctrlKey && !i.altKey && !i.shiftKey, u = (i.metaKey || i.ctrlKey) && !i.altKey && i.key.toLowerCase() === "k";
|
|
27
|
-
if (!c && !u || c &&
|
|
28
|
-
const
|
|
29
|
-
for (const
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
27
|
+
if (!c && !u || c && x(i)) return;
|
|
28
|
+
const p = document.querySelectorAll(M);
|
|
29
|
+
for (const f of p)
|
|
30
|
+
if (F(f)) return;
|
|
31
|
+
const d = t.find((f) => f.isVisible());
|
|
32
|
+
if (!d) return;
|
|
33
33
|
i.preventDefault();
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
n || (window.addEventListener("keydown",
|
|
38
|
-
},
|
|
39
|
-
!n || t.length > 0 || (window.removeEventListener("keydown",
|
|
40
|
-
},
|
|
34
|
+
const h = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
35
|
+
d.focus(h);
|
|
36
|
+
}, o = () => {
|
|
37
|
+
n || (window.addEventListener("keydown", r), n = !0);
|
|
38
|
+
}, s = () => {
|
|
39
|
+
!n || t.length > 0 || (window.removeEventListener("keydown", r), n = !1);
|
|
40
|
+
}, a = {
|
|
41
41
|
register(i) {
|
|
42
|
-
t.includes(i) || t.push(i),
|
|
42
|
+
t.includes(i) || t.push(i), o();
|
|
43
43
|
},
|
|
44
44
|
unregister(i) {
|
|
45
45
|
const c = t.indexOf(i);
|
|
46
|
-
c >= 0 && t.splice(c, 1),
|
|
46
|
+
c >= 0 && t.splice(c, 1), s();
|
|
47
47
|
},
|
|
48
48
|
__teardown() {
|
|
49
|
-
t.length = 0, n && (window.removeEventListener("keydown",
|
|
49
|
+
t.length = 0, n && (window.removeEventListener("keydown", r), n = !1);
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
return e[
|
|
52
|
+
return e[m] = a, a;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function oe() {
|
|
55
55
|
const e = window;
|
|
56
|
-
e[
|
|
56
|
+
e[m]?.__teardown(), delete e[m];
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
async function
|
|
58
|
+
const H = "https://www.wixapis.com/web50-server/static-versions", T = "__web5_static_versions";
|
|
59
|
+
async function O(e = H) {
|
|
60
60
|
const t = await fetch(e, {
|
|
61
61
|
method: "GET",
|
|
62
62
|
headers: { Accept: "application/json" },
|
|
@@ -67,41 +67,41 @@ async function _(e = I) {
|
|
|
67
67
|
throw new Error(`[Web5Embed] static-versions returned ${t.status}`);
|
|
68
68
|
return t.json();
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
const n = e.find((
|
|
70
|
+
function v(e, t) {
|
|
71
|
+
const n = e.find((r) => r.artifactId === t);
|
|
72
72
|
if (!n)
|
|
73
73
|
throw new Error(
|
|
74
74
|
`[Web5Embed] artifact ${t} not found in static-versions`
|
|
75
75
|
);
|
|
76
76
|
return n.version;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
return window[
|
|
78
|
+
function P() {
|
|
79
|
+
return window[T];
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
window[
|
|
81
|
+
function U(e) {
|
|
82
|
+
window[T] = e;
|
|
83
83
|
}
|
|
84
|
-
const
|
|
84
|
+
const N = {
|
|
85
85
|
staticVersionsUrl: "https://www.wixapis.com/web50-server/static-versions",
|
|
86
86
|
tokensCdnBase: "https://static.parastorage.com/services/web50-server-ui",
|
|
87
87
|
tokensArtifactId: "com.wixpress.web50-server-ui",
|
|
88
88
|
tokensFileName: "prompt-input-tokens.css",
|
|
89
89
|
fallbackVersion: "1.459.0"
|
|
90
90
|
};
|
|
91
|
-
function
|
|
92
|
-
return { ...
|
|
91
|
+
function S(e) {
|
|
92
|
+
return { ...N, ...e ?? {} };
|
|
93
93
|
}
|
|
94
|
-
function
|
|
95
|
-
const { tokensCdnBase: n, tokensFileName:
|
|
96
|
-
return `${n}/${e}/${
|
|
94
|
+
function R(e, t) {
|
|
95
|
+
const { tokensCdnBase: n, tokensFileName: r } = S(t);
|
|
96
|
+
return `${n}/${e}/${r}`;
|
|
97
97
|
}
|
|
98
|
-
async function
|
|
99
|
-
const t =
|
|
98
|
+
async function V(e) {
|
|
99
|
+
const t = S(e);
|
|
100
100
|
try {
|
|
101
|
-
const n =
|
|
102
|
-
if (n) return
|
|
103
|
-
const
|
|
104
|
-
return
|
|
101
|
+
const n = P();
|
|
102
|
+
if (n) return v(n, t.tokensArtifactId);
|
|
103
|
+
const r = await O(t.staticVersionsUrl);
|
|
104
|
+
return U(r), v(r, t.tokensArtifactId);
|
|
105
105
|
} catch (n) {
|
|
106
106
|
return console.warn(
|
|
107
107
|
"[Web5Embed] Failed to resolve prompt token version, using fallback:",
|
|
@@ -109,151 +109,151 @@ async function M(e) {
|
|
|
109
109
|
), t.fallbackVersion;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
async function
|
|
113
|
-
const t = await
|
|
114
|
-
return
|
|
112
|
+
async function D(e) {
|
|
113
|
+
const t = await V(e);
|
|
114
|
+
return R(t, e);
|
|
115
115
|
}
|
|
116
|
-
async function
|
|
116
|
+
async function ie(e, t) {
|
|
117
117
|
if (e.querySelector(
|
|
118
118
|
'link[data-web5-prompt-input-tokens="true"]'
|
|
119
119
|
)) return;
|
|
120
|
-
const
|
|
121
|
-
|
|
120
|
+
const r = document.createElement("link");
|
|
121
|
+
r.rel = "stylesheet", r.dataset.web5PromptInputTokens = "true", r.href = await D(t), e.prepend(r);
|
|
122
122
|
}
|
|
123
|
-
const
|
|
123
|
+
const se = `
|
|
124
124
|
<svg class="web5-submit-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
125
125
|
<path d="M13.0306 7.53114C12.9609 7.60106 12.8781 7.65654 12.787 7.69439C12.6958 7.73224 12.5981 7.75173 12.4993 7.75173C12.4006 7.75173 12.3029 7.73224 12.2117 7.69439C12.1206 7.65654 12.0378 7.60106 11.9681 7.53114L8.74997 4.31301V13.5005C8.74997 13.6994 8.67095 13.8902 8.5303 14.0308C8.38965 14.1715 8.19888 14.2505 7.99997 14.2505C7.80106 14.2505 7.61029 14.1715 7.46964 14.0308C7.32899 13.8902 7.24997 13.6994 7.24997 13.5005V4.31301L4.0306 7.53114C3.8897 7.67203 3.69861 7.75119 3.49935 7.75119C3.30009 7.75119 3.10899 7.67203 2.9681 7.53114C2.8272 7.39024 2.74805 7.19915 2.74805 6.99989C2.74805 6.80063 2.8272 6.60953 2.9681 6.46864L7.4681 1.96864C7.53778 1.89872 7.62057 1.84324 7.71173 1.80539C7.8029 1.76753 7.90064 1.74805 7.99935 1.74805C8.09806 1.74805 8.1958 1.76753 8.28696 1.80539C8.37813 1.84324 8.46092 1.89872 8.5306 1.96864L13.0306 6.46864C13.1005 6.53832 13.156 6.62111 13.1938 6.71227C13.2317 6.80344 13.2512 6.90118 13.2512 6.99989C13.2512 7.0986 13.2317 7.19634 13.1938 7.2875C13.156 7.37867 13.1005 7.46146 13.0306 7.53114Z" fill="currentColor" />
|
|
126
126
|
</svg>
|
|
127
127
|
`;
|
|
128
|
-
function
|
|
128
|
+
function B(e) {
|
|
129
129
|
return `${e}?initialQuestion=`;
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function ae(e) {
|
|
132
132
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
async function
|
|
134
|
+
const $ = "https://www.wixapis.com/page-enrichment/v1/page-meta-data/chips", _ = 5e3, W = "https://www.wixapis.com/wix-assistant-web5/v1/turn", K = "pdpChips";
|
|
135
|
+
async function ce(e, t) {
|
|
136
136
|
if (t.conversation?.web5Id)
|
|
137
|
-
return
|
|
137
|
+
return q({
|
|
138
138
|
...t.conversation,
|
|
139
139
|
timeoutMs: t.timeoutMs,
|
|
140
140
|
fetchImpl: t.fetchImpl
|
|
141
141
|
});
|
|
142
|
-
const n = t.endpoint ??
|
|
142
|
+
const n = t.endpoint ?? $, r = t.timeoutMs ?? _, o = A(t.fetchImpl), s = new AbortController(), a = setTimeout(() => s.abort(), r);
|
|
143
143
|
try {
|
|
144
|
-
const i = await
|
|
144
|
+
const i = await o(
|
|
145
145
|
`${n}?url=${encodeURIComponent(e)}&sessionId=${encodeURIComponent(
|
|
146
146
|
t.sessionId
|
|
147
147
|
)}`,
|
|
148
|
-
{ signal:
|
|
148
|
+
{ signal: s.signal }
|
|
149
149
|
);
|
|
150
150
|
if (!i.ok)
|
|
151
151
|
throw new Error(`HTTP ${i.status}`);
|
|
152
152
|
return (await i.json()).chips?.map((u) => u.label).filter(Boolean) ?? [];
|
|
153
153
|
} finally {
|
|
154
|
-
clearTimeout(
|
|
154
|
+
clearTimeout(a);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
async function
|
|
158
|
-
const t = e.endpoint ??
|
|
157
|
+
async function q(e) {
|
|
158
|
+
const t = e.endpoint ?? W, n = e.timeoutMs ?? _, r = A(e.fetchImpl), o = new AbortController(), s = setTimeout(() => o.abort(), n);
|
|
159
159
|
try {
|
|
160
|
-
const
|
|
160
|
+
const a = e.handle ? { handle: e.handle } : void 0, i = {
|
|
161
161
|
...e.sessionId ? { sessionId: e.sessionId } : {},
|
|
162
162
|
...e.web5Id ? { parentMessageId: e.web5Id } : {},
|
|
163
|
-
placement:
|
|
164
|
-
...
|
|
165
|
-
}, c = await
|
|
163
|
+
placement: K,
|
|
164
|
+
...a ? { additionalData: a } : {}
|
|
165
|
+
}, c = await r(t, {
|
|
166
166
|
method: "POST",
|
|
167
167
|
headers: {
|
|
168
168
|
"Content-Type": "application/json",
|
|
169
169
|
Accept: "text/event-stream"
|
|
170
170
|
},
|
|
171
171
|
body: JSON.stringify(i),
|
|
172
|
-
signal:
|
|
172
|
+
signal: o.signal
|
|
173
173
|
});
|
|
174
174
|
if (!c.ok)
|
|
175
175
|
throw new Error(`HTTP ${c.status}`);
|
|
176
176
|
const u = await c.text();
|
|
177
|
-
return
|
|
177
|
+
return J(j(u));
|
|
178
178
|
} finally {
|
|
179
|
-
clearTimeout(
|
|
179
|
+
clearTimeout(s);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function A(e) {
|
|
183
183
|
return e || (typeof window < "u" ? fetch.bind(window) : fetch);
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function j(e) {
|
|
186
186
|
let t = e.trim();
|
|
187
187
|
if (!t) return "";
|
|
188
188
|
t.endsWith(",") && (t = t.slice(0, -1)), t.startsWith("[") || (t = `[${t}`), t.endsWith("]") || (t += "]");
|
|
189
189
|
try {
|
|
190
190
|
const n = JSON.parse(t);
|
|
191
191
|
if (!Array.isArray(n)) return "";
|
|
192
|
-
const
|
|
193
|
-
(
|
|
192
|
+
const r = n.find(
|
|
193
|
+
(o) => typeof o?.completed?.markdown == "string"
|
|
194
194
|
)?.completed?.markdown;
|
|
195
|
-
return
|
|
195
|
+
return r || n.map((o) => typeof o?.markdown == "string" ? o.markdown : "").join("");
|
|
196
196
|
} catch {
|
|
197
197
|
return "";
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
function
|
|
200
|
+
function J(e) {
|
|
201
201
|
const t = e.trim().replace(/^```(?:json)?\s*/i, "").replace(/\s*```$/, "").trim();
|
|
202
202
|
if (!t) return [];
|
|
203
203
|
try {
|
|
204
|
-
return JSON.parse(t).chips?.map((
|
|
204
|
+
return JSON.parse(t).chips?.map((r) => r.label).filter(Boolean) ?? [];
|
|
205
205
|
} catch {
|
|
206
206
|
return [];
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function ue(e) {
|
|
210
210
|
if (e instanceof HTMLElement) return e;
|
|
211
211
|
if (typeof e == "string") {
|
|
212
|
-
const
|
|
213
|
-
if (!
|
|
212
|
+
const r = document.querySelector(e);
|
|
213
|
+
if (!r)
|
|
214
214
|
throw new Error(`[Web5Embed] Target element not found: ${e}`);
|
|
215
|
-
return
|
|
215
|
+
return r;
|
|
216
216
|
}
|
|
217
217
|
const t = document.currentScript, n = document.createElement("div");
|
|
218
218
|
return t?.parentElement ? t.parentElement.insertBefore(n, t) : document.body.appendChild(n), n;
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function le(e) {
|
|
221
221
|
return e ? new URLSearchParams(window.location.search).has(e) : !0;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function de(e, t = []) {
|
|
224
224
|
return !(Array.isArray(e) ? e : e != null ? [e] : t).includes(window.location.pathname);
|
|
225
225
|
}
|
|
226
|
-
function
|
|
226
|
+
function X(e) {
|
|
227
227
|
if (!e) return {};
|
|
228
228
|
const t = {}, n = e.getAttribute("data-target");
|
|
229
229
|
n && (t.target = n);
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
if (
|
|
230
|
+
const r = e.getAttribute("data-placeholder");
|
|
231
|
+
r && (t.placeholder = r);
|
|
232
|
+
const o = e.getAttribute("data-base-url");
|
|
233
|
+
o && (t.baseUrl = o);
|
|
234
|
+
const s = e.getAttribute("data-require-param");
|
|
235
|
+
s && (t.requireParam = s);
|
|
236
|
+
const a = e.getAttribute("data-suggestions");
|
|
237
|
+
if (a)
|
|
238
238
|
try {
|
|
239
|
-
const i = JSON.parse(
|
|
239
|
+
const i = JSON.parse(a);
|
|
240
240
|
Array.isArray(i) && i.length && (t.suggestions = i);
|
|
241
241
|
} catch {
|
|
242
242
|
console.warn("[Web5Embed] Invalid data-suggestions JSON, ignoring.");
|
|
243
243
|
}
|
|
244
244
|
return t;
|
|
245
245
|
}
|
|
246
|
-
function
|
|
247
|
-
const t =
|
|
246
|
+
function fe(e) {
|
|
247
|
+
const t = X(e);
|
|
248
248
|
if (!e) return t;
|
|
249
249
|
const n = e.getAttribute("data-visibility-mode");
|
|
250
250
|
(n === "always" || n === "after-target") && (t.visibilityMode = n);
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
const
|
|
254
|
-
return
|
|
251
|
+
const r = e.getAttribute("data-show-after-target");
|
|
252
|
+
r && (t.showAfterTarget = r);
|
|
253
|
+
const o = e.getAttribute("data-exclude-paths");
|
|
254
|
+
return o && (t.excludePaths = o.includes(",") ? o.split(",").map((s) => s.trim()) : o), t;
|
|
255
255
|
}
|
|
256
|
-
function
|
|
256
|
+
function we(e) {
|
|
257
257
|
if (typeof window > "u") return;
|
|
258
258
|
const t = window.__web5Loader__;
|
|
259
259
|
if (!t) {
|
|
@@ -262,63 +262,63 @@ function ne(e) {
|
|
|
262
262
|
);
|
|
263
263
|
return;
|
|
264
264
|
}
|
|
265
|
-
const n = async (
|
|
265
|
+
const n = async (r) => e.mount(r, e.parseOptions(r.options));
|
|
266
266
|
t.register(e.widgetId, n);
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function me(e) {
|
|
269
269
|
return (t, n) => {
|
|
270
|
-
const
|
|
271
|
-
if (!
|
|
270
|
+
const r = n.variant;
|
|
271
|
+
if (!r || r === "default")
|
|
272
272
|
return e.default(t, n);
|
|
273
|
-
const
|
|
274
|
-
return
|
|
275
|
-
`[Web5Embed] unknown variant "${
|
|
273
|
+
const o = e.variants?.[r];
|
|
274
|
+
return o ? o(t, n) : (console.warn(
|
|
275
|
+
`[Web5Embed] unknown variant "${r}" — falling back to default`
|
|
276
276
|
), e.default(t, n));
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
|
-
function
|
|
279
|
+
function pe(e) {
|
|
280
280
|
const t = (n) => e?.[n];
|
|
281
281
|
return {
|
|
282
282
|
isEnabled: (n) => {
|
|
283
|
-
const
|
|
284
|
-
return
|
|
283
|
+
const r = t(n);
|
|
284
|
+
return r?.status === "SUCCESSFUL" && r.enabled === !0;
|
|
285
285
|
},
|
|
286
286
|
get: t
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function he(e) {
|
|
290
290
|
const {
|
|
291
291
|
input: t,
|
|
292
292
|
wrapper: n,
|
|
293
|
-
multilineClass:
|
|
294
|
-
maxHeightPx:
|
|
295
|
-
multilineThresholdMultiplier:
|
|
296
|
-
fallbackLineHeightPx:
|
|
293
|
+
multilineClass: r,
|
|
294
|
+
maxHeightPx: o,
|
|
295
|
+
multilineThresholdMultiplier: s = 1,
|
|
296
|
+
fallbackLineHeightPx: a = 32
|
|
297
297
|
} = e;
|
|
298
298
|
return {
|
|
299
299
|
sync() {
|
|
300
300
|
if (!n) return;
|
|
301
|
-
const i = window.getComputedStyle(t), c = Number.parseFloat(i.lineHeight) ||
|
|
301
|
+
const i = window.getComputedStyle(t), c = Number.parseFloat(i.lineHeight) || a;
|
|
302
302
|
t.style.height = "auto";
|
|
303
|
-
const u = t.value.trim().length === 0 ? c : Math.min(Math.max(t.scrollHeight, c),
|
|
303
|
+
const u = t.value.trim().length === 0 ? c : Math.min(Math.max(t.scrollHeight, c), o);
|
|
304
304
|
t.style.height = `${u}px`, n.classList.toggle(
|
|
305
|
-
|
|
306
|
-
u > c *
|
|
305
|
+
r,
|
|
306
|
+
u > c * s
|
|
307
307
|
);
|
|
308
308
|
}
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
|
-
const
|
|
312
|
-
function
|
|
313
|
-
const t = e.thresholdPx ??
|
|
311
|
+
const Y = 400;
|
|
312
|
+
function ge(e = {}) {
|
|
313
|
+
const t = e.thresholdPx ?? Y;
|
|
314
314
|
let n = !1;
|
|
315
|
-
function
|
|
316
|
-
const
|
|
317
|
-
return
|
|
315
|
+
function r() {
|
|
316
|
+
const o = document.documentElement, s = window.scrollY || o.scrollTop || 0, a = s + window.innerHeight, i = o.scrollHeight - a;
|
|
317
|
+
return o.scrollHeight > window.innerHeight + t && s > 0 && i <= t;
|
|
318
318
|
}
|
|
319
319
|
return {
|
|
320
|
-
evaluate(
|
|
321
|
-
return !
|
|
320
|
+
evaluate(o) {
|
|
321
|
+
return !o.isCoordinatorVisible() || !r() ? (n = !1, !1) : o.hasFocusInside() || n ? o.isCollapsed() : !0;
|
|
322
322
|
},
|
|
323
323
|
markManuallyExpanded() {
|
|
324
324
|
n = !0;
|
|
@@ -328,90 +328,128 @@ function se(e = {}) {
|
|
|
328
328
|
}
|
|
329
329
|
};
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function be(e) {
|
|
332
332
|
if (!e.baseUrl)
|
|
333
333
|
throw new Error(
|
|
334
334
|
"[Web5Embed] createSubmitFlow requires a non-empty baseUrl."
|
|
335
335
|
);
|
|
336
|
-
const t =
|
|
336
|
+
const t = B(e.baseUrl), n = e.windowTarget ?? "_self";
|
|
337
337
|
return {
|
|
338
|
-
open(
|
|
339
|
-
return window.open(t + encodeURIComponent(
|
|
338
|
+
open(r) {
|
|
339
|
+
return window.open(t + encodeURIComponent(r), n), !0;
|
|
340
340
|
}
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
|
-
const
|
|
344
|
-
function
|
|
343
|
+
const z = 100, G = 0.5, Z = 250, Q = 10, ee = 60, te = "--web5-host-bottom-inset";
|
|
344
|
+
function y() {
|
|
345
|
+
if (typeof document > "u" || typeof window > "u")
|
|
346
|
+
return [];
|
|
347
|
+
const e = [];
|
|
348
|
+
return document.body?.querySelectorAll("*").forEach((t) => {
|
|
349
|
+
const n = window.getComputedStyle(t).position;
|
|
350
|
+
(n === "fixed" || n === "sticky") && e.push(t);
|
|
351
|
+
}), e;
|
|
352
|
+
}
|
|
353
|
+
function ne(e, t) {
|
|
345
354
|
if (typeof document > "u" || typeof window > "u")
|
|
346
355
|
return 0;
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
for (const o of t) {
|
|
352
|
-
if (e != null && (e.contains(o) || o.contains(e)))
|
|
356
|
+
const n = t ?? y(), r = window.innerWidth / 2;
|
|
357
|
+
let o = 0;
|
|
358
|
+
for (const s of n) {
|
|
359
|
+
if (e != null && (e.contains(s) || s.contains(e)))
|
|
353
360
|
continue;
|
|
354
|
-
const
|
|
355
|
-
if (
|
|
361
|
+
const a = window.getComputedStyle(s);
|
|
362
|
+
if (a.position !== "fixed" && a.position !== "sticky" || a.visibility === "hidden" || a.bottom === "auto")
|
|
356
363
|
continue;
|
|
357
|
-
const
|
|
358
|
-
if (!Number.isFinite(
|
|
364
|
+
const i = Number.parseFloat(a.bottom);
|
|
365
|
+
if (!Number.isFinite(i) || i > z)
|
|
359
366
|
continue;
|
|
360
|
-
const
|
|
361
|
-
if (
|
|
367
|
+
const c = s.getBoundingClientRect();
|
|
368
|
+
if (c.height <= 0 || c.left > r || c.right < r)
|
|
362
369
|
continue;
|
|
363
|
-
const
|
|
364
|
-
|
|
370
|
+
const u = window.innerHeight - c.top;
|
|
371
|
+
u <= 0 || u > window.innerHeight * G || (o = Math.max(o, u));
|
|
365
372
|
}
|
|
366
|
-
return Math.round(
|
|
373
|
+
return Math.round(o);
|
|
367
374
|
}
|
|
368
|
-
function
|
|
375
|
+
function ye(e, t = {}) {
|
|
369
376
|
if (typeof window > "u")
|
|
370
377
|
return () => {
|
|
371
378
|
};
|
|
372
379
|
const n = t.exclude === void 0 ? e : t.exclude;
|
|
373
|
-
let o = 0,
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
380
|
+
let r = y(), o = null, s = 0, a = !1, i = 0, c = 0, u = 0, p = 0, d = !1;
|
|
381
|
+
const h = () => {
|
|
382
|
+
const l = ne(n, r);
|
|
383
|
+
return l === o ? !1 : (o = l, e.style.setProperty(te, `${l}px`), !0);
|
|
384
|
+
}, f = () => {
|
|
385
|
+
if (s = 0, d) {
|
|
386
|
+
a = !1;
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
if (i = h() ? 0 : i + 1, c -= 1, i >= Q || c <= 0) {
|
|
390
|
+
a = !1;
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
s = window.requestAnimationFrame(f);
|
|
394
|
+
}, g = () => {
|
|
395
|
+
d || (i = 0, c = ee, !a && (a = !0, s = window.requestAnimationFrame(f)));
|
|
396
|
+
}, E = () => {
|
|
397
|
+
u = 0, !d && (p = Date.now(), r = y(), g());
|
|
398
|
+
}, I = () => {
|
|
399
|
+
if (d || u !== 0)
|
|
400
|
+
return;
|
|
401
|
+
const l = Z - (Date.now() - p);
|
|
402
|
+
if (l <= 0) {
|
|
403
|
+
E();
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
u = window.setTimeout(E, l);
|
|
407
|
+
}, w = () => {
|
|
408
|
+
g(), I();
|
|
378
409
|
};
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
410
|
+
h(), g(), window.addEventListener("resize", w, { passive: !0 }), window.addEventListener("orientationchange", w, { passive: !0 });
|
|
411
|
+
const k = (l) => n != null && l.every((C) => C.target instanceof Node && n.contains(C.target));
|
|
412
|
+
let b;
|
|
413
|
+
return typeof MutationObserver < "u" && document.body != null && (b = new MutationObserver((l) => {
|
|
414
|
+
k(l) || w();
|
|
415
|
+
}), b.observe(document.body, {
|
|
416
|
+
childList: !0,
|
|
417
|
+
subtree: !0,
|
|
418
|
+
attributes: !0
|
|
419
|
+
})), () => {
|
|
420
|
+
d = !0, a && (window.cancelAnimationFrame(s), a = !1, s = 0), u !== 0 && (window.clearTimeout(u), u = 0), window.removeEventListener("resize", w), window.removeEventListener("orientationchange", w), b?.disconnect();
|
|
383
421
|
};
|
|
384
422
|
}
|
|
385
423
|
export {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
424
|
+
H as DEFAULT_STATIC_VERSIONS_URL,
|
|
425
|
+
te as HOST_BOTTOM_INSET_VAR,
|
|
426
|
+
oe as __resetFocusShortcutCoordinatorForTests,
|
|
427
|
+
ie as attachPromptInputTokensStylesheet,
|
|
428
|
+
B as buildUrl,
|
|
429
|
+
U as cacheVersions,
|
|
430
|
+
ge as createCollapseController,
|
|
431
|
+
pe as createFeatureToggleReader,
|
|
432
|
+
he as createInputHeightSync,
|
|
433
|
+
be as createSubmitFlow,
|
|
434
|
+
me as createVariantMount,
|
|
435
|
+
ae as escapeHtml,
|
|
436
|
+
ce as fetchChipSuggestions,
|
|
437
|
+
q as fetchContextualChips,
|
|
438
|
+
O as fetchStaticVersions,
|
|
439
|
+
v as findVersion,
|
|
440
|
+
P as getCachedVersions,
|
|
441
|
+
re as getFocusShortcutCoordinator,
|
|
442
|
+
R as getPromptInputTokensUrl,
|
|
443
|
+
ne as measureHostBottomInset,
|
|
444
|
+
X as readBaseConfigFromScript,
|
|
445
|
+
fe as readBottomConfigFromScript,
|
|
446
|
+
we as registerWeb5Widget,
|
|
447
|
+
D as resolvePromptInputTokensUrl,
|
|
448
|
+
V as resolvePromptInputTokensVersion,
|
|
449
|
+
ue as resolveTarget,
|
|
450
|
+
se as sendIconSvg,
|
|
451
|
+
le as shouldInit,
|
|
452
|
+
de as shouldInitForPath,
|
|
453
|
+
ye as trackHostBottomInset
|
|
416
454
|
};
|
|
417
455
|
//# sourceMappingURL=index.js.map
|