@flowengage/react-chatbot 1.0.9 → 1.1.1
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.
|
@@ -171,12 +171,14 @@ var d = Object.defineProperty, f = (e, t) => {
|
|
|
171
171
|
body: JSON.stringify({ session_id: e })
|
|
172
172
|
});
|
|
173
173
|
},
|
|
174
|
-
async syncVoice(e,
|
|
174
|
+
async syncVoice(e, r) {
|
|
175
175
|
return i("/api/ai/voice/sync", {
|
|
176
176
|
method: "POST",
|
|
177
177
|
body: JSON.stringify({
|
|
178
178
|
session_id: e,
|
|
179
|
-
messages:
|
|
179
|
+
messages: r,
|
|
180
|
+
...t ? { userId: String(t) } : {},
|
|
181
|
+
...n ? { siteId: String(n) } : {}
|
|
180
182
|
})
|
|
181
183
|
});
|
|
182
184
|
},
|
|
@@ -264,13 +266,15 @@ var d = Object.defineProperty, f = (e, t) => {
|
|
|
264
266
|
site_id: n
|
|
265
267
|
});
|
|
266
268
|
},
|
|
267
|
-
beaconSyncVoice(
|
|
269
|
+
beaconSyncVoice(r, i) {
|
|
268
270
|
if (typeof navigator > "u" || !navigator.sendBeacon) return !1;
|
|
269
|
-
let
|
|
270
|
-
session_id:
|
|
271
|
-
messages:
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
let a = {
|
|
272
|
+
session_id: r,
|
|
273
|
+
messages: i,
|
|
274
|
+
...t ? { userId: String(t) } : {},
|
|
275
|
+
...n ? { siteId: String(n) } : {}
|
|
276
|
+
}, o = new Blob([JSON.stringify(a)], { type: "application/json" });
|
|
277
|
+
return navigator.sendBeacon(`${e}/api/ai/voice/sync`, o);
|
|
274
278
|
}
|
|
275
279
|
};
|
|
276
280
|
}, y = Object.create(null);
|
|
@@ -2423,8 +2427,8 @@ function vn({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2423
2427
|
};
|
|
2424
2428
|
}, [c, r]), i(() => () => {
|
|
2425
2429
|
if (x && !ct.current && st.current.length > 0) {
|
|
2426
|
-
let e = T.current, t = st.current, n = w.current
|
|
2427
|
-
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(
|
|
2430
|
+
let e = T.current, t = st.current, n = w.current;
|
|
2431
|
+
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), ct.current = !0);
|
|
2428
2432
|
}
|
|
2429
2433
|
}, [x, _]), i(() => {
|
|
2430
2434
|
if (!w.current || !v || d !== "ready" || he) return;
|
|
@@ -22133,19 +22137,30 @@ function tg(e) {
|
|
|
22133
22137
|
}
|
|
22134
22138
|
//#endregion
|
|
22135
22139
|
//#region src/utils/voiceClientTools.js
|
|
22140
|
+
function ng(e) {
|
|
22141
|
+
return (...t) => {
|
|
22142
|
+
try {
|
|
22143
|
+
let n = e(...t);
|
|
22144
|
+
return n instanceof Promise ? n.catch(() => {}) : n;
|
|
22145
|
+
} catch {
|
|
22146
|
+
return;
|
|
22147
|
+
}
|
|
22148
|
+
};
|
|
22149
|
+
}
|
|
22150
|
+
var rg = ng(Ih), ig = ng(Lh), ag = ng(Vh), og = ng(Hh), sg = ng(Wh), cg = ng(Gh), lg = ng(Uh), ug = ng(Xh), dg = ng(Zh), fg = ng(Qh), pg = ng($h);
|
|
22136
22151
|
function $(...e) {
|
|
22137
22152
|
Zt() && console.log("[FlowEngage:voice-tools]", ...e);
|
|
22138
22153
|
}
|
|
22139
|
-
var
|
|
22140
|
-
function
|
|
22154
|
+
var mg = "#flowengage-root, .flowengage-shell";
|
|
22155
|
+
function hg(e) {
|
|
22141
22156
|
if (!e || typeof e.closest != "function") return !1;
|
|
22142
22157
|
try {
|
|
22143
|
-
return !!e.closest(
|
|
22158
|
+
return !!e.closest(mg);
|
|
22144
22159
|
} catch {
|
|
22145
22160
|
return !1;
|
|
22146
22161
|
}
|
|
22147
22162
|
}
|
|
22148
|
-
function
|
|
22163
|
+
function gg(e) {
|
|
22149
22164
|
if (!e) return null;
|
|
22150
22165
|
try {
|
|
22151
22166
|
return e.closest("form");
|
|
@@ -22158,7 +22173,7 @@ function ig(e) {
|
|
|
22158
22173
|
return null;
|
|
22159
22174
|
}
|
|
22160
22175
|
}
|
|
22161
|
-
function
|
|
22176
|
+
function _g(e) {
|
|
22162
22177
|
if (!e) return null;
|
|
22163
22178
|
let t = e.querySelector("h1, h2, h3, h4, h5, legend");
|
|
22164
22179
|
if (t) return t.textContent.replace(/\s+/g, " ").trim().slice(0, 60);
|
|
@@ -22173,30 +22188,30 @@ function ag(e) {
|
|
|
22173
22188
|
}
|
|
22174
22189
|
return null;
|
|
22175
22190
|
}
|
|
22176
|
-
function
|
|
22191
|
+
function vg(e) {
|
|
22177
22192
|
try {
|
|
22178
22193
|
let t = e.ownerDocument?.defaultView;
|
|
22179
22194
|
if (t) return t.getComputedStyle(e);
|
|
22180
22195
|
} catch {}
|
|
22181
22196
|
return window.getComputedStyle(e);
|
|
22182
22197
|
}
|
|
22183
|
-
function
|
|
22198
|
+
function yg(e) {
|
|
22184
22199
|
let t = /* @__PURE__ */ new Set();
|
|
22185
22200
|
function n(r) {
|
|
22186
22201
|
if (!r || t.has(r)) return;
|
|
22187
22202
|
t.add(r), e(r);
|
|
22188
22203
|
let i = r.querySelectorAll("iframe");
|
|
22189
|
-
for (let e of i) if (!
|
|
22204
|
+
for (let e of i) if (!hg(e)) try {
|
|
22190
22205
|
let t = e.contentDocument;
|
|
22191
22206
|
t && n(t);
|
|
22192
22207
|
} catch {}
|
|
22193
22208
|
}
|
|
22194
22209
|
typeof document < "u" && n(document);
|
|
22195
22210
|
}
|
|
22196
|
-
function
|
|
22211
|
+
function bg(e) {
|
|
22197
22212
|
return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
|
|
22198
22213
|
}
|
|
22199
|
-
function
|
|
22214
|
+
function xg(e) {
|
|
22200
22215
|
let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
|
|
22201
22216
|
if (n) {
|
|
22202
22217
|
let e = n.trim().split(/\s+/).filter(Boolean), r = [];
|
|
@@ -22204,42 +22219,42 @@ function lg(e) {
|
|
|
22204
22219
|
let e = t.getElementById(n);
|
|
22205
22220
|
e?.textContent && r.push(e.textContent.trim());
|
|
22206
22221
|
} catch {}
|
|
22207
|
-
if (r.length) return
|
|
22222
|
+
if (r.length) return bg(r.join(" "));
|
|
22208
22223
|
}
|
|
22209
|
-
if (e.labels && e.labels.length) return
|
|
22224
|
+
if (e.labels && e.labels.length) return bg(e.labels[0].textContent);
|
|
22210
22225
|
let r = e.id;
|
|
22211
22226
|
if (r) try {
|
|
22212
22227
|
let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
|
|
22213
|
-
if (e) return
|
|
22228
|
+
if (e) return bg(e.textContent);
|
|
22214
22229
|
} catch {
|
|
22215
22230
|
let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
|
|
22216
|
-
if (e) return
|
|
22231
|
+
if (e) return bg(e.textContent);
|
|
22217
22232
|
}
|
|
22218
22233
|
let i = e.previousElementSibling;
|
|
22219
22234
|
for (let e = 0; e < 6 && i; e += 1) {
|
|
22220
|
-
if (i.tagName === "LABEL") return
|
|
22235
|
+
if (i.tagName === "LABEL") return bg(i.textContent);
|
|
22221
22236
|
let e = (i.className || "").toString().toLowerCase();
|
|
22222
22237
|
if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
|
|
22223
|
-
let e =
|
|
22238
|
+
let e = bg(i.textContent);
|
|
22224
22239
|
if (e) return e;
|
|
22225
22240
|
}
|
|
22226
22241
|
i = i.previousElementSibling;
|
|
22227
22242
|
}
|
|
22228
22243
|
let a = e.parentElement;
|
|
22229
22244
|
for (let e = 0; e < 5 && a; e += 1) {
|
|
22230
|
-
if (a.tagName === "LABEL") return
|
|
22245
|
+
if (a.tagName === "LABEL") return bg(a.textContent);
|
|
22231
22246
|
let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
|
|
22232
|
-
if (e?.textContent) return
|
|
22247
|
+
if (e?.textContent) return bg(e.textContent);
|
|
22233
22248
|
a = a.parentElement;
|
|
22234
22249
|
}
|
|
22235
22250
|
let o = e.getAttribute("aria-label");
|
|
22236
|
-
return o ?
|
|
22251
|
+
return o ? bg(o) : null;
|
|
22237
22252
|
}
|
|
22238
|
-
function
|
|
22253
|
+
function Sg() {
|
|
22239
22254
|
let e = [];
|
|
22240
|
-
return
|
|
22255
|
+
return yg((t) => {
|
|
22241
22256
|
e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
|
|
22242
|
-
if (
|
|
22257
|
+
if (hg(e)) return !1;
|
|
22243
22258
|
let t = (e.type || "").toLowerCase();
|
|
22244
22259
|
if ([
|
|
22245
22260
|
"hidden",
|
|
@@ -22248,7 +22263,7 @@ function ug() {
|
|
|
22248
22263
|
"image"
|
|
22249
22264
|
].includes(t) || e.disabled || e.readOnly) return !1;
|
|
22250
22265
|
try {
|
|
22251
|
-
let t =
|
|
22266
|
+
let t = vg(e);
|
|
22252
22267
|
if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
|
|
22253
22268
|
} catch {}
|
|
22254
22269
|
try {
|
|
@@ -22258,32 +22273,32 @@ function ug() {
|
|
|
22258
22273
|
}));
|
|
22259
22274
|
}), e;
|
|
22260
22275
|
}
|
|
22261
|
-
function
|
|
22262
|
-
let e =
|
|
22276
|
+
function Cg() {
|
|
22277
|
+
let e = Sg(), t = /* @__PURE__ */ new Map(), n = 0;
|
|
22263
22278
|
return e.map((e, r) => {
|
|
22264
|
-
let i =
|
|
22279
|
+
let i = gg(e), a = i || "__orphan__";
|
|
22265
22280
|
t.has(a) || t.set(a, n++);
|
|
22266
22281
|
let o = t.get(a);
|
|
22267
22282
|
return {
|
|
22268
22283
|
formIndex: o,
|
|
22269
|
-
formName: (i ?
|
|
22284
|
+
formName: (i ? _g(i) : null) || `Form ${o}`,
|
|
22270
22285
|
fieldIndex: r,
|
|
22271
22286
|
tag: e.tagName,
|
|
22272
22287
|
type: e.type || "text",
|
|
22273
22288
|
name: e.name || null,
|
|
22274
22289
|
id: e.id || null,
|
|
22275
|
-
label:
|
|
22290
|
+
label: xg(e),
|
|
22276
22291
|
placeholder: e.placeholder || null
|
|
22277
22292
|
};
|
|
22278
22293
|
});
|
|
22279
22294
|
}
|
|
22280
|
-
function
|
|
22295
|
+
function wg() {
|
|
22281
22296
|
let e = [];
|
|
22282
|
-
return
|
|
22297
|
+
return yg((t) => {
|
|
22283
22298
|
e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
|
|
22284
|
-
if (
|
|
22299
|
+
if (hg(e) || e.disabled) return !1;
|
|
22285
22300
|
try {
|
|
22286
|
-
let t =
|
|
22301
|
+
let t = vg(e);
|
|
22287
22302
|
if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
|
|
22288
22303
|
} catch {}
|
|
22289
22304
|
return !0;
|
|
@@ -22295,15 +22310,15 @@ function fg() {
|
|
|
22295
22310
|
type: e.type || e.tagName
|
|
22296
22311
|
}));
|
|
22297
22312
|
}
|
|
22298
|
-
function
|
|
22313
|
+
function Tg(e) {
|
|
22299
22314
|
return String(e || "").toLowerCase().replace(/\u00a0/g, " ").replace(/\*/g, "").replace(/\s+/g, " ").trim();
|
|
22300
22315
|
}
|
|
22301
|
-
function
|
|
22302
|
-
let t =
|
|
22316
|
+
function Eg(e) {
|
|
22317
|
+
let t = Tg(e);
|
|
22303
22318
|
return t = t.replace(/\s+field\s*$/i, "").trim(), t;
|
|
22304
22319
|
}
|
|
22305
|
-
function
|
|
22306
|
-
let n =
|
|
22320
|
+
function Dg(e, t) {
|
|
22321
|
+
let n = Eg(t);
|
|
22307
22322
|
if (!n) return 0;
|
|
22308
22323
|
let r = (e.name || "").toLowerCase(), i = (e.id || "").toLowerCase();
|
|
22309
22324
|
if (r === "url" && /url|website|domain|site|audit/.test(n) || (i === "url-input" || i.endsWith("-url-input")) && /url|website|domain|site|audit/.test(n)) return 100;
|
|
@@ -22315,12 +22330,12 @@ function hg(e, t) {
|
|
|
22315
22330
|
e.name,
|
|
22316
22331
|
e.id,
|
|
22317
22332
|
e.placeholder,
|
|
22318
|
-
|
|
22333
|
+
xg(e),
|
|
22319
22334
|
e.getAttribute("aria-label"),
|
|
22320
22335
|
e.getAttribute("title"),
|
|
22321
22336
|
e.getAttribute("data-testid"),
|
|
22322
22337
|
e.getAttribute("autocomplete")
|
|
22323
|
-
].filter(Boolean).map((e) =>
|
|
22338
|
+
].filter(Boolean).map((e) => Tg(e)), s = 0;
|
|
22324
22339
|
for (let e of o) {
|
|
22325
22340
|
if (!e) continue;
|
|
22326
22341
|
if (e === n) {
|
|
@@ -22340,16 +22355,16 @@ function hg(e, t) {
|
|
|
22340
22355
|
}
|
|
22341
22356
|
return s;
|
|
22342
22357
|
}
|
|
22343
|
-
var
|
|
22344
|
-
function
|
|
22358
|
+
var Og = 22;
|
|
22359
|
+
function kg(e, t) {
|
|
22345
22360
|
let n = null, r = 0;
|
|
22346
22361
|
for (let i of e) {
|
|
22347
|
-
let e =
|
|
22362
|
+
let e = Dg(i, t);
|
|
22348
22363
|
e > r && (r = e, n = i);
|
|
22349
22364
|
}
|
|
22350
|
-
return !n || r <
|
|
22365
|
+
return !n || r < Og ? null : n;
|
|
22351
22366
|
}
|
|
22352
|
-
function
|
|
22367
|
+
function Ag(e, t, n) {
|
|
22353
22368
|
let r = String(t || "").toLowerCase().trim(), i = String(n || "").trim();
|
|
22354
22369
|
if (!(/^https?:\/\//i.test(i) || /\.\w{2,}(\/|\s|$)/.test(i) || r.includes("url") || r.includes("website") || r.includes("domain") || r.includes("site"))) return null;
|
|
22355
22370
|
let a = null, o = 0;
|
|
@@ -22369,7 +22384,7 @@ function vg(e, t, n) {
|
|
|
22369
22384
|
t.name,
|
|
22370
22385
|
t.id,
|
|
22371
22386
|
t.placeholder,
|
|
22372
|
-
|
|
22387
|
+
xg(t),
|
|
22373
22388
|
t.getAttribute("aria-label"),
|
|
22374
22389
|
t.getAttribute("autocomplete")
|
|
22375
22390
|
].filter(Boolean).join(" ").toLowerCase();
|
|
@@ -22377,15 +22392,15 @@ function vg(e, t, n) {
|
|
|
22377
22392
|
}
|
|
22378
22393
|
return !a || o < 42 ? null : a;
|
|
22379
22394
|
}
|
|
22380
|
-
function
|
|
22395
|
+
function jg(e) {
|
|
22381
22396
|
let t = String(e ?? "").trim();
|
|
22382
22397
|
return t ? /^https?:\/\//i.test(t) ? !0 : /\.\w{2,}(\/|\s|$)/.test(t) : !1;
|
|
22383
22398
|
}
|
|
22384
|
-
function
|
|
22399
|
+
function Mg(e) {
|
|
22385
22400
|
let t = String(e ?? "").toLowerCase().trim();
|
|
22386
22401
|
return t ? !!(t === "url" || t === "website" || t === "website url" || t === "website_url" || t === "enter website url" || t.includes("website") || t.includes("domain") || /(enter\s+website|site\s*url|page\s*url)/.test(t)) : !1;
|
|
22387
22402
|
}
|
|
22388
|
-
function
|
|
22403
|
+
function Ng(e) {
|
|
22389
22404
|
if (!e || e.tagName !== "INPUT" && e.tagName !== "TEXTAREA") return !1;
|
|
22390
22405
|
let t = (e.type || "").toLowerCase();
|
|
22391
22406
|
return ![
|
|
@@ -22397,22 +22412,22 @@ function xg(e) {
|
|
|
22397
22412
|
"file"
|
|
22398
22413
|
].includes(t);
|
|
22399
22414
|
}
|
|
22400
|
-
function
|
|
22401
|
-
if (!
|
|
22415
|
+
function Pg(e) {
|
|
22416
|
+
if (!Ng(e)) return !1;
|
|
22402
22417
|
let t = (e.name || "").toLowerCase(), n = (e.id || "").toLowerCase(), r = [
|
|
22403
22418
|
e.name,
|
|
22404
22419
|
e.id,
|
|
22405
22420
|
e.placeholder,
|
|
22406
|
-
|
|
22421
|
+
xg(e),
|
|
22407
22422
|
e.getAttribute("aria-label")
|
|
22408
22423
|
].filter(Boolean).join(" ").toLowerCase();
|
|
22409
22424
|
return t === "url" || n === "url-input" || n.endsWith("-url-input") || /(website\s*url|enter\s+website|site\s*url)/.test(r) || /(website|domain)/.test(r) && /(url|site)/.test(r);
|
|
22410
22425
|
}
|
|
22411
|
-
function
|
|
22412
|
-
let r = String(t ?? ""), i = String(n ?? ""), a =
|
|
22426
|
+
function Fg(e, t, n) {
|
|
22427
|
+
let r = String(t ?? ""), i = String(n ?? ""), a = Rg(e, r) || kg(e, r) || Ag(e, r, i);
|
|
22413
22428
|
if (!a) return [];
|
|
22414
22429
|
let o = new Set([a]);
|
|
22415
|
-
if (
|
|
22430
|
+
if (jg(i) && Mg(r)) for (let t of e) t !== a && Pg(t) && o.add(t);
|
|
22416
22431
|
let s = Array.from(o);
|
|
22417
22432
|
return s.sort((e, t) => {
|
|
22418
22433
|
if (e === t) return 0;
|
|
@@ -22420,7 +22435,7 @@ function Cg(e, t, n) {
|
|
|
22420
22435
|
return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
|
|
22421
22436
|
}), s;
|
|
22422
22437
|
}
|
|
22423
|
-
function
|
|
22438
|
+
function Ig(e, t) {
|
|
22424
22439
|
try {
|
|
22425
22440
|
if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
|
|
22426
22441
|
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
|
|
@@ -22435,17 +22450,17 @@ function wg(e, t) {
|
|
|
22435
22450
|
return Infinity;
|
|
22436
22451
|
}
|
|
22437
22452
|
}
|
|
22438
|
-
function
|
|
22453
|
+
function Lg(e) {
|
|
22439
22454
|
if (!e || typeof e != "string") return null;
|
|
22440
22455
|
let t = null;
|
|
22441
|
-
return
|
|
22456
|
+
return yg((n) => {
|
|
22442
22457
|
try {
|
|
22443
22458
|
let r = n.getElementById(e);
|
|
22444
|
-
r && !
|
|
22459
|
+
r && !hg(r) && r.matches?.("input, select, textarea") && (t = r);
|
|
22445
22460
|
} catch {}
|
|
22446
22461
|
}), t;
|
|
22447
22462
|
}
|
|
22448
|
-
function
|
|
22463
|
+
function Rg(e, t) {
|
|
22449
22464
|
let n = String(t ?? "").trim();
|
|
22450
22465
|
if (!n) return null;
|
|
22451
22466
|
let r = n.match(/^name:\s*([\w.-]+)$/i);
|
|
@@ -22455,12 +22470,12 @@ function Eg(e, t) {
|
|
|
22455
22470
|
}
|
|
22456
22471
|
let i = n.match(/^id:\s*([\w.-]+)$/i);
|
|
22457
22472
|
if (i) {
|
|
22458
|
-
let e =
|
|
22473
|
+
let e = Lg(i[1]);
|
|
22459
22474
|
if (e) return e;
|
|
22460
22475
|
}
|
|
22461
22476
|
let a = n.startsWith("#") ? n.slice(1) : n;
|
|
22462
22477
|
if (/^[\w-]+$/.test(a)) {
|
|
22463
|
-
let e =
|
|
22478
|
+
let e = Lg(a);
|
|
22464
22479
|
if (e) return e;
|
|
22465
22480
|
}
|
|
22466
22481
|
let o = n.toLowerCase().replace(/\s+/g, " ");
|
|
@@ -22470,7 +22485,7 @@ function Eg(e, t) {
|
|
|
22470
22485
|
}
|
|
22471
22486
|
return null;
|
|
22472
22487
|
}
|
|
22473
|
-
function
|
|
22488
|
+
function zg(e, t) {
|
|
22474
22489
|
let n = String(t || "").toLowerCase().trim();
|
|
22475
22490
|
if (!n) return 0;
|
|
22476
22491
|
let r = [
|
|
@@ -22487,13 +22502,13 @@ function Dg(e, t) {
|
|
|
22487
22502
|
for (let e of i) r.includes(e) && (a += 1);
|
|
22488
22503
|
return a / i.length * 92;
|
|
22489
22504
|
}
|
|
22490
|
-
function
|
|
22505
|
+
function Bg(e, t) {
|
|
22491
22506
|
let n = [];
|
|
22492
|
-
|
|
22507
|
+
yg((e) => {
|
|
22493
22508
|
n.push(...Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
|
|
22494
|
-
if (
|
|
22509
|
+
if (hg(e) || e.disabled) return !1;
|
|
22495
22510
|
try {
|
|
22496
|
-
let t =
|
|
22511
|
+
let t = vg(e);
|
|
22497
22512
|
if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
|
|
22498
22513
|
} catch {}
|
|
22499
22514
|
return !0;
|
|
@@ -22501,7 +22516,7 @@ function Og(e, t) {
|
|
|
22501
22516
|
});
|
|
22502
22517
|
let r = 0, i = n.map((t) => ({
|
|
22503
22518
|
el: t,
|
|
22504
|
-
s:
|
|
22519
|
+
s: zg(t, e)
|
|
22505
22520
|
}));
|
|
22506
22521
|
for (let { s: e } of i) e > r && (r = e);
|
|
22507
22522
|
if (r < 36) return null;
|
|
@@ -22511,14 +22526,14 @@ function Og(e, t) {
|
|
|
22511
22526
|
if (o.length) {
|
|
22512
22527
|
let e = a[0], t = Infinity;
|
|
22513
22528
|
for (let n of a) for (let r of o) {
|
|
22514
|
-
let i =
|
|
22529
|
+
let i = Ig(n, r);
|
|
22515
22530
|
i < t && (t = i, e = n);
|
|
22516
22531
|
}
|
|
22517
22532
|
return e;
|
|
22518
22533
|
}
|
|
22519
22534
|
return a[0];
|
|
22520
22535
|
}
|
|
22521
|
-
function
|
|
22536
|
+
function Vg(e) {
|
|
22522
22537
|
if (e == null) return {};
|
|
22523
22538
|
if (typeof e == "string") {
|
|
22524
22539
|
let t = e.trim();
|
|
@@ -22531,8 +22546,8 @@ function kg(e) {
|
|
|
22531
22546
|
}
|
|
22532
22547
|
return e;
|
|
22533
22548
|
}
|
|
22534
|
-
function
|
|
22535
|
-
let t =
|
|
22549
|
+
function Hg(e) {
|
|
22550
|
+
let t = Vg(e);
|
|
22536
22551
|
if (Array.isArray(t) && t.length > 0) {
|
|
22537
22552
|
let e = t[0];
|
|
22538
22553
|
if (e?.field_key != null || e?.fieldKey != null) return t.map((e) => ({
|
|
@@ -22560,12 +22575,12 @@ function Ag(e) {
|
|
|
22560
22575
|
value: e?.value ?? e?.Value
|
|
22561
22576
|
})) : [];
|
|
22562
22577
|
}
|
|
22563
|
-
function
|
|
22578
|
+
function Ug(e) {
|
|
22564
22579
|
if (!e || typeof e != "string") return e;
|
|
22565
22580
|
let t = e.trim();
|
|
22566
22581
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t) ? t : (t = t.replace(/\s+at\s+the\s+rate\s*(of)?\s+/gi, "@"), t = t.replace(/\s+at\s+/gi, "@"), t = t.replace(/\s+dot\s+/gi, "."), t = t.replace(/\s+/g, ""), t = t.replace(/\.{2,}/g, ".").replace(/\.$/, ""), t);
|
|
22567
22582
|
}
|
|
22568
|
-
function
|
|
22583
|
+
function Wg(e) {
|
|
22569
22584
|
if (!e || typeof e != "string") return e;
|
|
22570
22585
|
let t = {
|
|
22571
22586
|
zero: "0",
|
|
@@ -22584,7 +22599,7 @@ function Mg(e) {
|
|
|
22584
22599
|
for (let [e, r] of Object.entries(t)) n = n.replace(RegExp(`\\b${e}\\b`, "g"), r);
|
|
22585
22600
|
return n = n.replace(/[^\d+]/g, ""), n;
|
|
22586
22601
|
}
|
|
22587
|
-
function
|
|
22602
|
+
function Gg(e) {
|
|
22588
22603
|
if (!e || typeof e != "string") return [];
|
|
22589
22604
|
let t = e.trim();
|
|
22590
22605
|
if (!t || /\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t)) return [];
|
|
@@ -22603,7 +22618,7 @@ function Ng(e) {
|
|
|
22603
22618
|
}
|
|
22604
22619
|
return [];
|
|
22605
22620
|
}
|
|
22606
|
-
function
|
|
22621
|
+
function Kg(e) {
|
|
22607
22622
|
if (!e || typeof e != "string") return [];
|
|
22608
22623
|
let t = e.trim();
|
|
22609
22624
|
if (!t) return [];
|
|
@@ -22615,7 +22630,7 @@ function Pg(e) {
|
|
|
22615
22630
|
field_key: e,
|
|
22616
22631
|
value: i
|
|
22617
22632
|
}));
|
|
22618
|
-
}, o =
|
|
22633
|
+
}, o = Ug(t), s = i.test(o), c = o.match(/^\s*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\s*$/i);
|
|
22619
22634
|
if (c) return a("Email Address", c[1]), n;
|
|
22620
22635
|
if (!i.test(t) && s) {
|
|
22621
22636
|
let e = o.match(i);
|
|
@@ -22643,17 +22658,17 @@ function Pg(e) {
|
|
|
22643
22658
|
}
|
|
22644
22659
|
return n;
|
|
22645
22660
|
}
|
|
22646
|
-
function
|
|
22661
|
+
function qg(e) {
|
|
22647
22662
|
if (!e || typeof e != "object") return null;
|
|
22648
22663
|
let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
|
|
22649
22664
|
return t == null ? null : String(t).trim() || null;
|
|
22650
22665
|
}
|
|
22651
|
-
function
|
|
22666
|
+
function Jg(e) {
|
|
22652
22667
|
if (!e || typeof e != "object") return null;
|
|
22653
|
-
let t = e.query ?? e.q ?? e.search ?? e.text ?? e.keywords;
|
|
22668
|
+
let t = e.query ?? e.q ?? e.search ?? e.text ?? e.keywords ?? e.search_query ?? e.searchQuery ?? e.question ?? e.prompt ?? e.topic ?? e.intent;
|
|
22654
22669
|
return t == null ? null : String(t).trim() || null;
|
|
22655
22670
|
}
|
|
22656
|
-
function
|
|
22671
|
+
function Yg(e) {
|
|
22657
22672
|
let t = e.ownerDocument?.defaultView || window, n = e.tagName === "TEXTAREA" ? t.HTMLTextAreaElement.prototype : t.HTMLInputElement.prototype, r = Object.getOwnPropertyDescriptor(n, "value");
|
|
22658
22673
|
return (e, t) => {
|
|
22659
22674
|
try {
|
|
@@ -22662,7 +22677,7 @@ function Lg(e) {
|
|
|
22662
22677
|
r?.set ? r.set.call(e, t) : e.value = t;
|
|
22663
22678
|
};
|
|
22664
22679
|
}
|
|
22665
|
-
async function
|
|
22680
|
+
async function Xg(e, t, n) {
|
|
22666
22681
|
if (!n?.skipScroll) try {
|
|
22667
22682
|
e.scrollIntoView({
|
|
22668
22683
|
behavior: "smooth",
|
|
@@ -22675,10 +22690,10 @@ async function Rg(e, t, n) {
|
|
|
22675
22690
|
} catch {}
|
|
22676
22691
|
}
|
|
22677
22692
|
try {
|
|
22678
|
-
await
|
|
22693
|
+
await ug(e);
|
|
22679
22694
|
} catch {}
|
|
22680
22695
|
try {
|
|
22681
|
-
|
|
22696
|
+
sg(e);
|
|
22682
22697
|
} catch {}
|
|
22683
22698
|
await new Promise((e) => setTimeout(e, 180));
|
|
22684
22699
|
try {
|
|
@@ -22693,15 +22708,33 @@ async function Rg(e, t, n) {
|
|
|
22693
22708
|
cancelable: !0,
|
|
22694
22709
|
composed: !0
|
|
22695
22710
|
};
|
|
22696
|
-
if (r === "SELECT") return e.value = String(t), e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a)), e.dispatchEvent(new Event("blur", a)),
|
|
22711
|
+
if (r === "SELECT") return e.value = String(t), e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a)), e.dispatchEvent(new Event("blur", a)), cg(e), !0;
|
|
22697
22712
|
if (i === "checkbox" || i === "radio") return e.checked = [
|
|
22698
22713
|
"1",
|
|
22699
22714
|
"true",
|
|
22700
22715
|
"yes",
|
|
22701
22716
|
"on"
|
|
22702
|
-
].includes(String(t).toLowerCase().trim()), e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a)),
|
|
22717
|
+
].includes(String(t).toLowerCase().trim()), e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a)), cg(e), !0;
|
|
22703
22718
|
let o = String(t);
|
|
22704
|
-
r === "INPUT" || r === "TEXTAREA"
|
|
22719
|
+
if (r === "INPUT" || r === "TEXTAREA") {
|
|
22720
|
+
let t = Yg(e);
|
|
22721
|
+
try {
|
|
22722
|
+
await eg(e, o, t);
|
|
22723
|
+
} catch {
|
|
22724
|
+
t(e, o);
|
|
22725
|
+
}
|
|
22726
|
+
e.value !== o && t(e, o);
|
|
22727
|
+
} else e.value = o;
|
|
22728
|
+
try {
|
|
22729
|
+
e.dispatchEvent(new InputEvent("input", {
|
|
22730
|
+
...a,
|
|
22731
|
+
inputType: "insertText",
|
|
22732
|
+
data: o
|
|
22733
|
+
}));
|
|
22734
|
+
} catch {
|
|
22735
|
+
e.dispatchEvent(new Event("input", a));
|
|
22736
|
+
}
|
|
22737
|
+
e.dispatchEvent(new Event("change", a)), e.dispatchEvent(new Event("blur", a));
|
|
22705
22738
|
try {
|
|
22706
22739
|
e.focus({ preventScroll: !0 });
|
|
22707
22740
|
} catch {}
|
|
@@ -22712,16 +22745,13 @@ async function Rg(e, t, n) {
|
|
|
22712
22745
|
} catch {}
|
|
22713
22746
|
});
|
|
22714
22747
|
} catch {}
|
|
22715
|
-
|
|
22716
|
-
Gh(e);
|
|
22717
|
-
} catch {}
|
|
22718
|
-
return !0;
|
|
22748
|
+
return cg(e), !0;
|
|
22719
22749
|
}
|
|
22720
|
-
function
|
|
22750
|
+
function Zg(e) {
|
|
22721
22751
|
let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = null, o = {
|
|
22722
22752
|
navigate_to_page: async (n) => {
|
|
22723
22753
|
$("navigate_to_page ▶ raw parameters:", n);
|
|
22724
|
-
let r =
|
|
22754
|
+
let r = Vg(n), i = qg(r), a = r.section_text ?? r.sectionText ?? r.section;
|
|
22725
22755
|
if ($("navigate_to_page · coerced:", {
|
|
22726
22756
|
url: i,
|
|
22727
22757
|
sectionText: a
|
|
@@ -22729,16 +22759,17 @@ function zg(e) {
|
|
|
22729
22759
|
let e = "Missing url: pass a string url, path like /pricing, or JSON with a url field.";
|
|
22730
22760
|
return $("navigate_to_page ✖", e), e;
|
|
22731
22761
|
}
|
|
22732
|
-
|
|
22762
|
+
let o = typeof window < "u" ? sn(i) : i;
|
|
22763
|
+
if (rg(`Navigating to ${String(o).replace(/^https?:\/\/[^/]+/, "") || "/"}…`), ag(), !await ln(o, {
|
|
22733
22764
|
siteId: t,
|
|
22734
22765
|
apiBaseUrl: e.apiBaseUrl
|
|
22735
22766
|
})) {
|
|
22736
|
-
|
|
22767
|
+
og(), ig(200);
|
|
22737
22768
|
let e = "That page is not available in the site index; answer without navigating.";
|
|
22738
22769
|
return $("navigate_to_page ✖ blocked", e), e;
|
|
22739
22770
|
}
|
|
22740
22771
|
try {
|
|
22741
|
-
if ($("navigate_to_page → shadowNavigate",
|
|
22772
|
+
if ($("navigate_to_page → shadowNavigate", o), await dn(o, { sectionText: a || void 0 }), await new Promise((e) => setTimeout(e, 600)), og(), ig(300), a && typeof a == "string") {
|
|
22742
22773
|
let e = rn(null, a);
|
|
22743
22774
|
e && an(e), $("navigate_to_page · highlight", {
|
|
22744
22775
|
sectionText: a,
|
|
@@ -22747,31 +22778,31 @@ function zg(e) {
|
|
|
22747
22778
|
}
|
|
22748
22779
|
let e = "";
|
|
22749
22780
|
try {
|
|
22750
|
-
let t =
|
|
22781
|
+
let t = Cg(), n = wg();
|
|
22751
22782
|
if (t.length > 0) {
|
|
22752
22783
|
let r = t.map((e) => e.label || e.placeholder || e.name || e.id).filter(Boolean).join(", "), i = n.map((e) => e.text).filter(Boolean).join(", ");
|
|
22753
22784
|
e = ` This page has a form with fields: [${r}]` + (i ? ` and buttons: [${i}].` : ".") + " Call list_page_forms then start filling.";
|
|
22754
22785
|
}
|
|
22755
22786
|
} catch {}
|
|
22756
|
-
let t = `OK_NAVIGATION ${
|
|
22787
|
+
let t = `OK_NAVIGATION ${o}${e}`;
|
|
22757
22788
|
return $("navigate_to_page ✓", t), t;
|
|
22758
22789
|
} catch (e) {
|
|
22759
|
-
|
|
22790
|
+
og(), ig(200);
|
|
22760
22791
|
let t = `Navigation error: ${e?.message || String(e)}`;
|
|
22761
22792
|
return $("navigate_to_page ✖", t), t;
|
|
22762
22793
|
}
|
|
22763
22794
|
},
|
|
22764
22795
|
highlight_on_page: async (e) => {
|
|
22765
22796
|
$("highlight_on_page ▶", e);
|
|
22766
|
-
let t =
|
|
22797
|
+
let t = Vg(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText, i = rn(n || null, r || null);
|
|
22767
22798
|
return i ? (an(i), $("highlight_on_page ✓"), "Highlighted the section.") : ($("highlight_on_page ✖ no element"), "Could not find that section on the page.");
|
|
22768
22799
|
},
|
|
22769
22800
|
search_site_content: async (e) => {
|
|
22770
22801
|
$("search_site_content ▶", e);
|
|
22771
|
-
let r =
|
|
22772
|
-
if ($("search_site_content · query:", r, "siteId:", t, "apiBase:", n || "(empty)"),
|
|
22773
|
-
if (!t) return
|
|
22774
|
-
if (!n) return
|
|
22802
|
+
let r = Jg(Vg(e));
|
|
22803
|
+
if ($("search_site_content · query:", r, "siteId:", t, "apiBase:", n || "(empty)"), rg("Searching site content…", { spinner: !0 }), !r) return ig(), $("search_site_content ✖ missing query"), "Missing query parameter.";
|
|
22804
|
+
if (!t) return ig(), $("search_site_content ✖ no siteId"), "Site is not configured for search.";
|
|
22805
|
+
if (!n) return ig(), $("search_site_content ✖ no api base"), "API base URL is missing; cannot search.";
|
|
22775
22806
|
try {
|
|
22776
22807
|
let e = `${n}/api/site-tools/search`;
|
|
22777
22808
|
$("search_site_content → POST", e);
|
|
@@ -22784,25 +22815,25 @@ function zg(e) {
|
|
|
22784
22815
|
currentUrl: typeof window < "u" ? window.location.href : ""
|
|
22785
22816
|
})
|
|
22786
22817
|
}), a = await i.json();
|
|
22787
|
-
if ($("search_site_content · HTTP", i.status, "success:", a.success),
|
|
22818
|
+
if ($("search_site_content · HTTP", i.status, "success:", a.success), ig(200), !a.success) {
|
|
22788
22819
|
let e = a.error || "Search failed.";
|
|
22789
22820
|
return $("search_site_content ✖", e), e;
|
|
22790
22821
|
}
|
|
22791
22822
|
let o = a.results || [];
|
|
22792
22823
|
return $("search_site_content ✓", `${o.length} result(s)`, o.slice(0, 3).map((e) => e?.url || e)), JSON.stringify(o);
|
|
22793
22824
|
} catch (e) {
|
|
22794
|
-
|
|
22825
|
+
ig();
|
|
22795
22826
|
let t = `Search error: ${e.message || "network"}`;
|
|
22796
22827
|
return $("search_site_content ✖", t), t;
|
|
22797
22828
|
}
|
|
22798
22829
|
},
|
|
22799
|
-
end_voice_session: async () => ($("end_voice_session ▶"),
|
|
22830
|
+
end_voice_session: async () => ($("end_voice_session ▶"), rg("Ending voice session…", {
|
|
22800
22831
|
icon: "👋",
|
|
22801
22832
|
spinner: !1,
|
|
22802
22833
|
duration: 2e3
|
|
22803
|
-
}),
|
|
22834
|
+
}), dg(!0), lg(), typeof e.requestEndSession == "function" && e.requestEndSession(), "Voice session is ending."),
|
|
22804
22835
|
list_page_forms: async () => {
|
|
22805
|
-
let e =
|
|
22836
|
+
let e = Cg(), t = wg();
|
|
22806
22837
|
return $("list_page_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), a = null, JSON.stringify({
|
|
22807
22838
|
fields: e,
|
|
22808
22839
|
buttons: t,
|
|
@@ -22812,60 +22843,60 @@ function zg(e) {
|
|
|
22812
22843
|
fill_form_fields: async (e) => {
|
|
22813
22844
|
try {
|
|
22814
22845
|
$("fill_form_fields ▶ raw:", e);
|
|
22815
|
-
let t =
|
|
22846
|
+
let t = Hg(e);
|
|
22816
22847
|
if (!t.length && r) {
|
|
22817
|
-
let e = r(), n =
|
|
22818
|
-
n.length ? $("fill_form_fields · inferred URL from last user utterance (model omitted usable fields):", n) : (n =
|
|
22848
|
+
let e = r(), n = Gg(e);
|
|
22849
|
+
n.length ? $("fill_form_fields · inferred URL from last user utterance (model omitted usable fields):", n) : (n = Kg(e), n.length && $("fill_form_fields · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
|
|
22819
22850
|
}
|
|
22820
22851
|
if ($("fill_form_fields · normalized fields:", t), !t.length) return "No fields provided. Call list_page_forms for field_key strings, then fill_form_fields with { \"fields\": [ { \"field_key\": \"<label or placeholder from list>\", \"value\": \"<user value>\" } ] }. Never use empty {}. Pass the value the user just said (email, message, name, URL) in fields.";
|
|
22821
|
-
t.length > 1 &&
|
|
22852
|
+
t.length > 1 && rg(`Filling ${t.length} fields…`);
|
|
22822
22853
|
let n = [];
|
|
22823
22854
|
for (let e of t) {
|
|
22824
22855
|
let t = e?.field_key ?? e?.fieldKey, r = e?.value;
|
|
22825
22856
|
if (t == null || r == null) continue;
|
|
22826
22857
|
let o = String(t).toLowerCase();
|
|
22827
|
-
/email|e-mail|mail/.test(o) ? r =
|
|
22828
|
-
let s =
|
|
22858
|
+
/email|e-mail|mail/.test(o) ? r = Ug(r) : /phone|mobile|tel|cell/.test(o) && (r = Wg(r)), rg(`Filling ${t}…`), $("fill_form_fields · processing field:", t, "=", r);
|
|
22859
|
+
let s = Sg(), c = s;
|
|
22829
22860
|
if (a) {
|
|
22830
|
-
let e = s.filter((e) =>
|
|
22861
|
+
let e = s.filter((e) => gg(e) === a);
|
|
22831
22862
|
e.length > 0 && (c = e, $("fill_form_fields · scoped to active form, inputs:", e.length));
|
|
22832
22863
|
}
|
|
22833
22864
|
$("fill_form_fields · visible inputs count:", s.length, "scoped:", c.length);
|
|
22834
22865
|
let l = !1;
|
|
22835
22866
|
for (let e of [c, ...c === s ? [] : [s]]) {
|
|
22836
|
-
let o =
|
|
22867
|
+
let o = Fg(e, String(t), r);
|
|
22837
22868
|
if (o.length) {
|
|
22838
|
-
for (let e = 0; e < o.length; e++) await
|
|
22839
|
-
i = o, a =
|
|
22869
|
+
for (let e = 0; e < o.length; e++) await Xg(o[e], r, { skipScroll: e > 0 }), await new Promise((e) => setTimeout(e, 80));
|
|
22870
|
+
i = o, a = gg(o[0]) || a, n.push(String(t)), l = !0;
|
|
22840
22871
|
break;
|
|
22841
22872
|
}
|
|
22842
|
-
let s =
|
|
22843
|
-
if (s ||=
|
|
22844
|
-
await
|
|
22873
|
+
let s = Rg(e, String(t));
|
|
22874
|
+
if (s ||= kg(e, String(t)), s ||= Ag(e, String(t), r), s) {
|
|
22875
|
+
await Xg(s, r), i = [s], a = gg(s) || a, n.push(String(t)), l = !0;
|
|
22845
22876
|
break;
|
|
22846
22877
|
}
|
|
22847
22878
|
}
|
|
22848
22879
|
l || $("fill_form_fields · no match for field:", t);
|
|
22849
22880
|
}
|
|
22850
|
-
|
|
22881
|
+
ig(400);
|
|
22851
22882
|
try {
|
|
22852
|
-
|
|
22883
|
+
dg();
|
|
22853
22884
|
} catch {}
|
|
22854
22885
|
if (!n.length) return $("fill_form_fields ✖ no matches"), "Could not match any fields. Call list_page_forms and use field_key values that match placeholder, label, name, or id (e.g. Enter Website URL). Ensure the form is on the page, not the chat panel.";
|
|
22855
22886
|
let o = `OK_FILLED: ${n.join(", ")}`;
|
|
22856
22887
|
return $("fill_form_fields ✓", o), o;
|
|
22857
22888
|
} catch (e) {
|
|
22858
|
-
|
|
22889
|
+
ig(), lg(), dg(!0);
|
|
22859
22890
|
let t = `fill_form_fields error: ${e?.message || String(e)}`;
|
|
22860
22891
|
return $("fill_form_fields ✖", t), t;
|
|
22861
22892
|
}
|
|
22862
22893
|
},
|
|
22863
22894
|
click_page_button: async (e) => {
|
|
22864
|
-
let t =
|
|
22895
|
+
let t = Vg(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
|
|
22865
22896
|
if ($("click_page_button ▶", n), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
|
|
22866
|
-
|
|
22867
|
-
let r =
|
|
22868
|
-
if (!r) return
|
|
22897
|
+
rg(`Clicking "${n}"…`);
|
|
22898
|
+
let r = Bg(n, i);
|
|
22899
|
+
if (!r) return ig(200), $("click_page_button ✖ no match"), `Could not find a button matching "${n}". Call list_page_forms to see button texts.`;
|
|
22869
22900
|
try {
|
|
22870
22901
|
try {
|
|
22871
22902
|
r.scrollIntoView({
|
|
@@ -22877,41 +22908,41 @@ function zg(e) {
|
|
|
22877
22908
|
r.scrollIntoView(!0);
|
|
22878
22909
|
}
|
|
22879
22910
|
try {
|
|
22880
|
-
await
|
|
22911
|
+
await ug(r);
|
|
22881
22912
|
} catch {}
|
|
22882
22913
|
try {
|
|
22883
|
-
|
|
22914
|
+
pg(r);
|
|
22884
22915
|
} catch {}
|
|
22885
22916
|
try {
|
|
22886
|
-
await
|
|
22917
|
+
await fg(r);
|
|
22887
22918
|
} catch {}
|
|
22888
|
-
let e =
|
|
22919
|
+
let e = gg(r) || a, t = [];
|
|
22889
22920
|
if (e) {
|
|
22890
|
-
let n = Array.from(e.querySelectorAll("input[required], textarea[required], select[required]")).filter((e) => !
|
|
22921
|
+
let n = Array.from(e.querySelectorAll("input[required], textarea[required], select[required]")).filter((e) => !hg(e));
|
|
22891
22922
|
for (let e of n) if (!(e.value || "").trim()) {
|
|
22892
|
-
let n =
|
|
22923
|
+
let n = xg(e) || e.placeholder || e.name || e.type;
|
|
22893
22924
|
t.push(n);
|
|
22894
22925
|
}
|
|
22895
22926
|
}
|
|
22896
22927
|
if (t.length > 0) {
|
|
22897
|
-
|
|
22928
|
+
ig(200);
|
|
22898
22929
|
try {
|
|
22899
|
-
|
|
22930
|
+
dg();
|
|
22900
22931
|
} catch {}
|
|
22901
22932
|
let e = `Cannot submit — these required fields are still empty: ${t.join(", ")}. Fill them first with fill_form_fields, then click again.`;
|
|
22902
22933
|
return $("click_page_button ✖ empty required fields:", t), e;
|
|
22903
22934
|
}
|
|
22904
22935
|
r.focus?.(), r.click();
|
|
22905
22936
|
let n = (r.textContent || r.value || r.getAttribute("aria-label") || "").trim().slice(0, 80) || "button";
|
|
22906
|
-
|
|
22937
|
+
ig(600);
|
|
22907
22938
|
try {
|
|
22908
|
-
|
|
22939
|
+
dg();
|
|
22909
22940
|
} catch {}
|
|
22910
|
-
|
|
22941
|
+
lg(), a = null, i = [];
|
|
22911
22942
|
let o = `OK_CLICK ${n}`;
|
|
22912
22943
|
return $("click_page_button ✓", o), o;
|
|
22913
22944
|
} catch (e) {
|
|
22914
|
-
|
|
22945
|
+
ig(200), dg(!0);
|
|
22915
22946
|
let t = `Click failed: ${e?.message || String(e)}`;
|
|
22916
22947
|
return $("click_page_button ✖", t), t;
|
|
22917
22948
|
}
|
|
@@ -22930,32 +22961,39 @@ function zg(e) {
|
|
|
22930
22961
|
}
|
|
22931
22962
|
//#endregion
|
|
22932
22963
|
//#region src/utils/wrapVoiceToolsForLogging.js
|
|
22933
|
-
function
|
|
22964
|
+
function Qg(e) {
|
|
22934
22965
|
return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
|
|
22935
22966
|
let r = Zt();
|
|
22936
22967
|
r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
|
|
22937
|
-
let i
|
|
22968
|
+
let i;
|
|
22969
|
+
try {
|
|
22970
|
+
i = await t(n);
|
|
22971
|
+
} catch (t) {
|
|
22972
|
+
let n = `Tool error: ${t?.message || String(t)}`;
|
|
22973
|
+
return console.error(`[FlowEngage] voice tool ${e} threw:`, t), n;
|
|
22974
|
+
}
|
|
22975
|
+
let a = typeof i == "string" ? i.length > 220 ? `${i.slice(0, 220)}…` : i : String(i);
|
|
22938
22976
|
return r ? console.log("[FlowEngage:voice-tool] ◀", e, a) : console.info(`[FlowEngage] voice tool « ${e}:`, a), i;
|
|
22939
22977
|
}]));
|
|
22940
22978
|
}
|
|
22941
22979
|
//#endregion
|
|
22942
22980
|
//#region src/components/VoiceInterface.jsx
|
|
22943
|
-
var
|
|
22981
|
+
var $g = {
|
|
22944
22982
|
idle: "rgba(99,102,241,0.18)",
|
|
22945
22983
|
listening: "rgba(16,185,129,0.25)",
|
|
22946
22984
|
speaking: "rgba(245,158,11,0.25)",
|
|
22947
22985
|
error: "rgba(239,68,68,0.2)"
|
|
22948
|
-
},
|
|
22986
|
+
}, e_ = {
|
|
22949
22987
|
idle: "#6366f1",
|
|
22950
22988
|
listening: "#10b981",
|
|
22951
22989
|
speaking: "#f59e0b",
|
|
22952
22990
|
error: "#ef4444"
|
|
22953
22991
|
};
|
|
22954
|
-
function
|
|
22992
|
+
function t_(e, t) {
|
|
22955
22993
|
let n = (t || "").trim();
|
|
22956
22994
|
return n ? !!(/\b(let'?s|let us)\s+(end|stop|finish|wrap up|close)\s+(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\bend\s+(this\s+)?(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\b(hang\s+up|disconnect)\b/i.test(n) || /\b(that'?s all|we'?re done)\b/i.test(n) || e === "bot" && (/\b(I'?ll|I will|Let me|I can|I'?m going to)\s+(end|close)\s+(the\s+)?(voice\s+)?(session|call)\b/i.test(n) || /\b(ending|closing)\s+(the\s+)?(voice\s+)?session\b|\bvoice\s+session\s+(is\s+)?(now\s+)?(ended|over|closing)\b/i.test(n) || /\b(session|call)\s+(is\s+)?(now\s+)?(ended|over)\b/i.test(n) || /\bwe\s+can\s+end\s+(the\s+)?(session|call)?\s*(here|now)\b/i.test(n) || /\b(wrapping\s+up|signing\s+off)\b/i.test(n)) || /^(goodbye|bye|that'?s all|we'?re done|hang up|disconnect)\b/i.test(n)) : !1;
|
|
22957
22995
|
}
|
|
22958
|
-
function
|
|
22996
|
+
function n_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, historyRef: d, hasSyncedRef: f, onMessageSync: p, onStartSync: m }) {
|
|
22959
22997
|
let [h, g] = s("idle"), [ee, te] = s(null), [_, ne] = s(!1), re = o(null), ie = o(null), ae = o(""), oe = o(async () => {}), se = o(!1), v = n(async () => {
|
|
22960
22998
|
try {
|
|
22961
22999
|
await re.current?.endSession?.();
|
|
@@ -22972,7 +23010,7 @@ function Wg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
22972
23010
|
try {
|
|
22973
23011
|
if (await navigator.mediaDevices.getUserMedia({ audio: !0 }), t) return;
|
|
22974
23012
|
d.current = [], ae.current = "", se.current = !1;
|
|
22975
|
-
let i =
|
|
23013
|
+
let i = Qg(Zg({
|
|
22976
23014
|
siteId: r || null,
|
|
22977
23015
|
apiBaseUrl: a || null,
|
|
22978
23016
|
getLastUserVoiceText: () => ae.current,
|
|
@@ -22999,7 +23037,7 @@ function Wg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
22999
23037
|
message: r,
|
|
23000
23038
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
23001
23039
|
};
|
|
23002
|
-
n === "user" && (ae.current = r), d.current = [...d.current, i],
|
|
23040
|
+
n === "user" && (ae.current = r), d.current = [...d.current, i], t_(n, r) && queueMicrotask(() => {
|
|
23003
23041
|
se.current || (se.current = !0, oe.current?.());
|
|
23004
23042
|
});
|
|
23005
23043
|
},
|
|
@@ -23022,12 +23060,7 @@ function Wg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23022
23060
|
} catch {
|
|
23023
23061
|
t = "[]";
|
|
23024
23062
|
}
|
|
23025
|
-
|
|
23026
|
-
try {
|
|
23027
|
-
let e = await i.search_site_content({ query: "pages" }), t = typeof e == "string" ? JSON.parse(e) : e;
|
|
23028
|
-
Array.isArray(t) && t.length && (n = ` Site pages available: ${t.map((e) => `${e.title || ""} (${e.url || ""})`).join(", ")}.`);
|
|
23029
|
-
} catch {}
|
|
23030
|
-
o.sendContextualUpdate(`Current page URL: ${e}. Site ID: ${r || "unknown"}. Page fields/buttons JSON: ${t}.${n} Navigation: when the user wants to go to any page (contact, pricing, about, services, etc.), call search_site_content then navigate_to_page immediately — never ask permission. After navigating to a page with a form, call list_page_forms and proactively start helping the user fill it. Forms: use fill_form_fields then click_page_button (e.g. Conduct Audit, Send Message) when the user wants to submit. Fill each field immediately after the user answers — never skip ahead. Voice: if the user wants to end the voice session, call end_voice_session or confirm and end.`);
|
|
23063
|
+
o.sendContextualUpdate(`Current page URL: ${e}. Site ID: ${r || "unknown"}. Page fields/buttons JSON: ${t}. Navigation: when the user wants to go to any page (contact, pricing, about, services, etc.), call search_site_content then navigate_to_page immediately — never ask permission. After navigating to a page with a form, call list_page_forms and proactively start helping the user fill it. Forms: use fill_form_fields then click_page_button (e.g. Conduct Audit, Send Message) when the user wants to submit. Fill each field immediately after the user answers — never skip ahead. Voice: if the user wants to end the voice session, call end_voice_session or confirm and end.`);
|
|
23031
23064
|
} catch {}
|
|
23032
23065
|
typeof m == "function" && m();
|
|
23033
23066
|
} catch (e) {
|
|
@@ -23043,7 +23076,7 @@ function Wg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23043
23076
|
d,
|
|
23044
23077
|
m
|
|
23045
23078
|
]);
|
|
23046
|
-
let ce = h === "listening" || h === "speaking", le =
|
|
23079
|
+
let ce = h === "listening" || h === "speaking", le = e_[h] || e_.idle, ue = $g[h] || $g.idle;
|
|
23047
23080
|
return /* @__PURE__ */ u("div", {
|
|
23048
23081
|
ref: ie,
|
|
23049
23082
|
style: {
|
|
@@ -23149,7 +23182,7 @@ function Wg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23149
23182
|
}
|
|
23150
23183
|
//#endregion
|
|
23151
23184
|
//#region src/components/FlowEngageWidget.jsx
|
|
23152
|
-
var
|
|
23185
|
+
var r_ = [
|
|
23153
23186
|
{
|
|
23154
23187
|
key: "become_client",
|
|
23155
23188
|
label: "Become a Client"
|
|
@@ -23170,7 +23203,7 @@ var Gg = [
|
|
|
23170
23203
|
key: "looking_for_job",
|
|
23171
23204
|
label: "Looking for a Job"
|
|
23172
23205
|
}
|
|
23173
|
-
],
|
|
23206
|
+
], i_ = () => /* @__PURE__ */ l("div", {
|
|
23174
23207
|
style: {
|
|
23175
23208
|
display: "flex",
|
|
23176
23209
|
marginBottom: "12px",
|
|
@@ -23201,7 +23234,7 @@ var Gg = [
|
|
|
23201
23234
|
} }, e)), /* @__PURE__ */ l("style", { children: "\n @keyframes fe-dot-bounce {\n 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }\n 40% { transform: translateY(-5px); opacity: 1; }\n }\n " })]
|
|
23202
23235
|
})
|
|
23203
23236
|
});
|
|
23204
|
-
function
|
|
23237
|
+
function a_() {
|
|
23205
23238
|
let { status: e, runtimeConfig: t, resolvedConfig: n, chatId: r, chatHistory: o, isOpen: c, activeScreen: d, isHumanHandled: f, agentName: p, agentHeadshot: m, visitorEmail: h, isAgentTyping: g, isAiTyping: ee, isLoading: te, isVoiceMode: _, isRateLimited: ne, rateLimitMessage: re, isConversationEnded: ie, incomingCall: ae, activeCallId: oe, callConnectionState: se, callConnectedAt: v, isCallMuted: ce, webRTCError: le, language: ue, historyRef: y, onMessageSync: b, endConversation: de, acceptCall: fe, rejectCall: pe, endWebRTCCall: me, toggleCallMute: he, dismissCallError: ge, captureVisitorEmail: _e, openWidget: ve, closeWidget: ye, sendMessage: be, setVoiceMode: xe, startTyping: Se, stopTyping: Ce, updateTypingDraft: we } = Xt(), [Te, Ee] = s(""), [De, Oe] = s(null), [ke, Ae] = s(null), [je, Me] = s(null), [Ne, Pe] = s(0), [x, Fe] = s(h || ""), [Ie, Le] = s("");
|
|
23206
23239
|
i(() => {
|
|
23207
23240
|
try {
|
|
@@ -23229,7 +23262,7 @@ function qg() {
|
|
|
23229
23262
|
outline: "none",
|
|
23230
23263
|
fontFamily: "ui-sans-serif, system-ui, sans-serif",
|
|
23231
23264
|
...c ? {} : Ue
|
|
23232
|
-
}, Ge = S.recommendations?.[ue] || Re.recommendations?.[ue] ||
|
|
23265
|
+
}, Ge = S.recommendations?.[ue] || Re.recommendations?.[ue] || r_, Ke = S.greetings?.[ue] || Re.greetings?.[ue], qe = ze.chatButtonText || "Chat with us", Je = ze.headerName || t?.websiteName || "OpenSense Labs", C = ze.logoUrl || null, w = ze.hideWatermark || !1, T = Re.elevenLabsAgentId || t?.elevenLabsAgentId || null, Ye = t?.siteId || n?.siteId || null, Xe = t?.apiBaseUrl || "", Ze = ze.fallbackAgentName || "Agent", Qe = ze.botLabel || "AI", $e = m && String(m).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, et = ae?.agentName || p || Ze, tt = o.some((e) => e.sender === "user"), nt = a(() => {
|
|
23233
23266
|
let e = o.findIndex((e) => e.sender === "user");
|
|
23234
23267
|
return e === -1 ? !1 : o.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
23235
23268
|
}, [o]), rt = !h && tt && nt;
|
|
@@ -23357,7 +23390,7 @@ function qg() {
|
|
|
23357
23390
|
flexDirection: "column"
|
|
23358
23391
|
},
|
|
23359
23392
|
className: "fe-screen-fade-in",
|
|
23360
|
-
children: /* @__PURE__ */ l(
|
|
23393
|
+
children: /* @__PURE__ */ l(n_, {
|
|
23361
23394
|
agentId: T,
|
|
23362
23395
|
chatId: r,
|
|
23363
23396
|
siteId: Ye,
|
|
@@ -23390,7 +23423,7 @@ function qg() {
|
|
|
23390
23423
|
isAiTyping: ee,
|
|
23391
23424
|
isAgentTyping: g,
|
|
23392
23425
|
setReplyContext: Me,
|
|
23393
|
-
TypingDots:
|
|
23426
|
+
TypingDots: i_,
|
|
23394
23427
|
primaryColor: Ve,
|
|
23395
23428
|
agentHeadshot: $e,
|
|
23396
23429
|
agentDisplayName: p || Ze
|
|
@@ -23469,4 +23502,4 @@ function qg() {
|
|
|
23469
23502
|
}) : null;
|
|
23470
23503
|
}
|
|
23471
23504
|
//#endregion
|
|
23472
|
-
export { vn as FlowEngageProvider,
|
|
23505
|
+
export { vn as FlowEngageProvider, a_ as FlowEngageWidget, Xt as useFlowEngage };
|