@chaibuilder/pages 0.16.14 → 0.16.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{2AITGKQY-B7xwscsX.js → 2AITGKQY-2rt9M99C.js} +5 -5
- package/dist/{2AITGKQY-B9AnRLq_.cjs → 2AITGKQY-Cs6RBSPQ.cjs} +1 -1
- package/dist/{NCMVHL6D-CRMC-wXy.cjs → NCMVHL6D-CsC6nsSQ.cjs} +1 -1
- package/dist/{NCMVHL6D-B1mwht0Q.js → NCMVHL6D-vUfYKc6i.js} +4 -4
- package/dist/{ZDWCUMSJ-BqqPEOij.cjs → ZDWCUMSJ-B2OZjsr6.cjs} +1 -1
- package/dist/{ZDWCUMSJ-CxKNtXtp.js → ZDWCUMSJ-CzEWKlEU.js} +1 -1
- package/dist/active-in-another-tab-B0N5S-Bh.js +34 -0
- package/dist/active-in-another-tab-BK3cZf-x.cjs +1 -0
- package/dist/{add-new-language-page-D2a6GK-7.cjs → add-new-language-page-Dt1j-8Zg.cjs} +1 -1
- package/dist/{add-new-language-page-DD0qvJJs.js → add-new-language-page-YlqcCdlK.js} +20 -20
- package/dist/{add-new-page-01GDCaa4.cjs → add-new-page-DqhQUQBz.cjs} +1 -1
- package/dist/{add-new-page-CYtuChN1.js → add-new-page-aYomeid4.js} +1 -1
- package/dist/{ai-panel-content-DfdnvlS8.js → ai-panel-content-C6cH9rrC.js} +2 -2
- package/dist/{ai-panel-content-Ouz6pu_0.cjs → ai-panel-content-MOZmNIKP.cjs} +1 -1
- package/dist/{ai-panel-default-lang-Bi2fH1so.js → ai-panel-default-lang-BZHkFsox.js} +3 -3
- package/dist/{ai-panel-default-lang-N1pb8rzQ.cjs → ai-panel-default-lang-DOk_Q0IO.cjs} +2 -2
- package/dist/{ai-panel-other-lang-2JPRSyO1.js → ai-panel-other-lang-D2A46FTg.js} +3 -3
- package/dist/{ai-panel-other-lang-BysU1464.cjs → ai-panel-other-lang-qHrdvAMa.cjs} +1 -1
- package/dist/{ai-prompt-input-JeIqWZco.cjs → ai-prompt-input-BZSjjNJd.cjs} +1 -1
- package/dist/{ai-prompt-input-DadL_cng.js → ai-prompt-input-C6gDvvLQ.js} +2 -2
- package/dist/{ai-translation-prompt-CQb1L7NM.cjs → ai-translation-prompt-BqXo2CLp.cjs} +1 -1
- package/dist/{ai-translation-prompt-B0si-R0R.js → ai-translation-prompt-DTR0wbGt.js} +1 -1
- package/dist/continue-editing-in-this-client-C3T6Jzhi.cjs +1 -0
- package/dist/continue-editing-in-this-client-D2S1yCOM.js +24 -0
- package/dist/delete-page-BF1k60U2.js +70 -0
- package/dist/delete-page-x0DWKzsR.cjs +1 -0
- package/dist/{digital-asset-manager-B5FQGtGY.cjs → digital-asset-manager-BmlFt2T_.cjs} +1 -1
- package/dist/{digital-asset-manager-jfnmWRJj.js → digital-asset-manager-C8udwDBW.js} +1 -1
- package/dist/{duplicate-page-BNjfZ7Wd.cjs → duplicate-page-Dt_QZkTk.cjs} +1 -1
- package/dist/{duplicate-page-CERjaPIW.js → duplicate-page-u_6vUVo1.js} +13 -13
- package/dist/{dynamic-page-selector-Bpz_bvRu.cjs → dynamic-page-selector-Cgs_Y_Kl.cjs} +1 -1
- package/dist/{dynamic-page-selector-XEWV4iCf.js → dynamic-page-selector-DxBHmglP.js} +1 -1
- package/dist/index-BeWL6Sj6.cjs +5 -0
- package/dist/index-DI2Rwk5v.js +4820 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -34
- package/dist/index.js +21 -22
- package/dist/{json-diff-viewer-H-2DkGza.cjs → json-diff-viewer-D2g0Yab2.cjs} +1 -1
- package/dist/{json-diff-viewer-DyvKomxd.js → json-diff-viewer-QdUwk7yF.js} +6 -6
- package/dist/{lang-panel-BWP5A-FD.js → lang-panel-B8OD0GiA.js} +24 -24
- package/dist/{lang-panel-DcZ7u4em.cjs → lang-panel-M2Zb01lF.cjs} +1 -1
- package/dist/{mark-as-template-1oVraE1x.js → mark-as-template-CJ1mlxYT.js} +7 -7
- package/dist/{mark-as-template-B_FyVRRO.cjs → mark-as-template-DONU52b1.cjs} +1 -1
- package/dist/{no-language-page-content-JO4YYUx7.cjs → no-language-page-content-DD9Ok2Ku.cjs} +1 -1
- package/dist/{no-language-page-content-CEci_4j7.js → no-language-page-content-Dtm37LTJ.js} +1 -1
- package/dist/no-language-page-dialog-D3dvenZ7.cjs +1 -0
- package/dist/no-language-page-dialog-Dj_z2_hF.js +10 -0
- package/dist/{page-creator-DJJFl7px.js → page-creator-DIMFISo4.js} +52 -52
- package/dist/{page-creator-BGgoOA92.cjs → page-creator-DTC66ujU.cjs} +1 -1
- package/dist/page-lock-CI6BYvF_.cjs +1 -0
- package/dist/page-lock-DUlNr3os.js +30 -0
- package/dist/page-locked-dialog-BKwULMV7.js +133 -0
- package/dist/page-locked-dialog-DorIbva0.cjs +1 -0
- package/dist/page-manager-new-lNVrLOJp.cjs +1 -0
- package/dist/page-manager-new-znvqI9_L.js +354 -0
- package/dist/{page-manager-search-and-filter-DbUoW8Di.js → page-manager-search-and-filter-C-_w7N27.js} +1 -1
- package/dist/{page-manager-search-and-filter-Dgh8iyGp.cjs → page-manager-search-and-filter-pe0q0qnZ.cjs} +1 -1
- package/dist/{page-revisions-content-CwoXXE53.cjs → page-revisions-content-Caaj5TEI.cjs} +1 -1
- package/dist/{page-revisions-content-CxEJGxLY.js → page-revisions-content-CyLjyxNU.js} +19 -19
- package/dist/pages.css +1 -1
- package/dist/{publish-pages-content-CfAlmivf.js → publish-pages-content-Bih1W9C4.js} +88 -88
- package/dist/publish-pages-content-D5beVcQI.cjs +1 -0
- package/dist/{save-to-lib-BCaBfh0I.js → save-to-lib-BwpkJcT2.js} +1 -1
- package/dist/{save-to-lib-DpyJA0y1.cjs → save-to-lib-DPAERsi4.cjs} +1 -1
- package/dist/{selected-block-display-BmNhvYKu.js → selected-block-display-GXSf3y2s.js} +1 -1
- package/dist/{selected-block-display-CqnwyGRp.cjs → selected-block-display-s99Y91qI.cjs} +1 -1
- package/dist/{seo-panel-BH8fcGqr.js → seo-panel-BurZA566.js} +61 -61
- package/dist/{seo-panel-D-nKfsRJ.cjs → seo-panel-BxUfalVy.cjs} +1 -1
- package/dist/{shared-json-ld-m_OsVv8h.cjs → shared-json-ld-BYAdrPeC.cjs} +1 -1
- package/dist/{shared-json-ld-zTDoJzUv.js → shared-json-ld-DHWdJvQd.js} +39 -39
- package/dist/{slug-input-vzNtu37S.cjs → slug-input-CR2B1kDJ.cjs} +1 -1
- package/dist/{slug-input-CumDDlCk.js → slug-input-Z_ny7bgX.js} +1 -1
- package/dist/take-over-request-CnEpToCM.cjs +1 -0
- package/dist/take-over-request-DF2JsIes.js +63 -0
- package/dist/{theme-panel-footer-CdUmjB-e.js → theme-panel-footer-5mxFeEua.js} +4 -4
- package/dist/{theme-panel-footer-CKccBcd9.cjs → theme-panel-footer-C2CjHoBu.cjs} +1 -1
- package/dist/{unmark-as-template-BNFOsxIg.cjs → unmark-as-template-Dn90g1eh.cjs} +1 -1
- package/dist/{unmark-as-template-6ew-7bf8.js → unmark-as-template-JRRUYTOY.js} +1 -1
- package/dist/{unpublish-page-BZQpTpU3.cjs → unpublish-page-C3C_rTRd.cjs} +1 -1
- package/dist/{unpublish-page-BomE76Wg.js → unpublish-page-FZ8rbi7u.js} +9 -9
- package/dist/{web-preview-jo8lnpEx.js → web-preview-CGBKG162.js} +1 -1
- package/dist/{web-preview-C5QTX7bS.cjs → web-preview-NdxC92Fk.cjs} +1 -1
- package/package.json +3 -3
- package/dist/delete-page-C8Nt7IYF.cjs +0 -1
- package/dist/delete-page-_96Di9yN.js +0 -40
- package/dist/index-Pdb5tSRL.cjs +0 -5
- package/dist/index-e9WlBH0R.js +0 -4960
- package/dist/page-lock-request-BoYzkcyt.cjs +0 -1
- package/dist/page-lock-request-WzpcD2ZN.js +0 -75
- package/dist/page-locked-by-dialog-Djvjp2Hx.js +0 -68
- package/dist/page-locked-by-dialog-bvI27OZ6.cjs +0 -1
- package/dist/page-manager-new-CMfGorRQ.cjs +0 -1
- package/dist/page-manager-new-DmVX0qLk.js +0 -354
- package/dist/publish-pages-content-BRu7qwAo.cjs +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var xs = Object.defineProperty;
|
|
2
2
|
var ws = (e, t, n) => t in e ? xs(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var _e = (e, t, n) => ws(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import {
|
|
4
|
+
import { y as Vn, z as jn, C as K, D as sr, F as H, x as y, G as W, H as oe, S as R, w as O, I as $e, J as Ce, K as G, M as A, N as He, O as ft, Q as ve, R as Ro, U as V, V as $s, W as P, X as wt, Y as un, Z as k, _ as T, $ as Cs, a0 as Kt, a1 as Ss, a2 as ks, a3 as Cn, a4 as Es, a5 as Ds, a6 as Ms, a7 as Nt, a8 as As, a9 as Ts, aa as Fs, ab as ar, ac as Hr, ad as qs, ae as _t, af as Ko, ag as Ur, ah as Is, ai as Os, aj as Kn, ak as Ls, al as Ps, am as _s } from "./index-DI2Rwk5v.js";
|
|
5
5
|
var zs = (e) => e != null, Rs = (e) => e.filter(zs);
|
|
6
6
|
function Ks(e) {
|
|
7
7
|
return (...t) => {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as e, jsxs as a } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation as r } from "@chaibuilder/sdk";
|
|
3
|
+
import { Card as i, CardHeader as o, CardTitle as l, CardContent as c, CardFooter as d, Button as m } from "@chaibuilder/sdk/ui";
|
|
4
|
+
import { TableIcon as h, Edit as u } from "lucide-react";
|
|
5
|
+
import { an as N, a as p, B as T, E as f, P as E } from "./index-DI2Rwk5v.js";
|
|
6
|
+
const S = () => {
|
|
7
|
+
const n = N(), { setPageStatus: s } = p(), { t } = r();
|
|
8
|
+
return /* @__PURE__ */ e(T, { children: /* @__PURE__ */ a(i, { className: "mx-auto w-full max-w-md", children: [
|
|
9
|
+
/* @__PURE__ */ e(o, { className: "space-y-1", children: /* @__PURE__ */ a(l, { className: "flex items-center gap-2 text-xl font-medium", children: [
|
|
10
|
+
/* @__PURE__ */ e(h, { className: "h-6 w-6 text-green-500" }),
|
|
11
|
+
/* @__PURE__ */ e("span", { children: t("Active in Another Tab") })
|
|
12
|
+
] }) }),
|
|
13
|
+
/* @__PURE__ */ e(c, { className: "space-y-4", children: /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t(
|
|
14
|
+
"This page is currently being edited in another tab. You can continue editing here, which will close the editor in the other tab."
|
|
15
|
+
) }) }),
|
|
16
|
+
/* @__PURE__ */ e(d, { className: "flex justify-end gap-2", children: /* @__PURE__ */ a(
|
|
17
|
+
m,
|
|
18
|
+
{
|
|
19
|
+
variant: "default",
|
|
20
|
+
onClick: () => {
|
|
21
|
+
n(f.CONTINUE_EDITING_IN_THIS_TAB_REQUEST), s(E.CHECKING);
|
|
22
|
+
},
|
|
23
|
+
className: "gap-2",
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ e(u, { className: "h-4 w-4" }),
|
|
26
|
+
t("Continue Editing Here")
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
) })
|
|
30
|
+
] }) });
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
S as default
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),a=require("lucide-react"),s=require("./index-BeWL6Sj6.cjs"),l=()=>{const i=s.useSendRealtimeEvent(),{setPageStatus:r}=s.usePageLockStatus(),{t:n}=c.useTranslation();return e.jsx(s.BlurContainer,{children:e.jsxs(t.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(t.CardHeader,{className:"space-y-1",children:e.jsxs(t.CardTitle,{className:"flex items-center gap-2 text-xl font-medium",children:[e.jsx(a.TableIcon,{className:"h-6 w-6 text-green-500"}),e.jsx("span",{children:n("Active in Another Tab")})]})}),e.jsx(t.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:n("This page is currently being edited in another tab. You can continue editing here, which will close the editor in the other tab.")})}),e.jsx(t.CardFooter,{className:"flex justify-end gap-2",children:e.jsxs(t.Button,{variant:"default",onClick:()=>{i(s.EVENT.CONTINUE_EDITING_IN_THIS_TAB_REQUEST),r(s.PAGE_STATUS.CHECKING)},className:"gap-2",children:[e.jsx(a.Edit,{className:"h-4 w-4"}),n("Continue Editing Here")]})})]})})};exports.default=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),V=require("./slug-input-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),V=require("./slug-input-CR2B1kDJ.cjs"),f=require("./index-BeWL6Sj6.cjs"),w=require("@chaibuilder/sdk"),S=require("@chaibuilder/sdk/ui"),Y=require("lodash-es"),is=require("lucide-react"),N=require("react"),X=({edit:c,lang:h,languages:a,name:u,setLang:t,setName:i,primaryPageObject:o})=>{const{t:s}=w.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(S.Label,{htmlFor:"lang",children:s("Language")}),e.jsxs("select",{value:c?"":h,disabled:c||!a.length,onChange:l=>{const x=l.target.value;t(x),!c&&(Y.startsWith(u,o==null?void 0:o.name)||u.length===0)&&i(`${o==null?void 0:o.name} - ${f.LANGUAGES[x]}`)},className:"col-span-3 flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("option",{value:"",disabled:!0,children:c?f.LANGUAGES[h]||h:a.length?s("Choose language"):s("All available language page is created.")}),a.map(l=>e.jsx("option",{value:l,children:f.LANGUAGES[l]||l},l))]})]})},Z=({lang:c,name:h,setName:a,parentHasSelectedLanguagePage:u})=>{const{t}=w.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(S.Label,{htmlFor:"name",children:t("Page Name")}),e.jsx(S.Input,{id:"name",value:c?h:"",onChange:i=>a(i.target.value),required:!0,placeholder:t(c?"Enter page name":"Choose language to add slug"),disabled:!u||!c})]})},ds=({dynamic:c,isNonSlugPageType:h,isRootPage:a,lang:u,useLanguagePrefix:t,setUseLanguagePrefix:i,isHomePage:o,parentSlug:s,parentHasSelectedLanguagePage:l,slug:x,setSlug:d,setIsSlugValid:m,getSlug:g})=>{const{t:r}=w.useTranslation();return h?null:e.jsxs("div",{className:"space-y-1",children:[a&&u&&e.jsxs("div",{className:"flex items-center space-x-2 pb-1",children:[e.jsx("input",{type:"checkbox",id:"useLanguagePrefix",checked:t,onChange:A=>i(A.target.checked),className:"rounded border-gray-300"}),e.jsxs(S.Label,{htmlFor:"useLanguagePrefix",className:"text-sm font-normal leading-tight",children:["Add language code (",e.jsxs("span",{className:"font-mono text-gray-900",children:["/",u]}),") as slug prefix"]})]}),e.jsx(S.Label,{htmlFor:"slug",children:r("Slug")}),c?e.jsx(S.Alert,{variant:"default",className:"p-2 text-xs font-medium italic text-muted-foreground",children:r("This page will use dynamic slug as defined in primary page")}):e.jsx(V.SlugInput,{disabled:!u||!l,value:x,onChange:d,placeholder:r(u?o&&t?"Leave empty for home page":"Enter page slug":"Choose language to add slug"),parentSlug:s,onValidationChange:m,fullSlug:g()})]})},_=({parentHasSelectedLanguagePage:c,name:h,lang:a,slug:u,edit:t,id:i,primaryPageObject:o,pages:s,isNonSlugPageType:l,isHomePage:x,useLanguagePrefix:d,isSlugValid:m,isPending:g})=>{const{t:r}=w.useTranslation(),A=g||!h||!a||s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)||!l&&!(x&&d)&&(!m||!u);return e.jsx(S.DialogFooter,{children:c?e.jsxs(e.Fragment,{children:[e.jsx(S.Button,{type:"submit",disabled:A&&!o.dynamic,children:g?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"loader mr-2"}),r(t?"Updating...":"Adding...")]}):r(t?"Update":"Add new language page")}),s.some(v=>(t?v.id!==i:!0)&&v.parent===(o==null?void 0:o.id)&&v.lang===a)&&e.jsx("p",{className:"mt-2 text-xs text-red-500",children:r("A page for this language already exists.")})]}):a&&e.jsx(S.Alert,{variant:"destructive",children:e.jsxs("p",{className:"mx-auto w-5/6 text-center",children:[r("You need to create the")," ",e.jsx("span",{className:"font-medium",children:f.LANGUAGES[a]})," ",r("page in the parent to add here.")]})})})},cs=({onSubmit:c,edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s,parentHasSelectedLanguagePage:l,id:x,pages:d,isNonSlugPageType:m,isHomePage:g,useLanguagePrefix:r,slug:A,isSlugValid:v,isPending:E})=>e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s}),e.jsx(Z,{lang:a,name:t,setName:o,parentHasSelectedLanguagePage:l})]}),e.jsx(_,{parentHasSelectedLanguagePage:l,name:t,lang:a,slug:A,edit:h,id:x,primaryPageObject:s,pages:d,isNonSlugPageType:m,isHomePage:g,useLanguagePrefix:r,isSlugValid:v,isPending:E})]}),rs=({loading:c,onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,isNonSlugPageType:d,isRootPage:m,useLanguagePrefix:g,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,slug:E,setSlug:C,isSlugValid:T,setIsSlugValid:R,getSlug:M,isPending:$,id:D,pages:L})=>c?e.jsx("div",{className:"flex h-80 items-center justify-center",children:e.jsx(is.Loader,{className:"animate-spin"})}):d?e.jsx(cs,{onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,id:D,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:g,slug:E,isSlugValid:T,isPending:$}):e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(X,{edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l}),e.jsx(Z,{lang:u,name:i,setName:s,parentHasSelectedLanguagePage:x}),e.jsx(ds,{dynamic:l==null?void 0:l.dynamic,isNonSlugPageType:d,isRootPage:m,lang:u,useLanguagePrefix:g,setUseLanguagePrefix:r,isHomePage:A,parentSlug:v,parentHasSelectedLanguagePage:x,slug:E,setSlug:C,isSlugValid:T,setIsSlugValid:R,getSlug:M})]}),e.jsx(_,{parentHasSelectedLanguagePage:x,name:i,lang:u,slug:E,edit:a,id:D,primaryPageObject:l,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:g,isSlugValid:T,isPending:$})]}),hs=({id:c,isOpen:h,onClose:a,primaryPage:u,edit:t=!1,preselectedLang:i})=>{const{data:o=[]}=f.useWebsitePages(),s=N.useMemo(()=>o.find(n=>n.id===u),[o,u]),[l,x]=N.useState(""),[d,m]=N.useState(""),[g,r]=N.useState(""),[A,v]=N.useState(!0),[E,C]=N.useState(!0),{mutate:T,isPending:R}=f.useCreatePage(),{mutate:M,isPending:$}=f.useUpdatePage(),D=R||$,{data:L,isFetching:H}=f.useWebsiteSetting(),j=f.useFallbackLang(),{data:G,isFetching:b}=f.useLanguagePages(u),{data:F=[],isFetching:y}=f.useLanguagePages(s==null?void 0:s.parent),{data:z=[],isFetching:P}=f.usePageTypes(),{setSelectedLang:O}=w.useLanguages(),{t:I}=w.useTranslation(),[,ss]=f.useSearchParams(),[,es]=w.useSidebarActivePanel(),ns=H||b||y||P,U=N.useMemo(()=>Y.filter(L==null?void 0:L.languages,n=>!Y.find(G,{lang:n})),[L,G]),W=N.useMemo(()=>z.find(n=>n.key===(s==null?void 0:s.pageType)),[z,s==null?void 0:s.pageType]),J=!(W!=null&&W.hasSlug),B=(s==null?void 0:s.slug)==="/";N.useEffect(()=>{if(!t&&s&&i&&(m(i),x(`${s.name} - ${f.LANGUAGES[i]}`)),!t||!s)return;const n=G==null?void 0:G.find(us=>us.id===c);if(!n)return;x(n.name),m(n.lang);const p=n.slug||"",{initSlug:k,prefix:as}=V.parseSlugForEdit(p,s);r(k),C(as)},[t,c,G,s,i]),N.useEffect(()=>{if(i)m(i);else if((U==null?void 0:U.length)===1&&!t){const n=U[0];if(!n||!f.LANGUAGES[n])return;m(n),(!l||l===(s==null?void 0:s.name))&&x(`${s==null?void 0:s.name} - ${f.LANGUAGES[n]}`)}},[i,U,t,l,s]);const{parentSlug:K,isRootPage:q}=N.useMemo(()=>{if(B||!d)return{parentSlug:void 0,isRootPage:!(s!=null&&s.parent)};if(!(s!=null&&s.parent))return{parentSlug:E?`/${d}`:void 0,isRootPage:!0};const n=F==null?void 0:F.find(p=>p.lang===d);return{parentSlug:n==null?void 0:n.slug,isRootPage:!1}},[s==null?void 0:s.parent,F,E,d,B]),ts=N.useMemo(()=>q?!0:!!(F!=null&&F.some(n=>(n==null?void 0:n.lang)===d)),[d,F,q]),Q=()=>{let n="";return q?n=`/${E?[d,g].filter(Boolean).join("/"):g}`:n=`${V.removeSlugExtension(K)}/${g}`,n.replace(/\/{2,}/g,"/").replace(/\/$/,"")},os=n=>{const p=new URLSearchParams(window.location.search);j&&n===j?p.delete("lang"):p.set("lang",n),ss(p),window.dispatchEvent(new PopStateEvent("popstate"))},ls=n=>{n.preventDefault();const p={name:l,lang:d,primaryPage:s==null?void 0:s.id,slug:J?"":Q(),pageType:s==null?void 0:s.pageType,...t&&{id:c}},k=()=>{!t&&d&&(O(d),os(d)),es("outline"),a()};t?M(p,{onSuccess:k}):T(p,{onSuccess:k})};return e.jsx(S.Dialog,{open:h,onOpenChange:a,children:h&&e.jsxs(S.DialogContent,{className:"text-slate-600 sm:max-w-[425px]",children:[e.jsxs(S.DialogHeader,{children:[e.jsx(S.DialogTitle,{children:I(t?"Edit language":"Add new language page")}),e.jsx(S.DialogDescription,{className:"font-light",children:I("Enter the details for the language")})]}),e.jsx(rs,{id:c,pages:o,loading:ns,onSubmit:ls,edit:t,lang:d,languages:U,name:l,setLang:m,setName:x,primaryPageObject:s,parentHasSelectedLanguagePage:ts,isNonSlugPageType:J,isRootPage:q,useLanguagePrefix:E,setUseLanguagePrefix:C,isHomePage:B,parentSlug:K,slug:g,setSlug:r,isSlugValid:A,setIsSlugValid:v,getSlug:Q,isPending:D})]})})};exports.default=hs;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as t, jsxs as g, Fragment as hn } from "react/jsx-runtime";
|
|
2
|
-
import { p as fn, r as gn, S as mn } from "./slug-input-
|
|
3
|
-
import {
|
|
4
|
-
import { useLanguages as An, useTranslation as
|
|
5
|
-
import { Dialog as En, DialogContent as $n, DialogHeader as Dn, DialogTitle as Ln, DialogDescription as
|
|
2
|
+
import { p as fn, r as gn, S as mn } from "./slug-input-Z_ny7bgX.js";
|
|
3
|
+
import { g as xn, h as vn, i as Sn, j as pn, k as Nn, l as Z, m as Fn, c as wn, L as A } from "./index-DI2Rwk5v.js";
|
|
4
|
+
import { useLanguages as An, useTranslation as k, useSidebarActivePanel as Cn } from "@chaibuilder/sdk";
|
|
5
|
+
import { Dialog as En, DialogContent as $n, DialogHeader as Dn, DialogTitle as Ln, DialogDescription as kn, Label as I, Input as Tn, Alert as H, DialogFooter as Un, Button as Rn } from "@chaibuilder/sdk/ui";
|
|
6
6
|
import { filter as Wn, find as Bn, startsWith as In } from "lodash-es";
|
|
7
7
|
import { Loader as Gn } from "lucide-react";
|
|
8
8
|
import { useMemo as D, useState as L, useEffect as _ } from "react";
|
|
@@ -15,7 +15,7 @@ const b = ({
|
|
|
15
15
|
setName: d,
|
|
16
16
|
primaryPageObject: o
|
|
17
17
|
}) => {
|
|
18
|
-
const { t: n } =
|
|
18
|
+
const { t: n } = k();
|
|
19
19
|
return /* @__PURE__ */ g("div", { className: "space-y-1", children: [
|
|
20
20
|
/* @__PURE__ */ t(I, { htmlFor: "lang", children: n("Language") }),
|
|
21
21
|
/* @__PURE__ */ g(
|
|
@@ -36,11 +36,11 @@ const b = ({
|
|
|
36
36
|
)
|
|
37
37
|
] });
|
|
38
38
|
}, y = ({ lang: c, name: h, setName: a, parentHasSelectedLanguagePage: i }) => {
|
|
39
|
-
const { t: s } =
|
|
39
|
+
const { t: s } = k();
|
|
40
40
|
return /* @__PURE__ */ g("div", { className: "space-y-1", children: [
|
|
41
41
|
/* @__PURE__ */ t(I, { htmlFor: "name", children: s("Page Name") }),
|
|
42
42
|
/* @__PURE__ */ t(
|
|
43
|
-
|
|
43
|
+
Tn,
|
|
44
44
|
{
|
|
45
45
|
id: "name",
|
|
46
46
|
value: c ? h : "",
|
|
@@ -66,7 +66,7 @@ const b = ({
|
|
|
66
66
|
setIsSlugValid: x,
|
|
67
67
|
getSlug: m
|
|
68
68
|
}) => {
|
|
69
|
-
const { t: r } =
|
|
69
|
+
const { t: r } = k();
|
|
70
70
|
return h ? null : /* @__PURE__ */ g("div", { className: "space-y-1", children: [
|
|
71
71
|
a && i && /* @__PURE__ */ g("div", { className: "flex items-center space-x-2 pb-1", children: [
|
|
72
72
|
/* @__PURE__ */ t(
|
|
@@ -117,8 +117,8 @@ const b = ({
|
|
|
117
117
|
isSlugValid: x,
|
|
118
118
|
isPending: m
|
|
119
119
|
}) => {
|
|
120
|
-
const { t: r } =
|
|
121
|
-
return /* @__PURE__ */ t(
|
|
120
|
+
const { t: r } = k(), S = m || !h || !a || n.some((v) => (s ? v.id !== d : !0) && v.parent === (o == null ? void 0 : o.id) && v.lang === a) || !l && !(f && u) && (!x || !i);
|
|
121
|
+
return /* @__PURE__ */ t(Un, { children: c ? /* @__PURE__ */ g(hn, { children: [
|
|
122
122
|
/* @__PURE__ */ t(Rn, { type: "submit", disabled: S && !o.dynamic, children: m ? /* @__PURE__ */ g("span", { className: "flex items-center gap-2", children: [
|
|
123
123
|
/* @__PURE__ */ t("span", { className: "loader mr-2" }),
|
|
124
124
|
r(s ? "Updating..." : "Adding...")
|
|
@@ -211,11 +211,11 @@ const b = ({
|
|
|
211
211
|
isHomePage: S,
|
|
212
212
|
parentSlug: v,
|
|
213
213
|
slug: p,
|
|
214
|
-
setSlug:
|
|
214
|
+
setSlug: T,
|
|
215
215
|
isSlugValid: $,
|
|
216
216
|
setIsSlugValid: G,
|
|
217
217
|
getSlug: q,
|
|
218
|
-
isPending:
|
|
218
|
+
isPending: U,
|
|
219
219
|
id: R,
|
|
220
220
|
pages: w
|
|
221
221
|
}) => c ? /* @__PURE__ */ t("div", { className: "flex h-80 items-center justify-center", children: /* @__PURE__ */ t(Gn, { className: "animate-spin" }) }) : u ? /* @__PURE__ */ t(
|
|
@@ -237,7 +237,7 @@ const b = ({
|
|
|
237
237
|
useLanguagePrefix: m,
|
|
238
238
|
slug: p,
|
|
239
239
|
isSlugValid: $,
|
|
240
|
-
isPending:
|
|
240
|
+
isPending: U
|
|
241
241
|
}
|
|
242
242
|
) : /* @__PURE__ */ g("form", { onSubmit: h, children: [
|
|
243
243
|
/* @__PURE__ */ g("div", { className: "grid gap-4 py-4", children: [
|
|
@@ -275,7 +275,7 @@ const b = ({
|
|
|
275
275
|
parentSlug: v,
|
|
276
276
|
parentHasSelectedLanguagePage: f,
|
|
277
277
|
slug: p,
|
|
278
|
-
setSlug:
|
|
278
|
+
setSlug: T,
|
|
279
279
|
isSlugValid: $,
|
|
280
280
|
setIsSlugValid: G,
|
|
281
281
|
getSlug: q
|
|
@@ -297,7 +297,7 @@ const b = ({
|
|
|
297
297
|
isHomePage: S,
|
|
298
298
|
useLanguagePrefix: m,
|
|
299
299
|
isSlugValid: $,
|
|
300
|
-
isPending:
|
|
300
|
+
isPending: U
|
|
301
301
|
}
|
|
302
302
|
)
|
|
303
303
|
] }), Hn = ({
|
|
@@ -308,9 +308,9 @@ const b = ({
|
|
|
308
308
|
edit: s = !1,
|
|
309
309
|
preselectedLang: d
|
|
310
310
|
}) => {
|
|
311
|
-
const { data: o = [] } = xn(), n = D(() => o.find((e) => e.id === i), [o, i]), [l, f] = L(""), [u, x] = L(""), [m, r] = L(""), [S, v] = L(!0), [p,
|
|
311
|
+
const { data: o = [] } = xn(), n = D(() => o.find((e) => e.id === i), [o, i]), [l, f] = L(""), [u, x] = L(""), [m, r] = L(""), [S, v] = L(!0), [p, T] = L(!0), { mutate: $, isPending: G } = vn(), { mutate: q, isPending: U } = Sn(), R = G || U, { data: w, isFetching: j } = pn(), z = Nn(), { data: C, isFetching: O } = Z(i), { data: F = [], isFetching: nn } = Z(
|
|
312
312
|
n == null ? void 0 : n.parent
|
|
313
|
-
), { data: J = [], isFetching: en } = Fn(), { setSelectedLang: sn } = An(), { t: M } =
|
|
313
|
+
), { data: J = [], isFetching: en } = Fn(), { setSelectedLang: sn } = An(), { t: M } = k(), [, tn] = wn(), [, on] = Cn(), ln = j || O || nn || en, E = D(() => Wn(w == null ? void 0 : w.languages, (e) => !Bn(C, { lang: e })), [w, C]), V = D(
|
|
314
314
|
() => J.find((e) => e.key === (n == null ? void 0 : n.pageType)),
|
|
315
315
|
[J, n == null ? void 0 : n.pageType]
|
|
316
316
|
), K = !(V != null && V.hasSlug), Y = (n == null ? void 0 : n.slug) === "/";
|
|
@@ -320,7 +320,7 @@ const b = ({
|
|
|
320
320
|
if (!e) return;
|
|
321
321
|
f(e.name), x(e.lang);
|
|
322
322
|
const N = e.slug || "", { initSlug: B, prefix: cn } = fn(N, n);
|
|
323
|
-
r(B),
|
|
323
|
+
r(B), T(cn);
|
|
324
324
|
}, [s, c, C, n, d]), _(() => {
|
|
325
325
|
if (d)
|
|
326
326
|
x(d);
|
|
@@ -363,7 +363,7 @@ const b = ({
|
|
|
363
363
|
return /* @__PURE__ */ t(En, { open: h, onOpenChange: a, children: h && /* @__PURE__ */ g($n, { className: "text-slate-600 sm:max-w-[425px]", children: [
|
|
364
364
|
/* @__PURE__ */ g(Dn, { children: [
|
|
365
365
|
/* @__PURE__ */ t(Ln, { children: M(s ? "Edit language" : "Add new language page") }),
|
|
366
|
-
/* @__PURE__ */ t(
|
|
366
|
+
/* @__PURE__ */ t(kn, { className: "font-light", children: M("Enter the details for the language") })
|
|
367
367
|
] }),
|
|
368
368
|
/* @__PURE__ */ t(
|
|
369
369
|
Vn,
|
|
@@ -383,7 +383,7 @@ const b = ({
|
|
|
383
383
|
isNonSlugPageType: K,
|
|
384
384
|
isRootPage: W,
|
|
385
385
|
useLanguagePrefix: p,
|
|
386
|
-
setUseLanguagePrefix:
|
|
386
|
+
setUseLanguagePrefix: T,
|
|
387
387
|
isHomePage: Y,
|
|
388
388
|
parentSlug: Q,
|
|
389
389
|
slug: m,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk"),n=require("@chaibuilder/sdk/ui"),t=require("react"),u=t.lazy(()=>Promise.resolve().then(()=>require("./page-creator-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk"),n=require("@chaibuilder/sdk/ui"),t=require("react"),u=t.lazy(()=>Promise.resolve().then(()=>require("./page-creator-DTC66ujU.cjs"))),x=({addEditPage:s,setAddEditPage:r,closePanel:c})=>{const{t:o}=a.useTranslation(),i=!!(s!=null&&s.id),l=!!s;return e.jsx(n.Dialog,{open:l,onOpenChange:()=>r(void 0),children:l&&e.jsxs(n.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(n.DialogHeader,{children:[e.jsxs(n.DialogTitle,{children:[o(i?"Edit":"Add New")," "]}),e.jsx(n.DialogDescription,{children:o(i?"Update your page name":"Enter details to create a new page")})]}),e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"min-h-40"}),children:e.jsx(u,{closePanel:c,addEditPage:s,close:()=>r(void 0)})})]})})};exports.default=x;
|
|
@@ -2,7 +2,7 @@ import { jsx as e, jsxs as r } from "react/jsx-runtime";
|
|
|
2
2
|
import { useTranslation as a } from "@chaibuilder/sdk";
|
|
3
3
|
import { Dialog as c, DialogContent as m, DialogHeader as p, DialogTitle as h, DialogDescription as f } from "@chaibuilder/sdk/ui";
|
|
4
4
|
import { lazy as D, Suspense as u } from "react";
|
|
5
|
-
const x = D(() => import("./page-creator-
|
|
5
|
+
const x = D(() => import("./page-creator-DIMFISo4.js")), C = ({
|
|
6
6
|
addEditPage: o,
|
|
7
7
|
setAddEditPage: i,
|
|
8
8
|
closePanel: t
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as g, Fragment as k, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { at as A, c as F } from "./index-DI2Rwk5v.js";
|
|
3
3
|
import { useTranslation as G, useLanguages as B } from "@chaibuilder/sdk";
|
|
4
4
|
import { Button as I } from "@chaibuilder/sdk/ui";
|
|
5
5
|
import { Plus as _ } from "lucide-react";
|
|
@@ -62,7 +62,7 @@ const v = [
|
|
|
62
62
|
description: "2x Credits",
|
|
63
63
|
multiplier: 2
|
|
64
64
|
}
|
|
65
|
-
], X = (o) => v.find((s) => s.id === o), D = () => v[0], E = C(() => import("./ai-panel-default-lang-
|
|
65
|
+
], X = (o) => v.find((s) => s.id === o), D = () => v[0], E = C(() => import("./ai-panel-default-lang-BZHkFsox.js")), R = C(() => import("./ai-panel-other-lang-D2A46FTg.js")), H = () => {
|
|
66
66
|
const { t: o } = G(), [s, a] = i(""), [e, l] = i([]), [c, d] = i(!1), [u, p] = i(null), [P, m] = i(null), [b, S] = i(D().id), { selectedLang: f, fallbackLang: w } = B(), L = A(), [M] = F(), y = M.get("page"), N = (e == null ? void 0 : e.filter((t) => t.role === "user").length) >= 4, j = (e == null ? void 0 : e.filter((t) => t.role === "user").length) >= 10;
|
|
67
67
|
z(() => {
|
|
68
68
|
l([]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),C=require("./index-
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),C=require("./index-BeWL6Sj6.cjs"),S=require("@chaibuilder/sdk"),N=require("@chaibuilder/sdk/ui"),A=require("lucide-react"),n=require("react"),I=require("sonner"),h=[{id:"google/gemini-2.5-flash",name:"Gemini 2.5 Flash",provider:"google",description:"0.5x Credits",multiplier:.5},{id:"google/gemini-2.5-flash-pro",name:"Gemini 2.5 Flash Pro",provider:"google",description:"1.25x Credits",multiplier:1.25},{id:"google/gemini-3-pro",name:"Gemini 3 Pro",provider:"google",description:"2.5x Credits",multiplier:2.5},{id:"openai/gpt-5",name:"GPT-5",provider:"openai",description:"2x Credits",multiplier:2},{id:"anthropic/claude-haiku-4.5",name:"Claude Haiku 4.5",provider:"anthropic",description:"1x Credits",multiplier:1},{id:"anthropic/claude-sonnet-4",name:"Claude Sonnet 4",provider:"anthropic",description:"3x Credits",multiplier:3},{id:"anthropic/claude-sonnet-4.5",name:"Claude Sonnet 4.5",provider:"anthropic",description:"3x Credits",multiplier:3},{id:"openai/gpt-4.1",name:"GPT-4.1",provider:"openai",description:"2x Credits",multiplier:2}],B=s=>h.find(r=>r.id===s),j=()=>h[0],F=n.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-default-lang-DOk_Q0IO.cjs"))),G=n.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-other-lang-qHrdvAMa.cjs"))),_=()=>{const{t:s}=S.useTranslation(),[r,a]=n.useState(""),[t,o]=n.useState([]),[c,d]=n.useState(!1),[u,p]=n.useState(null),[v,g]=n.useState(null),[P,b]=n.useState(j().id),{selectedLang:f,fallbackLang:M}=S.useLanguages(),y=C.useBuilderFetch(),[L]=C.useSearchParams(),q=L.get("page"),w=(t==null?void 0:t.filter(i=>i.role==="user").length)>=4,k=(t==null?void 0:t.filter(i=>i.role==="user").length)>=10;n.useEffect(()=>{o([])},[f,q]);const m=()=>{o([]),a(""),g(null),p(null),d(!1)},x={t:s,fetch:y,input:r,messages:t,setInput:a,isLoading:c,handleStop:()=>{u&&(u.abort(),p(null)),d(!1),a(""),g(null),o(i=>{const l=i[i.length-1];return l&&l.role==="assistant"&&l.isReasoning&&l.isStreaming?i.slice(0,-1):i}),I.toast.info(s("Generation stopped"))},handleReset:m,setMessages:o,setIsLoading:d,currentBlock:v,fallbackLang:M,abortController:u,setCurrentBlock:g,setAbortController:p,forceNewConversation:k,suggestNewConversation:w,selectedModel:P,onModelChange:b};return e.jsxs(e.Fragment,{children:[c&&e.jsx("div",{className:"fixed inset-0 left-0 top-0 z-40 flex h-screen w-screen flex-col items-center justify-center bg-transparent"}),e.jsxs("div",{className:"flex h-full w-full flex-col",children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("p",{className:"text-xs text-gray-500",children:s("Your conversation will not be saved")}),(t==null?void 0:t.length)>0&&e.jsx(N.Button,{variant:"outline",size:"icon",onClick:m,className:"h-6 w-6",disabled:c,children:e.jsx(A.Plus,{})})]}),e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"flex h-full w-full items-center justify-center text-xs",children:"Loading AI Panel"}),children:f?e.jsx(G,{...x,selectedLang:f}):e.jsx(F,{...x})})]})]})},z=Object.freeze(Object.defineProperty({__proto__:null,default:_},Symbol.toStringTag,{value:"Module"}));exports.AI_MODELS=h;exports.aiPanelContent=z;exports.getDefaultModel=j;exports.getModelById=B;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsxs as C, Fragment as F, jsx as f } from "react/jsx-runtime";
|
|
2
|
-
import { C as P, a as W, b as O, R as $, c as q, d as V, T as K, M as _, e as j, f as G, h as z, S as Q, i as U } from "./selected-block-display-
|
|
2
|
+
import { C as P, a as W, b as O, R as $, c as q, d as V, T as K, M as _, e as j, f as G, h as z, S as Q, i as U } from "./selected-block-display-GXSf3y2s.js";
|
|
3
3
|
import { useAddBlock as J, useReplaceBlock as X, useRemoveBlocks as Y, getBlocksFromHTML as L, useSelectedBlock as Z, useSelectedBlockIds as tt, useBlocksHtmlForAi as et } from "@chaibuilder/sdk";
|
|
4
4
|
import { Bot as nt } from "lucide-react";
|
|
5
5
|
import { useCallback as rt, lazy as st, Fragment as ot, Suspense as it } from "react";
|
|
6
6
|
import { toast as at } from "sonner";
|
|
7
|
-
import { g as ct } from "./ai-panel-content-
|
|
7
|
+
import { g as ct } from "./ai-panel-content-C6cH9rrC.js";
|
|
8
8
|
import { useQueryClient as lt } from "@tanstack/react-query";
|
|
9
9
|
const ut = () => {
|
|
10
10
|
const { addPredefinedBlock: k } = J(), x = X(), y = Y(), v = lt(), w = async (s, e) => {
|
|
@@ -199,7 +199,7 @@ const ut = () => {
|
|
|
199
199
|
},
|
|
200
200
|
[y]
|
|
201
201
|
);
|
|
202
|
-
}, dt = st(() => import("./ai-prompt-input-
|
|
202
|
+
}, dt = st(() => import("./ai-prompt-input-C6gDvvLQ.js")), bt = ({
|
|
203
203
|
t: k,
|
|
204
204
|
fetch: x,
|
|
205
205
|
input: y,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),g=require("./selected-block-display-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),g=require("./selected-block-display-s99Y91qI.cjs"),y=require("@chaibuilder/sdk"),L=require("lucide-react"),j=require("react"),P=require("sonner"),F=require("./ai-panel-content-MOZmNIKP.cjs"),O=require("@tanstack/react-query"),W=()=>{const{addPredefinedBlock:b}=y.useAddBlock(),H=y.useReplaceBlock(),I=y.useRemoveBlocks(),C=O.useQueryClient(),T=async(s,e)=>{if(!e)return;const r=y.getBlocksFromHTML(e);await b(r,s.parentId,s.position)},B=async(s,e)=>{if(!s.blockId||!e)return;const r=y.getBlocksFromHTML(e);await H(s.blockId,r)},v=async s=>{!s.ids||s.ids.length===0||await I(s.ids)};let f=null;const w=(s,e)=>{const r=document.getElementById("canvas-iframe");if(!r)return null;const l=r==null?void 0:r.contentDocument;if(!l)return null;l.querySelectorAll("[data-stream-canvas]").forEach(d=>d.remove());let n=null;if(s&&s!=="undefined"&&(n=l.querySelector(`[data-block-id="${s}"]`)),n||(n=l.body),!n)return null;if(f=l.createElement("div"),f.setAttribute("data-stream-canvas","true"),e!==void 0&&e>=0&&n.children){const d=Math.min(e,n.children.length);d<n.children.length?n.insertBefore(f,n.children[d]):n.appendChild(f)}else n.appendChild(f);return f},N=s=>{var n;const e=document.getElementById("canvas-iframe");if(!e)return null;const r=e==null?void 0:e.contentDocument;if(!r)return null;r.querySelectorAll("[data-stream-canvas]").forEach(d=>d.remove());const u=r.querySelector(`[data-block-id="${s}"]`);return u?(f=r.createElement("div"),f.setAttribute("data-stream-canvas","true"),(n=u.parentNode)==null||n.insertBefore(f,u.nextSibling),u.style.display="none",f):null},E=(s,e,r)=>{const l=w(e,r);if(l){l.innerHTML=s;const u=l.getBoundingClientRect(),n=document.getElementById("canvas-iframe"),d=n==null?void 0:n.contentWindow;d&&(u.top>=0&&u.bottom<=d.innerHeight||l.scrollIntoView({behavior:"smooth",block:"nearest"}))}},x=(s,e)=>{const r=N(e);r&&(r.innerHTML=s)},M=s=>{const e=s.match(/^--ACTION=(.+)--$/);if(!e)return null;let l=e[1].replace(/--/g,"").split("|");const n={type:l[0]};return l.forEach(d=>{const t=d.trim();if(t.startsWith("PARENT=")){const A=t.substring(7);n.parentId=A==="undefined"?void 0:A}else t.startsWith("POS=")?n.position=parseInt(t.substring(4)):t.startsWith("ID=")?n.blockId=t.substring(3):t.startsWith("IDS=")&&(n.ids=t.substring(4).split(",").map(A=>A.trim()))}),n};return j.useCallback(async(s,e)=>{const r=new TextDecoder;let l="",u="",n=!1,d=null;const t={isInAction:!1,currentAction:null,htmlBuffer:"",isCapturingHtml:!1},A=async m=>{const o=m.trim();if(o==="--START--"){n=!0;return}if(n){if(o==="--END--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await S(t.currentAction,t.htmlBuffer),f&&(f.remove(),f=null);return}if(o.startsWith("--THINKING=")){const i=o.substring(11);e(c=>{const h=[...c],p=h[h.length-1];if(p&&p.role==="assistant"&&p.isReasoning)p.content=i,p.isStreaming=!1;else{const k={id:Date.now().toString(),role:"assistant",content:i,isReasoning:!0,isStreaming:!1};h.push(k)}return h});return}if(o.startsWith("--TASK=")){const i=o.substring(7),c=`task-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,h={id:c,role:"assistant",content:i.replace(/--$/,""),isTask:!0,isTaskLoading:!0,isTaskCompleted:!1};d=c,e(p=>[...p,h]);return}if(o.startsWith("--MSG=")){const i=o.substring(6),c={id:Date.now().toString(),role:"assistant",content:i.replace(/--$/g,""),isReasoning:!1,isStreaming:!1};e(h=>[...h,c]);return}if(o.startsWith("--ACTION=")){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await S(t.currentAction,t.htmlBuffer),t.currentAction=M(o),t.htmlBuffer="",t.isInAction=!0;return}if(o==="--ENDACTION--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await S(t.currentAction,t.htmlBuffer),d&&(e(i=>i.map(c=>c.isTask?{...c,isTaskCompleted:!0}:c)),d=null),t.currentAction=null,t.htmlBuffer="",t.isInAction=!1;return}if(o==="--HTML--"){t.isCapturingHtml=!0;return}if(o==="--ENDHTML--"){t.isCapturingHtml=!1;return}if(o.startsWith("--HTML--")&&o.includes("--ENDHTML--")){const i=o.match(/^--HTML--(.+?)--ENDHTML--$/);if(i&&t.currentAction){const c=i[1];t.htmlBuffer+=c,t.currentAction.type==="ADD"?E(t.htmlBuffer,t.currentAction.parentId,t.currentAction.position):t.currentAction.type==="EDIT"&&t.currentAction.blockId&&x(t.htmlBuffer,t.currentAction.blockId)}return}t.isCapturingHtml&&t.currentAction&&(t.htmlBuffer+=m+`
|
|
2
2
|
`,t.currentAction.type==="ADD"?E(t.htmlBuffer,t.currentAction.parentId,t.currentAction.position):t.currentAction.type==="EDIT"&&t.currentAction.blockId&&x(t.htmlBuffer,t.currentAction.blockId))}},S=async(m,o)=>{try{switch(m.type){case"ADD":await T(m,o);break;case"EDIT":await B(m,o);break;case"REMOVE":await v(m);break}e(i=>i.filter(c=>!c.isTask))}catch(i){console.log(i)}};try{for(;;){const{done:m,value:o}=await s.read();if(m)break;const i=r.decode(o,{stream:!0});l+=i,u+=i;const c=u.split(`
|
|
3
|
-
`);u=c.pop()||"";for(const h of c)await A(h)}u&&await A(u),C.invalidateQueries({queryKey:["AI_USAGE"]})}catch(m){console.log(m)}},[I])},$=j.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-
|
|
3
|
+
`);u=c.pop()||"";for(const h of c)await A(h)}u&&await A(u),C.invalidateQueries({queryKey:["AI_USAGE"]})}catch(m){console.log(m)}},[I])},$=j.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-BZSjjNJd.cjs"))),V=({t:b,fetch:H,input:I,messages:C,setInput:T,isLoading:B,setMessages:v,handleStop:f,setIsLoading:w,currentBlock:N,fallbackLang:E,setCurrentBlock:x,setAbortController:M,selectedModel:s=F.getDefaultModel().id,onModelChange:e})=>{const r=y.useSelectedBlock(),[,l]=y.useSelectedBlockIds(),u=y.useBlocksHtmlForAi(),n=W(),d=async(t,A,S,m)=>{var p;if(!t||B)return;x(r);const o=u(r?{blockId:r._id,additionalCoreBlocks:["Icon"]}:{additionalCoreBlocks:["Icon"]});if(r&&!o){P.toast.error(b("Something went wrong. Please try again."));return}const i={id:Date.now().toString(),role:"user",content:g.getUserPrompt({language:E,userInput:A||t,currentHtml:o}),userMessage:t},c={id:(Date.now()+1).toString(),role:"assistant",content:"",isReasoning:!0,isStreaming:!0};v(k=>[...k,i,c]),w(!0);const h=new AbortController;M(h);try{const k={messages:[i].map(q=>({role:q.role,content:q.content})),model:m||s};S&&(k.image=S);const D=await H({body:{action:"ASK_AI",data:k},streamResponse:!0});if(!D.ok)throw new Error(b("Failed to get AI response"));const R=(p=D.body)==null?void 0:p.getReader();if(!R)throw new Error(b("Response body is not readable"));await n(R,v)}catch(k){if(k.name!=="AbortError"){const D={id:(Date.now()+1).toString(),role:"assistant",content:b("Sorry, I encountered an error. Please try again.")};v(R=>[...R,D])}}finally{T(""),w(!1),x(null),M(null)}};return a.jsxs(a.Fragment,{children:[a.jsxs(g.Conversation,{className:"no-scrollbar",children:[a.jsxs(g.ConversationContent,{className:"gap-2 px-0",children:[C.length===0&&a.jsx(g.ConversationEmptyState,{icon:a.jsx(L.Bot,{size:48,className:"text-gray-300"}),title:"Start a conversation",description:b("Start a conversation with the AI assistant to add/edit current page")}),C.map(t=>t.role!=="system"&&a.jsx(j.Fragment,{children:t.isReasoning?a.jsxs(g.Reasoning,{isStreaming:t.isStreaming,defaultOpen:!0,children:[a.jsx(g.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),a.jsx(g.ReasoningContent,{className:"p-0 text-xs",children:t.content})]}):t.isTask&&!t.isTaskCompleted?a.jsx(g.TaskMessage,{content:t.content,isLoading:t.isTaskLoading}):a.jsx(g.Message,{from:t.role,children:a.jsx(g.MessageContent,{className:"p-0",children:t.role==="assistant"?a.jsx(g.MessageResponse,{className:"p-0 text-xs",children:t.content}):a.jsx("div",{className:"p-0 text-xs",children:t.userMessage||t.content})})})},t.id))]}),a.jsx(g.ConversationScrollButton,{})]}),a.jsxs("div",{className:"border-gray-200 pb-2",children:[a.jsx(g.SelectedBlockDisplay,{onRemove:()=>l([]),isLoading:B}),a.jsx(j.Suspense,{fallback:a.jsx("div",{children:"Loading..."}),children:a.jsx($,{input:I,setInput:T,onSend:d,onStop:f,isLoading:B,selectedLang:"",currentBlock:r||N,disabled:(I==null?void 0:I.length)===0,selectedModel:s,onModelChange:e})})]})]})};exports.default=V;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsxs as i, Fragment as $, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { C as G, a as H, b as Q, R as X, c as Y, d as Z, T as L, M as ee, e as te, f as ne, S as oe, g as se } from "./selected-block-display-
|
|
2
|
+
import { C as G, a as H, b as Q, R as X, c as Y, d as Z, T as L, M as ee, e as te, f as ne, S as oe, g as se } from "./selected-block-display-GXSf3y2s.js";
|
|
3
3
|
import { useTranslation as ae, useSelectedBlock as re, useSelectedBlockIds as ce, useI18nBlocks as ie, useStreamMultipleBlocksProps as le } from "@chaibuilder/sdk";
|
|
4
4
|
import { Bot as de } from "lucide-react";
|
|
5
5
|
import { lazy as v, useRef as ue, useEffect as he, Suspense as B, Fragment as ge } from "react";
|
|
6
|
-
import { g as me } from "./ai-panel-content-
|
|
7
|
-
const fe = v(() => import("./ai-translation-prompt-
|
|
6
|
+
import { g as me } from "./ai-panel-content-C6cH9rrC.js";
|
|
7
|
+
const fe = v(() => import("./ai-translation-prompt-DTR0wbGt.js")), pe = v(() => import("./ai-prompt-input-C6gDvvLQ.js")), be = ({
|
|
8
8
|
fetch: A,
|
|
9
9
|
input: s,
|
|
10
10
|
messages: l,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./selected-block-display-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./selected-block-display-s99Y91qI.cjs"),a=require("@chaibuilder/sdk"),G=require("lucide-react"),o=require("react"),H=require("./ai-panel-content-MOZmNIKP.cjs"),Q=o.lazy(()=>Promise.resolve().then(()=>require("./ai-translation-prompt-BqXo2CLp.cjs"))),X=o.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-BZSjjNJd.cjs"))),Y=({fetch:v,input:c,messages:u,setInput:j,isLoading:i,handleStop:P,setMessages:y,setIsLoading:h,selectedLang:l,currentBlock:q,fallbackLang:A,abortController:x,setAbortController:E,setCurrentBlock:k,selectedModel:S=H.getDefaultModel().id,onModelChange:M})=>{const{t:s}=a.useTranslation(),O=o.useRef(null),d=a.useSelectedBlock(),[,C]=a.useSelectedBlockIds(),T=a.useI18nBlocks(),D=a.useStreamMultipleBlocksProps(),I=()=>{var t;(t=O.current)==null||t.scrollIntoView({behavior:"smooth"})};o.useEffect(()=>{I()},[u,i]);const f=async(t,m,F)=>{var b;d&&k(d);const p=(t==null?void 0:t.toLowerCase())==="translate",R={id:Date.now().toString(),role:"user",content:n.getTranslationUserPrompt({fallbackLang:A,userInput:m||t,language:l,blocks:p?T():T(l)}),userMessage:m||t||s("Translate the content")},_={id:(Date.now()+1).toString(),role:"assistant",content:"Thinking...",isReasoning:!0,isStreaming:!0};h(!0);const z=new AbortController;E(z),y(w=>[...w,R,_]),h(!0);try{const N=await v({body:{action:"ASK_AI",data:{messages:[R],initiator:p?"TRANSLATE_CONTENT":"UPDATE_CONTENT",model:F||S}},streamResponse:!0});if(!N.ok)throw new Error(s("Failed to get AI response"));const B=(b=N.body)==null?void 0:b.getReader(),U=new TextDecoder;let r="";if(!B)throw new Error(s("Response body is not readable"));for(;;){const{done:K,value:V}=await B.read();if(K)break;const W=U.decode(V,{stream:!0});r+=W,y(g=>(g[g.length-1].content=r,[...g]))}const J=JSON.parse(r==null?void 0:r.replace("```json","").replace("```",""));D(J)}catch{x==null||x.abort()}finally{h(!1),j(""),k(null)}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx(o.Suspense,{fallback:e.jsx("div",{children:s("Loading...")}),children:e.jsx(Q,{isLoading:i,selectedBlock:d,selectedLang:l,onClick:f})})}),e.jsx(n.Conversation,{children:e.jsxs(n.ConversationContent,{className:"gap-4 px-0",children:[u.length===0&&e.jsx(n.ConversationEmptyState,{icon:e.jsx(G.Bot,{size:48,className:"text-gray-300"}),title:s("Start a conversation with the AI assistant to translate/edit your content"),description:s("Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language.")}),u.map(t=>t.role!=="system"&&e.jsx(o.Fragment,{children:t.isReasoning?e.jsxs(n.Reasoning,{isStreaming:t.isStreaming,defaultOpen:!0,children:[e.jsx(n.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),e.jsx(n.ReasoningContent,{className:"p-0 text-xs",children:t.content})]}):t.isTask?e.jsx(n.TaskMessage,{content:t.content,isLoading:t.isTaskLoading}):e.jsx(n.Message,{from:t.role,children:e.jsx(n.MessageContent,{className:"p-0",children:t.role==="assistant"?e.jsx(n.MessageResponse,{className:"p-0 text-xs",children:t.content}):e.jsx("div",{className:"p-0 text-xs",children:t.userMessage||t.content})})})},t.id))]})}),e.jsxs("div",{className:"border-gray-200 pb-2",children:[e.jsx(n.SelectedBlockDisplay,{onRemove:()=>C([]),isLoading:i}),e.jsx(o.Suspense,{fallback:e.jsx("div",{children:s("Loading...")}),children:e.jsx(X,{input:c,setInput:j,onSend:f,onStop:P,isLoading:i,selectedLang:l,currentBlock:d||q,disabled:(c==null?void 0:c.length)===0,selectedModel:S,onModelChange:M})})]})]})};exports.default=Y;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./selected-block-display-CqnwyGRp.cjs"),d=require("react"),R=require("cmdk"),b=require("lucide-react"),ye=require("@radix-ui/react-dialog"),Ne=require("@radix-ui/react-dropdown-menu"),we=require("@radix-ui/react-hover-card"),J=require("class-variance-authority"),Se=require("@radix-ui/react-select"),Ie=require("@chaibuilder/sdk"),U=require("./ai-panel-content-Ouz6pu_0.cjs");function q(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const n=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,n.get?n:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const p=q(d),z=q(ye),w=q(Ne),G=q(we),I=q(Se),Ce=z.Root,ke=z.Trigger,Re=z.Portal,Q=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Overlay,{ref:a,className:r.cn("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));Q.displayName=z.Overlay.displayName;const Z=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(Re,{children:[e.jsx(Q,{}),e.jsxs(z.Content,{ref:n,className:r.cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...a,children:[s,e.jsxs(z.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(b.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Z.displayName=z.Content.displayName;const ee=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Title,{ref:a,className:r.cn("text-lg font-semibold leading-none tracking-tight",t),...s}));ee.displayName=z.Title.displayName;const De=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Description,{ref:a,className:r.cn("text-sm text-muted-foreground",t),...s}));De.displayName=z.Description.displayName;const te=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command,{ref:a,className:r.cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));te.displayName=R.Command.displayName;const se=p.forwardRef(({className:t,...s},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(b.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(R.Command.Input,{ref:a,className:r.cn("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));se.displayName=R.Command.Input.displayName;const ae=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.List,{ref:a,className:r.cn("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));ae.displayName=R.Command.List.displayName;const ze=p.forwardRef((t,s)=>e.jsx(R.Command.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));ze.displayName=R.Command.Empty.displayName;const ne=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Group,{ref:a,className:r.cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));ne.displayName=R.Command.Group.displayName;const Pe=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Separator,{ref:a,className:r.cn("-mx-1 h-px bg-border",t),...s}));Pe.displayName=R.Command.Separator.displayName;const oe=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Item,{ref:a,className:r.cn("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t),...s}));oe.displayName=R.Command.Item.displayName;const Te=w.Root,Le=w.Trigger,Ae=p.forwardRef(({className:t,inset:s,children:a,...n},l)=>e.jsxs(w.SubTrigger,{ref:l,className:r.cn("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...n,children:[a,e.jsx(b.ChevronRight,{className:"ml-auto"})]}));Ae.displayName=w.SubTrigger.displayName;const Me=p.forwardRef(({className:t,...s},a)=>e.jsx(w.SubContent,{ref:a,className:r.cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...s}));Me.displayName=w.SubContent.displayName;const re=p.forwardRef(({className:t,sideOffset:s=4,...a},n)=>e.jsx(w.Portal,{children:e.jsx(w.Content,{ref:n,sideOffset:s,className:r.cn("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...a})}));re.displayName=w.Content.displayName;const ie=p.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(w.Item,{ref:n,className:r.cn("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...a}));ie.displayName=w.Item.displayName;const _e=p.forwardRef(({className:t,children:s,checked:a,...n},l)=>e.jsxs(w.CheckboxItem,{ref:l,className:r.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:a,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(w.ItemIndicator,{children:e.jsx(b.Check,{className:"h-4 w-4"})})}),s]}));_e.displayName=w.CheckboxItem.displayName;const Oe=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(w.RadioItem,{ref:n,className:r.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(w.ItemIndicator,{children:e.jsx(b.Circle,{className:"h-2 w-2 fill-current"})})}),s]}));Oe.displayName=w.RadioItem.displayName;const Ue=p.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(w.Label,{ref:n,className:r.cn("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...a}));Ue.displayName=w.Label.displayName;const qe=p.forwardRef(({className:t,...s},a)=>e.jsx(w.Separator,{ref:a,className:r.cn("-mx-1 my-1 h-px bg-muted",t),...s}));qe.displayName=w.Separator.displayName;const Be=G.Root,Ee=G.Trigger,le=p.forwardRef(({className:t,align:s="center",sideOffset:a=4,...n},l)=>e.jsx(G.Content,{ref:l,align:s,sideOffset:a,className:r.cn("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-hover-card-content-transform-origin]",t),...n}));le.displayName=G.Content.displayName;const Fe=p.forwardRef(({className:t,type:s,...a},n)=>e.jsx("input",{type:s,className:r.cn("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...a}));Fe.displayName="Input";const ce=p.forwardRef(({className:t,...s},a)=>e.jsx("textarea",{className:r.cn("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:a,...s}));ce.displayName="Textarea";function Ge({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:r.cn("group/input-group border-input dark:bg-input/30 shadow-xs relative flex w-full items-center rounded-md border outline-none transition-[color,box-shadow]","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-ring has-[[data-slot=input-group-control]:focus-visible]:ring-1","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...s})}const Ve=J.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 de({className:t,align:s="inline-start",...a}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:r.cn(Ve({align:s}),t),onClick:n=>{var l,g;n.target.closest("button")||(g=(l=n.currentTarget.parentElement)==null?void 0:l.querySelector("input"))==null||g.focus()},...a})}const He=J.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 ue({className:t,type:s="button",variant:a="ghost",size:n="xs",...l}){return e.jsx(r.Button,{type:s,"data-size":n,variant:a,className:r.cn(He({size:n}),t),...l})}function We({className:t,...s}){return e.jsx(ce,{"data-slot":"input-group-control",className:r.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 Ke=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(I.Trigger,{ref:n,className:r.cn("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...a,children:[s,e.jsx(I.Icon,{asChild:!0,children:e.jsx(b.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ke.displayName=I.Trigger.displayName;const me=p.forwardRef(({className:t,...s},a)=>e.jsx(I.ScrollUpButton,{ref:a,className:r.cn("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(b.ChevronUp,{className:"h-4 w-4"})}));me.displayName=I.ScrollUpButton.displayName;const pe=p.forwardRef(({className:t,...s},a)=>e.jsx(I.ScrollDownButton,{ref:a,className:r.cn("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(b.ChevronDown,{className:"h-4 w-4"})}));pe.displayName=I.ScrollDownButton.displayName;const Xe=p.forwardRef(({className:t,children:s,position:a="popper",...n},l)=>e.jsx(I.Portal,{children:e.jsxs(I.Content,{ref:l,className:r.cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,...n,children:[e.jsx(me,{}),e.jsx(I.Viewport,{className:r.cn("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(pe,{})]})}));Xe.displayName=I.Content.displayName;const Ye=p.forwardRef(({className:t,...s},a)=>e.jsx(I.Label,{ref:a,className:r.cn("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));Ye.displayName=I.Label.displayName;const $e=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(I.Item,{ref:n,className:r.cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(I.ItemIndicator,{children:e.jsx(b.Check,{className:"h-4 w-4"})})}),e.jsx(I.ItemText,{children:s})]}));$e.displayName=I.Item.displayName;const Je=p.forwardRef(({className:t,...s},a)=>e.jsx(I.Separator,{ref:a,className:r.cn("-mx-1 my-1 h-px bg-muted",t),...s}));Je.displayName=I.Separator.displayName;const Qe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ze=(t=21)=>{let s="",a=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)s+=Qe[a[t]&63];return s};const et=d.createContext(null),tt=d.createContext(null),fe=()=>d.useContext(et),st=()=>d.useContext(tt),xe=d.createContext(null),V=()=>{const t=st(),s=d.useContext(xe),a=t??s;if(!a)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return a};function at({data:t,className:s,...a}){var v;const n=V(),l=t.filename||"",u=((v=t.mediaType)!=null&&v.startsWith("image/")&&t.url?"image":"file")==="image",y=l||(u?"Image":"Attachment");return e.jsxs(gt,{children:[e.jsx(Ee,{asChild:!0,children:e.jsxs("div",{className:r.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:u?e.jsx("img",{alt:l||"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(b.PaperclipIcon,{className:"size-3"})})}),e.jsxs(r.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:k=>{k.stopPropagation(),n.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(b.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:y})]},t.id)}),e.jsx(ht,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[u&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:l||"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:l||(u?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function nt({children:t,className:s,...a}){const n=V();return n.files.length?e.jsx("div",{className:r.cn("flex flex-wrap items-center gap-2 p-3",s),...a,children:n.files.map(l=>e.jsx(d.Fragment,{children:t(l)},l.id))}):null}const ot=({label:t="Add photos or files",...s})=>{const a=V();return e.jsxs(ie,{...s,onSelect:n=>{n.preventDefault(),a.openFileDialog()},children:[e.jsx(b.ImageIcon,{className:"mr-2 size-4"})," ",t]})},rt=({className:t,accept:s,multiple:a,globalDrop:n,syncHiddenInput:l,maxFiles:g,maxFileSize:u,onError:y,onSubmit:v,children:k,...T})=>{const o=fe(),c=!!o,m=d.useRef(null),P=d.useRef(null),C=d.useRef(null);d.useEffect(()=>{var N;const i=(N=P.current)==null?void 0:N.closest("form");i instanceof HTMLFormElement&&(C.current=i)},[]);const[D,A]=d.useState([]),j=c?o.attachments.files:D,M=d.useCallback(()=>{var i;(i=m.current)==null||i.click()},[]),B=d.useCallback(i=>!s||s.trim()===""?!0:s.includes("image/*")?i.type.startsWith("image/"):!0,[s]),E=d.useCallback(i=>{const N=Array.from(i),h=N.filter(S=>B(S));if(N.length&&h.length===0){y==null||y({code:"accept",message:"No files match the accepted types."});return}const x=S=>u?S.size<=u:!0,f=h.filter(x);if(h.length>0&&f.length===0){y==null||y({code:"max_file_size",message:"All files exceed the maximum size."});return}A(S=>{const _=typeof g=="number"?Math.max(0,g-S.length):void 0,je=typeof _=="number"?f.slice(0,_):f;typeof _=="number"&&f.length>_&&(y==null||y({code:"max_files",message:"Too many files. Some were not added."}));const Y=[];for(const H of je)Y.push({id:Ze(),type:"file",url:URL.createObjectURL(H),mediaType:H.type,filename:H.name});return S.concat(Y)})},[B,g,u,y]),L=c?i=>o.attachments.add(i):E,O=c?i=>o.attachments.remove(i):i=>A(N=>{const h=N.find(x=>x.id===i);return h!=null&&h.url&&URL.revokeObjectURL(h.url),N.filter(x=>x.id!==i)}),F=c?()=>o.attachments.clear():()=>A(i=>{for(const N of i)N.url&&URL.revokeObjectURL(N.url);return[]}),K=c?()=>o.attachments.openFileDialog():M;d.useEffect(()=>{c&&o.__registerFileInput(m,()=>{var i;return(i=m.current)==null?void 0:i.click()})},[c,o]),d.useEffect(()=>{l&&m.current&&j.length===0&&(m.current.value="")},[j,l]),d.useEffect(()=>{const i=C.current;if(!i)return;const N=x=>{var f,S;(S=(f=x.dataTransfer)==null?void 0:f.types)!=null&&S.includes("Files")&&x.preventDefault()},h=x=>{var f,S,_;(S=(f=x.dataTransfer)==null?void 0:f.types)!=null&&S.includes("Files")&&x.preventDefault(),(_=x.dataTransfer)!=null&&_.files&&x.dataTransfer.files.length>0&&L(x.dataTransfer.files)};return i.addEventListener("dragover",N),i.addEventListener("drop",h),()=>{i.removeEventListener("dragover",N),i.removeEventListener("drop",h)}},[L]),d.useEffect(()=>{if(!n)return;const i=h=>{var x,f;(f=(x=h.dataTransfer)==null?void 0:x.types)!=null&&f.includes("Files")&&h.preventDefault()},N=h=>{var x,f,S;(f=(x=h.dataTransfer)==null?void 0:x.types)!=null&&f.includes("Files")&&h.preventDefault(),(S=h.dataTransfer)!=null&&S.files&&h.dataTransfer.files.length>0&&L(h.dataTransfer.files)};return document.addEventListener("dragover",i),document.addEventListener("drop",N),()=>{document.removeEventListener("dragover",i),document.removeEventListener("drop",N)}},[L,n]),d.useEffect(()=>()=>{if(!c)for(const i of j)i.url&&URL.revokeObjectURL(i.url)},[c,j]);const ge=i=>{i.currentTarget.files&&L(i.currentTarget.files)},he=async i=>{const h=await(await fetch(i)).blob();return new Promise((x,f)=>{const S=new FileReader;S.onloadend=()=>x(S.result),S.onerror=f,S.readAsDataURL(h)})},be=d.useMemo(()=>({files:j.map(i=>({...i,id:i.id})),add:L,remove:O,clear:F,openFileDialog:K,fileInputRef:m}),[j,L,O,F,K]),ve=i=>{i.preventDefault();const N=i.currentTarget,h=c?o.textInput.value:new FormData(N).get("message")||"";c||N.reset(),Promise.all(j.map(async({id:x,...f})=>f.url&&f.url.startsWith("blob:")?{...f,url:await he(f.url)}:f)).then(x=>{try{const f=v({text:h,files:x},i);f instanceof Promise?f.then(()=>{F(),c&&o.textInput.clear()}).catch(()=>{}):(F(),c&&o.textInput.clear())}catch{}})},X=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:P}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:a,onChange:ge,ref:m,title:"Upload files",type:"file"}),e.jsx("form",{className:r.cn("w-full",t),onSubmit:ve,...T,children:e.jsx(Ge,{className:"overflow-hidden",children:k})})]});return c?X:e.jsx(xe.Provider,{value:be,children:X})},it=({onChange:t,className:s,placeholder:a="What would you like to know?",...n})=>{const l=fe(),g=V(),[u,y]=d.useState(!1),v=o=>{if(o.key==="Enter"){if(u||o.nativeEvent.isComposing||o.shiftKey)return;o.preventDefault();const c=o.currentTarget.form,m=c==null?void 0:c.querySelector('button[type="submit"]');if(m!=null&&m.disabled)return;c==null||c.requestSubmit()}if(o.key==="Backspace"&&o.currentTarget.value===""&&g.files.length>0){o.preventDefault();const c=g.files.at(-1);c&&g.remove(c.id)}},k=o=>{var P;const c=(P=o.clipboardData)==null?void 0:P.items;if(!c)return;const m=[];for(const C of c)if(C.kind==="file"){const D=C.getAsFile();D&&m.push(D)}m.length>0&&(o.preventDefault(),g.add(m))},T=l?{value:l.textInput.value,onChange:o=>{l.textInput.setInput(o.currentTarget.value),t==null||t(o)}}:{onChange:t};return e.jsx(We,{className:r.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>y(!1),onCompositionStart:()=>y(!0),onKeyDown:v,onPaste:k,placeholder:a,...n,...T})},lt=({className:t,...s})=>e.jsx(de,{align:"block-end",className:r.cn("order-first flex-wrap gap-1",t),...s}),ct=({className:t,...s})=>e.jsx(de,{align:"block-end",className:r.cn("justify-between gap-1",t),...s}),dt=({className:t,...s})=>e.jsx("div",{className:r.cn("flex items-center gap-1",t),...s}),W=({variant:t="ghost",className:s,size:a,...n})=>{const l=a??(d.Children.count(n.children)>1?"sm":"icon-sm");return e.jsx(ue,{className:r.cn(s),size:l,type:"button",variant:t,...n})},ut=t=>e.jsx(Te,{...t}),mt=({className:t,children:s,...a})=>e.jsx(Le,{asChild:!0,children:e.jsx(W,{className:t,...a,children:s??e.jsx(b.PlusIcon,{className:"size-4"})})}),pt=({className:t,...s})=>e.jsx(re,{align:"start",className:r.cn(t),...s}),ft=({className:t,variant:s="default",size:a="icon-sm",status:n,children:l,...g})=>{let u=e.jsx(b.CornerDownLeftIcon,{className:"size-4"});return n==="submitted"?u=e.jsx(b.Loader2Icon,{className:"size-4 animate-spin"}):n==="streaming"?u=e.jsx(b.SquareIcon,{className:"size-4"}):n==="error"&&(u=e.jsx(b.XIcon,{className:"size-4"})),e.jsx(ue,{"aria-label":"Submit",className:r.cn(t),size:a,type:"submit",variant:s,...g,children:l??u})},xt=({className:t,textareaRef:s,onTranscriptionChange:a,...n})=>{const[l,g]=d.useState(!1),[u,y]=d.useState(null),v=d.useRef(null);d.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const T=window.SpeechRecognition||window.webkitSpeechRecognition,o=new T;o.continuous=!0,o.interimResults=!0,o.lang="en-US",o.onstart=()=>{g(!0)},o.onend=()=>{g(!1)},o.onresult=c=>{var P;let m="";for(let C=c.resultIndex;C<c.results.length;C++){const D=c.results[C];D.isFinal&&(m+=((P=D[0])==null?void 0:P.transcript)??"")}if(m&&(s!=null&&s.current)){const C=s.current,D=C.value,A=D+(D?" ":"")+m;C.value=A,C.dispatchEvent(new Event("input",{bubbles:!0})),a==null||a(A)}},o.onerror=c=>{console.error("Speech recognition error:",c.error),g(!1)},v.current=o,y(o)}return()=>{v.current&&v.current.stop()}},[s,a]);const k=d.useCallback(()=>{u&&(l?u.stop():u.start())},[u,l]);return e.jsx(W,{className:r.cn("relative transition-all duration-200",l&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!u,onClick:k,...n,children:e.jsx(b.MicIcon,{className:"size-4"})})},gt=({openDelay:t=0,closeDelay:s=0,...a})=>e.jsx(Be,{closeDelay:s,openDelay:t,...a}),ht=({align:t="start",...s})=>e.jsx(le,{align:t,...s}),bt=t=>e.jsx(Ce,{...t}),vt=t=>e.jsx(ke,{...t}),jt=({className:t,children:s,title:a="Model Selector",...n})=>e.jsxs(Z,{className:r.cn("p-0",t),...n,children:[e.jsx(ee,{className:"sr-only",children:a}),e.jsx(te,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),yt=({className:t,...s})=>e.jsx(se,{className:r.cn("h-auto py-3.5",t),...s}),Nt=t=>e.jsx(ae,{...t}),wt=t=>e.jsx(ne,{...t}),St=t=>e.jsx(oe,{...t}),It=({provider:t,className:s,...a})=>e.jsx("img",{...a,alt:`${t} logo`,className:r.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Ct=({className:t,...s})=>e.jsx("span",{className:r.cn("flex-1 truncate text-left",t),...s}),kt=({selectedModel:t,onModelChange:s,disabled:a=!1})=>{const[n,l]=d.useState(!1),[g,u]=d.useState(""),y=U.getModelById(t)||U.getDefaultModel(),k=U.AI_MODELS.filter(o=>o.name.toLowerCase().includes(g.toLowerCase())||o.provider.toLowerCase().includes(g.toLowerCase())).reduce((o,c)=>(o[c.provider]||(o[c.provider]=[]),o[c.provider].push(c),o),{}),T=o=>{s(o),l(!1),u("")};return e.jsxs(bt,{open:n,onOpenChange:l,children:[e.jsx(vt,{asChild:!0,children:e.jsxs(r.Button,{variant:"outline",size:"sm",disabled:a,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(b.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:y.name})]})}),e.jsxs(jt,{className:"w-96 p-0",children:[e.jsx(yt,{placeholder:"Search models...",value:g,onValueChange:u}),e.jsx(Nt,{children:Object.entries(k).map(([o,c])=>e.jsx(wt,{heading:o.charAt(0).toUpperCase()+o.slice(1),children:c.map(m=>e.jsxs(St,{value:m.id,onSelect:()=>T(m.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(It,{provider:m.provider}),e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsx(Ct,{children:m.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:m.description})]}),t===m.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},m.id))},o))})]})]})},$="chai-ai-selected-model",Rt=({input:t,setInput:s,onSend:a,onStop:n,isLoading:l,disabled:g,selectedLang:u,selectedModel:y=U.getDefaultModel().id,onModelChange:v})=>{const{t:k}=Ie.useTranslation(),[T,o]=d.useState(y),[c,m]=d.useState(null),P=d.useRef(null),[C,D]=d.useState(!1);d.useEffect(()=>{if(!u){const j=localStorage.getItem($);if(j)o(j),v==null||v(j);else{const M=U.getDefaultModel().id;o(M),v==null||v(M)}}},[u,v]);const A=j=>{var E;const M=j.files.find(L=>{var O;return(O=L.mediaType)==null?void 0:O.startsWith("image/")}),B=(M==null?void 0:M.url)||c;a((E=j.text)==null?void 0:E.trim(),void 0,B,T),m(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(rt,{onSubmit:A,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(lt,{className:"p-0",children:e.jsx(nt,{className:"pb-0",children:j=>e.jsx(at,{className:"text-xs",data:j})})}),e.jsx(it,{ref:P,value:t,onChange:j=>s(j.target.value),placeholder:k(u?"Ask to update content":"Ask me anything..."),disabled:l,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(ct,{children:[u?e.jsx("div",{}):e.jsxs(dt,{children:[e.jsxs(ut,{children:[e.jsx(mt,{disabled:l,children:e.jsx(b.Paperclip,{size:16})}),e.jsx(pt,{children:e.jsx(ot,{})})]}),e.jsx(xt,{textareaRef:P,onTranscriptionChange:s,disabled:l}),e.jsx(kt,{selectedModel:T,onModelChange:j=>{o(j),v==null||v(j),localStorage.setItem($,j)},disabled:l}),e.jsxs(W,{className:"hidden",size:"sm",onClick:()=>D(!C),variant:C?"default":"ghost",children:[e.jsx(b.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),l?e.jsxs("button",{onClick:n,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:k("Stop generation"),children:[e.jsx(b.Square,{size:16})," ",e.jsx("span",{className:"text-xs",children:k("Stop")})]}):e.jsx(ft,{disabled:!t.trim()||g,children:e.jsx(b.Send,{size:16})})]})]})})})};exports.default=Rt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./selected-block-display-s99Y91qI.cjs"),d=require("react"),R=require("cmdk"),b=require("lucide-react"),ye=require("@radix-ui/react-dialog"),Ne=require("@radix-ui/react-dropdown-menu"),we=require("@radix-ui/react-hover-card"),J=require("class-variance-authority"),Se=require("@radix-ui/react-select"),Ie=require("@chaibuilder/sdk"),U=require("./ai-panel-content-MOZmNIKP.cjs");function q(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const n=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,n.get?n:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const p=q(d),z=q(ye),w=q(Ne),G=q(we),I=q(Se),Ce=z.Root,ke=z.Trigger,Re=z.Portal,Q=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Overlay,{ref:a,className:r.cn("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));Q.displayName=z.Overlay.displayName;const Z=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(Re,{children:[e.jsx(Q,{}),e.jsxs(z.Content,{ref:n,className:r.cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...a,children:[s,e.jsxs(z.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(b.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Z.displayName=z.Content.displayName;const ee=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Title,{ref:a,className:r.cn("text-lg font-semibold leading-none tracking-tight",t),...s}));ee.displayName=z.Title.displayName;const De=p.forwardRef(({className:t,...s},a)=>e.jsx(z.Description,{ref:a,className:r.cn("text-sm text-muted-foreground",t),...s}));De.displayName=z.Description.displayName;const te=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command,{ref:a,className:r.cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));te.displayName=R.Command.displayName;const se=p.forwardRef(({className:t,...s},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(b.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(R.Command.Input,{ref:a,className:r.cn("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));se.displayName=R.Command.Input.displayName;const ae=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.List,{ref:a,className:r.cn("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));ae.displayName=R.Command.List.displayName;const ze=p.forwardRef((t,s)=>e.jsx(R.Command.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));ze.displayName=R.Command.Empty.displayName;const ne=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Group,{ref:a,className:r.cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));ne.displayName=R.Command.Group.displayName;const Pe=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Separator,{ref:a,className:r.cn("-mx-1 h-px bg-border",t),...s}));Pe.displayName=R.Command.Separator.displayName;const oe=p.forwardRef(({className:t,...s},a)=>e.jsx(R.Command.Item,{ref:a,className:r.cn("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t),...s}));oe.displayName=R.Command.Item.displayName;const Te=w.Root,Le=w.Trigger,Ae=p.forwardRef(({className:t,inset:s,children:a,...n},l)=>e.jsxs(w.SubTrigger,{ref:l,className:r.cn("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...n,children:[a,e.jsx(b.ChevronRight,{className:"ml-auto"})]}));Ae.displayName=w.SubTrigger.displayName;const Me=p.forwardRef(({className:t,...s},a)=>e.jsx(w.SubContent,{ref:a,className:r.cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...s}));Me.displayName=w.SubContent.displayName;const re=p.forwardRef(({className:t,sideOffset:s=4,...a},n)=>e.jsx(w.Portal,{children:e.jsx(w.Content,{ref:n,sideOffset:s,className:r.cn("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",t),...a})}));re.displayName=w.Content.displayName;const ie=p.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(w.Item,{ref:n,className:r.cn("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...a}));ie.displayName=w.Item.displayName;const _e=p.forwardRef(({className:t,children:s,checked:a,...n},l)=>e.jsxs(w.CheckboxItem,{ref:l,className:r.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:a,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(w.ItemIndicator,{children:e.jsx(b.Check,{className:"h-4 w-4"})})}),s]}));_e.displayName=w.CheckboxItem.displayName;const Oe=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(w.RadioItem,{ref:n,className:r.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(w.ItemIndicator,{children:e.jsx(b.Circle,{className:"h-2 w-2 fill-current"})})}),s]}));Oe.displayName=w.RadioItem.displayName;const Ue=p.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(w.Label,{ref:n,className:r.cn("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...a}));Ue.displayName=w.Label.displayName;const qe=p.forwardRef(({className:t,...s},a)=>e.jsx(w.Separator,{ref:a,className:r.cn("-mx-1 my-1 h-px bg-muted",t),...s}));qe.displayName=w.Separator.displayName;const Be=G.Root,Ee=G.Trigger,le=p.forwardRef(({className:t,align:s="center",sideOffset:a=4,...n},l)=>e.jsx(G.Content,{ref:l,align:s,sideOffset:a,className:r.cn("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-hover-card-content-transform-origin]",t),...n}));le.displayName=G.Content.displayName;const Fe=p.forwardRef(({className:t,type:s,...a},n)=>e.jsx("input",{type:s,className:r.cn("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...a}));Fe.displayName="Input";const ce=p.forwardRef(({className:t,...s},a)=>e.jsx("textarea",{className:r.cn("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:a,...s}));ce.displayName="Textarea";function Ge({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:r.cn("group/input-group border-input dark:bg-input/30 shadow-xs relative flex w-full items-center rounded-md border outline-none transition-[color,box-shadow]","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-ring has-[[data-slot=input-group-control]:focus-visible]:ring-1","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...s})}const Ve=J.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 de({className:t,align:s="inline-start",...a}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:r.cn(Ve({align:s}),t),onClick:n=>{var l,g;n.target.closest("button")||(g=(l=n.currentTarget.parentElement)==null?void 0:l.querySelector("input"))==null||g.focus()},...a})}const He=J.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 ue({className:t,type:s="button",variant:a="ghost",size:n="xs",...l}){return e.jsx(r.Button,{type:s,"data-size":n,variant:a,className:r.cn(He({size:n}),t),...l})}function We({className:t,...s}){return e.jsx(ce,{"data-slot":"input-group-control",className:r.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 Ke=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(I.Trigger,{ref:n,className:r.cn("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...a,children:[s,e.jsx(I.Icon,{asChild:!0,children:e.jsx(b.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ke.displayName=I.Trigger.displayName;const me=p.forwardRef(({className:t,...s},a)=>e.jsx(I.ScrollUpButton,{ref:a,className:r.cn("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(b.ChevronUp,{className:"h-4 w-4"})}));me.displayName=I.ScrollUpButton.displayName;const pe=p.forwardRef(({className:t,...s},a)=>e.jsx(I.ScrollDownButton,{ref:a,className:r.cn("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(b.ChevronDown,{className:"h-4 w-4"})}));pe.displayName=I.ScrollDownButton.displayName;const Xe=p.forwardRef(({className:t,children:s,position:a="popper",...n},l)=>e.jsx(I.Portal,{children:e.jsxs(I.Content,{ref:l,className:r.cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,...n,children:[e.jsx(me,{}),e.jsx(I.Viewport,{className:r.cn("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(pe,{})]})}));Xe.displayName=I.Content.displayName;const Ye=p.forwardRef(({className:t,...s},a)=>e.jsx(I.Label,{ref:a,className:r.cn("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));Ye.displayName=I.Label.displayName;const $e=p.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(I.Item,{ref:n,className:r.cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(I.ItemIndicator,{children:e.jsx(b.Check,{className:"h-4 w-4"})})}),e.jsx(I.ItemText,{children:s})]}));$e.displayName=I.Item.displayName;const Je=p.forwardRef(({className:t,...s},a)=>e.jsx(I.Separator,{ref:a,className:r.cn("-mx-1 my-1 h-px bg-muted",t),...s}));Je.displayName=I.Separator.displayName;const Qe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ze=(t=21)=>{let s="",a=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)s+=Qe[a[t]&63];return s};const et=d.createContext(null),tt=d.createContext(null),fe=()=>d.useContext(et),st=()=>d.useContext(tt),xe=d.createContext(null),V=()=>{const t=st(),s=d.useContext(xe),a=t??s;if(!a)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return a};function at({data:t,className:s,...a}){var v;const n=V(),l=t.filename||"",u=((v=t.mediaType)!=null&&v.startsWith("image/")&&t.url?"image":"file")==="image",y=l||(u?"Image":"Attachment");return e.jsxs(gt,{children:[e.jsx(Ee,{asChild:!0,children:e.jsxs("div",{className:r.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:u?e.jsx("img",{alt:l||"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(b.PaperclipIcon,{className:"size-3"})})}),e.jsxs(r.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:k=>{k.stopPropagation(),n.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(b.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:y})]},t.id)}),e.jsx(ht,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[u&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:l||"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:l||(u?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function nt({children:t,className:s,...a}){const n=V();return n.files.length?e.jsx("div",{className:r.cn("flex flex-wrap items-center gap-2 p-3",s),...a,children:n.files.map(l=>e.jsx(d.Fragment,{children:t(l)},l.id))}):null}const ot=({label:t="Add photos or files",...s})=>{const a=V();return e.jsxs(ie,{...s,onSelect:n=>{n.preventDefault(),a.openFileDialog()},children:[e.jsx(b.ImageIcon,{className:"mr-2 size-4"})," ",t]})},rt=({className:t,accept:s,multiple:a,globalDrop:n,syncHiddenInput:l,maxFiles:g,maxFileSize:u,onError:y,onSubmit:v,children:k,...T})=>{const o=fe(),c=!!o,m=d.useRef(null),P=d.useRef(null),C=d.useRef(null);d.useEffect(()=>{var N;const i=(N=P.current)==null?void 0:N.closest("form");i instanceof HTMLFormElement&&(C.current=i)},[]);const[D,A]=d.useState([]),j=c?o.attachments.files:D,M=d.useCallback(()=>{var i;(i=m.current)==null||i.click()},[]),B=d.useCallback(i=>!s||s.trim()===""?!0:s.includes("image/*")?i.type.startsWith("image/"):!0,[s]),E=d.useCallback(i=>{const N=Array.from(i),h=N.filter(S=>B(S));if(N.length&&h.length===0){y==null||y({code:"accept",message:"No files match the accepted types."});return}const x=S=>u?S.size<=u:!0,f=h.filter(x);if(h.length>0&&f.length===0){y==null||y({code:"max_file_size",message:"All files exceed the maximum size."});return}A(S=>{const _=typeof g=="number"?Math.max(0,g-S.length):void 0,je=typeof _=="number"?f.slice(0,_):f;typeof _=="number"&&f.length>_&&(y==null||y({code:"max_files",message:"Too many files. Some were not added."}));const Y=[];for(const H of je)Y.push({id:Ze(),type:"file",url:URL.createObjectURL(H),mediaType:H.type,filename:H.name});return S.concat(Y)})},[B,g,u,y]),L=c?i=>o.attachments.add(i):E,O=c?i=>o.attachments.remove(i):i=>A(N=>{const h=N.find(x=>x.id===i);return h!=null&&h.url&&URL.revokeObjectURL(h.url),N.filter(x=>x.id!==i)}),F=c?()=>o.attachments.clear():()=>A(i=>{for(const N of i)N.url&&URL.revokeObjectURL(N.url);return[]}),K=c?()=>o.attachments.openFileDialog():M;d.useEffect(()=>{c&&o.__registerFileInput(m,()=>{var i;return(i=m.current)==null?void 0:i.click()})},[c,o]),d.useEffect(()=>{l&&m.current&&j.length===0&&(m.current.value="")},[j,l]),d.useEffect(()=>{const i=C.current;if(!i)return;const N=x=>{var f,S;(S=(f=x.dataTransfer)==null?void 0:f.types)!=null&&S.includes("Files")&&x.preventDefault()},h=x=>{var f,S,_;(S=(f=x.dataTransfer)==null?void 0:f.types)!=null&&S.includes("Files")&&x.preventDefault(),(_=x.dataTransfer)!=null&&_.files&&x.dataTransfer.files.length>0&&L(x.dataTransfer.files)};return i.addEventListener("dragover",N),i.addEventListener("drop",h),()=>{i.removeEventListener("dragover",N),i.removeEventListener("drop",h)}},[L]),d.useEffect(()=>{if(!n)return;const i=h=>{var x,f;(f=(x=h.dataTransfer)==null?void 0:x.types)!=null&&f.includes("Files")&&h.preventDefault()},N=h=>{var x,f,S;(f=(x=h.dataTransfer)==null?void 0:x.types)!=null&&f.includes("Files")&&h.preventDefault(),(S=h.dataTransfer)!=null&&S.files&&h.dataTransfer.files.length>0&&L(h.dataTransfer.files)};return document.addEventListener("dragover",i),document.addEventListener("drop",N),()=>{document.removeEventListener("dragover",i),document.removeEventListener("drop",N)}},[L,n]),d.useEffect(()=>()=>{if(!c)for(const i of j)i.url&&URL.revokeObjectURL(i.url)},[c,j]);const ge=i=>{i.currentTarget.files&&L(i.currentTarget.files)},he=async i=>{const h=await(await fetch(i)).blob();return new Promise((x,f)=>{const S=new FileReader;S.onloadend=()=>x(S.result),S.onerror=f,S.readAsDataURL(h)})},be=d.useMemo(()=>({files:j.map(i=>({...i,id:i.id})),add:L,remove:O,clear:F,openFileDialog:K,fileInputRef:m}),[j,L,O,F,K]),ve=i=>{i.preventDefault();const N=i.currentTarget,h=c?o.textInput.value:new FormData(N).get("message")||"";c||N.reset(),Promise.all(j.map(async({id:x,...f})=>f.url&&f.url.startsWith("blob:")?{...f,url:await he(f.url)}:f)).then(x=>{try{const f=v({text:h,files:x},i);f instanceof Promise?f.then(()=>{F(),c&&o.textInput.clear()}).catch(()=>{}):(F(),c&&o.textInput.clear())}catch{}})},X=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:P}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:a,onChange:ge,ref:m,title:"Upload files",type:"file"}),e.jsx("form",{className:r.cn("w-full",t),onSubmit:ve,...T,children:e.jsx(Ge,{className:"overflow-hidden",children:k})})]});return c?X:e.jsx(xe.Provider,{value:be,children:X})},it=({onChange:t,className:s,placeholder:a="What would you like to know?",...n})=>{const l=fe(),g=V(),[u,y]=d.useState(!1),v=o=>{if(o.key==="Enter"){if(u||o.nativeEvent.isComposing||o.shiftKey)return;o.preventDefault();const c=o.currentTarget.form,m=c==null?void 0:c.querySelector('button[type="submit"]');if(m!=null&&m.disabled)return;c==null||c.requestSubmit()}if(o.key==="Backspace"&&o.currentTarget.value===""&&g.files.length>0){o.preventDefault();const c=g.files.at(-1);c&&g.remove(c.id)}},k=o=>{var P;const c=(P=o.clipboardData)==null?void 0:P.items;if(!c)return;const m=[];for(const C of c)if(C.kind==="file"){const D=C.getAsFile();D&&m.push(D)}m.length>0&&(o.preventDefault(),g.add(m))},T=l?{value:l.textInput.value,onChange:o=>{l.textInput.setInput(o.currentTarget.value),t==null||t(o)}}:{onChange:t};return e.jsx(We,{className:r.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>y(!1),onCompositionStart:()=>y(!0),onKeyDown:v,onPaste:k,placeholder:a,...n,...T})},lt=({className:t,...s})=>e.jsx(de,{align:"block-end",className:r.cn("order-first flex-wrap gap-1",t),...s}),ct=({className:t,...s})=>e.jsx(de,{align:"block-end",className:r.cn("justify-between gap-1",t),...s}),dt=({className:t,...s})=>e.jsx("div",{className:r.cn("flex items-center gap-1",t),...s}),W=({variant:t="ghost",className:s,size:a,...n})=>{const l=a??(d.Children.count(n.children)>1?"sm":"icon-sm");return e.jsx(ue,{className:r.cn(s),size:l,type:"button",variant:t,...n})},ut=t=>e.jsx(Te,{...t}),mt=({className:t,children:s,...a})=>e.jsx(Le,{asChild:!0,children:e.jsx(W,{className:t,...a,children:s??e.jsx(b.PlusIcon,{className:"size-4"})})}),pt=({className:t,...s})=>e.jsx(re,{align:"start",className:r.cn(t),...s}),ft=({className:t,variant:s="default",size:a="icon-sm",status:n,children:l,...g})=>{let u=e.jsx(b.CornerDownLeftIcon,{className:"size-4"});return n==="submitted"?u=e.jsx(b.Loader2Icon,{className:"size-4 animate-spin"}):n==="streaming"?u=e.jsx(b.SquareIcon,{className:"size-4"}):n==="error"&&(u=e.jsx(b.XIcon,{className:"size-4"})),e.jsx(ue,{"aria-label":"Submit",className:r.cn(t),size:a,type:"submit",variant:s,...g,children:l??u})},xt=({className:t,textareaRef:s,onTranscriptionChange:a,...n})=>{const[l,g]=d.useState(!1),[u,y]=d.useState(null),v=d.useRef(null);d.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const T=window.SpeechRecognition||window.webkitSpeechRecognition,o=new T;o.continuous=!0,o.interimResults=!0,o.lang="en-US",o.onstart=()=>{g(!0)},o.onend=()=>{g(!1)},o.onresult=c=>{var P;let m="";for(let C=c.resultIndex;C<c.results.length;C++){const D=c.results[C];D.isFinal&&(m+=((P=D[0])==null?void 0:P.transcript)??"")}if(m&&(s!=null&&s.current)){const C=s.current,D=C.value,A=D+(D?" ":"")+m;C.value=A,C.dispatchEvent(new Event("input",{bubbles:!0})),a==null||a(A)}},o.onerror=c=>{console.error("Speech recognition error:",c.error),g(!1)},v.current=o,y(o)}return()=>{v.current&&v.current.stop()}},[s,a]);const k=d.useCallback(()=>{u&&(l?u.stop():u.start())},[u,l]);return e.jsx(W,{className:r.cn("relative transition-all duration-200",l&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!u,onClick:k,...n,children:e.jsx(b.MicIcon,{className:"size-4"})})},gt=({openDelay:t=0,closeDelay:s=0,...a})=>e.jsx(Be,{closeDelay:s,openDelay:t,...a}),ht=({align:t="start",...s})=>e.jsx(le,{align:t,...s}),bt=t=>e.jsx(Ce,{...t}),vt=t=>e.jsx(ke,{...t}),jt=({className:t,children:s,title:a="Model Selector",...n})=>e.jsxs(Z,{className:r.cn("p-0",t),...n,children:[e.jsx(ee,{className:"sr-only",children:a}),e.jsx(te,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),yt=({className:t,...s})=>e.jsx(se,{className:r.cn("h-auto py-3.5",t),...s}),Nt=t=>e.jsx(ae,{...t}),wt=t=>e.jsx(ne,{...t}),St=t=>e.jsx(oe,{...t}),It=({provider:t,className:s,...a})=>e.jsx("img",{...a,alt:`${t} logo`,className:r.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Ct=({className:t,...s})=>e.jsx("span",{className:r.cn("flex-1 truncate text-left",t),...s}),kt=({selectedModel:t,onModelChange:s,disabled:a=!1})=>{const[n,l]=d.useState(!1),[g,u]=d.useState(""),y=U.getModelById(t)||U.getDefaultModel(),k=U.AI_MODELS.filter(o=>o.name.toLowerCase().includes(g.toLowerCase())||o.provider.toLowerCase().includes(g.toLowerCase())).reduce((o,c)=>(o[c.provider]||(o[c.provider]=[]),o[c.provider].push(c),o),{}),T=o=>{s(o),l(!1),u("")};return e.jsxs(bt,{open:n,onOpenChange:l,children:[e.jsx(vt,{asChild:!0,children:e.jsxs(r.Button,{variant:"outline",size:"sm",disabled:a,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(b.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:y.name})]})}),e.jsxs(jt,{className:"w-96 p-0",children:[e.jsx(yt,{placeholder:"Search models...",value:g,onValueChange:u}),e.jsx(Nt,{children:Object.entries(k).map(([o,c])=>e.jsx(wt,{heading:o.charAt(0).toUpperCase()+o.slice(1),children:c.map(m=>e.jsxs(St,{value:m.id,onSelect:()=>T(m.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(It,{provider:m.provider}),e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsx(Ct,{children:m.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:m.description})]}),t===m.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},m.id))},o))})]})]})},$="chai-ai-selected-model",Rt=({input:t,setInput:s,onSend:a,onStop:n,isLoading:l,disabled:g,selectedLang:u,selectedModel:y=U.getDefaultModel().id,onModelChange:v})=>{const{t:k}=Ie.useTranslation(),[T,o]=d.useState(y),[c,m]=d.useState(null),P=d.useRef(null),[C,D]=d.useState(!1);d.useEffect(()=>{if(!u){const j=localStorage.getItem($);if(j)o(j),v==null||v(j);else{const M=U.getDefaultModel().id;o(M),v==null||v(M)}}},[u,v]);const A=j=>{var E;const M=j.files.find(L=>{var O;return(O=L.mediaType)==null?void 0:O.startsWith("image/")}),B=(M==null?void 0:M.url)||c;a((E=j.text)==null?void 0:E.trim(),void 0,B,T),m(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(rt,{onSubmit:A,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(lt,{className:"p-0",children:e.jsx(nt,{className:"pb-0",children:j=>e.jsx(at,{className:"text-xs",data:j})})}),e.jsx(it,{ref:P,value:t,onChange:j=>s(j.target.value),placeholder:k(u?"Ask to update content":"Ask me anything..."),disabled:l,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(ct,{children:[u?e.jsx("div",{}):e.jsxs(dt,{children:[e.jsxs(ut,{children:[e.jsx(mt,{disabled:l,children:e.jsx(b.Paperclip,{size:16})}),e.jsx(pt,{children:e.jsx(ot,{})})]}),e.jsx(xt,{textareaRef:P,onTranscriptionChange:s,disabled:l}),e.jsx(kt,{selectedModel:T,onModelChange:j=>{o(j),v==null||v(j),localStorage.setItem($,j)},disabled:l}),e.jsxs(W,{className:"hidden",size:"sm",onClick:()=>D(!C),variant:C?"default":"ghost",children:[e.jsx(b.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),l?e.jsxs("button",{onClick:n,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:k("Stop generation"),children:[e.jsx(b.Square,{size:16})," ",e.jsx("span",{className:"text-xs",children:k("Stop")})]}):e.jsx(ft,{disabled:!t.trim()||g,children:e.jsx(b.Send,{size:16})})]})]})})})};exports.default=Rt;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as t, jsxs as c, Fragment as Ce } from "react/jsx-runtime";
|
|
2
|
-
import { j as s, B as $ } from "./selected-block-display-
|
|
2
|
+
import { j as s, B as $ } from "./selected-block-display-GXSf3y2s.js";
|
|
3
3
|
import * as p from "react";
|
|
4
4
|
import { createContext as X, Fragment as Te, useRef as B, useEffect as j, useState as A, useCallback as V, useMemo as Pe, Children as Le, useContext as Y } from "react";
|
|
5
5
|
import { Command as D } from "cmdk";
|
|
@@ -10,7 +10,7 @@ import * as H from "@radix-ui/react-hover-card";
|
|
|
10
10
|
import { cva as re } from "class-variance-authority";
|
|
11
11
|
import * as S from "@radix-ui/react-select";
|
|
12
12
|
import { useTranslation as Ye } from "@chaibuilder/sdk";
|
|
13
|
-
import { a as Je, g as K, A as Qe } from "./ai-panel-content-
|
|
13
|
+
import { a as Je, g as K, A as Qe } from "./ai-panel-content-C6cH9rrC.js";
|
|
14
14
|
const Ze = C.Root, et = C.Trigger, tt = C.Portal, se = p.forwardRef(({ className: e, ...a }, n) => /* @__PURE__ */ t(
|
|
15
15
|
C.Overlay,
|
|
16
16
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-BeWL6Sj6.cjs"),c=require("@chaibuilder/sdk"),r=require("@chaibuilder/sdk/ui"),o=require("lucide-react"),x=({selectedLang:s,isLoading:n,selectedBlock:l,onClick:i})=>{const{t}=c.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:l?e.jsx(r.Button,{variant:"outline",className:"h-auto",onClick:()=>i("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")," ",a.LANGUAGES[s]," ",e.jsx(o.ArrowRight,{className:"h-4 w-4"})]})]})}):null})})};exports.default=x;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
2
|
-
import { L as r } from "./index-
|
|
2
|
+
import { L as r } from "./index-DI2Rwk5v.js";
|
|
3
3
|
import { useTranslation as i } from "@chaibuilder/sdk";
|
|
4
4
|
import { Button as c } from "@chaibuilder/sdk/ui";
|
|
5
5
|
import { ArrowRight as m } from "lucide-react";
|