@sampleapp.ai/sdk 1.0.26 → 1.0.27
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/components/chat-bar.js +19 -14
- package/dist/index.d.ts +4 -4
- package/dist/index.es.js +184 -182
- package/dist/index.standalone.js +1 -3
- package/dist/index.standalone.umd.js +14 -14
- package/dist/index.umd.js +29 -29
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -3,11 +3,11 @@ import { useState as f, useEffect as M, forwardRef as oe, useRef as U, useMemo a
|
|
|
3
3
|
import * as ee from "react-dom/client";
|
|
4
4
|
import { jsxs as c, jsx as e, Fragment as z } from "react/jsx-runtime";
|
|
5
5
|
const ie = ({ settings: t, onClick: i }) => {
|
|
6
|
-
const [r,
|
|
7
|
-
const
|
|
6
|
+
const [r, l] = f(!1), s = () => {
|
|
7
|
+
const d = new CustomEvent("chatButtonClick", {
|
|
8
8
|
detail: { settings: t }
|
|
9
9
|
});
|
|
10
|
-
document.dispatchEvent(
|
|
10
|
+
document.dispatchEvent(d), i?.();
|
|
11
11
|
};
|
|
12
12
|
return /* @__PURE__ */ c(
|
|
13
13
|
"button",
|
|
@@ -44,11 +44,11 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
44
44
|
outline: "none",
|
|
45
45
|
userSelect: "none"
|
|
46
46
|
},
|
|
47
|
-
onMouseEnter: () =>
|
|
48
|
-
onMouseLeave: () =>
|
|
47
|
+
onMouseEnter: () => l(!0),
|
|
48
|
+
onMouseLeave: () => l(!1),
|
|
49
49
|
onClick: s,
|
|
50
|
-
onFocus: () =>
|
|
51
|
-
onBlur: () =>
|
|
50
|
+
onFocus: () => l(!0),
|
|
51
|
+
onBlur: () => l(!1),
|
|
52
52
|
children: [
|
|
53
53
|
t.aiChatSettings?.aiAssistantAvatar && /* @__PURE__ */ e(
|
|
54
54
|
"img",
|
|
@@ -62,8 +62,8 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
62
62
|
objectFit: "cover",
|
|
63
63
|
flexShrink: 0
|
|
64
64
|
},
|
|
65
|
-
onError: (
|
|
66
|
-
|
|
65
|
+
onError: (d) => {
|
|
66
|
+
d.currentTarget.style.display = "none";
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
),
|
|
@@ -75,17 +75,17 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
75
75
|
settings: t,
|
|
76
76
|
onClose: i
|
|
77
77
|
}) => {
|
|
78
|
-
const [r,
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
|
|
78
|
+
const [r, l] = f(!0), [s, d] = f(""), g = () => {
|
|
79
|
+
l(!1), i?.();
|
|
80
|
+
}, T = (o) => {
|
|
81
|
+
d(o);
|
|
82
82
|
};
|
|
83
83
|
return M(() => {
|
|
84
|
-
const
|
|
85
|
-
b.key === "Escape" &&
|
|
84
|
+
const o = (b) => {
|
|
85
|
+
b.key === "Escape" && g();
|
|
86
86
|
};
|
|
87
87
|
if (r)
|
|
88
|
-
return document.addEventListener("keydown",
|
|
88
|
+
return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
|
|
89
89
|
}, [r]), M(() => {
|
|
90
90
|
if (r)
|
|
91
91
|
return document.body.style.overflow = "hidden", () => {
|
|
@@ -106,7 +106,7 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
106
106
|
zIndex: 999,
|
|
107
107
|
animation: "fadeIn 0.2s ease-out"
|
|
108
108
|
},
|
|
109
|
-
onClick:
|
|
109
|
+
onClick: g
|
|
110
110
|
}
|
|
111
111
|
),
|
|
112
112
|
/* @__PURE__ */ c(
|
|
@@ -128,7 +128,7 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
128
128
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
129
129
|
animation: "slideIn 0.3s ease-out"
|
|
130
130
|
},
|
|
131
|
-
onClick: (
|
|
131
|
+
onClick: (o) => o.stopPropagation(),
|
|
132
132
|
children: [
|
|
133
133
|
/* @__PURE__ */ c(
|
|
134
134
|
"div",
|
|
@@ -154,8 +154,8 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
154
154
|
borderRadius: "50%",
|
|
155
155
|
objectFit: "cover"
|
|
156
156
|
},
|
|
157
|
-
onError: (
|
|
158
|
-
|
|
157
|
+
onError: (o) => {
|
|
158
|
+
o.currentTarget.style.display = "none";
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
),
|
|
@@ -176,7 +176,7 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
176
176
|
/* @__PURE__ */ e(
|
|
177
177
|
"button",
|
|
178
178
|
{
|
|
179
|
-
onClick:
|
|
179
|
+
onClick: g,
|
|
180
180
|
style: {
|
|
181
181
|
background: "none",
|
|
182
182
|
border: "none",
|
|
@@ -190,11 +190,11 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
190
190
|
justifyContent: "center",
|
|
191
191
|
transition: "all 0.15s ease"
|
|
192
192
|
},
|
|
193
|
-
onMouseEnter: (
|
|
194
|
-
|
|
193
|
+
onMouseEnter: (o) => {
|
|
194
|
+
o.currentTarget.style.backgroundColor = "#f1f5f9", o.currentTarget.style.color = "#334155";
|
|
195
195
|
},
|
|
196
|
-
onMouseLeave: (
|
|
197
|
-
|
|
196
|
+
onMouseLeave: (o) => {
|
|
197
|
+
o.currentTarget.style.backgroundColor = "transparent", o.currentTarget.style.color = "#64748b";
|
|
198
198
|
},
|
|
199
199
|
children: "×"
|
|
200
200
|
}
|
|
@@ -218,7 +218,7 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
218
218
|
type: "text",
|
|
219
219
|
placeholder: "Ask a question...",
|
|
220
220
|
value: s,
|
|
221
|
-
onChange: (
|
|
221
|
+
onChange: (o) => d(o.target.value),
|
|
222
222
|
style: {
|
|
223
223
|
width: "100%",
|
|
224
224
|
padding: "14px 16px",
|
|
@@ -231,11 +231,11 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
231
231
|
transition: "border-color 0.15s ease",
|
|
232
232
|
backgroundColor: "#fafafa"
|
|
233
233
|
},
|
|
234
|
-
onFocus: (
|
|
235
|
-
|
|
234
|
+
onFocus: (o) => {
|
|
235
|
+
o.currentTarget.style.borderColor = t.baseSettings.primaryBrandColor, o.currentTarget.style.backgroundColor = "white";
|
|
236
236
|
},
|
|
237
|
-
onBlur: (
|
|
238
|
-
|
|
237
|
+
onBlur: (o) => {
|
|
238
|
+
o.currentTarget.style.borderColor = "#e2e8f0", o.currentTarget.style.backgroundColor = "#fafafa";
|
|
239
239
|
},
|
|
240
240
|
autoFocus: !0
|
|
241
241
|
}
|
|
@@ -258,11 +258,11 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
258
258
|
fontWeight: "500",
|
|
259
259
|
transition: "opacity 0.15s ease"
|
|
260
260
|
},
|
|
261
|
-
onMouseEnter: (
|
|
262
|
-
|
|
261
|
+
onMouseEnter: (o) => {
|
|
262
|
+
o.currentTarget.style.opacity = "0.9";
|
|
263
263
|
},
|
|
264
|
-
onMouseLeave: (
|
|
265
|
-
|
|
264
|
+
onMouseLeave: (o) => {
|
|
265
|
+
o.currentTarget.style.opacity = "1";
|
|
266
266
|
},
|
|
267
267
|
onClick: () => {
|
|
268
268
|
console.log("Search for:", s);
|
|
@@ -290,10 +290,10 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
290
290
|
{
|
|
291
291
|
style: { display: "flex", flexDirection: "column", gap: "8px" },
|
|
292
292
|
children: t.aiChatSettings.exampleQuestions.map(
|
|
293
|
-
(
|
|
293
|
+
(o, b) => /* @__PURE__ */ e(
|
|
294
294
|
"button",
|
|
295
295
|
{
|
|
296
|
-
onClick: () =>
|
|
296
|
+
onClick: () => T(o),
|
|
297
297
|
style: {
|
|
298
298
|
display: "block",
|
|
299
299
|
width: "100%",
|
|
@@ -309,13 +309,13 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
309
309
|
transition: "all 0.15s ease",
|
|
310
310
|
lineHeight: "1.4"
|
|
311
311
|
},
|
|
312
|
-
onMouseEnter: (
|
|
313
|
-
|
|
312
|
+
onMouseEnter: (p) => {
|
|
313
|
+
p.currentTarget.style.backgroundColor = "#f8fafc", p.currentTarget.style.borderColor = t.baseSettings.primaryBrandColor, p.currentTarget.style.transform = "translateY(-1px)", p.currentTarget.style.boxShadow = "0 4px 12px rgba(0,0,0,0.1)";
|
|
314
314
|
},
|
|
315
|
-
onMouseLeave: (
|
|
316
|
-
|
|
315
|
+
onMouseLeave: (p) => {
|
|
316
|
+
p.currentTarget.style.backgroundColor = "white", p.currentTarget.style.borderColor = "#e2e8f0", p.currentTarget.style.transform = "translateY(0)", p.currentTarget.style.boxShadow = "none";
|
|
317
317
|
},
|
|
318
|
-
children:
|
|
318
|
+
children: o
|
|
319
319
|
},
|
|
320
320
|
b
|
|
321
321
|
)
|
|
@@ -367,17 +367,17 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
367
367
|
}, le = {
|
|
368
368
|
borderColor: "#0f172a",
|
|
369
369
|
boxShadow: "0 0 0 1px #0f172a"
|
|
370
|
-
}, ce = "#64748b",
|
|
371
|
-
({ style: t, onFocus: i, onBlur: r, ...
|
|
372
|
-
const [
|
|
370
|
+
}, ce = "#64748b", G = L.forwardRef(
|
|
371
|
+
({ style: t, onFocus: i, onBlur: r, ...l }, s) => {
|
|
372
|
+
const [d, g] = L.useState(!1), T = {
|
|
373
373
|
...de,
|
|
374
|
-
...
|
|
374
|
+
...d ? le : {},
|
|
375
375
|
...t,
|
|
376
376
|
// Handle placeholder color via CSS custom property
|
|
377
377
|
// @ts-ignore - CSS custom properties are valid
|
|
378
378
|
"--placeholder-color": ce
|
|
379
379
|
};
|
|
380
|
-
return
|
|
380
|
+
return l.disabled && (T.cursor = "not-allowed", T.opacity = 0.5), /* @__PURE__ */ c(z, { children: [
|
|
381
381
|
/* @__PURE__ */ e("style", { children: `
|
|
382
382
|
.textarea-with-placeholder::placeholder {
|
|
383
383
|
color: var(--placeholder-color);
|
|
@@ -387,21 +387,21 @@ const ie = ({ settings: t, onClick: i }) => {
|
|
|
387
387
|
"textarea",
|
|
388
388
|
{
|
|
389
389
|
className: "textarea-with-placeholder",
|
|
390
|
-
style:
|
|
390
|
+
style: T,
|
|
391
391
|
ref: s,
|
|
392
|
-
onFocus: (
|
|
393
|
-
|
|
392
|
+
onFocus: (p) => {
|
|
393
|
+
g(!0), i?.(p);
|
|
394
394
|
},
|
|
395
|
-
onBlur: (
|
|
396
|
-
|
|
395
|
+
onBlur: (p) => {
|
|
396
|
+
g(!1), r?.(p);
|
|
397
397
|
},
|
|
398
|
-
...
|
|
398
|
+
...l
|
|
399
399
|
}
|
|
400
400
|
)
|
|
401
401
|
] });
|
|
402
402
|
}
|
|
403
403
|
);
|
|
404
|
-
|
|
404
|
+
G.displayName = "Textarea";
|
|
405
405
|
const pe = {
|
|
406
406
|
display: "inline-flex",
|
|
407
407
|
alignItems: "center",
|
|
@@ -528,41 +528,41 @@ const pe = {
|
|
|
528
528
|
default:
|
|
529
529
|
return i;
|
|
530
530
|
}
|
|
531
|
-
},
|
|
531
|
+
}, J = L.forwardRef(
|
|
532
532
|
({
|
|
533
533
|
variant: t = "default",
|
|
534
534
|
size: i = "default",
|
|
535
535
|
asChild: r = !1,
|
|
536
|
-
style:
|
|
536
|
+
style: l,
|
|
537
537
|
onMouseEnter: s,
|
|
538
|
-
onMouseLeave:
|
|
539
|
-
onFocus:
|
|
540
|
-
onBlur:
|
|
541
|
-
onClick:
|
|
538
|
+
onMouseLeave: d,
|
|
539
|
+
onFocus: g,
|
|
540
|
+
onBlur: T,
|
|
541
|
+
onClick: o,
|
|
542
542
|
...b
|
|
543
|
-
},
|
|
543
|
+
}, p) => {
|
|
544
544
|
const [H, A] = L.useState(!1), [y, F] = L.useState(!1), k = {
|
|
545
545
|
...pe,
|
|
546
546
|
...ue[t],
|
|
547
547
|
...fe[i],
|
|
548
548
|
...H ? he(t) : {},
|
|
549
549
|
...y ? ge(t) : {},
|
|
550
|
-
...
|
|
550
|
+
...l
|
|
551
551
|
// Allow style override
|
|
552
552
|
};
|
|
553
553
|
b.disabled && (k.pointerEvents = "none", k.opacity = 0.5, k.cursor = "not-allowed");
|
|
554
|
-
const I = (
|
|
555
|
-
A(!0), s?.(
|
|
556
|
-
}, R = (
|
|
557
|
-
A(!1),
|
|
558
|
-
}, w = (
|
|
559
|
-
F(!0),
|
|
560
|
-
}, D = (
|
|
561
|
-
F(!1),
|
|
562
|
-
}, j = (
|
|
554
|
+
const I = (u) => {
|
|
555
|
+
A(!0), s?.(u);
|
|
556
|
+
}, R = (u) => {
|
|
557
|
+
A(!1), d?.(u);
|
|
558
|
+
}, w = (u) => {
|
|
559
|
+
F(!0), g?.(u);
|
|
560
|
+
}, D = (u) => {
|
|
561
|
+
F(!1), T?.(u);
|
|
562
|
+
}, j = (u) => {
|
|
563
563
|
setTimeout(() => {
|
|
564
|
-
|
|
565
|
-
}, 150),
|
|
564
|
+
u.currentTarget && u.currentTarget.blur();
|
|
565
|
+
}, 150), o?.(u);
|
|
566
566
|
};
|
|
567
567
|
return r && console.warn(
|
|
568
568
|
"asChild prop is not supported in the inline CSS version of Button."
|
|
@@ -570,7 +570,7 @@ const pe = {
|
|
|
570
570
|
"button",
|
|
571
571
|
{
|
|
572
572
|
style: k,
|
|
573
|
-
ref:
|
|
573
|
+
ref: p,
|
|
574
574
|
onMouseEnter: I,
|
|
575
575
|
onMouseLeave: R,
|
|
576
576
|
onFocus: w,
|
|
@@ -581,7 +581,7 @@ const pe = {
|
|
|
581
581
|
);
|
|
582
582
|
}
|
|
583
583
|
);
|
|
584
|
-
|
|
584
|
+
J.displayName = "Button";
|
|
585
585
|
const me = {
|
|
586
586
|
ocean: {
|
|
587
587
|
primary: "#1ca0fb",
|
|
@@ -895,7 +895,7 @@ const me = {
|
|
|
895
895
|
isRecording: t = !1,
|
|
896
896
|
isTranscribing: i = !1,
|
|
897
897
|
size: r = 20,
|
|
898
|
-
style:
|
|
898
|
+
style: l = {}
|
|
899
899
|
}) => {
|
|
900
900
|
const s = {
|
|
901
901
|
position: "relative",
|
|
@@ -904,7 +904,7 @@ const me = {
|
|
|
904
904
|
display: "flex",
|
|
905
905
|
alignItems: "center",
|
|
906
906
|
justifyContent: "center",
|
|
907
|
-
...
|
|
907
|
+
...l
|
|
908
908
|
};
|
|
909
909
|
if (i)
|
|
910
910
|
return /* @__PURE__ */ c(z, { children: [
|
|
@@ -949,7 +949,7 @@ const me = {
|
|
|
949
949
|
}
|
|
950
950
|
) })
|
|
951
951
|
] });
|
|
952
|
-
const
|
|
952
|
+
const d = Math.max(1, Math.floor(r * 0.075)), g = Math.max(1, Math.floor(r * 0.1));
|
|
953
953
|
return /* @__PURE__ */ c(z, { children: [
|
|
954
954
|
/* @__PURE__ */ e("style", { children: `
|
|
955
955
|
@keyframes wave1 {
|
|
@@ -1007,12 +1007,12 @@ const me = {
|
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
1009
1009
|
` }),
|
|
1010
|
-
/* @__PURE__ */ e("div", { style: s, children: /* @__PURE__ */ c("div", { style: { display: "flex", alignItems: "center", gap: `${
|
|
1010
|
+
/* @__PURE__ */ e("div", { style: s, children: /* @__PURE__ */ c("div", { style: { display: "flex", alignItems: "center", gap: `${g}px` }, children: [
|
|
1011
1011
|
/* @__PURE__ */ e(
|
|
1012
1012
|
"div",
|
|
1013
1013
|
{
|
|
1014
1014
|
style: {
|
|
1015
|
-
width: `${
|
|
1015
|
+
width: `${d}px`,
|
|
1016
1016
|
height: `${Math.floor(r * 0.4)}px`,
|
|
1017
1017
|
backgroundColor: "currentColor",
|
|
1018
1018
|
borderRadius: "999px",
|
|
@@ -1024,7 +1024,7 @@ const me = {
|
|
|
1024
1024
|
"div",
|
|
1025
1025
|
{
|
|
1026
1026
|
style: {
|
|
1027
|
-
width: `${
|
|
1027
|
+
width: `${d}px`,
|
|
1028
1028
|
height: `${Math.floor(r * 0.6)}px`,
|
|
1029
1029
|
backgroundColor: "currentColor",
|
|
1030
1030
|
borderRadius: "999px",
|
|
@@ -1036,7 +1036,7 @@ const me = {
|
|
|
1036
1036
|
"div",
|
|
1037
1037
|
{
|
|
1038
1038
|
style: {
|
|
1039
|
-
width: `${
|
|
1039
|
+
width: `${d}px`,
|
|
1040
1040
|
height: `${Math.floor(r * 0.8)}px`,
|
|
1041
1041
|
backgroundColor: "currentColor",
|
|
1042
1042
|
borderRadius: "999px",
|
|
@@ -1048,7 +1048,7 @@ const me = {
|
|
|
1048
1048
|
"div",
|
|
1049
1049
|
{
|
|
1050
1050
|
style: {
|
|
1051
|
-
width: `${
|
|
1051
|
+
width: `${d}px`,
|
|
1052
1052
|
height: `${Math.floor(r * 0.6)}px`,
|
|
1053
1053
|
backgroundColor: "currentColor",
|
|
1054
1054
|
borderRadius: "999px",
|
|
@@ -1060,7 +1060,7 @@ const me = {
|
|
|
1060
1060
|
"div",
|
|
1061
1061
|
{
|
|
1062
1062
|
style: {
|
|
1063
|
-
width: `${
|
|
1063
|
+
width: `${d}px`,
|
|
1064
1064
|
height: `${Math.floor(r * 0.4)}px`,
|
|
1065
1065
|
backgroundColor: "currentColor",
|
|
1066
1066
|
borderRadius: "999px",
|
|
@@ -1075,14 +1075,14 @@ const me = {
|
|
|
1075
1075
|
texts: t,
|
|
1076
1076
|
typingSpeed: i = 30,
|
|
1077
1077
|
deletingSpeed: r = 15,
|
|
1078
|
-
delayAfterText:
|
|
1078
|
+
delayAfterText: l = 800,
|
|
1079
1079
|
onSubmit: s,
|
|
1080
|
-
isStreaming:
|
|
1081
|
-
className:
|
|
1082
|
-
placeholderClassName:
|
|
1083
|
-
value:
|
|
1080
|
+
isStreaming: d = !1,
|
|
1081
|
+
className: g = "",
|
|
1082
|
+
placeholderClassName: T = "",
|
|
1083
|
+
value: o,
|
|
1084
1084
|
onChange: b,
|
|
1085
|
-
onFocus:
|
|
1085
|
+
onFocus: p,
|
|
1086
1086
|
onBlur: H,
|
|
1087
1087
|
onKeyDown: A,
|
|
1088
1088
|
onPaste: y,
|
|
@@ -1090,47 +1090,47 @@ const me = {
|
|
|
1090
1090
|
rows: k = 1,
|
|
1091
1091
|
...I
|
|
1092
1092
|
}, R) => {
|
|
1093
|
-
const [w, D] = f(""), [j,
|
|
1093
|
+
const [w, D] = f(""), [j, u] = f(!1), [C, W] = f(0), [x, S] = f(!1), [v, N] = f(!1), [K, $] = f(!1), [P, Q] = f(!1), _ = U(null), O = R || _, B = t[C], E = o === "" || o === void 0;
|
|
1094
1094
|
M(() => {
|
|
1095
1095
|
if (!E) return;
|
|
1096
|
-
let
|
|
1097
|
-
return x ? (
|
|
1098
|
-
|
|
1099
|
-
},
|
|
1096
|
+
let n;
|
|
1097
|
+
return x ? (n = setTimeout(() => {
|
|
1098
|
+
S(!1), $(!0), N(!0), Q(!0);
|
|
1099
|
+
}, l), () => clearTimeout(n)) : K ? (n = setTimeout(() => {
|
|
1100
1100
|
Q(!1), setTimeout(() => {
|
|
1101
|
-
N(!1), $(!1),
|
|
1101
|
+
N(!1), $(!1), u(!0);
|
|
1102
1102
|
}, 300);
|
|
1103
|
-
}, 3e3), () => clearTimeout(
|
|
1103
|
+
}, 3e3), () => clearTimeout(n)) : (j ? w === "" ? (u(!1), W((m) => (m + 1) % t.length)) : n = setTimeout(() => {
|
|
1104
1104
|
D((m) => m.slice(0, -1));
|
|
1105
|
-
}, r) : w === B ?
|
|
1105
|
+
}, r) : w === B ? S(!0) : n = setTimeout(() => {
|
|
1106
1106
|
D(B.slice(0, w.length + 1));
|
|
1107
|
-
}, i), () => clearTimeout(
|
|
1107
|
+
}, i), () => clearTimeout(n));
|
|
1108
1108
|
}, [
|
|
1109
1109
|
w,
|
|
1110
1110
|
j,
|
|
1111
|
-
|
|
1111
|
+
C,
|
|
1112
1112
|
x,
|
|
1113
1113
|
K,
|
|
1114
1114
|
B,
|
|
1115
1115
|
t,
|
|
1116
1116
|
i,
|
|
1117
1117
|
r,
|
|
1118
|
-
|
|
1118
|
+
l,
|
|
1119
1119
|
E
|
|
1120
1120
|
]);
|
|
1121
|
-
const a = (
|
|
1122
|
-
if (
|
|
1123
|
-
|
|
1121
|
+
const a = (n) => {
|
|
1122
|
+
if (n.key === "Tab" && E) {
|
|
1123
|
+
n.preventDefault(), b?.({
|
|
1124
1124
|
target: { value: B }
|
|
1125
1125
|
});
|
|
1126
1126
|
return;
|
|
1127
1127
|
}
|
|
1128
|
-
if (
|
|
1129
|
-
if (
|
|
1128
|
+
if (n.key === "Enter") {
|
|
1129
|
+
if (n.shiftKey || (n.preventDefault(), d))
|
|
1130
1130
|
return;
|
|
1131
|
-
s?.(
|
|
1131
|
+
s?.(n);
|
|
1132
1132
|
}
|
|
1133
|
-
A?.(
|
|
1133
|
+
A?.(n);
|
|
1134
1134
|
};
|
|
1135
1135
|
return /* @__PURE__ */ c("div", { style: { position: "relative", width: "100%" }, children: [
|
|
1136
1136
|
E && /* @__PURE__ */ e(
|
|
@@ -1158,7 +1158,7 @@ const me = {
|
|
|
1158
1158
|
color: "#a1a1aa",
|
|
1159
1159
|
fontWeight: "500",
|
|
1160
1160
|
lineHeight: "1.25",
|
|
1161
|
-
...
|
|
1161
|
+
...T ? {} : {}
|
|
1162
1162
|
},
|
|
1163
1163
|
children: [
|
|
1164
1164
|
w,
|
|
@@ -1194,13 +1194,13 @@ const me = {
|
|
|
1194
1194
|
}
|
|
1195
1195
|
),
|
|
1196
1196
|
/* @__PURE__ */ e(
|
|
1197
|
-
|
|
1197
|
+
G,
|
|
1198
1198
|
{
|
|
1199
1199
|
ref: O,
|
|
1200
1200
|
placeholder: F,
|
|
1201
|
-
style:
|
|
1202
|
-
value:
|
|
1203
|
-
onFocus:
|
|
1201
|
+
style: g ? {} : {},
|
|
1202
|
+
value: o,
|
|
1203
|
+
onFocus: p,
|
|
1204
1204
|
onBlur: H,
|
|
1205
1205
|
onChange: b,
|
|
1206
1206
|
onKeyDown: a,
|
|
@@ -1218,7 +1218,7 @@ const ke = ({
|
|
|
1218
1218
|
isTranscribing: i,
|
|
1219
1219
|
onVoiceRecording: r
|
|
1220
1220
|
}) => /* @__PURE__ */ e(
|
|
1221
|
-
|
|
1221
|
+
J,
|
|
1222
1222
|
{
|
|
1223
1223
|
size: "icon",
|
|
1224
1224
|
variant: "outline",
|
|
@@ -1264,10 +1264,9 @@ const ke = ({
|
|
|
1264
1264
|
}, Ie = ({
|
|
1265
1265
|
placeholder: t = "Ask anything...",
|
|
1266
1266
|
onSubmit: i,
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
typingTexts: l = [
|
|
1267
|
+
playgroundUid: r,
|
|
1268
|
+
isSubmitting: l,
|
|
1269
|
+
typingTexts: s = [
|
|
1271
1270
|
"Build me an AI chatbot application using OpenAI API",
|
|
1272
1271
|
"Build me an ecommerce website using Stripe API",
|
|
1273
1272
|
"Build me a price tracking tool using AgentQL API",
|
|
@@ -1276,32 +1275,33 @@ const ke = ({
|
|
|
1276
1275
|
"Build me a SMS notification system using Twilio API",
|
|
1277
1276
|
"Build me a travel booking platform using Skyscanner API"
|
|
1278
1277
|
],
|
|
1279
|
-
shouldFocusOnMount:
|
|
1280
|
-
showModelSelector:
|
|
1281
|
-
projectUid:
|
|
1282
|
-
theme:
|
|
1283
|
-
height:
|
|
1278
|
+
shouldFocusOnMount: d = !0,
|
|
1279
|
+
showModelSelector: g = !0,
|
|
1280
|
+
projectUid: T,
|
|
1281
|
+
theme: o,
|
|
1282
|
+
height: b = "auto",
|
|
1284
1283
|
// Add default for required height prop
|
|
1284
|
+
deepgramApiKey: p
|
|
1285
1285
|
}) => {
|
|
1286
|
-
const [H, A] = f(!0), [y, F] = f(!1), [k, I] = f(!1), [, R] = f(!1), [w, D] = f(null), [j,
|
|
1286
|
+
const [H, A] = f(!0), [y, F] = f(!1), [k, I] = f(!1), [, R] = f(!1), [w, D] = f(null), [j, u] = f(
|
|
1287
1287
|
null
|
|
1288
|
-
), [
|
|
1288
|
+
), [C, W] = f(""), x = U(null), S = U([]), v = U(null), [N, K] = f(!1), $ = ne(() => {
|
|
1289
1289
|
try {
|
|
1290
|
-
return we(
|
|
1290
|
+
return we(o, r);
|
|
1291
1291
|
} catch (a) {
|
|
1292
1292
|
return console.warn("Error getting color scheme:", a), Y;
|
|
1293
1293
|
}
|
|
1294
|
-
}, [
|
|
1294
|
+
}, [o, r]);
|
|
1295
1295
|
M(() => {
|
|
1296
1296
|
K(!0);
|
|
1297
1297
|
}, []), M(() => {
|
|
1298
|
-
if (
|
|
1298
|
+
if (d && v.current && N)
|
|
1299
1299
|
try {
|
|
1300
1300
|
v.current.focus(), v.current.select();
|
|
1301
1301
|
} catch (a) {
|
|
1302
1302
|
console.warn("Focus error:", a);
|
|
1303
1303
|
}
|
|
1304
|
-
}, [N,
|
|
1304
|
+
}, [N, d]);
|
|
1305
1305
|
const P = () => {
|
|
1306
1306
|
A(!0);
|
|
1307
1307
|
}, Q = () => {
|
|
@@ -1311,18 +1311,18 @@ const ke = ({
|
|
|
1311
1311
|
if (a)
|
|
1312
1312
|
try {
|
|
1313
1313
|
a.style.height = "auto";
|
|
1314
|
-
const
|
|
1315
|
-
a.style.height = `${
|
|
1316
|
-
} catch (
|
|
1317
|
-
console.warn("Textarea height adjustment error:",
|
|
1314
|
+
const n = Math.min(a.scrollHeight, 200);
|
|
1315
|
+
a.style.height = `${n}px`;
|
|
1316
|
+
} catch (n) {
|
|
1317
|
+
console.warn("Textarea height adjustment error:", n);
|
|
1318
1318
|
}
|
|
1319
1319
|
};
|
|
1320
1320
|
M(() => {
|
|
1321
1321
|
_();
|
|
1322
|
-
}, [
|
|
1323
|
-
const a = (
|
|
1324
|
-
const m = (
|
|
1325
|
-
m ? (
|
|
1322
|
+
}, [C]), M(() => {
|
|
1323
|
+
const a = (n) => {
|
|
1324
|
+
const m = (n.metaKey || n.ctrlKey) && n.key === "/", h = (n.key === "Enter" || n.key === "Escape") && (y || k);
|
|
1325
|
+
m ? (n.preventDefault(), B()) : h && (n.preventDefault(), y && !k && B());
|
|
1326
1326
|
};
|
|
1327
1327
|
return document.addEventListener("keydown", a), () => {
|
|
1328
1328
|
document.removeEventListener("keydown", a);
|
|
@@ -1334,29 +1334,29 @@ const ke = ({
|
|
|
1334
1334
|
if (x.current && y)
|
|
1335
1335
|
return F(!1), I(!0), w && (clearTimeout(w), D(null)), new Promise((a) => {
|
|
1336
1336
|
if (x.current) {
|
|
1337
|
-
let
|
|
1338
|
-
x.current.ondataavailable = (
|
|
1339
|
-
|
|
1337
|
+
let n = !1, m;
|
|
1338
|
+
x.current.ondataavailable = (h) => {
|
|
1339
|
+
h.data.size > 0 && (n = !0, S.current.push(h.data));
|
|
1340
1340
|
}, x.current.onstop = async () => {
|
|
1341
1341
|
m && clearTimeout(m);
|
|
1342
1342
|
try {
|
|
1343
|
-
if (!
|
|
1343
|
+
if (!n || S.current.length === 0)
|
|
1344
1344
|
throw new Error("No audio data recorded");
|
|
1345
|
-
const
|
|
1345
|
+
const h = new Blob(S.current, {
|
|
1346
1346
|
type: "audio/wav"
|
|
1347
1347
|
});
|
|
1348
|
-
if (
|
|
1348
|
+
if (h.size < 1024)
|
|
1349
1349
|
throw new Error("Audio recording too short");
|
|
1350
|
-
const
|
|
1351
|
-
|
|
1350
|
+
const q = new FormData();
|
|
1351
|
+
q.append("audio", h, "recording.wav"), p && q.append("deepgramApiKey", p);
|
|
1352
1352
|
const X = await fetch("/api/voice/transcribe", {
|
|
1353
1353
|
method: "POST",
|
|
1354
|
-
body:
|
|
1354
|
+
body: q
|
|
1355
1355
|
});
|
|
1356
1356
|
if (X.ok) {
|
|
1357
1357
|
const { transcription: V } = await X.json();
|
|
1358
1358
|
if (V && V.trim()) {
|
|
1359
|
-
const ae =
|
|
1359
|
+
const ae = C ? `${C} ${V}` : V;
|
|
1360
1360
|
W(ae.trim()), setTimeout(() => {
|
|
1361
1361
|
if (v.current) {
|
|
1362
1362
|
v.current.focus();
|
|
@@ -1367,21 +1367,21 @@ const ke = ({
|
|
|
1367
1367
|
}
|
|
1368
1368
|
} else
|
|
1369
1369
|
throw new Error("Transcription failed");
|
|
1370
|
-
} catch (
|
|
1371
|
-
console.error("Transcription error:",
|
|
1370
|
+
} catch (h) {
|
|
1371
|
+
console.error("Transcription error:", h), h instanceof Error && (h.message.includes("No audio data") || h.message.includes("too short"));
|
|
1372
1372
|
} finally {
|
|
1373
|
-
|
|
1373
|
+
S.current = [], x.current = null, u(null), I(!1), R(!1), a();
|
|
1374
1374
|
}
|
|
1375
1375
|
}, m = setTimeout(() => {
|
|
1376
|
-
console.warn("MediaRecorder stop timeout, forcing cleanup"),
|
|
1376
|
+
console.warn("MediaRecorder stop timeout, forcing cleanup"), S.current = [], x.current = null, u(null), I(!1), R(!1), a();
|
|
1377
1377
|
}, 5e3);
|
|
1378
1378
|
try {
|
|
1379
1379
|
x.current.stop();
|
|
1380
|
-
} catch (
|
|
1381
|
-
console.error("Error stopping MediaRecorder:",
|
|
1380
|
+
} catch (h) {
|
|
1381
|
+
console.error("Error stopping MediaRecorder:", h), m && clearTimeout(m), S.current = [], x.current = null, u(null), I(!1), R(!1), a();
|
|
1382
1382
|
}
|
|
1383
1383
|
} else
|
|
1384
|
-
|
|
1384
|
+
u(null), I(!1), R(!1), a();
|
|
1385
1385
|
});
|
|
1386
1386
|
}, B = async () => {
|
|
1387
1387
|
if (!k)
|
|
@@ -1397,12 +1397,12 @@ const ke = ({
|
|
|
1397
1397
|
noiseSuppression: !0,
|
|
1398
1398
|
sampleRate: 44100
|
|
1399
1399
|
}
|
|
1400
|
-
}),
|
|
1400
|
+
}), n = new MediaRecorder(a, {
|
|
1401
1401
|
mimeType: MediaRecorder.isTypeSupported("audio/webm") ? "audio/webm" : "audio/mp4"
|
|
1402
1402
|
});
|
|
1403
|
-
x.current =
|
|
1404
|
-
|
|
1405
|
-
},
|
|
1403
|
+
x.current = n, S.current = [], n.ondataavailable = (h) => {
|
|
1404
|
+
h.data.size > 0 && S.current.push(h.data);
|
|
1405
|
+
}, n.start(200), F(!0), u(Date.now()), R(!0);
|
|
1406
1406
|
const m = setTimeout(async () => {
|
|
1407
1407
|
await O();
|
|
1408
1408
|
}, 6e4);
|
|
@@ -1411,15 +1411,15 @@ const ke = ({
|
|
|
1411
1411
|
console.error("Microphone access error:", a), a instanceof Error && (a.name === "NotAllowedError" || a.name === "NotFoundError" || a.name === "NotReadableError" || a.name);
|
|
1412
1412
|
}
|
|
1413
1413
|
}, E = (a) => {
|
|
1414
|
-
if (a.preventDefault(), !!
|
|
1414
|
+
if (a.preventDefault(), !!C.trim())
|
|
1415
1415
|
try {
|
|
1416
|
-
if (
|
|
1417
|
-
const
|
|
1416
|
+
if (r) {
|
|
1417
|
+
const n = encodeURIComponent(C.trim()), m = `https://${r}.sampleapp.ai?q=${n}`;
|
|
1418
1418
|
window.open(m, "_blank");
|
|
1419
1419
|
}
|
|
1420
1420
|
i && i(a);
|
|
1421
|
-
} catch (
|
|
1422
|
-
console.error("Submit error:",
|
|
1421
|
+
} catch (n) {
|
|
1422
|
+
console.error("Submit error:", n);
|
|
1423
1423
|
}
|
|
1424
1424
|
};
|
|
1425
1425
|
return /* @__PURE__ */ e("div", { children: /* @__PURE__ */ c(
|
|
@@ -1522,10 +1522,10 @@ const ke = ({
|
|
|
1522
1522
|
paddingBottom: "4px"
|
|
1523
1523
|
},
|
|
1524
1524
|
children: [
|
|
1525
|
-
|
|
1525
|
+
s.length > 0 ? /* @__PURE__ */ e(
|
|
1526
1526
|
re,
|
|
1527
1527
|
{
|
|
1528
|
-
texts:
|
|
1528
|
+
texts: s,
|
|
1529
1529
|
ref: v,
|
|
1530
1530
|
style: {
|
|
1531
1531
|
flex: 1,
|
|
@@ -1547,9 +1547,10 @@ const ke = ({
|
|
|
1547
1547
|
maxHeight: "192px",
|
|
1548
1548
|
marginTop: "4px",
|
|
1549
1549
|
color: "#f4f4f5",
|
|
1550
|
-
fontFamily: "inherit"
|
|
1550
|
+
fontFamily: "inherit",
|
|
1551
|
+
height: b
|
|
1551
1552
|
},
|
|
1552
|
-
value:
|
|
1553
|
+
value: C,
|
|
1553
1554
|
onFocus: P,
|
|
1554
1555
|
onBlur: Q,
|
|
1555
1556
|
onChange: (a) => W(a.target.value),
|
|
@@ -1563,7 +1564,7 @@ const ke = ({
|
|
|
1563
1564
|
rows: 1
|
|
1564
1565
|
}
|
|
1565
1566
|
) : /* @__PURE__ */ e(
|
|
1566
|
-
|
|
1567
|
+
G,
|
|
1567
1568
|
{
|
|
1568
1569
|
ref: v,
|
|
1569
1570
|
placeholder: t,
|
|
@@ -1587,9 +1588,10 @@ const ke = ({
|
|
|
1587
1588
|
maxHeight: "192px",
|
|
1588
1589
|
marginTop: "4px",
|
|
1589
1590
|
color: "#f4f4f5",
|
|
1590
|
-
fontFamily: "inherit"
|
|
1591
|
+
fontFamily: "inherit",
|
|
1592
|
+
height: b
|
|
1591
1593
|
},
|
|
1592
|
-
value:
|
|
1594
|
+
value: C,
|
|
1593
1595
|
onFocus: P,
|
|
1594
1596
|
onBlur: Q,
|
|
1595
1597
|
onChange: (a) => W(a.target.value),
|
|
@@ -1613,17 +1615,17 @@ const ke = ({
|
|
|
1613
1615
|
}
|
|
1614
1616
|
),
|
|
1615
1617
|
/* @__PURE__ */ e(
|
|
1616
|
-
|
|
1618
|
+
J,
|
|
1617
1619
|
{
|
|
1618
1620
|
style: {
|
|
1619
1621
|
height: "32px",
|
|
1620
1622
|
width: "32px"
|
|
1621
1623
|
},
|
|
1622
|
-
disabled:
|
|
1624
|
+
disabled: C.length === 0 || l,
|
|
1623
1625
|
variant: "secondary",
|
|
1624
1626
|
onClick: E,
|
|
1625
1627
|
size: "icon",
|
|
1626
|
-
children:
|
|
1628
|
+
children: l ? /* @__PURE__ */ e(
|
|
1627
1629
|
xe,
|
|
1628
1630
|
{
|
|
1629
1631
|
size: 20,
|
|
@@ -1646,7 +1648,7 @@ const ke = ({
|
|
|
1646
1648
|
paddingLeft: "8px",
|
|
1647
1649
|
paddingRight: "8px"
|
|
1648
1650
|
},
|
|
1649
|
-
children: /* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children:
|
|
1651
|
+
children: /* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: g && /* @__PURE__ */ e(
|
|
1650
1652
|
"div",
|
|
1651
1653
|
{
|
|
1652
1654
|
style: { display: "flex", alignItems: "center", gap: "8px" }
|
|
@@ -1683,17 +1685,17 @@ const ke = ({
|
|
|
1683
1685
|
class ve {
|
|
1684
1686
|
constructor() {
|
|
1685
1687
|
this.ModalSearchAndChat = (i, r) => {
|
|
1686
|
-
const
|
|
1687
|
-
s.id = "sampleapp-modal-" + Date.now(),
|
|
1688
|
-
const
|
|
1688
|
+
const l = r || document.body, s = document.createElement("div");
|
|
1689
|
+
s.id = "sampleapp-modal-" + Date.now(), l.appendChild(s);
|
|
1690
|
+
const d = ee.createRoot(s), g = L.createElement(se, {
|
|
1689
1691
|
settings: i,
|
|
1690
1692
|
onClose: () => {
|
|
1691
|
-
|
|
1693
|
+
d.unmount(), s.remove();
|
|
1692
1694
|
}
|
|
1693
1695
|
});
|
|
1694
|
-
return
|
|
1696
|
+
return d.render(g), {
|
|
1695
1697
|
unmount: () => {
|
|
1696
|
-
|
|
1698
|
+
d.unmount(), s.remove();
|
|
1697
1699
|
},
|
|
1698
1700
|
show: () => {
|
|
1699
1701
|
s.style.display = "block";
|
|
@@ -1703,10 +1705,10 @@ class ve {
|
|
|
1703
1705
|
}
|
|
1704
1706
|
};
|
|
1705
1707
|
}, this.ChatButton = (i, r) => {
|
|
1706
|
-
const
|
|
1707
|
-
return s.render(
|
|
1708
|
+
const l = r || this.createButtonContainer(), s = ee.createRoot(l), d = L.createElement(ie, { settings: i });
|
|
1709
|
+
return s.render(d), {
|
|
1708
1710
|
unmount: () => {
|
|
1709
|
-
s.unmount(),
|
|
1711
|
+
s.unmount(), l.remove();
|
|
1710
1712
|
}
|
|
1711
1713
|
};
|
|
1712
1714
|
};
|