@chaibuilder/sdk 4.0.0-beta.8 → 4.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/dist/{2SSKDMRQ-DewwiCoQ.js → 2SSKDMRQ-CdFBQR2o.js} +2 -2
- package/dist/{2SSKDMRQ-DHv4u_0i.cjs → 2SSKDMRQ-CuQ42ST6.cjs} +1 -1
- package/dist/{AP7HFJJL-cz754qhG.cjs → AP7HFJJL-DcnEb4BE.cjs} +1 -1
- package/dist/{AP7HFJJL-ComnZw7J.js → AP7HFJJL-bDlWX5Yx.js} +1 -1
- package/dist/{IconPicker-2H9IGKMS.js → IconPicker-CNwplOGy.js} +1 -1
- package/dist/{IconPicker-U0Z2dWeR.cjs → IconPicker-FpyYsxOf.cjs} +1 -1
- package/dist/STRINGS-BExFecZW.js +8 -0
- package/dist/STRINGS-FNnfjF5H.cjs +1 -0
- package/dist/{WDYDFRGG-BfRX3M58.cjs → WDYDFRGG-BxLmjulP.cjs} +1 -1
- package/dist/{WDYDFRGG-vy7nMYD4.js → WDYDFRGG-CWq7H6Qk.js} +2 -2
- package/dist/{actions-registery-CtQSSexG.cjs → actions-registery-BRgseJas.cjs} +16 -16
- package/dist/{actions-registery-DqrFhSMp.js → actions-registery-DRV8xywr.js} +180 -181
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.ts +112 -51
- package/dist/actions.js +2 -2
- package/dist/{active-in-another-tab-5hn17Jeq.js → active-in-another-tab-C392ZWQc.js} +2 -2
- package/dist/{active-in-another-tab-ijahI5qu.cjs → active-in-another-tab-DEWOFgY5.cjs} +1 -1
- package/dist/{add-new-language-page-DmOyPy0u.js → add-new-language-page-BL2F_Cu7.js} +3 -3
- package/dist/{add-new-language-page-vmNKNx-e.cjs → add-new-language-page-DBWd0wDY.cjs} +1 -1
- package/dist/{add-new-page-XDuCkOyb.cjs → add-new-page-DYrQeKCi.cjs} +1 -1
- package/dist/{add-new-page-NHScAQn8.js → add-new-page-QVlyJhn9.js} +2 -2
- package/dist/{ai-panel-content-CHJ0JcQI.js → ai-panel-content-CCOluPtK.js} +3 -3
- package/dist/{ai-panel-content-BDqW16AW.cjs → ai-panel-content-DCZRBa6s.cjs} +1 -1
- package/dist/{ai-panel-default-lang-HeYWpbMu.cjs → ai-panel-default-lang-C3t0elrO.cjs} +2 -2
- package/dist/{ai-panel-default-lang-BIomgsN0.js → ai-panel-default-lang-Crz7QAxl.js} +4 -4
- package/dist/{ai-panel-other-lang-BMelEs3p.cjs → ai-panel-other-lang-BRkr4Te3.cjs} +1 -1
- package/dist/{ai-panel-other-lang-CbAgG-qX.js → ai-panel-other-lang-DIF8PYLh.js} +4 -4
- package/dist/{ai-prompt-input-BH8LOVT4.js → ai-prompt-input-D4dqy8L2.js} +1 -1
- package/dist/{ai-prompt-input-C_GG6nwq.cjs → ai-prompt-input-Ybgvrvd6.cjs} +1 -1
- package/dist/{ai-translation-prompt-CkHaFv5I.cjs → ai-translation-prompt-Ck12Bfl6.cjs} +1 -1
- package/dist/{ai-translation-prompt-DxsNw8YR.js → ai-translation-prompt-eZ4Sllva.js} +1 -1
- package/dist/{apply-binding-BvWfJCSZ.js → apply-binding-CLU6Xp4K.js} +77 -81
- package/dist/apply-binding-NvZX_rJe.cjs +1 -0
- package/dist/{code-editor-CGBAc-A6.js → code-editor-D45h29W1.js} +1 -1
- package/dist/{code-editor-GV8ibQ4h.cjs → code-editor-DH8eU4WL.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-Da8ab_9d.js → continue-editing-in-this-client-BRrIvSrl.js} +2 -2
- package/dist/{continue-editing-in-this-client-DKHP0pq8.cjs → continue-editing-in-this-client-DgZ9Q18G.cjs} +1 -1
- package/dist/core-8lkXy4lC.cjs +1 -0
- package/dist/core-BvsZwF26.js +52 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +147 -87
- package/dist/core.js +2 -2
- package/dist/{css-import-modal-CcZVLsF9.js → css-import-modal-BhLPzQH8.js} +1 -1
- package/dist/{css-import-modal-B4j26_cO.cjs → css-import-modal-C2-oVwFv.cjs} +1 -1
- package/dist/{delete-design-token-DzINIVtO.js → delete-design-token-D4Q5-Xql.js} +1 -1
- package/dist/{delete-design-token-3-WwqXMO.cjs → delete-design-token-DJSQluQ6.cjs} +1 -1
- package/dist/{delete-page-B7ODELqM.cjs → delete-page-BxbsKhY5.cjs} +1 -1
- package/dist/{delete-page-DwZDMwfI.js → delete-page-xHdZT-7c.js} +2 -2
- package/dist/{design-token-usage-DQf180Lg.js → design-token-usage-7wgmVSWI.js} +1 -1
- package/dist/{design-token-usage-Dy08kcIc.cjs → design-token-usage-KZ4pilLm.cjs} +1 -1
- package/dist/{digital-asset-manager-CDy9kHZO.js → digital-asset-manager-BmbVU7fX.js} +3 -3
- package/dist/{digital-asset-manager-C7subULa.cjs → digital-asset-manager-a1fqrQVH.cjs} +1 -1
- package/dist/{duplicate-page-DTnSztlr.js → duplicate-page-5uIno9Yh.js} +3 -3
- package/dist/{duplicate-page-CWQ9aMd9.cjs → duplicate-page-BBTxn_o1.cjs} +1 -1
- package/dist/{dynamic-page-selector-DJuxLcsM.cjs → dynamic-page-selector-C1ef0i2I.cjs} +1 -1
- package/dist/{dynamic-page-selector-DYW3ov_u.js → dynamic-page-selector-rhvhg7ol.js} +2 -2
- package/dist/{image-editor-DLeSST0K.js → image-editor-BXYZDa0s.js} +1 -1
- package/dist/{image-editor-C4H3AkZK.cjs → image-editor-rqUgAO8V.cjs} +1 -1
- package/dist/{index-D5d4QDq7.js → index-Be9lAaD7.js} +420 -422
- package/dist/index-BhqugjzS.cjs +160 -0
- package/dist/index-CNEEEgTV.cjs +5 -0
- package/dist/{index-BK0xWO1z.js → index-mjuSGlPU.js} +440 -447
- package/dist/{json-diff-viewer-g6SY62bl.cjs → json-diff-viewer-C9qmLiaq.cjs} +1 -1
- package/dist/{json-diff-viewer-BYHieVod.js → json-diff-viewer-aVwY7_hZ.js} +2 -2
- package/dist/{lang-panel-BG1GMn-1.js → lang-panel-BTWk23Mw.js} +3 -3
- package/dist/{lang-panel-Dm1eOO2J.cjs → lang-panel-Bo1ZWYfu.cjs} +1 -1
- package/dist/{manage-design-tokens-BdWQUHhw.js → manage-design-tokens-id8bylgO.js} +3 -3
- package/dist/manage-design-tokens-lUMCgjdS.cjs +1 -0
- package/dist/{mark-as-template-DUFnfVM3.cjs → mark-as-template-BYXBDXMv.cjs} +1 -1
- package/dist/{mark-as-template-D2XxagVO.js → mark-as-template-hv3WD852.js} +2 -2
- package/dist/{nested-path-selector-content-Wd6-Eql0.js → nested-path-selector-content-B8z90MFF.js} +1 -1
- package/dist/{nested-path-selector-content-CQOx2L9C.cjs → nested-path-selector-content-DgFFXcTD.cjs} +1 -1
- package/dist/{no-language-page-content-C11uF6hs.cjs → no-language-page-content-6Kk8UjFX.cjs} +1 -1
- package/dist/{no-language-page-content-BOv6TZIk.js → no-language-page-content-DMACzysm.js} +2 -2
- package/dist/{no-language-page-dialog-DIXyKRJq.js → no-language-page-dialog-D4n_XYUq.js} +2 -2
- package/dist/{no-language-page-dialog-CY5XhXsC.cjs → no-language-page-dialog-mBH-fthh.cjs} +1 -1
- package/dist/{page-creator-zSUFF4eT.cjs → page-creator-CGglYnYg.cjs} +1 -1
- package/dist/{page-creator-WX9lMrJY.js → page-creator-CgsOF0Eg.js} +3 -3
- package/dist/{page-lock-D9miLZjm.js → page-lock-CUCEBnJb.js} +2 -2
- package/dist/{page-lock-DGhR_url.cjs → page-lock-Hsi61Mk5.cjs} +1 -1
- package/dist/{page-locked-dialog-DTLnbfuP.cjs → page-locked-dialog-DSxbAMpt.cjs} +1 -1
- package/dist/{page-locked-dialog-CNCUCcvH.js → page-locked-dialog-bHvbFllT.js} +2 -2
- package/dist/{page-manager-new-Dd2c-Q_O.cjs → page-manager-new-CBfFl5rL.cjs} +1 -1
- package/dist/{page-manager-new-BFFOLh-l.js → page-manager-new-Cifc526h.js} +7 -7
- package/dist/{page-manager-search-and-filter-C1IWF_4d.js → page-manager-search-and-filter-CLJss6pV.js} +2 -2
- package/dist/{page-manager-search-and-filter-BKdQUJ2W.cjs → page-manager-search-and-filter-mEKl-UKh.cjs} +1 -1
- package/dist/{page-revisions-content-D0cflnj1.cjs → page-revisions-content-C95dQJyx.cjs} +1 -1
- package/dist/{page-revisions-content-DHapiLck.js → page-revisions-content-DvL4ya9g.js} +3 -3
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +146 -93
- package/dist/pages.js +1 -1
- package/dist/{publish-pages-content-BqLcnKry.cjs → publish-pages-content-B-6vSkql.cjs} +1 -1
- package/dist/{publish-pages-content-Bd2zJHtK.js → publish-pages-content-B8-IZW_U.js} +3 -3
- package/dist/render.cjs +1 -1
- package/dist/render.d.ts +12 -14
- package/dist/render.js +3 -3
- package/dist/{rte-widget-modal-RS8PMKOn.js → rte-widget-modal-1SbY5bcQ.js} +1 -1
- package/dist/{rte-widget-modal-DiB5BjH1.cjs → rte-widget-modal-CyKwtbOG.cjs} +1 -1
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +91 -77
- package/dist/runtime.js +57 -56
- package/dist/{save-to-lib--6ZXHEbC.js → save-to-lib-BKcBfjfi.js} +2 -2
- package/dist/{save-to-lib-BXJvaC1N.cjs → save-to-lib-BmPh_Vns.cjs} +1 -1
- package/dist/{selected-block-display-CUnCqXQw.js → selected-block-display-B3hHlcLA.js} +2 -2
- package/dist/{selected-block-display-BfpJda4h.cjs → selected-block-display-BCvTNcp2.cjs} +1 -1
- package/dist/{seo-panel-Bs-FcY1A.js → seo-panel-D3EyOYij.js} +2 -2
- package/dist/{seo-panel-CQITMfZ6.cjs → seo-panel-DVClgzX9.cjs} +1 -1
- package/dist/{shared-json-ld-DDXXi-Mj.cjs → shared-json-ld-BRgJTv0m.cjs} +1 -1
- package/dist/{shared-json-ld-7EujD341.js → shared-json-ld-DSPadwbY.js} +2 -2
- package/dist/{slug-input-CsVJAr7r.cjs → slug-input-B39SPBdP.cjs} +1 -1
- package/dist/{slug-input-DoEIq5rs.js → slug-input-C3UrwSkt.js} +1 -1
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.js +1 -1
- package/dist/{take-over-request-C14kJ356.js → take-over-request-DfAlPvpE.js} +2 -2
- package/dist/{take-over-request-D5Oo3MPo.cjs → take-over-request-Tq9-gOCV.cjs} +1 -1
- package/dist/{theme-panel-footer-Dvknelm8.js → theme-panel-footer-DIy4baYU.js} +2 -2
- package/dist/{theme-panel-footer-Eeibz2JA.cjs → theme-panel-footer-DQzjVBBP.cjs} +1 -1
- package/dist/{translation-warning-modal-YlzP2XoO.js → translation-warning-modal-BHwLZZOw.js} +1 -1
- package/dist/{translation-warning-modal-CPzdHzqq.cjs → translation-warning-modal-Ckwt5Skc.cjs} +1 -1
- package/dist/types.cjs +1 -0
- package/dist/types.d.ts +598 -0
- package/dist/types.js +1 -0
- package/dist/{unmark-as-template-BGDwuCnv.cjs → unmark-as-template-BKA-sNZr.cjs} +1 -1
- package/dist/{unmark-as-template-CPJvQk7L.js → unmark-as-template-CbgifSbI.js} +2 -2
- package/dist/{unpublish-page-BMowW5wT.cjs → unpublish-page-BqzvOD76.cjs} +1 -1
- package/dist/{unpublish-page-DlFHLlmI.js → unpublish-page-DXQpAkvc.js} +2 -2
- package/dist/utils.d.ts +5 -5
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +237 -237
- package/dist/{web-preview-BUnv3jIc.js → web-preview-DH7Yv-jg.js} +1 -1
- package/dist/{web-preview-D8GQHCjs.cjs → web-preview-DShy13AM.cjs} +1 -1
- package/package.json +6 -1
- package/dist/apply-binding-IsUf6UWJ.cjs +0 -1
- package/dist/core-Dr7QYemB.js +0 -56
- package/dist/core-Y0lXLwkq.cjs +0 -1
- package/dist/index-BRJCj7c_.cjs +0 -5
- package/dist/index-Bm8iS2OH.cjs +0 -160
- package/dist/manage-design-tokens-XWs_B6jo.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("./register-chai-top-bar-DWTuRU53.cjs"),N=require("./index-Bm8iS2OH.cjs"),W=require("class-variance-authority"),S=require("lucide-react"),te=require("nanoid"),c=require("react"),se=require("react-i18next"),R=require("./models-5gOsRC56.cjs");function ne({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:g.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",...o}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:g.cn(re({align:s}),t),onClick:l=>{var i,m;l.target.closest("button")||(m=(i=l.currentTarget.parentElement)==null?void 0:i.querySelector("input"))==null||m.focus()},...o})}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:o="ghost",size:l="xs",...i}){return e.jsx(g.Button,{type:s,"data-size":l,variant:o,className:g.cn(ae({size:l}),t),...i})}function oe({className:t,...s}){return e.jsx(N.Textarea,{"data-slot":"input-group-control",className:g.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($),o=t??s;if(!o)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return o};function ue({data:t,className:s,...o}){var h;const l=q(),i=t.filename||"",d=((h=t.mediaType)!=null&&h.startsWith("image/")&&t.url?"image":"file")==="image",v=i||(d?"Image":"Attachment");return e.jsxs(Ie,{children:[e.jsx(N.HoverCardTrigger,{asChild:!0,children:e.jsxs("div",{className:g.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),...o,children:[e.jsxs("div",{className:"relative size-5 shrink-0",children:[e.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:d?e.jsx("img",{alt:i||"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(S.PaperclipIcon,{className:"size-3"})})}),e.jsxs(g.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:y=>{y.stopPropagation(),l.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(S.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:v})]},t.id)}),e.jsx(ye,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[d&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:i||"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:i||(d?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function de({children:t,className:s,...o}){const l=q();return l.files.length?e.jsx("div",{className:g.cn("flex flex-wrap items-center gap-2 p-3",s),...o,children:l.files.map(i=>e.jsx(c.Fragment,{children:t(i)},i.id))}):null}const pe=({label:t="Add photos or files",...s})=>{const o=q();return e.jsxs(N.DropdownMenuItem,{...s,onSelect:l=>{l.preventDefault(),o.openFileDialog()},children:[e.jsx(S.ImageIcon,{className:"mr-2 size-4"})," ",t]})},me=({className:t,accept:s,multiple:o,globalDrop:l,syncHiddenInput:i,maxFiles:m,maxFileSize:d,onError:v,onSubmit:h,children:y,...P})=>{const n=X(),a=!!n,p=c.useRef(null),D=c.useRef(null),I=c.useRef(null);c.useEffect(()=>{var j;const r=(j=D.current)==null?void 0:j.closest("form");r instanceof HTMLFormElement&&(I.current=r)},[]);const[k,z]=c.useState([]),x=a?n.attachments.files:k,C=c.useCallback(()=>{var r;(r=p.current)==null||r.click()},[]),M=c.useCallback(r=>!s||s.trim()===""?!0:s.includes("image/*")?r.type.startsWith("image/"):!0,[s]),U=c.useCallback(r=>{const j=Array.from(r),f=j.filter(w=>M(w));if(j.length&&f.length===0){v==null||v({code:"accept",message:"No files match the accepted types."});return}const u=w=>d?w.size<=d:!0,b=f.filter(u);if(f.length>0&&b.length===0){v==null||v({code:"max_file_size",message:"All files exceed the maximum size."});return}z(w=>{const A=typeof m=="number"?Math.max(0,m-w.length):void 0,ee=typeof A=="number"?b.slice(0,A):b;typeof A=="number"&&b.length>A&&(v==null||v({code:"max_files",message:"Too many files. Some were not added."}));const V=[];for(const E of ee)V.push({id:te.nanoid(),type:"file",url:URL.createObjectURL(E),mediaType:E.type,filename:E.name});return w.concat(V)})},[M,m,d,v]),T=a?r=>n.attachments.add(r):U,L=a?r=>n.attachments.remove(r):r=>z(j=>{const f=j.find(u=>u.id===r);return f!=null&&f.url&&URL.revokeObjectURL(f.url),j.filter(u=>u.id!==r)}),O=a?()=>n.attachments.clear():()=>z(r=>{for(const j of r)j.url&&URL.revokeObjectURL(j.url);return[]}),B=a?()=>n.attachments.openFileDialog():C;c.useEffect(()=>{a&&n.__registerFileInput(p,()=>{var r;return(r=p.current)==null?void 0:r.click()})},[a,n]),c.useEffect(()=>{i&&p.current&&x.length===0&&(p.current.value="")},[x,i]),c.useEffect(()=>{const r=I.current;if(!r)return;const j=u=>{var b,w;(w=(b=u.dataTransfer)==null?void 0:b.types)!=null&&w.includes("Files")&&u.preventDefault()},f=u=>{var b,w,A;(w=(b=u.dataTransfer)==null?void 0:b.types)!=null&&w.includes("Files")&&u.preventDefault(),(A=u.dataTransfer)!=null&&A.files&&u.dataTransfer.files.length>0&&T(u.dataTransfer.files)};return r.addEventListener("dragover",j),r.addEventListener("drop",f),()=>{r.removeEventListener("dragover",j),r.removeEventListener("drop",f)}},[T]),c.useEffect(()=>{if(!l)return;const r=f=>{var u,b;(b=(u=f.dataTransfer)==null?void 0:u.types)!=null&&b.includes("Files")&&f.preventDefault()},j=f=>{var u,b,w;(b=(u=f.dataTransfer)==null?void 0:u.types)!=null&&b.includes("Files")&&f.preventDefault(),(w=f.dataTransfer)!=null&&w.files&&f.dataTransfer.files.length>0&&T(f.dataTransfer.files)};return document.addEventListener("dragover",r),document.addEventListener("drop",j),()=>{document.removeEventListener("dragover",r),document.removeEventListener("drop",j)}},[T,l]),c.useEffect(()=>()=>{if(!a)for(const r of x)r.url&&URL.revokeObjectURL(r.url)},[a,x]);const Y=r=>{r.currentTarget.files&&T(r.currentTarget.files)},J=async r=>{const f=await(await fetch(r)).blob();return new Promise((u,b)=>{const w=new FileReader;w.onloadend=()=>u(w.result),w.onerror=b,w.readAsDataURL(f)})},Q=c.useMemo(()=>({files:x.map(r=>({...r,id:r.id})),add:T,remove:L,clear:O,openFileDialog:B,fileInputRef:p}),[x,T,L,O,B]),Z=r=>{r.preventDefault();const j=r.currentTarget,f=a?n.textInput.value:new FormData(j).get("message")||"";a||j.reset(),Promise.all(x.map(async({...u})=>u.url&&u.url.startsWith("blob:")?{...u,url:await J(u.url)}:u)).then(u=>{try{const b=h({text:f,files:u},r);b instanceof Promise?b.then(()=>{O(),a&&n.textInput.clear()}).catch(()=>{}):(O(),a&&n.textInput.clear())}catch{}})},G=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:D}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:o,onChange:Y,ref:p,title:"Upload files",type:"file"}),e.jsx("form",{className:g.cn("w-full",t),onSubmit:Z,...P,children:e.jsx(ne,{className:"overflow-hidden",children:y})})]});return a?G:e.jsx($.Provider,{value:Q,children:G})},fe=({onChange:t,className:s,placeholder:o="What would you like to know?",...l})=>{const i=X(),m=q(),[d,v]=c.useState(!1),h=n=>{if(n.key==="Enter"){if(d||n.nativeEvent.isComposing||n.shiftKey)return;n.preventDefault();const a=n.currentTarget.form,p=a==null?void 0:a.querySelector('button[type="submit"]');if(p!=null&&p.disabled)return;a==null||a.requestSubmit()}if(n.key==="Backspace"&&n.currentTarget.value===""&&m.files.length>0){n.preventDefault();const a=m.files.at(-1);a&&m.remove(a.id)}},y=n=>{var D;const a=(D=n.clipboardData)==null?void 0:D.items;if(!a)return;const p=[];for(const I of a)if(I.kind==="file"){const k=I.getAsFile();k&&p.push(k)}p.length>0&&(n.preventDefault(),m.add(p))},P=i?{value:i.textInput.value,onChange:n=>{i.textInput.setInput(n.currentTarget.value),t==null||t(n)}}:{onChange:t};return e.jsx(oe,{className:g.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>v(!1),onCompositionStart:()=>v(!0),onKeyDown:h,onPaste:y,placeholder:o,...l,...P})},he=({className:t,...s})=>e.jsx(H,{align:"block-end",className:g.cn("order-first flex-wrap gap-1",t),...s}),xe=({className:t,...s})=>e.jsx(H,{align:"block-end",className:g.cn("justify-between gap-1",t),...s}),ge=({className:t,...s})=>e.jsx("div",{className:g.cn("flex items-center gap-1",t),...s}),F=({variant:t="ghost",className:s,size:o,...l})=>{const i=o??(c.Children.count(l.children)>1?"sm":"icon-sm");return e.jsx(K,{className:g.cn(s),size:i,type:"button",variant:t,...l})},ve=t=>e.jsx(N.DropdownMenu,{...t}),je=({className:t,children:s,...o})=>e.jsx(N.DropdownMenuTrigger,{asChild:!0,children:e.jsx(F,{className:t,...o,children:s??e.jsx(S.PlusIcon,{className:"size-4"})})}),be=({className:t,...s})=>e.jsx(N.DropdownMenuContent,{align:"start",className:g.cn(t),...s}),we=({className:t,variant:s="default",size:o="icon-sm",status:l,children:i,...m})=>{let d=e.jsx(S.CornerDownLeftIcon,{className:"size-4"});return l==="submitted"?d=e.jsx(S.Loader2Icon,{className:"size-4 animate-spin"}):l==="streaming"?d=e.jsx(S.SquareIcon,{className:"size-4"}):l==="error"&&(d=e.jsx(S.XIcon,{className:"size-4"})),e.jsx(K,{"aria-label":"Submit",className:g.cn(t),size:o,type:"submit",variant:s,...m,children:i??d})},Ne=({className:t,textareaRef:s,onTranscriptionChange:o,...l})=>{const[i,m]=c.useState(!1),[d,v]=c.useState(null),h=c.useRef(null);c.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const P=window.SpeechRecognition||window.webkitSpeechRecognition,n=new P;n.continuous=!0,n.interimResults=!0,n.lang="en-US",n.onstart=()=>{m(!0)},n.onend=()=>{m(!1)},n.onresult=a=>{var D;let p="";for(let I=a.resultIndex;I<a.results.length;I++){const k=a.results[I];k.isFinal&&(p+=((D=k[0])==null?void 0:D.transcript)??"")}if(p&&(s!=null&&s.current)){const I=s.current,k=I.value,z=k+(k?" ":"")+p;I.value=z,I.dispatchEvent(new Event("input",{bubbles:!0})),o==null||o(z)}},n.onerror=a=>{console.error("Speech recognition error:",a.error),m(!1)},h.current=n,c.startTransition(()=>v(n))}return()=>{h.current&&h.current.stop()}},[s,o]);const y=c.useCallback(()=>{d&&(i?d.stop():d.start())},[d,i]);return e.jsx(F,{className:g.cn("relative transition-all duration-200",i&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!d,onClick:y,...l,children:e.jsx(S.MicIcon,{className:"size-4"})})},Ie=({openDelay:t=0,closeDelay:s=0,...o})=>e.jsx(N.HoverCard,{closeDelay:s,openDelay:t,...o}),ye=({align:t="start",...s})=>e.jsx(N.HoverCardContent,{align:t,...s}),Se=t=>e.jsx(N.Dialog,{...t}),ke=t=>e.jsx(N.DialogTrigger,{...t}),De=({className:t,children:s,title:o="Model Selector",...l})=>e.jsxs(N.DialogContent,{className:g.cn("p-0",t),...l,children:[e.jsx(N.DialogTitle,{className:"sr-only",children:o}),e.jsx(N.Command,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),Pe=({className:t,...s})=>e.jsx(N.CommandInput,{className:g.cn("h-auto py-3.5",t),...s}),Te=t=>e.jsx(N.CommandList,{...t}),ze=t=>e.jsx(N.CommandGroup,{...t}),Ce=t=>e.jsx(N.CommandItem,{...t}),Ae=({provider:t,className:s,...o})=>e.jsx("img",{...o,alt:`${t} logo`,className:g.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Le=({className:t,...s})=>e.jsx("span",{className:g.cn("flex-1 truncate text-left",t),...s}),Re=({selectedModel:t,onModelChange:s,disabled:o=!1})=>{const[l,i]=c.useState(!1),[m,d]=c.useState(""),v=R.getModelById(t)||R.getDefaultModel(),y=R.AI_MODELS.filter(n=>n.name.toLowerCase().includes(m.toLowerCase())||n.provider.toLowerCase().includes(m.toLowerCase())).reduce((n,a)=>(n[a.provider]||(n[a.provider]=[]),n[a.provider].push(a),n),{}),P=n=>{s(n),i(!1),d("")};return e.jsxs(Se,{open:l,onOpenChange:i,children:[e.jsx(ke,{asChild:!0,children:e.jsxs(g.Button,{variant:"outline",size:"sm",disabled:o,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(S.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:v.name})]})}),e.jsxs(De,{className:"w-96 p-0",children:[e.jsx(Pe,{placeholder:"Search models...",value:m,onValueChange:d}),e.jsx(Te,{children:Object.entries(y).map(([n,a])=>e.jsx(ze,{heading:n.charAt(0).toUpperCase()+n.slice(1),children:a.map(p=>e.jsxs(Ce,{value:p.id,onSelect:()=>P(p.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(Ae,{provider:p.provider}),e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsx(Le,{children:p.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:p.description})]}),t===p.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},p.id))},n))})]})]})},_="chai-ai-selected-model",Me=({input:t,setInput:s,onSend:o,onStop:l,isLoading:i,disabled:m,selectedLang:d,selectedModel:v=R.getDefaultModel().id,onModelChange:h})=>{const{t:y}=se.useTranslation(),[P,n]=c.useState(v),[a,p]=c.useState(null),D=c.useRef(null),[I,k]=c.useState(!1);c.useEffect(()=>{if(!d){const x=localStorage.getItem(_);if(x)n(x),h==null||h(x);else{const C=R.getDefaultModel().id;n(C),h==null||h(C)}}},[d,h]);const z=x=>{var U;const C=x.files.find(T=>{var L;return(L=T.mediaType)==null?void 0:L.startsWith("image/")}),M=(C==null?void 0:C.url)||a;o((U=x.text)==null?void 0:U.trim(),void 0,M,P),p(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:x=>e.jsx(ue,{className:"text-xs",data:x})})}),e.jsx(fe,{ref:D,value:t,onChange:x=>s(x.target.value),placeholder:y(d?"Ask to update content":"Ask me anything..."),disabled:i,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(xe,{children:[d?e.jsx("div",{}):e.jsxs(ge,{children:[e.jsxs(ve,{children:[e.jsx(je,{disabled:i,children:e.jsx(S.Paperclip,{size:16})}),e.jsx(be,{children:e.jsx(pe,{})})]}),e.jsx(Ne,{textareaRef:D,onTranscriptionChange:s,disabled:i}),e.jsx(Re,{selectedModel:P,onModelChange:x=>{n(x),h==null||h(x),localStorage.setItem(_,x)},disabled:i}),e.jsxs(F,{className:"hidden",size:"sm",onClick:()=>k(!I),variant:I?"default":"ghost",children:[e.jsx(S.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),i?e.jsxs("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:y("Stop generation"),children:[e.jsx(S.Square,{size:16})," ",e.jsx("span",{className:"text-xs",children:y("Stop")})]}):e.jsx(we,{disabled:!t.trim()||m,children:e.jsx(S.Send,{size:16})})]})]})})})};exports.default=Me;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("./register-chai-top-bar-DWTuRU53.cjs"),N=require("./index-BhqugjzS.cjs"),W=require("class-variance-authority"),S=require("lucide-react"),te=require("nanoid"),c=require("react"),se=require("react-i18next"),R=require("./models-5gOsRC56.cjs");function ne({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:g.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",...o}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:g.cn(re({align:s}),t),onClick:l=>{var i,m;l.target.closest("button")||(m=(i=l.currentTarget.parentElement)==null?void 0:i.querySelector("input"))==null||m.focus()},...o})}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:o="ghost",size:l="xs",...i}){return e.jsx(g.Button,{type:s,"data-size":l,variant:o,className:g.cn(ae({size:l}),t),...i})}function oe({className:t,...s}){return e.jsx(N.Textarea,{"data-slot":"input-group-control",className:g.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($),o=t??s;if(!o)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return o};function ue({data:t,className:s,...o}){var h;const l=q(),i=t.filename||"",d=((h=t.mediaType)!=null&&h.startsWith("image/")&&t.url?"image":"file")==="image",v=i||(d?"Image":"Attachment");return e.jsxs(Ie,{children:[e.jsx(N.HoverCardTrigger,{asChild:!0,children:e.jsxs("div",{className:g.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),...o,children:[e.jsxs("div",{className:"relative size-5 shrink-0",children:[e.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:d?e.jsx("img",{alt:i||"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(S.PaperclipIcon,{className:"size-3"})})}),e.jsxs(g.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:y=>{y.stopPropagation(),l.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(S.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:v})]},t.id)}),e.jsx(ye,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[d&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:i||"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:i||(d?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function de({children:t,className:s,...o}){const l=q();return l.files.length?e.jsx("div",{className:g.cn("flex flex-wrap items-center gap-2 p-3",s),...o,children:l.files.map(i=>e.jsx(c.Fragment,{children:t(i)},i.id))}):null}const pe=({label:t="Add photos or files",...s})=>{const o=q();return e.jsxs(N.DropdownMenuItem,{...s,onSelect:l=>{l.preventDefault(),o.openFileDialog()},children:[e.jsx(S.ImageIcon,{className:"mr-2 size-4"})," ",t]})},me=({className:t,accept:s,multiple:o,globalDrop:l,syncHiddenInput:i,maxFiles:m,maxFileSize:d,onError:v,onSubmit:h,children:y,...P})=>{const n=X(),a=!!n,p=c.useRef(null),D=c.useRef(null),I=c.useRef(null);c.useEffect(()=>{var j;const r=(j=D.current)==null?void 0:j.closest("form");r instanceof HTMLFormElement&&(I.current=r)},[]);const[k,z]=c.useState([]),x=a?n.attachments.files:k,C=c.useCallback(()=>{var r;(r=p.current)==null||r.click()},[]),M=c.useCallback(r=>!s||s.trim()===""?!0:s.includes("image/*")?r.type.startsWith("image/"):!0,[s]),U=c.useCallback(r=>{const j=Array.from(r),f=j.filter(w=>M(w));if(j.length&&f.length===0){v==null||v({code:"accept",message:"No files match the accepted types."});return}const u=w=>d?w.size<=d:!0,b=f.filter(u);if(f.length>0&&b.length===0){v==null||v({code:"max_file_size",message:"All files exceed the maximum size."});return}z(w=>{const A=typeof m=="number"?Math.max(0,m-w.length):void 0,ee=typeof A=="number"?b.slice(0,A):b;typeof A=="number"&&b.length>A&&(v==null||v({code:"max_files",message:"Too many files. Some were not added."}));const V=[];for(const E of ee)V.push({id:te.nanoid(),type:"file",url:URL.createObjectURL(E),mediaType:E.type,filename:E.name});return w.concat(V)})},[M,m,d,v]),T=a?r=>n.attachments.add(r):U,L=a?r=>n.attachments.remove(r):r=>z(j=>{const f=j.find(u=>u.id===r);return f!=null&&f.url&&URL.revokeObjectURL(f.url),j.filter(u=>u.id!==r)}),O=a?()=>n.attachments.clear():()=>z(r=>{for(const j of r)j.url&&URL.revokeObjectURL(j.url);return[]}),B=a?()=>n.attachments.openFileDialog():C;c.useEffect(()=>{a&&n.__registerFileInput(p,()=>{var r;return(r=p.current)==null?void 0:r.click()})},[a,n]),c.useEffect(()=>{i&&p.current&&x.length===0&&(p.current.value="")},[x,i]),c.useEffect(()=>{const r=I.current;if(!r)return;const j=u=>{var b,w;(w=(b=u.dataTransfer)==null?void 0:b.types)!=null&&w.includes("Files")&&u.preventDefault()},f=u=>{var b,w,A;(w=(b=u.dataTransfer)==null?void 0:b.types)!=null&&w.includes("Files")&&u.preventDefault(),(A=u.dataTransfer)!=null&&A.files&&u.dataTransfer.files.length>0&&T(u.dataTransfer.files)};return r.addEventListener("dragover",j),r.addEventListener("drop",f),()=>{r.removeEventListener("dragover",j),r.removeEventListener("drop",f)}},[T]),c.useEffect(()=>{if(!l)return;const r=f=>{var u,b;(b=(u=f.dataTransfer)==null?void 0:u.types)!=null&&b.includes("Files")&&f.preventDefault()},j=f=>{var u,b,w;(b=(u=f.dataTransfer)==null?void 0:u.types)!=null&&b.includes("Files")&&f.preventDefault(),(w=f.dataTransfer)!=null&&w.files&&f.dataTransfer.files.length>0&&T(f.dataTransfer.files)};return document.addEventListener("dragover",r),document.addEventListener("drop",j),()=>{document.removeEventListener("dragover",r),document.removeEventListener("drop",j)}},[T,l]),c.useEffect(()=>()=>{if(!a)for(const r of x)r.url&&URL.revokeObjectURL(r.url)},[a,x]);const Y=r=>{r.currentTarget.files&&T(r.currentTarget.files)},J=async r=>{const f=await(await fetch(r)).blob();return new Promise((u,b)=>{const w=new FileReader;w.onloadend=()=>u(w.result),w.onerror=b,w.readAsDataURL(f)})},Q=c.useMemo(()=>({files:x.map(r=>({...r,id:r.id})),add:T,remove:L,clear:O,openFileDialog:B,fileInputRef:p}),[x,T,L,O,B]),Z=r=>{r.preventDefault();const j=r.currentTarget,f=a?n.textInput.value:new FormData(j).get("message")||"";a||j.reset(),Promise.all(x.map(async({...u})=>u.url&&u.url.startsWith("blob:")?{...u,url:await J(u.url)}:u)).then(u=>{try{const b=h({text:f,files:u},r);b instanceof Promise?b.then(()=>{O(),a&&n.textInput.clear()}).catch(()=>{}):(O(),a&&n.textInput.clear())}catch{}})},G=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:D}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:o,onChange:Y,ref:p,title:"Upload files",type:"file"}),e.jsx("form",{className:g.cn("w-full",t),onSubmit:Z,...P,children:e.jsx(ne,{className:"overflow-hidden",children:y})})]});return a?G:e.jsx($.Provider,{value:Q,children:G})},fe=({onChange:t,className:s,placeholder:o="What would you like to know?",...l})=>{const i=X(),m=q(),[d,v]=c.useState(!1),h=n=>{if(n.key==="Enter"){if(d||n.nativeEvent.isComposing||n.shiftKey)return;n.preventDefault();const a=n.currentTarget.form,p=a==null?void 0:a.querySelector('button[type="submit"]');if(p!=null&&p.disabled)return;a==null||a.requestSubmit()}if(n.key==="Backspace"&&n.currentTarget.value===""&&m.files.length>0){n.preventDefault();const a=m.files.at(-1);a&&m.remove(a.id)}},y=n=>{var D;const a=(D=n.clipboardData)==null?void 0:D.items;if(!a)return;const p=[];for(const I of a)if(I.kind==="file"){const k=I.getAsFile();k&&p.push(k)}p.length>0&&(n.preventDefault(),m.add(p))},P=i?{value:i.textInput.value,onChange:n=>{i.textInput.setInput(n.currentTarget.value),t==null||t(n)}}:{onChange:t};return e.jsx(oe,{className:g.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>v(!1),onCompositionStart:()=>v(!0),onKeyDown:h,onPaste:y,placeholder:o,...l,...P})},he=({className:t,...s})=>e.jsx(H,{align:"block-end",className:g.cn("order-first flex-wrap gap-1",t),...s}),xe=({className:t,...s})=>e.jsx(H,{align:"block-end",className:g.cn("justify-between gap-1",t),...s}),ge=({className:t,...s})=>e.jsx("div",{className:g.cn("flex items-center gap-1",t),...s}),F=({variant:t="ghost",className:s,size:o,...l})=>{const i=o??(c.Children.count(l.children)>1?"sm":"icon-sm");return e.jsx(K,{className:g.cn(s),size:i,type:"button",variant:t,...l})},ve=t=>e.jsx(N.DropdownMenu,{...t}),je=({className:t,children:s,...o})=>e.jsx(N.DropdownMenuTrigger,{asChild:!0,children:e.jsx(F,{className:t,...o,children:s??e.jsx(S.PlusIcon,{className:"size-4"})})}),be=({className:t,...s})=>e.jsx(N.DropdownMenuContent,{align:"start",className:g.cn(t),...s}),we=({className:t,variant:s="default",size:o="icon-sm",status:l,children:i,...m})=>{let d=e.jsx(S.CornerDownLeftIcon,{className:"size-4"});return l==="submitted"?d=e.jsx(S.Loader2Icon,{className:"size-4 animate-spin"}):l==="streaming"?d=e.jsx(S.SquareIcon,{className:"size-4"}):l==="error"&&(d=e.jsx(S.XIcon,{className:"size-4"})),e.jsx(K,{"aria-label":"Submit",className:g.cn(t),size:o,type:"submit",variant:s,...m,children:i??d})},Ne=({className:t,textareaRef:s,onTranscriptionChange:o,...l})=>{const[i,m]=c.useState(!1),[d,v]=c.useState(null),h=c.useRef(null);c.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const P=window.SpeechRecognition||window.webkitSpeechRecognition,n=new P;n.continuous=!0,n.interimResults=!0,n.lang="en-US",n.onstart=()=>{m(!0)},n.onend=()=>{m(!1)},n.onresult=a=>{var D;let p="";for(let I=a.resultIndex;I<a.results.length;I++){const k=a.results[I];k.isFinal&&(p+=((D=k[0])==null?void 0:D.transcript)??"")}if(p&&(s!=null&&s.current)){const I=s.current,k=I.value,z=k+(k?" ":"")+p;I.value=z,I.dispatchEvent(new Event("input",{bubbles:!0})),o==null||o(z)}},n.onerror=a=>{console.error("Speech recognition error:",a.error),m(!1)},h.current=n,c.startTransition(()=>v(n))}return()=>{h.current&&h.current.stop()}},[s,o]);const y=c.useCallback(()=>{d&&(i?d.stop():d.start())},[d,i]);return e.jsx(F,{className:g.cn("relative transition-all duration-200",i&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!d,onClick:y,...l,children:e.jsx(S.MicIcon,{className:"size-4"})})},Ie=({openDelay:t=0,closeDelay:s=0,...o})=>e.jsx(N.HoverCard,{closeDelay:s,openDelay:t,...o}),ye=({align:t="start",...s})=>e.jsx(N.HoverCardContent,{align:t,...s}),Se=t=>e.jsx(N.Dialog,{...t}),ke=t=>e.jsx(N.DialogTrigger,{...t}),De=({className:t,children:s,title:o="Model Selector",...l})=>e.jsxs(N.DialogContent,{className:g.cn("p-0",t),...l,children:[e.jsx(N.DialogTitle,{className:"sr-only",children:o}),e.jsx(N.Command,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),Pe=({className:t,...s})=>e.jsx(N.CommandInput,{className:g.cn("h-auto py-3.5",t),...s}),Te=t=>e.jsx(N.CommandList,{...t}),ze=t=>e.jsx(N.CommandGroup,{...t}),Ce=t=>e.jsx(N.CommandItem,{...t}),Ae=({provider:t,className:s,...o})=>e.jsx("img",{...o,alt:`${t} logo`,className:g.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Le=({className:t,...s})=>e.jsx("span",{className:g.cn("flex-1 truncate text-left",t),...s}),Re=({selectedModel:t,onModelChange:s,disabled:o=!1})=>{const[l,i]=c.useState(!1),[m,d]=c.useState(""),v=R.getModelById(t)||R.getDefaultModel(),y=R.AI_MODELS.filter(n=>n.name.toLowerCase().includes(m.toLowerCase())||n.provider.toLowerCase().includes(m.toLowerCase())).reduce((n,a)=>(n[a.provider]||(n[a.provider]=[]),n[a.provider].push(a),n),{}),P=n=>{s(n),i(!1),d("")};return e.jsxs(Se,{open:l,onOpenChange:i,children:[e.jsx(ke,{asChild:!0,children:e.jsxs(g.Button,{variant:"outline",size:"sm",disabled:o,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(S.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:v.name})]})}),e.jsxs(De,{className:"w-96 p-0",children:[e.jsx(Pe,{placeholder:"Search models...",value:m,onValueChange:d}),e.jsx(Te,{children:Object.entries(y).map(([n,a])=>e.jsx(ze,{heading:n.charAt(0).toUpperCase()+n.slice(1),children:a.map(p=>e.jsxs(Ce,{value:p.id,onSelect:()=>P(p.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(Ae,{provider:p.provider}),e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsx(Le,{children:p.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:p.description})]}),t===p.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},p.id))},n))})]})]})},_="chai-ai-selected-model",Me=({input:t,setInput:s,onSend:o,onStop:l,isLoading:i,disabled:m,selectedLang:d,selectedModel:v=R.getDefaultModel().id,onModelChange:h})=>{const{t:y}=se.useTranslation(),[P,n]=c.useState(v),[a,p]=c.useState(null),D=c.useRef(null),[I,k]=c.useState(!1);c.useEffect(()=>{if(!d){const x=localStorage.getItem(_);if(x)n(x),h==null||h(x);else{const C=R.getDefaultModel().id;n(C),h==null||h(C)}}},[d,h]);const z=x=>{var U;const C=x.files.find(T=>{var L;return(L=T.mediaType)==null?void 0:L.startsWith("image/")}),M=(C==null?void 0:C.url)||a;o((U=x.text)==null?void 0:U.trim(),void 0,M,P),p(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:x=>e.jsx(ue,{className:"text-xs",data:x})})}),e.jsx(fe,{ref:D,value:t,onChange:x=>s(x.target.value),placeholder:y(d?"Ask to update content":"Ask me anything..."),disabled:i,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(xe,{children:[d?e.jsx("div",{}):e.jsxs(ge,{children:[e.jsxs(ve,{children:[e.jsx(je,{disabled:i,children:e.jsx(S.Paperclip,{size:16})}),e.jsx(be,{children:e.jsx(pe,{})})]}),e.jsx(Ne,{textareaRef:D,onTranscriptionChange:s,disabled:i}),e.jsx(Re,{selectedModel:P,onModelChange:x=>{n(x),h==null||h(x),localStorage.setItem(_,x)},disabled:i}),e.jsxs(F,{className:"hidden",size:"sm",onClick:()=>k(!I),variant:I?"default":"ghost",children:[e.jsx(S.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),i?e.jsxs("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:y("Stop generation"),children:[e.jsx(S.Square,{size:16})," ",e.jsx("span",{className:"text-xs",children:y("Stop")})]}):e.jsx(we,{disabled:!t.trim()||m,children:e.jsx(S.Send,{size:16})})]})]})})})};exports.default=Me;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./register-chai-top-bar-DWTuRU53.cjs"),i=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./register-chai-top-bar-DWTuRU53.cjs"),i=require("./index-CNEEEgTV.cjs"),c=require("lucide-react"),o=require("react-i18next"),x=({selectedLang:s,isLoading:n,selectedBlock:a,onClick:l})=>{const{t}=o.useTranslation();return e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx("div",{className:`flex flex-col gap-2 ${n?"pointer-events-none opacity-50":""}`,children:a?e.jsx(r.Button,{variant:"outline",className:"h-auto",onClick:()=>l("TRANSLATE"),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-left text-xs font-thin",children:t("Quick Action:")}),e.jsxs("span",{className:"flex items-center gap-x-2 text-sm font-medium",children:[t("Translate Content")," ",t("to")," ",i.LANGUAGES[s]," ",e.jsx(c.ArrowRight,{className:"h-4 w-4"})]})]})}):null})})};exports.default=x;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t, jsxs as a } from "react/jsx-runtime";
|
|
2
2
|
import { B as r } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
-
import { L as i } from "./index-
|
|
3
|
+
import { L as i } from "./index-Be9lAaD7.js";
|
|
4
4
|
import { ArrowRight as c } from "lucide-react";
|
|
5
5
|
import { useTranslation as m } from "react-i18next";
|
|
6
6
|
const u = ({
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { S as x, D as G, C as rt } from "./STRINGS-BExFecZW.js";
|
|
2
|
+
import { g as ct, c as j } from "./common-functions-D2lMFR6K.js";
|
|
3
|
+
import { memoize as pt, get as y, cloneDeep as P, forEach as S, keys as A, isString as $, startsWith as k, isArray as I, isEmpty as _, includes as B, flatten as ut, flatMapDeep as dt, set as w, find as m, startCase as yt, camelCase as Q, has as H, filter as tt, some as ht, capitalize as mt, compact as gt, map as bt, trim as xt, each as ft, last as _t } from "lodash-es";
|
|
4
|
+
import { parse as kt, stringify as D } from "himalaya";
|
|
5
|
+
import { e as vt, i as wt } from "./core-BvsZwF26.js";
|
|
6
|
+
import { twMerge as Bt } from "tailwind-merge";
|
|
7
|
+
const st = (s) => {
|
|
7
8
|
if (s = s.replace(x, ""), !s) return { baseClasses: "", classes: "" };
|
|
8
9
|
const n = s.split(/,(?![^\[]*\])/);
|
|
9
10
|
if (n.length === 1)
|
|
@@ -46,11 +47,11 @@ import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
49
|
});
|
|
49
|
-
function
|
|
50
|
+
function Pt(s, n, t) {
|
|
50
51
|
const e = y(t, "i18nProps", []);
|
|
51
52
|
if (_(n) || _(e)) return s;
|
|
52
|
-
const a =
|
|
53
|
-
return
|
|
53
|
+
const a = P(s);
|
|
54
|
+
return S(A(a), (o) => {
|
|
54
55
|
if (B(e, o) && !_(n)) {
|
|
55
56
|
const i = y(a, o), l = y(a, `${o}-${n}`, "");
|
|
56
57
|
$(i) ? a[o] = $(l) && !_(l.trim()) && l.trimStart() || i : a[o] = _(l) ? i : l;
|
|
@@ -58,11 +59,11 @@ function Ot(s, n, t) {
|
|
|
58
59
|
}), a;
|
|
59
60
|
}
|
|
60
61
|
const at = (s, n) => {
|
|
61
|
-
const { baseClasses: t, classes: e } = st(s), o = e.split(" ").filter((l) => l.startsWith(
|
|
62
|
+
const { baseClasses: t, classes: e } = st(s), o = e.split(" ").filter((l) => l.startsWith(G)).map((l) => {
|
|
62
63
|
var u;
|
|
63
64
|
return (u = n[l]) == null ? void 0 : u.value;
|
|
64
|
-
}), i = e.split(" ").filter((l) => !l.startsWith(
|
|
65
|
-
return
|
|
65
|
+
}), i = e.split(" ").filter((l) => !l.startsWith(G)).join(" ");
|
|
66
|
+
return Bt.apply(null, [t, ...o, i]);
|
|
66
67
|
};
|
|
67
68
|
function Tt(s, n) {
|
|
68
69
|
return y(s, `${n}_attrs`, {});
|
|
@@ -84,16 +85,16 @@ function Mt(s, n = !0, t = {}) {
|
|
|
84
85
|
}
|
|
85
86
|
}), e;
|
|
86
87
|
}
|
|
87
|
-
const Vt =
|
|
88
|
-
const n =
|
|
88
|
+
const Vt = pt((s) => {
|
|
89
|
+
const n = vt(s), t = y(n, "schema.properties", {});
|
|
89
90
|
return Object.fromEntries(Object.entries(t).filter(([, e]) => y(e, "runtime", !1)));
|
|
90
91
|
}), Jt = (s, n) => {
|
|
91
92
|
if (!I(s)) return s;
|
|
92
93
|
let t = s, e;
|
|
93
94
|
return typeof n.limit == "number" && n.limit > 0 && (e = n.limit), e !== void 0 && (t = t.slice(0, e)), t;
|
|
94
|
-
},
|
|
95
|
-
const t =
|
|
96
|
-
return
|
|
95
|
+
}, Ot = (s, n) => {
|
|
96
|
+
const t = P(s);
|
|
97
|
+
return S(A(t), (e) => {
|
|
97
98
|
if ($(t[e]) && !k(e, "_")) {
|
|
98
99
|
let a = t[e];
|
|
99
100
|
e === "repeaterItems" && (t.repeaterItemsBinding = a);
|
|
@@ -112,7 +113,7 @@ const Vt = ct((s) => {
|
|
|
112
113
|
if (_(s)) return s;
|
|
113
114
|
const n = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, e = s.match(n), a = s.match(t), o = e ? e[1] : a ? a[1] : null, i = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, l = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
|
|
114
115
|
return o && (i.test(o) || l.test(o)) ? o : s;
|
|
115
|
-
}, nt = ["chai-name", "data-chai-name"],
|
|
116
|
+
}, nt = ["chai-name", "data-chai-name"], St = {
|
|
116
117
|
img: { alt: "alt", width: "width", height: "height", src: "image" },
|
|
117
118
|
video: {
|
|
118
119
|
src: "url",
|
|
@@ -148,14 +149,14 @@ const Vt = ct((s) => {
|
|
|
148
149
|
form: {
|
|
149
150
|
action: "action"
|
|
150
151
|
}
|
|
151
|
-
},
|
|
152
|
+
}, Nt = (s, n) => {
|
|
152
153
|
var t;
|
|
153
154
|
return ((t = s.children) == null ? void 0 : t.length) === 1 && B(
|
|
154
155
|
["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
|
|
155
156
|
n._type
|
|
156
157
|
);
|
|
157
|
-
},
|
|
158
|
-
const n =
|
|
158
|
+
}, q = (s) => s.map((n) => n.type === "text" ? y(n, "content", "") : _(n.children) ? "" : q(n.children || [])).join(""), W = (s) => s === null ? "" : s, ot = (s) => {
|
|
159
|
+
const n = gt(bt(s.split(/\s+/), xt)), t = m(n, (l) => /^w-/.test(l)), e = m(n, (l) => /^h-/.test(l));
|
|
159
160
|
if (!e || !t) return { height: "", width: "" };
|
|
160
161
|
const a = (l) => {
|
|
161
162
|
if (!l) return;
|
|
@@ -171,11 +172,11 @@ const Vt = ct((s) => {
|
|
|
171
172
|
};
|
|
172
173
|
}, et = (s) => {
|
|
173
174
|
if (s.tagName === "svg") return {};
|
|
174
|
-
const n = {}, t =
|
|
175
|
-
return
|
|
175
|
+
const n = {}, t = St[s.tagName || ""] || {}, e = s.attributes || [];
|
|
176
|
+
return S(e, ({ key: a, value: o }) => {
|
|
176
177
|
var i;
|
|
177
178
|
if (!B(nt, a))
|
|
178
|
-
if (a === "bid" && (n._bid =
|
|
179
|
+
if (a === "bid" && (n._bid = W(o)), t[a]) {
|
|
179
180
|
if (s.tagName === "img" && a === "src" && !o.startsWith("http")) {
|
|
180
181
|
const l = m(s.attributes, { key: "width" }), u = m(s.attributes, { key: "height" });
|
|
181
182
|
l && u ? o = `https://picsum.photos/${l == null ? void 0 : l.value}x${u == null ? void 0 : u.value}` : o = "https://picsum.photos/150x150";
|
|
@@ -183,8 +184,8 @@ const Vt = ct((s) => {
|
|
|
183
184
|
const l = m(s.attributes, { key: "href" });
|
|
184
185
|
l && typeof (l == null ? void 0 : l.value) == "string" && ((i = l == null ? void 0 : l.value) != null && i.startsWith("pageType:")) && w(n, "link.type", "pageType");
|
|
185
186
|
}
|
|
186
|
-
w(n, t[a],
|
|
187
|
-
} else B(["style", "class", "srcset", "bid"], a) || (n.styles_attrs = n.styles_attrs || {}, k(a, "@") && (a = a.replace("@", "x-on:")), n.styles_attrs[`${a}`] =
|
|
187
|
+
w(n, t[a], W(o));
|
|
188
|
+
} else B(["style", "class", "srcset", "bid"], a) || (n.styles_attrs = n.styles_attrs || {}, k(a, "@") && (a = a.replace("@", "x-on:")), n.styles_attrs[`${a}`] = W(o));
|
|
188
189
|
}), delete n.class, n;
|
|
189
190
|
}, It = (s, n = "styles") => {
|
|
190
191
|
if (!s.attributes) return { [n]: `${x},` };
|
|
@@ -194,7 +195,7 @@ const Vt = ct((s) => {
|
|
|
194
195
|
return { [n]: `${x},${e}` };
|
|
195
196
|
}
|
|
196
197
|
return { [n]: `${x},` };
|
|
197
|
-
},
|
|
198
|
+
}, Ct = (s) => {
|
|
198
199
|
const n = y(s, "attributes", []), t = n.find((r) => r.key === "data-chai-richtext" || r.key === "chai-richtext"), e = n.find((r) => r.key === "data-chai-lightbox" || r.key === "chai-lightbox"), a = n.find((r) => r.key === "data-chai-dropdown" || r.key === "chai-dropdown"), o = n.find(
|
|
199
200
|
(r) => r.key === "data-chai-dropdown-button" || r.key === "chai-dropdown-button"
|
|
200
201
|
), i = n.find(
|
|
@@ -292,29 +293,29 @@ const Vt = ct((s) => {
|
|
|
292
293
|
return {
|
|
293
294
|
_type: r,
|
|
294
295
|
tag: s.tagName,
|
|
295
|
-
_name: r == "EmptyBox" || s.tagName === "div" ? r :
|
|
296
|
+
_name: r == "EmptyBox" || s.tagName === "div" ? r : mt(s.tagName)
|
|
296
297
|
};
|
|
297
298
|
}
|
|
298
299
|
}
|
|
299
|
-
},
|
|
300
|
-
var
|
|
300
|
+
}, R = (s, n = null) => dt(s, (t) => {
|
|
301
|
+
var M, V, J, O, z, F, U, Y, K, X;
|
|
301
302
|
if (t.type === "comment") return [];
|
|
302
|
-
let e = { _id:
|
|
303
|
+
let e = { _id: ct() };
|
|
303
304
|
if (n && (e._parent = n.block._id), t.type === "text")
|
|
304
|
-
return _(y(t, "content", "")) ? [] : n &&
|
|
305
|
+
return _(y(t, "content", "")) ? [] : n && Nt(n.node, n.block) ? (w(n, "block.content", y(t, "content", "")), []) : { ...e, _type: "Text", content: y(t, "content", "") };
|
|
305
306
|
if (k(t.tagName, "chai-")) {
|
|
306
|
-
const c = t.attributes || [], p = m(c, { key: "chai-type" }), d = (p == null ? void 0 : p.value) ||
|
|
307
|
-
e._type = d,
|
|
307
|
+
const c = t.attributes || [], p = m(c, { key: "chai-type" }), d = (p == null ? void 0 : p.value) || yt(Q(t.tagName || "")).replace(/ /g, "").replace(/\s+/g, "");
|
|
308
|
+
e._type = d, S(c, ({ key: g, value: Z }) => {
|
|
308
309
|
if (g === "about-this-component" || g === "chai-type" || g === "can-move" || g === "can-delete") return;
|
|
309
310
|
if (g === "id") {
|
|
310
311
|
e._id = Z;
|
|
311
312
|
return;
|
|
312
313
|
}
|
|
313
|
-
const lt = k(g, "_") ? g :
|
|
314
|
-
let
|
|
315
|
-
typeof
|
|
314
|
+
const lt = k(g, "_") ? g : Q(g);
|
|
315
|
+
let N = W(Z);
|
|
316
|
+
typeof N == "string" && k(N, "#styles:") && (N = N.replace("#styles:", "#styles:,")), e[lt] = N;
|
|
316
317
|
});
|
|
317
|
-
const h =
|
|
318
|
+
const h = R(t.children || [], { block: e, node: t });
|
|
318
319
|
return [e, ...h];
|
|
319
320
|
}
|
|
320
321
|
const a = y(t, "attributes", []), o = t.tagName === "p" || a.find((c) => c.key === "data-chai-richtext" || c.key === "chai-richtext"), i = a.find((c) => c.key === "class"), l = i && i.value.split(/\s+/).includes("rte"), u = a.find(
|
|
@@ -323,12 +324,12 @@ const Vt = ct((s) => {
|
|
|
323
324
|
(c) => c.key === "data-chai-dropdown" || c.key === "chai-dropdown"
|
|
324
325
|
), T = a.find(
|
|
325
326
|
(c) => c.key === "data-chai-dropdown-button" || c.key === "chai-dropdown-button"
|
|
326
|
-
),
|
|
327
|
+
), C = a.find(
|
|
327
328
|
(c) => c.key === "data-chai-dropdown-content" || c.key === "chai-dropdown-content"
|
|
328
329
|
);
|
|
329
330
|
if (e = {
|
|
330
331
|
...e,
|
|
331
|
-
...
|
|
332
|
+
...Ct(t),
|
|
332
333
|
...et(t),
|
|
333
334
|
...It(t)
|
|
334
335
|
}, t.attributes) {
|
|
@@ -336,7 +337,7 @@ const Vt = ct((s) => {
|
|
|
336
337
|
c && (e._name = c.value);
|
|
337
338
|
}
|
|
338
339
|
if (o || l)
|
|
339
|
-
return e.content = `<p>${
|
|
340
|
+
return e.content = `<p>${D(t.children || [])}</p>`, H(e, "styles_attrs.data-chai-richtext") && delete e.styles_attrs["data-chai-richtext"], H(e, "styles_attrs.chai-richtext") && delete e.styles_attrs["chai-richtext"], [e];
|
|
340
341
|
if (u) {
|
|
341
342
|
const c = [
|
|
342
343
|
"data-chai-lightbox",
|
|
@@ -350,29 +351,29 @@ const Vt = ct((s) => {
|
|
|
350
351
|
];
|
|
351
352
|
e = {
|
|
352
353
|
...e,
|
|
353
|
-
href: ((
|
|
354
|
-
hrefType: ((
|
|
355
|
-
autoplay: ((
|
|
356
|
-
maxWidth: ((z = (
|
|
354
|
+
href: ((M = a.find((p) => p.key === "href")) == null ? void 0 : M.value) || "",
|
|
355
|
+
hrefType: ((V = a.find((p) => p.key === "data-vbtype")) == null ? void 0 : V.value) || "video",
|
|
356
|
+
autoplay: ((J = a.find((p) => p.key === "data-autoplay")) == null ? void 0 : J.value) === "true" ? "true" : "false",
|
|
357
|
+
maxWidth: ((z = (O = a.find((p) => p.key === "data-maxwidth")) == null ? void 0 : O.value) == null ? void 0 : z.replace("px", "")) || "",
|
|
357
358
|
backdropColor: ((F = a.find((p) => p.key === "data-overlay")) == null ? void 0 : F.value) || "",
|
|
358
359
|
galleryName: ((U = a.find((p) => p.key === "data-gall")) == null ? void 0 : U.value) || ""
|
|
359
|
-
},
|
|
360
|
-
|
|
360
|
+
}, S(c, (p) => {
|
|
361
|
+
H(e, `styles_attrs.${p}`) && delete e.styles_attrs[p];
|
|
361
362
|
});
|
|
362
363
|
}
|
|
363
|
-
if (r && (delete e.styles_attrs, e.showDropdown = !1),
|
|
364
|
+
if (r && (delete e.styles_attrs, e.showDropdown = !1), C && delete e.styles_attrs, T) {
|
|
364
365
|
delete e.styles_attrs;
|
|
365
|
-
const c =
|
|
366
|
-
e.content =
|
|
366
|
+
const c = tt(t.children || [], (d) => (d == null ? void 0 : d.tagName) !== "span");
|
|
367
|
+
e.content = q(c);
|
|
367
368
|
const p = m(
|
|
368
369
|
t.children || [],
|
|
369
|
-
(d) => (d == null ? void 0 : d.tagName) === "span" &&
|
|
370
|
+
(d) => (d == null ? void 0 : d.tagName) === "span" && ht(d.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg")
|
|
370
371
|
);
|
|
371
372
|
if (p) {
|
|
372
373
|
const d = m(p.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg");
|
|
373
374
|
if (d) {
|
|
374
|
-
e.icon =
|
|
375
|
-
const { height: h, width: g } =
|
|
375
|
+
e.icon = D([d]);
|
|
376
|
+
const { height: h, width: g } = Dt(d, "16px", "16px");
|
|
376
377
|
e.iconHeight = h, e.iconWidth = g;
|
|
377
378
|
}
|
|
378
379
|
}
|
|
@@ -382,25 +383,25 @@ const Vt = ct((s) => {
|
|
|
382
383
|
const c = e.inputType || "text";
|
|
383
384
|
c === "checkbox" ? w(e, "_type", "Checkbox") : c === "radio" && w(e, "_type", "Radio");
|
|
384
385
|
} else if (t.tagName === "video" || t.tagName === "iframe") {
|
|
385
|
-
const c =
|
|
386
|
+
const c = D([t]);
|
|
386
387
|
return Et(c) && (w(e, "_type", "Video"), w(e, "url", $t(c)), w(e, "styles", `${x},`), w(e, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), e.content = c, [e];
|
|
387
388
|
} else if (t.tagName === "svg") {
|
|
388
389
|
const c = y(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: d } = ot(c);
|
|
389
390
|
if (p && d)
|
|
390
|
-
e.styles = `${x}, ${
|
|
391
|
+
e.styles = `${x}, ${j(`w-${d} h-${p}`, c)}`.trim(), e.height = p == null ? void 0 : p.replace("px", ""), e.width = d == null ? void 0 : d.replace("px", "");
|
|
391
392
|
else {
|
|
392
393
|
const h = (Y = m(t.attributes, { key: "height" })) == null ? void 0 : Y.value, g = (K = m(t.attributes, { key: "width" })) == null ? void 0 : K.value;
|
|
393
|
-
h && g ? (e.styles = `${x}, ${
|
|
394
|
+
h && g ? (e.styles = `${x}, ${j(`w-[${g}px] h-[${h}px]`, c)}`.trim(), e.height = h, e.width = g) : e.styles = `${x}, ${j("w-full h-full", c)}`.trim();
|
|
394
395
|
}
|
|
395
|
-
return t.attributes =
|
|
396
|
+
return t.attributes = tt(t.attributes, (h) => !B(["style", "width", "height", "class"], h.key)), e.icon = D([t]), [e];
|
|
396
397
|
} else if (t.tagName == "option" && n && ((X = n.block) == null ? void 0 : X._type) === "Select")
|
|
397
398
|
return n.block.options.push({
|
|
398
|
-
label:
|
|
399
|
+
label: q(t.children || []),
|
|
399
400
|
...et(t)
|
|
400
401
|
}), [];
|
|
401
|
-
const E =
|
|
402
|
+
const E = R(t.children || [], { block: e, node: t });
|
|
402
403
|
return [e, ...E];
|
|
403
|
-
}),
|
|
404
|
+
}), Dt = (s, n, t) => {
|
|
404
405
|
var u, r;
|
|
405
406
|
const e = y(s, "attributes", []), { height: a, width: o } = ot(
|
|
406
407
|
y(m(e, { key: "class" }), "value", "")
|
|
@@ -422,14 +423,14 @@ const Vt = ct((s) => {
|
|
|
422
423
|
}), s = s.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, ""), s = s.replace(/\$name="[^"]*"/g, "");
|
|
423
424
|
const n = s.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
424
425
|
return (n && n.length > 0 ? n[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : s).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
|
|
425
|
-
},
|
|
426
|
-
const n =
|
|
426
|
+
}, zt = (s) => {
|
|
427
|
+
const n = kt(Lt(s));
|
|
427
428
|
if (_(s)) return [];
|
|
428
|
-
const t =
|
|
429
|
-
return
|
|
429
|
+
const t = ut(R(n));
|
|
430
|
+
return wt(t);
|
|
430
431
|
}, f = (s, n) => s.map((t) => {
|
|
431
|
-
const e =
|
|
432
|
-
return
|
|
432
|
+
const e = A(t).filter((a) => $(t[a]) && t[a].startsWith(x));
|
|
433
|
+
return ft(e, (a) => {
|
|
433
434
|
t[a] = `${x},${at(t[a], n)}`;
|
|
434
435
|
}), t;
|
|
435
436
|
});
|
|
@@ -552,7 +553,7 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
552
553
|
});
|
|
553
554
|
});
|
|
554
555
|
const v = (s) => {
|
|
555
|
-
const n =
|
|
556
|
+
const n = _t(s);
|
|
556
557
|
return s.map((t) => {
|
|
557
558
|
const e = Object.keys(t);
|
|
558
559
|
for (let a = 0; a < e.length; a++)
|
|
@@ -625,8 +626,8 @@ const b = (s, n, { index: t, key: e }, a) => {
|
|
|
625
626
|
if (l) {
|
|
626
627
|
const u = a === "image" || a === "mobileImage";
|
|
627
628
|
l.forEach((r) => {
|
|
628
|
-
let T = r.slice(2, -2).trim(),
|
|
629
|
-
t !== -1 && k(T, "$index.") ? T = `${
|
|
629
|
+
let T = r.slice(2, -2).trim(), C = e.slice(2, -2).trim();
|
|
630
|
+
t !== -1 && k(T, "$index.") ? T = `${C}.${t}.${T.slice(7)}` : t !== -1 && k(T, "$index") && (T = `${C}.${t}`);
|
|
630
631
|
const E = y(n, T);
|
|
631
632
|
E === void 0 ? o = o.replace(r, "") : u && !I(E) ? o = E : o = I(E) ? E : o.replace(r, E);
|
|
632
633
|
});
|
|
@@ -637,7 +638,7 @@ const b = (s, n, { index: t, key: e }, a) => {
|
|
|
637
638
|
return s.map((o) => b(o, n, { index: t, key: e }, a));
|
|
638
639
|
if (s && typeof s == "object") {
|
|
639
640
|
const o = {};
|
|
640
|
-
return
|
|
641
|
+
return S(A(s), (i) => {
|
|
641
642
|
!k(i, "_") && i !== "$repeaterItemsKey" ? o[i] = b(
|
|
642
643
|
s[i],
|
|
643
644
|
n,
|
|
@@ -648,8 +649,8 @@ const b = (s, n, { index: t, key: e }, a) => {
|
|
|
648
649
|
}
|
|
649
650
|
return s;
|
|
650
651
|
}, L = (s, n, { index: t, key: e }) => {
|
|
651
|
-
let a =
|
|
652
|
-
return a.repeaterItems && (a.$repeaterItemsKey = a.repeaterItems, k(a.repeaterItems, `{{${
|
|
652
|
+
let a = P(s);
|
|
653
|
+
return a.repeaterItems && (a.$repeaterItemsKey = a.repeaterItems, k(a.repeaterItems, `{{${rt}`) && (a.$repeaterItemsKey = a.repeaterItems = `${a.repeaterItems.replace("}}", `/${a._id}}}`)}`), !_(a.repeaterItems) && a.pagination && (a.repeaterTotalItems = `${a.repeaterItems.replace("}}", `/${a._id}/totalItems}}`)}`)), b(a, n, { index: t, key: e });
|
|
653
654
|
};
|
|
654
655
|
import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
655
656
|
it("should handle string values with bindings", () => {
|
|
@@ -823,19 +824,14 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
823
824
|
});
|
|
824
825
|
}));
|
|
825
826
|
export {
|
|
826
|
-
Bt as C,
|
|
827
|
-
tt as D,
|
|
828
|
-
qt as R,
|
|
829
|
-
x as S,
|
|
830
827
|
L as a,
|
|
831
|
-
|
|
828
|
+
Pt as b,
|
|
832
829
|
Mt as c,
|
|
833
830
|
Vt as d,
|
|
834
831
|
Jt as e,
|
|
835
832
|
v as f,
|
|
836
|
-
|
|
837
|
-
|
|
833
|
+
zt as g,
|
|
834
|
+
Ot as h,
|
|
838
835
|
f as i,
|
|
839
|
-
st as j
|
|
840
|
-
Ht as k
|
|
836
|
+
st as j
|
|
841
837
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const m=require("./STRINGS-FNnfjF5H.cjs"),T=require("./common-functions-B3a4xKt_.cjs"),e=require("lodash-es"),f=require("himalaya"),P=require("./core-8lkXy4lC.cjs"),O=require("tailwind-merge"),R=t=>{if(t=t.replace(m.STYLES_KEY,""),!t)return{baseClasses:"",classes:""};const l=t.split(/,(?![^\[]*\])/);if(l.length===1)return{baseClasses:"",classes:l[0].trim()};const[n,...s]=l;return{baseClasses:n.trim(),classes:s.join(",").trim().replace(/ +(?= )/g,"")}};function F(t,l,n){const s=e.get(n,"i18nProps",[]);if(e.isEmpty(l)||e.isEmpty(s))return t;const a=e.cloneDeep(t);return e.forEach(e.keys(a),o=>{if(e.includes(s,o)&&!e.isEmpty(l)){const r=e.get(a,o),i=e.get(a,`${o}-${l}`,"");e.isString(r)?a[o]=e.isString(i)&&!e.isEmpty(i.trim())&&i.trimStart()||r:a[o]=e.isEmpty(i)?r:i}}),a}const Y=(t,l)=>{const{baseClasses:n,classes:s}=R(t),o=s.split(" ").filter(i=>i.startsWith(m.DESIGN_TOKEN_PREFIX)).map(i=>{var d;return(d=l[i])==null?void 0:d.value}),r=s.split(" ").filter(i=>!i.startsWith(m.DESIGN_TOKEN_PREFIX)).join(" ");return O.twMerge.apply(null,[n,...o,r])};function K(t,l){return e.get(t,`${l}_attrs`,{})}function z(t,l=!0,n={}){const s={};return Object.keys(t).forEach(a=>{if(e.isString(t[a])&&t[a].startsWith(m.STYLES_KEY)){const o=Y(t[a],n),r=K(t,a);s[a]={...!e.isEmpty(o)&&{className:o},...r,...l?{"data-style-prop":a,"data-block-parent":t._id,"data-style-id":`${a}-${t._id}`}:{}}}}),s}const U=e.memoize(t=>{const l=P.getRegisteredChaiBlock(t),n=e.get(l,"schema.properties",{});return Object.fromEntries(Object.entries(n).filter(([,s])=>e.get(s,"runtime",!1)))}),G=(t,l)=>{if(!e.isArray(t))return t;let n=t,s;return typeof l.limit=="number"&&l.limit>0&&(s=l.limit),s!==void 0&&(n=n.slice(0,s)),n},X=(t,l)=>{const n=e.cloneDeep(t);return e.forEach(e.keys(n),s=>{if(e.isString(n[s])&&!e.startsWith(s,"_")){let a=n[s];s==="repeaterItems"&&(n.repeaterItemsBinding=a);const o=/\{\{(.*?)\}\}/g,r=a.match(o);r&&r.forEach(i=>{let d=i.slice(2,-2);const c=e.get(l,d,i);a=e.isArray(c)?c:a.replace(i,c)}),n[s]=a}}),n},Z=t=>{const l=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,n=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return l.test(t)||n.test(t)},Q=t=>{if(e.isEmpty(t))return t;const l=/<video[^>]+src=['"]([^'">]+)['"]/,n=/<iframe[^>]+src=['"]([^'">]+)['"]/,s=t.match(l),a=t.match(n),o=s?s[1]:a?a[1]:null,r=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,i=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return o&&(r.test(o)||i.test(o))?o:t},H=["chai-name","data-chai-name"],ee={img:{alt:"alt",width:"width",height:"height",src:"image"},video:{src:"url",autoplay:"controls.autoPlay",muted:"controls.muted",loop:"controls.loop",controls:"controls.widgets"},a:{href:"link.href",target:"link.target",type:""},input:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},textarea:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},select:{placeholder:"placeholder",required:"required",multiple:"multiple",name:"fieldName"},form:{action:"action"}},te=(t,l)=>{var n;return((n=t.children)==null?void 0:n.length)===1&&e.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link","RichText"],l._type)},v=t=>t.map(l=>l.type==="text"?e.get(l,"content",""):e.isEmpty(l.children)?"":v(l.children||[])).join(""),B=t=>t===null?"":t,M=t=>{const l=e.compact(e.map(t.split(/\s+/),e.trim)),n=e.find(l,i=>/^w-/.test(i)),s=e.find(l,i=>/^h-/.test(i));if(!s||!n)return{height:"",width:""};const a=i=>{if(!i)return;const d=i.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);if(!d)return;if(d[1])return d[1];const c=d[2];return/^\d+(\.\d+)?$/.test(c)?`${Number(c)*4}px`:c==="auto"||e.includes(c,"%")?c:"16px"},o=a(n),r=a(s);return{width:e.includes(o,"px")?o:"16px",height:e.includes(r,"px")?r:"16px"}},q=t=>{if(t.tagName==="svg")return{};const l={},n=ee[t.tagName||""]||{},s=t.attributes||[];return e.forEach(s,({key:a,value:o})=>{var r;if(!e.includes(H,a))if(a==="bid"&&(l._bid=B(o)),n[a]){if(t.tagName==="img"&&a==="src"&&!o.startsWith("http")){const i=e.find(t.attributes,{key:"width"}),d=e.find(t.attributes,{key:"height"});i&&d?o=`https://picsum.photos/${i==null?void 0:i.value}x${d==null?void 0:d.value}`:o="https://picsum.photos/150x150"}else if(t.tagName==="a"){const i=e.find(t.attributes,{key:"href"});i&&typeof(i==null?void 0:i.value)=="string"&&((r=i==null?void 0:i.value)!=null&&r.startsWith("pageType:"))&&e.set(l,"link.type","pageType")}e.set(l,n[a],B(o))}else e.includes(["style","class","srcset","bid"],a)||(l.styles_attrs=l.styles_attrs||{},e.startsWith(a,"@")&&(a=a.replace("@","x-on:")),l.styles_attrs[`${a}`]=B(o))}),delete l.class,l},se=(t,l="styles")=>{if(!t.attributes)return{[l]:`${m.STYLES_KEY},`};const n=e.find(t.attributes,{key:"class"});if(n){const s=n.value;return{[l]:`${m.STYLES_KEY},${s}`}}return{[l]:`${m.STYLES_KEY},`}},ne=t=>{const l=e.get(t,"attributes",[]),n=l.find(c=>c.key==="data-chai-richtext"||c.key==="chai-richtext"),s=l.find(c=>c.key==="data-chai-lightbox"||c.key==="chai-lightbox"),a=l.find(c=>c.key==="data-chai-dropdown"||c.key==="chai-dropdown"),o=l.find(c=>c.key==="data-chai-dropdown-button"||c.key==="chai-dropdown-button"),r=l.find(c=>c.key==="data-chai-dropdown-content"||c.key==="chai-dropdown-content"),i=l.find(c=>c.key==="class"),d=i&&i.value.split(/\s+/).includes("rte");if(a)return{_type:"Dropdown"};if(o)return{_type:"DropdownButton"};if(r)return{_type:"DropdownContent"};if(n||d)return{_type:"Paragraph"};if(s)return{_type:"LightBoxLink"};switch(t.tagName){case"img":return{_type:"Image"};case"input":return{_type:"Input",showLabel:!1};case"hr":return{_type:"Divider"};case"br":return{_type:"LineBreak"};case"textarea":return{_type:"TextArea",showLabel:!1};case"audio":return{_type:"Audio"};case"canvas":return{_type:"Canvas"};case"video":case"iframe":return{_type:"CustomHTML"};case"svg":return{_type:"Icon"};case"select":return{_type:"Select",options:[]};case"option":return{_type:"Option"};case"ul":case"ol":case"dl":return{_type:"List",tag:t.tagName,_listType:t.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:t.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:t.tagName};case"p":return{_type:"Paragraph",content:""};case"a":return{_type:"Link"};case"form":return{_type:"Form"};case"label":return{_type:"Label"};case"button":return{_type:"Button"};case"code":return{_type:"Box",_name:"Code"};case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return{_type:"Heading",tag:t.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:t.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:{const c=e.get(t,"children",[]).length>0?"Box":"EmptyBox";return{_type:c,tag:t.tagName,_name:c=="EmptyBox"||t.tagName==="div"?c:e.capitalize(t.tagName)}}}},E=(t,l=null)=>e.flatMapDeep(t,n=>{var S,D,$,C,I,N,L,W,A,j;if(n.type==="comment")return[];let s={_id:T.generateUUID()};if(l&&(s._parent=l.block._id),n.type==="text")return e.isEmpty(e.get(n,"content",""))?[]:l&&te(l.node,l.block)?(e.set(l,"block.content",e.get(n,"content","")),[]):{...s,_type:"Text",content:e.get(n,"content","")};if(e.startsWith(n.tagName,"chai-")){const p=n.attributes||[],u=e.find(p,{key:"chai-type"}),y=(u==null?void 0:u.value)||e.startCase(e.camelCase(n.tagName||"")).replace(/ /g,"").replace(/\s+/g,"");s._type=y,e.forEach(p,({key:h,value:V})=>{if(h==="about-this-component"||h==="chai-type"||h==="can-move"||h==="can-delete")return;if(h==="id"){s._id=V;return}const J=e.startsWith(h,"_")?h:e.camelCase(h);let k=B(V);typeof k=="string"&&e.startsWith(k,"#styles:")&&(k=k.replace("#styles:","#styles:,")),s[J]=k});const g=E(n.children||[],{block:s,node:n});return[s,...g]}const a=e.get(n,"attributes",[]),o=n.tagName==="p"||a.find(p=>p.key==="data-chai-richtext"||p.key==="chai-richtext"),r=a.find(p=>p.key==="class"),i=r&&r.value.split(/\s+/).includes("rte"),d=a.find(p=>p.key==="data-chai-lightbox"||p.key==="chai-lightbox"),c=a.find(p=>p.key==="data-chai-dropdown"||p.key==="chai-dropdown"),b=a.find(p=>p.key==="data-chai-dropdown-button"||p.key==="chai-dropdown-button"),_=a.find(p=>p.key==="data-chai-dropdown-content"||p.key==="chai-dropdown-content");if(s={...s,...ne(n),...q(n),...se(n)},n.attributes){const p=n.attributes.find(u=>e.includes(H,u.key));p&&(s._name=p.value)}if(o||i)return s.content=`<p>${f.stringify(n.children||[])}</p>`,e.has(s,"styles_attrs.data-chai-richtext")&&delete s.styles_attrs["data-chai-richtext"],e.has(s,"styles_attrs.chai-richtext")&&delete s.styles_attrs["chai-richtext"],[s];if(d){const p=["data-chai-lightbox","chai-lightbox","data-vbtype","data-autoplay","data-maxwidth","data-overlay","data-gall","href"];s={...s,href:((S=a.find(u=>u.key==="href"))==null?void 0:S.value)||"",hrefType:((D=a.find(u=>u.key==="data-vbtype"))==null?void 0:D.value)||"video",autoplay:(($=a.find(u=>u.key==="data-autoplay"))==null?void 0:$.value)==="true"?"true":"false",maxWidth:((I=(C=a.find(u=>u.key==="data-maxwidth"))==null?void 0:C.value)==null?void 0:I.replace("px",""))||"",backdropColor:((N=a.find(u=>u.key==="data-overlay"))==null?void 0:N.value)||"",galleryName:((L=a.find(u=>u.key==="data-gall"))==null?void 0:L.value)||""},e.forEach(p,u=>{e.has(s,`styles_attrs.${u}`)&&delete s.styles_attrs[u]})}if(c&&(delete s.styles_attrs,s.showDropdown=!1),_&&delete s.styles_attrs,b){delete s.styles_attrs;const p=e.filter(n.children||[],y=>(y==null?void 0:y.tagName)!=="span");s.content=v(p);const u=e.find(n.children||[],y=>(y==null?void 0:y.tagName)==="span"&&e.some(y.children||[],g=>(g==null?void 0:g.tagName)==="svg"));if(u){const y=e.find(u.children||[],g=>(g==null?void 0:g.tagName)==="svg");if(y){s.icon=f.stringify([y]);const{height:g,width:h}=ae(y,"16px","16px");s.iconHeight=g,s.iconWidth=h}}return[s]}if(s._type==="Input"){const p=s.inputType||"text";p==="checkbox"?e.set(s,"_type","Checkbox"):p==="radio"&&e.set(s,"_type","Radio")}else if(n.tagName==="video"||n.tagName==="iframe"){const p=f.stringify([n]);return Z(p)&&(e.set(s,"_type","Video"),e.set(s,"url",Q(p)),e.set(s,"styles",`${m.STYLES_KEY},`),e.set(s,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),s.content=p,[s]}else if(n.tagName==="svg"){const p=e.get(e.find(n.attributes,{key:"class"}),"value",""),{height:u,width:y}=M(p);if(u&&y)s.styles=`${m.STYLES_KEY}, ${T.cn(`w-${y} h-${u}`,p)}`.trim(),s.height=u==null?void 0:u.replace("px",""),s.width=y==null?void 0:y.replace("px","");else{const g=(W=e.find(n.attributes,{key:"height"}))==null?void 0:W.value,h=(A=e.find(n.attributes,{key:"width"}))==null?void 0:A.value;g&&h?(s.styles=`${m.STYLES_KEY}, ${T.cn(`w-[${h}px] h-[${g}px]`,p)}`.trim(),s.height=g,s.width=h):s.styles=`${m.STYLES_KEY}, ${T.cn("w-full h-full",p)}`.trim()}return n.attributes=e.filter(n.attributes,g=>!e.includes(["style","width","height","class"],g.key)),s.icon=f.stringify([n]),[s]}else if(n.tagName=="option"&&l&&((j=l.block)==null?void 0:j._type)==="Select")return l.block.options.push({label:v(n.children||[]),...q(n)}),[];const x=E(n.children||[],{block:s,node:n});return[s,...x]}),ae=(t,l,n)=>{var d,c;const s=e.get(t,"attributes",[]),{height:a,width:o}=M(e.get(e.find(s,{key:"class"}),"value",""));if(a&&o)return{height:`[${a}px]`,width:`[${o}px]`};const r=(d=e.find(s,{key:"height"}))==null?void 0:d.value,i=(c=e.find(s,{key:"width"}))==null?void 0:c.value;return{height:r?`[${r}px]`:n,width:i?`[${i}px]`:l}},le=t=>{t=t.replace(/(\w+)=\\?"(.*?)\\?"/g,(s,a,o)=>{let r=o.replace(/\\"/g,'"');return r=r.replace(/{([^}]+)}/g,i=>i.replace(/"/g,'\\"')),`${a}="${r.replace(/\\"/g,'"')}"`}),t=t.replace(/\\n/g,"").replace(/\\\\/g,"").replace(/\\([/<>])/g,"$1").replace(/\\./g,"").replace(/[\n\r\t\f\v]/g,""),t=t.replace(/\$name="[^"]*"/g,"");const l=t.match(/<body[^>]*>[\s\S]*?<\/body>/);return(l&&l.length>0?l[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):t).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},oe=t=>{const l=f.parse(le(t));if(e.isEmpty(t))return[];const n=e.flatten(E(l));return P.syncBlocksWithDefaults(n)},ie=(t,l)=>t.map(n=>{const s=e.keys(n).filter(a=>e.isString(n[a])&&n[a].startsWith(m.STYLES_KEY));return e.each(s,a=>{n[a]=`${m.STYLES_KEY},${Y(n[a],l)}`}),n}),re=t=>{const l=e.last(t);return t.map(n=>{const s=Object.keys(n);for(let a=0;a<s.length;a++)if(e.isString(n[s[a]])&&e.startsWith(s[a],"content")){const o=n===l?"":" ";n[s[a]]=`${n[s[a]].trim()}${o}`}return n})},w=(t,l,{index:n,key:s},a)=>{if(e.isString(t)){let o=t;const r=/\{\{(.*?)\}\}/g,i=t.match(r);if(i){const d=a==="image"||a==="mobileImage";i.forEach(c=>{let b=c.slice(2,-2).trim(),_=s.slice(2,-2).trim();n!==-1&&e.startsWith(b,"$index.")?b=`${_}.${n}.${b.slice(7)}`:n!==-1&&e.startsWith(b,"$index")&&(b=`${_}.${n}`);const x=e.get(l,b);x===void 0?o=o.replace(c,""):d&&!e.isArray(x)?o=x:o=e.isArray(x)?x:o.replace(c,x)})}return o}if(e.isArray(t))return t.map(o=>w(o,l,{index:n,key:s},a));if(t&&typeof t=="object"){const o={};return e.forEach(e.keys(t),r=>{!e.startsWith(r,"_")&&r!=="$repeaterItemsKey"?o[r]=w(t[r],l,{index:n,key:s},r):o[r]=t[r]}),o}return t},ce=(t,l,{index:n,key:s})=>{let a=e.cloneDeep(t);return a.repeaterItems&&(a.$repeaterItemsKey=a.repeaterItems,e.startsWith(a.repeaterItems,`{{${m.COLLECTION_PREFIX}`)&&(a.$repeaterItemsKey=a.repeaterItems=`${a.repeaterItems.replace("}}",`/${a._id}}}`)}`),!e.isEmpty(a.repeaterItems)&&a.pagination&&(a.repeaterTotalItems=`${a.repeaterItems.replace("}}",`/${a._id}/totalItems}}`)}`)),w(a,l,{index:n,key:s})};exports.adjustSpacingInContentBlocks=re;exports.applyBindingToBlockProps=ce;exports.applyChaiDataBinding=X;exports.applyDesignTokens=ie;exports.applyLanguage=F;exports.applyLimit=G;exports.getBlockRuntimeProps=U;exports.getBlockTagAttributes=z;exports.getBlocksFromHTML=oe;exports.getSplitChaiClasses=R;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as o, jsxs as d } from "react/jsx-runtime";
|
|
2
|
-
import { u as C, a as k, b as v, c as T, D as g, d as y, e as E, f as w, T as N } from "./index-
|
|
2
|
+
import { u as C, a as k, b as v, c as T, D as g, d as y, e as E, f as w, T as N } from "./index-mjuSGlPU.js";
|
|
3
3
|
import { useThrottledCallback as D } from "@react-hookz/web";
|
|
4
4
|
import { useState as m, useCallback as H, useEffect as P } from "react";
|
|
5
5
|
import { useTranslation as B } from "react-i18next";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),o=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),o=require("./index-BhqugjzS.cjs"),k=require("@react-hookz/web"),c=require("react"),g=require("react-i18next"),x=l=>{const s=document.createElement("div");return s.innerHTML=l,s.innerHTML};function j(){const{t:l}=g.useTranslation(),[s,m]=c.useState(!1),[a,h]=c.useState(""),[e,i]=o.useCodeEditor(),[d]=o.useSelectedBlockIds(),p=o.useUpdateBlocksProps(),b=o.useUpdateBlocksPropsRealtime(),f=k.useThrottledCallback(n=>{if(!e)return;const r=x(n);b([e.blockId],{[e.blockProp]:r})},[],300),u=c.useCallback(()=>{if(s&&e){const n=x(a);p([e.blockId],{[e.blockProp]:n})}},[s,a,e]);c.useEffect(()=>{e&&!d.includes(e.blockId)&&(u(),i(null))},[d,e]);const C=()=>{u(),i(null)};return t.jsx(o.Dialog,{open:!0,onOpenChange:C,children:t.jsxs(o.DialogContent,{className:"flex max-h-[400px] min-h-[200px] max-w-4xl flex-col border-gray-700 text-black",children:[t.jsx(o.DialogHeader,{className:"shrink-0 border-b border-gray-700 pb-3",children:t.jsx(o.DialogTitle,{className:"flex items-center justify-between text-black",children:t.jsxs("div",{className:"space-x-3 text-sm font-semibold",children:[t.jsx("span",{children:l("HTML Code Editor |")}),t.jsx("span",{className:"text-xs text-gray-400",children:l("Scripts will be only executed in preview and live mode.")})]})})}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(o.Textarea,{className:"h-full w-full resize-none font-mono text-xs",value:e?a||e.initialCode:"",onChange:n=>{const r=n.target.value;m(!0),h(r),f(r)},rows:10,placeholder:"Enter your code here..."})})]})})}exports.default=j;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
2
|
import { B as r } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
-
import { R as o, U as c, V as i, W as l, X as m } from "./index-
|
|
4
|
-
import { b as d, B as h } from "./index-
|
|
3
|
+
import { R as o, U as c, V as i, W as l, X as m } from "./index-mjuSGlPU.js";
|
|
4
|
+
import { b as d, B as h } from "./index-Be9lAaD7.js";
|
|
5
5
|
import { CheckCircle as u, Check as p } from "lucide-react";
|
|
6
6
|
import { useTranslation as C } from "react-i18next";
|
|
7
7
|
const y = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./register-chai-top-bar-DWTuRU53.cjs"),s=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./register-chai-top-bar-DWTuRU53.cjs"),s=require("./index-BhqugjzS.cjs"),a=require("./index-CNEEEgTV.cjs"),n=require("lucide-react"),l=require("react-i18next"),o=()=>{const{setPageLockMeta:r}=a.usePageLockMeta(),{t}=l.useTranslation(),c=async()=>{r({})};return e.jsx(a.BlurContainer,{children:e.jsxs(s.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(s.CardHeader,{className:"space-y-1",children:e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(n.CheckCircle,{className:"h-6 w-6 text-green-500"}),t("You can edit the page now")]})}),e.jsx(s.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:t("This page is released by other user you can continue editing now")})}),e.jsx(s.CardFooter,{className:"flex gap-2",children:e.jsxs(i.Button,{variant:"default",onClick:c,className:"flex-1 gap-2",children:[e.jsx(n.Check,{className:"h-4 w-4"}),t("Continue Editing")]})})]})})};exports.default=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("lodash-es"),g=require("react"),c={},B=()=>c,k=e=>g.useMemo(()=>s.get(c,e,null),[e]),l=e=>s.get(c,e,null),a=e=>{const t=s.get(c,`${e}.schema.properties`,{}),r={};return s.each(t,(o,n)=>{s.has(o,"block")||s.set(r,n,o.default)}),r},h=e=>s.get(c,`${e}.i18nProps`,[]),d=e=>s.get(c,`${e}.aiProps`,[]),C=e=>{const t=l(e);if(!t)return null;const r=s.cloneDeep(t.schema),o=s.get(r,"properties",{}),n=s.omitBy(o,i=>(i==null?void 0:i.styles)===!0);s.set(r,"properties",n);const u=s.get(c,`${e}.uiSchema`,{});return{schema:r,uiSchema:u}},f=e=>e.map(t=>s.has(c,t._type)?{...a(t._type),...t}:t),P=(e,t)=>{const r=s.get(c,t.type);r?s.set(c,t.type,{...r,component:e,...t}):s.set(c,t.type,{component:e,...t})},m=(e,t)=>{P(e,{...t,category:t.category||"core"})},y=(e,t)=>{const r=s.get(c,t.type);r?s.set(c,t.type,{...r,component:e,...t}):s.set(c,t.type,{component:e,...t})},p=(e,t)=>{const r=l(e);s.set(c,e,{...r,dataProvider:t})},S=(e,t)=>{const r=l(e);s.set(c,e,{...r,component:t})},R=(e,t)=>({type:"null",block:e,prop:t,default:null,runtime:!0,ui:{"ui:widget":"hidden"}});exports.closestBlockProp=R;exports.getAIBlockProps=d;exports.getBlockFormSchemas=C;exports.getDefaultBlockProps=a;exports.getI18nBlockProps=h;exports.getRegisteredChaiBlock=l;exports.registerChaiBlock=m;exports.registerChaiServerBlock=y;exports.setChaiBlockComponent=S;exports.setChaiServerBlockDataProvider=p;exports.syncBlocksWithDefaults=f;exports.useRegisteredChaiBlock=k;exports.useRegisteredChaiBlocks=B;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { get as c, each as B, has as u, set as o, cloneDeep as k, omitBy as h } from "lodash-es";
|
|
2
|
+
import { useMemo as d } from "react";
|
|
3
|
+
const r = {}, P = () => r, p = (e) => d(() => c(r, e, null), [e]), i = (e) => c(r, e, null), f = (e) => {
|
|
4
|
+
const t = c(r, `${e}.schema.properties`, {}), s = {};
|
|
5
|
+
return B(t, (n, a) => {
|
|
6
|
+
u(n, "block") || o(s, a, n.default);
|
|
7
|
+
}), s;
|
|
8
|
+
}, S = (e) => c(r, `${e}.i18nProps`, []), D = (e) => c(r, `${e}.aiProps`, []), I = (e) => {
|
|
9
|
+
const t = i(e);
|
|
10
|
+
if (!t)
|
|
11
|
+
return null;
|
|
12
|
+
const s = k(t.schema), n = c(s, "properties", {}), a = h(n, (l) => (l == null ? void 0 : l.styles) === !0);
|
|
13
|
+
o(s, "properties", a);
|
|
14
|
+
const g = c(r, `${e}.uiSchema`, {});
|
|
15
|
+
return { schema: s, uiSchema: g };
|
|
16
|
+
}, R = (e) => e.map((t) => u(r, t._type) ? { ...f(t._type), ...t } : t), m = (e, t) => {
|
|
17
|
+
const s = c(r, t.type);
|
|
18
|
+
s ? o(r, t.type, { ...s, component: e, ...t }) : o(r, t.type, { component: e, ...t });
|
|
19
|
+
}, _ = (e, t) => {
|
|
20
|
+
m(e, { ...t, category: t.category || "core" });
|
|
21
|
+
}, $ = (e, t) => {
|
|
22
|
+
const s = c(r, t.type);
|
|
23
|
+
s ? o(r, t.type, { ...s, component: e, ...t }) : o(r, t.type, { component: e, ...t });
|
|
24
|
+
}, v = (e, t) => {
|
|
25
|
+
const s = i(e);
|
|
26
|
+
o(r, e, { ...s, dataProvider: t });
|
|
27
|
+
}, x = (e, t) => {
|
|
28
|
+
const s = i(e);
|
|
29
|
+
o(r, e, { ...s, component: t });
|
|
30
|
+
}, E = (e, t) => ({
|
|
31
|
+
type: "null",
|
|
32
|
+
block: e,
|
|
33
|
+
prop: t,
|
|
34
|
+
default: null,
|
|
35
|
+
runtime: !0,
|
|
36
|
+
ui: { "ui:widget": "hidden" }
|
|
37
|
+
});
|
|
38
|
+
export {
|
|
39
|
+
I as a,
|
|
40
|
+
f as b,
|
|
41
|
+
E as c,
|
|
42
|
+
S as d,
|
|
43
|
+
i as e,
|
|
44
|
+
$ as f,
|
|
45
|
+
D as g,
|
|
46
|
+
x as h,
|
|
47
|
+
R as i,
|
|
48
|
+
P as j,
|
|
49
|
+
_ as r,
|
|
50
|
+
v as s,
|
|
51
|
+
p as u
|
|
52
|
+
};
|