@chaibuilder/sdk 4.0.0-beta.1 → 4.0.0-beta.3
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 +27 -20
- package/dist/2SSKDMRQ-BnsZi3K3.cjs +1 -0
- package/dist/2SSKDMRQ-CnSDkQcy.js +42 -0
- package/dist/AP7HFJJL-B31839PG.cjs +1228 -0
- package/dist/AP7HFJJL-CymCmW14.js +9214 -0
- package/dist/IconPicker-B1rWC-Ex.js +59 -0
- package/dist/IconPicker-DREyo007.cjs +1 -0
- package/dist/WDYDFRGG-BUVnbAci.js +33 -0
- package/dist/WDYDFRGG-BxhOCHc3.cjs +1 -0
- package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
- package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
- package/dist/actions-registery-CZ1w0NKa.js +15545 -0
- package/dist/actions-registery-YnFmU21O.cjs +418 -0
- package/dist/actions.cjs +1 -0
- package/dist/actions.d.ts +3202 -0
- package/dist/actions.js +216 -0
- package/dist/active-in-another-tab-B47YjQGN.cjs +1 -0
- package/dist/active-in-another-tab-CyjngVA6.js +34 -0
- package/dist/add-new-language-page-88xzrUy8.cjs +1 -0
- package/dist/add-new-language-page-WmlCnytQ.js +401 -0
- package/dist/add-new-page-VW2wAYZp.js +31 -0
- package/dist/add-new-page-soZ8GAkN.cjs +1 -0
- package/dist/ai-panel-content-7zCil042.cjs +1 -0
- package/dist/ai-panel-content-D_o7Q_A-.js +61 -0
- package/dist/ai-panel-default-lang-COYaxNwn.cjs +3 -0
- package/dist/ai-panel-default-lang-DnElspF0.js +341 -0
- package/dist/ai-panel-other-lang-CkynNlAU.cjs +1 -0
- package/dist/ai-panel-other-lang-Dp0E9_Hx.js +162 -0
- package/dist/ai-prompt-input-Bhc0ds7X.js +655 -0
- package/dist/ai-prompt-input-CThbVp0_.cjs +1 -0
- package/dist/ai-translation-prompt-C2kJQFDX.cjs +1 -0
- package/dist/ai-translation-prompt-CZ55HQmo.js +28 -0
- package/dist/apply-binding-6iwlED02.js +833 -0
- package/dist/apply-binding-KKp5PnpZ.cjs +1 -0
- package/dist/code-display-BnqzqzoP.cjs +1 -0
- package/dist/{code-display-337R7Dev.js → code-display-DhD_RBcg.js} +1 -1
- package/dist/code-editor-DRIAnNbb.js +50 -0
- package/dist/code-editor-o3___nu2.cjs +1 -0
- package/dist/common-functions-B3a4xKt_.cjs +1 -0
- package/dist/common-functions-D2lMFR6K.js +13 -0
- package/dist/continue-editing-in-this-client-CS2aQ7yY.js +24 -0
- package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +1 -0
- package/dist/core-BoRDjj4h.cjs +1 -0
- package/dist/core-yvI6kCyw.js +56 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +51 -383
- package/dist/core.js +39 -106
- package/dist/{css-import-modal-DA2L6kwP.js → css-import-modal-Byg6wV0O.js} +36 -36
- package/dist/css-import-modal-CyqkXWCO.cjs +13 -0
- package/dist/delete-design-token-BRZZiWtQ.js +40 -0
- package/dist/delete-design-token-DkVs1oBf.cjs +1 -0
- package/dist/delete-page-BzyX9TN-.js +70 -0
- package/dist/delete-page-DxX7PFIE.cjs +1 -0
- package/dist/design-token-usage-CAHzEGgJ.cjs +1 -0
- package/dist/design-token-usage-xQs6SlaJ.js +113 -0
- package/dist/digital-asset-manager--uO8Agia.cjs +1 -0
- package/dist/digital-asset-manager-DbtwzxRz.js +876 -0
- package/dist/duplicate-page-BR7Dlo9d.js +133 -0
- package/dist/duplicate-page-CaNAbXwV.cjs +1 -0
- package/dist/dynamic-page-selector-Cb5r_W8s.js +85 -0
- package/dist/dynamic-page-selector-Cxk_gjni.cjs +1 -0
- package/dist/fonts-B-Xt29pe.cjs +1 -0
- package/dist/fonts-DRly3Wzd.js +78 -0
- package/dist/{get-chai-builder-tailwind-config-C6MHaUM0.cjs → get-chai-builder-tailwind-config-B9rCyiQo.cjs} +1 -1
- package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-DjoVOuAf.js} +13 -10
- package/dist/{get-chai-builder-theme-D0IsUvK4.js → get-chai-builder-theme-BYtp20KD.js} +4 -4
- package/dist/get-chai-builder-theme-Dl72X7cz.cjs +1 -0
- package/dist/get-seo-defaults-9zHebckY.js +65 -0
- package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
- package/dist/image-compression-DZ9WMmyn.cjs +1 -0
- package/dist/image-compression-DsZ1oqpb.js +37 -0
- package/dist/image-editor-DV8kUKhl.js +108 -0
- package/dist/image-editor-G-K28aTS.cjs +1 -0
- package/dist/index-B-rSiAp_.cjs +1 -0
- package/dist/index-Ct7ElCGK.js +19069 -0
- package/dist/index-DF5DEvqb.cjs +160 -0
- package/dist/index-Dxfyt4d4.js +39 -0
- package/dist/index-WQwzsC7A.cjs +5 -0
- package/dist/index-ZuacEL1j.js +4732 -0
- package/dist/json-diff-viewer-D7z4zNvv.cjs +8 -0
- package/dist/json-diff-viewer-krslPepD.js +258 -0
- package/dist/lang-panel-BwIewMyw.js +215 -0
- package/dist/lang-panel-DT96k1xg.cjs +1 -0
- package/dist/manage-design-tokens-Caz_20VK.js +240 -0
- package/dist/manage-design-tokens-CrmLe7UT.cjs +1 -0
- package/dist/mark-as-template-D295ZQtU.js +156 -0
- package/dist/mark-as-template-W3LmpiqN.cjs +1 -0
- package/dist/models-5gOsRC56.cjs +1 -0
- package/dist/models-D95ZYr_x.js +70 -0
- package/dist/nested-path-selector-content-CKYYK-C5.js +87 -0
- package/dist/nested-path-selector-content-CoS_d3dc.cjs +1 -0
- package/dist/no-language-page-content-BvqRBP6y.js +42 -0
- package/dist/no-language-page-content-DkfeMl90.cjs +1 -0
- package/dist/no-language-page-dialog-BcEoqyQB.cjs +1 -0
- package/dist/no-language-page-dialog-PjNqTUpl.js +10 -0
- package/dist/page-creator-C4gc5NSC.cjs +1 -0
- package/dist/page-creator-DiOITEMw.js +795 -0
- package/dist/page-lock-BdYmCks0.cjs +1 -0
- package/dist/page-lock-Bfbs6RgL.js +30 -0
- package/dist/page-locked-dialog-B1FAtK92.cjs +1 -0
- package/dist/page-locked-dialog-B6MKTRfY.js +133 -0
- package/dist/page-manager-new-CHDueBDk.cjs +1 -0
- package/dist/page-manager-new-CzX22g2n.js +394 -0
- package/dist/page-manager-search-and-filter-CM0UMb6U.js +201 -0
- package/dist/page-manager-search-and-filter-DkkRIH86.cjs +1 -0
- package/dist/page-revisions-content-ChY-4f2V.cjs +1 -0
- package/dist/page-revisions-content-NH9JK4Ey.js +445 -0
- package/dist/pages.cjs +1 -0
- package/dist/pages.d.ts +491 -0
- package/dist/pages.js +27 -0
- package/dist/plugin-3ZKK6RXm.js +245 -0
- package/dist/plugin-C6rgJDNQ.cjs +22 -0
- package/dist/publish-pages-content-D9aixMN5.js +178 -0
- package/dist/publish-pages-content-x-JuSFJ9.cjs +1 -0
- package/dist/register-partial-type-BjtdfKHE.js +36 -0
- package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +26 -13
- package/dist/render.js +130 -124
- package/dist/rte-widget-modal-BaHIuEjF.cjs +1 -0
- package/dist/rte-widget-modal-DOJEXLIf.js +38 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +306 -7
- package/dist/runtime.js +44 -1
- package/dist/save-to-lib-Cgpxw8-g.cjs +1 -0
- package/dist/save-to-lib-eiOc_SSN.js +422 -0
- package/dist/sdk.css +1 -1
- package/dist/selected-block-display-BgRY82CT.cjs +16 -0
- package/dist/selected-block-display-CBFePS19.js +319 -0
- package/dist/seo-panel-C1-iMOR1.js +798 -0
- package/dist/seo-panel-DfAb8U7W.cjs +2 -0
- package/dist/shared-json-ld-B4PxAM_0.js +565 -0
- package/dist/shared-json-ld-DzG398hr.cjs +1 -0
- package/dist/slug-input-AwNJs9im.js +86 -0
- package/dist/slug-input-C_ijLQ_X.cjs +1 -0
- package/dist/supabase-actions.cjs +1 -0
- package/dist/supabase-actions.d.ts +284 -0
- package/dist/supabase-actions.js +524 -0
- package/dist/take-over-request-BNxcjY2j.cjs +1 -0
- package/dist/take-over-request-C4FeDtN_.js +63 -0
- package/dist/theme-panel-footer-Cq9pljro.cjs +1 -0
- package/dist/theme-panel-footer-uBQqSJXm.js +25 -0
- package/dist/translation-warning-modal-B64YqlbI.js +26 -0
- package/dist/translation-warning-modal-BZAcwM2_.cjs +1 -0
- package/dist/unmark-as-template-CZ9sQp_P.js +39 -0
- package/dist/unmark-as-template-EVvk0vmp.cjs +1 -0
- package/dist/unpublish-page-D4VwOlxc.js +27 -0
- package/dist/unpublish-page-bdSmwAVQ.cjs +1 -0
- package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
- package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
- package/dist/{tailwind.cjs → utils.cjs} +1 -1
- package/dist/{tailwind.d.ts → utils.d.ts} +12 -11
- package/dist/utils.js +7 -0
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.d.ts +0 -6
- package/dist/web-blocks.js +248 -241
- package/dist/web-preview-Cio70gk5.cjs +1 -0
- package/dist/web-preview-Djy6WIyj.js +73 -0
- package/package.json +175 -105
- package/dist/IconPicker-CGWn9C4u.cjs +0 -1
- package/dist/IconPicker-QvxJ-4Ez.js +0 -64
- package/dist/apply-binding-DCno1xQL.js +0 -711
- package/dist/apply-binding-DvHNFLQD.cjs +0 -1
- package/dist/code-display-BZ1x7SqI.cjs +0 -1
- package/dist/code-editor-B28LoECM.cjs +0 -1
- package/dist/code-editor-CfG2FhJ-.js +0 -58
- package/dist/common-functions-BGzDsf1z.js +0 -14
- package/dist/common-functions-BZmyleS1.cjs +0 -1
- package/dist/css-import-modal-CENUYvcl.cjs +0 -13
- package/dist/get-chai-builder-theme-Ck_Z4Q-M.cjs +0 -1
- package/dist/index-CaGNHF7f.js +0 -12209
- package/dist/index-Gn6pJt2v.cjs +0 -166
- package/dist/mockServiceWorker.js +0 -307
- package/dist/plugin-B5627hMN.js +0 -195
- package/dist/plugin-UxTRfDum.cjs +0 -22
- package/dist/rte-widget-modal-DL739qeQ.cjs +0 -1
- package/dist/rte-widget-modal-Dte0od04.js +0 -41
- package/dist/tailwind.js +0 -7
- package/dist/tooltip-A4qGk781.cjs +0 -1
- package/dist/tooltip-tLiIOgjq.js +0 -1067
- package/dist/ui.cjs +0 -1
- package/dist/ui.d.ts +0 -415
- package/dist/ui.js +0 -129
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1,655 @@
|
|
|
1
|
+
import { jsx as e, jsxs as w, Fragment as ie } from "react/jsx-runtime";
|
|
2
|
+
import { ag as N, T as le, B as V, aA as ce, r as ue, s as de, t as pe, v as me, aB as fe, aC as he, D as ge, aD as ve, d as be, f as xe, C as we, i as Ne, j as Ie, l as ye, m as Se } from "./index-Ct7ElCGK.js";
|
|
3
|
+
import { PaperclipIcon as ke, XIcon as Y, PlusIcon as De, ImageIcon as ze, MicIcon as Pe, CornerDownLeftIcon as Te, Loader2Icon as Ae, SquareIcon as Ce, Cpu as Le, Paperclip as Re, GlobeIcon as Me, Square as je, Send as Ue } from "lucide-react";
|
|
4
|
+
import { nanoid as Oe } from "nanoid";
|
|
5
|
+
import { useContext as W, useRef as M, useEffect as A, useState as P, useCallback as F, useMemo as Fe, createContext as E, Fragment as Ge, Children as Be } from "react";
|
|
6
|
+
import { cva as J } from "class-variance-authority";
|
|
7
|
+
import { useTranslation as _e } from "react-i18next";
|
|
8
|
+
import { a as Ve, g as _, A as We } from "./models-D95ZYr_x.js";
|
|
9
|
+
function Ee({ className: t, ...n }) {
|
|
10
|
+
return /* @__PURE__ */ e(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
"data-slot": "input-group",
|
|
14
|
+
role: "group",
|
|
15
|
+
className: N(
|
|
16
|
+
"group/input-group shadow-xs relative flex w-full items-center rounded-md border border-input outline-none transition-[color,box-shadow] dark:bg-input/30",
|
|
17
|
+
"h-9 has-[>textarea]:h-auto",
|
|
18
|
+
// Variants based on alignment.
|
|
19
|
+
"has-[>[data-align=inline-start]]:[&>input]:pl-2",
|
|
20
|
+
"has-[>[data-align=inline-end]]:[&>input]:pr-2",
|
|
21
|
+
"has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3",
|
|
22
|
+
"has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3",
|
|
23
|
+
// Focus state.
|
|
24
|
+
"has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-ring",
|
|
25
|
+
// Error state.
|
|
26
|
+
"has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",
|
|
27
|
+
t
|
|
28
|
+
),
|
|
29
|
+
...n
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const He = J(
|
|
34
|
+
"text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",
|
|
35
|
+
{
|
|
36
|
+
variants: {
|
|
37
|
+
align: {
|
|
38
|
+
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
39
|
+
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]",
|
|
40
|
+
"block-start": "[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5",
|
|
41
|
+
"block-end": "[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
defaultVariants: {
|
|
45
|
+
align: "inline-start"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
function Q({
|
|
50
|
+
className: t,
|
|
51
|
+
align: n = "inline-start",
|
|
52
|
+
...o
|
|
53
|
+
}) {
|
|
54
|
+
return /* @__PURE__ */ e(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
role: "group",
|
|
58
|
+
"data-slot": "input-group-addon",
|
|
59
|
+
"data-align": n,
|
|
60
|
+
className: N(He({ align: n }), t),
|
|
61
|
+
onClick: (l) => {
|
|
62
|
+
var i, p;
|
|
63
|
+
l.target.closest("button") || (p = (i = l.currentTarget.parentElement) == null ? void 0 : i.querySelector("input")) == null || p.focus();
|
|
64
|
+
},
|
|
65
|
+
...o
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const qe = J("flex items-center gap-2 text-sm shadow-none", {
|
|
70
|
+
variants: {
|
|
71
|
+
size: {
|
|
72
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
73
|
+
sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
|
|
74
|
+
"icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
|
|
75
|
+
"icon-sm": "size-8 p-0 has-[>svg]:p-0"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
defaultVariants: {
|
|
79
|
+
size: "xs"
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
function Z({
|
|
83
|
+
className: t,
|
|
84
|
+
type: n = "button",
|
|
85
|
+
variant: o = "ghost",
|
|
86
|
+
size: l = "xs",
|
|
87
|
+
...i
|
|
88
|
+
}) {
|
|
89
|
+
return /* @__PURE__ */ e(
|
|
90
|
+
V,
|
|
91
|
+
{
|
|
92
|
+
type: n,
|
|
93
|
+
"data-size": l,
|
|
94
|
+
variant: o,
|
|
95
|
+
className: N(qe({ size: l }), t),
|
|
96
|
+
...i
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
function Ke({ className: t, ...n }) {
|
|
101
|
+
return /* @__PURE__ */ e(
|
|
102
|
+
le,
|
|
103
|
+
{
|
|
104
|
+
"data-slot": "input-group-control",
|
|
105
|
+
className: N(
|
|
106
|
+
"flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",
|
|
107
|
+
t
|
|
108
|
+
),
|
|
109
|
+
...n
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
const $e = E(null), Xe = E(null), ee = () => W($e), Ye = () => W(Xe), te = E(null), G = () => {
|
|
114
|
+
const t = Ye(), n = W(te), o = t ?? n;
|
|
115
|
+
if (!o)
|
|
116
|
+
throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");
|
|
117
|
+
return o;
|
|
118
|
+
};
|
|
119
|
+
function Je({ data: t, className: n, ...o }) {
|
|
120
|
+
var f;
|
|
121
|
+
const l = G(), i = t.filename || "", u = ((f = t.mediaType) != null && f.startsWith("image/") && t.url ? "image" : "file") === "image", g = i || (u ? "Image" : "Attachment");
|
|
122
|
+
return /* @__PURE__ */ w(ut, { children: [
|
|
123
|
+
/* @__PURE__ */ e(ce, { asChild: !0, children: /* @__PURE__ */ w(
|
|
124
|
+
"div",
|
|
125
|
+
{
|
|
126
|
+
className: N(
|
|
127
|
+
"group relative flex h-8 cursor-default select-none items-center gap-1.5 rounded-md border border-border px-1.5 text-sm font-medium transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
128
|
+
n
|
|
129
|
+
),
|
|
130
|
+
...o,
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ w("div", { className: "relative size-5 shrink-0", children: [
|
|
133
|
+
/* @__PURE__ */ e("div", { className: "absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0", children: u ? /* @__PURE__ */ e(
|
|
134
|
+
"img",
|
|
135
|
+
{
|
|
136
|
+
alt: i || "attachment",
|
|
137
|
+
className: "size-5 object-cover",
|
|
138
|
+
height: 20,
|
|
139
|
+
src: t.url,
|
|
140
|
+
width: 20
|
|
141
|
+
}
|
|
142
|
+
) : /* @__PURE__ */ e("div", { className: "flex size-5 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ e(ke, { className: "size-3" }) }) }),
|
|
143
|
+
/* @__PURE__ */ w(
|
|
144
|
+
V,
|
|
145
|
+
{
|
|
146
|
+
"aria-label": "Remove attachment",
|
|
147
|
+
className: "absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",
|
|
148
|
+
onClick: (y) => {
|
|
149
|
+
y.stopPropagation(), l.remove(t.id);
|
|
150
|
+
},
|
|
151
|
+
type: "button",
|
|
152
|
+
variant: "ghost",
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ e(Y, {}),
|
|
155
|
+
/* @__PURE__ */ e("span", { className: "sr-only", children: "Remove" })
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
] }),
|
|
160
|
+
/* @__PURE__ */ e("span", { className: "flex-1 truncate", children: g })
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
t.id
|
|
164
|
+
) }),
|
|
165
|
+
/* @__PURE__ */ e(dt, { className: "w-auto p-2", children: /* @__PURE__ */ w("div", { className: "w-auto space-y-3", children: [
|
|
166
|
+
u && /* @__PURE__ */ e("div", { className: "flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border", children: /* @__PURE__ */ e(
|
|
167
|
+
"img",
|
|
168
|
+
{
|
|
169
|
+
alt: i || "attachment preview",
|
|
170
|
+
className: "max-h-full max-w-full object-contain",
|
|
171
|
+
height: 384,
|
|
172
|
+
src: t.url,
|
|
173
|
+
width: 448
|
|
174
|
+
}
|
|
175
|
+
) }),
|
|
176
|
+
/* @__PURE__ */ e("div", { className: "flex items-center gap-2.5", children: /* @__PURE__ */ w("div", { className: "min-w-0 flex-1 space-y-1 px-0.5", children: [
|
|
177
|
+
/* @__PURE__ */ e("h4", { className: "truncate text-sm font-semibold leading-none", children: i || (u ? "Image" : "Attachment") }),
|
|
178
|
+
t.mediaType && /* @__PURE__ */ e("p", { className: "truncate font-mono text-xs text-muted-foreground", children: t.mediaType })
|
|
179
|
+
] }) })
|
|
180
|
+
] }) })
|
|
181
|
+
] });
|
|
182
|
+
}
|
|
183
|
+
function Qe({ children: t, className: n, ...o }) {
|
|
184
|
+
const l = G();
|
|
185
|
+
return l.files.length ? /* @__PURE__ */ e("div", { className: N("flex flex-wrap items-center gap-2 p-3", n), ...o, children: l.files.map((i) => /* @__PURE__ */ e(Ge, { children: t(i) }, i.id)) }) : null;
|
|
186
|
+
}
|
|
187
|
+
const Ze = ({
|
|
188
|
+
label: t = "Add photos or files",
|
|
189
|
+
...n
|
|
190
|
+
}) => {
|
|
191
|
+
const o = G();
|
|
192
|
+
return /* @__PURE__ */ w(
|
|
193
|
+
me,
|
|
194
|
+
{
|
|
195
|
+
...n,
|
|
196
|
+
onSelect: (l) => {
|
|
197
|
+
l.preventDefault(), o.openFileDialog();
|
|
198
|
+
},
|
|
199
|
+
children: [
|
|
200
|
+
/* @__PURE__ */ e(ze, { className: "mr-2 size-4" }),
|
|
201
|
+
" ",
|
|
202
|
+
t
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
}, et = ({
|
|
207
|
+
className: t,
|
|
208
|
+
accept: n,
|
|
209
|
+
multiple: o,
|
|
210
|
+
globalDrop: l,
|
|
211
|
+
syncHiddenInput: i,
|
|
212
|
+
maxFiles: p,
|
|
213
|
+
maxFileSize: u,
|
|
214
|
+
onError: g,
|
|
215
|
+
onSubmit: f,
|
|
216
|
+
children: y,
|
|
217
|
+
...D
|
|
218
|
+
}) => {
|
|
219
|
+
const s = ee(), a = !!s, d = M(null), k = M(null), I = M(null);
|
|
220
|
+
A(() => {
|
|
221
|
+
var v;
|
|
222
|
+
const r = (v = k.current) == null ? void 0 : v.closest("form");
|
|
223
|
+
r instanceof HTMLFormElement && (I.current = r);
|
|
224
|
+
}, []);
|
|
225
|
+
const [S, C] = P([]), h = a ? s.attachments.files : S, T = F(() => {
|
|
226
|
+
var r;
|
|
227
|
+
(r = d.current) == null || r.click();
|
|
228
|
+
}, []), j = F(
|
|
229
|
+
(r) => !n || n.trim() === "" ? !0 : n.includes("image/*") ? r.type.startsWith("image/") : !0,
|
|
230
|
+
[n]
|
|
231
|
+
), U = F(
|
|
232
|
+
(r) => {
|
|
233
|
+
const v = Array.from(r), m = v.filter((x) => j(x));
|
|
234
|
+
if (v.length && m.length === 0) {
|
|
235
|
+
g == null || g({
|
|
236
|
+
code: "accept",
|
|
237
|
+
message: "No files match the accepted types."
|
|
238
|
+
});
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const c = (x) => u ? x.size <= u : !0, b = m.filter(c);
|
|
242
|
+
if (m.length > 0 && b.length === 0) {
|
|
243
|
+
g == null || g({
|
|
244
|
+
code: "max_file_size",
|
|
245
|
+
message: "All files exceed the maximum size."
|
|
246
|
+
});
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
C((x) => {
|
|
250
|
+
const L = typeof p == "number" ? Math.max(0, p - x.length) : void 0, oe = typeof L == "number" ? b.slice(0, L) : b;
|
|
251
|
+
typeof L == "number" && b.length > L && (g == null || g({
|
|
252
|
+
code: "max_files",
|
|
253
|
+
message: "Too many files. Some were not added."
|
|
254
|
+
}));
|
|
255
|
+
const $ = [];
|
|
256
|
+
for (const B of oe)
|
|
257
|
+
$.push({
|
|
258
|
+
id: Oe(),
|
|
259
|
+
type: "file",
|
|
260
|
+
url: URL.createObjectURL(B),
|
|
261
|
+
mediaType: B.type,
|
|
262
|
+
filename: B.name
|
|
263
|
+
});
|
|
264
|
+
return x.concat($);
|
|
265
|
+
});
|
|
266
|
+
},
|
|
267
|
+
[j, p, u, g]
|
|
268
|
+
), z = a ? (r) => s.attachments.add(r) : U, R = a ? (r) => s.attachments.remove(r) : (r) => C((v) => {
|
|
269
|
+
const m = v.find((c) => c.id === r);
|
|
270
|
+
return m != null && m.url && URL.revokeObjectURL(m.url), v.filter((c) => c.id !== r);
|
|
271
|
+
}), O = a ? () => s.attachments.clear() : () => C((r) => {
|
|
272
|
+
for (const v of r)
|
|
273
|
+
v.url && URL.revokeObjectURL(v.url);
|
|
274
|
+
return [];
|
|
275
|
+
}), q = a ? () => s.attachments.openFileDialog() : T;
|
|
276
|
+
A(() => {
|
|
277
|
+
a && s.__registerFileInput(d, () => {
|
|
278
|
+
var r;
|
|
279
|
+
return (r = d.current) == null ? void 0 : r.click();
|
|
280
|
+
});
|
|
281
|
+
}, [a, s]), A(() => {
|
|
282
|
+
i && d.current && h.length === 0 && (d.current.value = "");
|
|
283
|
+
}, [h, i]), A(() => {
|
|
284
|
+
const r = I.current;
|
|
285
|
+
if (!r) return;
|
|
286
|
+
const v = (c) => {
|
|
287
|
+
var b, x;
|
|
288
|
+
(x = (b = c.dataTransfer) == null ? void 0 : b.types) != null && x.includes("Files") && c.preventDefault();
|
|
289
|
+
}, m = (c) => {
|
|
290
|
+
var b, x, L;
|
|
291
|
+
(x = (b = c.dataTransfer) == null ? void 0 : b.types) != null && x.includes("Files") && c.preventDefault(), (L = c.dataTransfer) != null && L.files && c.dataTransfer.files.length > 0 && z(c.dataTransfer.files);
|
|
292
|
+
};
|
|
293
|
+
return r.addEventListener("dragover", v), r.addEventListener("drop", m), () => {
|
|
294
|
+
r.removeEventListener("dragover", v), r.removeEventListener("drop", m);
|
|
295
|
+
};
|
|
296
|
+
}, [z]), A(() => {
|
|
297
|
+
if (!l) return;
|
|
298
|
+
const r = (m) => {
|
|
299
|
+
var c, b;
|
|
300
|
+
(b = (c = m.dataTransfer) == null ? void 0 : c.types) != null && b.includes("Files") && m.preventDefault();
|
|
301
|
+
}, v = (m) => {
|
|
302
|
+
var c, b, x;
|
|
303
|
+
(b = (c = m.dataTransfer) == null ? void 0 : c.types) != null && b.includes("Files") && m.preventDefault(), (x = m.dataTransfer) != null && x.files && m.dataTransfer.files.length > 0 && z(m.dataTransfer.files);
|
|
304
|
+
};
|
|
305
|
+
return document.addEventListener("dragover", r), document.addEventListener("drop", v), () => {
|
|
306
|
+
document.removeEventListener("dragover", r), document.removeEventListener("drop", v);
|
|
307
|
+
};
|
|
308
|
+
}, [z, l]), A(
|
|
309
|
+
() => () => {
|
|
310
|
+
if (!a)
|
|
311
|
+
for (const r of h)
|
|
312
|
+
r.url && URL.revokeObjectURL(r.url);
|
|
313
|
+
},
|
|
314
|
+
[a, h]
|
|
315
|
+
);
|
|
316
|
+
const ne = (r) => {
|
|
317
|
+
r.currentTarget.files && z(r.currentTarget.files);
|
|
318
|
+
}, se = async (r) => {
|
|
319
|
+
const m = await (await fetch(r)).blob();
|
|
320
|
+
return new Promise((c, b) => {
|
|
321
|
+
const x = new FileReader();
|
|
322
|
+
x.onloadend = () => c(x.result), x.onerror = b, x.readAsDataURL(m);
|
|
323
|
+
});
|
|
324
|
+
}, re = Fe(
|
|
325
|
+
() => ({
|
|
326
|
+
files: h.map((r) => ({ ...r, id: r.id })),
|
|
327
|
+
add: z,
|
|
328
|
+
remove: R,
|
|
329
|
+
clear: O,
|
|
330
|
+
openFileDialog: q,
|
|
331
|
+
fileInputRef: d
|
|
332
|
+
}),
|
|
333
|
+
[h, z, R, O, q]
|
|
334
|
+
), ae = (r) => {
|
|
335
|
+
r.preventDefault();
|
|
336
|
+
const v = r.currentTarget, m = a ? s.textInput.value : new FormData(v).get("message") || "";
|
|
337
|
+
a || v.reset(), Promise.all(
|
|
338
|
+
h.map(async ({ ...c }) => c.url && c.url.startsWith("blob:") ? {
|
|
339
|
+
...c,
|
|
340
|
+
url: await se(c.url)
|
|
341
|
+
} : c)
|
|
342
|
+
).then((c) => {
|
|
343
|
+
try {
|
|
344
|
+
const b = f({ text: m, files: c }, r);
|
|
345
|
+
b instanceof Promise ? b.then(() => {
|
|
346
|
+
O(), a && s.textInput.clear();
|
|
347
|
+
}).catch(() => {
|
|
348
|
+
}) : (O(), a && s.textInput.clear());
|
|
349
|
+
} catch {
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}, K = /* @__PURE__ */ w(ie, { children: [
|
|
353
|
+
/* @__PURE__ */ e("span", { "aria-hidden": "true", className: "hidden", ref: k }),
|
|
354
|
+
/* @__PURE__ */ e(
|
|
355
|
+
"input",
|
|
356
|
+
{
|
|
357
|
+
accept: n,
|
|
358
|
+
"aria-label": "Upload files",
|
|
359
|
+
className: "hidden",
|
|
360
|
+
multiple: o,
|
|
361
|
+
onChange: ne,
|
|
362
|
+
ref: d,
|
|
363
|
+
title: "Upload files",
|
|
364
|
+
type: "file"
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
/* @__PURE__ */ e("form", { className: N("w-full", t), onSubmit: ae, ...D, children: /* @__PURE__ */ e(Ee, { className: "overflow-hidden", children: y }) })
|
|
368
|
+
] });
|
|
369
|
+
return a ? K : /* @__PURE__ */ e(te.Provider, { value: re, children: K });
|
|
370
|
+
}, tt = ({
|
|
371
|
+
onChange: t,
|
|
372
|
+
className: n,
|
|
373
|
+
placeholder: o = "What would you like to know?",
|
|
374
|
+
...l
|
|
375
|
+
}) => {
|
|
376
|
+
const i = ee(), p = G(), [u, g] = P(!1), f = (s) => {
|
|
377
|
+
if (s.key === "Enter") {
|
|
378
|
+
if (u || s.nativeEvent.isComposing || s.shiftKey)
|
|
379
|
+
return;
|
|
380
|
+
s.preventDefault();
|
|
381
|
+
const a = s.currentTarget.form, d = a == null ? void 0 : a.querySelector('button[type="submit"]');
|
|
382
|
+
if (d != null && d.disabled)
|
|
383
|
+
return;
|
|
384
|
+
a == null || a.requestSubmit();
|
|
385
|
+
}
|
|
386
|
+
if (s.key === "Backspace" && s.currentTarget.value === "" && p.files.length > 0) {
|
|
387
|
+
s.preventDefault();
|
|
388
|
+
const a = p.files.at(-1);
|
|
389
|
+
a && p.remove(a.id);
|
|
390
|
+
}
|
|
391
|
+
}, y = (s) => {
|
|
392
|
+
var k;
|
|
393
|
+
const a = (k = s.clipboardData) == null ? void 0 : k.items;
|
|
394
|
+
if (!a)
|
|
395
|
+
return;
|
|
396
|
+
const d = [];
|
|
397
|
+
for (const I of a)
|
|
398
|
+
if (I.kind === "file") {
|
|
399
|
+
const S = I.getAsFile();
|
|
400
|
+
S && d.push(S);
|
|
401
|
+
}
|
|
402
|
+
d.length > 0 && (s.preventDefault(), p.add(d));
|
|
403
|
+
}, D = i ? {
|
|
404
|
+
value: i.textInput.value,
|
|
405
|
+
onChange: (s) => {
|
|
406
|
+
i.textInput.setInput(s.currentTarget.value), t == null || t(s);
|
|
407
|
+
}
|
|
408
|
+
} : {
|
|
409
|
+
onChange: t
|
|
410
|
+
};
|
|
411
|
+
return /* @__PURE__ */ e(
|
|
412
|
+
Ke,
|
|
413
|
+
{
|
|
414
|
+
className: N("field-sizing-content max-h-48 min-h-16", n),
|
|
415
|
+
name: "message",
|
|
416
|
+
onCompositionEnd: () => g(!1),
|
|
417
|
+
onCompositionStart: () => g(!0),
|
|
418
|
+
onKeyDown: f,
|
|
419
|
+
onPaste: y,
|
|
420
|
+
placeholder: o,
|
|
421
|
+
...l,
|
|
422
|
+
...D
|
|
423
|
+
}
|
|
424
|
+
);
|
|
425
|
+
}, nt = ({ className: t, ...n }) => /* @__PURE__ */ e(Q, { align: "block-end", className: N("order-first flex-wrap gap-1", t), ...n }), st = ({ className: t, ...n }) => /* @__PURE__ */ e(Q, { align: "block-end", className: N("justify-between gap-1", t), ...n }), rt = ({ className: t, ...n }) => /* @__PURE__ */ e("div", { className: N("flex items-center gap-1", t), ...n }), H = ({ variant: t = "ghost", className: n, size: o, ...l }) => {
|
|
426
|
+
const i = o ?? (Be.count(l.children) > 1 ? "sm" : "icon-sm");
|
|
427
|
+
return /* @__PURE__ */ e(Z, { className: N(n), size: i, type: "button", variant: t, ...l });
|
|
428
|
+
}, at = (t) => /* @__PURE__ */ e(ue, { ...t }), ot = ({ className: t, children: n, ...o }) => /* @__PURE__ */ e(de, { asChild: !0, children: /* @__PURE__ */ e(H, { className: t, ...o, children: n ?? /* @__PURE__ */ e(De, { className: "size-4" }) }) }), it = ({ className: t, ...n }) => /* @__PURE__ */ e(pe, { align: "start", className: N(t), ...n }), lt = ({
|
|
429
|
+
className: t,
|
|
430
|
+
variant: n = "default",
|
|
431
|
+
size: o = "icon-sm",
|
|
432
|
+
status: l,
|
|
433
|
+
children: i,
|
|
434
|
+
...p
|
|
435
|
+
}) => {
|
|
436
|
+
let u = /* @__PURE__ */ e(Te, { className: "size-4" });
|
|
437
|
+
return l === "submitted" ? u = /* @__PURE__ */ e(Ae, { className: "size-4 animate-spin" }) : l === "streaming" ? u = /* @__PURE__ */ e(Ce, { className: "size-4" }) : l === "error" && (u = /* @__PURE__ */ e(Y, { className: "size-4" })), /* @__PURE__ */ e(
|
|
438
|
+
Z,
|
|
439
|
+
{
|
|
440
|
+
"aria-label": "Submit",
|
|
441
|
+
className: N(t),
|
|
442
|
+
size: o,
|
|
443
|
+
type: "submit",
|
|
444
|
+
variant: n,
|
|
445
|
+
...p,
|
|
446
|
+
children: i ?? u
|
|
447
|
+
}
|
|
448
|
+
);
|
|
449
|
+
}, ct = ({
|
|
450
|
+
className: t,
|
|
451
|
+
textareaRef: n,
|
|
452
|
+
onTranscriptionChange: o,
|
|
453
|
+
...l
|
|
454
|
+
}) => {
|
|
455
|
+
const [i, p] = P(!1), [u, g] = P(null), f = M(null);
|
|
456
|
+
A(() => {
|
|
457
|
+
if (typeof window < "u" && ("SpeechRecognition" in window || "webkitSpeechRecognition" in window)) {
|
|
458
|
+
const D = window.SpeechRecognition || window.webkitSpeechRecognition, s = new D();
|
|
459
|
+
s.continuous = !0, s.interimResults = !0, s.lang = "en-US", s.onstart = () => {
|
|
460
|
+
p(!0);
|
|
461
|
+
}, s.onend = () => {
|
|
462
|
+
p(!1);
|
|
463
|
+
}, s.onresult = (a) => {
|
|
464
|
+
var k;
|
|
465
|
+
let d = "";
|
|
466
|
+
for (let I = a.resultIndex; I < a.results.length; I++) {
|
|
467
|
+
const S = a.results[I];
|
|
468
|
+
S.isFinal && (d += ((k = S[0]) == null ? void 0 : k.transcript) ?? "");
|
|
469
|
+
}
|
|
470
|
+
if (d && (n != null && n.current)) {
|
|
471
|
+
const I = n.current, S = I.value, C = S + (S ? " " : "") + d;
|
|
472
|
+
I.value = C, I.dispatchEvent(new Event("input", { bubbles: !0 })), o == null || o(C);
|
|
473
|
+
}
|
|
474
|
+
}, s.onerror = (a) => {
|
|
475
|
+
console.error("Speech recognition error:", a.error), p(!1);
|
|
476
|
+
}, f.current = s, g(s);
|
|
477
|
+
}
|
|
478
|
+
return () => {
|
|
479
|
+
f.current && f.current.stop();
|
|
480
|
+
};
|
|
481
|
+
}, [n, o]);
|
|
482
|
+
const y = F(() => {
|
|
483
|
+
u && (i ? u.stop() : u.start());
|
|
484
|
+
}, [u, i]);
|
|
485
|
+
return /* @__PURE__ */ e(
|
|
486
|
+
H,
|
|
487
|
+
{
|
|
488
|
+
className: N(
|
|
489
|
+
"relative transition-all duration-200",
|
|
490
|
+
i && "animate-pulse bg-accent text-accent-foreground",
|
|
491
|
+
t
|
|
492
|
+
),
|
|
493
|
+
disabled: !u,
|
|
494
|
+
onClick: y,
|
|
495
|
+
...l,
|
|
496
|
+
children: /* @__PURE__ */ e(Pe, { className: "size-4" })
|
|
497
|
+
}
|
|
498
|
+
);
|
|
499
|
+
}, ut = ({ openDelay: t = 0, closeDelay: n = 0, ...o }) => /* @__PURE__ */ e(fe, { closeDelay: n, openDelay: t, ...o }), dt = ({ align: t = "start", ...n }) => /* @__PURE__ */ e(he, { align: t, ...n }), pt = (t) => /* @__PURE__ */ e(ge, { ...t }), mt = (t) => /* @__PURE__ */ e(ve, { ...t }), ft = ({
|
|
500
|
+
className: t,
|
|
501
|
+
children: n,
|
|
502
|
+
title: o = "Model Selector",
|
|
503
|
+
...l
|
|
504
|
+
}) => /* @__PURE__ */ w(be, { className: N("p-0", t), ...l, children: [
|
|
505
|
+
/* @__PURE__ */ e(xe, { className: "sr-only", children: o }),
|
|
506
|
+
/* @__PURE__ */ e(we, { className: "**:data-[slot=command-input-wrapper]:h-auto", children: n })
|
|
507
|
+
] }), ht = ({ className: t, ...n }) => /* @__PURE__ */ e(Ne, { className: N("h-auto py-3.5", t), ...n }), gt = (t) => /* @__PURE__ */ e(Ie, { ...t }), vt = (t) => /* @__PURE__ */ e(ye, { ...t }), bt = (t) => /* @__PURE__ */ e(Se, { ...t }), xt = ({ provider: t, className: n, ...o }) => /* @__PURE__ */ e(
|
|
508
|
+
"img",
|
|
509
|
+
{
|
|
510
|
+
...o,
|
|
511
|
+
alt: `${t} logo`,
|
|
512
|
+
className: N("size-3 dark:invert", n),
|
|
513
|
+
height: 12,
|
|
514
|
+
src: `https://models.dev/logos/${t}.svg`,
|
|
515
|
+
width: 12
|
|
516
|
+
}
|
|
517
|
+
), wt = ({ className: t, ...n }) => /* @__PURE__ */ e("span", { className: N("flex-1 truncate text-left", t), ...n }), Nt = ({
|
|
518
|
+
selectedModel: t,
|
|
519
|
+
onModelChange: n,
|
|
520
|
+
disabled: o = !1
|
|
521
|
+
}) => {
|
|
522
|
+
const [l, i] = P(!1), [p, u] = P(""), g = Ve(t) || _(), y = We.filter(
|
|
523
|
+
(s) => s.name.toLowerCase().includes(p.toLowerCase()) || s.provider.toLowerCase().includes(p.toLowerCase())
|
|
524
|
+
).reduce(
|
|
525
|
+
(s, a) => (s[a.provider] || (s[a.provider] = []), s[a.provider].push(a), s),
|
|
526
|
+
{}
|
|
527
|
+
), D = (s) => {
|
|
528
|
+
n(s), i(!1), u("");
|
|
529
|
+
};
|
|
530
|
+
return /* @__PURE__ */ w(pt, { open: l, onOpenChange: i, children: [
|
|
531
|
+
/* @__PURE__ */ e(mt, { asChild: !0, children: /* @__PURE__ */ w(V, { variant: "outline", size: "sm", disabled: o, className: "h-8 gap-1 px-2 text-xs", children: [
|
|
532
|
+
/* @__PURE__ */ e(Le, { size: 14 }),
|
|
533
|
+
/* @__PURE__ */ e("span", { className: "max-w-20 truncate", children: g.name })
|
|
534
|
+
] }) }),
|
|
535
|
+
/* @__PURE__ */ w(ft, { className: "w-96 p-0", children: [
|
|
536
|
+
/* @__PURE__ */ e(ht, { placeholder: "Search models...", value: p, onValueChange: u }),
|
|
537
|
+
/* @__PURE__ */ e(gt, { children: Object.entries(y).map(([s, a]) => /* @__PURE__ */ e(vt, { heading: s.charAt(0).toUpperCase() + s.slice(1), children: a.map((d) => /* @__PURE__ */ w(
|
|
538
|
+
bt,
|
|
539
|
+
{
|
|
540
|
+
value: d.id,
|
|
541
|
+
onSelect: () => D(d.id),
|
|
542
|
+
className: "flex cursor-pointer items-center gap-2 p-2",
|
|
543
|
+
children: [
|
|
544
|
+
/* @__PURE__ */ e(xt, { provider: d.provider }),
|
|
545
|
+
/* @__PURE__ */ w("div", { className: "flex flex-1 flex-col", children: [
|
|
546
|
+
/* @__PURE__ */ e(wt, { children: d.name }),
|
|
547
|
+
/* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground", children: d.description })
|
|
548
|
+
] }),
|
|
549
|
+
t === d.id && /* @__PURE__ */ e("div", { className: "h-2 w-2 rounded-full bg-blue-500" })
|
|
550
|
+
]
|
|
551
|
+
},
|
|
552
|
+
d.id
|
|
553
|
+
)) }, s)) })
|
|
554
|
+
] })
|
|
555
|
+
] });
|
|
556
|
+
}, X = "chai-ai-selected-model", At = ({
|
|
557
|
+
input: t,
|
|
558
|
+
setInput: n,
|
|
559
|
+
onSend: o,
|
|
560
|
+
onStop: l,
|
|
561
|
+
isLoading: i,
|
|
562
|
+
disabled: p,
|
|
563
|
+
selectedLang: u,
|
|
564
|
+
selectedModel: g = _().id,
|
|
565
|
+
onModelChange: f
|
|
566
|
+
}) => {
|
|
567
|
+
const { t: y } = _e(), [D, s] = P(g), [a, d] = P(null), k = M(null), [I, S] = P(!1);
|
|
568
|
+
return A(() => {
|
|
569
|
+
if (!u) {
|
|
570
|
+
const h = localStorage.getItem(X);
|
|
571
|
+
if (h)
|
|
572
|
+
s(h), f == null || f(h);
|
|
573
|
+
else {
|
|
574
|
+
const T = _().id;
|
|
575
|
+
s(T), f == null || f(T);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}, [u, f]), /* @__PURE__ */ e("div", { className: "relative", children: /* @__PURE__ */ e("div", { className: "border-gray-20 rounded-lg border", children: /* @__PURE__ */ w(et, { onSubmit: (h) => {
|
|
579
|
+
var U;
|
|
580
|
+
const T = h.files.find((z) => {
|
|
581
|
+
var R;
|
|
582
|
+
return (R = z.mediaType) == null ? void 0 : R.startsWith("image/");
|
|
583
|
+
}), j = (T == null ? void 0 : T.url) || a;
|
|
584
|
+
o((U = h.text) == null ? void 0 : U.trim(), void 0, j, D), d(null);
|
|
585
|
+
}, accept: "image/*", className: "flex h-auto w-full flex-col", children: [
|
|
586
|
+
/* @__PURE__ */ e(nt, { className: "p-0", children: /* @__PURE__ */ e(Qe, { className: "pb-0", children: (h) => /* @__PURE__ */ e(Je, { className: "text-xs", data: h }) }) }),
|
|
587
|
+
/* @__PURE__ */ e(
|
|
588
|
+
tt,
|
|
589
|
+
{
|
|
590
|
+
ref: k,
|
|
591
|
+
value: t,
|
|
592
|
+
onChange: (h) => n(h.target.value),
|
|
593
|
+
placeholder: y(u ? "Ask to update content" : "Ask me anything..."),
|
|
594
|
+
disabled: i,
|
|
595
|
+
className: "max-h-[200px] min-h-[60px] w-full",
|
|
596
|
+
rows: 3
|
|
597
|
+
}
|
|
598
|
+
),
|
|
599
|
+
/* @__PURE__ */ w(st, { children: [
|
|
600
|
+
u ? /* @__PURE__ */ e("div", {}) : /* @__PURE__ */ w(rt, { children: [
|
|
601
|
+
/* @__PURE__ */ w(at, { children: [
|
|
602
|
+
/* @__PURE__ */ e(ot, { disabled: i, children: /* @__PURE__ */ e(Re, { size: 16 }) }),
|
|
603
|
+
/* @__PURE__ */ e(it, { children: /* @__PURE__ */ e(Ze, {}) })
|
|
604
|
+
] }),
|
|
605
|
+
/* @__PURE__ */ e(
|
|
606
|
+
ct,
|
|
607
|
+
{
|
|
608
|
+
textareaRef: k,
|
|
609
|
+
onTranscriptionChange: n,
|
|
610
|
+
disabled: i
|
|
611
|
+
}
|
|
612
|
+
),
|
|
613
|
+
/* @__PURE__ */ e(
|
|
614
|
+
Nt,
|
|
615
|
+
{
|
|
616
|
+
selectedModel: D,
|
|
617
|
+
onModelChange: (h) => {
|
|
618
|
+
s(h), f == null || f(h), localStorage.setItem(X, h);
|
|
619
|
+
},
|
|
620
|
+
disabled: i
|
|
621
|
+
}
|
|
622
|
+
),
|
|
623
|
+
/* @__PURE__ */ w(
|
|
624
|
+
H,
|
|
625
|
+
{
|
|
626
|
+
className: "hidden",
|
|
627
|
+
size: "sm",
|
|
628
|
+
onClick: () => S(!I),
|
|
629
|
+
variant: I ? "default" : "ghost",
|
|
630
|
+
children: [
|
|
631
|
+
/* @__PURE__ */ e(Me, { size: 16 }),
|
|
632
|
+
/* @__PURE__ */ e("span", { children: "Search" })
|
|
633
|
+
]
|
|
634
|
+
}
|
|
635
|
+
)
|
|
636
|
+
] }),
|
|
637
|
+
i ? /* @__PURE__ */ w(
|
|
638
|
+
"button",
|
|
639
|
+
{
|
|
640
|
+
onClick: l,
|
|
641
|
+
className: "z-50 flex items-center gap-x-1 rounded-md bg-red-500 p-1.5 text-white transition-colors hover:bg-red-600",
|
|
642
|
+
title: y("Stop generation"),
|
|
643
|
+
children: [
|
|
644
|
+
/* @__PURE__ */ e(je, { size: 16 }),
|
|
645
|
+
" ",
|
|
646
|
+
/* @__PURE__ */ e("span", { className: "text-xs", children: y("Stop") })
|
|
647
|
+
]
|
|
648
|
+
}
|
|
649
|
+
) : /* @__PURE__ */ e(lt, { disabled: !t.trim() || p, children: /* @__PURE__ */ e(Ue, { size: 16 }) })
|
|
650
|
+
] })
|
|
651
|
+
] }) }) });
|
|
652
|
+
};
|
|
653
|
+
export {
|
|
654
|
+
At as default
|
|
655
|
+
};
|