@chaibuilder/sdk 4.0.0-beta.49 → 4.0.0-beta.51
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 +35 -52
- package/dist/{2SSKDMRQ-CjvuNdPo.cjs → 2SSKDMRQ-BSYe_xPq.cjs} +1 -1
- package/dist/{2SSKDMRQ-Dvf9zadl.js → 2SSKDMRQ-Dv-C_YAA.js} +3 -3
- package/dist/{AP7HFJJL-DYFttFoI.cjs → AP7HFJJL-BJolKJBt.cjs} +1 -1
- package/dist/{AP7HFJJL-q4dJdyFs.js → AP7HFJJL-DhdVstVC.js} +1 -1
- package/dist/{IconPicker-Bf163F7t.js → IconPicker-BBkl0T8b.js} +13 -13
- package/dist/{IconPicker-JWhYq2Gp.cjs → IconPicker-C0WWlb8t.cjs} +1 -1
- package/dist/{WDYDFRGG-O9GIrtX0.js → WDYDFRGG-CJs2MxSq.js} +4 -4
- package/dist/{WDYDFRGG-BEksfGMC.cjs → WDYDFRGG-DRt6Zg7Q.cjs} +1 -1
- package/dist/{actions-registery-BHbZHkE3.cjs → actions-registery-CLL3KrNv.cjs} +2 -2
- package/dist/{actions-registery-gJb_wq2F.js → actions-registery-CrGIlqUX.js} +88 -88
- package/dist/actions.cjs +1 -1
- package/dist/actions.js +2 -2
- package/dist/{add-new-language-page-BfUp5Ua2.cjs → add-new-language-page-ByMSfRcN.cjs} +1 -1
- package/dist/{add-new-language-page-CRR93tLq.js → add-new-language-page-DtVoDNfI.js} +35 -35
- package/dist/{add-new-page-B8NGK6WS.cjs → add-new-page-CnuChfJz.cjs} +1 -1
- package/dist/add-new-page-DanzzvYo.js +31 -0
- package/dist/{ai-panel-default-lang-BXYQye3N.js → ai-panel-default-lang-BaPz2d_6.js} +35 -35
- package/dist/{ai-panel-default-lang-VhgmHFoQ.cjs → ai-panel-default-lang-CoIQSz_Y.cjs} +2 -2
- package/dist/{ai-panel-other-lang-DaCf-cq4.js → ai-panel-other-lang--i-5z4e2.js} +22 -22
- package/dist/{ai-panel-other-lang-Ds0EXeUC.cjs → ai-panel-other-lang-ChlMVodg.cjs} +1 -1
- package/dist/{ai-prompt-input-7iWk72w5.js → ai-prompt-input-BQi0VDJC.js} +77 -77
- package/dist/{ai-prompt-input-nZ5_Dm7X.cjs → ai-prompt-input-BT5426AB.cjs} +1 -1
- package/dist/{ai-translation-prompt-1OUs1P7n.js → ai-translation-prompt-BN78s33t.js} +8 -8
- package/dist/{ai-translation-prompt-B16cK-1Q.cjs → ai-translation-prompt-BQPaekp3.cjs} +1 -1
- package/dist/{apply-binding-CBSjMYSk.cjs → apply-binding-Cjh1kqMO.cjs} +1 -1
- package/dist/{apply-binding-vAuN-TGV.js → apply-binding-v_W4uR3U.js} +28 -28
- package/dist/{plugin-BSjgGgwo.js → chai-theme-helpers-BEf2rwE4.js} +83 -83
- package/dist/chai-theme-helpers-q3nwoNht.cjs +22 -0
- package/dist/{change-password-modal-D5eXjiYq.cjs → change-password-modal-DHUrrKw7.cjs} +1 -1
- package/dist/{change-password-modal-CdvJR1Ln.js → change-password-modal-pEp-nMNb.js} +30 -30
- package/dist/{code-display-DdWcOQ_i.js → code-display-BaLKScgW.js} +5 -5
- package/dist/{code-display-BR-gij5j.cjs → code-display-i7jb2kmw.cjs} +1 -1
- package/dist/{code-editor-CyLjDiEp.js → code-editor-CRoniyP0.js} +12 -12
- package/dist/{code-editor-SWbfFj1E.cjs → code-editor-gwFRjQ2_.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +0 -5
- package/dist/core.js +49 -49
- package/dist/{css-import-modal-Be47CBJn.js → css-import-modal-B3qxX9Iv.js} +14 -14
- package/dist/{css-import-modal-Bdwgd05S.cjs → css-import-modal-nAB5FSwn.cjs} +2 -2
- package/dist/{delete-page-C99K2qzS.js → delete-page-DbawNFf7.js} +13 -13
- package/dist/{delete-page-DLohaU-U.cjs → delete-page-YP1HEAoD.cjs} +1 -1
- package/dist/{digital-asset-manager-BZMb6sC7.js → digital-asset-manager-DTD5mf24.js} +388 -357
- package/dist/digital-asset-manager-kJnuMqpw.cjs +1 -0
- package/dist/{duplicate-page-D5Gtvqdv.cjs → duplicate-page-CxqW_EO7.cjs} +1 -1
- package/dist/{duplicate-page-CDc2X0eW.js → duplicate-page-DnRb1y6K.js} +19 -19
- package/dist/{dynamic-page-selector-DZHhX008.cjs → dynamic-page-selector-2EqJhUrB.cjs} +1 -1
- package/dist/{dynamic-page-selector-DvNBXo6o.js → dynamic-page-selector-D6VLDIN9.js} +17 -17
- package/dist/{get-chai-builder-tailwind-config-7CxFxEYL.cjs → get-chai-builder-tailwind-config-DNp8Vhme.cjs} +1 -1
- package/dist/{get-chai-builder-tailwind-config-DC4sDOYK.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +3 -3
- package/dist/{get-chai-builder-theme-BpuwSLeS.js → get-chai-builder-theme-DLpviqPJ.js} +1 -1
- package/dist/get-chai-builder-theme-Du4ARJlw.cjs +1 -0
- package/dist/{image-editor-DwhTYkVR.cjs → image-editor-BQcOGsli.cjs} +1 -1
- package/dist/{image-editor-BBvvi9Vm.js → image-editor-CMf731xL.js} +15 -15
- package/dist/index-BYrRPW_c.cjs +5 -0
- package/dist/index-D-r_K4yA.cjs +160 -0
- package/dist/{index-OuHV9Ann.js → index-DPV6NiJ-.js} +5894 -6049
- package/dist/index-DqzFD1CG.js +4861 -0
- package/dist/{mark-as-template-CP_F9ZQ4.js → mark-as-template-D7jqSCXw.js} +28 -28
- package/dist/{mark-as-template-B9yLcasI.cjs → mark-as-template-DyB56HzI.cjs} +1 -1
- package/dist/{nested-path-selector-content-DmtCI3q9.js → nested-path-selector-content-dwSikrsV.js} +2 -2
- package/dist/{nested-path-selector-content-aTdu-o0e.cjs → nested-path-selector-content-g9_Tq_sR.cjs} +1 -1
- package/dist/no-language-page-content-BRITuyfN.js +43 -0
- package/dist/{no-language-page-content-C-MCdPXt.cjs → no-language-page-content-ZvMNVY-Y.cjs} +1 -1
- package/dist/{no-language-page-dialog-D4QIAHnE.cjs → no-language-page-dialog-Cndq8xRP.cjs} +1 -1
- package/dist/no-language-page-dialog-D7L9nVb9.js +10 -0
- package/dist/page-creator-BAIbU14q.js +652 -0
- package/dist/page-creator-qL3-M8g3.cjs +1 -0
- package/dist/{page-manager-new-ah6QYar2.cjs → page-manager-new-By3eGO3i.cjs} +1 -1
- package/dist/{page-manager-new-ttsrxdW9.js → page-manager-new-YRG89y4f.js} +63 -63
- package/dist/page-manager-search-and-filter-BbdgOU9V.cjs +1 -0
- package/dist/page-manager-search-and-filter-Cllju4CV.js +184 -0
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +0 -15
- package/dist/pages.js +20 -21
- package/dist/{publish-pages-content-KZVMHT6V.js → publish-pages-content-CG5LBUnY.js} +48 -48
- package/dist/{publish-pages-content-BrajJUcP.cjs → publish-pages-content-DxMiBxNU.cjs} +1 -1
- package/dist/{register-chai-top-bar-DyW9GPzV.cjs → register-chai-top-bar-CCssW5dL.cjs} +1 -1
- package/dist/{register-chai-top-bar-D6GjnauV.js → register-chai-top-bar-DWmJ2efT.js} +11 -11
- package/dist/render.cjs +1 -1
- package/dist/render.js +54 -54
- package/dist/{rte-widget-modal-CiTwsXTr.cjs → rte-widget-modal-CsTqFJc_.cjs} +1 -1
- package/dist/{rte-widget-modal-IU8JzPuZ.js → rte-widget-modal-DoeTMRtX.js} +2 -2
- package/dist/runtime-client.cjs +1 -1
- package/dist/runtime-client.js +1 -1
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +1 -1
- package/dist/sdk.css +1 -1
- package/dist/{selected-block-display-CidmQ-wz.js → selected-block-display-Ck1kkNEi.js} +17 -28
- package/dist/{selected-block-display-CAFEOrLV.cjs → selected-block-display-DSow6N4b.cjs} +1 -1
- package/dist/seo-panel---mYZmLD.js +559 -0
- package/dist/seo-panel-mfX63fua.cjs +1 -0
- package/dist/{shared-json-ld-uvMmwCYp.js → shared-json-ld-B3I_RLE2.js} +46 -46
- package/dist/{shared-json-ld-CMH-eRUq.cjs → shared-json-ld-CGgwUOlW.cjs} +1 -1
- package/dist/{slug-input-DLWTMTsO.js → slug-input-DQ4t3-Tt.js} +5 -5
- package/dist/{slug-input-CiHC5l3r.cjs → slug-input-DaNbl597.cjs} +1 -1
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.js +2 -2
- package/dist/types.d.ts +0 -96
- package/dist/{unmark-as-template-F7TdgWjI.cjs → unmark-as-template-CZ65AE4v.cjs} +1 -1
- package/dist/{unmark-as-template-C5ovsEBP.js → unmark-as-template-DvmoTbVu.js} +11 -11
- package/dist/unpublish-page-3--vO5b0.js +28 -0
- package/dist/{unpublish-page-CUr8Xub6.cjs → unpublish-page-B46TiWlU.cjs} +1 -1
- package/dist/{unpublished-partials-modal-BhNAub_z.js → unpublished-partials-modal-DVMz3q83.js} +18 -15
- package/dist/{unpublished-partials-modal-Cv5R9-hi.cjs → unpublished-partials-modal-U5lKBOSR.cjs} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +2 -2
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +2 -2
- package/dist/{web-preview-D9pXonAv.js → web-preview-D5o5XQo0.js} +2 -2
- package/dist/{web-preview-CuMYekVJ.cjs → web-preview-Da3RhcjQ.cjs} +1 -1
- package/package.json +1 -1
- package/dist/active-in-another-tab-B4Ur0JP7.js +0 -35
- package/dist/active-in-another-tab-BPdx4lWh.cjs +0 -1
- package/dist/add-new-page-Ppy5-y5j.js +0 -31
- package/dist/continue-editing-in-this-client-BrSvK-Ay.js +0 -25
- package/dist/continue-editing-in-this-client-Cmi-GkYZ.cjs +0 -1
- package/dist/design-token-usage-D1lWCJ3L.js +0 -114
- package/dist/design-token-usage-eY2wQ0l3.cjs +0 -1
- package/dist/digital-asset-manager-Z5aJxkq0.cjs +0 -1
- package/dist/get-chai-builder-theme-B5RkBTsB.cjs +0 -1
- package/dist/image-compression-DPFITwOL.js +0 -37
- package/dist/image-compression-UaU7Bwqe.cjs +0 -1
- package/dist/index-BVwFJWDq.cjs +0 -5
- package/dist/index-DCJDQs1a.cjs +0 -160
- package/dist/index-LBTm1Jmk.js +0 -5199
- package/dist/json-diff-viewer-Cb1CmRqP.cjs +0 -8
- package/dist/json-diff-viewer-DG6qMOBS.js +0 -261
- package/dist/lang-panel-B3USOxGq.js +0 -216
- package/dist/lang-panel-DxoJ0v4y.cjs +0 -1
- package/dist/manage-design-tokens-6YGIctip.js +0 -446
- package/dist/manage-design-tokens-modal-BSSCXH8Y.cjs +0 -1
- package/dist/manage-design-tokens-modal-CzsnN49F.js +0 -161
- package/dist/manage-design-tokens-udLBvkHA.cjs +0 -1
- package/dist/no-language-page-content-D8t5dfgh.js +0 -43
- package/dist/no-language-page-dialog-C_fHI2zI.js +0 -10
- package/dist/page-creator-Cz_ah-qE.cjs +0 -1
- package/dist/page-creator-DKEkuGCO.js +0 -796
- package/dist/page-lock-CwZKJ4IE.js +0 -30
- package/dist/page-lock-DdCvtA-I.cjs +0 -1
- package/dist/page-locked-dialog-CrTDBoC4.cjs +0 -1
- package/dist/page-locked-dialog-DqLlooUz.js +0 -136
- package/dist/page-manager-search-and-filter-D7AupT6_.cjs +0 -1
- package/dist/page-manager-search-and-filter-bsqZ6wnI.js +0 -210
- package/dist/page-revisions-content-B6hsIla7.cjs +0 -1
- package/dist/page-revisions-content-C5O8_Fms.js +0 -459
- package/dist/plugin-DHpuZZXz.cjs +0 -22
- package/dist/save-to-lib-DMnv7ENo.js +0 -429
- package/dist/save-to-lib-Dc700Aop.cjs +0 -1
- package/dist/seo-panel-Br8gxDxu.js +0 -789
- package/dist/seo-panel-CMY-adM-.cjs +0 -2
- package/dist/take-over-request-IRLgF1dG.cjs +0 -1
- package/dist/take-over-request-KdR1_h_K.js +0 -64
- package/dist/translation-warning-modal-CLZ9tC1F.cjs +0 -1
- package/dist/translation-warning-modal-CzNt6LDO.js +0 -27
- package/dist/unpublish-page-0fR1o0b7.js +0 -28
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as e, jsxs as N, Fragment as ie } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
function
|
|
2
|
+
import { PaperclipIcon as le, XIcon as X, PlusIcon as ce, ImageIcon as ue, MicIcon as de, CornerDownLeftIcon as me, Loader2Icon as pe, SquareIcon as fe, Cpu as he, Paperclip as ge, GlobeIcon as ve, Square as be, Send as xe } from "lucide-react";
|
|
3
|
+
import { useContext as W, useRef as F, useEffect as A, useState as L, useCallback as O, useMemo as we, createContext as _, Fragment as Ne, startTransition as ye, Children as Ie } from "react";
|
|
4
|
+
import { useTranslation as Se } from "react-i18next";
|
|
5
|
+
import { nanoid as ke } from "nanoid";
|
|
6
|
+
import { F as y, B as H } from "./register-chai-top-bar-DWmJ2efT.js";
|
|
7
|
+
import { T as ze, aa as Pe, v as Te, w as De, x as Ae, y as Le, ab as Ce, ac as Re, D as je, ad as Me, e as Ue, g as Fe, C as Oe, j as Ge, l as Be, m as We } from "./index-DPV6NiJ-.js";
|
|
8
|
+
import { cva as Y } from "class-variance-authority";
|
|
9
|
+
import { i as J } from "./index-DqzFD1CG.js";
|
|
10
|
+
function _e({ className: t, ...n }) {
|
|
11
11
|
return /* @__PURE__ */ e(
|
|
12
12
|
"div",
|
|
13
13
|
{
|
|
@@ -31,7 +31,7 @@ function We({ className: t, ...n }) {
|
|
|
31
31
|
}
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
|
-
const
|
|
34
|
+
const He = Y(
|
|
35
35
|
"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",
|
|
36
36
|
{
|
|
37
37
|
variants: {
|
|
@@ -58,7 +58,7 @@ function Q({
|
|
|
58
58
|
role: "group",
|
|
59
59
|
"data-slot": "input-group-addon",
|
|
60
60
|
"data-align": n,
|
|
61
|
-
className: y(
|
|
61
|
+
className: y(He({ align: n }), t),
|
|
62
62
|
onClick: (l) => {
|
|
63
63
|
var o, d;
|
|
64
64
|
l.target.closest("button") || (d = (o = l.currentTarget.parentElement) == null ? void 0 : o.querySelector("input")) == null || d.focus();
|
|
@@ -67,7 +67,7 @@ function Q({
|
|
|
67
67
|
}
|
|
68
68
|
);
|
|
69
69
|
}
|
|
70
|
-
const
|
|
70
|
+
const Ve = Y("flex items-center gap-2 text-sm shadow-none", {
|
|
71
71
|
variants: {
|
|
72
72
|
size: {
|
|
73
73
|
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
@@ -88,19 +88,19 @@ function Z({
|
|
|
88
88
|
...o
|
|
89
89
|
}) {
|
|
90
90
|
return /* @__PURE__ */ e(
|
|
91
|
-
|
|
91
|
+
H,
|
|
92
92
|
{
|
|
93
93
|
type: n,
|
|
94
94
|
"data-size": l,
|
|
95
95
|
variant: a,
|
|
96
|
-
className: y(
|
|
96
|
+
className: y(Ve({ size: l }), t),
|
|
97
97
|
...o
|
|
98
98
|
}
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function qe({ className: t, ...n }) {
|
|
102
102
|
return /* @__PURE__ */ e(
|
|
103
|
-
|
|
103
|
+
ze,
|
|
104
104
|
{
|
|
105
105
|
"data-slot": "input-group-control",
|
|
106
106
|
className: y(
|
|
@@ -111,7 +111,7 @@ function Ve({ className: t, ...n }) {
|
|
|
111
111
|
}
|
|
112
112
|
);
|
|
113
113
|
}
|
|
114
|
-
const
|
|
114
|
+
const Ee = _(null), Ke = _(null), ee = () => W(Ee), $e = () => W(Ke), te = _(null), G = () => {
|
|
115
115
|
const t = $e(), n = W(te), a = t ?? n;
|
|
116
116
|
if (!a)
|
|
117
117
|
throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");
|
|
@@ -121,7 +121,7 @@ function Xe({ data: t, className: n, ...a }) {
|
|
|
121
121
|
var f;
|
|
122
122
|
const l = G(), o = t.filename || "", u = ((f = t.mediaType) != null && f.startsWith("image/") && t.url ? "image" : "file") === "image", g = o || (u ? "Image" : "Attachment");
|
|
123
123
|
return /* @__PURE__ */ N(lt, { children: [
|
|
124
|
-
/* @__PURE__ */ e(
|
|
124
|
+
/* @__PURE__ */ e(Pe, { asChild: !0, children: /* @__PURE__ */ N(
|
|
125
125
|
"div",
|
|
126
126
|
{
|
|
127
127
|
className: y(
|
|
@@ -140,9 +140,9 @@ function Xe({ data: t, className: n, ...a }) {
|
|
|
140
140
|
src: t.url,
|
|
141
141
|
width: 20
|
|
142
142
|
}
|
|
143
|
-
) : /* @__PURE__ */ e("div", { className: "flex size-5 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ e(
|
|
143
|
+
) : /* @__PURE__ */ e("div", { className: "flex size-5 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ e(le, { className: "size-3" }) }) }),
|
|
144
144
|
/* @__PURE__ */ N(
|
|
145
|
-
|
|
145
|
+
H,
|
|
146
146
|
{
|
|
147
147
|
"aria-label": "Remove attachment",
|
|
148
148
|
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",
|
|
@@ -152,7 +152,7 @@ function Xe({ data: t, className: n, ...a }) {
|
|
|
152
152
|
type: "button",
|
|
153
153
|
variant: "ghost",
|
|
154
154
|
children: [
|
|
155
|
-
/* @__PURE__ */ e(
|
|
155
|
+
/* @__PURE__ */ e(X, {}),
|
|
156
156
|
/* @__PURE__ */ e("span", { className: "sr-only", children: "Remove" })
|
|
157
157
|
]
|
|
158
158
|
}
|
|
@@ -183,7 +183,7 @@ function Xe({ data: t, className: n, ...a }) {
|
|
|
183
183
|
}
|
|
184
184
|
function Ye({ children: t, className: n, ...a }) {
|
|
185
185
|
const l = G();
|
|
186
|
-
return l.files.length ? /* @__PURE__ */ e("div", { className: y("flex flex-wrap items-center gap-2 p-3", n), ...a, children: l.files.map((o) => /* @__PURE__ */ e(
|
|
186
|
+
return l.files.length ? /* @__PURE__ */ e("div", { className: y("flex flex-wrap items-center gap-2 p-3", n), ...a, children: l.files.map((o) => /* @__PURE__ */ e(Ne, { children: t(o) }, o.id)) }) : null;
|
|
187
187
|
}
|
|
188
188
|
const Je = ({
|
|
189
189
|
label: t = "Add photos or files",
|
|
@@ -191,14 +191,14 @@ const Je = ({
|
|
|
191
191
|
}) => {
|
|
192
192
|
const a = G();
|
|
193
193
|
return /* @__PURE__ */ N(
|
|
194
|
-
|
|
194
|
+
Le,
|
|
195
195
|
{
|
|
196
196
|
...n,
|
|
197
197
|
onSelect: (l) => {
|
|
198
198
|
l.preventDefault(), a.openFileDialog();
|
|
199
199
|
},
|
|
200
200
|
children: [
|
|
201
|
-
/* @__PURE__ */ e(
|
|
201
|
+
/* @__PURE__ */ e(ue, { className: "mr-2 size-4" }),
|
|
202
202
|
" ",
|
|
203
203
|
t
|
|
204
204
|
]
|
|
@@ -223,7 +223,7 @@ const Je = ({
|
|
|
223
223
|
const r = (v = z.current) == null ? void 0 : v.closest("form");
|
|
224
224
|
r instanceof HTMLFormElement && (S.current = r);
|
|
225
225
|
}, []);
|
|
226
|
-
const [k,
|
|
226
|
+
const [k, P] = L([]), T = i ? s.attachments.files : k, q = O(() => {
|
|
227
227
|
var r;
|
|
228
228
|
(r = h.current) == null || r.click();
|
|
229
229
|
}, []), w = O(
|
|
@@ -247,7 +247,7 @@ const Je = ({
|
|
|
247
247
|
});
|
|
248
248
|
return;
|
|
249
249
|
}
|
|
250
|
-
|
|
250
|
+
P((x) => {
|
|
251
251
|
const C = typeof d == "number" ? Math.max(0, d - x.length) : void 0, oe = typeof C == "number" ? b.slice(0, C) : b;
|
|
252
252
|
typeof C == "number" && b.length > C && (g == null || g({
|
|
253
253
|
code: "max_files",
|
|
@@ -256,7 +256,7 @@ const Je = ({
|
|
|
256
256
|
const K = [];
|
|
257
257
|
for (const B of oe)
|
|
258
258
|
K.push({
|
|
259
|
-
id:
|
|
259
|
+
id: ke(),
|
|
260
260
|
type: "file",
|
|
261
261
|
url: URL.createObjectURL(B),
|
|
262
262
|
mediaType: B.type,
|
|
@@ -266,22 +266,22 @@ const Je = ({
|
|
|
266
266
|
});
|
|
267
267
|
},
|
|
268
268
|
[w, d, u, g]
|
|
269
|
-
),
|
|
269
|
+
), D = i ? (r) => s.attachments.add(r) : j, M = i ? (r) => s.attachments.remove(r) : (r) => P((v) => {
|
|
270
270
|
const p = v.find((c) => c.id === r);
|
|
271
271
|
return p != null && p.url && URL.revokeObjectURL(p.url), v.filter((c) => c.id !== r);
|
|
272
|
-
}), R = i ? () => s.attachments.clear() : () =>
|
|
272
|
+
}), R = i ? () => s.attachments.clear() : () => P((r) => {
|
|
273
273
|
for (const v of r)
|
|
274
274
|
v.url && URL.revokeObjectURL(v.url);
|
|
275
275
|
return [];
|
|
276
|
-
}), U = i ? () => s.attachments.openFileDialog() :
|
|
276
|
+
}), U = i ? () => s.attachments.openFileDialog() : q;
|
|
277
277
|
A(() => {
|
|
278
278
|
i && s.__registerFileInput(h, () => {
|
|
279
279
|
var r;
|
|
280
280
|
return (r = h.current) == null ? void 0 : r.click();
|
|
281
281
|
});
|
|
282
282
|
}, [i, s]), A(() => {
|
|
283
|
-
o && h.current &&
|
|
284
|
-
}, [
|
|
283
|
+
o && h.current && T.length === 0 && (h.current.value = "");
|
|
284
|
+
}, [T, o]), A(() => {
|
|
285
285
|
const r = S.current;
|
|
286
286
|
if (!r) return;
|
|
287
287
|
const v = (c) => {
|
|
@@ -289,54 +289,54 @@ const Je = ({
|
|
|
289
289
|
(x = (b = c.dataTransfer) == null ? void 0 : b.types) != null && x.includes("Files") && c.preventDefault();
|
|
290
290
|
}, p = (c) => {
|
|
291
291
|
var b, x, C;
|
|
292
|
-
(x = (b = c.dataTransfer) == null ? void 0 : b.types) != null && x.includes("Files") && c.preventDefault(), (C = c.dataTransfer) != null && C.files && c.dataTransfer.files.length > 0 &&
|
|
292
|
+
(x = (b = c.dataTransfer) == null ? void 0 : b.types) != null && x.includes("Files") && c.preventDefault(), (C = c.dataTransfer) != null && C.files && c.dataTransfer.files.length > 0 && D(c.dataTransfer.files);
|
|
293
293
|
};
|
|
294
294
|
return r.addEventListener("dragover", v), r.addEventListener("drop", p), () => {
|
|
295
295
|
r.removeEventListener("dragover", v), r.removeEventListener("drop", p);
|
|
296
296
|
};
|
|
297
|
-
}, [
|
|
297
|
+
}, [D]), A(() => {
|
|
298
298
|
if (!l) return;
|
|
299
299
|
const r = (p) => {
|
|
300
300
|
var c, b;
|
|
301
301
|
(b = (c = p.dataTransfer) == null ? void 0 : c.types) != null && b.includes("Files") && p.preventDefault();
|
|
302
302
|
}, v = (p) => {
|
|
303
303
|
var c, b, x;
|
|
304
|
-
(b = (c = p.dataTransfer) == null ? void 0 : c.types) != null && b.includes("Files") && p.preventDefault(), (x = p.dataTransfer) != null && x.files && p.dataTransfer.files.length > 0 &&
|
|
304
|
+
(b = (c = p.dataTransfer) == null ? void 0 : c.types) != null && b.includes("Files") && p.preventDefault(), (x = p.dataTransfer) != null && x.files && p.dataTransfer.files.length > 0 && D(p.dataTransfer.files);
|
|
305
305
|
};
|
|
306
306
|
return document.addEventListener("dragover", r), document.addEventListener("drop", v), () => {
|
|
307
307
|
document.removeEventListener("dragover", r), document.removeEventListener("drop", v);
|
|
308
308
|
};
|
|
309
|
-
}, [
|
|
309
|
+
}, [D, l]), A(
|
|
310
310
|
() => () => {
|
|
311
311
|
if (!i)
|
|
312
|
-
for (const r of
|
|
312
|
+
for (const r of T)
|
|
313
313
|
r.url && URL.revokeObjectURL(r.url);
|
|
314
314
|
},
|
|
315
|
-
[i,
|
|
315
|
+
[i, T]
|
|
316
316
|
);
|
|
317
317
|
const ne = (r) => {
|
|
318
|
-
r.currentTarget.files &&
|
|
318
|
+
r.currentTarget.files && D(r.currentTarget.files);
|
|
319
319
|
}, se = async (r) => {
|
|
320
320
|
const p = await (await fetch(r)).blob();
|
|
321
321
|
return new Promise((c, b) => {
|
|
322
322
|
const x = new FileReader();
|
|
323
323
|
x.onloadend = () => c(x.result), x.onerror = b, x.readAsDataURL(p);
|
|
324
324
|
});
|
|
325
|
-
}, re =
|
|
325
|
+
}, re = we(
|
|
326
326
|
() => ({
|
|
327
|
-
files:
|
|
328
|
-
add:
|
|
327
|
+
files: T.map((r) => ({ ...r, id: r.id })),
|
|
328
|
+
add: D,
|
|
329
329
|
remove: M,
|
|
330
330
|
clear: R,
|
|
331
331
|
openFileDialog: U,
|
|
332
332
|
fileInputRef: h
|
|
333
333
|
}),
|
|
334
|
-
[
|
|
334
|
+
[T, D, M, R, U]
|
|
335
335
|
), ae = (r) => {
|
|
336
336
|
r.preventDefault();
|
|
337
337
|
const v = r.currentTarget, p = i ? s.textInput.value : new FormData(v).get("message") || "";
|
|
338
338
|
i || v.reset(), Promise.all(
|
|
339
|
-
|
|
339
|
+
T.map(async ({ ...c }) => c.url && c.url.startsWith("blob:") ? {
|
|
340
340
|
...c,
|
|
341
341
|
url: await se(c.url)
|
|
342
342
|
} : c)
|
|
@@ -350,7 +350,7 @@ const Je = ({
|
|
|
350
350
|
} catch {
|
|
351
351
|
}
|
|
352
352
|
});
|
|
353
|
-
},
|
|
353
|
+
}, E = /* @__PURE__ */ N(ie, { children: [
|
|
354
354
|
/* @__PURE__ */ e("span", { "aria-hidden": "true", className: "hidden", ref: z }),
|
|
355
355
|
/* @__PURE__ */ e(
|
|
356
356
|
"input",
|
|
@@ -365,9 +365,9 @@ const Je = ({
|
|
|
365
365
|
type: "file"
|
|
366
366
|
}
|
|
367
367
|
),
|
|
368
|
-
/* @__PURE__ */ e("form", { className: y("w-full", t), onSubmit: ae, ...I, children: /* @__PURE__ */ e(
|
|
368
|
+
/* @__PURE__ */ e("form", { className: y("w-full", t), onSubmit: ae, ...I, children: /* @__PURE__ */ e(_e, { className: "overflow-hidden", children: m }) })
|
|
369
369
|
] });
|
|
370
|
-
return i ?
|
|
370
|
+
return i ? E : /* @__PURE__ */ e(te.Provider, { value: re, children: E });
|
|
371
371
|
}, Ze = ({
|
|
372
372
|
onChange: t,
|
|
373
373
|
className: n,
|
|
@@ -410,7 +410,7 @@ const Je = ({
|
|
|
410
410
|
onChange: t
|
|
411
411
|
};
|
|
412
412
|
return /* @__PURE__ */ e(
|
|
413
|
-
|
|
413
|
+
qe,
|
|
414
414
|
{
|
|
415
415
|
className: y("field-sizing-content max-h-48 min-h-16", n),
|
|
416
416
|
name: "message",
|
|
@@ -423,10 +423,10 @@ const Je = ({
|
|
|
423
423
|
...I
|
|
424
424
|
}
|
|
425
425
|
);
|
|
426
|
-
}, et = ({ className: t, ...n }) => /* @__PURE__ */ e(Q, { align: "block-end", className: y("order-first flex-wrap gap-1", t), ...n }), tt = ({ className: t, ...n }) => /* @__PURE__ */ e(Q, { align: "block-end", className: y("justify-between gap-1", t), ...n }), nt = ({ className: t, ...n }) => /* @__PURE__ */ e("div", { className: y("flex items-center gap-1", t), ...n }),
|
|
427
|
-
const o = a ?? (
|
|
426
|
+
}, et = ({ className: t, ...n }) => /* @__PURE__ */ e(Q, { align: "block-end", className: y("order-first flex-wrap gap-1", t), ...n }), tt = ({ className: t, ...n }) => /* @__PURE__ */ e(Q, { align: "block-end", className: y("justify-between gap-1", t), ...n }), nt = ({ className: t, ...n }) => /* @__PURE__ */ e("div", { className: y("flex items-center gap-1", t), ...n }), V = ({ variant: t = "ghost", className: n, size: a, ...l }) => {
|
|
427
|
+
const o = a ?? (Ie.count(l.children) > 1 ? "sm" : "icon-sm");
|
|
428
428
|
return /* @__PURE__ */ e(Z, { className: y(n), size: o, type: "button", variant: t, ...l });
|
|
429
|
-
}, st = (t) => /* @__PURE__ */ e(
|
|
429
|
+
}, st = (t) => /* @__PURE__ */ e(Te, { ...t }), rt = ({ className: t, children: n, ...a }) => /* @__PURE__ */ e(De, { asChild: !0, children: /* @__PURE__ */ e(V, { className: t, ...a, children: n ?? /* @__PURE__ */ e(ce, { className: "size-4" }) }) }), at = ({ className: t, ...n }) => /* @__PURE__ */ e(Ae, { align: "start", className: y(t), ...n }), ot = ({
|
|
430
430
|
className: t,
|
|
431
431
|
variant: n = "default",
|
|
432
432
|
size: a = "icon-sm",
|
|
@@ -434,8 +434,8 @@ const Je = ({
|
|
|
434
434
|
children: o,
|
|
435
435
|
...d
|
|
436
436
|
}) => {
|
|
437
|
-
let u = /* @__PURE__ */ e(
|
|
438
|
-
return l === "submitted" ? u = /* @__PURE__ */ e(
|
|
437
|
+
let u = /* @__PURE__ */ e(me, { className: "size-4" });
|
|
438
|
+
return l === "submitted" ? u = /* @__PURE__ */ e(pe, { className: "size-4 animate-spin" }) : l === "streaming" ? u = /* @__PURE__ */ e(fe, { className: "size-4" }) : l === "error" && (u = /* @__PURE__ */ e(X, { className: "size-4" })), /* @__PURE__ */ e(
|
|
439
439
|
Z,
|
|
440
440
|
{
|
|
441
441
|
"aria-label": "Submit",
|
|
@@ -469,12 +469,12 @@ const Je = ({
|
|
|
469
469
|
k.isFinal && (h += ((z = k[0]) == null ? void 0 : z.transcript) ?? "");
|
|
470
470
|
}
|
|
471
471
|
if (h && (n != null && n.current)) {
|
|
472
|
-
const S = n.current, k = S.value,
|
|
473
|
-
S.value =
|
|
472
|
+
const S = n.current, k = S.value, P = k + (k ? " " : "") + h;
|
|
473
|
+
S.value = P, S.dispatchEvent(new Event("input", { bubbles: !0 })), a == null || a(P);
|
|
474
474
|
}
|
|
475
475
|
}, s.onerror = (i) => {
|
|
476
476
|
console.error("Speech recognition error:", i.error), d(!1);
|
|
477
|
-
}, f.current = s,
|
|
477
|
+
}, f.current = s, ye(() => g(s));
|
|
478
478
|
}
|
|
479
479
|
return () => {
|
|
480
480
|
f.current && f.current.stop();
|
|
@@ -484,7 +484,7 @@ const Je = ({
|
|
|
484
484
|
u && (o ? u.stop() : u.start());
|
|
485
485
|
}, [u, o]);
|
|
486
486
|
return /* @__PURE__ */ e(
|
|
487
|
-
|
|
487
|
+
V,
|
|
488
488
|
{
|
|
489
489
|
className: y(
|
|
490
490
|
"relative transition-all duration-200",
|
|
@@ -494,18 +494,18 @@ const Je = ({
|
|
|
494
494
|
disabled: !u,
|
|
495
495
|
onClick: m,
|
|
496
496
|
...l,
|
|
497
|
-
children: /* @__PURE__ */ e(
|
|
497
|
+
children: /* @__PURE__ */ e(de, { className: "size-4" })
|
|
498
498
|
}
|
|
499
499
|
);
|
|
500
|
-
}, lt = ({ openDelay: t = 0, closeDelay: n = 0, ...a }) => /* @__PURE__ */ e(
|
|
500
|
+
}, lt = ({ openDelay: t = 0, closeDelay: n = 0, ...a }) => /* @__PURE__ */ e(Ce, { closeDelay: n, openDelay: t, ...a }), ct = ({ align: t = "start", ...n }) => /* @__PURE__ */ e(Re, { align: t, ...n }), ut = (t) => /* @__PURE__ */ e(je, { ...t }), dt = (t) => /* @__PURE__ */ e(Me, { ...t }), mt = ({
|
|
501
501
|
className: t,
|
|
502
502
|
children: n,
|
|
503
503
|
title: a = "Model Selector",
|
|
504
504
|
...l
|
|
505
|
-
}) => /* @__PURE__ */ N(
|
|
506
|
-
/* @__PURE__ */ e(
|
|
507
|
-
/* @__PURE__ */ e(
|
|
508
|
-
] }), pt = (t) => /* @__PURE__ */ e(
|
|
505
|
+
}) => /* @__PURE__ */ N(Ue, { className: y("p-0", t), ...l, children: [
|
|
506
|
+
/* @__PURE__ */ e(Fe, { className: "sr-only", children: a }),
|
|
507
|
+
/* @__PURE__ */ e(Oe, { className: "**:data-[slot=command-input-wrapper]:h-auto", children: n })
|
|
508
|
+
] }), pt = (t) => /* @__PURE__ */ e(Ge, { ...t }), ft = (t) => /* @__PURE__ */ e(Be, { ...t }), ht = (t) => /* @__PURE__ */ e(We, { ...t }), gt = ({ provider: t, className: n, ...a }) => /* @__PURE__ */ e(
|
|
509
509
|
"img",
|
|
510
510
|
{
|
|
511
511
|
...a,
|
|
@@ -527,8 +527,8 @@ const Je = ({
|
|
|
527
527
|
n(m), o(!1);
|
|
528
528
|
};
|
|
529
529
|
return /* @__PURE__ */ N(ut, { open: l, onOpenChange: o, children: [
|
|
530
|
-
/* @__PURE__ */ e(dt, { asChild: !0, children: /* @__PURE__ */ N(
|
|
531
|
-
/* @__PURE__ */ e(
|
|
530
|
+
/* @__PURE__ */ e(dt, { asChild: !0, children: /* @__PURE__ */ N(H, { variant: "outline", size: "sm", disabled: a, className: "h-8 gap-1 px-2 text-xs", children: [
|
|
531
|
+
/* @__PURE__ */ e(he, { size: 14 }),
|
|
532
532
|
/* @__PURE__ */ e("span", { className: "max-w-20 truncate", children: u.name })
|
|
533
533
|
] }) }),
|
|
534
534
|
/* @__PURE__ */ N(mt, { className: "w-96 p-0", children: [
|
|
@@ -552,7 +552,7 @@ const Je = ({
|
|
|
552
552
|
)) }, m)) })
|
|
553
553
|
] })
|
|
554
554
|
] });
|
|
555
|
-
}, $ = "chai-ai-selected-model",
|
|
555
|
+
}, $ = "chai-ai-selected-model", Tt = ({
|
|
556
556
|
input: t,
|
|
557
557
|
setInput: n,
|
|
558
558
|
onSend: a,
|
|
@@ -563,7 +563,7 @@ const Je = ({
|
|
|
563
563
|
selectedModel: g,
|
|
564
564
|
onModelChange: f
|
|
565
565
|
}) => {
|
|
566
|
-
const { t: m } =
|
|
566
|
+
const { t: m } = Se(), { models: I } = J(), s = I.find((w) => w.id === "google/gemini-3-flash") || I[0], [i, h] = L(g || s.id), [z, S] = L(null), k = F(null), [P, T] = L(!1);
|
|
567
567
|
return A(() => {
|
|
568
568
|
if (!u) {
|
|
569
569
|
const w = localStorage.getItem($);
|
|
@@ -574,8 +574,8 @@ const Je = ({
|
|
|
574
574
|
const j = w.files.find((R) => {
|
|
575
575
|
var U;
|
|
576
576
|
return (U = R.mediaType) == null ? void 0 : U.startsWith("image/");
|
|
577
|
-
}),
|
|
578
|
-
a((M = w.text) == null ? void 0 : M.trim(), void 0,
|
|
577
|
+
}), D = (j == null ? void 0 : j.url) || z;
|
|
578
|
+
a((M = w.text) == null ? void 0 : M.trim(), void 0, D, i), S(null);
|
|
579
579
|
}, accept: "image/*", className: "flex h-auto w-full flex-col", children: [
|
|
580
580
|
/* @__PURE__ */ e(et, { className: "p-0", children: /* @__PURE__ */ e(Ye, { className: "pb-0", children: (w) => /* @__PURE__ */ e(Xe, { className: "text-xs", data: w }) }) }),
|
|
581
581
|
/* @__PURE__ */ e(
|
|
@@ -593,7 +593,7 @@ const Je = ({
|
|
|
593
593
|
/* @__PURE__ */ N(tt, { children: [
|
|
594
594
|
u ? /* @__PURE__ */ e("div", {}) : /* @__PURE__ */ N(nt, { children: [
|
|
595
595
|
/* @__PURE__ */ N(st, { children: [
|
|
596
|
-
/* @__PURE__ */ e(rt, { disabled: o, children: /* @__PURE__ */ e(
|
|
596
|
+
/* @__PURE__ */ e(rt, { disabled: o, children: /* @__PURE__ */ e(ge, { size: 16 }) }),
|
|
597
597
|
/* @__PURE__ */ e(at, { children: /* @__PURE__ */ e(Je, {}) })
|
|
598
598
|
] }),
|
|
599
599
|
/* @__PURE__ */ e(
|
|
@@ -615,14 +615,14 @@ const Je = ({
|
|
|
615
615
|
}
|
|
616
616
|
),
|
|
617
617
|
/* @__PURE__ */ N(
|
|
618
|
-
|
|
618
|
+
V,
|
|
619
619
|
{
|
|
620
620
|
className: "hidden",
|
|
621
621
|
size: "sm",
|
|
622
|
-
onClick: () =>
|
|
623
|
-
variant:
|
|
622
|
+
onClick: () => T(!P),
|
|
623
|
+
variant: P ? "default" : "ghost",
|
|
624
624
|
children: [
|
|
625
|
-
/* @__PURE__ */ e(
|
|
625
|
+
/* @__PURE__ */ e(ve, { size: 16 }),
|
|
626
626
|
/* @__PURE__ */ e("span", { children: "Search" })
|
|
627
627
|
]
|
|
628
628
|
}
|
|
@@ -634,12 +634,12 @@ const Je = ({
|
|
|
634
634
|
onClick: l,
|
|
635
635
|
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",
|
|
636
636
|
title: m("Stop generation"),
|
|
637
|
-
children: /* @__PURE__ */ e(
|
|
637
|
+
children: /* @__PURE__ */ e(be, { size: 16 })
|
|
638
638
|
}
|
|
639
|
-
) : /* @__PURE__ */ e(ot, { disabled: !t.trim() || d, children: /* @__PURE__ */ e(
|
|
639
|
+
) : /* @__PURE__ */ e(ot, { disabled: !t.trim() || d, children: /* @__PURE__ */ e(xe, { size: 16 }) })
|
|
640
640
|
] })
|
|
641
641
|
] }) }) });
|
|
642
642
|
};
|
|
643
643
|
export {
|
|
644
|
-
|
|
644
|
+
Tt as default
|
|
645
645
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),y=require("./index-DCJDQs1a.cjs"),W=require("class-variance-authority"),k=require("lucide-react"),te=require("nanoid"),c=require("react"),se=require("react-i18next"),_=require("./index-BVwFJWDq.cjs");function ne({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:b.cn("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","h-9 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-ring","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",t),...s})}const re=W.cva("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",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5","block-end":"[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function H({className:t,align:s="inline-start",...a}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:b.cn(re({align:s}),t),onClick:l=>{var o,p;l.target.closest("button")||(p=(o=l.currentTarget.parentElement)==null?void 0:o.querySelector("input"))==null||p.focus()},...a})}const ae=W.cva("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function K({className:t,type:s="button",variant:a="ghost",size:l="xs",...o}){return e.jsx(b.Button,{type:s,"data-size":l,variant:a,className:b.cn(ae({size:l}),t),...o})}function oe({className:t,...s}){return e.jsx(y.Textarea,{"data-slot":"input-group-control",className:b.cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",t),...s})}const ie=c.createContext(null),ce=c.createContext(null),X=()=>c.useContext(ie),le=()=>c.useContext(ce),$=c.createContext(null),q=()=>{const t=le(),s=c.useContext($),a=t??s;if(!a)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return a};function ue({data:t,className:s,...a}){var h;const l=q(),o=t.filename||"",d=((h=t.mediaType)!=null&&h.startsWith("image/")&&t.url?"image":"file")==="image",g=o||(d?"Image":"Attachment");return e.jsxs(ye,{children:[e.jsx(y.HoverCardTrigger,{asChild:!0,children:e.jsxs("div",{className:b.cn("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",s),...a,children:[e.jsxs("div",{className:"relative size-5 shrink-0",children:[e.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:d?e.jsx("img",{alt:o||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20}):e.jsx("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:e.jsx(k.PaperclipIcon,{className:"size-3"})})}),e.jsxs(b.Button,{"aria-label":"Remove attachment",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",onClick:m=>{m.stopPropagation(),l.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(k.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:g})]},t.id)}),e.jsx(Ie,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[d&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:o||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),e.jsx("div",{className:"flex items-center gap-2.5",children:e.jsxs("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[e.jsx("h4",{className:"truncate text-sm font-semibold leading-none",children:o||(d?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function de({children:t,className:s,...a}){const l=q();return l.files.length?e.jsx("div",{className:b.cn("flex flex-wrap items-center gap-2 p-3",s),...a,children:l.files.map(o=>e.jsx(c.Fragment,{children:t(o)},o.id))}):null}const pe=({label:t="Add photos or files",...s})=>{const a=q();return e.jsxs(y.DropdownMenuItem,{...s,onSelect:l=>{l.preventDefault(),a.openFileDialog()},children:[e.jsx(k.ImageIcon,{className:"mr-2 size-4"})," ",t]})},me=({className:t,accept:s,multiple:a,globalDrop:l,syncHiddenInput:o,maxFiles:p,maxFileSize:d,onError:g,onSubmit:h,children:m,...I})=>{const n=X(),i=!!n,x=c.useRef(null),T=c.useRef(null),S=c.useRef(null);c.useEffect(()=>{var v;const r=(v=T.current)==null?void 0:v.closest("form");r instanceof HTMLFormElement&&(S.current=r)},[]);const[P,z]=c.useState([]),D=i?n.attachments.files:P,O=c.useCallback(()=>{var r;(r=x.current)==null||r.click()},[]),N=c.useCallback(r=>!s||s.trim()===""?!0:s.includes("image/*")?r.type.startsWith("image/"):!0,[s]),L=c.useCallback(r=>{const v=Array.from(r),f=v.filter(w=>N(w));if(v.length&&f.length===0){g==null||g({code:"accept",message:"No files match the accepted types."});return}const u=w=>d?w.size<=d:!0,j=f.filter(u);if(f.length>0&&j.length===0){g==null||g({code:"max_file_size",message:"All files exceed the maximum size."});return}z(w=>{const C=typeof p=="number"?Math.max(0,p-w.length):void 0,ee=typeof C=="number"?j.slice(0,C):j;typeof C=="number"&&j.length>C&&(g==null||g({code:"max_files",message:"Too many files. Some were not added."}));const B=[];for(const E of ee)B.push({id:te.nanoid(),type:"file",url:URL.createObjectURL(E),mediaType:E.type,filename:E.name});return w.concat(B)})},[N,p,d,g]),A=i?r=>n.attachments.add(r):L,M=i?r=>n.attachments.remove(r):r=>z(v=>{const f=v.find(u=>u.id===r);return f!=null&&f.url&&URL.revokeObjectURL(f.url),v.filter(u=>u.id!==r)}),R=i?()=>n.attachments.clear():()=>z(r=>{for(const v of r)v.url&&URL.revokeObjectURL(v.url);return[]}),U=i?()=>n.attachments.openFileDialog():O;c.useEffect(()=>{i&&n.__registerFileInput(x,()=>{var r;return(r=x.current)==null?void 0:r.click()})},[i,n]),c.useEffect(()=>{o&&x.current&&D.length===0&&(x.current.value="")},[D,o]),c.useEffect(()=>{const r=S.current;if(!r)return;const v=u=>{var j,w;(w=(j=u.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&u.preventDefault()},f=u=>{var j,w,C;(w=(j=u.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&u.preventDefault(),(C=u.dataTransfer)!=null&&C.files&&u.dataTransfer.files.length>0&&A(u.dataTransfer.files)};return r.addEventListener("dragover",v),r.addEventListener("drop",f),()=>{r.removeEventListener("dragover",v),r.removeEventListener("drop",f)}},[A]),c.useEffect(()=>{if(!l)return;const r=f=>{var u,j;(j=(u=f.dataTransfer)==null?void 0:u.types)!=null&&j.includes("Files")&&f.preventDefault()},v=f=>{var u,j,w;(j=(u=f.dataTransfer)==null?void 0:u.types)!=null&&j.includes("Files")&&f.preventDefault(),(w=f.dataTransfer)!=null&&w.files&&f.dataTransfer.files.length>0&&A(f.dataTransfer.files)};return document.addEventListener("dragover",r),document.addEventListener("drop",v),()=>{document.removeEventListener("dragover",r),document.removeEventListener("drop",v)}},[A,l]),c.useEffect(()=>()=>{if(!i)for(const r of D)r.url&&URL.revokeObjectURL(r.url)},[i,D]);const Y=r=>{r.currentTarget.files&&A(r.currentTarget.files)},J=async r=>{const f=await(await fetch(r)).blob();return new Promise((u,j)=>{const w=new FileReader;w.onloadend=()=>u(w.result),w.onerror=j,w.readAsDataURL(f)})},Q=c.useMemo(()=>({files:D.map(r=>({...r,id:r.id})),add:A,remove:M,clear:R,openFileDialog:U,fileInputRef:x}),[D,A,M,R,U]),Z=r=>{r.preventDefault();const v=r.currentTarget,f=i?n.textInput.value:new FormData(v).get("message")||"";i||v.reset(),Promise.all(D.map(async({...u})=>u.url&&u.url.startsWith("blob:")?{...u,url:await J(u.url)}:u)).then(u=>{try{const j=h({text:f,files:u},r);j instanceof Promise?j.then(()=>{R(),i&&n.textInput.clear()}).catch(()=>{}):(R(),i&&n.textInput.clear())}catch{}})},G=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:T}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:a,onChange:Y,ref:x,title:"Upload files",type:"file"}),e.jsx("form",{className:b.cn("w-full",t),onSubmit:Z,...I,children:e.jsx(ne,{className:"overflow-hidden",children:m})})]});return i?G:e.jsx($.Provider,{value:Q,children:G})},fe=({onChange:t,className:s,placeholder:a="What would you like to know?",...l})=>{const o=X(),p=q(),[d,g]=c.useState(!1),h=n=>{if(n.key==="Enter"){if(d||n.nativeEvent.isComposing||n.shiftKey)return;n.preventDefault();const i=n.currentTarget.form,x=i==null?void 0:i.querySelector('button[type="submit"]');if(x!=null&&x.disabled)return;i==null||i.requestSubmit()}if(n.key==="Backspace"&&n.currentTarget.value===""&&p.files.length>0){n.preventDefault();const i=p.files.at(-1);i&&p.remove(i.id)}},m=n=>{var T;const i=(T=n.clipboardData)==null?void 0:T.items;if(!i)return;const x=[];for(const S of i)if(S.kind==="file"){const P=S.getAsFile();P&&x.push(P)}x.length>0&&(n.preventDefault(),p.add(x))},I=o?{value:o.textInput.value,onChange:n=>{o.textInput.setInput(n.currentTarget.value),t==null||t(n)}}:{onChange:t};return e.jsx(oe,{className:b.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>g(!1),onCompositionStart:()=>g(!0),onKeyDown:h,onPaste:m,placeholder:a,...l,...I})},he=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("order-first flex-wrap gap-1",t),...s}),xe=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("justify-between gap-1",t),...s}),ge=({className:t,...s})=>e.jsx("div",{className:b.cn("flex items-center gap-1",t),...s}),F=({variant:t="ghost",className:s,size:a,...l})=>{const o=a??(c.Children.count(l.children)>1?"sm":"icon-sm");return e.jsx(K,{className:b.cn(s),size:o,type:"button",variant:t,...l})},ve=t=>e.jsx(y.DropdownMenu,{...t}),je=({className:t,children:s,...a})=>e.jsx(y.DropdownMenuTrigger,{asChild:!0,children:e.jsx(F,{className:t,...a,children:s??e.jsx(k.PlusIcon,{className:"size-4"})})}),be=({className:t,...s})=>e.jsx(y.DropdownMenuContent,{align:"start",className:b.cn(t),...s}),we=({className:t,variant:s="default",size:a="icon-sm",status:l,children:o,...p})=>{let d=e.jsx(k.CornerDownLeftIcon,{className:"size-4"});return l==="submitted"?d=e.jsx(k.Loader2Icon,{className:"size-4 animate-spin"}):l==="streaming"?d=e.jsx(k.SquareIcon,{className:"size-4"}):l==="error"&&(d=e.jsx(k.XIcon,{className:"size-4"})),e.jsx(K,{"aria-label":"Submit",className:b.cn(t),size:a,type:"submit",variant:s,...p,children:o??d})},Ne=({className:t,textareaRef:s,onTranscriptionChange:a,...l})=>{const[o,p]=c.useState(!1),[d,g]=c.useState(null),h=c.useRef(null);c.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const I=window.SpeechRecognition||window.webkitSpeechRecognition,n=new I;n.continuous=!0,n.interimResults=!0,n.lang="en-US",n.onstart=()=>{p(!0)},n.onend=()=>{p(!1)},n.onresult=i=>{var T;let x="";for(let S=i.resultIndex;S<i.results.length;S++){const P=i.results[S];P.isFinal&&(x+=((T=P[0])==null?void 0:T.transcript)??"")}if(x&&(s!=null&&s.current)){const S=s.current,P=S.value,z=P+(P?" ":"")+x;S.value=z,S.dispatchEvent(new Event("input",{bubbles:!0})),a==null||a(z)}},n.onerror=i=>{console.error("Speech recognition error:",i.error),p(!1)},h.current=n,c.startTransition(()=>g(n))}return()=>{h.current&&h.current.stop()}},[s,a]);const m=c.useCallback(()=>{d&&(o?d.stop():d.start())},[d,o]);return e.jsx(F,{className:b.cn("relative transition-all duration-200",o&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!d,onClick:m,...l,children:e.jsx(k.MicIcon,{className:"size-4"})})},ye=({openDelay:t=0,closeDelay:s=0,...a})=>e.jsx(y.HoverCard,{closeDelay:s,openDelay:t,...a}),Ie=({align:t="start",...s})=>e.jsx(y.HoverCardContent,{align:t,...s}),Se=t=>e.jsx(y.Dialog,{...t}),ke=t=>e.jsx(y.DialogTrigger,{...t}),Pe=({className:t,children:s,title:a="Model Selector",...l})=>e.jsxs(y.DialogContent,{className:b.cn("p-0",t),...l,children:[e.jsx(y.DialogTitle,{className:"sr-only",children:a}),e.jsx(y.Command,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),Te=t=>e.jsx(y.CommandList,{...t}),ze=t=>e.jsx(y.CommandGroup,{...t}),De=t=>e.jsx(y.CommandItem,{...t}),Ae=({provider:t,className:s,...a})=>e.jsx("img",{...a,alt:`${t} logo`,className:b.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Ce=({className:t,...s})=>e.jsx("span",{className:b.cn("flex-1 truncate text-left",t),...s}),Re=({selectedModel:t,onModelChange:s,disabled:a=!1})=>{const[l,o]=c.useState(!1),{models:p}=_.useAIModels(),d=p.find(m=>m.id===t)||p[0],g=p.reduce((m,I)=>(m[I.provider]||(m[I.provider]=[]),m[I.provider].push(I),m),{}),h=m=>{s(m),o(!1)};return e.jsxs(Se,{open:l,onOpenChange:o,children:[e.jsx(ke,{asChild:!0,children:e.jsxs(b.Button,{variant:"outline",size:"sm",disabled:a,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(k.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:d.name})]})}),e.jsxs(Pe,{className:"w-96 p-0",children:[e.jsx("h3",{className:"mt-2 px-2 py-2 font-semibold",children:"Models"}),e.jsx(Te,{children:Object.entries(g).map(([m,I])=>e.jsx(ze,{heading:m.charAt(0).toUpperCase()+m.slice(1),children:I.map(n=>e.jsxs(De,{value:n.id,onSelect:()=>h(n.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(Ae,{provider:n.provider}),e.jsxs("div",{className:"flex flex-1 items-center justify-between",children:[e.jsx(Ce,{children:n.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n.description})]}),t===n.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},n.id))},m))})]})]})},V="chai-ai-selected-model",Le=({input:t,setInput:s,onSend:a,onStop:l,isLoading:o,disabled:p,selectedLang:d,selectedModel:g,onModelChange:h})=>{const{t:m}=se.useTranslation(),{models:I}=_.useAIModels(),n=I.find(N=>N.id==="google/gemini-3-flash")||I[0],[i,x]=c.useState(g||n.id),[T,S]=c.useState(null),P=c.useRef(null),[z,D]=c.useState(!1);c.useEffect(()=>{if(!d){const N=localStorage.getItem(V);N?(x(N),h==null||h(N)):(x(n.id),h==null||h(n.id))}},[d,h,n.id]);const O=N=>{var M;const L=N.files.find(R=>{var U;return(U=R.mediaType)==null?void 0:U.startsWith("image/")}),A=(L==null?void 0:L.url)||T;a((M=N.text)==null?void 0:M.trim(),void 0,A,i),S(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(me,{onSubmit:O,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(he,{className:"p-0",children:e.jsx(de,{className:"pb-0",children:N=>e.jsx(ue,{className:"text-xs",data:N})})}),e.jsx(fe,{ref:P,value:t,onChange:N=>s(N.target.value),placeholder:m(d?"Ask to update content":"Ask me anything..."),disabled:o,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(xe,{children:[d?e.jsx("div",{}):e.jsxs(ge,{children:[e.jsxs(ve,{children:[e.jsx(je,{disabled:o,children:e.jsx(k.Paperclip,{size:16})}),e.jsx(be,{children:e.jsx(pe,{})})]}),e.jsx(Ne,{textareaRef:P,onTranscriptionChange:s,disabled:o}),e.jsx(Re,{selectedModel:i,onModelChange:N=>{x(N),h==null||h(N),localStorage.setItem(V,N)},disabled:o}),e.jsxs(F,{className:"hidden",size:"sm",onClick:()=>D(!z),variant:z?"default":"ghost",children:[e.jsx(k.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),o?e.jsx("button",{onClick:l,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",title:m("Stop generation"),children:e.jsx(k.Square,{size:16})}):e.jsx(we,{disabled:!t.trim()||p,children:e.jsx(k.Send,{size:16})})]})]})})})};exports.default=Le;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),k=require("lucide-react"),c=require("react"),te=require("react-i18next"),se=require("nanoid"),b=require("./register-chai-top-bar-CCssW5dL.cjs"),y=require("./index-D-r_K4yA.cjs"),W=require("class-variance-authority"),_=require("./index-BYrRPW_c.cjs");function ne({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:b.cn("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","h-9 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-ring","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",t),...s})}const re=W.cva("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",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5","block-end":"[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function H({className:t,align:s="inline-start",...a}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:b.cn(re({align:s}),t),onClick:l=>{var o,p;l.target.closest("button")||(p=(o=l.currentTarget.parentElement)==null?void 0:o.querySelector("input"))==null||p.focus()},...a})}const ae=W.cva("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function K({className:t,type:s="button",variant:a="ghost",size:l="xs",...o}){return e.jsx(b.Button,{type:s,"data-size":l,variant:a,className:b.cn(ae({size:l}),t),...o})}function oe({className:t,...s}){return e.jsx(y.Textarea,{"data-slot":"input-group-control",className:b.cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",t),...s})}const ie=c.createContext(null),ce=c.createContext(null),X=()=>c.useContext(ie),le=()=>c.useContext(ce),$=c.createContext(null),q=()=>{const t=le(),s=c.useContext($),a=t??s;if(!a)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return a};function ue({data:t,className:s,...a}){var h;const l=q(),o=t.filename||"",d=((h=t.mediaType)!=null&&h.startsWith("image/")&&t.url?"image":"file")==="image",g=o||(d?"Image":"Attachment");return e.jsxs(ye,{children:[e.jsx(y.HoverCardTrigger,{asChild:!0,children:e.jsxs("div",{className:b.cn("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",s),...a,children:[e.jsxs("div",{className:"relative size-5 shrink-0",children:[e.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:d?e.jsx("img",{alt:o||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20}):e.jsx("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:e.jsx(k.PaperclipIcon,{className:"size-3"})})}),e.jsxs(b.Button,{"aria-label":"Remove attachment",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",onClick:m=>{m.stopPropagation(),l.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(k.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:g})]},t.id)}),e.jsx(Ie,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[d&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:o||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),e.jsx("div",{className:"flex items-center gap-2.5",children:e.jsxs("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[e.jsx("h4",{className:"truncate text-sm font-semibold leading-none",children:o||(d?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function de({children:t,className:s,...a}){const l=q();return l.files.length?e.jsx("div",{className:b.cn("flex flex-wrap items-center gap-2 p-3",s),...a,children:l.files.map(o=>e.jsx(c.Fragment,{children:t(o)},o.id))}):null}const pe=({label:t="Add photos or files",...s})=>{const a=q();return e.jsxs(y.DropdownMenuItem,{...s,onSelect:l=>{l.preventDefault(),a.openFileDialog()},children:[e.jsx(k.ImageIcon,{className:"mr-2 size-4"})," ",t]})},me=({className:t,accept:s,multiple:a,globalDrop:l,syncHiddenInput:o,maxFiles:p,maxFileSize:d,onError:g,onSubmit:h,children:m,...I})=>{const n=X(),i=!!n,x=c.useRef(null),T=c.useRef(null),S=c.useRef(null);c.useEffect(()=>{var v;const r=(v=T.current)==null?void 0:v.closest("form");r instanceof HTMLFormElement&&(S.current=r)},[]);const[P,z]=c.useState([]),D=i?n.attachments.files:P,O=c.useCallback(()=>{var r;(r=x.current)==null||r.click()},[]),N=c.useCallback(r=>!s||s.trim()===""?!0:s.includes("image/*")?r.type.startsWith("image/"):!0,[s]),L=c.useCallback(r=>{const v=Array.from(r),f=v.filter(w=>N(w));if(v.length&&f.length===0){g==null||g({code:"accept",message:"No files match the accepted types."});return}const u=w=>d?w.size<=d:!0,j=f.filter(u);if(f.length>0&&j.length===0){g==null||g({code:"max_file_size",message:"All files exceed the maximum size."});return}z(w=>{const C=typeof p=="number"?Math.max(0,p-w.length):void 0,ee=typeof C=="number"?j.slice(0,C):j;typeof C=="number"&&j.length>C&&(g==null||g({code:"max_files",message:"Too many files. Some were not added."}));const B=[];for(const E of ee)B.push({id:se.nanoid(),type:"file",url:URL.createObjectURL(E),mediaType:E.type,filename:E.name});return w.concat(B)})},[N,p,d,g]),A=i?r=>n.attachments.add(r):L,M=i?r=>n.attachments.remove(r):r=>z(v=>{const f=v.find(u=>u.id===r);return f!=null&&f.url&&URL.revokeObjectURL(f.url),v.filter(u=>u.id!==r)}),R=i?()=>n.attachments.clear():()=>z(r=>{for(const v of r)v.url&&URL.revokeObjectURL(v.url);return[]}),U=i?()=>n.attachments.openFileDialog():O;c.useEffect(()=>{i&&n.__registerFileInput(x,()=>{var r;return(r=x.current)==null?void 0:r.click()})},[i,n]),c.useEffect(()=>{o&&x.current&&D.length===0&&(x.current.value="")},[D,o]),c.useEffect(()=>{const r=S.current;if(!r)return;const v=u=>{var j,w;(w=(j=u.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&u.preventDefault()},f=u=>{var j,w,C;(w=(j=u.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&u.preventDefault(),(C=u.dataTransfer)!=null&&C.files&&u.dataTransfer.files.length>0&&A(u.dataTransfer.files)};return r.addEventListener("dragover",v),r.addEventListener("drop",f),()=>{r.removeEventListener("dragover",v),r.removeEventListener("drop",f)}},[A]),c.useEffect(()=>{if(!l)return;const r=f=>{var u,j;(j=(u=f.dataTransfer)==null?void 0:u.types)!=null&&j.includes("Files")&&f.preventDefault()},v=f=>{var u,j,w;(j=(u=f.dataTransfer)==null?void 0:u.types)!=null&&j.includes("Files")&&f.preventDefault(),(w=f.dataTransfer)!=null&&w.files&&f.dataTransfer.files.length>0&&A(f.dataTransfer.files)};return document.addEventListener("dragover",r),document.addEventListener("drop",v),()=>{document.removeEventListener("dragover",r),document.removeEventListener("drop",v)}},[A,l]),c.useEffect(()=>()=>{if(!i)for(const r of D)r.url&&URL.revokeObjectURL(r.url)},[i,D]);const Y=r=>{r.currentTarget.files&&A(r.currentTarget.files)},J=async r=>{const f=await(await fetch(r)).blob();return new Promise((u,j)=>{const w=new FileReader;w.onloadend=()=>u(w.result),w.onerror=j,w.readAsDataURL(f)})},Q=c.useMemo(()=>({files:D.map(r=>({...r,id:r.id})),add:A,remove:M,clear:R,openFileDialog:U,fileInputRef:x}),[D,A,M,R,U]),Z=r=>{r.preventDefault();const v=r.currentTarget,f=i?n.textInput.value:new FormData(v).get("message")||"";i||v.reset(),Promise.all(D.map(async({...u})=>u.url&&u.url.startsWith("blob:")?{...u,url:await J(u.url)}:u)).then(u=>{try{const j=h({text:f,files:u},r);j instanceof Promise?j.then(()=>{R(),i&&n.textInput.clear()}).catch(()=>{}):(R(),i&&n.textInput.clear())}catch{}})},G=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:T}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:a,onChange:Y,ref:x,title:"Upload files",type:"file"}),e.jsx("form",{className:b.cn("w-full",t),onSubmit:Z,...I,children:e.jsx(ne,{className:"overflow-hidden",children:m})})]});return i?G:e.jsx($.Provider,{value:Q,children:G})},fe=({onChange:t,className:s,placeholder:a="What would you like to know?",...l})=>{const o=X(),p=q(),[d,g]=c.useState(!1),h=n=>{if(n.key==="Enter"){if(d||n.nativeEvent.isComposing||n.shiftKey)return;n.preventDefault();const i=n.currentTarget.form,x=i==null?void 0:i.querySelector('button[type="submit"]');if(x!=null&&x.disabled)return;i==null||i.requestSubmit()}if(n.key==="Backspace"&&n.currentTarget.value===""&&p.files.length>0){n.preventDefault();const i=p.files.at(-1);i&&p.remove(i.id)}},m=n=>{var T;const i=(T=n.clipboardData)==null?void 0:T.items;if(!i)return;const x=[];for(const S of i)if(S.kind==="file"){const P=S.getAsFile();P&&x.push(P)}x.length>0&&(n.preventDefault(),p.add(x))},I=o?{value:o.textInput.value,onChange:n=>{o.textInput.setInput(n.currentTarget.value),t==null||t(n)}}:{onChange:t};return e.jsx(oe,{className:b.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>g(!1),onCompositionStart:()=>g(!0),onKeyDown:h,onPaste:m,placeholder:a,...l,...I})},he=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("order-first flex-wrap gap-1",t),...s}),xe=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("justify-between gap-1",t),...s}),ge=({className:t,...s})=>e.jsx("div",{className:b.cn("flex items-center gap-1",t),...s}),F=({variant:t="ghost",className:s,size:a,...l})=>{const o=a??(c.Children.count(l.children)>1?"sm":"icon-sm");return e.jsx(K,{className:b.cn(s),size:o,type:"button",variant:t,...l})},ve=t=>e.jsx(y.DropdownMenu,{...t}),je=({className:t,children:s,...a})=>e.jsx(y.DropdownMenuTrigger,{asChild:!0,children:e.jsx(F,{className:t,...a,children:s??e.jsx(k.PlusIcon,{className:"size-4"})})}),be=({className:t,...s})=>e.jsx(y.DropdownMenuContent,{align:"start",className:b.cn(t),...s}),we=({className:t,variant:s="default",size:a="icon-sm",status:l,children:o,...p})=>{let d=e.jsx(k.CornerDownLeftIcon,{className:"size-4"});return l==="submitted"?d=e.jsx(k.Loader2Icon,{className:"size-4 animate-spin"}):l==="streaming"?d=e.jsx(k.SquareIcon,{className:"size-4"}):l==="error"&&(d=e.jsx(k.XIcon,{className:"size-4"})),e.jsx(K,{"aria-label":"Submit",className:b.cn(t),size:a,type:"submit",variant:s,...p,children:o??d})},Ne=({className:t,textareaRef:s,onTranscriptionChange:a,...l})=>{const[o,p]=c.useState(!1),[d,g]=c.useState(null),h=c.useRef(null);c.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const I=window.SpeechRecognition||window.webkitSpeechRecognition,n=new I;n.continuous=!0,n.interimResults=!0,n.lang="en-US",n.onstart=()=>{p(!0)},n.onend=()=>{p(!1)},n.onresult=i=>{var T;let x="";for(let S=i.resultIndex;S<i.results.length;S++){const P=i.results[S];P.isFinal&&(x+=((T=P[0])==null?void 0:T.transcript)??"")}if(x&&(s!=null&&s.current)){const S=s.current,P=S.value,z=P+(P?" ":"")+x;S.value=z,S.dispatchEvent(new Event("input",{bubbles:!0})),a==null||a(z)}},n.onerror=i=>{console.error("Speech recognition error:",i.error),p(!1)},h.current=n,c.startTransition(()=>g(n))}return()=>{h.current&&h.current.stop()}},[s,a]);const m=c.useCallback(()=>{d&&(o?d.stop():d.start())},[d,o]);return e.jsx(F,{className:b.cn("relative transition-all duration-200",o&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!d,onClick:m,...l,children:e.jsx(k.MicIcon,{className:"size-4"})})},ye=({openDelay:t=0,closeDelay:s=0,...a})=>e.jsx(y.HoverCard,{closeDelay:s,openDelay:t,...a}),Ie=({align:t="start",...s})=>e.jsx(y.HoverCardContent,{align:t,...s}),Se=t=>e.jsx(y.Dialog,{...t}),ke=t=>e.jsx(y.DialogTrigger,{...t}),Pe=({className:t,children:s,title:a="Model Selector",...l})=>e.jsxs(y.DialogContent,{className:b.cn("p-0",t),...l,children:[e.jsx(y.DialogTitle,{className:"sr-only",children:a}),e.jsx(y.Command,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),Te=t=>e.jsx(y.CommandList,{...t}),ze=t=>e.jsx(y.CommandGroup,{...t}),De=t=>e.jsx(y.CommandItem,{...t}),Ae=({provider:t,className:s,...a})=>e.jsx("img",{...a,alt:`${t} logo`,className:b.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Ce=({className:t,...s})=>e.jsx("span",{className:b.cn("flex-1 truncate text-left",t),...s}),Re=({selectedModel:t,onModelChange:s,disabled:a=!1})=>{const[l,o]=c.useState(!1),{models:p}=_.useAIModels(),d=p.find(m=>m.id===t)||p[0],g=p.reduce((m,I)=>(m[I.provider]||(m[I.provider]=[]),m[I.provider].push(I),m),{}),h=m=>{s(m),o(!1)};return e.jsxs(Se,{open:l,onOpenChange:o,children:[e.jsx(ke,{asChild:!0,children:e.jsxs(b.Button,{variant:"outline",size:"sm",disabled:a,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(k.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:d.name})]})}),e.jsxs(Pe,{className:"w-96 p-0",children:[e.jsx("h3",{className:"mt-2 px-2 py-2 font-semibold",children:"Models"}),e.jsx(Te,{children:Object.entries(g).map(([m,I])=>e.jsx(ze,{heading:m.charAt(0).toUpperCase()+m.slice(1),children:I.map(n=>e.jsxs(De,{value:n.id,onSelect:()=>h(n.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(Ae,{provider:n.provider}),e.jsxs("div",{className:"flex flex-1 items-center justify-between",children:[e.jsx(Ce,{children:n.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n.description})]}),t===n.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},n.id))},m))})]})]})},V="chai-ai-selected-model",Le=({input:t,setInput:s,onSend:a,onStop:l,isLoading:o,disabled:p,selectedLang:d,selectedModel:g,onModelChange:h})=>{const{t:m}=te.useTranslation(),{models:I}=_.useAIModels(),n=I.find(N=>N.id==="google/gemini-3-flash")||I[0],[i,x]=c.useState(g||n.id),[T,S]=c.useState(null),P=c.useRef(null),[z,D]=c.useState(!1);c.useEffect(()=>{if(!d){const N=localStorage.getItem(V);N?(x(N),h==null||h(N)):(x(n.id),h==null||h(n.id))}},[d,h,n.id]);const O=N=>{var M;const L=N.files.find(R=>{var U;return(U=R.mediaType)==null?void 0:U.startsWith("image/")}),A=(L==null?void 0:L.url)||T;a((M=N.text)==null?void 0:M.trim(),void 0,A,i),S(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(me,{onSubmit:O,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(he,{className:"p-0",children:e.jsx(de,{className:"pb-0",children:N=>e.jsx(ue,{className:"text-xs",data:N})})}),e.jsx(fe,{ref:P,value:t,onChange:N=>s(N.target.value),placeholder:m(d?"Ask to update content":"Ask me anything..."),disabled:o,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(xe,{children:[d?e.jsx("div",{}):e.jsxs(ge,{children:[e.jsxs(ve,{children:[e.jsx(je,{disabled:o,children:e.jsx(k.Paperclip,{size:16})}),e.jsx(be,{children:e.jsx(pe,{})})]}),e.jsx(Ne,{textareaRef:P,onTranscriptionChange:s,disabled:o}),e.jsx(Re,{selectedModel:i,onModelChange:N=>{x(N),h==null||h(N),localStorage.setItem(V,N)},disabled:o}),e.jsxs(F,{className:"hidden",size:"sm",onClick:()=>D(!z),variant:z?"default":"ghost",children:[e.jsx(k.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),o?e.jsx("button",{onClick:l,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",title:m("Stop generation"),children:e.jsx(k.Square,{size:16})}):e.jsx(we,{disabled:!t.trim()||p,children:e.jsx(k.Send,{size:16})})]})]})})})};exports.default=Le;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { jsx as t, jsxs as a } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { ArrowRight as r } from "lucide-react";
|
|
3
|
+
import { useTranslation as i } from "react-i18next";
|
|
4
|
+
import { B as c } from "./register-chai-top-bar-DWmJ2efT.js";
|
|
5
|
+
import { L as m } from "./index-DqzFD1CG.js";
|
|
6
6
|
const u = ({
|
|
7
7
|
selectedLang: l,
|
|
8
8
|
isLoading: o,
|
|
9
9
|
selectedBlock: s,
|
|
10
10
|
onClick: n
|
|
11
11
|
}) => {
|
|
12
|
-
const { t: e } =
|
|
13
|
-
return /* @__PURE__ */ t("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ t("div", { className: `flex flex-col gap-2 ${o ? "pointer-events-none opacity-50" : ""}`, children: s ? /* @__PURE__ */ t(
|
|
12
|
+
const { t: e } = i();
|
|
13
|
+
return /* @__PURE__ */ t("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ t("div", { className: `flex flex-col gap-2 ${o ? "pointer-events-none opacity-50" : ""}`, children: s ? /* @__PURE__ */ t(c, { variant: "outline", className: "h-auto", onClick: () => n("TRANSLATE"), children: /* @__PURE__ */ a("div", { className: "flex flex-col", children: [
|
|
14
14
|
/* @__PURE__ */ t("p", { className: "text-left text-xs font-thin", children: e("Quick Action:") }),
|
|
15
15
|
/* @__PURE__ */ a("span", { className: "flex items-center gap-x-2 text-sm font-medium", children: [
|
|
16
16
|
e("Translate Content"),
|
|
17
17
|
" ",
|
|
18
18
|
e("to"),
|
|
19
19
|
" ",
|
|
20
|
-
|
|
20
|
+
m[l],
|
|
21
21
|
" ",
|
|
22
|
-
/* @__PURE__ */ t(
|
|
22
|
+
/* @__PURE__ */ t(r, { className: "h-4 w-4" })
|
|
23
23
|
] })
|
|
24
24
|
] }) }) : null }) });
|
|
25
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("lucide-react"),i=require("react-i18next"),c=require("./register-chai-top-bar-CCssW5dL.cjs"),o=require("./index-BYrRPW_c.cjs"),x=({selectedLang:s,isLoading:n,selectedBlock:a,onClick:l})=>{const{t}=i.useTranslation();return e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx("div",{className:`flex flex-col gap-2 ${n?"pointer-events-none opacity-50":""}`,children:a?e.jsx(c.Button,{variant:"outline",className:"h-auto",onClick:()=>l("TRANSLATE"),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-left text-xs font-thin",children:t("Quick Action:")}),e.jsxs("span",{className:"flex items-center gap-x-2 text-sm font-medium",children:[t("Translate Content")," ",t("to")," ",o.LANGUAGES[s]," ",e.jsx(r.ArrowRight,{className:"h-4 w-4"})]})]})}):null})})};exports.default=x;
|