@sonordev/site-kit 6.1.3 → 6.2.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/agent-manifest.json +1 -1
- package/dist/{AnalyticsProvider-QK6XBDEJ.js → AnalyticsProvider-AT5XFQKT.js} +10 -10
- package/dist/{AnalyticsProvider-QK6XBDEJ.js.map → AnalyticsProvider-AT5XFQKT.js.map} +1 -1
- package/dist/{AnalyticsProvider-TIJWTISP.mjs → AnalyticsProvider-KPK3N52Q.mjs} +6 -6
- package/dist/{AnalyticsProvider-TIJWTISP.mjs.map → AnalyticsProvider-KPK3N52Q.mjs.map} +1 -1
- package/dist/{ArticleViewTracker-ALE672ZR.js → ArticleViewTracker-3PFASMTC.js} +6 -6
- package/dist/{ArticleViewTracker-ALE672ZR.js.map → ArticleViewTracker-3PFASMTC.js.map} +1 -1
- package/dist/{ArticleViewTracker-I66RBWDK.mjs → ArticleViewTracker-KIKKHBO6.mjs} +5 -5
- package/dist/{ArticleViewTracker-I66RBWDK.mjs.map → ArticleViewTracker-KIKKHBO6.mjs.map} +1 -1
- package/dist/ChatWidget-6PXV6RSI.mjs +17 -0
- package/dist/{ChatWidget-LNOY4TUZ.mjs.map → ChatWidget-6PXV6RSI.mjs.map} +1 -1
- package/dist/ChatWidget-D27PSWMO.js +34 -0
- package/dist/{ChatWidget-566CQUN6.js.map → ChatWidget-D27PSWMO.js.map} +1 -1
- package/dist/EngageWidget-SPZL3KPX.js +21 -0
- package/dist/{EngageWidget-DF47YUHQ.js.map → EngageWidget-SPZL3KPX.js.map} +1 -1
- package/dist/EngageWidget-YRTVPYAY.mjs +12 -0
- package/dist/{EngageWidget-IGF7SC3R.mjs.map → EngageWidget-YRTVPYAY.mjs.map} +1 -1
- package/dist/{FileField-IK6E5IOC.js → FileField-6RC33ORG.js} +6 -6
- package/dist/{FileField-IK6E5IOC.js.map → FileField-6RC33ORG.js.map} +1 -1
- package/dist/{FileField-AG63W2BC.mjs → FileField-GXNG2LH2.mjs} +5 -5
- package/dist/{FileField-AG63W2BC.mjs.map → FileField-GXNG2LH2.mjs.map} +1 -1
- package/dist/{FormSpotlight-6MUDJWW5.js → FormSpotlight-73E2CMV6.js} +9 -9
- package/dist/{FormSpotlight-6MUDJWW5.js.map → FormSpotlight-73E2CMV6.js.map} +1 -1
- package/dist/{FormSpotlight-H7V4GBXG.mjs → FormSpotlight-YDUF3TSC.mjs} +3 -3
- package/dist/{FormSpotlight-H7V4GBXG.mjs.map → FormSpotlight-YDUF3TSC.mjs.map} +1 -1
- package/dist/{FormStage-ZXZRZ2LS.js → FormStage-BL5FREFE.js} +9 -9
- package/dist/{FormStage-ZXZRZ2LS.js.map → FormStage-BL5FREFE.js.map} +1 -1
- package/dist/{FormStage-ACETL7SD.mjs → FormStage-VJZHYW6J.mjs} +3 -3
- package/dist/{FormStage-ACETL7SD.mjs.map → FormStage-VJZHYW6J.mjs.map} +1 -1
- package/dist/ManagedForm-FUIOTKSI.js +25 -0
- package/dist/{ManagedForm-4U54NPW2.js.map → ManagedForm-FUIOTKSI.js.map} +1 -1
- package/dist/ManagedForm-Z2S37RFX.mjs +16 -0
- package/dist/{ManagedForm-MOBWSG4D.mjs.map → ManagedForm-Z2S37RFX.mjs.map} +1 -1
- package/dist/{ManagedNewsletterForm-5LBGBE2F.js → ManagedNewsletterForm-3D3IW6JG.js} +8 -8
- package/dist/{ManagedNewsletterForm-5LBGBE2F.js.map → ManagedNewsletterForm-3D3IW6JG.js.map} +1 -1
- package/dist/{ManagedNewsletterForm-OV3OEMUP.mjs → ManagedNewsletterForm-ZXASCHZV.mjs} +7 -7
- package/dist/{ManagedNewsletterForm-OV3OEMUP.mjs.map → ManagedNewsletterForm-ZXASCHZV.mjs.map} +1 -1
- package/dist/{SignalCore-XM2MHEGR.mjs → SignalCore-LKSU7UYG.mjs} +5 -5
- package/dist/{SignalCore-XM2MHEGR.mjs.map → SignalCore-LKSU7UYG.mjs.map} +1 -1
- package/dist/{SignalCore-QCVR7TZV.js → SignalCore-RNMT4ZP4.js} +11 -11
- package/dist/{SignalCore-QCVR7TZV.js.map → SignalCore-RNMT4ZP4.js.map} +1 -1
- package/dist/SitemapSync-IDJ3PXER.js +18 -0
- package/dist/{SitemapSync-BQFZAE3X.js.map → SitemapSync-IDJ3PXER.js.map} +1 -1
- package/dist/SitemapSync-NTYKLAEH.mjs +9 -0
- package/dist/{SitemapSync-74EVNOFQ.mjs.map → SitemapSync-NTYKLAEH.mjs.map} +1 -1
- package/dist/analytics/index.js +9 -9
- package/dist/analytics/index.mjs +4 -4
- package/dist/articles/index.js +1 -1
- package/dist/articles/index.mjs +1 -1
- package/dist/articles/server-ui.js +1 -1
- package/dist/articles/server-ui.mjs +1 -1
- package/dist/{chunk-PTQHPWEK.mjs → chunk-22WIVF4O.mjs} +151 -165
- package/dist/chunk-22WIVF4O.mjs.map +1 -0
- package/dist/{chunk-IWHAJBYL.js → chunk-3NDDCSWR.js} +15 -15
- package/dist/{chunk-IWHAJBYL.js.map → chunk-3NDDCSWR.js.map} +1 -1
- package/dist/{chunk-RGXYE2ZI.mjs → chunk-3T74AR7S.mjs} +4 -4
- package/dist/{chunk-RGXYE2ZI.mjs.map → chunk-3T74AR7S.mjs.map} +1 -1
- package/dist/{chunk-ESPOINPT.mjs → chunk-4FWJ5K5O.mjs} +3 -3
- package/dist/{chunk-ESPOINPT.mjs.map → chunk-4FWJ5K5O.mjs.map} +1 -1
- package/dist/{chunk-YK7SEUFJ.mjs → chunk-53OU4TGU.mjs} +4 -4
- package/dist/{chunk-YK7SEUFJ.mjs.map → chunk-53OU4TGU.mjs.map} +1 -1
- package/dist/{chunk-JAA42HR7.js → chunk-5IOMLUQS.js} +7 -7
- package/dist/{chunk-JAA42HR7.js.map → chunk-5IOMLUQS.js.map} +1 -1
- package/dist/{chunk-MTHMOXZF.js → chunk-5L46GS7N.js} +5 -5
- package/dist/{chunk-MTHMOXZF.js.map → chunk-5L46GS7N.js.map} +1 -1
- package/dist/{chunk-EVKP4SOM.js → chunk-7JRFYQKN.js} +10 -10
- package/dist/{chunk-EVKP4SOM.js.map → chunk-7JRFYQKN.js.map} +1 -1
- package/dist/{chunk-P4J3WG6C.js → chunk-7JYLE3X6.js} +4 -4
- package/dist/{chunk-P4J3WG6C.js.map → chunk-7JYLE3X6.js.map} +1 -1
- package/dist/{chunk-EXVHO3CZ.mjs → chunk-7OOPIYLP.mjs} +3 -3
- package/dist/{chunk-EXVHO3CZ.mjs.map → chunk-7OOPIYLP.mjs.map} +1 -1
- package/dist/{chunk-2SLA2LOD.js → chunk-A4WTX36Y.js} +12 -12
- package/dist/{chunk-2SLA2LOD.js.map → chunk-A4WTX36Y.js.map} +1 -1
- package/dist/{chunk-AEW7EFYU.js → chunk-AEN7EL6N.js} +20 -6
- package/dist/chunk-AEN7EL6N.js.map +1 -0
- package/dist/{chunk-7VRK3DWU.js → chunk-BYVAXSH5.js} +6 -6
- package/dist/{chunk-7VRK3DWU.js.map → chunk-BYVAXSH5.js.map} +1 -1
- package/dist/{chunk-KEEZX6Q4.js → chunk-CRIZNSD2.js} +3 -3
- package/dist/{chunk-KEEZX6Q4.js.map → chunk-CRIZNSD2.js.map} +1 -1
- package/dist/{chunk-6FIIA6ME.mjs → chunk-EG3F5AHL.mjs} +4 -4
- package/dist/{chunk-6FIIA6ME.mjs.map → chunk-EG3F5AHL.mjs.map} +1 -1
- package/dist/{chunk-EVETX2XF.mjs → chunk-EJTRU275.mjs} +4 -4
- package/dist/{chunk-EVETX2XF.mjs.map → chunk-EJTRU275.mjs.map} +1 -1
- package/dist/{chunk-OUP6UL74.mjs → chunk-GSH4DBAD.mjs} +3 -3
- package/dist/{chunk-OUP6UL74.mjs.map → chunk-GSH4DBAD.mjs.map} +1 -1
- package/dist/chunk-IMWON7OV.mjs +27 -0
- package/dist/chunk-IMWON7OV.mjs.map +1 -0
- package/dist/{chunk-JSM4AYSZ.js → chunk-IPLOSM5F.js} +14 -14
- package/dist/{chunk-JSM4AYSZ.js.map → chunk-IPLOSM5F.js.map} +1 -1
- package/dist/{chunk-MQEVQ5YB.js → chunk-ITJ5ZF33.js} +3 -3
- package/dist/{chunk-MQEVQ5YB.js.map → chunk-ITJ5ZF33.js.map} +1 -1
- package/dist/{chunk-3RISRHOK.mjs → chunk-IXJ2H4MU.mjs} +8 -8
- package/dist/{chunk-3RISRHOK.mjs.map → chunk-IXJ2H4MU.mjs.map} +1 -1
- package/dist/{chunk-3MLVI5DH.mjs → chunk-JLVKZTYZ.mjs} +3 -3
- package/dist/{chunk-3MLVI5DH.mjs.map → chunk-JLVKZTYZ.mjs.map} +1 -1
- package/dist/{chunk-I4PUQYBI.mjs → chunk-JOSSKN4J.mjs} +3 -3
- package/dist/{chunk-I4PUQYBI.mjs.map → chunk-JOSSKN4J.mjs.map} +1 -1
- package/dist/chunk-LGFRHT34.js +8 -0
- package/dist/{chunk-OI3FCJSP.js.map → chunk-LGFRHT34.js.map} +1 -1
- package/dist/{chunk-OZTVJSFX.js → chunk-NJVU2DCX.js} +160 -172
- package/dist/chunk-NJVU2DCX.js.map +1 -0
- package/dist/{chunk-AGEE4CGH.js → chunk-OASA6M53.js} +5 -5
- package/dist/{chunk-AGEE4CGH.js.map → chunk-OASA6M53.js.map} +1 -1
- package/dist/{chunk-LXBPTKYT.mjs → chunk-P2UCNCQZ.mjs} +4 -4
- package/dist/{chunk-LXBPTKYT.mjs.map → chunk-P2UCNCQZ.mjs.map} +1 -1
- package/dist/{chunk-I7KIVKVW.js → chunk-RKRCWQBU.js} +3 -3
- package/dist/{chunk-I7KIVKVW.js.map → chunk-RKRCWQBU.js.map} +1 -1
- package/dist/{chunk-OWEJXMKY.mjs → chunk-RKWBC43M.mjs} +3 -3
- package/dist/{chunk-OWEJXMKY.mjs.map → chunk-RKWBC43M.mjs.map} +1 -1
- package/dist/{chunk-CTAYH725.js → chunk-RPDSNMVR.js} +11 -11
- package/dist/{chunk-CTAYH725.js.map → chunk-RPDSNMVR.js.map} +1 -1
- package/dist/{chunk-NRT7MOEO.mjs → chunk-RT7XKV6A.mjs} +3 -3
- package/dist/{chunk-NRT7MOEO.mjs.map → chunk-RT7XKV6A.mjs.map} +1 -1
- package/dist/{chunk-VDGCZVUF.js → chunk-RWJ3IJUP.js} +14 -14
- package/dist/{chunk-VDGCZVUF.js.map → chunk-RWJ3IJUP.js.map} +1 -1
- package/dist/{chunk-5IQOPL7T.mjs → chunk-S4LTYXPR.mjs} +3 -3
- package/dist/{chunk-5IQOPL7T.mjs.map → chunk-S4LTYXPR.mjs.map} +1 -1
- package/dist/chunk-SIHPFJ6C.mjs +6 -0
- package/dist/{chunk-5FBALULE.mjs.map → chunk-SIHPFJ6C.mjs.map} +1 -1
- package/dist/{chunk-BGBP4UN4.js → chunk-T742S2CY.js} +4 -4
- package/dist/{chunk-BGBP4UN4.js.map → chunk-T742S2CY.js.map} +1 -1
- package/dist/{chunk-GYKFHQSZ.mjs → chunk-TBAP7JNJ.mjs} +3 -3
- package/dist/{chunk-GYKFHQSZ.mjs.map → chunk-TBAP7JNJ.mjs.map} +1 -1
- package/dist/{chunk-MLXUMVBK.mjs → chunk-UCMMIGC6.mjs} +20 -6
- package/dist/chunk-UCMMIGC6.mjs.map +1 -0
- package/dist/{chunk-DVZ4BMXX.mjs → chunk-UPF6HX5C.mjs} +7 -7
- package/dist/{chunk-DVZ4BMXX.mjs.map → chunk-UPF6HX5C.mjs.map} +1 -1
- package/dist/{chunk-S6CMQTVZ.js → chunk-UTCZNQ4G.js} +5 -5
- package/dist/{chunk-S6CMQTVZ.js.map → chunk-UTCZNQ4G.js.map} +1 -1
- package/dist/{chunk-D5KKVWZK.mjs → chunk-UV3HJDMT.mjs} +3 -3
- package/dist/{chunk-D5KKVWZK.mjs.map → chunk-UV3HJDMT.mjs.map} +1 -1
- package/dist/{chunk-IZRVSIOK.js → chunk-W6GQNGIM.js} +4 -4
- package/dist/{chunk-IZRVSIOK.js.map → chunk-W6GQNGIM.js.map} +1 -1
- package/dist/{chunk-YEHC7VMW.mjs → chunk-W7D27SYJ.mjs} +3 -3
- package/dist/{chunk-YEHC7VMW.mjs.map → chunk-W7D27SYJ.mjs.map} +1 -1
- package/dist/{chunk-KDLN2MR5.js → chunk-WI6RV2U4.js} +18 -18
- package/dist/{chunk-KDLN2MR5.js.map → chunk-WI6RV2U4.js.map} +1 -1
- package/dist/{chunk-IUNFAKOS.mjs → chunk-XAPGVZNN.mjs} +3 -3
- package/dist/{chunk-IUNFAKOS.mjs.map → chunk-XAPGVZNN.mjs.map} +1 -1
- package/dist/{chunk-XCOMBHLF.js → chunk-Y63EG5CW.js} +8 -8
- package/dist/{chunk-XCOMBHLF.js.map → chunk-Y63EG5CW.js.map} +1 -1
- package/dist/{chunk-5OUOVPXC.js → chunk-YNI7WQJN.js} +8 -8
- package/dist/{chunk-5OUOVPXC.js.map → chunk-YNI7WQJN.js.map} +1 -1
- package/dist/chunk-YZJ22HUQ.js +29 -0
- package/dist/chunk-YZJ22HUQ.js.map +1 -0
- package/dist/{chunk-RQG7I6O4.js → chunk-ZRCA5YGZ.js} +4 -4
- package/dist/{chunk-RQG7I6O4.js.map → chunk-ZRCA5YGZ.js.map} +1 -1
- package/dist/{chunk-QSN2QST7.mjs → chunk-ZRD75SE5.mjs} +3 -3
- package/dist/{chunk-QSN2QST7.mjs.map → chunk-ZRD75SE5.mjs.map} +1 -1
- package/dist/{chunk-CI7T4ZRP.mjs → chunk-ZZ6P27A5.mjs} +4 -4
- package/dist/{chunk-CI7T4ZRP.mjs.map → chunk-ZZ6P27A5.mjs.map} +1 -1
- package/dist/cli/index.js +3 -3
- package/dist/cli/index.mjs +1 -1
- package/dist/client/index.js +4 -4
- package/dist/client/index.mjs +3 -3
- package/dist/commerce/index.js +57 -57
- package/dist/commerce/index.mjs +5 -5
- package/dist/engage/ChatWidget.d.ts +60 -1
- package/dist/engage/ChatWidget.d.ts.map +1 -1
- package/dist/engage/chat-messages.d.ts +86 -0
- package/dist/engage/chat-messages.d.ts.map +1 -0
- package/dist/engage/index.js +10 -10
- package/dist/engage/index.mjs +7 -7
- package/dist/fleet/index.js +8 -8
- package/dist/fleet/index.mjs +4 -4
- package/dist/forms/index.js +16 -16
- package/dist/forms/index.mjs +9 -9
- package/dist/forms/server.js +10 -10
- package/dist/forms/server.mjs +8 -8
- package/dist/forms/static.js +7 -7
- package/dist/forms/static.mjs +6 -6
- package/dist/images/index.js +11 -11
- package/dist/images/index.mjs +4 -4
- package/dist/index.js +63 -63
- package/dist/index.mjs +9 -9
- package/dist/layout/client.js +8 -8
- package/dist/layout/client.mjs +7 -7
- package/dist/layout/index.js +10 -10
- package/dist/layout/index.mjs +8 -8
- package/dist/maps/index.js +5 -5
- package/dist/maps/index.mjs +3 -3
- package/dist/motion/CountUp.d.ts +49 -0
- package/dist/motion/CountUp.d.ts.map +1 -0
- package/dist/motion/Parallax.d.ts +14 -0
- package/dist/motion/Parallax.d.ts.map +1 -1
- package/dist/motion/ScrollScene.d.ts +1 -1
- package/dist/motion/ScrollScene.d.ts.map +1 -1
- package/dist/motion/engine.d.ts +19 -0
- package/dist/motion/engine.d.ts.map +1 -1
- package/dist/motion/gsap.d.ts +55 -6
- package/dist/motion/gsap.d.ts.map +1 -1
- package/dist/motion/gsap.js +101 -4
- package/dist/motion/gsap.js.map +1 -1
- package/dist/motion/gsap.mjs +96 -3
- package/dist/motion/gsap.mjs.map +1 -1
- package/dist/motion/index.d.ts +1 -1
- package/dist/motion/index.d.ts.map +1 -1
- package/dist/motion/index.js +21 -40
- package/dist/motion/index.js.map +1 -1
- package/dist/motion/index.mjs +11 -32
- package/dist/motion/index.mjs.map +1 -1
- package/dist/motion/three.js +5 -5
- package/dist/motion/three.mjs +1 -1
- package/dist/search/index.js +4 -4
- package/dist/search/index.mjs +3 -3
- package/dist/seo/client.js +5 -5
- package/dist/seo/client.mjs +4 -4
- package/dist/seo/index.js +5 -5
- package/dist/seo/index.mjs +4 -4
- package/dist/server/index.js +3 -3
- package/dist/server/index.mjs +2 -2
- package/dist/shared/version.d.ts +1 -1
- package/dist/signal/index.js +11 -11
- package/dist/signal/index.mjs +2 -2
- package/dist/sync/index.js +17 -17
- package/dist/sync/index.mjs +4 -4
- package/package.json +1 -1
- package/dist/ChatWidget-566CQUN6.js +0 -26
- package/dist/ChatWidget-LNOY4TUZ.mjs +0 -17
- package/dist/EngageWidget-DF47YUHQ.js +0 -21
- package/dist/EngageWidget-IGF7SC3R.mjs +0 -12
- package/dist/ManagedForm-4U54NPW2.js +0 -25
- package/dist/ManagedForm-MOBWSG4D.mjs +0 -16
- package/dist/SitemapSync-74EVNOFQ.mjs +0 -9
- package/dist/SitemapSync-BQFZAE3X.js +0 -18
- package/dist/chunk-5FBALULE.mjs +0 -6
- package/dist/chunk-AEW7EFYU.js.map +0 -1
- package/dist/chunk-MLXUMVBK.mjs.map +0 -1
- package/dist/chunk-OI3FCJSP.js +0 -8
- package/dist/chunk-OZTVJSFX.js.map +0 -1
- package/dist/chunk-PTQHPWEK.mjs.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { chatLauncherStyles } from './chunk-4U5NCKQY.mjs';
|
|
3
3
|
import { GlassStyles } from './chunk-OBKS3CPP.mjs';
|
|
4
|
-
import { useForm } from './chunk-
|
|
4
|
+
import { useForm } from './chunk-EG3F5AHL.mjs';
|
|
5
5
|
import { parseColor, relativeLuminance, DARK_LUMINANCE, contrastRatio } from './chunk-NYXENHD2.mjs';
|
|
6
|
-
import { sonorFetch } from './chunk-
|
|
7
|
-
import { useState,
|
|
6
|
+
import { sonorFetch } from './chunk-ZZ6P27A5.mjs';
|
|
7
|
+
import { useState, useEffect, useRef, useLayoutEffect, useCallback } from 'react';
|
|
8
8
|
import ReactMarkdown from 'react-markdown';
|
|
9
9
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
10
10
|
|
|
@@ -317,6 +317,71 @@ function EchoUiActions({ actions, primaryColor, primaryRgb, brandText, onSuggest
|
|
|
317
317
|
}) }) : null
|
|
318
318
|
] });
|
|
319
319
|
}
|
|
320
|
+
|
|
321
|
+
// src/engage/chat-messages.ts
|
|
322
|
+
function userRequestedHandoff(text) {
|
|
323
|
+
const lower = text.toLowerCase().trim();
|
|
324
|
+
const patterns = [
|
|
325
|
+
/\b(talk|speak)\s+(to|with)\s+(a\s+)?(person|human|agent|representative|someone)\b/,
|
|
326
|
+
/\b(real|live)\s+(person|human|agent|support)\b/,
|
|
327
|
+
/\bconnect\s+(me\s+)?(with|to)\s+(a\s+)?(person|human|agent)\b/,
|
|
328
|
+
/\b(need|want)\s+(to\s+)?(talk|speak)\s+(to|with)\s+(someone|a\s+person)\b/,
|
|
329
|
+
/\bhuman\s+(support|agent|help)\b/,
|
|
330
|
+
/\b(talk|speak)\s+to\s+(a\s+)?person\b/,
|
|
331
|
+
/\bget\s+(a\s+)?(person|human)\b/
|
|
332
|
+
];
|
|
333
|
+
return patterns.some((p) => p.test(lower));
|
|
334
|
+
}
|
|
335
|
+
function visitorMessage(content, attachments = []) {
|
|
336
|
+
return {
|
|
337
|
+
id: `user-${Date.now()}`,
|
|
338
|
+
role: "user",
|
|
339
|
+
content,
|
|
340
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
341
|
+
...attachments.length ? { attachments } : {}
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
function openingMessages(welcome, initialMessage) {
|
|
345
|
+
const opening = [{ id: "welcome", role: "assistant", content: welcome, timestamp: /* @__PURE__ */ new Date() }];
|
|
346
|
+
if (initialMessage) opening.push(visitorMessage(initialMessage));
|
|
347
|
+
return opening;
|
|
348
|
+
}
|
|
349
|
+
function echoReplyMessage(reply, probe) {
|
|
350
|
+
return {
|
|
351
|
+
id: `ai-${Date.now()}`,
|
|
352
|
+
role: "assistant",
|
|
353
|
+
content: reply.content,
|
|
354
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
355
|
+
...reply.suggestions?.length ? { suggestions: reply.suggestions } : {},
|
|
356
|
+
...reply.uiActions?.length ? { uiActions: reply.uiActions } : {},
|
|
357
|
+
...reply.offerHandoff || userRequestedHandoff(probe) ? { offerHandoff: true } : {}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
function echoErrorMessage() {
|
|
361
|
+
return {
|
|
362
|
+
id: `err-${Date.now()}`,
|
|
363
|
+
role: "assistant",
|
|
364
|
+
content: "I apologize, but I encountered an error. Would you like to speak with a team member?",
|
|
365
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
366
|
+
suggestions: ["Talk to a person", "Try again"],
|
|
367
|
+
offerHandoff: true
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
async function askEcho(content, deps) {
|
|
371
|
+
deps.setLoading(true);
|
|
372
|
+
try {
|
|
373
|
+
const reply = await deps.send(content);
|
|
374
|
+
deps.append(echoReplyMessage(reply, content));
|
|
375
|
+
} catch (err) {
|
|
376
|
+
deps.onError?.(err);
|
|
377
|
+
deps.append(echoErrorMessage());
|
|
378
|
+
} finally {
|
|
379
|
+
deps.setLoading(false);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function deliverOpeningMessage(pending, route) {
|
|
383
|
+
return route.signalEnabled ? route.ask(pending) : route.emitLive(pending);
|
|
384
|
+
}
|
|
320
385
|
function getApiConfig() {
|
|
321
386
|
const isDev = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
|
|
322
387
|
const defaultApiUrl = isDev && process.env?.SONOR_API_URL ? process.env.SONOR_API_URL : "https://api.sonor.io";
|
|
@@ -339,19 +404,6 @@ function linkifyUrls(text) {
|
|
|
339
404
|
(_, before, url) => `${before}[${url}](${url})`
|
|
340
405
|
);
|
|
341
406
|
}
|
|
342
|
-
function userRequestedHandoff(text) {
|
|
343
|
-
const lower = text.toLowerCase().trim();
|
|
344
|
-
const patterns = [
|
|
345
|
-
/\b(talk|speak)\s+(to|with)\s+(a\s+)?(person|human|agent|representative|someone)\b/,
|
|
346
|
-
/\b(real|live)\s+(person|human|agent|support)\b/,
|
|
347
|
-
/\bconnect\s+(me\s+)?(with|to)\s+(a\s+)?(person|human|agent)\b/,
|
|
348
|
-
/\b(need|want)\s+(to\s+)?(talk|speak)\s+(to|with)\s+(someone|a\s+person)\b/,
|
|
349
|
-
/\bhuman\s+(support|agent|help)\b/,
|
|
350
|
-
/\b(talk|speak)\s+to\s+(a\s+)?person\b/,
|
|
351
|
-
/\bget\s+(a\s+)?(person|human)\b/
|
|
352
|
-
];
|
|
353
|
-
return patterns.some((p) => p.test(lower));
|
|
354
|
-
}
|
|
355
407
|
var BUBBLE_BG = "color-mix(in srgb, var(--sk-bg, #ffffff) 94%, transparent)";
|
|
356
408
|
var HAIRLINE = "1px solid color-mix(in srgb, var(--sk-text-primary, #111827) 9%, transparent)";
|
|
357
409
|
var ECHO_STYLE_HREF = "sk-echo";
|
|
@@ -369,9 +421,52 @@ function staticPrimaryColor(apiFallback, hardDefault) {
|
|
|
369
421
|
function hexAlpha(rgbVar, alpha2, fallbackRgb = "37, 99, 235") {
|
|
370
422
|
return `rgba(var(${rgbVar}, ${fallbackRgb}), ${alpha2})`;
|
|
371
423
|
}
|
|
372
|
-
function
|
|
424
|
+
function isChatEnabled(config) {
|
|
425
|
+
return config !== null && config.is_enabled !== false;
|
|
426
|
+
}
|
|
427
|
+
function ChatWidget(props) {
|
|
428
|
+
const { projectId: propProjectId, apiUrl: propApiUrl } = props;
|
|
373
429
|
const [resolvedProjectId, setResolvedProjectId] = useState(propProjectId || null);
|
|
374
430
|
const projectId = propProjectId || resolvedProjectId || "";
|
|
431
|
+
const [widgetConfig, setWidgetConfig] = useState(null);
|
|
432
|
+
const baseUrl = propApiUrl || getApiConfig().apiUrl;
|
|
433
|
+
useEffect(() => {
|
|
434
|
+
if (propProjectId || resolvedProjectId) return;
|
|
435
|
+
const { apiKey } = getApiConfig();
|
|
436
|
+
if (!apiKey) return;
|
|
437
|
+
let cancelled = false;
|
|
438
|
+
sonorFetch(`${baseUrl}/api/public/seo/project-info`, {}, { apiKey, retries: 0 }).then((res) => res.ok ? res.json() : null).then((data) => {
|
|
439
|
+
if (cancelled || !data?.valid || !data?.project_id) return;
|
|
440
|
+
setResolvedProjectId(data.project_id);
|
|
441
|
+
}).catch(() => {
|
|
442
|
+
});
|
|
443
|
+
return () => {
|
|
444
|
+
cancelled = true;
|
|
445
|
+
};
|
|
446
|
+
}, [propProjectId, resolvedProjectId, baseUrl]);
|
|
447
|
+
useEffect(() => {
|
|
448
|
+
if (!projectId) return;
|
|
449
|
+
const { apiKey } = getApiConfig();
|
|
450
|
+
if (!apiKey) {
|
|
451
|
+
console.warn("[ChatWidget] No site credential found. Render SiteKitLayout in app/layout.tsx and set SONOR_API_KEY on the server.");
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
let cancelled = false;
|
|
455
|
+
sonorFetch(`${baseUrl}/engage/widget/config?projectId=${projectId}`, {}, { apiKey, retries: 0 }).then((res) => res.ok ? res.json() : null).then((json) => {
|
|
456
|
+
if (!cancelled) setWidgetConfig(json?.data ?? null);
|
|
457
|
+
}).catch((error) => {
|
|
458
|
+
if (process.env.NODE_ENV === "development") {
|
|
459
|
+
console.warn("[ChatWidget] Config fetch failed:", error instanceof Error ? error.message : error);
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
return () => {
|
|
463
|
+
cancelled = true;
|
|
464
|
+
};
|
|
465
|
+
}, [projectId, baseUrl]);
|
|
466
|
+
if (!isChatEnabled(widgetConfig)) return null;
|
|
467
|
+
return /* @__PURE__ */ jsx(EchoChat, { ...props, projectId, widgetConfig });
|
|
468
|
+
}
|
|
469
|
+
function EchoChat({ projectId, widgetConfig, config, apiUrl: propApiUrl, signalUrl: propSignalUrl, suggested_questions: propSuggestedQuestions, assistant_name: propAssistantName, welcome_message: propWelcomeMessage, assistant_avatar: propAssistantAvatar }) {
|
|
375
470
|
const [isOpen, setIsOpen] = useState(false);
|
|
376
471
|
const [messages, setMessages] = useState([]);
|
|
377
472
|
const [inputValue, setInputValue] = useState("");
|
|
@@ -384,7 +479,6 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
|
|
|
384
479
|
const [offlineForm, setOfflineForm] = useState({ name: "", email: "", phone: "", message: "" });
|
|
385
480
|
const [offlineSubmitted, setOfflineSubmitted] = useState(false);
|
|
386
481
|
const [connectionStatus, setConnectionStatus] = useState("disconnected");
|
|
387
|
-
const [widgetConfig, setWidgetConfig] = useState(null);
|
|
388
482
|
const [handoffOfflinePrompt, setHandoffOfflinePrompt] = useState(null);
|
|
389
483
|
const [pendingFiles, setPendingFiles] = useState([]);
|
|
390
484
|
const [lastFailedSend, setLastFailedSend] = useState(null);
|
|
@@ -441,36 +535,6 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
|
|
|
441
535
|
const offlineSubheading = handoffOfflinePrompt ?? widgetConfig?.offline_subheading ?? widgetConfig?.form_description ?? widgetConfig?.offline_message ?? config?.offlineMessage ?? "Leave us a message and we'll get back to you!";
|
|
442
536
|
const baseUrl = propApiUrl || getApiConfig().apiUrl;
|
|
443
537
|
const signalUrl = propSignalUrl || getApiConfig().signalUrl;
|
|
444
|
-
useEffect(() => {
|
|
445
|
-
if (propProjectId || resolvedProjectId) return;
|
|
446
|
-
const { apiKey } = getApiConfig();
|
|
447
|
-
if (!apiKey) return;
|
|
448
|
-
let cancelled = false;
|
|
449
|
-
sonorFetch(`${baseUrl}/api/public/seo/project-info`, {}, { apiKey, retries: 0 }).then((res) => res.ok ? res.json() : null).then((data) => {
|
|
450
|
-
if (cancelled || !data?.valid || !data?.project_id) return;
|
|
451
|
-
setResolvedProjectId(data.project_id);
|
|
452
|
-
}).catch(() => {
|
|
453
|
-
});
|
|
454
|
-
return () => {
|
|
455
|
-
cancelled = true;
|
|
456
|
-
};
|
|
457
|
-
}, [propProjectId, resolvedProjectId, baseUrl]);
|
|
458
|
-
const fetchWidgetConfig = useCallback(async () => {
|
|
459
|
-
if (!projectId) return;
|
|
460
|
-
const apiKey = ensureApiKey();
|
|
461
|
-
if (!apiKey) return;
|
|
462
|
-
try {
|
|
463
|
-
const response = await sonorFetch(`${baseUrl}/engage/widget/config?projectId=${projectId}`, {}, { apiKey, retries: 0 });
|
|
464
|
-
if (response.ok) {
|
|
465
|
-
const { data } = await response.json();
|
|
466
|
-
setWidgetConfig(data ?? null);
|
|
467
|
-
}
|
|
468
|
-
} catch (error) {
|
|
469
|
-
if (process.env.NODE_ENV === "development") {
|
|
470
|
-
console.warn("[ChatWidget] Config fetch failed:", error instanceof Error ? error.message : error);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}, [projectId, baseUrl]);
|
|
474
538
|
const checkAvailability = useCallback(async () => {
|
|
475
539
|
if (!projectId) return null;
|
|
476
540
|
const apiKey = ensureApiKey();
|
|
@@ -575,22 +639,14 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
|
|
|
575
639
|
},
|
|
576
640
|
[signalUrl, visitorId, fetchSiteContext]
|
|
577
641
|
);
|
|
578
|
-
const
|
|
579
|
-
(
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
587
|
-
...reply.suggestions?.length ? { suggestions: reply.suggestions } : {},
|
|
588
|
-
...reply.uiActions?.length ? { uiActions: reply.uiActions } : {},
|
|
589
|
-
...reply.offerHandoff || userRequestedHandoff(probeContent) ? { offerHandoff: true } : {}
|
|
590
|
-
}
|
|
591
|
-
]);
|
|
592
|
-
},
|
|
593
|
-
[]
|
|
642
|
+
const sendTurnToEcho = useCallback(
|
|
643
|
+
(content, conversationId) => askEcho(content, {
|
|
644
|
+
send: (text) => sendToSignalApi(text, conversationId),
|
|
645
|
+
append: (message) => setMessages((prev) => [...prev, message]),
|
|
646
|
+
setLoading: setIsLoading,
|
|
647
|
+
onError: (err) => console.error("[ChatWidget] Signal API error:", err)
|
|
648
|
+
}),
|
|
649
|
+
[sendToSignalApi]
|
|
594
650
|
);
|
|
595
651
|
const handleSocketMessage = useCallback((data) => {
|
|
596
652
|
switch (data.type || data.event) {
|
|
@@ -763,7 +819,6 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
|
|
|
763
819
|
if (isOpen && !showWelcome && inputRef.current) inputRef.current.focus();
|
|
764
820
|
}, [isOpen, showWelcome]);
|
|
765
821
|
useEffect(() => {
|
|
766
|
-
fetchWidgetConfig();
|
|
767
822
|
checkAvailability();
|
|
768
823
|
const interval = setInterval(checkAvailability, 6e4);
|
|
769
824
|
return () => {
|
|
@@ -773,7 +828,7 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
|
|
|
773
828
|
socketRef.current = null;
|
|
774
829
|
}
|
|
775
830
|
};
|
|
776
|
-
}, [
|
|
831
|
+
}, [checkAvailability]);
|
|
777
832
|
useEffect(() => {
|
|
778
833
|
if (isOpen && !showWelcome && !checkingAvailability && !showOfflineForm && !sessionId) {
|
|
779
834
|
initSession().then(async (result) => {
|
|
@@ -783,58 +838,38 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
|
|
|
783
838
|
if (pending) {
|
|
784
839
|
pendingInitialMessageRef.current = null;
|
|
785
840
|
}
|
|
786
|
-
if (signalEnabled && pending) {
|
|
787
|
-
setIsLoading(true);
|
|
788
|
-
setMessages((prev) => [
|
|
789
|
-
...prev,
|
|
790
|
-
{ id: `u-${Date.now()}`, role: "user", content: pending, timestamp: /* @__PURE__ */ new Date() }
|
|
791
|
-
]);
|
|
792
|
-
try {
|
|
793
|
-
const reply = await sendToSignalApi(pending, id);
|
|
794
|
-
pushEchoReply(reply, pending);
|
|
795
|
-
} catch (err) {
|
|
796
|
-
console.error("[ChatWidget] Signal API error:", err);
|
|
797
|
-
setMessages((prev) => [
|
|
798
|
-
...prev,
|
|
799
|
-
{
|
|
800
|
-
id: `err-${Date.now()}`,
|
|
801
|
-
role: "assistant",
|
|
802
|
-
content: "I apologize, but I encountered an error. Would you like to speak with a team member?",
|
|
803
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
804
|
-
suggestions: ["Talk to a person", "Try again"],
|
|
805
|
-
offerHandoff: true
|
|
806
|
-
}
|
|
807
|
-
]);
|
|
808
|
-
} finally {
|
|
809
|
-
setIsLoading(false);
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
841
|
if (!signalEnabled) {
|
|
813
842
|
setConnectionStatus("connecting");
|
|
814
843
|
await connectSocket(id);
|
|
815
844
|
}
|
|
816
|
-
if (
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
845
|
+
if (pending) {
|
|
846
|
+
await deliverOpeningMessage(pending, {
|
|
847
|
+
signalEnabled,
|
|
848
|
+
ask: (content) => sendTurnToEcho(content, id),
|
|
849
|
+
emitLive: async (content) => {
|
|
850
|
+
const waitForSocket = () => new Promise((resolve) => {
|
|
851
|
+
const check = (attempts = 0) => {
|
|
852
|
+
if (socketRef.current?.connected || attempts > 20) {
|
|
853
|
+
resolve();
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
setTimeout(() => check(attempts + 1), 150);
|
|
857
|
+
};
|
|
858
|
+
check();
|
|
859
|
+
});
|
|
860
|
+
await waitForSocket();
|
|
861
|
+
if (socketRef.current?.connected) {
|
|
862
|
+
socketRef.current.emit("visitor:message", { content });
|
|
822
863
|
}
|
|
823
|
-
|
|
824
|
-
};
|
|
825
|
-
check();
|
|
864
|
+
}
|
|
826
865
|
});
|
|
827
|
-
await waitForSocket();
|
|
828
|
-
if (socketRef.current?.connected) {
|
|
829
|
-
socketRef.current.emit("visitor:message", { content: pending });
|
|
830
|
-
}
|
|
831
866
|
}
|
|
832
867
|
});
|
|
833
868
|
}
|
|
834
869
|
return () => {
|
|
835
870
|
if (pollingIntervalRef.current) clearInterval(pollingIntervalRef.current);
|
|
836
871
|
};
|
|
837
|
-
}, [isOpen, showWelcome, checkingAvailability, showOfflineForm, sessionId, initSession, connectSocket,
|
|
872
|
+
}, [isOpen, showWelcome, checkingAvailability, showOfflineForm, sessionId, initSession, connectSocket, sendTurnToEcho]);
|
|
838
873
|
const handleToggle = useCallback(() => {
|
|
839
874
|
setIsOpen((prev) => !prev);
|
|
840
875
|
}, []);
|
|
@@ -842,11 +877,9 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
|
|
|
842
877
|
async (initialMessage) => {
|
|
843
878
|
setShowWelcome(false);
|
|
844
879
|
const beginChatSession = () => {
|
|
845
|
-
setMessages(
|
|
880
|
+
setMessages(openingMessages(welcomeMessage, initialMessage));
|
|
846
881
|
if (initialMessage) {
|
|
847
882
|
pendingInitialMessageRef.current = initialMessage;
|
|
848
|
-
const userMsg = { id: `user-${Date.now()}`, role: "user", content: initialMessage, timestamp: /* @__PURE__ */ new Date() };
|
|
849
|
-
setMessages((prev) => [...prev, userMsg]);
|
|
850
883
|
setIsLoading(true);
|
|
851
884
|
}
|
|
852
885
|
};
|
|
@@ -913,37 +946,12 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
|
|
|
913
946
|
return;
|
|
914
947
|
}
|
|
915
948
|
}
|
|
916
|
-
const userMessage =
|
|
917
|
-
id: `user-${Date.now()}`,
|
|
918
|
-
role: "user",
|
|
919
|
-
content,
|
|
920
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
921
|
-
...attachments.length ? { attachments } : {}
|
|
922
|
-
};
|
|
949
|
+
const userMessage = visitorMessage(content, attachments);
|
|
923
950
|
setMessages((prev) => [...prev, userMessage]);
|
|
924
951
|
setInputValue("");
|
|
925
952
|
setIsLoading(true);
|
|
926
953
|
if (widgetConfig?.signal_enabled && !isHandedOff && hasText) {
|
|
927
|
-
|
|
928
|
-
const reply = await sendToSignalApi(content, sessionId);
|
|
929
|
-
const lastUserContent = messages.filter((m) => m.role === "user").slice(-1)[0]?.content ?? "";
|
|
930
|
-
pushEchoReply(reply, lastUserContent);
|
|
931
|
-
} catch (err) {
|
|
932
|
-
console.error("[ChatWidget] Signal API error:", err);
|
|
933
|
-
setMessages((prev) => [
|
|
934
|
-
...prev,
|
|
935
|
-
{
|
|
936
|
-
id: `err-${Date.now()}`,
|
|
937
|
-
role: "assistant",
|
|
938
|
-
content: "I apologize, but I encountered an error. Would you like to speak with a team member?",
|
|
939
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
940
|
-
suggestions: ["Talk to a person", "Try again"],
|
|
941
|
-
offerHandoff: true
|
|
942
|
-
}
|
|
943
|
-
]);
|
|
944
|
-
} finally {
|
|
945
|
-
setIsLoading(false);
|
|
946
|
-
}
|
|
954
|
+
await sendTurnToEcho(content, sessionId);
|
|
947
955
|
return;
|
|
948
956
|
}
|
|
949
957
|
const socket = socketRef.current;
|
|
@@ -963,38 +971,16 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
|
|
|
963
971
|
}
|
|
964
972
|
}, 3e3);
|
|
965
973
|
},
|
|
966
|
-
[inputValue, isLoading, pendingFiles, uploadWidgetFile, widgetConfig?.signal_enabled, isHandedOff,
|
|
974
|
+
[inputValue, isLoading, pendingFiles, uploadWidgetFile, widgetConfig?.signal_enabled, isHandedOff, sendTurnToEcho, sessionId]
|
|
967
975
|
);
|
|
968
976
|
const sendEchoText = useCallback(
|
|
969
977
|
async (text) => {
|
|
970
978
|
const content = text.trim();
|
|
971
979
|
if (!content || isLoading) return;
|
|
972
|
-
setMessages((prev) => [
|
|
973
|
-
|
|
974
|
-
{ id: `user-${Date.now()}`, role: "user", content, timestamp: /* @__PURE__ */ new Date() }
|
|
975
|
-
]);
|
|
976
|
-
setIsLoading(true);
|
|
977
|
-
try {
|
|
978
|
-
const reply = await sendToSignalApi(content, sessionId);
|
|
979
|
-
pushEchoReply(reply, content);
|
|
980
|
-
} catch (err) {
|
|
981
|
-
console.error("[ChatWidget] Signal API error:", err);
|
|
982
|
-
setMessages((prev) => [
|
|
983
|
-
...prev,
|
|
984
|
-
{
|
|
985
|
-
id: `err-${Date.now()}`,
|
|
986
|
-
role: "assistant",
|
|
987
|
-
content: "I apologize, but I encountered an error. Would you like to speak with a team member?",
|
|
988
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
989
|
-
suggestions: ["Talk to a person", "Try again"],
|
|
990
|
-
offerHandoff: true
|
|
991
|
-
}
|
|
992
|
-
]);
|
|
993
|
-
} finally {
|
|
994
|
-
setIsLoading(false);
|
|
995
|
-
}
|
|
980
|
+
setMessages((prev) => [...prev, visitorMessage(content)]);
|
|
981
|
+
await sendTurnToEcho(content, sessionId);
|
|
996
982
|
},
|
|
997
|
-
[isLoading, sessionId,
|
|
983
|
+
[isLoading, sessionId, sendTurnToEcho]
|
|
998
984
|
);
|
|
999
985
|
const handleSuggestAction = useCallback(
|
|
1000
986
|
(action, message) => {
|
|
@@ -1678,6 +1664,6 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
|
|
|
1678
1664
|
] });
|
|
1679
1665
|
}
|
|
1680
1666
|
|
|
1681
|
-
export { ChatWidget };
|
|
1682
|
-
//# sourceMappingURL=chunk-
|
|
1683
|
-
//# sourceMappingURL=chunk-
|
|
1667
|
+
export { ChatWidget, EchoChat, isChatEnabled };
|
|
1668
|
+
//# sourceMappingURL=chunk-22WIVF4O.mjs.map
|
|
1669
|
+
//# sourceMappingURL=chunk-22WIVF4O.mjs.map
|