@eka-care/medassist-widget-embed 0.2.5 → 0.2.7
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/dist/iframe.js +49 -14
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/src/medassist-widget.css +47 -82
- package/dist/src/medassist-widget.js +238 -169
- package/dist/src/medassist-widget.js.map +1 -1
- package/iframe.ts +57 -16
- package/index.ts +6 -1
- package/package.json +1 -1
- package/src/medassist-widget.css +47 -82
- package/src/medassist-widget.js +238 -169
- package/src/medassist-widget.js.map +1 -1
- package/test.html +1 -1
package/src/medassist-widget.js
CHANGED
|
@@ -26043,12 +26043,12 @@ var MedAssistWidget = (function(exports) {
|
|
|
26043
26043
|
Component.displayName = toPascalCase(iconName);
|
|
26044
26044
|
return Component;
|
|
26045
26045
|
};
|
|
26046
|
-
const __iconNode$
|
|
26046
|
+
const __iconNode$k = [
|
|
26047
26047
|
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
26048
26048
|
["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
|
|
26049
26049
|
];
|
|
26050
|
-
const ArrowRight = createLucideIcon("arrow-right", __iconNode$
|
|
26051
|
-
const __iconNode$
|
|
26050
|
+
const ArrowRight = createLucideIcon("arrow-right", __iconNode$k);
|
|
26051
|
+
const __iconNode$j = [
|
|
26052
26052
|
["path", { d: "M10 12h4", key: "a56b0p" }],
|
|
26053
26053
|
["path", { d: "M10 8h4", key: "1sr2af" }],
|
|
26054
26054
|
["path", { d: "M14 21v-3a2 2 0 0 0-4 0v3", key: "1rgiei" }],
|
|
@@ -26061,28 +26061,28 @@ var MedAssistWidget = (function(exports) {
|
|
|
26061
26061
|
],
|
|
26062
26062
|
["path", { d: "M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16", key: "16ra0t" }]
|
|
26063
26063
|
];
|
|
26064
|
-
const Building2 = createLucideIcon("building-2", __iconNode$
|
|
26065
|
-
const __iconNode$
|
|
26064
|
+
const Building2 = createLucideIcon("building-2", __iconNode$j);
|
|
26065
|
+
const __iconNode$i = [
|
|
26066
26066
|
["path", { d: "M8 2v4", key: "1cmpym" }],
|
|
26067
26067
|
["path", { d: "M16 2v4", key: "4m81vk" }],
|
|
26068
26068
|
["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
|
|
26069
26069
|
["path", { d: "M3 10h18", key: "8toen8" }]
|
|
26070
26070
|
];
|
|
26071
|
-
const Calendar = createLucideIcon("calendar", __iconNode$
|
|
26072
|
-
const __iconNode$
|
|
26073
|
-
const Check = createLucideIcon("check", __iconNode$
|
|
26074
|
-
const __iconNode$
|
|
26075
|
-
const ChevronDown = createLucideIcon("chevron-down", __iconNode$
|
|
26076
|
-
const __iconNode$
|
|
26077
|
-
const ChevronLeft = createLucideIcon("chevron-left", __iconNode$
|
|
26078
|
-
const __iconNode$
|
|
26079
|
-
const ChevronRight = createLucideIcon("chevron-right", __iconNode$
|
|
26080
|
-
const __iconNode$
|
|
26071
|
+
const Calendar = createLucideIcon("calendar", __iconNode$i);
|
|
26072
|
+
const __iconNode$h = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
|
|
26073
|
+
const Check = createLucideIcon("check", __iconNode$h);
|
|
26074
|
+
const __iconNode$g = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
|
|
26075
|
+
const ChevronDown = createLucideIcon("chevron-down", __iconNode$g);
|
|
26076
|
+
const __iconNode$f = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
|
|
26077
|
+
const ChevronLeft = createLucideIcon("chevron-left", __iconNode$f);
|
|
26078
|
+
const __iconNode$e = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
|
|
26079
|
+
const ChevronRight = createLucideIcon("chevron-right", __iconNode$e);
|
|
26080
|
+
const __iconNode$d = [
|
|
26081
26081
|
["path", { d: "M12 6v6l4 2", key: "mmk7yg" }],
|
|
26082
26082
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]
|
|
26083
26083
|
];
|
|
26084
|
-
const Clock = createLucideIcon("clock", __iconNode$
|
|
26085
|
-
const __iconNode$
|
|
26084
|
+
const Clock = createLucideIcon("clock", __iconNode$d);
|
|
26085
|
+
const __iconNode$c = [
|
|
26086
26086
|
[
|
|
26087
26087
|
"path",
|
|
26088
26088
|
{
|
|
@@ -26095,8 +26095,8 @@ var MedAssistWidget = (function(exports) {
|
|
|
26095
26095
|
["path", { d: "M16 13H8", key: "t4e002" }],
|
|
26096
26096
|
["path", { d: "M16 17H8", key: "z1uh3a" }]
|
|
26097
26097
|
];
|
|
26098
|
-
const FileText = createLucideIcon("file-text", __iconNode$
|
|
26099
|
-
const __iconNode$
|
|
26098
|
+
const FileText = createLucideIcon("file-text", __iconNode$c);
|
|
26099
|
+
const __iconNode$b = [
|
|
26100
26100
|
["path", { d: "m5 8 6 6", key: "1wu5hv" }],
|
|
26101
26101
|
["path", { d: "m4 14 6-6 2-3", key: "1k1g8d" }],
|
|
26102
26102
|
["path", { d: "M2 5h12", key: "or177f" }],
|
|
@@ -26104,15 +26104,15 @@ var MedAssistWidget = (function(exports) {
|
|
|
26104
26104
|
["path", { d: "m22 22-5-10-5 10", key: "don7ne" }],
|
|
26105
26105
|
["path", { d: "M14 18h6", key: "1m8k6r" }]
|
|
26106
26106
|
];
|
|
26107
|
-
const Languages = createLucideIcon("languages", __iconNode$
|
|
26108
|
-
const __iconNode$
|
|
26107
|
+
const Languages = createLucideIcon("languages", __iconNode$b);
|
|
26108
|
+
const __iconNode$a = [
|
|
26109
26109
|
["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
|
|
26110
26110
|
["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
|
|
26111
26111
|
];
|
|
26112
|
-
const Link = createLucideIcon("link", __iconNode$
|
|
26113
|
-
const __iconNode$
|
|
26114
|
-
const LoaderCircle = createLucideIcon("loader-circle", __iconNode$
|
|
26115
|
-
const __iconNode$
|
|
26112
|
+
const Link = createLucideIcon("link", __iconNode$a);
|
|
26113
|
+
const __iconNode$9 = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
|
|
26114
|
+
const LoaderCircle = createLucideIcon("loader-circle", __iconNode$9);
|
|
26115
|
+
const __iconNode$8 = [
|
|
26116
26116
|
[
|
|
26117
26117
|
"path",
|
|
26118
26118
|
{
|
|
@@ -26122,7 +26122,19 @@ var MedAssistWidget = (function(exports) {
|
|
|
26122
26122
|
],
|
|
26123
26123
|
["circle", { cx: "12", cy: "10", r: "3", key: "ilqhr7" }]
|
|
26124
26124
|
];
|
|
26125
|
-
const MapPin = createLucideIcon("map-pin", __iconNode$
|
|
26125
|
+
const MapPin = createLucideIcon("map-pin", __iconNode$8);
|
|
26126
|
+
const __iconNode$7 = [
|
|
26127
|
+
[
|
|
26128
|
+
"path",
|
|
26129
|
+
{
|
|
26130
|
+
d: "M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",
|
|
26131
|
+
key: "169xi5"
|
|
26132
|
+
}
|
|
26133
|
+
],
|
|
26134
|
+
["path", { d: "M15 5.764v15", key: "1pn4in" }],
|
|
26135
|
+
["path", { d: "M9 3.236v15", key: "1uimfh" }]
|
|
26136
|
+
];
|
|
26137
|
+
const Map$1 = createLucideIcon("map", __iconNode$7);
|
|
26126
26138
|
const __iconNode$6 = [
|
|
26127
26139
|
[
|
|
26128
26140
|
"path",
|
|
@@ -27490,7 +27502,7 @@ var MedAssistWidget = (function(exports) {
|
|
|
27490
27502
|
PILL: "pills",
|
|
27491
27503
|
MULTI: "multi",
|
|
27492
27504
|
DOCTOR_CARD: "doctor_card",
|
|
27493
|
-
|
|
27505
|
+
CARD: "card"
|
|
27494
27506
|
};
|
|
27495
27507
|
var SYNAPSE_TOOL_CALLBACK_NAME;
|
|
27496
27508
|
(function(SYNAPSE_TOOL_CALLBACK_NAME2) {
|
|
@@ -27613,7 +27625,7 @@ var MedAssistWidget = (function(exports) {
|
|
|
27613
27625
|
try {
|
|
27614
27626
|
const { profile, intent, user_location, referer, ...extraContext } = context || {};
|
|
27615
27627
|
const sessionRequest = {
|
|
27616
|
-
user_id: userId,
|
|
27628
|
+
...userId && { user_id: userId },
|
|
27617
27629
|
...profile && { user_context: profile },
|
|
27618
27630
|
...(intent || Object.keys(extraContext).length > 0) && {
|
|
27619
27631
|
session_context: {
|
|
@@ -29160,7 +29172,7 @@ var MedAssistWidget = (function(exports) {
|
|
|
29160
29172
|
* Create a new session
|
|
29161
29173
|
*/
|
|
29162
29174
|
async createNewSession() {
|
|
29163
|
-
return await this.resourceManager.createSession(this.config.userId
|
|
29175
|
+
return await this.resourceManager.createSession(this.config.userId, this.config.context);
|
|
29164
29176
|
}
|
|
29165
29177
|
/**
|
|
29166
29178
|
* Set up event handlers for connection and messages
|
|
@@ -30659,7 +30671,8 @@ var MedAssistWidget = (function(exports) {
|
|
|
30659
30671
|
isMobile,
|
|
30660
30672
|
placeholder: chatComposer.placeholder,
|
|
30661
30673
|
recordingStatus: chatComposer.recordingStatus,
|
|
30662
|
-
theme: mergedTheme
|
|
30674
|
+
theme: mergedTheme,
|
|
30675
|
+
allowed: chatComposer.allowed
|
|
30663
30676
|
}
|
|
30664
30677
|
) }),
|
|
30665
30678
|
sessionId && environment === "development" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-6 flex justify-center items-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-[8px] text-text-secondary font-mono opacity-50", children: [
|
|
@@ -30741,6 +30754,7 @@ var MedAssistWidget = (function(exports) {
|
|
|
30741
30754
|
updateMessageInSession,
|
|
30742
30755
|
setInitialMessage,
|
|
30743
30756
|
userId,
|
|
30757
|
+
setUserId,
|
|
30744
30758
|
fileUploadPerSession,
|
|
30745
30759
|
setFileUploadPerSession
|
|
30746
30760
|
} = useMedAssistStore();
|
|
@@ -30967,6 +30981,9 @@ var MedAssistWidget = (function(exports) {
|
|
|
30967
30981
|
session
|
|
30968
30982
|
);
|
|
30969
30983
|
}
|
|
30984
|
+
if (session?.user_id) {
|
|
30985
|
+
setUserId(session.user_id);
|
|
30986
|
+
}
|
|
30970
30987
|
setUpEventListeners();
|
|
30971
30988
|
} catch (error) {
|
|
30972
30989
|
console.error("useChat: Error starting session", error);
|
|
@@ -31551,8 +31568,6 @@ var MedAssistWidget = (function(exports) {
|
|
|
31551
31568
|
setError,
|
|
31552
31569
|
// initialMessage,
|
|
31553
31570
|
sessionId,
|
|
31554
|
-
setUserId,
|
|
31555
|
-
userId,
|
|
31556
31571
|
setContext
|
|
31557
31572
|
} = useMedAssistStore();
|
|
31558
31573
|
const {
|
|
@@ -31581,10 +31596,6 @@ var MedAssistWidget = (function(exports) {
|
|
|
31581
31596
|
return;
|
|
31582
31597
|
}
|
|
31583
31598
|
setAgentId(agentId);
|
|
31584
|
-
if (!userId) {
|
|
31585
|
-
const uuid = crypto?.randomUUID?.() || Date.now().toString();
|
|
31586
|
-
setUserId(uuid);
|
|
31587
|
-
}
|
|
31588
31599
|
if (config?.context && Object.keys(config?.context || {}).length) {
|
|
31589
31600
|
setContext(config.context);
|
|
31590
31601
|
}
|
|
@@ -31733,7 +31744,8 @@ var MedAssistWidget = (function(exports) {
|
|
|
31733
31744
|
attachmentFiles,
|
|
31734
31745
|
isDisabled: isComposerDisabled,
|
|
31735
31746
|
placeholder: composerPlaceholder,
|
|
31736
|
-
recordingStatus
|
|
31747
|
+
recordingStatus,
|
|
31748
|
+
allowed: config.allowed
|
|
31737
31749
|
},
|
|
31738
31750
|
children: !loading && /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(WidgetContentFallback, {}), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("flex-1 flex flex-col min-h-0 overflow-hidden relative synapse-chat-window", config.theme?.backgroundImage ? "" : "bg-surface"), children: [
|
|
31739
31751
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -32000,11 +32012,16 @@ var MedAssistWidget = (function(exports) {
|
|
|
32000
32012
|
placeholder,
|
|
32001
32013
|
isMobile,
|
|
32002
32014
|
recordingStatus,
|
|
32003
|
-
theme
|
|
32015
|
+
theme,
|
|
32016
|
+
allowed
|
|
32004
32017
|
}) {
|
|
32005
32018
|
const fileInputRef = reactExports.useRef(null);
|
|
32006
32019
|
const textareaRef = reactExports.useRef(null);
|
|
32007
|
-
const
|
|
32020
|
+
const hasContent = value.trim().length > 0 || hasAttachment;
|
|
32021
|
+
const showMic = allowed === void 0 || allowed.includes("audio");
|
|
32022
|
+
const showSendButton = hasContent || !showMic;
|
|
32023
|
+
const canSend = hasContent;
|
|
32024
|
+
const showFileAttachment = allowed === void 0 || allowed.includes("file");
|
|
32008
32025
|
const isMicDisabled = (isDisabled || recordingStatus !== AudioRecordingStatus.IDLE) && !isRecording;
|
|
32009
32026
|
const micButtonClasses = cn(
|
|
32010
32027
|
"rounded-full transition-all duration-200 ",
|
|
@@ -32023,7 +32040,7 @@ var MedAssistWidget = (function(exports) {
|
|
|
32023
32040
|
fileInputRef.current?.click();
|
|
32024
32041
|
};
|
|
32025
32042
|
const handleKeyPress = (e) => {
|
|
32026
|
-
if (e.key === "Enter" && !e.shiftKey &&
|
|
32043
|
+
if (e.key === "Enter" && !e.shiftKey && canSend && !isDisabled) {
|
|
32027
32044
|
e.preventDefault();
|
|
32028
32045
|
onSend();
|
|
32029
32046
|
}
|
|
@@ -32080,7 +32097,7 @@ var MedAssistWidget = (function(exports) {
|
|
|
32080
32097
|
}
|
|
32081
32098
|
),
|
|
32082
32099
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 w-full", children: [
|
|
32083
|
-
recordingStatus === AudioRecordingStatus.IDLE && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
32100
|
+
showFileAttachment && recordingStatus === AudioRecordingStatus.IDLE && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
32084
32101
|
Button,
|
|
32085
32102
|
{
|
|
32086
32103
|
type: "button",
|
|
@@ -32146,7 +32163,7 @@ var MedAssistWidget = (function(exports) {
|
|
|
32146
32163
|
"aria-label": "Stop recording",
|
|
32147
32164
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Square, { className: "w-4 h-4" })
|
|
32148
32165
|
}
|
|
32149
|
-
) : !showSendButton && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
32166
|
+
) : showMic && !showSendButton && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
32150
32167
|
Button,
|
|
32151
32168
|
{
|
|
32152
32169
|
type: "button",
|
|
@@ -32163,15 +32180,16 @@ var MedAssistWidget = (function(exports) {
|
|
|
32163
32180
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Mic, { className: "w-5 h-5" })
|
|
32164
32181
|
}
|
|
32165
32182
|
),
|
|
32166
|
-
showSendButton &&
|
|
32183
|
+
showSendButton && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
32167
32184
|
Button,
|
|
32168
32185
|
{
|
|
32169
32186
|
type: "button",
|
|
32170
32187
|
size: "icon",
|
|
32171
32188
|
onClick: onSend,
|
|
32172
|
-
|
|
32173
|
-
|
|
32174
|
-
"
|
|
32189
|
+
disabled: isDisabled || !canSend,
|
|
32190
|
+
className: `absolute right-0.5 top-1/2 -translate-y-1/2 h-10 w-10 ${!showMic ? "" : "bg-primary"} hover:bg-primary/90 rounded-full text-primary-foreground transition-all duration-200 shadow-lg hover:shadow-xl hover:scale-105 active:scale-95 shrink-0 disabled:opacity-50 disabled:pointer-events-none disabled:hover:scale-100`,
|
|
32191
|
+
title: canSend ? "Send message" : "Type a message to send",
|
|
32192
|
+
"aria-label": canSend ? "Send message" : "Type a message to send",
|
|
32175
32193
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(SendIcon, { className: "w-4 h-4 text-primary-foreground" })
|
|
32176
32194
|
}
|
|
32177
32195
|
)
|
|
@@ -43028,128 +43046,178 @@ var MedAssistWidget = (function(exports) {
|
|
|
43028
43046
|
] })
|
|
43029
43047
|
] });
|
|
43030
43048
|
}
|
|
43031
|
-
|
|
43032
|
-
|
|
43033
|
-
|
|
43034
|
-
|
|
43035
|
-
|
|
43036
|
-
|
|
43037
|
-
|
|
43038
|
-
|
|
43039
|
-
|
|
43049
|
+
const CARD_ICONS = {
|
|
43050
|
+
voucher: Ticket,
|
|
43051
|
+
pharmacy: Building2,
|
|
43052
|
+
hospital: Building2,
|
|
43053
|
+
map: Map$1,
|
|
43054
|
+
location_pin: MapPin,
|
|
43055
|
+
"location pin": MapPin,
|
|
43056
|
+
check: Check,
|
|
43057
|
+
calendar: Calendar
|
|
43058
|
+
};
|
|
43059
|
+
const ICON_CDN_BASE = "https://cdn.jsdelivr.net/npm/lucide-static@0.263.1/icons";
|
|
43060
|
+
function CardIcon({
|
|
43061
|
+
name: name2,
|
|
43062
|
+
className,
|
|
43063
|
+
size = 16
|
|
43040
43064
|
}) {
|
|
43041
|
-
const
|
|
43042
|
-
|
|
43043
|
-
const
|
|
43044
|
-
|
|
43045
|
-
|
|
43065
|
+
const key = name2?.trim().toLowerCase().replace(/\s+/g, "_");
|
|
43066
|
+
if (!key) return null;
|
|
43067
|
+
const IconComponent = CARD_ICONS[key];
|
|
43068
|
+
if (IconComponent) {
|
|
43069
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(IconComponent, { className, size, "aria-hidden": true });
|
|
43070
|
+
}
|
|
43071
|
+
if (/^https?:\/\//i.test(name2) || name2.startsWith("//")) {
|
|
43072
|
+
const src = name2.startsWith("//") ? `https:${name2}` : name2;
|
|
43073
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
43074
|
+
"img",
|
|
43075
|
+
{
|
|
43076
|
+
src,
|
|
43077
|
+
alt: "",
|
|
43078
|
+
className,
|
|
43079
|
+
width: size,
|
|
43080
|
+
height: size,
|
|
43081
|
+
"aria-hidden": true,
|
|
43082
|
+
onError: (e) => {
|
|
43083
|
+
e.target.style.display = "none";
|
|
43084
|
+
}
|
|
43085
|
+
}
|
|
43086
|
+
);
|
|
43087
|
+
}
|
|
43088
|
+
const kebab2 = key.replace(/_/g, "-");
|
|
43089
|
+
const cdnUrl = `${ICON_CDN_BASE}/${kebab2}.svg`;
|
|
43046
43090
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
43047
|
-
|
|
43091
|
+
"img",
|
|
43048
43092
|
{
|
|
43049
|
-
|
|
43050
|
-
|
|
43051
|
-
|
|
43052
|
-
|
|
43053
|
-
|
|
43054
|
-
|
|
43055
|
-
|
|
43056
|
-
|
|
43057
|
-
|
|
43058
|
-
{
|
|
43059
|
-
className: cn(
|
|
43060
|
-
"font-semibold leading-tight",
|
|
43061
|
-
isCustom ? "text-base text-white" : "text-foreground text-sm"
|
|
43062
|
-
),
|
|
43063
|
-
children: pharmacy.name || "Pharmacy"
|
|
43064
|
-
}
|
|
43065
|
-
),
|
|
43066
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
43067
|
-
"div",
|
|
43068
|
-
{
|
|
43069
|
-
className: cn(
|
|
43070
|
-
"shrink-0 rounded-lg p-1.5",
|
|
43071
|
-
isCustom ? "bg-[var(--accent-400)]/20 text-[var(--accent-300)]" : "bg-accent/10 text-[var(--color-primary)]"
|
|
43072
|
-
),
|
|
43073
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Building2, { className: "h-4 w-4", "aria-hidden": true })
|
|
43074
|
-
}
|
|
43075
|
-
)
|
|
43076
|
-
] }),
|
|
43077
|
-
subtitle ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
43078
|
-
"p",
|
|
43079
|
-
{
|
|
43080
|
-
className: cn(
|
|
43081
|
-
"text-xs mb-3",
|
|
43082
|
-
isCustom ? "text-[var(--white-600)]" : "text-muted-foreground"
|
|
43083
|
-
),
|
|
43084
|
-
children: subtitle
|
|
43085
|
-
}
|
|
43086
|
-
) : null,
|
|
43087
|
-
pharmacy.offer ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
43088
|
-
"div",
|
|
43089
|
-
{
|
|
43090
|
-
className: cn(
|
|
43091
|
-
"inline-flex items-center rounded-full px-3 py-1 text-xs font-medium mb-4",
|
|
43092
|
-
isCustom ? "bg-emerald-900/80 text-emerald-300" : "bg-emerald-100 text-emerald-800 dark:bg-emerald-900/40 dark:text-emerald-300"
|
|
43093
|
-
),
|
|
43094
|
-
children: pharmacy.offer
|
|
43095
|
-
}
|
|
43096
|
-
) : null,
|
|
43097
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
43098
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
43099
|
-
Button,
|
|
43100
|
-
{
|
|
43101
|
-
type: "button",
|
|
43102
|
-
size: "sm",
|
|
43103
|
-
className: cn(
|
|
43104
|
-
"rounded-lg gap-1.5 font-medium",
|
|
43105
|
-
isCustom ? "bg-[var(--accent-400)] text-[var(--accent-1000)] hover:bg-[var(--accent-300)]" : "bg-primary text-primary-foreground hover:bg-primary/90"
|
|
43106
|
-
),
|
|
43107
|
-
onClick: () => onGetVoucher?.(pharmacy),
|
|
43108
|
-
children: [
|
|
43109
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Ticket, { className: "h-4 w-4", "aria-hidden": true }),
|
|
43110
|
-
"Get voucher"
|
|
43111
|
-
]
|
|
43112
|
-
}
|
|
43113
|
-
),
|
|
43114
|
-
hasLink && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
43115
|
-
Button,
|
|
43116
|
-
{
|
|
43117
|
-
type: "button",
|
|
43118
|
-
variant: "outline",
|
|
43119
|
-
size: "sm",
|
|
43120
|
-
className: cn(
|
|
43121
|
-
"rounded-lg gap-1.5",
|
|
43122
|
-
isCustom ? "border-[var(--white-300)] text-[var(--white-900)] hover:bg-[var(--white-100)]" : "border-border bg-background text-foreground hover:bg-accent"
|
|
43123
|
-
),
|
|
43124
|
-
onClick: () => pharmacy.link && window.open(pharmacy.link, "_blank", "noopener,noreferrer"),
|
|
43125
|
-
children: [
|
|
43126
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(MapPin, { className: "h-4 w-4", "aria-hidden": true }),
|
|
43127
|
-
"View on maps"
|
|
43128
|
-
]
|
|
43129
|
-
}
|
|
43130
|
-
)
|
|
43131
|
-
] })
|
|
43132
|
-
] })
|
|
43093
|
+
src: cdnUrl,
|
|
43094
|
+
alt: "",
|
|
43095
|
+
className,
|
|
43096
|
+
width: size,
|
|
43097
|
+
height: size,
|
|
43098
|
+
"aria-hidden": true,
|
|
43099
|
+
onError: (e) => {
|
|
43100
|
+
e.target.style.display = "none";
|
|
43101
|
+
}
|
|
43133
43102
|
}
|
|
43134
43103
|
);
|
|
43135
43104
|
}
|
|
43136
|
-
|
|
43137
|
-
|
|
43138
|
-
|
|
43139
|
-
|
|
43105
|
+
const BANNER_THEME_CLASSES = {
|
|
43106
|
+
success: "bg-emerald-100 text-emerald-800",
|
|
43107
|
+
warning: "bg-amber-100 text-amber-800",
|
|
43108
|
+
danger: "bg-red-100 text-red-800",
|
|
43109
|
+
primary: "bg-primary/15 text-primary"
|
|
43110
|
+
};
|
|
43111
|
+
const CTA_VARIANT = {
|
|
43112
|
+
primary: "default",
|
|
43113
|
+
success: "default",
|
|
43114
|
+
warning: "default",
|
|
43115
|
+
danger: "destructive"
|
|
43116
|
+
};
|
|
43117
|
+
function GenericCard({
|
|
43118
|
+
card,
|
|
43119
|
+
onSendMessage,
|
|
43120
|
+
disabled = false
|
|
43121
|
+
}) {
|
|
43122
|
+
const {
|
|
43123
|
+
title,
|
|
43124
|
+
tags,
|
|
43125
|
+
icon,
|
|
43126
|
+
description,
|
|
43127
|
+
banner,
|
|
43128
|
+
items,
|
|
43129
|
+
ctas
|
|
43130
|
+
} = card;
|
|
43131
|
+
const handleCtaClick = (cta) => {
|
|
43132
|
+
if (disabled) return;
|
|
43133
|
+
if (cta.link) {
|
|
43134
|
+
window.open(cta.link, "_blank", "noopener,noreferrer");
|
|
43135
|
+
}
|
|
43136
|
+
const action = cta.action?.trim();
|
|
43137
|
+
if (action) {
|
|
43138
|
+
onSendMessage?.(action);
|
|
43139
|
+
}
|
|
43140
|
+
};
|
|
43141
|
+
const bannerTheme = banner?.theme ?? "success";
|
|
43142
|
+
const bannerClass = BANNER_THEME_CLASSES[bannerTheme];
|
|
43143
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-sm", children: [
|
|
43144
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { className: "flex flex-row items-start justify-between gap-3 pb-2", children: [
|
|
43145
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
43146
|
+
title ? /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base font-bold leading-tight tracking-tight", children: title }) : null,
|
|
43147
|
+
tags?.length ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: tags.join(" • ") }) : null
|
|
43148
|
+
] }),
|
|
43149
|
+
icon ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "shrink-0 text-muted-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardIcon, { name: icon, size: 24, className: "text-primary" }) }) : null
|
|
43150
|
+
] }),
|
|
43151
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "space-y-3 pt-0", children: [
|
|
43152
|
+
description ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-foreground leading-snug", children: description }) : null,
|
|
43153
|
+
banner?.text ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
43154
|
+
"div",
|
|
43155
|
+
{
|
|
43156
|
+
className: cn(
|
|
43157
|
+
"rounded-full px-4 py-2 text-center text-sm font-semibold",
|
|
43158
|
+
bannerClass
|
|
43159
|
+
),
|
|
43160
|
+
children: banner.text
|
|
43161
|
+
}
|
|
43162
|
+
) : null,
|
|
43163
|
+
items?.length ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: items.map((item, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
43164
|
+
"div",
|
|
43165
|
+
{
|
|
43166
|
+
className: "flex items-center gap-1.5 text-xs text-foreground",
|
|
43167
|
+
children: [
|
|
43168
|
+
item.icon ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
43169
|
+
CardIcon,
|
|
43170
|
+
{
|
|
43171
|
+
name: item.icon,
|
|
43172
|
+
size: 12,
|
|
43173
|
+
className: "shrink-0 text-muted-foreground"
|
|
43174
|
+
}
|
|
43175
|
+
) : null,
|
|
43176
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: item.text })
|
|
43177
|
+
]
|
|
43178
|
+
},
|
|
43179
|
+
i
|
|
43180
|
+
)) }) : null
|
|
43181
|
+
] }),
|
|
43182
|
+
ctas?.length ? /* @__PURE__ */ jsxRuntimeExports.jsx(CardFooter, { className: "flex justify-center flex-wrap gap-2 pt-0", children: ctas.map((cta, i) => {
|
|
43183
|
+
const variant = cta.theme ? CTA_VARIANT[cta.theme] : "default";
|
|
43184
|
+
const isOutline = i > 0 || cta.link && !cta.action;
|
|
43185
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
43186
|
+
Button,
|
|
43187
|
+
{
|
|
43188
|
+
type: "button",
|
|
43189
|
+
variant: isOutline ? "outline" : variant,
|
|
43190
|
+
size: "sm",
|
|
43191
|
+
className: "gap-1.5",
|
|
43192
|
+
disabled,
|
|
43193
|
+
onClick: () => handleCtaClick(cta),
|
|
43194
|
+
children: [
|
|
43195
|
+
cta.icon ? /* @__PURE__ */ jsxRuntimeExports.jsx(CardIcon, { name: cta.icon, size: 14, className: "shrink-0" }) : null,
|
|
43196
|
+
cta.title
|
|
43197
|
+
]
|
|
43198
|
+
},
|
|
43199
|
+
i
|
|
43200
|
+
);
|
|
43201
|
+
}) }) : null
|
|
43202
|
+
] });
|
|
43203
|
+
}
|
|
43204
|
+
function CardList({
|
|
43205
|
+
cards,
|
|
43206
|
+
onSendMessage,
|
|
43207
|
+
disabled = false,
|
|
43140
43208
|
className
|
|
43141
43209
|
}) {
|
|
43142
|
-
if (!
|
|
43143
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground py-2", children: "No
|
|
43210
|
+
if (!cards?.length) {
|
|
43211
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground py-2", children: "No options available." });
|
|
43144
43212
|
}
|
|
43145
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: className ?? "
|
|
43146
|
-
|
|
43213
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: className ?? "flex flex-col gap-3 mt-3", children: cards.map((card, index2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
43214
|
+
GenericCard,
|
|
43147
43215
|
{
|
|
43148
|
-
|
|
43149
|
-
|
|
43150
|
-
|
|
43216
|
+
card,
|
|
43217
|
+
onSendMessage,
|
|
43218
|
+
disabled
|
|
43151
43219
|
},
|
|
43152
|
-
|
|
43220
|
+
index2
|
|
43153
43221
|
)) });
|
|
43154
43222
|
}
|
|
43155
43223
|
function ChatMessage({
|
|
@@ -43169,13 +43237,6 @@ var MedAssistWidget = (function(exports) {
|
|
|
43169
43237
|
const [selectedValues, setSelectedValues] = reactExports.useState([]);
|
|
43170
43238
|
const [userFeedback, setUserFeedback] = reactExports.useState(distExports.USER_FEEDBACK.NONE);
|
|
43171
43239
|
const { isStreaming } = useMedAssistStore();
|
|
43172
|
-
const [hasBackgroundImage, setHasBackgroundImage] = reactExports.useState(false);
|
|
43173
|
-
reactExports.useEffect(() => {
|
|
43174
|
-
const container = document.querySelector(".synapse-chat-widget-container");
|
|
43175
|
-
if (container) {
|
|
43176
|
-
setHasBackgroundImage(container.classList.contains("theme-with-background"));
|
|
43177
|
-
}
|
|
43178
|
-
}, []);
|
|
43179
43240
|
const handlePillClick = async (choice) => {
|
|
43180
43241
|
const messageId = Date.now().toString();
|
|
43181
43242
|
await onSendMessage({
|
|
@@ -43370,13 +43431,21 @@ var MedAssistWidget = (function(exports) {
|
|
|
43370
43431
|
disabled: toolEscalationData?.isResponded
|
|
43371
43432
|
}
|
|
43372
43433
|
) }) : null,
|
|
43373
|
-
toolEscalationData?.details?.component === distExports.SYNAPSE_COMPONENTS.
|
|
43374
|
-
|
|
43434
|
+
toolEscalationData?.details?.component === distExports.SYNAPSE_COMPONENTS.CARD && toolEscalationData?.details?.input?.cards && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
43435
|
+
CardList,
|
|
43375
43436
|
{
|
|
43376
|
-
|
|
43377
|
-
|
|
43437
|
+
cards: toolEscalationData.details.input.cards,
|
|
43438
|
+
onSendMessage: async (message) => {
|
|
43439
|
+
const messageId = Date.now().toString();
|
|
43440
|
+
await onSendMessage({
|
|
43441
|
+
message,
|
|
43442
|
+
messageId,
|
|
43443
|
+
toolCalled: true
|
|
43444
|
+
});
|
|
43445
|
+
},
|
|
43446
|
+
disabled: toolEscalationData?.isResponded
|
|
43378
43447
|
}
|
|
43379
|
-
)
|
|
43448
|
+
)
|
|
43380
43449
|
] })
|
|
43381
43450
|
] });
|
|
43382
43451
|
}
|