@chaibuilder/sdk 2.5.2 → 2.5.4

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
@@ -58,7 +58,7 @@
58
58
  outline: 1px solid ${n.length>0?"#42a1fc":"#de8f09"} !important; outline-offset: -1px;
59
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(",")}{
60
60
  outline: 1px solid #42a1fc !important; outline-offset: -1px;
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]),l=React.useMemo(()=>plugin.getThemeFontsUrls(lodashEs.filter(a,i=>lodashEs.has(i,"url"))),[a]),r=React.useMemo(()=>plugin.getThemeCustomFontFace(lodashEs.filter(a,i=>lodashEs.has(i,"src"))),[a]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l.map((i,c)=>jsxRuntime.jsx("link",{rel:"stylesheet",href:i},`google-font-${c}`)),jsxRuntime.jsx("style",{id:"chai-custom-fonts",dangerouslySetInnerHTML:{__html:r}})]})},ResizableCanvasWrapper=({children:o,onMount:n,onResize:a})=>{const[,l]=useSelectedBlockIds(),[,r]=useSelectedStylingBlocks(),i=React.useRef(null),c=web.useDebouncedCallback(()=>{const{clientWidth:m}=i.current;a(m)},[i.current],100);web.useResizeObserver(i.current,c,i.current!==null),React.useEffect(()=>{const{clientWidth:m}=i.current;n(m)},[]);const d=React.useCallback(()=>{l([]),r([])},[l,r]);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]),l=lodashEs.get(a,"dataProviderDependencies"),r=lodashEs.get(a,"dataProvider"),i=lodashEs.get(a,"dataProviderMode","mock"),c=useAsyncProps(n,i,l,r);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((l,[r,i])=>{const c=[];let d=lodashEs.find(o,{_id:n});for(;d;)c.push(d),d=lodashEs.find(o,{_id:d._parent});const m=lodashEs.find(c,{_type:i.block});return m&&(l[r]=lodashEs.get(m,lodashEs.get(i,"prop"),null)),l},{}),[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:l})=>{const r=BUBBLE_MENU_ICONS[o];return jsxRuntime.jsx("button",{onClick:a,className:toggle.cn("rounded-md p-1.5 transition-colors duration-200",l?"bg-white/20":"hover:bg-white/10"),title:n,children:jsxRuntime.jsx(r,{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:l,onEscape:r})=>{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})=>l((u==null?void 0:u.getHTML())||""),onBlur:({editor:u,event:p})=>{const g=p.relatedTarget,x=i.querySelector(".ProseMirror"),f=i.querySelector(".tippy-box"),h=x==null?void 0:x.contains(g),j=f==null?void 0:f.contains(g);if(!h&&!j){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 g;const u="max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";if(!n)return u;const p=((g=n==null?void 0:n.className)==null?void 0:g.replace("sr-only",""))||"";return`${u} ${p}`},[n]),m=React.useCallback(u=>{u.key==="Escape"&&r(u)},[r]);return jsxRuntime.jsxs("div",{onKeyDown:m,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:l,onChange:r,onEscape:i})=>{const{document:c,window:d}=useFrame();React.useEffect(()=>{if(l.current){l.current.innerText=n,l.current.focus();const x=c.createRange(),f=d.getSelection();x.selectNodeContents(l.current),x.collapse(!1),f==null||f.removeAllRanges(),f==null||f.addRange(x),l.current.focus()}else a()},[c,d]);const m=React.useMemo(()=>{var f;const x=((f=o==null?void 0:o.tagName)==null?void 0:f.toLowerCase())||"div";return x==="button"?"div":x},[o]),u=React.useCallback(x=>{(x.key==="Enter"||x.key==="Escape")&&i(x)},[i]),p=React.useCallback(()=>{a()},[a]),g=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:f=>{const h=f.target;h&&(h.innerText.trim()===""?(h.setAttribute("data-placeholder","Enter text here"),h.children.length>0&&h.children[0].remove()):f.target.removeAttribute("data-placeholder"),r(f.target.innerText))},onClick:f=>{f.stopPropagation(),f.preventDefault()}}},[o==null?void 0:o.className,o==null?void 0:o.style]);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:React.createElement(m,{ref:l,onBlur:p,onKeyDown:u,...g})})}),WithBlockTextEditor=React.memo(({block:o,children:n})=>{const a="content",{document:l}=useFrame(),{editingBlockId:r,editingItemIndex:i,setEditingBlockId:c,setEditingItemIndex:d}=useInlineEditing(),[m,u]=React.useState(null),p=React.useRef(null),{clearHighlight:g}=useBlockHighlight(),x=useUpdateBlocksProps(),{selectedLang:f}=useLanguages(),[,h]=useSelectedBlockIds(),j=React.useRef(null),b=r,{blockContent:C,blockType:B}=React.useMemo(()=>{var v;const E=o._type;let A=o[a];const R=runtime.getRegisteredChaiBlock(o._type);return f&&((v=R==null?void 0:R.i18nProps)==null?void 0:v.includes(a))&&lodashEs.has(o,`${a}-${f}`)&&(A=lodashEs.get(o,`${a}-${f}`)),{blockContent:A,blockType:E}},[o,f]),w=React.useCallback(E=>{var R;const A=E||((R=p.current)==null?void 0:R.innerText);x([b],{[a]:A}),u(null),c(null),d(-1),h(b?[b]:[])},[b,x,c,h,f]),_=web.useDebouncedCallback(E=>{x([b],{[a]:E})},[b,o,x,f],1e3),S=React.useCallback(E=>{E.preventDefault(),b&&(j.current=b),w(),setTimeout(()=>{const A=j.current;j.current=null,h([A])},100)},[h,b,f]);React.useEffect(()=>{var k;if(!b)return;const E=`[data-block-id="${b}"]`,A=i>=0?`[data-block-index="${i}"]`:"",R=l.querySelector(`${E}${A}`);R&&((k=R==null?void 0:R.classList)==null||k.add("sr-only"),u(R))},[b,B,l,i]);const y=React.useMemo(()=>m?(g(),B==="RichText"?jsxRuntime.jsx(RichTextEditor,{blockContent:C,editingElement:m,onChange:_,onClose:w,onEscape:S}):jsxRuntime.jsx(MemoizedEditor,{editorRef:p,blockContent:C,editingElement:m,onClose:w,onChange:_,onEscape:S})):null,[m,b,B,C,w,f]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[y,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:l,editingItemIndex:r}=useInlineEditing(),[i]=jotai.useAtom(n),c=React.useMemo(()=>runtime.getRegisteredChaiBlock(i._type),[i._type]),{selectedLang:d,fallbackLang:m}=useLanguages(),u=useBlockRuntimeProps(),p=usePageExternalData(),[g]=useHiddenBlockIds(),[x]=jotai.useAtom(dataBindingActiveAtom),f=lodashEs.get(c,"component",null),{index:h,key:j}=React.useContext(RepeaterContext),b=React.useMemo(()=>x?applyBinding.applyBindingToBlockProps(applyBinding.applyLanguage(i,d,c),p,{index:h,key:j}):applyBinding.applyLanguage(i,d,c),[i,d,c,p,x,h,j]),C=React.useMemo(()=>applyBinding.getBlockTagAttributes(i),[i,applyBinding.getBlockTagAttributes]),B=React.useMemo(()=>u(i._id,applyBinding.getBlockRuntimeProps(i._type)),[i._id,i._type,u,applyBinding.getBlockRuntimeProps]),w=React.useMemo(()=>({blockProps:{"data-block-id":i._id,"data-block-type":i._type,"data-block-index":h},inBuilder:!0,lang:d||m,...b,...C,...B,...o}),[i._id,i._type,d,m,b,C,B,o]),_=React.useMemo(()=>!CORE_BLOCKS.includes(i._type),[i._type]);if(lodashEs.isNull(f)||g.includes(i._id))return null;let S=jsxRuntime.jsx(React.Suspense,{children:React.createElement(f,{...w,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 y=l===i._id&&(r===h||h<0)?jsxRuntime.jsx(WithBlockTextEditor,{block:i,children:S}):S;return _?jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallbackRender:ErrorFallback,children:y}):y},PartialWrapper=({children:o,partialBlockId:n})=>{const a=useBuilderProp("gotoPage",lodashEs.noop),{saveState:l}=useSavePage(),{selectedLang:r,fallbackLang:i}=useLanguages(),c=React.useCallback(d=>{if(d.stopPropagation(),l!=="SAVED"){sonner.toast.error("You have unsaved changes. Please save the page first.");return}a({pageId:n,lang:r||i})},[l,a,n,r,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]),l=React.useMemo(()=>utils.splitAtom(jotai.atom(a)),[a]);return lodashEs.isEmpty(a)?null:jsxRuntime.jsx(PartialWrapper,{partialBlockId:o,children:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:l,blocks:a})})},BlocksRenderer=({blocks:o,parent:n=null,splitAtoms:a=void 0})=>{const l=useGetBlockAtom(a),r=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(r,c=>{const d=l(c._id);return d?jsxRuntime.jsx(MayBeAsyncPropsWrapper,{block:c,children:m=>jsxRuntime.jsx(BlockRenderer,{blockAtom:d,asyncProps:m,children:({_id:u,_type:p,partialBlockId:g,repeaterItems:x,$repeaterItemsKey:f})=>p==="Repeater"?lodashEs.isArray(x)&&x.map((h,j)=>jsxRuntime.jsx(RepeaterContext.Provider,{value:{index:j,key:f},children:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:c._id})},`${u}-${j}`)):p==="GlobalBlock"||p==="PartialBlock"?jsxRuntime.jsx(jotai.Provider,{store:builderStore,children:jsxRuntime.jsx(PartialBlocksRenderer,{partialBlockId:g})}):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(),l=useBuilderProp("htmlDir","ltr"),[r,i]=React.useState({}),c=React.useCallback(()=>{const{width:d,height:m}=o;if(d<n){const u=parseFloat((d/n).toFixed(2).toString());let p={};const g=m*u,x=d*u;m&&(p={height:100+(m-g)/g*100+"%",width:100+(d-x)/x*100+"%"}),i({position:"relative",top:0,transform:`scale(${u})`,transformOrigin:l==="rtl"?"top right":"top left",...p,maxWidth:"none"}),a(u*100)}else i({}),a(100)},[n,o,l,a]);return React.useEffect(()=>{c()},[n,o,a,c]),r};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:l}=useFrame(),{clearHighlight:r}=useBlockHighlight(),[i]=useSelectedBlockIds(),[c]=jotai.useAtom(treeRefAtom);return React.useEffect(()=>{setTimeout(()=>{if(!lodashEs.isEmpty(n))return;const d=getElementByDataBlockId(l,lodashEs.first(i));if(d){const m=d.getAttribute("data-style-prop");if(m){const u=d.getAttribute("data-style-id"),p=d.getAttribute("data-block-parent");a([{id:u,prop:m,blockId:p}])}}},100)},[l,i,a,n]),React.useEffect(()=>()=>r(),[r]),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:m,styleId:u,styleProp:p}=d;m&&(lodashEs.includes(i,m)||c==null||c.closeAll(),a([{id:u,prop:p,blockId:m}]),o([m]))}),usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION,()=>{r(),o([]),a([])}),null},StaticCanvas=()=>{const[o]=useCanvasDisplayWidth(),[,n]=useHighlightBlockId(),a=React.useRef(null),l=React.useRef(null),[r,i]=React.useState({width:0,height:0}),c=useCanvasScale(r),[,d]=jotai.useAtom(canvasIframeAtom),m=useBuilderProp("loading",!1),u=useBuilderProp("htmlDir","ltr"),p=React.useCallback(x=>{i(f=>({...f,width:x}))},[i]);React.useEffect(()=>{if(!l.current)return;const{clientWidth:x,clientHeight:f}=l.current;i({width:x,height:f})},[l,o]);const g=React.useMemo(()=>{let x=IframeInitialContent;return x=x.replace("__HTML_DIR__",u),x},[u]);return jsxRuntime.jsx(ResizableCanvasWrapper,{onMount:p,onResize:p,children:jsxRuntime.jsx("div",{onMouseLeave:()=>setTimeout(()=>n(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:l,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:g,children:[jsxRuntime.jsx(KeyboardHandler,{}),jsxRuntime.jsx(BlockSelectionHighlighter,{}),jsxRuntime.jsx(HeadTags,{}),jsxRuntime.jsxs(reactWrapBalancer.Provider,{children:[jsxRuntime.jsxs(Canvas,{children:[m?jsxRuntime.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsx(toggle.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-67qfXwGU.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(toggle.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(toggle.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:l}=reactI18next.useTranslation(),[r,i]=React.useState(o||"");React.useEffect(()=>{i(o||"")},[o]);const c=d=>{i(d);const m=removeSizeAttributes(d);n(m)};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:r?jsxRuntime.jsx("div",{className:"h-6 w-6",dangerouslySetInnerHTML:{__html:r}}):jsxRuntime.jsx("span",{className:"text-xs text-gray-400",children:"SVG"})}),jsxRuntime.jsx("textarea",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:r,onChange:d=>c(d.target.value),placeholder:l("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:l("Paste SVG code to use as an icon")})]})},DefaultMediaManager=({close:o,onSelect:n,mode:a="image"})=>{const[l,r]=React.useState(""),[i,c]=React.useState(!1),[d,m]=React.useState(!1),[u,p]=React.useState(null),g=async f=>{if(!f.trim()){m(!1),p("Please enter a URL");return}try{c(!0),p(null),m(!0),p(null)}catch{m(!1),p("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(toggle.Alert,{variant:"destructive",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(toggle.AlertDescription,{children:u})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsx(toggle.Input,{placeholder:x(`Enter ${a} URL`),value:l,onChange:f=>r(f.target.value),onKeyUp:()=>g(l)}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(toggle.Button,{variant:"outline",onClick:o,children:x("Cancel")}),jsxRuntime.jsx(toggle.Button,{onClick:()=>n({id:"dam-id",url:l,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:l="image"})=>{const[r,i]=React.useState(!1),c=useMediaManagerComponent(),d=(...m)=>{a.call(void 0,...m),i(!1)};return jsxRuntime.jsxs(toggle.Dialog,{open:r,onOpenChange:m=>i(m),children:[jsxRuntime.jsx(toggle.DialogTrigger,{asChild:!0,children:n}),jsxRuntime.jsx(toggle.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:l,assetId:o}):null})})]})};MediaManagerModal.displayName="MediaManagerModal";const PLACEHOLDER_IMAGE_URL="https://fldwljgzcktqnysdkxnn.supabase.co/storage/v1/object/public/dam-assets/02817647-2581-4c50-a005-f72de13d3da7/banner-placeholder.png",ImagePickerField=({value:o,onChange:n,id:a,onBlur:l})=>{const{t:r}=reactI18next.useTranslation(),{selectedLang:i}=useLanguages(),c=useSelectedBlock(),d=useUpdateBlocksProps(),m=a.split(".").pop()||"",u=i?`_${m}Id-${i}`:`${m}Id`,p=lodashEs.isEmpty(i)&&(c==null?void 0:c._type)==="Image"&&lodashEs.has(c,"assetId"),g=lodashEs.get(c,u,p?c==null?void 0:c.assetId:""),x=!!g,f=j=>{const b=lodashEs.isArray(j)?lodashEs.first(j):j;if(b){n(b==null?void 0:b.url);const C=b==null?void 0:b.width,B=b==null?void 0:b.height;if(c!=null&&c._id){const w={...C&&{width:C},...B&&{height:B},...b.description&&{alt:b.description}};if(lodashEs.set(w,u,b.id),lodashEs.isEmpty(w))return;d([c._id],w)}}},h=React.useCallback(()=>{n(PLACEHOLDER_IMAGE_URL),c!=null&&c._id&&d([c._id],{assetId:""})},[n,c==null?void 0:c._id,d]);return jsxRuntime.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[o?jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsx("img",{src:o,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover transition duration-200 "+(g&&g!==""?"cursor-pointer group-hover:blur-sm":""),alt:""}),x&&jsxRuntime.jsx("button",{type:"button",onClick:h,className:"absolute -right-2 -top-2 z-20 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})}),g&&g!==""&&jsxRuntime.jsx(MediaManagerModal,{onSelect:f,assetId:g,children:jsxRuntime.jsx("button",{type:"button",className:"absolute inset-0 z-10 flex cursor-pointer items-center justify-center bg-black/10 opacity-0 transition duration-200 group-hover:bg-black/30 group-hover:opacity-100",children:jsxRuntime.jsx(lucideReact.Edit2Icon,{className:"h-4 w-4 text-white"})})})]}):jsxRuntime.jsx(MediaManagerModal,{onSelect:f,mode:"image",assetId:g,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:f,assetId:"",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)?r("Replace image"):r("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:r("Enter image URL"),value:o,onBlur:({target:{value:j}})=>l(a,j),onChange:j=>n(j.target.value)})]})]})},PathDropdown=({data:o,onSelect:n,dataType:a})=>{const[l,r]=React.useState([]),[i,c]=React.useState(o),d=g=>Array.isArray(g)?"array":typeof g=="object"&&g!==null?"object":"value",m=React.useCallback(g=>{const x=f=>a==="value"?f==="value"||f==="object":a==="array"?f==="array":f===a;g.type==="object"?(r(f=>[...f,g.key]),c(g.value)):x(g.type)&&n([...l,g.key].join("."),a)},[l,n,a]),u=React.useCallback(()=>{if(l.length>0){const g=l.slice(0,-1);r(g),c(g.reduce((x,f)=>x[f],o))}},[l,o]),p=React.useMemo(()=>i?Object.entries(i).map(([g,x])=>({key:g,value:x,type:d(x)})).filter(g=>!lodashEs.startsWith(g.key,applyBinding.REPEATER_PREFIX)&&g.key.includes("/")?!1:a==="value"?g.type==="value"||g.type==="object":a==="array"?g.type==="array"||g.type==="object":a==="object"?g.type==="object":!0):[],[i,a]);return jsxRuntime.jsxs(toggle.Command,{className:"fields-command",children:[jsxRuntime.jsx(toggle.CommandInput,{className:"border-none",placeholder:"Search..."}),jsxRuntime.jsxs(toggle.CommandList,{children:[jsxRuntime.jsx(toggle.CommandEmpty,{children:"No option found."}),jsxRuntime.jsxs(toggle.CommandGroup,{children:[l.length>0&&jsxRuntime.jsxs(toggle.CommandItem,{onSelect:u,className:"flex items-center text-sm",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),p.map(g=>jsxRuntime.jsxs(toggle.CommandItem,{value:g.key,disabled:!1,onSelect:()=>m(g),className:"flex items-center justify-between",children:[jsxRuntime.jsxs("span",{className:"flex items-center gap-x-2",children:[lodashEs.startsWith(g.key,applyBinding.REPEATER_PREFIX)?jsxRuntime.jsx(reactIcons.LoopIcon,{}):lodashEs.startsWith(g.key,applyBinding.COLLECTION_PREFIX)?jsxRuntime.jsx(lucideReact.DatabaseIcon,{}):null,lodashEs.startsWith(g.key,applyBinding.REPEATER_PREFIX)?"Repeater Data":lodashEs.startsWith(g.key,applyBinding.COLLECTION_PREFIX)?g.key.replace(applyBinding.COLLECTION_PREFIX,""):g.key]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[a==="object"&&g.type==="object"&&jsxRuntime.jsx(toggle.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:x=>{x.stopPropagation(),n([...l,g.key].join("."),a)},children:"Select"}),g.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"})})]})]},g.key))]})]})]})};function NestedPathSelector({data:o,onSelect:n,dataType:a="value"}){const[l,r]=React.useState(!1),i=useBuilderProp("collections",[]),c=React.useMemo(()=>a==="array"?{...i.map(m=>m.id).reduce((m,u)=>({...m,[applyBinding.COLLECTION_PREFIX+u]:[]}),{}),...o}:o,[o,i,a]);return jsxRuntime.jsxs(toggle.Popover,{open:l,onOpenChange:r,children:[jsxRuntime.jsxs(toggle.Tooltip,{children:[jsxRuntime.jsx(toggle.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(toggle.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(toggle.Button,{size:"sm",variant:"outline",className:"h-5 rounded-sm px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":l,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(toggle.TooltipContent,{children:"Add field"})]}),jsxRuntime.jsx(toggle.PopoverContent,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:jsxRuntime.jsx(PathDropdown,{data:c,onSelect:(d,m)=>{n(d,m),r(!1)},dataType:a})})]})}const DataBindingSelector=({schema:o,onChange:n,id:a,formData:l})=>{const r=usePageExternalData(),i=useSelectedBlockHierarchy(),c=useSelectedBlock(),d=React.useMemo(()=>{if(i.length===1)return"";const p=i.find(f=>f._type==="Repeater"),x=lodashEs.get(p,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1");return`${applyBinding.REPEATER_PREFIX}${lodashEs.startsWith(x,applyBinding.COLLECTION_PREFIX)?`${x}/${p._id}`:x}`},[i]),m=React.useMemo(()=>lodashEs.first(lodashEs.get(r,d.replace(applyBinding.REPEATER_PREFIX,""),[])),[d,r]),u=React.useCallback((p,g)=>{if(p=lodashEs.isEmpty(d)?p:p.replace(`${d}`,"$index"),g==="array"||g==="object"){n(`{{${p}}}`,{},a);return}const x=b=>/[.,!?;:]/.test(b),f=(b,C,B)=>{let w="",_="";const S=C>0?b[C-1]:"",y=C<b.length?b[C]:"";return C>0&&(S==="."||!x(S)&&S!==" ")&&(w=" "),C<b.length&&!x(y)&&y!==" "&&(_=" "),{text:w+B+_,prefixLength:w.length,suffixLength:_.length}},h=document.getElementById(a);if(!h)return;const j=document.getElementById(`chai-rte-${a}`)||document.getElementById(`chai-rte-modal-${a}`);if(j&&(j.querySelector(".ProseMirror")||j.__chaiRTE)){const b=j.__chaiRTE;if(b){const C=`{{${p}}}`;b.commands.focus();const{from:B,to:w}=b.state.selection;if(B!==w)b.chain().deleteSelection().insertContent(C).run();else{const{state:S}=b,y=S.selection.from,E=S.doc.textBetween(Math.max(0,y-1),y),A=S.doc.textBetween(y,Math.min(y+1,S.doc.content.size));let R="";y>0&&E!==" "&&!x(E)&&(R=" ");let k="";A&&A!==" "&&!x(A)&&(k=" "),b.chain().insertContent(R+C+k).run()}setTimeout(()=>n(b.getHTML(),{},a),100);return}}else{const b=h,C=b.selectionStart||0,B=b.value||"",w=b.selectionEnd||C;if(w>C){const A=`{{${p}}}`,{text:R}=f(B,C,A),k=B.slice(0,C)+R+B.slice(w);n(k,{},a);return}const S=`{{${p}}}`,{text:y}=f(B,C,S),E=B.slice(0,C)+y+B.slice(C);n(E,{},a)}},[a,n,l,c==null?void 0:c._id,d]);return jsxRuntime.jsx(NestedPathSelector,{data:{...m&&{[d]:m},...r},onSelect:u,dataType:o.binding==="array"?"array":"value"})},PageTypeField=({href:o,pageTypes:n,onChange:a})=>{var A;const{t:l}=reactI18next.useTranslation(),r=useBuilderProp("searchPageTypeItems",(R,k)=>[]),[i,c]=React.useState(!1),[d,m]=React.useState(!1),[u,p]=React.useState("page"),[g,x]=React.useState(""),[f,h]=React.useState([]),[j,b]=React.useState(-1),C=React.useRef(null),B=(A=n==null?void 0:n.find(R=>R.key===u))==null?void 0:A.name;React.useEffect(()=>{if(x(""),h([]),b(-1),m(!1),!o||i||!lodashEs.startsWith(o,"pageType:"))return;const R=lodashEs.split(o,":"),k=lodashEs.get(R,1,"page")||"page";p(k),(async()=>{const v=await r(k,[lodashEs.get(R,2,"page")]);v&&Array.isArray(v)&&x(lodashEs.get(v,[0,"name"],""))})()},[o]);const w=web.useDebouncedCallback(async R=>{if(lodashEs.isEmpty(R))h([]);else{const k=await r(u,R);h(k)}c(!1),b(-1)},[u],300),_=R=>{const k=["pageType",u,R.id];k[1]&&(a(k.join(":")),x(R.name),m(!1),h([]),b(-1))},S=R=>{switch(R.key){case"ArrowDown":R.preventDefault(),b(k=>k<f.length-1?k+1:k);break;case"ArrowUp":R.preventDefault(),b(k=>k>0?k-1:k);break;case"Enter":if(R.preventDefault(),f.length===0)return;j>=0&&_(f[j]);break;case"Escape":R.preventDefault(),y();break}};React.useEffect(()=>{if(j>=0&&C.current){const R=C.current.children[j];R==null||R.scrollIntoView({block:"nearest"})}},[j]);const y=()=>{x(""),h([]),b(-1),m(!1),a("")},E=R=>{x(R),m(!lodashEs.isEmpty(R)),c(!0),w(R)};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("select",{name:"pageType",value:u,onChange:R=>p(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:g,onChange:R=>E(R.target.value),onKeyDown:S,placeholder:l(`Search ${B??""}`),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:g&&jsxRuntime.jsx("button",{onClick:y,className:"text-gray-400 hover:text-gray-600",title:l("Clear search"),children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})})]}),(i||!lodashEs.isEmpty(f)||d&&lodashEs.isEmpty(f))&&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(f)?jsxRuntime.jsxs("div",{className:"flex items-center justify-center p-4 text-sm text-gray-500",children:[l("No results found for"),' "',g,'"']}):jsxRuntime.jsx("ul",{ref:C,children:lodashEs.map(f==null?void 0:f.slice(0,20),(R,k)=>jsxRuntime.jsxs("li",{onClick:()=>_(R),className:`cursor-pointer p-2 text-xs ${o!=null&&o.includes(R.id)?"bg-blue-200":k===j?"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:l})=>{const{t:r}=reactI18next.useTranslation(),{type:i="pageType",href:c="",target:d="self"}=n,m=useBuilderProp("pageTypes",[]),u=i==="pageType"&&lodashEs.isEmpty(m)?"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:p=>{console.log("value",n,p),a({...n,href:p,...u==="pageType"?{type:"url"}:{}})},id:`root.${l}.href`,formData:n})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("select",{name:"type",value:i,onChange:p=>a({...n,type:p.target.value}),children:lodashEs.map([...lodashEs.isEmpty(m)?[]:[{const:"pageType",title:r("Goto Page")}],{const:"url",title:r("Open URL")},{const:"email",title:r("Compose Email")},{const:"telephone",title:r("Call Phone")},{const:"scroll",title:r("Scroll to element")}],p=>jsxRuntime.jsx("option",{value:p.const,children:p.title},p.const))}),u==="pageType"&&!lodashEs.isEmpty(m)?jsxRuntime.jsx(PageTypeField,{href:c,pageTypes:m,onChange:p=>a({...n,href:p})}):null,jsxRuntime.jsx("input",{id:`root.${l}.href`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",className:u==="pageType"?"!hidden":"",value:c,onChange:p=>a({...n,href:p.target.value}),placeholder:r(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.${l}.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:r("Open in new tab")})]})]})]})},RowColField=()=>{const o=useSelectedBlock(),n=useWrapperBlock(),{addCoreBlock:a}=useAddBlock();if(!o&&!n)return null;const l=(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:,"},l==null?void 0:l._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 r=window.prompt("URL");r&&o.chain().focus().extendMarkRange("link").setLink({href:r}).run()},l=()=>{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:l,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:l,onChange:r,onBlur:i})=>{const c=React.useRef(null),d=React.useRef(l||""),m=usePageExternalData();React.useEffect(()=>{if(o){const g=document.createElement("style");return g.id="rte-modal-styles",g.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]),l=React.useMemo(()=>plugin.getThemeFontsUrls(lodashEs.filter(a,i=>lodashEs.has(i,"url"))),[a]),r=React.useMemo(()=>plugin.getThemeCustomFontFace(lodashEs.filter(a,i=>lodashEs.has(i,"src"))),[a]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l.map((i,c)=>jsxRuntime.jsx("link",{rel:"stylesheet",href:i},`google-font-${c}`)),jsxRuntime.jsx("style",{id:"chai-custom-fonts",dangerouslySetInnerHTML:{__html:r}})]})},ResizableCanvasWrapper=({children:o,onMount:n,onResize:a})=>{const[,l]=useSelectedBlockIds(),[,r]=useSelectedStylingBlocks(),i=React.useRef(null),c=web.useDebouncedCallback(()=>{const{clientWidth:m}=i.current;a(m)},[i.current],100);web.useResizeObserver(i.current,c,i.current!==null),React.useEffect(()=>{const{clientWidth:m}=i.current;n(m)},[]);const d=React.useCallback(()=>{l([]),r([])},[l,r]);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]),l=lodashEs.get(a,"dataProviderDependencies"),r=lodashEs.get(a,"dataProvider"),i=lodashEs.get(a,"dataProviderMode","mock"),c=useAsyncProps(n,i,l,r);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((l,[r,i])=>{const c=[];let d=lodashEs.find(o,{_id:n});for(;d;)c.push(d),d=lodashEs.find(o,{_id:d._parent});const m=lodashEs.find(c,{_type:i.block});return m&&(l[r]=lodashEs.get(m,lodashEs.get(i,"prop"),null)),l},{}),[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:l})=>{const r=BUBBLE_MENU_ICONS[o];return jsxRuntime.jsx("button",{onClick:a,className:toggle.cn("rounded-md p-1.5 transition-colors duration-200",l?"bg-white/20":"hover:bg-white/10"),title:n,children:jsxRuntime.jsx(r,{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:l,onEscape:r})=>{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})=>l((u==null?void 0:u.getHTML())||""),onBlur:({editor:u,event:p})=>{const g=p.relatedTarget,x=i.querySelector(".ProseMirror"),f=i.querySelector(".tippy-box"),h=x==null?void 0:x.contains(g),j=f==null?void 0:f.contains(g);if(!h&&!j){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 g;const u="max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";if(!n)return u;const p=((g=n==null?void 0:n.className)==null?void 0:g.replace("sr-only",""))||"";return`${u} ${p}`},[n]),m=React.useCallback(u=>{u.key==="Escape"&&r(u)},[r]);return jsxRuntime.jsxs("div",{onKeyDown:m,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:l,onChange:r,onEscape:i})=>{const{document:c,window:d}=useFrame();React.useEffect(()=>{if(l.current){l.current.innerText=n,l.current.focus();const x=c.createRange(),f=d.getSelection();x.selectNodeContents(l.current),x.collapse(!1),f==null||f.removeAllRanges(),f==null||f.addRange(x),l.current.focus()}else a()},[c,d]);const m=React.useMemo(()=>{var f;const x=((f=o==null?void 0:o.tagName)==null?void 0:f.toLowerCase())||"div";return x==="button"?"div":x},[o]),u=React.useCallback(x=>{(x.key==="Enter"||x.key==="Escape")&&i(x)},[i]),p=React.useCallback(()=>{a()},[a]),g=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:f=>{const h=f.target;h&&(h.innerText.trim()===""?(h.setAttribute("data-placeholder","Enter text here"),h.children.length>0&&h.children[0].remove()):f.target.removeAttribute("data-placeholder"),r(f.target.innerText))},onClick:f=>{f.stopPropagation(),f.preventDefault()}}},[o==null?void 0:o.className,o==null?void 0:o.style]);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:React.createElement(m,{ref:l,onBlur:p,onKeyDown:u,...g})})}),WithBlockTextEditor=React.memo(({block:o,children:n})=>{const a="content",{document:l}=useFrame(),{editingBlockId:r,editingItemIndex:i,setEditingBlockId:c,setEditingItemIndex:d}=useInlineEditing(),[m,u]=React.useState(null),p=React.useRef(null),{clearHighlight:g}=useBlockHighlight(),x=useUpdateBlocksProps(),{selectedLang:f}=useLanguages(),[,h]=useSelectedBlockIds(),j=React.useRef(null),b=r,{blockContent:C,blockType:B}=React.useMemo(()=>{var v;const E=o._type;let A=o[a];const R=runtime.getRegisteredChaiBlock(o._type);return f&&((v=R==null?void 0:R.i18nProps)==null?void 0:v.includes(a))&&lodashEs.has(o,`${a}-${f}`)&&(A=lodashEs.get(o,`${a}-${f}`)),{blockContent:A,blockType:E}},[o,f]),w=React.useCallback(E=>{var R;const A=E||((R=p.current)==null?void 0:R.innerText);x([b],{[a]:A}),u(null),c(null),d(-1),h(b?[b]:[])},[b,x,c,h,f]),_=web.useDebouncedCallback(E=>{x([b],{[a]:E})},[b,o,x,f],1e3),S=React.useCallback(E=>{E.preventDefault(),b&&(j.current=b),w(),setTimeout(()=>{const A=j.current;j.current=null,h([A])},100)},[h,b,f]);React.useEffect(()=>{var k;if(!b)return;const E=`[data-block-id="${b}"]`,A=i>=0?`[data-block-index="${i}"]`:"",R=l.querySelector(`${E}${A}`);R&&((k=R==null?void 0:R.classList)==null||k.add("sr-only"),u(R))},[b,B,l,i]);const y=React.useMemo(()=>m?(g(),B==="RichText"?jsxRuntime.jsx(RichTextEditor,{blockContent:C,editingElement:m,onChange:_,onClose:w,onEscape:S}):jsxRuntime.jsx(MemoizedEditor,{editorRef:p,blockContent:C,editingElement:m,onClose:w,onChange:_,onEscape:S})):null,[m,b,B,C,w,f]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[y,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:l,editingItemIndex:r}=useInlineEditing(),[i]=jotai.useAtom(n),c=React.useMemo(()=>runtime.getRegisteredChaiBlock(i._type),[i._type]),{selectedLang:d,fallbackLang:m}=useLanguages(),u=useBlockRuntimeProps(),p=usePageExternalData(),[g]=useHiddenBlockIds(),[x]=jotai.useAtom(dataBindingActiveAtom),f=lodashEs.get(c,"component",null),{index:h,key:j}=React.useContext(RepeaterContext),b=React.useMemo(()=>x?applyBinding.applyBindingToBlockProps(applyBinding.applyLanguage(i,d,c),p,{index:h,key:j}):applyBinding.applyLanguage(i,d,c),[i,d,c,p,x,h,j]),C=React.useMemo(()=>applyBinding.getBlockTagAttributes(i),[i,applyBinding.getBlockTagAttributes]),B=React.useMemo(()=>u(i._id,applyBinding.getBlockRuntimeProps(i._type)),[i._id,i._type,u,applyBinding.getBlockRuntimeProps]),w=React.useMemo(()=>({blockProps:{"data-block-id":i._id,"data-block-type":i._type,"data-block-index":h},inBuilder:!0,lang:d||m,...b,...C,...B,...o}),[i._id,i._type,d,m,b,C,B,o]),_=React.useMemo(()=>!CORE_BLOCKS.includes(i._type),[i._type]);if(lodashEs.isNull(f)||g.includes(i._id))return null;let S=jsxRuntime.jsx(React.Suspense,{children:React.createElement(f,{...w,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 y=l===i._id&&(r===h||h<0)?jsxRuntime.jsx(WithBlockTextEditor,{block:i,children:S}):S;return _?jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallbackRender:ErrorFallback,children:y}):y},PartialWrapper=({children:o,partialBlockId:n})=>{const a=useBuilderProp("gotoPage",lodashEs.noop),{saveState:l}=useSavePage(),{selectedLang:r,fallbackLang:i}=useLanguages(),c=React.useCallback(d=>{if(d.stopPropagation(),l!=="SAVED"){sonner.toast.error("You have unsaved changes. Please save the page first.");return}a({pageId:n,lang:r||i})},[l,a,n,r,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]),l=React.useMemo(()=>utils.splitAtom(jotai.atom(a)),[a]);return lodashEs.isEmpty(a)?null:jsxRuntime.jsx(PartialWrapper,{partialBlockId:o,children:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:l,blocks:a})})},BlocksRenderer=({blocks:o,parent:n=null,splitAtoms:a=void 0})=>{const l=useGetBlockAtom(a),r=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(r,c=>{const d=l(c._id);return d?jsxRuntime.jsx(MayBeAsyncPropsWrapper,{block:c,children:m=>jsxRuntime.jsx(BlockRenderer,{blockAtom:d,asyncProps:m,children:({_id:u,_type:p,partialBlockId:g,repeaterItems:x,$repeaterItemsKey:f})=>p==="Repeater"?lodashEs.isArray(x)&&x.map((h,j)=>jsxRuntime.jsx(RepeaterContext.Provider,{value:{index:j,key:f},children:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:c._id})},`${u}-${j}`)):p==="GlobalBlock"||p==="PartialBlock"?jsxRuntime.jsx(jotai.Provider,{store:builderStore,children:jsxRuntime.jsx(PartialBlocksRenderer,{partialBlockId:g})}):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(),l=useBuilderProp("htmlDir","ltr"),[r,i]=React.useState({}),c=React.useCallback(()=>{const{width:d,height:m}=o;if(d<n){const u=parseFloat((d/n).toFixed(2).toString());let p={};const g=m*u,x=d*u;m&&(p={height:100+(m-g)/g*100+"%",width:100+(d-x)/x*100+"%"}),i({position:"relative",top:0,transform:`scale(${u})`,transformOrigin:l==="rtl"?"top right":"top left",...p,maxWidth:"none"}),a(u*100)}else i({}),a(100)},[n,o,l,a]);return React.useEffect(()=>{c()},[n,o,a,c]),r};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:l}=useFrame(),{clearHighlight:r}=useBlockHighlight(),[i]=useSelectedBlockIds(),[c]=jotai.useAtom(treeRefAtom);return React.useEffect(()=>{setTimeout(()=>{if(!lodashEs.isEmpty(n))return;const d=getElementByDataBlockId(l,lodashEs.first(i));if(d){const m=d.getAttribute("data-style-prop");if(m){const u=d.getAttribute("data-style-id"),p=d.getAttribute("data-block-parent");a([{id:u,prop:m,blockId:p}])}}},100)},[l,i,a,n]),React.useEffect(()=>()=>r(),[r]),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:m,styleId:u,styleProp:p}=d;m&&(lodashEs.includes(i,m)||c==null||c.closeAll(),a([{id:u,prop:p,blockId:m}]),o([m]))}),usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION,()=>{r(),o([]),a([])}),null},StaticCanvas=()=>{const[o]=useCanvasDisplayWidth(),[,n]=useHighlightBlockId(),a=React.useRef(null),l=React.useRef(null),[r,i]=React.useState({width:0,height:0}),c=useCanvasScale(r),[,d]=jotai.useAtom(canvasIframeAtom),m=useBuilderProp("loading",!1),u=useBuilderProp("htmlDir","ltr"),p=React.useCallback(x=>{i(f=>({...f,width:x}))},[i]);React.useEffect(()=>{if(!l.current)return;const{clientWidth:x,clientHeight:f}=l.current;i({width:x,height:f})},[l,o]);const g=React.useMemo(()=>{let x=IframeInitialContent;return x=x.replace("__HTML_DIR__",u),x},[u]);return jsxRuntime.jsx(ResizableCanvasWrapper,{onMount:p,onResize:p,children:jsxRuntime.jsx("div",{onMouseLeave:()=>setTimeout(()=>n(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:l,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:g,children:[jsxRuntime.jsx(KeyboardHandler,{}),jsxRuntime.jsx(BlockSelectionHighlighter,{}),jsxRuntime.jsx(HeadTags,{}),jsxRuntime.jsxs(reactWrapBalancer.Provider,{children:[jsxRuntime.jsxs(Canvas,{children:[m?jsxRuntime.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsx(toggle.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-67qfXwGU.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(toggle.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(toggle.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:l}=reactI18next.useTranslation(),[r,i]=React.useState(o||"");React.useEffect(()=>{i(o||"")},[o]);const c=d=>{i(d);const m=removeSizeAttributes(d);n(m)};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:r?jsxRuntime.jsx("div",{className:"h-6 w-6",dangerouslySetInnerHTML:{__html:r}}):jsxRuntime.jsx("span",{className:"text-xs text-gray-400",children:"SVG"})}),jsxRuntime.jsx("textarea",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:r,onChange:d=>c(d.target.value),placeholder:l("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:l("Paste SVG code to use as an icon")})]})},DefaultMediaManager=({close:o,onSelect:n,mode:a="image"})=>{const[l,r]=React.useState(""),[i,c]=React.useState(!1),[d,m]=React.useState(!1),[u,p]=React.useState(null),g=async f=>{if(!f.trim()){m(!1),p("Please enter a URL");return}try{c(!0),p(null),m(!0),p(null)}catch{m(!1),p("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(toggle.Alert,{variant:"destructive",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(toggle.AlertDescription,{children:u})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsx(toggle.Input,{placeholder:x(`Enter ${a} URL`),value:l,onChange:f=>r(f.target.value),onKeyUp:()=>g(l)}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(toggle.Button,{variant:"outline",onClick:o,children:x("Cancel")}),jsxRuntime.jsx(toggle.Button,{onClick:()=>n({id:"dam-id",url:l,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:l="image"})=>{const[r,i]=React.useState(!1),c=useMediaManagerComponent(),d=(...m)=>{a.call(void 0,...m),i(!1)};return jsxRuntime.jsxs(toggle.Dialog,{open:r,onOpenChange:m=>i(m),children:[jsxRuntime.jsx(toggle.DialogTrigger,{asChild:!0,children:n}),jsxRuntime.jsxs(toggle.DialogContent,{className:"flex max-h-[90vh] max-w-7xl border-border md:w-fit",children:[jsxRuntime.jsx(toggle.DialogTitle,{className:"sr-only",children:"Media Manager"}),jsxRuntime.jsx("div",{className:"h-full w-full",children:c?jsxRuntime.jsx(c,{close:()=>i(!1),onSelect:d,mode:l,assetId:o}):null})]})]})};MediaManagerModal.displayName="MediaManagerModal";const PLACEHOLDER_IMAGE="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==",ImagePickerField=({value:o,onChange:n,id:a,onBlur:l})=>{const{t:r}=reactI18next.useTranslation(),{selectedLang:i}=useLanguages(),c=useSelectedBlock(),d=useUpdateBlocksProps(),m=a.split(".").pop()||"",u=i?`_${m}Id-${i}`:`_${m}Id`,p=lodashEs.isEmpty(i)&&(c==null?void 0:c._type)==="Image"&&lodashEs.has(c,"assetId"),g=lodashEs.get(c,u,p?c==null?void 0:c.assetId:""),x=!!g,f=j=>{const b=lodashEs.isArray(j)?lodashEs.first(j):j;if(b){n(b==null?void 0:b.url);const C=b==null?void 0:b.width,B=b==null?void 0:b.height;if(c!=null&&c._id){const w={...C&&{width:C},...B&&{height:B},...b.description&&{alt:b.description}};if(lodashEs.set(w,u,b.id),lodashEs.isEmpty(w))return;d([c._id],w)}}},h=React.useCallback(()=>{n(PLACEHOLDER_IMAGE),c!=null&&c._id&&d([c._id],{assetId:""})},[n,c==null?void 0:c._id,d]);return jsxRuntime.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[o?jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsx("img",{src:o,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover transition duration-200 "+(g&&g!==""?"cursor-pointer group-hover:blur-sm":""),alt:""}),x&&jsxRuntime.jsx("button",{type:"button",onClick:h,className:"absolute -right-2 -top-2 z-20 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})}),g&&g!==""&&jsxRuntime.jsx(MediaManagerModal,{onSelect:f,assetId:g,children:jsxRuntime.jsx("button",{type:"button",className:"absolute inset-0 z-10 flex cursor-pointer items-center justify-center bg-black/10 opacity-0 transition duration-200 group-hover:bg-black/30 group-hover:opacity-100",children:jsxRuntime.jsx(lucideReact.Edit2Icon,{className:"h-4 w-4 text-white"})})})]}):jsxRuntime.jsx(MediaManagerModal,{onSelect:f,mode:"image",assetId:g,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:f,assetId:"",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)?r("Replace image"):r("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:r("Enter image URL"),value:o,onBlur:({target:{value:j}})=>l(a,j),onChange:j=>n(j.target.value)})]})]})},PathDropdown=({data:o,onSelect:n,dataType:a})=>{const[l,r]=React.useState([]),[i,c]=React.useState(o),d=g=>Array.isArray(g)?"array":typeof g=="object"&&g!==null?"object":"value",m=React.useCallback(g=>{const x=f=>a==="value"?f==="value"||f==="object":a==="array"?f==="array":f===a;g.type==="object"?(r(f=>[...f,g.key]),c(g.value)):x(g.type)&&n([...l,g.key].join("."),a)},[l,n,a]),u=React.useCallback(()=>{if(l.length>0){const g=l.slice(0,-1);r(g),c(g.reduce((x,f)=>x[f],o))}},[l,o]),p=React.useMemo(()=>i?Object.entries(i).map(([g,x])=>({key:g,value:x,type:d(x)})).filter(g=>!lodashEs.startsWith(g.key,applyBinding.REPEATER_PREFIX)&&g.key.includes("/")?!1:a==="value"?g.type==="value"||g.type==="object":a==="array"?g.type==="array"||g.type==="object":a==="object"?g.type==="object":!0):[],[i,a]);return jsxRuntime.jsxs(toggle.Command,{className:"fields-command",children:[jsxRuntime.jsx(toggle.CommandInput,{className:"border-none",placeholder:"Search..."}),jsxRuntime.jsxs(toggle.CommandList,{children:[jsxRuntime.jsx(toggle.CommandEmpty,{children:"No option found."}),jsxRuntime.jsxs(toggle.CommandGroup,{children:[l.length>0&&jsxRuntime.jsxs(toggle.CommandItem,{onSelect:u,className:"flex items-center text-sm",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),p.map(g=>jsxRuntime.jsxs(toggle.CommandItem,{value:g.key,disabled:!1,onSelect:()=>m(g),className:"flex items-center justify-between",children:[jsxRuntime.jsxs("span",{className:"flex items-center gap-x-2",children:[lodashEs.startsWith(g.key,applyBinding.REPEATER_PREFIX)?jsxRuntime.jsx(reactIcons.LoopIcon,{}):lodashEs.startsWith(g.key,applyBinding.COLLECTION_PREFIX)?jsxRuntime.jsx(lucideReact.DatabaseIcon,{}):null,lodashEs.startsWith(g.key,applyBinding.REPEATER_PREFIX)?"Repeater Data":lodashEs.startsWith(g.key,applyBinding.COLLECTION_PREFIX)?g.key.replace(applyBinding.COLLECTION_PREFIX,""):g.key]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[a==="object"&&g.type==="object"&&jsxRuntime.jsx(toggle.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:x=>{x.stopPropagation(),n([...l,g.key].join("."),a)},children:"Select"}),g.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"})})]})]},g.key))]})]})]})};function NestedPathSelector({data:o,onSelect:n,dataType:a="value"}){const[l,r]=React.useState(!1),i=useBuilderProp("collections",[]),c=React.useMemo(()=>a==="array"?{...i.map(m=>m.id).reduce((m,u)=>({...m,[applyBinding.COLLECTION_PREFIX+u]:[]}),{}),...o}:o,[o,i,a]);return jsxRuntime.jsxs(toggle.Popover,{open:l,onOpenChange:r,children:[jsxRuntime.jsxs(toggle.Tooltip,{children:[jsxRuntime.jsx(toggle.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(toggle.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(toggle.Button,{size:"sm",variant:"outline",className:"h-5 rounded-sm px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":l,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(toggle.TooltipContent,{children:"Add field"})]}),jsxRuntime.jsx(toggle.PopoverContent,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:jsxRuntime.jsx(PathDropdown,{data:c,onSelect:(d,m)=>{n(d,m),r(!1)},dataType:a})})]})}const DataBindingSelector=({schema:o,onChange:n,id:a,formData:l})=>{const r=usePageExternalData(),i=useSelectedBlockHierarchy(),c=useSelectedBlock(),d=React.useMemo(()=>{if(i.length===1)return"";const p=i.find(f=>f._type==="Repeater"),x=lodashEs.get(p,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1");return`${applyBinding.REPEATER_PREFIX}${lodashEs.startsWith(x,applyBinding.COLLECTION_PREFIX)?`${x}/${p._id}`:x}`},[i]),m=React.useMemo(()=>lodashEs.first(lodashEs.get(r,d.replace(applyBinding.REPEATER_PREFIX,""),[])),[d,r]),u=React.useCallback((p,g)=>{if(p=lodashEs.isEmpty(d)?p:p.replace(`${d}`,"$index"),g==="array"||g==="object"){n(`{{${p}}}`,{},a);return}const x=b=>/[.,!?;:]/.test(b),f=(b,C,B)=>{let w="",_="";const S=C>0?b[C-1]:"",y=C<b.length?b[C]:"";return C>0&&(S==="."||!x(S)&&S!==" ")&&(w=" "),C<b.length&&!x(y)&&y!==" "&&(_=" "),{text:w+B+_,prefixLength:w.length,suffixLength:_.length}},h=document.getElementById(a);if(!h)return;const j=document.getElementById(`chai-rte-${a}`)||document.getElementById(`chai-rte-modal-${a}`);if(j&&(j.querySelector(".ProseMirror")||j.__chaiRTE)){const b=j.__chaiRTE;if(b){const C=`{{${p}}}`;b.commands.focus();const{from:B,to:w}=b.state.selection;if(B!==w)b.chain().deleteSelection().insertContent(C).run();else{const{state:S}=b,y=S.selection.from,E=S.doc.textBetween(Math.max(0,y-1),y),A=S.doc.textBetween(y,Math.min(y+1,S.doc.content.size));let R="";y>0&&E!==" "&&!x(E)&&(R=" ");let k="";A&&A!==" "&&!x(A)&&(k=" "),b.chain().insertContent(R+C+k).run()}setTimeout(()=>n(b.getHTML(),{},a),100);return}}else{const b=h,C=b.selectionStart||0,B=b.value||"",w=b.selectionEnd||C;if(w>C){const A=`{{${p}}}`,{text:R}=f(B,C,A),k=B.slice(0,C)+R+B.slice(w);n(k,{},a);return}const S=`{{${p}}}`,{text:y}=f(B,C,S),E=B.slice(0,C)+y+B.slice(C);n(E,{},a)}},[a,n,l,c==null?void 0:c._id,d]);return jsxRuntime.jsx(NestedPathSelector,{data:{...m&&{[d]:m},...r},onSelect:u,dataType:o.binding==="array"?"array":"value"})},PageTypeField=({href:o,pageTypes:n,onChange:a})=>{var A;const{t:l}=reactI18next.useTranslation(),r=useBuilderProp("searchPageTypeItems",(R,k)=>[]),[i,c]=React.useState(!1),[d,m]=React.useState(!1),[u,p]=React.useState("page"),[g,x]=React.useState(""),[f,h]=React.useState([]),[j,b]=React.useState(-1),C=React.useRef(null),B=(A=n==null?void 0:n.find(R=>R.key===u))==null?void 0:A.name;React.useEffect(()=>{if(x(""),h([]),b(-1),m(!1),!o||i||!lodashEs.startsWith(o,"pageType:"))return;const R=lodashEs.split(o,":"),k=lodashEs.get(R,1,"page")||"page";p(k),(async()=>{const v=await r(k,[lodashEs.get(R,2,"page")]);v&&Array.isArray(v)&&x(lodashEs.get(v,[0,"name"],""))})()},[o]);const w=web.useDebouncedCallback(async R=>{if(lodashEs.isEmpty(R))h([]);else{const k=await r(u,R);h(k)}c(!1),b(-1)},[u],300),_=R=>{const k=["pageType",u,R.id];k[1]&&(a(k.join(":")),x(R.name),m(!1),h([]),b(-1))},S=R=>{switch(R.key){case"ArrowDown":R.preventDefault(),b(k=>k<f.length-1?k+1:k);break;case"ArrowUp":R.preventDefault(),b(k=>k>0?k-1:k);break;case"Enter":if(R.preventDefault(),f.length===0)return;j>=0&&_(f[j]);break;case"Escape":R.preventDefault(),y();break}};React.useEffect(()=>{if(j>=0&&C.current){const R=C.current.children[j];R==null||R.scrollIntoView({block:"nearest"})}},[j]);const y=()=>{x(""),h([]),b(-1),m(!1),a("")},E=R=>{x(R),m(!lodashEs.isEmpty(R)),c(!0),w(R)};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("select",{name:"pageType",value:u,onChange:R=>p(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:g,onChange:R=>E(R.target.value),onKeyDown:S,placeholder:l(`Search ${B??""}`),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:g&&jsxRuntime.jsx("button",{onClick:y,className:"text-gray-400 hover:text-gray-600",title:l("Clear search"),children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})})]}),(i||!lodashEs.isEmpty(f)||d&&lodashEs.isEmpty(f))&&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(f)?jsxRuntime.jsxs("div",{className:"flex items-center justify-center p-4 text-sm text-gray-500",children:[l("No results found for"),' "',g,'"']}):jsxRuntime.jsx("ul",{ref:C,children:lodashEs.map(f==null?void 0:f.slice(0,20),(R,k)=>jsxRuntime.jsxs("li",{onClick:()=>_(R),className:`cursor-pointer p-2 text-xs ${o!=null&&o.includes(R.id)?"bg-blue-200":k===j?"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:l})=>{const{t:r}=reactI18next.useTranslation(),{type:i="pageType",href:c="",target:d="self"}=n,m=useBuilderProp("pageTypes",[]),u=i==="pageType"&&lodashEs.isEmpty(m)?"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:p=>{console.log("value",n,p),a({...n,href:p,...u==="pageType"?{type:"url"}:{}})},id:`root.${l}.href`,formData:n})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("select",{name:"type",value:i,onChange:p=>a({...n,type:p.target.value}),children:lodashEs.map([...lodashEs.isEmpty(m)?[]:[{const:"pageType",title:r("Goto Page")}],{const:"url",title:r("Open URL")},{const:"email",title:r("Compose Email")},{const:"telephone",title:r("Call Phone")},{const:"scroll",title:r("Scroll to element")}],p=>jsxRuntime.jsx("option",{value:p.const,children:p.title},p.const))}),u==="pageType"&&!lodashEs.isEmpty(m)?jsxRuntime.jsx(PageTypeField,{href:c,pageTypes:m,onChange:p=>a({...n,href:p})}):null,jsxRuntime.jsx("input",{id:`root.${l}.href`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",className:u==="pageType"?"!hidden":"",value:c,onChange:p=>a({...n,href:p.target.value}),placeholder:r(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.${l}.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:r("Open in new tab")})]})]})]})},RowColField=()=>{const o=useSelectedBlock(),n=useWrapperBlock(),{addCoreBlock:a}=useAddBlock();if(!o&&!n)return null;const l=(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:,"},l==null?void 0:l._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 r=window.prompt("URL");r&&o.chain().focus().extendMarkRange("link").setLink({href:r}).run()},l=()=>{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:l,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:l,onChange:r,onBlur:i})=>{const c=React.useRef(null),d=React.useRef(l||""),m=usePageExternalData();React.useEffect(()=>{if(o){const g=document.createElement("style");return g.id="rte-modal-styles",g.innerHTML=`
62
62
  /* Ensure the NestedPathSelector popover appears above the dialog */
63
63
  .rte-path-selector + [data-radix-popper-content-wrapper],
64
64
  [data-radix-popper-content-wrapper] {
package/dist/core.js CHANGED
@@ -10,7 +10,7 @@ import React__default, { useMemo, useCallback, useEffect, useState, useRef, Comp
10
10
  import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
11
11
  import { atomWithStorage, splitAtom, useAtomCallback } from "jotai/utils";
12
12
  import { g as generateUUID, a as getBreakpointValue, c as cn$2 } from "./common-functions-BGzDsf1z.js";
13
- import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, b8 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, av as Popover, b4 as Tooltip, b7 as TooltipTrigger, ay as PopoverTrigger, b5 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, a6 as DialogHeader, a9 as DialogTitle, B as Badge, b6 as TooltipProvider, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, b1 as Textarea, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, z as CardFooter, az as ScrollArea, aZ as Tabs, a$ as TabsList, b0 as TabsTrigger, a_ as TabsContent, aX as Slider, aB as Select$1, aJ as SelectTrigger, aK as SelectValue, aC as SelectContent, aE as SelectItem, aL as Separator, aY as Switch, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, r as Avatar, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./toggle-CyXEVUOu.js";
13
+ import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, b8 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, a9 as DialogTitle, av as Popover, b4 as Tooltip, b7 as TooltipTrigger, ay as PopoverTrigger, b5 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, a6 as DialogHeader, B as Badge, b6 as TooltipProvider, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, b1 as Textarea, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, z as CardFooter, az as ScrollArea, aZ as Tabs, a$ as TabsList, b0 as TabsTrigger, a_ as TabsContent, aX as Slider, aB as Select$1, aJ as SelectTrigger, aK as SelectValue, aC as SelectContent, aE as SelectItem, aL as Separator, aY as Switch, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, r as Avatar, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./toggle-CyXEVUOu.js";
14
14
  import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, Edit2Icon, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, Info, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, Undo as Undo$1, ImportIcon, Type, CornerUpRight, Palette, Sun, Moon, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Layers } from "lucide-react";
15
15
  import clsx$1, { clsx } from "clsx";
16
16
  import { twMerge } from "tailwind-merge";
@@ -37,7 +37,7 @@ import { useFeature } from "flagged";
37
37
  import { parse, stringify } from "himalaya";
38
38
  import { Tree } from "react-arborist";
39
39
  import i18n from "i18next";
40
- import { default as ze } from "i18next";
40
+ import { default as We } from "i18next";
41
41
  import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
42
42
  import tailwindForms from "@tailwindcss/forms";
43
43
  import tailwindTypography from "@tailwindcss/typography";
@@ -4014,14 +4014,17 @@ const CanvasEventsWatcher = () => {
4014
4014
  const [l, i] = useState(!1), c = useMediaManagerComponent();
4015
4015
  return /* @__PURE__ */ jsxs(Dialog, { open: l, onOpenChange: (p) => i(p), children: [
4016
4016
  /* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children: r }),
4017
- /* @__PURE__ */ jsx(DialogContent, { className: "flex max-h-[90vh] max-w-7xl border-border md:w-fit", children: /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: c ? /* @__PURE__ */ jsx(c, { close: () => i(!1), onSelect: (...p) => {
4018
- n.call(void 0, ...p), i(!1);
4019
- }, mode: a, assetId: o }) : null }) })
4017
+ /* @__PURE__ */ jsxs(DialogContent, { className: "flex max-h-[90vh] max-w-7xl border-border md:w-fit", children: [
4018
+ /* @__PURE__ */ jsx(DialogTitle, { className: "sr-only", children: "Media Manager" }),
4019
+ /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: c ? /* @__PURE__ */ jsx(c, { close: () => i(!1), onSelect: (...p) => {
4020
+ n.call(void 0, ...p), i(!1);
4021
+ }, mode: a, assetId: o }) : null })
4022
+ ] })
4020
4023
  ] });
4021
4024
  };
4022
4025
  MediaManagerModal.displayName = "MediaManagerModal";
4023
- const PLACEHOLDER_IMAGE_URL = "https://fldwljgzcktqnysdkxnn.supabase.co/storage/v1/object/public/dam-assets/02817647-2581-4c50-a005-f72de13d3da7/banner-placeholder.png", ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
4024
- const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = n.split(".").pop() || "", u = i ? `_${p}Id-${i}` : `${p}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, u, g ? c == null ? void 0 : c.assetId : ""), m = !!h, f = (y) => {
4026
+ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==", ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
4027
+ const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = n.split(".").pop() || "", u = i ? `_${p}Id-${i}` : `_${p}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, u, g ? c == null ? void 0 : c.assetId : ""), m = !!h, f = (y) => {
4025
4028
  const b = isArray(y) ? first(y) : y;
4026
4029
  if (b) {
4027
4030
  r(b == null ? void 0 : b.url);
@@ -4037,7 +4040,7 @@ const PLACEHOLDER_IMAGE_URL = "https://fldwljgzcktqnysdkxnn.supabase.co/storage/
4037
4040
  }
4038
4041
  }
4039
4042
  }, x = useCallback(() => {
4040
- r(PLACEHOLDER_IMAGE_URL), c != null && c._id && d([c._id], { assetId: "" });
4043
+ r(PLACEHOLDER_IMAGE), c != null && c._id && d([c._id], { assetId: "" });
4041
4044
  }, [r, c == null ? void 0 : c._id, d]);
4042
4045
  return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-center gap-x-3", children: [
4043
4046
  o ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
@@ -10563,7 +10566,7 @@ export {
10563
10566
  getBlocksFromHTML as convertHTMLToChaiBlocks,
10564
10567
  generateUUID as generateBlockId,
10565
10568
  getBlocksFromHTML,
10566
- ze as i18n,
10569
+ We as i18n,
10567
10570
  cn$2 as mergeClasses,
10568
10571
  registerBlockSettingField,
10569
10572
  registerBlockSettingTemplate,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@chaibuilder/runtime"),i=require("react/jsx-runtime"),C=require("./common-functions-BZmyleS1.cjs"),f=require("react"),u=require("@radix-ui/react-icons"),d=require("lodash-es"),B=require("lucide-react");function j(e){const o=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(o,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const y=j(f),x=({className:e="",inBuilder:o})=>o?i.jsx("div",{className:C.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,_=e=>{const{blockProps:o,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})`}),y.createElement(n,{...o,...a,style:p},c)},T={type:"Box",description:"Similar to a div or section elements in HTML",label:"Box",category:"core",group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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=e=>{const{blockProps:o,iconSize:t,icon:r,content:s,styles:n,children:a,iconPos:c,link:p,inBuilder:m}=e,b=r,g=a||i.jsxs(i.Fragment,{children:[s&&i.jsx("span",{"data-ai-key":"content",children:s}),b&&i.jsx("div",{style:{width:t+"px"},className:c+" "+(s?c==="order-first"?"mr-2":"ml-2":"")||"",dangerouslySetInnerHTML:{__html:b}})]}),k=f.createElement("button",{...o,...n,type:"button","aria-label":s},g);return d.isEmpty(d.get(p,"href"))?k:m?i.jsx("span",{children:k}):i.jsx("a",{"aria-label":s,href:d.get(p,"href")||"/",target:d.get(p,"target","_self"),children:k})},N={type:"Button",description:"similar to a button element in HTML",label:"Button",category:"core",icon:u.ButtonIcon,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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"}},prefetchLink:{type:"boolean",default:!1,title:"Prefetch Link"}}}),i18nProps:["content"],aiProps:["content"]},R=e=>{const{blockProps:o,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 f.createElement("button",{...o,...n,type:"button","aria-label":s},c)},M={type:"CopyButton",description:"A copy button component",label:"Copy Button",category:"core",icon:u.CopyIcon,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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"]},A=e=>{const{blockProps:o,styles:t,htmlCode:r,inBuilder:s}=e;return s?i.jsxs("div",{className:"relative",children:[s?i.jsx("div",{...o,...t,className:"absolute z-20 h-full w-full"}):null,y.createElement("div",{...t,dangerouslySetInnerHTML:{__html:r.replace(/<script.*?>.*?<\/script>/g,"")}})]}):y.createElement("div",{...o,...t,dangerouslySetInnerHTML:{__html:r}})},$={type:"CustomHTML",description:"similar to a div or section elements in HTML",label:"Custom HTML",category:"core",icon:u.CodeIcon,group:"advanced",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),htmlCode:{type:"string",default:"<div><p>Enter your HTML code here...</p></div>",ui:{"ui:widget":"code"}}}}),i18nProps:["htmlCode"]},H=e=>{const{scripts:o,inBuilder:t,blockProps:r}=e;return t?i.jsx("div",{...r,children:i.jsx("div",{className:C.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:o}})},z={type:"CustomScript",description:"similar to a script element in HTML",label:"Custom Script",category:"core",icon:B.FileCode,group:"advanced",...l.registerChaiBlockSchema({properties:{scripts:{type:"string",title:"Script",default:"",format:"code",placeholder:"<script>console.log('Hello, world!');<\/script>"}}})},D=e=>{const{blockProps:o,styles:t}=e;return f.createElement("hr",{...t,...o})},U={type:"Divider",description:"A horizontal line component",label:"Divider",category:"core",icon:u.DividerHorizontalIcon,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("bg-gray-900 h-0.5 py-2 my-1")}})},V=e=>{const{blockProps:o,styles:t,backgroundImage:r}=e;let s={};return r&&(s={backgroundImage:`url(${r})`}),y.createElement("div",{...o,...t,style:s})},q={type:"EmptyBox",description:"A box component with no children",label:"Empty Box",category:"core",group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),backgroundImage:{type:"string",title:"Background Image",default:"",ui:{"ui:widget":"image"}}}})},F=e=>{const{blockProps:o,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e;return p?i.jsxs("div",{...s,...o,children:[i.jsx("input",{...n,name:t,type:"checkbox",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:t,children:r})]}):i.jsx("input",{name:t,...o,...n,...s,type:"checkbox",required:a,defaultChecked:c})},O={type:"Checkbox",label:"web_blocks.checkbox",category:"core",icon:u.CheckboxIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("flex items-center gap-x-2"),inputStyles:l.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"]},G=e=>{const{children:o,blockProps:t,errorMessage:r,successMessage:s,action:n,styles:a,inBuilder:c}=e;let p=o;o||(p=i.jsx(x,{inBuilder:c}));const m={"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",{...m,"data-error":r,"data-success":s,method:"post",action:n,...t,...a,children:[i.jsx("div",{...b}),p]})},Y={type:"Form",label:"Form",category:"core",icon:B.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,"}],...l.registerChaiBlockSchema({properties:{styles:l.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},W=e=>{const{blockProps:o,inBuilder:t,label:r,styles:s,icon:n,iconSize:a,iconPos:c}=e;return i.jsxs("button",{...s,...o||{},type:t?"button":"submit","aria-label":r,children:[r,n&&i.jsx("div",{style:{width:a+"px"},className:c+" "+(c==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:n}})]})},X={type:"FormButton",label:"Submit Button",category:"core",icon:u.ButtonIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("text-white bg-primary disabled:bg-gray-400 px-4 py-2 rounded-global flex items-center gap-x-2"),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"]},J=e=>{const o={type:"text",autocomplete:"on"};return e?["text","password","number","hidden","range","color","date","time"].includes(e)?{type:e,autocomplete:"on"}:e==="email"?{type:"email",autocomplete:"email"}:e==="tel"?{type:"tel",autocomplete:"tel"}:e==="url"?{type:"url",autocomplete:"url"}:{off:{type:"text",autocomplete:"off"},on:{type:"text",autocomplete:"on"},name:{type:"text",autocomplete:"name"},"honorific-prefix":{type:"text",autocomplete:"honorific-prefix"},"given-name":{type:"text",autocomplete:"given-name"},"additional-name":{type:"text",autocomplete:"additional-name"},"family-name":{type:"text",autocomplete:"family-name"},"honorific-suffix":{type:"text",autocomplete:"honorific-suffix"},nickname:{type:"text",autocomplete:"nickname"},email:{type:"email",autocomplete:"email"},tel:{type:"tel",autocomplete:"tel"},"tel-country-code":{type:"tel",autocomplete:"tel-country-code"},"tel-national":{type:"tel",autocomplete:"tel-national"},"tel-area-code":{type:"tel",autocomplete:"tel-area-code"},"tel-local":{type:"tel",autocomplete:"tel-local"},"tel-extension":{type:"tel",autocomplete:"tel-extension"},"street-address":{type:"text",autocomplete:"street-address"},"address-line1":{type:"text",autocomplete:"address-line1"},"address-line2":{type:"text",autocomplete:"address-line2"},"address-line3":{type:"text",autocomplete:"address-line3"},"address-level1":{type:"text",autocomplete:"address-level1"},"address-level2":{type:"text",autocomplete:"address-level2"},"address-level3":{type:"text",autocomplete:"address-level3"},"address-level4":{type:"text",autocomplete:"address-level4"},country:{type:"text",autocomplete:"country"},"country-name":{type:"text",autocomplete:"country-name"},"postal-code":{type:"text",autocomplete:"postal-code"},"cc-name":{type:"text",autocomplete:"cc-name"},"cc-given-name":{type:"text",autocomplete:"cc-given-name"},"cc-additional-name":{type:"text",autocomplete:"cc-additional-name"},"cc-family-name":{type:"text",autocomplete:"cc-family-name"},"cc-number":{type:"text",autocomplete:"cc-number"},"cc-exp":{type:"text",autocomplete:"cc-exp"},"cc-exp-month":{type:"number",autocomplete:"cc-exp-month"},"cc-exp-year":{type:"number",autocomplete:"cc-exp-year"},"cc-csc":{type:"text",autocomplete:"cc-csc"},"cc-type":{type:"text",autocomplete:"cc-type"},bday:{type:"date",autocomplete:"bday"},"bday-day":{type:"number",autocomplete:"bday-day"},"bday-month":{type:"number",autocomplete:"bday-month"},"bday-year":{type:"number",autocomplete:"bday-year"},username:{type:"text",autocomplete:"username"},"new-password":{type:"password",autocomplete:"new-password"},"current-password":{type:"password",autocomplete:"current-password"},"one-time-code":{type:"text",autocomplete:"one-time-code"},"transaction-currency":{type:"text",autocomplete:"transaction-currency"},"transaction-amount":{type:"number",autocomplete:"transaction-amount"},url:{type:"url",autocomplete:"url"},photo:{type:"url",autocomplete:"photo"},sex:{type:"text",autocomplete:"sex"},"organization-title":{type:"text",autocomplete:"organization-title"},organization:{type:"text",autocomplete:"organization"},language:{type:"text",autocomplete:"language"}}[e]||o:o},Q=e=>{const{blockProps:o,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,showLabel:c,required:p,inputType:m,defaultValue:b}=e,{type:g,autocomplete:k}=J(m);return c?i.jsxs("div",{...n,...o,children:[c&&i.jsx("label",{htmlFor:t,children:r}),i.jsx("input",{name:t,defaultValue:b,...a,type:g,placeholder:s,required:p,autoComplete:k})]}):i.jsx("input",{name:t,...o,...a,...n,type:g,placeholder:s,required:p,autoComplete:k,defaultValue:b})},Z={type:"Input",label:"web_blocks.input",category:"core",icon:u.InputIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),inputStyles:l.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},inputType:{type:"string",title:"Type",default:"email",oneOf:[{const:"text",title:"Text"},{const:"email",title:"Email"},{const:"password",title:"Password"},{const:"number",title:"Number"},{const:"tel",title:"Telephone"},{const:"hidden",title:"Hidden"},{const:"range",title:"Range"},{const:"color",title:"Color"},{const:"date",title:"Date"},{const:"time",title:"Time"},{const:"url",title:"URL"},{const:"name",title:"Name"},{const:"tel-country-code",title:"Telephone Country Code"},{const:"tel-national",title:"Telephone National"},{const:"tel-area-code",title:"Telephone Area Code"},{const:"tel-local",title:"Telephone Local"},{const:"tel-extension",title:"Telephone Extension"},{const:"street-address",title:"Street Address"},{const:"address-line1",title:"Address Line 1"},{const:"address-line2",title:"Address Line 2"},{const:"address-line3",title:"Address Line 3"},{const:"address-level1",title:"Address Level 1"},{const:"address-level2",title:"Address Level 2"},{const:"address-level3",title:"Address Level 3"},{const:"address-level4",title:"Address Level 4"},{const:"country",title:"Country"},{const:"country-name",title:"Country Name"},{const:"postal-code",title:"Postal Code"},{const:"cc-name",title:"Credit Card Name"},{const:"cc-number",title:"Credit Card Number"},{const:"cc-exp",title:"Credit Card Expiry"},{const:"cc-exp-month",title:"Credit Card Expiry Month"},{const:"cc-exp-year",title:"Credit Card Expiry Year"},{const:"cc-csc",title:"Credit Card CSC"},{const:"cc-type",title:"Credit Card Type"},{const:"bday",title:"Birthday"},{const:"bday-day",title:"Birthday Day"},{const:"bday-month",title:"Birthday Month"},{const:"bday-year",title:"Birthday Year"},{const:"username",title:"Username"},{const:"new-password",title:"New Password"},{const:"current-password",title:"Current Password"},{const:"one-time-code",title:"One Time Code"},{const:"transaction-currency",title:"Transaction Currency"},{const:"transaction-amount",title:"Transaction Amount"},{const:"url",title:"URL"},{const:"photo",title:"Photo"},{const:"sex",title:"Sex"},{const:"organization-title",title:"Organization Title"},{const:"organization",title:"Organization"},{const:"language",title:"Language"}]},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"},required:{type:"boolean",title:"Required",default:!1},defaultValue:{type:"string",title:"Default Value",default:""}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},K=e=>{const{blockProps:o,content:t,styles:r,children:s}=e,n={...r,...o};return s?y.createElement("label",n,s):y.createElement("label",{...n,dangerouslySetInnerHTML:{__html:t}})},ee={type:"Label",label:"Label",category:"core",icon:u.LetterCaseToggleIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(),content:{type:"string",title:"Content",default:""}}}),aiProps:["content"],i18nProps:["content"]},te=e=>{const{blockProps:o,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e;return p?i.jsxs("div",{...s,...o,children:[i.jsx("input",{...n,name:t,type:"radio",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:t,children:r})]}):i.jsx("input",{name:t,...o,...n,...s,type:"radio",required:a,checked:c})},oe={type:"Radio",label:"web_blocks.radio",category:"core",icon:u.RadiobuttonIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("flex items-center gap-x-2"),inputStyles:l.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"]},le=e=>{const{blockProps:o,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,required:c,showLabel:p,_multiple:m,options:b,defaultValue:g}=e,k=m&&g?g.split(",").map(h=>h.trim()):g||"";return p?i.jsxs("div",{...n,...o,children:[p&&i.jsx("label",{htmlFor:t,children:r}),i.jsxs("select",{...a,required:c,multiple:m,name:t,defaultValue:k,children:[i.jsx("option",{value:"",disabled:!0,hidden:!0,children:s}),d.map(b,h=>i.jsx("option",{value:h==null?void 0:h.value,children:h==null?void 0:h.label},h==null?void 0:h.value))]})]}):i.jsxs("select",{...n,...o,required:c,multiple:m,name:t,defaultValue:k,children:[i.jsx("option",{value:"",disabled:!0,hidden:!0,children:s}),d.map(b,h=>i.jsx("option",{value:h==null?void 0:h.value,children:h==null?void 0:h.label},h==null?void 0:h.value))]})},re={type:"Select",label:"web_blocks.select",category:"core",icon:u.DropdownMenuIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),inputStyles:l.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},defaultValue:{type:"string",title:"Default Value",default:""},_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"]},se=e=>{const{blockProps:o,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,rows:c,showLabel:p,required:m,defaultValue:b}=e;return p?i.jsxs("div",{...n,...o,children:[p&&i.jsx("label",{htmlFor:t,children:r}),i.jsx("textarea",{name:t,...a,placeholder:s,rows:c,required:m,defaultValue:b})]}):i.jsx("textarea",{name:t,...o,...a,...n,placeholder:s,rows:c,required:m,defaultValue:b})},ie={type:"TextArea",label:"web_blocks.textarea",category:"core",icon:u.InputIcon,group:"form",...l.registerChaiBlockSchema({properties:{fieldName:{type:"string",title:"Field Name",default:"fieldName"},styles:l.StylesProp(""),inputStyles:l.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},defaultValue:{type:"string",title:"Default Value",default:"",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},ne=e=>{const{blockProps:o,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",...o,children:[i.jsxs("h1",{children:["Global Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):y.createElement("span",{...o},r)},ae={type:"GlobalBlock",description:"A global block component",label:"Global Block",icon:B.GlobeIcon,category:"core",group:"basic",hidden:!0,...l.registerChaiBlockSchema({properties:{globalBlock:{type:"string",title:"Global Block",default:"",ui:{"ui:widget":"hidden"}}}})},ce=e=>{const{blockProps:o,styles:t,content:r,tag:s="h1",children:n=null}=e;return n?y.createElement(s,{...t,...o},n):y.createElement(s,{...t,...o,dangerouslySetInnerHTML:{__html:r}})},pe={type:"Heading",description:"A heading component similar to h1, h2, h3, h4, h5, h6 elements in HTML",label:"Heading",category:"core",icon:u.HeadingIcon,group:"typography",...l.registerChaiBlockSchema({properties:{tag:{type:"string",default:"h2",title:"Level",enum:["h1","h2","h3","h4","h5","h6"]},styles:l.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"},de=e=>{const{blockProps:o,styles:t}=e;return f.createElement("br",{...o,...t})},ue={type:"LineBreak",label:"Line Break",category:"core",group:"basic",hidden:!0,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},me=e=>{const{blockProps:o,children:t,styles:r}=e;return t?f.createElement("table",{...o,...r},t):i.jsx(x,{})},ye=e=>{const{blockProps:o,children:t,styles:r}=e;return t?f.createElement("thead",{...o,...r},t):i.jsx(x,{})},ge=e=>{const{blockProps:o,children:t,styles:r}=e;return t?f.createElement("tbody",{...o,...r},t):i.jsx(x,{})},he=e=>{const{blockProps:o,children:t,styles:r}=e;return t?f.createElement("tr",{...o,...r},t):i.jsx(x,{})},be=e=>{const{blockProps:o,children:t,content:r,styles:s}=e;return!t&&d.isEmpty(r)?i.jsx(x,{}):t?f.createElement("td",{...o,...s},t):f.createElement("td",{...o,...s,dangerouslySetInnerHTML:{__html:r}})};l.registerChaiBlock(me,{type:"Table",label:"Table",category:"core",group:"table",hidden:!0,icon:u.TableIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:S("Table")});l.registerChaiBlock(ye,{type:"TableHead",label:"Table Head",category:"core",group:"table",hidden:!0,icon:u.BorderTopIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:S("TableHead")});l.registerChaiBlock(ge,{type:"TableBody",label:"Table Body",category:"core",group:"table",hidden:!0,icon:u.BorderAllIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:S("TableBody")});l.registerChaiBlock(he,{type:"TableRow",label:"Table Row",category:"core",group:"table",hidden:!0,icon:u.ViewHorizontalIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:S("TableRow")});l.registerChaiBlock(be,{type:"TableCell",label:"Table Cell",category:"core",group:"table",hidden:!0,icon:u.DragHandleHorizontalIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),blocks:S("TableCell"),i18nProps:["content"],aiProps:["content"]});function S(e){const o=(n,a)=>({_id:C.generateUUID(),_parent:n,_type:"TableCell",styles:"#styles:,",content:`${e==="TableHead"?"Table Head":"Table Cell "+a}`}),t=n=>{const a=C.generateUUID(),c={_type:"TableRow",_id:a,styles:"#styles:,border-b"};return n&&(c._parent=n),[c,o(a,"1"),o(a,"2"),o(a,"3")]},r=n=>{const a=C.generateUUID(),c={_id:a,_type:"TableHead",styles:"#styles:,font-medium"};return n&&(c._parent=n),[c,...t(a)]},s=n=>{const a=C.generateUUID(),c={_id:a,_type:"TableBody",styles:"#styles:,"};return n&&(c._parent=n),[c,...t(a),...t(a)]};if(e==="Table"){const n=C.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,...o)=>({...e,className:C.cn(e.className,...o)}),fe=e=>{const{blockProps:o,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 y.createElement("span",{...o,...c,style:{width:s?`${s}px`:"auto",height:a?`${a}px`:"auto"},dangerouslySetInnerHTML:{__html:p}})},ke={type:"Icon",label:"web_blocks.icon",category:"core",icon:u.SketchLogoIcon,group:"media",...l.registerChaiBlockSchema({properties:{styles:l.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"}}})},xe=e=>{const{blockProps:o,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",{...o,...s,src:t,alt:n,loading:p?"lazy":"eager",width:c,height:a})]})},Ce={type:"Image",description:"A image component",label:"Image",category:"core",icon:u.ImageIcon,group:"media",...l.registerChaiBlockSchema({properties:{styles:l.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"}}}}),aiProps:["alt"],i18nProps:["alt","image","imageId","mobileImage","mobileImageId"]},Be=e=>{const{blockProps:o,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",{role:"link",...o,style:c,...s,children:r}):f.createElement("span",{...o,...s,style:c,role:"link"},a):r?i.jsx("a",{"aria-label":a,href:(t==null?void 0:t.href)||"#/",target:t==null?void 0:t.target,...o,...s,children:r}):f.createElement("a",{...o,...s,href:(t==null?void 0:t.href)||"#",target:(t==null?void 0:t.target)||"_self","aria-label":a},a)},Se={type:"Link",description:"A link component",label:"Link",category:"core",icon:u.Link1Icon,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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"}},prefetchLink:{type:"boolean",default:!1,title:"Prefetch Link"}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e!=="Link"},we=e=>{const{blockProps:o,children:t,listType:r,styles:s,tag:n,inBuilder:a}=e,c=C.cn(d.get(s,"className",""),r);return!t&&d.isEmpty(s==null?void 0:s.className)?i.jsx(x,{inBuilder:a}):y.createElement(n||(r==="list-decimal"?"ol":"ul"),{...o,...s,className:c},t)},Pe={type:"List",description:"A list component",label:"List",icon:u.RowsIcon,category:"core",group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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"}]},ve=e=>{const{blockProps:o,content:t,styles:r,children:s,tag:n}=e;return s?y.createElement(n||"li",{...r,...o},s):y.createElement(n||"li",{...r,...o,dangerouslySetInnerHTML:{__html:t}})},Le={type:"ListItem",description:"A list item component",label:"List Item",icon:u.ColumnsIcon,category:"core",group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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"},Ie=e=>{const{blockProps:o,styles:t,content:r}=e;return d.isNull(e.children)?y.createElement("p",{...t,...o,dangerouslySetInnerHTML:{__html:r}}):y.createElement("p",{...t,...o},e.children)},je={type:"Paragraph",description:"A paragraph component",label:"Paragraph",category:"core",icon:u.TextIcon,group:"typography",...l.registerChaiBlockSchema({properties:{styles:l.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"},_e=e=>{const{blockProps:o,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",...o,children:[i.jsxs("h1",{children:["Partial Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):y.createElement("span",{...o},r)},Te={type:"PartialBlock",description:"A partial block component",label:"Partial Block",icon:B.GlobeIcon,category:"core",group:"basic",hidden:!0,...l.registerChaiBlockSchema({properties:{partialBlockId:{type:"string",title:"Partial Block",default:"",ui:{"ui:widget":"hidden"}}}})},w={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"}},Ee=e=>{const{blockProps:o,children:t,styles:r,colSpan:s,tabletColSpan:n,desktopColSpan:a}=e,p={className:[d.get(r,"className",""),d.get(w,["SMALL",isNaN(s)||!s?6:s],""),n?d.get(w,["MEDIUM",n||s],""):"",a?d.get(w,["LARGE",n||s],""):""].join(" ")};return i.jsx("div",{...o,...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"})})},Ne={type:"Column",description:"A column component",label:"Column",group:"basic",category:"core",icon:B.Columns,wrapper:!0,canDelete:()=>!0,canAcceptBlock:()=>!0,canBeNested:e=>e==="Row",...l.registerChaiBlockSchema({properties:{styles:l.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]}}})},Re=e=>{const{blockProps:o,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",{...o,...r,...a,children:t})},Me={type:"Row",description:"A row component",label:"Row",group:"basic",icon:B.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",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),colCount:{type:"number",default:2,minimum:0,ui:{"ui:widget":"colCount"}},gutter:{type:"number",title:"Gutter (in px)",default:16,minimum:0}}})},Ae=e=>{const{blockProps:o,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",{...o,...s,dangerouslySetInnerHTML:{__html:t}})},$e={type:"RichText",description:"A rich text block",label:"Rich Text",category:"core",icon:u.CursorTextIcon,group:"typography",...l.registerChaiBlockSchema({properties:{styles:l.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"]},He=e=>{const{blockProps:o,styles:t,content:r,children:s=null,tag:n}=e;return s?y.createElement("span",{...t,...o},s):y.createElement(n||"span",{...t,...o,dangerouslySetInnerHTML:{__html:r||""}})},ze={type:"Span",description:"A span component",label:"Span",category:"core",group:"typography",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),content:{type:"string",title:"Content",default:"",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:()=>!0},De=e=>e.inBuilder||e.forceWrapper?i.jsx("span",{...e.blockProps,children:e.content}):`${e.content}`,Ue={type:"Text",description:"A text component with no styling",label:"Text",hidden:!0,category:"core",group:"typography",icon:u.SpaceBetweenVerticallyIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("text-black"),content:{title:"Content",type:"string",default:""}}}),aiProps:["content"],i18nProps:["content"]},P={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}}},v=/^(https?:\/\/)?(www\.)?youtube\.com\/(watch\?v=|embed\/)([a-zA-Z0-9_-]{11})/,L=/(?:https?:\/\/)?(?:www\.)?(?:vimeo\.com\/(?:channels\/[\w]+\/|groups\/[^\/]+\/videos\/|album\/\d+\/video\/|video\/)?|player\.vimeo\.com\/video\/)(\d+)/,Ve=(e,o)=>{const t=d.get(o,"autoplay",!1),r=d.get(o,"controls",!1),s=d.get(o,"loop",!1),n=t||d.get(o,"muted",!0);if(v.test(e)){const a=e.match(v);if(a){const c=a[4];let p=`https://www.youtube.com/embed/${c}`,m=t?"autoplay=1":"";return m+=s?`&loop=1&playlist=${c}`:"",m+=n?"&mute=1&muted=1":"",m+=r?"&controls=1":"&controls=0",`${p}?${m}`}}if(L.test(e)){const a=e.match(L);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:o,blockProps:t,styles:r,controls:s,videoSource:n,inBuilder:a}=e,c=Ve(o,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(o)?`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"})]})},Fe=e=>{const{url:o,styles:t,controls:r,sources:s,poster:n,blockProps:a}=e;let c=n;const p=[...d.get(s,"srcsets",[])||[]];o&&typeof o=="string"&&p.push({url:o,width:"9999"});const m=p.sort((g,k)=>parseInt(g.width)-parseInt(k.width)).filter(g=>!d.isEmpty(g.url)&&!d.isEmpty(g.width));m.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(m))&&i.jsx("div",{className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:f.createElement("video",{...t,...a,key:JSON.stringify(m),controls:d.get(r,"controls",!1),autoPlay:d.get(r,"autoplay",!1),loop:d.get(r,"loop",!1),poster:c,...b?{muted:!0}:{}},m.map(g=>{if(!g.url||g.url.length<4||isNaN(g.width))return null;const k=`(max-width: ${g.width}px)`;return i.jsx("source",{src:g.url,media:k,type:g.type},g.url)}),"Your browser does not support the video tag.")})},Oe=e=>{const{videoSource:o}=e;return o==="Custom"?i.jsx(Fe,{...e}):o==="Youtube"||o==="Vimeo"?i.jsx(qe,{...e}):i.jsxs("div",{children:["Invalid video source : ",o]})},Ge={type:"Video",label:"Video",category:"core",icon:u.VideoIcon,group:"media",...l.registerChaiBlockSchema({properties:{styles:l.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:{...P}}}},{if:{properties:{videoSource:{const:"Youtube"}}},then:{properties:{url:{type:"string",title:"Youtube Video URL",default:""},controls:{...P}}}},{if:{properties:{videoSource:{const:"Vimeo"}}},then:{properties:{url:{type:"string",title:"Vimeo Video URL",default:""},controls:{...P}}}}],ui:{url:{"ui:placeholder":"Enter Video URL"},sources:{"ui:field":"sources"},poster:{"ui:placeholder":"Enter poster URL"}}}),i18nProps:["url"]},Ye=e=>{const{children:o,tag:t,styles:r,blockProps:s,inBuilder:n,$loading:a}=e;let c=o;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"})),t==="none"?a&&n?Array.from({length:2}).map((p,m)=>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"})]},m)):c:y.createElement(t,{...s,...r},a&&n?Array.from({length:2}).map((p,m)=>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"})]},m)):c)},We={type:"Repeater",label:"Repeater",icon:u.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"}],...l.registerChaiBlockSchema({properties:{styles:l.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"}}}})},Xe=({children:e,blockProps:o,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?y.createElement(n,{...o,...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"})):y.createElement(n,{...o,...t},e)},Je={type:"RepeaterItem",label:"Repeater Item",icon:u.LoopIcon,hidden:!0,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.stylesProp(""),parentTag:l.closestBlockProp("Repeater","tag")}}),canAcceptBlock:e=>e!=="RepeaterItem",canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Qe=({children:e,blockProps:o,styles:t})=>y.createElement("div",{...o,...t},e),Ze={type:"RepeaterEmptyState",label:"Empty State",hidden:!0,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.stylesProp("p-5 flex items-center justify-center")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Ke=()=>{l.registerChaiBlock(_,T),l.registerChaiBlock(V,q),l.registerChaiBlock(E,N),l.registerChaiBlock(ce,pe),l.registerChaiBlock(Ie,je),l.registerChaiBlock(He,ze),l.registerChaiBlock(Ae,$e),l.registerChaiBlock(Be,Se),l.registerChaiBlock(we,Pe),l.registerChaiBlock(ve,Le),l.registerChaiBlock(fe,ke),l.registerChaiBlock(xe,Ce),l.registerChaiBlock(Oe,Ge),l.registerChaiBlock(A,$),l.registerChaiBlock(H,z),l.registerChaiBlock(De,Ue),l.registerChaiBlock(G,Y),l.registerChaiBlock(W,X),l.registerChaiBlock(Q,Z),l.registerChaiBlock(F,O),l.registerChaiBlock(te,oe),l.registerChaiBlock(le,re),l.registerChaiBlock(se,ie),l.registerChaiBlock(K,ee),l.registerChaiBlock(de,ue),l.registerChaiBlock(D,U),l.registerChaiBlock(ne,ae),l.registerChaiBlock(_e,Te),l.registerChaiBlock(Re,Me),l.registerChaiBlock(Ee,Ne),l.registerChaiBlock(R,M),l.registerChaiBlock(Ye,We),l.registerChaiBlock(Xe,Je),l.registerChaiBlock(Qe,Ze)};exports.loadWebBlocks=Ke;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@chaibuilder/runtime"),i=require("react/jsx-runtime"),C=require("./common-functions-BZmyleS1.cjs"),f=require("react"),u=require("@radix-ui/react-icons"),d=require("lodash-es"),B=require("lucide-react");function j(e){const o=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(o,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const y=j(f),x=({className:e="",inBuilder:o})=>o?i.jsx("div",{className:C.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,_=e=>{const{blockProps:o,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})`}),y.createElement(n,{...o,...a,style:p},c)},T={type:"Box",description:"Similar to a div or section elements in HTML",label:"Box",category:"core",group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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},N=e=>{const{blockProps:o,iconSize:t,icon:r,content:s,styles:n,children:a,iconPos:c,link:p,inBuilder:m}=e,b=r,g=a||i.jsxs(i.Fragment,{children:[s&&i.jsx("span",{"data-ai-key":"content",children:s}),b&&i.jsx("div",{style:{width:t+"px"},className:c+" "+(s?c==="order-first"?"mr-2":"ml-2":"")||"",dangerouslySetInnerHTML:{__html:b}})]}),k=f.createElement("button",{...o,...n,type:"button","aria-label":s},g);return d.isEmpty(d.get(p,"href"))?k:m?i.jsx("span",{children:k}):i.jsx("a",{"aria-label":s,href:d.get(p,"href")||"/",target:d.get(p,"target","_self"),children:k})},E={type:"Button",description:"similar to a button element in HTML",label:"Button",category:"core",icon:u.ButtonIcon,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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"}},prefetchLink:{type:"boolean",default:!1,title:"Prefetch Link"}}}),i18nProps:["content"],aiProps:["content"]},R=e=>{const{blockProps:o,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 f.createElement("button",{...o,...n,type:"button","aria-label":s},c)},M={type:"CopyButton",description:"A copy button component",label:"Copy Button",category:"core",icon:u.CopyIcon,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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"]},A=e=>{const{blockProps:o,styles:t,htmlCode:r,inBuilder:s}=e;return s?i.jsxs("div",{className:"relative",children:[s?i.jsx("div",{...o,...t,className:"absolute z-20 h-full w-full"}):null,y.createElement("div",{...t,dangerouslySetInnerHTML:{__html:r.replace(/<script.*?>.*?<\/script>/g,"")}})]}):y.createElement("div",{...o,...t,dangerouslySetInnerHTML:{__html:r}})},H={type:"CustomHTML",description:"similar to a div or section elements in HTML",label:"Custom HTML",category:"core",icon:u.CodeIcon,group:"advanced",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),htmlCode:{type:"string",default:"<div><p>Enter your HTML code here...</p></div>",ui:{"ui:widget":"code"}}}}),i18nProps:["htmlCode"]},$=e=>{const{scripts:o,inBuilder:t,blockProps:r}=e;return t?i.jsx("div",{...r,children:i.jsx("div",{className:C.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:o}})},D={type:"CustomScript",description:"similar to a script element in HTML",label:"Custom Script",category:"core",icon:B.FileCode,group:"advanced",...l.registerChaiBlockSchema({properties:{scripts:{type:"string",title:"Script",default:"",format:"code",placeholder:"<script>console.log('Hello, world!');<\/script>"}}})},z=e=>{const{blockProps:o,styles:t}=e;return f.createElement("hr",{...t,...o})},V={type:"Divider",description:"A horizontal line component",label:"Divider",category:"core",icon:u.DividerHorizontalIcon,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("bg-gray-900 h-0.5 py-2 my-1")}})},U=e=>{const{blockProps:o,styles:t,backgroundImage:r}=e;let s={};return r&&(s={backgroundImage:`url(${r})`}),y.createElement("div",{...o,...t,style:s})},q={type:"EmptyBox",description:"A box component with no children",label:"Empty Box",category:"core",group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),backgroundImage:{type:"string",title:"Background Image",default:"",ui:{"ui:widget":"image"}}}})},F=e=>{const{blockProps:o,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e;return p?i.jsxs("div",{...s,...o,children:[i.jsx("input",{...n,name:t,type:"checkbox",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:t,children:r})]}):i.jsx("input",{name:t,...o,...n,...s,type:"checkbox",required:a,defaultChecked:c})},G={type:"Checkbox",label:"web_blocks.checkbox",category:"core",icon:u.CheckboxIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("flex items-center gap-x-2"),inputStyles:l.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"]},O=e=>{const{children:o,blockProps:t,errorMessage:r,successMessage:s,action:n,styles:a,inBuilder:c}=e;let p=o;o||(p=i.jsx(x,{inBuilder:c}));const m={"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",{...m,"data-error":r,"data-success":s,method:"post",action:n,...t,...a,children:[i.jsx("div",{...b}),p]})},Z={type:"Form",label:"Form",category:"core",icon:B.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,"}],...l.registerChaiBlockSchema({properties:{styles:l.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},W=e=>{const{blockProps:o,inBuilder:t,label:r,styles:s,icon:n,iconSize:a,iconPos:c}=e;return i.jsxs("button",{...s,...o||{},type:t?"button":"submit","aria-label":r,children:[r,n&&i.jsx("div",{style:{width:a+"px"},className:c+" "+(c==="order-first"?"mr-2":"ml-2")||"",dangerouslySetInnerHTML:{__html:n}})]})},Y={type:"FormButton",label:"Submit Button",category:"core",icon:u.ButtonIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("text-white bg-primary disabled:bg-gray-400 px-4 py-2 rounded-global flex items-center gap-x-2"),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"]},Q=e=>{const o={type:"text",autocomplete:"on"};return e?["text","password","number","hidden","range","color","date","time"].includes(e)?{type:e,autocomplete:"on"}:e==="email"?{type:"email",autocomplete:"email"}:e==="tel"?{type:"tel",autocomplete:"tel"}:e==="url"?{type:"url",autocomplete:"url"}:{off:{type:"text",autocomplete:"off"},on:{type:"text",autocomplete:"on"},name:{type:"text",autocomplete:"name"},"honorific-prefix":{type:"text",autocomplete:"honorific-prefix"},"given-name":{type:"text",autocomplete:"given-name"},"additional-name":{type:"text",autocomplete:"additional-name"},"family-name":{type:"text",autocomplete:"family-name"},"honorific-suffix":{type:"text",autocomplete:"honorific-suffix"},nickname:{type:"text",autocomplete:"nickname"},email:{type:"email",autocomplete:"email"},tel:{type:"tel",autocomplete:"tel"},"tel-country-code":{type:"tel",autocomplete:"tel-country-code"},"tel-national":{type:"tel",autocomplete:"tel-national"},"tel-area-code":{type:"tel",autocomplete:"tel-area-code"},"tel-local":{type:"tel",autocomplete:"tel-local"},"tel-extension":{type:"tel",autocomplete:"tel-extension"},"street-address":{type:"text",autocomplete:"street-address"},"address-line1":{type:"text",autocomplete:"address-line1"},"address-line2":{type:"text",autocomplete:"address-line2"},"address-line3":{type:"text",autocomplete:"address-line3"},"address-level1":{type:"text",autocomplete:"address-level1"},"address-level2":{type:"text",autocomplete:"address-level2"},"address-level3":{type:"text",autocomplete:"address-level3"},"address-level4":{type:"text",autocomplete:"address-level4"},country:{type:"text",autocomplete:"country"},"country-name":{type:"text",autocomplete:"country-name"},"postal-code":{type:"text",autocomplete:"postal-code"},"cc-name":{type:"text",autocomplete:"cc-name"},"cc-given-name":{type:"text",autocomplete:"cc-given-name"},"cc-additional-name":{type:"text",autocomplete:"cc-additional-name"},"cc-family-name":{type:"text",autocomplete:"cc-family-name"},"cc-number":{type:"text",autocomplete:"cc-number"},"cc-exp":{type:"text",autocomplete:"cc-exp"},"cc-exp-month":{type:"number",autocomplete:"cc-exp-month"},"cc-exp-year":{type:"number",autocomplete:"cc-exp-year"},"cc-csc":{type:"text",autocomplete:"cc-csc"},"cc-type":{type:"text",autocomplete:"cc-type"},bday:{type:"date",autocomplete:"bday"},"bday-day":{type:"number",autocomplete:"bday-day"},"bday-month":{type:"number",autocomplete:"bday-month"},"bday-year":{type:"number",autocomplete:"bday-year"},username:{type:"text",autocomplete:"username"},"new-password":{type:"password",autocomplete:"new-password"},"current-password":{type:"password",autocomplete:"current-password"},"one-time-code":{type:"text",autocomplete:"one-time-code"},"transaction-currency":{type:"text",autocomplete:"transaction-currency"},"transaction-amount":{type:"number",autocomplete:"transaction-amount"},url:{type:"url",autocomplete:"url"},photo:{type:"url",autocomplete:"photo"},sex:{type:"text",autocomplete:"sex"},"organization-title":{type:"text",autocomplete:"organization-title"},organization:{type:"text",autocomplete:"organization"},language:{type:"text",autocomplete:"language"}}[e]||o:o},J=e=>{const{blockProps:o,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,showLabel:c,required:p,inputType:m,defaultValue:b}=e,{type:g,autocomplete:k}=Q(m);return c?i.jsxs("div",{...n,...o,children:[c&&i.jsx("label",{htmlFor:t,children:r}),i.jsx("input",{name:t,defaultValue:b,...a,type:g,placeholder:s,required:p,autoComplete:k})]}):i.jsx("input",{name:t,...o,...a,...n,type:g,placeholder:s,required:p,autoComplete:k,defaultValue:b})},X={type:"Input",label:"web_blocks.input",category:"core",icon:u.InputIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),inputStyles:l.StylesProp("w-full p-1"),fieldName:{type:"string",title:"Field Name",default:"fieldName"},inputType:{type:"string",title:"Type",default:"email",oneOf:[{const:"text",title:"Text"},{const:"email",title:"Email"},{const:"password",title:"Password"},{const:"number",title:"Number"},{const:"tel",title:"Telephone"},{const:"hidden",title:"Hidden"},{const:"range",title:"Range"},{const:"color",title:"Color"},{const:"date",title:"Date"},{const:"time",title:"Time"},{const:"url",title:"URL"},{const:"name",title:"Name"},{const:"tel-country-code",title:"Telephone Country Code"},{const:"tel-national",title:"Telephone National"},{const:"tel-area-code",title:"Telephone Area Code"},{const:"tel-local",title:"Telephone Local"},{const:"tel-extension",title:"Telephone Extension"},{const:"street-address",title:"Street Address"},{const:"address-line1",title:"Address Line 1"},{const:"address-line2",title:"Address Line 2"},{const:"address-line3",title:"Address Line 3"},{const:"address-level1",title:"Address Level 1"},{const:"address-level2",title:"Address Level 2"},{const:"address-level3",title:"Address Level 3"},{const:"address-level4",title:"Address Level 4"},{const:"country",title:"Country"},{const:"country-name",title:"Country Name"},{const:"postal-code",title:"Postal Code"},{const:"cc-name",title:"Credit Card Name"},{const:"cc-number",title:"Credit Card Number"},{const:"cc-exp",title:"Credit Card Expiry"},{const:"cc-exp-month",title:"Credit Card Expiry Month"},{const:"cc-exp-year",title:"Credit Card Expiry Year"},{const:"cc-csc",title:"Credit Card CSC"},{const:"cc-type",title:"Credit Card Type"},{const:"bday",title:"Birthday"},{const:"bday-day",title:"Birthday Day"},{const:"bday-month",title:"Birthday Month"},{const:"bday-year",title:"Birthday Year"},{const:"username",title:"Username"},{const:"new-password",title:"New Password"},{const:"current-password",title:"Current Password"},{const:"one-time-code",title:"One Time Code"},{const:"transaction-currency",title:"Transaction Currency"},{const:"transaction-amount",title:"Transaction Amount"},{const:"url",title:"URL"},{const:"photo",title:"Photo"},{const:"sex",title:"Sex"},{const:"organization-title",title:"Organization Title"},{const:"organization",title:"Organization"},{const:"language",title:"Language"}]},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"},required:{type:"boolean",title:"Required",default:!1},defaultValue:{type:"string",title:"Default Value",default:""}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},K=e=>{const{blockProps:o,content:t,styles:r,children:s}=e,n={...r,...o};return s?y.createElement("label",n,s):y.createElement("label",{...n,dangerouslySetInnerHTML:{__html:t}})},ee={type:"Label",label:"Label",category:"core",icon:u.LetterCaseToggleIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(),content:{type:"string",title:"Content",default:""}}}),aiProps:["content"],i18nProps:["content"]},te=e=>{const{blockProps:o,fieldName:t,label:r,styles:s,inputStyles:n,required:a,checked:c,showLabel:p=!0}=e;return p?i.jsxs("div",{...s,...o,children:[i.jsx("input",{...n,name:t,type:"radio",required:a,defaultChecked:c}),r&&i.jsx("label",{htmlFor:t,children:r})]}):i.jsx("input",{name:t,...o,...n,...s,type:"radio",required:a,checked:c})},oe={type:"Radio",label:"web_blocks.radio",category:"core",icon:u.RadiobuttonIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("flex items-center gap-x-2"),inputStyles:l.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"]},le=e=>{const{blockProps:o,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,required:c,showLabel:p,_multiple:m,options:b,defaultValue:g}=e,k=m&&g?g.split(",").map(h=>h.trim()):g||"";return p?i.jsxs("div",{...n,...o,children:[p&&i.jsx("label",{htmlFor:t,children:r}),i.jsxs("select",{...a,required:c,multiple:m,name:t,defaultValue:k,children:[i.jsx("option",{value:"",disabled:!0,hidden:!0,children:s}),d.map(b,h=>i.jsx("option",{value:h==null?void 0:h.value,children:h==null?void 0:h.label},h==null?void 0:h.value))]})]}):i.jsxs("select",{...n,...o,required:c,multiple:m,name:t,defaultValue:k,children:[i.jsx("option",{value:"",disabled:!0,hidden:!0,children:s}),d.map(b,h=>i.jsx("option",{value:h==null?void 0:h.value,children:h==null?void 0:h.label},h==null?void 0:h.value))]})},re={type:"Select",label:"web_blocks.select",category:"core",icon:u.DropdownMenuIcon,group:"form",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),inputStyles:l.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},defaultValue:{type:"string",title:"Default Value",default:""},_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"]},se=e=>{const{blockProps:o,fieldName:t,label:r,placeholder:s,styles:n,inputStyles:a,rows:c,showLabel:p,required:m,defaultValue:b}=e;return p?i.jsxs("div",{...n,...o,children:[p&&i.jsx("label",{htmlFor:t,children:r}),i.jsx("textarea",{name:t,...a,placeholder:s,rows:c,required:m,defaultValue:b})]}):i.jsx("textarea",{name:t,...o,...a,...n,placeholder:s,rows:c,required:m,defaultValue:b})},ie={type:"TextArea",label:"web_blocks.textarea",category:"core",icon:u.InputIcon,group:"form",...l.registerChaiBlockSchema({properties:{fieldName:{type:"string",title:"Field Name",default:"fieldName"},styles:l.StylesProp(""),inputStyles:l.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},defaultValue:{type:"string",title:"Default Value",default:"",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}}}}),aiProps:["label","placeholder"],i18nProps:["label","placeholder"]},ne=e=>{const{blockProps:o,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",...o,children:[i.jsxs("h1",{children:["Global Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):y.createElement("span",{...o},r)},ae={type:"GlobalBlock",description:"A global block component",label:"Global Block",icon:B.GlobeIcon,category:"core",group:"basic",hidden:!0,...l.registerChaiBlockSchema({properties:{globalBlock:{type:"string",title:"Global Block",default:"",ui:{"ui:widget":"hidden"}}}})},ce=e=>{const{blockProps:o,styles:t,content:r,tag:s="h1",children:n=null}=e;return n?y.createElement(s,{...t,...o},n):y.createElement(s,{...t,...o,dangerouslySetInnerHTML:{__html:r}})},pe={type:"Heading",description:"A heading component similar to h1, h2, h3, h4, h5, h6 elements in HTML",label:"Heading",category:"core",icon:u.HeadingIcon,group:"typography",...l.registerChaiBlockSchema({properties:{tag:{type:"string",default:"h2",title:"Level",enum:["h1","h2","h3","h4","h5","h6"]},styles:l.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"},de=e=>{const{blockProps:o,styles:t}=e;return f.createElement("br",{...o,...t})},ue={type:"LineBreak",label:"Line Break",category:"core",group:"basic",hidden:!0,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},me=e=>{const{blockProps:o,children:t,styles:r}=e;return t?f.createElement("table",{...o,...r},t):i.jsx(x,{})},ye=e=>{const{blockProps:o,children:t,styles:r}=e;return t?f.createElement("thead",{...o,...r},t):i.jsx(x,{})},ge=e=>{const{blockProps:o,children:t,styles:r}=e;return t?f.createElement("tbody",{...o,...r},t):i.jsx(x,{})},he=e=>{const{blockProps:o,children:t,styles:r}=e;return t?f.createElement("tr",{...o,...r},t):i.jsx(x,{})},be=e=>{const{blockProps:o,children:t,content:r,styles:s}=e;return!t&&d.isEmpty(r)?i.jsx(x,{}):t?f.createElement("td",{...o,...s},t):f.createElement("td",{...o,...s,dangerouslySetInnerHTML:{__html:r}})};l.registerChaiBlock(me,{type:"Table",label:"Table",category:"core",group:"table",hidden:!0,icon:u.TableIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:S("Table")});l.registerChaiBlock(ye,{type:"TableHead",label:"Table Head",category:"core",group:"table",hidden:!0,icon:u.BorderTopIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:S("TableHead")});l.registerChaiBlock(ge,{type:"TableBody",label:"Table Body",category:"core",group:"table",hidden:!0,icon:u.BorderAllIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:S("TableBody")});l.registerChaiBlock(he,{type:"TableRow",label:"Table Row",category:"core",group:"table",hidden:!0,icon:u.ViewHorizontalIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("")}}),blocks:S("TableRow")});l.registerChaiBlock(be,{type:"TableCell",label:"Table Cell",category:"core",group:"table",hidden:!0,icon:u.DragHandleHorizontalIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),content:{type:"string",default:"Heading goes here",title:"Content",ui:{"ui:widget":"textarea"}}}}),blocks:S("TableCell"),i18nProps:["content"],aiProps:["content"]});function S(e){const o=(n,a)=>({_id:C.generateUUID(),_parent:n,_type:"TableCell",styles:"#styles:,",content:`${e==="TableHead"?"Table Head":"Table Cell "+a}`}),t=n=>{const a=C.generateUUID(),c={_type:"TableRow",_id:a,styles:"#styles:,border-b"};return n&&(c._parent=n),[c,o(a,"1"),o(a,"2"),o(a,"3")]},r=n=>{const a=C.generateUUID(),c={_id:a,_type:"TableHead",styles:"#styles:,font-medium"};return n&&(c._parent=n),[c,...t(a)]},s=n=>{const a=C.generateUUID(),c={_id:a,_type:"TableBody",styles:"#styles:,"};return n&&(c._parent=n),[c,...t(a),...t(a)]};if(e==="Table"){const n=C.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 L=(e,...o)=>({...e,className:C.cn(e.className,...o)}),fe=e=>{const{blockProps:o,icon:t,styles:r,width:s,inBuilder:n,height:a}=e,c=L(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 y.createElement("span",{...o,...c,style:{width:s?`${s}px`:"auto",height:a?`${a}px`:"auto"},dangerouslySetInnerHTML:{__html:p}})},ke={type:"Icon",label:"web_blocks.icon",category:"core",icon:u.SketchLogoIcon,group:"media",...l.registerChaiBlockSchema({properties:{styles:l.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"}}})},xe="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==",Ce=e=>{const{blockProps:o,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",{...o,...s,src:t,alt:n,loading:p?"lazy":"eager",width:c,height:a})]})},Be={type:"Image",description:"A image component",label:"Image",category:"core",icon:u.ImageIcon,group:"media",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),image:{type:"string",title:"Image",default:xe,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"}}}}),aiProps:["alt"],i18nProps:["alt","image","_imageId","mobileImage","_mobileImageId"]},Se=e=>{const{blockProps:o,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",{role:"link",...o,style:c,...s,children:r}):f.createElement("span",{...o,...s,style:c,role:"link"},a):r?i.jsx("a",{"aria-label":a,href:(t==null?void 0:t.href)||"#/",target:t==null?void 0:t.target,...o,...s,children:r}):f.createElement("a",{...o,...s,href:(t==null?void 0:t.href)||"#",target:(t==null?void 0:t.target)||"_self","aria-label":a},a)},we={type:"Link",description:"A link component",label:"Link",category:"core",icon:u.Link1Icon,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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"}},prefetchLink:{type:"boolean",default:!1,title:"Prefetch Link"}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:e=>e!=="Link"},Pe=e=>{const{blockProps:o,children:t,listType:r,styles:s,tag:n,inBuilder:a}=e,c=C.cn(d.get(s,"className",""),r);return!t&&d.isEmpty(s==null?void 0:s.className)?i.jsx(x,{inBuilder:a}):y.createElement(n||(r==="list-decimal"?"ol":"ul"),{...o,...s,className:c},t)},ve={type:"List",description:"A list component",label:"List",icon:u.RowsIcon,category:"core",group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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"}]},Ie=e=>{const{blockProps:o,content:t,styles:r,children:s,tag:n}=e;return s?y.createElement(n||"li",{...r,...o},s):y.createElement(n||"li",{...r,...o,dangerouslySetInnerHTML:{__html:t}})},Le={type:"ListItem",description:"A list item component",label:"List Item",icon:u.ColumnsIcon,category:"core",group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.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"},je=e=>{const{blockProps:o,styles:t,content:r}=e;return d.isNull(e.children)?y.createElement("p",{...t,...o,dangerouslySetInnerHTML:{__html:r}}):y.createElement("p",{...t,...o},e.children)},_e={type:"Paragraph",description:"A paragraph component",label:"Paragraph",category:"core",icon:u.TextIcon,group:"typography",...l.registerChaiBlockSchema({properties:{styles:l.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"},Te=e=>{const{blockProps:o,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",...o,children:[i.jsxs("h1",{children:["Partial Block - ",s]}),i.jsx("p",{children:"Choose a block from the sidebar to add it to this page."})]}):y.createElement("span",{...o},r)},Ne={type:"PartialBlock",description:"A partial block component",label:"Partial Block",icon:B.GlobeIcon,category:"core",group:"basic",hidden:!0,...l.registerChaiBlockSchema({properties:{partialBlockId:{type:"string",title:"Partial Block",default:"",ui:{"ui:widget":"hidden"}}}})},w={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"}},Ee=e=>{const{blockProps:o,children:t,styles:r,colSpan:s,tabletColSpan:n,desktopColSpan:a}=e,p={className:[d.get(r,"className",""),d.get(w,["SMALL",isNaN(s)||!s?6:s],""),n?d.get(w,["MEDIUM",n||s],""):"",a?d.get(w,["LARGE",n||s],""):""].join(" ")};return i.jsx("div",{...o,...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"})})},Re={type:"Column",description:"A column component",label:"Column",group:"basic",category:"core",icon:B.Columns,wrapper:!0,canDelete:()=>!0,canAcceptBlock:()=>!0,canBeNested:e=>e==="Row",...l.registerChaiBlockSchema({properties:{styles:l.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]}}})},Me=e=>{const{blockProps:o,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",{...o,...r,...a,children:t})},Ae={type:"Row",description:"A row component",label:"Row",group:"basic",icon:B.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",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),colCount:{type:"number",default:2,minimum:0,ui:{"ui:widget":"colCount"}},gutter:{type:"number",title:"Gutter (in px)",default:16,minimum:0}}})},He=e=>{const{blockProps:o,content:t,styles:r}=e,s=L(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",{...o,...s,dangerouslySetInnerHTML:{__html:t}})},$e={type:"RichText",description:"A rich text block",label:"Rich Text",category:"core",icon:u.CursorTextIcon,group:"typography",...l.registerChaiBlockSchema({properties:{styles:l.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"]},De=e=>{const{blockProps:o,styles:t,content:r,children:s=null,tag:n}=e;return s?y.createElement("span",{...t,...o},s):y.createElement(n||"span",{...t,...o,dangerouslySetInnerHTML:{__html:r||""}})},ze={type:"Span",description:"A span component",label:"Span",category:"core",group:"typography",...l.registerChaiBlockSchema({properties:{styles:l.StylesProp(""),content:{type:"string",title:"Content",default:"",ui:{"ui:widget":"textarea","ui:autosize":!0,"ui:rows":3}}}}),aiProps:["content"],i18nProps:["content"],canAcceptBlock:()=>!0},Ve=e=>e.inBuilder||e.forceWrapper?i.jsx("span",{...e.blockProps,children:e.content}):`${e.content}`,Ue={type:"Text",description:"A text component with no styling",label:"Text",hidden:!0,category:"core",group:"typography",icon:u.SpaceBetweenVerticallyIcon,...l.registerChaiBlockSchema({properties:{styles:l.StylesProp("text-black"),content:{title:"Content",type:"string",default:""}}}),aiProps:["content"],i18nProps:["content"]},P={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}}},v=/^(https?:\/\/)?(www\.)?youtube\.com\/(watch\?v=|embed\/)([a-zA-Z0-9_-]{11})/,I=/(?:https?:\/\/)?(?:www\.)?(?:vimeo\.com\/(?:channels\/[\w]+\/|groups\/[^\/]+\/videos\/|album\/\d+\/video\/|video\/)?|player\.vimeo\.com\/video\/)(\d+)/,qe=(e,o)=>{const t=d.get(o,"autoplay",!1),r=d.get(o,"controls",!1),s=d.get(o,"loop",!1),n=t||d.get(o,"muted",!0);if(v.test(e)){const a=e.match(v);if(a){const c=a[4];let p=`https://www.youtube.com/embed/${c}`,m=t?"autoplay=1":"";return m+=s?`&loop=1&playlist=${c}`:"",m+=n?"&mute=1&muted=1":"",m+=r?"&controls=1":"&controls=0",`${p}?${m}`}}if(I.test(e)){const a=e.match(I);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},Fe=e=>{const{url:o,blockProps:t,styles:r,controls:s,videoSource:n,inBuilder:a}=e,c=qe(o,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(o)?`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"})]})},Ge=e=>{const{url:o,styles:t,controls:r,sources:s,poster:n,blockProps:a}=e;let c=n;const p=[...d.get(s,"srcsets",[])||[]];o&&typeof o=="string"&&p.push({url:o,width:"9999"});const m=p.sort((g,k)=>parseInt(g.width)-parseInt(k.width)).filter(g=>!d.isEmpty(g.url)&&!d.isEmpty(g.width));m.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(m))&&i.jsx("div",{className:"relative w-full overflow-hidden",style:{paddingBottom:"56.25%"},children:f.createElement("video",{...t,...a,key:JSON.stringify(m),controls:d.get(r,"controls",!1),autoPlay:d.get(r,"autoplay",!1),loop:d.get(r,"loop",!1),poster:c,...b?{muted:!0}:{}},m.map(g=>{if(!g.url||g.url.length<4||isNaN(g.width))return null;const k=`(max-width: ${g.width}px)`;return i.jsx("source",{src:g.url,media:k,type:g.type},g.url)}),"Your browser does not support the video tag.")})},Oe=e=>{const{videoSource:o}=e;return o==="Custom"?i.jsx(Ge,{...e}):o==="Youtube"||o==="Vimeo"?i.jsx(Fe,{...e}):i.jsxs("div",{children:["Invalid video source : ",o]})},Ze={type:"Video",label:"Video",category:"core",icon:u.VideoIcon,group:"media",...l.registerChaiBlockSchema({properties:{styles:l.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:{...P}}}},{if:{properties:{videoSource:{const:"Youtube"}}},then:{properties:{url:{type:"string",title:"Youtube Video URL",default:""},controls:{...P}}}},{if:{properties:{videoSource:{const:"Vimeo"}}},then:{properties:{url:{type:"string",title:"Vimeo Video URL",default:""},controls:{...P}}}}],ui:{url:{"ui:placeholder":"Enter Video URL"},sources:{"ui:field":"sources"},poster:{"ui:placeholder":"Enter poster URL"}}}),i18nProps:["url"]},We=e=>{const{children:o,tag:t,styles:r,blockProps:s,inBuilder:n,$loading:a}=e;let c=o;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"})),t==="none"?a&&n?Array.from({length:2}).map((p,m)=>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"})]},m)):c:y.createElement(t,{...s,...r},a&&n?Array.from({length:2}).map((p,m)=>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"})]},m)):c)},Ye={type:"Repeater",label:"Repeater",icon:u.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"}],...l.registerChaiBlockSchema({properties:{styles:l.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"}}}})},Qe=({children:e,blockProps:o,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?y.createElement(n,{...o,...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"})):y.createElement(n,{...o,...t},e)},Je={type:"RepeaterItem",label:"Repeater Item",icon:u.LoopIcon,hidden:!0,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.stylesProp(""),parentTag:l.closestBlockProp("Repeater","tag")}}),canAcceptBlock:e=>e!=="RepeaterItem",canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},Xe=({children:e,blockProps:o,styles:t})=>y.createElement("div",{...o,...t},e),Ke={type:"RepeaterEmptyState",label:"Empty State",hidden:!0,group:"basic",...l.registerChaiBlockSchema({properties:{styles:l.stylesProp("p-5 flex items-center justify-center")}}),canAcceptBlock:()=>!0,canDelete:()=>!1,canMove:()=>!1,canDuplicate:()=>!1},et=()=>{l.registerChaiBlock(_,T),l.registerChaiBlock(U,q),l.registerChaiBlock(N,E),l.registerChaiBlock(ce,pe),l.registerChaiBlock(je,_e),l.registerChaiBlock(De,ze),l.registerChaiBlock(He,$e),l.registerChaiBlock(Se,we),l.registerChaiBlock(Pe,ve),l.registerChaiBlock(Ie,Le),l.registerChaiBlock(fe,ke),l.registerChaiBlock(Ce,Be),l.registerChaiBlock(Oe,Ze),l.registerChaiBlock(A,H),l.registerChaiBlock($,D),l.registerChaiBlock(Ve,Ue),l.registerChaiBlock(O,Z),l.registerChaiBlock(W,Y),l.registerChaiBlock(J,X),l.registerChaiBlock(F,G),l.registerChaiBlock(te,oe),l.registerChaiBlock(le,re),l.registerChaiBlock(se,ie),l.registerChaiBlock(K,ee),l.registerChaiBlock(de,ue),l.registerChaiBlock(z,V),l.registerChaiBlock(ne,ae),l.registerChaiBlock(Te,Ne),l.registerChaiBlock(Me,Ae),l.registerChaiBlock(Ee,Re),l.registerChaiBlock(R,M),l.registerChaiBlock(We,Ye),l.registerChaiBlock(Qe,Je),l.registerChaiBlock(Xe,Ke)};exports.loadWebBlocks=et;