@runtypelabs/persona 3.8.3 → 3.9.1
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 +1 -1
- package/dist/index.cjs +42 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.global.js +56 -56
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +42 -42
- package/dist/index.js.map +1 -1
- package/dist/theme-editor.cjs +590 -517
- package/dist/theme-editor.js +590 -517
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.js +1 -1
- package/package.json +1 -1
- package/src/client.test.ts +400 -0
- package/src/client.ts +86 -3
- package/src/components/panel.ts +2 -1
- package/src/defaults.ts +11 -1
- package/src/index.ts +2 -0
- package/src/presets.ts +2 -1
- package/src/theme-editor/sections.ts +7 -3
- package/src/theme-reference.ts +1 -1
- package/src/ui.ts +4 -4
- package/src/utils/tokens.ts +6 -2
package/dist/theme-editor.js
CHANGED
|
@@ -1,3 +1,293 @@
|
|
|
1
|
+
// src/utils/deep-merge.ts
|
|
2
|
+
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3
|
+
function deepMerge(base, override) {
|
|
4
|
+
if (!base) return override;
|
|
5
|
+
if (!override) return base;
|
|
6
|
+
const merged = { ...base };
|
|
7
|
+
for (const [key, value] of Object.entries(override)) {
|
|
8
|
+
const existing = merged[key];
|
|
9
|
+
if (isObject(existing) && isObject(value)) {
|
|
10
|
+
merged[key] = deepMerge(existing, value);
|
|
11
|
+
} else {
|
|
12
|
+
merged[key] = value;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return merged;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/defaults.ts
|
|
19
|
+
var DEFAULT_FLOATING_LAUNCHER_WIDTH = "min(440px, calc(100vw - 24px))";
|
|
20
|
+
var DEFAULT_FLOATING_LAUNCHER_MAX_WIDTH = "440px";
|
|
21
|
+
var DEFAULT_WIDGET_CONFIG = {
|
|
22
|
+
apiUrl: "http://localhost:43111/api/chat/dispatch",
|
|
23
|
+
// Client token mode defaults (optional, only used when clientToken is set)
|
|
24
|
+
clientToken: void 0,
|
|
25
|
+
theme: void 0,
|
|
26
|
+
darkTheme: void 0,
|
|
27
|
+
colorScheme: "light",
|
|
28
|
+
launcher: {
|
|
29
|
+
enabled: true,
|
|
30
|
+
mountMode: "floating",
|
|
31
|
+
dock: {
|
|
32
|
+
side: "right",
|
|
33
|
+
width: "420px"
|
|
34
|
+
},
|
|
35
|
+
title: "Chat Assistant",
|
|
36
|
+
subtitle: "Here to help you get answers fast",
|
|
37
|
+
agentIconText: "\u{1F4AC}",
|
|
38
|
+
agentIconName: "bot",
|
|
39
|
+
headerIconName: "bot",
|
|
40
|
+
position: "bottom-right",
|
|
41
|
+
width: DEFAULT_FLOATING_LAUNCHER_WIDTH,
|
|
42
|
+
heightOffset: 0,
|
|
43
|
+
autoExpand: false,
|
|
44
|
+
callToActionIconHidden: false,
|
|
45
|
+
agentIconSize: "40px",
|
|
46
|
+
headerIconSize: "40px",
|
|
47
|
+
closeButtonSize: "32px",
|
|
48
|
+
callToActionIconName: "arrow-up-right",
|
|
49
|
+
callToActionIconText: "",
|
|
50
|
+
callToActionIconSize: "32px",
|
|
51
|
+
callToActionIconPadding: "5px",
|
|
52
|
+
callToActionIconColor: void 0,
|
|
53
|
+
callToActionIconBackgroundColor: void 0,
|
|
54
|
+
// closeButtonColor / clearChat.iconColor omitted so theme.components.header.actionIconForeground applies.
|
|
55
|
+
closeButtonBackgroundColor: "transparent",
|
|
56
|
+
clearChat: {
|
|
57
|
+
backgroundColor: "transparent",
|
|
58
|
+
borderColor: "transparent",
|
|
59
|
+
enabled: true,
|
|
60
|
+
placement: "inline",
|
|
61
|
+
iconName: "refresh-cw",
|
|
62
|
+
size: "32px",
|
|
63
|
+
showTooltip: true,
|
|
64
|
+
tooltipText: "Clear chat",
|
|
65
|
+
paddingX: "0px",
|
|
66
|
+
paddingY: "0px"
|
|
67
|
+
},
|
|
68
|
+
headerIconHidden: false,
|
|
69
|
+
border: void 0,
|
|
70
|
+
shadow: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)"
|
|
71
|
+
},
|
|
72
|
+
copy: {
|
|
73
|
+
welcomeTitle: "Hello \u{1F44B}",
|
|
74
|
+
welcomeSubtitle: "Ask anything about your account or products.",
|
|
75
|
+
inputPlaceholder: "How can I help...",
|
|
76
|
+
sendButtonLabel: "Send"
|
|
77
|
+
},
|
|
78
|
+
sendButton: {
|
|
79
|
+
borderWidth: "0px",
|
|
80
|
+
paddingX: "12px",
|
|
81
|
+
paddingY: "10px",
|
|
82
|
+
borderColor: void 0,
|
|
83
|
+
useIcon: true,
|
|
84
|
+
iconText: "\u2191",
|
|
85
|
+
size: "40px",
|
|
86
|
+
showTooltip: true,
|
|
87
|
+
tooltipText: "Send message",
|
|
88
|
+
iconName: "send"
|
|
89
|
+
},
|
|
90
|
+
statusIndicator: {
|
|
91
|
+
visible: true,
|
|
92
|
+
idleText: "Online",
|
|
93
|
+
connectingText: "Connecting\u2026",
|
|
94
|
+
connectedText: "Streaming\u2026",
|
|
95
|
+
errorText: "Offline"
|
|
96
|
+
},
|
|
97
|
+
voiceRecognition: {
|
|
98
|
+
enabled: true,
|
|
99
|
+
pauseDuration: 2e3,
|
|
100
|
+
iconName: "mic",
|
|
101
|
+
iconSize: "39px",
|
|
102
|
+
borderWidth: "0px",
|
|
103
|
+
paddingX: "9px",
|
|
104
|
+
paddingY: "14px",
|
|
105
|
+
iconColor: void 0,
|
|
106
|
+
backgroundColor: "transparent",
|
|
107
|
+
borderColor: "transparent",
|
|
108
|
+
recordingIconColor: void 0,
|
|
109
|
+
recordingBackgroundColor: void 0,
|
|
110
|
+
recordingBorderColor: "transparent",
|
|
111
|
+
showTooltip: true,
|
|
112
|
+
tooltipText: "Start voice recognition"
|
|
113
|
+
},
|
|
114
|
+
features: {
|
|
115
|
+
showReasoning: true,
|
|
116
|
+
showToolCalls: true,
|
|
117
|
+
scrollToBottom: {
|
|
118
|
+
enabled: true,
|
|
119
|
+
iconName: "arrow-down",
|
|
120
|
+
label: ""
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
suggestionChips: [
|
|
124
|
+
"What can you help me with?",
|
|
125
|
+
"Tell me about your features",
|
|
126
|
+
"How does this work?"
|
|
127
|
+
],
|
|
128
|
+
suggestionChipsConfig: {
|
|
129
|
+
fontFamily: "sans-serif",
|
|
130
|
+
fontWeight: "500",
|
|
131
|
+
paddingX: "12px",
|
|
132
|
+
paddingY: "6px"
|
|
133
|
+
},
|
|
134
|
+
layout: {
|
|
135
|
+
header: {
|
|
136
|
+
layout: "default",
|
|
137
|
+
showIcon: true,
|
|
138
|
+
showTitle: true,
|
|
139
|
+
showSubtitle: true,
|
|
140
|
+
showCloseButton: true,
|
|
141
|
+
showClearChat: true
|
|
142
|
+
},
|
|
143
|
+
messages: {
|
|
144
|
+
layout: "bubble",
|
|
145
|
+
avatar: {
|
|
146
|
+
show: false,
|
|
147
|
+
position: "left"
|
|
148
|
+
},
|
|
149
|
+
timestamp: {
|
|
150
|
+
show: false,
|
|
151
|
+
position: "below"
|
|
152
|
+
},
|
|
153
|
+
groupConsecutive: false
|
|
154
|
+
},
|
|
155
|
+
slots: {}
|
|
156
|
+
},
|
|
157
|
+
markdown: {
|
|
158
|
+
options: {
|
|
159
|
+
gfm: true,
|
|
160
|
+
breaks: true
|
|
161
|
+
},
|
|
162
|
+
disableDefaultStyles: false
|
|
163
|
+
},
|
|
164
|
+
messageActions: {
|
|
165
|
+
enabled: true,
|
|
166
|
+
showCopy: true,
|
|
167
|
+
showUpvote: false,
|
|
168
|
+
// Requires backend - disabled by default
|
|
169
|
+
showDownvote: false,
|
|
170
|
+
// Requires backend - disabled by default
|
|
171
|
+
visibility: "hover",
|
|
172
|
+
align: "right",
|
|
173
|
+
layout: "pill-inside"
|
|
174
|
+
},
|
|
175
|
+
debug: false
|
|
176
|
+
};
|
|
177
|
+
function mergeThemePartials(base, override) {
|
|
178
|
+
if (!base && !override) return void 0;
|
|
179
|
+
if (!base) return override;
|
|
180
|
+
if (!override) return base;
|
|
181
|
+
return deepMerge(
|
|
182
|
+
base,
|
|
183
|
+
override
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
function mergeWithDefaults(config) {
|
|
187
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
188
|
+
if (!config) return DEFAULT_WIDGET_CONFIG;
|
|
189
|
+
return {
|
|
190
|
+
...DEFAULT_WIDGET_CONFIG,
|
|
191
|
+
...config,
|
|
192
|
+
theme: mergeThemePartials(DEFAULT_WIDGET_CONFIG.theme, config.theme),
|
|
193
|
+
darkTheme: mergeThemePartials(DEFAULT_WIDGET_CONFIG.darkTheme, config.darkTheme),
|
|
194
|
+
launcher: {
|
|
195
|
+
...DEFAULT_WIDGET_CONFIG.launcher,
|
|
196
|
+
...config.launcher,
|
|
197
|
+
dock: {
|
|
198
|
+
...(_a = DEFAULT_WIDGET_CONFIG.launcher) == null ? void 0 : _a.dock,
|
|
199
|
+
...(_b = config.launcher) == null ? void 0 : _b.dock
|
|
200
|
+
},
|
|
201
|
+
clearChat: {
|
|
202
|
+
...(_c = DEFAULT_WIDGET_CONFIG.launcher) == null ? void 0 : _c.clearChat,
|
|
203
|
+
...(_d = config.launcher) == null ? void 0 : _d.clearChat
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
copy: {
|
|
207
|
+
...DEFAULT_WIDGET_CONFIG.copy,
|
|
208
|
+
...config.copy
|
|
209
|
+
},
|
|
210
|
+
sendButton: {
|
|
211
|
+
...DEFAULT_WIDGET_CONFIG.sendButton,
|
|
212
|
+
...config.sendButton
|
|
213
|
+
},
|
|
214
|
+
statusIndicator: {
|
|
215
|
+
...DEFAULT_WIDGET_CONFIG.statusIndicator,
|
|
216
|
+
...config.statusIndicator
|
|
217
|
+
},
|
|
218
|
+
voiceRecognition: {
|
|
219
|
+
...DEFAULT_WIDGET_CONFIG.voiceRecognition,
|
|
220
|
+
...config.voiceRecognition
|
|
221
|
+
},
|
|
222
|
+
features: (() => {
|
|
223
|
+
var _a2, _b2, _c2, _d2;
|
|
224
|
+
const da = (_a2 = DEFAULT_WIDGET_CONFIG.features) == null ? void 0 : _a2.artifacts;
|
|
225
|
+
const ca = (_b2 = config.features) == null ? void 0 : _b2.artifacts;
|
|
226
|
+
const dsb = (_c2 = DEFAULT_WIDGET_CONFIG.features) == null ? void 0 : _c2.scrollToBottom;
|
|
227
|
+
const csb = (_d2 = config.features) == null ? void 0 : _d2.scrollToBottom;
|
|
228
|
+
const mergedArtifacts = da === void 0 && ca === void 0 ? void 0 : {
|
|
229
|
+
...da,
|
|
230
|
+
...ca,
|
|
231
|
+
layout: {
|
|
232
|
+
...da == null ? void 0 : da.layout,
|
|
233
|
+
...ca == null ? void 0 : ca.layout
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
const mergedScrollToBottom = dsb === void 0 && csb === void 0 ? void 0 : {
|
|
237
|
+
...dsb,
|
|
238
|
+
...csb
|
|
239
|
+
};
|
|
240
|
+
return {
|
|
241
|
+
...DEFAULT_WIDGET_CONFIG.features,
|
|
242
|
+
...config.features,
|
|
243
|
+
...mergedScrollToBottom !== void 0 ? { scrollToBottom: mergedScrollToBottom } : {},
|
|
244
|
+
...mergedArtifacts !== void 0 ? { artifacts: mergedArtifacts } : {}
|
|
245
|
+
};
|
|
246
|
+
})(),
|
|
247
|
+
suggestionChips: (_e = config.suggestionChips) != null ? _e : DEFAULT_WIDGET_CONFIG.suggestionChips,
|
|
248
|
+
suggestionChipsConfig: {
|
|
249
|
+
...DEFAULT_WIDGET_CONFIG.suggestionChipsConfig,
|
|
250
|
+
...config.suggestionChipsConfig
|
|
251
|
+
},
|
|
252
|
+
layout: {
|
|
253
|
+
...DEFAULT_WIDGET_CONFIG.layout,
|
|
254
|
+
...config.layout,
|
|
255
|
+
header: {
|
|
256
|
+
...(_f = DEFAULT_WIDGET_CONFIG.layout) == null ? void 0 : _f.header,
|
|
257
|
+
...(_g = config.layout) == null ? void 0 : _g.header
|
|
258
|
+
},
|
|
259
|
+
messages: {
|
|
260
|
+
...(_h = DEFAULT_WIDGET_CONFIG.layout) == null ? void 0 : _h.messages,
|
|
261
|
+
...(_i = config.layout) == null ? void 0 : _i.messages,
|
|
262
|
+
avatar: {
|
|
263
|
+
...(_k = (_j = DEFAULT_WIDGET_CONFIG.layout) == null ? void 0 : _j.messages) == null ? void 0 : _k.avatar,
|
|
264
|
+
...(_m = (_l = config.layout) == null ? void 0 : _l.messages) == null ? void 0 : _m.avatar
|
|
265
|
+
},
|
|
266
|
+
timestamp: {
|
|
267
|
+
...(_o = (_n = DEFAULT_WIDGET_CONFIG.layout) == null ? void 0 : _n.messages) == null ? void 0 : _o.timestamp,
|
|
268
|
+
...(_q = (_p = config.layout) == null ? void 0 : _p.messages) == null ? void 0 : _q.timestamp
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
slots: {
|
|
272
|
+
...(_r = DEFAULT_WIDGET_CONFIG.layout) == null ? void 0 : _r.slots,
|
|
273
|
+
...(_s = config.layout) == null ? void 0 : _s.slots
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
markdown: {
|
|
277
|
+
...DEFAULT_WIDGET_CONFIG.markdown,
|
|
278
|
+
...config.markdown,
|
|
279
|
+
options: {
|
|
280
|
+
...(_t = DEFAULT_WIDGET_CONFIG.markdown) == null ? void 0 : _t.options,
|
|
281
|
+
...(_u = config.markdown) == null ? void 0 : _u.options
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
messageActions: {
|
|
285
|
+
...DEFAULT_WIDGET_CONFIG.messageActions,
|
|
286
|
+
...config.messageActions
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
1
291
|
// src/utils/tokens.ts
|
|
2
292
|
var DEFAULT_PALETTE = {
|
|
3
293
|
colors: {
|
|
@@ -265,8 +555,8 @@ var DEFAULT_COMPONENTS = {
|
|
|
265
555
|
shadow: "palette.shadows.lg"
|
|
266
556
|
},
|
|
267
557
|
panel: {
|
|
268
|
-
width:
|
|
269
|
-
maxWidth:
|
|
558
|
+
width: DEFAULT_FLOATING_LAUNCHER_WIDTH,
|
|
559
|
+
maxWidth: DEFAULT_FLOATING_LAUNCHER_MAX_WIDTH,
|
|
270
560
|
height: "600px",
|
|
271
561
|
maxHeight: "calc(100vh - 80px)",
|
|
272
562
|
borderRadius: "palette.radius.xl",
|
|
@@ -745,526 +1035,238 @@ function themeToCssVariables(theme) {
|
|
|
745
1035
|
cssVars["--persona-dropdown-border"] = (_Za = cssVars["--persona-dropdown-border"]) != null ? _Za : t.copyMenuBorder;
|
|
746
1036
|
}
|
|
747
1037
|
if (t.copyMenuShadow) {
|
|
748
|
-
cssVars["--persona-artifact-toolbar-copy-menu-shadow"] = t.copyMenuShadow;
|
|
749
|
-
cssVars["--persona-dropdown-shadow"] = (__a = cssVars["--persona-dropdown-shadow"]) != null ? __a : t.copyMenuShadow;
|
|
750
|
-
}
|
|
751
|
-
if (t.copyMenuBorderRadius) {
|
|
752
|
-
cssVars["--persona-artifact-toolbar-copy-menu-radius"] = t.copyMenuBorderRadius;
|
|
753
|
-
cssVars["--persona-dropdown-radius"] = (_$a = cssVars["--persona-dropdown-radius"]) != null ? _$a : t.copyMenuBorderRadius;
|
|
754
|
-
}
|
|
755
|
-
if (t.copyMenuItemHoverBackground) {
|
|
756
|
-
cssVars["--persona-artifact-toolbar-copy-menu-item-hover-bg"] = t.copyMenuItemHoverBackground;
|
|
757
|
-
cssVars["--persona-dropdown-item-hover-bg"] = (_ab = cssVars["--persona-dropdown-item-hover-bg"]) != null ? _ab : t.copyMenuItemHoverBackground;
|
|
758
|
-
}
|
|
759
|
-
if (t.iconBackground) cssVars["--persona-artifact-toolbar-icon-bg"] = t.iconBackground;
|
|
760
|
-
if (t.toolbarBorder) cssVars["--persona-artifact-toolbar-border"] = t.toolbarBorder;
|
|
761
|
-
}
|
|
762
|
-
if (artifact == null ? void 0 : artifact.tab) {
|
|
763
|
-
const t = artifact.tab;
|
|
764
|
-
if (t.background) cssVars["--persona-artifact-tab-bg"] = t.background;
|
|
765
|
-
if (t.activeBackground) cssVars["--persona-artifact-tab-active-bg"] = t.activeBackground;
|
|
766
|
-
if (t.activeBorder) cssVars["--persona-artifact-tab-active-border"] = t.activeBorder;
|
|
767
|
-
if (t.borderRadius) cssVars["--persona-artifact-tab-radius"] = t.borderRadius;
|
|
768
|
-
if (t.textColor) cssVars["--persona-artifact-tab-color"] = t.textColor;
|
|
769
|
-
if (t.hoverBackground) cssVars["--persona-artifact-tab-hover-bg"] = t.hoverBackground;
|
|
770
|
-
if (t.listBackground) cssVars["--persona-artifact-tab-list-bg"] = t.listBackground;
|
|
771
|
-
if (t.listBorderColor) cssVars["--persona-artifact-tab-list-border-color"] = t.listBorderColor;
|
|
772
|
-
if (t.listPadding) cssVars["--persona-artifact-tab-list-padding"] = t.listPadding;
|
|
773
|
-
}
|
|
774
|
-
if (artifact == null ? void 0 : artifact.pane) {
|
|
775
|
-
const t = artifact.pane;
|
|
776
|
-
if (t.toolbarBackground) {
|
|
777
|
-
const toolbarBg = (_bb = resolveTokenValue(theme, t.toolbarBackground)) != null ? _bb : t.toolbarBackground;
|
|
778
|
-
cssVars["--persona-artifact-toolbar-bg"] = toolbarBg;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
return cssVars;
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
// src/utils/deep-merge.ts
|
|
785
|
-
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
786
|
-
function deepMerge(base, override) {
|
|
787
|
-
if (!base) return override;
|
|
788
|
-
if (!override) return base;
|
|
789
|
-
const merged = { ...base };
|
|
790
|
-
for (const [key, value] of Object.entries(override)) {
|
|
791
|
-
const existing = merged[key];
|
|
792
|
-
if (isObject(existing) && isObject(value)) {
|
|
793
|
-
merged[key] = deepMerge(existing, value);
|
|
794
|
-
} else {
|
|
795
|
-
merged[key] = value;
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
return merged;
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
// src/utils/theme.ts
|
|
802
|
-
var DARK_PALETTE = {
|
|
803
|
-
colors: {
|
|
804
|
-
primary: {
|
|
805
|
-
50: "#ffffff",
|
|
806
|
-
100: "#f5f5f5",
|
|
807
|
-
200: "#d4d4d4",
|
|
808
|
-
300: "#a3a3a3",
|
|
809
|
-
400: "#737373",
|
|
810
|
-
500: "#171717",
|
|
811
|
-
600: "#0f0f0f",
|
|
812
|
-
700: "#0a0a0a",
|
|
813
|
-
800: "#050505",
|
|
814
|
-
900: "#030303",
|
|
815
|
-
950: "#000000"
|
|
816
|
-
},
|
|
817
|
-
secondary: {
|
|
818
|
-
50: "#f5f3ff",
|
|
819
|
-
100: "#ede9fe",
|
|
820
|
-
200: "#ddd6fe",
|
|
821
|
-
300: "#c4b5fd",
|
|
822
|
-
400: "#a78bfa",
|
|
823
|
-
500: "#8b5cf6",
|
|
824
|
-
600: "#7c3aed",
|
|
825
|
-
700: "#6d28d9",
|
|
826
|
-
800: "#5b21b6",
|
|
827
|
-
900: "#4c1d95",
|
|
828
|
-
950: "#2e1065"
|
|
829
|
-
},
|
|
830
|
-
accent: {
|
|
831
|
-
50: "#ecfeff",
|
|
832
|
-
100: "#cffafe",
|
|
833
|
-
200: "#a5f3fc",
|
|
834
|
-
300: "#67e8f9",
|
|
835
|
-
400: "#22d3ee",
|
|
836
|
-
500: "#06b6d4",
|
|
837
|
-
600: "#0891b2",
|
|
838
|
-
700: "#0e7490",
|
|
839
|
-
800: "#155e75",
|
|
840
|
-
900: "#164e63",
|
|
841
|
-
950: "#083344"
|
|
842
|
-
},
|
|
843
|
-
gray: {
|
|
844
|
-
50: "#f9fafb",
|
|
845
|
-
100: "#f3f4f6",
|
|
846
|
-
200: "#e5e7eb",
|
|
847
|
-
300: "#d1d5db",
|
|
848
|
-
400: "#9ca3af",
|
|
849
|
-
500: "#6b7280",
|
|
850
|
-
600: "#4b5563",
|
|
851
|
-
700: "#374151",
|
|
852
|
-
800: "#1f2937",
|
|
853
|
-
900: "#111827",
|
|
854
|
-
950: "#030712"
|
|
855
|
-
},
|
|
856
|
-
success: {
|
|
857
|
-
50: "#f0fdf4",
|
|
858
|
-
100: "#dcfce7",
|
|
859
|
-
200: "#bbf7d0",
|
|
860
|
-
300: "#86efac",
|
|
861
|
-
400: "#4ade80",
|
|
862
|
-
500: "#22c55e",
|
|
863
|
-
600: "#16a34a",
|
|
864
|
-
700: "#15803d",
|
|
865
|
-
800: "#166534",
|
|
866
|
-
900: "#14532d"
|
|
867
|
-
},
|
|
868
|
-
warning: {
|
|
869
|
-
50: "#fefce8",
|
|
870
|
-
100: "#fef9c3",
|
|
871
|
-
200: "#fef08a",
|
|
872
|
-
300: "#fde047",
|
|
873
|
-
400: "#facc15",
|
|
874
|
-
500: "#eab308",
|
|
875
|
-
600: "#ca8a04",
|
|
876
|
-
700: "#a16207",
|
|
877
|
-
800: "#854d0e",
|
|
878
|
-
900: "#713f12"
|
|
879
|
-
},
|
|
880
|
-
error: {
|
|
881
|
-
50: "#fef2f2",
|
|
882
|
-
100: "#fee2e2",
|
|
883
|
-
200: "#fecaca",
|
|
884
|
-
300: "#fca5a5",
|
|
885
|
-
400: "#f87171",
|
|
886
|
-
500: "#ef4444",
|
|
887
|
-
600: "#dc2626",
|
|
888
|
-
700: "#b91c1c",
|
|
889
|
-
800: "#991b1b",
|
|
890
|
-
900: "#7f1d1d"
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
};
|
|
894
|
-
var normalizeThemeConfig = (theme) => {
|
|
895
|
-
if (!theme || typeof theme !== "object" || Array.isArray(theme)) return void 0;
|
|
896
|
-
return theme;
|
|
897
|
-
};
|
|
898
|
-
var detectColorScheme = () => {
|
|
899
|
-
var _a;
|
|
900
|
-
if (typeof document !== "undefined" && document.documentElement.classList.contains("dark")) {
|
|
901
|
-
return "dark";
|
|
902
|
-
}
|
|
903
|
-
if (typeof window !== "undefined" && ((_a = window.matchMedia) == null ? void 0 : _a.call(window, "(prefers-color-scheme: dark)").matches)) {
|
|
904
|
-
return "dark";
|
|
905
|
-
}
|
|
906
|
-
return "light";
|
|
907
|
-
};
|
|
908
|
-
var getColorSchemeFromConfig = (config) => {
|
|
909
|
-
var _a;
|
|
910
|
-
const colorScheme = (_a = config == null ? void 0 : config.colorScheme) != null ? _a : "light";
|
|
911
|
-
if (colorScheme === "light") return "light";
|
|
912
|
-
if (colorScheme === "dark") return "dark";
|
|
913
|
-
return detectColorScheme();
|
|
914
|
-
};
|
|
915
|
-
var getColorScheme = (config) => {
|
|
916
|
-
return getColorSchemeFromConfig(config);
|
|
917
|
-
};
|
|
918
|
-
var createLightTheme = (userConfig) => {
|
|
919
|
-
return createTheme(userConfig);
|
|
920
|
-
};
|
|
921
|
-
var createDarkTheme = (userConfig) => {
|
|
922
|
-
var _a;
|
|
923
|
-
const baseTheme = createTheme(void 0, { validate: false });
|
|
924
|
-
return createTheme(
|
|
925
|
-
{
|
|
926
|
-
...userConfig,
|
|
927
|
-
palette: {
|
|
928
|
-
...baseTheme.palette,
|
|
929
|
-
colors: {
|
|
930
|
-
...DARK_PALETTE.colors,
|
|
931
|
-
...(_a = userConfig == null ? void 0 : userConfig.palette) == null ? void 0 : _a.colors
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
},
|
|
935
|
-
{ validate: false }
|
|
936
|
-
);
|
|
937
|
-
};
|
|
938
|
-
var getActiveTheme = (config) => {
|
|
939
|
-
const scheme = getColorScheme(config);
|
|
940
|
-
const lightThemeConfig = normalizeThemeConfig(config == null ? void 0 : config.theme);
|
|
941
|
-
const darkThemeConfig = normalizeThemeConfig(config == null ? void 0 : config.darkTheme);
|
|
942
|
-
if (scheme === "dark") {
|
|
943
|
-
return createDarkTheme(
|
|
944
|
-
deepMerge(
|
|
945
|
-
lightThemeConfig != null ? lightThemeConfig : {},
|
|
946
|
-
darkThemeConfig != null ? darkThemeConfig : {}
|
|
947
|
-
)
|
|
948
|
-
);
|
|
949
|
-
}
|
|
950
|
-
return createLightTheme(lightThemeConfig);
|
|
951
|
-
};
|
|
952
|
-
var getCssVariables = (theme) => {
|
|
953
|
-
return themeToCssVariables(theme);
|
|
954
|
-
};
|
|
955
|
-
var applyThemeVariables = (element, config) => {
|
|
956
|
-
var _a;
|
|
957
|
-
const theme = getActiveTheme(config);
|
|
958
|
-
const cssVars = getCssVariables(theme);
|
|
959
|
-
for (const [name, value] of Object.entries(cssVars)) {
|
|
960
|
-
element.style.setProperty(name, value);
|
|
961
|
-
}
|
|
962
|
-
const toolCallShadow = (_a = config == null ? void 0 : config.toolCall) == null ? void 0 : _a.shadow;
|
|
963
|
-
if (toolCallShadow !== void 0) {
|
|
964
|
-
element.style.setProperty(
|
|
965
|
-
"--persona-tool-bubble-shadow",
|
|
966
|
-
toolCallShadow.trim() === "" ? "none" : toolCallShadow
|
|
967
|
-
);
|
|
968
|
-
}
|
|
969
|
-
};
|
|
970
|
-
var createThemeObserver = (callback) => {
|
|
971
|
-
const cleanupFns = [];
|
|
972
|
-
if (typeof document !== "undefined" && typeof MutationObserver !== "undefined") {
|
|
973
|
-
const observer = new MutationObserver(() => {
|
|
974
|
-
callback(detectColorScheme());
|
|
975
|
-
});
|
|
976
|
-
observer.observe(document.documentElement, {
|
|
977
|
-
attributes: true,
|
|
978
|
-
attributeFilter: ["class"]
|
|
979
|
-
});
|
|
980
|
-
cleanupFns.push(() => observer.disconnect());
|
|
981
|
-
}
|
|
982
|
-
if (typeof window !== "undefined" && window.matchMedia) {
|
|
983
|
-
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
984
|
-
const handleChange = () => callback(detectColorScheme());
|
|
985
|
-
if (mediaQuery.addEventListener) {
|
|
986
|
-
mediaQuery.addEventListener("change", handleChange);
|
|
987
|
-
cleanupFns.push(() => mediaQuery.removeEventListener("change", handleChange));
|
|
988
|
-
} else if (mediaQuery.addListener) {
|
|
989
|
-
mediaQuery.addListener(handleChange);
|
|
990
|
-
cleanupFns.push(() => mediaQuery.removeListener(handleChange));
|
|
1038
|
+
cssVars["--persona-artifact-toolbar-copy-menu-shadow"] = t.copyMenuShadow;
|
|
1039
|
+
cssVars["--persona-dropdown-shadow"] = (__a = cssVars["--persona-dropdown-shadow"]) != null ? __a : t.copyMenuShadow;
|
|
1040
|
+
}
|
|
1041
|
+
if (t.copyMenuBorderRadius) {
|
|
1042
|
+
cssVars["--persona-artifact-toolbar-copy-menu-radius"] = t.copyMenuBorderRadius;
|
|
1043
|
+
cssVars["--persona-dropdown-radius"] = (_$a = cssVars["--persona-dropdown-radius"]) != null ? _$a : t.copyMenuBorderRadius;
|
|
1044
|
+
}
|
|
1045
|
+
if (t.copyMenuItemHoverBackground) {
|
|
1046
|
+
cssVars["--persona-artifact-toolbar-copy-menu-item-hover-bg"] = t.copyMenuItemHoverBackground;
|
|
1047
|
+
cssVars["--persona-dropdown-item-hover-bg"] = (_ab = cssVars["--persona-dropdown-item-hover-bg"]) != null ? _ab : t.copyMenuItemHoverBackground;
|
|
991
1048
|
}
|
|
1049
|
+
if (t.iconBackground) cssVars["--persona-artifact-toolbar-icon-bg"] = t.iconBackground;
|
|
1050
|
+
if (t.toolbarBorder) cssVars["--persona-artifact-toolbar-border"] = t.toolbarBorder;
|
|
992
1051
|
}
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
side: "right",
|
|
1011
|
-
width: "420px"
|
|
1012
|
-
},
|
|
1013
|
-
title: "Chat Assistant",
|
|
1014
|
-
subtitle: "Here to help you get answers fast",
|
|
1015
|
-
agentIconText: "\u{1F4AC}",
|
|
1016
|
-
agentIconName: "bot",
|
|
1017
|
-
headerIconName: "bot",
|
|
1018
|
-
position: "bottom-right",
|
|
1019
|
-
width: "min(400px, calc(100vw - 24px))",
|
|
1020
|
-
heightOffset: 0,
|
|
1021
|
-
autoExpand: false,
|
|
1022
|
-
callToActionIconHidden: false,
|
|
1023
|
-
agentIconSize: "40px",
|
|
1024
|
-
headerIconSize: "40px",
|
|
1025
|
-
closeButtonSize: "32px",
|
|
1026
|
-
callToActionIconName: "arrow-up-right",
|
|
1027
|
-
callToActionIconText: "",
|
|
1028
|
-
callToActionIconSize: "32px",
|
|
1029
|
-
callToActionIconPadding: "5px",
|
|
1030
|
-
callToActionIconColor: void 0,
|
|
1031
|
-
callToActionIconBackgroundColor: void 0,
|
|
1032
|
-
// closeButtonColor / clearChat.iconColor omitted so theme.components.header.actionIconForeground applies.
|
|
1033
|
-
closeButtonBackgroundColor: "transparent",
|
|
1034
|
-
clearChat: {
|
|
1035
|
-
backgroundColor: "transparent",
|
|
1036
|
-
borderColor: "transparent",
|
|
1037
|
-
enabled: true,
|
|
1038
|
-
placement: "inline",
|
|
1039
|
-
iconName: "refresh-cw",
|
|
1040
|
-
size: "32px",
|
|
1041
|
-
showTooltip: true,
|
|
1042
|
-
tooltipText: "Clear chat",
|
|
1043
|
-
paddingX: "0px",
|
|
1044
|
-
paddingY: "0px"
|
|
1045
|
-
},
|
|
1046
|
-
headerIconHidden: false,
|
|
1047
|
-
border: void 0,
|
|
1048
|
-
shadow: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)"
|
|
1049
|
-
},
|
|
1050
|
-
copy: {
|
|
1051
|
-
welcomeTitle: "Hello \u{1F44B}",
|
|
1052
|
-
welcomeSubtitle: "Ask anything about your account or products.",
|
|
1053
|
-
inputPlaceholder: "How can I help...",
|
|
1054
|
-
sendButtonLabel: "Send"
|
|
1055
|
-
},
|
|
1056
|
-
sendButton: {
|
|
1057
|
-
borderWidth: "0px",
|
|
1058
|
-
paddingX: "12px",
|
|
1059
|
-
paddingY: "10px",
|
|
1060
|
-
borderColor: void 0,
|
|
1061
|
-
useIcon: true,
|
|
1062
|
-
iconText: "\u2191",
|
|
1063
|
-
size: "40px",
|
|
1064
|
-
showTooltip: true,
|
|
1065
|
-
tooltipText: "Send message",
|
|
1066
|
-
iconName: "send"
|
|
1067
|
-
},
|
|
1068
|
-
statusIndicator: {
|
|
1069
|
-
visible: true,
|
|
1070
|
-
idleText: "Online",
|
|
1071
|
-
connectingText: "Connecting\u2026",
|
|
1072
|
-
connectedText: "Streaming\u2026",
|
|
1073
|
-
errorText: "Offline"
|
|
1074
|
-
},
|
|
1075
|
-
voiceRecognition: {
|
|
1076
|
-
enabled: true,
|
|
1077
|
-
pauseDuration: 2e3,
|
|
1078
|
-
iconName: "mic",
|
|
1079
|
-
iconSize: "39px",
|
|
1080
|
-
borderWidth: "0px",
|
|
1081
|
-
paddingX: "9px",
|
|
1082
|
-
paddingY: "14px",
|
|
1083
|
-
iconColor: void 0,
|
|
1084
|
-
backgroundColor: "transparent",
|
|
1085
|
-
borderColor: "transparent",
|
|
1086
|
-
recordingIconColor: void 0,
|
|
1087
|
-
recordingBackgroundColor: void 0,
|
|
1088
|
-
recordingBorderColor: "transparent",
|
|
1089
|
-
showTooltip: true,
|
|
1090
|
-
tooltipText: "Start voice recognition"
|
|
1091
|
-
},
|
|
1092
|
-
features: {
|
|
1093
|
-
showReasoning: true,
|
|
1094
|
-
showToolCalls: true,
|
|
1095
|
-
scrollToBottom: {
|
|
1096
|
-
enabled: true,
|
|
1097
|
-
iconName: "arrow-down",
|
|
1098
|
-
label: ""
|
|
1052
|
+
if (artifact == null ? void 0 : artifact.tab) {
|
|
1053
|
+
const t = artifact.tab;
|
|
1054
|
+
if (t.background) cssVars["--persona-artifact-tab-bg"] = t.background;
|
|
1055
|
+
if (t.activeBackground) cssVars["--persona-artifact-tab-active-bg"] = t.activeBackground;
|
|
1056
|
+
if (t.activeBorder) cssVars["--persona-artifact-tab-active-border"] = t.activeBorder;
|
|
1057
|
+
if (t.borderRadius) cssVars["--persona-artifact-tab-radius"] = t.borderRadius;
|
|
1058
|
+
if (t.textColor) cssVars["--persona-artifact-tab-color"] = t.textColor;
|
|
1059
|
+
if (t.hoverBackground) cssVars["--persona-artifact-tab-hover-bg"] = t.hoverBackground;
|
|
1060
|
+
if (t.listBackground) cssVars["--persona-artifact-tab-list-bg"] = t.listBackground;
|
|
1061
|
+
if (t.listBorderColor) cssVars["--persona-artifact-tab-list-border-color"] = t.listBorderColor;
|
|
1062
|
+
if (t.listPadding) cssVars["--persona-artifact-tab-list-padding"] = t.listPadding;
|
|
1063
|
+
}
|
|
1064
|
+
if (artifact == null ? void 0 : artifact.pane) {
|
|
1065
|
+
const t = artifact.pane;
|
|
1066
|
+
if (t.toolbarBackground) {
|
|
1067
|
+
const toolbarBg = (_bb = resolveTokenValue(theme, t.toolbarBackground)) != null ? _bb : t.toolbarBackground;
|
|
1068
|
+
cssVars["--persona-artifact-toolbar-bg"] = toolbarBg;
|
|
1099
1069
|
}
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
"What can you help me with?",
|
|
1103
|
-
"Tell me about your features",
|
|
1104
|
-
"How does this work?"
|
|
1105
|
-
],
|
|
1106
|
-
suggestionChipsConfig: {
|
|
1107
|
-
fontFamily: "sans-serif",
|
|
1108
|
-
fontWeight: "500",
|
|
1109
|
-
paddingX: "12px",
|
|
1110
|
-
paddingY: "6px"
|
|
1111
|
-
},
|
|
1112
|
-
layout: {
|
|
1113
|
-
header: {
|
|
1114
|
-
layout: "default",
|
|
1115
|
-
showIcon: true,
|
|
1116
|
-
showTitle: true,
|
|
1117
|
-
showSubtitle: true,
|
|
1118
|
-
showCloseButton: true,
|
|
1119
|
-
showClearChat: true
|
|
1120
|
-
},
|
|
1121
|
-
messages: {
|
|
1122
|
-
layout: "bubble",
|
|
1123
|
-
avatar: {
|
|
1124
|
-
show: false,
|
|
1125
|
-
position: "left"
|
|
1126
|
-
},
|
|
1127
|
-
timestamp: {
|
|
1128
|
-
show: false,
|
|
1129
|
-
position: "below"
|
|
1130
|
-
},
|
|
1131
|
-
groupConsecutive: false
|
|
1132
|
-
},
|
|
1133
|
-
slots: {}
|
|
1134
|
-
},
|
|
1135
|
-
markdown: {
|
|
1136
|
-
options: {
|
|
1137
|
-
gfm: true,
|
|
1138
|
-
breaks: true
|
|
1139
|
-
},
|
|
1140
|
-
disableDefaultStyles: false
|
|
1141
|
-
},
|
|
1142
|
-
messageActions: {
|
|
1143
|
-
enabled: true,
|
|
1144
|
-
showCopy: true,
|
|
1145
|
-
showUpvote: false,
|
|
1146
|
-
// Requires backend - disabled by default
|
|
1147
|
-
showDownvote: false,
|
|
1148
|
-
// Requires backend - disabled by default
|
|
1149
|
-
visibility: "hover",
|
|
1150
|
-
align: "right",
|
|
1151
|
-
layout: "pill-inside"
|
|
1152
|
-
},
|
|
1153
|
-
debug: false
|
|
1154
|
-
};
|
|
1155
|
-
function mergeThemePartials(base, override) {
|
|
1156
|
-
if (!base && !override) return void 0;
|
|
1157
|
-
if (!base) return override;
|
|
1158
|
-
if (!override) return base;
|
|
1159
|
-
return deepMerge(
|
|
1160
|
-
base,
|
|
1161
|
-
override
|
|
1162
|
-
);
|
|
1070
|
+
}
|
|
1071
|
+
return cssVars;
|
|
1163
1072
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
...(_c = DEFAULT_WIDGET_CONFIG.launcher) == null ? void 0 : _c.clearChat,
|
|
1181
|
-
...(_d = config.launcher) == null ? void 0 : _d.clearChat
|
|
1182
|
-
}
|
|
1073
|
+
|
|
1074
|
+
// src/utils/theme.ts
|
|
1075
|
+
var DARK_PALETTE = {
|
|
1076
|
+
colors: {
|
|
1077
|
+
primary: {
|
|
1078
|
+
50: "#ffffff",
|
|
1079
|
+
100: "#f5f5f5",
|
|
1080
|
+
200: "#d4d4d4",
|
|
1081
|
+
300: "#a3a3a3",
|
|
1082
|
+
400: "#737373",
|
|
1083
|
+
500: "#171717",
|
|
1084
|
+
600: "#0f0f0f",
|
|
1085
|
+
700: "#0a0a0a",
|
|
1086
|
+
800: "#050505",
|
|
1087
|
+
900: "#030303",
|
|
1088
|
+
950: "#000000"
|
|
1183
1089
|
},
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1090
|
+
secondary: {
|
|
1091
|
+
50: "#f5f3ff",
|
|
1092
|
+
100: "#ede9fe",
|
|
1093
|
+
200: "#ddd6fe",
|
|
1094
|
+
300: "#c4b5fd",
|
|
1095
|
+
400: "#a78bfa",
|
|
1096
|
+
500: "#8b5cf6",
|
|
1097
|
+
600: "#7c3aed",
|
|
1098
|
+
700: "#6d28d9",
|
|
1099
|
+
800: "#5b21b6",
|
|
1100
|
+
900: "#4c1d95",
|
|
1101
|
+
950: "#2e1065"
|
|
1187
1102
|
},
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1103
|
+
accent: {
|
|
1104
|
+
50: "#ecfeff",
|
|
1105
|
+
100: "#cffafe",
|
|
1106
|
+
200: "#a5f3fc",
|
|
1107
|
+
300: "#67e8f9",
|
|
1108
|
+
400: "#22d3ee",
|
|
1109
|
+
500: "#06b6d4",
|
|
1110
|
+
600: "#0891b2",
|
|
1111
|
+
700: "#0e7490",
|
|
1112
|
+
800: "#155e75",
|
|
1113
|
+
900: "#164e63",
|
|
1114
|
+
950: "#083344"
|
|
1191
1115
|
},
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1116
|
+
gray: {
|
|
1117
|
+
50: "#f9fafb",
|
|
1118
|
+
100: "#f3f4f6",
|
|
1119
|
+
200: "#e5e7eb",
|
|
1120
|
+
300: "#d1d5db",
|
|
1121
|
+
400: "#9ca3af",
|
|
1122
|
+
500: "#6b7280",
|
|
1123
|
+
600: "#4b5563",
|
|
1124
|
+
700: "#374151",
|
|
1125
|
+
800: "#1f2937",
|
|
1126
|
+
900: "#111827",
|
|
1127
|
+
950: "#030712"
|
|
1195
1128
|
},
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1129
|
+
success: {
|
|
1130
|
+
50: "#f0fdf4",
|
|
1131
|
+
100: "#dcfce7",
|
|
1132
|
+
200: "#bbf7d0",
|
|
1133
|
+
300: "#86efac",
|
|
1134
|
+
400: "#4ade80",
|
|
1135
|
+
500: "#22c55e",
|
|
1136
|
+
600: "#16a34a",
|
|
1137
|
+
700: "#15803d",
|
|
1138
|
+
800: "#166534",
|
|
1139
|
+
900: "#14532d"
|
|
1199
1140
|
},
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
...ca == null ? void 0 : ca.layout
|
|
1212
|
-
}
|
|
1213
|
-
};
|
|
1214
|
-
const mergedScrollToBottom = dsb === void 0 && csb === void 0 ? void 0 : {
|
|
1215
|
-
...dsb,
|
|
1216
|
-
...csb
|
|
1217
|
-
};
|
|
1218
|
-
return {
|
|
1219
|
-
...DEFAULT_WIDGET_CONFIG.features,
|
|
1220
|
-
...config.features,
|
|
1221
|
-
...mergedScrollToBottom !== void 0 ? { scrollToBottom: mergedScrollToBottom } : {},
|
|
1222
|
-
...mergedArtifacts !== void 0 ? { artifacts: mergedArtifacts } : {}
|
|
1223
|
-
};
|
|
1224
|
-
})(),
|
|
1225
|
-
suggestionChips: (_e = config.suggestionChips) != null ? _e : DEFAULT_WIDGET_CONFIG.suggestionChips,
|
|
1226
|
-
suggestionChipsConfig: {
|
|
1227
|
-
...DEFAULT_WIDGET_CONFIG.suggestionChipsConfig,
|
|
1228
|
-
...config.suggestionChipsConfig
|
|
1141
|
+
warning: {
|
|
1142
|
+
50: "#fefce8",
|
|
1143
|
+
100: "#fef9c3",
|
|
1144
|
+
200: "#fef08a",
|
|
1145
|
+
300: "#fde047",
|
|
1146
|
+
400: "#facc15",
|
|
1147
|
+
500: "#eab308",
|
|
1148
|
+
600: "#ca8a04",
|
|
1149
|
+
700: "#a16207",
|
|
1150
|
+
800: "#854d0e",
|
|
1151
|
+
900: "#713f12"
|
|
1229
1152
|
},
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1153
|
+
error: {
|
|
1154
|
+
50: "#fef2f2",
|
|
1155
|
+
100: "#fee2e2",
|
|
1156
|
+
200: "#fecaca",
|
|
1157
|
+
300: "#fca5a5",
|
|
1158
|
+
400: "#f87171",
|
|
1159
|
+
500: "#ef4444",
|
|
1160
|
+
600: "#dc2626",
|
|
1161
|
+
700: "#b91c1c",
|
|
1162
|
+
800: "#991b1b",
|
|
1163
|
+
900: "#7f1d1d"
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
var normalizeThemeConfig = (theme) => {
|
|
1168
|
+
if (!theme || typeof theme !== "object" || Array.isArray(theme)) return void 0;
|
|
1169
|
+
return theme;
|
|
1170
|
+
};
|
|
1171
|
+
var detectColorScheme = () => {
|
|
1172
|
+
var _a;
|
|
1173
|
+
if (typeof document !== "undefined" && document.documentElement.classList.contains("dark")) {
|
|
1174
|
+
return "dark";
|
|
1175
|
+
}
|
|
1176
|
+
if (typeof window !== "undefined" && ((_a = window.matchMedia) == null ? void 0 : _a.call(window, "(prefers-color-scheme: dark)").matches)) {
|
|
1177
|
+
return "dark";
|
|
1178
|
+
}
|
|
1179
|
+
return "light";
|
|
1180
|
+
};
|
|
1181
|
+
var getColorSchemeFromConfig = (config) => {
|
|
1182
|
+
var _a;
|
|
1183
|
+
const colorScheme = (_a = config == null ? void 0 : config.colorScheme) != null ? _a : "light";
|
|
1184
|
+
if (colorScheme === "light") return "light";
|
|
1185
|
+
if (colorScheme === "dark") return "dark";
|
|
1186
|
+
return detectColorScheme();
|
|
1187
|
+
};
|
|
1188
|
+
var getColorScheme = (config) => {
|
|
1189
|
+
return getColorSchemeFromConfig(config);
|
|
1190
|
+
};
|
|
1191
|
+
var createLightTheme = (userConfig) => {
|
|
1192
|
+
return createTheme(userConfig);
|
|
1193
|
+
};
|
|
1194
|
+
var createDarkTheme = (userConfig) => {
|
|
1195
|
+
var _a;
|
|
1196
|
+
const baseTheme = createTheme(void 0, { validate: false });
|
|
1197
|
+
return createTheme(
|
|
1198
|
+
{
|
|
1199
|
+
...userConfig,
|
|
1200
|
+
palette: {
|
|
1201
|
+
...baseTheme.palette,
|
|
1202
|
+
colors: {
|
|
1203
|
+
...DARK_PALETTE.colors,
|
|
1204
|
+
...(_a = userConfig == null ? void 0 : userConfig.palette) == null ? void 0 : _a.colors
|
|
1247
1205
|
}
|
|
1248
|
-
},
|
|
1249
|
-
slots: {
|
|
1250
|
-
...(_r = DEFAULT_WIDGET_CONFIG.layout) == null ? void 0 : _r.slots,
|
|
1251
|
-
...(_s = config.layout) == null ? void 0 : _s.slots
|
|
1252
|
-
}
|
|
1253
|
-
},
|
|
1254
|
-
markdown: {
|
|
1255
|
-
...DEFAULT_WIDGET_CONFIG.markdown,
|
|
1256
|
-
...config.markdown,
|
|
1257
|
-
options: {
|
|
1258
|
-
...(_t = DEFAULT_WIDGET_CONFIG.markdown) == null ? void 0 : _t.options,
|
|
1259
|
-
...(_u = config.markdown) == null ? void 0 : _u.options
|
|
1260
1206
|
}
|
|
1261
1207
|
},
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1208
|
+
{ validate: false }
|
|
1209
|
+
);
|
|
1210
|
+
};
|
|
1211
|
+
var getActiveTheme = (config) => {
|
|
1212
|
+
const scheme = getColorScheme(config);
|
|
1213
|
+
const lightThemeConfig = normalizeThemeConfig(config == null ? void 0 : config.theme);
|
|
1214
|
+
const darkThemeConfig = normalizeThemeConfig(config == null ? void 0 : config.darkTheme);
|
|
1215
|
+
if (scheme === "dark") {
|
|
1216
|
+
return createDarkTheme(
|
|
1217
|
+
deepMerge(
|
|
1218
|
+
lightThemeConfig != null ? lightThemeConfig : {},
|
|
1219
|
+
darkThemeConfig != null ? darkThemeConfig : {}
|
|
1220
|
+
)
|
|
1221
|
+
);
|
|
1222
|
+
}
|
|
1223
|
+
return createLightTheme(lightThemeConfig);
|
|
1224
|
+
};
|
|
1225
|
+
var getCssVariables = (theme) => {
|
|
1226
|
+
return themeToCssVariables(theme);
|
|
1227
|
+
};
|
|
1228
|
+
var applyThemeVariables = (element, config) => {
|
|
1229
|
+
var _a;
|
|
1230
|
+
const theme = getActiveTheme(config);
|
|
1231
|
+
const cssVars = getCssVariables(theme);
|
|
1232
|
+
for (const [name, value] of Object.entries(cssVars)) {
|
|
1233
|
+
element.style.setProperty(name, value);
|
|
1234
|
+
}
|
|
1235
|
+
const toolCallShadow = (_a = config == null ? void 0 : config.toolCall) == null ? void 0 : _a.shadow;
|
|
1236
|
+
if (toolCallShadow !== void 0) {
|
|
1237
|
+
element.style.setProperty(
|
|
1238
|
+
"--persona-tool-bubble-shadow",
|
|
1239
|
+
toolCallShadow.trim() === "" ? "none" : toolCallShadow
|
|
1240
|
+
);
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1243
|
+
var createThemeObserver = (callback) => {
|
|
1244
|
+
const cleanupFns = [];
|
|
1245
|
+
if (typeof document !== "undefined" && typeof MutationObserver !== "undefined") {
|
|
1246
|
+
const observer = new MutationObserver(() => {
|
|
1247
|
+
callback(detectColorScheme());
|
|
1248
|
+
});
|
|
1249
|
+
observer.observe(document.documentElement, {
|
|
1250
|
+
attributes: true,
|
|
1251
|
+
attributeFilter: ["class"]
|
|
1252
|
+
});
|
|
1253
|
+
cleanupFns.push(() => observer.disconnect());
|
|
1254
|
+
}
|
|
1255
|
+
if (typeof window !== "undefined" && window.matchMedia) {
|
|
1256
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1257
|
+
const handleChange = () => callback(detectColorScheme());
|
|
1258
|
+
if (mediaQuery.addEventListener) {
|
|
1259
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
1260
|
+
cleanupFns.push(() => mediaQuery.removeEventListener("change", handleChange));
|
|
1261
|
+
} else if (mediaQuery.addListener) {
|
|
1262
|
+
mediaQuery.addListener(handleChange);
|
|
1263
|
+
cleanupFns.push(() => mediaQuery.removeListener(handleChange));
|
|
1265
1264
|
}
|
|
1265
|
+
}
|
|
1266
|
+
return () => {
|
|
1267
|
+
cleanupFns.forEach((fn) => fn());
|
|
1266
1268
|
};
|
|
1267
|
-
}
|
|
1269
|
+
};
|
|
1268
1270
|
|
|
1269
1271
|
// src/theme-editor/state.ts
|
|
1270
1272
|
function getByPath(obj, path) {
|
|
@@ -2129,8 +2131,8 @@ var panelLayoutSectionDef = {
|
|
|
2129
2131
|
title: "Panel",
|
|
2130
2132
|
collapsed: false,
|
|
2131
2133
|
fields: [
|
|
2132
|
-
{ id: "panel-width", label: "Width", type: "text", path: "theme.components.panel.width", defaultValue:
|
|
2133
|
-
{ id: "panel-max-width", label: "Max Width", type: "text", path: "theme.components.panel.maxWidth", defaultValue:
|
|
2134
|
+
{ id: "panel-width", label: "Width", type: "text", path: "theme.components.panel.width", defaultValue: DEFAULT_FLOATING_LAUNCHER_WIDTH },
|
|
2135
|
+
{ id: "panel-max-width", label: "Max Width", type: "text", path: "theme.components.panel.maxWidth", defaultValue: DEFAULT_FLOATING_LAUNCHER_MAX_WIDTH },
|
|
2134
2136
|
{ id: "panel-height", label: "Height", type: "text", path: "theme.components.panel.height", defaultValue: "600px" },
|
|
2135
2137
|
{ id: "panel-max-height", label: "Max Height", type: "text", path: "theme.components.panel.maxHeight", defaultValue: "calc(100vh - 80px)" },
|
|
2136
2138
|
{ id: "panel-border-radius", label: "Border Radius", type: "select", path: "theme.components.panel.borderRadius", defaultValue: "palette.radius.xl", options: [
|
|
@@ -2434,7 +2436,7 @@ var launcherBasicsSectionDef = {
|
|
|
2434
2436
|
{ id: "launch-enabled", label: "Enabled", type: "toggle", path: "launcher.enabled", defaultValue: true },
|
|
2435
2437
|
{ id: "launch-mount-mode", label: "Mount Mode", type: "select", path: "launcher.mountMode", defaultValue: "floating", options: [{ value: "floating", label: "Floating" }, { value: "docked", label: "Docked" }] },
|
|
2436
2438
|
{ id: "launch-position", label: "Position", type: "select", path: "launcher.position", defaultValue: "bottom-right", options: [{ value: "bottom-right", label: "Bottom Right" }, { value: "bottom-left", label: "Bottom Left" }, { value: "top-right", label: "Top Right" }, { value: "top-left", label: "Top Left" }] },
|
|
2437
|
-
{ id: "launch-width", label: "Width", type: "text", path: "launcher.width", defaultValue:
|
|
2439
|
+
{ id: "launch-width", label: "Width", type: "text", path: "launcher.width", defaultValue: DEFAULT_FLOATING_LAUNCHER_WIDTH },
|
|
2438
2440
|
{ id: "launch-auto-expand", label: "Auto Expand", type: "toggle", path: "launcher.autoExpand", defaultValue: false },
|
|
2439
2441
|
{ id: "launch-title", label: "Title", type: "text", path: "launcher.title", defaultValue: "Chat Assistant" },
|
|
2440
2442
|
{ id: "launch-subtitle", label: "Subtitle", type: "text", path: "launcher.subtitle", defaultValue: "Here to help you get answers fast" }
|
|
@@ -4148,6 +4150,7 @@ var AgentWidgetClient = class {
|
|
|
4148
4150
|
let assistantMessage = null;
|
|
4149
4151
|
const assistantMessageRef = { current: null };
|
|
4150
4152
|
const partIdState = { current: null };
|
|
4153
|
+
let didSplitByPartId = false;
|
|
4151
4154
|
const reasoningMessages = /* @__PURE__ */ new Map();
|
|
4152
4155
|
const toolMessages = /* @__PURE__ */ new Map();
|
|
4153
4156
|
const reasoningContext = {
|
|
@@ -4178,11 +4181,21 @@ var AgentWidgetClient = class {
|
|
|
4178
4181
|
(_g2 = (_f2 = (_e2 = (_d2 = (_c2 = (_b2 = (_a2 = payload.callId) != null ? _a2 : payload.call_id) != null ? _b2 : payload.requestId) != null ? _c2 : payload.request_id) != null ? _d2 : payload.toolCallId) != null ? _e2 : payload.tool_call_id) != null ? _f2 : payload.stepId) != null ? _g2 : payload.step_id
|
|
4179
4182
|
);
|
|
4180
4183
|
};
|
|
4184
|
+
const baseAssistantId = assistantMessageId;
|
|
4185
|
+
let assistantIdConsumed = false;
|
|
4181
4186
|
const ensureAssistantMessage = () => {
|
|
4182
4187
|
if (assistantMessage) return assistantMessage;
|
|
4188
|
+
let id;
|
|
4189
|
+
if (!assistantIdConsumed && baseAssistantId) {
|
|
4190
|
+
id = baseAssistantId;
|
|
4191
|
+
assistantIdConsumed = true;
|
|
4192
|
+
} else if (baseAssistantId && partIdState.current) {
|
|
4193
|
+
id = `${baseAssistantId}_${partIdState.current}`;
|
|
4194
|
+
} else {
|
|
4195
|
+
id = `assistant-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
4196
|
+
}
|
|
4183
4197
|
assistantMessage = {
|
|
4184
|
-
|
|
4185
|
-
id: assistantMessageId != null ? assistantMessageId : `assistant-${Date.now()}-${Math.random().toString(16).slice(2)}`,
|
|
4198
|
+
id,
|
|
4186
4199
|
role: "assistant",
|
|
4187
4200
|
content: "",
|
|
4188
4201
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -4551,13 +4564,51 @@ var AgentWidgetClient = class {
|
|
|
4551
4564
|
if (callKey) {
|
|
4552
4565
|
toolContext.byCall.delete(callKey);
|
|
4553
4566
|
}
|
|
4567
|
+
} else if (payloadType === "text_start") {
|
|
4568
|
+
const incomingPartId = payload.partId;
|
|
4569
|
+
if (incomingPartId !== void 0 && partIdState.current !== null && incomingPartId !== partIdState.current) {
|
|
4570
|
+
const prev = assistantMessage;
|
|
4571
|
+
if (prev) {
|
|
4572
|
+
prev.streaming = false;
|
|
4573
|
+
emitMessage(prev);
|
|
4574
|
+
assistantMessage = null;
|
|
4575
|
+
didSplitByPartId = true;
|
|
4576
|
+
}
|
|
4577
|
+
}
|
|
4578
|
+
if (incomingPartId !== void 0) {
|
|
4579
|
+
partIdState.current = incomingPartId;
|
|
4580
|
+
}
|
|
4581
|
+
} else if (payloadType === "text_end") {
|
|
4582
|
+
const prev = assistantMessage;
|
|
4583
|
+
if (prev) {
|
|
4584
|
+
prev.streaming = false;
|
|
4585
|
+
emitMessage(prev);
|
|
4586
|
+
assistantMessage = null;
|
|
4587
|
+
didSplitByPartId = true;
|
|
4588
|
+
}
|
|
4554
4589
|
} else if (payloadType === "step_chunk" || payloadType === "step_delta") {
|
|
4555
4590
|
const stepType = payload.stepType;
|
|
4556
4591
|
const executionType = payload.executionType;
|
|
4557
4592
|
if (stepType === "tool" || executionType === "context") {
|
|
4558
4593
|
continue;
|
|
4559
4594
|
}
|
|
4595
|
+
const incomingPartId = payload.partId;
|
|
4596
|
+
if (incomingPartId !== void 0 && partIdState.current !== null && incomingPartId !== partIdState.current) {
|
|
4597
|
+
const prev = assistantMessage;
|
|
4598
|
+
if (prev) {
|
|
4599
|
+
prev.streaming = false;
|
|
4600
|
+
emitMessage(prev);
|
|
4601
|
+
assistantMessage = null;
|
|
4602
|
+
didSplitByPartId = true;
|
|
4603
|
+
}
|
|
4604
|
+
}
|
|
4605
|
+
if (incomingPartId !== void 0) {
|
|
4606
|
+
partIdState.current = incomingPartId;
|
|
4607
|
+
}
|
|
4560
4608
|
const assistant = ensureAssistantMessage();
|
|
4609
|
+
if (incomingPartId !== void 0 && !assistant.partId) {
|
|
4610
|
+
assistant.partId = incomingPartId;
|
|
4611
|
+
}
|
|
4561
4612
|
const chunk = (_ca = (_ba = (_aa = (_$ = payload.text) != null ? _$ : payload.delta) != null ? _aa : payload.content) != null ? _ba : payload.chunk) != null ? _ca : "";
|
|
4562
4613
|
if (chunk) {
|
|
4563
4614
|
const rawBuffer = (_da = rawContentBuffers.get(assistant.id)) != null ? _da : "";
|
|
@@ -4686,6 +4737,18 @@ var AgentWidgetClient = class {
|
|
|
4686
4737
|
if (stepType === "tool" || executionType === "context") {
|
|
4687
4738
|
continue;
|
|
4688
4739
|
}
|
|
4740
|
+
if (didSplitByPartId) {
|
|
4741
|
+
if (assistantMessage !== null) {
|
|
4742
|
+
const msg = assistantMessage;
|
|
4743
|
+
streamParsers.delete(msg.id);
|
|
4744
|
+
rawContentBuffers.delete(msg.id);
|
|
4745
|
+
if (msg.streaming !== false) {
|
|
4746
|
+
msg.streaming = false;
|
|
4747
|
+
emitMessage(msg);
|
|
4748
|
+
}
|
|
4749
|
+
}
|
|
4750
|
+
continue;
|
|
4751
|
+
}
|
|
4689
4752
|
const finalContent = (_ja = payload.result) == null ? void 0 : _ja.response;
|
|
4690
4753
|
const assistant = ensureAssistantMessage();
|
|
4691
4754
|
if (finalContent !== void 0 && finalContent !== null) {
|
|
@@ -4781,7 +4844,17 @@ var AgentWidgetClient = class {
|
|
|
4781
4844
|
}
|
|
4782
4845
|
} else if (payloadType === "flow_complete") {
|
|
4783
4846
|
const finalContent = (_ma = payload.result) == null ? void 0 : _ma.response;
|
|
4784
|
-
if (
|
|
4847
|
+
if (didSplitByPartId) {
|
|
4848
|
+
if (assistantMessage !== null) {
|
|
4849
|
+
const msg = assistantMessage;
|
|
4850
|
+
streamParsers.delete(msg.id);
|
|
4851
|
+
rawContentBuffers.delete(msg.id);
|
|
4852
|
+
if (msg.streaming !== false) {
|
|
4853
|
+
msg.streaming = false;
|
|
4854
|
+
emitMessage(msg);
|
|
4855
|
+
}
|
|
4856
|
+
}
|
|
4857
|
+
} else if (finalContent !== void 0 && finalContent !== null) {
|
|
4785
4858
|
const assistant = ensureAssistantMessage();
|
|
4786
4859
|
const rawBuffer = rawContentBuffers.get(assistant.id);
|
|
4787
4860
|
const stringContent = rawBuffer != null ? rawBuffer : ensureStringContent(finalContent);
|
|
@@ -9201,7 +9274,7 @@ var createWrapper = (config) => {
|
|
|
9201
9274
|
"persona-widget-panel persona-relative persona-min-h-[320px]"
|
|
9202
9275
|
);
|
|
9203
9276
|
const launcherWidth = (_i = (_h = config == null ? void 0 : config.launcher) == null ? void 0 : _h.width) != null ? _i : config == null ? void 0 : config.launcherWidth;
|
|
9204
|
-
const width = launcherWidth != null ? launcherWidth :
|
|
9277
|
+
const width = launcherWidth != null ? launcherWidth : DEFAULT_FLOATING_LAUNCHER_WIDTH;
|
|
9205
9278
|
panel.style.width = width;
|
|
9206
9279
|
panel.style.maxWidth = width;
|
|
9207
9280
|
wrapper.appendChild(panel);
|
|
@@ -13909,7 +13982,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
13909
13982
|
const mobileBreakpoint = (_g2 = (_f2 = config.launcher) == null ? void 0 : _f2.mobileBreakpoint) != null ? _g2 : 640;
|
|
13910
13983
|
if (mobileFullscreen && ownerWindow2.innerWidth <= mobileBreakpoint) return;
|
|
13911
13984
|
if (!shouldExpandLauncherForArtifacts(config, launcherEnabled)) return;
|
|
13912
|
-
const base = (_j2 = (_i2 = (_h2 = config.launcher) == null ? void 0 : _h2.width) != null ? _i2 : config.launcherWidth) != null ? _j2 :
|
|
13985
|
+
const base = (_j2 = (_i2 = (_h2 = config.launcher) == null ? void 0 : _h2.width) != null ? _i2 : config.launcherWidth) != null ? _j2 : DEFAULT_FLOATING_LAUNCHER_WIDTH;
|
|
13913
13986
|
const expanded = (_n2 = (_m2 = (_l2 = (_k2 = config.features) == null ? void 0 : _k2.artifacts) == null ? void 0 : _l2.layout) == null ? void 0 : _m2.expandedPanelWidth) != null ? _n2 : "min(720px, calc(100vw - 24px))";
|
|
13914
13987
|
const hasVisible = lastArtifactsState.artifacts.length > 0 && !artifactsPaneUserHidden;
|
|
13915
13988
|
if (hasVisible) {
|
|
@@ -14025,7 +14098,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14025
14098
|
return;
|
|
14026
14099
|
}
|
|
14027
14100
|
const launcherWidth = (_r2 = (_q2 = config == null ? void 0 : config.launcher) == null ? void 0 : _q2.width) != null ? _r2 : config == null ? void 0 : config.launcherWidth;
|
|
14028
|
-
const width = launcherWidth != null ? launcherWidth :
|
|
14101
|
+
const width = launcherWidth != null ? launcherWidth : DEFAULT_FLOATING_LAUNCHER_WIDTH;
|
|
14029
14102
|
if (!sidebarMode && !dockedMode) {
|
|
14030
14103
|
if (isInlineEmbed && fullHeight) {
|
|
14031
14104
|
panel.style.width = "100%";
|
|
@@ -15545,7 +15618,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15545
15618
|
}
|
|
15546
15619
|
if (!sidebarMode && !dockedMode) {
|
|
15547
15620
|
const launcherWidth = (_k2 = (_j2 = config == null ? void 0 : config.launcher) == null ? void 0 : _j2.width) != null ? _k2 : config == null ? void 0 : config.launcherWidth;
|
|
15548
|
-
const width = launcherWidth != null ? launcherWidth :
|
|
15621
|
+
const width = launcherWidth != null ? launcherWidth : DEFAULT_FLOATING_LAUNCHER_WIDTH;
|
|
15549
15622
|
panel.style.width = width;
|
|
15550
15623
|
panel.style.maxWidth = width;
|
|
15551
15624
|
}
|