@chaibuilder/sdk 2.2.30 → 2.2.31

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/core.cjs CHANGED
@@ -37,6 +37,8 @@
37
37
  [data-drop="yes"] { outline: 2px dashed orange !important; outline-offset: -2px }
38
38
  [data-dnd="yes"] { pointer-events: auto !important}
39
39
  [data-dnd="no"],[data-block-type="GlobalBlock"],[data-block-type="PartialBlock"] > * { pointer-events: none !important; }
40
+ [data-block-type="GlobalBlock"],[data-block-type="PartialBlock"] { position: relative !important; }
41
+ .partial-overlay { pointer-events: auto !important; }
40
42
  [data-dnd-dragged="yes"] { opacity: 0.6; pointer-events: none; }
41
43
  [data-dnd-dragged="no"] { opacity: 1; pointer-events: auto !important; }
42
44
  [force-show] { display: block !important; }
@@ -56,7 +58,7 @@
56
58
  outline: 1px solid ${n.length>0?"#42a1fc":"#de8f09"} !important; outline-offset: -1px;
57
59
  }`,[o,n]);return jsxRuntime.jsx("style",{id:"selected-styling-blocks",dangerouslySetInnerHTML:{__html:a}})},SelectedBlocks=()=>{const[o]=useSelectedBlockIds(),n=React.useMemo(()=>`${lodashEs.map(o,a=>`[data-block-id="${a}"]`).join(",")}{
58
60
  outline: 1px solid #42a1fc !important; outline-offset: -1px;
59
- }`,[o]);return jsxRuntime.jsx("style",{id:"selected-blocks",dangerouslySetInnerHTML:{__html:n}})},Fonts=()=>{const[o]=useTheme(),n=runtime.useRegisteredFonts(),a=React.useMemo(()=>{const{heading:i,body:c}={heading:lodashEs.get(o,"fontFamily.heading"),body:lodashEs.get(o,"fontFamily.body")};return n.filter(d=>d.family===i||d.family===c)},[o==null?void 0:o.fontFamily,n]),r=React.useMemo(()=>plugin.getThemeFontsUrls(lodashEs.filter(a,i=>lodashEs.has(i,"url"))),[a]),l=React.useMemo(()=>plugin.getThemeCustomFontFace(lodashEs.filter(a,i=>lodashEs.has(i,"src"))),[a]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r.map((i,c)=>jsxRuntime.jsx("link",{rel:"stylesheet",href:i},`google-font-${c}`)),jsxRuntime.jsx("style",{id:"chai-custom-fonts",dangerouslySetInnerHTML:{__html:l}})]})},ResizableCanvasWrapper=({children:o,onMount:n,onResize:a})=>{const[,r]=useSelectedBlockIds(),[,l]=useSelectedStylingBlocks(),i=React.useRef(null),c=web.useDebouncedCallback(()=>{const{clientWidth:p}=i.current;a(p)},[i.current],100);web.useResizeObserver(i.current,c,i.current!==null),React.useEffect(()=>{const{clientWidth:p}=i.current;n(p)},[]);const d=React.useCallback(()=>{r([]),l([])},[r,l]);return jsxRuntime.jsx("div",{id:"main-content",onClick:d,className:"h-full w-full p-8 pb-0",ref:i,children:o})},MayBeAsyncPropsWrapper=({children:o,block:n})=>{const a=React.useMemo(()=>runtime.getRegisteredChaiBlock(n._type),[n._type]),r=lodashEs.get(a,"dataProviderDependencies"),l=lodashEs.get(a,"dataProvider"),i=lodashEs.get(a,"dataProviderMode","mock"),c=useAsyncProps(n,i,r,l);return o(c)},ErrorFallback=()=>jsxRuntime.jsx("div",{className:"flex min-h-[100px] items-center justify-center bg-red-50 p-2 text-center text-red-500",children:"Something went wrong."}),useBlockRuntimeProps=()=>{const[o]=useBlocksStore();return React.useCallback((n,a)=>lodashEs.isEmpty(a)?{}:Object.entries(a).reduce((r,[l,i])=>{const c=[];let d=lodashEs.find(o,{_id:n});for(;d;)c.push(d),d=lodashEs.find(o,{_id:d._parent});const p=lodashEs.find(c,{_type:i.block});return p&&(r[l]=lodashEs.get(p,lodashEs.get(i,"prop"),null)),r},{}),[o])},BUBBLE_MENU_ICONS={bold:reactIcons.FontBoldIcon,italic:reactIcons.FontItalicIcon,underline:reactIcons.UnderlineIcon,strikethrough:reactIcons.StrikethroughIcon,code:reactIcons.CodeIcon,link:reactIcons.Link1Icon,bulletList:reactIcons.ListBulletIcon,orderedList:reactIcons.ListBulletIcon,heading1:reactIcons.HeadingIcon,heading2:reactIcons.HeadingIcon,heading3:reactIcons.HeadingIcon,quote:reactIcons.QuoteIcon,alignLeft:reactIcons.TextAlignLeftIcon,alignCenter:reactIcons.TextAlignCenterIcon,alignRight:reactIcons.TextAlignRightIcon},BubbleMenuButton=({icon:o,title:n,onClick:a,isActive:r})=>{const l=BUBBLE_MENU_ICONS[o];return jsxRuntime.jsx("button",{onClick:a,className:sooner.cn("rounded-md p-1.5 transition-colors duration-200",r?"bg-white/20":"hover:bg-white/10"),title:n,children:jsxRuntime.jsx(l,{className:"h-4 w-4"})})},BubbleMenu=({editor:o})=>{if(!o)return null;const n=()=>{const a=window.prompt("Enter URL");a&&o.chain().focus().setLink({href:a}).run()};return jsxRuntime.jsx("div",{className:"flex items-center overflow-hidden rounded-lg border border-blue-500/20 bg-blue-600 text-white shadow-lg",children:jsxRuntime.jsxs("div",{className:"flex items-center p-1",children:[jsxRuntime.jsx(BubbleMenuButton,{icon:"bold",title:"Bold",onClick:()=>o.chain().focus().toggleBold().run(),isActive:o.isActive("bold")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"italic",title:"Italic",onClick:()=>o.chain().focus().toggleItalic().run(),isActive:o.isActive("italic")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"underline",title:"Underline",onClick:()=>o.chain().focus().toggleUnderline().run(),isActive:o.isActive("underline")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"strikethrough",title:"Strikethrough",onClick:()=>o.chain().focus().toggleStrike().run(),isActive:o.isActive("strike")}),jsxRuntime.jsx("div",{className:"mx-1 h-4 w-[1px] bg-white/20"}),jsxRuntime.jsx(BubbleMenuButton,{icon:"link",title:o.isActive("link")?"Remove link":"Add link",onClick:()=>{o.isActive("link")?o.chain().focus().unsetLink().run():n()},isActive:o.isActive("link")}),jsxRuntime.jsx("div",{className:"mx-1 h-4 w-[1px] bg-white/20"}),jsxRuntime.jsx(BubbleMenuButton,{icon:"bulletList",title:"Bullet list",onClick:()=>o.chain().focus().toggleBulletList().run(),isActive:o.isActive("bulletList")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"orderedList",title:"Numbered list",onClick:()=>o.chain().focus().toggleOrderedList().run(),isActive:o.isActive("orderedList")}),jsxRuntime.jsx("div",{className:"mx-1 h-4 w-[1px] bg-white/20"}),jsxRuntime.jsx(BubbleMenuButton,{icon:"alignLeft",title:"Align left",onClick:()=>o.chain().focus().setTextAlign("left").run(),isActive:o.isActive({textAlign:"left"})}),jsxRuntime.jsx(BubbleMenuButton,{icon:"alignCenter",title:"Align center",onClick:()=>o.chain().focus().setTextAlign("center").run(),isActive:o.isActive({textAlign:"center"})}),jsxRuntime.jsx(BubbleMenuButton,{icon:"alignRight",title:"Align right",onClick:()=>o.chain().focus().setTextAlign("right").run(),isActive:o.isActive({textAlign:"right"})})]})})},RichTextEditor=React.memo(({blockContent:o,editingElement:n,onClose:a,onChange:r,onEscape:l})=>{const{document:i}=useFrame(),c=react.useEditor({editable:!0,content:o,extensions:[StarterKit,Underline,TextAlign.configure({types:["heading","paragraph"]}),Link.configure({openOnClick:!1,HTMLAttributes:{class:"text-blue-500 hover:text-blue-600 underline"}}),Placeholder.configure({placeholder:"Enter text here",emptyEditorClass:"cursor-text before:content-[attr(data-placeholder)] before:absolute before:opacity-50 before:pointer-events-none"})],onUpdate:({editor:u})=>r((u==null?void 0:u.getHTML())||""),onBlur:({editor:u,event:m})=>{const h=m.relatedTarget,x=i.querySelector(".ProseMirror"),g=i.querySelector(".tippy-box"),f=x==null?void 0:x.contains(h),y=g==null?void 0:g.contains(h);if(!f&&!y){const b=(u==null?void 0:u.getHTML())||"";a(b)}}},[]);React.useEffect(()=>{var u;(u=c==null?void 0:c.commands)==null||u.focus(),c==null||c.emit("focus",{editor:c,event:new FocusEvent("focus"),transaction:[]})},[c]);const d=React.useMemo(()=>{var h;const u="max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";if(!n)return u;const m=((h=n==null?void 0:n.className)==null?void 0:h.replace("sr-only",""))||"";return`${u} ${m}`},[n]),p=React.useCallback(u=>{u.key==="Escape"&&l(u)},[l]);return jsxRuntime.jsxs("div",{onKeyDown:p,onClick:u=>u.stopPropagation(),children:[c&&jsxRuntime.jsx(react.BubbleMenu,{editor:c,tippyOptions:{duration:100},children:jsxRuntime.jsx(BubbleMenu,{editor:c})}),jsxRuntime.jsx(react.EditorContent,{editor:c,className:d})]})}),MemoizedEditor=React.memo(({editingElement:o,blockContent:n,onClose:a,editorRef:r,onChange:l,onEscape:i})=>{const{document:c,window:d}=useFrame();React.useEffect(()=>{if(r.current){r.current.innerText=n,r.current.focus();const x=c.createRange(),g=d.getSelection();x.selectNodeContents(r.current),x.collapse(!1),g==null||g.removeAllRanges(),g==null||g.addRange(x),r.current.focus()}else a()},[c,d]);const p=React.useMemo(()=>{var g;const x=((g=o==null?void 0:o.tagName)==null?void 0:g.toLowerCase())||"div";return x==="button"?"div":x},[o]),u=React.useCallback(x=>{(x.key==="Enter"||x.key==="Escape")&&i(x)},[i]),m=React.useCallback(()=>{a()},[a]),h=React.useMemo(()=>{var x;return{id:"active-inline-editing-element",contentEditable:!0,className:`${((x=o==null?void 0:o.className)==null?void 0:x.replace("sr-only",""))||""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,style:lodashEs.cloneDeep(o==null?void 0:o.style)||{},onInput:g=>{const f=g.target;f&&(f.innerText.trim()===""?(f.setAttribute("data-placeholder","Enter text here"),f.children.length>0&&f.children[0].remove()):g.target.removeAttribute("data-placeholder"),l(g.target.innerText))},onClick:g=>{g.stopPropagation(),g.preventDefault()}}},[o==null?void 0:o.className,o==null?void 0:o.style]);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:React.createElement(p,{ref:r,onBlur:m,onKeyDown:u,...h})})}),WithBlockTextEditor=React.memo(({block:o,children:n})=>{const a="content",{document:r}=useFrame(),{editingBlockId:l,editingItemIndex:i,setEditingBlockId:c,setEditingItemIndex:d}=useInlineEditing(),[p,u]=React.useState(null),m=React.useRef(null),{clearHighlight:h}=useBlockHighlight(),x=useUpdateBlocksProps(),{selectedLang:g}=useLanguages(),[,f]=useSelectedBlockIds(),y=React.useRef(null),b=l,{blockContent:E,blockType:v}=React.useMemo(()=>{var B;const C=o._type;let _=o[a];const R=runtime.getRegisteredChaiBlock(o._type);return g&&((B=R==null?void 0:R.i18nProps)==null?void 0:B.includes(a))&&lodashEs.has(o,`${a}-${g}`)&&(_=lodashEs.get(o,`${a}-${g}`)),{blockContent:_,blockType:C}},[o,g]),S=React.useCallback(C=>{var R;const _=C||((R=m.current)==null?void 0:R.innerText);x([b],{[a]:_}),u(null),c(null),d(-1),f([])},[b,x,c,f,g]),w=web.useDebouncedCallback(C=>{x([b],{[a]:C})},[b,o,x,g],1e3),A=React.useCallback(C=>{C.preventDefault(),b&&(y.current=b),S(),setTimeout(()=>{const _=y.current;y.current=null,f([_])},100)},[f,b,g]);React.useEffect(()=>{var j;if(!b)return;const C=`[data-block-id="${b}"]`,_=i>=0?`[data-block-index="${i}"]`:"",R=r.querySelector(`${C}${_}`);R&&((j=R==null?void 0:R.classList)==null||j.add("sr-only"),u(R))},[b,v,r,i]);const k=React.useMemo(()=>p?(h(),v==="RichText"?jsxRuntime.jsx(RichTextEditor,{blockContent:E,editingElement:p,onChange:w,onClose:S,onEscape:A}):jsxRuntime.jsx(MemoizedEditor,{editorRef:m,blockContent:E,editingElement:p,onClose:S,onChange:w,onEscape:A})):null,[p,b,v,E,S,g]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[k,n]})},(o,n)=>o.block._id===n.block._id&&o.block.content===n.block.content),RepeaterContext=React.createContext({index:-1,key:""}),CORE_BLOCKS=["Box","Repeater","GlobalBlock","PartialBlock","Heading","Text","RichText","Span","Image","Button","Paragraph","Link","Video","Audio","Icon","List","ListItem","CustomScript","CustomHTML"],BlockRenderer=({asyncProps:o,blockAtom:n,children:a})=>{const{editingBlockId:r,editingItemIndex:l}=useInlineEditing(),[i]=jotai.useAtom(n),c=React.useMemo(()=>runtime.getRegisteredChaiBlock(i._type),[i._type]),{selectedLang:d,fallbackLang:p}=useLanguages(),u=useBlockRuntimeProps(),m=usePageExternalData(),[h]=useHiddenBlockIds(),[x]=jotai.useAtom(dataBindingActiveAtom),g=lodashEs.get(c,"component",null),{index:f,key:y}=React.useContext(RepeaterContext),b=React.useMemo(()=>x?applyBinding.applyBindingToBlockProps(applyBinding.applyLanguage(i,d,c),m,{index:f,key:y}):applyBinding.applyLanguage(i,d,c),[i,d,c,m,x,f,y]),E=React.useMemo(()=>applyBinding.getBlockTagAttributes(i),[i,applyBinding.getBlockTagAttributes]),v=React.useMemo(()=>u(i._id,applyBinding.getBlockRuntimeProps(i._type)),[i._id,i._type,u,applyBinding.getBlockRuntimeProps]),S=React.useMemo(()=>({blockProps:{"data-block-id":i._id,"data-block-type":i._type,"data-block-index":f},inBuilder:!0,lang:d||p,...b,...E,...v,...o}),[i._id,i._type,d,p,b,E,v,o]),w=React.useMemo(()=>!CORE_BLOCKS.includes(i._type),[i._type]);if(lodashEs.isNull(g)||h.includes(i._id))return null;let A=jsxRuntime.jsx(React.Suspense,{children:React.createElement(g,{...S,children:a({_id:i._id,_type:i._type,...lodashEs.isArray(b.repeaterItems)?{repeaterItems:applyBinding.applyLimit(b.repeaterItems,i),$repeaterItemsKey:b.$repeaterItemsKey}:{},...i.partialBlockId?{partialBlockId:i.partialBlockId}:"",...i.globalBlock?{partialBlockId:i.globalBlock}:""})})});const k=r===i._id&&(l===f||f<0)?jsxRuntime.jsx(WithBlockTextEditor,{block:i,children:A}):A;return w?jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallbackRender:ErrorFallback,children:k}):k},PartialBlocksRenderer=({partialBlockId:o})=>{const{getPartailBlocks:n}=usePartialBlocksStore(),a=React.useMemo(()=>n(o),[n,o]),r=React.useMemo(()=>utils.splitAtom(jotai.atom(a)),[a]);return lodashEs.isEmpty(a)?null:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:r,blocks:a})},BlocksRenderer=({blocks:o,parent:n=null,splitAtoms:a=void 0})=>{const r=useGetBlockAtom(a),l=React.useMemo(()=>lodashEs.filter(o,c=>lodashEs.has(c,"_id")&&(lodashEs.isEmpty(n)?!c._parent:c._parent===n)),[o,n]),i=React.useCallback(c=>lodashEs.filter(o,d=>d._parent===c).length>0,[o]);return lodashEs.map(l,c=>{const d=r(c._id);return d?jsxRuntime.jsx(MayBeAsyncPropsWrapper,{block:c,children:p=>jsxRuntime.jsx(BlockRenderer,{blockAtom:d,asyncProps:p,children:({_id:u,_type:m,partialBlockId:h,repeaterItems:x,$repeaterItemsKey:g})=>m==="Repeater"?lodashEs.isArray(x)&&x.map((f,y)=>jsxRuntime.jsx(RepeaterContext.Provider,{value:{index:y,key:g},children:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:c._id})},`${u}-${y}`)):m==="GlobalBlock"||m==="PartialBlock"?jsxRuntime.jsx(jotai.Provider,{store:builderStore,children:jsxRuntime.jsx(PartialBlocksRenderer,{partialBlockId:h})}):i(u)?jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:c._id}):null})},c._id):null})},PageBlocksRenderer=()=>{const[o]=useBlocksStore();return jsxRuntime.jsx(BlocksRenderer,{splitAtoms:pageBlocksAtomsAtom,blocks:o})},StaticBlocksRenderer=()=>{const[o]=useBlocksStore(),n=lodashEs.isEmpty(o)?null:jsxRuntime.jsx(PageBlocksRenderer,{});return jsxRuntime.jsx(jsxRuntime.Fragment,{children:n})},useCanvasScale=o=>{const[n]=useCanvasDisplayWidth(),[,a]=useCanvasZoom(),r=useBuilderProp("htmlDir","ltr"),[l,i]=React.useState({}),c=React.useCallback(()=>{const{width:d,height:p}=o;if(d<n){const u=parseFloat((d/n).toFixed(2).toString());let m={};const h=p*u,x=d*u;p&&(m={height:100+(p-h)/h*100+"%",width:100+(d-x)/x*100+"%"}),i({position:"relative",top:0,transform:`scale(${u})`,transformOrigin:r==="rtl"?"top right":"top left",...m,maxWidth:"none"}),a(u*100)}else i({}),a(100)},[n,o,r,a]);return React.useEffect(()=>{c()},[n,o,a,c]),l};function usePubSub(o,n){React.useEffect(()=>{const a=pubsub.subscribe(o,n);return()=>a()},[o,n])}const CanvasEventsWatcher=()=>{const[,o]=useSelectedBlockIds(),[n,a]=useSelectedStylingBlocks(),{document:r}=useFrame(),{clearHighlight:l}=useBlockHighlight(),[i]=useSelectedBlockIds(),[c]=jotai.useAtom(treeRefAtom);return React.useEffect(()=>{setTimeout(()=>{if(!lodashEs.isEmpty(n))return;const d=getElementByDataBlockId(r,lodashEs.first(i));if(d){const p=d.getAttribute("data-style-prop");if(p){const u=d.getAttribute("data-style-id"),m=d.getAttribute("data-block-parent");a([{id:u,prop:p,blockId:m}])}}},100)},[r,i,a,n]),React.useEffect(()=>()=>l(),[l]),usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED,d=>{d&&(!lodashEs.isEmpty(d)&&!lodashEs.includes(i,lodashEs.first(d))&&(c==null||c.closeAll()),o(d))}),usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED,d=>{if(!d)return;const{blockId:p,styleId:u,styleProp:m}=d;p&&(lodashEs.includes(i,p)||c==null||c.closeAll(),a([{id:u,prop:m,blockId:p}]),o([p]))}),usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION,()=>{l(),o([]),a([])}),null},StaticCanvas=()=>{const[o]=useCanvasDisplayWidth(),[,n]=useHighlightBlockId(),a=React.useRef(null),r=React.useRef(null),[l,i]=React.useState({width:0,height:0}),c=useCanvasScale(l),[,d]=jotai.useAtom(canvasIframeAtom),p=useBuilderProp("loading",!1),u=useBuilderProp("htmlDir","ltr"),m=React.useCallback(x=>{i(g=>({...g,width:x}))},[i]);React.useEffect(()=>{if(!r.current)return;const{clientWidth:x,clientHeight:g}=r.current;i({width:x,height:g})},[r,o]);const h=React.useMemo(()=>{let x=IframeInitialContent;return x=x.replace("__HTML_DIR__",u),x},[u]);return jsxRuntime.jsx(ResizableCanvasWrapper,{onMount:m,onResize:m,children:jsxRuntime.jsx("div",{onMouseLeave:()=>setTimeout(()=>n(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:r,children:jsxRuntime.jsxs(ChaiFrame,{contentDidMount:()=>d(a.current),ref:a,id:"canvas-iframe",style:{...c,...lodashEs.isEmpty(c)?{width:`${o}px`}:{}},className:"relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:h,children:[jsxRuntime.jsx(KeyboardHandler,{}),jsxRuntime.jsx(BlockSelectionHighlighter,{}),jsxRuntime.jsx(HeadTags,{}),jsxRuntime.jsxs(reactWrapBalancer.Provider,{children:[jsxRuntime.jsxs(Canvas,{children:[p?jsxRuntime.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"})}):jsxRuntime.jsx(StaticBlocksRenderer,{}),jsxRuntime.jsx(AddBlockAtBottom,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]}),jsxRuntime.jsx(CanvasEventsWatcher,{})]}),jsxRuntime.jsx("div",{id:"placeholder",className:"pointer-events-none absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})})},FallbackError=()=>jsxRuntime.jsx("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[jsxRuntime.jsx("p",{className:"font-semibold",children:"Oops! Something went wrong."}),jsxRuntime.jsx("p",{children:"Please try again."})]})}),CodeEditor$1=React.lazy(()=>Promise.resolve().then(()=>require("./code-editor-DydX0A0c.cjs"))),CanvasArea=()=>{const[o]=useCodeEditor(),n=useBuilderProp("onError",lodashEs.noop);return jsxRuntime.jsx("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:jsxRuntime.jsxs("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2",children:[jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:n,children:jsxRuntime.jsx(StaticCanvas,{})})}),o?jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reResizable.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:jsxRuntime.jsx(CodeEditor$1,{})})}):null,jsxRuntime.jsx(Breadcrumb,{})]})})},RJSF_EXTENSIONS={},registerBlockSettingWidget=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"widget"}},registerBlockSettingField=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"field"}},registerBlockSettingTemplate=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"template"}},useBlockSettingComponents=o=>Object.values(RJSF_EXTENSIONS).filter(n=>n.type===o).reduce((n,a)=>(n[a.id]=a.component,n),{}),removeSizeAttributes=o=>{try{return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>")}catch{return o}},IconPickerField=({value:o,onChange:n,id:a})=>{const{t:r}=reactI18next.useTranslation(),[l,i]=React.useState(o||"");React.useEffect(()=>{i(o||"")},[o]);const c=d=>{i(d);const p=removeSizeAttributes(d);n(p)};return jsxRuntime.jsxs("div",{className:"mt-1 flex flex-col gap-2",id:"icon-picker-field",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-lg border bg-gray-50",children:l?jsxRuntime.jsx("div",{className:"h-6 w-6",dangerouslySetInnerHTML:{__html:l}}):jsxRuntime.jsx("span",{className:"text-xs text-gray-400",children:"SVG"})}),jsxRuntime.jsx("textarea",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:l,onChange:d=>c(d.target.value),placeholder:r("Enter SVG code here"),rows:2,className:"no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"})]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:r("Paste SVG code to use as an icon")})]})},DefaultMediaManager=({close:o,onSelect:n,mode:a="image"})=>{const[r,l]=React.useState(""),[i,c]=React.useState(!1),[d,p]=React.useState(!1),[u,m]=React.useState(null),h=async g=>{if(!g.trim()){p(!1),m("Please enter a URL");return}try{c(!0),m(null),p(!0),m(null)}catch{p(!1),m("Error validating URL")}finally{c(!1)}},{t:x}=reactI18next.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-96 flex-col gap-4 p-4",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:x(`${a.charAt(0).toUpperCase()+a.slice(1)} Manager`)}),u&&jsxRuntime.jsxs(sooner.Alert,{variant:"destructive",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(sooner.AlertDescription,{children:u})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsx(sooner.Input,{placeholder:x(`Enter ${a} URL`),value:r,onChange:g=>l(g.target.value),onKeyUp:()=>h(r)}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(sooner.Button,{variant:"outline",onClick:o,children:x("Cancel")}),jsxRuntime.jsx(sooner.Button,{onClick:()=>n({id:"dam-id",url:r,width:600,height:400,description:"This is image description"}),disabled:!d||i,children:x("Insert")})]})]})]})},MEDIA_MANAGER={component:DefaultMediaManager},registerChaiMediaManager=o=>{MEDIA_MANAGER.component=o},useMediaManagerComponent=()=>React.useMemo(()=>MEDIA_MANAGER.component,[]),MediaManagerModal=({assetId:o,children:n,onSelect:a,mode:r="image"})=>{const[l,i]=React.useState(!1),c=useMediaManagerComponent(),d=(...p)=>{a.call(void 0,...p),i(!1)};return jsxRuntime.jsxs(sooner.Dialog,{open:l,onOpenChange:p=>i(p),children:[jsxRuntime.jsx(sooner.DialogTrigger,{asChild:!0,children:n}),jsxRuntime.jsx(sooner.DialogContent,{className:"flex max-h-[90vh] max-w-7xl border-border md:w-fit",children:jsxRuntime.jsx("div",{className:"h-full w-full",children:c?jsxRuntime.jsx(c,{close:()=>i(!1),onSelect:d,mode:r,assetId:o}):null})})]})};MediaManagerModal.displayName="MediaManagerModal";const ImagePickerField=({value:o,onChange:n,id:a,onBlur:r})=>{const{t:l}=reactI18next.useTranslation(),i=useSelectedBlock(),c=useUpdateBlocksProps(),d=m=>{const h=lodashEs.isArray(m)?lodashEs.first(m):m;if(h){n(h==null?void 0:h.url);const x=h==null?void 0:h.width,g=h==null?void 0:h.height;if(i!=null&&i._id){const f={...x&&{width:x},...g&&{height:g},...h.description&&{alt:h.description},...h.id&&{assetId:h.id}};if(lodashEs.isEmpty(f))return;c([i._id],f)}}},p=React.useCallback(()=>{n("https://placehold.co/400"),i!=null&&i._id&&c([i._id],{assetId:""})},[n,i==null?void 0:i._id,c]),u=lodashEs.get(i,"assetId","");return jsxRuntime.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[o?jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("img",{src:o,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover",alt:""}),jsxRuntime.jsx("button",{type:"button",onClick:p,className:"absolute -right-2 -top-2 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})})]}):jsxRuntime.jsx(MediaManagerModal,{onSelect:d,mode:"image",assetId:u,children:jsxRuntime.jsx("div",{className:"h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]"})}),jsxRuntime.jsxs("div",{className:"flex w-3/5 flex-col",children:[jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MediaManagerModal,{onSelect:d,assetId:u,children:jsxRuntime.jsx("small",{className:"h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80",children:o||!lodashEs.isEmpty(o)?l("Replace image"):l("Choose image")})}),jsxRuntime.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-secondary-foreground",children:"OR"})]}),jsxRuntime.jsx("input",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"text-xs",placeholder:l("Enter image URL"),value:o,onBlur:({target:{value:m}})=>r(a,m),onChange:m=>n(m.target.value)})]})]})},PathDropdown=({data:o,onSelect:n,dataType:a})=>{const[r,l]=React.useState([]),[i,c]=React.useState(o),d=h=>Array.isArray(h)?"array":typeof h=="object"&&h!==null?"object":"value",p=React.useCallback(h=>{const x=g=>a==="value"?g==="value"||g==="object":a==="array"?g==="array":g===a;h.type==="object"?(l(g=>[...g,h.key]),c(h.value)):x(h.type)&&n([...r,h.key].join("."),a)},[r,n,a]),u=React.useCallback(()=>{if(r.length>0){const h=r.slice(0,-1);l(h),c(h.reduce((x,g)=>x[g],o))}},[r,o]),m=React.useMemo(()=>i?Object.entries(i).map(([h,x])=>({key:h,value:x,type:d(x)})).filter(h=>!lodashEs.startsWith(h.key,applyBinding.REPEATER_PREFIX)&&h.key.includes("/")?!1:a==="value"?h.type==="value"||h.type==="object":a==="array"?h.type==="array"||h.type==="object":a==="object"?h.type==="object":!0):[],[i,a]);return jsxRuntime.jsxs(sooner.Command,{className:"fields-command",children:[jsxRuntime.jsx(sooner.CommandInput,{className:"border-none",placeholder:"Search..."}),jsxRuntime.jsxs(sooner.CommandList,{children:[jsxRuntime.jsx(sooner.CommandEmpty,{children:"No option found."}),jsxRuntime.jsxs(sooner.CommandGroup,{children:[r.length>0&&jsxRuntime.jsxs(sooner.CommandItem,{onSelect:u,className:"flex items-center text-sm",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),m.map(h=>jsxRuntime.jsxs(sooner.CommandItem,{value:h.key,disabled:!1,onSelect:()=>p(h),className:"flex items-center justify-between",children:[jsxRuntime.jsxs("span",{className:"flex items-center gap-x-2",children:[lodashEs.startsWith(h.key,applyBinding.REPEATER_PREFIX)?jsxRuntime.jsx(reactIcons.LoopIcon,{}):lodashEs.startsWith(h.key,applyBinding.COLLECTION_PREFIX)?jsxRuntime.jsx(lucideReact.DatabaseIcon,{}):null,lodashEs.startsWith(h.key,applyBinding.REPEATER_PREFIX)?"Repeater Data":lodashEs.startsWith(h.key,applyBinding.COLLECTION_PREFIX)?h.key.replace(applyBinding.COLLECTION_PREFIX,""):h.key]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[a==="object"&&h.type==="object"&&jsxRuntime.jsx(sooner.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:x=>{x.stopPropagation(),n([...r,h.key].join("."),a)},children:"Select"}),h.type==="object"&&jsxRuntime.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 opacity-50"})})]})]},h.key))]})]})]})};function NestedPathSelector({data:o,onSelect:n,dataType:a="value"}){const[r,l]=React.useState(!1),i=useBuilderProp("collections",[]),c=React.useMemo(()=>a==="array"?{...i.map(p=>p.id).reduce((p,u)=>({...p,[applyBinding.COLLECTION_PREFIX+u]:[]}),{}),...o}:o,[o,i,a]);return jsxRuntime.jsxs(sooner.Popover,{open:r,onOpenChange:l,children:[jsxRuntime.jsxs(sooner.Tooltip,{children:[jsxRuntime.jsx(sooner.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(sooner.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(sooner.Button,{size:"sm",variant:"outline",className:"h-5 rounded-sm px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),jsxRuntime.jsx(sooner.TooltipContent,{children:"Add field"})]}),jsxRuntime.jsx(sooner.PopoverContent,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:jsxRuntime.jsx(PathDropdown,{data:c,onSelect:(d,p)=>{n(d,p),l(!1)},dataType:a})})]})}const DataBindingSelector=({schema:o,onChange:n,id:a,formData:r})=>{const l=usePageExternalData(),i=useSelectedBlockHierarchy(),c=useSelectedBlock(),d=React.useMemo(()=>{if(i.length===1)return"";const m=i.find(g=>g._type==="Repeater"),x=lodashEs.get(m,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1");return`${applyBinding.REPEATER_PREFIX}${lodashEs.startsWith(x,applyBinding.COLLECTION_PREFIX)?`${x}/${m._id}`:x}`},[i]),p=React.useMemo(()=>lodashEs.first(lodashEs.get(l,d.replace(applyBinding.REPEATER_PREFIX,""),[])),[d,l]),u=React.useCallback((m,h)=>{if(m=lodashEs.isEmpty(d)?m:m.replace(`${d}`,"$index"),h==="array"||h==="object"){n(`{{${m}}}`,{},a);return}const x=b=>/[.,!?;:]/.test(b),g=(b,E,v)=>{let S="",w="";const A=E>0?b[E-1]:"",k=E<b.length?b[E]:"";return E>0&&(A==="."||!x(A)&&A!==" ")&&(S=" "),E<b.length&&!x(k)&&k!==" "&&(w=" "),{text:S+v+w,prefixLength:S.length,suffixLength:w.length}},f=document.getElementById(a);if(!f)return;const y=document.getElementById(`chai-rte-${a}`)||document.getElementById(`chai-rte-modal-${a}`);if(y&&(y.querySelector(".ProseMirror")||y.__chaiRTE)){const b=y.__chaiRTE;if(b){const E=`{{${m}}}`;b.commands.focus();const{from:v,to:S}=b.state.selection;if(v!==S)b.chain().deleteSelection().insertContent(E).run();else{const{state:A}=b,k=A.selection.from,C=A.doc.textBetween(Math.max(0,k-1),k),_=A.doc.textBetween(k,Math.min(k+1,A.doc.content.size));let R="";k>0&&C!==" "&&!x(C)&&(R=" ");let j="";_&&_!==" "&&!x(_)&&(j=" "),b.chain().insertContent(R+E+j).run()}setTimeout(()=>n(b.getHTML(),{},a),100);return}}else{const b=f,E=b.selectionStart||0,v=b.value||"",S=b.selectionEnd||E;if(S>E){const _=`{{${m}}}`,{text:R}=g(v,E,_),j=v.slice(0,E)+R+v.slice(S);n(j,{},a);return}const A=`{{${m}}}`,{text:k}=g(v,E,A),C=v.slice(0,E)+k+v.slice(E);n(C,{},a)}},[a,n,r,c==null?void 0:c._id,d]);return jsxRuntime.jsx(NestedPathSelector,{data:{...p&&{[d]:p},...l},onSelect:u,dataType:o.binding==="array"?"array":"value"})},PageTypeField=({href:o,pageTypes:n,onChange:a})=>{var _;const{t:r}=reactI18next.useTranslation(),l=useBuilderProp("searchPageTypeItems",(R,j)=>[]),[i,c]=React.useState(!1),[d,p]=React.useState(!1),[u,m]=React.useState("page"),[h,x]=React.useState(""),[g,f]=React.useState([]),[y,b]=React.useState(-1),E=React.useRef(null),v=(_=n==null?void 0:n.find(R=>R.key===u))==null?void 0:_.name;React.useEffect(()=>{if(x(""),f([]),b(-1),p(!1),!o||i||!lodashEs.startsWith(o,"pageType:"))return;const R=lodashEs.split(o,":"),j=lodashEs.get(R,1,"page")||"page";m(j),(async()=>{const B=await l(j,[lodashEs.get(R,2,"page")]);B&&Array.isArray(B)&&x(lodashEs.get(B,[0,"name"],""))})()},[o]);const S=web.useDebouncedCallback(async R=>{if(lodashEs.isEmpty(R))f([]);else{const j=await l(u,R);f(j)}c(!1),b(-1)},[u],300),w=R=>{const j=["pageType",u,R.id];j[1]&&(a(j.join(":")),x(R.name),p(!1),f([]),b(-1))},A=R=>{switch(R.key){case"ArrowDown":R.preventDefault(),b(j=>j<g.length-1?j+1:j);break;case"ArrowUp":R.preventDefault(),b(j=>j>0?j-1:j);break;case"Enter":if(R.preventDefault(),g.length===0)return;y>=0&&w(g[y]);break;case"Escape":R.preventDefault(),k();break}};React.useEffect(()=>{if(y>=0&&E.current){const R=E.current.children[y];R==null||R.scrollIntoView({block:"nearest"})}},[y]);const k=()=>{x(""),f([]),b(-1),p(!1),a("")},C=R=>{x(R),p(!lodashEs.isEmpty(R)),c(!0),S(R)};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("select",{name:"pageType",value:u,onChange:R=>m(R.target.value),children:lodashEs.map(n,R=>jsxRuntime.jsx("option",{value:R.key,children:R.name},R.key))}),u&&jsxRuntime.jsxs("div",{className:"group relative mt-2 flex items-center",children:[jsxRuntime.jsx("input",{type:"text",value:h,onChange:R=>C(R.target.value),onKeyDown:A,placeholder:r(`Search ${v??""}`),className:"w-full rounded-md border border-gray-300 p-2 pr-16"}),jsxRuntime.jsx("div",{className:"absolute bottom-2 right-2 top-3 flex items-center gap-1.5",children:h&&jsxRuntime.jsx("button",{onClick:k,className:"text-gray-400 hover:text-gray-600",title:r("Clear search"),children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})})]}),(i||!lodashEs.isEmpty(g)||d&&lodashEs.isEmpty(g))&&jsxRuntime.jsx("div",{className:"absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg",children:i?jsxRuntime.jsxs("div",{className:"space-y-1 p-2",children:[jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):d&&lodashEs.isEmpty(g)?jsxRuntime.jsxs("div",{className:"flex items-center justify-center p-4 text-sm text-gray-500",children:[r("No results found for"),' "',h,'"']}):jsxRuntime.jsx("ul",{ref:E,children:lodashEs.map(g==null?void 0:g.slice(0,20),(R,j)=>jsxRuntime.jsxs("li",{onClick:()=>w(R),className:`cursor-pointer p-2 text-xs ${o!=null&&o.includes(R.id)?"bg-blue-200":j===y?"bg-gray-100":"hover:bg-gray-100"}`,children:[R.name," ",R.slug&&jsxRuntime.jsxs("small",{className:"font-light text-gray-500",children:["( ",R.slug," )"]})]},R.id))})})]})},LinkField=({schema:o,formData:n,onChange:a,name:r})=>{const{t:l}=reactI18next.useTranslation(),{type:i="pageType",href:c="",target:d="self"}=n,p=useBuilderProp("pageTypes",[]),u=i==="pageType"&&lodashEs.isEmpty(p)?"url":i;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{className:"flex items-center justify-between gap-x-2 text-xs font-medium",children:[(o==null?void 0:o.title)??"Link",jsxRuntime.jsx(DataBindingSelector,{schema:o,onChange:m=>{console.log("value",n,m),a({...n,href:m,...u==="pageType"?{type:"url"}:{}})},id:`root.${r}.href`,formData:n})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("select",{name:"type",value:i,onChange:m=>a({...n,type:m.target.value}),children:lodashEs.map([...lodashEs.isEmpty(p)?[]:[{const:"pageType",title:l("Goto Page")}],{const:"url",title:l("Open URL")},{const:"email",title:l("Compose Email")},{const:"telephone",title:l("Call Phone")},{const:"scroll",title:l("Scroll to element")}],m=>jsxRuntime.jsx("option",{value:m.const,children:m.title},m.const))}),u==="pageType"&&!lodashEs.isEmpty(p)?jsxRuntime.jsx(PageTypeField,{href:c,pageTypes:p,onChange:m=>a({...n,href:m})}):null,jsxRuntime.jsx("input",{id:`root.${r}.href`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",className:u==="pageType"?"!hidden":"",value:c,onChange:m=>a({...n,href:m.target.value}),placeholder:l(i==="url"?"Enter URL":i==="scroll"?"#ElementID":"Enter details")}),u==="url"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsx("input",{id:`root.${r}.target`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"checkbox",defaultChecked:d==="_blank",className:"!w-fit cursor-pointer rounded-md border border-border",onChange:()=>a({...n,target:d==="_blank"?"_self":"_blank"})}),jsxRuntime.jsx("span",{className:"pt-1 text-xs",children:l("Open in new tab")})]})]})]})},RowColField=()=>{const o=useSelectedBlock(),n=useWrapperBlock(),{addCoreBlock:a}=useAddBlock();if(!o&&!n)return null;const r=(o==null?void 0:o._type)==="Row"?o:n;return jsxRuntime.jsx("div",{className:"pt-1",children:jsxRuntime.jsxs("button",{type:"button",className:"duratiom-300 flex items-center gap-x-1 rounded border border-gray-400 bg-gray-100 px-4 py-1 text-[11px] font-medium leading-tight hover:bg-slate-200",onClick:()=>a({type:"Column",styles:"#styles:,"},r==null?void 0:r._id),children:[jsxRuntime.jsx(lucideReact.Plus,{className:"h-4 w-4"})," Add Column"]})})};function cn(...o){return tailwindMerge.twMerge(clsx.clsx(o))}const MenuBar=({editor:o,onExpand:n})=>{if(!o)return null;const a=()=>{const l=window.prompt("URL");l&&o.chain().focus().extendMarkRange("link").setLink({href:l}).run()},r=()=>{o.chain().focus().unsetLink().run()};return jsxRuntime.jsxs("div",{className:"mb-1 flex flex-wrap gap-1 rounded-md border border-border p-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleBold().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("bold")}),title:"Bold",children:jsxRuntime.jsx(lucideReact.Bold,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleItalic().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("italic")}),title:"Italic",children:jsxRuntime.jsx(lucideReact.Italic,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleUnderline().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("underline")}),title:"Underline",children:jsxRuntime.jsx(lucideReact.Underline,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleStrike().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("strike")}),title:"Strike",children:jsxRuntime.jsx(lucideReact.Strikethrough,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleBulletList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("bulletList")}),title:"Bullet List",children:jsxRuntime.jsx(lucideReact.List,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleOrderedList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("orderedList")}),title:"Ordered List",children:jsxRuntime.jsx(lucideReact.ListOrdered,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("left").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"left"})}),title:"Align Left",children:jsxRuntime.jsx(lucideReact.AlignLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("center").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"center"})}),title:"Align Center",children:jsxRuntime.jsx(lucideReact.AlignCenter,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("right").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"right"})}),title:"Align Right",children:jsxRuntime.jsx(lucideReact.AlignRight,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:a,className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("link")}),title:"Add Link",children:jsxRuntime.jsx(lucideReact.Link,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:r,className:cn("rounded p-1 hover:bg-muted"),title:"Remove Link",disabled:!o.isActive("link"),children:jsxRuntime.jsx(lucideReact.Unlink,{className:"h-4 w-4"})}),n&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:n,className:"rounded p-1 hover:bg-muted",title:"Open in full screen mode",children:jsxRuntime.jsx(lucideReact.Maximize2,{className:"h-4 w-4"})})]})]})},RTEModal=({isOpen:o,onClose:n,id:a,value:r,onChange:l,onBlur:i})=>{const c=React.useRef(null),d=React.useRef(r||""),p=usePageExternalData();React.useEffect(()=>{if(o){const h=document.createElement("style");return h.id="rte-modal-styles",h.innerHTML=`
61
+ }`,[o]);return jsxRuntime.jsx("style",{id:"selected-blocks",dangerouslySetInnerHTML:{__html:n}})},Fonts=()=>{const[o]=useTheme(),n=runtime.useRegisteredFonts(),a=React.useMemo(()=>{const{heading:i,body:c}={heading:lodashEs.get(o,"fontFamily.heading"),body:lodashEs.get(o,"fontFamily.body")};return n.filter(d=>d.family===i||d.family===c)},[o==null?void 0:o.fontFamily,n]),r=React.useMemo(()=>plugin.getThemeFontsUrls(lodashEs.filter(a,i=>lodashEs.has(i,"url"))),[a]),l=React.useMemo(()=>plugin.getThemeCustomFontFace(lodashEs.filter(a,i=>lodashEs.has(i,"src"))),[a]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r.map((i,c)=>jsxRuntime.jsx("link",{rel:"stylesheet",href:i},`google-font-${c}`)),jsxRuntime.jsx("style",{id:"chai-custom-fonts",dangerouslySetInnerHTML:{__html:l}})]})},ResizableCanvasWrapper=({children:o,onMount:n,onResize:a})=>{const[,r]=useSelectedBlockIds(),[,l]=useSelectedStylingBlocks(),i=React.useRef(null),c=web.useDebouncedCallback(()=>{const{clientWidth:p}=i.current;a(p)},[i.current],100);web.useResizeObserver(i.current,c,i.current!==null),React.useEffect(()=>{const{clientWidth:p}=i.current;n(p)},[]);const d=React.useCallback(()=>{r([]),l([])},[r,l]);return jsxRuntime.jsx("div",{id:"main-content",onClick:d,className:"h-full w-full p-8 pb-0",ref:i,children:o})},MayBeAsyncPropsWrapper=({children:o,block:n})=>{const a=React.useMemo(()=>runtime.getRegisteredChaiBlock(n._type),[n._type]),r=lodashEs.get(a,"dataProviderDependencies"),l=lodashEs.get(a,"dataProvider"),i=lodashEs.get(a,"dataProviderMode","mock"),c=useAsyncProps(n,i,r,l);return o(c)},ErrorFallback=()=>jsxRuntime.jsx("div",{className:"flex min-h-[100px] items-center justify-center bg-red-50 p-2 text-center text-red-500",children:"Something went wrong."}),useBlockRuntimeProps=()=>{const[o]=useBlocksStore();return React.useCallback((n,a)=>lodashEs.isEmpty(a)?{}:Object.entries(a).reduce((r,[l,i])=>{const c=[];let d=lodashEs.find(o,{_id:n});for(;d;)c.push(d),d=lodashEs.find(o,{_id:d._parent});const p=lodashEs.find(c,{_type:i.block});return p&&(r[l]=lodashEs.get(p,lodashEs.get(i,"prop"),null)),r},{}),[o])},BUBBLE_MENU_ICONS={bold:reactIcons.FontBoldIcon,italic:reactIcons.FontItalicIcon,underline:reactIcons.UnderlineIcon,strikethrough:reactIcons.StrikethroughIcon,code:reactIcons.CodeIcon,link:reactIcons.Link1Icon,bulletList:reactIcons.ListBulletIcon,orderedList:reactIcons.ListBulletIcon,heading1:reactIcons.HeadingIcon,heading2:reactIcons.HeadingIcon,heading3:reactIcons.HeadingIcon,quote:reactIcons.QuoteIcon,alignLeft:reactIcons.TextAlignLeftIcon,alignCenter:reactIcons.TextAlignCenterIcon,alignRight:reactIcons.TextAlignRightIcon},BubbleMenuButton=({icon:o,title:n,onClick:a,isActive:r})=>{const l=BUBBLE_MENU_ICONS[o];return jsxRuntime.jsx("button",{onClick:a,className:sooner.cn("rounded-md p-1.5 transition-colors duration-200",r?"bg-white/20":"hover:bg-white/10"),title:n,children:jsxRuntime.jsx(l,{className:"h-4 w-4"})})},BubbleMenu=({editor:o})=>{if(!o)return null;const n=()=>{const a=window.prompt("Enter URL");a&&o.chain().focus().setLink({href:a}).run()};return jsxRuntime.jsx("div",{className:"flex items-center overflow-hidden rounded-lg border border-blue-500/20 bg-blue-600 text-white shadow-lg",children:jsxRuntime.jsxs("div",{className:"flex items-center p-1",children:[jsxRuntime.jsx(BubbleMenuButton,{icon:"bold",title:"Bold",onClick:()=>o.chain().focus().toggleBold().run(),isActive:o.isActive("bold")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"italic",title:"Italic",onClick:()=>o.chain().focus().toggleItalic().run(),isActive:o.isActive("italic")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"underline",title:"Underline",onClick:()=>o.chain().focus().toggleUnderline().run(),isActive:o.isActive("underline")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"strikethrough",title:"Strikethrough",onClick:()=>o.chain().focus().toggleStrike().run(),isActive:o.isActive("strike")}),jsxRuntime.jsx("div",{className:"mx-1 h-4 w-[1px] bg-white/20"}),jsxRuntime.jsx(BubbleMenuButton,{icon:"link",title:o.isActive("link")?"Remove link":"Add link",onClick:()=>{o.isActive("link")?o.chain().focus().unsetLink().run():n()},isActive:o.isActive("link")}),jsxRuntime.jsx("div",{className:"mx-1 h-4 w-[1px] bg-white/20"}),jsxRuntime.jsx(BubbleMenuButton,{icon:"bulletList",title:"Bullet list",onClick:()=>o.chain().focus().toggleBulletList().run(),isActive:o.isActive("bulletList")}),jsxRuntime.jsx(BubbleMenuButton,{icon:"orderedList",title:"Numbered list",onClick:()=>o.chain().focus().toggleOrderedList().run(),isActive:o.isActive("orderedList")}),jsxRuntime.jsx("div",{className:"mx-1 h-4 w-[1px] bg-white/20"}),jsxRuntime.jsx(BubbleMenuButton,{icon:"alignLeft",title:"Align left",onClick:()=>o.chain().focus().setTextAlign("left").run(),isActive:o.isActive({textAlign:"left"})}),jsxRuntime.jsx(BubbleMenuButton,{icon:"alignCenter",title:"Align center",onClick:()=>o.chain().focus().setTextAlign("center").run(),isActive:o.isActive({textAlign:"center"})}),jsxRuntime.jsx(BubbleMenuButton,{icon:"alignRight",title:"Align right",onClick:()=>o.chain().focus().setTextAlign("right").run(),isActive:o.isActive({textAlign:"right"})})]})})},RichTextEditor=React.memo(({blockContent:o,editingElement:n,onClose:a,onChange:r,onEscape:l})=>{const{document:i}=useFrame(),c=react.useEditor({editable:!0,content:o,extensions:[StarterKit,Underline,TextAlign.configure({types:["heading","paragraph"]}),Link.configure({openOnClick:!1,HTMLAttributes:{class:"text-blue-500 hover:text-blue-600 underline"}}),Placeholder.configure({placeholder:"Enter text here",emptyEditorClass:"cursor-text before:content-[attr(data-placeholder)] before:absolute before:opacity-50 before:pointer-events-none"})],onUpdate:({editor:u})=>r((u==null?void 0:u.getHTML())||""),onBlur:({editor:u,event:m})=>{const h=m.relatedTarget,x=i.querySelector(".ProseMirror"),g=i.querySelector(".tippy-box"),f=x==null?void 0:x.contains(h),y=g==null?void 0:g.contains(h);if(!f&&!y){const b=(u==null?void 0:u.getHTML())||"";a(b)}}},[]);React.useEffect(()=>{var u;(u=c==null?void 0:c.commands)==null||u.focus(),c==null||c.emit("focus",{editor:c,event:new FocusEvent("focus"),transaction:[]})},[c]);const d=React.useMemo(()=>{var h;const u="max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";if(!n)return u;const m=((h=n==null?void 0:n.className)==null?void 0:h.replace("sr-only",""))||"";return`${u} ${m}`},[n]),p=React.useCallback(u=>{u.key==="Escape"&&l(u)},[l]);return jsxRuntime.jsxs("div",{onKeyDown:p,onClick:u=>u.stopPropagation(),children:[c&&jsxRuntime.jsx(react.BubbleMenu,{editor:c,tippyOptions:{duration:100},children:jsxRuntime.jsx(BubbleMenu,{editor:c})}),jsxRuntime.jsx(react.EditorContent,{editor:c,className:d})]})}),MemoizedEditor=React.memo(({editingElement:o,blockContent:n,onClose:a,editorRef:r,onChange:l,onEscape:i})=>{const{document:c,window:d}=useFrame();React.useEffect(()=>{if(r.current){r.current.innerText=n,r.current.focus();const x=c.createRange(),g=d.getSelection();x.selectNodeContents(r.current),x.collapse(!1),g==null||g.removeAllRanges(),g==null||g.addRange(x),r.current.focus()}else a()},[c,d]);const p=React.useMemo(()=>{var g;const x=((g=o==null?void 0:o.tagName)==null?void 0:g.toLowerCase())||"div";return x==="button"?"div":x},[o]),u=React.useCallback(x=>{(x.key==="Enter"||x.key==="Escape")&&i(x)},[i]),m=React.useCallback(()=>{a()},[a]),h=React.useMemo(()=>{var x;return{id:"active-inline-editing-element",contentEditable:!0,className:`${((x=o==null?void 0:o.className)==null?void 0:x.replace("sr-only",""))||""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,style:lodashEs.cloneDeep(o==null?void 0:o.style)||{},onInput:g=>{const f=g.target;f&&(f.innerText.trim()===""?(f.setAttribute("data-placeholder","Enter text here"),f.children.length>0&&f.children[0].remove()):g.target.removeAttribute("data-placeholder"),l(g.target.innerText))},onClick:g=>{g.stopPropagation(),g.preventDefault()}}},[o==null?void 0:o.className,o==null?void 0:o.style]);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:React.createElement(p,{ref:r,onBlur:m,onKeyDown:u,...h})})}),WithBlockTextEditor=React.memo(({block:o,children:n})=>{const a="content",{document:r}=useFrame(),{editingBlockId:l,editingItemIndex:i,setEditingBlockId:c,setEditingItemIndex:d}=useInlineEditing(),[p,u]=React.useState(null),m=React.useRef(null),{clearHighlight:h}=useBlockHighlight(),x=useUpdateBlocksProps(),{selectedLang:g}=useLanguages(),[,f]=useSelectedBlockIds(),y=React.useRef(null),b=l,{blockContent:E,blockType:v}=React.useMemo(()=>{var B;const C=o._type;let _=o[a];const R=runtime.getRegisteredChaiBlock(o._type);return g&&((B=R==null?void 0:R.i18nProps)==null?void 0:B.includes(a))&&lodashEs.has(o,`${a}-${g}`)&&(_=lodashEs.get(o,`${a}-${g}`)),{blockContent:_,blockType:C}},[o,g]),S=React.useCallback(C=>{var R;const _=C||((R=m.current)==null?void 0:R.innerText);x([b],{[a]:_}),u(null),c(null),d(-1),f([])},[b,x,c,f,g]),w=web.useDebouncedCallback(C=>{x([b],{[a]:C})},[b,o,x,g],1e3),A=React.useCallback(C=>{C.preventDefault(),b&&(y.current=b),S(),setTimeout(()=>{const _=y.current;y.current=null,f([_])},100)},[f,b,g]);React.useEffect(()=>{var j;if(!b)return;const C=`[data-block-id="${b}"]`,_=i>=0?`[data-block-index="${i}"]`:"",R=r.querySelector(`${C}${_}`);R&&((j=R==null?void 0:R.classList)==null||j.add("sr-only"),u(R))},[b,v,r,i]);const k=React.useMemo(()=>p?(h(),v==="RichText"?jsxRuntime.jsx(RichTextEditor,{blockContent:E,editingElement:p,onChange:w,onClose:S,onEscape:A}):jsxRuntime.jsx(MemoizedEditor,{editorRef:m,blockContent:E,editingElement:p,onClose:S,onChange:w,onEscape:A})):null,[p,b,v,E,S,g]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[k,n]})},(o,n)=>o.block._id===n.block._id&&o.block.content===n.block.content),RepeaterContext=React.createContext({index:-1,key:""}),CORE_BLOCKS=["Box","Repeater","GlobalBlock","PartialBlock","Heading","Text","RichText","Span","Image","Button","Paragraph","Link","Video","Audio","Icon","List","ListItem","CustomScript","CustomHTML"],BlockRenderer=({asyncProps:o,blockAtom:n,children:a})=>{const{editingBlockId:r,editingItemIndex:l}=useInlineEditing(),[i]=jotai.useAtom(n),c=React.useMemo(()=>runtime.getRegisteredChaiBlock(i._type),[i._type]),{selectedLang:d,fallbackLang:p}=useLanguages(),u=useBlockRuntimeProps(),m=usePageExternalData(),[h]=useHiddenBlockIds(),[x]=jotai.useAtom(dataBindingActiveAtom),g=lodashEs.get(c,"component",null),{index:f,key:y}=React.useContext(RepeaterContext),b=React.useMemo(()=>x?applyBinding.applyBindingToBlockProps(applyBinding.applyLanguage(i,d,c),m,{index:f,key:y}):applyBinding.applyLanguage(i,d,c),[i,d,c,m,x,f,y]),E=React.useMemo(()=>applyBinding.getBlockTagAttributes(i),[i,applyBinding.getBlockTagAttributes]),v=React.useMemo(()=>u(i._id,applyBinding.getBlockRuntimeProps(i._type)),[i._id,i._type,u,applyBinding.getBlockRuntimeProps]),S=React.useMemo(()=>({blockProps:{"data-block-id":i._id,"data-block-type":i._type,"data-block-index":f},inBuilder:!0,lang:d||p,...b,...E,...v,...o}),[i._id,i._type,d,p,b,E,v,o]),w=React.useMemo(()=>!CORE_BLOCKS.includes(i._type),[i._type]);if(lodashEs.isNull(g)||h.includes(i._id))return null;let A=jsxRuntime.jsx(React.Suspense,{children:React.createElement(g,{...S,children:a({_id:i._id,_type:i._type,...lodashEs.isArray(b.repeaterItems)?{repeaterItems:applyBinding.applyLimit(b.repeaterItems,i),$repeaterItemsKey:b.$repeaterItemsKey}:{},...i.partialBlockId?{partialBlockId:i.partialBlockId}:"",...i.globalBlock?{partialBlockId:i.globalBlock}:""})})});const k=r===i._id&&(l===f||f<0)?jsxRuntime.jsx(WithBlockTextEditor,{block:i,children:A}):A;return w?jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallbackRender:ErrorFallback,children:k}):k},PartialWrapper=({children:o,partialBlockId:n})=>{const a=useBuilderProp("gotoPage",lodashEs.noop),{saveState:r}=useSavePage(),{selectedLang:l,fallbackLang:i}=useLanguages(),c=React.useCallback(d=>{if(d.stopPropagation(),r!=="SAVED"){sonner.toast.error("You have unsaved changes. Please save the page first.");return}a({pageId:n,lang:l||i})},[r,a,n,l,i]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[o,jsxRuntime.jsx("div",{className:"partial-overlay group absolute inset-0 z-50",children:jsxRuntime.jsx("div",{onDoubleClick:c,className:"flex h-full w-full items-center justify-center bg-black/10 opacity-0 transition-opacity duration-300 ease-in-out group-hover:opacity-100 group-hover:backdrop-opacity-85",children:jsxRuntime.jsx("p",{className:"rounded-md bg-white px-2 py-1 text-xs",children:"Partial block. Double click to edit."})})})]})},PartialBlocksRenderer=({partialBlockId:o})=>{const{getPartailBlocks:n}=usePartialBlocksStore(),a=React.useMemo(()=>n(o),[n,o]),r=React.useMemo(()=>utils.splitAtom(jotai.atom(a)),[a]);return lodashEs.isEmpty(a)?null:jsxRuntime.jsx(PartialWrapper,{partialBlockId:o,children:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:r,blocks:a})})},BlocksRenderer=({blocks:o,parent:n=null,splitAtoms:a=void 0})=>{const r=useGetBlockAtom(a),l=React.useMemo(()=>lodashEs.filter(o,c=>lodashEs.has(c,"_id")&&(lodashEs.isEmpty(n)?!c._parent:c._parent===n)),[o,n]),i=React.useCallback(c=>lodashEs.filter(o,d=>d._parent===c).length>0,[o]);return lodashEs.map(l,c=>{const d=r(c._id);return d?jsxRuntime.jsx(MayBeAsyncPropsWrapper,{block:c,children:p=>jsxRuntime.jsx(BlockRenderer,{blockAtom:d,asyncProps:p,children:({_id:u,_type:m,partialBlockId:h,repeaterItems:x,$repeaterItemsKey:g})=>m==="Repeater"?lodashEs.isArray(x)&&x.map((f,y)=>jsxRuntime.jsx(RepeaterContext.Provider,{value:{index:y,key:g},children:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:c._id})},`${u}-${y}`)):m==="GlobalBlock"||m==="PartialBlock"?jsxRuntime.jsx(jotai.Provider,{store:builderStore,children:jsxRuntime.jsx(PartialBlocksRenderer,{partialBlockId:h})}):i(u)?jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:c._id}):null})},c._id):null})},PageBlocksRenderer=()=>{const[o]=useBlocksStore();return jsxRuntime.jsx(BlocksRenderer,{splitAtoms:pageBlocksAtomsAtom,blocks:o})},StaticBlocksRenderer=()=>{const[o]=useBlocksStore(),n=lodashEs.isEmpty(o)?null:jsxRuntime.jsx(PageBlocksRenderer,{});return jsxRuntime.jsx(jsxRuntime.Fragment,{children:n})},useCanvasScale=o=>{const[n]=useCanvasDisplayWidth(),[,a]=useCanvasZoom(),r=useBuilderProp("htmlDir","ltr"),[l,i]=React.useState({}),c=React.useCallback(()=>{const{width:d,height:p}=o;if(d<n){const u=parseFloat((d/n).toFixed(2).toString());let m={};const h=p*u,x=d*u;p&&(m={height:100+(p-h)/h*100+"%",width:100+(d-x)/x*100+"%"}),i({position:"relative",top:0,transform:`scale(${u})`,transformOrigin:r==="rtl"?"top right":"top left",...m,maxWidth:"none"}),a(u*100)}else i({}),a(100)},[n,o,r,a]);return React.useEffect(()=>{c()},[n,o,a,c]),l};function usePubSub(o,n){React.useEffect(()=>{const a=pubsub.subscribe(o,n);return()=>a()},[o,n])}const CanvasEventsWatcher=()=>{const[,o]=useSelectedBlockIds(),[n,a]=useSelectedStylingBlocks(),{document:r}=useFrame(),{clearHighlight:l}=useBlockHighlight(),[i]=useSelectedBlockIds(),[c]=jotai.useAtom(treeRefAtom);return React.useEffect(()=>{setTimeout(()=>{if(!lodashEs.isEmpty(n))return;const d=getElementByDataBlockId(r,lodashEs.first(i));if(d){const p=d.getAttribute("data-style-prop");if(p){const u=d.getAttribute("data-style-id"),m=d.getAttribute("data-block-parent");a([{id:u,prop:p,blockId:m}])}}},100)},[r,i,a,n]),React.useEffect(()=>()=>l(),[l]),usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED,d=>{d&&(!lodashEs.isEmpty(d)&&!lodashEs.includes(i,lodashEs.first(d))&&(c==null||c.closeAll()),o(d))}),usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED,d=>{if(!d)return;const{blockId:p,styleId:u,styleProp:m}=d;p&&(lodashEs.includes(i,p)||c==null||c.closeAll(),a([{id:u,prop:m,blockId:p}]),o([p]))}),usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION,()=>{l(),o([]),a([])}),null},StaticCanvas=()=>{const[o]=useCanvasDisplayWidth(),[,n]=useHighlightBlockId(),a=React.useRef(null),r=React.useRef(null),[l,i]=React.useState({width:0,height:0}),c=useCanvasScale(l),[,d]=jotai.useAtom(canvasIframeAtom),p=useBuilderProp("loading",!1),u=useBuilderProp("htmlDir","ltr"),m=React.useCallback(x=>{i(g=>({...g,width:x}))},[i]);React.useEffect(()=>{if(!r.current)return;const{clientWidth:x,clientHeight:g}=r.current;i({width:x,height:g})},[r,o]);const h=React.useMemo(()=>{let x=IframeInitialContent;return x=x.replace("__HTML_DIR__",u),x},[u]);return jsxRuntime.jsx(ResizableCanvasWrapper,{onMount:m,onResize:m,children:jsxRuntime.jsx("div",{onMouseLeave:()=>setTimeout(()=>n(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:r,children:jsxRuntime.jsxs(ChaiFrame,{contentDidMount:()=>d(a.current),ref:a,id:"canvas-iframe",style:{...c,...lodashEs.isEmpty(c)?{width:`${o}px`}:{}},className:"relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:h,children:[jsxRuntime.jsx(KeyboardHandler,{}),jsxRuntime.jsx(BlockSelectionHighlighter,{}),jsxRuntime.jsx(HeadTags,{}),jsxRuntime.jsxs(reactWrapBalancer.Provider,{children:[jsxRuntime.jsxs(Canvas,{children:[p?jsxRuntime.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"})}):jsxRuntime.jsx(StaticBlocksRenderer,{}),jsxRuntime.jsx(AddBlockAtBottom,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]}),jsxRuntime.jsx(CanvasEventsWatcher,{})]}),jsxRuntime.jsx("div",{id:"placeholder",className:"pointer-events-none absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})})},FallbackError=()=>jsxRuntime.jsx("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[jsxRuntime.jsx("p",{className:"font-semibold",children:"Oops! Something went wrong."}),jsxRuntime.jsx("p",{children:"Please try again."})]})}),CodeEditor$1=React.lazy(()=>Promise.resolve().then(()=>require("./code-editor-DydX0A0c.cjs"))),CanvasArea=()=>{const[o]=useCodeEditor(),n=useBuilderProp("onError",lodashEs.noop);return jsxRuntime.jsx("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:jsxRuntime.jsxs("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2",children:[jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:n,children:jsxRuntime.jsx(StaticCanvas,{})})}),o?jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reResizable.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:jsxRuntime.jsx(CodeEditor$1,{})})}):null,jsxRuntime.jsx(Breadcrumb,{})]})})},RJSF_EXTENSIONS={},registerBlockSettingWidget=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"widget"}},registerBlockSettingField=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"field"}},registerBlockSettingTemplate=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"template"}},useBlockSettingComponents=o=>Object.values(RJSF_EXTENSIONS).filter(n=>n.type===o).reduce((n,a)=>(n[a.id]=a.component,n),{}),removeSizeAttributes=o=>{try{return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>")}catch{return o}},IconPickerField=({value:o,onChange:n,id:a})=>{const{t:r}=reactI18next.useTranslation(),[l,i]=React.useState(o||"");React.useEffect(()=>{i(o||"")},[o]);const c=d=>{i(d);const p=removeSizeAttributes(d);n(p)};return jsxRuntime.jsxs("div",{className:"mt-1 flex flex-col gap-2",id:"icon-picker-field",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-lg border bg-gray-50",children:l?jsxRuntime.jsx("div",{className:"h-6 w-6",dangerouslySetInnerHTML:{__html:l}}):jsxRuntime.jsx("span",{className:"text-xs text-gray-400",children:"SVG"})}),jsxRuntime.jsx("textarea",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:l,onChange:d=>c(d.target.value),placeholder:r("Enter SVG code here"),rows:2,className:"no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"})]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:r("Paste SVG code to use as an icon")})]})},DefaultMediaManager=({close:o,onSelect:n,mode:a="image"})=>{const[r,l]=React.useState(""),[i,c]=React.useState(!1),[d,p]=React.useState(!1),[u,m]=React.useState(null),h=async g=>{if(!g.trim()){p(!1),m("Please enter a URL");return}try{c(!0),m(null),p(!0),m(null)}catch{p(!1),m("Error validating URL")}finally{c(!1)}},{t:x}=reactI18next.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-96 flex-col gap-4 p-4",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:x(`${a.charAt(0).toUpperCase()+a.slice(1)} Manager`)}),u&&jsxRuntime.jsxs(sooner.Alert,{variant:"destructive",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(sooner.AlertDescription,{children:u})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsx(sooner.Input,{placeholder:x(`Enter ${a} URL`),value:r,onChange:g=>l(g.target.value),onKeyUp:()=>h(r)}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(sooner.Button,{variant:"outline",onClick:o,children:x("Cancel")}),jsxRuntime.jsx(sooner.Button,{onClick:()=>n({id:"dam-id",url:r,width:600,height:400,description:"This is image description"}),disabled:!d||i,children:x("Insert")})]})]})]})},MEDIA_MANAGER={component:DefaultMediaManager},registerChaiMediaManager=o=>{MEDIA_MANAGER.component=o},useMediaManagerComponent=()=>React.useMemo(()=>MEDIA_MANAGER.component,[]),MediaManagerModal=({assetId:o,children:n,onSelect:a,mode:r="image"})=>{const[l,i]=React.useState(!1),c=useMediaManagerComponent(),d=(...p)=>{a.call(void 0,...p),i(!1)};return jsxRuntime.jsxs(sooner.Dialog,{open:l,onOpenChange:p=>i(p),children:[jsxRuntime.jsx(sooner.DialogTrigger,{asChild:!0,children:n}),jsxRuntime.jsx(sooner.DialogContent,{className:"flex max-h-[90vh] max-w-7xl border-border md:w-fit",children:jsxRuntime.jsx("div",{className:"h-full w-full",children:c?jsxRuntime.jsx(c,{close:()=>i(!1),onSelect:d,mode:r,assetId:o}):null})})]})};MediaManagerModal.displayName="MediaManagerModal";const ImagePickerField=({value:o,onChange:n,id:a,onBlur:r})=>{const{t:l}=reactI18next.useTranslation(),i=useSelectedBlock(),c=useUpdateBlocksProps(),d=m=>{const h=lodashEs.isArray(m)?lodashEs.first(m):m;if(h){n(h==null?void 0:h.url);const x=h==null?void 0:h.width,g=h==null?void 0:h.height;if(i!=null&&i._id){const f={...x&&{width:x},...g&&{height:g},...h.description&&{alt:h.description},...h.id&&{assetId:h.id}};if(lodashEs.isEmpty(f))return;c([i._id],f)}}},p=React.useCallback(()=>{n("https://placehold.co/400"),i!=null&&i._id&&c([i._id],{assetId:""})},[n,i==null?void 0:i._id,c]),u=lodashEs.get(i,"assetId","");return jsxRuntime.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[o?jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("img",{src:o,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover",alt:""}),jsxRuntime.jsx("button",{type:"button",onClick:p,className:"absolute -right-2 -top-2 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})})]}):jsxRuntime.jsx(MediaManagerModal,{onSelect:d,mode:"image",assetId:u,children:jsxRuntime.jsx("div",{className:"h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]"})}),jsxRuntime.jsxs("div",{className:"flex w-3/5 flex-col",children:[jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MediaManagerModal,{onSelect:d,assetId:u,children:jsxRuntime.jsx("small",{className:"h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80",children:o||!lodashEs.isEmpty(o)?l("Replace image"):l("Choose image")})}),jsxRuntime.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-secondary-foreground",children:"OR"})]}),jsxRuntime.jsx("input",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"text-xs",placeholder:l("Enter image URL"),value:o,onBlur:({target:{value:m}})=>r(a,m),onChange:m=>n(m.target.value)})]})]})},PathDropdown=({data:o,onSelect:n,dataType:a})=>{const[r,l]=React.useState([]),[i,c]=React.useState(o),d=h=>Array.isArray(h)?"array":typeof h=="object"&&h!==null?"object":"value",p=React.useCallback(h=>{const x=g=>a==="value"?g==="value"||g==="object":a==="array"?g==="array":g===a;h.type==="object"?(l(g=>[...g,h.key]),c(h.value)):x(h.type)&&n([...r,h.key].join("."),a)},[r,n,a]),u=React.useCallback(()=>{if(r.length>0){const h=r.slice(0,-1);l(h),c(h.reduce((x,g)=>x[g],o))}},[r,o]),m=React.useMemo(()=>i?Object.entries(i).map(([h,x])=>({key:h,value:x,type:d(x)})).filter(h=>!lodashEs.startsWith(h.key,applyBinding.REPEATER_PREFIX)&&h.key.includes("/")?!1:a==="value"?h.type==="value"||h.type==="object":a==="array"?h.type==="array"||h.type==="object":a==="object"?h.type==="object":!0):[],[i,a]);return jsxRuntime.jsxs(sooner.Command,{className:"fields-command",children:[jsxRuntime.jsx(sooner.CommandInput,{className:"border-none",placeholder:"Search..."}),jsxRuntime.jsxs(sooner.CommandList,{children:[jsxRuntime.jsx(sooner.CommandEmpty,{children:"No option found."}),jsxRuntime.jsxs(sooner.CommandGroup,{children:[r.length>0&&jsxRuntime.jsxs(sooner.CommandItem,{onSelect:u,className:"flex items-center text-sm",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),m.map(h=>jsxRuntime.jsxs(sooner.CommandItem,{value:h.key,disabled:!1,onSelect:()=>p(h),className:"flex items-center justify-between",children:[jsxRuntime.jsxs("span",{className:"flex items-center gap-x-2",children:[lodashEs.startsWith(h.key,applyBinding.REPEATER_PREFIX)?jsxRuntime.jsx(reactIcons.LoopIcon,{}):lodashEs.startsWith(h.key,applyBinding.COLLECTION_PREFIX)?jsxRuntime.jsx(lucideReact.DatabaseIcon,{}):null,lodashEs.startsWith(h.key,applyBinding.REPEATER_PREFIX)?"Repeater Data":lodashEs.startsWith(h.key,applyBinding.COLLECTION_PREFIX)?h.key.replace(applyBinding.COLLECTION_PREFIX,""):h.key]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[a==="object"&&h.type==="object"&&jsxRuntime.jsx(sooner.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:x=>{x.stopPropagation(),n([...r,h.key].join("."),a)},children:"Select"}),h.type==="object"&&jsxRuntime.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 opacity-50"})})]})]},h.key))]})]})]})};function NestedPathSelector({data:o,onSelect:n,dataType:a="value"}){const[r,l]=React.useState(!1),i=useBuilderProp("collections",[]),c=React.useMemo(()=>a==="array"?{...i.map(p=>p.id).reduce((p,u)=>({...p,[applyBinding.COLLECTION_PREFIX+u]:[]}),{}),...o}:o,[o,i,a]);return jsxRuntime.jsxs(sooner.Popover,{open:r,onOpenChange:l,children:[jsxRuntime.jsxs(sooner.Tooltip,{children:[jsxRuntime.jsx(sooner.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(sooner.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(sooner.Button,{size:"sm",variant:"outline",className:"h-5 rounded-sm px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),jsxRuntime.jsx(sooner.TooltipContent,{children:"Add field"})]}),jsxRuntime.jsx(sooner.PopoverContent,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:jsxRuntime.jsx(PathDropdown,{data:c,onSelect:(d,p)=>{n(d,p),l(!1)},dataType:a})})]})}const DataBindingSelector=({schema:o,onChange:n,id:a,formData:r})=>{const l=usePageExternalData(),i=useSelectedBlockHierarchy(),c=useSelectedBlock(),d=React.useMemo(()=>{if(i.length===1)return"";const m=i.find(g=>g._type==="Repeater"),x=lodashEs.get(m,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1");return`${applyBinding.REPEATER_PREFIX}${lodashEs.startsWith(x,applyBinding.COLLECTION_PREFIX)?`${x}/${m._id}`:x}`},[i]),p=React.useMemo(()=>lodashEs.first(lodashEs.get(l,d.replace(applyBinding.REPEATER_PREFIX,""),[])),[d,l]),u=React.useCallback((m,h)=>{if(m=lodashEs.isEmpty(d)?m:m.replace(`${d}`,"$index"),h==="array"||h==="object"){n(`{{${m}}}`,{},a);return}const x=b=>/[.,!?;:]/.test(b),g=(b,E,v)=>{let S="",w="";const A=E>0?b[E-1]:"",k=E<b.length?b[E]:"";return E>0&&(A==="."||!x(A)&&A!==" ")&&(S=" "),E<b.length&&!x(k)&&k!==" "&&(w=" "),{text:S+v+w,prefixLength:S.length,suffixLength:w.length}},f=document.getElementById(a);if(!f)return;const y=document.getElementById(`chai-rte-${a}`)||document.getElementById(`chai-rte-modal-${a}`);if(y&&(y.querySelector(".ProseMirror")||y.__chaiRTE)){const b=y.__chaiRTE;if(b){const E=`{{${m}}}`;b.commands.focus();const{from:v,to:S}=b.state.selection;if(v!==S)b.chain().deleteSelection().insertContent(E).run();else{const{state:A}=b,k=A.selection.from,C=A.doc.textBetween(Math.max(0,k-1),k),_=A.doc.textBetween(k,Math.min(k+1,A.doc.content.size));let R="";k>0&&C!==" "&&!x(C)&&(R=" ");let j="";_&&_!==" "&&!x(_)&&(j=" "),b.chain().insertContent(R+E+j).run()}setTimeout(()=>n(b.getHTML(),{},a),100);return}}else{const b=f,E=b.selectionStart||0,v=b.value||"",S=b.selectionEnd||E;if(S>E){const _=`{{${m}}}`,{text:R}=g(v,E,_),j=v.slice(0,E)+R+v.slice(S);n(j,{},a);return}const A=`{{${m}}}`,{text:k}=g(v,E,A),C=v.slice(0,E)+k+v.slice(E);n(C,{},a)}},[a,n,r,c==null?void 0:c._id,d]);return jsxRuntime.jsx(NestedPathSelector,{data:{...p&&{[d]:p},...l},onSelect:u,dataType:o.binding==="array"?"array":"value"})},PageTypeField=({href:o,pageTypes:n,onChange:a})=>{var _;const{t:r}=reactI18next.useTranslation(),l=useBuilderProp("searchPageTypeItems",(R,j)=>[]),[i,c]=React.useState(!1),[d,p]=React.useState(!1),[u,m]=React.useState("page"),[h,x]=React.useState(""),[g,f]=React.useState([]),[y,b]=React.useState(-1),E=React.useRef(null),v=(_=n==null?void 0:n.find(R=>R.key===u))==null?void 0:_.name;React.useEffect(()=>{if(x(""),f([]),b(-1),p(!1),!o||i||!lodashEs.startsWith(o,"pageType:"))return;const R=lodashEs.split(o,":"),j=lodashEs.get(R,1,"page")||"page";m(j),(async()=>{const B=await l(j,[lodashEs.get(R,2,"page")]);B&&Array.isArray(B)&&x(lodashEs.get(B,[0,"name"],""))})()},[o]);const S=web.useDebouncedCallback(async R=>{if(lodashEs.isEmpty(R))f([]);else{const j=await l(u,R);f(j)}c(!1),b(-1)},[u],300),w=R=>{const j=["pageType",u,R.id];j[1]&&(a(j.join(":")),x(R.name),p(!1),f([]),b(-1))},A=R=>{switch(R.key){case"ArrowDown":R.preventDefault(),b(j=>j<g.length-1?j+1:j);break;case"ArrowUp":R.preventDefault(),b(j=>j>0?j-1:j);break;case"Enter":if(R.preventDefault(),g.length===0)return;y>=0&&w(g[y]);break;case"Escape":R.preventDefault(),k();break}};React.useEffect(()=>{if(y>=0&&E.current){const R=E.current.children[y];R==null||R.scrollIntoView({block:"nearest"})}},[y]);const k=()=>{x(""),f([]),b(-1),p(!1),a("")},C=R=>{x(R),p(!lodashEs.isEmpty(R)),c(!0),S(R)};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("select",{name:"pageType",value:u,onChange:R=>m(R.target.value),children:lodashEs.map(n,R=>jsxRuntime.jsx("option",{value:R.key,children:R.name},R.key))}),u&&jsxRuntime.jsxs("div",{className:"group relative mt-2 flex items-center",children:[jsxRuntime.jsx("input",{type:"text",value:h,onChange:R=>C(R.target.value),onKeyDown:A,placeholder:r(`Search ${v??""}`),className:"w-full rounded-md border border-gray-300 p-2 pr-16"}),jsxRuntime.jsx("div",{className:"absolute bottom-2 right-2 top-3 flex items-center gap-1.5",children:h&&jsxRuntime.jsx("button",{onClick:k,className:"text-gray-400 hover:text-gray-600",title:r("Clear search"),children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})})]}),(i||!lodashEs.isEmpty(g)||d&&lodashEs.isEmpty(g))&&jsxRuntime.jsx("div",{className:"absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg",children:i?jsxRuntime.jsxs("div",{className:"space-y-1 p-2",children:[jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):d&&lodashEs.isEmpty(g)?jsxRuntime.jsxs("div",{className:"flex items-center justify-center p-4 text-sm text-gray-500",children:[r("No results found for"),' "',h,'"']}):jsxRuntime.jsx("ul",{ref:E,children:lodashEs.map(g==null?void 0:g.slice(0,20),(R,j)=>jsxRuntime.jsxs("li",{onClick:()=>w(R),className:`cursor-pointer p-2 text-xs ${o!=null&&o.includes(R.id)?"bg-blue-200":j===y?"bg-gray-100":"hover:bg-gray-100"}`,children:[R.name," ",R.slug&&jsxRuntime.jsxs("small",{className:"font-light text-gray-500",children:["( ",R.slug," )"]})]},R.id))})})]})},LinkField=({schema:o,formData:n,onChange:a,name:r})=>{const{t:l}=reactI18next.useTranslation(),{type:i="pageType",href:c="",target:d="self"}=n,p=useBuilderProp("pageTypes",[]),u=i==="pageType"&&lodashEs.isEmpty(p)?"url":i;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{className:"flex items-center justify-between gap-x-2 text-xs font-medium",children:[(o==null?void 0:o.title)??"Link",jsxRuntime.jsx(DataBindingSelector,{schema:o,onChange:m=>{console.log("value",n,m),a({...n,href:m,...u==="pageType"?{type:"url"}:{}})},id:`root.${r}.href`,formData:n})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("select",{name:"type",value:i,onChange:m=>a({...n,type:m.target.value}),children:lodashEs.map([...lodashEs.isEmpty(p)?[]:[{const:"pageType",title:l("Goto Page")}],{const:"url",title:l("Open URL")},{const:"email",title:l("Compose Email")},{const:"telephone",title:l("Call Phone")},{const:"scroll",title:l("Scroll to element")}],m=>jsxRuntime.jsx("option",{value:m.const,children:m.title},m.const))}),u==="pageType"&&!lodashEs.isEmpty(p)?jsxRuntime.jsx(PageTypeField,{href:c,pageTypes:p,onChange:m=>a({...n,href:m})}):null,jsxRuntime.jsx("input",{id:`root.${r}.href`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",className:u==="pageType"?"!hidden":"",value:c,onChange:m=>a({...n,href:m.target.value}),placeholder:l(i==="url"?"Enter URL":i==="scroll"?"#ElementID":"Enter details")}),u==="url"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsx("input",{id:`root.${r}.target`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"checkbox",defaultChecked:d==="_blank",className:"!w-fit cursor-pointer rounded-md border border-border",onChange:()=>a({...n,target:d==="_blank"?"_self":"_blank"})}),jsxRuntime.jsx("span",{className:"pt-1 text-xs",children:l("Open in new tab")})]})]})]})},RowColField=()=>{const o=useSelectedBlock(),n=useWrapperBlock(),{addCoreBlock:a}=useAddBlock();if(!o&&!n)return null;const r=(o==null?void 0:o._type)==="Row"?o:n;return jsxRuntime.jsx("div",{className:"pt-1",children:jsxRuntime.jsxs("button",{type:"button",className:"duratiom-300 flex items-center gap-x-1 rounded border border-gray-400 bg-gray-100 px-4 py-1 text-[11px] font-medium leading-tight hover:bg-slate-200",onClick:()=>a({type:"Column",styles:"#styles:,"},r==null?void 0:r._id),children:[jsxRuntime.jsx(lucideReact.Plus,{className:"h-4 w-4"})," Add Column"]})})};function cn(...o){return tailwindMerge.twMerge(clsx.clsx(o))}const MenuBar=({editor:o,onExpand:n})=>{if(!o)return null;const a=()=>{const l=window.prompt("URL");l&&o.chain().focus().extendMarkRange("link").setLink({href:l}).run()},r=()=>{o.chain().focus().unsetLink().run()};return jsxRuntime.jsxs("div",{className:"mb-1 flex flex-wrap gap-1 rounded-md border border-border p-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleBold().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("bold")}),title:"Bold",children:jsxRuntime.jsx(lucideReact.Bold,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleItalic().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("italic")}),title:"Italic",children:jsxRuntime.jsx(lucideReact.Italic,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleUnderline().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("underline")}),title:"Underline",children:jsxRuntime.jsx(lucideReact.Underline,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleStrike().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("strike")}),title:"Strike",children:jsxRuntime.jsx(lucideReact.Strikethrough,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleBulletList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("bulletList")}),title:"Bullet List",children:jsxRuntime.jsx(lucideReact.List,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleOrderedList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("orderedList")}),title:"Ordered List",children:jsxRuntime.jsx(lucideReact.ListOrdered,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("left").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"left"})}),title:"Align Left",children:jsxRuntime.jsx(lucideReact.AlignLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("center").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"center"})}),title:"Align Center",children:jsxRuntime.jsx(lucideReact.AlignCenter,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("right").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"right"})}),title:"Align Right",children:jsxRuntime.jsx(lucideReact.AlignRight,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:a,className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("link")}),title:"Add Link",children:jsxRuntime.jsx(lucideReact.Link,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:r,className:cn("rounded p-1 hover:bg-muted"),title:"Remove Link",disabled:!o.isActive("link"),children:jsxRuntime.jsx(lucideReact.Unlink,{className:"h-4 w-4"})}),n&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:n,className:"rounded p-1 hover:bg-muted",title:"Open in full screen mode",children:jsxRuntime.jsx(lucideReact.Maximize2,{className:"h-4 w-4"})})]})]})},RTEModal=({isOpen:o,onClose:n,id:a,value:r,onChange:l,onBlur:i})=>{const c=React.useRef(null),d=React.useRef(r||""),p=usePageExternalData();React.useEffect(()=>{if(o){const h=document.createElement("style");return h.id="rte-modal-styles",h.innerHTML=`
60
62
  /* Ensure the NestedPathSelector popover appears above the dialog */
61
63
  .rte-path-selector + [data-radix-popper-content-wrapper],
62
64
  [data-radix-popper-content-wrapper] {
package/dist/core.d.ts CHANGED
@@ -98,6 +98,13 @@ export declare const ChaiBuilderCanvas: default_2.FC;
98
98
  export declare const ChaiBuilderEditor: default_2.FC<ChaiBuilderEditorProps>;
99
99
 
100
100
  export declare interface ChaiBuilderEditorProps {
101
+ /**
102
+ * Goto page callback
103
+ */
104
+ gotoPage?: ({ pageId, lang }: {
105
+ pageId: string;
106
+ lang: string;
107
+ }) => void;
101
108
  /**
102
109
  * User
103
110
  */
package/dist/core.js CHANGED
@@ -3005,6 +3005,8 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
3005
3005
  [data-drop="yes"] { outline: 2px dashed orange !important; outline-offset: -2px }
3006
3006
  [data-dnd="yes"] { pointer-events: auto !important}
3007
3007
  [data-dnd="no"],[data-block-type="GlobalBlock"],[data-block-type="PartialBlock"] > * { pointer-events: none !important; }
3008
+ [data-block-type="GlobalBlock"],[data-block-type="PartialBlock"] { position: relative !important; }
3009
+ .partial-overlay { pointer-events: auto !important; }
3008
3010
  [data-dnd-dragged="yes"] { opacity: 0.6; pointer-events: none; }
3009
3011
  [data-dnd-dragged="no"] { opacity: 1; pointer-events: auto !important; }
3010
3012
  [force-show] { display: block !important; }
@@ -3632,9 +3634,31 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3632
3634
  }) });
3633
3635
  const C = a === i._id && (l === x || x < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: E }) : E;
3634
3636
  return _ ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: C }) : C;
3637
+ }, PartialWrapper = ({ children: o, partialBlockId: n }) => {
3638
+ const r = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
3639
+ (d) => {
3640
+ if (d.stopPropagation(), a !== "SAVED") {
3641
+ toast.error("You have unsaved changes. Please save the page first.");
3642
+ return;
3643
+ }
3644
+ r({ pageId: n, lang: l || i });
3645
+ },
3646
+ [a, r, n, l, i]
3647
+ );
3648
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3649
+ o,
3650
+ /* @__PURE__ */ jsx("div", { className: "partial-overlay group absolute inset-0 z-50", children: /* @__PURE__ */ jsx(
3651
+ "div",
3652
+ {
3653
+ onDoubleClick: c,
3654
+ className: "flex h-full w-full items-center justify-center bg-black/10 opacity-0 transition-opacity duration-300 ease-in-out group-hover:opacity-100 group-hover:backdrop-opacity-85",
3655
+ children: /* @__PURE__ */ jsx("p", { className: "rounded-md bg-white px-2 py-1 text-xs", children: "Partial block. Double click to edit." })
3656
+ }
3657
+ ) })
3658
+ ] });
3635
3659
  }, PartialBlocksRenderer = ({ partialBlockId: o }) => {
3636
3660
  const { getPartailBlocks: n } = usePartialBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom(r)), [r]);
