@flowengage/react-chatbot 1.1.1 → 1.1.2
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.
|
@@ -22273,7 +22273,24 @@ function Sg() {
|
|
|
22273
22273
|
}));
|
|
22274
22274
|
}), e;
|
|
22275
22275
|
}
|
|
22276
|
-
function Cg() {
|
|
22276
|
+
function Cg(e) {
|
|
22277
|
+
if (!e || typeof e.closest != "function") return !1;
|
|
22278
|
+
try {
|
|
22279
|
+
return !!e.closest("footer, [role=\"contentinfo\"], #footer, .site-footer, [class*=\"footer\"], [id*=\"footer\"]");
|
|
22280
|
+
} catch {
|
|
22281
|
+
return !1;
|
|
22282
|
+
}
|
|
22283
|
+
}
|
|
22284
|
+
function wg() {
|
|
22285
|
+
let e = Sg();
|
|
22286
|
+
for (let t of e) {
|
|
22287
|
+
if ((t.type || "").toLowerCase() !== "email" || Cg(t)) continue;
|
|
22288
|
+
let e = gg(t);
|
|
22289
|
+
if (e) return e;
|
|
22290
|
+
}
|
|
22291
|
+
return null;
|
|
22292
|
+
}
|
|
22293
|
+
function Tg() {
|
|
22277
22294
|
let e = Sg(), t = /* @__PURE__ */ new Map(), n = 0;
|
|
22278
22295
|
return e.map((e, r) => {
|
|
22279
22296
|
let i = gg(e), a = i || "__orphan__";
|
|
@@ -22292,7 +22309,7 @@ function Cg() {
|
|
|
22292
22309
|
};
|
|
22293
22310
|
});
|
|
22294
22311
|
}
|
|
22295
|
-
function
|
|
22312
|
+
function Eg() {
|
|
22296
22313
|
let e = [];
|
|
22297
22314
|
return yg((t) => {
|
|
22298
22315
|
e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
|
|
@@ -22310,18 +22327,18 @@ function wg() {
|
|
|
22310
22327
|
type: e.type || e.tagName
|
|
22311
22328
|
}));
|
|
22312
22329
|
}
|
|
22313
|
-
function
|
|
22330
|
+
function Dg(e) {
|
|
22314
22331
|
return String(e || "").toLowerCase().replace(/\u00a0/g, " ").replace(/\*/g, "").replace(/\s+/g, " ").trim();
|
|
22315
22332
|
}
|
|
22316
|
-
function
|
|
22317
|
-
let t =
|
|
22333
|
+
function Og(e) {
|
|
22334
|
+
let t = Dg(e);
|
|
22318
22335
|
return t = t.replace(/\s+field\s*$/i, "").trim(), t;
|
|
22319
22336
|
}
|
|
22320
|
-
function
|
|
22321
|
-
let n =
|
|
22337
|
+
function kg(e, t) {
|
|
22338
|
+
let n = Og(t);
|
|
22322
22339
|
if (!n) return 0;
|
|
22323
22340
|
let r = (e.name || "").toLowerCase(), i = (e.id || "").toLowerCase();
|
|
22324
|
-
if (r === "url" && /url|website|domain|site|
|
|
22341
|
+
if (r === "url" && /url|website|domain|audit|conduct|site(\s|$)|page(\s|$)/.test(n) && !/email|e-mail|mail|name|message|phone/.test(n) || (i === "url-input" || i.endsWith("-url-input")) && /url|website|domain|audit|conduct/.test(n) && !/email|e-mail|mail|name|message|phone/.test(n)) return 100;
|
|
22325
22342
|
let a = (e.type || "").toLowerCase();
|
|
22326
22343
|
if (a === "email" && /email|e-mail|mail/.test(n)) return 100;
|
|
22327
22344
|
if (a === "tel" && /phone|mobile|tel|cell/.test(n)) return 95;
|
|
@@ -22335,7 +22352,7 @@ function Dg(e, t) {
|
|
|
22335
22352
|
e.getAttribute("title"),
|
|
22336
22353
|
e.getAttribute("data-testid"),
|
|
22337
22354
|
e.getAttribute("autocomplete")
|
|
22338
|
-
].filter(Boolean).map((e) =>
|
|
22355
|
+
].filter(Boolean).map((e) => Dg(e)), s = 0;
|
|
22339
22356
|
for (let e of o) {
|
|
22340
22357
|
if (!e) continue;
|
|
22341
22358
|
if (e === n) {
|
|
@@ -22355,18 +22372,18 @@ function Dg(e, t) {
|
|
|
22355
22372
|
}
|
|
22356
22373
|
return s;
|
|
22357
22374
|
}
|
|
22358
|
-
var
|
|
22359
|
-
function
|
|
22375
|
+
var Ag = 22;
|
|
22376
|
+
function jg(e, t) {
|
|
22360
22377
|
let n = null, r = 0;
|
|
22361
22378
|
for (let i of e) {
|
|
22362
|
-
let e =
|
|
22379
|
+
let e = kg(i, t);
|
|
22363
22380
|
e > r && (r = e, n = i);
|
|
22364
22381
|
}
|
|
22365
|
-
return !n || r <
|
|
22382
|
+
return !n || r < Ag ? null : n;
|
|
22366
22383
|
}
|
|
22367
|
-
function
|
|
22384
|
+
function Mg(e, t, n) {
|
|
22368
22385
|
let r = String(t || "").toLowerCase().trim(), i = String(n || "").trim();
|
|
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;
|
|
22386
|
+
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i) || !(/^https?:\/\//i.test(i) || /\.\w{2,}(\/|\s|$)/.test(i) || r.includes("url") || r.includes("website") || r.includes("domain") || r.includes("site"))) return null;
|
|
22370
22387
|
let a = null, o = 0;
|
|
22371
22388
|
for (let t of e) {
|
|
22372
22389
|
if (t.tagName !== "INPUT" && t.tagName !== "TEXTAREA") continue;
|
|
@@ -22392,15 +22409,15 @@ function Ag(e, t, n) {
|
|
|
22392
22409
|
}
|
|
22393
22410
|
return !a || o < 42 ? null : a;
|
|
22394
22411
|
}
|
|
22395
|
-
function
|
|
22412
|
+
function Ng(e) {
|
|
22396
22413
|
let t = String(e ?? "").trim();
|
|
22397
|
-
return t ? /^https?:\/\//i.test(t) ? !0 : /\.\w{2,}(\/|\s|$)/.test(t)
|
|
22414
|
+
return !t || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t) ? !1 : /^https?:\/\//i.test(t) ? !0 : /\.\w{2,}(\/|\s|$)/.test(t);
|
|
22398
22415
|
}
|
|
22399
|
-
function
|
|
22416
|
+
function Pg(e) {
|
|
22400
22417
|
let t = String(e ?? "").toLowerCase().trim();
|
|
22401
22418
|
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;
|
|
22402
22419
|
}
|
|
22403
|
-
function
|
|
22420
|
+
function Fg(e) {
|
|
22404
22421
|
if (!e || e.tagName !== "INPUT" && e.tagName !== "TEXTAREA") return !1;
|
|
22405
22422
|
let t = (e.type || "").toLowerCase();
|
|
22406
22423
|
return ![
|
|
@@ -22412,8 +22429,8 @@ function Ng(e) {
|
|
|
22412
22429
|
"file"
|
|
22413
22430
|
].includes(t);
|
|
22414
22431
|
}
|
|
22415
|
-
function
|
|
22416
|
-
if (!
|
|
22432
|
+
function Ig(e) {
|
|
22433
|
+
if (!Fg(e)) return !1;
|
|
22417
22434
|
let t = (e.name || "").toLowerCase(), n = (e.id || "").toLowerCase(), r = [
|
|
22418
22435
|
e.name,
|
|
22419
22436
|
e.id,
|
|
@@ -22423,11 +22440,11 @@ function Pg(e) {
|
|
|
22423
22440
|
].filter(Boolean).join(" ").toLowerCase();
|
|
22424
22441
|
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);
|
|
22425
22442
|
}
|
|
22426
|
-
function
|
|
22427
|
-
let r = String(t ?? ""), i = String(n ?? ""), a =
|
|
22443
|
+
function Lg(e, t, n) {
|
|
22444
|
+
let r = String(t ?? ""), i = String(n ?? ""), a = Bg(e, r) || jg(e, r) || Mg(e, r, i);
|
|
22428
22445
|
if (!a) return [];
|
|
22429
22446
|
let o = new Set([a]);
|
|
22430
|
-
if (
|
|
22447
|
+
if (Ng(i) && Pg(r)) for (let t of e) t !== a && Ig(t) && o.add(t);
|
|
22431
22448
|
let s = Array.from(o);
|
|
22432
22449
|
return s.sort((e, t) => {
|
|
22433
22450
|
if (e === t) return 0;
|
|
@@ -22435,7 +22452,7 @@ function Fg(e, t, n) {
|
|
|
22435
22452
|
return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
|
|
22436
22453
|
}), s;
|
|
22437
22454
|
}
|
|
22438
|
-
function
|
|
22455
|
+
function Rg(e, t) {
|
|
22439
22456
|
try {
|
|
22440
22457
|
if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
|
|
22441
22458
|
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
|
|
@@ -22450,7 +22467,7 @@ function Ig(e, t) {
|
|
|
22450
22467
|
return Infinity;
|
|
22451
22468
|
}
|
|
22452
22469
|
}
|
|
22453
|
-
function
|
|
22470
|
+
function zg(e) {
|
|
22454
22471
|
if (!e || typeof e != "string") return null;
|
|
22455
22472
|
let t = null;
|
|
22456
22473
|
return yg((n) => {
|
|
@@ -22460,7 +22477,7 @@ function Lg(e) {
|
|
|
22460
22477
|
} catch {}
|
|
22461
22478
|
}), t;
|
|
22462
22479
|
}
|
|
22463
|
-
function
|
|
22480
|
+
function Bg(e, t) {
|
|
22464
22481
|
let n = String(t ?? "").trim();
|
|
22465
22482
|
if (!n) return null;
|
|
22466
22483
|
let r = n.match(/^name:\s*([\w.-]+)$/i);
|
|
@@ -22470,12 +22487,12 @@ function Rg(e, t) {
|
|
|
22470
22487
|
}
|
|
22471
22488
|
let i = n.match(/^id:\s*([\w.-]+)$/i);
|
|
22472
22489
|
if (i) {
|
|
22473
|
-
let e =
|
|
22490
|
+
let e = zg(i[1]);
|
|
22474
22491
|
if (e) return e;
|
|
22475
22492
|
}
|
|
22476
22493
|
let a = n.startsWith("#") ? n.slice(1) : n;
|
|
22477
22494
|
if (/^[\w-]+$/.test(a)) {
|
|
22478
|
-
let e =
|
|
22495
|
+
let e = zg(a);
|
|
22479
22496
|
if (e) return e;
|
|
22480
22497
|
}
|
|
22481
22498
|
let o = n.toLowerCase().replace(/\s+/g, " ");
|
|
@@ -22485,7 +22502,7 @@ function Rg(e, t) {
|
|
|
22485
22502
|
}
|
|
22486
22503
|
return null;
|
|
22487
22504
|
}
|
|
22488
|
-
function
|
|
22505
|
+
function Vg(e, t) {
|
|
22489
22506
|
let n = String(t || "").toLowerCase().trim();
|
|
22490
22507
|
if (!n) return 0;
|
|
22491
22508
|
let r = [
|
|
@@ -22502,7 +22519,7 @@ function zg(e, t) {
|
|
|
22502
22519
|
for (let e of i) r.includes(e) && (a += 1);
|
|
22503
22520
|
return a / i.length * 92;
|
|
22504
22521
|
}
|
|
22505
|
-
function
|
|
22522
|
+
function Hg(e, t) {
|
|
22506
22523
|
let n = [];
|
|
22507
22524
|
yg((e) => {
|
|
22508
22525
|
n.push(...Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
|
|
@@ -22516,7 +22533,7 @@ function Bg(e, t) {
|
|
|
22516
22533
|
});
|
|
22517
22534
|
let r = 0, i = n.map((t) => ({
|
|
22518
22535
|
el: t,
|
|
22519
|
-
s:
|
|
22536
|
+
s: Vg(t, e)
|
|
22520
22537
|
}));
|
|
22521
22538
|
for (let { s: e } of i) e > r && (r = e);
|
|
22522
22539
|
if (r < 36) return null;
|
|
@@ -22526,14 +22543,14 @@ function Bg(e, t) {
|
|
|
22526
22543
|
if (o.length) {
|
|
22527
22544
|
let e = a[0], t = Infinity;
|
|
22528
22545
|
for (let n of a) for (let r of o) {
|
|
22529
|
-
let i =
|
|
22546
|
+
let i = Rg(n, r);
|
|
22530
22547
|
i < t && (t = i, e = n);
|
|
22531
22548
|
}
|
|
22532
22549
|
return e;
|
|
22533
22550
|
}
|
|
22534
22551
|
return a[0];
|
|
22535
22552
|
}
|
|
22536
|
-
function
|
|
22553
|
+
function Ug(e) {
|
|
22537
22554
|
if (e == null) return {};
|
|
22538
22555
|
if (typeof e == "string") {
|
|
22539
22556
|
let t = e.trim();
|
|
@@ -22546,8 +22563,8 @@ function Vg(e) {
|
|
|
22546
22563
|
}
|
|
22547
22564
|
return e;
|
|
22548
22565
|
}
|
|
22549
|
-
function
|
|
22550
|
-
let t =
|
|
22566
|
+
function Wg(e) {
|
|
22567
|
+
let t = Ug(e);
|
|
22551
22568
|
if (Array.isArray(t) && t.length > 0) {
|
|
22552
22569
|
let e = t[0];
|
|
22553
22570
|
if (e?.field_key != null || e?.fieldKey != null) return t.map((e) => ({
|
|
@@ -22575,12 +22592,12 @@ function Hg(e) {
|
|
|
22575
22592
|
value: e?.value ?? e?.Value
|
|
22576
22593
|
})) : [];
|
|
22577
22594
|
}
|
|
22578
|
-
function
|
|
22595
|
+
function Gg(e) {
|
|
22579
22596
|
if (!e || typeof e != "string") return e;
|
|
22580
22597
|
let t = e.trim();
|
|
22581
22598
|
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);
|
|
22582
22599
|
}
|
|
22583
|
-
function
|
|
22600
|
+
function Kg(e) {
|
|
22584
22601
|
if (!e || typeof e != "string") return e;
|
|
22585
22602
|
let t = {
|
|
22586
22603
|
zero: "0",
|
|
@@ -22599,7 +22616,7 @@ function Wg(e) {
|
|
|
22599
22616
|
for (let [e, r] of Object.entries(t)) n = n.replace(RegExp(`\\b${e}\\b`, "g"), r);
|
|
22600
22617
|
return n = n.replace(/[^\d+]/g, ""), n;
|
|
22601
22618
|
}
|
|
22602
|
-
function
|
|
22619
|
+
function qg(e) {
|
|
22603
22620
|
if (!e || typeof e != "string") return [];
|
|
22604
22621
|
let t = e.trim();
|
|
22605
22622
|
if (!t || /\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t)) return [];
|
|
@@ -22618,7 +22635,7 @@ function Gg(e) {
|
|
|
22618
22635
|
}
|
|
22619
22636
|
return [];
|
|
22620
22637
|
}
|
|
22621
|
-
function
|
|
22638
|
+
function Jg(e) {
|
|
22622
22639
|
if (!e || typeof e != "string") return [];
|
|
22623
22640
|
let t = e.trim();
|
|
22624
22641
|
if (!t) return [];
|
|
@@ -22630,7 +22647,7 @@ function Kg(e) {
|
|
|
22630
22647
|
field_key: e,
|
|
22631
22648
|
value: i
|
|
22632
22649
|
}));
|
|
22633
|
-
}, o =
|
|
22650
|
+
}, o = Gg(t), s = i.test(o), c = o.match(/^\s*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\s*$/i);
|
|
22634
22651
|
if (c) return a("Email Address", c[1]), n;
|
|
22635
22652
|
if (!i.test(t) && s) {
|
|
22636
22653
|
let e = o.match(i);
|
|
@@ -22658,17 +22675,17 @@ function Kg(e) {
|
|
|
22658
22675
|
}
|
|
22659
22676
|
return n;
|
|
22660
22677
|
}
|
|
22661
|
-
function
|
|
22678
|
+
function Yg(e) {
|
|
22662
22679
|
if (!e || typeof e != "object") return null;
|
|
22663
22680
|
let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
|
|
22664
22681
|
return t == null ? null : String(t).trim() || null;
|
|
22665
22682
|
}
|
|
22666
|
-
function
|
|
22683
|
+
function Xg(e) {
|
|
22667
22684
|
if (!e || typeof e != "object") return null;
|
|
22668
22685
|
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;
|
|
22669
22686
|
return t == null ? null : String(t).trim() || null;
|
|
22670
22687
|
}
|
|
22671
|
-
function
|
|
22688
|
+
function Zg(e) {
|
|
22672
22689
|
let t = e.ownerDocument?.defaultView || window, n = e.tagName === "TEXTAREA" ? t.HTMLTextAreaElement.prototype : t.HTMLInputElement.prototype, r = Object.getOwnPropertyDescriptor(n, "value");
|
|
22673
22690
|
return (e, t) => {
|
|
22674
22691
|
try {
|
|
@@ -22677,7 +22694,7 @@ function Yg(e) {
|
|
|
22677
22694
|
r?.set ? r.set.call(e, t) : e.value = t;
|
|
22678
22695
|
};
|
|
22679
22696
|
}
|
|
22680
|
-
async function
|
|
22697
|
+
async function Qg(e, t, n) {
|
|
22681
22698
|
if (!n?.skipScroll) try {
|
|
22682
22699
|
e.scrollIntoView({
|
|
22683
22700
|
behavior: "smooth",
|
|
@@ -22717,7 +22734,7 @@ async function Xg(e, t, n) {
|
|
|
22717
22734
|
].includes(String(t).toLowerCase().trim()), e.dispatchEvent(new Event("input", a)), e.dispatchEvent(new Event("change", a)), cg(e), !0;
|
|
22718
22735
|
let o = String(t);
|
|
22719
22736
|
if (r === "INPUT" || r === "TEXTAREA") {
|
|
22720
|
-
let t =
|
|
22737
|
+
let t = Zg(e);
|
|
22721
22738
|
try {
|
|
22722
22739
|
await eg(e, o, t);
|
|
22723
22740
|
} catch {
|
|
@@ -22747,11 +22764,11 @@ async function Xg(e, t, n) {
|
|
|
22747
22764
|
} catch {}
|
|
22748
22765
|
return cg(e), !0;
|
|
22749
22766
|
}
|
|
22750
|
-
function
|
|
22767
|
+
function $g(e) {
|
|
22751
22768
|
let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = null, o = {
|
|
22752
22769
|
navigate_to_page: async (n) => {
|
|
22753
22770
|
$("navigate_to_page ▶ raw parameters:", n);
|
|
22754
|
-
let r =
|
|
22771
|
+
let r = Ug(n), i = Yg(r), a = r.section_text ?? r.sectionText ?? r.section;
|
|
22755
22772
|
if ($("navigate_to_page · coerced:", {
|
|
22756
22773
|
url: i,
|
|
22757
22774
|
sectionText: a
|
|
@@ -22778,7 +22795,7 @@ function Zg(e) {
|
|
|
22778
22795
|
}
|
|
22779
22796
|
let e = "";
|
|
22780
22797
|
try {
|
|
22781
|
-
let t =
|
|
22798
|
+
let t = Tg(), n = Eg();
|
|
22782
22799
|
if (t.length > 0) {
|
|
22783
22800
|
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(", ");
|
|
22784
22801
|
e = ` This page has a form with fields: [${r}]` + (i ? ` and buttons: [${i}].` : ".") + " Call list_page_forms then start filling.";
|
|
@@ -22794,12 +22811,12 @@ function Zg(e) {
|
|
|
22794
22811
|
},
|
|
22795
22812
|
highlight_on_page: async (e) => {
|
|
22796
22813
|
$("highlight_on_page ▶", e);
|
|
22797
|
-
let t =
|
|
22814
|
+
let t = Ug(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText, i = rn(n || null, r || null);
|
|
22798
22815
|
return i ? (an(i), $("highlight_on_page ✓"), "Highlighted the section.") : ($("highlight_on_page ✖ no element"), "Could not find that section on the page.");
|
|
22799
22816
|
},
|
|
22800
22817
|
search_site_content: async (e) => {
|
|
22801
22818
|
$("search_site_content ▶", e);
|
|
22802
|
-
let r =
|
|
22819
|
+
let r = Xg(Ug(e));
|
|
22803
22820
|
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
22821
|
if (!t) return ig(), $("search_site_content ✖ no siteId"), "Site is not configured for search.";
|
|
22805
22822
|
if (!n) return ig(), $("search_site_content ✖ no api base"), "API base URL is missing; cannot search.";
|
|
@@ -22833,20 +22850,20 @@ function Zg(e) {
|
|
|
22833
22850
|
duration: 2e3
|
|
22834
22851
|
}), dg(!0), lg(), typeof e.requestEndSession == "function" && e.requestEndSession(), "Voice session is ending."),
|
|
22835
22852
|
list_page_forms: async () => {
|
|
22836
|
-
let e =
|
|
22837
|
-
return $("list_page_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), a =
|
|
22853
|
+
let e = Tg(), t = Eg();
|
|
22854
|
+
return $("list_page_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), a = wg(), $("list_page_forms · activeFormAncestor", a ? "contact-preferring" : "none"), JSON.stringify({
|
|
22838
22855
|
fields: e,
|
|
22839
22856
|
buttons: t,
|
|
22840
|
-
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."
|
|
22857
|
+
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. On pages with a contact form AND a footer 'Conduct Audit' / website URL field: only use the contact form unless the visitor explicitly asks to run an audit. Contact forms: fill in order Full Name → Email Address → Message. Message must be a short note the visitor wants to send (one or two sentences), never a recap of the whole chat or assistant replies. field_key: use placeholder, label, name, or id from this list. click_page_button picks the button nearest the filled fields (e.g. Send Message on the same form)."
|
|
22841
22858
|
});
|
|
22842
22859
|
},
|
|
22843
22860
|
fill_form_fields: async (e) => {
|
|
22844
22861
|
try {
|
|
22845
22862
|
$("fill_form_fields ▶ raw:", e);
|
|
22846
|
-
let t =
|
|
22863
|
+
let t = Wg(e);
|
|
22847
22864
|
if (!t.length && r) {
|
|
22848
|
-
let e = r(), n =
|
|
22849
|
-
n.length ? $("fill_form_fields · inferred URL from last user utterance (model omitted usable fields):", n) : (n =
|
|
22865
|
+
let e = r(), n = qg(e);
|
|
22866
|
+
n.length ? $("fill_form_fields · inferred URL from last user utterance (model omitted usable fields):", n) : (n = Jg(e), n.length && $("fill_form_fields · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
|
|
22850
22867
|
}
|
|
22851
22868
|
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.";
|
|
22852
22869
|
t.length > 1 && rg(`Filling ${t.length} fields…`);
|
|
@@ -22855,7 +22872,16 @@ function Zg(e) {
|
|
|
22855
22872
|
let t = e?.field_key ?? e?.fieldKey, r = e?.value;
|
|
22856
22873
|
if (t == null || r == null) continue;
|
|
22857
22874
|
let o = String(t).toLowerCase();
|
|
22858
|
-
/email|e-mail|mail/.test(o)
|
|
22875
|
+
if (/email|e-mail|mail/.test(o)) r = Gg(r);
|
|
22876
|
+
else if (/phone|mobile|tel|cell/.test(o)) r = Kg(r);
|
|
22877
|
+
else if (Pg(t) || o === "url") {
|
|
22878
|
+
let e = String(r ?? "").trim();
|
|
22879
|
+
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e) || /\bat\b/i.test(e) && /\bdot\b/i.test(e)) {
|
|
22880
|
+
let n = Gg(e);
|
|
22881
|
+
/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n.trim()) && ($("fill_form_fields · remapping url/website intent to Email Address (value is an email)"), t = "Email Address", o = "email address", r = n.trim());
|
|
22882
|
+
}
|
|
22883
|
+
}
|
|
22884
|
+
rg(`Filling ${t}…`), $("fill_form_fields · processing field:", t, "=", r);
|
|
22859
22885
|
let s = Sg(), c = s;
|
|
22860
22886
|
if (a) {
|
|
22861
22887
|
let e = s.filter((e) => gg(e) === a);
|
|
@@ -22864,15 +22890,15 @@ function Zg(e) {
|
|
|
22864
22890
|
$("fill_form_fields · visible inputs count:", s.length, "scoped:", c.length);
|
|
22865
22891
|
let l = !1;
|
|
22866
22892
|
for (let e of [c, ...c === s ? [] : [s]]) {
|
|
22867
|
-
let o =
|
|
22893
|
+
let o = Lg(e, String(t), r);
|
|
22868
22894
|
if (o.length) {
|
|
22869
|
-
for (let e = 0; e < o.length; e++) await
|
|
22895
|
+
for (let e = 0; e < o.length; e++) await Qg(o[e], r, { skipScroll: e > 0 }), await new Promise((e) => setTimeout(e, 80));
|
|
22870
22896
|
i = o, a = gg(o[0]) || a, n.push(String(t)), l = !0;
|
|
22871
22897
|
break;
|
|
22872
22898
|
}
|
|
22873
|
-
let s =
|
|
22874
|
-
if (s ||=
|
|
22875
|
-
await
|
|
22899
|
+
let s = Bg(e, String(t));
|
|
22900
|
+
if (s ||= jg(e, String(t)), s ||= Mg(e, String(t), r), s) {
|
|
22901
|
+
await Qg(s, r), i = [s], a = gg(s) || a, n.push(String(t)), l = !0;
|
|
22876
22902
|
break;
|
|
22877
22903
|
}
|
|
22878
22904
|
}
|
|
@@ -22892,10 +22918,10 @@ function Zg(e) {
|
|
|
22892
22918
|
}
|
|
22893
22919
|
},
|
|
22894
22920
|
click_page_button: async (e) => {
|
|
22895
|
-
let t =
|
|
22921
|
+
let t = Ug(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
|
|
22896
22922
|
if ($("click_page_button ▶", n), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
|
|
22897
22923
|
rg(`Clicking "${n}"…`);
|
|
22898
|
-
let r =
|
|
22924
|
+
let r = Hg(n, i);
|
|
22899
22925
|
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.`;
|
|
22900
22926
|
try {
|
|
22901
22927
|
try {
|
|
@@ -22961,7 +22987,7 @@ function Zg(e) {
|
|
|
22961
22987
|
}
|
|
22962
22988
|
//#endregion
|
|
22963
22989
|
//#region src/utils/wrapVoiceToolsForLogging.js
|
|
22964
|
-
function
|
|
22990
|
+
function e_(e) {
|
|
22965
22991
|
return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
|
|
22966
22992
|
let r = Zt();
|
|
22967
22993
|
r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
|
|
@@ -22978,22 +23004,22 @@ function Qg(e) {
|
|
|
22978
23004
|
}
|
|
22979
23005
|
//#endregion
|
|
22980
23006
|
//#region src/components/VoiceInterface.jsx
|
|
22981
|
-
var
|
|
23007
|
+
var t_ = {
|
|
22982
23008
|
idle: "rgba(99,102,241,0.18)",
|
|
22983
23009
|
listening: "rgba(16,185,129,0.25)",
|
|
22984
23010
|
speaking: "rgba(245,158,11,0.25)",
|
|
22985
23011
|
error: "rgba(239,68,68,0.2)"
|
|
22986
|
-
},
|
|
23012
|
+
}, n_ = {
|
|
22987
23013
|
idle: "#6366f1",
|
|
22988
23014
|
listening: "#10b981",
|
|
22989
23015
|
speaking: "#f59e0b",
|
|
22990
23016
|
error: "#ef4444"
|
|
22991
23017
|
};
|
|
22992
|
-
function
|
|
23018
|
+
function r_(e, t) {
|
|
22993
23019
|
let n = (t || "").trim();
|
|
22994
23020
|
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;
|
|
22995
23021
|
}
|
|
22996
|
-
function
|
|
23022
|
+
function i_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, historyRef: d, hasSyncedRef: f, onMessageSync: p, onStartSync: m }) {
|
|
22997
23023
|
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 () => {
|
|
22998
23024
|
try {
|
|
22999
23025
|
await re.current?.endSession?.();
|
|
@@ -23010,7 +23036,7 @@ function n_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23010
23036
|
try {
|
|
23011
23037
|
if (await navigator.mediaDevices.getUserMedia({ audio: !0 }), t) return;
|
|
23012
23038
|
d.current = [], ae.current = "", se.current = !1;
|
|
23013
|
-
let i =
|
|
23039
|
+
let i = e_($g({
|
|
23014
23040
|
siteId: r || null,
|
|
23015
23041
|
apiBaseUrl: a || null,
|
|
23016
23042
|
getLastUserVoiceText: () => ae.current,
|
|
@@ -23037,7 +23063,7 @@ function n_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23037
23063
|
message: r,
|
|
23038
23064
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
23039
23065
|
};
|
|
23040
|
-
n === "user" && (ae.current = r), d.current = [...d.current, i],
|
|
23066
|
+
n === "user" && (ae.current = r), d.current = [...d.current, i], r_(n, r) && queueMicrotask(() => {
|
|
23041
23067
|
se.current || (se.current = !0, oe.current?.());
|
|
23042
23068
|
});
|
|
23043
23069
|
},
|
|
@@ -23060,7 +23086,7 @@ function n_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23060
23086
|
} catch {
|
|
23061
23087
|
t = "[]";
|
|
23062
23088
|
}
|
|
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.
|
|
23089
|
+
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. Contact / lead forms: use only the main contact form (Full Name, Email, Message). Ignore footer “Conduct Audit” or marketing URL fields unless the user explicitly asks to run a website audit. Fill in order: name → email → message. Message must be a short visitor note (what they want from the team), not a transcript of the conversation. Forms: use fill_form_fields then click_page_button (e.g. Send Message) when appropriate. Fill each field right after the user gives that value — do not click submit until required fields are filled. Voice: if the user wants to end the voice session, call end_voice_session or confirm and end.`);
|
|
23064
23090
|
} catch {}
|
|
23065
23091
|
typeof m == "function" && m();
|
|
23066
23092
|
} catch (e) {
|
|
@@ -23076,7 +23102,7 @@ function n_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23076
23102
|
d,
|
|
23077
23103
|
m
|
|
23078
23104
|
]);
|
|
23079
|
-
let ce = h === "listening" || h === "speaking", le =
|
|
23105
|
+
let ce = h === "listening" || h === "speaking", le = n_[h] || n_.idle, ue = t_[h] || t_.idle;
|
|
23080
23106
|
return /* @__PURE__ */ u("div", {
|
|
23081
23107
|
ref: ie,
|
|
23082
23108
|
style: {
|
|
@@ -23182,7 +23208,7 @@ function n_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23182
23208
|
}
|
|
23183
23209
|
//#endregion
|
|
23184
23210
|
//#region src/components/FlowEngageWidget.jsx
|
|
23185
|
-
var
|
|
23211
|
+
var a_ = [
|
|
23186
23212
|
{
|
|
23187
23213
|
key: "become_client",
|
|
23188
23214
|
label: "Become a Client"
|
|
@@ -23203,7 +23229,7 @@ var r_ = [
|
|
|
23203
23229
|
key: "looking_for_job",
|
|
23204
23230
|
label: "Looking for a Job"
|
|
23205
23231
|
}
|
|
23206
|
-
],
|
|
23232
|
+
], o_ = () => /* @__PURE__ */ l("div", {
|
|
23207
23233
|
style: {
|
|
23208
23234
|
display: "flex",
|
|
23209
23235
|
marginBottom: "12px",
|
|
@@ -23234,7 +23260,7 @@ var r_ = [
|
|
|
23234
23260
|
} }, 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 " })]
|
|
23235
23261
|
})
|
|
23236
23262
|
});
|
|
23237
|
-
function
|
|
23263
|
+
function s_() {
|
|
23238
23264
|
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("");
|
|
23239
23265
|
i(() => {
|
|
23240
23266
|
try {
|
|
@@ -23262,7 +23288,7 @@ function a_() {
|
|
|
23262
23288
|
outline: "none",
|
|
23263
23289
|
fontFamily: "ui-sans-serif, system-ui, sans-serif",
|
|
23264
23290
|
...c ? {} : Ue
|
|
23265
|
-
}, Ge = S.recommendations?.[ue] || Re.recommendations?.[ue] ||
|
|
23291
|
+
}, Ge = S.recommendations?.[ue] || Re.recommendations?.[ue] || a_, 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(() => {
|
|
23266
23292
|
let e = o.findIndex((e) => e.sender === "user");
|
|
23267
23293
|
return e === -1 ? !1 : o.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
23268
23294
|
}, [o]), rt = !h && tt && nt;
|
|
@@ -23390,7 +23416,7 @@ function a_() {
|
|
|
23390
23416
|
flexDirection: "column"
|
|
23391
23417
|
},
|
|
23392
23418
|
className: "fe-screen-fade-in",
|
|
23393
|
-
children: /* @__PURE__ */ l(
|
|
23419
|
+
children: /* @__PURE__ */ l(i_, {
|
|
23394
23420
|
agentId: T,
|
|
23395
23421
|
chatId: r,
|
|
23396
23422
|
siteId: Ye,
|
|
@@ -23423,7 +23449,7 @@ function a_() {
|
|
|
23423
23449
|
isAiTyping: ee,
|
|
23424
23450
|
isAgentTyping: g,
|
|
23425
23451
|
setReplyContext: Me,
|
|
23426
|
-
TypingDots:
|
|
23452
|
+
TypingDots: o_,
|
|
23427
23453
|
primaryColor: Ve,
|
|
23428
23454
|
agentHeadshot: $e,
|
|
23429
23455
|
agentDisplayName: p || Ze
|
|
@@ -23502,4 +23528,4 @@ function a_() {
|
|
|
23502
23528
|
}) : null;
|
|
23503
23529
|
}
|
|
23504
23530
|
//#endregion
|
|
23505
|
-
export { vn as FlowEngageProvider,
|
|
23531
|
+
export { vn as FlowEngageProvider, s_ as FlowEngageWidget, Xt as useFlowEngage };
|