@chaibuilder/sdk 4.0.0-beta.47 → 4.0.0-beta.49
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/{2SSKDMRQ-CVHl6i14.cjs → 2SSKDMRQ-CjvuNdPo.cjs} +1 -1
- package/dist/{2SSKDMRQ-D9rlRpnI.js → 2SSKDMRQ-Dvf9zadl.js} +2 -2
- package/dist/{AP7HFJJL-D18sv0Wh.cjs → AP7HFJJL-DYFttFoI.cjs} +1 -1
- package/dist/{AP7HFJJL-CBrphwP9.js → AP7HFJJL-q4dJdyFs.js} +1 -1
- package/dist/{IconPicker-CSewv0kY.js → IconPicker-Bf163F7t.js} +1 -1
- package/dist/{IconPicker-CxEGCcVZ.cjs → IconPicker-JWhYq2Gp.cjs} +1 -1
- package/dist/{WDYDFRGG-C0G8c0hR.cjs → WDYDFRGG-BEksfGMC.cjs} +1 -1
- package/dist/{WDYDFRGG-BCmjXFs0.js → WDYDFRGG-O9GIrtX0.js} +2 -2
- package/dist/{actions-registery-BQ31lpix.cjs → actions-registery-BHbZHkE3.cjs} +11 -3
- package/dist/{actions-registery-B1VeX52Y.js → actions-registery-gJb_wq2F.js} +25 -13
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.ts +10 -3
- package/dist/actions.js +6 -4
- package/dist/{active-in-another-tab-BhbPijx9.js → active-in-another-tab-B4Ur0JP7.js} +2 -2
- package/dist/{active-in-another-tab-CMmhCRma.cjs → active-in-another-tab-BPdx4lWh.cjs} +1 -1
- package/dist/{add-new-language-page-ChQgjFwb.cjs → add-new-language-page-BfUp5Ua2.cjs} +1 -1
- package/dist/{add-new-language-page-C0sayTSF.js → add-new-language-page-CRR93tLq.js} +3 -3
- package/dist/{add-new-page-DLf5Tfb7.cjs → add-new-page-B8NGK6WS.cjs} +1 -1
- package/dist/{add-new-page-DLKzuaNM.js → add-new-page-Ppy5-y5j.js} +2 -2
- package/dist/ai-panel-default-lang-BXYQye3N.js +333 -0
- package/dist/ai-panel-default-lang-VhgmHFoQ.cjs +3 -0
- package/dist/ai-panel-other-lang-DaCf-cq4.js +148 -0
- package/dist/ai-panel-other-lang-Ds0EXeUC.cjs +1 -0
- package/dist/{ai-prompt-input-DNb1FKXQ.js → ai-prompt-input-7iWk72w5.js} +253 -258
- package/dist/ai-prompt-input-nZ5_Dm7X.cjs +1 -0
- package/dist/{ai-translation-prompt-B2MfzTjb.js → ai-translation-prompt-1OUs1P7n.js} +1 -1
- package/dist/{ai-translation-prompt-CL3yk8K1.cjs → ai-translation-prompt-B16cK-1Q.cjs} +1 -1
- package/dist/{change-password-modal-CbMifP62.js → change-password-modal-CdvJR1Ln.js} +10 -10
- package/dist/{change-password-modal-D_NFPZxI.cjs → change-password-modal-D5eXjiYq.cjs} +1 -1
- package/dist/{code-editor-53rOkfhX.js → code-editor-CyLjDiEp.js} +1 -1
- package/dist/{code-editor-CCsljULB.cjs → code-editor-SWbfFj1E.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-hB4O3CHJ.js → continue-editing-in-this-client-BrSvK-Ay.js} +2 -2
- package/dist/{continue-editing-in-this-client-3QLL7tQH.cjs → continue-editing-in-this-client-Cmi-GkYZ.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{css-import-modal-Bmi3LrEJ.cjs → css-import-modal-Bdwgd05S.cjs} +1 -1
- package/dist/{css-import-modal-DCivkVh2.js → css-import-modal-Be47CBJn.js} +1 -1
- package/dist/{delete-page-BW2NxLZu.js → delete-page-C99K2qzS.js} +15 -15
- package/dist/{delete-page-CxVfKrBz.cjs → delete-page-DLohaU-U.cjs} +1 -1
- package/dist/{design-token-usage-WTVjf9c-.js → design-token-usage-D1lWCJ3L.js} +1 -1
- package/dist/{design-token-usage-5jsa9ojN.cjs → design-token-usage-eY2wQ0l3.cjs} +1 -1
- package/dist/{digital-asset-manager-dNK-BYdI.js → digital-asset-manager-BZMb6sC7.js} +3 -3
- package/dist/{digital-asset-manager-DlFCWUP4.cjs → digital-asset-manager-Z5aJxkq0.cjs} +1 -1
- package/dist/{duplicate-page-BbB2anQO.js → duplicate-page-CDc2X0eW.js} +12 -12
- package/dist/{duplicate-page-0o6G-oY_.cjs → duplicate-page-D5Gtvqdv.cjs} +1 -1
- package/dist/{dynamic-page-selector-Ds3MqxTF.cjs → dynamic-page-selector-DZHhX008.cjs} +1 -1
- package/dist/{dynamic-page-selector-rFO8457w.js → dynamic-page-selector-DvNBXo6o.js} +2 -2
- package/dist/{image-editor-BnVkes6Q.js → image-editor-BBvvi9Vm.js} +1 -1
- package/dist/{image-editor-DqItmbk1.cjs → image-editor-DwhTYkVR.cjs} +1 -1
- package/dist/index-BVwFJWDq.cjs +5 -0
- package/dist/{index-DTNHTRZu.cjs → index-DCJDQs1a.cjs} +8 -8
- package/dist/{index-BYjniKhj.js → index-LBTm1Jmk.js} +838 -806
- package/dist/{index-B7HAfx-2.js → index-OuHV9Ann.js} +16 -9
- package/dist/{json-diff-viewer-B4rnFiN_.cjs → json-diff-viewer-Cb1CmRqP.cjs} +1 -1
- package/dist/{json-diff-viewer-CKlyO9eW.js → json-diff-viewer-DG6qMOBS.js} +6 -6
- package/dist/{lang-panel-YT96E5Xj.js → lang-panel-B3USOxGq.js} +9 -9
- package/dist/{lang-panel-DiVz4Cay.cjs → lang-panel-DxoJ0v4y.cjs} +1 -1
- package/dist/{manage-design-tokens-LwImeKaK.js → manage-design-tokens-6YGIctip.js} +2 -2
- package/dist/{manage-design-tokens-modal-BEElCTcN.cjs → manage-design-tokens-modal-BSSCXH8Y.cjs} +1 -1
- package/dist/{manage-design-tokens-modal-DFVcoyra.js → manage-design-tokens-modal-CzsnN49F.js} +2 -2
- package/dist/{manage-design-tokens-BwrIc6dS.cjs → manage-design-tokens-udLBvkHA.cjs} +1 -1
- package/dist/{mark-as-template-DtDkh6jB.cjs → mark-as-template-B9yLcasI.cjs} +1 -1
- package/dist/{mark-as-template-D2Hpz0IE.js → mark-as-template-CP_F9ZQ4.js} +2 -2
- package/dist/{models-D0RH2u4C.cjs → models-CQaC3EBW.cjs} +1 -1
- package/dist/{models-BCu-p_QK.js → models-DZ9C6CvE.js} +4 -5
- package/dist/{nested-path-selector-content-TqjBbNys.js → nested-path-selector-content-DmtCI3q9.js} +1 -1
- package/dist/{nested-path-selector-content-CJfN8Hhw.cjs → nested-path-selector-content-aTdu-o0e.cjs} +1 -1
- package/dist/{no-language-page-content-CcD-fgMa.cjs → no-language-page-content-C-MCdPXt.cjs} +1 -1
- package/dist/{no-language-page-content-Ce3wniZT.js → no-language-page-content-D8t5dfgh.js} +2 -2
- package/dist/{no-language-page-dialog-CU1zXsYv.js → no-language-page-dialog-C_fHI2zI.js} +2 -2
- package/dist/{no-language-page-dialog-B7fhPdob.cjs → no-language-page-dialog-D4QIAHnE.cjs} +1 -1
- package/dist/{page-creator-C7XEqUx_.cjs → page-creator-Cz_ah-qE.cjs} +1 -1
- package/dist/{page-creator-wg3uymVG.js → page-creator-DKEkuGCO.js} +33 -33
- package/dist/{page-lock-BuVma3e5.js → page-lock-CwZKJ4IE.js} +2 -2
- package/dist/{page-lock-CINb2air.cjs → page-lock-DdCvtA-I.cjs} +1 -1
- package/dist/{page-locked-dialog-s-3ROcy0.cjs → page-locked-dialog-CrTDBoC4.cjs} +1 -1
- package/dist/{page-locked-dialog-C7_1gjO5.js → page-locked-dialog-DqLlooUz.js} +11 -11
- package/dist/{page-manager-new-CKWSLVrb.cjs → page-manager-new-ah6QYar2.cjs} +1 -1
- package/dist/{page-manager-new-zlobCGqL.js → page-manager-new-ttsrxdW9.js} +42 -42
- package/dist/{page-manager-search-and-filter-BaOsl_5u.cjs → page-manager-search-and-filter-D7AupT6_.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-BU_iNmHy.js → page-manager-search-and-filter-bsqZ6wnI.js} +2 -2
- package/dist/{page-revisions-content-BmaNPNoS.cjs → page-revisions-content-B6hsIla7.cjs} +1 -1
- package/dist/{page-revisions-content-D6l_d2jW.js → page-revisions-content-C5O8_Fms.js} +16 -16
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +66 -1
- package/dist/pages.js +19 -19
- package/dist/{publish-pages-content-2LG6JOrm.cjs → publish-pages-content-BrajJUcP.cjs} +1 -1
- package/dist/{publish-pages-content-CQteRtBA.js → publish-pages-content-KZVMHT6V.js} +32 -32
- package/dist/{rte-widget-modal-KzT2hLFt.cjs → rte-widget-modal-CiTwsXTr.cjs} +1 -1
- package/dist/{rte-widget-modal-CFk0Izg5.js → rte-widget-modal-IU8JzPuZ.js} +1 -1
- package/dist/{save-to-lib-D1V3bNZX.js → save-to-lib-DMnv7ENo.js} +50 -50
- package/dist/{save-to-lib-D82Vrekv.cjs → save-to-lib-Dc700Aop.cjs} +1 -1
- package/dist/{selected-block-display-BHx9N14K.cjs → selected-block-display-CAFEOrLV.cjs} +1 -1
- package/dist/{selected-block-display-BbUH5RaW.js → selected-block-display-CidmQ-wz.js} +2 -2
- package/dist/{seo-panel-CyBmGg6k.js → seo-panel-Br8gxDxu.js} +148 -158
- package/dist/{seo-panel-CPsjZLtL.cjs → seo-panel-CMY-adM-.cjs} +2 -2
- package/dist/{shared-json-ld-DyU9wqrE.cjs → shared-json-ld-CMH-eRUq.cjs} +1 -1
- package/dist/{shared-json-ld-SGykyppC.js → shared-json-ld-uvMmwCYp.js} +26 -26
- package/dist/{slug-input-BzpnOdXG.cjs → slug-input-CiHC5l3r.cjs} +1 -1
- package/dist/{slug-input-DpMI4nEB.js → slug-input-DLWTMTsO.js} +1 -1
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.js +1 -1
- package/dist/{take-over-request-wTVLAotu.cjs → take-over-request-IRLgF1dG.cjs} +1 -1
- package/dist/{take-over-request-D97Fg-xB.js → take-over-request-KdR1_h_K.js} +5 -5
- package/dist/{translation-warning-modal-Xk6oYGFS.cjs → translation-warning-modal-CLZ9tC1F.cjs} +1 -1
- package/dist/{translation-warning-modal-Du-CnfyH.js → translation-warning-modal-CzNt6LDO.js} +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/{unmark-as-template-BHk2F0ck.js → unmark-as-template-C5ovsEBP.js} +2 -2
- package/dist/{unmark-as-template-BRnMhh7n.cjs → unmark-as-template-F7TdgWjI.cjs} +1 -1
- package/dist/{unpublish-page-BOEjCHLB.js → unpublish-page-0fR1o0b7.js} +8 -8
- package/dist/{unpublish-page-Bu75lH33.cjs → unpublish-page-CUr8Xub6.cjs} +1 -1
- package/dist/{unpublished-partials-modal-C0_0qNvV.js → unpublished-partials-modal-BhNAub_z.js} +1 -1
- package/dist/{unpublished-partials-modal-BS_GddEG.cjs → unpublished-partials-modal-Cv5R9-hi.cjs} +1 -1
- package/dist/{web-preview-DcOhTGup.cjs → web-preview-CuMYekVJ.cjs} +1 -1
- package/dist/{web-preview-C3bbIF6T.js → web-preview-D9pXonAv.js} +1 -1
- package/package.json +1 -1
- package/dist/ai-panel-default-lang-DsGjoITc.cjs +0 -3
- package/dist/ai-panel-default-lang-Dy_4L5pH.js +0 -317
- package/dist/ai-panel-other-lang-1RYtb71B.js +0 -132
- package/dist/ai-panel-other-lang-CL3coL7Z.cjs +0 -1
- package/dist/ai-prompt-input-BhTL_-mT.cjs +0 -1
- package/dist/index-BeGLwvqs.cjs +0 -5
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
2
2
|
import { B as l } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { D as c, e as u, f as h, g as d, o as m, q as b } from "./index-
|
|
4
|
-
import {
|
|
3
|
+
import { D as c, e as u, f as h, g as d, o as m, q as b } from "./index-OuHV9Ann.js";
|
|
4
|
+
import { t as f } from "./index-LBTm1Jmk.js";
|
|
5
5
|
import { useTranslation as D } from "react-i18next";
|
|
6
|
-
const v = ({ page: n, onClose:
|
|
7
|
-
const { t: i } = D(), { mutate: e, isPending:
|
|
8
|
-
e(n, { onSuccess:
|
|
6
|
+
const v = ({ page: n, onClose: t }) => {
|
|
7
|
+
const { t: i } = D(), { mutate: e, isPending: r } = f(), a = async () => {
|
|
8
|
+
e(n, { onSuccess: t });
|
|
9
9
|
};
|
|
10
|
-
return /* @__PURE__ */ o(c, { open: !!n, onOpenChange:
|
|
10
|
+
return /* @__PURE__ */ o(c, { open: !!n, onOpenChange: t, children: /* @__PURE__ */ s(u, { children: [
|
|
11
11
|
/* @__PURE__ */ s(h, { children: [
|
|
12
12
|
/* @__PURE__ */ o(d, { children: i("Confirm action") }),
|
|
13
13
|
/* @__PURE__ */ s(m, { children: [
|
|
@@ -18,8 +18,8 @@ const v = ({ page: n, onClose: r }) => {
|
|
|
18
18
|
] })
|
|
19
19
|
] }),
|
|
20
20
|
/* @__PURE__ */ s(b, { children: [
|
|
21
|
-
/* @__PURE__ */ o(l, { variant: "outline", onClick:
|
|
22
|
-
/* @__PURE__ */ o(l, { variant: "destructive", disabled:
|
|
21
|
+
/* @__PURE__ */ o(l, { variant: "outline", onClick: t, children: i("Cancel") }),
|
|
22
|
+
/* @__PURE__ */ o(l, { variant: "destructive", disabled: r, onClick: a, children: i(r ? "Updating..." : "Unpublish") })
|
|
23
23
|
] })
|
|
24
24
|
] }) });
|
|
25
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("./register-chai-top-bar-DyW9GPzV.cjs"),e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("./register-chai-top-bar-DyW9GPzV.cjs"),e=require("./index-DCJDQs1a.cjs"),c=require("./index-BVwFJWDq.cjs"),a=require("react-i18next"),d=({page:i,onClose:t})=>{const{t:s}=a.useTranslation(),{mutate:l,isPending:r}=c.useUnpublishPage(),u=async()=>{l(i,{onSuccess:t})};return n.jsx(e.Dialog,{open:!!i,onOpenChange:t,children:n.jsxs(e.DialogContent,{children:[n.jsxs(e.DialogHeader,{children:[n.jsx(e.DialogTitle,{children:s("Confirm action")}),n.jsxs(e.DialogDescription,{children:[s("Are you sure you want to unpublish")," ",n.jsx("b",{children:(i==null?void 0:i.name)??(i==null?void 0:i.slug)}),"?"]})]}),n.jsxs(e.DialogFooter,{children:[n.jsx(o.Button,{variant:"outline",onClick:t,children:s("Cancel")}),n.jsx(o.Button,{variant:"destructive",disabled:r,onClick:u,children:s(r?"Updating...":"Unpublish")})]})]})})};exports.default=d;
|
package/dist/{unpublished-partials-modal-C0_0qNvV.js → unpublished-partials-modal-BhNAub_z.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as a, jsxs as r, Fragment as m } from "react/jsx-runtime";
|
|
2
|
-
import { D as i, e as p, f as b, g as x, o, B as c, q as v } from "./index-
|
|
2
|
+
import { D as i, e as p, f as b, g as x, o, B as c, q as v } from "./index-OuHV9Ann.js";
|
|
3
3
|
import { B as d } from "./register-chai-top-bar-D6GjnauV.js";
|
|
4
4
|
import { useTranslation as N } from "react-i18next";
|
|
5
5
|
const P = ({
|
package/dist/{unpublished-partials-modal-BS_GddEG.cjs → unpublished-partials-modal-Cv5R9-hi.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./index-DCJDQs1a.cjs"),d=require("./register-chai-top-bar-DyW9GPzV.cjs"),g=require("react-i18next"),x=({isOpen:n,onClose:h,onContinue:c,onViewChanges:u,isPending:l=!1,partialBlocksInfo:t=[]})=>{const{t:a}=g.useTranslation();return e.jsx(r.Dialog,{open:n,onOpenChange:h,children:n&&e.jsxs(r.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(r.DialogHeader,{children:[e.jsx(r.DialogTitle,{children:a("You have some unpublished changes")}),e.jsx(r.DialogDescription,{children:a("The following partials are either unpublished or have unpublished changes.")})]}),(t==null?void 0:t.length)>0&&e.jsx("div",{className:"max-h-32 overflow-y-auto rounded-md border bg-muted/50 p-2",children:e.jsx("ul",{className:"space-y-1 text-sm",children:t.map(s=>e.jsxs("li",{className:"flex items-center justify-between text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("p",{className:`h-2 w-2 rounded-full ${(s==null?void 0:s.status)==="unpublished_changes"?"bg-green-400":"bg-gray-300"}`})," ",s==null?void 0:s.name]}),e.jsxs("span",{className:"flex items-center gap-1",children:[(s==null?void 0:s.status)==="unpublished_changes"&&e.jsxs(e.Fragment,{children:[e.jsx(r.Badge,{className:"bg-green-100 text-green-600 border-green-200 hover:bg-green-100 text-[10px] px-1.5 py-0",children:a("Published")}),u&&e.jsx(d.Button,{variant:"ghost",title:a("View Changes"),className:"text-blue-600 hover:text-blue-600 hover:bg-transparent hover:underline text-[10px] p-0",onClick:()=>u(s.id,s.name),children:a("View Changes")})]}),(s==null?void 0:s.status)==="unpublished"&&e.jsx(r.Badge,{className:"bg-orange-100 text-orange-600 border-orange-200 hover:bg-orange-100 text-[10px] px-1.5 py-0",children:a("Unpublished")})]})]},s==null?void 0:s.id))})}),e.jsxs(r.DialogFooter,{className:"flex gap-2",children:[e.jsx(d.Button,{variant:"outline",onClick:h,disabled:l,children:a("Cancel")}),e.jsx(d.Button,{onClick:c,disabled:l,children:a(l?"Publishing...":"Publish Partials & Page")})]})]})})};exports.default=x;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),a=require("./register-chai-top-bar-DyW9GPzV.cjs"),u=require("jotai"),x=require("lodash-es"),n=require("lucide-react"),c=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),a=require("./register-chai-top-bar-DyW9GPzV.cjs"),u=require("jotai"),x=require("lodash-es"),n=require("lucide-react"),c=require("./index-BVwFJWDq.cjs"),m=[{title:"mobile_xs_title",content:"mobile_xs_content",icon:e.jsx(n.Smartphone,{className:"h-4 w-4"}),width:400},{title:"tablet_md_title",content:"tablet_md_content",icon:e.jsx(n.Tablet,{className:"h-4 w-4"}),width:800},{title:"desktop_xl_title",content:"desktop_xl_content",icon:e.jsx(n.Laptop,{className:"h-4 w-4"}),width:1200},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",icon:e.jsx(n.LaptopMinimal,{className:"h-4 w-4"}),width:1600}],w=({currentWidth:t,width:s,icon:o,setIframeWidth:r})=>e.jsx(a.Button,{className:"px-3 py-3",onClick:()=>r(s),variant:s===t?"default":"ghost",children:o}),p=()=>{const[t,s]=l.useState(1200),o=i=>s(i),[r,d]=u.useAtom(c.previewUrlAtom);if(!r)return null;const h=()=>{d("")};return e.jsxs("div",{className:"absolute inset-0 z-[999999] flex h-screen w-screen flex-col overflow-hidden bg-gray-100",children:[e.jsxs("div",{className:"flex h-[50px] items-center justify-center border-b border-gray-200 px-4 shadow-sm",children:[e.jsx("div",{className:"flex items-center justify-center rounded-md border border-gray-300",children:x.map(m,i=>l.createElement(w,{...i,setIframeWidth:o,key:i.title,currentWidth:t}))})," ",e.jsx(c.Tooltip,{content:"Exit Preview",delayDuration:0,children:e.jsx(a.Button,{variant:"destructive",size:"sm",onClick:h,children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M2 3C2 2.44772 2.44772 2 3 2H12C12.5523 2 13 2.44772 13 3V12C13 12.5523 12.5523 13 12 13H3C2.44772 13 2 12.5523 2 12V3ZM12 3H3V12H12V3Z",fill:"currentColor",fillRule:"evenodd","clip-rule":"evenodd"})})})})]}),e.jsx("iframe",{style:{width:`${t}px`,transition:"width 0.3s ease-in-out"},className:"no-scrollbar mx-auto h-full overflow-y-auto border bg-white",src:r})]})};exports.default=p;
|
|
@@ -4,7 +4,7 @@ import { B as s } from "./register-chai-top-bar-D6GjnauV.js";
|
|
|
4
4
|
import { useAtom as h } from "jotai";
|
|
5
5
|
import { map as p } from "lodash-es";
|
|
6
6
|
import { Smartphone as w, Tablet as f, Laptop as u, LaptopMinimal as x } from "lucide-react";
|
|
7
|
-
import { p as v, T as _ } from "./index-
|
|
7
|
+
import { p as v, T as _ } from "./index-LBTm1Jmk.js";
|
|
8
8
|
const b = [
|
|
9
9
|
{
|
|
10
10
|
title: "mobile_xs_title",
|
package/package.json
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),S=require("./index-DTNHTRZu.cjs"),p=require("./selected-block-display-BHx9N14K.cjs"),P=require("lucide-react"),j=require("react"),W=require("sonner"),F=require("./models-D0RH2u4C.cjs"),L=require("./apply-binding-CBSjMYSk.cjs"),O=require("@tanstack/react-query"),$=()=>{const{addPredefinedBlock:k}=S.useAddBlock(),N=S.useReplaceBlock(),y=S.useRemoveBlocks(),T=O.useQueryClient(),w=async(r,e)=>{if(!e)return;const s=L.getBlocksFromHTML(e);await k(s,r.parentId,r.position)},B=async(r,e)=>{if(!r.blockId||!e)return;const s=L.getBlocksFromHTML(e);await N(r.blockId,s)},I=async r=>{!r.ids||r.ids.length===0||await y(r.ids)};let d=null;const E=(r,e)=>{const s=document.getElementById("canvas-iframe");if(!s)return null;const u=s==null?void 0:s.contentDocument;if(!u)return null;u.querySelectorAll("[data-stream-canvas]").forEach(n=>n.remove());let o=null;if(r&&r!=="undefined"&&(o=u.querySelector(`[data-block-id="${r}"]`)),o||(o=u.body),!o)return null;if(d=u.createElement("div"),d.setAttribute("data-stream-canvas","true"),e!==void 0&&e>=0&&o.children){const n=Math.min(e,o.children.length);n<o.children.length?o.insertBefore(d,o.children[n]):o.appendChild(d)}else o.appendChild(d);return d},H=r=>{var o;const e=document.getElementById("canvas-iframe");if(!e)return null;const s=e==null?void 0:e.contentDocument;if(!s)return null;s.querySelectorAll("[data-stream-canvas]").forEach(n=>n.remove());const f=s.querySelector(`[data-block-id="${r}"]`);return f?(d=s.createElement("div"),d.setAttribute("data-stream-canvas","true"),(o=f.parentNode)==null||o.insertBefore(d,f.nextSibling),f.style.display="none",d):null},M=r=>{const e=document.getElementById("canvas-iframe");(e==null?void 0:e.contentWindow)&&r.scrollIntoView({behavior:"smooth",block:"end"})},v=(r,e,s)=>{const u=E(e,s);u&&(u.innerHTML=r,M(u))},x=(r,e)=>{const s=H(e);s&&(s.innerHTML=r,M(s))},D=r=>{const e=r.match(/^--ACTION=(.+)--$/);if(!e)return null;let u=e[1].replace(/--/g,"").split("|");const o={type:u[0]};return u.forEach(n=>{const t=n.trim();if(t.startsWith("PARENT=")){const A=t.substring(7);o.parentId=A==="undefined"?void 0:A}else t.startsWith("POS=")?o.position=parseInt(t.substring(4)):t.startsWith("ID=")?o.blockId=t.substring(3):t.startsWith("IDS=")&&(o.ids=t.substring(4).split(",").map(A=>A.trim()))}),o};return j.useCallback(async(r,e)=>{const s=new TextDecoder;let u="",f="",o=!1,n=null;const t={isInAction:!1,currentAction:null,htmlBuffer:"",isCapturingHtml:!1},A=async m=>{const i=m.trim();if(i==="--START--"){o=!0;return}if(o){if(i==="--END--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await C(t.currentAction,t.htmlBuffer),d&&(d.remove(),d=null);return}if(i.startsWith("--THINKING=")){const c=i.substring(11);e(l=>{const h=[...l],g=h[h.length-1];if(g&&g.role==="assistant"&&g.isReasoning)g.content=c,g.isStreaming=!1;else{const b={id:Date.now().toString(),role:"assistant",content:c,isReasoning:!0,isStreaming:!1};h.push(b)}return h});return}if(i.startsWith("--TASK=")){const c=i.substring(7),l=`task-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,h={id:l,role:"assistant",content:c.replace(/--$/,""),isTask:!0,isTaskLoading:!0,isTaskCompleted:!1};n=l,e(g=>[...g,h]);return}if(i.startsWith("--MSG=")){const c=i.substring(6),l={id:Date.now().toString(),role:"assistant",content:c.replace(/--$/g,""),isReasoning:!1,isStreaming:!1};e(h=>[...h,l]);return}if(i.startsWith("--ACTION=")){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await C(t.currentAction,t.htmlBuffer),t.currentAction=D(i),t.htmlBuffer="",t.isInAction=!0;return}if(i==="--ENDACTION--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await C(t.currentAction,t.htmlBuffer),n&&(e(c=>c.map(l=>l.isTask?{...l,isTaskCompleted:!0}:l)),n=null),t.currentAction=null,t.htmlBuffer="",t.isInAction=!1;return}if(i==="--HTML--"){t.isCapturingHtml=!0;return}if(i==="--ENDHTML--"){t.isCapturingHtml=!1;return}if(i.startsWith("--HTML--")&&i.includes("--ENDHTML--")){const c=i.match(/^--HTML--(.+?)--ENDHTML--$/);if(c&&t.currentAction){const l=c[1];t.htmlBuffer+=l,t.currentAction.type==="ADD"?v(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
|
-
`,t.currentAction.type==="ADD"?v(t.htmlBuffer,t.currentAction.parentId,t.currentAction.position):t.currentAction.type==="EDIT"&&t.currentAction.blockId&&x(t.htmlBuffer,t.currentAction.blockId))}},C=async(m,i)=>{try{switch(m.type){case"ADD":await w(m,i);break;case"EDIT":await B(m,i);break;case"REMOVE":await I(m);break}e(c=>c.filter(l=>!l.isTask))}catch(c){console.log(c)}};try{for(;;){const{done:m,value:i}=await r.read();if(m)break;const c=s.decode(i,{stream:!0});u+=c,f+=c;const l=f.split(`
|
|
3
|
-
`);f=l.pop()||"";for(const h of l)await A(h)}f&&await A(f),T.invalidateQueries({queryKey:["AI_USAGE"]})}catch(m){console.log(m)}},[y])},V=j.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-BhTL_-mT.cjs"))),K=({t:k,fetch:N,input:y,messages:T,setInput:w,isLoading:B,setMessages:I,handleStop:d,setIsLoading:E,currentBlock:H,fallbackLang:M,setCurrentBlock:v,setAbortController:x,selectedModel:D=F.getDefaultModel().id,onModelChange:r})=>{const e=S.useSelectedBlock(),[,s]=S.useSelectedBlockIds(),u=S.useBlocksHtmlForAi(),f=$(),o=async(n,t,A,C)=>{var h;if(!n||B)return;v(e);const m=u(e?{blockId:e._id,additionalCoreBlocks:["Icon"]}:{additionalCoreBlocks:["Icon"]});if(e&&!m){W.toast.error(k("Something went wrong. Please try again."));return}const i={id:Date.now().toString(),role:"user",content:p.getUserPrompt({language:M,userInput:t||n,currentHtml:m}),userMessage:n},c={id:(Date.now()+1).toString(),role:"assistant",content:"",isReasoning:!0,isStreaming:!0};I(g=>[...g,i,c]),E(!0);const l=new AbortController;x(l);try{const g={messages:[i].map(q=>({role:q.role,content:q.content})),model:C||D};A&&(g.image=A);const b=await N({body:{action:"ASK_AI",data:g},streamResponse:!0});if(!b.ok)throw new Error(k("Failed to get AI response"));const R=(h=b.body)==null?void 0:h.getReader();if(!R)throw new Error(k("Response body is not readable"));await f(R,I)}catch(g){if(g.name!=="AbortError"){const b={id:(Date.now()+1).toString(),role:"assistant",content:k("Sorry, I encountered an error. Please try again.")};I(R=>[...R,b])}}finally{w(""),E(!1),v(null),x(null)}};return a.jsxs(a.Fragment,{children:[a.jsxs(p.Conversation,{className:"no-scrollbar",children:[a.jsxs(p.ConversationContent,{className:"gap-2 px-0",children:[T.length===0&&a.jsx(p.ConversationEmptyState,{icon:a.jsx(P.Bot,{size:48,className:"text-gray-300"}),title:"Start a conversation",description:k("Start a conversation with the AI assistant to add/edit current page")}),T.map(n=>n.role!=="system"&&a.jsx(j.Fragment,{children:n.isReasoning?a.jsxs(p.Reasoning,{isStreaming:n.isStreaming,defaultOpen:!0,children:[a.jsx(p.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),a.jsx(p.ReasoningContent,{className:"p-0 text-xs",children:n.content})]}):n.isTask&&!n.isTaskCompleted?a.jsx(p.TaskMessage,{content:n.content,isLoading:n.isTaskLoading}):a.jsx(p.Message,{from:n.role,children:a.jsx(p.MessageContent,{className:"p-0",children:n.role==="assistant"?a.jsx(p.MessageResponse,{className:"p-0 text-xs",children:n.content}):a.jsx("div",{className:"p-0 text-xs",children:n.userMessage||n.content})})})},n.id))]}),a.jsx(p.ConversationScrollButton,{})]}),a.jsxs("div",{className:"border-gray-200 pb-2",children:[a.jsx(p.SelectedBlockDisplay,{onRemove:()=>s([]),isLoading:B}),a.jsx(j.Suspense,{fallback:a.jsx("div",{children:"Loading..."}),children:a.jsx(V,{input:y,setInput:w,onSend:o,onStop:d,isLoading:B,selectedLang:"",currentBlock:e||H,disabled:(y==null?void 0:y.length)===0,selectedModel:D,onModelChange:r})})]})]})};exports.default=K;
|
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import { jsxs as C, Fragment as W, jsx as d } from "react/jsx-runtime";
|
|
2
|
-
import { ab as F, ac as P, ad as O, r as $, a as q, ae as V } from "./index-B7HAfx-2.js";
|
|
3
|
-
import { C as K, a as _, b as j, R as G, c as z, d as Q, T as U, M as J, e as X, f as Y, h as Z, S as tt, i as et } from "./selected-block-display-BbUH5RaW.js";
|
|
4
|
-
import { Bot as nt } from "lucide-react";
|
|
5
|
-
import { useCallback as rt, Fragment as st, Suspense as ot, lazy as at } from "react";
|
|
6
|
-
import { toast as it } from "sonner";
|
|
7
|
-
import { g as ct } from "./models-BCu-p_QK.js";
|
|
8
|
-
import { g as L } from "./apply-binding-vAuN-TGV.js";
|
|
9
|
-
import { useQueryClient as lt } from "@tanstack/react-query";
|
|
10
|
-
const ut = () => {
|
|
11
|
-
const { addPredefinedBlock: A } = F(), x = P(), k = O(), w = lt(), E = async (r, e) => {
|
|
12
|
-
if (!e) return;
|
|
13
|
-
const s = L(e);
|
|
14
|
-
await A(s, r.parentId, r.position);
|
|
15
|
-
}, b = async (r, e) => {
|
|
16
|
-
if (!r.blockId || !e) return;
|
|
17
|
-
const s = L(e);
|
|
18
|
-
await x(r.blockId, s);
|
|
19
|
-
}, I = async (r) => {
|
|
20
|
-
!r.ids || r.ids.length === 0 || await k(r.ids);
|
|
21
|
-
};
|
|
22
|
-
let u = null;
|
|
23
|
-
const T = (r, e) => {
|
|
24
|
-
const s = document.getElementById("canvas-iframe");
|
|
25
|
-
if (!s)
|
|
26
|
-
return null;
|
|
27
|
-
const l = s == null ? void 0 : s.contentDocument;
|
|
28
|
-
if (!l)
|
|
29
|
-
return null;
|
|
30
|
-
l.querySelectorAll("[data-stream-canvas]").forEach((n) => n.remove());
|
|
31
|
-
let o = null;
|
|
32
|
-
if (r && r !== "undefined" && (o = l.querySelector(`[data-block-id="${r}"]`)), o || (o = l.body), !o)
|
|
33
|
-
return null;
|
|
34
|
-
if (u = l.createElement("div"), u.setAttribute("data-stream-canvas", "true"), e !== void 0 && e >= 0 && o.children) {
|
|
35
|
-
const n = Math.min(e, o.children.length);
|
|
36
|
-
n < o.children.length ? o.insertBefore(u, o.children[n]) : o.appendChild(u);
|
|
37
|
-
} else
|
|
38
|
-
o.appendChild(u);
|
|
39
|
-
return u;
|
|
40
|
-
}, N = (r) => {
|
|
41
|
-
var o;
|
|
42
|
-
const e = document.getElementById("canvas-iframe");
|
|
43
|
-
if (!e)
|
|
44
|
-
return null;
|
|
45
|
-
const s = e == null ? void 0 : e.contentDocument;
|
|
46
|
-
if (!s)
|
|
47
|
-
return null;
|
|
48
|
-
s.querySelectorAll("[data-stream-canvas]").forEach((n) => n.remove());
|
|
49
|
-
const f = s.querySelector(`[data-block-id="${r}"]`);
|
|
50
|
-
return f ? (u = s.createElement("div"), u.setAttribute("data-stream-canvas", "true"), (o = f.parentNode) == null || o.insertBefore(u, f.nextSibling), f.style.display = "none", u) : null;
|
|
51
|
-
}, M = (r) => {
|
|
52
|
-
const e = document.getElementById("canvas-iframe");
|
|
53
|
-
(e == null ? void 0 : e.contentWindow) && r.scrollIntoView({ behavior: "smooth", block: "end" });
|
|
54
|
-
}, S = (r, e, s) => {
|
|
55
|
-
const l = T(e, s);
|
|
56
|
-
l && (l.innerHTML = r, M(l));
|
|
57
|
-
}, v = (r, e) => {
|
|
58
|
-
const s = N(e);
|
|
59
|
-
s && (s.innerHTML = r, M(s));
|
|
60
|
-
}, D = (r) => {
|
|
61
|
-
const e = r.match(/^--ACTION=(.+)--$/);
|
|
62
|
-
if (!e) return null;
|
|
63
|
-
let l = e[1].replace(/--/g, "").split("|");
|
|
64
|
-
const o = { type: l[0] };
|
|
65
|
-
return l.forEach((n) => {
|
|
66
|
-
const t = n.trim();
|
|
67
|
-
if (t.startsWith("PARENT=")) {
|
|
68
|
-
const p = t.substring(7);
|
|
69
|
-
o.parentId = p === "undefined" ? void 0 : p;
|
|
70
|
-
} else t.startsWith("POS=") ? o.position = parseInt(t.substring(4)) : t.startsWith("ID=") ? o.blockId = t.substring(3) : t.startsWith("IDS=") && (o.ids = t.substring(4).split(",").map((p) => p.trim()));
|
|
71
|
-
}), o;
|
|
72
|
-
};
|
|
73
|
-
return rt(
|
|
74
|
-
async (r, e) => {
|
|
75
|
-
const s = new TextDecoder();
|
|
76
|
-
let l = "", f = "", o = !1, n = null;
|
|
77
|
-
const t = {
|
|
78
|
-
isInAction: !1,
|
|
79
|
-
currentAction: null,
|
|
80
|
-
htmlBuffer: "",
|
|
81
|
-
isCapturingHtml: !1
|
|
82
|
-
}, p = async (m) => {
|
|
83
|
-
const a = m.trim();
|
|
84
|
-
if (a === "--START--") {
|
|
85
|
-
o = !0;
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (o) {
|
|
89
|
-
if (a === "--END--") {
|
|
90
|
-
t.currentAction && (t.htmlBuffer || t.currentAction.type === "REMOVE") && await B(t.currentAction, t.htmlBuffer), u && (u.remove(), u = null);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (a.startsWith("--THINKING=")) {
|
|
94
|
-
const i = a.substring(11);
|
|
95
|
-
e((c) => {
|
|
96
|
-
const g = [...c], h = g[g.length - 1];
|
|
97
|
-
if (h && h.role === "assistant" && h.isReasoning)
|
|
98
|
-
h.content = i, h.isStreaming = !1;
|
|
99
|
-
else {
|
|
100
|
-
const y = {
|
|
101
|
-
id: Date.now().toString(),
|
|
102
|
-
role: "assistant",
|
|
103
|
-
content: i,
|
|
104
|
-
isReasoning: !0,
|
|
105
|
-
isStreaming: !1
|
|
106
|
-
};
|
|
107
|
-
g.push(y);
|
|
108
|
-
}
|
|
109
|
-
return g;
|
|
110
|
-
});
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (a.startsWith("--TASK=")) {
|
|
114
|
-
const i = a.substring(7), c = `task-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, g = {
|
|
115
|
-
id: c,
|
|
116
|
-
role: "assistant",
|
|
117
|
-
content: i.replace(/--$/, ""),
|
|
118
|
-
isTask: !0,
|
|
119
|
-
isTaskLoading: !0,
|
|
120
|
-
isTaskCompleted: !1
|
|
121
|
-
};
|
|
122
|
-
n = c, e((h) => [...h, g]);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
if (a.startsWith("--MSG=")) {
|
|
126
|
-
const i = a.substring(6), c = {
|
|
127
|
-
id: Date.now().toString(),
|
|
128
|
-
role: "assistant",
|
|
129
|
-
content: i.replace(/--$/g, ""),
|
|
130
|
-
isReasoning: !1,
|
|
131
|
-
isStreaming: !1
|
|
132
|
-
};
|
|
133
|
-
e((g) => [...g, c]);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (a.startsWith("--ACTION=")) {
|
|
137
|
-
t.currentAction && (t.htmlBuffer || t.currentAction.type === "REMOVE") && await B(t.currentAction, t.htmlBuffer), t.currentAction = D(a), t.htmlBuffer = "", t.isInAction = !0;
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (a === "--ENDACTION--") {
|
|
141
|
-
t.currentAction && (t.htmlBuffer || t.currentAction.type === "REMOVE") && await B(t.currentAction, t.htmlBuffer), n && (e((i) => i.map((c) => c.isTask ? { ...c, isTaskCompleted: !0 } : c)), n = null), t.currentAction = null, t.htmlBuffer = "", t.isInAction = !1;
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (a === "--HTML--") {
|
|
145
|
-
t.isCapturingHtml = !0;
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (a === "--ENDHTML--") {
|
|
149
|
-
t.isCapturingHtml = !1;
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
if (a.startsWith("--HTML--") && a.includes("--ENDHTML--")) {
|
|
153
|
-
const i = a.match(/^--HTML--(.+?)--ENDHTML--$/);
|
|
154
|
-
if (i && t.currentAction) {
|
|
155
|
-
const c = i[1];
|
|
156
|
-
t.htmlBuffer += c, t.currentAction.type === "ADD" ? S(t.htmlBuffer, t.currentAction.parentId, t.currentAction.position) : t.currentAction.type === "EDIT" && t.currentAction.blockId && v(t.htmlBuffer, t.currentAction.blockId);
|
|
157
|
-
}
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
t.isCapturingHtml && t.currentAction && (t.htmlBuffer += m + `
|
|
161
|
-
`, t.currentAction.type === "ADD" ? S(t.htmlBuffer, t.currentAction.parentId, t.currentAction.position) : t.currentAction.type === "EDIT" && t.currentAction.blockId && v(t.htmlBuffer, t.currentAction.blockId));
|
|
162
|
-
}
|
|
163
|
-
}, B = async (m, a) => {
|
|
164
|
-
try {
|
|
165
|
-
switch (m.type) {
|
|
166
|
-
case "ADD":
|
|
167
|
-
await E(m, a);
|
|
168
|
-
break;
|
|
169
|
-
case "EDIT":
|
|
170
|
-
await b(m, a);
|
|
171
|
-
break;
|
|
172
|
-
case "REMOVE":
|
|
173
|
-
await I(m);
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
e((i) => i.filter((c) => !c.isTask));
|
|
177
|
-
} catch (i) {
|
|
178
|
-
console.log(i);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
try {
|
|
182
|
-
for (; ; ) {
|
|
183
|
-
const { done: m, value: a } = await r.read();
|
|
184
|
-
if (m) break;
|
|
185
|
-
const i = s.decode(a, { stream: !0 });
|
|
186
|
-
l += i, f += i;
|
|
187
|
-
const c = f.split(`
|
|
188
|
-
`);
|
|
189
|
-
f = c.pop() || "";
|
|
190
|
-
for (const g of c)
|
|
191
|
-
await p(g);
|
|
192
|
-
}
|
|
193
|
-
f && await p(f), w.invalidateQueries({
|
|
194
|
-
queryKey: ["AI_USAGE"]
|
|
195
|
-
});
|
|
196
|
-
} catch (m) {
|
|
197
|
-
console.log(m);
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
[k]
|
|
201
|
-
);
|
|
202
|
-
}, dt = at(() => import("./ai-prompt-input-DNb1FKXQ.js")), It = ({
|
|
203
|
-
t: A,
|
|
204
|
-
fetch: x,
|
|
205
|
-
input: k,
|
|
206
|
-
messages: w,
|
|
207
|
-
setInput: E,
|
|
208
|
-
isLoading: b,
|
|
209
|
-
setMessages: I,
|
|
210
|
-
handleStop: u,
|
|
211
|
-
setIsLoading: T,
|
|
212
|
-
currentBlock: N,
|
|
213
|
-
fallbackLang: M,
|
|
214
|
-
setCurrentBlock: S,
|
|
215
|
-
setAbortController: v,
|
|
216
|
-
selectedModel: D = ct().id,
|
|
217
|
-
onModelChange: r
|
|
218
|
-
}) => {
|
|
219
|
-
const e = $(), [, s] = q(), l = V(), f = ut(), o = async (n, t, p, B) => {
|
|
220
|
-
var g;
|
|
221
|
-
if (!n || b) return;
|
|
222
|
-
S(e);
|
|
223
|
-
const m = l(e ? { blockId: e._id, additionalCoreBlocks: ["Icon"] } : { additionalCoreBlocks: ["Icon"] });
|
|
224
|
-
if (e && !m) {
|
|
225
|
-
it.error(A("Something went wrong. Please try again."));
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
const a = {
|
|
229
|
-
id: Date.now().toString(),
|
|
230
|
-
role: "user",
|
|
231
|
-
content: et({
|
|
232
|
-
language: M,
|
|
233
|
-
userInput: t || n,
|
|
234
|
-
currentHtml: m
|
|
235
|
-
}),
|
|
236
|
-
userMessage: n
|
|
237
|
-
}, i = {
|
|
238
|
-
id: (Date.now() + 1).toString(),
|
|
239
|
-
role: "assistant",
|
|
240
|
-
content: "",
|
|
241
|
-
isReasoning: !0,
|
|
242
|
-
isStreaming: !0
|
|
243
|
-
};
|
|
244
|
-
I((h) => [...h, a, i]), T(!0);
|
|
245
|
-
const c = new AbortController();
|
|
246
|
-
v(c);
|
|
247
|
-
try {
|
|
248
|
-
const h = {
|
|
249
|
-
messages: [a].map((H) => ({
|
|
250
|
-
role: H.role,
|
|
251
|
-
content: H.content
|
|
252
|
-
})),
|
|
253
|
-
model: B || D
|
|
254
|
-
};
|
|
255
|
-
p && (h.image = p);
|
|
256
|
-
const y = await x({ body: { action: "ASK_AI", data: h }, streamResponse: !0 });
|
|
257
|
-
if (!y.ok)
|
|
258
|
-
throw new Error(A("Failed to get AI response"));
|
|
259
|
-
const R = (g = y.body) == null ? void 0 : g.getReader();
|
|
260
|
-
if (!R) throw new Error(A("Response body is not readable"));
|
|
261
|
-
await f(R, I);
|
|
262
|
-
} catch (h) {
|
|
263
|
-
if (h.name !== "AbortError") {
|
|
264
|
-
const y = {
|
|
265
|
-
id: (Date.now() + 1).toString(),
|
|
266
|
-
role: "assistant",
|
|
267
|
-
content: A("Sorry, I encountered an error. Please try again.")
|
|
268
|
-
};
|
|
269
|
-
I((R) => [...R, y]);
|
|
270
|
-
}
|
|
271
|
-
} finally {
|
|
272
|
-
E(""), T(!1), S(null), v(null);
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
return /* @__PURE__ */ C(W, { children: [
|
|
276
|
-
/* @__PURE__ */ C(K, { className: "no-scrollbar", children: [
|
|
277
|
-
/* @__PURE__ */ C(_, { className: "gap-2 px-0", children: [
|
|
278
|
-
w.length === 0 && /* @__PURE__ */ d(
|
|
279
|
-
j,
|
|
280
|
-
{
|
|
281
|
-
icon: /* @__PURE__ */ d(nt, { size: 48, className: "text-gray-300" }),
|
|
282
|
-
title: "Start a conversation",
|
|
283
|
-
description: A("Start a conversation with the AI assistant to add/edit current page")
|
|
284
|
-
}
|
|
285
|
-
),
|
|
286
|
-
w.map(
|
|
287
|
-
(n) => n.role !== "system" && /* @__PURE__ */ d(st, { children: n.isReasoning ? /* @__PURE__ */ C(G, { isStreaming: n.isStreaming, defaultOpen: !0, children: [
|
|
288
|
-
/* @__PURE__ */ d(z, { className: "text-xs [&_p]:text-muted-foreground" }),
|
|
289
|
-
/* @__PURE__ */ d(Q, { className: "p-0 text-xs", children: n.content })
|
|
290
|
-
] }) : n.isTask && !n.isTaskCompleted ? /* @__PURE__ */ d(U, { content: n.content, isLoading: n.isTaskLoading }) : /* @__PURE__ */ d(J, { from: n.role, children: /* @__PURE__ */ d(X, { className: "p-0", children: n.role === "assistant" ? /* @__PURE__ */ d(Y, { className: "p-0 text-xs", children: n.content }) : /* @__PURE__ */ d("div", { className: "p-0 text-xs", children: n.userMessage || n.content }) }) }) }, n.id)
|
|
291
|
-
)
|
|
292
|
-
] }),
|
|
293
|
-
/* @__PURE__ */ d(Z, {})
|
|
294
|
-
] }),
|
|
295
|
-
/* @__PURE__ */ C("div", { className: "border-gray-200 pb-2", children: [
|
|
296
|
-
/* @__PURE__ */ d(tt, { onRemove: () => s([]), isLoading: b }),
|
|
297
|
-
/* @__PURE__ */ d(ot, { fallback: /* @__PURE__ */ d("div", { children: "Loading..." }), children: /* @__PURE__ */ d(
|
|
298
|
-
dt,
|
|
299
|
-
{
|
|
300
|
-
input: k,
|
|
301
|
-
setInput: E,
|
|
302
|
-
onSend: o,
|
|
303
|
-
onStop: u,
|
|
304
|
-
isLoading: b,
|
|
305
|
-
selectedLang: "",
|
|
306
|
-
currentBlock: e || N,
|
|
307
|
-
disabled: (k == null ? void 0 : k.length) === 0,
|
|
308
|
-
selectedModel: D,
|
|
309
|
-
onModelChange: r
|
|
310
|
-
}
|
|
311
|
-
) })
|
|
312
|
-
] })
|
|
313
|
-
] });
|
|
314
|
-
};
|
|
315
|
-
export {
|
|
316
|
-
It as default
|
|
317
|
-
};
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { jsxs as c, Fragment as $, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { r as G, a as H, s as Q, t as X } from "./index-B7HAfx-2.js";
|
|
3
|
-
import { C as Y, a as Z, b as L, R as ee, c as te, d as ne, T as se, M as oe, e as ae, f as re, S as ie, g as ce } from "./selected-block-display-BbUH5RaW.js";
|
|
4
|
-
import { Bot as le } from "lucide-react";
|
|
5
|
-
import { useRef as de, useEffect as ue, Suspense as B, lazy as v, Fragment as he } from "react";
|
|
6
|
-
import { useTranslation as me } from "react-i18next";
|
|
7
|
-
import { g as ge } from "./models-BCu-p_QK.js";
|
|
8
|
-
const fe = v(() => import("./ai-translation-prompt-B2MfzTjb.js")), pe = v(() => import("./ai-prompt-input-DNb1FKXQ.js")), xe = ({
|
|
9
|
-
fetch: A,
|
|
10
|
-
input: o,
|
|
11
|
-
messages: l,
|
|
12
|
-
setInput: m,
|
|
13
|
-
isLoading: a,
|
|
14
|
-
handleStop: E,
|
|
15
|
-
setMessages: g,
|
|
16
|
-
setIsLoading: d,
|
|
17
|
-
selectedLang: r,
|
|
18
|
-
currentBlock: M,
|
|
19
|
-
fallbackLang: C,
|
|
20
|
-
abortController: u,
|
|
21
|
-
setAbortController: O,
|
|
22
|
-
setCurrentBlock: f,
|
|
23
|
-
selectedModel: p = ge().id,
|
|
24
|
-
onModelChange: P
|
|
25
|
-
}) => {
|
|
26
|
-
const { t: n } = me(), D = de(null), i = G(), [, I] = H(), k = Q(), F = X(), j = () => {
|
|
27
|
-
var e;
|
|
28
|
-
(e = D.current) == null || e.scrollIntoView({ behavior: "smooth" });
|
|
29
|
-
};
|
|
30
|
-
ue(() => {
|
|
31
|
-
j();
|
|
32
|
-
}, [l, a]);
|
|
33
|
-
const T = async (e, y, _) => {
|
|
34
|
-
var N;
|
|
35
|
-
i && f(i);
|
|
36
|
-
const S = (e == null ? void 0 : e.toLowerCase()) === "translate", w = {
|
|
37
|
-
id: Date.now().toString(),
|
|
38
|
-
role: "user",
|
|
39
|
-
content: ce({
|
|
40
|
-
fallbackLang: C,
|
|
41
|
-
userInput: y || e,
|
|
42
|
-
language: r,
|
|
43
|
-
blocks: S ? k() : k(r)
|
|
44
|
-
}),
|
|
45
|
-
userMessage: y || e || n("Translate the content")
|
|
46
|
-
}, q = {
|
|
47
|
-
id: (Date.now() + 1).toString(),
|
|
48
|
-
role: "assistant",
|
|
49
|
-
content: "Thinking...",
|
|
50
|
-
isReasoning: !0,
|
|
51
|
-
isStreaming: !0
|
|
52
|
-
};
|
|
53
|
-
d(!0);
|
|
54
|
-
const z = new AbortController();
|
|
55
|
-
O(z), g((b) => [...b, w, q]), d(!0);
|
|
56
|
-
try {
|
|
57
|
-
const x = await A({ body: { action: "ASK_AI", data: {
|
|
58
|
-
messages: [w],
|
|
59
|
-
initiator: S ? "TRANSLATE_CONTENT" : "UPDATE_CONTENT",
|
|
60
|
-
model: _ || p
|
|
61
|
-
} }, streamResponse: !0 });
|
|
62
|
-
if (!x.ok)
|
|
63
|
-
throw new Error(n("Failed to get AI response"));
|
|
64
|
-
const R = (N = x.body) == null ? void 0 : N.getReader(), U = new TextDecoder();
|
|
65
|
-
let s = "";
|
|
66
|
-
if (!R) throw new Error(n("Response body is not readable"));
|
|
67
|
-
for (; ; ) {
|
|
68
|
-
const { done: K, value: V } = await R.read();
|
|
69
|
-
if (K)
|
|
70
|
-
break;
|
|
71
|
-
const W = U.decode(V, { stream: !0 });
|
|
72
|
-
s += W, g((h) => (h[h.length - 1].content = s, [...h]));
|
|
73
|
-
}
|
|
74
|
-
const J = JSON.parse(s == null ? void 0 : s.replace("```json", "").replace("```", ""));
|
|
75
|
-
F(J);
|
|
76
|
-
} catch {
|
|
77
|
-
u == null || u.abort();
|
|
78
|
-
} finally {
|
|
79
|
-
d(!1), m(""), f(null);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
return /* @__PURE__ */ c($, { children: [
|
|
83
|
-
/* @__PURE__ */ t("div", { className: "py-2", children: /* @__PURE__ */ t(B, { fallback: /* @__PURE__ */ t("div", { children: n("Loading...") }), children: /* @__PURE__ */ t(
|
|
84
|
-
fe,
|
|
85
|
-
{
|
|
86
|
-
isLoading: a,
|
|
87
|
-
selectedBlock: i,
|
|
88
|
-
selectedLang: r,
|
|
89
|
-
onClick: T
|
|
90
|
-
}
|
|
91
|
-
) }) }),
|
|
92
|
-
/* @__PURE__ */ t(Y, { children: /* @__PURE__ */ c(Z, { className: "gap-4 px-0", children: [
|
|
93
|
-
l.length === 0 && /* @__PURE__ */ t(
|
|
94
|
-
L,
|
|
95
|
-
{
|
|
96
|
-
icon: /* @__PURE__ */ t(le, { size: 48, className: "text-gray-300" }),
|
|
97
|
-
title: n("Start a conversation with the AI assistant to translate/edit your content"),
|
|
98
|
-
description: n(
|
|
99
|
-
"Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language."
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
),
|
|
103
|
-
l.map(
|
|
104
|
-
(e) => e.role !== "system" && /* @__PURE__ */ t(he, { children: e.isReasoning ? /* @__PURE__ */ c(ee, { isStreaming: e.isStreaming, defaultOpen: !0, children: [
|
|
105
|
-
/* @__PURE__ */ t(te, { className: "text-xs [&_p]:text-muted-foreground" }),
|
|
106
|
-
/* @__PURE__ */ t(ne, { className: "p-0 text-xs", children: e.content })
|
|
107
|
-
] }) : e.isTask ? /* @__PURE__ */ t(se, { content: e.content, isLoading: e.isTaskLoading }) : /* @__PURE__ */ t(oe, { from: e.role, children: /* @__PURE__ */ t(ae, { className: "p-0", children: e.role === "assistant" ? /* @__PURE__ */ t(re, { className: "p-0 text-xs", children: e.content }) : /* @__PURE__ */ t("div", { className: "p-0 text-xs", children: e.userMessage || e.content }) }) }) }, e.id)
|
|
108
|
-
)
|
|
109
|
-
] }) }),
|
|
110
|
-
/* @__PURE__ */ c("div", { className: "border-gray-200 pb-2", children: [
|
|
111
|
-
/* @__PURE__ */ t(ie, { onRemove: () => I([]), isLoading: a }),
|
|
112
|
-
/* @__PURE__ */ t(B, { fallback: /* @__PURE__ */ t("div", { children: n("Loading...") }), children: /* @__PURE__ */ t(
|
|
113
|
-
pe,
|
|
114
|
-
{
|
|
115
|
-
input: o,
|
|
116
|
-
setInput: m,
|
|
117
|
-
onSend: T,
|
|
118
|
-
onStop: E,
|
|
119
|
-
isLoading: a,
|
|
120
|
-
selectedLang: r,
|
|
121
|
-
currentBlock: i || M,
|
|
122
|
-
disabled: (o == null ? void 0 : o.length) === 0,
|
|
123
|
-
selectedModel: p,
|
|
124
|
-
onModelChange: P
|
|
125
|
-
}
|
|
126
|
-
) })
|
|
127
|
-
] })
|
|
128
|
-
] });
|
|
129
|
-
};
|
|
130
|
-
export {
|
|
131
|
-
xe as default
|
|
132
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("./index-DTNHTRZu.cjs"),s=require("./selected-block-display-BHx9N14K.cjs"),G=require("lucide-react"),o=require("react"),H=require("react-i18next"),Q=require("./models-D0RH2u4C.cjs"),X=o.lazy(()=>Promise.resolve().then(()=>require("./ai-translation-prompt-CL3yk8K1.cjs"))),Y=o.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-BhTL_-mT.cjs"))),Z=({fetch:v,input:a,messages:u,setInput:j,isLoading:c,handleStop:q,setMessages:y,setIsLoading:h,selectedLang:i,currentBlock:A,fallbackLang:P,abortController:x,setAbortController:E,setCurrentBlock:k,selectedModel:S=Q.getDefaultModel().id,onModelChange:M})=>{const{t:n}=H.useTranslation(),O=o.useRef(null),l=d.useSelectedBlock(),[,D]=d.useSelectedBlockIds(),T=d.useI18nBlocks(),I=d.useStreamMultipleBlocksProps(),C=()=>{var t;(t=O.current)==null||t.scrollIntoView({behavior:"smooth"})};o.useEffect(()=>{C()},[u,c]);const f=async(t,m,F)=>{var b;l&&k(l);const p=(t==null?void 0:t.toLowerCase())==="translate",R={id:Date.now().toString(),role:"user",content:s.getTranslationUserPrompt({fallbackLang:P,userInput:m||t,language:i,blocks:p?T():T(i)}),userMessage:m||t||n("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(n("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(n("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("```",""));I(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:n("Loading...")}),children:e.jsx(X,{isLoading:c,selectedBlock:l,selectedLang:i,onClick:f})})}),e.jsx(s.Conversation,{children:e.jsxs(s.ConversationContent,{className:"gap-4 px-0",children:[u.length===0&&e.jsx(s.ConversationEmptyState,{icon:e.jsx(G.Bot,{size:48,className:"text-gray-300"}),title:n("Start a conversation with the AI assistant to translate/edit your content"),description:n("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(s.Reasoning,{isStreaming:t.isStreaming,defaultOpen:!0,children:[e.jsx(s.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),e.jsx(s.ReasoningContent,{className:"p-0 text-xs",children:t.content})]}):t.isTask?e.jsx(s.TaskMessage,{content:t.content,isLoading:t.isTaskLoading}):e.jsx(s.Message,{from:t.role,children:e.jsx(s.MessageContent,{className:"p-0",children:t.role==="assistant"?e.jsx(s.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(s.SelectedBlockDisplay,{onRemove:()=>D([]),isLoading:c}),e.jsx(o.Suspense,{fallback:e.jsx("div",{children:n("Loading...")}),children:e.jsx(Y,{input:a,setInput:j,onSend:f,onStop:q,isLoading:c,selectedLang:i,currentBlock:l||A,disabled:(a==null?void 0:a.length)===0,selectedModel:S,onModelChange:M})})]})]})};exports.default=Z;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./register-chai-top-bar-DyW9GPzV.cjs"),S=require("./index-DTNHTRZu.cjs"),W=require("class-variance-authority"),k=require("lucide-react"),te=require("nanoid"),c=require("react"),se=require("react-i18next"),L=require("./models-D0RH2u4C.cjs");function ne({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:b.cn("group/input-group shadow-xs relative flex w-full items-center rounded-md border border-input outline-none transition-[color,box-shadow] dark:bg-input/30","h-9 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-ring","has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...s})}const re=W.cva("text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5","block-end":"[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function H({className:t,align:s="inline-start",...a}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:b.cn(re({align:s}),t),onClick:l=>{var o,f;l.target.closest("button")||(f=(o=l.currentTarget.parentElement)==null?void 0:o.querySelector("input"))==null||f.focus()},...a})}const ae=W.cva("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function K({className:t,type:s="button",variant:a="ghost",size:l="xs",...o}){return e.jsx(b.Button,{type:s,"data-size":l,variant:a,className:b.cn(ae({size:l}),t),...o})}function oe({className:t,...s}){return e.jsx(S.Textarea,{"data-slot":"input-group-control",className:b.cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",t),...s})}const ie=c.createContext(null),ce=c.createContext(null),X=()=>c.useContext(ie),le=()=>c.useContext(ce),$=c.createContext(null),q=()=>{const t=le(),s=c.useContext($),a=t??s;if(!a)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return a};function ue({data:t,className:s,...a}){var u;const l=q(),o=t.filename||"",p=((u=t.mediaType)!=null&&u.startsWith("image/")&&t.url?"image":"file")==="image",x=o||(p?"Image":"Attachment");return e.jsxs(ye,{children:[e.jsx(S.HoverCardTrigger,{asChild:!0,children:e.jsxs("div",{className:b.cn("group relative flex h-8 cursor-default select-none items-center gap-1.5 rounded-md border border-border px-1.5 text-sm font-medium transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",s),...a,children:[e.jsxs("div",{className:"relative size-5 shrink-0",children:[e.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:p?e.jsx("img",{alt:o||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20}):e.jsx("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:e.jsx(k.PaperclipIcon,{className:"size-3"})})}),e.jsxs(b.Button,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:N=>{N.stopPropagation(),l.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(k.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:x})]},t.id)}),e.jsx(Ie,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[p&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:o||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),e.jsx("div",{className:"flex items-center gap-2.5",children:e.jsxs("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[e.jsx("h4",{className:"truncate text-sm font-semibold leading-none",children:o||(p?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function de({children:t,className:s,...a}){const l=q();return l.files.length?e.jsx("div",{className:b.cn("flex flex-wrap items-center gap-2 p-3",s),...a,children:l.files.map(o=>e.jsx(c.Fragment,{children:t(o)},o.id))}):null}const pe=({label:t="Add photos or files",...s})=>{const a=q();return e.jsxs(S.DropdownMenuItem,{...s,onSelect:l=>{l.preventDefault(),a.openFileDialog()},children:[e.jsx(k.ImageIcon,{className:"mr-2 size-4"})," ",t]})},me=({className:t,accept:s,multiple:a,globalDrop:l,syncHiddenInput:o,maxFiles:f,maxFileSize:p,onError:x,onSubmit:u,children:N,...y})=>{const r=X(),i=!!r,g=c.useRef(null),P=c.useRef(null),I=c.useRef(null);c.useEffect(()=>{var v;const n=(v=P.current)==null?void 0:v.closest("form");n instanceof HTMLFormElement&&(I.current=n)},[]);const[D,z]=c.useState([]),h=i?r.attachments.files:D,A=c.useCallback(()=>{var n;(n=g.current)==null||n.click()},[]),M=c.useCallback(n=>!s||s.trim()===""?!0:s.includes("image/*")?n.type.startsWith("image/"):!0,[s]),U=c.useCallback(n=>{const v=Array.from(n),m=v.filter(w=>M(w));if(v.length&&m.length===0){x==null||x({code:"accept",message:"No files match the accepted types."});return}const d=w=>p?w.size<=p:!0,j=m.filter(d);if(m.length>0&&j.length===0){x==null||x({code:"max_file_size",message:"All files exceed the maximum size."});return}z(w=>{const C=typeof f=="number"?Math.max(0,f-w.length):void 0,ee=typeof C=="number"?j.slice(0,C):j;typeof C=="number"&&j.length>C&&(x==null||x({code:"max_files",message:"Too many files. Some were not added."}));const _=[];for(const E of ee)_.push({id:te.nanoid(),type:"file",url:URL.createObjectURL(E),mediaType:E.type,filename:E.name});return w.concat(_)})},[M,f,p,x]),T=i?n=>r.attachments.add(n):U,R=i?n=>r.attachments.remove(n):n=>z(v=>{const m=v.find(d=>d.id===n);return m!=null&&m.url&&URL.revokeObjectURL(m.url),v.filter(d=>d.id!==n)}),O=i?()=>r.attachments.clear():()=>z(n=>{for(const v of n)v.url&&URL.revokeObjectURL(v.url);return[]}),B=i?()=>r.attachments.openFileDialog():A;c.useEffect(()=>{i&&r.__registerFileInput(g,()=>{var n;return(n=g.current)==null?void 0:n.click()})},[i,r]),c.useEffect(()=>{o&&g.current&&h.length===0&&(g.current.value="")},[h,o]),c.useEffect(()=>{const n=I.current;if(!n)return;const v=d=>{var j,w;(w=(j=d.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&d.preventDefault()},m=d=>{var j,w,C;(w=(j=d.dataTransfer)==null?void 0:j.types)!=null&&w.includes("Files")&&d.preventDefault(),(C=d.dataTransfer)!=null&&C.files&&d.dataTransfer.files.length>0&&T(d.dataTransfer.files)};return n.addEventListener("dragover",v),n.addEventListener("drop",m),()=>{n.removeEventListener("dragover",v),n.removeEventListener("drop",m)}},[T]),c.useEffect(()=>{if(!l)return;const n=m=>{var d,j;(j=(d=m.dataTransfer)==null?void 0:d.types)!=null&&j.includes("Files")&&m.preventDefault()},v=m=>{var d,j,w;(j=(d=m.dataTransfer)==null?void 0:d.types)!=null&&j.includes("Files")&&m.preventDefault(),(w=m.dataTransfer)!=null&&w.files&&m.dataTransfer.files.length>0&&T(m.dataTransfer.files)};return document.addEventListener("dragover",n),document.addEventListener("drop",v),()=>{document.removeEventListener("dragover",n),document.removeEventListener("drop",v)}},[T,l]),c.useEffect(()=>()=>{if(!i)for(const n of h)n.url&&URL.revokeObjectURL(n.url)},[i,h]);const Y=n=>{n.currentTarget.files&&T(n.currentTarget.files)},J=async n=>{const m=await(await fetch(n)).blob();return new Promise((d,j)=>{const w=new FileReader;w.onloadend=()=>d(w.result),w.onerror=j,w.readAsDataURL(m)})},Q=c.useMemo(()=>({files:h.map(n=>({...n,id:n.id})),add:T,remove:R,clear:O,openFileDialog:B,fileInputRef:g}),[h,T,R,O,B]),Z=n=>{n.preventDefault();const v=n.currentTarget,m=i?r.textInput.value:new FormData(v).get("message")||"";i||v.reset(),Promise.all(h.map(async({...d})=>d.url&&d.url.startsWith("blob:")?{...d,url:await J(d.url)}:d)).then(d=>{try{const j=u({text:m,files:d},n);j instanceof Promise?j.then(()=>{O(),i&&r.textInput.clear()}).catch(()=>{}):(O(),i&&r.textInput.clear())}catch{}})},G=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:Y,ref:g,title:"Upload files",type:"file"}),e.jsx("form",{className:b.cn("w-full",t),onSubmit:Z,...y,children:e.jsx(ne,{className:"overflow-hidden",children:N})})]});return i?G:e.jsx($.Provider,{value:Q,children:G})},fe=({onChange:t,className:s,placeholder:a="What would you like to know?",...l})=>{const o=X(),f=q(),[p,x]=c.useState(!1),u=r=>{if(r.key==="Enter"){if(p||r.nativeEvent.isComposing||r.shiftKey)return;r.preventDefault();const i=r.currentTarget.form,g=i==null?void 0:i.querySelector('button[type="submit"]');if(g!=null&&g.disabled)return;i==null||i.requestSubmit()}if(r.key==="Backspace"&&r.currentTarget.value===""&&f.files.length>0){r.preventDefault();const i=f.files.at(-1);i&&f.remove(i.id)}},N=r=>{var P;const i=(P=r.clipboardData)==null?void 0:P.items;if(!i)return;const g=[];for(const I of i)if(I.kind==="file"){const D=I.getAsFile();D&&g.push(D)}g.length>0&&(r.preventDefault(),f.add(g))},y=o?{value:o.textInput.value,onChange:r=>{o.textInput.setInput(r.currentTarget.value),t==null||t(r)}}:{onChange:t};return e.jsx(oe,{className:b.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>x(!1),onCompositionStart:()=>x(!0),onKeyDown:u,onPaste:N,placeholder:a,...l,...y})},he=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("order-first flex-wrap gap-1",t),...s}),xe=({className:t,...s})=>e.jsx(H,{align:"block-end",className:b.cn("justify-between gap-1",t),...s}),ge=({className:t,...s})=>e.jsx("div",{className:b.cn("flex items-center gap-1",t),...s}),F=({variant:t="ghost",className:s,size:a,...l})=>{const o=a??(c.Children.count(l.children)>1?"sm":"icon-sm");return e.jsx(K,{className:b.cn(s),size:o,type:"button",variant:t,...l})},ve=t=>e.jsx(S.DropdownMenu,{...t}),je=({className:t,children:s,...a})=>e.jsx(S.DropdownMenuTrigger,{asChild:!0,children:e.jsx(F,{className:t,...a,children:s??e.jsx(k.PlusIcon,{className:"size-4"})})}),be=({className:t,...s})=>e.jsx(S.DropdownMenuContent,{align:"start",className:b.cn(t),...s}),we=({className:t,variant:s="default",size:a="icon-sm",status:l,children:o,...f})=>{let p=e.jsx(k.CornerDownLeftIcon,{className:"size-4"});return l==="submitted"?p=e.jsx(k.Loader2Icon,{className:"size-4 animate-spin"}):l==="streaming"?p=e.jsx(k.SquareIcon,{className:"size-4"}):l==="error"&&(p=e.jsx(k.XIcon,{className:"size-4"})),e.jsx(K,{"aria-label":"Submit",className:b.cn(t),size:a,type:"submit",variant:s,...f,children:o??p})},Ne=({className:t,textareaRef:s,onTranscriptionChange:a,...l})=>{const[o,f]=c.useState(!1),[p,x]=c.useState(null),u=c.useRef(null);c.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const y=window.SpeechRecognition||window.webkitSpeechRecognition,r=new y;r.continuous=!0,r.interimResults=!0,r.lang="en-US",r.onstart=()=>{f(!0)},r.onend=()=>{f(!1)},r.onresult=i=>{var P;let g="";for(let I=i.resultIndex;I<i.results.length;I++){const D=i.results[I];D.isFinal&&(g+=((P=D[0])==null?void 0:P.transcript)??"")}if(g&&(s!=null&&s.current)){const I=s.current,D=I.value,z=D+(D?" ":"")+g;I.value=z,I.dispatchEvent(new Event("input",{bubbles:!0})),a==null||a(z)}},r.onerror=i=>{console.error("Speech recognition error:",i.error),f(!1)},u.current=r,c.startTransition(()=>x(r))}return()=>{u.current&&u.current.stop()}},[s,a]);const N=c.useCallback(()=>{p&&(o?p.stop():p.start())},[p,o]);return e.jsx(F,{className:b.cn("relative transition-all duration-200",o&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!p,onClick:N,...l,children:e.jsx(k.MicIcon,{className:"size-4"})})},ye=({openDelay:t=0,closeDelay:s=0,...a})=>e.jsx(S.HoverCard,{closeDelay:s,openDelay:t,...a}),Ie=({align:t="start",...s})=>e.jsx(S.HoverCardContent,{align:t,...s}),Se=t=>e.jsx(S.Dialog,{...t}),ke=t=>e.jsx(S.DialogTrigger,{...t}),De=({className:t,children:s,title:a="Model Selector",...l})=>e.jsxs(S.DialogContent,{className:b.cn("p-0",t),...l,children:[e.jsx(S.DialogTitle,{className:"sr-only",children:a}),e.jsx(S.Command,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),Pe=t=>e.jsx(S.CommandList,{...t}),Te=t=>e.jsx(S.CommandGroup,{...t}),ze=t=>e.jsx(S.CommandItem,{...t}),Ae=({provider:t,className:s,...a})=>e.jsx("img",{...a,alt:`${t} logo`,className:b.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Ce=({className:t,...s})=>e.jsx("span",{className:b.cn("flex-1 truncate text-left",t),...s}),Re=({selectedModel:t,onModelChange:s,disabled:a=!1})=>{const[l,o]=c.useState(!1),f=L.getModelById(t)||L.getDefaultModel(),p=L.AI_MODELS.reduce((u,N)=>(u[N.provider]||(u[N.provider]=[]),u[N.provider].push(N),u),{}),x=u=>{s(u),o(!1)};return e.jsxs(Se,{open:l,onOpenChange:o,children:[e.jsx(ke,{asChild:!0,children:e.jsxs(b.Button,{variant:"outline",size:"sm",disabled:a,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(k.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:f.name})]})}),e.jsxs(De,{className:"w-96 p-0",children:[e.jsx("h3",{className:"mt-2 px-2 py-2 font-semibold",children:"Models"}),e.jsx(Pe,{children:Object.entries(p).map(([u,N])=>e.jsx(Te,{heading:u.charAt(0).toUpperCase()+u.slice(1),children:N.map(y=>e.jsxs(ze,{value:y.id,onSelect:()=>x(y.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(Ae,{provider:y.provider}),e.jsxs("div",{className:"flex flex-1 items-center justify-between",children:[e.jsx(Ce,{children:y.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:y.description})]}),t===y.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},y.id))},u))})]})]})},V="chai-ai-selected-model",Le=({input:t,setInput:s,onSend:a,onStop:l,isLoading:o,disabled:f,selectedLang:p,selectedModel:x=L.getDefaultModel().id,onModelChange:u})=>{const{t:N}=se.useTranslation(),[y,r]=c.useState(x),[i,g]=c.useState(null),P=c.useRef(null),[I,D]=c.useState(!1);c.useEffect(()=>{if(!p){const h=localStorage.getItem(V);if(h)r(h),u==null||u(h);else{const A=L.getDefaultModel().id;r(A),u==null||u(A)}}},[p,u]);const z=h=>{var U;const A=h.files.find(T=>{var R;return(R=T.mediaType)==null?void 0:R.startsWith("image/")}),M=(A==null?void 0:A.url)||i;a((U=h.text)==null?void 0:U.trim(),void 0,M,y),g(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(me,{onSubmit:z,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(he,{className:"p-0",children:e.jsx(de,{className:"pb-0",children:h=>e.jsx(ue,{className:"text-xs",data:h})})}),e.jsx(fe,{ref:P,value:t,onChange:h=>s(h.target.value),placeholder:N(p?"Ask to update content":"Ask me anything..."),disabled:o,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(xe,{children:[p?e.jsx("div",{}):e.jsxs(ge,{children:[e.jsxs(ve,{children:[e.jsx(je,{disabled:o,children:e.jsx(k.Paperclip,{size:16})}),e.jsx(be,{children:e.jsx(pe,{})})]}),e.jsx(Ne,{textareaRef:P,onTranscriptionChange:s,disabled:o}),e.jsx(Re,{selectedModel:y,onModelChange:h=>{r(h),u==null||u(h),localStorage.setItem(V,h)},disabled:o}),e.jsxs(F,{className:"hidden",size:"sm",onClick:()=>D(!I),variant:I?"default":"ghost",children:[e.jsx(k.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),o?e.jsx("button",{onClick:l,className:"z-50 flex items-center gap-x-1 rounded-md bg-red-500 p-1.5 text-white transition-colors hover:bg-red-600",title:N("Stop generation"),children:e.jsx(k.Square,{size:16})}):e.jsx(we,{disabled:!t.trim()||f,children:e.jsx(k.Send,{size:16})})]})]})})})};exports.default=Le;
|