3637
- return isEmpty(r) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r });
3661
+ return isEmpty(r) ? null : /* @__PURE__ */ jsx(PartialWrapper, { partialBlockId: o, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r }) });
3638
3662
  }, BlocksRenderer = ({
3639
3663
  blocks: o,
3640
3664
  parent: n = null,
@@ -5299,8 +5323,8 @@ const BlockStylingProps = () => {
5299
5323
  const y = parseInt$1(S.target.value);
5300
5324
  let j = isNaN$1(y) ? 0 : y;
5301
5325
  S.keyCode === 38 && (j += 1), S.keyCode === 40 && (j -= 1);
5302
- const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
5303
- C(R);
5326
+ const I = `${j}`, P = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
5327
+ C(P);
5304
5328
  },
5305
5329
  onKeyUp: (S) => {
5306
5330
  w && (S.preventDefault(), _(!1));
@@ -6275,16 +6299,16 @@ function ManualClasses() {
6275
6299
  const L = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6276
6300
  u(h, L, !0), x("");
6277
6301
  }, [w, _] = useState([]), E = ({ value: L }) => {
6278
- const R = L.trim().toLowerCase(), T = R.match(/.+:/g);
6302
+ const P = L.trim().toLowerCase(), T = P.match(/.+:/g);
6279
6303
  let D = [];
6280
6304
  if (T && T.length > 0) {
6281
- const [O] = T, P = R.replace(O, "");
6282
- D = i.search(P).map((M) => ({
6305
+ const [O] = T, R = P.replace(O, "");
6306
+ D = i.search(R).map((M) => ({
6283
6307
  ...M,
6284
6308
  item: { ...M.item, name: O + M.item.name }
6285
6309
  }));
6286
6310
  } else
6287
- D = i.search(R);
6311
+ D = i.search(P);
6288
6312
  return _(map(D, "item"));
6289
6313
  }, C = () => {
6290
6314
  _([]);
@@ -6305,14 +6329,14 @@ function ManualClasses() {
6305
6329
  onKeyDown: (L) => {
6306
6330
  L.key === "Enter" && f.trim() !== "" && B();
6307
6331
  },
6308
- onChange: (L, { newValue: R }) => x(R),
6332
+ onChange: (L, { newValue: P }) => x(P),
6309
6333
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
6310
6334
  }),
6311
6335
  [f, c, o]
6312
6336
  ), y = (L) => {
6313
6337
  debugger;
6314
- const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6315
- g(h, [L]), u(h, R, !0), r(""), l(-1);
6338
+ const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6339
+ g(h, [L]), u(h, P, !0), r(""), l(-1);
6316
6340
  }, j = () => {
6317
6341
  if (navigator.clipboard === void 0) {
6318
6342
  toast.error(c("Clipboard not supported"));
@@ -6370,7 +6394,7 @@ function ManualClasses() {
6370
6394
  )
6371
6395
  ] }),
6372
6396
  /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: v.map(
6373
- (L, R) => a === R ? /* @__PURE__ */ jsx(
6397
+ (L, P) => a === P ? /* @__PURE__ */ jsx(
6374
6398
  "input",
6375
6399
  {
6376
6400
  ref: o,
@@ -7691,7 +7715,7 @@ const Input = ({ node: o }) => {
7691
7715
  }
7692
7716
  );
7693
7717
  }, currentAddSelection = atom(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
7694
- var R;
7718
+ var P;
7695
7719
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7696
7720
  let p = null;
7697
7721
  const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: k, isDragging: b, isEditing: v, handleClick: B } = o, w = (T) => {
@@ -7715,10 +7739,10 @@ const Input = ({ node: o }) => {
7715
7739
  return () => clearTimeout(T);
7716
7740
  }, [k, o, b]);
7717
7741
  const j = (T, D) => {
7718
- const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${T}]`);
7719
- P && P.setAttribute("data-drop", D);
7720
- const $ = P.getBoundingClientRect(), M = c.getBoundingClientRect();
7721
- $.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = P.offsetTop - M.top);
7742
+ const O = c.contentDocument || c.contentWindow.document, R = O.querySelector(`[data-block-id=${T}]`);
7743
+ R && R.setAttribute("data-drop", D);
7744
+ const $ = R.getBoundingClientRect(), M = c.getBoundingClientRect();
7745
+ $.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = R.offsetTop - M.top);
7722
7746
  }, I = (T) => {
7723
7747
  S();
7724
7748
  const D = get(o, "parent.id");
@@ -7764,7 +7788,7 @@ const Input = ({ node: o }) => {
7764
7788
  T.preventDefault(), j(m, "no");
7765
7789
  },
7766
7790
  children: [
7767
- d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7791
+ d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7768
7792
  "div",
7769
7793
  {
7770
7794
  onClick: (T) => {
@@ -9162,22 +9186,22 @@ const AiAssistant = () => {
9162
9186
  C.key === "Enter" && !C.shiftKey && (C.preventDefault(), u !== null ? w() : b());
9163
9187
  }, E = useCallback((C) => {
9164
9188
  const A = (y) => /[.,!?;:]/.test(y), N = (y, j, I) => {
9165
- let L = "", R = "";
9189
+ let L = "", P = "";
9166
9190
  const T = j > 0 ? y[j - 1] : "", D = j < y.length ? y[j] : "";
9167
- return j > 0 && (T === "." || !A(T) && T !== " ") && (L = " "), j < y.length && !A(D) && D !== " " && (R = " "), {
9168
- text: L + I + R,
9191
+ return j > 0 && (T === "." || !A(T) && T !== " ") && (L = " "), j < y.length && !A(D) && D !== " " && (P = " "), {
9192
+ text: L + I + P,
9169
9193
  prefixLength: L.length,
9170
- suffixLength: R.length
9194
+ suffixLength: P.length
9171
9195
  };
9172
9196
  }, S = x.current;
9173
9197
  if (S) {
9174
9198
  const y = S.selectionStart || 0, j = S.value || "", I = S.selectionEnd || y;
9175
9199
  if (I > y) {
9176
- const O = `{{${C}}}`, { text: P } = N(j, y, O), $ = j.slice(0, y) + P + j.slice(I);
9200
+ const O = `{{${C}}}`, { text: R } = N(j, y, O), $ = j.slice(0, y) + R + j.slice(I);
9177
9201
  p($);
9178
9202
  return;
9179
9203
  }
9180
- const R = `{{${C}}}`, { text: T } = N(j, y, R), D = j.slice(0, y) + T + j.slice(y);
9204
+ const P = `{{${C}}}`, { text: T } = N(j, y, P), D = j.slice(0, y) + T + j.slice(y);
9181
9205
  p(D);
9182
9206
  }
9183
9207
  }, []);
@@ -9703,22 +9727,22 @@ const FEATURE_TOGGLES = {
9703
9727
  }
9704
9728
  for (let j = A.length - 1; j >= 0; --j) {
9705
9729
  const [I, L] = A[j];
9706
- let R = !1;
9730
+ let P = !1;
9707
9731
  for (const T of L.d.keys())
9708
9732
  if (T !== I && a.has(T)) {
9709
- R = !0;
9733
+ P = !0;
9710
9734
  break;
9711
9735
  }
9712
- R && (k(I), B(I)), r.delete(I);
9736
+ P && (k(I), B(I)), r.delete(I);
9713
9737
  }
9714
9738
  }), k = h[3] || ((A) => {
9715
9739
  var N, S;
9716
9740
  const y = m(A);
9717
9741
  if (isAtomStateInitialized(y) && (n.has(A) && r.get(A) !== y.n || Array.from(y.d).every(
9718
- ([P, $]) => (
9742
+ ([R, $]) => (
9719
9743
  // Recursively, read the atom state of the dependency, and
9720
9744
  // check if the atom epoch number is unchanged
9721
- k(P).n === $
9745
+ k(R).n === $
9722
9746
  )
9723
9747
  )))
9724
9748
  return y;
@@ -9726,34 +9750,34 @@ const FEATURE_TOGGLES = {
9726
9750
  let j = !0;
9727
9751
  const I = () => {
9728
9752
  n.has(A) && (B(A), x(), f());
9729
- }, L = (P) => {
9753
+ }, L = (R) => {
9730
9754
  var $;
9731
- if (isSelfAtom(A, P)) {
9732
- const U = m(P);
9755
+ if (isSelfAtom(A, R)) {
9756
+ const U = m(R);
9733
9757
  if (!isAtomStateInitialized(U))
9734
- if (hasInitialValue(P))
9735
- setAtomStateValueOrPromise(P, P.init, m);
9758
+ if (hasInitialValue(R))
9759
+ setAtomStateValueOrPromise(R, R.init, m);
9736
9760
  else
9737
9761
  throw new Error("no atom init");
9738
9762
  return returnAtomValue(U);
9739
9763
  }
9740
- const M = k(P);
9764
+ const M = k(R);
9741
9765
  try {
9742
9766
  return returnAtomValue(M);
9743
9767
  } finally {
9744
- y.d.set(P, M.n), isPendingPromise(y.v) && addPendingPromiseToDependency(A, y.v, M), ($ = n.get(P)) == null || $.t.add(A), j || I();
9768
+ y.d.set(R, M.n), isPendingPromise(y.v) && addPendingPromiseToDependency(A, y.v, M), ($ = n.get(R)) == null || $.t.add(A), j || I();
9745
9769
  }
9746
9770
  };
9747
- let R, T;
9771
+ let P, T;
9748
9772
  const D = {
9749
9773
  get signal() {
9750
- return R || (R = new AbortController()), R.signal;
9774
+ return P || (P = new AbortController()), P.signal;
9751
9775
  },
9752
9776
  get setSelf() {
9753
- return !T && isActuallyWritableAtom(A) && (T = (...P) => {
9777
+ return !T && isActuallyWritableAtom(A) && (T = (...R) => {
9754
9778
  if (!j)
9755
9779
  try {
9756
- return v(A, ...P);
9780
+ return v(A, ...R);
9757
9781
  } finally {
9758
9782
  x(), f();
9759
9783
  }
@@ -9761,13 +9785,13 @@ const FEATURE_TOGGLES = {
9761
9785
  }
9762
9786
  }, O = y.n;
9763
9787
  try {
9764
- const P = d(A, L, D);
9765
- return setAtomStateValueOrPromise(A, P, m), isPromiseLike$1(P) && ((N = P.onCancel) == null || N.call(P, () => R == null ? void 0 : R.abort()), P.then(
9788
+ const R = d(A, L, D);
9789
+ return setAtomStateValueOrPromise(A, R, m), isPromiseLike$1(R) && ((N = R.onCancel) == null || N.call(R, () => P == null ? void 0 : P.abort()), R.then(
9766
9790
  I,
9767
9791
  I
9768
9792
  )), y;
9769
- } catch (P) {
9770
- return delete y.v, y.e = P, ++y.n, y;
9793
+ } catch (R) {
9794
+ return delete y.v, y.e = R, ++y.n, y;
9771
9795
  } finally {
9772
9796
  j = !1, O !== y.n && r.get(A) === O && (r.set(A, y.n), a.add(A), (S = c.c) == null || S.call(c, A));
9773
9797
  }
@@ -9783,14 +9807,14 @@ const FEATURE_TOGGLES = {
9783
9807
  }), v = h[5] || ((A, ...N) => {
9784
9808
  let S = !0;
9785
9809
  const y = (I) => returnAtomValue(k(I)), j = (I, ...L) => {
9786
- var R;
9810
+ var P;
9787
9811
  const T = m(I);
9788
9812
  try {
9789
9813
  if (isSelfAtom(A, I)) {
9790
9814
  if (!hasInitialValue(I))
9791
9815
  throw new Error("atom not writable");
9792
9816
  const D = T.n, O = L[0];
9793
- setAtomStateValueOrPromise(I, O, m), B(I), D !== T.n && (a.add(I), (R = c.c) == null || R.call(c, I), b(I));
9817
+ setAtomStateValueOrPromise(I, O, m), B(I), D !== T.n && (a.add(I), (P = c.c) == null || P.call(c, I), b(I));
9794
9818
  return;
9795
9819
  } else
9796
9820
  return v(I, ...L);
@@ -9834,19 +9858,19 @@ const FEATURE_TOGGLES = {
9834
9858
  }, n.set(A, y), (N = c.m) == null || N.call(c, A), isActuallyWritableAtom(A)) {
9835
9859
  const j = () => {
9836
9860
  let I = !0;
9837
- const L = (...R) => {
9861
+ const L = (...P) => {
9838
9862
  try {
9839
- return v(A, ...R);
9863
+ return v(A, ...P);
9840
9864
  } finally {
9841
9865
  I || (x(), f());
9842
9866
  }
9843
9867
  };
9844
9868
  try {
9845
- const R = g(A, L);
9846
- R && (y.u = () => {
9869
+ const P = g(A, L);
9870
+ P && (y.u = () => {
9847
9871
  I = !0;
9848
9872
  try {
9849
- R();
9873
+ P();
9850
9874
  } finally {
9851
9875
  I = !1;
9852
9876
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@chaibuilder/runtime"),i=require("react/jsx-runtime"),f=require("./common-functions-BZmyleS1.cjs"),k=require("react"),g=require("@radix-ui/react-icons"),d=require("lodash-es"),C=require("lucide-react");function v(e){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(l,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return l.default=e,Object.freeze(l)}const h=v(k),x=({className:e="",inBuilder:l})=>l?i.jsx("div",{className:f.cn("pointer-events-none flex h-20 flex-col items-center justify-center p-2",e),children:i.jsx("div",{className:"h-full w-full rounded bg-gray-200 p-2 dark:bg-gray-800",children:i.jsx("div",{className:"flex h-full w-full items-center justify-center outline-dashed outline-1 -outline-offset-1 outline-gray-400 duration-300 dark:outline-gray-700"})})}):null,j=e=>{const{blockProps:l,inBuilder:t,backgroundImage:r,children:s,tag:n="div",styles:a}=e;let c=s;s||(c=i.jsx(x,{inBuilder:t}));let p={};return r&&(p={backgroundImage:`url(${r})`}),h.createElement(n,{...l,...a,style:p},c)},L={type:"Box",description:"Similar to a div or section elements in HTML",label:"Box",category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),backgroundImage:{type:"string",default:"",title:"Background Image",ui:{"ui:widget":"image"}},tag:{type:"string",default:"div",title:"Tag",oneOf:[{const:"div",title:"div"},{const:"header",title:"header"},{const:"footer",title:"footer"},{const:"section",title:"section"},{const:"article",title:"article"},{const:"aside",title:"aside"},{const:"main",title:"main"},{const:"nav",title:"nav"},{const:"figure",title:"figure"},{const:"details",title:"details"},{const:"summary",title:"summary"},{const:"dialog",title:"dialog"},{const:"strike",title:"strike"},{const:"caption",title:"caption"},{const:"legend",title:"legend"},{const:"figcaption",title:"figcaption"},{const:"mark",title:"mark"}]}}}),canAcceptBlock:()=>!0},_=e=>{const{blockProps:l,iconSize:t,icon:r,content:s,styles:n,children:a,iconPos:c,link:p,inBuilder:u}=e,b=r,y=a||i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-ai-key":"content",children:s}),b&&i.jsx("div",{style:{width:t+"px"},className:c+" "+(c==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:b}})]}),m=k.createElement("button",{...l,...n,type:"button","aria-label":s},y);return d.isEmpty(d.get(p,"href"))?m:u?i.jsx("span",{children:m}):i.jsx("a",{"aria-label":s,href:d.get(p,"href")||"/",target:d.get(p,"target","_self"),children:m})},T={type:"Button",description:"similar to a button element in HTML",label:"Button",category:"core",icon:g.ButtonIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-primary-foreground bg-primary px-4 py-2 rounded-lg flex items-center"),content:{type:"string",title:"Button label",default:"Button"},icon:{type:"string",title:"Icon",default:"",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:16},iconPos:{type:"string",title:"Icon position",default:"order-last",enum:["order-first","order-last"]},link:{type:"object",properties:{type:{type:"string"},href:{type:"string"},target:{type:"string"}},default:{type:"url",href:"",target:"_self"},ui:{"ui:field":"link"}}}}),i18nProps:["content"],aiProps:["content"]},E=e=>{const{blockProps:l,iconSize:t,icon:r,content:s,styles:n}=e,a=r,c=i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-ai-key":"content",children:s}),a&&i.jsx("div",{style:{width:t+"px"},dangerouslySetInnerHTML:{__html:a}})]});return k.createElement("button",{...l,...n,type:"button","aria-label":s},c)},N={type:"CopyButton",description:"A copy button component",label:"Copy Button",category:"core",icon:g.CopyIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("p-2 rounded-md flex items-center"),content:{type:"string",title:"Button label",default:"Button"},icon:{type:"string",title:"Icon",default:"<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-copy'><path d='M8 17L19 8M8 17V7a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v10'/></svg>",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:20}}}),i18nProps:["content"],aiProps:["content"]},R=e=>{const{blockProps:l,styles:t,htmlCode:r,inBuilder:s}=e;return s?i.jsxs("div",{className:"relative",children:[s?i.jsx("div",{...l,...t,className:"absolute z-20 h-full w-full"}):null,h.createElement("div",{...t,dangerouslySetInnerHTML:{__html:r.replace(/<script.*?>.*?<\/script>/g,"")}})]}):h.createElement("div",{...l,...t,dangerouslySetInnerHTML:{__html:r}})},M={type:"CustomHTML",description:"similar to a div or section elements in HTML",label:"Custom HTML",category:"core",icon:g.CodeIcon,group:"advanced",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),htmlCode:{type:"string",default:"<div><p>Enter your HTML code here...</p></div>",ui:{"ui:widget":"code"}}}})},$=e=>{const{scripts:l,inBuilder:t,blockProps:r}=e;return t?i.jsx("div",{...r,children:i.jsx("div",{className:f.cn("pointer-events-none flex flex-col items-center justify-center p-2",""),children:i.jsx("div",{className:"h-full w-full rounded bg-gray-200 p-1 dark:bg-gray-800",children:i.jsx("p",{className:"text-left text-xs text-gray-400",children:"Scripts will be only executed in preview and live mode. Place your script at the bottom of the"})})})}):i.jsx("div",{dangerouslySetInnerHTML:{__html:l}})},A={type:"CustomScript",description:"similar to a script element in HTML",label:"Custom Script",category:"core",icon:C.FileCode,group:"advanced",...o.registerChaiBlockSchema({properties:{scripts:{type:"string",title:"Script",default:"",format:"code",placeholder:"<script>console.log('Hello, world!');<\/script>"}}})},H=e=>{const{blockProps:l,styles:t}=e;return k.createElement("hr",{...t,...l})},U={type:"Divider",description:"A horizontal line component",label:"Divider",category:"core",icon:g.DividerHorizontalIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("bg-gray-900 h-0.5 py-2 my-1")}})},D=e=>{const{blockProps:l,styles:t,backgroundImage:r}=e;let s={};return r&&(s={backgroundImage:`url(${r})`}),h.createElement("div",{...l,...t,style:s})},q={type:"EmptyBox",description:"A box component with no children",label:"Empty Box",category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),backgroundImage:{type:"string",title:"Background Image",default:"",ui:{"ui:widget":"image"}}}})},z=e=>{const{blockProps:l,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,u=f.generateUUID();return p?i.jsxs("div",{...s,...l,children:[i.jsx("input",{...n,name:t,id:u,type:"checkbox",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:u,children:r})]}):i.jsx("input",{id:u,...l,...n,...s,type:"checkbox",required:a,name:t})},F={type:"Checkbox",label:"web_blocks.checkbox",category:"core",icon:g.CheckboxIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("flex items-center gap-x-2"),inputStyles:o.StylesProp(""),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]},V=e=>{const{children:l,blockProps:t,errorMessage:r,successMessage:s,action:n,styles:a,inBuilder:c}=e;let p=l;l||(p=i.jsx(x,{inBuilder:c}));const u={"x-data":"{}","x-on:submit.prevent":"post"},b={"x-html":"",":class":"{'text-red-500': formStatus === 'ERROR', 'text-green-500': formStatus === 'SUCCESS'}"};return i.jsxs("form",{...u,"data-error":r,"data-success":s,method:"post",action:n,...t,...a,children:[i.jsx("div",{...b}),p]})},O={type:"Form",label:"Form",category:"core",icon:C.GroupIcon,group:"form",blocks:()=>[{_type:"Form",_id:"form",styles:"#styles:p-1 space-y-2,"},{_type:"Input",_id:"form_input",_parent:"form",styles:"#styles:,"},{_type:"FormButton",_id:"form_submit_btn",_parent:"form",styles:"#styles:bg-black text-white rounded px-3 py-1,"}],...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),action:{type:"string",title:"Submit URL",default:"/api/form"},errorMessage:{type:"string",title:"Error Message",default:"Something went wrong. Please try again",ui:{"ui:widget":"richtext"}},successMessage:{type:"string",title:"Success Message",default:"Thank you for your submission.",ui:{"ui:widget":"richtext"}}}}),i18nProps:["errorMessage","successMessage"],aiProps:["errorMessage","successMessage"],canAcceptBlock:()=>!0},G=e=>{const{blockProps:l,inBuilder:t,label:r,styles:s,inputStyles:n,icon:a,iconSize:c,iconPos:p}=e,u=f.generateUUID(),b={"x-bind:disabled":"formLoading"};return i.jsxs("button",{id:u,...b,...n,...s,...l||{},type:t?"button":"submit","aria-label":r,children:[r,a&&i.jsx("div",{style:{width:c+"px"},className:p+" "+(p==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:a}})]})},Y={type:"FormButton",label:"Submit Button",category:"core",icon:g.ButtonIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-white bg-primary disabled:bg-gray-400 px-4 py-2 rounded-global flex items-center gap-x-2"),inputStyles:o.StylesProp(""),label:{type:"string",title:"Label",default:"Submit",ai:!0,i18n:!0},icon:{type:"string",title:"Icon",default:"",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:24},iconPos:{type:"string",title:"Icon Position",default:"order-last",enum:["order-first","order-last"]}}}),i18nProps:["label"],aiProps:["label"]},W=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,showLabel:c,required:p,inputType:u,autocomplete:b}=e,y=f.generateUUID();return c?i.jsxs("div",{...n,...l,children:[c&&i.jsx("label",{htmlFor:y,children:r}),i.jsx("input",{name:t,...a,id:y,type:u,placeholder:s,required:p,autoComplete:b?"on":"off"})]}):i.jsx("input",{id:y,name:t,...l,...a,...n,type:u,placeholder:s,required:p,autoComplete:b?"on":"off"})},X={type:"Input",label:"web_blocks.input",category:"core",icon:g.InputIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ai:!0,i18n:!0},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},inputType:{type:"string",title:"Input Type",default:"text",enum:["text","email","password","number","tel","hidden","range","color","date","time","name","postal-code"]},required:{type:"boolean",title:"Required",default:!1},autocomplete:{type:"boolean",title:"Autocomplete",default:!0}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},J=e=>{const{blockProps:l,content:t,styles:r,children:s}=e,n={...r,...l};return s?h.createElement("label",n,s):h.createElement("label",{...n,dangerouslySetInnerHTML:{__html:t}})},Q={type:"Label",label:"Label",category:"core",icon:g.LetterCaseToggleIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(),content:{type:"string",title:"Content",default:""}}}),aiProps:["content"],i18nProps:["content"]},Z=e=>{const{blockProps:l,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,u=f.generateUUID();return p?i.jsxs("div",{...s,...l,children:[i.jsx("input",{...n,name:t,id:u,type:"radio",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:u,children:r})]}):i.jsx("input",{id:u,...l,...n,...s,type:"radio",required:a,checked:c,name:t})},K={type:"Radio",label:"web_blocks.radio",category:"core",icon:g.RadiobuttonIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("flex items-center gap-x-2"),inputStyles:o.StylesProp(""),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]},ee=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,required:c,showLabel:p,_multiple:u,options:b}=e,y=f.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:y,children:r}),i.jsxs("select",{...a,id:y,required:c,multiple:u,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:s}),d.map(b,m=>i.jsx("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})]}):i.jsxs("select",{id:y,...n,...l,required:c,multiple:u,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:s}),d.map(b,m=>i.jsx("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})},te={type:"Select",label:"web_blocks.select",category:"core",icon:g.DropdownMenuIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label"},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},required:{type:"boolean",title:"Required",default:!1},_multiple:{type:"boolean",title:"Multiple",default:!1},options:{title:"Options",type:"array",default:[],items:{type:"object",properties:{label:{type:"string",title:"Label",default:""},value:{type:"string",title:"Value",default:""}}}}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},oe=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,rows:c,showLabel:p,required:u}=e,b=f.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:b,children:r}),i.jsx("textarea",{name:t,...a,id:b,placeholder:s,rows:c,required:u})]}):i.jsx("textarea",{id:b,name:t,...l,...a,...n,placeholder:s,rows:c,required:u})},le={type:"TextArea",label:"web_blocks.textarea",category:"core",icon:g.InputIcon,group:"form",...o.registerChaiBlockSchema({properties:{fieldName:{type:"string",title:"Field Name",default:"fieldName"},styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},rows:{type:"number",title:"Rows",default:3},required:{type:"boolean",title:"Required",default:!1}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},re=e=>{const{blockProps:l,inBuilder:t,children:r,globalBlock:s}=e;return t&&!s?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",...l,children:[i.jsxs("h1",{children:["Global Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},r)},se={type:"GlobalBlock",description:"A global block component",label:"Global Block",icon:C.GlobeIcon,category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{globalBlock:{type:"string",title:"Global Block",default:"",ui:{"ui:widget":"hidden"}}}})},ie=e=>{const{blockProps:l,styles:t,content:r,tag:s="h1",children:n=null}=e;return n?h.createElement(s,{...t,...l},n):h.createElement(s,{...t,...l,dangerouslySetInnerHTML:{__html:r}})},ne={type:"Heading",description:"A heading component similar to h1, h2, h3, h4, h5, h6 elements in HTML",label:"Heading",category:"core",icon:g.HeadingIcon,group:"typography",...o.registerChaiBlockSchema({properties:{tag:{type:"string",default:"h2",title:"Level",enum:["h1","h2","h3","h4","h5","h6"]},styles:o.StylesProp("text-3xl"),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e==="Span"||e==="Text"},ae=e=>{const{blockProps:l,styles:t}=e;return k.createElement("br",{...l,...t})},ce={type:"LineBreak",label:"Line Break",category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},pe=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("table",{...l,...r},t):i.jsx(x,{})},de=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("thead",{...l,...r},t):i.jsx(x,{})},ue=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tbody",{...l,...r},t):i.jsx(x,{})},ge=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tr",{...l,...r},t):i.jsx(x,{})},me=e=>{const{blockProps:l,children:t,content:r,styles:s}=e;return!t&&d.isEmpty(r)?i.jsx(x,{}):t?k.createElement("td",{...l,...s},t):k.createElement("td",{...l,...s,dangerouslySetInnerHTML:{__html:r}})};o.registerChaiBlock(pe,{type:"Table",label:"Table",category:"core",group:"table",hidden:!0,icon:g.TableIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("Table")});o.registerChaiBlock(de,{type:"TableHead",label:"Table Head",category:"core",group:"table",hidden:!0,icon:g.BorderTopIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableHead")});o.registerChaiBlock(ue,{type:"TableBody",label:"Table Body",category:"core",group:"table",hidden:!0,icon:g.BorderAllIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableBody")});o.registerChaiBlock(ge,{type:"TableRow",label:"Table Row",category:"core",group:"table",hidden:!0,icon:g.ViewHorizontalIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableRow")});o.registerChaiBlock(me,{type:"TableCell",label:"Table Cell",category:"core",group:"table",hidden:!0,icon:g.DragHandleHorizontalIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),blocks:B("TableCell"),i18nProps:["content"],aiProps:["content"]});function B(e){const l=(n,a)=>({_id:f.generateUUID(),_parent:n,_type:"TableCell",styles:"#styles:,",content:`${e==="TableHead"?"Table Head":"Table Cell "+a}`}),t=n=>{const a=f.generateUUID(),c={_type:"TableRow",_id:a,styles:"#styles:,border-b"};return n&&(c._parent=n),[c,l(a,"1"),l(a,"2"),l(a,"3")]},r=n=>{const a=f.generateUUID(),c={_id:a,_type:"TableHead",styles:"#styles:,font-medium"};return n&&(c._parent=n),[c,...t(a)]},s=n=>{const a=f.generateUUID(),c={_id:a,_type:"TableBody",styles:"#styles:,"};return n&&(c._parent=n),[c,...t(a),...t(a)]};if(e==="Table"){const n=f.generateUUID();return[{_id:n,_type:"Table",styles:"#styles:,w-full text-left text-gray-500 dark:text-gray-400"},...r(n),...s(n)]}return e==="TableRow"?t():e==="TableHead"?r():e==="TableBody"?s():[]}const I=(e,...l)=>({...e,className:f.cn(e.className,...l)}),ye=e=>{const{blockProps:l,icon:t,styles:r,width:s,inBuilder:n,height:a}=e,c=I(r,"");if(d.isEmpty(t))return i.jsx(x,{inBuilder:n,className:"h-8 w-14"});const p=t.replace(/<svg /g,'<svg class="w-[inherit] h-[inherit]" ');return h.createElement("span",{...l,...c,style:{width:s?`${s}px`:"auto",height:a?`${a}px`:"auto"},dangerouslySetInnerHTML:{__html:p}})},he={type:"Icon",label:"web_blocks.icon",category:"core",icon:g.SketchLogoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),icon:{type:"string",title:"Icon",default:'<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M8 16c4.418 0 8-3.582 8-8s-3.582-8-8-8-8 3.582-8 8 3.582 8 8 8zM8 1.5c3.59 0 6.5 2.91 6.5 6.5s-2.91 6.5-6.5 6.5-6.5-2.91-6.5-6.5 2.91-6.5 6.5-6.5zM8 9.356c1.812 0 3.535-0.481 5-1.327-0.228 2.788-2.393 4.971-5 4.971s-4.772-2.186-5-4.973c1.465 0.845 3.188 1.329 5 1.329zM4 5.5c0-0.828 0.448-1.5 1-1.5s1 0.672 1 1.5c0 0.828-0.448 1.5-1 1.5s-1-0.672-1-1.5zM10 5.5c0-0.828 0.448-1.5 1-1.5s1 0.672 1 1.5c0 0.828-0.448 1.5-1 1.5s-1-0.672-1-1.5z"></path></svg>',ui:{"ui:widget":"icon"}},width:{type:"number",default:16,title:"Width"},height:{type:"number",default:16,title:"Height"}}})},be=e=>{const{blockProps:l,image:t,mobileImage:r,styles:s,alt:n,height:a,width:c,lazyLoading:p}=e;return d.isEmpty(t)?i.jsx(x,{className:"h-36"}):i.jsxs("picture",{children:[r&&i.jsx("source",{srcSet:r,media:"(max-width: 480px)"}),i.jsx("img",{...l,...s,src:t,alt:n,loading:p?"lazy":"eager",width:c,height:a})]})},fe={type:"Image",description:"A image component",label:"Image",category:"core",icon:g.ImageIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),image:{type:"string",title:"Image",default:"https://fakeimg.pl/400x200?text=Choose&font=bebas",ui:{"ui:widget":"image"}},alt:{type:"string",title:"Alt text",default:"",ui:{"ui:placeholder":"Enter alt text"}},lazyLoading:{type:"boolean",title:"Lazy Load",default:!0},width:{type:"number",title:"Width",default:"",ui:{"ui:placeholder":"Enter width"}},height:{type:"number",title:"Height",default:"",ui:{"ui:placeholder":"Enter height"}},mobileImage:{type:"string",title:"Mobile Image",default:"",ui:{"ui:widget":"image"}},assetId:{type:"string",title:"Asset ID",default:"",ui:{"ui:widget":"hidden"}}}}),aiProps:["alt"],i18nProps:["alt"]},ke=e=>{const{blockProps:l,link:t,children:r,styles:s,inBuilder:n,content:a}=e;let c={};return!r&&d.isEmpty(a)&&(c={minHeight:"50px",display:"flex",alignItems:"center",justifyContent:"center"}),n?r?i.jsx("span",{...l,style:c,...s,children:r}):k.createElement("span",{...l,...s,style:c},a):r?i.jsx("a",{"aria-label":a,href:(t==null?void 0:t.href)||"#/",target:t==null?void 0:t.target,...l,...s,children:r}):k.createElement("a",{...l,...s,href:(t==null?void 0:t.href)||"#",target:(t==null?void 0:t.target)||"_self","aria-label":a},a)},xe={type:"Link",description:"A link component",label:"Link",category:"core",icon:g.Link1Icon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"Link goes here",title:"Content"},link:{type:"object",properties:{type:{type:"string"},href:{type:"string"},target:{type:"string"}},default:{type:"url",href:"",target:"_self"},ui:{"ui:field":"link"}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e!=="Link"},Ce=e=>{const{blockProps:l,children:t,listType:r,styles:s,tag:n,inBuilder:a}=e,c=f.cn(d.get(s,"className",""),r);return!t&&d.isEmpty(s==null?void 0:s.className)?i.jsx(x,{inBuilder:a}):h.createElement(n||(r==="list-decimal"?"ol":"ul"),{...l,...s,className:c},t)},Be={type:"List",description:"A list component",label:"List",icon:g.RowsIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),listType:{type:"string",title:"List Type",default:"list-none",oneOf:[{enum:["list-none"],title:"List None"},{enum:["list-disc"],title:"Disc"},{enum:["list-decimal"],title:"Decimal"}]}}}),canAcceptBlock:e=>e==="ListItem",blocks:[{_type:"List",_id:"a",listType:"list-none",styles:"#styles:,"},{_type:"ListItem",_id:"b",_parent:"a",styles:"#styles:,",content:"Item 1"},{_type:"ListItem",_id:"c",_parent:"a",styles:"#styles:,",content:"Item 2"},{_type:"ListItem",_id:"d",_parent:"a",styles:"#styles:,",content:"Item 3"}]},Se=e=>{const{blockProps:l,content:t,styles:r,children:s,tag:n}=e;return s?h.createElement(n||"li",{...r,...l},s):h.createElement(n||"li",{...r,...l,dangerouslySetInnerHTML:{__html:t}})},we={type:"ListItem",description:"A list item component",label:"List Item",icon:g.ColumnsIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"List item",title:"Content",ui:{"ui:widget":"textarea"}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e!=="ListItem",canBeNested:e=>e==="List"||e==="Repeater"},Pe=e=>{const{blockProps:l,styles:t,content:r}=e;return d.isNull(e.children)?h.createElement("p",{...t,...l,dangerouslySetInnerHTML:{__html:r}}):h.createElement("p",{...t,...l},e.children)},Ie={type:"Paragraph",description:"A paragraph component",label:"Paragraph",category:"core",icon:g.TextIcon,group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":5}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e==="Span"||e==="Link"||e==="Text"},ve=e=>{const{blockProps:l,inBuilder:t,children:r,partialBlockId:s}=e;return t&&!s?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",...l,children:[i.jsxs("h1",{children:["Partial Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},r)},je={type:"PartialBlock",description:"A partial block component",label:"Partial Block",icon:C.GlobeIcon,category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{partialBlockId:{type:"string",title:"Partial Block",default:"",ui:{"ui:widget":"hidden"}}}})},S={SMALL:{1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4",5:"col-span-5",6:"col-span-6",7:"col-span-7",8:"col-span-8",9:"col-span-9",10:"col-span-10",11:"col-span-11",12:"col-span-12"},MEDIUM:{1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3",4:"md:col-span-4",5:"md:col-span-5",6:"md:col-span-6",7:"md:col-span-7",8:"md:col-span-8",9:"md:col-span-9",10:"md:col-span-10",11:"md:col-span-11",12:"md:col-span-12"},LARGE:{1:"lg:col-span-1",2:"lg:col-span-2",3:"lg:col-span-3",4:"lg:col-span-4",5:"lg:col-span-5",6:"lg:col-span-6",7:"lg:col-span-7",8:"lg:col-span-8",9:"lg:col-span-9",10:"lg:col-span-10",11:"lg:col-span-11",12:"lg:col-span-12"}},Le=e=>{const{blockProps:l,children:t,styles:r,colSpan:s,tabletColSpan:n,desktopColSpan:a}=e,p={className:[d.get(r,"className",""),d.get(S,["SMALL",isNaN(s)||!s?6:s],""),n?d.get(S,["MEDIUM",n||s],""):"",a?d.get(S,["LARGE",n||s],""):""].join(" ")};return i.jsx("div",{...l,...r,...p,children:t||i.jsx("div",{className:"h-full min-h-12 w-full border-2 border-dashed border-gray-400 bg-gray-100 dark:bg-gray-900"})})},_e={type:"Column",description:"A column component",label:"Column",group:"basic",category:"core",icon:C.Columns,wrapper:!0,canDelete:()=>!0,canAcceptBlock:()=>!0,canBeNested:e=>e==="Row",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),colSpan:{type:"number",title:"Column Span",default:6,enum:[1,2,3,4,5,6,7,8,9,10,11,12]},tabletColSpan:{type:"number",title:"Column Span (Tablet)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]},desktopColSpan:{type:"number",title:"Column Span (Desktop)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]}}})},Te=e=>{const{blockProps:l,children:t,styles:r,gutter:s}=e,a={className:[d.get(r,"className","")," grid grid-cols-12"].join()};return typeof(r==null?void 0:r.style)=="object"?r.style.gap=`${s}px`:a.style={gap:`${s}px`},i.jsx("div",{...l,...r,...a,children:t})},Ee={type:"Row",description:"A row component",label:"Row",group:"basic",icon:C.Rows,blocks:()=>[{_type:"Row",_id:"row",styles:"#styles:,p-1"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"}],category:"core",wrapper:!0,canAcceptBlock:e=>e==="Column",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),colCount:{type:"number",default:2,minimum:0,ui:{"ui:widget":"colCount"}},gutter:{type:"number",title:"Gutter (in px)",default:16,minimum:0}}})},Ne=e=>{const{blockProps:l,content:t,styles:r}=e,s=I(r,"prose dark:prose-invert prose-p:m-0 prose-p:min-h-[1rem] prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0","max-w-full");return i.jsx("div",{...l,...s,dangerouslySetInnerHTML:{__html:t}})},Re={type:"RichText",description:"A rich text block",label:"Rich Text",category:"core",icon:g.CursorTextIcon,group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"<p>This is a rich text block. You can add text, and other content here.</p>",ui:{"ui:widget":"richtext"}}}}),aiProps:["content"],i18nProps:["content"]},Me=e=>{const{blockProps:l,styles:t,content:r,children:s=null,tag:n}=e;return s?h.createElement("span",{...t,...l},s):h.createElement(n||"span",{...t,...l,dangerouslySetInnerHTML:{__html:r||""}})},$e={type:"Span",description:"A span component",label:"Span",category:"core",group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:()=>!0},Ae=e=>e.inBuilder||e.forceWrapper?i.jsx("span",{...e.blockProps,children:e.content}):`${e.content}`,He={type:"Text",description:"A text component with no styling",label:"Text",hidden:!0,category:"core",group:"typography",icon:g.SpaceBetweenVerticallyIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-black"),content:{title:"Content",type:"string",default:""}}}),aiProps:["content"],i18nProps:["content"]},Ue={type:"object",title:"Controls",default:{autoplay:!0,controls:!1,loop:!0,muted:!0},properties:{autoplay:{type:"boolean",title:"Autoplay",default:!1},controls:{type:"boolean",title:"Show Controls",default:!0},loop:{type:"boolean",title:"Loop Video",default:!1},muted:{type:"boolean",title:"Muted",default:!1}}},w=/^(https?:\/\/)?(www\.)?youtube\.com\/(watch\?v=|embed\/)([a-zA-Z0-9_-]{11})/,P=/(?:https?:\/\/)?(?:www\.)?(?:vimeo\.com\/(?:channels\/[\w]+\/|groups\/[^\/]+\/videos\/|album\/\d+\/video\/|video\/)?|player\.vimeo\.com\/video\/)(\d+)/,De=(e,l)=>{const t=d.get(l,"autoplay",!1),r=d.get(l,"controls",!1),s=d.get(l,"loop",!1),n=t||d.get(l,"muted",!0);if(w.test(e)){const a=e.match(w);if(a){const c=a[4];let p=`https://www.youtube.com/embed/${c}`,u=t?"autoplay=1":"";return u+=s?`&loop=1&playlist=${c}`:"",u+=n?"&mute=1&muted=1":"",u+=r?"&controls=1":"&controls=0",`${p}?${u}`}}if(P.test(e)){const a=e.match(P);if(a){const c=a[1];let p="";return p+=t?"autoplay=1":"",p+=r?"&controls=1":"&controls=0",p+=n?"&muted=1":"",p+=s?"&loop=1":"",`https://player.vimeo.com/video/${c}?${p}`}}return null},qe=e=>{const{url:l,blockProps:t,styles:r,controls:s,videoSource:n,inBuilder:a}=e,c=De(l,s);return i.jsxs("div",{...d.omit(r,"className"),className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:[!c&&a?i.jsx("div",{className:"absolute flex h-full w-full items-center justify-center bg-gray-300 text-center",children:d.isEmpty(l)?`Provided ${n} video link in settings Video URL.`:`Provided ${n} video link is invalid.`}):i.jsx("iframe",{width:"100%",src:c,...d.pick(r,"className")}),a&&i.jsx("div",{...t,className:"absolute top-0 h-full w-full"})]})},ze=e=>{const{url:l,styles:t,controls:r,sources:s,poster:n,blockProps:a}=e;let c=n;const p=[...d.get(s,"srcsets",[])||[]];l&&typeof l=="string"&&p.push({url:l,width:"9999"});const u=p.sort((y,m)=>parseInt(y.width)-parseInt(m.width)).filter(y=>!d.isEmpty(y.url)&&!d.isEmpty(y.width));u.length===0&&!c&&(c="https://placehold.co/300x200/EEE/ccc?text=Choose%20Video");const b=d.get(r,"autoplay",!1)||d.get(r,"muted",!0);return(c||!d.isEmpty(u))&&i.jsx("div",{className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:k.createElement("video",{...t,...a,key:JSON.stringify(u),controls:d.get(r,"controls",!1),autoPlay:d.get(r,"autoplay",!1),loop:d.get(r,"loop",!1),poster:c,...b?{muted:!0}:{}},u.map(y=>{if(!y.url||y.url.length<4||isNaN(y.width))return null;const m=`(max-width: ${y.width}px)`;return i.jsx("source",{src:y.url,media:m,type:y.type},y.url)}),"Your browser does not support the video tag.")})},Fe=e=>{const{videoSource:l}=e;return l==="Custom"?i.jsx(ze,{...e}):l==="Youtube"||l==="Vimeo"?i.jsx(qe,{...e}):i.jsxs("div",{children:["Invalid video source : ",l]})},Ve={type:"Video",label:"Video",category:"core",icon:g.VideoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("absolute h-full w-full object-cover"),videoSource:{type:"string",default:"Custom",enum:["Custom","Youtube","Vimeo"],title:"Video source"}},allOf:[{if:{properties:{videoSource:{const:"Custom"}}},then:{properties:{url:{type:"string",title:"Video URL",default:""},poster:{type:"string",title:"Poster URL",default:""},sources:{type:"object",default:{srcsets:[]}},controls:{...Ue}}}},{if:{properties:{videoSource:{const:"Youtube"}}},then:{properties:{url:{type:"string",title:"Youtube Video URL",default:""}}}},{if:{properties:{videoSource:{const:"Vimeo"}}},then:{properties:{url:{type:"string",title:"Vimeo Video URL",default:""}}}}],ui:{url:{"ui:placeholder":"Enter Video URL"},sources:{"ui:field":"sources"},poster:{"ui:placeholder":"Enter poster URL"}}}),i18nProps:["url"]},Oe=e=>{const{children:l,tag:t,styles:r,blockProps:s,inBuilder:n,$loading:a}=e;let c=l;return d.isEmpty(c)&&n&&(c=i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Choose a collection to display items"})),h.createElement(t,{...s,...r},a&&n?Array.from({length:2}).map((p,u)=>i.jsxs("div",{className:"animate-pulse rounded-md bg-primary/10 p-5",children:[i.jsx("div",{className:"h-6 w-1/2 rounded-md bg-primary/10"}),i.jsx("div",{className:"mt-2 h-4 w-1/2 rounded-md bg-primary/10"})]},u)):c)},Ge={type:"Repeater",label:"Repeater",icon:g.LoopIcon,group:"basic",dataProviderMode:"live",dataProviderDependencies:["filter","sort","limit","repeaterItems"],blocks:()=>[{_id:"A",_type:"Repeater",tag:"ul"},{_id:"B",_name:"Repeater Item",_type:"RepeaterItem",parentTag:"ul",_parent:"A"}],...o.registerChaiBlockSchema({properties:{styles:o.stylesProp("grid gap-4 md:grid-cols-2 xl:grid-cols-3"),repeaterItems:{title:"Collection",type:"string",binding:"array",default:"",ui:{"ui:widget":"repeaterBinding","ui:readonly":!0}},tag:{title:"Tag",type:"string",default:"ul",enum:["div","ul","ol"]},limit:{title:"Limit",type:"number",default:3},filter:{title:"Filter by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}},sort:{title:"Sort by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}}}})},Ye=({children:e,blockProps:l,styles:t,parentTag:r,inBuilder:s})=>{let n="li";switch(r){case"ul":n="li";break;case"ol":n="li";break;default:n="div"}return!e&&s?h.createElement(n,{...l,...t},i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Add children to repeater item"})):h.createElement(n,{...l,...t},e)},We={type:"RepeaterItem",label:"Repeater Item",icon:g.LoopIcon,hidden:!0,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.stylesProp(""),parentTag:o.closestBlockProp("Repeater","tag")}}),canAcceptBlock:e=>e!=="RepeaterItem",canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Xe=({children:e,blockProps:l,styles:t})=>h.createElement("div",{...l,...t},e),Je={type:"RepeaterEmptyState",label:"Empty State",hidden:!0,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.stylesProp("p-5 flex items-center justify-center")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Qe=()=>{o.registerChaiBlock(j,L),o.registerChaiBlock(D,q),o.registerChaiBlock(_,T),o.registerChaiBlock(ie,ne),o.registerChaiBlock(Pe,Ie),o.registerChaiBlock(Me,$e),o.registerChaiBlock(Ne,Re),o.registerChaiBlock(ke,xe),o.registerChaiBlock(Ce,Be),o.registerChaiBlock(Se,we),o.registerChaiBlock(ye,he),o.registerChaiBlock(be,fe),o.registerChaiBlock(Fe,Ve),o.registerChaiBlock(R,M),o.registerChaiBlock($,A),o.registerChaiBlock(Ae,He),o.registerChaiBlock(V,O),o.registerChaiBlock(G,Y),o.registerChaiBlock(W,X),o.registerChaiBlock(z,F),o.registerChaiBlock(Z,K),o.registerChaiBlock(ee,te),o.registerChaiBlock(oe,le),o.registerChaiBlock(J,Q),o.registerChaiBlock(ae,ce),o.registerChaiBlock(H,U),o.registerChaiBlock(re,se),o.registerChaiBlock(ve,je),o.registerChaiBlock(Te,Ee),o.registerChaiBlock(Le,_e),o.registerChaiBlock(E,N),o.registerChaiBlock(Oe,Ge),o.registerChaiBlock(Ye,We),o.registerChaiBlock(Xe,Je)};exports.loadWebBlocks=Qe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@chaibuilder/runtime"),i=require("react/jsx-runtime"),f=require("./common-functions-BZmyleS1.cjs"),k=require("react"),g=require("@radix-ui/react-icons"),u=require("lodash-es"),C=require("lucide-react");function I(e){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(l,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return l.default=e,Object.freeze(l)}const h=I(k),x=({className:e="",inBuilder:l})=>l?i.jsx("div",{className:f.cn("pointer-events-none flex h-20 flex-col items-center justify-center p-2",e),children:i.jsx("div",{className:"h-full w-full rounded bg-gray-200 p-2 dark:bg-gray-800",children:i.jsx("div",{className:"flex h-full w-full items-center justify-center outline-dashed outline-1 -outline-offset-1 outline-gray-400 duration-300 dark:outline-gray-700"})})}):null,j=e=>{const{blockProps:l,inBuilder:t,backgroundImage:r,children:s,tag:n="div",styles:a}=e;let c=s;s||(c=i.jsx(x,{inBuilder:t}));let p={};return r&&(p={backgroundImage:`url(${r})`}),h.createElement(n,{...l,...a,style:p},c)},L={type:"Box",description:"Similar to a div or section elements in HTML",label:"Box",category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),backgroundImage:{type:"string",default:"",title:"Background Image",ui:{"ui:widget":"image"}},tag:{type:"string",default:"div",title:"Tag",oneOf:[{const:"div",title:"div"},{const:"header",title:"header"},{const:"footer",title:"footer"},{const:"section",title:"section"},{const:"article",title:"article"},{const:"aside",title:"aside"},{const:"main",title:"main"},{const:"nav",title:"nav"},{const:"figure",title:"figure"},{const:"details",title:"details"},{const:"summary",title:"summary"},{const:"dialog",title:"dialog"},{const:"strike",title:"strike"},{const:"caption",title:"caption"},{const:"legend",title:"legend"},{const:"figcaption",title:"figcaption"},{const:"mark",title:"mark"}]}}}),canAcceptBlock:()=>!0},_=e=>{const{blockProps:l,iconSize:t,icon:r,content:s,styles:n,children:a,iconPos:c,link:p,inBuilder:d}=e,b=r,y=a||i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-ai-key":"content",children:s}),b&&i.jsx("div",{style:{width:t+"px"},className:c+" "+(c==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:b}})]}),m=k.createElement("button",{...l,...n,type:"button","aria-label":s},y);return u.isEmpty(u.get(p,"href"))?m:d?i.jsx("span",{children:m}):i.jsx("a",{"aria-label":s,href:u.get(p,"href")||"/",target:u.get(p,"target","_self"),children:m})},T={type:"Button",description:"similar to a button element in HTML",label:"Button",category:"core",icon:g.ButtonIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-primary-foreground bg-primary px-4 py-2 rounded-lg flex items-center"),content:{type:"string",title:"Button label",default:"Button"},icon:{type:"string",title:"Icon",default:"",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:16},iconPos:{type:"string",title:"Icon position",default:"order-last",enum:["order-first","order-last"]},link:{type:"object",properties:{type:{type:"string"},href:{type:"string"},target:{type:"string"}},default:{type:"url",href:"",target:"_self"},ui:{"ui:field":"link"}}}}),i18nProps:["content"],aiProps:["content"]},E=e=>{const{blockProps:l,iconSize:t,icon:r,content:s,styles:n}=e,a=r,c=i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-ai-key":"content",children:s}),a&&i.jsx("div",{style:{width:t+"px"},dangerouslySetInnerHTML:{__html:a}})]});return k.createElement("button",{...l,...n,type:"button","aria-label":s},c)},N={type:"CopyButton",description:"A copy button component",label:"Copy Button",category:"core",icon:g.CopyIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("p-2 rounded-md flex items-center"),content:{type:"string",title:"Button label",default:"Button"},icon:{type:"string",title:"Icon",default:"<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-copy'><path d='M8 17L19 8M8 17V7a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v10'/></svg>",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:20}}}),i18nProps:["content"],aiProps:["content"]},R=e=>{const{blockProps:l,styles:t,htmlCode:r,inBuilder:s}=e;return s?i.jsxs("div",{className:"relative",children:[s?i.jsx("div",{...l,...t,className:"absolute z-20 h-full w-full"}):null,h.createElement("div",{...t,dangerouslySetInnerHTML:{__html:r.replace(/<script.*?>.*?<\/script>/g,"")}})]}):h.createElement("div",{...l,...t,dangerouslySetInnerHTML:{__html:r}})},M={type:"CustomHTML",description:"similar to a div or section elements in HTML",label:"Custom HTML",category:"core",icon:g.CodeIcon,group:"advanced",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),htmlCode:{type:"string",default:"<div><p>Enter your HTML code here...</p></div>",ui:{"ui:widget":"code"}}}})},$=e=>{const{scripts:l,inBuilder:t,blockProps:r}=e;return t?i.jsx("div",{...r,children:i.jsx("div",{className:f.cn("pointer-events-none flex flex-col items-center justify-center p-2",""),children:i.jsx("div",{className:"h-full w-full rounded bg-gray-200 p-1 dark:bg-gray-800",children:i.jsx("p",{className:"text-left text-xs text-gray-400",children:"Scripts will be only executed in preview and live mode. Place your script at the bottom of the"})})})}):i.jsx("div",{dangerouslySetInnerHTML:{__html:l}})},A={type:"CustomScript",description:"similar to a script element in HTML",label:"Custom Script",category:"core",icon:C.FileCode,group:"advanced",...o.registerChaiBlockSchema({properties:{scripts:{type:"string",title:"Script",default:"",format:"code",placeholder:"<script>console.log('Hello, world!');<\/script>"}}})},H=e=>{const{blockProps:l,styles:t}=e;return k.createElement("hr",{...t,...l})},U={type:"Divider",description:"A horizontal line component",label:"Divider",category:"core",icon:g.DividerHorizontalIcon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("bg-gray-900 h-0.5 py-2 my-1")}})},D=e=>{const{blockProps:l,styles:t,backgroundImage:r}=e;let s={};return r&&(s={backgroundImage:`url(${r})`}),h.createElement("div",{...l,...t,style:s})},q={type:"EmptyBox",description:"A box component with no children",label:"Empty Box",category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),backgroundImage:{type:"string",title:"Background Image",default:"",ui:{"ui:widget":"image"}}}})},z=e=>{const{blockProps:l,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,d=f.generateUUID();return p?i.jsxs("div",{...s,...l,children:[i.jsx("input",{...n,name:t,id:d,type:"checkbox",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:d,children:r})]}):i.jsx("input",{id:d,...l,...n,...s,type:"checkbox",required:a,name:t})},F={type:"Checkbox",label:"web_blocks.checkbox",category:"core",icon:g.CheckboxIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("flex items-center gap-x-2"),inputStyles:o.StylesProp(""),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]},V=e=>{const{children:l,blockProps:t,errorMessage:r,successMessage:s,action:n,styles:a,inBuilder:c}=e;let p=l;l||(p=i.jsx(x,{inBuilder:c}));const d={"x-data":"{}","x-on:submit.prevent":"post"},b={"x-html":"",":class":"{'text-red-500': formStatus === 'ERROR', 'text-green-500': formStatus === 'SUCCESS'}"};return i.jsxs("form",{...d,"data-error":r,"data-success":s,method:"post",action:n,...t,...a,children:[i.jsx("div",{...b}),p]})},O={type:"Form",label:"Form",category:"core",icon:C.GroupIcon,group:"form",blocks:()=>[{_type:"Form",_id:"form",styles:"#styles:p-1 space-y-2,"},{_type:"Input",_id:"form_input",_parent:"form",styles:"#styles:,"},{_type:"FormButton",_id:"form_submit_btn",_parent:"form",styles:"#styles:bg-black text-white rounded px-3 py-1,"}],...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),action:{type:"string",title:"Submit URL",default:"/api/form"},errorMessage:{type:"string",title:"Error Message",default:"Something went wrong. Please try again",ui:{"ui:widget":"richtext"}},successMessage:{type:"string",title:"Success Message",default:"Thank you for your submission.",ui:{"ui:widget":"richtext"}}}}),i18nProps:["errorMessage","successMessage"],aiProps:["errorMessage","successMessage"],canAcceptBlock:()=>!0},G=e=>{const{blockProps:l,inBuilder:t,label:r,styles:s,inputStyles:n,icon:a,iconSize:c,iconPos:p}=e,d=f.generateUUID(),b={"x-bind:disabled":"formLoading"};return i.jsxs("button",{id:d,...b,...n,...s,...l||{},type:t?"button":"submit","aria-label":r,children:[r,a&&i.jsx("div",{style:{width:c+"px"},className:p+" "+(p==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:a}})]})},Y={type:"FormButton",label:"Submit Button",category:"core",icon:g.ButtonIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-white bg-primary disabled:bg-gray-400 px-4 py-2 rounded-global flex items-center gap-x-2"),inputStyles:o.StylesProp(""),label:{type:"string",title:"Label",default:"Submit",ai:!0,i18n:!0},icon:{type:"string",title:"Icon",default:"",ui:{"ui:widget":"icon"}},iconSize:{type:"number",title:"Icon size",default:24},iconPos:{type:"string",title:"Icon Position",default:"order-last",enum:["order-first","order-last"]}}}),i18nProps:["label"],aiProps:["label"]},W=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,showLabel:c,required:p,inputType:d,autocomplete:b}=e,y=f.generateUUID();return c?i.jsxs("div",{...n,...l,children:[c&&i.jsx("label",{htmlFor:y,children:r}),i.jsx("input",{name:t,...a,id:y,type:d,placeholder:s,required:p,autoComplete:b?"on":"off"})]}):i.jsx("input",{id:y,name:t,...l,...a,...n,type:d,placeholder:s,required:p,autoComplete:b?"on":"off"})},X={type:"Input",label:"web_blocks.input",category:"core",icon:g.InputIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ai:!0,i18n:!0},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},inputType:{type:"string",title:"Input Type",default:"text",enum:["text","email","password","number","tel","hidden","range","color","date","time","name","postal-code"]},required:{type:"boolean",title:"Required",default:!1},autocomplete:{type:"boolean",title:"Autocomplete",default:!0}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},J=e=>{const{blockProps:l,content:t,styles:r,children:s}=e,n={...r,...l};return s?h.createElement("label",n,s):h.createElement("label",{...n,dangerouslySetInnerHTML:{__html:t}})},Q={type:"Label",label:"Label",category:"core",icon:g.LetterCaseToggleIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(),content:{type:"string",title:"Content",default:""}}}),aiProps:["content"],i18nProps:["content"]},Z=e=>{const{blockProps:l,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e,d=f.generateUUID();return p?i.jsxs("div",{...s,...l,children:[i.jsx("input",{...n,name:t,id:d,type:"radio",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:d,children:r})]}):i.jsx("input",{id:d,...l,...n,...s,type:"radio",required:a,checked:c,name:t})},K={type:"Radio",label:"web_blocks.radio",category:"core",icon:g.RadiobuttonIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("flex items-center gap-x-2"),inputStyles:o.StylesProp(""),fieldName:{type:"string",title:"Field Name",default:"fieldName"},label:{type:"string",title:"Label",default:"Label"},checked:{type:"boolean",title:"Checked",default:!1},required:{type:"boolean",title:"Required",default:!1},showLabel:{type:"boolean",title:"Show Label",default:!0}}}),aiProps:["label"],i18nProps:["label"]},ee=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,required:c,showLabel:p,_multiple:d,options:b}=e,y=f.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:y,children:r}),i.jsxs("select",{...a,id:y,required:c,multiple:d,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:s}),u.map(b,m=>i.jsx("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})]}):i.jsxs("select",{id:y,...n,...l,required:c,multiple:d,name:t,children:[i.jsx("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:s}),u.map(b,m=>i.jsx("option",{value:m==null?void 0:m.value,children:m==null?void 0:m.label},m==null?void 0:m.value))]})},te={type:"Select",label:"web_blocks.select",category:"core",icon:g.DropdownMenuIcon,group:"form",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label"},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},required:{type:"boolean",title:"Required",default:!1},_multiple:{type:"boolean",title:"Multiple",default:!1},options:{title:"Options",type:"array",default:[],items:{type:"object",properties:{label:{type:"string",title:"Label",default:""},value:{type:"string",title:"Value",default:""}}}}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},oe=e=>{const{blockProps:l,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,rows:c,showLabel:p,required:d}=e,b=f.generateUUID();return p?i.jsxs("div",{...n,...l,children:[p&&i.jsx("label",{htmlFor:b,children:r}),i.jsx("textarea",{name:t,...a,id:b,placeholder:s,rows:c,required:d})]}):i.jsx("textarea",{id:b,name:t,...l,...a,...n,placeholder:s,rows:c,required:d})},le={type:"TextArea",label:"web_blocks.textarea",category:"core",icon:g.InputIcon,group:"form",...o.registerChaiBlockSchema({properties:{fieldName:{type:"string",title:"Field Name",default:"fieldName"},styles:o.StylesProp(""),inputStyles:o.StylesProp("w-full p-1"),showLabel:{type:"boolean",title:"Show Label",default:!0},label:{type:"string",title:"Label",default:"Label",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}},placeholder:{type:"string",title:"Placeholder",default:"Placeholder"},rows:{type:"number",title:"Rows",default:3},required:{type:"boolean",title:"Required",default:!1}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},re=e=>{const{blockProps:l,inBuilder:t,children:r,globalBlock:s}=e;return t&&!s?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",...l,children:[i.jsxs("h1",{children:["Global Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},r)},se={type:"GlobalBlock",description:"A global block component",label:"Global Block",icon:C.GlobeIcon,category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{globalBlock:{type:"string",title:"Global Block",default:"",ui:{"ui:widget":"hidden"}}}})},ie=e=>{const{blockProps:l,styles:t,content:r,tag:s="h1",children:n=null}=e;return n?h.createElement(s,{...t,...l},n):h.createElement(s,{...t,...l,dangerouslySetInnerHTML:{__html:r}})},ne={type:"Heading",description:"A heading component similar to h1, h2, h3, h4, h5, h6 elements in HTML",label:"Heading",category:"core",icon:g.HeadingIcon,group:"typography",...o.registerChaiBlockSchema({properties:{tag:{type:"string",default:"h2",title:"Level",enum:["h1","h2","h3","h4","h5","h6"]},styles:o.StylesProp("text-3xl"),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e==="Span"||e==="Text"},ae=e=>{const{blockProps:l,styles:t}=e;return k.createElement("br",{...l,...t})},ce={type:"LineBreak",label:"Line Break",category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},pe=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("table",{...l,...r},t):i.jsx(x,{})},de=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("thead",{...l,...r},t):i.jsx(x,{})},ue=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tbody",{...l,...r},t):i.jsx(x,{})},ge=e=>{const{blockProps:l,children:t,styles:r}=e;return t?k.createElement("tr",{...l,...r},t):i.jsx(x,{})},me=e=>{const{blockProps:l,children:t,content:r,styles:s}=e;return!t&&u.isEmpty(r)?i.jsx(x,{}):t?k.createElement("td",{...l,...s},t):k.createElement("td",{...l,...s,dangerouslySetInnerHTML:{__html:r}})};o.registerChaiBlock(pe,{type:"Table",label:"Table",category:"core",group:"table",hidden:!0,icon:g.TableIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("Table")});o.registerChaiBlock(de,{type:"TableHead",label:"Table Head",category:"core",group:"table",hidden:!0,icon:g.BorderTopIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableHead")});o.registerChaiBlock(ue,{type:"TableBody",label:"Table Body",category:"core",group:"table",hidden:!0,icon:g.BorderAllIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableBody")});o.registerChaiBlock(ge,{type:"TableRow",label:"Table Row",category:"core",group:"table",hidden:!0,icon:g.ViewHorizontalIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("")}}),blocks:B("TableRow")});o.registerChaiBlock(me,{type:"TableCell",label:"Table Cell",category:"core",group:"table",hidden:!0,icon:g.DragHandleHorizontalIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),blocks:B("TableCell"),i18nProps:["content"],aiProps:["content"]});function B(e){const l=(n,a)=>({_id:f.generateUUID(),_parent:n,_type:"TableCell",styles:"#styles:,",content:`${e==="TableHead"?"Table Head":"Table Cell "+a}`}),t=n=>{const a=f.generateUUID(),c={_type:"TableRow",_id:a,styles:"#styles:,border-b"};return n&&(c._parent=n),[c,l(a,"1"),l(a,"2"),l(a,"3")]},r=n=>{const a=f.generateUUID(),c={_id:a,_type:"TableHead",styles:"#styles:,font-medium"};return n&&(c._parent=n),[c,...t(a)]},s=n=>{const a=f.generateUUID(),c={_id:a,_type:"TableBody",styles:"#styles:,"};return n&&(c._parent=n),[c,...t(a),...t(a)]};if(e==="Table"){const n=f.generateUUID();return[{_id:n,_type:"Table",styles:"#styles:,w-full text-left text-gray-500 dark:text-gray-400"},...r(n),...s(n)]}return e==="TableRow"?t():e==="TableHead"?r():e==="TableBody"?s():[]}const v=(e,...l)=>({...e,className:f.cn(e.className,...l)}),ye=e=>{const{blockProps:l,icon:t,styles:r,width:s,inBuilder:n,height:a}=e,c=v(r,"");if(u.isEmpty(t))return i.jsx(x,{inBuilder:n,className:"h-8 w-14"});const p=t.replace(/<svg /g,'<svg class="w-[inherit] h-[inherit]" ');return h.createElement("span",{...l,...c,style:{width:s?`${s}px`:"auto",height:a?`${a}px`:"auto"},dangerouslySetInnerHTML:{__html:p}})},he={type:"Icon",label:"web_blocks.icon",category:"core",icon:g.SketchLogoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),icon:{type:"string",title:"Icon",default:'<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M8 16c4.418 0 8-3.582 8-8s-3.582-8-8-8-8 3.582-8 8 3.582 8 8 8zM8 1.5c3.59 0 6.5 2.91 6.5 6.5s-2.91 6.5-6.5 6.5-6.5-2.91-6.5-6.5 2.91-6.5 6.5-6.5zM8 9.356c1.812 0 3.535-0.481 5-1.327-0.228 2.788-2.393 4.971-5 4.971s-4.772-2.186-5-4.973c1.465 0.845 3.188 1.329 5 1.329zM4 5.5c0-0.828 0.448-1.5 1-1.5s1 0.672 1 1.5c0 0.828-0.448 1.5-1 1.5s-1-0.672-1-1.5zM10 5.5c0-0.828 0.448-1.5 1-1.5s1 0.672 1 1.5c0 0.828-0.448 1.5-1 1.5s-1-0.672-1-1.5z"></path></svg>',ui:{"ui:widget":"icon"}},width:{type:"number",default:16,title:"Width"},height:{type:"number",default:16,title:"Height"}}})},be=e=>{const{blockProps:l,image:t,mobileImage:r,styles:s,alt:n,height:a,width:c,lazyLoading:p}=e;return u.isEmpty(t)?i.jsx(x,{className:"h-36"}):i.jsxs("picture",{children:[r&&i.jsx("source",{srcSet:r,media:"(max-width: 480px)"}),i.jsx("img",{...l,...s,src:t,alt:n,loading:p?"lazy":"eager",width:c,height:a})]})},fe={type:"Image",description:"A image component",label:"Image",category:"core",icon:g.ImageIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),image:{type:"string",title:"Image",default:"https://fakeimg.pl/400x200?text=Choose&font=bebas",ui:{"ui:widget":"image"}},alt:{type:"string",title:"Alt text",default:"",ui:{"ui:placeholder":"Enter alt text"}},lazyLoading:{type:"boolean",title:"Lazy Load",default:!0},width:{type:"number",title:"Width",default:"",ui:{"ui:placeholder":"Enter width"}},height:{type:"number",title:"Height",default:"",ui:{"ui:placeholder":"Enter height"}},mobileImage:{type:"string",title:"Mobile Image",default:"",ui:{"ui:widget":"image"}},assetId:{type:"string",title:"Asset ID",default:"",ui:{"ui:widget":"hidden"}}}}),aiProps:["alt"],i18nProps:["alt"]},ke=e=>{const{blockProps:l,link:t,children:r,styles:s,inBuilder:n,content:a}=e;let c={};return!r&&u.isEmpty(a)&&(c={minHeight:"50px",display:"flex",alignItems:"center",justifyContent:"center"}),n?r?i.jsx("span",{...l,style:c,...s,children:r}):k.createElement("span",{...l,...s,style:c},a):r?i.jsx("a",{"aria-label":a,href:(t==null?void 0:t.href)||"#/",target:t==null?void 0:t.target,...l,...s,children:r}):k.createElement("a",{...l,...s,href:(t==null?void 0:t.href)||"#",target:(t==null?void 0:t.target)||"_self","aria-label":a},a)},xe={type:"Link",description:"A link component",label:"Link",category:"core",icon:g.Link1Icon,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"Link goes here",title:"Content"},link:{type:"object",properties:{type:{type:"string"},href:{type:"string"},target:{type:"string"}},default:{type:"url",href:"",target:"_self"},ui:{"ui:field":"link"}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e!=="Link"},Ce=e=>{const{blockProps:l,children:t,listType:r,styles:s,tag:n,inBuilder:a}=e,c=f.cn(u.get(s,"className",""),r);return!t&&u.isEmpty(s==null?void 0:s.className)?i.jsx(x,{inBuilder:a}):h.createElement(n||(r==="list-decimal"?"ol":"ul"),{...l,...s,className:c},t)},Be={type:"List",description:"A list component",label:"List",icon:g.RowsIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),listType:{type:"string",title:"List Type",default:"list-none",oneOf:[{enum:["list-none"],title:"List None"},{enum:["list-disc"],title:"Disc"},{enum:["list-decimal"],title:"Decimal"}]}}}),canAcceptBlock:e=>e==="ListItem",blocks:[{_type:"List",_id:"a",listType:"list-none",styles:"#styles:,"},{_type:"ListItem",_id:"b",_parent:"a",styles:"#styles:,",content:"Item 1"},{_type:"ListItem",_id:"c",_parent:"a",styles:"#styles:,",content:"Item 2"},{_type:"ListItem",_id:"d",_parent:"a",styles:"#styles:,",content:"Item 3"}]},Se=e=>{const{blockProps:l,content:t,styles:r,children:s,tag:n}=e;return s?h.createElement(n||"li",{...r,...l},s):h.createElement(n||"li",{...r,...l,dangerouslySetInnerHTML:{__html:t}})},we={type:"ListItem",description:"A list item component",label:"List Item",icon:g.ColumnsIcon,category:"core",group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",default:"List item",title:"Content",ui:{"ui:widget":"textarea"}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e!=="ListItem",canBeNested:e=>e==="List"||e==="Repeater"},Pe=e=>{const{blockProps:l,styles:t,content:r}=e;return u.isNull(e.children)?h.createElement("p",{...t,...l,dangerouslySetInnerHTML:{__html:r}}):h.createElement("p",{...t,...l},e.children)},ve={type:"Paragraph",description:"A paragraph component",label:"Paragraph",category:"core",icon:g.TextIcon,group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":5}}}}),i18nProps:["content"],aiProps:["content"],canAcceptBlock:e=>e==="Span"||e==="Link"||e==="Text"},Ie=e=>{const{blockProps:l,inBuilder:t,children:r,partialBlockId:s}=e;return t&&!s?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",...l,children:[i.jsxs("h1",{children:["Partial Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):h.createElement("span",{...l},r)},je={type:"PartialBlock",description:"A partial block component",label:"Partial Block",icon:C.GlobeIcon,category:"core",group:"basic",hidden:!0,...o.registerChaiBlockSchema({properties:{partialBlockId:{type:"string",title:"Partial Block",default:"",ui:{"ui:widget":"hidden"}}}})},S={SMALL:{1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4",5:"col-span-5",6:"col-span-6",7:"col-span-7",8:"col-span-8",9:"col-span-9",10:"col-span-10",11:"col-span-11",12:"col-span-12"},MEDIUM:{1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3",4:"md:col-span-4",5:"md:col-span-5",6:"md:col-span-6",7:"md:col-span-7",8:"md:col-span-8",9:"md:col-span-9",10:"md:col-span-10",11:"md:col-span-11",12:"md:col-span-12"},LARGE:{1:"lg:col-span-1",2:"lg:col-span-2",3:"lg:col-span-3",4:"lg:col-span-4",5:"lg:col-span-5",6:"lg:col-span-6",7:"lg:col-span-7",8:"lg:col-span-8",9:"lg:col-span-9",10:"lg:col-span-10",11:"lg:col-span-11",12:"lg:col-span-12"}},Le=e=>{const{blockProps:l,children:t,styles:r,colSpan:s,tabletColSpan:n,desktopColSpan:a}=e,p={className:[u.get(r,"className",""),u.get(S,["SMALL",isNaN(s)||!s?6:s],""),n?u.get(S,["MEDIUM",n||s],""):"",a?u.get(S,["LARGE",n||s],""):""].join(" ")};return i.jsx("div",{...l,...r,...p,children:t||i.jsx("div",{className:"h-full min-h-12 w-full border-2 border-dashed border-gray-400 bg-gray-100 dark:bg-gray-900"})})},_e={type:"Column",description:"A column component",label:"Column",group:"basic",category:"core",icon:C.Columns,wrapper:!0,canDelete:()=>!0,canAcceptBlock:()=>!0,canBeNested:e=>e==="Row",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),colSpan:{type:"number",title:"Column Span",default:6,enum:[1,2,3,4,5,6,7,8,9,10,11,12]},tabletColSpan:{type:"number",title:"Column Span (Tablet)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]},desktopColSpan:{type:"number",title:"Column Span (Desktop)",default:null,enumNames:["Default",1,2,3,4,5,6,7,8,9,10,11,12],enum:[null,1,2,3,4,5,6,7,8,9,10,11,12]}}})},Te=e=>{const{blockProps:l,children:t,styles:r,gutter:s}=e,a={className:[u.get(r,"className","")," grid grid-cols-12"].join()};return typeof(r==null?void 0:r.style)=="object"?r.style.gap=`${s}px`:a.style={gap:`${s}px`},i.jsx("div",{...l,...r,...a,children:t})},Ee={type:"Row",description:"A row component",label:"Row",group:"basic",icon:C.Rows,blocks:()=>[{_type:"Row",_id:"row",styles:"#styles:,p-1"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"},{_type:"Column",id:"column",_parent:"row",styles:"#styles:,"}],category:"core",wrapper:!0,canAcceptBlock:e=>e==="Column",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),colCount:{type:"number",default:2,minimum:0,ui:{"ui:widget":"colCount"}},gutter:{type:"number",title:"Gutter (in px)",default:16,minimum:0}}})},Ne=e=>{const{blockProps:l,content:t,styles:r}=e,s=v(r,"prose dark:prose-invert prose-p:m-0 prose-p:min-h-[1rem] prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0","max-w-full");return i.jsx("div",{...l,...s,dangerouslySetInnerHTML:{__html:t}})},Re={type:"RichText",description:"A rich text block",label:"Rich Text",category:"core",icon:g.CursorTextIcon,group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"<p>This is a rich text block. You can add text, and other content here.</p>",ui:{"ui:widget":"richtext"}}}}),aiProps:["content"],i18nProps:["content"]},Me=e=>{const{blockProps:l,styles:t,content:r,children:s=null,tag:n}=e;return s?h.createElement("span",{...t,...l},s):h.createElement(n||"span",{...t,...l,dangerouslySetInnerHTML:{__html:r||""}})},$e={type:"Span",description:"A span component",label:"Span",category:"core",group:"typography",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp(""),content:{type:"string",title:"Content",default:"",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:()=>!0},Ae=e=>e.inBuilder||e.forceWrapper?i.jsx("span",{...e.blockProps,children:e.content}):`${e.content}`,He={type:"Text",description:"A text component with no styling",label:"Text",hidden:!0,category:"core",group:"typography",icon:g.SpaceBetweenVerticallyIcon,...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("text-black"),content:{title:"Content",type:"string",default:""}}}),aiProps:["content"],i18nProps:["content"]},Ue={type:"object",title:"Controls",default:{autoplay:!0,controls:!1,loop:!0,muted:!0},properties:{autoplay:{type:"boolean",title:"Autoplay",default:!1},controls:{type:"boolean",title:"Show Controls",default:!0},loop:{type:"boolean",title:"Loop Video",default:!1},muted:{type:"boolean",title:"Muted",default:!1}}},w=/^(https?:\/\/)?(www\.)?youtube\.com\/(watch\?v=|embed\/)([a-zA-Z0-9_-]{11})/,P=/(?:https?:\/\/)?(?:www\.)?(?:vimeo\.com\/(?:channels\/[\w]+\/|groups\/[^\/]+\/videos\/|album\/\d+\/video\/|video\/)?|player\.vimeo\.com\/video\/)(\d+)/,De=(e,l)=>{const t=u.get(l,"autoplay",!1),r=u.get(l,"controls",!1),s=u.get(l,"loop",!1),n=t||u.get(l,"muted",!0);if(w.test(e)){const a=e.match(w);if(a){const c=a[4];let p=`https://www.youtube.com/embed/${c}`,d=t?"autoplay=1":"";return d+=s?`&loop=1&playlist=${c}`:"",d+=n?"&mute=1&muted=1":"",d+=r?"&controls=1":"&controls=0",`${p}?${d}`}}if(P.test(e)){const a=e.match(P);if(a){const c=a[1];let p="";return p+=t?"autoplay=1":"",p+=r?"&controls=1":"&controls=0",p+=n?"&muted=1":"",p+=s?"&loop=1":"",`https://player.vimeo.com/video/${c}?${p}`}}return null},qe=e=>{const{url:l,blockProps:t,styles:r,controls:s,videoSource:n,inBuilder:a}=e,c=De(l,s);return i.jsxs("div",{...u.omit(r,"className"),className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:[!c&&a?i.jsx("div",{className:"absolute flex h-full w-full items-center justify-center bg-gray-300 text-center",children:u.isEmpty(l)?`Provided ${n} video link in settings Video URL.`:`Provided ${n} video link is invalid.`}):i.jsx("iframe",{width:"100%",src:c,...u.pick(r,"className")}),a&&i.jsx("div",{...t,className:"absolute top-0 h-full w-full"})]})},ze=e=>{const{url:l,styles:t,controls:r,sources:s,poster:n,blockProps:a}=e;let c=n;const p=[...u.get(s,"srcsets",[])||[]];l&&typeof l=="string"&&p.push({url:l,width:"9999"});const d=p.sort((y,m)=>parseInt(y.width)-parseInt(m.width)).filter(y=>!u.isEmpty(y.url)&&!u.isEmpty(y.width));d.length===0&&!c&&(c="https://placehold.co/300x200/EEE/ccc?text=Choose%20Video");const b=u.get(r,"autoplay",!1)||u.get(r,"muted",!0);return(c||!u.isEmpty(d))&&i.jsx("div",{className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:k.createElement("video",{...t,...a,key:JSON.stringify(d),controls:u.get(r,"controls",!1),autoPlay:u.get(r,"autoplay",!1),loop:u.get(r,"loop",!1),poster:c,...b?{muted:!0}:{}},d.map(y=>{if(!y.url||y.url.length<4||isNaN(y.width))return null;const m=`(max-width: ${y.width}px)`;return i.jsx("source",{src:y.url,media:m,type:y.type},y.url)}),"Your browser does not support the video tag.")})},Fe=e=>{const{videoSource:l}=e;return l==="Custom"?i.jsx(ze,{...e}):l==="Youtube"||l==="Vimeo"?i.jsx(qe,{...e}):i.jsxs("div",{children:["Invalid video source : ",l]})},Ve={type:"Video",label:"Video",category:"core",icon:g.VideoIcon,group:"media",...o.registerChaiBlockSchema({properties:{styles:o.StylesProp("absolute h-full w-full object-cover"),videoSource:{type:"string",default:"Custom",enum:["Custom","Youtube","Vimeo"],title:"Video source"}},allOf:[{if:{properties:{videoSource:{const:"Custom"}}},then:{properties:{url:{type:"string",title:"Video URL",default:""},poster:{type:"string",title:"Poster URL",default:""},sources:{type:"object",default:{srcsets:[]}},controls:{...Ue}}}},{if:{properties:{videoSource:{const:"Youtube"}}},then:{properties:{url:{type:"string",title:"Youtube Video URL",default:""}}}},{if:{properties:{videoSource:{const:"Vimeo"}}},then:{properties:{url:{type:"string",title:"Vimeo Video URL",default:""}}}}],ui:{url:{"ui:placeholder":"Enter Video URL"},sources:{"ui:field":"sources"},poster:{"ui:placeholder":"Enter poster URL"}}}),i18nProps:["url"]},Oe=e=>{const{children:l,tag:t,styles:r,blockProps:s,inBuilder:n,$loading:a}=e;let c=l;return u.isEmpty(c)&&n&&(c=i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Choose a collection to display items"})),t==="none"?a&&n?Array.from({length:2}).map((p,d)=>i.jsxs("div",{className:"animate-pulse rounded-md bg-primary/10 p-5",children:[i.jsx("div",{className:"h-6 w-1/2 rounded-md bg-primary/10"}),i.jsx("div",{className:"mt-2 h-4 w-1/2 rounded-md bg-primary/10"})]},d)):c:h.createElement(t,{...s,...r},a&&n?Array.from({length:2}).map((p,d)=>i.jsxs("div",{className:"animate-pulse rounded-md bg-primary/10 p-5",children:[i.jsx("div",{className:"h-6 w-1/2 rounded-md bg-primary/10"}),i.jsx("div",{className:"mt-2 h-4 w-1/2 rounded-md bg-primary/10"})]},d)):c)},Ge={type:"Repeater",label:"Repeater",icon:g.LoopIcon,group:"basic",dataProviderMode:"live",dataProviderDependencies:["filter","sort","limit","repeaterItems"],blocks:()=>[{_id:"A",_type:"Repeater",tag:"ul"},{_id:"B",_name:"Repeater Item",_type:"RepeaterItem",parentTag:"ul",_parent:"A"}],...o.registerChaiBlockSchema({properties:{styles:o.stylesProp("grid gap-4 md:grid-cols-2 xl:grid-cols-3"),repeaterItems:{title:"Collection",type:"string",binding:"array",default:"",ui:{"ui:widget":"repeaterBinding","ui:readonly":!0}},tag:{title:"Tag",type:"string",default:"ul",enum:["none","div","ul","ol"]},limit:{title:"Limit",type:"number",default:3},filter:{title:"Filter by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}},sort:{title:"Sort by",type:"string",default:"",ui:{"ui:widget":"collectionSelect"}}}})},Ye=({children:e,blockProps:l,styles:t,parentTag:r,inBuilder:s})=>{let n="li";switch(r){case"ul":n="li";break;case"ol":n="li";break;default:n="div"}return!e&&s?h.createElement(n,{...l,...t},i.jsx("div",{className:"col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground",children:"Add children to repeater item"})):h.createElement(n,{...l,...t},e)},We={type:"RepeaterItem",label:"Repeater Item",icon:g.LoopIcon,hidden:!0,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.stylesProp(""),parentTag:o.closestBlockProp("Repeater","tag")}}),canAcceptBlock:e=>e!=="RepeaterItem",canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Xe=({children:e,blockProps:l,styles:t})=>h.createElement("div",{...l,...t},e),Je={type:"RepeaterEmptyState",label:"Empty State",hidden:!0,group:"basic",...o.registerChaiBlockSchema({properties:{styles:o.stylesProp("p-5 flex items-center justify-center")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Qe=()=>{o.registerChaiBlock(j,L),o.registerChaiBlock(D,q),o.registerChaiBlock(_,T),o.registerChaiBlock(ie,ne),o.registerChaiBlock(Pe,ve),o.registerChaiBlock(Me,$e),o.registerChaiBlock(Ne,Re),o.registerChaiBlock(ke,xe),o.registerChaiBlock(Ce,Be),o.registerChaiBlock(Se,we),o.registerChaiBlock(ye,he),o.registerChaiBlock(be,fe),o.registerChaiBlock(Fe,Ve),o.registerChaiBlock(R,M),o.registerChaiBlock($,A),o.registerChaiBlock(Ae,He),o.registerChaiBlock(V,O),o.registerChaiBlock(G,Y),o.registerChaiBlock(W,X),o.registerChaiBlock(z,F),o.registerChaiBlock(Z,K),o.registerChaiBlock(ee,te),o.registerChaiBlock(oe,le),o.registerChaiBlock(J,Q),o.registerChaiBlock(ae,ce),o.registerChaiBlock(H,U),o.registerChaiBlock(re,se),o.registerChaiBlock(Ie,je),o.registerChaiBlock(Te,Ee),o.registerChaiBlock(Le,_e),o.registerChaiBlock(E,N),o.registerChaiBlock(Oe,Ge),o.registerChaiBlock(Ye,We),o.registerChaiBlock(Xe,Je)};exports.loadWebBlocks=Qe;
@@ -5,7 +5,7 @@ import * as b from "react";
5
5
  import { createElement as w } from "react";
6
6
  import { ButtonIcon as R, CopyIcon as z, CodeIcon as D, DividerHorizontalIcon as j, CheckboxIcon as V, InputIcon as M, LetterCaseToggleIcon as q, RadiobuttonIcon as F, DropdownMenuIcon as U, HeadingIcon as G, TableIcon as O, BorderTopIcon as Y, BorderAllIcon as W, ViewHorizontalIcon as X, DragHandleHorizontalIcon as J, SketchLogoIcon as Q, ImageIcon as Z, Link1Icon as K, RowsIcon as ee, ColumnsIcon as te, TextIcon as oe, CursorTextIcon as le, SpaceBetweenVerticallyIcon as re, VideoIcon as ne, LoopIcon as E } from "@radix-ui/react-icons";
7
7
  import { isEmpty as C, get as h, map as S, isNull as ie, omit as se, pick as ae } from "lodash-es";
8
- import { FileCode as ce, GroupIcon as pe, GlobeIcon as $, Columns as de, Rows as ue } from "lucide-react";
8
+ import { FileCode as ce, GroupIcon as pe, GlobeIcon as A, Columns as de, Rows as ue } from "lucide-react";
9
9
  const x = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ s("div", { className: B("pointer-events-none flex h-20 flex-col items-center justify-center p-2", e), children: /* @__PURE__ */ s("div", { className: "h-full w-full rounded bg-gray-200 p-2 dark:bg-gray-800", children: /* @__PURE__ */ s("div", { className: "flex h-full w-full items-center justify-center outline-dashed outline-1 -outline-offset-1 outline-gray-400 duration-300 dark:outline-gray-700" }) }) }) : null, me = (e) => {
10
10
  const { blockProps: o, inBuilder: t, backgroundImage: l, children: r, tag: n = "div", styles: i } = e;
11
11
  let a = r;
@@ -565,13 +565,13 @@ const x = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ s("div",
565
565
  }),
566
566
  aiProps: ["label", "placeholder"],
567
567
  i18nProps: ["label", "placeholder"]
568
- }, $e = (e) => {
568
+ }, Ae = (e) => {
569
569
  const { blockProps: o, content: t, styles: l, children: r } = e, n = { ...l, ...o };
570
570
  return r ? b.createElement("label", n, r) : b.createElement("label", {
571
571
  ...n,
572
572
  dangerouslySetInnerHTML: { __html: t }
573
573
  });
574
- }, Ae = {
574
+ }, $e = {
575
575
  type: "Label",
576
576
  label: "Label",
577
577
  category: "core",
@@ -815,7 +815,7 @@ const x = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ s("div",
815
815
  type: "GlobalBlock",
816
816
  description: "A global block component",
817
817
  label: "Global Block",
818
- icon: $,
818
+ icon: A,
819
819
  category: "core",
820
820
  group: "basic",
821
821
  hidden: !0,
@@ -1022,11 +1022,11 @@ function I(e) {
1022
1022
  }
1023
1023
  return e === "TableRow" ? t() : e === "TableHead" ? l() : e === "TableBody" ? r() : [];
1024
1024
  }
1025
- const A = (e, ...o) => ({
1025
+ const $ = (e, ...o) => ({
1026
1026
  ...e,
1027
1027
  className: B(e.className, ...o)
1028
1028
  }), et = (e) => {
1029
- const { blockProps: o, icon: t, styles: l, width: r, inBuilder: n, height: i } = e, a = A(l, "");
1029
+ const { blockProps: o, icon: t, styles: l, width: r, inBuilder: n, height: i } = e, a = $(l, "");
1030
1030
  if (C(t))
1031
1031
  return /* @__PURE__ */ s(x, { inBuilder: n, className: "h-8 w-14" });
1032
1032
  const c = t.replace(/<svg /g, '<svg class="w-[inherit] h-[inherit]" ');
@@ -1329,7 +1329,7 @@ const A = (e, ...o) => ({
1329
1329
  type: "PartialBlock",
1330
1330
  description: "A partial block component",
1331
1331
  label: "Partial Block",
1332
- icon: $,
1332
+ icon: A,
1333
1333
  category: "core",
1334
1334
  group: "basic",
1335
1335
  hidden: !0,
@@ -1465,7 +1465,7 @@ const A = (e, ...o) => ({
1465
1465
  }
1466
1466
  })
1467
1467
  }, ht = (e) => {
1468
- const { blockProps: o, content: t, styles: l } = e, r = A(
1468
+ const { blockProps: o, content: t, styles: l } = e, r = $(
1469
1469
  l,
1470
1470
  "prose dark:prose-invert prose-p:m-0 prose-p:min-h-[1rem] prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0",
1471
1471
  "max-w-full"
@@ -1713,7 +1713,10 @@ const A = (e, ...o) => ({
1713
1713
  }, Tt = (e) => {
1714
1714
  const { children: o, tag: t, styles: l, blockProps: r, inBuilder: n, $loading: i } = e;
1715
1715
  let a = o;
1716
- return C(a) && n && (a = /* @__PURE__ */ s("div", { className: "col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground", children: "Choose a collection to display items" })), b.createElement(
1716
+ return C(a) && n && (a = /* @__PURE__ */ s("div", { className: "col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground", children: "Choose a collection to display items" })), t === "none" ? i && n ? Array.from({ length: 2 }).map((c, m) => /* @__PURE__ */ f("div", { className: "animate-pulse rounded-md bg-primary/10 p-5", children: [
1717
+ /* @__PURE__ */ s("div", { className: "h-6 w-1/2 rounded-md bg-primary/10" }),
1718
+ /* @__PURE__ */ s("div", { className: "mt-2 h-4 w-1/2 rounded-md bg-primary/10" })
1719
+ ] }, m)) : a : b.createElement(
1717
1720
  t,
1718
1721
  { ...r, ...l },
1719
1722
  i && n ? Array.from({ length: 2 }).map((c, m) => /* @__PURE__ */ f("div", { className: "animate-pulse rounded-md bg-primary/10 p-5", children: [
@@ -1758,7 +1761,7 @@ const A = (e, ...o) => ({
1758
1761
  title: "Tag",
1759
1762
  type: "string",
1760
1763
  default: "ul",
1761
- enum: ["div", "ul", "ol"]
1764
+ enum: ["none", "div", "ul", "ol"]
1762
1765
  },
1763
1766
  limit: {
1764
1767
  title: "Limit",
@@ -1822,7 +1825,7 @@ const A = (e, ...o) => ({
1822
1825
  children: e,
1823
1826
  blockProps: o,
1824
1827
  styles: t
1825
- }) => b.createElement("div", { ...o, ...t }, e), $t = {
1828
+ }) => b.createElement("div", { ...o, ...t }, e), At = {
1826
1829
  type: "RepeaterEmptyState",
1827
1830
  label: "Empty State",
1828
1831
  hidden: !0,
@@ -1835,7 +1838,7 @@ const A = (e, ...o) => ({
1835
1838
  canMove: () => !1,
1836
1839
  canDuplicate: () => !1
1837
1840
  }, Ft = () => {
1838
- p(me, ye), p(Be, Le), p(ge, be), p(Ge, Oe), p(pt, dt), p(wt, vt), p(ht, kt), p(rt, nt), p(it, st), p(at, ct), p(et, tt), p(ot, lt), p(St, _t), p(ke, we), p(ve, Ce), p(Ct, xt), p(_e, Te), p(Ne, Re), p(Me, Ee), p(Pe, Se), p(He, ze), p(De, je), p(Ve, qe), p($e, Ae), p(Ye, We), p(xe, Ie), p(Fe, Ue), p(ut, mt), p(bt, ft), p(yt, gt), p(fe, he), p(Tt, Nt), p(Rt, Mt), p(Et, $t);
1841
+ p(me, ye), p(Be, Le), p(ge, be), p(Ge, Oe), p(pt, dt), p(wt, vt), p(ht, kt), p(rt, nt), p(it, st), p(at, ct), p(et, tt), p(ot, lt), p(St, _t), p(ke, we), p(ve, Ce), p(Ct, xt), p(_e, Te), p(Ne, Re), p(Me, Ee), p(Pe, Se), p(He, ze), p(De, je), p(Ve, qe), p(Ae, $e), p(Ye, We), p(xe, Ie), p(Fe, Ue), p(ut, mt), p(bt, ft), p(yt, gt), p(fe, he), p(Tt, Nt), p(Rt, Mt), p(Et, At);
1839
1842
  };
1840
1843
  export {
1841
1844
  Ft as loadWebBlocks
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "Suraj Air",
6
6
  "license": "BSD-3-Clause",
7
7
  "homepage": "https://chaibuilder.com",
8
- "version": "2.2.30",
8
+ "version": "2.2.31",
9
9
  "type": "module",
10
10
  "repository": {
11
11
  "type": "git",