@flowengage/react-chatbot 3.0.9 → 4.0.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.
- package/README.md +0 -61
- package/dist/flowengage-embed.js +19 -19
- package/dist/flowengage-react-chatbot.cjs +18 -18
- package/dist/flowengage-react-chatbot.mjs +5913 -5891
- package/package.json +1 -1
- package/dist/navFeedback-DfScMGBH.mjs +0 -33
- package/dist/navFeedback-sUJfoGrs.js +0 -1
- package/dist/navLog-CFMQ4ZYH.mjs +0 -45
- package/dist/navLog-DcdVdf44.js +0 -1
- package/dist/reload-H8LF3bZU.mjs +0 -13
- package/dist/reload-QLoC5roX.js +0 -1
- package/dist/spa-AtFQKJ1w.mjs +0 -71
- package/dist/spa-C8SSgJtr.js +0 -1
- package/dist/urlGuards-DAIyNQW3.js +0 -1
- package/dist/urlGuards-DbG5voWk.mjs +0 -128
package/package.json
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
//#region src/navigation/feedback/navFeedback.js
|
|
2
|
-
async function e({ url: e, fromStrategy: t, reason: n }) {
|
|
3
|
-
if (typeof window > "u") return;
|
|
4
|
-
let r = window.__flowengage_config__ || {};
|
|
5
|
-
if (!r.apiBaseUrl || !r.siteId) return;
|
|
6
|
-
let i;
|
|
7
|
-
try {
|
|
8
|
-
i = new URL(e, window.location.href).pathname;
|
|
9
|
-
} catch {
|
|
10
|
-
i = e;
|
|
11
|
-
}
|
|
12
|
-
let a = {
|
|
13
|
-
"x-site-id": String(r.siteId),
|
|
14
|
-
"Content-Type": "application/json"
|
|
15
|
-
};
|
|
16
|
-
r.visitorId && (a["x-visitor-id"] = String(r.visitorId));
|
|
17
|
-
let o = JSON.stringify({
|
|
18
|
-
url: i,
|
|
19
|
-
fromStrategy: t || "unknown",
|
|
20
|
-
reason: n || "unknown",
|
|
21
|
-
ts: Date.now()
|
|
22
|
-
}), s = String(r.apiBaseUrl).replace(/\/$/, "");
|
|
23
|
-
try {
|
|
24
|
-
await fetch(`${s}/api/widget/nav-feedback`, {
|
|
25
|
-
method: "POST",
|
|
26
|
-
headers: a,
|
|
27
|
-
body: o,
|
|
28
|
-
keepalive: !0
|
|
29
|
-
});
|
|
30
|
-
} catch {}
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { e as reportNavFailure };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require(`./flowengage-react-chatbot.cjs`);async function e({url:e,fromStrategy:t,reason:n}){if(typeof window>`u`)return;let r=window.__flowengage_config__||{};if(!r.apiBaseUrl||!r.siteId)return;let i;try{i=new URL(e,window.location.href).pathname}catch{i=e}let a={"x-site-id":String(r.siteId),"Content-Type":`application/json`};r.visitorId&&(a[`x-visitor-id`]=String(r.visitorId));let o=JSON.stringify({url:i,fromStrategy:t||`unknown`,reason:n||`unknown`,ts:Date.now()}),s=String(r.apiBaseUrl).replace(/\/$/,``);try{await fetch(`${s}/api/widget/nav-feedback`,{method:`POST`,headers:a,body:o,keepalive:!0})}catch{}}exports.reportNavFailure=e;
|
package/dist/navLog-CFMQ4ZYH.mjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
//#region src/utils/feDebug.js
|
|
2
|
-
function e() {
|
|
3
|
-
if (typeof window > "u") return !1;
|
|
4
|
-
try {
|
|
5
|
-
let e = window.localStorage?.getItem("FE_DEBUG_VOICE");
|
|
6
|
-
if (e === "0" || e === "false") return !1;
|
|
7
|
-
if (e === "1" || e === "true") return !0;
|
|
8
|
-
} catch {}
|
|
9
|
-
return window.__FE_DEBUG_VOICE_TOOLS__ === !1 ? !1 : window.__FE_DEBUG_VOICE_TOOLS__ === !0;
|
|
10
|
-
}
|
|
11
|
-
function t() {
|
|
12
|
-
if (typeof window > "u") return {};
|
|
13
|
-
try {
|
|
14
|
-
let e = window.localStorage?.getItem("flowengage_flags");
|
|
15
|
-
if (!e) return {};
|
|
16
|
-
let t = JSON.parse(e);
|
|
17
|
-
return t && typeof t == "object" ? t : {};
|
|
18
|
-
} catch {
|
|
19
|
-
return {};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function n(e, n = !1) {
|
|
23
|
-
let r = t();
|
|
24
|
-
if (Object.prototype.hasOwnProperty.call(r, e)) {
|
|
25
|
-
let t = r[e];
|
|
26
|
-
return t === !0 || t === "1" || t === "true";
|
|
27
|
-
}
|
|
28
|
-
return n;
|
|
29
|
-
}
|
|
30
|
-
function r() {
|
|
31
|
-
return n("FE_NAV_RELOAD_ENABLED", !1);
|
|
32
|
-
}
|
|
33
|
-
function i() {
|
|
34
|
-
return n("FE_NAV_SPA_ENABLED", !1);
|
|
35
|
-
}
|
|
36
|
-
function a() {
|
|
37
|
-
return n("FE_DEBUG_NAV", !1) || e();
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/navigation/shared/navLog.js
|
|
41
|
-
function o(...e) {
|
|
42
|
-
a() && console.log("[FlowEngage:shadowNavigate]", ...e);
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
export { e as i, r as n, i as r, o as t };
|
package/dist/navLog-DcdVdf44.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(){if(typeof window>`u`)return!1;try{let e=window.localStorage?.getItem(`FE_DEBUG_VOICE`);if(e===`0`||e===`false`)return!1;if(e===`1`||e===`true`)return!0}catch{}return window.__FE_DEBUG_VOICE_TOOLS__===!1?!1:window.__FE_DEBUG_VOICE_TOOLS__===!0}function t(){if(typeof window>`u`)return{};try{let e=window.localStorage?.getItem(`flowengage_flags`);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}function n(e,n=!1){let r=t();if(Object.prototype.hasOwnProperty.call(r,e)){let t=r[e];return t===!0||t===`1`||t===`true`}return n}function r(){return n(`FE_NAV_RELOAD_ENABLED`,!1)}function i(){return n(`FE_NAV_SPA_ENABLED`,!1)}function a(){return n(`FE_DEBUG_NAV`,!1)||e()}function o(...e){a()&&console.log(`[FlowEngage:shadowNavigate]`,...e)}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
|
package/dist/reload-H8LF3bZU.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./navLog-CFMQ4ZYH.mjs";
|
|
2
|
-
import { a as t, l as n, t as r } from "./urlGuards-DbG5voWk.mjs";
|
|
3
|
-
//#region src/navigation/strategies/reload.js
|
|
4
|
-
async function i(i, a = {}) {
|
|
5
|
-
if (typeof window > "u") return !1;
|
|
6
|
-
let { sectionText: o, voiceActive: s = !1 } = a, c = r(i);
|
|
7
|
-
return e("reload: dispatching full reload →", c, {
|
|
8
|
-
voiceActive: s,
|
|
9
|
-
sectionText: !!o
|
|
10
|
-
}), o && t(o), s ? (n(c), !0) : (window.location.assign(c), !0);
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { i as navigate };
|
package/dist/reload-QLoC5roX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./navLog-DcdVdf44.js`),t=require(`./urlGuards-DAIyNQW3.js`);require(`./flowengage-react-chatbot.cjs`);async function n(n,r={}){if(typeof window>`u`)return!1;let{sectionText:i,voiceActive:a=!1}=r,o=t.t(n);return e.t(`reload: dispatching full reload →`,o,{voiceActive:a,sectionText:!!i}),i&&t.a(i),a?(t.l(o),!0):(window.location.assign(o),!0)}exports.navigate=n;
|
package/dist/spa-AtFQKJ1w.mjs
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./navLog-CFMQ4ZYH.mjs";
|
|
2
|
-
//#region src/navigation/strategies/spa.js
|
|
3
|
-
var t = [
|
|
4
|
-
{
|
|
5
|
-
name: "next-pages",
|
|
6
|
-
test: () => typeof window < "u" && !!window.next?.router?.push,
|
|
7
|
-
call: (e) => window.next.router.push(e),
|
|
8
|
-
awaitDone: (e) => new Promise((t) => {
|
|
9
|
-
let n = window.next.router, r = () => {
|
|
10
|
-
n.events?.off("routeChangeComplete", r), t(!0);
|
|
11
|
-
};
|
|
12
|
-
n.events?.on("routeChangeComplete", r), n.push(e), setTimeout(r, 5e3);
|
|
13
|
-
})
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
name: "next-app",
|
|
17
|
-
test: () => typeof window < "u" && !!window.__NEXT_ROUTER__?.push,
|
|
18
|
-
call: (e) => window.__NEXT_ROUTER__.push(e)
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
name: "remix",
|
|
22
|
-
test: () => typeof window < "u" && typeof window.__remixRouter?.navigate == "function",
|
|
23
|
-
call: (e) => window.__remixRouter.navigate(e)
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: "react-router",
|
|
27
|
-
test: () => {
|
|
28
|
-
if (typeof document > "u") return !1;
|
|
29
|
-
let e = document.getElementById("root") || document.getElementById("app");
|
|
30
|
-
return e ? !!Object.keys(e).find((e) => e.startsWith("__reactContainer$") || e.startsWith("__reactFiber$") || e.startsWith("__reactInternalInstance$") || e === "_reactRootContainer") : !1;
|
|
31
|
-
},
|
|
32
|
-
call: (e) => {
|
|
33
|
-
window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
|
|
34
|
-
},
|
|
35
|
-
awaitDone: (e) => new Promise((t) => {
|
|
36
|
-
window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
|
|
37
|
-
let n = null, r = () => {
|
|
38
|
-
i.disconnect(), t(!0);
|
|
39
|
-
}, i = new MutationObserver(() => {
|
|
40
|
-
n && clearTimeout(n), n = setTimeout(r, 250);
|
|
41
|
-
});
|
|
42
|
-
i.observe(document.getElementById("root") || document.body, {
|
|
43
|
-
childList: !0,
|
|
44
|
-
subtree: !0
|
|
45
|
-
}), setTimeout(r, 3e3);
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
];
|
|
49
|
-
async function n(n, r = {}) {
|
|
50
|
-
if (typeof window > "u") return !1;
|
|
51
|
-
let i = (() => {
|
|
52
|
-
try {
|
|
53
|
-
return new URL(n, window.location.href).pathname + new URL(n, window.location.href).search;
|
|
54
|
-
} catch {
|
|
55
|
-
return n;
|
|
56
|
-
}
|
|
57
|
-
})();
|
|
58
|
-
for (let n of t) if (n.test()) {
|
|
59
|
-
e("spa: dispatching via", n.name, "→", i);
|
|
60
|
-
try {
|
|
61
|
-
return n.awaitDone ? await n.awaitDone(i) : (n.call(i), !0);
|
|
62
|
-
} catch (e) {
|
|
63
|
-
console.warn(`[FlowEngage] SPA router '${n.name}' threw:`, e);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
e("spa: no router exposed, falling back to reload strategy");
|
|
67
|
-
let { navigate: a } = await import("./reload-H8LF3bZU.mjs");
|
|
68
|
-
return a(n, r);
|
|
69
|
-
}
|
|
70
|
-
//#endregion
|
|
71
|
-
export { n as navigate };
|
package/dist/spa-C8SSgJtr.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./navLog-DcdVdf44.js`);require(`./flowengage-react-chatbot.cjs`);var t=[{name:`next-pages`,test:()=>typeof window<`u`&&!!window.next?.router?.push,call:e=>window.next.router.push(e),awaitDone:e=>new Promise(t=>{let n=window.next.router,r=()=>{n.events?.off(`routeChangeComplete`,r),t(!0)};n.events?.on(`routeChangeComplete`,r),n.push(e),setTimeout(r,5e3)})},{name:`next-app`,test:()=>typeof window<`u`&&!!window.__NEXT_ROUTER__?.push,call:e=>window.__NEXT_ROUTER__.push(e)},{name:`remix`,test:()=>typeof window<`u`&&typeof window.__remixRouter?.navigate==`function`,call:e=>window.__remixRouter.navigate(e)},{name:`react-router`,test:()=>{if(typeof document>`u`)return!1;let e=document.getElementById(`root`)||document.getElementById(`app`);return e?!!Object.keys(e).find(e=>e.startsWith(`__reactContainer$`)||e.startsWith(`__reactFiber$`)||e.startsWith(`__reactInternalInstance$`)||e===`_reactRootContainer`):!1},call:e=>{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`,{state:{}}))},awaitDone:e=>new Promise(t=>{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`,{state:{}}));let n=null,r=()=>{i.disconnect(),t(!0)},i=new MutationObserver(()=>{n&&clearTimeout(n),n=setTimeout(r,250)});i.observe(document.getElementById(`root`)||document.body,{childList:!0,subtree:!0}),setTimeout(r,3e3)})}];async function n(n,r={}){if(typeof window>`u`)return!1;let i=(()=>{try{return new URL(n,window.location.href).pathname+new URL(n,window.location.href).search}catch{return n}})();for(let n of t)if(n.test()){e.t(`spa: dispatching via`,n.name,`→`,i);try{return n.awaitDone?await n.awaitDone(i):(n.call(i),!0)}catch(e){console.warn(`[FlowEngage] SPA router '${n.name}' threw:`,e)}}e.t(`spa: no router exposed, falling back to reload strategy`);let{navigate:a}=await Promise.resolve().then(()=>require(`./reload-QLoC5roX.js`));return a(n,r)}exports.navigate=n;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./navLog-DcdVdf44.js`);var t=`fe_voice_nav_state`,n=2e4,r=null,i=null;function a(e){if(e){r=e,i&&clearTimeout(i),i=setTimeout(()=>{let e=r;r=null,i=null,e&&window.location.assign(e)},6e3);try{sessionStorage.setItem(t,JSON.stringify({voiceWasActive:!0,targetUrl:e,ts:Date.now()}))}catch{}}}function o(){if(typeof window>`u`||typeof sessionStorage>`u`)return{shouldResumeVoice:!1,targetUrl:null};let r;try{r=JSON.parse(sessionStorage.getItem(t)||`null`)}catch{return{shouldResumeVoice:!1,targetUrl:null}}if(!r)return{shouldResumeVoice:!1,targetUrl:null};try{sessionStorage.removeItem(t)}catch{}return r.voiceWasActive?Date.now()-r.ts>n?(e.t(`initVoiceNavResume: state expired, skipping`),{shouldResumeVoice:!1,targetUrl:null}):(e.t(`initVoiceNavResume: voice was active during navigation to`,r.targetUrl),{shouldResumeVoice:!0,targetUrl:r.targetUrl||null}):{shouldResumeVoice:!1,targetUrl:null}}function s(){return!!r}function c(){if(!(typeof sessionStorage>`u`))try{sessionStorage.removeItem(t)}catch{}}var l=`fe_pending_nav_section`;function u(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(l,JSON.stringify({sectionText:e,ts:Date.now()}))}catch{}}function d(){if(typeof sessionStorage>`u`)return null;let e;try{e=JSON.parse(sessionStorage.getItem(`fe_pending_nav_section`)||`null`)}catch{return null}if(!e)return null;try{sessionStorage.removeItem(l)}catch{}return!e.sectionText||Date.now()-e.ts>15e3?null:e}function f(){if(!(typeof sessionStorage>`u`))try{sessionStorage.removeItem(l)}catch{}}function p(e){if(typeof window>`u`)return e;try{let t=new URL(String(e).trim(),window.location.href);return!/^https?:$/i.test(t.protocol)||t.origin===window.location.origin?t.href:new URL(t.pathname+t.search+t.hash,window.location.origin).href}catch{return e}}async function m(e){if(typeof window>`u`)return!1;try{let t=new URL(String(e).trim(),window.location.href),n=t.origin===window.location.origin?t.href:new URL(t.pathname+t.search+t.hash,window.location.origin).href;return(await fetch(n,{method:`HEAD`,mode:`same-origin`,cache:`no-store`})).ok}catch{return!1}}async function h(e,{siteId:t,apiBaseUrl:n}){if(!e)return!1;if(!t||!n)return console.warn(`[FlowEngage] shouldProceedWithNavigation: missing siteId or apiBaseUrl`),m(e);let r=String(n).replace(/\/$/,``),i=new URLSearchParams({siteId:String(t),url:String(e).trim()});try{let t=await(await fetch(`${r}/api/widget/navigate-allowed?${i.toString()}`)).json().catch(()=>({}));return t.success&&t.allowed?!0:m(e)}catch(t){return console.warn(`[FlowEngage] navigate-allowed check failed:`,t?.message),m(e)}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return p}});
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./navLog-CFMQ4ZYH.mjs";
|
|
2
|
-
//#region src/navigation/shared/voiceNavResume.js
|
|
3
|
-
var t = "fe_voice_nav_state", n = 2e4, r = null, i = null;
|
|
4
|
-
function a(e) {
|
|
5
|
-
if (e) {
|
|
6
|
-
r = e, i && clearTimeout(i), i = setTimeout(() => {
|
|
7
|
-
let e = r;
|
|
8
|
-
r = null, i = null, e && window.location.assign(e);
|
|
9
|
-
}, 6e3);
|
|
10
|
-
try {
|
|
11
|
-
sessionStorage.setItem(t, JSON.stringify({
|
|
12
|
-
voiceWasActive: !0,
|
|
13
|
-
targetUrl: e,
|
|
14
|
-
ts: Date.now()
|
|
15
|
-
}));
|
|
16
|
-
} catch {}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function o() {
|
|
20
|
-
if (typeof window > "u" || typeof sessionStorage > "u") return {
|
|
21
|
-
shouldResumeVoice: !1,
|
|
22
|
-
targetUrl: null
|
|
23
|
-
};
|
|
24
|
-
let r;
|
|
25
|
-
try {
|
|
26
|
-
r = JSON.parse(sessionStorage.getItem(t) || "null");
|
|
27
|
-
} catch {
|
|
28
|
-
return {
|
|
29
|
-
shouldResumeVoice: !1,
|
|
30
|
-
targetUrl: null
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
if (!r) return {
|
|
34
|
-
shouldResumeVoice: !1,
|
|
35
|
-
targetUrl: null
|
|
36
|
-
};
|
|
37
|
-
try {
|
|
38
|
-
sessionStorage.removeItem(t);
|
|
39
|
-
} catch {}
|
|
40
|
-
return r.voiceWasActive ? Date.now() - r.ts > n ? (e("initVoiceNavResume: state expired, skipping"), {
|
|
41
|
-
shouldResumeVoice: !1,
|
|
42
|
-
targetUrl: null
|
|
43
|
-
}) : (e("initVoiceNavResume: voice was active during navigation to", r.targetUrl), {
|
|
44
|
-
shouldResumeVoice: !0,
|
|
45
|
-
targetUrl: r.targetUrl || null
|
|
46
|
-
}) : {
|
|
47
|
-
shouldResumeVoice: !1,
|
|
48
|
-
targetUrl: null
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function s() {
|
|
52
|
-
return !!r;
|
|
53
|
-
}
|
|
54
|
-
function c() {
|
|
55
|
-
if (!(typeof sessionStorage > "u")) try {
|
|
56
|
-
sessionStorage.removeItem(t);
|
|
57
|
-
} catch {}
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/navigation/shared/pendingSection.js
|
|
61
|
-
var l = "fe_pending_nav_section";
|
|
62
|
-
function u(e) {
|
|
63
|
-
if (!(!e || typeof sessionStorage > "u")) try {
|
|
64
|
-
sessionStorage.setItem(l, JSON.stringify({
|
|
65
|
-
sectionText: e,
|
|
66
|
-
ts: Date.now()
|
|
67
|
-
}));
|
|
68
|
-
} catch {}
|
|
69
|
-
}
|
|
70
|
-
function d() {
|
|
71
|
-
if (typeof sessionStorage > "u") return null;
|
|
72
|
-
let e;
|
|
73
|
-
try {
|
|
74
|
-
e = JSON.parse(sessionStorage.getItem("fe_pending_nav_section") || "null");
|
|
75
|
-
} catch {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
if (!e) return null;
|
|
79
|
-
try {
|
|
80
|
-
sessionStorage.removeItem(l);
|
|
81
|
-
} catch {}
|
|
82
|
-
return !e.sectionText || Date.now() - e.ts > 15e3 ? null : e;
|
|
83
|
-
}
|
|
84
|
-
function f() {
|
|
85
|
-
if (!(typeof sessionStorage > "u")) try {
|
|
86
|
-
sessionStorage.removeItem(l);
|
|
87
|
-
} catch {}
|
|
88
|
-
}
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region src/navigation/shared/urlGuards.js
|
|
91
|
-
function p(e) {
|
|
92
|
-
if (typeof window > "u") return e;
|
|
93
|
-
try {
|
|
94
|
-
let t = new URL(String(e).trim(), window.location.href);
|
|
95
|
-
return !/^https?:$/i.test(t.protocol) || t.origin === window.location.origin ? t.href : new URL(t.pathname + t.search + t.hash, window.location.origin).href;
|
|
96
|
-
} catch {
|
|
97
|
-
return e;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
async function m(e) {
|
|
101
|
-
if (typeof window > "u") return !1;
|
|
102
|
-
try {
|
|
103
|
-
let t = new URL(String(e).trim(), window.location.href), n = t.origin === window.location.origin ? t.href : new URL(t.pathname + t.search + t.hash, window.location.origin).href;
|
|
104
|
-
return (await fetch(n, {
|
|
105
|
-
method: "HEAD",
|
|
106
|
-
mode: "same-origin",
|
|
107
|
-
cache: "no-store"
|
|
108
|
-
})).ok;
|
|
109
|
-
} catch {
|
|
110
|
-
return !1;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
async function h(e, { siteId: t, apiBaseUrl: n }) {
|
|
114
|
-
if (!e) return !1;
|
|
115
|
-
if (!t || !n) return console.warn("[FlowEngage] shouldProceedWithNavigation: missing siteId or apiBaseUrl"), m(e);
|
|
116
|
-
let r = String(n).replace(/\/$/, ""), i = new URLSearchParams({
|
|
117
|
-
siteId: String(t),
|
|
118
|
-
url: String(e).trim()
|
|
119
|
-
});
|
|
120
|
-
try {
|
|
121
|
-
let t = await (await fetch(`${r}/api/widget/navigate-allowed?${i.toString()}`)).json().catch(() => ({}));
|
|
122
|
-
return t.success && t.allowed ? !0 : m(e);
|
|
123
|
-
} catch (t) {
|
|
124
|
-
return console.warn("[FlowEngage] navigate-allowed check failed:", t?.message), m(e);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
//#endregion
|
|
128
|
-
export { u as a, o as c, d as i, a as l, h as n, c as o, f as r, s, p as t };
|