@chaibuilder/pages 0.16.24 → 0.16.26
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-UndKMj-X.cjs → 2AITGKQY-Be359164.cjs} +1 -1
- package/dist/{2AITGKQY-Ir_ZXu1s.js → 2AITGKQY-CoZaZMrf.js} +2 -2
- package/dist/{NCMVHL6D-B3xcD0Vz.js → NCMVHL6D-C2p_bwgN.js} +2 -2
- package/dist/{NCMVHL6D-taGMv4he.cjs → NCMVHL6D-CmKLw38-.cjs} +1 -1
- package/dist/{ZDWCUMSJ-Cot4ixKZ.cjs → ZDWCUMSJ-DDHOTUX8.cjs} +1 -1
- package/dist/{ZDWCUMSJ-B1vApR00.js → ZDWCUMSJ-DmZy2MGb.js} +1 -1
- package/dist/{active-in-another-tab-Kp8LaYW5.js → active-in-another-tab-At1yEu4g.js} +1 -1
- package/dist/{active-in-another-tab-DYU7aCUa.cjs → active-in-another-tab-B1PAoWFL.cjs} +1 -1
- package/dist/{add-new-language-page-CkyPkpzC.cjs → add-new-language-page-B7fKZbYT.cjs} +1 -1
- package/dist/{add-new-language-page-0J2KTKg6.js → add-new-language-page-BfPVFqO4.js} +2 -2
- package/dist/{add-new-page-DPtVHa8m.cjs → add-new-page-DBVt7xSO.cjs} +1 -1
- package/dist/{add-new-page-BjxHUGIo.js → add-new-page-GZdKxwCY.js} +1 -1
- package/dist/{ai-panel-content-CMfopU0G.js → ai-panel-content-CWw-2gPV.js} +2 -2
- package/dist/{ai-panel-content-nmbQV7rT.cjs → ai-panel-content-Cv67WLJd.cjs} +1 -1
- package/dist/{ai-panel-default-lang-7L9rURdC.js → ai-panel-default-lang-B1WScOB4.js} +3 -3
- package/dist/{ai-panel-default-lang-B5eNybL4.cjs → ai-panel-default-lang-BBk6sSyh.cjs} +2 -2
- package/dist/{ai-panel-other-lang-DLn89TFE.cjs → ai-panel-other-lang-BrVV9nKv.cjs} +1 -1
- package/dist/{ai-panel-other-lang-U5XRqxbF.js → ai-panel-other-lang-DgNon2GH.js} +3 -3
- package/dist/{ai-prompt-input-B24vn-LG.js → ai-prompt-input-B6KsNLgP.js} +2 -2
- package/dist/ai-prompt-input-DSmIbsS_.cjs +1 -0
- package/dist/{ai-translation-prompt-CB67Sqo9.cjs → ai-translation-prompt-BYTviKVU.cjs} +1 -1
- package/dist/{ai-translation-prompt-cym054ja.js → ai-translation-prompt-CfnXqyai.js} +1 -1
- package/dist/button-CMMN5Cp4.cjs +1 -0
- package/dist/button-CggatMM3.js +48 -0
- package/dist/{continue-editing-in-this-client-BYJaymOL.cjs → continue-editing-in-this-client--Fzos10u.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-BDYiQrbE.js → continue-editing-in-this-client--RRixZUo.js} +1 -1
- package/dist/{delete-page-BXEQB0Si.cjs → delete-page-BOuq3v6x.cjs} +1 -1
- package/dist/{delete-page-CvSN4E4V.js → delete-page-CeJdK5hc.js} +1 -1
- package/dist/{digital-asset-manager-CF1Lyc5K.cjs → digital-asset-manager-BUEa7fSG.cjs} +1 -1
- package/dist/{digital-asset-manager-BxbX7ji1.js → digital-asset-manager-D6GbpYDo.js} +1 -1
- package/dist/{duplicate-page-BFnuk1nL.js → duplicate-page-C7FjAbqP.js} +2 -2
- package/dist/{duplicate-page-C32_9H41.cjs → duplicate-page-Ch9Fn-Gu.cjs} +1 -1
- package/dist/{dynamic-page-selector-CLxpglyO.cjs → dynamic-page-selector-CZNYCxbJ.cjs} +1 -1
- package/dist/{dynamic-page-selector-CSTuQhej.js → dynamic-page-selector-C_-ihnB7.js} +1 -1
- package/dist/{index-Bre43r-W.cjs → index-CJcS3b8n.cjs} +5 -5
- package/dist/{index-tgsBai_8.js → index-CtRx3Y3K.js} +1039 -1028
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/{json-diff-viewer-2gVCV5T-.js → json-diff-viewer-DX4sQltt.js} +1 -1
- package/dist/{json-diff-viewer-34Sqd4il.cjs → json-diff-viewer-DluaC8tY.cjs} +1 -1
- package/dist/{lang-panel-CXIcTGVk.cjs → lang-panel-DFe4DfU4.cjs} +1 -1
- package/dist/{lang-panel-Cj0axCpE.js → lang-panel-p7OYw-2c.js} +2 -2
- package/dist/{mark-as-template-DKBwTiMJ.cjs → mark-as-template-Biqpp8uM.cjs} +1 -1
- package/dist/{mark-as-template-1TuznHtx.js → mark-as-template-CuPKgc5N.js} +1 -1
- package/dist/{no-language-page-content-C265--no.js → no-language-page-content-B_zNVuVO.js} +1 -1
- package/dist/{no-language-page-content-B8udZsi2.cjs → no-language-page-content-oy4ZcH34.cjs} +1 -1
- package/dist/{no-language-page-dialog-CctilPnb.cjs → no-language-page-dialog-CTRG81hU.cjs} +1 -1
- package/dist/{no-language-page-dialog-DgaP74-Y.js → no-language-page-dialog-Q2rvsEP6.js} +2 -2
- package/dist/{page-creator-NkF29o0S.cjs → page-creator-CVrbjJa-.cjs} +1 -1
- package/dist/{page-creator-Cer7L7dg.js → page-creator-b6UTCFeu.js} +2 -2
- package/dist/{page-lock-0qEG4sLX.cjs → page-lock-DUwWdppB.cjs} +1 -1
- package/dist/{page-lock-DNrP3AhL.js → page-lock-Dl5CmUgk.js} +2 -2
- package/dist/{page-locked-dialog-B9p5gIGE.cjs → page-locked-dialog-DeUMR-pV.cjs} +1 -1
- package/dist/{page-locked-dialog-U5eDKeBc.js → page-locked-dialog-MJ3kA-oQ.js} +1 -1
- package/dist/page-manager-new-C3XuiDiM.cjs +1 -0
- package/dist/page-manager-new-C8PGR_4a.js +394 -0
- package/dist/{page-manager-search-and-filter-DKrQdcb0.cjs → page-manager-search-and-filter-BdfXZwwH.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-DDdYtDF7.js → page-manager-search-and-filter-DIz68YHL.js} +1 -1
- package/dist/{page-revisions-content-CoVYI0hI.js → page-revisions-content-BvYTXKgT.js} +2 -2
- package/dist/{page-revisions-content-NE8Y5DrC.cjs → page-revisions-content-CwrPL9kp.cjs} +1 -1
- package/dist/pages.css +1 -1
- package/dist/{publish-pages-content-KgbEbRVV.js → publish-pages-content-9VBFj6LH.js} +2 -2
- package/dist/{publish-pages-content-CCUKnVTH.cjs → publish-pages-content-DTPjR33T.cjs} +1 -1
- package/dist/{save-to-lib-CQmcDI5w.js → save-to-lib-Bkou78G6.js} +1 -1
- package/dist/{save-to-lib-C06RQn4k.cjs → save-to-lib-ByoB0FW5.cjs} +1 -1
- package/dist/selected-block-display-Auur5nl7.cjs +16 -0
- package/dist/selected-block-display-D1L4e4Cb.js +355 -0
- package/dist/{seo-panel-C-dqg-1A.js → seo-panel-KjxjFcdp.js} +16 -16
- package/dist/{seo-panel-hwJUoGfJ.cjs → seo-panel-Mjkh_Urn.cjs} +1 -1
- package/dist/{shared-json-ld-BP2l89h2.cjs → shared-json-ld-DYD7q8ST.cjs} +1 -1
- package/dist/{shared-json-ld-BUPafGh_.js → shared-json-ld-S9OIaOTA.js} +1 -1
- package/dist/{slug-input-91_G-ww1.cjs → slug-input-C0BtQs2w.cjs} +1 -1
- package/dist/{slug-input-hcJHNszn.js → slug-input-CUTtvZQ9.js} +1 -1
- package/dist/{take-over-request-Dw2P9U_Q.js → take-over-request-CXED2804.js} +1 -1
- package/dist/{take-over-request-kRGwkXvv.cjs → take-over-request-Dh9HVZPO.cjs} +1 -1
- package/dist/{theme-panel-footer-2qsvp4AM.js → theme-panel-footer-CftO53LS.js} +1 -1
- package/dist/{theme-panel-footer-DmO4-lci.cjs → theme-panel-footer-tdNtbqZs.cjs} +1 -1
- package/dist/{unmark-as-template-DbXx3l6p.js → unmark-as-template-Dp6S9dY3.js} +1 -1
- package/dist/{unmark-as-template-BBzZqNJt.cjs → unmark-as-template-DyUqAa9Z.cjs} +1 -1
- package/dist/{unpublish-page-BKQqPk_e.js → unpublish-page-c382vh74.js} +1 -1
- package/dist/{unpublish-page-CHYNjTFU.cjs → unpublish-page-ch791au1.cjs} +1 -1
- package/dist/{web-preview-BKoPv6AO.js → web-preview-DiOChE4E.js} +1 -1
- package/dist/{web-preview-D4KdtUYp.cjs → web-preview-cls5-Dlv.cjs} +1 -1
- package/package.json +3 -3
- package/dist/ai-prompt-input-6LzuYu5L.cjs +0 -1
- package/dist/page-manager-new-BL5S9ccS.cjs +0 -1
- package/dist/page-manager-new-DGaBkeJp.js +0 -354
- package/dist/selected-block-display-7n8S3vf1.js +0 -394
- package/dist/selected-block-display-DDC1_UC8.cjs +0 -16
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as n, jsx as t, Fragment as _ } from "react/jsx-runtime";
|
|
2
|
-
import { LanguageSelector as $ } from "./page-manager-search-and-filter-
|
|
3
|
-
import { aq as K, ar as Q, A as L, aA as q, aB as J, k as V, m as W, ao as X, T as I, t as Y } from "./index-
|
|
2
|
+
import { LanguageSelector as $ } from "./page-manager-search-and-filter-DIz68YHL.js";
|
|
3
|
+
import { aq as K, ar as Q, A as L, aA as q, aB as J, k as V, m as W, ao as X, T as I, t as Y } from "./index-CtRx3Y3K.js";
|
|
4
4
|
import { useQuery as Z } from "@tanstack/react-query";
|
|
5
5
|
import { DialogContent as ee, DialogHeader as te, DialogTitle as se, DialogDescription as le, DialogFooter as ae, Button as U } from "@chaibuilder/sdk/ui";
|
|
6
6
|
import { find as F, filter as a, map as b, keys as ne, get as G, includes as C, orderBy as N, isEmpty as re, first as oe, uniq as B, concat as ce } from "lodash-es";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),L=require("./page-manager-search-and-filter-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),L=require("./page-manager-search-and-filter-BdfXZwwH.cjs"),r=require("./index-CJcS3b8n.cjs"),U=require("@tanstack/react-query"),h=require("@chaibuilder/sdk/ui"),t=require("lodash-es"),b=require("lucide-react"),i=require("react"),F=()=>{const l=r.useApiUrl(),d=r.useFetch();return U.useQuery({queryKey:[r.ACTIONS.GET_CHANGES],queryFn:async()=>d(l,{action:r.ACTIONS.GET_CHANGES})})},M=({page:l,selectedPages:d,handleCheckboxChange:N,getPageType:y,hasSlug:m,currentOwnerId:a})=>{const x=r.useUserId(),{data:u}=r.useChaiUserInfo(a),c=a===x?null:u==null?void 0:u.name;return e.jsxs("tr",{className:"group relative border-b last:border-b-0 hover:bg-gray-50",children:[e.jsxs("td",{scope:"row",className:`flex items-center gap-x-1 whitespace-nowrap px-6 py-2 text-gray-900 dark:text-white ${c?"opacity-50":""}`,children:[c?e.jsx(b.Lock,{className:"h-4 w-4 fill-red-200 text-red-500"}):e.jsx("input",{checked:t.includes(d,l==null?void 0:l.id),onClick:p=>{p.stopPropagation(),N(l==null?void 0:l.id)},type:"checkbox",className:"cursor-pointer rounded focus:outline-none focus:ring-0"})," ",m(l.pageType)?e.jsx(b.File,{className:"h-4 w-4"}):e.jsx(b.GlobeIcon,{className:"h-4 w-4"}),e.jsx(r.Tooltip,{content:l.name,side:"top",showTooltip:l.name.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-medium text-black",children:l.name})}),l.slug&&e.jsx(r.Tooltip,{content:l.slug,side:"top",showTooltip:l.slug.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-mono text-xs text-muted-foreground",children:l.slug})})]}),e.jsx("td",{className:"px-2",children:y(l==null?void 0:l.pageType)}),e.jsx("td",{className:"px-4 text-right",children:t.first(l.changes)||""}),e.jsx(e.Fragment,{children:c&&e.jsxs("button",{className:"absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100",children:[e.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",e.jsx("span",{className:"font-medium",children:c})," is editing this page"]})})]},l==null?void 0:l.id)},G=({onClose:l=()=>{},isPending:d,publishPage:N})=>{const y=r.useUserId(),{pageToUser:m}=r.usePageToUser(),[a,x]=i.useState([]),u=r.useFallbackLang(),[c,p]=i.useState(u),{data:k,isFetching:P}=F(),{data:g}=r.usePageTypes(),T=i.useCallback(s=>{var n;return(n=t.find(g,{key:s}))==null?void 0:n.hasSlug},[g]),j=i.useMemo(()=>t.filter(g,s=>!T(s.key)).map(s=>s.key),[T,g]),C=t.uniq(t.map(k,"lang")).filter(Boolean),o=i.useMemo(()=>t.filter(k,s=>s.pageType==="theme"?!1:c===u?s.lang===c||s.lang==="":s.lang===c),[k,c,u]),w=i.useMemo(()=>t.filter(o,s=>!j.includes(s.pageType)),[o,j]),S=i.useMemo(()=>t.filter(o,s=>j.includes(s.pageType)),[o,j]);i.useEffect(()=>{const s=t.map(t.filter(o,{online:!0}),"id");x(s)},[o]),i.useEffect(()=>{const s=t.filter(t.keys(m),n=>t.get(m,[n,"userId"])!==y);x(n=>t.filter(n,f=>!t.includes(s,f)))},[m,y]);const v=a.length===(o==null?void 0:o.length),E=s=>{x(n=>t.includes(n,s)?t.filter(n,f=>f!==s):t.concat(n,s))},q=()=>{x(v?[]:t.map(o,"id"))},I=()=>{N({ids:t.uniq(a)},{onSuccess:()=>{l(),r.throwConfetti("CENTER_CENTER"),p(u)}})},A=s=>{if(s==="theme")return"Theme";const n=t.find(g,{key:s});return n?n==null?void 0:n.name:s},B=i.useMemo(()=>{const s=[{label:"Updated",top:"pt-2"},...t.orderBy(t.filter(w,{online:!0}),"pageType"),...t.orderBy(t.filter(S,{online:!0}),"pageType")].filter(f=>f.pageType!=="theme"),n=[{label:"Offline",top:"pt-6"},...t.orderBy(t.filter(w,{online:!1}),"pageType"),...t.orderBy(t.filter(S,{online:!1}),"pageType")];return[...s,...n]},[w,S]);return e.jsxs(h.DialogContent,{className:"flex max-h-[80%] max-w-4xl flex-col",children:[e.jsxs(h.DialogHeader,{children:[e.jsx(h.DialogTitle,{children:"Publish changes"}),e.jsx(h.DialogDescription,{className:"text-xs",children:"Select the pages you want to publish. Click publish when you're done."})]}),C.length>0&&e.jsx("div",{className:"my-[2px] mt-0",children:e.jsx(L.LanguageSelector,{languages:[u,...C],selectedLanguage:c,setSelectedLanguage:p})}),e.jsx("div",{className:"no-scrollbar relative -mx-4 -mt-4 h-full max-h-full overflow-y-auto",children:P?e.jsxs("div",{className:"space-y-2 px-1",children:[e.jsx("div",{className:"mt-2 h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):e.jsxs("table",{className:"w-full text-left text-xs text-gray-500 dark:text-gray-400 rtl:text-right",children:[e.jsx("thead",{className:"sticky top-0 z-10 border-b bg-gray-50 text-gray-700 dark:bg-gray-700 dark:text-gray-400",children:e.jsxs("tr",{children:[e.jsxs("th",{scope:"col",className:"w-[1 50px] flex items-center gap-x-2 px-6 py-3",children:[e.jsx("input",{checked:v,onClick:s=>{s.stopPropagation(),q()},type:"checkbox",className:"mt-1 cursor-pointer rounded focus:outline-none focus:ring-0"}),"Name"]}),e.jsx("th",{scope:"col",className:"w-[150px] px-2 py-3",children:"Type"}),e.jsx("th",{scope:"col",className:"w-[150px] px-4 py-3 text-right",children:"Status"})]})}),e.jsx("tbody",{children:t.map(B,s=>s.label?e.jsx("tr",{children:e.jsxs("td",{colSpan:3,className:`relative px-6 py-2 text-xs font-medium text-gray-800 ${s.top}`,children:[e.jsx("div",{className:"absolute inset-0 left-6 flex items-center",children:e.jsx("div",{className:"order-gray-300 w-full"})}),e.jsx("div",{className:"relative flex justify-start",children:e.jsx("span",{className:"bg-gray-50 pr-2",children:s.label})})]})},"separator"):e.jsx(M,{page:s,selectedPages:a,handleCheckboxChange:E,getPageType:A,hasSlug:T,currentOwnerId:t.get(m,[(s==null?void 0:s.primaryPage)||(s==null?void 0:s.id),"userId"])}))})]})}),e.jsxs(h.DialogFooter,{className:"mt-10 flex items-center justify-center",children:[a.length>0&&e.jsxs("span",{className:"text-center text-sm text-muted-foreground",children:[a.length," Page",a.length!==1?"s":""," Selected"]}),e.jsx(h.Button,{disabled:d,variant:"outline",onClick:l,children:"Cancel"}),e.jsx(h.Button,{disabled:d||P||t.isEmpty(a),onClick:I,children:d?"Publishing...":"Publish Selected"})]})]})};exports.default=G;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as i } from "react/jsx-runtime";
|
|
2
2
|
import { useMutation as U, useQuery as z, useQueryClient as se } from "@tanstack/react-query";
|
|
3
3
|
import { toast as B } from "sonner";
|
|
4
|
-
import { aq as L, ar as G, A as _, ay as ie } from "./index-
|
|
4
|
+
import { aq as L, ar as G, A as _, ay as ie } from "./index-CtRx3Y3K.js";
|
|
5
5
|
import { useUpdateBlocksPropsRealtime as K, usePartailBlocksStore as oe, usePermissions as le, useLibraryBlocks as ce } from "@chaibuilder/sdk";
|
|
6
6
|
import { Button as b, Popover as de, PopoverTrigger as ue, PopoverContent as me, Input as D, Label as P } from "@chaibuilder/sdk/ui";
|
|
7
7
|
import { Trash2 as Y, Plus as pe, ImageIcon as he, X as fe, AlertCircle as ge } from "lucide-react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),I=require("@tanstack/react-query"),k=require("sonner"),x=require("./index-Bre43r-W.cjs"),E=require("@chaibuilder/sdk"),c=require("@chaibuilder/sdk/ui"),C=require("lucide-react"),i=require("react"),X=require("./image-compression-DZ9WMmyn.cjs"),R=require("lodash-es"),J=n=>{const s=x.useApiUrl(),l=x.useFetch();return I.useMutation({mutationFn:async t=>l(s,{action:x.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{n(t)},onError:t=>{console.error("Error saving block:",t),k.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},Z=n=>{const s=x.useApiUrl(),l=x.useFetch();return I.useQuery({staleTime:"static",queryKey:[x.ACTIONS.GET_LIBRARY_ITEM,n],enabled:!!n,queryFn:async()=>{if(!n)return null;try{return await l(s,{action:x.ACTIONS.GET_LIBRARY_ITEM,data:{id:n}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},ee=n=>{const s=x.useApiUrl(),l=x.useFetch();return I.useMutation({mutationFn:async t=>l(s,{action:x.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:t}}),onSuccess:()=>{n()},onError:t=>{console.error("Error deleting block:",t),k.toast.error("Failed to delete block",{description:t instanceof Error?t.message:"Unknown error"})}})},te=({blockId:n,libBlockId:s,isOpen:l,onClose:t,blockName:m,trigger:f})=>{const[u,o]=i.useState(!1),d=E.useUpdateBlocksPropsRealtime(),b=ee(()=>{d([n],{_libBlockId:void 0}),k.toast.success("Block deleted successfully"),o(!1),t()}),p=()=>{o(!0),b.mutate(s)},g=e.jsxs(c.Button,{type:"button",variant:"destructive",size:"sm",onClick:h=>h.preventDefault(),disabled:u,children:[e.jsx(C.Trash2,{className:"h-4 w-4 mr-2"}),"Delete"]});return e.jsxs(c.Popover,{open:l,onOpenChange:h=>!h&&t(),children:[e.jsx(c.PopoverTrigger,{asChild:!0,children:f||g}),e.jsx(c.PopoverContent,{className:"w-72 p-4 z-[9999]",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',m,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(c.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(c.Button,{type:"button",variant:"destructive",size:"sm",onClick:p,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},se=({blockId:n,libBlockId:s,blockName:l,size:t="sm",className:m="",close:f})=>{const[u,o]=i.useState(!1);return e.jsx(te,{blockId:n,libBlockId:s,isOpen:u,onClose:()=>{o(!1),f()},blockName:l,trigger:e.jsxs(c.Button,{type:"button",variant:"destructive",size:t,className:m,onClick:()=>o(!0),children:[e.jsx(C.Trash2,{className:"h-4 w-4 mr-2"}),"Delete"]})})},re=()=>{const n=x.useApiUrl(),s=x.useFetch(),l=I.useQueryClient(),{data:t=[],isLoading:m,error:f}=I.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await s(n,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=I.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return s(n,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),k.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),k.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:m,error:f,createGroup:u,isCreating:o}},ne=({value:n,onChange:s})=>{const[l,t]=i.useState(!1),[m,f]=i.useState(""),u=i.useRef(null),{groups:o}=re(),[d,b]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),p=i.useMemo(()=>[...o,...d.filter(r=>!o.some(j=>j.id===r.id))],[o,d]),g=()=>{const r=m.trim();if(!r)return;const j={id:r,name:r};b(w=>[...w,j]),s(j.id),f(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const h=r=>{r.key==="Enter"&&(r.preventDefault(),g())};return i.useEffect(()=>{n&&!p.some(r=>r.id===n)&&s("")},[n,p,s]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Input,{ref:u,placeholder:"Enter new group name",value:m,onChange:r=>f(r.target.value),onKeyDown:h}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(c.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(c.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:n,onChange:r=>s(r.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(r=>e.jsx("option",{value:r.id,children:r.name},`lib-${r.id}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.filter(r=>!o.some(j=>j.id===r.id)).map(r=>e.jsx("option",{value:r.id,children:r.name},`local-${r.id}`))})]}),e.jsx(c.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(C.Plus,{className:"h-4 w-4"})})]})},ae=({value:n,onChange:s})=>{const[l,t]=i.useState(!1),m=i.useRef(null),f=i.useCallback(async d=>{var p;const b=(p=d.target.files)==null?void 0:p[0];if(b)try{t(!0);let g=b;b.type.startsWith("image/")&&(g=await X.compressImageIfNeeded(b));const h=new FileReader;h.onloadend=()=>{s(h.result),t(!1)},h.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),k.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[s]),u=()=>{s(""),m.current&&(m.current.value="")},o=()=>{var d;(d=m.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c.Input,{type:"file",ref:m,onChange:f,accept:"image/*",className:"hidden"}),e.jsx(c.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(C.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),n&&e.jsx(c.Button,{type:"button",variant:"outline",size:"icon",onClick:u,children:e.jsx(C.X,{className:"h-4 w-4"})})]}),n&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:n,alt:"Preview",className:"h-full w-full object-contain"})})]})},oe=n=>{const{blocks:s,close:l,blockId:t}=n,{getPartailBlocks:m}=E.usePartailBlocksStore(),f=s.find(a=>a._id===t),u=f==null?void 0:f._libBlockId,o=!!u,d=i.useMemo(()=>s.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[s]),b=i.useMemo(()=>{let a=[];for(const y of s)if(y._type==="PartialBlock"||y._type==="GlobalBlock"){let v=m(y.partialBlockId);y._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",y._parent),T))),a=[...a,...v]}else a.push(y);return a},[s,m]),[p,g]=i.useState(""),[h,r]=i.useState(""),[j,w]=i.useState(""),[S,_]=i.useState(""),[N,A]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=E.usePermissions(),Q=Y(x.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=E.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),k.toast.success("Block delinked from library"),l()},{data:B,isLoading:P,isError:G}=Z(u);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{B&&!P&&(g(B.name||""),r(B.group||""),w(B.description||""),_(B.preview||""),F(!1))},[B,P]),i.useEffect(()=>{const a=p.trim().length>=2,y=h.trim()!=="";M(a&&y)},[p,h]);const W=()=>{const a={};return p.trim()?p.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",h||(a.group="Group is required"),A(a),Object.keys(a).length===0},{resetLibrary:$}=E.useLibraryBlocks({id:""}),U=J(a=>{o||D([t],{_libBlockId:a.id}),k.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const y=b.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));U.mutate({name:p.trim(),group:h,blocks:y,description:j.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=U.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(c.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(c.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(C.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(c.Input,{id:"name",placeholder:"Enter block name",value:p,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ne,{value:h,onChange:r}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(c.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:j,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(ae,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(se,{blockId:t,libBlockId:u,blockName:p,className:"mr-auto",close:l}),e.jsx(c.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(c.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=oe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),I=require("@tanstack/react-query"),k=require("sonner"),x=require("./index-CJcS3b8n.cjs"),E=require("@chaibuilder/sdk"),c=require("@chaibuilder/sdk/ui"),C=require("lucide-react"),i=require("react"),X=require("./image-compression-DZ9WMmyn.cjs"),R=require("lodash-es"),J=n=>{const s=x.useApiUrl(),l=x.useFetch();return I.useMutation({mutationFn:async t=>l(s,{action:x.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{n(t)},onError:t=>{console.error("Error saving block:",t),k.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},Z=n=>{const s=x.useApiUrl(),l=x.useFetch();return I.useQuery({staleTime:"static",queryKey:[x.ACTIONS.GET_LIBRARY_ITEM,n],enabled:!!n,queryFn:async()=>{if(!n)return null;try{return await l(s,{action:x.ACTIONS.GET_LIBRARY_ITEM,data:{id:n}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},ee=n=>{const s=x.useApiUrl(),l=x.useFetch();return I.useMutation({mutationFn:async t=>l(s,{action:x.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:t}}),onSuccess:()=>{n()},onError:t=>{console.error("Error deleting block:",t),k.toast.error("Failed to delete block",{description:t instanceof Error?t.message:"Unknown error"})}})},te=({blockId:n,libBlockId:s,isOpen:l,onClose:t,blockName:m,trigger:f})=>{const[u,o]=i.useState(!1),d=E.useUpdateBlocksPropsRealtime(),b=ee(()=>{d([n],{_libBlockId:void 0}),k.toast.success("Block deleted successfully"),o(!1),t()}),p=()=>{o(!0),b.mutate(s)},g=e.jsxs(c.Button,{type:"button",variant:"destructive",size:"sm",onClick:h=>h.preventDefault(),disabled:u,children:[e.jsx(C.Trash2,{className:"h-4 w-4 mr-2"}),"Delete"]});return e.jsxs(c.Popover,{open:l,onOpenChange:h=>!h&&t(),children:[e.jsx(c.PopoverTrigger,{asChild:!0,children:f||g}),e.jsx(c.PopoverContent,{className:"w-72 p-4 z-[9999]",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',m,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(c.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(c.Button,{type:"button",variant:"destructive",size:"sm",onClick:p,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},se=({blockId:n,libBlockId:s,blockName:l,size:t="sm",className:m="",close:f})=>{const[u,o]=i.useState(!1);return e.jsx(te,{blockId:n,libBlockId:s,isOpen:u,onClose:()=>{o(!1),f()},blockName:l,trigger:e.jsxs(c.Button,{type:"button",variant:"destructive",size:t,className:m,onClick:()=>o(!0),children:[e.jsx(C.Trash2,{className:"h-4 w-4 mr-2"}),"Delete"]})})},re=()=>{const n=x.useApiUrl(),s=x.useFetch(),l=I.useQueryClient(),{data:t=[],isLoading:m,error:f}=I.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await s(n,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=I.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return s(n,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),k.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),k.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:m,error:f,createGroup:u,isCreating:o}},ne=({value:n,onChange:s})=>{const[l,t]=i.useState(!1),[m,f]=i.useState(""),u=i.useRef(null),{groups:o}=re(),[d,b]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),p=i.useMemo(()=>[...o,...d.filter(r=>!o.some(j=>j.id===r.id))],[o,d]),g=()=>{const r=m.trim();if(!r)return;const j={id:r,name:r};b(w=>[...w,j]),s(j.id),f(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const h=r=>{r.key==="Enter"&&(r.preventDefault(),g())};return i.useEffect(()=>{n&&!p.some(r=>r.id===n)&&s("")},[n,p,s]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Input,{ref:u,placeholder:"Enter new group name",value:m,onChange:r=>f(r.target.value),onKeyDown:h}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(c.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(c.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:n,onChange:r=>s(r.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(r=>e.jsx("option",{value:r.id,children:r.name},`lib-${r.id}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.filter(r=>!o.some(j=>j.id===r.id)).map(r=>e.jsx("option",{value:r.id,children:r.name},`local-${r.id}`))})]}),e.jsx(c.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(C.Plus,{className:"h-4 w-4"})})]})},ae=({value:n,onChange:s})=>{const[l,t]=i.useState(!1),m=i.useRef(null),f=i.useCallback(async d=>{var p;const b=(p=d.target.files)==null?void 0:p[0];if(b)try{t(!0);let g=b;b.type.startsWith("image/")&&(g=await X.compressImageIfNeeded(b));const h=new FileReader;h.onloadend=()=>{s(h.result),t(!1)},h.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),k.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[s]),u=()=>{s(""),m.current&&(m.current.value="")},o=()=>{var d;(d=m.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c.Input,{type:"file",ref:m,onChange:f,accept:"image/*",className:"hidden"}),e.jsx(c.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(C.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),n&&e.jsx(c.Button,{type:"button",variant:"outline",size:"icon",onClick:u,children:e.jsx(C.X,{className:"h-4 w-4"})})]}),n&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:n,alt:"Preview",className:"h-full w-full object-contain"})})]})},oe=n=>{const{blocks:s,close:l,blockId:t}=n,{getPartailBlocks:m}=E.usePartailBlocksStore(),f=s.find(a=>a._id===t),u=f==null?void 0:f._libBlockId,o=!!u,d=i.useMemo(()=>s.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[s]),b=i.useMemo(()=>{let a=[];for(const y of s)if(y._type==="PartialBlock"||y._type==="GlobalBlock"){let v=m(y.partialBlockId);y._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",y._parent),T))),a=[...a,...v]}else a.push(y);return a},[s,m]),[p,g]=i.useState(""),[h,r]=i.useState(""),[j,w]=i.useState(""),[S,_]=i.useState(""),[N,A]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=E.usePermissions(),Q=Y(x.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=E.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),k.toast.success("Block delinked from library"),l()},{data:B,isLoading:P,isError:G}=Z(u);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{B&&!P&&(g(B.name||""),r(B.group||""),w(B.description||""),_(B.preview||""),F(!1))},[B,P]),i.useEffect(()=>{const a=p.trim().length>=2,y=h.trim()!=="";M(a&&y)},[p,h]);const W=()=>{const a={};return p.trim()?p.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",h||(a.group="Group is required"),A(a),Object.keys(a).length===0},{resetLibrary:$}=E.useLibraryBlocks({id:""}),U=J(a=>{o||D([t],{_libBlockId:a.id}),k.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const y=b.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));U.mutate({name:p.trim(),group:h,blocks:y,description:j.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=U.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(c.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(c.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(C.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(c.Input,{id:"name",placeholder:"Enter block name",value:p,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ne,{value:h,onChange:r}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(c.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:j,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(ae,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(se,{blockId:t,libBlockId:u,blockName:p,className:"mr-auto",close:l}),e.jsx(c.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(c.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=oe;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";const o=require("react/jsx-runtime"),a=require("./button-CMMN5Cp4.cjs"),m=require("lucide-react"),i=require("react"),h=require("use-stick-to-bottom");require("@radix-ui/react-slot");const B=require("class-variance-authority");require("clsx");require("tailwind-merge");const D=require("@radix-ui/react-separator"),L=require("@radix-ui/react-tooltip"),S=require("streamdown"),G=require("@radix-ui/react-collapsible"),j=require("@radix-ui/react-use-controllable-state"),I=require("motion/react"),p=require("./index-CJcS3b8n.cjs"),T=require("@chaibuilder/sdk"),$=require("@chaibuilder/sdk/ui");function g(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const w=g(i),R=g(D),E=g(L),b=g(G),F=({className:e,...t})=>o.jsx(h.StickToBottom,{className:a.cn("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),Q=({className:e,...t})=>o.jsx(h.StickToBottom.Content,{className:a.cn("flex flex-col gap-8 p-4",e),...t}),V=({className:e,title:t="No messages yet",description:s="Start a conversation to see messages here",icon:n,children:r,...l})=>o.jsx("div",{className:a.cn("flex size-full flex-col items-center justify-center gap-3 p-8 text-center",e),...l,children:r??o.jsxs(o.Fragment,{children:[n&&o.jsx("div",{className:"text-muted-foreground",children:n}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h3",{className:"font-medium text-sm",children:t}),s&&o.jsx("p",{className:"text-muted-foreground text-sm",children:s})]})]})}),K=({className:e,...t})=>{const{isAtBottom:s,scrollToBottom:n}=h.useStickToBottomContext(),r=i.useCallback(()=>{n()},[n]);return!s&&o.jsx(a.Button,{className:a.cn("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:r,size:"icon",type:"button",variant:"outline",...t,children:o.jsx(m.ArrowDownIcon,{className:"size-4"})})},Y=w.forwardRef(({className:e,orientation:t="horizontal",decorative:s=!0,...n},r)=>o.jsx(R.Root,{ref:r,decorative:s,orientation:t,className:a.cn("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));Y.displayName=R.Root.displayName;B.cva("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});const J=w.forwardRef(({className:e,sideOffset:t=4,...s},n)=>o.jsx(E.Content,{ref:n,sideOffset:t,className:a.cn("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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-tooltip-content-transform-origin]",e),...s}));J.displayName=E.Content.displayName;const X=({className:e,from:t,...s})=>o.jsx("div",{className:a.cn("group flex w-full max-w-[80%] flex-col gap-2",t==="user"?"is-user ml-auto justify-end":"is-assistant",e),...s}),H=({children:e,className:t,...s})=>o.jsx("div",{className:a.cn("is-user:dark flex w-fit flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",t),...s,children:e});i.createContext(null);const y=i.memo(({className:e,...t})=>o.jsx(S.Streamdown,{className:a.cn("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);y.displayName="MessageResponse";const W=b.Root,Z=b.CollapsibleTrigger,ee=b.CollapsibleContent,te=({children:e,as:t="p",className:s,duration:n=2,spread:r=2})=>{const l=I.motion.create(t),x=i.useMemo(()=>((e==null?void 0:e.length)??0)*r,[e,r]);return o.jsx(l,{animate:{backgroundPosition:"0% center"},className:a.cn("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",s),initial:{backgroundPosition:"100% center"},style:{"--spread":`${x}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:n,ease:"linear"},children:e})},k=i.memo(te),A=i.createContext(null),oe=()=>{const e=i.useContext(A);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},se=1e3,ne=1e3,U=i.memo(({className:e,isStreaming:t=!1,open:s,defaultOpen:n=!0,onOpenChange:r,duration:l,children:x,..._})=>{const[c,d]=j.useControllableState({prop:s,defaultProp:n,onChange:r}),[q,v]=j.useControllableState({prop:l,defaultProp:void 0}),[N,z]=i.useState(!1),[u,C]=i.useState(null);i.useEffect(()=>{t?u===null&&C(Date.now()):u!==null&&(v(Math.ceil((Date.now()-u)/ne)),C(null))},[t,u,v]),i.useEffect(()=>{if(n&&!t&&c&&!N){const f=setTimeout(()=>{d(!1),z(!0)},se);return()=>clearTimeout(f)}},[t,c,n,d,N]);const O=f=>{d(f)};return o.jsx(A.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:d,duration:q},children:o.jsx(W,{className:a.cn("not-prose mb-4",e),onOpenChange:O,open:c,..._,children:x})})}),re=(e,t)=>e||t===0?o.jsx(k,{duration:1,children:"Thinking..."}):t===void 0?o.jsx("p",{children:"Thought for a few seconds"}):o.jsxs("p",{children:["Thought for ",t," seconds"]}),M=i.memo(({className:e,children:t,...s})=>{const{isStreaming:n,isOpen:r,duration:l}=oe();return o.jsx(Z,{className:a.cn("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...s,children:t??o.jsxs(o.Fragment,{children:[o.jsx(m.BrainIcon,{className:"size-4"}),re(n,l),o.jsx(m.ChevronDownIcon,{className:a.cn("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),P=i.memo(({className:e,children:t,...s})=>o.jsx(ee,{className:a.cn("mt-4 text-sm","text-muted-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2",e),...s,children:o.jsx(S.Streamdown,{...s,children:t})}));U.displayName="Reasoning";M.displayName="ReasoningTrigger";P.displayName="ReasoningContent";const ae=({className:e,content:t,isLoading:s=!1,...n})=>o.jsx("div",{className:a.cn("is-assistant flex w-full max-w-[80%] flex-col gap-2",e),...n,children:o.jsx("div",{className:"flex w-fit flex-col gap-2 overflow-hidden text-sm",children:o.jsx("div",{className:"flex items-center gap-2 rounded-lg border border-muted-foreground/20 bg-muted/50 p-3",children:o.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[s&&o.jsx(k,{duration:1.5,children:t}),!s&&o.jsx("div",{className:"text-xs text-muted-foreground",children:t})]})})})});function ie({userInput:e,language:t="en",currentHtml:s}){const n=p.LANGUAGES[t]||"English";return s&&s.trim().length>0?`
|
|
2
|
+
MODE: EDIT
|
|
3
|
+
CURRENT HTML:
|
|
4
|
+
${s}
|
|
5
|
+
|
|
6
|
+
USER REQUEST: ${e}
|
|
7
|
+
Use ${n} language.
|
|
8
|
+
`.trim():`
|
|
9
|
+
USER REQUEST: ${e}
|
|
10
|
+
Use ${n} language.
|
|
11
|
+
`.trim()}function le({fallbackLang:e,language:t,blocks:s=[],userInput:n}){const r=p.LANGUAGES[t]||"English";return`
|
|
12
|
+
USER REQUEST: ${n||"Translate the content"}
|
|
13
|
+
LANGUAGE TO TRANSLATE: ${r}
|
|
14
|
+
REQUESTED TRANSLATION LANGUAGE CODE: ${t}
|
|
15
|
+
FALLBACK LANGUAGE: ${p.LANGUAGES[e]}
|
|
16
|
+
BLOCKS: ${JSON.stringify(s)}`.trim()}const ce=({onRemove:e,isLoading:t=!1})=>{const{t:s}=T.useTranslation(),n=T.useSelectedBlock(),r=(n==null?void 0:n._type)||"Unknown",l=(n==null?void 0:n._name)||r;return o.jsx(o.Fragment,{children:o.jsxs("div",{className:"mx-auto flex w-[95%] items-center justify-between rounded-t-md border border-b-0 border-blue-200 bg-blue-50",children:[o.jsxs("div",{className:"flex items-center",children:[o.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-l rounded-bl-none bg-blue-500 text-xs font-semibold text-white",children:"@"}),o.jsx("div",{className:"flex w-[95%] flex-col",children:n?o.jsx(o.Fragment,{children:o.jsxs("span",{className:"truncate text-xs font-medium text-blue-900",children:[" ",s("Context: ")," ",l]})}):o.jsxs("span",{className:"text-xs font-medium text-blue-900",children:[" ",s("Context: Entire Page")]})})]}),n&&o.jsx($.Button,{variant:"ghost",size:"icon",onClick:e,disabled:t,className:"h-6 w-6 text-blue-600 hover:bg-blue-100 hover:text-blue-800",title:"Remove block from context",children:o.jsx(m.X,{size:14})})]})})};exports.Conversation=F;exports.ConversationContent=Q;exports.ConversationEmptyState=V;exports.ConversationScrollButton=K;exports.Message=X;exports.MessageContent=H;exports.MessageResponse=y;exports.Reasoning=U;exports.ReasoningContent=P;exports.ReasoningTrigger=M;exports.SelectedBlockDisplay=ce;exports.TaskMessage=ae;exports.getTranslationUserPrompt=le;exports.getUserPrompt=ie;
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { jsx as o, jsxs as l, Fragment as f } from "react/jsx-runtime";
|
|
2
|
+
import { c as r, B as O } from "./button-CggatMM3.js";
|
|
3
|
+
import { ArrowDownIcon as P, BrainIcon as $, ChevronDownIcon as D, X as _ } from "lucide-react";
|
|
4
|
+
import * as E from "react";
|
|
5
|
+
import { useCallback as G, createContext as R, memo as d, useMemo as j, useState as C, useEffect as T, useContext as Q } from "react";
|
|
6
|
+
import { StickToBottom as S, useStickToBottomContext as F } from "use-stick-to-bottom";
|
|
7
|
+
import "@radix-ui/react-slot";
|
|
8
|
+
import { cva as K } from "class-variance-authority";
|
|
9
|
+
import "clsx";
|
|
10
|
+
import "tailwind-merge";
|
|
11
|
+
import * as y from "@radix-ui/react-separator";
|
|
12
|
+
import * as A from "@radix-ui/react-tooltip";
|
|
13
|
+
import { Streamdown as k } from "streamdown";
|
|
14
|
+
import * as x from "@radix-ui/react-collapsible";
|
|
15
|
+
import { useControllableState as w } from "@radix-ui/react-use-controllable-state";
|
|
16
|
+
import { motion as V } from "motion/react";
|
|
17
|
+
import { L as h } from "./index-CtRx3Y3K.js";
|
|
18
|
+
import { useTranslation as Y, useSelectedBlock as J } from "@chaibuilder/sdk";
|
|
19
|
+
import { Button as X } from "@chaibuilder/sdk/ui";
|
|
20
|
+
const Re = ({ className: t, ...e }) => /* @__PURE__ */ o(
|
|
21
|
+
S,
|
|
22
|
+
{
|
|
23
|
+
className: r("relative flex-1 overflow-y-hidden", t),
|
|
24
|
+
initial: "smooth",
|
|
25
|
+
resize: "smooth",
|
|
26
|
+
role: "log",
|
|
27
|
+
...e
|
|
28
|
+
}
|
|
29
|
+
), Se = ({
|
|
30
|
+
className: t,
|
|
31
|
+
...e
|
|
32
|
+
}) => /* @__PURE__ */ o(
|
|
33
|
+
S.Content,
|
|
34
|
+
{
|
|
35
|
+
className: r("flex flex-col gap-8 p-4", t),
|
|
36
|
+
...e
|
|
37
|
+
}
|
|
38
|
+
), ye = ({
|
|
39
|
+
className: t,
|
|
40
|
+
title: e = "No messages yet",
|
|
41
|
+
description: s = "Start a conversation to see messages here",
|
|
42
|
+
icon: n,
|
|
43
|
+
children: a,
|
|
44
|
+
...i
|
|
45
|
+
}) => /* @__PURE__ */ o(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
className: r(
|
|
49
|
+
"flex size-full flex-col items-center justify-center gap-3 p-8 text-center",
|
|
50
|
+
t
|
|
51
|
+
),
|
|
52
|
+
...i,
|
|
53
|
+
children: a ?? /* @__PURE__ */ l(f, { children: [
|
|
54
|
+
n && /* @__PURE__ */ o("div", { className: "text-muted-foreground", children: n }),
|
|
55
|
+
/* @__PURE__ */ l("div", { className: "space-y-1", children: [
|
|
56
|
+
/* @__PURE__ */ o("h3", { className: "font-medium text-sm", children: e }),
|
|
57
|
+
s && /* @__PURE__ */ o("p", { className: "text-muted-foreground text-sm", children: s })
|
|
58
|
+
] })
|
|
59
|
+
] })
|
|
60
|
+
}
|
|
61
|
+
), Ae = ({
|
|
62
|
+
className: t,
|
|
63
|
+
...e
|
|
64
|
+
}) => {
|
|
65
|
+
const { isAtBottom: s, scrollToBottom: n } = F(), a = G(() => {
|
|
66
|
+
n();
|
|
67
|
+
}, [n]);
|
|
68
|
+
return !s && /* @__PURE__ */ o(
|
|
69
|
+
O,
|
|
70
|
+
{
|
|
71
|
+
className: r(
|
|
72
|
+
"absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",
|
|
73
|
+
t
|
|
74
|
+
),
|
|
75
|
+
onClick: a,
|
|
76
|
+
size: "icon",
|
|
77
|
+
type: "button",
|
|
78
|
+
variant: "outline",
|
|
79
|
+
...e,
|
|
80
|
+
children: /* @__PURE__ */ o(P, { className: "size-4" })
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}, q = E.forwardRef(
|
|
84
|
+
({ className: t, orientation: e = "horizontal", decorative: s = !0, ...n }, a) => /* @__PURE__ */ o(
|
|
85
|
+
y.Root,
|
|
86
|
+
{
|
|
87
|
+
ref: a,
|
|
88
|
+
decorative: s,
|
|
89
|
+
orientation: e,
|
|
90
|
+
className: r(
|
|
91
|
+
"shrink-0 bg-border",
|
|
92
|
+
e === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
|
|
93
|
+
t
|
|
94
|
+
),
|
|
95
|
+
...n
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
q.displayName = y.Root.displayName;
|
|
100
|
+
K(
|
|
101
|
+
"flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
|
|
102
|
+
{
|
|
103
|
+
variants: {
|
|
104
|
+
orientation: {
|
|
105
|
+
horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
|
|
106
|
+
vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
defaultVariants: {
|
|
110
|
+
orientation: "horizontal"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
const H = E.forwardRef(({ className: t, sideOffset: e = 4, ...s }, n) => /* @__PURE__ */ o(
|
|
115
|
+
A.Content,
|
|
116
|
+
{
|
|
117
|
+
ref: n,
|
|
118
|
+
sideOffset: e,
|
|
119
|
+
className: r(
|
|
120
|
+
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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-tooltip-content-transform-origin]",
|
|
121
|
+
t
|
|
122
|
+
),
|
|
123
|
+
...s
|
|
124
|
+
}
|
|
125
|
+
));
|
|
126
|
+
H.displayName = A.Content.displayName;
|
|
127
|
+
const ke = ({ className: t, from: e, ...s }) => /* @__PURE__ */ o(
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
className: r(
|
|
131
|
+
"group flex w-full max-w-[80%] flex-col gap-2",
|
|
132
|
+
e === "user" ? "is-user ml-auto justify-end" : "is-assistant",
|
|
133
|
+
t
|
|
134
|
+
),
|
|
135
|
+
...s
|
|
136
|
+
}
|
|
137
|
+
), Ue = ({ children: t, className: e, ...s }) => /* @__PURE__ */ o(
|
|
138
|
+
"div",
|
|
139
|
+
{
|
|
140
|
+
className: r(
|
|
141
|
+
"is-user:dark flex w-fit flex-col gap-2 overflow-hidden text-sm",
|
|
142
|
+
"group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground",
|
|
143
|
+
"group-[.is-assistant]:text-foreground",
|
|
144
|
+
e
|
|
145
|
+
),
|
|
146
|
+
...s,
|
|
147
|
+
children: t
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
R(null);
|
|
151
|
+
const W = d(
|
|
152
|
+
({ className: t, ...e }) => /* @__PURE__ */ o(k, { className: r("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", t), ...e }),
|
|
153
|
+
(t, e) => t.children === e.children
|
|
154
|
+
);
|
|
155
|
+
W.displayName = "MessageResponse";
|
|
156
|
+
const Z = x.Root, ee = x.CollapsibleTrigger, te = x.CollapsibleContent, oe = ({
|
|
157
|
+
children: t,
|
|
158
|
+
as: e = "p",
|
|
159
|
+
className: s,
|
|
160
|
+
duration: n = 2,
|
|
161
|
+
spread: a = 2
|
|
162
|
+
}) => {
|
|
163
|
+
const i = V.create(
|
|
164
|
+
e
|
|
165
|
+
), p = j(
|
|
166
|
+
() => ((t == null ? void 0 : t.length) ?? 0) * a,
|
|
167
|
+
[t, a]
|
|
168
|
+
);
|
|
169
|
+
return /* @__PURE__ */ o(
|
|
170
|
+
i,
|
|
171
|
+
{
|
|
172
|
+
animate: { backgroundPosition: "0% center" },
|
|
173
|
+
className: r(
|
|
174
|
+
"relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent",
|
|
175
|
+
"[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",
|
|
176
|
+
s
|
|
177
|
+
),
|
|
178
|
+
initial: { backgroundPosition: "100% center" },
|
|
179
|
+
style: {
|
|
180
|
+
"--spread": `${p}px`,
|
|
181
|
+
backgroundImage: "var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"
|
|
182
|
+
},
|
|
183
|
+
transition: {
|
|
184
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
185
|
+
duration: n,
|
|
186
|
+
ease: "linear"
|
|
187
|
+
},
|
|
188
|
+
children: t
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
}, U = d(oe), z = R(null), se = () => {
|
|
192
|
+
const t = Q(z);
|
|
193
|
+
if (!t)
|
|
194
|
+
throw new Error("Reasoning components must be used within Reasoning");
|
|
195
|
+
return t;
|
|
196
|
+
}, ne = 1e3, ae = 1e3, re = d(
|
|
197
|
+
({
|
|
198
|
+
className: t,
|
|
199
|
+
isStreaming: e = !1,
|
|
200
|
+
open: s,
|
|
201
|
+
defaultOpen: n = !0,
|
|
202
|
+
onOpenChange: a,
|
|
203
|
+
duration: i,
|
|
204
|
+
children: p,
|
|
205
|
+
...M
|
|
206
|
+
}) => {
|
|
207
|
+
const [c, m] = w({
|
|
208
|
+
prop: s,
|
|
209
|
+
defaultProp: n,
|
|
210
|
+
onChange: a
|
|
211
|
+
}), [B, b] = w({
|
|
212
|
+
prop: i,
|
|
213
|
+
defaultProp: void 0
|
|
214
|
+
}), [N, I] = C(!1), [u, v] = C(null);
|
|
215
|
+
T(() => {
|
|
216
|
+
e ? u === null && v(Date.now()) : u !== null && (b(Math.ceil((Date.now() - u) / ae)), v(null));
|
|
217
|
+
}, [e, u, b]), T(() => {
|
|
218
|
+
if (n && !e && c && !N) {
|
|
219
|
+
const g = setTimeout(() => {
|
|
220
|
+
m(!1), I(!0);
|
|
221
|
+
}, ne);
|
|
222
|
+
return () => clearTimeout(g);
|
|
223
|
+
}
|
|
224
|
+
}, [e, c, n, m, N]);
|
|
225
|
+
const L = (g) => {
|
|
226
|
+
m(g);
|
|
227
|
+
};
|
|
228
|
+
return /* @__PURE__ */ o(z.Provider, { value: { isStreaming: e, isOpen: c, setIsOpen: m, duration: B }, children: /* @__PURE__ */ o(
|
|
229
|
+
Z,
|
|
230
|
+
{
|
|
231
|
+
className: r("not-prose mb-4", t),
|
|
232
|
+
onOpenChange: L,
|
|
233
|
+
open: c,
|
|
234
|
+
...M,
|
|
235
|
+
children: p
|
|
236
|
+
}
|
|
237
|
+
) });
|
|
238
|
+
}
|
|
239
|
+
), ie = (t, e) => t || e === 0 ? /* @__PURE__ */ o(U, { duration: 1, children: "Thinking..." }) : e === void 0 ? /* @__PURE__ */ o("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ l("p", { children: [
|
|
240
|
+
"Thought for ",
|
|
241
|
+
e,
|
|
242
|
+
" seconds"
|
|
243
|
+
] }), le = d(({ className: t, children: e, ...s }) => {
|
|
244
|
+
const { isStreaming: n, isOpen: a, duration: i } = se();
|
|
245
|
+
return /* @__PURE__ */ o(
|
|
246
|
+
ee,
|
|
247
|
+
{
|
|
248
|
+
className: r(
|
|
249
|
+
"flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",
|
|
250
|
+
t
|
|
251
|
+
),
|
|
252
|
+
...s,
|
|
253
|
+
children: e ?? /* @__PURE__ */ l(f, { children: [
|
|
254
|
+
/* @__PURE__ */ o($, { className: "size-4" }),
|
|
255
|
+
ie(n, i),
|
|
256
|
+
/* @__PURE__ */ o(D, { className: r("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
|
|
257
|
+
] })
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
}), de = d(({ className: t, children: e, ...s }) => /* @__PURE__ */ o(
|
|
261
|
+
te,
|
|
262
|
+
{
|
|
263
|
+
className: r(
|
|
264
|
+
"mt-4 text-sm",
|
|
265
|
+
"text-muted-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2",
|
|
266
|
+
t
|
|
267
|
+
),
|
|
268
|
+
...s,
|
|
269
|
+
children: /* @__PURE__ */ o(k, { ...s, children: e })
|
|
270
|
+
}
|
|
271
|
+
));
|
|
272
|
+
re.displayName = "Reasoning";
|
|
273
|
+
le.displayName = "ReasoningTrigger";
|
|
274
|
+
de.displayName = "ReasoningContent";
|
|
275
|
+
const ze = ({ className: t, content: e, isLoading: s = !1, ...n }) => /* @__PURE__ */ o("div", { className: r("is-assistant flex w-full max-w-[80%] flex-col gap-2", t), ...n, children: /* @__PURE__ */ o("div", { className: "flex w-fit flex-col gap-2 overflow-hidden text-sm", children: /* @__PURE__ */ o("div", { className: "flex items-center gap-2 rounded-lg border border-muted-foreground/20 bg-muted/50 p-3", children: /* @__PURE__ */ l("div", { className: "flex flex-1 items-center gap-2", children: [
|
|
276
|
+
s && /* @__PURE__ */ o(U, { duration: 1.5, children: e }),
|
|
277
|
+
!s && /* @__PURE__ */ o("div", { className: "text-xs text-muted-foreground", children: e })
|
|
278
|
+
] }) }) }) });
|
|
279
|
+
function Me({
|
|
280
|
+
userInput: t,
|
|
281
|
+
language: e = "en",
|
|
282
|
+
currentHtml: s
|
|
283
|
+
}) {
|
|
284
|
+
const n = h[e] || "English";
|
|
285
|
+
return s && s.trim().length > 0 ? `
|
|
286
|
+
MODE: EDIT
|
|
287
|
+
CURRENT HTML:
|
|
288
|
+
${s}
|
|
289
|
+
|
|
290
|
+
USER REQUEST: ${t}
|
|
291
|
+
Use ${n} language.
|
|
292
|
+
`.trim() : `
|
|
293
|
+
USER REQUEST: ${t}
|
|
294
|
+
Use ${n} language.
|
|
295
|
+
`.trim();
|
|
296
|
+
}
|
|
297
|
+
function Be({
|
|
298
|
+
fallbackLang: t,
|
|
299
|
+
language: e,
|
|
300
|
+
blocks: s = [],
|
|
301
|
+
userInput: n
|
|
302
|
+
}) {
|
|
303
|
+
const a = h[e] || "English";
|
|
304
|
+
return `
|
|
305
|
+
USER REQUEST: ${n || "Translate the content"}
|
|
306
|
+
LANGUAGE TO TRANSLATE: ${a}
|
|
307
|
+
REQUESTED TRANSLATION LANGUAGE CODE: ${e}
|
|
308
|
+
FALLBACK LANGUAGE: ${h[t]}
|
|
309
|
+
BLOCKS: ${JSON.stringify(s)}`.trim();
|
|
310
|
+
}
|
|
311
|
+
const Ie = ({ onRemove: t, isLoading: e = !1 }) => {
|
|
312
|
+
const { t: s } = Y(), n = J(), a = (n == null ? void 0 : n._type) || "Unknown", i = (n == null ? void 0 : n._name) || a;
|
|
313
|
+
return /* @__PURE__ */ o(f, { children: /* @__PURE__ */ l("div", { className: "mx-auto flex w-[95%] items-center justify-between rounded-t-md border border-b-0 border-blue-200 bg-blue-50", children: [
|
|
314
|
+
/* @__PURE__ */ l("div", { className: "flex items-center", children: [
|
|
315
|
+
/* @__PURE__ */ o("div", { className: "flex h-6 w-6 items-center justify-center rounded-l rounded-bl-none bg-blue-500 text-xs font-semibold text-white", children: "@" }),
|
|
316
|
+
/* @__PURE__ */ o("div", { className: "flex w-[95%] flex-col", children: n ? /* @__PURE__ */ o(f, { children: /* @__PURE__ */ l("span", { className: "truncate text-xs font-medium text-blue-900", children: [
|
|
317
|
+
" ",
|
|
318
|
+
s("Context: "),
|
|
319
|
+
" ",
|
|
320
|
+
i
|
|
321
|
+
] }) }) : /* @__PURE__ */ l("span", { className: "text-xs font-medium text-blue-900", children: [
|
|
322
|
+
" ",
|
|
323
|
+
s("Context: Entire Page")
|
|
324
|
+
] }) })
|
|
325
|
+
] }),
|
|
326
|
+
n && /* @__PURE__ */ o(
|
|
327
|
+
X,
|
|
328
|
+
{
|
|
329
|
+
variant: "ghost",
|
|
330
|
+
size: "icon",
|
|
331
|
+
onClick: t,
|
|
332
|
+
disabled: e,
|
|
333
|
+
className: "h-6 w-6 text-blue-600 hover:bg-blue-100 hover:text-blue-800",
|
|
334
|
+
title: "Remove block from context",
|
|
335
|
+
children: /* @__PURE__ */ o(_, { size: 14 })
|
|
336
|
+
}
|
|
337
|
+
)
|
|
338
|
+
] }) });
|
|
339
|
+
};
|
|
340
|
+
export {
|
|
341
|
+
Re as C,
|
|
342
|
+
ke as M,
|
|
343
|
+
re as R,
|
|
344
|
+
Ie as S,
|
|
345
|
+
ze as T,
|
|
346
|
+
Se as a,
|
|
347
|
+
ye as b,
|
|
348
|
+
le as c,
|
|
349
|
+
de as d,
|
|
350
|
+
Ue as e,
|
|
351
|
+
W as f,
|
|
352
|
+
Be as g,
|
|
353
|
+
Ae as h,
|
|
354
|
+
Me as i
|
|
355
|
+
};
|