@flowengage/react-chatbot 1.0.8 → 1.1.0
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.
|
@@ -22133,42 +22133,81 @@ function tg(e) {
|
|
|
22133
22133
|
}
|
|
22134
22134
|
//#endregion
|
|
22135
22135
|
//#region src/utils/voiceClientTools.js
|
|
22136
|
+
function ng(e) {
|
|
22137
|
+
return (...t) => {
|
|
22138
|
+
try {
|
|
22139
|
+
let n = e(...t);
|
|
22140
|
+
return n instanceof Promise ? n.catch(() => {}) : n;
|
|
22141
|
+
} catch {
|
|
22142
|
+
return;
|
|
22143
|
+
}
|
|
22144
|
+
};
|
|
22145
|
+
}
|
|
22146
|
+
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
22147
|
function $(...e) {
|
|
22137
22148
|
Zt() && console.log("[FlowEngage:voice-tools]", ...e);
|
|
22138
22149
|
}
|
|
22139
|
-
var
|
|
22140
|
-
function
|
|
22150
|
+
var mg = "#flowengage-root, .flowengage-shell";
|
|
22151
|
+
function hg(e) {
|
|
22141
22152
|
if (!e || typeof e.closest != "function") return !1;
|
|
22142
22153
|
try {
|
|
22143
|
-
return !!e.closest(
|
|
22154
|
+
return !!e.closest(mg);
|
|
22144
22155
|
} catch {
|
|
22145
22156
|
return !1;
|
|
22146
22157
|
}
|
|
22147
22158
|
}
|
|
22148
|
-
function
|
|
22159
|
+
function gg(e) {
|
|
22160
|
+
if (!e) return null;
|
|
22161
|
+
try {
|
|
22162
|
+
return e.closest("form");
|
|
22163
|
+
} catch {
|
|
22164
|
+
let t = e.parentElement;
|
|
22165
|
+
for (; t;) {
|
|
22166
|
+
if (t.tagName === "FORM") return t;
|
|
22167
|
+
t = t.parentElement;
|
|
22168
|
+
}
|
|
22169
|
+
return null;
|
|
22170
|
+
}
|
|
22171
|
+
}
|
|
22172
|
+
function _g(e) {
|
|
22173
|
+
if (!e) return null;
|
|
22174
|
+
let t = e.querySelector("h1, h2, h3, h4, h5, legend");
|
|
22175
|
+
if (t) return t.textContent.replace(/\s+/g, " ").trim().slice(0, 60);
|
|
22176
|
+
let n = e.getAttribute("aria-label");
|
|
22177
|
+
if (n) return n.trim().slice(0, 60);
|
|
22178
|
+
let r = e.getAttribute("title");
|
|
22179
|
+
if (r) return r.trim().slice(0, 60);
|
|
22180
|
+
let i = e.previousElementSibling;
|
|
22181
|
+
for (let e = 0; e < 3 && i; e++) {
|
|
22182
|
+
if (/^H[1-5]$/.test(i.tagName)) return i.textContent.replace(/\s+/g, " ").trim().slice(0, 60);
|
|
22183
|
+
i = i.previousElementSibling;
|
|
22184
|
+
}
|
|
22185
|
+
return null;
|
|
22186
|
+
}
|
|
22187
|
+
function vg(e) {
|
|
22149
22188
|
try {
|
|
22150
22189
|
let t = e.ownerDocument?.defaultView;
|
|
22151
22190
|
if (t) return t.getComputedStyle(e);
|
|
22152
22191
|
} catch {}
|
|
22153
22192
|
return window.getComputedStyle(e);
|
|
22154
22193
|
}
|
|
22155
|
-
function
|
|
22194
|
+
function yg(e) {
|
|
22156
22195
|
let t = /* @__PURE__ */ new Set();
|
|
22157
22196
|
function n(r) {
|
|
22158
22197
|
if (!r || t.has(r)) return;
|
|
22159
22198
|
t.add(r), e(r);
|
|
22160
22199
|
let i = r.querySelectorAll("iframe");
|
|
22161
|
-
for (let e of i) if (!
|
|
22200
|
+
for (let e of i) if (!hg(e)) try {
|
|
22162
22201
|
let t = e.contentDocument;
|
|
22163
22202
|
t && n(t);
|
|
22164
22203
|
} catch {}
|
|
22165
22204
|
}
|
|
22166
22205
|
typeof document < "u" && n(document);
|
|
22167
22206
|
}
|
|
22168
|
-
function
|
|
22207
|
+
function bg(e) {
|
|
22169
22208
|
return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
|
|
22170
22209
|
}
|
|
22171
|
-
function
|
|
22210
|
+
function xg(e) {
|
|
22172
22211
|
let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
|
|
22173
22212
|
if (n) {
|
|
22174
22213
|
let e = n.trim().split(/\s+/).filter(Boolean), r = [];
|
|
@@ -22176,42 +22215,42 @@ function sg(e) {
|
|
|
22176
22215
|
let e = t.getElementById(n);
|
|
22177
22216
|
e?.textContent && r.push(e.textContent.trim());
|
|
22178
22217
|
} catch {}
|
|
22179
|
-
if (r.length) return
|
|
22218
|
+
if (r.length) return bg(r.join(" "));
|
|
22180
22219
|
}
|
|
22181
|
-
if (e.labels && e.labels.length) return
|
|
22220
|
+
if (e.labels && e.labels.length) return bg(e.labels[0].textContent);
|
|
22182
22221
|
let r = e.id;
|
|
22183
22222
|
if (r) try {
|
|
22184
22223
|
let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
|
|
22185
|
-
if (e) return
|
|
22224
|
+
if (e) return bg(e.textContent);
|
|
22186
22225
|
} catch {
|
|
22187
22226
|
let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
|
|
22188
|
-
if (e) return
|
|
22227
|
+
if (e) return bg(e.textContent);
|
|
22189
22228
|
}
|
|
22190
22229
|
let i = e.previousElementSibling;
|
|
22191
22230
|
for (let e = 0; e < 6 && i; e += 1) {
|
|
22192
|
-
if (i.tagName === "LABEL") return
|
|
22231
|
+
if (i.tagName === "LABEL") return bg(i.textContent);
|
|
22193
22232
|
let e = (i.className || "").toString().toLowerCase();
|
|
22194
22233
|
if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
|
|
22195
|
-
let e =
|
|
22234
|
+
let e = bg(i.textContent);
|
|
22196
22235
|
if (e) return e;
|
|
22197
22236
|
}
|
|
22198
22237
|
i = i.previousElementSibling;
|
|
22199
22238
|
}
|
|
22200
22239
|
let a = e.parentElement;
|
|
22201
22240
|
for (let e = 0; e < 5 && a; e += 1) {
|
|
22202
|
-
if (a.tagName === "LABEL") return
|
|
22241
|
+
if (a.tagName === "LABEL") return bg(a.textContent);
|
|
22203
22242
|
let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
|
|
22204
|
-
if (e?.textContent) return
|
|
22243
|
+
if (e?.textContent) return bg(e.textContent);
|
|
22205
22244
|
a = a.parentElement;
|
|
22206
22245
|
}
|
|
22207
22246
|
let o = e.getAttribute("aria-label");
|
|
22208
|
-
return o ?
|
|
22247
|
+
return o ? bg(o) : null;
|
|
22209
22248
|
}
|
|
22210
|
-
function
|
|
22249
|
+
function Sg() {
|
|
22211
22250
|
let e = [];
|
|
22212
|
-
return
|
|
22251
|
+
return yg((t) => {
|
|
22213
22252
|
e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
|
|
22214
|
-
if (
|
|
22253
|
+
if (hg(e)) return !1;
|
|
22215
22254
|
let t = (e.type || "").toLowerCase();
|
|
22216
22255
|
if ([
|
|
22217
22256
|
"hidden",
|
|
@@ -22220,7 +22259,7 @@ function cg() {
|
|
|
22220
22259
|
"image"
|
|
22221
22260
|
].includes(t) || e.disabled || e.readOnly) return !1;
|
|
22222
22261
|
try {
|
|
22223
|
-
let t =
|
|
22262
|
+
let t = vg(e);
|
|
22224
22263
|
if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
|
|
22225
22264
|
} catch {}
|
|
22226
22265
|
try {
|
|
@@ -22230,25 +22269,32 @@ function cg() {
|
|
|
22230
22269
|
}));
|
|
22231
22270
|
}), e;
|
|
22232
22271
|
}
|
|
22233
|
-
function
|
|
22234
|
-
|
|
22235
|
-
|
|
22236
|
-
|
|
22237
|
-
|
|
22238
|
-
|
|
22239
|
-
|
|
22240
|
-
|
|
22241
|
-
|
|
22242
|
-
|
|
22243
|
-
|
|
22272
|
+
function Cg() {
|
|
22273
|
+
let e = Sg(), t = /* @__PURE__ */ new Map(), n = 0;
|
|
22274
|
+
return e.map((e, r) => {
|
|
22275
|
+
let i = gg(e), a = i || "__orphan__";
|
|
22276
|
+
t.has(a) || t.set(a, n++);
|
|
22277
|
+
let o = t.get(a);
|
|
22278
|
+
return {
|
|
22279
|
+
formIndex: o,
|
|
22280
|
+
formName: (i ? _g(i) : null) || `Form ${o}`,
|
|
22281
|
+
fieldIndex: r,
|
|
22282
|
+
tag: e.tagName,
|
|
22283
|
+
type: e.type || "text",
|
|
22284
|
+
name: e.name || null,
|
|
22285
|
+
id: e.id || null,
|
|
22286
|
+
label: xg(e),
|
|
22287
|
+
placeholder: e.placeholder || null
|
|
22288
|
+
};
|
|
22289
|
+
});
|
|
22244
22290
|
}
|
|
22245
|
-
function
|
|
22291
|
+
function wg() {
|
|
22246
22292
|
let e = [];
|
|
22247
|
-
return
|
|
22293
|
+
return yg((t) => {
|
|
22248
22294
|
e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
|
|
22249
|
-
if (
|
|
22295
|
+
if (hg(e) || e.disabled) return !1;
|
|
22250
22296
|
try {
|
|
22251
|
-
let t =
|
|
22297
|
+
let t = vg(e);
|
|
22252
22298
|
if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
|
|
22253
22299
|
} catch {}
|
|
22254
22300
|
return !0;
|
|
@@ -22260,15 +22306,15 @@ function ug() {
|
|
|
22260
22306
|
type: e.type || e.tagName
|
|
22261
22307
|
}));
|
|
22262
22308
|
}
|
|
22263
|
-
function
|
|
22309
|
+
function Tg(e) {
|
|
22264
22310
|
return String(e || "").toLowerCase().replace(/\u00a0/g, " ").replace(/\*/g, "").replace(/\s+/g, " ").trim();
|
|
22265
22311
|
}
|
|
22266
|
-
function
|
|
22267
|
-
let t =
|
|
22312
|
+
function Eg(e) {
|
|
22313
|
+
let t = Tg(e);
|
|
22268
22314
|
return t = t.replace(/\s+field\s*$/i, "").trim(), t;
|
|
22269
22315
|
}
|
|
22270
|
-
function
|
|
22271
|
-
let n =
|
|
22316
|
+
function Dg(e, t) {
|
|
22317
|
+
let n = Eg(t);
|
|
22272
22318
|
if (!n) return 0;
|
|
22273
22319
|
let r = (e.name || "").toLowerCase(), i = (e.id || "").toLowerCase();
|
|
22274
22320
|
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;
|
|
@@ -22280,12 +22326,12 @@ function pg(e, t) {
|
|
|
22280
22326
|
e.name,
|
|
22281
22327
|
e.id,
|
|
22282
22328
|
e.placeholder,
|
|
22283
|
-
|
|
22329
|
+
xg(e),
|
|
22284
22330
|
e.getAttribute("aria-label"),
|
|
22285
22331
|
e.getAttribute("title"),
|
|
22286
22332
|
e.getAttribute("data-testid"),
|
|
22287
22333
|
e.getAttribute("autocomplete")
|
|
22288
|
-
].filter(Boolean).map((e) =>
|
|
22334
|
+
].filter(Boolean).map((e) => Tg(e)), s = 0;
|
|
22289
22335
|
for (let e of o) {
|
|
22290
22336
|
if (!e) continue;
|
|
22291
22337
|
if (e === n) {
|
|
@@ -22305,16 +22351,16 @@ function pg(e, t) {
|
|
|
22305
22351
|
}
|
|
22306
22352
|
return s;
|
|
22307
22353
|
}
|
|
22308
|
-
var
|
|
22309
|
-
function
|
|
22354
|
+
var Og = 22;
|
|
22355
|
+
function kg(e, t) {
|
|
22310
22356
|
let n = null, r = 0;
|
|
22311
22357
|
for (let i of e) {
|
|
22312
|
-
let e =
|
|
22358
|
+
let e = Dg(i, t);
|
|
22313
22359
|
e > r && (r = e, n = i);
|
|
22314
22360
|
}
|
|
22315
|
-
return !n || r <
|
|
22361
|
+
return !n || r < Og ? null : n;
|
|
22316
22362
|
}
|
|
22317
|
-
function
|
|
22363
|
+
function Ag(e, t, n) {
|
|
22318
22364
|
let r = String(t || "").toLowerCase().trim(), i = String(n || "").trim();
|
|
22319
22365
|
if (!(/^https?:\/\//i.test(i) || /\.\w{2,}(\/|\s|$)/.test(i) || r.includes("url") || r.includes("website") || r.includes("domain") || r.includes("site"))) return null;
|
|
22320
22366
|
let a = null, o = 0;
|
|
@@ -22334,7 +22380,7 @@ function gg(e, t, n) {
|
|
|
22334
22380
|
t.name,
|
|
22335
22381
|
t.id,
|
|
22336
22382
|
t.placeholder,
|
|
22337
|
-
|
|
22383
|
+
xg(t),
|
|
22338
22384
|
t.getAttribute("aria-label"),
|
|
22339
22385
|
t.getAttribute("autocomplete")
|
|
22340
22386
|
].filter(Boolean).join(" ").toLowerCase();
|
|
@@ -22342,15 +22388,15 @@ function gg(e, t, n) {
|
|
|
22342
22388
|
}
|
|
22343
22389
|
return !a || o < 42 ? null : a;
|
|
22344
22390
|
}
|
|
22345
|
-
function
|
|
22391
|
+
function jg(e) {
|
|
22346
22392
|
let t = String(e ?? "").trim();
|
|
22347
22393
|
return t ? /^https?:\/\//i.test(t) ? !0 : /\.\w{2,}(\/|\s|$)/.test(t) : !1;
|
|
22348
22394
|
}
|
|
22349
|
-
function
|
|
22395
|
+
function Mg(e) {
|
|
22350
22396
|
let t = String(e ?? "").toLowerCase().trim();
|
|
22351
22397
|
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;
|
|
22352
22398
|
}
|
|
22353
|
-
function
|
|
22399
|
+
function Ng(e) {
|
|
22354
22400
|
if (!e || e.tagName !== "INPUT" && e.tagName !== "TEXTAREA") return !1;
|
|
22355
22401
|
let t = (e.type || "").toLowerCase();
|
|
22356
22402
|
return ![
|
|
@@ -22362,22 +22408,22 @@ function yg(e) {
|
|
|
22362
22408
|
"file"
|
|
22363
22409
|
].includes(t);
|
|
22364
22410
|
}
|
|
22365
|
-
function
|
|
22366
|
-
if (!
|
|
22411
|
+
function Pg(e) {
|
|
22412
|
+
if (!Ng(e)) return !1;
|
|
22367
22413
|
let t = (e.name || "").toLowerCase(), n = (e.id || "").toLowerCase(), r = [
|
|
22368
22414
|
e.name,
|
|
22369
22415
|
e.id,
|
|
22370
22416
|
e.placeholder,
|
|
22371
|
-
|
|
22417
|
+
xg(e),
|
|
22372
22418
|
e.getAttribute("aria-label")
|
|
22373
22419
|
].filter(Boolean).join(" ").toLowerCase();
|
|
22374
22420
|
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);
|
|
22375
22421
|
}
|
|
22376
|
-
function
|
|
22377
|
-
let r = String(t ?? ""), i = String(n ?? ""), a =
|
|
22422
|
+
function Fg(e, t, n) {
|
|
22423
|
+
let r = String(t ?? ""), i = String(n ?? ""), a = Rg(e, r) || kg(e, r) || Ag(e, r, i);
|
|
22378
22424
|
if (!a) return [];
|
|
22379
22425
|
let o = new Set([a]);
|
|
22380
|
-
if (
|
|
22426
|
+
if (jg(i) && Mg(r)) for (let t of e) t !== a && Pg(t) && o.add(t);
|
|
22381
22427
|
let s = Array.from(o);
|
|
22382
22428
|
return s.sort((e, t) => {
|
|
22383
22429
|
if (e === t) return 0;
|
|
@@ -22385,7 +22431,7 @@ function xg(e, t, n) {
|
|
|
22385
22431
|
return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
|
|
22386
22432
|
}), s;
|
|
22387
22433
|
}
|
|
22388
|
-
function
|
|
22434
|
+
function Ig(e, t) {
|
|
22389
22435
|
try {
|
|
22390
22436
|
if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
|
|
22391
22437
|
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
|
|
@@ -22400,17 +22446,17 @@ function Sg(e, t) {
|
|
|
22400
22446
|
return Infinity;
|
|
22401
22447
|
}
|
|
22402
22448
|
}
|
|
22403
|
-
function
|
|
22449
|
+
function Lg(e) {
|
|
22404
22450
|
if (!e || typeof e != "string") return null;
|
|
22405
22451
|
let t = null;
|
|
22406
|
-
return
|
|
22452
|
+
return yg((n) => {
|
|
22407
22453
|
try {
|
|
22408
22454
|
let r = n.getElementById(e);
|
|
22409
|
-
r && !
|
|
22455
|
+
r && !hg(r) && r.matches?.("input, select, textarea") && (t = r);
|
|
22410
22456
|
} catch {}
|
|
22411
22457
|
}), t;
|
|
22412
22458
|
}
|
|
22413
|
-
function
|
|
22459
|
+
function Rg(e, t) {
|
|
22414
22460
|
let n = String(t ?? "").trim();
|
|
22415
22461
|
if (!n) return null;
|
|
22416
22462
|
let r = n.match(/^name:\s*([\w.-]+)$/i);
|
|
@@ -22420,12 +22466,12 @@ function wg(e, t) {
|
|
|
22420
22466
|
}
|
|
22421
22467
|
let i = n.match(/^id:\s*([\w.-]+)$/i);
|
|
22422
22468
|
if (i) {
|
|
22423
|
-
let e =
|
|
22469
|
+
let e = Lg(i[1]);
|
|
22424
22470
|
if (e) return e;
|
|
22425
22471
|
}
|
|
22426
22472
|
let a = n.startsWith("#") ? n.slice(1) : n;
|
|
22427
22473
|
if (/^[\w-]+$/.test(a)) {
|
|
22428
|
-
let e =
|
|
22474
|
+
let e = Lg(a);
|
|
22429
22475
|
if (e) return e;
|
|
22430
22476
|
}
|
|
22431
22477
|
let o = n.toLowerCase().replace(/\s+/g, " ");
|
|
@@ -22435,7 +22481,7 @@ function wg(e, t) {
|
|
|
22435
22481
|
}
|
|
22436
22482
|
return null;
|
|
22437
22483
|
}
|
|
22438
|
-
function
|
|
22484
|
+
function zg(e, t) {
|
|
22439
22485
|
let n = String(t || "").toLowerCase().trim();
|
|
22440
22486
|
if (!n) return 0;
|
|
22441
22487
|
let r = [
|
|
@@ -22452,13 +22498,13 @@ function Tg(e, t) {
|
|
|
22452
22498
|
for (let e of i) r.includes(e) && (a += 1);
|
|
22453
22499
|
return a / i.length * 92;
|
|
22454
22500
|
}
|
|
22455
|
-
function
|
|
22501
|
+
function Bg(e, t) {
|
|
22456
22502
|
let n = [];
|
|
22457
|
-
|
|
22503
|
+
yg((e) => {
|
|
22458
22504
|
n.push(...Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
|
|
22459
|
-
if (
|
|
22505
|
+
if (hg(e) || e.disabled) return !1;
|
|
22460
22506
|
try {
|
|
22461
|
-
let t =
|
|
22507
|
+
let t = vg(e);
|
|
22462
22508
|
if (t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0) return !1;
|
|
22463
22509
|
} catch {}
|
|
22464
22510
|
return !0;
|
|
@@ -22466,7 +22512,7 @@ function Eg(e, t) {
|
|
|
22466
22512
|
});
|
|
22467
22513
|
let r = 0, i = n.map((t) => ({
|
|
22468
22514
|
el: t,
|
|
22469
|
-
s:
|
|
22515
|
+
s: zg(t, e)
|
|
22470
22516
|
}));
|
|
22471
22517
|
for (let { s: e } of i) e > r && (r = e);
|
|
22472
22518
|
if (r < 36) return null;
|
|
@@ -22476,14 +22522,14 @@ function Eg(e, t) {
|
|
|
22476
22522
|
if (o.length) {
|
|
22477
22523
|
let e = a[0], t = Infinity;
|
|
22478
22524
|
for (let n of a) for (let r of o) {
|
|
22479
|
-
let i =
|
|
22525
|
+
let i = Ig(n, r);
|
|
22480
22526
|
i < t && (t = i, e = n);
|
|
22481
22527
|
}
|
|
22482
22528
|
return e;
|
|
22483
22529
|
}
|
|
22484
22530
|
return a[0];
|
|
22485
22531
|
}
|
|
22486
|
-
function
|
|
22532
|
+
function Vg(e) {
|
|
22487
22533
|
if (e == null) return {};
|
|
22488
22534
|
if (typeof e == "string") {
|
|
22489
22535
|
let t = e.trim();
|
|
@@ -22496,8 +22542,8 @@ function Dg(e) {
|
|
|
22496
22542
|
}
|
|
22497
22543
|
return e;
|
|
22498
22544
|
}
|
|
22499
|
-
function
|
|
22500
|
-
let t =
|
|
22545
|
+
function Hg(e) {
|
|
22546
|
+
let t = Vg(e);
|
|
22501
22547
|
if (Array.isArray(t) && t.length > 0) {
|
|
22502
22548
|
let e = t[0];
|
|
22503
22549
|
if (e?.field_key != null || e?.fieldKey != null) return t.map((e) => ({
|
|
@@ -22525,12 +22571,12 @@ function Og(e) {
|
|
|
22525
22571
|
value: e?.value ?? e?.Value
|
|
22526
22572
|
})) : [];
|
|
22527
22573
|
}
|
|
22528
|
-
function
|
|
22574
|
+
function Ug(e) {
|
|
22529
22575
|
if (!e || typeof e != "string") return e;
|
|
22530
22576
|
let t = e.trim();
|
|
22531
22577
|
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);
|
|
22532
22578
|
}
|
|
22533
|
-
function
|
|
22579
|
+
function Wg(e) {
|
|
22534
22580
|
if (!e || typeof e != "string") return e;
|
|
22535
22581
|
let t = {
|
|
22536
22582
|
zero: "0",
|
|
@@ -22549,7 +22595,7 @@ function Ag(e) {
|
|
|
22549
22595
|
for (let [e, r] of Object.entries(t)) n = n.replace(RegExp(`\\b${e}\\b`, "g"), r);
|
|
22550
22596
|
return n = n.replace(/[^\d+]/g, ""), n;
|
|
22551
22597
|
}
|
|
22552
|
-
function
|
|
22598
|
+
function Gg(e) {
|
|
22553
22599
|
if (!e || typeof e != "string") return [];
|
|
22554
22600
|
let t = e.trim();
|
|
22555
22601
|
if (!t || /\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t)) return [];
|
|
@@ -22568,7 +22614,7 @@ function jg(e) {
|
|
|
22568
22614
|
}
|
|
22569
22615
|
return [];
|
|
22570
22616
|
}
|
|
22571
|
-
function
|
|
22617
|
+
function Kg(e) {
|
|
22572
22618
|
if (!e || typeof e != "string") return [];
|
|
22573
22619
|
let t = e.trim();
|
|
22574
22620
|
if (!t) return [];
|
|
@@ -22580,7 +22626,7 @@ function Mg(e) {
|
|
|
22580
22626
|
field_key: e,
|
|
22581
22627
|
value: i
|
|
22582
22628
|
}));
|
|
22583
|
-
}, o =
|
|
22629
|
+
}, o = Ug(t), s = i.test(o), c = o.match(/^\s*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\s*$/i);
|
|
22584
22630
|
if (c) return a("Email Address", c[1]), n;
|
|
22585
22631
|
if (!i.test(t) && s) {
|
|
22586
22632
|
let e = o.match(i);
|
|
@@ -22608,17 +22654,17 @@ function Mg(e) {
|
|
|
22608
22654
|
}
|
|
22609
22655
|
return n;
|
|
22610
22656
|
}
|
|
22611
|
-
function
|
|
22657
|
+
function qg(e) {
|
|
22612
22658
|
if (!e || typeof e != "object") return null;
|
|
22613
22659
|
let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
|
|
22614
22660
|
return t == null ? null : String(t).trim() || null;
|
|
22615
22661
|
}
|
|
22616
|
-
function
|
|
22662
|
+
function Jg(e) {
|
|
22617
22663
|
if (!e || typeof e != "object") return null;
|
|
22618
22664
|
let t = e.query ?? e.q ?? e.search ?? e.text ?? e.keywords;
|
|
22619
22665
|
return t == null ? null : String(t).trim() || null;
|
|
22620
22666
|
}
|
|
22621
|
-
function
|
|
22667
|
+
function Yg(e) {
|
|
22622
22668
|
let t = e.ownerDocument?.defaultView || window, n = e.tagName === "TEXTAREA" ? t.HTMLTextAreaElement.prototype : t.HTMLInputElement.prototype, r = Object.getOwnPropertyDescriptor(n, "value");
|
|
22623
22669
|
return (e, t) => {
|
|
22624
22670
|
try {
|
|
@@ -22627,7 +22673,7 @@ function Fg(e) {
|
|
|
22627
22673
|
r?.set ? r.set.call(e, t) : e.value = t;
|
|
22628
22674
|
};
|
|
22629
22675
|
}
|
|
22630
|
-
async function
|
|
22676
|
+
async function Xg(e, t, n) {
|
|
22631
22677
|
if (!n?.skipScroll) try {
|
|
22632
22678
|
e.scrollIntoView({
|
|
22633
22679
|
behavior: "smooth",
|
|
@@ -22640,10 +22686,10 @@ async function Ig(e, t, n) {
|
|
|
22640
22686
|
} catch {}
|
|
22641
22687
|
}
|
|
22642
22688
|
try {
|
|
22643
|
-
await
|
|
22689
|
+
await ug(e);
|
|
22644
22690
|
} catch {}
|
|
22645
22691
|
try {
|
|
22646
|
-
|
|
22692
|
+
sg(e);
|
|
22647
22693
|
} catch {}
|
|
22648
22694
|
await new Promise((e) => setTimeout(e, 180));
|
|
22649
22695
|
try {
|
|
@@ -22658,15 +22704,33 @@ async function Ig(e, t, n) {
|
|
|
22658
22704
|
cancelable: !0,
|
|
22659
22705
|
composed: !0
|
|
22660
22706
|
};
|
|
22661
|
-
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)),
|
|
22707
|
+
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;
|
|
22662
22708
|
if (i === "checkbox" || i === "radio") return e.checked = [
|
|
22663
22709
|
"1",
|
|
22664
22710
|
"true",
|
|
22665
22711
|
"yes",
|
|
22666
22712
|
"on"
|
|
22667
|
-
].includes(String(t).toLowerCase().trim()), e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a)),
|
|
22713
|
+
].includes(String(t).toLowerCase().trim()), e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a)), cg(e), !0;
|
|
22668
22714
|
let o = String(t);
|
|
22669
|
-
r === "INPUT" || r === "TEXTAREA"
|
|
22715
|
+
if (r === "INPUT" || r === "TEXTAREA") {
|
|
22716
|
+
let t = Yg(e);
|
|
22717
|
+
try {
|
|
22718
|
+
await eg(e, o, t);
|
|
22719
|
+
} catch {
|
|
22720
|
+
t(e, o);
|
|
22721
|
+
}
|
|
22722
|
+
e.value !== o && t(e, o);
|
|
22723
|
+
} else e.value = o;
|
|
22724
|
+
try {
|
|
22725
|
+
e.dispatchEvent(new InputEvent("input", {
|
|
22726
|
+
...a,
|
|
22727
|
+
inputType: "insertText",
|
|
22728
|
+
data: o
|
|
22729
|
+
}));
|
|
22730
|
+
} catch {
|
|
22731
|
+
e.dispatchEvent(new Event("input", a));
|
|
22732
|
+
}
|
|
22733
|
+
e.dispatchEvent(new Event("change", a)), e.dispatchEvent(new Event("blur", a));
|
|
22670
22734
|
try {
|
|
22671
22735
|
e.focus({ preventScroll: !0 });
|
|
22672
22736
|
} catch {}
|
|
@@ -22677,16 +22741,13 @@ async function Ig(e, t, n) {
|
|
|
22677
22741
|
} catch {}
|
|
22678
22742
|
});
|
|
22679
22743
|
} catch {}
|
|
22680
|
-
|
|
22681
|
-
Gh(e);
|
|
22682
|
-
} catch {}
|
|
22683
|
-
return !0;
|
|
22744
|
+
return cg(e), !0;
|
|
22684
22745
|
}
|
|
22685
|
-
function
|
|
22686
|
-
let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
|
|
22746
|
+
function Zg(e) {
|
|
22747
|
+
let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = null, o = {
|
|
22687
22748
|
navigate_to_page: async (n) => {
|
|
22688
22749
|
$("navigate_to_page ▶ raw parameters:", n);
|
|
22689
|
-
let r =
|
|
22750
|
+
let r = Vg(n), i = qg(r), a = r.section_text ?? r.sectionText ?? r.section;
|
|
22690
22751
|
if ($("navigate_to_page · coerced:", {
|
|
22691
22752
|
url: i,
|
|
22692
22753
|
sectionText: a
|
|
@@ -22694,16 +22755,16 @@ function Lg(e) {
|
|
|
22694
22755
|
let e = "Missing url: pass a string url, path like /pricing, or JSON with a url field.";
|
|
22695
22756
|
return $("navigate_to_page ✖", e), e;
|
|
22696
22757
|
}
|
|
22697
|
-
if (
|
|
22758
|
+
if (rg(`Navigating to ${i.replace(/^https?:\/\/[^/]+/, "") || "/"}…`), ag(), !await ln(i, {
|
|
22698
22759
|
siteId: t,
|
|
22699
22760
|
apiBaseUrl: e.apiBaseUrl
|
|
22700
22761
|
})) {
|
|
22701
|
-
|
|
22762
|
+
og(), ig(200);
|
|
22702
22763
|
let e = "That page is not available in the site index; answer without navigating.";
|
|
22703
22764
|
return $("navigate_to_page ✖ blocked", e), e;
|
|
22704
22765
|
}
|
|
22705
22766
|
try {
|
|
22706
|
-
if ($("navigate_to_page → shadowNavigate", i), await dn(i, { sectionText: a || void 0 }), await new Promise((e) => setTimeout(e, 600)),
|
|
22767
|
+
if ($("navigate_to_page → shadowNavigate", i), await dn(i, { sectionText: a || void 0 }), await new Promise((e) => setTimeout(e, 600)), og(), ig(300), a && typeof a == "string") {
|
|
22707
22768
|
let e = rn(null, a);
|
|
22708
22769
|
e && an(e), $("navigate_to_page · highlight", {
|
|
22709
22770
|
sectionText: a,
|
|
@@ -22712,7 +22773,7 @@ function Lg(e) {
|
|
|
22712
22773
|
}
|
|
22713
22774
|
let e = "";
|
|
22714
22775
|
try {
|
|
22715
|
-
let t =
|
|
22776
|
+
let t = Cg(), n = wg();
|
|
22716
22777
|
if (t.length > 0) {
|
|
22717
22778
|
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(", ");
|
|
22718
22779
|
e = ` This page has a form with fields: [${r}]` + (i ? ` and buttons: [${i}].` : ".") + " Call list_page_forms then start filling.";
|
|
@@ -22721,22 +22782,22 @@ function Lg(e) {
|
|
|
22721
22782
|
let t = `OK_NAVIGATION ${i}${e}`;
|
|
22722
22783
|
return $("navigate_to_page ✓", t), t;
|
|
22723
22784
|
} catch (e) {
|
|
22724
|
-
|
|
22785
|
+
og(), ig(200);
|
|
22725
22786
|
let t = `Navigation error: ${e?.message || String(e)}`;
|
|
22726
22787
|
return $("navigate_to_page ✖", t), t;
|
|
22727
22788
|
}
|
|
22728
22789
|
},
|
|
22729
22790
|
highlight_on_page: async (e) => {
|
|
22730
22791
|
$("highlight_on_page ▶", e);
|
|
22731
|
-
let t =
|
|
22792
|
+
let t = Vg(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText, i = rn(n || null, r || null);
|
|
22732
22793
|
return i ? (an(i), $("highlight_on_page ✓"), "Highlighted the section.") : ($("highlight_on_page ✖ no element"), "Could not find that section on the page.");
|
|
22733
22794
|
},
|
|
22734
22795
|
search_site_content: async (e) => {
|
|
22735
22796
|
$("search_site_content ▶", e);
|
|
22736
|
-
let r =
|
|
22737
|
-
if ($("search_site_content · query:", r, "siteId:", t, "apiBase:", n || "(empty)"),
|
|
22738
|
-
if (!t) return
|
|
22739
|
-
if (!n) return
|
|
22797
|
+
let r = Jg(Vg(e));
|
|
22798
|
+
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.";
|
|
22799
|
+
if (!t) return ig(), $("search_site_content ✖ no siteId"), "Site is not configured for search.";
|
|
22800
|
+
if (!n) return ig(), $("search_site_content ✖ no api base"), "API base URL is missing; cannot search.";
|
|
22740
22801
|
try {
|
|
22741
22802
|
let e = `${n}/api/site-tools/search`;
|
|
22742
22803
|
$("search_site_content → POST", e);
|
|
@@ -22749,77 +22810,88 @@ function Lg(e) {
|
|
|
22749
22810
|
currentUrl: typeof window < "u" ? window.location.href : ""
|
|
22750
22811
|
})
|
|
22751
22812
|
}), a = await i.json();
|
|
22752
|
-
if ($("search_site_content · HTTP", i.status, "success:", a.success),
|
|
22813
|
+
if ($("search_site_content · HTTP", i.status, "success:", a.success), ig(200), !a.success) {
|
|
22753
22814
|
let e = a.error || "Search failed.";
|
|
22754
22815
|
return $("search_site_content ✖", e), e;
|
|
22755
22816
|
}
|
|
22756
22817
|
let o = a.results || [];
|
|
22757
22818
|
return $("search_site_content ✓", `${o.length} result(s)`, o.slice(0, 3).map((e) => e?.url || e)), JSON.stringify(o);
|
|
22758
22819
|
} catch (e) {
|
|
22759
|
-
|
|
22820
|
+
ig();
|
|
22760
22821
|
let t = `Search error: ${e.message || "network"}`;
|
|
22761
22822
|
return $("search_site_content ✖", t), t;
|
|
22762
22823
|
}
|
|
22763
22824
|
},
|
|
22764
|
-
end_voice_session: async () => ($("end_voice_session ▶"),
|
|
22825
|
+
end_voice_session: async () => ($("end_voice_session ▶"), rg("Ending voice session…", {
|
|
22765
22826
|
icon: "👋",
|
|
22766
22827
|
spinner: !1,
|
|
22767
22828
|
duration: 2e3
|
|
22768
|
-
}),
|
|
22829
|
+
}), dg(!0), lg(), typeof e.requestEndSession == "function" && e.requestEndSession(), "Voice session is ending."),
|
|
22769
22830
|
list_page_forms: async () => {
|
|
22770
|
-
let e =
|
|
22771
|
-
return $("list_page_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), JSON.stringify({
|
|
22831
|
+
let e = Cg(), t = wg();
|
|
22832
|
+
return $("list_page_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), a = null, JSON.stringify({
|
|
22772
22833
|
fields: e,
|
|
22773
22834
|
buttons: t,
|
|
22774
|
-
hint: "
|
|
22835
|
+
hint: "Fields are grouped by formIndex/formName. Work with ONE form at a time — only fill fields from the same formIndex. Do not jump to fields in a different form. field_key: use placeholder, label, name, or id from this list. click_page_button picks the button nearest the filled fields."
|
|
22775
22836
|
});
|
|
22776
22837
|
},
|
|
22777
22838
|
fill_form_fields: async (e) => {
|
|
22778
22839
|
try {
|
|
22779
22840
|
$("fill_form_fields ▶ raw:", e);
|
|
22780
|
-
let t =
|
|
22841
|
+
let t = Hg(e);
|
|
22781
22842
|
if (!t.length && r) {
|
|
22782
|
-
let e = r(), n =
|
|
22783
|
-
n.length ? $("fill_form_fields · inferred URL from last user utterance (model omitted usable fields):", n) : (n =
|
|
22843
|
+
let e = r(), n = Gg(e);
|
|
22844
|
+
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);
|
|
22784
22845
|
}
|
|
22785
22846
|
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.";
|
|
22786
|
-
t.length > 1 &&
|
|
22847
|
+
t.length > 1 && rg(`Filling ${t.length} fields…`);
|
|
22787
22848
|
let n = [];
|
|
22788
22849
|
for (let e of t) {
|
|
22789
22850
|
let t = e?.field_key ?? e?.fieldKey, r = e?.value;
|
|
22790
22851
|
if (t == null || r == null) continue;
|
|
22791
|
-
let
|
|
22792
|
-
/email|e-mail|mail/.test(
|
|
22793
|
-
let
|
|
22794
|
-
|
|
22795
|
-
|
|
22796
|
-
|
|
22797
|
-
|
|
22798
|
-
|
|
22799
|
-
|
|
22852
|
+
let o = String(t).toLowerCase();
|
|
22853
|
+
/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);
|
|
22854
|
+
let s = Sg(), c = s;
|
|
22855
|
+
if (a) {
|
|
22856
|
+
let e = s.filter((e) => gg(e) === a);
|
|
22857
|
+
e.length > 0 && (c = e, $("fill_form_fields · scoped to active form, inputs:", e.length));
|
|
22858
|
+
}
|
|
22859
|
+
$("fill_form_fields · visible inputs count:", s.length, "scoped:", c.length);
|
|
22860
|
+
let l = !1;
|
|
22861
|
+
for (let e of [c, ...c === s ? [] : [s]]) {
|
|
22862
|
+
let o = Fg(e, String(t), r);
|
|
22863
|
+
if (o.length) {
|
|
22864
|
+
for (let e = 0; e < o.length; e++) await Xg(o[e], r, { skipScroll: e > 0 }), await new Promise((e) => setTimeout(e, 80));
|
|
22865
|
+
i = o, a = gg(o[0]) || a, n.push(String(t)), l = !0;
|
|
22866
|
+
break;
|
|
22867
|
+
}
|
|
22868
|
+
let s = Rg(e, String(t));
|
|
22869
|
+
if (s ||= kg(e, String(t)), s ||= Ag(e, String(t), r), s) {
|
|
22870
|
+
await Xg(s, r), i = [s], a = gg(s) || a, n.push(String(t)), l = !0;
|
|
22871
|
+
break;
|
|
22872
|
+
}
|
|
22800
22873
|
}
|
|
22801
|
-
|
|
22802
|
-
c ||= hg(o, String(t)), c ||= gg(o, String(t), r), c ? (await Ig(c, r), i = [c], n.push(String(t))) : $("fill_form_fields · no match for field:", t);
|
|
22874
|
+
l || $("fill_form_fields · no match for field:", t);
|
|
22803
22875
|
}
|
|
22804
|
-
|
|
22876
|
+
ig(400);
|
|
22805
22877
|
try {
|
|
22806
|
-
|
|
22878
|
+
dg();
|
|
22807
22879
|
} catch {}
|
|
22808
22880
|
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.";
|
|
22809
|
-
let
|
|
22810
|
-
return $("fill_form_fields ✓",
|
|
22881
|
+
let o = `OK_FILLED: ${n.join(", ")}`;
|
|
22882
|
+
return $("fill_form_fields ✓", o), o;
|
|
22811
22883
|
} catch (e) {
|
|
22812
|
-
|
|
22884
|
+
ig(), lg(), dg(!0);
|
|
22813
22885
|
let t = `fill_form_fields error: ${e?.message || String(e)}`;
|
|
22814
22886
|
return $("fill_form_fields ✖", t), t;
|
|
22815
22887
|
}
|
|
22816
22888
|
},
|
|
22817
22889
|
click_page_button: async (e) => {
|
|
22818
|
-
let t =
|
|
22890
|
+
let t = Vg(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
|
|
22819
22891
|
if ($("click_page_button ▶", n), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
|
|
22820
|
-
|
|
22821
|
-
let r =
|
|
22822
|
-
if (!r) return
|
|
22892
|
+
rg(`Clicking "${n}"…`);
|
|
22893
|
+
let r = Bg(n, i);
|
|
22894
|
+
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.`;
|
|
22823
22895
|
try {
|
|
22824
22896
|
try {
|
|
22825
22897
|
r.scrollIntoView({
|
|
@@ -22831,44 +22903,60 @@ function Lg(e) {
|
|
|
22831
22903
|
r.scrollIntoView(!0);
|
|
22832
22904
|
}
|
|
22833
22905
|
try {
|
|
22834
|
-
await
|
|
22906
|
+
await ug(r);
|
|
22835
22907
|
} catch {}
|
|
22836
22908
|
try {
|
|
22837
|
-
|
|
22909
|
+
pg(r);
|
|
22838
22910
|
} catch {}
|
|
22839
22911
|
try {
|
|
22840
|
-
await
|
|
22912
|
+
await fg(r);
|
|
22841
22913
|
} catch {}
|
|
22914
|
+
let e = gg(r) || a, t = [];
|
|
22915
|
+
if (e) {
|
|
22916
|
+
let n = Array.from(e.querySelectorAll("input[required], textarea[required], select[required]")).filter((e) => !hg(e));
|
|
22917
|
+
for (let e of n) if (!(e.value || "").trim()) {
|
|
22918
|
+
let n = xg(e) || e.placeholder || e.name || e.type;
|
|
22919
|
+
t.push(n);
|
|
22920
|
+
}
|
|
22921
|
+
}
|
|
22922
|
+
if (t.length > 0) {
|
|
22923
|
+
ig(200);
|
|
22924
|
+
try {
|
|
22925
|
+
dg();
|
|
22926
|
+
} catch {}
|
|
22927
|
+
let e = `Cannot submit — these required fields are still empty: ${t.join(", ")}. Fill them first with fill_form_fields, then click again.`;
|
|
22928
|
+
return $("click_page_button ✖ empty required fields:", t), e;
|
|
22929
|
+
}
|
|
22842
22930
|
r.focus?.(), r.click();
|
|
22843
|
-
let
|
|
22844
|
-
|
|
22931
|
+
let n = (r.textContent || r.value || r.getAttribute("aria-label") || "").trim().slice(0, 80) || "button";
|
|
22932
|
+
ig(600);
|
|
22845
22933
|
try {
|
|
22846
|
-
|
|
22934
|
+
dg();
|
|
22847
22935
|
} catch {}
|
|
22848
|
-
|
|
22849
|
-
let
|
|
22850
|
-
return $("click_page_button ✓",
|
|
22936
|
+
lg(), a = null, i = [];
|
|
22937
|
+
let o = `OK_CLICK ${n}`;
|
|
22938
|
+
return $("click_page_button ✓", o), o;
|
|
22851
22939
|
} catch (e) {
|
|
22852
|
-
|
|
22940
|
+
ig(200), dg(!0);
|
|
22853
22941
|
let t = `Click failed: ${e?.message || String(e)}`;
|
|
22854
22942
|
return $("click_page_button ✖", t), t;
|
|
22855
22943
|
}
|
|
22856
22944
|
}
|
|
22857
22945
|
};
|
|
22858
22946
|
return {
|
|
22859
|
-
...
|
|
22860
|
-
navigateToPage:
|
|
22861
|
-
highlightOnPage:
|
|
22862
|
-
searchSiteContent:
|
|
22863
|
-
endVoiceSession:
|
|
22864
|
-
listPageForms:
|
|
22865
|
-
fillFormFields:
|
|
22866
|
-
clickPageButton:
|
|
22947
|
+
...o,
|
|
22948
|
+
navigateToPage: o.navigate_to_page,
|
|
22949
|
+
highlightOnPage: o.highlight_on_page,
|
|
22950
|
+
searchSiteContent: o.search_site_content,
|
|
22951
|
+
endVoiceSession: o.end_voice_session,
|
|
22952
|
+
listPageForms: o.list_page_forms,
|
|
22953
|
+
fillFormFields: o.fill_form_fields,
|
|
22954
|
+
clickPageButton: o.click_page_button
|
|
22867
22955
|
};
|
|
22868
22956
|
}
|
|
22869
22957
|
//#endregion
|
|
22870
22958
|
//#region src/utils/wrapVoiceToolsForLogging.js
|
|
22871
|
-
function
|
|
22959
|
+
function Qg(e) {
|
|
22872
22960
|
return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
|
|
22873
22961
|
let r = Zt();
|
|
22874
22962
|
r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
|
|
@@ -22878,22 +22966,22 @@ function Rg(e) {
|
|
|
22878
22966
|
}
|
|
22879
22967
|
//#endregion
|
|
22880
22968
|
//#region src/components/VoiceInterface.jsx
|
|
22881
|
-
var
|
|
22969
|
+
var $g = {
|
|
22882
22970
|
idle: "rgba(99,102,241,0.18)",
|
|
22883
22971
|
listening: "rgba(16,185,129,0.25)",
|
|
22884
22972
|
speaking: "rgba(245,158,11,0.25)",
|
|
22885
22973
|
error: "rgba(239,68,68,0.2)"
|
|
22886
|
-
},
|
|
22974
|
+
}, e_ = {
|
|
22887
22975
|
idle: "#6366f1",
|
|
22888
22976
|
listening: "#10b981",
|
|
22889
22977
|
speaking: "#f59e0b",
|
|
22890
22978
|
error: "#ef4444"
|
|
22891
22979
|
};
|
|
22892
|
-
function
|
|
22980
|
+
function t_(e, t) {
|
|
22893
22981
|
let n = (t || "").trim();
|
|
22894
22982
|
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;
|
|
22895
22983
|
}
|
|
22896
|
-
function
|
|
22984
|
+
function n_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, historyRef: d, hasSyncedRef: f, onMessageSync: p, onStartSync: m }) {
|
|
22897
22985
|
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 () => {
|
|
22898
22986
|
try {
|
|
22899
22987
|
await re.current?.endSession?.();
|
|
@@ -22910,7 +22998,7 @@ function Hg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
22910
22998
|
try {
|
|
22911
22999
|
if (await navigator.mediaDevices.getUserMedia({ audio: !0 }), t) return;
|
|
22912
23000
|
d.current = [], ae.current = "", se.current = !1;
|
|
22913
|
-
let i =
|
|
23001
|
+
let i = Qg(Zg({
|
|
22914
23002
|
siteId: r || null,
|
|
22915
23003
|
apiBaseUrl: a || null,
|
|
22916
23004
|
getLastUserVoiceText: () => ae.current,
|
|
@@ -22937,7 +23025,7 @@ function Hg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
22937
23025
|
message: r,
|
|
22938
23026
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
22939
23027
|
};
|
|
22940
|
-
n === "user" && (ae.current = r), d.current = [...d.current, i],
|
|
23028
|
+
n === "user" && (ae.current = r), d.current = [...d.current, i], t_(n, r) && queueMicrotask(() => {
|
|
22941
23029
|
se.current || (se.current = !0, oe.current?.());
|
|
22942
23030
|
});
|
|
22943
23031
|
},
|
|
@@ -22960,12 +23048,7 @@ function Hg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
22960
23048
|
} catch {
|
|
22961
23049
|
t = "[]";
|
|
22962
23050
|
}
|
|
22963
|
-
|
|
22964
|
-
try {
|
|
22965
|
-
let e = await i.search_site_content({ query: "pages" }), t = typeof e == "string" ? JSON.parse(e) : e;
|
|
22966
|
-
Array.isArray(t) && t.length && (n = ` Site pages available: ${t.map((e) => `${e.title || ""} (${e.url || ""})`).join(", ")}.`);
|
|
22967
|
-
} catch {}
|
|
22968
|
-
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.`);
|
|
23051
|
+
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.`);
|
|
22969
23052
|
} catch {}
|
|
22970
23053
|
typeof m == "function" && m();
|
|
22971
23054
|
} catch (e) {
|
|
@@ -22981,7 +23064,7 @@ function Hg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
22981
23064
|
d,
|
|
22982
23065
|
m
|
|
22983
23066
|
]);
|
|
22984
|
-
let ce = h === "listening" || h === "speaking", le =
|
|
23067
|
+
let ce = h === "listening" || h === "speaking", le = e_[h] || e_.idle, ue = $g[h] || $g.idle;
|
|
22985
23068
|
return /* @__PURE__ */ u("div", {
|
|
22986
23069
|
ref: ie,
|
|
22987
23070
|
style: {
|
|
@@ -23087,7 +23170,7 @@ function Hg({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23087
23170
|
}
|
|
23088
23171
|
//#endregion
|
|
23089
23172
|
//#region src/components/FlowEngageWidget.jsx
|
|
23090
|
-
var
|
|
23173
|
+
var r_ = [
|
|
23091
23174
|
{
|
|
23092
23175
|
key: "become_client",
|
|
23093
23176
|
label: "Become a Client"
|
|
@@ -23108,7 +23191,7 @@ var Ug = [
|
|
|
23108
23191
|
key: "looking_for_job",
|
|
23109
23192
|
label: "Looking for a Job"
|
|
23110
23193
|
}
|
|
23111
|
-
],
|
|
23194
|
+
], i_ = () => /* @__PURE__ */ l("div", {
|
|
23112
23195
|
style: {
|
|
23113
23196
|
display: "flex",
|
|
23114
23197
|
marginBottom: "12px",
|
|
@@ -23139,7 +23222,7 @@ var Ug = [
|
|
|
23139
23222
|
} }, 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 " })]
|
|
23140
23223
|
})
|
|
23141
23224
|
});
|
|
23142
|
-
function
|
|
23225
|
+
function a_() {
|
|
23143
23226
|
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("");
|
|
23144
23227
|
i(() => {
|
|
23145
23228
|
try {
|
|
@@ -23167,7 +23250,7 @@ function Gg() {
|
|
|
23167
23250
|
outline: "none",
|
|
23168
23251
|
fontFamily: "ui-sans-serif, system-ui, sans-serif",
|
|
23169
23252
|
...c ? {} : Ue
|
|
23170
|
-
}, Ge = S.recommendations?.[ue] || Re.recommendations?.[ue] ||
|
|
23253
|
+
}, 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(() => {
|
|
23171
23254
|
let e = o.findIndex((e) => e.sender === "user");
|
|
23172
23255
|
return e === -1 ? !1 : o.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
23173
23256
|
}, [o]), rt = !h && tt && nt;
|
|
@@ -23295,7 +23378,7 @@ function Gg() {
|
|
|
23295
23378
|
flexDirection: "column"
|
|
23296
23379
|
},
|
|
23297
23380
|
className: "fe-screen-fade-in",
|
|
23298
|
-
children: /* @__PURE__ */ l(
|
|
23381
|
+
children: /* @__PURE__ */ l(n_, {
|
|
23299
23382
|
agentId: T,
|
|
23300
23383
|
chatId: r,
|
|
23301
23384
|
siteId: Ye,
|
|
@@ -23328,7 +23411,7 @@ function Gg() {
|
|
|
23328
23411
|
isAiTyping: ee,
|
|
23329
23412
|
isAgentTyping: g,
|
|
23330
23413
|
setReplyContext: Me,
|
|
23331
|
-
TypingDots:
|
|
23414
|
+
TypingDots: i_,
|
|
23332
23415
|
primaryColor: Ve,
|
|
23333
23416
|
agentHeadshot: $e,
|
|
23334
23417
|
agentDisplayName: p || Ze
|
|
@@ -23407,4 +23490,4 @@ function Gg() {
|
|
|
23407
23490
|
}) : null;
|
|
23408
23491
|
}
|
|
23409
23492
|
//#endregion
|
|
23410
|
-
export { vn as FlowEngageProvider,
|
|
23493
|
+
export { vn as FlowEngageProvider, a_ as FlowEngageWidget, Xt as useFlowEngage };
|