@chaibuilder/sdk 1.2.109 → 1.2.110

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.
@@ -58,6 +58,6 @@
58
58
  outline: 1px solid ${n.length===1?"#42a1fc":"orange"} !important; outline-offset: -1px;
59
59
  }`)},[n,x]),React.useEffect(()=>{h.textContent=i?`[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}`:""},[i,h]),React.useEffect(()=>{u&&(u.textContent='[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}')},[u]),React.useEffect(()=>{m&&(m.textContent=`${lodashEs.map(a,({id:R})=>`[data-style-id="${R}"]`).join(",")}{
60
60
  outline: 1px solid #42a1fc !important; outline-offset: -1px;
61
- }`)},[a,m]),React.useEffect(()=>{c.querySelector("#drop-target-block").innerHTML=l?`[data-block-id="${l}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}`:""},[l]),jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:(p||f)&&jsxRuntime.jsxRuntimeExports.jsx("link",{rel:"stylesheet",href:`https://fonts.googleapis.com/css2?family=${p?`${p.replace(/ /g,"+")}:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900`:""}${p&&f&&p!==f?"&":""}${f&&f!==p?`family=${f.replace(/ /g,"+")}:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900`:""}&display=swap`})})},useChaiExternalData=()=>jotai.useAtom(chaiExternalDataAtom),useCanvasSettings=()=>jotai.useAtom(canvasSettingsAtom),isVisibleAtBreakpoint=(o,n)=>{const r=["xs","sm","md","lg","xl","2xl"],a=r.indexOf(n),i=o.split(" ");let l=new Array(r.length).fill(!1);for(const c of i){let[d,u]=c.split(":");u||(u=d,d="xs");const x=r.indexOf(d);if(x<=a){const m=["block","flex","inline","inline-block","inline-flex","grid","table"],h=["hidden"];if(m.includes(u))for(let p=x;p<r.length;p++)l[p]=!0;else if(h.includes(u))for(let p=x;p<r.length;p++)l[p]=!1}}return l[a]},rscBlocksStoreAtom=atom({}),rscBlocksLoadingStateAtom=atom({}),useRSCBlocksStore=()=>{const[o,n]=useAtom(rscBlocksStoreAtom),[r]=useAtom(rscBlocksLoadingStateAtom),a=React.useCallback(c=>lodashEs.get(o,c==null?void 0:c._id,null),[o]),i=React.useCallback(c=>lodashEs.get(r,`${c}`,{loading:!1,error:null}),[r]),l=React.useCallback(c=>{n(d=>({...d,[c]:""}))},[n]);return{getRSCBlockMarkup:a,getRSCBlockState:i,reset:l}},useWatchRSCBlocks=()=>{const[o]=useBlocksStore(),[n,r]=useAtom(rscBlocksStoreAtom),[a,i]=useAtom(rscBlocksLoadingStateAtom),l=runtime.useChaiBlocks(),c=useBuilderProp("getRSCBlock",async u=>""),d=React.useMemo(()=>o.filter(x=>{var h;return(h=lodashEs.get(l,x._type))==null?void 0:h.server}).map(x=>x._id),[l,o]);React.useEffect(()=>{lodashEs.forEach(d,u=>{if(lodashEs.get(n,u,"")||lodashEs.get(a,`${u}.loading`,!1))return;const x=o.find(m=>m._id===u);i(m=>({...m,[u]:{loading:!0,error:null}})),c(x).then(m=>{r(h=>({...h,[u]:m})),i(h=>({...h,[u]:{loading:!1,error:null}}))}).catch(m=>{i(h=>({...h,[u]:{loading:!1,error:m.message}}))})})},[o,c,n,d,a,r,i])},RSCBlock=({blockProps:o,block:n})=>{const{getRSCBlockMarkup:r,getRSCBlockState:a}=useRSCBlocksStore(),i=r(n),{loading:l,error:c}=a(n._id);return l?jsxRuntime.jsxRuntimeExports.jsx("div",{...o,className:"h-10 w-full",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-full w-full rounded-md border"})}):c?jsxRuntime.jsxRuntimeExports.jsxs("div",{...o,children:["Error: ",c]}):jsxRuntime.jsxRuntimeExports.jsx("div",{...o,dangerouslySetInnerHTML:{__html:i}})},generateClassNames=lodashEs.memoize(o=>{const n=o.replace(STRINGS.STYLES_KEY,"").split(",");return tailwindMerge.twMerge(n[0],n[1])});function getElementAttrs(o,n){return lodashEs.get(o,`${n}_attrs`,{})}function getStyleAttrs(o,n){const r={};return Object.keys(o).forEach(a=>{if(lodashEs.isString(o[a])&&o[a].startsWith(STRINGS.STYLES_KEY)){const i=generateClassNames(o[a]),l=getElementAttrs(o,a);r[a]={className:i,"data-style-prop":a,"data-block-parent":o._id,"data-style-id":`${a}-${o._id}`,...l};const c=lodashEs.has(l,"x-show")||lodashEs.has(l,"x-if");c&&(r.__isHidden=c&&!isVisibleAtBreakpoint(i,n))}}),r}function applyBindings(o,n){const r=lodashEs.get(o,"_bindings",{});return lodashEs.isEmpty(r)?{...o}:(lodashEs.each(r,(a,i)=>{lodashEs.isString(a)&&lodashEs.get(n,a,null)&&(o[i]=lodashEs.get(n,a,null))}),o)}function isDescendant(o,n,r){if(!lodashEs.find(r,{_id:o}))return!1;const i=lodashEs.filter(r,{_parent:o});return i.some(l=>l._id===n)?!0:i.some(l=>isDescendant(l._id,n,r))}const RenderGlobalBlock=({blocks:o,allBlocks:n})=>jsxRuntime.jsxRuntimeExports.jsx(BlocksRendererStatic,{allBlocks:n,blocks:o});function applyLanguage(o,n,r){if(lodashEs.isEmpty(n))return o;const a=lodashEs.cloneDeep(o);return lodashEs.forEach(lodashEs.keys(a),i=>{lodashEs.get(r,["props",i,"i18n"])&&!lodashEs.isEmpty(n)&&(a[i]=lodashEs.get(a,`${i}-${n}`,a[i]))}),a}function BlocksRendererStatic({blocks:o,allBlocks:n}){const{selectedLang:r}=useLanguages(),[a]=jotai.useAtom(xShowBlocksAtom),[i]=useCutBlockIds(),[l]=jotai.useAtom(draggedBlockAtom),[c]=jotai.useAtom(dropTargetBlockIdAtom),[,d]=useCanvasWidth(),[u]=useCanvasSettings(),[x]=useHiddenBlockIds(),{getGlobalBlocks:m}=useGlobalBlocksStore(),h=React.useCallback(j=>getStyleAttrs(j,d),[d]),[p]=useChaiExternalData(),[f]=jotai.useAtom(inlineEditingActiveAtom),R=React.useCallback(j=>j.reduce((E,y)=>{const v=lodashEs.get(u,y,{});return{...E,...v}},{}),[u]);return jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:React.Children.toArray(o.map((j,E)=>{if(f===j._id||x.includes(j._id))return null;const y={},v=lodashEs.filter(n,{_parent:j._id});if(y.children=v.length>0?jsxRuntime.jsxRuntimeExports.jsx(BlocksRendererStatic,{allBlocks:n,blocks:v}):null,j._type==="GlobalBlock"){const _=m(j);y.children=jsxRuntime.jsxRuntimeExports.jsx(RenderGlobalBlock,{blocks:lodashEs.filter(_,S=>!S._parent),allBlocks:_})}const w=runtime.getBlockComponent(j._type),k=lodashEs.get(w,"server",!1),C=k?RSCBlock:lodashEs.get(w,"builderComponent",lodashEs.get(w,"component",null));if(lodashEs.isNull(C))return jsxRuntime.jsxRuntimeExports.jsx("noscript",{children:`<!-- ${j==null?void 0:j._type} not registered -->`});const I=lodashEs.has(w,"getBlockStateFrom")?w==null?void 0:w.getBlockStateFrom(j,n):[],N=R(I),L=h(j);if(lodashEs.get(L,"__isHidden",!1)&&!lodashEs.includes(a,j._id))return null;const g=l&&isDescendant(l._id,j._id,n),b={...lodashEs.includes(a,j._id)?{"force-show":""}:{},"data-block-id":j._id,"data-block-type":j._type,...l?{"data-dnd":canAcceptChildBlock(j._type,l==null?void 0:l._type)?"yes":"no","data-dnd-dragged":l._id===j._id||g?"yes":"no"}:{},...c===j._id&&!g?{"data-drop":"yes"}:{},...lodashEs.includes(i,j._id)?{"data-cut-block":"yes"}:{}};return k?jsxRuntime.jsxRuntimeExports.jsx(RSCBlock,{block:j,blockProps:b}):jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{children:React.createElement(C,{blockProps:b,index:E,...applyBindings(applyLanguage(j,r,w),p),...lodashEs.omit(L,["__isHidden"]),...y,inBuilder:!0,blockState:N})})}))})}const useAllDataProviders=()=>React.useMemo(()=>runtime.getChaiDataProviders(),[]),BlocksExternalDataProvider=({children:o})=>{const[,n]=useChaiExternalData(),[r]=usePageDataProviders(),a=useAllDataProviders();return React.useEffect(()=>(n({}),lodashEs.each(r,i=>{const l=lodashEs.find(a,{providerKey:i.providerKey});if(l){const c=(l==null?void 0:l.mockFn)||(l==null?void 0:l.dataFn);c&&c(i.args).then(d=>n(u=>({...u,[i.providerKey]:d})))}}),()=>{lodashEs.each(r,i=>{n(l=>(delete l[i.providerKey],l))})}),[a,r,n]),jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:o})},StaticBlocksRenderer=()=>{const[o]=useBlocksStore(),n=lodashEs.isEmpty(o)?null:jsxRuntime.jsxRuntimeExports.jsx(BlocksExternalDataProvider,{children:jsxRuntime.jsxRuntimeExports.jsx(BlocksRendererStatic,{allBlocks:o,blocks:lodashEs.filter(o,r=>lodashEs.isEmpty(r._parent))})});return jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:n})},AddBlockAtBottom=()=>{const{t:o}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs("button",{onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK}),className:"mt-1 block w-full rounded-md bg-gray-100 p-2 text-black hover:bg-gray-200 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-700",children:["+ ",o("add_block")]})},ResizableCanvasWrapper=({children:o,onMount:n,onResize:r})=>{const a=React.useRef(null),i=web.useDebouncedCallback(()=>{const{clientWidth:l}=a.current;r(l)},[a.current],100);return web.useResizeObserver(a.current,i,a.current!==null),React.useEffect(()=>{const{clientWidth:l}=a.current;n(l)},[]),jsxRuntime.jsxRuntimeExports.jsx("div",{id:"main-content",className:"h-full w-full p-8 pb-0",ref:a,children:o})},getElementByStyleId=(o,n)=>o.querySelector(`[data-style-id="${n}"]`),StaticCanvas=()=>{const[o]=jotai.useAtom(networkModeAtom),[n]=useCanvasWidth(),[,r]=useSelectedBlockIds(),a=useSelectedBlock(),[,i]=useHighlightBlockId(),l=React.useRef(null),c=React.useRef(null),[d,u]=React.useState({width:0,height:0}),x=useCanvasScale(d),[m,h]=React.useState([]),[,p]=React.useState([]),[,f]=jotai.useAtom(canvasIframeAtom),[R,j]=useSelectedStylingBlocks(),E=useBuilderProp("loading",!1),y=useBuilderProp("htmlDir","ltr"),v=C=>{u(I=>({...I,width:C}))};React.useEffect(()=>{if(!c.current)return;const{clientWidth:C,clientHeight:I}=c.current;u({width:C,height:I})},[c,n]);const w=(C,I=0)=>{const{top:N}=C.getBoundingClientRect();return N+I>=0&&N-I<=window.innerHeight};React.useEffect(()=>{var C,I;if(a&&a.type!=="Multiple"&&l.current){const N=getElementByDataBlockId(l.current.contentDocument,a._id);N&&(w(N)||(I=(C=l.current)==null?void 0:C.contentWindow)==null||I.scrollTo({top:N.offsetTop,behavior:"smooth"}),h([N]))}},[a]),React.useEffect(()=>{if(!lodashEs.isEmpty(R)&&l.current){const C=getElementByStyleId(l.current.contentDocument,lodashEs.first(R).id);p(C?[C]:[null])}else p([null])},[R]);const k=React.useMemo(()=>{let C=IframeInitialContent;return C=C.replace("__HTML_DIR__",y),o==="offline"&&(C=C.replace("https://old.chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js"),C=C.replace("https://unpkg.com/aos@next/dist/aos.css","/offline/aos.css"),C=C.replace("https://unpkg.com/aos@next/dist/aos.js","/offline/aos.js")),C},[o,y]);return jsxRuntime.jsxRuntimeExports.jsx(ResizableCanvasWrapper,{onMount:v,onResize:v,children:jsxRuntime.jsxRuntimeExports.jsx("div",{onClick:()=>{r([]),j([])},onMouseLeave:()=>setTimeout(()=>i(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:c,children:jsxRuntime.jsxRuntimeExports.jsxs(ChaiFrame,{contentDidMount:()=>f(l.current),ref:l,id:"canvas-iframe",style:{...x,...lodashEs.isEmpty(x)?{width:`${n}px`}:{}},className:"relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:k,children:[jsxRuntime.jsxRuntimeExports.jsx(KeyboardHandler,{}),jsxRuntime.jsxRuntimeExports.jsx(BlockActionsStatic,{block:a,selectedBlockElement:lodashEs.first(m)}),jsxRuntime.jsxRuntimeExports.jsx(HeadTags,{}),jsxRuntime.jsxRuntimeExports.jsx(reactWrapBalancer.Provider,{children:jsxRuntime.jsxRuntimeExports.jsxs(Canvas,{children:[E?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-full"})}):jsxRuntime.jsxRuntimeExports.jsx(StaticBlocksRenderer,{}),jsxRuntime.jsxRuntimeExports.jsx(AddBlockAtBottom,{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{})]})}),jsxRuntime.jsxRuntimeExports.jsx("div",{id:"placeholder",className:"pointer-events-none absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})})},StaticCanvas$1=StaticCanvas,FallbackError=()=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[jsxRuntime.jsxRuntimeExports.jsx("p",{className:"font-semibold",children:"Oops! Something went wrong."}),jsxRuntime.jsxRuntimeExports.jsx("p",{children:"Please try again."})]})}),TypeIcon=o=>{switch(o.type){case"GlobalBlock":return jsxRuntime.jsxRuntimeExports.jsx(lucideReact.GlobeIcon,{className:"h-4 w-4"});case"Image":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ImageIcon,{});case"Heading":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.HeadingIcon,{});case"Text":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TextIcon,{});case"Link":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Link1Icon,{});case"Video":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.VideoIcon,{});case"RichText":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CursorTextIcon,{});case"Button":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ButtonIcon,{});case"CustomHTML":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CodeIcon,{});case"Divider":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DividerHorizontalIcon,{});case"Icon":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.SketchLogoIcon,{});case"List":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RowsIcon,{});case"Paragraph":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TextIcon,{});case"Row":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RowsIcon,{});case"ListItem":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ColumnsIcon,{});case"LineBreak":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.SpaceBetweenVerticallyIcon,{});case"Form":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.GroupIcon,{});case"Checkbox":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CheckboxIcon,{});case"FormButton":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ButtonIcon,{});case"Input":case"TextArea":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.InputIcon,{});case"Radio":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RadiobuttonIcon,{});case"Select":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DropdownMenuIcon,{});case"Table":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TableIcon,{});case"TableHead":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BorderTopIcon,{});case"TableBody":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BorderAllIcon,{});case"TableRow":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ViewHorizontalIcon,{});case"TableCell":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DragHandleHorizontalIcon,{});case"DataProvider":return jsxRuntime.jsxRuntimeExports.jsx(lucideReact.DatabaseIcon,{size:16});case"Box":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BoxIcon,{});default:return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BoxModelIcon,{})}},Breadcrumb=()=>{const o=useSelectedBlockHierarchy(),[,n]=useSelectedBlockIds(),{highlightBlock:r}=useBlockHighlight();return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mx-2 border-t border-border bg-background px-2 py-1 text-xs text-muted-foreground",children:jsxRuntime.jsxRuntimeExports.jsxs("ol",{className:"flex items-center whitespace-nowrap",children:[jsxRuntime.jsxRuntimeExports.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{onClick:()=>n([]),variant:"ghost",className:"h-fit p-1 text-xs font-normal",children:"Body"}),jsxRuntime.jsxRuntimeExports.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]}),lodashEs.reverse(o).map((a,i)=>jsxRuntime.jsxRuntimeExports.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{onMouseEnter:()=>{r(a==null?void 0:a._id)},onClick:()=>n([a==null?void 0:a._id]),variant:"ghost",className:"h-fit gap-x-1 p-1 text-xs font-normal",children:[jsxRuntime.jsxRuntimeExports.jsx(TypeIcon,{type:a==null?void 0:a._type}),a._name||a._type]}),i!==o.length-1&&jsxRuntime.jsxRuntimeExports.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]},i))]})})},CodeEditor$1=React.lazy(()=>Promise.resolve().then(()=>require("./CodeEditor-heJvLZrQ.cjs"))),CanvasArea=()=>{const[o]=useCodeEditor(),n=useBuilderProp("onError",lodashEs.noop);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2",children:[jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-full"}),children:jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:n,children:jsxRuntime.jsxRuntimeExports.jsx(StaticCanvas$1,{})})}),o?jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-full"}),children:jsxRuntime.jsxRuntimeExports.jsx(reResizable.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:jsxRuntime.jsxRuntimeExports.jsx(CodeEditor$1,{})})}):null,jsxRuntime.jsxRuntimeExports.jsx(Breadcrumb,{})]})})},CanvasArea$1=CanvasArea,ColorField=({value:o,onChange:n,id:r,onBlur:a})=>{const i=lodashEs.debounce(n,200),l=c=>i(c.target.value);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-1.5 flex items-center gap-x-3",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-3/5 flex-col",children:jsxRuntime.jsxRuntimeExports.jsx("input",{type:"color",className:"text-xs p-0",value:o,onBlur:({target:{value:c}})=>a(r,c),onChange:l})})})},FONTS=[{title:"Roboto",value:"Roboto"},{title:"Open Sans",value:"Open Sans"},{title:"Montserrat",value:"Montserrat"},{title:"Lato",value:"Lato"},{title:"Poppins",value:"Poppins"},{title:"Oswald",value:"Oswald"},{title:"Raleway",value:"Raleway"},{title:"Ubuntu",value:"Ubuntu"},{title:"Nunito",value:"Nunito"},{title:"Merriweather",value:"Merriweather"},{title:"Nunito Sans",value:"Nunito Sans"},{title:"Playfair Display",value:"Playfair Display"},{title:"Rubik",value:"Rubik"},{title:"Inter",value:"Inter"},{title:"Lora",value:"Lora"},{title:"Kanit",value:"Kanit"},{title:"Fira Sans",value:"Fira Sans"},{title:"Hind",value:"Hind"},{title:"Quicksand",value:"Quicksand"},{title:"Mulish",value:"Mulish"},{title:"Barlow",value:"Barlow"},{title:"Inconsolata",value:"Inconsolata"},{title:"Titillium Web",value:"Titillium Web"},{title:"Heebo",value:"Heebo"},{title:"IBM Plex Sans",value:"IBM Plex Sans"},{title:"DM Sans",value:"DM Sans"},{title:"Nanum Gothic",value:"Nanum Gothic"},{title:"Karla",value:"Karla"},{title:"Arimo",value:"Arimo"},{title:"Cabin",value:"Cabin"},{title:"Oxygen",value:"Oxygen"},{title:"Overpass",value:"Overpass"},{title:"Assistant",value:"Assistant"},{title:"Tajawal",value:"Tajawal"},{title:"Play",value:"Play"},{title:"Exo",value:"Exo"},{title:"Cinzel",value:"Cinzel"},{title:"Faustina",value:"Faustina"},{title:"Philosopher",value:"Philosopher"},{title:"Gelasio",value:"Gelasio"},{title:"Sofia Sans Condensed",value:"Sofia Sans Condensed"},{title:"Noto Sans Devanagari",value:"Noto Sans Devanagari"},{title:"Actor",value:"Actor"},{title:"Epilogue",value:"Epilogue"},{title:"Glegoo",value:"Glegoo"},{title:"Overlock",value:"Overlock"},{title:"Lustria",value:"Lustria"},{title:"Ovo",value:"Ovo"},{title:"Suranna",value:"Suranna"},{title:"Bebas Neue",value:"Bebas Neue"},{title:"Manrope",value:"Manrope"}],ThemeConfigPanel=({showHeading:o=!0,className:n=""})=>{const[r,a]=useBrandingOptions(),[i]=useBlocksContainer(),l=React__namespace.useRef(r),{t:c}=reactI18next.useTranslation(),d=({formData:k},C)=>{C&&(a(k),l.current=k)},{bodyFont:u,headingFont:x,primaryColor:m,bodyTextDarkColor:h,bodyTextLightColor:p,bodyBgDarkColor:f,secondaryColor:R,bodyBgLightColor:j,roundedCorners:E}=r;let y={headingFont:controls.y({title:c("theme_config.heading_font"),default:x,options:FONTS}),bodyFont:controls.y({title:c("theme_config.body_font"),default:u,options:FONTS}),roundedCorners:controls.s({title:c("theme_config.rounded_corner"),default:parseInt(E||5,10)}),primaryColor:controls.h({title:c("theme_config.primary"),default:m}),secondaryColor:controls.h({title:c("theme_config.secondary"),default:R})};i||(y={...y,bodyBgLightColor:controls.h({title:c("theme_config.background"),default:j}),bodyTextLightColor:controls.h({title:c("theme_config.text_color"),default:h}),bodyBgDarkColor:controls.h({title:c("theme_config.background_dark_mode"),default:f}),bodyTextDarkColor:controls.h({title:c("theme_config.text_color_dark_mode"),default:p})});const v={type:"object",properties:{}},w={};return Object.keys(y).forEach(k=>{const C=y[k];return v.properties||(v.properties={}),v.properties[k]=C.schema,w[k]=C.uiSchema,!0}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:iconBase.cn("flex h-full w-full select-none flex-col",n),children:[o?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-background/30 p-1",children:jsxRuntime.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:c("Theme Configuration")})}):null,jsxRuntime.jsxRuntimeExports.jsx(Form,{widgets:{color:ColorField},idSeparator:".",autoComplete:"off",omitExtraData:!0,liveOmit:!0,liveValidate:!0,uiSchema:w,schema:v,formData:r,validator,onChange:d})]})},ThemeOptions=ThemeConfigPanel,placeholderStyle={display:"flex",alignItems:"center",zIndex:1},DefaultCursor=React.memo(function({top:n,left:r}){const a={position:"absolute",pointerEvents:"none",top:n+"px",left:r+"px",right:0};return jsxRuntime.jsxRuntimeExports.jsx("div",{style:{...placeholderStyle,...a},children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-0.5 flex-1 rounded-[1px] bg-green-500"})})}),Overlay=React.memo(function({children:n,isDragging:r}){return r?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"pointer-events-none fixed left-0 top-0 z-[100] h-full w-full",children:n}):null}),DefaultDragPreview=React.memo(({id:o,isDragging:n,mouse:r})=>{const[a]=useBlocksStore(),i=React.useMemo(()=>a.find(c=>c._id===o),[a,o]),l=React.useMemo(()=>({transform:`translate(${(r==null?void 0:r.x)-10}px, ${(r==null?void 0:r.y)-10}px)`}),[r]);return r?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx(Overlay,{isDragging:n,children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"pointer-events-none absolute z-50 rounded border border-border bg-gray-100/80 font-semibold text-blue-600 shadow-md dark:border-gray-700 dark:bg-gray-800",style:l,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{type:"button",className:"flex !cursor-grab items-center p-0.5","aria-label":`Type: ${i==null?void 0:i._type}`,children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mt-0.5 h-3 w-3",children:jsxRuntime.jsxRuntimeExports.jsx(TypeIcon,{type:i==null?void 0:i._type})}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"ml-2 truncate text-[11px]",children:(i==null?void 0:i._name)||(i==null?void 0:i._type)})]})})})}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"hidden"})}),CopyPasteBlocks=()=>{const[o]=useSelectedBlockIds(),{canPaste:n,pasteBlocks:r}=usePasteBlocks(),[,a]=useCopyBlockIds(),{t:i}=reactI18next.useTranslation(),l=useSelectedBlock();return jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{disabled:!canDuplicateBlock(l==null?void 0:l._type),onClick:()=>a(o),className:"flex items-center gap-x-4 text-xs",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CopyIcon,{})," Copy"]}),n(o[0])&&jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{className:"flex items-center gap-x-4 text-xs",onClick:()=>{r(o)},children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CardStackIcon,{})," ",i("Paste")]})]})},CutBlocks=()=>{const[o]=useSelectedBlockIds(),[,n]=useCutBlockIds(),{t:r}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{className:"flex items-center gap-x-4 text-xs",onClick:()=>n(o),children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ScissorsIcon,{})," ",r("Cut")]})},RemoveBlocks=()=>{const[o]=useSelectedBlockIds(),n=useRemoveBlocks(),r=useSelectedBlock(),{t:a}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{disabled:!canDeleteBlock(r==null?void 0:r._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>n(o),children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TrashIcon,{})," ",a("Remove")]})},BlockContextMenuContent=()=>{const{t:o}=reactI18next.useTranslation(),[n]=useSelectedBlockIds(),r=useDuplicateBlocks(),a=useSelectedBlock(),i=React.useCallback(()=>{r(n)},[n,r]);return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuContent,{className:"border-border text-xs",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{disabled:!canAddChildBlock(a==null?void 0:a._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,data:a}),children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.PlusIcon,{size:"14"})," ",o("Add block")]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{disabled:!canDuplicateBlock(a==null?void 0:a._type),className:"flex items-center gap-x-4 text-xs",onClick:i,children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CardStackPlusIcon,{})," ",o("Duplicate")]}),jsxRuntime.jsxRuntimeExports.jsx(CutBlocks,{}),jsxRuntime.jsxRuntimeExports.jsx(CopyPasteBlocks,{}),jsxRuntime.jsxRuntimeExports.jsx(RemoveBlocks,{})]})},BlockContextMenu=({children:o})=>jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenu,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.ContextMenuTrigger,{asChild:!0,children:o}),jsxRuntime.jsxRuntimeExports.jsx(BlockContextMenuContent,{})]})}),defaultShortcuts=[{key:"ArrowDown",command:"selectNext"},{key:"ArrowUp",command:"selectPrev"},{key:"ArrowLeft",command:"selectParent",when:"isLeaf || isClosed"},{key:"ArrowLeft",command:"close",when:"isOpen"},{key:"ArrowRight",command:"open",when:"isClosed"},{key:"ArrowRight",command:"selectNext",when:"isOpen"},{key:"Home",command:"selectFirst"},{key:"End",command:"selectLast"}];function selectFirst(o){o.firstNode&&o.select(o.firstNode.id)}function selectLast(o){o.lastNode&&o.select(o.lastNode.id)}function selectNext(o){const n=o.selectedNodes[0].next||o.firstNode;o.select(n.id)}function selectPrev(o){const n=o.selectedNodes[0].prev||o.lastNode;o.select(n.id)}const selectParent=(o,n)=>{var a;const r=((a=o.selectedIds[0])==null?void 0:a.parent)||null;r&&n&&o.select(r.id)},open=(o,n)=>{const r=o.selectedNodes[0];r.isInternal&&n&&r.open()},close=(o,n)=>{const r=o.selectedNodes[0];r.isInternal&&n&&r.close()};function VscJson(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.2 0-.387-.038-.563-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.502 1.502 0 0 1 .765-.787 1.38 1.38 0 0 1 .558-.115H14v-.984h-.09c-.196 0-.381-.04-.557-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.415 1.415 0 0 1-.307-.465v-.002a1.405 1.405 0 0 1-.118-.566c0-.29.006-.58.018-.869a6.174 6.174 0 0 0-.024-.87v-.001a3.537 3.537 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.331 2.331 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .387.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.285 2.285 0 0 0 .738.955 2.285 2.285 0 0 0-.738.955 2.689 2.689 0 0 0-.168.602c-.033.21-.051.423-.055.64a9.15 9.15 0 0 0 0 .666c.008.224.012.45.012.678a1.471 1.471 0 0 1-.877 1.354 1.33 1.33 0 0 1-.563.121H10z"},child:[]}]})(o)}function BsLightningFill(o){return iconBase.GenIcon({tag:"svg",attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M5.52.359A.5.5 0 0 1 6 0h4a.5.5 0 0 1 .474.658L8.694 6H12.5a.5.5 0 0 1 .395.807l-7 9a.5.5 0 0 1-.873-.454L6.823 9.5H3.5a.5.5 0 0 1-.48-.641z"},child:[]}]})(o)}function TbEyeDown(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"},child:[]},{tag:"path",attr:{d:"M12 18c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"},child:[]},{tag:"path",attr:{d:"M19 16v6"},child:[]},{tag:"path",attr:{d:"M22 19l-3 3l-3 -3"},child:[]}]})(o)}function BiCollapseVertical(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M12 7.59 7.05 2.64 5.64 4.05 12 10.41l6.36-6.36-1.41-1.41L12 7.59zM5.64 19.95l1.41 1.41L12 16.41l4.95 4.95 1.41-1.41L12 13.59l-6.36 6.36z"},child:[]}]})(o)}function BiExpandVertical(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"m12 19.24-4.95-4.95-1.41 1.42L12 22.07l6.36-6.36-1.41-1.42L12 19.24zM5.64 8.29l1.41 1.42L12 4.76l4.95 4.95 1.41-1.42L12 1.93 5.64 8.29z"},child:[]}]})(o)}const Node=React.memo(({node:o,style:n,dragHandle:r})=>{const a=useBuilderProp("outlineMenuItems",[]),{t:i}=reactI18next.useTranslation(),[l,,c]=useHiddenBlockIds(),[d]=jotai.useAtom(canvasIframeAtom);let u=null;const x=o.children.length>0,{highlightBlock:m,clearHighlight:h}=useBlockHighlight(),{id:p,data:f,isSelected:R,willReceiveDrop:j,isDragging:E,isEditing:y,handleClick:v}=o,w=g=>{g.stopPropagation(),!l.includes(p)&&o.toggle()},k=g=>{g.isInternal&&(u=g.isOpen,g.isOpen&&g.close())},C=g=>{g.isInternal&&u!==null&&(u?g.open():g.close(),u=null)},I=g=>{g.stopPropagation(),!o.isOpen&&!l.includes(p)&&o.toggle(),v(g)};React.useEffect(()=>{const g=setTimeout(()=>{j&&!o.isOpen&&!E&&!l.includes(p)&&o.toggle()},500);return()=>clearTimeout(g)},[j,o,E]);const N=React.useMemo(()=>{const g=Object.keys(f),b=[];for(let _=0;_<g.length;_++)if(g[_].endsWith("_attrs")){const S=f[g[_]],B=Object.keys(S).join("|");B.match(/x-data/)&&b.push("data"),B.match(/x-on/)&&b.push("event"),B.match(/x-show|x-if/)&&b.push("show")}return b},[f]),L=(g,b)=>{const _=d.contentDocument||d.contentWindow.document,S=_.querySelector(`[data-block-id=${g}]`);S&&S.setAttribute("data-drop",b);const B=S.getBoundingClientRect(),A=d.getBoundingClientRect();B.top>=A.top&&B.left>=A.left&&B.bottom<=A.bottom&&B.right<=A.right||(_.documentElement.scrollTop=S.offsetTop-A.top)};return p===STRINGS.ROOT_TEMP_KEY?jsxRuntime.jsxRuntimeExports.jsxs("button",{onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK}),className:"mb-10 mt-5 w-full rounded bg-gray-100 p-1 hover:bg-gray-200 dark:bg-gray-800",children:["+ ",i("add_block")]}):jsxRuntime.jsxRuntimeExports.jsx(BlockContextMenu,{id:p,children:jsxRuntime.jsxRuntimeExports.jsxs("div",{onMouseEnter:()=>m(p),onMouseLeave:()=>h(),onClick:I,style:n,"data-node-id":p,ref:l.includes(p)?null:r,onDragStart:()=>k(o),onDragEnd:()=>C(o),onDragOver:g=>{g.preventDefault(),L(p,"yes")},onDragLeave:g=>{g.preventDefault(),L(p,"no")},onDrop:g=>{g.preventDefault(),L(p,"no")},className:iconBase.cn("group flex !h-full w-full items-center justify-between space-x-px !rounded py-px text-foreground/80 outline-none",R?"bg-blue-500 text-white":"hover:bg-gray-200 dark:hover:bg-gray-800",j&&canAcceptChildBlock(f._type,"Icon")?"bg-green-200":"",E&&"opacity-20",l.includes(p)?"opacity-50":""),children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:`flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center text-xs transition-transform duration-100 ${o.isOpen?"rotate-90":""}`,children:x&&jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:w,type:"button",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TriangleRightIcon,{})})}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mt-0.5 h-3 w-3",children:jsxRuntime.jsxRuntimeExports.jsx(TypeIcon,{type:f==null?void 0:f._type})}),y?jsxRuntime.jsxRuntimeExports.jsx(Input,{node:o}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"ml-2 flex items-center gap-x-1 truncate text-[11px]",onDoubleClick:g=>{g.stopPropagation(),o.edit(),o.deselect()},children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:(f==null?void 0:f._name)||(f==null?void 0:f._type.split("/").pop())}),N.includes("data")&&jsxRuntime.jsxRuntimeExports.jsx(VscJson,{className:"h-3 w-3 text-orange-600"}),N.includes("event")&&jsxRuntime.jsxRuntimeExports.jsx(BsLightningFill,{className:"h-3 w-3 text-yellow-500"}),N.includes("show")&&jsxRuntime.jsxRuntimeExports.jsx(TbEyeDown,{className:"h-3 w-3 text-orange-600"})]})]})]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"invisible flex items-center space-x-1 pr-2 group-hover:visible",children:[!l.includes(p)&&a.map(g=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{className:"cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",asChild:!0,children:React.createElement(g.item,{blockId:p})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-10",children:g.tooltip})]})),canAddChildBlock(f==null?void 0:f._type)&&!l.includes(p)?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,data:{_id:p}}),className:"cursor-pointer rounded bg-transparent hover:bg-white hover:text-black",asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.PlusIcon,{size:"18"})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:i("Add block")})]}):null,jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{onClick:g=>{g.stopPropagation(),c(p),o.isOpen&&o.toggle()},className:"cursor-pointer rounded bg-transparent hover:bg-white hover:text-black",asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.EyeOff,{size:"15"})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:i("Add block")})]})]})]})})}),Input=({node:o})=>{var n,r;return jsxRuntime.jsxRuntimeExports.jsx("input",{autoFocus:!0,className:"ml-2 !h-4 w-full rounded-sm border border-border bg-background px-1 text-[11px] outline-none",type:"text",defaultValue:((n=o.data)==null?void 0:n._name)||((r=o.data)==null?void 0:r._type),onFocus:a=>a.currentTarget.select(),onBlur:a=>o.submit(a.currentTarget.value),onKeyDown:a=>{a.key==="Enter"&&o.submit(a.currentTarget.value)}})},useCanMove=()=>{const[o]=useBlocksStore();return(n,r)=>{var l;const a=(l=lodashEs.find(o,{_id:r}))==null?void 0:l._type,i=lodashEs.first(n.map(c=>{var d;return(d=lodashEs.find(o,{_id:c}))==null?void 0:d._type}));return canAcceptChildBlock(a,i)}},ListTree=()=>{const[treeData]=jotai.useAtom(treeDSBlocks),[ids,setIds]=useSelectedBlockIds(),[cutBlocksIds]=useCutBlockIds(),[,setHiddenBlocks]=useHiddenBlockIds(),updateBlockProps=useUpdateBlocksProps(),[,setStyleBlocks]=useSelectedStylingBlocks(),{moveBlocks}=useBlocksStoreUndoableActions(),canMove=useCanMove(),treeRef=React.useRef(null),[,setTreeRef]=jotai.useAtom(treeRefAtom),{t}=reactI18next.useTranslation(),clearSelection=()=>{setIds([]),setStyleBlocks([])},filteredTreeData=React.useMemo(()=>{const o=(r,a)=>r.filter(i=>!a.includes(i._id)).map(i=>({...i,children:i.children?o(i.children,a):[]}));return[...o(treeData,cutBlocksIds),{_type:STRINGS.ROOT_TEMP_KEY,_id:STRINGS.ROOT_TEMP_KEY,children:[]}]},[treeData,cutBlocksIds]);React.useEffect(()=>{setTreeRef(treeRef.current)},[setTreeRef,treeRef]);const onRename=({id:o,name:n,node:r})=>{updateBlockProps([o],{_name:n},r.data._name)},onMove=({dragIds:o,parentId:n,index:r})=>{canMove(o,n)&&moveBlocks(o,n,r)},onSelect=o=>{if(o.length===0)return;const n=o[0]?o[0].id:"";setStyleBlocks([]),setIds([n])},onContextMenu=o=>{var a;o.preventDefault();const n=o.target,r=n.getAttribute("data-node-id")||((a=n.closest("[data-node-id]"))==null?void 0:a.getAttribute("data-node-id"));r&&(setStyleBlocks([]),setIds([r]))},debouncedDisableDrop=web.useDebouncedCallback(({parentNode:o,dragNodes:n})=>{var r;return(o==null?void 0:o.data._type)===STRINGS.ROOT_TEMP_KEY||!canAcceptChildBlock(o==null?void 0:o.data._type,(r=n[0])==null?void 0:r.data._type)},[],300),handleKeyDown=e=>{if(!treeRef.current)return;const tree=treeRef.current,selectedNode=tree.selectedNodes[0];if(!selectedNode)return;setIds[selectedNode.id],setStyleBlocks([]);const isLeaf=!selectedNode.isInternal,isClosed=!selectedNode.isOpen,isOpen=selectedNode.isOpen,shortcut=defaultShortcuts.find(s=>s.key===e.key&&(!s.when||eval(s.when)));if(shortcut)switch(e.preventDefault(),shortcut.command){case"selectNext":selectNext(tree);break;case"selectPrev":selectPrev(tree);break;case"selectParent":selectParent(tree,isLeaf||isClosed);break;case"close":close(tree,isOpen);break;case"open":open(tree,isClosed);break;case"selectFirst":selectFirst(tree);break;case"selectLast":selectLast(tree);break}};return lodashEs.isEmpty(treeData)?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-10 flex h-full w-full items-center justify-center p-8 text-center",children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1.5 text-sm text-gray-400",children:[t("This page is empty"),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK}),variant:"default",size:"sm",children:["+ ",t("Add Block")]})]})})}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:iconBase.cn("flex h-full select-none flex-col space-y-1"),onClick:()=>clearSelection(),children:jsxRuntime.jsxRuntimeExports.jsxs("div",{id:"outline-view",className:"no-scrollbar h-full overflow-y-auto text-xs",onKeyDown:o=>{treeRef.current.isEditing||handleKeyDown(o)},children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mb-2 flex items-center justify-end gap-x-2 pb-2 text-xs text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{onClick:()=>setHiddenBlocks([]),variant:"outline",className:"h-fit p-1 disabled:cursor-not-allowed disabled:opacity-50",size:"sm",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.EyeOpenIcon,{className:"h-4 w-4"})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:t("Show hidden blocks")})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{className:"h-fit p-1",onClick:()=>{var o;return(o=treeRef==null?void 0:treeRef.current)==null?void 0:o.openAll()},variant:"outline",size:"sm",children:jsxRuntime.jsxRuntimeExports.jsx(BiExpandVertical,{size:"14"})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:t("Expand all")})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{className:"h-fit p-1",onClick:()=>{var o;return(o=treeRef==null?void 0:treeRef.current)==null?void 0:o.closeAll()},variant:"outline",size:"sm",children:jsxRuntime.jsxRuntimeExports.jsx(BiCollapseVertical,{size:"14"})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:t("Collapse all")})]})]}),jsxRuntime.jsxRuntimeExports.jsx(reactArborist.Tree,{ref:treeRef,height:window.innerHeight-160,className:"no-scrollbar !h-full max-w-full !overflow-y-auto !overflow-x-hidden",selection:ids[0]||"",onRename,openByDefault:!1,onMove,rowHeight:25,data:[...filteredTreeData],renderCursor:DefaultCursor,onSelect,childrenAccessor:o=>o.children,width:"100%",renderDragPreview:DefaultDragPreview,indent:10,onContextMenu,disableDrop:debouncedDisableDrop,idAccessor:"_id",children:Node})]})})},Outline$1=ListTree,hasVideoEmbed=o=>{const n=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,r=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return n.test(o)||r.test(o)},getVideoURLFromHTML=o=>{if(lodashEs.isEmpty(o))return o;const n=/<video[^>]+src=['"]([^'">]+)['"]/,r=/<iframe[^>]+src=['"]([^'">]+)['"]/,a=o.match(n),i=o.match(r),l=a?a[1]:i?i[1]:null,c=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,d=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return l&&(c.test(l)||d.test(l))?l:o},NAME_ATTRIBUTE="$name",ATTRIBUTE_MAP={img:{alt:"alt",width:"width",height:"height",src:"image"},video:{src:"url",autoplay:"controls.autoPlay",muted:"controls.muted",loop:"controls.loop",controls:"controls.widgets"},a:{href:"link.href",target:"link.target",type:""},input:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},textarea:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},select:{placeholder:"placeholder",required:"required",multiple:"multiple",name:"fieldName"}},shouldAddText=(o,n)=>o.children.length===1&&lodashEs.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link","RichText"],n._type),getTextContent=o=>o.map(n=>n.type==="text"?lodashEs.get(n,"content",""):lodashEs.isEmpty(n.children)?"":getTextContent(n.children)).join(""),getSanitizedValue=o=>o===null?"":o,getAttrs=o=>{if(o.tagName==="svg")return{};const n={},r=ATTRIBUTE_MAP[o.tagName]||{},a=o.attributes;return lodashEs.forEach(a,({key:i,value:l})=>{if(i!==NAME_ATTRIBUTE)if(r[i]){if(o.tagName==="img"&&i==="src"&&!l.startsWith("http")){const c=lodashEs.find(o.attributes,{key:"width"}),d=lodashEs.find(o.attributes,{key:"height"});c&&d?l=`https://via.placeholder.com/${c==null?void 0:c.value}x${d==null?void 0:d.value}`:l="https://via.placeholder.com/150x150"}lodashEs.set(n,r[i],getSanitizedValue(l))}else lodashEs.includes(["style","class","srcset"],i)||(lodashEs.has(n,"styles_attrs")||(n.styles_attrs={}),lodashEs.startsWith(i,"@")&&(i=i.replace("@","x-on:")),n.styles_attrs[`${i}`]=getSanitizedValue(l))}),delete n.class,n},getStyles=(o,n="styles")=>{if(!o.attributes)return{[n]:`${STRINGS.STYLES_KEY},`};const r=lodashEs.find(o.attributes,{key:"class"});if(r){const a=r.value;return{[n]:`${STRINGS.STYLES_KEY},${a}`}}return{[n]:`${STRINGS.STYLES_KEY},`}},getBlockProps=o=>{const n=lodashEs.get(o,"attributes",[]),r=n.find(i=>i.key==="data-chai-richtext"||i.key==="chai-richtext"),a=n.find(i=>i.key==="data-chai-lightbox"||i.key==="chai-lightbox");if(r)return{_type:"RichText"};if(a)return{_type:"LightBoxLink"};switch(o.tagName){case"img":return{_type:"Image"};case"input":return{_type:"Input",showLabel:!1};case"hr":return{_type:"Divider"};case"br":return{_type:"LineBreak"};case"textarea":return{_type:"TextArea",showLabel:!1};case"audio":return{_type:"Audio"};case"canvas":return{_type:"Canvas"};case"video":case"iframe":return{_type:"CustomHTML"};case"svg":return{_type:"Icon"};case"select":return{_type:"Select",options:[]};case"option":return{_type:"Option"};case"ul":case"ol":case"dl":return{_type:"List",tag:o.tagName,_listType:o.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:o.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:o.tagName};case"p":return{_type:"Paragraph",content:""};case"a":return{_type:"Link"};case"form":return{_type:"Form"};case"label":return{_type:"Label"};case"button":return{_type:"Button"};case"code":return{_type:"Code"};case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return{_type:"Heading",tag:o.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:o.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:{const i=lodashEs.get(o,"children",[]).length>0?"Box":"EmptyBox";return{_type:i,tag:o.tagName,_name:i=="EmptyBox"||o.tagName==="div"?i:lodashEs.capitalize(o.tagName)}}}},traverseNodes=(o,n=null)=>lodashEs.flatMapDeep(o,r=>{var u,x,m,h,p,f,R,j;if(r.type==="comment")return[];let a={_id:iconBase.generateUUID()};if(n&&(a._parent=n.block._id),r.type==="text")return lodashEs.isEmpty(lodashEs.get(r,"content",""))?[]:n&&shouldAddText(n.node,n.block)?(lodashEs.set(n,"block.content",lodashEs.get(r,"content","")),[]):{...a,_type:"Text",content:lodashEs.get(r,"content","")};const i=lodashEs.get(r,"attributes",[]),l=i.find(E=>E.key==="data-chai-richtext"||E.key==="chai-richtext"),c=i.find(E=>E.key==="data-chai-lightbox"||E.key==="chai-lightbox");if(a={...a,...getBlockProps(r),...getAttrs(r),...getStyles(r)},r.attributes){const E=r.attributes.find(y=>y.key===NAME_ATTRIBUTE);E&&(a._name=E.value)}if(l)return a.content=himalaya.stringify(r.children),lodashEs.has(a,"styles_attrs.data-chai-richtext")&&delete a.styles_attrs["data-chai-richtext"],lodashEs.has(a,"styles_attrs.chai-richtext")&&delete a.styles_attrs["chai-richtext"],[a];if(c){const E=["data-chai-lightbox","chai-lightbox","data-vbtype","data-autoplay","data-maxwidth","data-overlay","data-gall","href"];a={...a,href:((u=i.find(y=>y.key==="href"))==null?void 0:u.value)||"",hrefType:((x=i.find(y=>y.key==="data-vbtype"))==null?void 0:x.value)||"video",autoplay:((m=i.find(y=>y.key==="data-autoplay"))==null?void 0:m.value)==="true",maxWidth:((p=(h=i.find(y=>y.key==="data-maxwidth"))==null?void 0:h.value)==null?void 0:p.replace("px",""))||"",backdropColor:((f=i.find(y=>y.key==="data-overlay"))==null?void 0:f.value)||"",galleryName:((R=i.find(y=>y.key==="data-gall"))==null?void 0:R.value)||""},lodashEs.forEach(E,y=>{lodashEs.has(a,`styles_attrs.${y}`)&&delete a.styles_attrs[y]})}if(a._type==="Input"){const E=a.inputType||"text";E==="checkbox"?lodashEs.set(a,"_type","Checkbox"):E==="radio"&&lodashEs.set(a,"_type","Radio")}else if(r.tagName==="video"||r.tagName==="iframe"){const E=himalaya.stringify([r]);return hasVideoEmbed(E)&&(lodashEs.set(a,"_type","Video"),lodashEs.set(a,"url",getVideoURLFromHTML(E)),lodashEs.set(a,"styles",`${STRINGS.STYLES_KEY},absolute top-0 left-0 w-full h-full`),lodashEs.set(a,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),a.content=E,[a]}else if(r.tagName==="svg"){const E=lodashEs.find(r.attributes,{key:"height"}),y=lodashEs.find(r.attributes,{key:"width"}),v=lodashEs.get(E,"value")?`[${lodashEs.get(E,"value")}px]`:"24px",w=lodashEs.get(y,"value")?`[${lodashEs.get(y,"value")}px]`:"24px",k=lodashEs.get(lodashEs.find(r.attributes,{key:"class"}),"value","w-full h-full");return a.styles=`${STRINGS.STYLES_KEY}, ${iconBase.cn(`w-${w} h-${v}`,k)}`.trim(),r.attributes=lodashEs.filter(r.attributes,C=>!lodashEs.includes(["style","width","height","class"],C.key)),a.icon=himalaya.stringify([r]),[a]}else if(r.tagName=="option"&&n&&((j=n.block)==null?void 0:j._type)==="Select")return n.block.options.push({label:getTextContent(r.children),...getAttrs(r)}),[];const d=traverseNodes(r.children,{block:a,node:r});return[a,...d]}),getSanitizedHTML=o=>{const n=o.match(/<body[^>]*>[\s\S]*?<\/body>/);return(n&&n.length>0?n[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):o).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},getBlocksFromHTML=o=>{const n=himalaya.parse(getSanitizedHTML(o));return lodashEs.isEmpty(o)?[]:lodashEs.flatten(traverseNodes(n))},ImportHTML=({parentId:o})=>{const{t:n}=reactI18next.useTranslation(),[r,a]=React.useState(""),{addPredefinedBlock:i}=useAddBlock(),l=()=>{const c=getBlocksFromHTML(r);i([...c],o),a(""),emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK})};return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Card,{className:"border-border/0 p-0 shadow-none",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CardHeader,{className:"p-3",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CardDescription,{children:n("html_snippet_description")})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CardContent,{className:"space-y-2 px-3 py-0",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Label,{htmlFor:"current",className:"text-sm",children:n("tailwind_html_snippet")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{autoFocus:!0,tabIndex:1,ref:c=>c&&c.focus(),onChange:c=>a(c.target.value),rows:12,value:r,placeholder:n("enter_code_snippet"),className:"resize-none overflow-x-auto whitespace-pre bg-background font-mono text-xs font-normal"})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CardFooter,{className:"flex flex-col justify-end p-3",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:r.trim()==="",onClick:()=>l(),size:"sm",className:"w-fit",children:n("Import HTML")})})]})},ImportHTML$1=ImportHTML,isBoolean=o=>typeof o=="boolean"||o instanceof Boolean,isNumber=o=>typeof o=="number"||o instanceof Number,isBigInt=o=>typeof o=="bigint"||o instanceof BigInt,isDate=o=>!!o&&o instanceof Date,isString=o=>typeof o=="string"||o instanceof String,isArray=o=>Array.isArray(o),isObject=o=>o instanceof Object&&o!==null;function useBool(o){const[n,r]=React.useState(o());return[n,()=>r(i=>!i),r]}let componentId=1;const generateNextId=()=>componentId++;function useComponentId(){const o=React.useRef();return o.current===void 0&&(o.current=`:jsnvw:${generateNextId()}:`),o.current}function ExpandableObject(o){let{field:n,value:r,data:a,lastElement:i,openBracket:l,closeBracket:c,level:d,style:u,shouldExpandNode:x,clickToExpandNode:m}=o;const h=React.useRef(!1),[p,f,R]=useBool(()=>x(d,r,n));React.useEffect(()=>{h.current?R(x(d,r,n)):h.current=!0},[x]);const j=p?u.collapseIcon:u.expandIcon,E=p?"collapse JSON":"expand JSON",y=useComponentId(),v=d+1,w=a.length-1,k=C=>{C.key===" "&&(C.preventDefault(),f())};return React.createElement("div",{className:u.basicChildStyle,role:"list"},React.createElement("span",{className:j,onClick:f,onKeyDown:k,role:"button",tabIndex:0,"aria-label":E,"aria-expanded":p,"aria-controls":p?y:void 0}),n&&(m?React.createElement("span",{className:u.clickableLabel,onClick:f,onKeyDown:k,role:"button",tabIndex:-1},n,":"):React.createElement("span",{className:u.label},n,":")),React.createElement("span",{className:u.punctuation},l),p?React.createElement("div",{id:y},a.map((C,I)=>React.createElement(DataRender,{key:C[0]||I,field:C[0],value:C[1],style:u,lastElement:I===w,level:v,shouldExpandNode:x,clickToExpandNode:m}))):React.createElement("span",{className:u.collapsedContent,onClick:f,onKeyDown:k,role:"button",tabIndex:-1,"aria-hidden":!0,"aria-label":E,"aria-expanded":p}),React.createElement("span",{className:u.punctuation},c),!i&&React.createElement("span",{className:u.punctuation},","))}function JsonObject(o){let{field:n,value:r,style:a,lastElement:i,shouldExpandNode:l,clickToExpandNode:c,level:d}=o;return ExpandableObject({field:n,value:r,lastElement:i||!1,level:d,openBracket:"{",closeBracket:"}",style:a,shouldExpandNode:l,clickToExpandNode:c,data:Object.keys(r).map(u=>[u,r[u]])})}function JsonArray(o){let{field:n,value:r,style:a,lastElement:i,level:l,shouldExpandNode:c,clickToExpandNode:d}=o;return ExpandableObject({field:n,value:r,lastElement:i||!1,level:l,openBracket:"[",closeBracket:"]",style:a,shouldExpandNode:c,clickToExpandNode:d,data:r.map(u=>[void 0,u])})}function JsonPrimitiveValue(o){let{field:n,value:r,style:a,lastElement:i}=o,l=r,c=a.otherValue;return r===null?(l="null",c=a.nullValue):r===void 0?(l="undefined",c=a.undefinedValue):isString(r)?(l=a.noQuotesForStringValues?r:`"${r}"`,c=a.stringValue):isBoolean(r)?(l=r?"true":"false",c=a.booleanValue):isNumber(r)?(l=r.toString(),c=a.numberValue):isBigInt(r)?(l=`${r.toString()}n`,c=a.numberValue):isDate(r)?l=r.toISOString():l=r.toString(),n===""&&(n='""'),React.createElement("div",{className:a.basicChildStyle,role:"listitem"},n&&React.createElement("span",{className:a.label},n,":"),React.createElement("span",{className:c},l),!i&&React.createElement("span",{className:a.punctuation},","))}function DataRender(o){const n=o.value;return isArray(n)?React.createElement(JsonArray,Object.assign({},o)):isObject(n)&&!isDate(n)?React.createElement(JsonObject,Object.assign({},o)):React.createElement(JsonPrimitiveValue,Object.assign({},o))}var styles={"container-base":"_GzYRV","punctuation-base":"_3eOF8",pointer:"_1MFti","expander-base":"_f10Tu _1MFti","expand-icon":"_1UmXx","collapse-icon":"_1LId0","collapsed-content-base":"_1pNG9 _1MFti","container-light":"_2IvMF _GzYRV","basic-element-style":"_2bkNM","label-light":"_1MGIk","clickable-label-light":"_2YKJg _1MGIk _1MFti","punctuation-light":"_3uHL6 _3eOF8","value-null-light":"_2T6PJ","value-undefined-light":"_1Gho6","value-string-light":"_vGjyY","value-number-light":"_1bQdo","value-boolean-light":"_3zQKs","value-other-light":"_1xvuR","collapse-icon-light":"_oLqym _f10Tu _1MFti _1LId0","expand-icon-light":"_2AXVT _f10Tu _1MFti _1UmXx","collapsed-content-light":"_2KJWg _1pNG9 _1MFti","container-dark":"_11RoI _GzYRV","expand-icon-dark":"_17H2C _f10Tu _1MFti _1UmXx","collapse-icon-dark":"_3QHg2 _f10Tu _1MFti _1LId0","collapsed-content-dark":"_3fDAz _1pNG9 _1MFti","label-dark":"_2bSDX","clickable-label-dark":"_1RQEj _2bSDX _1MFti","punctuation-dark":"_gsbQL _3eOF8","value-null-dark":"_LaAZe","value-undefined-dark":"_GTKgm","value-string-dark":"_Chy1W","value-number-dark":"_2bveF","value-boolean-dark":"_2vRm-","value-other-dark":"_1prJR"};const defaultStyles={container:styles["container-light"],basicChildStyle:styles["basic-element-style"],label:styles["label-light"],clickableLabel:styles["clickable-label-light"],nullValue:styles["value-null-light"],undefinedValue:styles["value-undefined-light"],stringValue:styles["value-string-light"],booleanValue:styles["value-boolean-light"],numberValue:styles["value-number-light"],otherValue:styles["value-other-light"],punctuation:styles["punctuation-light"],collapseIcon:styles["collapse-icon-light"],expandIcon:styles["expand-icon-light"],collapsedContent:styles["collapsed-content-light"],noQuotesForStringValues:!1},allExpanded=()=>!0,JsonView=o=>{let{data:n,style:r=defaultStyles,shouldExpandNode:a=allExpanded,clickToExpandNode:i=!1}=o;return React.createElement("div",{className:r.container},React.createElement(DataRender,{value:n,style:r,lastElement:!0,level:0,shouldExpandNode:a,clickToExpandNode:i}))};function getPathAndTypes(o){const n=[],r={};function a(i,l){lodashEs.forEach(l,(c,d)=>{const u=i?`${i}.${d}`:d,x=lodashEs.isArray(c)?"list":typeof c;n.push(u),r[u]=x==="string"?"text":x==="object"?"model":x,x==="object"&&!lodashEs.isArray(c)&&a(u,c)})}return a("",lodashEs.omit(o,["styles","_type","_id","_name","_bindings"])),{paths:n,pathsType:r}}const ViewData=({data:o,fullView:n})=>{const r=useBuilderProp("onError",lodashEs.noop);if(!o)return null;const a=typeof o;return n?typeof o=="object"?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-3"}),jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:r,children:jsxRuntime.jsxRuntimeExports.jsx(JsonView,{data:o,shouldExpandNode:allExpanded,style:{...defaultStyles,container:"max-h-[40vh] overflow-y-auto text-[12px] leading-[1.5] tracking-wide font-mono",stringValue:"text-orange-600",label:"text-green-900 font-semibold pr-1 tracking-wider"}})})]}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"max-h-36 w-full overflow-y-auto overflow-x-hidden text-[12px] leading-4 text-gray-800/50",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"font-medium text-gray-800/80",children:"Content: "}),o]}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-full overflow-hidden whitespace-nowrap text-[10px] leading-3 text-gray-800/50",children:lodashEs.truncate(a==="object"?JSON.stringify(o):o,{length:40})})},DataProvidersSuggester=({type:o,value:n="",setValue:r,data:a,onChange:i,dataType:l,appliedBindings:c})=>{const{paths:d,pathsType:u}=getPathAndTypes(a),x=o==="PROP"?runtime.getBlockComponent(a==null?void 0:a._type):{},m=o==="PROP",[h,p]=React.useState(!1),f=React.useMemo(()=>o==="PROP"?d.filter(R=>!lodashEs.includes(c,R)&&lodashEs.get(x,`props.${lodashEs.first(lodashEs.split(R,"."))}.binding`)):d.filter(R=>l===lodashEs.get(u,R,"")),[o,d,c,l,x]);return React.useEffect(()=>{n&&i(n)},[n,o]),jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-4",children:[jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:lodashEs.startCase(lodashEs.toLower(o))}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Popover,{open:h,onOpenChange:p,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"outline",size:"sm",className:` ${lodashEs.isEmpty(n)?"w-44 justify-center bg-blue-500 text-gray-100 hover:bg-blue-400 hover:text-white":"min-w-[350px] items-center justify-between"}`,children:n?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs("span",{className:"pr-8 text-sm",children:[m&&jsxRuntime.jsxRuntimeExports.jsx("span",{className:"mr-2 rounded-full bg-purple-100 px-2 py-0.5 text-[10px] text-purple-500",children:lodashEs.startCase(l)}),n]}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"cursor-pointer text-[9px] text-blue-400 underline hover:text-blue-700",children:"Change"})]}):jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:["+ Set ",lodashEs.startCase(lodashEs.toLower(o))]})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverContent,{className:"z-[999] min-w-[300px] p-0",side:"right",align:"start",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Command,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CommandInput,{placeholder:`Choose ${lodashEs.toLower(o)}...`}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.CommandList,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CommandEmpty,{children:"No results found."}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CommandGroup,{children:lodashEs.map(f,R=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.CommandItem,{value:R,className:`cursor-pointer ${m?"flex items-center justify-between":"flex flex-col items-start justify-start"}`,onSelect:j=>{r(lodashEs.find(f,E=>E===j)||null),p(!1)},children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Check,{className:`h-4 w-4 text-green-500 ${n===R?"":"opacity-0"}`}),R]}),m?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"rounded-full bg-purple-100 px-2 py-0.5 text-[10px] text-purple-500",children:lodashEs.startCase(lodashEs.get(u,R,""))})}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"pl-6",children:jsxRuntime.jsxRuntimeExports.jsx(ViewData,{data:lodashEs.get(a,R)})})]},R))})]})]})})]})]}),!m&&!lodashEs.isEmpty(n)&&jsxRuntime.jsxRuntimeExports.jsx("div",{className:"pt-2",children:jsxRuntime.jsxRuntimeExports.jsx(ViewData,{data:lodashEs.get(a,n,""),fullView:!0})})]})},AddBindingModalContent=({appliedBindings:o=[],onAddBinding:n,editMode:r,item:a})=>{const[i,l]=React.useState(r?a.key:""),[c,d]=React.useState(r?a.value:""),u=useSelectedBlock(),[x]=useChaiExternalData(),m=React.useCallback((f,R)=>{if(lodashEs.isEmpty(f))return"";{const j=lodashEs.get(R==="PROP"?u:x,f,"");if(lodashEs.isArray(j))return"list";const E=typeof j;return E==="string"?"text":E==="object"?"model":E}},[u,x]),[h,p]=React.useState(r?m(a.key,"PROP"):"");return jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTitle,{children:"Add Data Binding"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogDescription,{className:"text-xs",children:"Add prop and path of binding. Click save when you're done."})]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex flex-col gap-1",children:[jsxRuntime.jsxRuntimeExports.jsx(DataProvidersSuggester,{type:"PROP",isDisabled:!1,placeholder:"Enter prop key",value:i,setValue:l,onChange:f=>{const R=m(f,"PROP");l(f),h!==R&&d(""),p(R)},data:u,dataType:h,appliedBindings:o}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-2"}),jsxRuntime.jsxRuntimeExports.jsx(DataProvidersSuggester,{type:"PATH",isDisabled:lodashEs.isEmpty(i),placeholder:"Enter data path",value:c,setValue:d,onChange:f=>{const R=m(f,"PATH");d(h===R?f:"")},data:x,dataType:h,appliedBindings:o})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogFooter,{children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{type:"submit",className:"mt-4",disabled:lodashEs.isEmpty(i)&&lodashEs.isEmpty(c),onClick:()=>n({key:i,value:c}),children:"Save"})})]})},AddBindingModal=({disabled:o,children:n,onAddBinding:r,appliedBindings:a,editMode:i=!0,item:l={}})=>{const[c,d]=React.useState(!1);return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Dialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTrigger,{disabled:o,asChild:!0,onClick:()=>d(!0),children:n}),c&&jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogContent,{children:jsxRuntime.jsxRuntimeExports.jsx(AddBindingModalContent,{item:l,editMode:i,appliedBindings:a,onAddBinding:u=>{r(u),d(!1)}})})]})},NewDataBindingPair=({item:o,onAddBinding:n,onRemove:r,selectedBlock:a,dataProvider:i,appliedBindings:l})=>{const[c,d]=React.useState("string"),u=(x,m)=>{if(lodashEs.isEmpty(x))return"";{const h=lodashEs.get(m==="PROP"?a:i,x,"");if(lodashEs.isArray(h))return"list";const p=typeof h;return p==="string"?"text":p==="object"?"model":p}};return React.useEffect(()=>d(()=>u(o.key,"PROP")),[o.key]),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex flex-col rounded-md border border-border p-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-sm font-normal text-gray-500",children:o.key}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"font-medium leading-5",children:o.value}),jsxRuntime.jsxRuntimeExports.jsx(ViewData,{data:lodashEs.get(i,o.value,"")}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx(AddBindingModal,{editMode:!0,onAddBinding:n,appliedBindings:l,item:o,children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.EditIcon,{className:"mt-1 h-6 w-6 cursor-pointer rounded border border-blue-400 p-1 text-blue-400 duration-200 hover:scale-105 hover:bg-blue-400 hover:text-white"})}),jsxRuntime.jsxRuntimeExports.jsx(lucideReact.TrashIcon,{onClick:()=>r(),className:"mt-1 h-6 w-6 cursor-pointer rounded border border-red-400 p-1 text-red-400 duration-200 hover:scale-105 hover:bg-red-400 hover:text-white"})]}),!lodashEs.isEmpty(c)&&!lodashEs.isEmpty(o.key)&&jsxRuntime.jsxRuntimeExports.jsx("div",{className:"absolute right-0 top-1 mt-px flex h-4 items-center rounded-full px-2 text-[10px] font-medium text-purple-600",children:lodashEs.startCase(c)})]})},DataBindingSetting=({bindingData:o,onChange:n})=>{const r=useSelectedBlock(),[a]=useChaiExternalData(),i=runtime.getChaiDataProviders(),[l,c]=React.useState(lodashEs.map(o,(h,p)=>({key:p,value:h})));React.useEffect(()=>{c(lodashEs.map(o,(h,p)=>({key:p,value:h})))},[r==null?void 0:r._id,o]);const d=React.useMemo(()=>{if(lodashEs.isEmpty(a))return!0;if(lodashEs.isEmpty(l))return!1;const h=lodashEs.last(l);return lodashEs.isEmpty(h==null?void 0:h.key)||lodashEs.isEmpty(h==null?void 0:h.value)},[a,l]),u=h=>{const p=lodashEs.filter(l,f=>f.key!==h.key);c([...p,h]),m([...p,h])},x=h=>{const p=lodashEs.filter(l,(f,R)=>h!==R);m([...p])},m=React.useCallback((h=[])=>{if(c(h),lodashEs.isEmpty(h)){n({});return}const p={};lodashEs.forEach(h,f=>{!lodashEs.isEmpty(f==null?void 0:f.key)&&!lodashEs.isEmpty(f==null?void 0:f.value)&&lodashEs.set(p,f.key,f.value)}),n(p)},[n]);return lodashEs.isEmpty(i)?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-full items-center justify-center",children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1.5 text-xs text-gray-500",children:["You have no data providers registered. Please add a data provider to your project. ",jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("a",{className:"text-blue-500",href:"https://chaibuilder.com/docs/registering-data-providers",target:"_blank",children:"Learn more"})]})}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[lodashEs.map(l,(h,p)=>jsxRuntime.jsxRuntimeExports.jsx(NewDataBindingPair,{item:h,onAddBinding:u,onRemove:()=>x(p),selectedBlock:r,dataProvider:a,appliedBindings:lodashEs.map(l,"key")},h.key)),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{delayDuration:200,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{disabled:lodashEs.isEmpty(a),className:"w-full",children:jsxRuntime.jsxRuntimeExports.jsx(AddBindingModal,{disabled:d,appliedBindings:lodashEs.map(l,"key"),onAddBinding:u,children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:`w-full rounded-md px-5 py-1.5 text-xs font-medium duration-200 ${d?"cursor-not-allowed bg-gray-200 text-gray-400":"bg-blue-700/20 text-blue-800 hover:bg-blue-700/30"}`,children:lodashEs.isEmpty(a)?jsxRuntime.jsxRuntimeExports.jsx("small",{className:"text-[9.5px] text-gray-500",children:"No data provider has been set up for this page"}):"+ Add Data Binding"})})}),d&&jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{sideOffset:-55,className:"text-[11px]",children:lodashEs.isEmpty(a)?"No data provider has been set up for this page.":"Complete last added data binding to add more"})]})]})},DataBindingSetting$1=DataBindingSetting,BindingWidget=()=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-xs border rounded-sm p-1 mt-1 border-orange-500 text-orange-500 bg-orange-100",children:"Data binding is set for this field"}),getSvgMarkup=o=>{try{const n=document.getElementById("icon-picker-field"),r=document.createElement("div");ReactDOM.render(jsxRuntime.jsxRuntimeExports.jsx(IconPicker.IconPickerItem,{value:o}),r),n.appendChild(r),r.hidden=!0;let a=r.innerHTML;setTimeout(()=>n.removeChild(r),100);const l=new DOMParser().parseFromString(a,"image/svg+xml"),c=l.querySelector("svg");return c&&(c.removeAttribute("width"),c.removeAttribute("height")),new XMLSerializer().serializeToString(l)}catch(n){return console.error(n),""}},IconPickerField=({value:o,onChange:n})=>{const{t:r}=reactI18next.useTranslation(),a=i=>{n("<svg />");const l=getSvgMarkup(i);n(l)};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-1 flex h-20 items-center gap-x-2",id:"icon-picker-field",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"group relative h-12 w-12",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:o?o.replace("<svg",'<svg class="h-5 w-5"'):"<svg class='h-5 w-5' />"},className:"absolute left-1/2 top-1/2 z-0 -translate-x-1/2 -translate-y-1/2 transform cursor-pointer bg-white"}),jsxRuntime.jsxRuntimeExports.jsx(IconPicker,{value:o?"BiSolidGrid":null,onChange:a,pickButtonStyle:{position:"relative",height:"48px",width:"48px",border:"1px solid #999",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"6px",backgroundColor:"transparent",zIndex:1},searchInputStyle:{backgroundColor:"transparent",width:"100%",border:"1px solid #BBBBBB",margin:"0px 10px",padding:"10px"}})]}),jsxRuntime.jsxRuntimeExports.jsx("textarea",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:o,onChange:i=>n(i.target.value),placeholder:r("choose_icon_or_enter_svg"),className:"no-scrollbar disabled:opacity-50; mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed"})]})},UnsplashImages=React.lazy(()=>Promise.resolve().then(()=>require("./UnsplashImages-8r1JNyap.cjs"))),UploadImages=React.lazy(()=>Promise.resolve().then(()=>require("./UploadImages-Vws49f38.cjs"))),ImagesPanel=({isModalView:o=!1,onSelect:n=()=>{}})=>{const r=useBuilderProp("uploadMediaCallback"),a=useBuilderProp("unsplashAccessKey"),i=r===void 0,l=a===void 0,[c,d]=React.useState(l?"upload":i?"unsplash":"upload");return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between rounded-md bg-background/30 p-1",children:jsxRuntime.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:o&&i?"Unsplash images":o?"Select or upload images":"Images"})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tabs,{value:c,onValueChange:u=>d(u),className:"flex h-full w-full flex-col py-2",children:[!(i||l)&&jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.TabsList,{className:"w-full",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"upload",className:"w-full",children:"Upload"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"unsplash",className:"w-full",children:"Unsplash"})]}),c==="unsplash"?jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsContent,{value:"unsplash",className:"flex h-full flex-col overflow-hidden",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-64 w-full animate-pulse bg-gray-100"}),children:jsxRuntime.jsxRuntimeExports.jsx(UnsplashImages,{isModalView:o,onSelect:n})})}):jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsContent,{value:"upload",className:"flex h-full flex-col overflow-hidden",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-64 w-full animate-pulse bg-gray-100"}),children:jsxRuntime.jsxRuntimeExports.jsx(UploadImages,{isModalView:o,onSelect:n})})})]})]})},ImagesPanel$1=ImagesPanel,ImagePickerModal=({children:o,onSelect:n})=>{const[r,a]=React.useState(!1),i=useBuilderProp("mediaManagerComponent",ImagesPanel$1),l=(...c)=>{n.call(void 0,...c),a(!1)};return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Dialog,{open:r,onOpenChange:c=>a(c),children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTrigger,{asChild:!0,children:o}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogContent,{className:"flex h-3/4 max-w-5xl border-border",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-full w-full",children:jsxRuntime.jsxRuntimeExports.jsx(i,{isModalView:!0,onSelect:l})})})]})};ImagePickerModal.displayName="ImagePickerModal";const ImagePickerModal$1=ImagePickerModal,ImagePickerField=({value:o,onChange:n,id:r,onBlur:a})=>{const i=useBuilderProp("uploadMediaCallback"),l=useBuilderProp("unsplashAccessKey"),{t:c}=reactI18next.useTranslation(),d=i!==void 0||l!==void 0;return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[o?jsxRuntime.jsxRuntimeExports.jsx("img",{src:o,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover",alt:""}):jsxRuntime.jsxRuntimeExports.jsx(ImagePickerModal$1,{onSelect:n,children:jsxRuntime.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("div",{className:"flex w-3/5 flex-col",children:[d&&jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(ImagePickerModal$1,{onSelect:n,children:jsxRuntime.jsxRuntimeExports.jsx("small",{className:"h-6 cursor-pointer rounded-md bg-primary px-2 py-1 text-center text-xs text-white hover:bg-gray-500 dark:bg-gray-700",children:o||!lodashEs.isEmpty(o)?c("Replace image"):c("Choose image")})}),jsxRuntime.jsxRuntimeExports.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-gray-600",children:"OR"})]}),jsxRuntime.jsxRuntimeExports.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"text-xs",placeholder:c("enter_image_url"),value:o,onBlur:({target:{value:u}})=>a(r,u),onChange:u=>n(u.target.value)})]})]})},RichTextEditorField=({id:o,placeholder:n,value:r,onChange:a,onBlur:i})=>{const l={toolbar:[["bold","italic","underline","strike","blockquote"],[{list:"ordered"},{list:"bullet"}],[{color:[]},{background:[]},{align:[]}],["link","clean"]]},c=["header","font","list","bold","italic","underline","strike","blockquote","color","background","align","link","image"];return typeof window>"u"?null:jsxRuntime.jsxRuntimeExports.jsx(ReactQuill,{id:o,value:r,onBlur:d=>i(o,d),onChange:d=>a(d),modules:l,formats:c,placeholder:n,className:"mt-1 rounded-md"})},LinkField=({schema:o,formData:n,onChange:r})=>{const[a,i]=React.useState([]),l=useBuilderProp("getPages",()=>[]),{type:c="page",href:d="",target:u="self"}=n;return React.useEffect(()=>{(async()=>{const x=await l();i(x||[])})()},[]),jsxRuntime.jsxRuntimeExports.jsxs("div",{children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"text-xs font-medium",children:(o==null?void 0:o.title)??"Link"}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxRuntimeExports.jsx("select",{name:"type",value:c,onChange:x=>r({...n,type:x.target.value}),children:[{const:"page",title:"Open Page"},{const:"url",title:"Open URL"},{const:"email",title:"Compose Email"},{const:"telephone",title:"Call Phone"},{const:"scroll",title:"Scroll to element"}].map(x=>jsxRuntime.jsxRuntimeExports.jsx("option",{value:x.const,children:x.title},x.const))}),c==="page"?jsxRuntime.jsxRuntimeExports.jsxs("select",{name:"href",value:d,onChange:x=>r({...n,href:x.target.value||"#"}),children:[jsxRuntime.jsxRuntimeExports.jsx("option",{value:"",children:"Choose page"}),lodashEs.map(a,x=>jsxRuntime.jsxRuntimeExports.jsx("option",{value:x.slug,children:x.name},x.uuid))]}):jsxRuntime.jsxRuntimeExports.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",value:d,onChange:x=>r({...n,href:x.target.value||"#"}),placeholder:c==="page"||c==="url"?"Enter URL":c==="scroll"?"#ElementID":"Enter detail"}),(c==="page"||c==="url")&&jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"checkbox",defaultChecked:u==="_blank",className:"!w-fit cursor-pointer rounded-md border border-border",onChange:()=>r({...n,target:u==="_blank"?"_self":"_blank"})}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"pt-1 text-xs",children:"Open in new tab"})]})]})]})},CodeEditor=({id:o,placeholder:n})=>{const{t:r}=reactI18next.useTranslation(),[,a]=useCodeEditor(),i=useSelectedBlock();if(typeof window>"u")return null;const l=o.replace("root.",""),c=lodashEs.get(i,l,""),d=()=>{const u=i==null?void 0:i._id;a({blockId:u,blockProp:l,placeholder:n,initialCode:lodashEs.get(i,l,c)})};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2 flex flex-col gap-y-1",children:[jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:d,className:"text-pretty w-[90%] max-w-full cursor-default truncate rounded border border-border bg-background p-2 text-left text-[10px]",children:c.trim().length>0?c.substring(0,46):n||"Eg: <script>console.log('Hello, world!');<\/script>"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{onClick:d,size:"sm",variant:"outline",className:"w-fit",children:r("Open code editor")})]})},JSONForm=React.memo(({id:o,properties:n,formData:r,onChange:a})=>{const[i,l]=React.useState(r),c={type:"object",properties:{}},d={},{t:u}=reactI18next.useTranslation(),{selectedLang:x,fallbackLang:m,languages:h}=useLanguages(),p=h.length===0?"":x.length?x:m;Object.keys(n).forEach(R=>{const j=n[R];if(lodashEs.includes(["slot","styles"],j.type))return;const E=R;c.properties[E]=getBlockJSONFromSchemas(j,u,p),d[E]=getBlockJSONFromUISchemas(j)}),React.useEffect(()=>{l(r)},[o,x]);const f=web.useThrottledCallback(async({formData:R},j)=>{a({formData:R},j)},[a],1e3);return jsxRuntime.jsxRuntimeExports.jsx(Form,{widgets:{binding:BindingWidget,richtext:RichTextEditorField,icon:IconPickerField,image:ImagePickerField,code:CodeEditor},fields:{link:LinkField},idSeparator:".",autoComplete:"off",omitExtraData:!1,liveOmit:!1,liveValidate:!1,validator,uiSchema:d,schema:c,formData:i,onChange:({formData:R},j)=>{j&&(l(R),f({formData:R},j))}})}),CanvasSettings=()=>{const[o,n]=jotai.useAtom(xShowBlocksAtom),r=useSelectedBlock(),[,a]=useSelectedBlockIds(),{t:i}=reactI18next.useTranslation(),l=React.useMemo(()=>(r?JSON.stringify(r):"").includes('"x-show"'),[r]);if(!r||!l)return null;const c=o.includes(r._id);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"py-2 text-xs hover:no-underline",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 border-b border-border bg-background py-2 font-normal text-muted-foreground",children:[r._name||r._type," ",i("visibility settings")]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Switch,{id:"show-on-canvas",checked:c,onCheckedChange:d=>{d?(n(u=>[...u,r._id]),a([r._id])):n(u=>u.filter(x=>x!==r._id))}}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Label,{htmlFor:"show-on-canvas",children:i("Show on canvas")})]})]})},GlobalBlockSettings=()=>{const o=useSelectedBlock(),{data:n,refetch:r,isLoading:a}=useGlobalBlocksList(),i=useUpdateBlocksProps();return jsxRuntime.jsxRuntimeExports.jsxs("div",{children:[jsxRuntime.jsxRuntimeExports.jsx("label",{className:"text-sm",children:"Choose a global block"}),jsxRuntime.jsxRuntimeExports.jsxs("select",{className:"h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",value:(o==null?void 0:o.globalBlock)||"",onChange:l=>{i([o._id],{globalBlock:l.target.value,_name:`Global: ${lodashEs.startCase(l.target.value)}`})},children:[jsxRuntime.jsxRuntimeExports.jsx("option",{value:"",children:"Select a global block"}),Object.keys(n).map(l=>jsxRuntime.jsxRuntimeExports.jsx("option",{value:l,children:n[l].name||l},l))]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-2 text-xs",children:jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:r,className:"rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",children:a?"Loading...":"Refresh List"})})]})},ResetRSCBlockButton=({blockId:o})=>{const{t:n}=reactI18next.useTranslation(),{reset:r}=useRSCBlocksStore();return jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{size:"sm",variant:"outline",onClick:()=>r(o),children:n("Reload")})},formDataWithSelectedLang=(o,n,r)=>{const a=lodashEs.cloneDeep(o);return lodashEs.forEach(lodashEs.keys(o),i=>{lodashEs.get(r,["props",i,"i18n"])&&!lodashEs.isEmpty(n)&&(a[i]=lodashEs.get(o,`${i}-${n}`))}),a};function BlockSettings(){const{selectedLang:o}=useLanguages(),n=useSelectedBlock(),r=useUpdateBlocksPropsRealtime(),a=useUpdateBlocksProps(),i=runtime.getBlockComponent(n==null?void 0:n._type),l=formDataWithSelectedLang(n,o,i),[c,d]=React.useState(l),u=useBuilderProp("dataBindingSupport",!1),x=({formData:j},E,y)=>{if(E&&(c==null?void 0:c._id)===n._id){const v=E.replace("root.","");a([n._id],{[v]:lodashEs.get(j,v)},y)}},m=React.useCallback(lodashEs.debounce(({formData:j},E,y)=>{x({formData:j},E,y),d(j)},1500),[n==null?void 0:n._id,o]),h=({formData:j},E)=>{if(E){const y=E.replace("root.","");r([n._id],convertDotNotationToObject(y,lodashEs.get(j,y.split(".")))),m({formData:j},E,{[y]:lodashEs.get(c,y)})}},p=lodashEs.keys(lodashEs.get(l,"_bindings",{})),f=React.useMemo(()=>{const j=lodashEs.cloneDeep(lodashEs.get(i,"props",{}));return lodashEs.each(j,(E,y)=>{lodashEs.get(E,"hidden",!1)&&delete j[y]}),u&&lodashEs.each(p,E=>delete j[E]),j},[i,p,u]),R=lodashEs.get(i,"server",!1);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"overflow-x-hidden px-px",children:[u?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Accordion,{type:"multiple",defaultValue:["STATIC","BINDING"],className:"mt-4 h-full w-full",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:"BINDING",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{className:"py-2",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:`h-[8px] w-[8px] rounded-full ${lodashEs.isEmpty(lodashEs.get(n,"_bindings",{}))?"bg-gray-300":"bg-blue-500"}`}),"Data Binding"]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionContent,{className:"pt-4",children:jsxRuntime.jsxRuntimeExports.jsx(DataBindingSetting$1,{bindingData:lodashEs.get(n,"_bindings",{}),onChange:j=>{x({formData:{_bindings:j}},"root._bindings")}})})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:"STATIC",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{className:"py-2",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-[8px] w-[8px] rounded-full bg-blue-500"}),"Static Content"]})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionContent,{className:"pt-4",children:[lodashEs.isEmpty(p)?null:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mb-1 mt-0 rounded-sm border border-orange-500 bg-orange-100 p-1 text-xs text-orange-500",children:["Data binding is set for ",jsxRuntime.jsxRuntimeExports.jsx("b",{children:lodashEs.map(p,lodashEs.capitalize).join(", ")})," ",p.length===1?"property":"properties",". Remove data binding to edit static content."]}),jsxRuntime.jsxRuntimeExports.jsx(JSONForm,{id:n==null?void 0:n._id,onChange:h,formData:l,properties:f})]})]})]}):lodashEs.isEmpty(f)?null:jsxRuntime.jsxRuntimeExports.jsx(JSONForm,{id:n==null?void 0:n._id,onChange:h,formData:l,properties:f}),(n==null?void 0:n._type)==="GlobalBlock"?jsxRuntime.jsxRuntimeExports.jsx(GlobalBlockSettings,{}):null,R?jsxRuntime.jsxRuntimeExports.jsx(ResetRSCBlockButton,{blockId:n==null?void 0:n._id}):null,jsxRuntime.jsxRuntimeExports.jsx(CanvasSettings,{})]})}function getChildBlocks(o,n,r){r.push(lodashEs.find(o,{_id:n}));const a=lodashEs.filter(o,{_parent:n});for(const i of a)r.push(...getBlockWithChildren(i._id,o));return r}const getBlockWithChildren=(o,n)=>{let r=[];return r=lodashEs.flattenDeep([...r,...getChildBlocks(n,o,r)]),r};function promptWithLanguage(o,n,r){if(!n||r!=="content")return o;const a=`Please provide the response in "${n}" language.`;return`${o}
61
+ }`)},[a,m]),React.useEffect(()=>{c.querySelector("#drop-target-block").innerHTML=l?`[data-block-id="${l}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}`:""},[l]),jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:(p||f)&&jsxRuntime.jsxRuntimeExports.jsx("link",{rel:"stylesheet",href:`https://fonts.googleapis.com/css2?family=${p?`${p.replace(/ /g,"+")}:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900`:""}${p&&f&&p!==f?"&":""}${f&&f!==p?`family=${f.replace(/ /g,"+")}:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900`:""}&display=swap`})})},useChaiExternalData=()=>jotai.useAtom(chaiExternalDataAtom),useCanvasSettings=()=>jotai.useAtom(canvasSettingsAtom),isVisibleAtBreakpoint=(o,n)=>{const r=["xs","sm","md","lg","xl","2xl"],a=r.indexOf(n),i=o.split(" ");let l=new Array(r.length).fill(!1);for(const c of i){let[d,u]=c.split(":");u||(u=d,d="xs");const x=r.indexOf(d);if(x<=a){const m=["block","flex","inline","inline-block","inline-flex","grid","table"],h=["hidden"];if(m.includes(u))for(let p=x;p<r.length;p++)l[p]=!0;else if(h.includes(u))for(let p=x;p<r.length;p++)l[p]=!1}}return l[a]},rscBlocksStoreAtom=atom({}),rscBlocksLoadingStateAtom=atom({}),useRSCBlocksStore=()=>{const[o,n]=useAtom(rscBlocksStoreAtom),[r]=useAtom(rscBlocksLoadingStateAtom),a=React.useCallback(c=>lodashEs.get(o,c==null?void 0:c._id,null),[o]),i=React.useCallback(c=>lodashEs.get(r,`${c}`,{loading:!1,error:null}),[r]),l=React.useCallback(c=>{n(d=>({...d,[c]:""}))},[n]);return{getRSCBlockMarkup:a,getRSCBlockState:i,reset:l}},useWatchRSCBlocks=()=>{const[o]=useBlocksStore(),[n,r]=useAtom(rscBlocksStoreAtom),[a,i]=useAtom(rscBlocksLoadingStateAtom),l=runtime.useChaiBlocks(),c=useBuilderProp("getRSCBlock",async u=>""),d=React.useMemo(()=>o.filter(x=>{var h;return(h=lodashEs.get(l,x._type))==null?void 0:h.server}).map(x=>x._id),[l,o]);React.useEffect(()=>{lodashEs.forEach(d,u=>{if(lodashEs.get(n,u,"")||lodashEs.get(a,`${u}.loading`,!1))return;const x=o.find(m=>m._id===u);i(m=>({...m,[u]:{loading:!0,error:null}})),c(x).then(m=>{r(h=>({...h,[u]:m})),i(h=>({...h,[u]:{loading:!1,error:null}}))}).catch(m=>{i(h=>({...h,[u]:{loading:!1,error:m.message}}))})})},[o,c,n,d,a,r,i])},RSCBlock=({blockProps:o,block:n})=>{const{getRSCBlockMarkup:r,getRSCBlockState:a}=useRSCBlocksStore(),i=r(n),{loading:l,error:c}=a(n._id);return l?jsxRuntime.jsxRuntimeExports.jsx("div",{...o,className:"h-10 w-full",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-full w-full rounded-md border"})}):c?jsxRuntime.jsxRuntimeExports.jsxs("div",{...o,children:["Error: ",c]}):jsxRuntime.jsxRuntimeExports.jsx("div",{...o,dangerouslySetInnerHTML:{__html:i}})},generateClassNames=lodashEs.memoize(o=>{const n=o.replace(STRINGS.STYLES_KEY,"").split(",");return tailwindMerge.twMerge(n[0],n[1])});function getElementAttrs(o,n){return lodashEs.get(o,`${n}_attrs`,{})}function getStyleAttrs(o,n){const r={};return Object.keys(o).forEach(a=>{if(lodashEs.isString(o[a])&&o[a].startsWith(STRINGS.STYLES_KEY)){const i=generateClassNames(o[a]),l=getElementAttrs(o,a);r[a]={className:i,"data-style-prop":a,"data-block-parent":o._id,"data-style-id":`${a}-${o._id}`,...l};const c=lodashEs.has(l,"x-show")||lodashEs.has(l,"x-if");c&&(r.__isHidden=c&&!isVisibleAtBreakpoint(i,n))}}),r}function applyBindings(o,n){const r=lodashEs.get(o,"_bindings",{});return lodashEs.isEmpty(r)?{...o}:(lodashEs.each(r,(a,i)=>{lodashEs.isString(a)&&lodashEs.get(n,a,null)&&(o[i]=lodashEs.get(n,a,null))}),o)}function isDescendant(o,n,r){if(!lodashEs.find(r,{_id:o}))return!1;const i=lodashEs.filter(r,{_parent:o});return i.some(l=>l._id===n)?!0:i.some(l=>isDescendant(l._id,n,r))}const RenderGlobalBlock=({blocks:o,allBlocks:n})=>jsxRuntime.jsxRuntimeExports.jsx(BlocksRendererStatic,{allBlocks:n,blocks:o});function applyLanguage(o,n,r){if(lodashEs.isEmpty(n))return o;const a=lodashEs.cloneDeep(o);return lodashEs.forEach(lodashEs.keys(a),i=>{lodashEs.get(r,["props",i,"i18n"])&&!lodashEs.isEmpty(n)&&(a[i]=lodashEs.get(a,`${i}-${n}`,a[i]))}),a}function BlocksRendererStatic({blocks:o,allBlocks:n}){const{selectedLang:r}=useLanguages(),[a]=jotai.useAtom(xShowBlocksAtom),[i]=useCutBlockIds(),[l]=jotai.useAtom(draggedBlockAtom),[c]=jotai.useAtom(dropTargetBlockIdAtom),[,d]=useCanvasWidth(),[u]=useCanvasSettings(),[x]=useHiddenBlockIds(),{getGlobalBlocks:m}=useGlobalBlocksStore(),h=React.useCallback(j=>getStyleAttrs(j,d),[d]),[p]=useChaiExternalData(),[f]=jotai.useAtom(inlineEditingActiveAtom),R=React.useCallback(j=>j.reduce((E,y)=>{const v=lodashEs.get(u,y,{});return{...E,...v}},{}),[u]);return jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:React.Children.toArray(o.map((j,E)=>{if(f===j._id||x.includes(j._id))return null;const y={},v=lodashEs.filter(n,{_parent:j._id});if(y.children=v.length>0?jsxRuntime.jsxRuntimeExports.jsx(BlocksRendererStatic,{allBlocks:n,blocks:v}):null,j._type==="GlobalBlock"){const _=m(j);y.children=jsxRuntime.jsxRuntimeExports.jsx(RenderGlobalBlock,{blocks:lodashEs.filter(_,S=>!S._parent),allBlocks:_})}const w=runtime.getBlockComponent(j._type),k=lodashEs.get(w,"server",!1),C=k?RSCBlock:lodashEs.get(w,"builderComponent",lodashEs.get(w,"component",null));if(lodashEs.isNull(C))return jsxRuntime.jsxRuntimeExports.jsx("noscript",{children:`<!-- ${j==null?void 0:j._type} not registered -->`});const I=lodashEs.has(w,"getBlockStateFrom")?w==null?void 0:w.getBlockStateFrom(j,n):[],N=R(I),L=h(j);if(lodashEs.get(L,"__isHidden",!1)&&!lodashEs.includes(a,j._id))return null;const g=l&&isDescendant(l._id,j._id,n),b={...lodashEs.includes(a,j._id)?{"force-show":""}:{},"data-block-id":j._id,"data-block-type":j._type,...l?{"data-dnd":canAcceptChildBlock(j._type,l==null?void 0:l._type)?"yes":"no","data-dnd-dragged":l._id===j._id||g?"yes":"no"}:{},...c===j._id&&!g?{"data-drop":"yes"}:{},...lodashEs.includes(i,j._id)?{"data-cut-block":"yes"}:{}};return k?jsxRuntime.jsxRuntimeExports.jsx(RSCBlock,{block:j,blockProps:b}):jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{children:React.createElement(C,{blockProps:b,index:E,...applyBindings(applyLanguage(j,r,w),p),...lodashEs.omit(L,["__isHidden"]),...y,inBuilder:!0,blockState:N})})}))})}const useAllDataProviders=()=>React.useMemo(()=>runtime.getChaiDataProviders(),[]),BlocksExternalDataProvider=({children:o})=>{const[,n]=useChaiExternalData(),[r]=usePageDataProviders(),a=useAllDataProviders();return React.useEffect(()=>(n({}),lodashEs.each(r,i=>{const l=lodashEs.find(a,{providerKey:i.providerKey});if(l){const c=(l==null?void 0:l.mockFn)||(l==null?void 0:l.dataFn);c&&c(i.args).then(d=>n(u=>({...u,[i.providerKey]:d})))}}),()=>{lodashEs.each(r,i=>{n(l=>(delete l[i.providerKey],l))})}),[a,r,n]),jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:o})},StaticBlocksRenderer=()=>{const[o]=useBlocksStore(),n=lodashEs.isEmpty(o)?null:jsxRuntime.jsxRuntimeExports.jsx(BlocksExternalDataProvider,{children:jsxRuntime.jsxRuntimeExports.jsx(BlocksRendererStatic,{allBlocks:o,blocks:lodashEs.filter(o,r=>lodashEs.isEmpty(r._parent))})});return jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:n})},AddBlockAtBottom=()=>{const{t:o}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs("button",{onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK}),className:"mt-1 block w-full rounded-md bg-gray-100 p-2 text-black hover:bg-gray-200 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-700",children:["+ ",o("add_block")]})},ResizableCanvasWrapper=({children:o,onMount:n,onResize:r})=>{const[,a]=useSelectedBlockIds(),[,i]=useSelectedStylingBlocks(),l=React.useRef(null),c=web.useDebouncedCallback(()=>{const{clientWidth:u}=l.current;r(u)},[l.current],100);web.useResizeObserver(l.current,c,l.current!==null),React.useEffect(()=>{const{clientWidth:u}=l.current;n(u)},[]);const d=()=>{a([]),i([])};return jsxRuntime.jsxRuntimeExports.jsx("div",{id:"main-content",onClick:d,className:"h-full w-full p-8 pb-0",ref:l,children:o})},getElementByStyleId=(o,n)=>o.querySelector(`[data-style-id="${n}"]`),StaticCanvas=()=>{const[o]=jotai.useAtom(networkModeAtom),[n]=useCanvasWidth(),[,r]=useSelectedBlockIds(),a=useSelectedBlock(),[,i]=useHighlightBlockId(),l=React.useRef(null),c=React.useRef(null),[d,u]=React.useState({width:0,height:0}),x=useCanvasScale(d),[m,h]=React.useState([]),[,p]=React.useState([]),[,f]=jotai.useAtom(canvasIframeAtom),[R,j]=useSelectedStylingBlocks(),E=useBuilderProp("loading",!1),y=useBuilderProp("htmlDir","ltr"),v=C=>{u(I=>({...I,width:C}))};React.useEffect(()=>{if(!c.current)return;const{clientWidth:C,clientHeight:I}=c.current;u({width:C,height:I})},[c,n]);const w=(C,I=0)=>{const{top:N}=C.getBoundingClientRect();return N+I>=0&&N-I<=window.innerHeight};React.useEffect(()=>{var C,I;if(a&&a.type!=="Multiple"&&l.current){const N=getElementByDataBlockId(l.current.contentDocument,a._id);N&&(w(N)||(I=(C=l.current)==null?void 0:C.contentWindow)==null||I.scrollTo({top:N.offsetTop,behavior:"smooth"}),h([N]))}},[a]),React.useEffect(()=>{if(!lodashEs.isEmpty(R)&&l.current){const C=getElementByStyleId(l.current.contentDocument,lodashEs.first(R).id);p(C?[C]:[null])}else p([null])},[R]);const k=React.useMemo(()=>{let C=IframeInitialContent;return C=C.replace("__HTML_DIR__",y),o==="offline"&&(C=C.replace("https://old.chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js"),C=C.replace("https://unpkg.com/aos@next/dist/aos.css","/offline/aos.css"),C=C.replace("https://unpkg.com/aos@next/dist/aos.js","/offline/aos.js")),C},[o,y]);return jsxRuntime.jsxRuntimeExports.jsx(ResizableCanvasWrapper,{onMount:v,onResize:v,children:jsxRuntime.jsxRuntimeExports.jsx("div",{onClick:()=>{r([]),j([])},onMouseLeave:()=>setTimeout(()=>i(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:c,children:jsxRuntime.jsxRuntimeExports.jsxs(ChaiFrame,{contentDidMount:()=>f(l.current),ref:l,id:"canvas-iframe",style:{...x,...lodashEs.isEmpty(x)?{width:`${n}px`}:{}},className:"relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:k,children:[jsxRuntime.jsxRuntimeExports.jsx(KeyboardHandler,{}),jsxRuntime.jsxRuntimeExports.jsx(BlockActionsStatic,{block:a,selectedBlockElement:lodashEs.first(m)}),jsxRuntime.jsxRuntimeExports.jsx(HeadTags,{}),jsxRuntime.jsxRuntimeExports.jsx(reactWrapBalancer.Provider,{children:jsxRuntime.jsxRuntimeExports.jsxs(Canvas,{children:[E?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-full"})}):jsxRuntime.jsxRuntimeExports.jsx(StaticBlocksRenderer,{}),jsxRuntime.jsxRuntimeExports.jsx(AddBlockAtBottom,{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{})]})}),jsxRuntime.jsxRuntimeExports.jsx("div",{id:"placeholder",className:"pointer-events-none absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})})},StaticCanvas$1=StaticCanvas,FallbackError=()=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[jsxRuntime.jsxRuntimeExports.jsx("p",{className:"font-semibold",children:"Oops! Something went wrong."}),jsxRuntime.jsxRuntimeExports.jsx("p",{children:"Please try again."})]})}),TypeIcon=o=>{switch(o.type){case"GlobalBlock":return jsxRuntime.jsxRuntimeExports.jsx(lucideReact.GlobeIcon,{className:"h-4 w-4"});case"Image":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ImageIcon,{});case"Heading":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.HeadingIcon,{});case"Text":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TextIcon,{});case"Link":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Link1Icon,{});case"Video":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.VideoIcon,{});case"RichText":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CursorTextIcon,{});case"Button":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ButtonIcon,{});case"CustomHTML":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CodeIcon,{});case"Divider":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DividerHorizontalIcon,{});case"Icon":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.SketchLogoIcon,{});case"List":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RowsIcon,{});case"Paragraph":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TextIcon,{});case"Row":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RowsIcon,{});case"ListItem":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ColumnsIcon,{});case"LineBreak":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.SpaceBetweenVerticallyIcon,{});case"Form":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.GroupIcon,{});case"Checkbox":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CheckboxIcon,{});case"FormButton":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ButtonIcon,{});case"Input":case"TextArea":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.InputIcon,{});case"Radio":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RadiobuttonIcon,{});case"Select":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DropdownMenuIcon,{});case"Table":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TableIcon,{});case"TableHead":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BorderTopIcon,{});case"TableBody":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BorderAllIcon,{});case"TableRow":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ViewHorizontalIcon,{});case"TableCell":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DragHandleHorizontalIcon,{});case"DataProvider":return jsxRuntime.jsxRuntimeExports.jsx(lucideReact.DatabaseIcon,{size:16});case"Box":return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BoxIcon,{});default:return jsxRuntime.jsxRuntimeExports.jsx(reactIcons.BoxModelIcon,{})}},Breadcrumb=()=>{const o=useSelectedBlockHierarchy(),[,n]=useSelectedBlockIds(),{highlightBlock:r}=useBlockHighlight();return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mx-2 border-t border-border bg-background px-2 py-1 text-xs text-muted-foreground",children:jsxRuntime.jsxRuntimeExports.jsxs("ol",{className:"flex items-center whitespace-nowrap",children:[jsxRuntime.jsxRuntimeExports.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{onClick:()=>n([]),variant:"ghost",className:"h-fit p-1 text-xs font-normal",children:"Body"}),jsxRuntime.jsxRuntimeExports.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]}),lodashEs.reverse(o).map((a,i)=>jsxRuntime.jsxRuntimeExports.jsxs("li",{className:"inline-flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{onMouseEnter:()=>{r(a==null?void 0:a._id)},onClick:()=>n([a==null?void 0:a._id]),variant:"ghost",className:"h-fit gap-x-1 p-1 text-xs font-normal",children:[jsxRuntime.jsxRuntimeExports.jsx(TypeIcon,{type:a==null?void 0:a._type}),a._name||a._type]}),i!==o.length-1&&jsxRuntime.jsxRuntimeExports.jsx(lucideReact.ChevronRight,{className:"rtl:rotate-180",size:16})]},i))]})})},CodeEditor$1=React.lazy(()=>Promise.resolve().then(()=>require("./CodeEditor-CLZUUbGV.cjs"))),CanvasArea=()=>{const[o]=useCodeEditor(),n=useBuilderProp("onError",lodashEs.noop);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2",children:[jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-full"}),children:jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:n,children:jsxRuntime.jsxRuntimeExports.jsx(StaticCanvas$1,{})})}),o?jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-full"}),children:jsxRuntime.jsxRuntimeExports.jsx(reResizable.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:jsxRuntime.jsxRuntimeExports.jsx(CodeEditor$1,{})})}):null,jsxRuntime.jsxRuntimeExports.jsx(Breadcrumb,{})]})})},CanvasArea$1=CanvasArea,ColorField=({value:o,onChange:n,id:r,onBlur:a})=>{const i=lodashEs.debounce(n,200),l=c=>i(c.target.value);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-1.5 flex items-center gap-x-3",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-3/5 flex-col",children:jsxRuntime.jsxRuntimeExports.jsx("input",{type:"color",className:"text-xs p-0",value:o,onBlur:({target:{value:c}})=>a(r,c),onChange:l})})})},FONTS=[{title:"Roboto",value:"Roboto"},{title:"Open Sans",value:"Open Sans"},{title:"Montserrat",value:"Montserrat"},{title:"Lato",value:"Lato"},{title:"Poppins",value:"Poppins"},{title:"Oswald",value:"Oswald"},{title:"Raleway",value:"Raleway"},{title:"Ubuntu",value:"Ubuntu"},{title:"Nunito",value:"Nunito"},{title:"Merriweather",value:"Merriweather"},{title:"Nunito Sans",value:"Nunito Sans"},{title:"Playfair Display",value:"Playfair Display"},{title:"Rubik",value:"Rubik"},{title:"Inter",value:"Inter"},{title:"Lora",value:"Lora"},{title:"Kanit",value:"Kanit"},{title:"Fira Sans",value:"Fira Sans"},{title:"Hind",value:"Hind"},{title:"Quicksand",value:"Quicksand"},{title:"Mulish",value:"Mulish"},{title:"Barlow",value:"Barlow"},{title:"Inconsolata",value:"Inconsolata"},{title:"Titillium Web",value:"Titillium Web"},{title:"Heebo",value:"Heebo"},{title:"IBM Plex Sans",value:"IBM Plex Sans"},{title:"DM Sans",value:"DM Sans"},{title:"Nanum Gothic",value:"Nanum Gothic"},{title:"Karla",value:"Karla"},{title:"Arimo",value:"Arimo"},{title:"Cabin",value:"Cabin"},{title:"Oxygen",value:"Oxygen"},{title:"Overpass",value:"Overpass"},{title:"Assistant",value:"Assistant"},{title:"Tajawal",value:"Tajawal"},{title:"Play",value:"Play"},{title:"Exo",value:"Exo"},{title:"Cinzel",value:"Cinzel"},{title:"Faustina",value:"Faustina"},{title:"Philosopher",value:"Philosopher"},{title:"Gelasio",value:"Gelasio"},{title:"Sofia Sans Condensed",value:"Sofia Sans Condensed"},{title:"Noto Sans Devanagari",value:"Noto Sans Devanagari"},{title:"Actor",value:"Actor"},{title:"Epilogue",value:"Epilogue"},{title:"Glegoo",value:"Glegoo"},{title:"Overlock",value:"Overlock"},{title:"Lustria",value:"Lustria"},{title:"Ovo",value:"Ovo"},{title:"Suranna",value:"Suranna"},{title:"Bebas Neue",value:"Bebas Neue"},{title:"Manrope",value:"Manrope"}],ThemeConfigPanel=({showHeading:o=!0,className:n=""})=>{const[r,a]=useBrandingOptions(),[i]=useBlocksContainer(),l=React__namespace.useRef(r),{t:c}=reactI18next.useTranslation(),d=({formData:k},C)=>{C&&(a(k),l.current=k)},{bodyFont:u,headingFont:x,primaryColor:m,bodyTextDarkColor:h,bodyTextLightColor:p,bodyBgDarkColor:f,secondaryColor:R,bodyBgLightColor:j,roundedCorners:E}=r;let y={headingFont:controls.y({title:c("theme_config.heading_font"),default:x,options:FONTS}),bodyFont:controls.y({title:c("theme_config.body_font"),default:u,options:FONTS}),roundedCorners:controls.s({title:c("theme_config.rounded_corner"),default:parseInt(E||5,10)}),primaryColor:controls.h({title:c("theme_config.primary"),default:m}),secondaryColor:controls.h({title:c("theme_config.secondary"),default:R})};i||(y={...y,bodyBgLightColor:controls.h({title:c("theme_config.background"),default:j}),bodyTextLightColor:controls.h({title:c("theme_config.text_color"),default:h}),bodyBgDarkColor:controls.h({title:c("theme_config.background_dark_mode"),default:f}),bodyTextDarkColor:controls.h({title:c("theme_config.text_color_dark_mode"),default:p})});const v={type:"object",properties:{}},w={};return Object.keys(y).forEach(k=>{const C=y[k];return v.properties||(v.properties={}),v.properties[k]=C.schema,w[k]=C.uiSchema,!0}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:iconBase.cn("flex h-full w-full select-none flex-col",n),children:[o?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-background/30 p-1",children:jsxRuntime.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:c("Theme Configuration")})}):null,jsxRuntime.jsxRuntimeExports.jsx(Form,{widgets:{color:ColorField},idSeparator:".",autoComplete:"off",omitExtraData:!0,liveOmit:!0,liveValidate:!0,uiSchema:w,schema:v,formData:r,validator,onChange:d})]})},ThemeOptions=ThemeConfigPanel,placeholderStyle={display:"flex",alignItems:"center",zIndex:1},DefaultCursor=React.memo(function({top:n,left:r}){const a={position:"absolute",pointerEvents:"none",top:n+"px",left:r+"px",right:0};return jsxRuntime.jsxRuntimeExports.jsx("div",{style:{...placeholderStyle,...a},children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-0.5 flex-1 rounded-[1px] bg-green-500"})})}),Overlay=React.memo(function({children:n,isDragging:r}){return r?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"pointer-events-none fixed left-0 top-0 z-[100] h-full w-full",children:n}):null}),DefaultDragPreview=React.memo(({id:o,isDragging:n,mouse:r})=>{const[a]=useBlocksStore(),i=React.useMemo(()=>a.find(c=>c._id===o),[a,o]),l=React.useMemo(()=>({transform:`translate(${(r==null?void 0:r.x)-10}px, ${(r==null?void 0:r.y)-10}px)`}),[r]);return r?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx(Overlay,{isDragging:n,children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"pointer-events-none absolute z-50 rounded border border-border bg-gray-100/80 font-semibold text-blue-600 shadow-md dark:border-gray-700 dark:bg-gray-800",style:l,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{type:"button",className:"flex !cursor-grab items-center p-0.5","aria-label":`Type: ${i==null?void 0:i._type}`,children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mt-0.5 h-3 w-3",children:jsxRuntime.jsxRuntimeExports.jsx(TypeIcon,{type:i==null?void 0:i._type})}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"ml-2 truncate text-[11px]",children:(i==null?void 0:i._name)||(i==null?void 0:i._type)})]})})})}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"hidden"})}),CopyPasteBlocks=()=>{const[o]=useSelectedBlockIds(),{canPaste:n,pasteBlocks:r}=usePasteBlocks(),[,a]=useCopyBlockIds(),{t:i}=reactI18next.useTranslation(),l=useSelectedBlock();return jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{disabled:!canDuplicateBlock(l==null?void 0:l._type),onClick:()=>a(o),className:"flex items-center gap-x-4 text-xs",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CopyIcon,{})," Copy"]}),n(o[0])&&jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{className:"flex items-center gap-x-4 text-xs",onClick:()=>{r(o)},children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CardStackIcon,{})," ",i("Paste")]})]})},CutBlocks=()=>{const[o]=useSelectedBlockIds(),[,n]=useCutBlockIds(),{t:r}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{className:"flex items-center gap-x-4 text-xs",onClick:()=>n(o),children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ScissorsIcon,{})," ",r("Cut")]})},RemoveBlocks=()=>{const[o]=useSelectedBlockIds(),n=useRemoveBlocks(),r=useSelectedBlock(),{t:a}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{disabled:!canDeleteBlock(r==null?void 0:r._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>n(o),children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TrashIcon,{})," ",a("Remove")]})},BlockContextMenuContent=()=>{const{t:o}=reactI18next.useTranslation(),[n]=useSelectedBlockIds(),r=useDuplicateBlocks(),a=useSelectedBlock(),i=React.useCallback(()=>{r(n)},[n,r]);return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuContent,{className:"border-border text-xs",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{disabled:!canAddChildBlock(a==null?void 0:a._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,data:a}),children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.PlusIcon,{size:"14"})," ",o("Add block")]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenuItem,{disabled:!canDuplicateBlock(a==null?void 0:a._type),className:"flex items-center gap-x-4 text-xs",onClick:i,children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CardStackPlusIcon,{})," ",o("Duplicate")]}),jsxRuntime.jsxRuntimeExports.jsx(CutBlocks,{}),jsxRuntime.jsxRuntimeExports.jsx(CopyPasteBlocks,{}),jsxRuntime.jsxRuntimeExports.jsx(RemoveBlocks,{})]})},BlockContextMenu=({children:o})=>jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ContextMenu,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.ContextMenuTrigger,{asChild:!0,children:o}),jsxRuntime.jsxRuntimeExports.jsx(BlockContextMenuContent,{})]})}),defaultShortcuts=[{key:"ArrowDown",command:"selectNext"},{key:"ArrowUp",command:"selectPrev"},{key:"ArrowLeft",command:"selectParent",when:"isLeaf || isClosed"},{key:"ArrowLeft",command:"close",when:"isOpen"},{key:"ArrowRight",command:"open",when:"isClosed"},{key:"ArrowRight",command:"selectNext",when:"isOpen"},{key:"Home",command:"selectFirst"},{key:"End",command:"selectLast"}];function selectFirst(o){o.firstNode&&o.select(o.firstNode.id)}function selectLast(o){o.lastNode&&o.select(o.lastNode.id)}function selectNext(o){const n=o.selectedNodes[0].next||o.firstNode;o.select(n.id)}function selectPrev(o){const n=o.selectedNodes[0].prev||o.lastNode;o.select(n.id)}const selectParent=(o,n)=>{var a;const r=((a=o.selectedIds[0])==null?void 0:a.parent)||null;r&&n&&o.select(r.id)},open=(o,n)=>{const r=o.selectedNodes[0];r.isInternal&&n&&r.open()},close=(o,n)=>{const r=o.selectedNodes[0];r.isInternal&&n&&r.close()};function VscJson(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.2 0-.387-.038-.563-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.502 1.502 0 0 1 .765-.787 1.38 1.38 0 0 1 .558-.115H14v-.984h-.09c-.196 0-.381-.04-.557-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.415 1.415 0 0 1-.307-.465v-.002a1.405 1.405 0 0 1-.118-.566c0-.29.006-.58.018-.869a6.174 6.174 0 0 0-.024-.87v-.001a3.537 3.537 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.331 2.331 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .387.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.285 2.285 0 0 0 .738.955 2.285 2.285 0 0 0-.738.955 2.689 2.689 0 0 0-.168.602c-.033.21-.051.423-.055.64a9.15 9.15 0 0 0 0 .666c.008.224.012.45.012.678a1.471 1.471 0 0 1-.877 1.354 1.33 1.33 0 0 1-.563.121H10z"},child:[]}]})(o)}function BsLightningFill(o){return iconBase.GenIcon({tag:"svg",attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M5.52.359A.5.5 0 0 1 6 0h4a.5.5 0 0 1 .474.658L8.694 6H12.5a.5.5 0 0 1 .395.807l-7 9a.5.5 0 0 1-.873-.454L6.823 9.5H3.5a.5.5 0 0 1-.48-.641z"},child:[]}]})(o)}function TbEyeDown(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"},child:[]},{tag:"path",attr:{d:"M12 18c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"},child:[]},{tag:"path",attr:{d:"M19 16v6"},child:[]},{tag:"path",attr:{d:"M22 19l-3 3l-3 -3"},child:[]}]})(o)}function BiCollapseVertical(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M12 7.59 7.05 2.64 5.64 4.05 12 10.41l6.36-6.36-1.41-1.41L12 7.59zM5.64 19.95l1.41 1.41L12 16.41l4.95 4.95 1.41-1.41L12 13.59l-6.36 6.36z"},child:[]}]})(o)}function BiExpandVertical(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"m12 19.24-4.95-4.95-1.41 1.42L12 22.07l6.36-6.36-1.41-1.42L12 19.24zM5.64 8.29l1.41 1.42L12 4.76l4.95 4.95 1.41-1.42L12 1.93 5.64 8.29z"},child:[]}]})(o)}const Node=React.memo(({node:o,style:n,dragHandle:r})=>{const a=useBuilderProp("outlineMenuItems",[]),{t:i}=reactI18next.useTranslation(),[l,,c]=useHiddenBlockIds(),[d]=jotai.useAtom(canvasIframeAtom);let u=null;const x=o.children.length>0,{highlightBlock:m,clearHighlight:h}=useBlockHighlight(),{id:p,data:f,isSelected:R,willReceiveDrop:j,isDragging:E,isEditing:y,handleClick:v}=o,w=g=>{g.stopPropagation(),!l.includes(p)&&o.toggle()},k=g=>{g.isInternal&&(u=g.isOpen,g.isOpen&&g.close())},C=g=>{g.isInternal&&u!==null&&(u?g.open():g.close(),u=null)},I=g=>{g.stopPropagation(),!o.isOpen&&!l.includes(p)&&o.toggle(),v(g)};React.useEffect(()=>{const g=setTimeout(()=>{j&&!o.isOpen&&!E&&!l.includes(p)&&o.toggle()},500);return()=>clearTimeout(g)},[j,o,E]);const N=React.useMemo(()=>{const g=Object.keys(f),b=[];for(let _=0;_<g.length;_++)if(g[_].endsWith("_attrs")){const S=f[g[_]],B=Object.keys(S).join("|");B.match(/x-data/)&&b.push("data"),B.match(/x-on/)&&b.push("event"),B.match(/x-show|x-if/)&&b.push("show")}return b},[f]),L=(g,b)=>{const _=d.contentDocument||d.contentWindow.document,S=_.querySelector(`[data-block-id=${g}]`);S&&S.setAttribute("data-drop",b);const B=S.getBoundingClientRect(),A=d.getBoundingClientRect();B.top>=A.top&&B.left>=A.left&&B.bottom<=A.bottom&&B.right<=A.right||(_.documentElement.scrollTop=S.offsetTop-A.top)};return p===STRINGS.ROOT_TEMP_KEY?jsxRuntime.jsxRuntimeExports.jsxs("button",{onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK}),className:"mb-10 mt-5 w-full rounded bg-gray-100 p-1 hover:bg-gray-200 dark:bg-gray-800",children:["+ ",i("add_block")]}):jsxRuntime.jsxRuntimeExports.jsx(BlockContextMenu,{id:p,children:jsxRuntime.jsxRuntimeExports.jsxs("div",{onMouseEnter:()=>m(p),onMouseLeave:()=>h(),onClick:I,style:n,"data-node-id":p,ref:l.includes(p)?null:r,onDragStart:()=>k(o),onDragEnd:()=>C(o),onDragOver:g=>{g.preventDefault(),L(p,"yes")},onDragLeave:g=>{g.preventDefault(),L(p,"no")},onDrop:g=>{g.preventDefault(),L(p,"no")},className:iconBase.cn("group flex !h-full w-full items-center justify-between space-x-px !rounded py-px text-foreground/80 outline-none",R?"bg-blue-500 text-white":"hover:bg-gray-200 dark:hover:bg-gray-800",j&&canAcceptChildBlock(f._type,"Icon")?"bg-green-200":"",E&&"opacity-20",l.includes(p)?"opacity-50":""),children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:`flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center text-xs transition-transform duration-100 ${o.isOpen?"rotate-90":""}`,children:x&&jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:w,type:"button",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TriangleRightIcon,{})})}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mt-0.5 h-3 w-3",children:jsxRuntime.jsxRuntimeExports.jsx(TypeIcon,{type:f==null?void 0:f._type})}),y?jsxRuntime.jsxRuntimeExports.jsx(Input,{node:o}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"ml-2 flex items-center gap-x-1 truncate text-[11px]",onDoubleClick:g=>{g.stopPropagation(),o.edit(),o.deselect()},children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:(f==null?void 0:f._name)||(f==null?void 0:f._type.split("/").pop())}),N.includes("data")&&jsxRuntime.jsxRuntimeExports.jsx(VscJson,{className:"h-3 w-3 text-orange-600"}),N.includes("event")&&jsxRuntime.jsxRuntimeExports.jsx(BsLightningFill,{className:"h-3 w-3 text-yellow-500"}),N.includes("show")&&jsxRuntime.jsxRuntimeExports.jsx(TbEyeDown,{className:"h-3 w-3 text-orange-600"})]})]})]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"invisible flex items-center space-x-1 pr-2 group-hover:visible",children:[!l.includes(p)&&a.map(g=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{className:"cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",asChild:!0,children:React.createElement(g.item,{blockId:p})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-10",children:g.tooltip})]})),canAddChildBlock(f==null?void 0:f._type)&&!l.includes(p)?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK,data:{_id:p}}),className:"cursor-pointer rounded bg-transparent hover:bg-white hover:text-black",asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.PlusIcon,{size:"18"})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:i("Add block")})]}):null,jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{onClick:g=>{g.stopPropagation(),c(p),o.isOpen&&o.toggle()},className:"cursor-pointer rounded bg-transparent hover:bg-white hover:text-black",asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.EyeOff,{size:"15"})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:i("Add block")})]})]})]})})}),Input=({node:o})=>{var n,r;return jsxRuntime.jsxRuntimeExports.jsx("input",{autoFocus:!0,className:"ml-2 !h-4 w-full rounded-sm border border-border bg-background px-1 text-[11px] outline-none",type:"text",defaultValue:((n=o.data)==null?void 0:n._name)||((r=o.data)==null?void 0:r._type),onFocus:a=>a.currentTarget.select(),onBlur:a=>o.submit(a.currentTarget.value),onKeyDown:a=>{a.key==="Enter"&&o.submit(a.currentTarget.value)}})},useCanMove=()=>{const[o]=useBlocksStore();return(n,r)=>{var l;const a=(l=lodashEs.find(o,{_id:r}))==null?void 0:l._type,i=lodashEs.first(n.map(c=>{var d;return(d=lodashEs.find(o,{_id:c}))==null?void 0:d._type}));return canAcceptChildBlock(a,i)}},ListTree=()=>{const[treeData]=jotai.useAtom(treeDSBlocks),[ids,setIds]=useSelectedBlockIds(),[cutBlocksIds]=useCutBlockIds(),[,setHiddenBlocks]=useHiddenBlockIds(),updateBlockProps=useUpdateBlocksProps(),[,setStyleBlocks]=useSelectedStylingBlocks(),{moveBlocks}=useBlocksStoreUndoableActions(),canMove=useCanMove(),treeRef=React.useRef(null),[,setTreeRef]=jotai.useAtom(treeRefAtom),{t}=reactI18next.useTranslation(),clearSelection=()=>{setIds([]),setStyleBlocks([])},filteredTreeData=React.useMemo(()=>{const o=(r,a)=>r.filter(i=>!a.includes(i._id)).map(i=>({...i,children:i.children?o(i.children,a):[]}));return[...o(treeData,cutBlocksIds),{_type:STRINGS.ROOT_TEMP_KEY,_id:STRINGS.ROOT_TEMP_KEY,children:[]}]},[treeData,cutBlocksIds]);React.useEffect(()=>{setTreeRef(treeRef.current)},[setTreeRef,treeRef]);const onRename=({id:o,name:n,node:r})=>{updateBlockProps([o],{_name:n},r.data._name)},onMove=({dragIds:o,parentId:n,index:r})=>{canMove(o,n)&&moveBlocks(o,n,r)},onSelect=o=>{if(o.length===0)return;const n=o[0]?o[0].id:"";setStyleBlocks([]),setIds([n])},onContextMenu=o=>{var a;o.preventDefault();const n=o.target,r=n.getAttribute("data-node-id")||((a=n.closest("[data-node-id]"))==null?void 0:a.getAttribute("data-node-id"));r&&(setStyleBlocks([]),setIds([r]))},debouncedDisableDrop=web.useDebouncedCallback(({parentNode:o,dragNodes:n})=>{var r;return(o==null?void 0:o.data._type)===STRINGS.ROOT_TEMP_KEY||!canAcceptChildBlock(o==null?void 0:o.data._type,(r=n[0])==null?void 0:r.data._type)},[],300),handleKeyDown=e=>{if(!treeRef.current)return;const tree=treeRef.current,selectedNode=tree.selectedNodes[0];if(!selectedNode)return;setIds[selectedNode.id],setStyleBlocks([]);const isLeaf=!selectedNode.isInternal,isClosed=!selectedNode.isOpen,isOpen=selectedNode.isOpen,shortcut=defaultShortcuts.find(s=>s.key===e.key&&(!s.when||eval(s.when)));if(shortcut)switch(e.preventDefault(),shortcut.command){case"selectNext":selectNext(tree);break;case"selectPrev":selectPrev(tree);break;case"selectParent":selectParent(tree,isLeaf||isClosed);break;case"close":close(tree,isOpen);break;case"open":open(tree,isClosed);break;case"selectFirst":selectFirst(tree);break;case"selectLast":selectLast(tree);break}};return lodashEs.isEmpty(treeData)?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-10 flex h-full w-full items-center justify-center p-8 text-center",children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1.5 text-sm text-gray-400",children:[t("This page is empty"),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{onClick:()=>emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK}),variant:"default",size:"sm",children:["+ ",t("Add Block")]})]})})}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:iconBase.cn("flex h-full select-none flex-col space-y-1"),onClick:()=>clearSelection(),children:jsxRuntime.jsxRuntimeExports.jsxs("div",{id:"outline-view",className:"no-scrollbar h-full overflow-y-auto text-xs",onKeyDown:o=>{treeRef.current.isEditing||handleKeyDown(o)},children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mb-2 flex items-center justify-end gap-x-2 pb-2 text-xs text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{onClick:()=>setHiddenBlocks([]),variant:"outline",className:"h-fit p-1 disabled:cursor-not-allowed disabled:opacity-50",size:"sm",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.EyeOpenIcon,{className:"h-4 w-4"})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:t("Show hidden blocks")})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{className:"h-fit p-1",onClick:()=>{var o;return(o=treeRef==null?void 0:treeRef.current)==null?void 0:o.openAll()},variant:"outline",size:"sm",children:jsxRuntime.jsxRuntimeExports.jsx(BiExpandVertical,{size:"14"})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:t("Expand all")})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{className:"h-fit p-1",onClick:()=>{var o;return(o=treeRef==null?void 0:treeRef.current)==null?void 0:o.closeAll()},variant:"outline",size:"sm",children:jsxRuntime.jsxRuntimeExports.jsx(BiCollapseVertical,{size:"14"})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"isolate z-[9999]",children:t("Collapse all")})]})]}),jsxRuntime.jsxRuntimeExports.jsx(reactArborist.Tree,{ref:treeRef,height:window.innerHeight-160,className:"no-scrollbar !h-full max-w-full !overflow-y-auto !overflow-x-hidden",selection:ids[0]||"",onRename,openByDefault:!1,onMove,rowHeight:25,data:[...filteredTreeData],renderCursor:DefaultCursor,onSelect,childrenAccessor:o=>o.children,width:"100%",renderDragPreview:DefaultDragPreview,indent:10,onContextMenu,disableDrop:debouncedDisableDrop,idAccessor:"_id",children:Node})]})})},Outline$1=ListTree,hasVideoEmbed=o=>{const n=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,r=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return n.test(o)||r.test(o)},getVideoURLFromHTML=o=>{if(lodashEs.isEmpty(o))return o;const n=/<video[^>]+src=['"]([^'">]+)['"]/,r=/<iframe[^>]+src=['"]([^'">]+)['"]/,a=o.match(n),i=o.match(r),l=a?a[1]:i?i[1]:null,c=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,d=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return l&&(c.test(l)||d.test(l))?l:o},NAME_ATTRIBUTES=["chai-name","data-chai-name"],ATTRIBUTE_MAP={img:{alt:"alt",width:"width",height:"height",src:"image"},video:{src:"url",autoplay:"controls.autoPlay",muted:"controls.muted",loop:"controls.loop",controls:"controls.widgets"},a:{href:"link.href",target:"link.target",type:""},input:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},textarea:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},select:{placeholder:"placeholder",required:"required",multiple:"multiple",name:"fieldName"}},shouldAddText=(o,n)=>o.children.length===1&&lodashEs.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link","RichText"],n._type),getTextContent=o=>o.map(n=>n.type==="text"?lodashEs.get(n,"content",""):lodashEs.isEmpty(n.children)?"":getTextContent(n.children)).join(""),getSanitizedValue=o=>o===null?"":o,getAttrs=o=>{if(o.tagName==="svg")return{};const n={},r=ATTRIBUTE_MAP[o.tagName]||{},a=o.attributes;return lodashEs.forEach(a,({key:i,value:l})=>{if(!lodashEs.includes(NAME_ATTRIBUTES,i))if(r[i]){if(o.tagName==="img"&&i==="src"&&!l.startsWith("http")){const c=lodashEs.find(o.attributes,{key:"width"}),d=lodashEs.find(o.attributes,{key:"height"});c&&d?l=`https://via.placeholder.com/${c==null?void 0:c.value}x${d==null?void 0:d.value}`:l="https://via.placeholder.com/150x150"}lodashEs.set(n,r[i],getSanitizedValue(l))}else lodashEs.includes(["style","class","srcset"],i)||(lodashEs.has(n,"styles_attrs")||(n.styles_attrs={}),lodashEs.startsWith(i,"@")&&(i=i.replace("@","x-on:")),n.styles_attrs[`${i}`]=getSanitizedValue(l))}),delete n.class,n},getStyles=(o,n="styles")=>{if(!o.attributes)return{[n]:`${STRINGS.STYLES_KEY},`};const r=lodashEs.find(o.attributes,{key:"class"});if(r){const a=r.value;return{[n]:`${STRINGS.STYLES_KEY},${a}`}}return{[n]:`${STRINGS.STYLES_KEY},`}},getBlockProps=o=>{const n=lodashEs.get(o,"attributes",[]),r=n.find(i=>i.key==="data-chai-richtext"||i.key==="chai-richtext"),a=n.find(i=>i.key==="data-chai-lightbox"||i.key==="chai-lightbox");if(r)return{_type:"RichText"};if(a)return{_type:"LightBoxLink"};switch(o.tagName){case"img":return{_type:"Image"};case"input":return{_type:"Input",showLabel:!1};case"hr":return{_type:"Divider"};case"br":return{_type:"LineBreak"};case"textarea":return{_type:"TextArea",showLabel:!1};case"audio":return{_type:"Audio"};case"canvas":return{_type:"Canvas"};case"video":case"iframe":return{_type:"CustomHTML"};case"svg":return{_type:"Icon"};case"select":return{_type:"Select",options:[]};case"option":return{_type:"Option"};case"ul":case"ol":case"dl":return{_type:"List",tag:o.tagName,_listType:o.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:o.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:o.tagName};case"p":return{_type:"Paragraph",content:""};case"a":return{_type:"Link"};case"form":return{_type:"Form"};case"label":return{_type:"Label"};case"button":return{_type:"Button"};case"code":return{_type:"Code"};case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return{_type:"Heading",tag:o.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:o.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:{const i=lodashEs.get(o,"children",[]).length>0?"Box":"EmptyBox";return{_type:i,tag:o.tagName,_name:i=="EmptyBox"||o.tagName==="div"?i:lodashEs.capitalize(o.tagName)}}}},traverseNodes=(o,n=null)=>lodashEs.flatMapDeep(o,r=>{var u,x,m,h,p,f,R,j;if(r.type==="comment")return[];let a={_id:iconBase.generateUUID()};if(n&&(a._parent=n.block._id),r.type==="text")return lodashEs.isEmpty(lodashEs.get(r,"content",""))?[]:n&&shouldAddText(n.node,n.block)?(lodashEs.set(n,"block.content",lodashEs.get(r,"content","")),[]):{...a,_type:"Text",content:lodashEs.get(r,"content","")};const i=lodashEs.get(r,"attributes",[]),l=i.find(E=>E.key==="data-chai-richtext"||E.key==="chai-richtext"),c=i.find(E=>E.key==="data-chai-lightbox"||E.key==="chai-lightbox");if(a={...a,...getBlockProps(r),...getAttrs(r),...getStyles(r)},r.attributes){const E=r.attributes.find(y=>lodashEs.includes(NAME_ATTRIBUTES,y.key));E&&(a._name=E.value)}if(l)return a.content=himalaya.stringify(r.children),lodashEs.has(a,"styles_attrs.data-chai-richtext")&&delete a.styles_attrs["data-chai-richtext"],lodashEs.has(a,"styles_attrs.chai-richtext")&&delete a.styles_attrs["chai-richtext"],[a];if(c){const E=["data-chai-lightbox","chai-lightbox","data-vbtype","data-autoplay","data-maxwidth","data-overlay","data-gall","href"];a={...a,href:((u=i.find(y=>y.key==="href"))==null?void 0:u.value)||"",hrefType:((x=i.find(y=>y.key==="data-vbtype"))==null?void 0:x.value)||"video",autoplay:((m=i.find(y=>y.key==="data-autoplay"))==null?void 0:m.value)==="true",maxWidth:((p=(h=i.find(y=>y.key==="data-maxwidth"))==null?void 0:h.value)==null?void 0:p.replace("px",""))||"",backdropColor:((f=i.find(y=>y.key==="data-overlay"))==null?void 0:f.value)||"",galleryName:((R=i.find(y=>y.key==="data-gall"))==null?void 0:R.value)||""},lodashEs.forEach(E,y=>{lodashEs.has(a,`styles_attrs.${y}`)&&delete a.styles_attrs[y]})}if(a._type==="Input"){const E=a.inputType||"text";E==="checkbox"?lodashEs.set(a,"_type","Checkbox"):E==="radio"&&lodashEs.set(a,"_type","Radio")}else if(r.tagName==="video"||r.tagName==="iframe"){const E=himalaya.stringify([r]);return hasVideoEmbed(E)&&(lodashEs.set(a,"_type","Video"),lodashEs.set(a,"url",getVideoURLFromHTML(E)),lodashEs.set(a,"styles",`${STRINGS.STYLES_KEY},absolute top-0 left-0 w-full h-full`),lodashEs.set(a,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),a.content=E,[a]}else if(r.tagName==="svg"){const E=lodashEs.find(r.attributes,{key:"height"}),y=lodashEs.find(r.attributes,{key:"width"}),v=lodashEs.get(E,"value")?`[${lodashEs.get(E,"value")}px]`:"24px",w=lodashEs.get(y,"value")?`[${lodashEs.get(y,"value")}px]`:"24px",k=lodashEs.get(lodashEs.find(r.attributes,{key:"class"}),"value","w-full h-full");return a.styles=`${STRINGS.STYLES_KEY}, ${iconBase.cn(`w-${w} h-${v}`,k)}`.trim(),r.attributes=lodashEs.filter(r.attributes,C=>!lodashEs.includes(["style","width","height","class"],C.key)),a.icon=himalaya.stringify([r]),[a]}else if(r.tagName=="option"&&n&&((j=n.block)==null?void 0:j._type)==="Select")return n.block.options.push({label:getTextContent(r.children),...getAttrs(r)}),[];const d=traverseNodes(r.children,{block:a,node:r});return[a,...d]}),getSanitizedHTML=o=>{const n=o.match(/<body[^>]*>[\s\S]*?<\/body>/);return(n&&n.length>0?n[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):o).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},getBlocksFromHTML=o=>{const n=himalaya.parse(getSanitizedHTML(o));return lodashEs.isEmpty(o)?[]:lodashEs.flatten(traverseNodes(n))},ImportHTML=({parentId:o})=>{const{t:n}=reactI18next.useTranslation(),[r,a]=React.useState(""),{addPredefinedBlock:i}=useAddBlock(),l=()=>{const c=getBlocksFromHTML(r);i([...c],o),a(""),emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK})};return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Card,{className:"border-border/0 p-0 shadow-none",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CardHeader,{className:"p-3",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CardDescription,{children:n("html_snippet_description")})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CardContent,{className:"space-y-2 px-3 py-0",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Label,{htmlFor:"current",className:"text-sm",children:n("tailwind_html_snippet")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{autoFocus:!0,tabIndex:1,ref:c=>c&&c.focus(),onChange:c=>a(c.target.value),rows:12,value:r,placeholder:n("enter_code_snippet"),className:"resize-none overflow-x-auto whitespace-pre bg-background font-mono text-xs font-normal"})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CardFooter,{className:"flex flex-col justify-end p-3",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:r.trim()==="",onClick:()=>l(),size:"sm",className:"w-fit",children:n("Import HTML")})})]})},ImportHTML$1=ImportHTML,isBoolean=o=>typeof o=="boolean"||o instanceof Boolean,isNumber=o=>typeof o=="number"||o instanceof Number,isBigInt=o=>typeof o=="bigint"||o instanceof BigInt,isDate=o=>!!o&&o instanceof Date,isString=o=>typeof o=="string"||o instanceof String,isArray=o=>Array.isArray(o),isObject=o=>o instanceof Object&&o!==null;function useBool(o){const[n,r]=React.useState(o());return[n,()=>r(i=>!i),r]}let componentId=1;const generateNextId=()=>componentId++;function useComponentId(){const o=React.useRef();return o.current===void 0&&(o.current=`:jsnvw:${generateNextId()}:`),o.current}function ExpandableObject(o){let{field:n,value:r,data:a,lastElement:i,openBracket:l,closeBracket:c,level:d,style:u,shouldExpandNode:x,clickToExpandNode:m}=o;const h=React.useRef(!1),[p,f,R]=useBool(()=>x(d,r,n));React.useEffect(()=>{h.current?R(x(d,r,n)):h.current=!0},[x]);const j=p?u.collapseIcon:u.expandIcon,E=p?"collapse JSON":"expand JSON",y=useComponentId(),v=d+1,w=a.length-1,k=C=>{C.key===" "&&(C.preventDefault(),f())};return React.createElement("div",{className:u.basicChildStyle,role:"list"},React.createElement("span",{className:j,onClick:f,onKeyDown:k,role:"button",tabIndex:0,"aria-label":E,"aria-expanded":p,"aria-controls":p?y:void 0}),n&&(m?React.createElement("span",{className:u.clickableLabel,onClick:f,onKeyDown:k,role:"button",tabIndex:-1},n,":"):React.createElement("span",{className:u.label},n,":")),React.createElement("span",{className:u.punctuation},l),p?React.createElement("div",{id:y},a.map((C,I)=>React.createElement(DataRender,{key:C[0]||I,field:C[0],value:C[1],style:u,lastElement:I===w,level:v,shouldExpandNode:x,clickToExpandNode:m}))):React.createElement("span",{className:u.collapsedContent,onClick:f,onKeyDown:k,role:"button",tabIndex:-1,"aria-hidden":!0,"aria-label":E,"aria-expanded":p}),React.createElement("span",{className:u.punctuation},c),!i&&React.createElement("span",{className:u.punctuation},","))}function JsonObject(o){let{field:n,value:r,style:a,lastElement:i,shouldExpandNode:l,clickToExpandNode:c,level:d}=o;return ExpandableObject({field:n,value:r,lastElement:i||!1,level:d,openBracket:"{",closeBracket:"}",style:a,shouldExpandNode:l,clickToExpandNode:c,data:Object.keys(r).map(u=>[u,r[u]])})}function JsonArray(o){let{field:n,value:r,style:a,lastElement:i,level:l,shouldExpandNode:c,clickToExpandNode:d}=o;return ExpandableObject({field:n,value:r,lastElement:i||!1,level:l,openBracket:"[",closeBracket:"]",style:a,shouldExpandNode:c,clickToExpandNode:d,data:r.map(u=>[void 0,u])})}function JsonPrimitiveValue(o){let{field:n,value:r,style:a,lastElement:i}=o,l=r,c=a.otherValue;return r===null?(l="null",c=a.nullValue):r===void 0?(l="undefined",c=a.undefinedValue):isString(r)?(l=a.noQuotesForStringValues?r:`"${r}"`,c=a.stringValue):isBoolean(r)?(l=r?"true":"false",c=a.booleanValue):isNumber(r)?(l=r.toString(),c=a.numberValue):isBigInt(r)?(l=`${r.toString()}n`,c=a.numberValue):isDate(r)?l=r.toISOString():l=r.toString(),n===""&&(n='""'),React.createElement("div",{className:a.basicChildStyle,role:"listitem"},n&&React.createElement("span",{className:a.label},n,":"),React.createElement("span",{className:c},l),!i&&React.createElement("span",{className:a.punctuation},","))}function DataRender(o){const n=o.value;return isArray(n)?React.createElement(JsonArray,Object.assign({},o)):isObject(n)&&!isDate(n)?React.createElement(JsonObject,Object.assign({},o)):React.createElement(JsonPrimitiveValue,Object.assign({},o))}var styles={"container-base":"_GzYRV","punctuation-base":"_3eOF8",pointer:"_1MFti","expander-base":"_f10Tu _1MFti","expand-icon":"_1UmXx","collapse-icon":"_1LId0","collapsed-content-base":"_1pNG9 _1MFti","container-light":"_2IvMF _GzYRV","basic-element-style":"_2bkNM","label-light":"_1MGIk","clickable-label-light":"_2YKJg _1MGIk _1MFti","punctuation-light":"_3uHL6 _3eOF8","value-null-light":"_2T6PJ","value-undefined-light":"_1Gho6","value-string-light":"_vGjyY","value-number-light":"_1bQdo","value-boolean-light":"_3zQKs","value-other-light":"_1xvuR","collapse-icon-light":"_oLqym _f10Tu _1MFti _1LId0","expand-icon-light":"_2AXVT _f10Tu _1MFti _1UmXx","collapsed-content-light":"_2KJWg _1pNG9 _1MFti","container-dark":"_11RoI _GzYRV","expand-icon-dark":"_17H2C _f10Tu _1MFti _1UmXx","collapse-icon-dark":"_3QHg2 _f10Tu _1MFti _1LId0","collapsed-content-dark":"_3fDAz _1pNG9 _1MFti","label-dark":"_2bSDX","clickable-label-dark":"_1RQEj _2bSDX _1MFti","punctuation-dark":"_gsbQL _3eOF8","value-null-dark":"_LaAZe","value-undefined-dark":"_GTKgm","value-string-dark":"_Chy1W","value-number-dark":"_2bveF","value-boolean-dark":"_2vRm-","value-other-dark":"_1prJR"};const defaultStyles={container:styles["container-light"],basicChildStyle:styles["basic-element-style"],label:styles["label-light"],clickableLabel:styles["clickable-label-light"],nullValue:styles["value-null-light"],undefinedValue:styles["value-undefined-light"],stringValue:styles["value-string-light"],booleanValue:styles["value-boolean-light"],numberValue:styles["value-number-light"],otherValue:styles["value-other-light"],punctuation:styles["punctuation-light"],collapseIcon:styles["collapse-icon-light"],expandIcon:styles["expand-icon-light"],collapsedContent:styles["collapsed-content-light"],noQuotesForStringValues:!1},allExpanded=()=>!0,JsonView=o=>{let{data:n,style:r=defaultStyles,shouldExpandNode:a=allExpanded,clickToExpandNode:i=!1}=o;return React.createElement("div",{className:r.container},React.createElement(DataRender,{value:n,style:r,lastElement:!0,level:0,shouldExpandNode:a,clickToExpandNode:i}))};function getPathAndTypes(o){const n=[],r={};function a(i,l){lodashEs.forEach(l,(c,d)=>{const u=i?`${i}.${d}`:d,x=lodashEs.isArray(c)?"list":typeof c;n.push(u),r[u]=x==="string"?"text":x==="object"?"model":x,x==="object"&&!lodashEs.isArray(c)&&a(u,c)})}return a("",lodashEs.omit(o,["styles","_type","_id","_name","_bindings"])),{paths:n,pathsType:r}}const ViewData=({data:o,fullView:n})=>{const r=useBuilderProp("onError",lodashEs.noop);if(!o)return null;const a=typeof o;return n?typeof o=="object"?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-3"}),jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:r,children:jsxRuntime.jsxRuntimeExports.jsx(JsonView,{data:o,shouldExpandNode:allExpanded,style:{...defaultStyles,container:"max-h-[40vh] overflow-y-auto text-[12px] leading-[1.5] tracking-wide font-mono",stringValue:"text-orange-600",label:"text-green-900 font-semibold pr-1 tracking-wider"}})})]}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"max-h-36 w-full overflow-y-auto overflow-x-hidden text-[12px] leading-4 text-gray-800/50",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"font-medium text-gray-800/80",children:"Content: "}),o]}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-full overflow-hidden whitespace-nowrap text-[10px] leading-3 text-gray-800/50",children:lodashEs.truncate(a==="object"?JSON.stringify(o):o,{length:40})})},DataProvidersSuggester=({type:o,value:n="",setValue:r,data:a,onChange:i,dataType:l,appliedBindings:c})=>{const{paths:d,pathsType:u}=getPathAndTypes(a),x=o==="PROP"?runtime.getBlockComponent(a==null?void 0:a._type):{},m=o==="PROP",[h,p]=React.useState(!1),f=React.useMemo(()=>o==="PROP"?d.filter(R=>!lodashEs.includes(c,R)&&lodashEs.get(x,`props.${lodashEs.first(lodashEs.split(R,"."))}.binding`)):d.filter(R=>l===lodashEs.get(u,R,"")),[o,d,c,l,x]);return React.useEffect(()=>{n&&i(n)},[n,o]),jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-4",children:[jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:lodashEs.startCase(lodashEs.toLower(o))}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Popover,{open:h,onOpenChange:p,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"outline",size:"sm",className:` ${lodashEs.isEmpty(n)?"w-44 justify-center bg-blue-500 text-gray-100 hover:bg-blue-400 hover:text-white":"min-w-[350px] items-center justify-between"}`,children:n?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs("span",{className:"pr-8 text-sm",children:[m&&jsxRuntime.jsxRuntimeExports.jsx("span",{className:"mr-2 rounded-full bg-purple-100 px-2 py-0.5 text-[10px] text-purple-500",children:lodashEs.startCase(l)}),n]}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"cursor-pointer text-[9px] text-blue-400 underline hover:text-blue-700",children:"Change"})]}):jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:["+ Set ",lodashEs.startCase(lodashEs.toLower(o))]})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverContent,{className:"z-[999] min-w-[300px] p-0",side:"right",align:"start",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Command,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CommandInput,{placeholder:`Choose ${lodashEs.toLower(o)}...`}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.CommandList,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CommandEmpty,{children:"No results found."}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.CommandGroup,{children:lodashEs.map(f,R=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.CommandItem,{value:R,className:`cursor-pointer ${m?"flex items-center justify-between":"flex flex-col items-start justify-start"}`,onSelect:j=>{r(lodashEs.find(f,E=>E===j)||null),p(!1)},children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Check,{className:`h-4 w-4 text-green-500 ${n===R?"":"opacity-0"}`}),R]}),m?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"rounded-full bg-purple-100 px-2 py-0.5 text-[10px] text-purple-500",children:lodashEs.startCase(lodashEs.get(u,R,""))})}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"pl-6",children:jsxRuntime.jsxRuntimeExports.jsx(ViewData,{data:lodashEs.get(a,R)})})]},R))})]})]})})]})]}),!m&&!lodashEs.isEmpty(n)&&jsxRuntime.jsxRuntimeExports.jsx("div",{className:"pt-2",children:jsxRuntime.jsxRuntimeExports.jsx(ViewData,{data:lodashEs.get(a,n,""),fullView:!0})})]})},AddBindingModalContent=({appliedBindings:o=[],onAddBinding:n,editMode:r,item:a})=>{const[i,l]=React.useState(r?a.key:""),[c,d]=React.useState(r?a.value:""),u=useSelectedBlock(),[x]=useChaiExternalData(),m=React.useCallback((f,R)=>{if(lodashEs.isEmpty(f))return"";{const j=lodashEs.get(R==="PROP"?u:x,f,"");if(lodashEs.isArray(j))return"list";const E=typeof j;return E==="string"?"text":E==="object"?"model":E}},[u,x]),[h,p]=React.useState(r?m(a.key,"PROP"):"");return jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTitle,{children:"Add Data Binding"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogDescription,{className:"text-xs",children:"Add prop and path of binding. Click save when you're done."})]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex flex-col gap-1",children:[jsxRuntime.jsxRuntimeExports.jsx(DataProvidersSuggester,{type:"PROP",isDisabled:!1,placeholder:"Enter prop key",value:i,setValue:l,onChange:f=>{const R=m(f,"PROP");l(f),h!==R&&d(""),p(R)},data:u,dataType:h,appliedBindings:o}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-2"}),jsxRuntime.jsxRuntimeExports.jsx(DataProvidersSuggester,{type:"PATH",isDisabled:lodashEs.isEmpty(i),placeholder:"Enter data path",value:c,setValue:d,onChange:f=>{const R=m(f,"PATH");d(h===R?f:"")},data:x,dataType:h,appliedBindings:o})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogFooter,{children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{type:"submit",className:"mt-4",disabled:lodashEs.isEmpty(i)&&lodashEs.isEmpty(c),onClick:()=>n({key:i,value:c}),children:"Save"})})]})},AddBindingModal=({disabled:o,children:n,onAddBinding:r,appliedBindings:a,editMode:i=!0,item:l={}})=>{const[c,d]=React.useState(!1);return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Dialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTrigger,{disabled:o,asChild:!0,onClick:()=>d(!0),children:n}),c&&jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogContent,{children:jsxRuntime.jsxRuntimeExports.jsx(AddBindingModalContent,{item:l,editMode:i,appliedBindings:a,onAddBinding:u=>{r(u),d(!1)}})})]})},NewDataBindingPair=({item:o,onAddBinding:n,onRemove:r,selectedBlock:a,dataProvider:i,appliedBindings:l})=>{const[c,d]=React.useState("string"),u=(x,m)=>{if(lodashEs.isEmpty(x))return"";{const h=lodashEs.get(m==="PROP"?a:i,x,"");if(lodashEs.isArray(h))return"list";const p=typeof h;return p==="string"?"text":p==="object"?"model":p}};return React.useEffect(()=>d(()=>u(o.key,"PROP")),[o.key]),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex flex-col rounded-md border border-border p-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-sm font-normal text-gray-500",children:o.key}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"font-medium leading-5",children:o.value}),jsxRuntime.jsxRuntimeExports.jsx(ViewData,{data:lodashEs.get(i,o.value,"")}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx(AddBindingModal,{editMode:!0,onAddBinding:n,appliedBindings:l,item:o,children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.EditIcon,{className:"mt-1 h-6 w-6 cursor-pointer rounded border border-blue-400 p-1 text-blue-400 duration-200 hover:scale-105 hover:bg-blue-400 hover:text-white"})}),jsxRuntime.jsxRuntimeExports.jsx(lucideReact.TrashIcon,{onClick:()=>r(),className:"mt-1 h-6 w-6 cursor-pointer rounded border border-red-400 p-1 text-red-400 duration-200 hover:scale-105 hover:bg-red-400 hover:text-white"})]}),!lodashEs.isEmpty(c)&&!lodashEs.isEmpty(o.key)&&jsxRuntime.jsxRuntimeExports.jsx("div",{className:"absolute right-0 top-1 mt-px flex h-4 items-center rounded-full px-2 text-[10px] font-medium text-purple-600",children:lodashEs.startCase(c)})]})},DataBindingSetting=({bindingData:o,onChange:n})=>{const r=useSelectedBlock(),[a]=useChaiExternalData(),i=runtime.getChaiDataProviders(),[l,c]=React.useState(lodashEs.map(o,(h,p)=>({key:p,value:h})));React.useEffect(()=>{c(lodashEs.map(o,(h,p)=>({key:p,value:h})))},[r==null?void 0:r._id,o]);const d=React.useMemo(()=>{if(lodashEs.isEmpty(a))return!0;if(lodashEs.isEmpty(l))return!1;const h=lodashEs.last(l);return lodashEs.isEmpty(h==null?void 0:h.key)||lodashEs.isEmpty(h==null?void 0:h.value)},[a,l]),u=h=>{const p=lodashEs.filter(l,f=>f.key!==h.key);c([...p,h]),m([...p,h])},x=h=>{const p=lodashEs.filter(l,(f,R)=>h!==R);m([...p])},m=React.useCallback((h=[])=>{if(c(h),lodashEs.isEmpty(h)){n({});return}const p={};lodashEs.forEach(h,f=>{!lodashEs.isEmpty(f==null?void 0:f.key)&&!lodashEs.isEmpty(f==null?void 0:f.value)&&lodashEs.set(p,f.key,f.value)}),n(p)},[n]);return lodashEs.isEmpty(i)?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-full items-center justify-center",children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1.5 text-xs text-gray-500",children:["You have no data providers registered. Please add a data provider to your project. ",jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("a",{className:"text-blue-500",href:"https://chaibuilder.com/docs/registering-data-providers",target:"_blank",children:"Learn more"})]})}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[lodashEs.map(l,(h,p)=>jsxRuntime.jsxRuntimeExports.jsx(NewDataBindingPair,{item:h,onAddBinding:u,onRemove:()=>x(p),selectedBlock:r,dataProvider:a,appliedBindings:lodashEs.map(l,"key")},h.key)),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{delayDuration:200,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{disabled:lodashEs.isEmpty(a),className:"w-full",children:jsxRuntime.jsxRuntimeExports.jsx(AddBindingModal,{disabled:d,appliedBindings:lodashEs.map(l,"key"),onAddBinding:u,children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:`w-full rounded-md px-5 py-1.5 text-xs font-medium duration-200 ${d?"cursor-not-allowed bg-gray-200 text-gray-400":"bg-blue-700/20 text-blue-800 hover:bg-blue-700/30"}`,children:lodashEs.isEmpty(a)?jsxRuntime.jsxRuntimeExports.jsx("small",{className:"text-[9.5px] text-gray-500",children:"No data provider has been set up for this page"}):"+ Add Data Binding"})})}),d&&jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{sideOffset:-55,className:"text-[11px]",children:lodashEs.isEmpty(a)?"No data provider has been set up for this page.":"Complete last added data binding to add more"})]})]})},DataBindingSetting$1=DataBindingSetting,BindingWidget=()=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-xs border rounded-sm p-1 mt-1 border-orange-500 text-orange-500 bg-orange-100",children:"Data binding is set for this field"}),getSvgMarkup=o=>{try{const n=document.getElementById("icon-picker-field"),r=document.createElement("div");ReactDOM.render(jsxRuntime.jsxRuntimeExports.jsx(IconPicker.IconPickerItem,{value:o}),r),n.appendChild(r),r.hidden=!0;let a=r.innerHTML;setTimeout(()=>n.removeChild(r),100);const l=new DOMParser().parseFromString(a,"image/svg+xml"),c=l.querySelector("svg");return c&&(c.removeAttribute("width"),c.removeAttribute("height")),new XMLSerializer().serializeToString(l)}catch(n){return console.error(n),""}},IconPickerField=({value:o,onChange:n})=>{const{t:r}=reactI18next.useTranslation(),a=i=>{n("<svg />");const l=getSvgMarkup(i);n(l)};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-1 flex h-20 items-center gap-x-2",id:"icon-picker-field",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"group relative h-12 w-12",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:o?o.replace("<svg",'<svg class="h-5 w-5"'):"<svg class='h-5 w-5' />"},className:"absolute left-1/2 top-1/2 z-0 -translate-x-1/2 -translate-y-1/2 transform cursor-pointer bg-white"}),jsxRuntime.jsxRuntimeExports.jsx(IconPicker,{value:o?"BiSolidGrid":null,onChange:a,pickButtonStyle:{position:"relative",height:"48px",width:"48px",border:"1px solid #999",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"6px",backgroundColor:"transparent",zIndex:1},searchInputStyle:{backgroundColor:"transparent",width:"100%",border:"1px solid #BBBBBB",margin:"0px 10px",padding:"10px"}})]}),jsxRuntime.jsxRuntimeExports.jsx("textarea",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:o,onChange:i=>n(i.target.value),placeholder:r("choose_icon_or_enter_svg"),className:"no-scrollbar disabled:opacity-50; mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed"})]})},UnsplashImages=React.lazy(()=>Promise.resolve().then(()=>require("./UnsplashImages-qlE_2pmY.cjs"))),UploadImages=React.lazy(()=>Promise.resolve().then(()=>require("./UploadImages-bZWXchWP.cjs"))),ImagesPanel=({isModalView:o=!1,onSelect:n=()=>{}})=>{const r=useBuilderProp("uploadMediaCallback"),a=useBuilderProp("unsplashAccessKey"),i=r===void 0,l=a===void 0,[c,d]=React.useState(l?"upload":i?"unsplash":"upload");return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between rounded-md bg-background/30 p-1",children:jsxRuntime.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:o&&i?"Unsplash images":o?"Select or upload images":"Images"})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tabs,{value:c,onValueChange:u=>d(u),className:"flex h-full w-full flex-col py-2",children:[!(i||l)&&jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.TabsList,{className:"w-full",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"upload",className:"w-full",children:"Upload"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"unsplash",className:"w-full",children:"Unsplash"})]}),c==="unsplash"?jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsContent,{value:"unsplash",className:"flex h-full flex-col overflow-hidden",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-64 w-full animate-pulse bg-gray-100"}),children:jsxRuntime.jsxRuntimeExports.jsx(UnsplashImages,{isModalView:o,onSelect:n})})}):jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsContent,{value:"upload",className:"flex h-full flex-col overflow-hidden",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-64 w-full animate-pulse bg-gray-100"}),children:jsxRuntime.jsxRuntimeExports.jsx(UploadImages,{isModalView:o,onSelect:n})})})]})]})},ImagesPanel$1=ImagesPanel,ImagePickerModal=({children:o,onSelect:n})=>{const[r,a]=React.useState(!1),i=useBuilderProp("mediaManagerComponent",ImagesPanel$1),l=(...c)=>{n.call(void 0,...c),a(!1)};return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Dialog,{open:r,onOpenChange:c=>a(c),children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTrigger,{asChild:!0,children:o}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogContent,{className:"flex h-3/4 max-w-5xl border-border",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-full w-full",children:jsxRuntime.jsxRuntimeExports.jsx(i,{isModalView:!0,onSelect:l})})})]})};ImagePickerModal.displayName="ImagePickerModal";const ImagePickerModal$1=ImagePickerModal,ImagePickerField=({value:o,onChange:n,id:r,onBlur:a})=>{const i=useBuilderProp("uploadMediaCallback"),l=useBuilderProp("unsplashAccessKey"),{t:c}=reactI18next.useTranslation(),d=i!==void 0||l!==void 0;return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[o?jsxRuntime.jsxRuntimeExports.jsx("img",{src:o,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover",alt:""}):jsxRuntime.jsxRuntimeExports.jsx(ImagePickerModal$1,{onSelect:n,children:jsxRuntime.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("div",{className:"flex w-3/5 flex-col",children:[d&&jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(ImagePickerModal$1,{onSelect:n,children:jsxRuntime.jsxRuntimeExports.jsx("small",{className:"h-6 cursor-pointer rounded-md bg-primary px-2 py-1 text-center text-xs text-white hover:bg-gray-500 dark:bg-gray-700",children:o||!lodashEs.isEmpty(o)?c("Replace image"):c("Choose image")})}),jsxRuntime.jsxRuntimeExports.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-gray-600",children:"OR"})]}),jsxRuntime.jsxRuntimeExports.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"text-xs",placeholder:c("enter_image_url"),value:o,onBlur:({target:{value:u}})=>a(r,u),onChange:u=>n(u.target.value)})]})]})},RichTextEditorField=({id:o,placeholder:n,value:r,onChange:a,onBlur:i})=>{const l={toolbar:[["bold","italic","underline","strike","blockquote"],[{list:"ordered"},{list:"bullet"}],[{color:[]},{background:[]},{align:[]}],["link","clean"]]},c=["header","font","list","bold","italic","underline","strike","blockquote","color","background","align","link","image"];return typeof window>"u"?null:jsxRuntime.jsxRuntimeExports.jsx(ReactQuill,{id:o,value:r,onBlur:d=>i(o,d),onChange:d=>a(d),modules:l,formats:c,placeholder:n,className:"mt-1 rounded-md"})},LinkField=({schema:o,formData:n,onChange:r})=>{const[a,i]=React.useState([]),l=useBuilderProp("getPages",()=>[]),{type:c="page",href:d="",target:u="self"}=n;return React.useEffect(()=>{(async()=>{const x=await l();i(x||[])})()},[]),jsxRuntime.jsxRuntimeExports.jsxs("div",{children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"text-xs font-medium",children:(o==null?void 0:o.title)??"Link"}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxRuntimeExports.jsx("select",{name:"type",value:c,onChange:x=>r({...n,type:x.target.value}),children:[{const:"page",title:"Open Page"},{const:"url",title:"Open URL"},{const:"email",title:"Compose Email"},{const:"telephone",title:"Call Phone"},{const:"scroll",title:"Scroll to element"}].map(x=>jsxRuntime.jsxRuntimeExports.jsx("option",{value:x.const,children:x.title},x.const))}),c==="page"?jsxRuntime.jsxRuntimeExports.jsxs("select",{name:"href",value:d,onChange:x=>r({...n,href:x.target.value||"#"}),children:[jsxRuntime.jsxRuntimeExports.jsx("option",{value:"",children:"Choose page"}),lodashEs.map(a,x=>jsxRuntime.jsxRuntimeExports.jsx("option",{value:x.slug,children:x.name},x.uuid))]}):jsxRuntime.jsxRuntimeExports.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",value:d,onChange:x=>r({...n,href:x.target.value||"#"}),placeholder:c==="page"||c==="url"?"Enter URL":c==="scroll"?"#ElementID":"Enter detail"}),(c==="page"||c==="url")&&jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"checkbox",defaultChecked:u==="_blank",className:"!w-fit cursor-pointer rounded-md border border-border",onChange:()=>r({...n,target:u==="_blank"?"_self":"_blank"})}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"pt-1 text-xs",children:"Open in new tab"})]})]})]})},CodeEditor=({id:o,placeholder:n})=>{const{t:r}=reactI18next.useTranslation(),[,a]=useCodeEditor(),i=useSelectedBlock();if(typeof window>"u")return null;const l=o.replace("root.",""),c=lodashEs.get(i,l,""),d=()=>{const u=i==null?void 0:i._id;a({blockId:u,blockProp:l,placeholder:n,initialCode:lodashEs.get(i,l,c)})};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2 flex flex-col gap-y-1",children:[jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:d,className:"text-pretty w-[90%] max-w-full cursor-default truncate rounded border border-border bg-background p-2 text-left text-[10px]",children:c.trim().length>0?c.substring(0,46):n||"Eg: <script>console.log('Hello, world!');<\/script>"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{onClick:d,size:"sm",variant:"outline",className:"w-fit",children:r("Open code editor")})]})},JSONForm=React.memo(({id:o,properties:n,formData:r,onChange:a})=>{const[i,l]=React.useState(r),c={type:"object",properties:{}},d={},{t:u}=reactI18next.useTranslation(),{selectedLang:x,fallbackLang:m,languages:h}=useLanguages(),p=h.length===0?"":x.length?x:m;Object.keys(n).forEach(R=>{const j=n[R];if(lodashEs.includes(["slot","styles"],j.type))return;const E=R;c.properties[E]=getBlockJSONFromSchemas(j,u,p),d[E]=getBlockJSONFromUISchemas(j)}),React.useEffect(()=>{l(r)},[o,x]);const f=web.useThrottledCallback(async({formData:R},j)=>{a({formData:R},j)},[a],1e3);return jsxRuntime.jsxRuntimeExports.jsx(Form,{widgets:{binding:BindingWidget,richtext:RichTextEditorField,icon:IconPickerField,image:ImagePickerField,code:CodeEditor},fields:{link:LinkField},idSeparator:".",autoComplete:"off",omitExtraData:!1,liveOmit:!1,liveValidate:!1,validator,uiSchema:d,schema:c,formData:i,onChange:({formData:R},j)=>{j&&(l(R),f({formData:R},j))}})}),CanvasSettings=()=>{const[o,n]=jotai.useAtom(xShowBlocksAtom),r=useSelectedBlock(),[,a]=useSelectedBlockIds(),{t:i}=reactI18next.useTranslation(),l=React.useMemo(()=>(r?JSON.stringify(r):"").includes('"x-show"'),[r]);if(!r||!l)return null;const c=o.includes(r._id);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"py-2 text-xs hover:no-underline",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 border-b border-border bg-background py-2 font-normal text-muted-foreground",children:[r._name||r._type," ",i("visibility settings")]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Switch,{id:"show-on-canvas",checked:c,onCheckedChange:d=>{d?(n(u=>[...u,r._id]),a([r._id])):n(u=>u.filter(x=>x!==r._id))}}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Label,{htmlFor:"show-on-canvas",children:i("Show on canvas")})]})]})},GlobalBlockSettings=()=>{const o=useSelectedBlock(),{data:n,refetch:r,isLoading:a}=useGlobalBlocksList(),i=useUpdateBlocksProps();return jsxRuntime.jsxRuntimeExports.jsxs("div",{children:[jsxRuntime.jsxRuntimeExports.jsx("label",{className:"text-sm",children:"Choose a global block"}),jsxRuntime.jsxRuntimeExports.jsxs("select",{className:"h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",value:(o==null?void 0:o.globalBlock)||"",onChange:l=>{i([o._id],{globalBlock:l.target.value,_name:`Global: ${lodashEs.startCase(l.target.value)}`})},children:[jsxRuntime.jsxRuntimeExports.jsx("option",{value:"",children:"Select a global block"}),Object.keys(n).map(l=>jsxRuntime.jsxRuntimeExports.jsx("option",{value:l,children:n[l].name||l},l))]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-2 text-xs",children:jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:r,className:"rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",children:a?"Loading...":"Refresh List"})})]})},ResetRSCBlockButton=({blockId:o})=>{const{t:n}=reactI18next.useTranslation(),{reset:r}=useRSCBlocksStore();return jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{size:"sm",variant:"outline",onClick:()=>r(o),children:n("Reload")})},formDataWithSelectedLang=(o,n,r)=>{const a=lodashEs.cloneDeep(o);return lodashEs.forEach(lodashEs.keys(o),i=>{lodashEs.get(r,["props",i,"i18n"])&&!lodashEs.isEmpty(n)&&(a[i]=lodashEs.get(o,`${i}-${n}`))}),a};function BlockSettings(){const{selectedLang:o}=useLanguages(),n=useSelectedBlock(),r=useUpdateBlocksPropsRealtime(),a=useUpdateBlocksProps(),i=runtime.getBlockComponent(n==null?void 0:n._type),l=formDataWithSelectedLang(n,o,i),[c,d]=React.useState(l),u=useBuilderProp("dataBindingSupport",!1),x=({formData:j},E,y)=>{if(E&&(c==null?void 0:c._id)===n._id){const v=E.replace("root.","");a([n._id],{[v]:lodashEs.get(j,v)},y)}},m=React.useCallback(lodashEs.debounce(({formData:j},E,y)=>{x({formData:j},E,y),d(j)},1500),[n==null?void 0:n._id,o]),h=({formData:j},E)=>{if(E){const y=E.replace("root.","");r([n._id],convertDotNotationToObject(y,lodashEs.get(j,y.split(".")))),m({formData:j},E,{[y]:lodashEs.get(c,y)})}},p=lodashEs.keys(lodashEs.get(l,"_bindings",{})),f=React.useMemo(()=>{const j=lodashEs.cloneDeep(lodashEs.get(i,"props",{}));return lodashEs.each(j,(E,y)=>{lodashEs.get(E,"hidden",!1)&&delete j[y]}),u&&lodashEs.each(p,E=>delete j[E]),j},[i,p,u]),R=lodashEs.get(i,"server",!1);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"overflow-x-hidden px-px",children:[u?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Accordion,{type:"multiple",defaultValue:["STATIC","BINDING"],className:"mt-4 h-full w-full",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:"BINDING",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{className:"py-2",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:`h-[8px] w-[8px] rounded-full ${lodashEs.isEmpty(lodashEs.get(n,"_bindings",{}))?"bg-gray-300":"bg-blue-500"}`}),"Data Binding"]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionContent,{className:"pt-4",children:jsxRuntime.jsxRuntimeExports.jsx(DataBindingSetting$1,{bindingData:lodashEs.get(n,"_bindings",{}),onChange:j=>{x({formData:{_bindings:j}},"root._bindings")}})})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:"STATIC",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{className:"py-2",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-[8px] w-[8px] rounded-full bg-blue-500"}),"Static Content"]})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionContent,{className:"pt-4",children:[lodashEs.isEmpty(p)?null:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mb-1 mt-0 rounded-sm border border-orange-500 bg-orange-100 p-1 text-xs text-orange-500",children:["Data binding is set for ",jsxRuntime.jsxRuntimeExports.jsx("b",{children:lodashEs.map(p,lodashEs.capitalize).join(", ")})," ",p.length===1?"property":"properties",". Remove data binding to edit static content."]}),jsxRuntime.jsxRuntimeExports.jsx(JSONForm,{id:n==null?void 0:n._id,onChange:h,formData:l,properties:f})]})]})]}):lodashEs.isEmpty(f)?null:jsxRuntime.jsxRuntimeExports.jsx(JSONForm,{id:n==null?void 0:n._id,onChange:h,formData:l,properties:f}),(n==null?void 0:n._type)==="GlobalBlock"?jsxRuntime.jsxRuntimeExports.jsx(GlobalBlockSettings,{}):null,R?jsxRuntime.jsxRuntimeExports.jsx(ResetRSCBlockButton,{blockId:n==null?void 0:n._id}):null,jsxRuntime.jsxRuntimeExports.jsx(CanvasSettings,{})]})}function getChildBlocks(o,n,r){r.push(lodashEs.find(o,{_id:n}));const a=lodashEs.filter(o,{_parent:n});for(const i of a)r.push(...getBlockWithChildren(i._id,o));return r}const getBlockWithChildren=(o,n)=>{let r=[];return r=lodashEs.flattenDeep([...r,...getChildBlocks(n,o,r)]),r};function promptWithLanguage(o,n,r){if(!n||r!=="content")return o;const a=`Please provide the response in "${n}" language.`;return`${o}
62
62
 
63
- ${a}`}const askAiProcessingAtom=jotai.atom(!1),useAskAi=()=>{const[o,n]=jotai.useAtom(askAiProcessingAtom),[r,a]=React.useState(null),i=useBuilderProp("askAiCallBack",null),l=useStreamMultipleBlocksProps(),c=useUpdateMultipleBlocksProps(),[d]=useBlocksStore(),{selectedLang:u,fallbackLang:x}=useLanguages(),m=u.length?u:x;return{askAi:React.useCallback(async(h,p,f,R)=>{if(i){n(!0),a(null);try{const j=h==="content"?lodashEs.cloneDeep(getBlockWithChildren(p,d)):[lodashEs.cloneDeep(d.find(k=>k._id===p))];lodashEs.set(j,"0._parent",null);const E=u===x?"":u,y=await i(h,promptWithLanguage(f,m,h),j,E),{blocks:v,error:w}=y;if(w){a(w);return}h==="styles"?c(v):l(v),R&&R(y)}catch(j){a(j)}finally{n(!1),R&&R()}}},[i,n,d,u,x,m,c,l]),loading:o,error:r}};function FaLanguage$1(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M152.1 236.2c-3.5-12.1-7.8-33.2-7.8-33.2h-.5s-4.3 21.1-7.8 33.2l-11.1 37.5H163zM616 96H336v320h280c13.3 0 24-10.7 24-24V120c0-13.3-10.7-24-24-24zm-24 120c0 6.6-5.4 12-12 12h-11.4c-6.9 23.6-21.7 47.4-42.7 69.9 8.4 6.4 17.1 12.5 26.1 18 5.5 3.4 7.3 10.5 4.1 16.2l-7.9 13.9c-3.4 5.9-10.9 7.8-16.7 4.3-12.6-7.8-24.5-16.1-35.4-24.9-10.9 8.7-22.7 17.1-35.4 24.9-5.8 3.5-13.3 1.6-16.7-4.3l-7.9-13.9c-3.2-5.6-1.4-12.8 4.2-16.2 9.3-5.7 18-11.7 26.1-18-7.9-8.4-14.9-17-21-25.7-4-5.7-2.2-13.6 3.7-17.1l6.5-3.9 7.3-4.3c5.4-3.2 12.4-1.7 16 3.4 5 7 10.8 14 17.4 20.9 13.5-14.2 23.8-28.9 30-43.2H412c-6.6 0-12-5.4-12-12v-16c0-6.6 5.4-12 12-12h64v-16c0-6.6 5.4-12 12-12h16c6.6 0 12 5.4 12 12v16h64c6.6 0 12 5.4 12 12zM0 120v272c0 13.3 10.7 24 24 24h280V96H24c-13.3 0-24 10.7-24 24zm58.9 216.1L116.4 167c1.7-4.9 6.2-8.1 11.4-8.1h32.5c5.1 0 9.7 3.3 11.4 8.1l57.5 169.1c2.6 7.8-3.1 15.9-11.4 15.9h-22.9a12 12 0 0 1-11.5-8.6l-9.4-31.9h-60.2l-9.1 31.8c-1.5 5.1-6.2 8.7-11.5 8.7H70.3c-8.2 0-14-8.1-11.4-15.9z"},child:[]}]})(o)}function FaMoon(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"},child:[]}]})(o)}function FaRecycle(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M184.561 261.903c3.232 13.997-12.123 24.635-24.068 17.168l-40.736-25.455-50.867 81.402C55.606 356.273 70.96 384 96.012 384H148c6.627 0 12 5.373 12 12v40c0 6.627-5.373 12-12 12H96.115c-75.334 0-121.302-83.048-81.408-146.88l50.822-81.388-40.725-25.448c-12.081-7.547-8.966-25.961 4.879-29.158l110.237-25.45c8.611-1.988 17.201 3.381 19.189 11.99l25.452 110.237zm98.561-182.915l41.289 66.076-40.74 25.457c-12.051 7.528-9 25.953 4.879 29.158l110.237 25.45c8.672 1.999 17.215-3.438 19.189-11.99l25.45-110.237c3.197-13.844-11.99-24.719-24.068-17.168l-40.687 25.424-41.263-66.082c-37.521-60.033-125.209-60.171-162.816 0l-17.963 28.766c-3.51 5.62-1.8 13.021 3.82 16.533l33.919 21.195c5.62 3.512 13.024 1.803 16.536-3.817l17.961-28.743c12.712-20.341 41.973-19.676 54.257-.022zM497.288 301.12l-27.515-44.065c-3.511-5.623-10.916-7.334-16.538-3.821l-33.861 21.159c-5.62 3.512-7.33 10.915-3.818 16.536l27.564 44.112c13.257 21.211-2.057 48.96-27.136 48.96H320V336.02c0-14.213-17.242-21.383-27.313-11.313l-80 79.981c-6.249 6.248-6.249 16.379 0 22.627l80 79.989C302.689 517.308 320 510.3 320 495.989V448h95.88c75.274 0 121.335-82.997 81.408-146.88z"},child:[]}]})(o)}function FaSpinner(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z"},child:[]}]})(o)}const SECONDS=10;function Countdown(){const[o,n]=React.useState(SECONDS),[r,a]=React.useState(!1);React.useEffect(()=>{if(r&&o>0){const u=setTimeout(()=>{n(o-.1)},100);return()=>clearTimeout(u)}else o<=0&&(a(!1),n(SECONDS))},[r,o]);const i=()=>{a(!0),n(SECONDS)};React.useEffect(()=>{o===SECONDS&&i()},[o]);const l=18,c=2*Math.PI*l,d=c*(1-(SECONDS-o)/SECONDS);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative h-4 w-4",children:[jsxRuntime.jsxRuntimeExports.jsxs("svg",{className:"h-full w-full",viewBox:"0 0 40 40",children:[jsxRuntime.jsxRuntimeExports.jsx("circle",{className:"text-gray-300",strokeWidth:"4",stroke:"currentColor",fill:"transparent",r:l,cx:"20",cy:"20"}),jsxRuntime.jsxRuntimeExports.jsx("circle",{className:"text-blue-600",strokeWidth:"4",strokeDasharray:c,strokeDashoffset:d,strokeLinecap:"round",stroke:"currentColor",fill:"transparent",r:l,cx:"20",cy:"20"})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"text-xs font-semibold",children:" "})})]})}const AskAIStyles=({blockId:o})=>{const{t:n}=reactI18next.useTranslation(),{askAi:r,loading:a,error:i}=useAskAi(),[l,c]=React.useState(""),d=React.useRef(null),u=React.useRef(null),[x,m]=React.useState();React.useEffect(()=>{var p;(p=d.current)==null||p.focus()},[]);const h=p=>{const{usage:f}=p||{};!i&&f&&m(f),u.current=setTimeout(()=>m(void 0),1e4),i||c("")};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"",children:[jsxRuntime.jsxRuntimeExports.jsx("h2",{className:"mb-1 text-sm font-semibold leading-none tracking-tight",children:n("ask_ai")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{ref:d,value:l,onChange:p=>c(p.target.value),placeholder:n("ask_ai_to_edit_styles"),className:"w-full border border-border focus:border-0",rows:3,onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),u.current&&clearTimeout(u.current),m(void 0),r("styles",o,l,h))}}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"my-2 flex items-center gap-2",children:[a?null:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:l.trim().length<5||a,onClick:()=>{u.current&&clearTimeout(u.current),m(void 0),r("styles",o,l,h)},variant:"default",className:"w-fit",size:"sm",children:a?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),n("generating_please_wait")]}):n("edit_with_ai")}),a?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Skeleton,{className:"flex w-full items-center space-x-1 px-4 py-1 pl-2",children:[jsxRuntime.jsxRuntimeExports.jsx(FaSpinner,{className:"h-4 w-4 animate-spin text-gray-500"}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs",children:n("generating_please_wait")})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"destructive",onClick:()=>stop(),className:"hidden w-fit",size:"sm",children:n("stop")})]}):null]}),x?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"max-w-full",children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500",children:[jsxRuntime.jsxRuntimeExports.jsxs("span",{children:[n("Total tokens used"),": ",x.totalTokens]}),jsxRuntime.jsxRuntimeExports.jsx(Countdown,{})]})}):null,jsxRuntime.jsxRuntimeExports.jsx("div",{className:"max-w-full",children:i&&jsxRuntime.jsxRuntimeExports.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:i.message})})]})},fuse=new Fuse(ALL_TW_CLASSES,{isCaseSensitive:!1,threshold:.2,minMatchCharLength:2,keys:["name"]});function ManualClasses(){var C;const{t:o}=reactI18next.useTranslation(),[n]=useSelectedStylingBlocks(),r=useSelectedBlock(),a=useAddClassesToBlocks(),i=useRemoveClassesFromBlocks(),[l]=useSelectedBlockIds(),c=useBuilderProp("askAiCallBack",null),[d,u]=React.useState(""),{toast:x}=contextMenu.useToast(),m=(C=lodashEs.first(n))==null?void 0:C.prop,h=lodashEs.reject((lodashEs.get(r,m,"").replace(STRINGS.STYLES_KEY,"").split(",").pop()||"").split(" "),lodashEs.isEmpty),p=()=>{const I=d.trim().toLowerCase().replace(/ +(?= )/g,"").split(" ");a(l,I,!0),u("")},[f,R]=React.useState([]),j=({value:I})=>{const N=I.trim().toLowerCase(),L=N.match(/.+:/g);let g=[];if(L&&L.length>0){const[b]=L,_=N.replace(b,"");g=fuse.search(_).map(B=>({...B,item:{...B.item,name:b+B.item.name}}))}else g=fuse.search(N);return R(lodashEs.map(g,"item"))},E=()=>{R([])},y=I=>I.name,v=I=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"rounded-md p-1",children:I.name}),w={autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,placeholder:o("enter_classes_separated_by_space"),value:d,onKeyDown:I=>{I.key==="Enter"&&d.trim()!==""&&p()},onChange:(I,{newValue:N})=>u(N),className:"w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"},k=()=>{if(navigator.clipboard===void 0){x({title:o("clipboard_not_supported"),description:o("please_use_chrome_firefox_or_safari"),variant:"destructive"});return}navigator.clipboard.writeText(h.join(" ")),x({title:o("copied"),description:o("classes_copied_to_clipboard")})};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:`flex ${f.length>0?"min-h-[300px]":"min-h-max"} w-full flex-col gap-y-1.5 overflow-y-auto pb-4`,children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:o("classes")}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CopyIcon,{onClick:k,className:"cursor-pointer"})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:o("copy_classes_to_clipboard")})})]})]}),c?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Popover,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{variant:"default",className:"h-6 w-fit",size:"sm",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.SparklesIcon,{className:"h-4 w-4"}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"ml-2",children:o("Ask AI")})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverContent,{side:"left",className:"p-2",children:jsxRuntime.jsxRuntimeExports.jsx(AskAIStyles,{blockId:r==null?void 0:r._id})})]}):null]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex items-center gap-x-3",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"relative flex w-full items-center gap-x-3",children:jsxRuntime.jsxRuntimeExports.jsx(Autosuggest,{suggestions:f,onSuggestionsFetchRequested:j,onSuggestionsClearRequested:E,getSuggestionValue:y,renderSuggestion:v,inputProps:w,containerProps:{className:"relative h-8 w-full gap-y-1 py-1 border-border"},theme:{suggestion:"bg-transparent",suggestionHighlighted:"!bg-gray-300 dark:!bg-gray-800 cursor-pointer",suggestionsContainerOpen:"absolute bg-background no-scrollbar z-50 max-h-[230px] overflow-y-auto w-full border border-border rounded-md"}})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"outline",className:"h-6 border-border",onClick:p,disabled:d.trim()==="",size:"sm",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.PlusIcon,{})})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-full flex-wrap gap-2 overflow-x-hidden",children:React__namespace.Children.toArray(h.map(I=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate rounded border border-border bg-gray-200 p-px px-1.5 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",children:[I,jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Cross2Icon,{onClick:()=>i(l,[I]),className:"invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"})]},I)))})]})}const BASIC_UNITS=["px","%","em","rem","ch","vh","vw"],FLEX_CHILD_SECTION={heading:"flex.heading",items:[{type:"arbitrary",label:"flex.basis",units:BASIC_UNITS,property:"flexBasis"},{type:"range",label:"flex.order",property:"order"},{type:"dropdown",label:"flex.flex",property:"flexGrowShrink"},{type:"dropdown",label:"flex.grow",property:"flexGrow"},{type:"dropdown",label:"flex.shrink",property:"flexShrink"}]},GRID_CHILD_SECTION={heading:"grid.heading",items:[{type:"range",label:"grid.col_span",property:"gridColSpan"},{type:"range",label:"grid.col_start",property:"gridColStart"},{type:"range",label:"grid.col_end",property:"gridColEnd"},{type:"range",label:"grid.row_span",property:"gridRowSpan"},{type:"range",label:"grid.row_start",property:"gridRowStart"},{type:"range",label:"grid.row_end",property:"gridRowEnd"},{type:"range",label:"grid.order",property:"order"}]},SETTINGS_SECTIONS=[{heading:"Styles",items:[{component:ManualClasses},{type:"arbitrary",label:"layout.width",units:BASIC_UNITS.concat("auto"),property:"width"},{type:"arbitrary",label:"layout.height",units:BASIC_UNITS.concat("auto"),property:"height"},{styleType:"multiple",label:"layout.margin",negative:!0,units:[...BASIC_UNITS,"auto"],options:[{key:"margin",label:"layout.margin_all"},{key:"marginX",label:"layout.margin_lr"},{key:"marginY",label:"layout.margin_tb"},{key:"marginTop",label:"layout.margin_top"},{key:"marginRight",label:"layout.margin_right"},{key:"marginBottom",label:"layout.margin_bottom"},{key:"marginLeft",label:"layout.margin_left"}]},{styleType:"multiple",label:"layout.padding",options:[{key:"padding",label:"layout.padding_all"},{key:"paddingX",label:"layout.padding_lr"},{key:"paddingY",label:"layout.padding_tb"},{key:"paddingTop",label:"layout.padding_top"},{key:"paddingRight",label:"layout.padding_right"},{key:"paddingBottom",label:"layout.padding_bottom"},{key:"paddingLeft",label:"layout.padding_left"}]},{styleType:"accordion",heading:"Typography",items:[{type:"dropdown",property:"textAlign",label:"typography.align"},{type:"dropdown",property:"fontFamily",label:"typography.font"},{type:"arbitrary",property:"fontSize",label:"typography.size",units:BASIC_UNITS},{type:"arbitrary",property:"lineHeight",label:"typography.height",units:BASIC_UNITS.concat("-")},{type:"range",property:"fontWeight",label:"typography.weight"},{type:"color",property:"textColor",label:"typography.color"}]},{styleType:"accordion",heading:"Background",items:[{type:"color",label:"background.bgcolor",property:"backgroundColor"},{type:"dropdown",label:"background.attachment",property:"backgroundAttachment"},{type:"dropdown",label:"background.clipping",property:"backgroundClip"},{type:"dropdown",label:"background.origin",property:"backgroundOrigin"},{type:"dropdown",label:"background.position",property:"backgroundPosition"},{type:"dropdown",label:"background.repeat",property:"backgroundRepeat"},{type:"dropdown",label:"background.size",property:"backgroundSize"}]}]}];BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),[...BASIC_UNITS],BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("-");const EDITOR_ICONS={"not-italic":()=>jsxRuntime.jsxRuntimeExports.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z",fill:"white"})}),visible:reactIcons.EyeOpenIcon,invisible:reactIcons.EyeClosedIcon,hidden:reactIcons.EyeClosedIcon,gap:reactIcons.BorderAllIcon,gapX:reactIcons.WidthIcon,gapY:reactIcons.HeightIcon,spaceX:reactIcons.WidthIcon,spaceY:reactIcons.HeightIcon,overscroll:reactIcons.BorderAllIcon,overscrollX:reactIcons.WidthIcon,overscrollY:reactIcons.HeightIcon,overflow:reactIcons.BorderAllIcon,overflowX:reactIcons.WidthIcon,overflowY:reactIcons.HeightIcon,top:reactIcons.ArrowUpIcon,right:reactIcons.ArrowRightIcon,bottom:reactIcons.ArrowDownIcon,left:reactIcons.ArrowLeftIcon,inset:reactIcons.BorderAllIcon,insetX:reactIcons.WidthIcon,insetY:reactIcons.HeightIcon,border:reactIcons.BorderAllIcon,borderX:reactIcons.WidthIcon,borderY:reactIcons.HeightIcon,borderTop:reactIcons.ArrowUpIcon,borderRight:reactIcons.ArrowRightIcon,borderBottom:reactIcons.ArrowDownIcon,borderLeft:reactIcons.ArrowLeftIcon,borderRadius:reactIcons.BorderAllIcon,borderRadiusX:reactIcons.WidthIcon,borderRadiusY:reactIcons.HeightIcon,borderRadiusTop:reactIcons.ArrowUpIcon,borderRadiusRight:reactIcons.ArrowRightIcon,borderRadiusBottom:reactIcons.ArrowDownIcon,borderRadiusLeft:reactIcons.ArrowLeftIcon,borderRadiusTopLeft:reactIcons.ArrowTopLeftIcon,borderRadiusTopRight:reactIcons.ArrowTopRightIcon,borderRadiusBottomRight:reactIcons.ArrowBottomRightIcon,borderRadiusBottomLeft:reactIcons.ArrowBottomLeftIcon,divideXWidth:reactIcons.WidthIcon,divideYWidth:reactIcons.HeightIcon,scale:reactIcons.BorderAllIcon,scaleX:reactIcons.WidthIcon,scaleY:reactIcons.HeightIcon,skewX:reactIcons.WidthIcon,skewY:reactIcons.HeightIcon,translateX:reactIcons.WidthIcon,translateY:reactIcons.HeightIcon,padding:reactIcons.BorderAllIcon,paddingX:reactIcons.WidthIcon,paddingY:reactIcons.HeightIcon,paddingTop:reactIcons.ArrowUpIcon,paddingRight:reactIcons.ArrowRightIcon,paddingBottom:reactIcons.ArrowDownIcon,paddingLeft:reactIcons.ArrowLeftIcon,margin:reactIcons.BorderAllIcon,marginX:reactIcons.WidthIcon,marginY:reactIcons.HeightIcon,marginTop:reactIcons.ArrowUpIcon,marginRight:reactIcons.ArrowRightIcon,marginBottom:reactIcons.ArrowDownIcon,marginLeft:reactIcons.ArrowLeftIcon,textLeft:reactIcons.AlignLeftIcon,textCenter:reactIcons.AlignCenterHorizontallyIcon,textRight:reactIcons.AlignRightIcon,textJustify:reactIcons.StretchHorizontallyIcon,italic:reactIcons.FontItalicIcon,underline:reactIcons.UnderlineIcon,overline:reactIcons.OverlineIcon,uppercase:reactIcons.LetterCaseUppercaseIcon,block:()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M2 2H14V14H2V2ZM1 1H15V15H1V1Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4H4V12H7V4ZM9 4H12V12H9V4Z",fill:"currentColor"})]}),"float-right":()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M8 4H16V12H8V4Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M0 4H6V6H0V4ZM0 7H6V9H0V7ZM4 10H0V12H4V10Z",fill:"currentColor"})]}),"float-left":()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M0 4H8V12H0V4Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M10 4H16V6H10V4ZM10 7H16V9H10V7ZM14 10H10V12H14V10Z",fill:"currentColor"})]}),"float-none":reactIcons.Cross2Icon,fixed:()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M15 2H14V4H13V5H14V6H15V2ZM10 5V4H9V2H1V8H2V5H10ZM7 4V3H5V4H7ZM4 4V3H2V4H4ZM1 13H7V14H1V13Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),absolute:()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M14 2H15V6H14V2ZM9 3V2H1V8H2V3H9ZM7 13H1V14H7V13Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),relative:()=>jsxRuntime.jsxRuntimeExports.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H9V3H11V6H12V3H14V2H11ZM2 8H1V13H2V11H7V10H2V8ZM15 7H8V14H15V7Z",fill:"currentColor"})}),sticky:()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M12.9998 7C13.6558 7 14.2937 6.78498 14.8158 6.38787C15.338 5.99076 15.7156 5.43345 15.8908 4.80128C16.066 4.16912 16.0292 3.49694 15.7859 2.8877C15.5427 2.27846 15.1065 1.76573 14.5441 1.42804C13.9817 1.09034 13.3241 0.946293 12.672 1.01795C12.02 1.08961 11.4094 1.37303 10.9337 1.8248C10.4581 2.27658 10.1436 2.8718 10.0385 3.51932C9.93341 4.16685 10.0434 4.83097 10.3518 5.41L6.88176 8.88C6.80034 8.96122 6.73572 9.05769 6.69158 9.16388C6.64744 9.27008 6.62465 9.38393 6.62451 9.49894C6.62437 9.61395 6.64689 9.72785 6.69077 9.83416C6.73465 9.94046 6.79904 10.0371 6.88026 10.1185C6.96149 10.1999 7.05795 10.2645 7.16415 10.3087C7.27035 10.3528 7.3842 10.3756 7.4992 10.3758C7.61421 10.3759 7.72812 10.3534 7.83442 10.3095C7.94072 10.2656 8.03734 10.2012 8.11876 10.12L11.5888 6.648C12.0088 6.873 12.4888 7 12.9988 7H12.9998Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M9.535 2H1V14H15V7.465C14.69 7.645 14.355 7.783 14 7.875V13H2V5H9.126C8.86504 3.98486 9.01223 2.90789 9.536 2H9.535ZM7 3V4H5V3H7ZM4 3V4H2V3H4Z",fill:"currentColor"})]}),static:reactIcons.Cross1Icon},StyleContext=React.createContext({canReset:!1,canChange:!0}),BlockStyleProvider=({children:o,canReset:n=!1,canChange:r=!0})=>jsxRuntime.jsxRuntimeExports.jsx(StyleContext.Provider,{value:{canReset:n,canChange:r},children:o}),DropDownChoices=({label:o,property:n,onChange:r})=>{const a=React.useMemo(()=>lodashEs.get(CLASSES_LIST,`${n}.classes`,[""]),[n]),i=useCurrentClassByProperty(n),l=React.useMemo(()=>lodashEs.get(i,"cls",""),[i]),{canChange:c}=React.useContext(StyleContext),d=/\[.*\]/g.test(l);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:o?"w-full rounded":"grow",children:d?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Input,{className:"w-[70%] rounded py-1",readOnly:!0,value:l}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{delayDuration:100,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:"Current value is using a Tailwind arbitrary value."})]})]}):jsxRuntime.jsxRuntimeExports.jsx(DropDown,{rounded:o,onChange:u=>r(u,n),selected:l,options:a,disabled:!c})})};function DropDown({selected:o,onChange:n,rounded:r=!1,options:a,disabled:i=!1}){const l=o.replace(/.*:/g,"").trim(),{undo:c,redo:d}=useUndoManager();return jsxRuntime.jsxRuntimeExports.jsxs("select",{disabled:!a.length||i,className:`${r?"rounded-md border border-border":"border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,onChange:u=>n(u.target.value),onKeyDown:u=>{u.ctrlKey&&(u.key==="z"&&c(),u.key==="y"&&d())},value:l,children:[jsxRuntime.jsxRuntimeExports.jsx("option",{className:"bg-transparent",value:""}),React.Children.toArray(a.map(u=>jsxRuntime.jsxRuntimeExports.jsx("option",{className:"bg-transparent",value:u,children:u})))]})}const RangeChoices=({property:o,onChange:n})=>{const{canReset:r,canChange:a}=React.useContext(StyleContext),i=useCurrentClassByProperty(o),l=React.useMemo(()=>lodashEs.get(i,"cls",""),[i]),c=React.useMemo(()=>lodashEs.get(CLASSES_LIST,`${o}.classes`,[""]),[o]),d=c.indexOf(l)>-1?c.indexOf(l):0,u=/\[.*\]/g.test(l);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs",children:u?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"py-[5px] px-2",children:l}):jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"box-border w-2/12 rounded-tl rounded-bl bg-background px-1 text-center hover:bg-bg-gray-700 disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!a&&(!r||d-1<0),onClick:()=>n(lodashEs.nth(c,d-1),o),children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"flex items-center justify-center",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.MinusIcon,{className:!a&&(!r||d-1<0)?"text-gray-500":"text-black/60 dark:text-white/60"})})}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-8/12 text-center",children:jsxRuntime.jsxRuntimeExports.jsx(DropDownChoices,{label:!1,property:o,onChange:n})}),jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"w-2/12 rounded-tr rounded-br bg-background px-1 text-center hover:bg-bg-gray-700 disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!a&&(!r||d+1>=c.length),onClick:()=>n(lodashEs.nth(c,d+1),o),children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"flex items-center justify-center",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.PlusIcon,{className:!a&&(!r||d+1>=c.length)?"text-gray-500":"text-black/60 dark:text-white/60"})})})]})})},IconChoices=({property:o,onChange:n})=>{const r=React.useMemo(()=>lodashEs.get(CLASSES_LIST,`${o}.classes`,[""]),[o]),{canChange:a}=React.useContext(StyleContext),i=useCurrentClassByProperty(o),l=React.useMemo(()=>lodashEs.get(i,"cls",""),[i]);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex grow flex-wrap gap-1",children:lodashEs.map(r,c=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",disabled:!a,onClick:()=>n(c,o),className:`cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${l===c?"bg-blue-500 text-white":"disabled:bg-gray-600 disabled:text-gray-400"}`,children:React.createElement(lodashEs.get(EDITOR_ICONS,c,reactIcons.BoxIcon))})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:lodashEs.startCase(lodashEs.toLower(c))})]}))})},COLOR_PROP={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},ColorChoice=({property:o,onChange:n})=>{const r=useCurrentClassByProperty(o),a=React.useMemo(()=>lodashEs.get(r,"cls",""),[r]),{canChange:i}=React.useContext(StyleContext),[l,c]=React.useState([]),[d,u]=React.useState({color:"",shade:""}),x=a.split("-"),m=lodashEs.get(x,"1",""),h=lodashEs.get(x,"2",""),p=React.useCallback(R=>{["current","inherit","transparent","black","white"].includes(R)?(c([]),u({color:R})):(c(["50","100","200","300","400","500","600","700","800","900"]),u(j=>({...j,color:R,shade:j.shade?j.shade:"500"})))},[c,u]);React.useEffect(()=>{if(["current","inherit","transparent","black","white"].includes(m))return c([]);c(["50","100","200","300","400","500","600","700","800","900"])},[m]);const f=React.useCallback(R=>{u({color:m,shade:R})},[m]);return React.useEffect(()=>{u({color:"",shade:""})},[r]),React.useEffect(()=>{const j=`${lodashEs.get(COLOR_PROP,o,"")}-${d.color}${d.shade?`-${d.shade}`:""}`;j.match(new RegExp(lodashEs.get(CLASSES_LIST,`${o}.regExp`,"")))&&n(j,o)},[d,n,o]),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"grow text-center",children:jsxRuntime.jsxRuntimeExports.jsx(DropDown,{disabled:!i,rounded:!0,selected:m,onChange:p,options:["current","transparent","primary","secondary","black","white","slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"]})}),jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"grow text-center",children:jsxRuntime.jsxRuntimeExports.jsx(DropDown,{rounded:!0,selected:h,disabled:!m||!i,onChange:f,options:l})})]})},getUserInputValues=(o,n)=>{o=o.toLowerCase();let r=o.trim().replace(/ |\+/g,"");if((r==="auto"||r==="none")&&n.includes(r))return{value:"",unit:r};const a=n.length?new RegExp(n.join("|"),"g"):/XXXXXX/g;r=r.replace(a,"");const i=o.match(a),l=i&&i.length>1,c=!lodashEs.isEmpty(r)&&Number.isNaN(Number(r));return l||c?{error:"Invalid value"}:i&&(i[0]==="auto"||i[0]==="none")?{value:i[0],unit:""}:{value:r,unit:i?i[0]:""}},getTwClassValue=o=>{const n=o.startsWith("-")?"-":"",r=o.split("-").pop();if(["auto","none"].includes(r))return{value:"",unit:r};if(r==="px")return{value:"1",unit:"px"};if(r==="screen")return{value:"100",unit:o.indexOf("w-")!==-1?"vw":"vh"};if(r==="full")return{value:"100",unit:"%"};if(lodashEs.includes(o,"skew-"))return{value:`${n}${r}`,unit:"deg"};if(lodashEs.includes(o,"rotate-"))return{value:`${n}${r}`,unit:"deg"};if(lodashEs.includes(o,"opacity-"))return{value:`${r/100}`,unit:"-"};if(lodashEs.includes(o,"duration-")||lodashEs.includes(o,"delay-"))return{value:`${r}`,unit:"ms"};if(lodashEs.includes(o,"translate-")&&!r.includes("/"))return{value:`${n}${`${r/4}`}`,unit:"rem"};if(lodashEs.includes(o,"scale-"))return{value:`${n}${`${r/100}`}`,unit:"-"};if(lodashEs.startsWith(o,"border")){const a=o.match(/border-?(x|y|t|r|b|l)?\d+/g);if(a)return{value:a[0].split("-").pop(),unit:"px"};if(o.match(/border-?(x|y|t|r|b|l)?/g))return{value:"1",unit:"px"}}if(lodashEs.startsWith(o,"max-w-")){if(o==="max-w-screen-sm")return{value:"640",unit:"px"};if(o==="max-w-screen-md")return{value:"768",unit:"px"};if(o==="max-w-screen-lg")return{value:"1024",unit:"px"};if(o==="max-w-screen-xl")return{value:"1280",unit:"px"};if(o==="max-w-screen-2xl")return{value:"1536",unit:"px"};if(r==="xs")return{value:"320",unit:"px"};if(r==="sm")return{value:"384",unit:"px"};if(r==="md")return{value:"448",unit:"px"};if(r==="lg")return{value:"512",unit:"px"};if(r==="xl")return{value:"576",unit:"px"};if(r==="2xl")return{value:"672",unit:"px"};if(r==="3xl")return{value:"768",unit:"px"};if(r==="4xl")return{value:"896",unit:"px"};if(r==="5xl")return{value:"1024",unit:"px"};if(r==="6xl")return{value:"1152",unit:"px"};if(r==="7xl")return{value:"1280",unit:"px"};if(r==="prose")return{value:"65",unit:"ch"}}if(lodashEs.startsWith(o,"text-")){if(r==="xs")return{value:"12",unit:"px"};if(r==="sm")return{value:"14",unit:"px"};if(r==="base")return{value:"16",unit:"px"};if(r==="lg")return{value:"18",unit:"px"};if(r==="xl")return{value:"20",unit:"px"};if(r==="2xl")return{value:"24",unit:"px"};if(r==="3xl")return{value:"30",unit:"px"};if(r==="4xl")return{value:"36",unit:"px"};if(r==="5xl")return{value:"48",unit:"px"};if(r==="6xl")return{value:"60",unit:"px"};if(r==="7xl")return{value:"72",unit:"px"};if(r==="8xl")return{value:"96",unit:"px"};if(r==="9xl")return{value:"128",unit:"px"}}if(lodashEs.startsWith(o,"leading-")){if(r==="none")return{value:"1",unit:"-"};if(r==="tight")return{value:"1.25",unit:"-"};if(r==="snug")return{value:"1.375",unit:"-"};if(r==="normal")return{value:"1.5",unit:"-"};if(r==="relaxed")return{value:"1.625",unit:"-"};if(r==="loose")return{value:"2",unit:"-"}}if(lodashEs.startsWith(o,"tracking-")){if(r==="tighter")return{value:"-0.05",unit:"em"};if(r==="tight")return{value:"-0.025",unit:"em"};if(r==="normal")return{value:"0",unit:"em"};if(r==="wide")return{value:"0.025",unit:"em"};if(r==="wider")return{value:"0.05",unit:"em"};if(r==="widest")return{value:"0.1",unit:"em"}}if(["max","min","fit"].includes(r))return{value:o,unit:"class"};if(r.includes("/")){const[a,i]=lodashEs.map(r.split("/"),l=>parseInt(l,10));return{value:n+(a/i*100).toFixed(2).replace(".00",""),unit:"%"}}return lodashEs.isNumber(parseFloat(r))?{value:`${n+parseFloat(r)*4}`,unit:"px"}:{value:r,unit:"class"}},getClassValueAndUnit=o=>{if(lodashEs.isEmpty(o))return{value:"",unit:""};const n=o.match(/\[.*\]/g);if(n===null)return getValueAndUnitForTWClass(o);const r=lodashEs.get(n,"0","").replace(/\[|\]/g,""),a=o.startsWith("-")?"-":"",i=lodashEs.first(r.match(/\d+.\d+|\d+/g));return{value:`${a}${i}`,unit:r.replace(i,"")}},getValueAndUnitForTWClass=o=>lodashEs.isEmpty(o)?{value:"",unit:""}:getTwClassValue(o),BlockSettingsContext=React.createContext({setDragData:()=>{}}),DragStyleButton=({unit:o,currentValue:n,onDrag:r,onDragEnd:a,onDragStart:i,negative:l,cssProperty:c})=>{const{setDragData:d}=React.useContext(BlockSettingsContext);return jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",onMouseDown:u=>{const x={onDrag:r,onDragEnd:a,dragging:!0,dragStartY:u.pageY,dragStartValue:`${n}`,dragUnit:o,negative:l,cssProperty:c};i(x),d(x)},color:void 0,className:"relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RowSpacingIcon,{})})},UnitSelection=({onSelect:o,current:n,units:r})=>jsxRuntime.jsxRuntimeExports.jsx("div",{"data-theme":"light",className:"-m-[7px] -mx-[13px] flex w-9 flex-col",children:r.map(a=>jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{className:"h-max rounded-none px-1 py-1 text-right text-[11px] hover:bg-blue-400",color:n===a?"primary":void 0,size:"sm",onClick:i=>{i.stopPropagation(),o(a)},children:a},a))}),THROTTLE_TIME=50,AdvanceChoices=o=>{const[n,r]=React.useState(!1),[a,i]=React.useState(""),{currentClass:l,onChange:c,classPrefix:d,cssProperty:u,units:x,negative:m}=o,[h,p]=React.useState(u!=null&&u.toLowerCase().includes("width")?"%":x[0]),[f,R]=React.useState(!1),[j,E]=React.useState(""),[y,v]=React.useState(!1),[w,k]=React.useState(!1);React.useEffect(()=>{const{value:g,unit:b}=getClassValueAndUnit(l);if(b===""){i(g),p(u!=null&&u.toLowerCase().includes("width")?"%":lodashEs.first(x));return}p(b),i(b==="class"||lodashEs.isEmpty(g)?"":g)},[l,u,x]);const C=web.useThrottledCallback(g=>c(g),[c],THROTTLE_TIME),I=web.useThrottledCallback(g=>c(g,!1),[c],THROTTLE_TIME),N=React.useCallback((g=!1)=>{const b=getUserInputValues(`${a}`,x);if(lodashEs.get(b,"error",!1)){R(!0);return}const _=lodashEs.get(b,"unit")!==""?lodashEs.get(b,"unit"):h;if(_==="auto"||_==="none"){C(`${d}${_}`);return}if(lodashEs.get(b,"value")==="")return;const B=`${lodashEs.get(b,"value","").startsWith("-")?"-":""}${d}[${lodashEs.get(b,"value","").replace("-","")}${_==="-"?"":_}]`;g?I(B):C(B)},[C,I,a,h,d,x]),L=React.useCallback(g=>{const b=getUserInputValues(`${a}`,x);if(lodashEs.get(b,"error",!1)){R(!0);return}if(g==="auto"||g==="none"){C(`${d}${g}`);return}if(lodashEs.get(b,"value")==="")return;const _=lodashEs.get(b,"unit")!==""?lodashEs.get(b,"unit"):g,B=`${lodashEs.get(b,"value","").startsWith("-")?"-":""}${d}[${lodashEs.get(b,"value","").replace("-","")}${_==="-"?"":_}]`;C(B)},[C,a,d,x]);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-full flex-col",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-start",children:h==="class"?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx("input",{className:"w-20 rounded py-1",readOnly:!0,value:l}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:"Current value is using a Tailwind preset class."})]})]}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:`group relative flex items-center ${y?"z-auto":""}`,children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center rounded-md border border-border",children:[["none","auto"].indexOf(h)!==-1?null:jsxRuntime.jsxRuntimeExports.jsx("input",{readOnly:h==="class",onKeyPress:g=>{g.key==="Enter"&&N()},onKeyDown:g=>{if(g.keyCode!==38&&g.keyCode!==40)return;g.preventDefault(),k(!0);const b=lodashEs.parseInt(g.target.value);let _=lodashEs.isNaN(b)?0:b;g.keyCode===38&&(_+=1),g.keyCode===40&&(_-=1);const S=`${_}`,A=`${S.startsWith("-")?"-":""}${d}[${S.replace("-","")}${h==="-"?"":h}]`;I(A)},onKeyUp:g=>{w&&(g.preventDefault(),k(!1))},onBlur:()=>N(),onChange:g=>{R(!1),i(g.target.value)},onClick:g=>{var b;(b=g==null?void 0:g.target)==null||b.select(),r(!1)},value:y?j:a,className:"h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(" ",f?"border-red-500 text-red-500":"border-foreground/20")}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{open:n,delayDuration:100,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:`inline-block ${x.length===1?"px-2 font-semibold":""}`,children:h}),x.length>1?jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TriangleDownIcon,{}):null]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipPortal,{children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"bg-background",children:jsxRuntime.jsxRuntimeExports.jsx(UnitSelection,{units:x,current:h,onSelect:g=>{r(!1),p(g),L(g)}})})})]})]}),["none","auto"].indexOf(h)!==-1||y?null:jsxRuntime.jsxRuntimeExports.jsx(DragStyleButton,{onDragStart:()=>v(!0),onDragEnd:g=>{if(E(()=>""),v(!1),lodashEs.isEmpty(g))return;const b=`${g}`,S=`${b.startsWith("-")?"-":""}${d}[${b.replace("-","")}${h==="-"?"":h}]`;C(S)},onDrag:g=>{if(lodashEs.isEmpty(g))return;E(g);const b=`${g}`,S=`${b.startsWith("-")?"-":""}${d}[${b.replace("-","")}${h==="-"?"":h}]`;I(S)},currentValue:a,unit:h,negative:m,cssProperty:u})]})})})},useCurrentClassByProperty=o=>{const n=useSelectedBlockCurrentClasses();return lodashEs.findLast(n,{property:o})},canChangeClass=(o,n)=>{const r={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5};return r[lodashEs.get(o,"mq","xs")]<=r[n]},CLASS_PREFIXES={width:"w-",height:"h-",minWidth:"min-w-",minHeight:"min-h-",maxWidth:"max-w-",maxHeight:"max-h-",zIndex:"z-",gap:"gap-",gapX:"gap-x-",gapY:"gap-y-",margin:"m-",marginX:"mx-",marginY:"my-",marginTop:"mt-",marginBottom:"mb-",marginLeft:"ml-",marginRight:"mr-",padding:"p-",paddingX:"px-",paddingY:"py-",paddingTop:"pt-",paddingBottom:"pb-",paddingLeft:"pl-",paddingRight:"pr-",spaceX:"space-x-",spaceY:"space-y-",border:"border-",borderTop:"border-t-",borderBottom:"border-b-",borderLeft:"border-l-",borderRight:"border-r-",borderX:"border-x-",borderY:"border-y-",borderRadius:"rounded-",borderRadiusTop:"rounded-t-",borderRadiusRight:"rounded-r-",borderRadiusBottom:"rounded-b-",borderRadiusLeft:"rounded-l-",borderRadiusTopLeft:"rounded-tl-",borderRadiusTopRight:"rounded-tr-",borderRadiusBottomRight:"rounded-br-",borderRadiusBottomLeft:"rounded-bl-",fontSize:"text-",lineHeight:"leading-",letterSpacing:"tracking-",textIndent:"indent-",rotate:"rotate-",duration:"duration-",transitionDelay:"delay-",scale:"scale-",scaleX:"scale-x-",scaleY:"scale-y-",translateX:"translate-x-",translateY:"translate-y-",skewX:"skew-x-",skewY:"skew-y-",top:"top-",bottom:"bottom-",left:"left-",right:"right-",inset:"inset-",insetX:"inset-x-",insetY:"inset-y-",opacity:"opacity-",flexBasis:"basis-"},BREAKPOINTS={xs:"",sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"},getBreakpoint=o=>`${o.toUpperCase()} ${BREAKPOINTS[o]?`(${BREAKPOINTS[o]} & up)`:""}`,BlockStyle=o=>{const{t:n}=reactI18next.useTranslation(),{type:r="icons",label:a,property:i,onEmitChange:l=()=>{},units:c,negative:d=!1}=o,[u]=useDarkMode(),[x]=useStylingState(),[,m]=useCanvasWidth(),h=useCurrentClassByProperty(i),p=useAddClassesToBlocks(),f=useRemoveClassesFromBlocks(),[R]=useSelectedBlockIds(),j=React.useMemo(()=>lodashEs.get(h,"fullCls",""),[h]),E=React.useCallback((I,N=!0)=>{const L={dark:u,mq:m,mod:x,cls:I,property:i,fullCls:""};(u||x!=="")&&(L.mq="xs");const g=generateFullClsName(L);p(R,[g],N)},[R,u,m,x,i,p]),y=React.useCallback(()=>{f(R,[j])},[R,j,f]),v=React.useMemo(()=>canChangeClass(h,m),[h,m]);React.useEffect(()=>{l(v,h)},[v,l,h]);const[,,w]=useCanvasWidth(),k=React.useCallback(I=>{w({xs:400,sm:640,md:800,lg:1024,xl:1420,"2xl":1920}[I])},[w]),C=lodashEs.get(h,"dark",null)===u&&lodashEs.get(h,"mod",null)===x&&lodashEs.get(h,"mq",null)===m;return jsxRuntime.jsxRuntimeExports.jsx(BlockStyleProvider,{canChange:v,canReset:h&&C,children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"group flex flex-row items-center py-2 first:pt-0 last:pb-0",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"relative w-[70px] truncate text-xs text-foreground",children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:`text-[11px] ${h&&!C?"text-foreground":""}`,children:n(a)})}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-row items-center",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"w-[150px]",children:[r==="arbitrary"?jsxRuntime.jsxRuntimeExports.jsx(AdvanceChoices,{currentClass:lodashEs.get(h,"cls",""),classPrefix:lodashEs.get(CLASS_PREFIXES,i,""),units:c||[],onChange:E,negative:d,cssProperty:i}):null,r==="icons"&&jsxRuntime.jsxRuntimeExports.jsx(IconChoices,{property:i,onChange:E}),r==="range"&&jsxRuntime.jsxRuntimeExports.jsx(RangeChoices,{property:i,onChange:E}),r==="color"&&jsxRuntime.jsxRuntimeExports.jsx(ColorChoice,{property:i,onChange:E}),r==="dropdown"&&jsxRuntime.jsxRuntimeExports.jsx(DropDownChoices,{label:a,property:i,onChange:E})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:`w-[30px] cursor-pointer ${j?"visible":"invisible"}`,children:C?jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>y(),title:"Reset",className:"flex px-1.5 text-xs",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CrossCircledIcon,{className:"h-5 w-5 text-blue-500 hover:opacity-80"})}):v&&h?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{delayDuration:100,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"invisible ml-3 mt-1 rounded-full bg-blue-500 text-white group-hover:visible",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-right",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{children:["Current style is set at  ",jsxRuntime.jsxRuntimeExports.jsxs("span",{className:"font-bold",children:[getBreakpoint(lodashEs.get(h,"mq")),u&&!h.dark?"(Light mode)":""]}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>k(lodashEs.get(h,"mq")),className:"block w-full cursor-default text-right font-semibold text-blue-500",children:["Switch to ",lodashEs.get(h,"mq").toUpperCase()]})]})})})]}):null})]})]})})},basicUnits=["px","%","em","rem","ch","vh","vw"],MultipleChoices=({label:o,options:n,borderB:r=!1,borderT:a=!1,type:i="arbitrary",units:l=basicUnits,negative:c=!1})=>{const{t:d}=reactI18next.useTranslation(),[u,x]=React.useState(n[0].key),m=useSelectedBlockCurrentClasses(),h=React.useCallback(p=>lodashEs.map(m,"property").includes(p),[m]);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:`mb-2 border-border py-2 first:pt-0 last:pb-0 ${r?"border-b":""} ${a?"border-t":""}`,children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-row text-xs",children:[o&&jsxRuntime.jsxRuntimeExports.jsx("span",{className:"relative w-[70px] flex-none text-xs text-foreground",children:d(o)}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mb-3 flex grow flex-row flex-wrap gap-x-px",children:React.Children.toArray(n.map(({label:p,key:f})=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"first:rounded-l last:rounded-r",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>x(f),className:`relative cursor-pointer rounded-full p-1 text-[8px] ${f===u?"bg-[#3E57F0] text-white":"text-gray-600 dark:text-gray-300"}`,children:[React.createElement("div",{className:h(f)?"-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full":""}),React.createElement(lodashEs.get(EDITOR_ICONS,f,reactIcons.BoxIcon),{className:"text-inherit w-3 h-3"})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:lodashEs.startCase(lodashEs.toLower(p))})]})})))})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-0 flex items-center",children:jsxRuntime.jsxRuntimeExports.jsx(BlockStyle,{type:i,units:[...l],label:"",property:u,negative:c})})]})},NestedOptions=({heading:o,items:n})=>{const{t:r}=reactI18next.useTranslation(),a=useSelectedBlockCurrentClasses(),i=React.useMemo(()=>{const l=u=>lodashEs.flatten(u.map(x=>x.styleType==="multiple"?lodashEs.map(x.options,"key"):x.property)),c=lodashEs.flatten(n.map(u=>u.styleType==="accordion"?l(u.items):u.styleType==="multiple"?lodashEs.map(u.options,"key"):u.property)),d=lodashEs.map(a,"property");return lodashEs.intersection(c,d).length>0},[a,n]);return jsxRuntime.jsxRuntimeExports.jsxs("details",{children:[jsxRuntime.jsxRuntimeExports.jsx("summary",{className:"my-px cursor-default rounded-md bg-gray-50 p-px px-2 text-[11px] text-foreground dark:bg-gray-800",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"inline",children:[r(o.toLowerCase()),i?jsxRuntime.jsxRuntimeExports.jsx("span",{className:`ml-1 mr-2 inline-block h-[8px] w-[8px] rounded-full ${i?"bg-blue-500":"bg-gray-300"}`}):null]})}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"p-2",children:n.map(l=>l.styleType==="multiple"?jsxRuntime.jsxRuntimeExports.jsx(MultipleChoices,{...l},l.label):jsxRuntime.jsxRuntimeExports.jsx(BlockStyle,{...l},l.label))})]})},SectionContext=React.createContext({}),StylingGroup=({section:o})=>{const{t:n}=reactI18next.useTranslation(),r=useSelectedBlockCurrentClasses(),a=React.useCallback((l=[])=>{const c={};for(let u=0;u<r.length;u++)c[r[u].property]=r[u].cls;let d=!0;for(const u in l)if(!lodashEs.has(c,u)||c[u]!==l[u]){d=!1;break}return d},[r]),i=React.useMemo(()=>({}),[]);return jsxRuntime.jsxRuntimeExports.jsx(SectionContext.Provider,{value:i,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:o.heading,className:"border-none",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{className:"border-b border-border py-2 text-xs",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-x-2 text-sm font-bold",children:n(o.heading)})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionContent,{className:"py-2",children:React.Children.toArray(o.items.map(l=>lodashEs.has(l,"component")?React.createElement(l.component,{key:l.label}):lodashEs.has(l,"styleType")?l.styleType==="multiple"?jsxRuntime.jsxRuntimeExports.jsx(MultipleChoices,{...l},l.label):l.styleType==="accordion"&&a(l==null?void 0:l.conditions)?jsxRuntime.jsxRuntimeExports.jsx(NestedOptions,{...l},l.label):null:jsxRuntime.jsxRuntimeExports.jsx(BlockStyle,{...l},l.label)))})]})})},StylingHelpers=()=>{const o=useSelectedBlock(),[n]=useSelectedStylingBlocks(),{t:r}=reactI18next.useTranslation(),a=runtime.useGlobalStylingPresets(),i=useAddClassesToBlocks(),l=runtime.getBlockComponent(o._type),c=lodashEs.get(lodashEs.first(n),"prop"),d=lodashEs.get(l.props,`${c}.presets`,{});if(lodashEs.isEmpty(a)&&(!lodashEs.has(l,"props")||lodashEs.isEmpty(d)))return null;const u=x=>{const m=x.trim().toLowerCase().replace(/ +(?= )/g,"").split(" ");i([o._id],m,!0)};return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-10",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenu,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"px-4",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{variant:"default",className:"w-full",size:"sm",children:[r("Apply Presets"),jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CaretDownIcon,{})]})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuContent,{className:"max-h-80 w-56",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ScrollArea,{className:"no-scrollbar h-full",children:[lodashEs.isEmpty(d)?null:jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenuLabel,{children:[l.type," ",r("presets")]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuSeparator,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuGroup,{children:lodashEs.keys(d).map(x=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenuItem,{className:"group text-xs",onClick:()=>u(d[x]),children:[lodashEs.capitalize(lodashEs.startCase(r(x))),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuShortcut,{className:"invisible hover:font-bold hover:text-blue-600 group-hover:visible",children:r("apply")})]}))})]}),lodashEs.isEmpty(a)?null:jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuLabel,{children:r("Global presets")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuSeparator,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuGroup,{children:lodashEs.keys(a).map(x=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenuItem,{className:"group text-xs",onClick:()=>u(a[x]),children:[lodashEs.capitalize(lodashEs.startCase(r(x))),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuShortcut,{className:"invisible hover:font-bold hover:text-blue-600 group-hover:visible",children:r("apply")})]}))})]})]})})]})})},MAPPER={px:1,"%":1,em:100,rem:100,ch:1,vw:1,vh:1,"-":1,deg:1,ms:.1};function BlockStyling(){const{flexChild:o,gridChild:n}=useSelectedBlocksDisplayChild(),[r]=useSelectedStylingBlocks(),[a,i]=React.useState(""),[l,c]=React.useState({onDrag:x=>x,onDragEnd:x=>x,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""}),d=web.useThrottledCallback(x=>{const m=!lodashEs.get(l,"negative",!1),h=lodashEs.get(l,"cssProperty","");let p=parseFloat(l.dragStartValue);p=isNaN(p)?0:p;let f=MAPPER[l.dragUnit];(lodashEs.startsWith(h,"scale")||h==="opacity")&&(f=10);let j=(l.dragStartY-x.pageY)/f+p;m&&j<0&&(j=0),h==="opacity"&&j>1&&(j=1),l.onDrag(`${j}`),i(`${j}`)},[l],50),u=React.useCallback(()=>{setTimeout(()=>l.onDragEnd(`${a}`),100),c({onDrag:x=>x,onDragEnd:x=>x,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""})},[l,a,c]);return lodashEs.isEmpty(r)?null:jsxRuntime.jsxRuntimeExports.jsxs(BlockSettingsContext.Provider,{value:{setDragData:c},children:[l.dragging?jsxRuntime.jsxRuntimeExports.jsx("div",{onMouseMove:d,onMouseUp:()=>u(),className:"absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"}):null,jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx(StylingHelpers,{}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Accordion,{defaultValue:["Styles"],type:"multiple",className:"w-full",children:[o&&jsxRuntime.jsxRuntimeExports.jsx(StylingGroup,{section:FLEX_CHILD_SECTION}),n?jsxRuntime.jsxRuntimeExports.jsx(StylingGroup,{section:GRID_CHILD_SECTION}):null,SETTINGS_SECTIONS.map(x=>jsxRuntime.jsxRuntimeExports.jsx(StylingGroup,{section:x},x.heading))]})]})]})}const ChaiSelect=({defaultValue:o="",onValueChange:n,options:r,placeholder:a="Select",className:i=""})=>{const[l,c]=React.useState(o),d=u=>{const x=u.target.value;c(x),n(x)};return jsxRuntime.jsxRuntimeExports.jsx("div",{className:iconBase.cn("relative inline-block w-full",i),children:jsxRuntime.jsxRuntimeExports.jsxs("select",{className:"mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm text-foreground shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",value:l,onChange:d,children:[jsxRuntime.jsxRuntimeExports.jsx("option",{value:"",disabled:!0,children:a}),r.map(u=>jsxRuntime.jsxRuntimeExports.jsx("option",{value:u.value,children:u.label},u.value))]})})},ChaiSelect$1=ChaiSelect;function UILibrariesSelect({uiLibraries:o,library:n,setLibrary:r}){const{t:a}=reactI18next.useTranslation();return n?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"h-12",children:[jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs font-bold text-gray-500",children:a("choose_library")}),jsxRuntime.jsxRuntimeExports.jsx(ChaiSelect$1,{className:"mt-1",options:o.map(i=>({value:i.uuid,label:i.name})),defaultValue:n,onValueChange:i=>r(i)})]}):null}const BlockCard=({block:o,library:n,parentId:r=void 0})=>{const[a,i]=React.useState(!1),l=useBuilderProp("getUILibraryBlock",lodashEs.noop),{addCoreBlock:c,addPredefinedBlock:d}=useAddBlock(),[,u]=useSelectedBlockIds(),{clearHighlight:x}=useBlockHighlight(),m=lodashEs.get(o,"name",lodashEs.get(o,"label")),h=flagged.useFeature("dnd"),[,p]=jotai.useAtom(draggedBlockAtom),f=E=>{const y=lodashEs.has(E,"styles_attrs.data-page-section");return E._type==="Box"&&y},R=React.useCallback(async E=>{if(E.stopPropagation(),lodashEs.has(o,"component")){c(o,r),emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK});return}i(!0);const y=await l(n,o);lodashEs.isEmpty(y)||d(runtime.syncBlocksWithDefaults(y),r),emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK})},[o]),j=async E=>{const y=await l(n,o);let v=r;if(f(lodashEs.first(y))&&(v=null),!lodashEs.isEmpty(y)){const w={blocks:y,uiLibrary:!0,parent:v};if(E.dataTransfer.setData("text/plain",JSON.stringify(w)),o.preview){const k=new Image;k.src=o.preview,k.onload=()=>{E.dataTransfer.setDragImage(k,0,0)}}else E.dataTransfer.setDragImage(new Image,0,0);p(w),setTimeout(()=>{u([]),x(),emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK})},200)}};return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("div",{onClick:a?()=>{}:R,draggable:h?"true":"false",onDragStart:j,className:clsx("relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"),children:[a&&jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"absolute flex h-full w-full items-center justify-center bg-black/70",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"animate-spin",size:15,color:"white"}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"pl-2 text-sm text-white",children:"Adding..."})]}),o.preview?jsxRuntime.jsxRuntimeExports.jsx("img",{src:o.preview,className:"min-h-[45px] w-full rounded-md",alt:m}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex h-20 items-center justify-center rounded-md border border-border bg-gray-200",children:jsxRuntime.jsxRuntimeExports.jsx("p",{className:"max-w-xs text-center text-sm text-gray-700",children:m})})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:m})})]})},libraryBlocksAtom=jotai.atom({}),useLibraryBlocks=o=>{const[n,r]=jotai.useAtom(libraryBlocksAtom),a=useBuilderProp("getUILibraryBlocks",lodashEs.noop),i=lodashEs.get(n,`${o==null?void 0:o.uuid}.blocks`,null),l=lodashEs.get(n,`${o==null?void 0:o.uuid}.loading`,"idle"),c=React.useRef("idle");return React.useEffect(()=>{(async()=>{if(l==="complete"||c.current==="loading")return;c.current="loading",r(u=>({...u,[o==null?void 0:o.uuid]:{loading:"loading",blocks:[]}}));const d=await a(o);c.current="idle",r(u=>({...u,[o==null?void 0:o.uuid]:{loading:"complete",blocks:d||[]}}))})()},[o,i,l,c]),{data:i||[],isLoading:l==="loading"}},UILibrarySection=({parentId:o})=>{const[n,r]=jotai.useAtom(selectedLibraryAtom),a=useBuilderProp("uiLibraries",[]),i=runtime.useChaiBlocks(),l=lodashEs.values(i).filter(v=>v.category==="custom"),c=a.find(v=>v.uuid===n)||lodashEs.first(a),{data:d,isLoading:u}=useLibraryBlocks(c),x=lodashEs.groupBy([...d,...l],"group"),[m,h]=React.useState("Hero"),p=lodashEs.get(x,m,[]),f=React.useRef(null),{t:R}=reactI18next.useTranslation(),j=v=>{f.current&&(clearTimeout(f.current),f.current=null),f.current=setTimeout(()=>{f.current&&h(v)},300)};if(u)return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-4 grid h-full w-full grid-cols-12 gap-2",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"col-span-3 h-full"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"col-span-9 h-full"})]});const E=lodashEs.filter(p,(v,w)=>w%2===0),y=lodashEs.filter(p,(v,w)=>w%2===1);return jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"relative mt-2 flex h-full max-h-full overflow-hidden bg-background",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full pt-2",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2",children:[jsxRuntime.jsxRuntimeExports.jsx(UILibrariesSelect,{library:c==null?void 0:c.uuid,setLibrary:r,uiLibraries:a}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2 flex h-full max-h-full w-full flex-1 flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"text-xs font-bold text-gray-500",children:R("groups")}),jsxRuntime.jsxRuntimeExports.jsx("hr",{className:"mt-1 border-border"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20",children:React.Children.toArray(lodashEs.map(x,(v,w)=>jsxRuntime.jsxRuntimeExports.jsxs("div",{onMouseEnter:()=>j(w),onMouseLeave:()=>clearTimeout(f.current),onClick:()=>h(w),className:iconBase.cn("flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",w===m?"bg-blue-500 text-white hover:bg-blue-600":""),children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:lodashEs.capitalize(R(w.toLowerCase()))}),jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CaretRightIcon,{className:"ml-2 h-5 w-5"})]},w)))})]})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ScrollArea,{onMouseEnter:()=>f.current?clearTimeout(f.current):null,className:"z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-2 px-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-1",children:React.Children.toArray(E.map(v=>jsxRuntime.jsxRuntimeExports.jsx(BlockCard,{parentId:o,block:v,library:c})))}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-1",children:React.Children.toArray(y.map(v=>jsxRuntime.jsxRuntimeExports.jsx(BlockCard,{parentId:o,block:v,library:c})))})]}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{})]})]})})})},UILibrariesPanel=({parentId:o})=>jsxRuntime.jsxRuntimeExports.jsx(UILibrarySection,{parentId:o}),UILibraries=UILibrariesPanel,add_block="Add block",enter_paste_tailwind_html="(Enter or paste TailwindCSS HTML snippet)",click_to_add_block="(Click to add block to page)",core="Core",custom_blocks="Custom Blocks",ui_library="UI Library",html_snippet_description="Use HTML snippets from Tailwind CSS component libraries etc. or just copy paste your own HTML code.",tailwind_html_snippet="Tailwind HTML snippet:",enter_code_snippet="Enter your code snippet here...",import_html="Import HTML",note_imported_html="NOTE: Imported html will be added to the currently selected block. If no block is selected, the html will be added to the page.",dark_mode="Dark mode",tree_view_no_blocks="This page has no blocks. Add a block by clicking the + button",canvas_empty="This page is empty",no_block_selected_for_styling="Please select a block to edit settings or styles",no_block_selected_for_ask_ai="Please select a block to ask AI",no_styling_block_selected="Please select a styling block",drop_here_message="Drop your block here",use_setting="Use setting",mobile_xs_title="Mobile (XS)",mobile_xs_content="Styles set here are applied to all screen unless edited at higher breakpoint",mobile_sm_title="Mobile landscape (SM)",mobile_sm_content="Styles set here are applied at 640px and up unless edited at higher breakpoint",tablet_md_title="Tablet (MD)",tablet_md_content="Styles set here are applied at 768px and up",tablet_lg_title="Tablet Landscape (LG)",tablet_lg_content="Styles set here are applied at 1024px and up unless edited at higher breakpoint",desktop_xl_title="Desktop (XL)",desktop_xl_content="Styles set here are applied at 1280px and up unless edited at higher breakpoint",large_desktop_2xl_title="Large Desktop (2XL)",large_desktop_2xl_content="Styles set here are applied at 1536px and up",Breakpoints$1="Breakpoints",clear="Clear",clear_canvas_title="Clear whole canvas?",clear_canvas_description="Are you sure you want to clear the whole canvas?",cancel="Cancel",yes="Yes",preview="Preview",settings="Settings",styling="Styling",data_provider="Data Provider",remove_provider_confirmation="Are you sure you want to remove <span class='text-blue-500'>{name}</span> provider?",remove_provider_warning="Your data provider will be removed from this page and all added data binding will be not visible on blocks.",remove="Remove",no_data_providers="You have no data providers registered. Please add a data provider to your project.",learn_more="Learn more",add_data_providers="Add data providers:",select_provider="Select a provider",choose="Choose",page_data_providers="Page data providers:",view_data="View Data",mark_as_global="Mark as Global",global_block_note="Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.",global_block_indicator="Global blocks are indicated with",global_block_category="Global blocks are available under 'Global' category",enter_global_block_name="Enter global block name",eg_header_footer="Eg: Header, Footer",blocks_selected="{{length}} blocks selected.",cut="Cut",copy="Copy",clear_selection="Clear Selection",dev_mode_message="This is dev mode. Visit",to_see_page_preview="to see page preview",theme_config={heading_font:"Heading Font",body_font:"Body Font",rounded_corner:"Rounded Corners",primary:"Primary",secondary:"Secondary",background:"Background",text_color:"Text Color",background_dark_mode:"Background (Dark Mode)",text_color_dark_mode:"Text Color (Dark Mode)"},web_blocks={box:"box",tag:"Tag",div:"div",level:"Level",header:"header",footer:"footer",section:"section",article:"article",aside:"aside",main:"main",nav:"navigation",figure:"figure",details:"details",summary:"summary",dialog:"dialog",strike:"strike",caption:"caption",legend:"legend",figcaption:"figure caption",mark:"mark",background_image:"Background Image",label:"Label",default:"default",icon_size:"Icon Size",icon_position:"Icon Position",start:"Start",end:"End",button:"Button",custom_html:"Custom HTML",html_code:"HTML Code",default_snippet:"The HTML snippet goes here...",placeholder:"Enter custom HTML code here",custom_script:"Custom Script",dark_mode:"Dark Mode",divider:"Divider",empty_box:"Empty Box",heading:"Heading",image:"Image",alt:"Alt",width:"Width",height:"Height",video:"Video",span:"Span",content:"Content",icon:"Icon",richtext:"Rich Text",list:"List",list_type:"List Type",listitem:"List Item",link:"Link",list_item:"List Item",none:"None",disc:"Disc",number:"Number",paragraph:"Paragraph",lightbox_link:"Lightbox Link",href:"Link",type:"Type",iframe:"iframe",inline:"inline",ajax:"ajax",autoplay:"Video autoplay",max_width:"Max Width",backdrop_color:"Background Color",gallery_name:"Gallery Name",slot:"Slot",empty_slot:"Empty Slot",text:"Text",video_url:"Video URL",controls:"Show Controls",loop:"Loop",muted:"Muted",checkbox:"Checkbox",required:"Required",checked:"Checked",submit_button:"Submit Button",form:"Form",submit_url:"Submit URL",error_message:"Error Message",success_message:"Success Message",input:"Input",value:"Value",show_label:"Show Label",field_name:"Field Name",radio:"Radio",multiple:"Multiple",options:"Options",select:"Select",multiple_choice:"Multiple Choice",textarea:"Textarea",rows:"Rows"},ai_assistant="AI Assistant",close_preview="Close Preview",saved="Saved",unsaved="Unsaved",saving="Saving...",page_is_empty="This page is empty.",Theme="Theme",Outline="Outline",clipboard_not_supported="Not supported",please_use_chrome_firefox_or_safari="Please use Chrome, Firefox or Safari",classes_copied_to_clipboard="Classes copied to clipboard",download_complete="Download complete",copied="Copied",enter_classes_separated_by_space="Enter classes separated by space",copy_classes_to_clipboard="Copy classes to clipboard",classes="Classes",ask_ai="Ask AI",edit_with_ai="Edit with AI",generating_please_wait="Generating... Please wait",stop$1="Stop",eg_this_page_is_about_an_ai_assistant_app_called_chai_studio_it_allows_users_to_create_beautiful_webpages_and_edit_content_with_ai="E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI.",ask_ai_to_edit_styles="Ask AI to edit styles",ask_ai_to_edit_content="Ask AI to edit content",ai_context="AI Context",please_select_a_block_to_ask_ai="Select a block to edit with AI",please_select_a_block_to_edit="Please select a block to edit",edit="Edit",tell_about_this_page_eg_this_page_is_about="Describe this page. E.g.: This page is about...",tag="Tag",value="Value",background_image="Background Image",enter_image_url="Enter image URL",replace_image="Replace image",choose_image="Choose image",images="Images",typography="Typography",background="Background",library="Library",blocks="Blocks",basic="Basic",media="Media",advanced="Advanced",form="Form",choose_icon_or_enter_svg="Choose an icon or enter SVG",groups="Groups",ui_libraries="UI Libraries",accordions="Accordions",buttons="Buttons",layouts="Layouts",choose_library="Choose library",no_library_found="No library found.",faq="FAQ",hero="Hero",features="Features",footer="Footer",navbar="Navbar",icons="Icons",testimonials="Testimonials",blog="Blog",ai_quick_prompts={improve_writing:"Improve writing",replace_placeholder_content:"Replace placeholder content",fix_grammar:"Fix grammar",make_longer:"Make longer",make_shorter:"Make shorter",add_emojis:"Add emojis",randomize:"Randomize"},sidebar={outline:"Outline",edit_block:"Edit Block",ai_assistant:"AI Assistant",theme:"Theme"},remove_context="Remove context",yes_delete="Yes, Delete",ai_context_updated="AI Context Updated",you_can_now_ask_ai_to_edit_your_content="You can now ask AI to edit your content.",lngEn={add_block,enter_paste_tailwind_html,click_to_add_block,core,custom_blocks,ui_library,import:"Import",html_snippet_description,tailwind_html_snippet,enter_code_snippet,import_html,note_imported_html,dark_mode,tree_view_no_blocks,canvas_empty,no_block_selected_for_styling,no_block_selected_for_ask_ai,no_styling_block_selected,drop_here_message,use_setting,mobile_xs_title,mobile_xs_content,mobile_sm_title,mobile_sm_content,tablet_md_title,tablet_md_content,tablet_lg_title,tablet_lg_content,desktop_xl_title,desktop_xl_content,large_desktop_2xl_title,large_desktop_2xl_content,Breakpoints:Breakpoints$1,clear,clear_canvas_title,clear_canvas_description,cancel,yes,preview,settings,styling,data_provider,remove_provider_confirmation,remove_provider_warning,remove,no_data_providers,learn_more,add_data_providers,select_provider,choose,page_data_providers,view_data,mark_as_global,global_block_note,global_block_indicator,global_block_category,enter_global_block_name,eg_header_footer,blocks_selected,cut,copy,delete:"Delete",clear_selection,dev_mode_message,to_see_page_preview,"flex.heading":"Flex Child","flex.basis":"Basis","flex.order":"Order","flex.flex":"Flex","flex.grow":"Grow","flex.shrink":"Shrink","grid.heading":"Grid Child","grid.col_span":"Col Span","grid.col_start":"Col Start","grid.col_end":"Col End","grid.row_span":"Row Span","grid.row_start":"Row Start","grid.row_end":"Row End","grid.order":"Order","layout.heading":"Layout","layout.width":"Width","layout.height":"Height","layout.margin":"Margin","layout.margin_all":"All","layout.margin_lr":"Left-Right","layout.margin_tb":"Top-Bottom","layout.margin_top":"Top","layout.margin_right":"Right","layout.margin_bottom":"Bottom","layout.margin_left":"Left","layout.padding":"Padding","layout.padding_all":"All","layout.padding_lr":"Left-Right","layout.padding_tb":"Top-Bottom","layout.padding_top":"Top","layout.padding_right":"Right","layout.padding_bottom":"Bottom","layout.padding_left":"Left","layout.space_bt":"Space Bt.","layout.space_lr":"Left-Right","layout.space_tb":"Top-Bottom","size.heading":"Size","size.min_width_height":"Min width & height","size.min_width":"Min Width","size.min_height":"Min Height","size.max_width_height":"Max width & height","size.max_width":"Max Width","size.max_height":"Max Height","size.object_options_aspect_ratio":"Object options & aspect ratio","size.aspect":"Aspect","size.fit":"Fit","size.position":"Position","display.heading":"Display","display.display":"Display","display.flex_options":"Flex options","display.flex_direction":"Direction","display.flex_wrap":"Wrap","display.justify_content":"Justify","display.align_content":"Content","display.align_items":"Items","display.gap":"Gap","display.gap_all":"All","display.gap_lr":"Left-Right","display.gap_tb":"Top-Bottom","display.grid_options":"Grid options","display.grid_columns":"Columns","display.grid_rows":"Rows","display.grid_auto_flow":"Auto Flow","display.grid_auto_cols":"Auto Cols","display.grid_auto_rows":"Auto Rows","display.visibility_opacity":"Visibility & Opacity","display.visibility":"Visibility","display.opacity":"Opacity","position.heading":"Position","position.position":"Position","position.options":"Position options","position.direction":"Direction","position.top":"Top","position.right":"Right","position.bottom":"Bottom","position.left":"Left","position.inset":"Inset","position.all":"All","position.lr":"Left Right","position.tb":"Top Bottom","position.z_index":"Z-Index","position.float_clear":"Float & Clear","position.float":"Float","position.clear":"Clear","position.overflow_overscroll":"Overflow & Overscroll","position.overflow":"Overflow","position.overscroll":"Overscroll","typography.heading":"Typography","typography.font":"Font","typography.size":"Size","typography.height":"Height","typography.weight":"Weight","typography.color":"Color","typography.alignments":"Alignments","typography.align":"Align","typography.valign":"V. Align","typography.spacing_decoration_more":"Spacing, decoration & more","typography.spacing":"Spacing","typography.decoration":"Decoration","typography.thickness":"Thickness","typography.transform":"Transform","typography.whitespace_breaks":"White space & breaks","typography.whitespace":"Whitespace","typography.wordbreak":"Wordbreak","background.heading":"Background","background.bgcolor":"Bg. Color","background.position_size_more":"Position, Size & more","background.attachment":"Attachment","background.clipping":"Clipping","background.origin":"Origin","background.position":"Position","background.repeat":"Repeat","background.size":"Size","background.gradient":"Gradient","background.gradient_colors":"Gradient colors","background.from_color":"From","background.via_color":"Via","background.to_color":"To","border.heading":"Border & Outline","border.width":"Width","border.all":"All","border.lr":"Left Right","border.tb":"Top bottom","border.top":"Top","border.right":"Right","border.bottom":"Bottom","border.left":"Left","border.corners":"Corners","border.top_left":"Top Left","border.top_right":"Top right","border.bottom_right":"Bottom right","border.bottom_left":"Bottom left","border.color":"Color","border.style":"Style","border.divide_options":"Divide options","border.divide_color":"Color","border.divide_style":"Style","border.outline_styling":"Outline styling","border.outline_width":"Width","border.outline_offset":"Offset","border.outline_style":"Style","border.ring_options":"Ring options","border.ring_width":"Width","border.ring_color":"Color","border.ring_offset_width":"Offset","border.ring_offset_color":"Off. color","effect.heading":"Effect & Animation","effect.shadow":"Shadow","effect.color":"Color","effect.cursor":"Cursor","effect.blend_cursor":"Blend & Cursor","effect.mix_blend":"Mix Blend","effect.bg_blend":"Bg. Blend","effect.transform":"Transform","effect.origin":"Origin","effect.scale":"Scale","effect.all":"All","effect.lr":"Left-Right","effect.tb":"Top-Bottom","effect.skew":"Skew","effect.translate":"Translate","effect.rotate":"Rotate","effect.animation":"Animation","effect.transition":"Transition","effect.easing":"Easing","effect.duration":"Duration","effect.delay":"Delay","classes.heading":"Classes",theme_config,web_blocks,ai_assistant,close_preview,saved,unsaved,saving,page_is_empty,Theme,Outline,clipboard_not_supported,please_use_chrome_firefox_or_safari,classes_copied_to_clipboard,download_complete,copied,enter_classes_separated_by_space,copy_classes_to_clipboard,classes,ask_ai,edit_with_ai,generating_please_wait,stop:stop$1,eg_this_page_is_about_an_ai_assistant_app_called_chai_studio_it_allows_users_to_create_beautiful_webpages_and_edit_content_with_ai,ask_ai_to_edit_styles,ask_ai_to_edit_content,ai_context,please_select_a_block_to_ask_ai,please_select_a_block_to_edit,edit,tell_about_this_page_eg_this_page_is_about,tag,value,background_image,enter_image_url,replace_image,choose_image,images,typography,background,library,blocks,basic,media,advanced,form,choose_icon_or_enter_svg,groups,ui_libraries,accordions,buttons,layouts,choose_library,no_library_found,faq,hero,features,footer,navbar,icons,testimonials,blog,ai_quick_prompts,sidebar,remove_context,yes_delete,ai_context_updated,you_can_now_ask_ai_to_edit_your_content};i18n.use(reactI18next.initReactI18next).init({resources:{en:{translation:lngEn}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const CoreBlock=({block:o,disabled:n,parentId:r})=>{const[,a]=jotai.useAtom(draggedBlockAtom),{type:i,icon:l,label:c}=o,{addCoreBlock:d,addPredefinedBlock:u}=useAddBlock(),[,x]=useSelectedBlockIds(),{clearHighlight:m}=useBlockHighlight(),h=()=>{if(lodashEs.has(o,"blocks")){const R=lodashEs.isFunction(o.blocks)?o.blocks():o.blocks;u(runtime.syncBlocksWithDefaults(R),r||null)}else d(o,r||null);emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK})},p=flagged.useFeature("dnd"),{t:f}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{disabled:n,onClick:h,type:"button",onDragStart:R=>{R.dataTransfer.setData("text/plain",JSON.stringify(lodashEs.omit(o,["component","icon"]))),R.dataTransfer.setDragImage(new Image,0,0),a(lodashEs.omit(o,["component","icon"])),setTimeout(()=>{x([]),m()},200)},draggable:p?"true":"false",className:"cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",children:[React.createElement(l||reactIcons.BoxIcon,{className:"w-4 h-4 mx-auto"}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"truncate text-xs",children:lodashEs.capitalize(f(c||i))})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:f(c||i)})})]})})},DefaultChaiBlocks=({parentId:o,gridCols:n="grid-cols-2"})=>{const r=runtime.useChaiBlocks(),a=useBuilderProp("filterChaiBlock",()=>!0),i=lodashEs.filter(r,a),l=lodashEs.groupBy(i,"category"),c=lodashEs.uniq(lodashEs.map(l.core,"group"));return jsxRuntime.jsxRuntimeExports.jsx(ChaiBuilderBlocks,{gridCols:n,parentId:o,groups:c,blocks:l.core})},CORE_GROUPS=["basic","typography","media","layout","form","advanced","other"],ChaiBuilderBlocks=({groups:o,blocks:n,parentId:r,gridCols:a="grid-cols-4"})=>{var d;const{t:i}=reactI18next.useTranslation(),[l]=useBlocksStore(),c=(d=lodashEs.find(l,u=>u._id===r))==null?void 0:d._type;return React.Children.toArray(lodashEs.map(lodashEs.sortBy(o,u=>CORE_GROUPS.indexOf(u)===-1?99:CORE_GROUPS.indexOf(u)),u=>lodashEs.reject(lodashEs.filter(lodashEs.values(n),{group:u}),{hidden:!0}).length?jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Accordion,{type:"single",value:u,collapsible:!0,className:"w-full",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:u,className:"border-border",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{className:"rounded-md bg-background px-4 py-2 capitalize text-foreground hover:no-underline",children:lodashEs.capitalize(i(u.toLowerCase()))}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionContent,{className:"mx-auto max-w-xl p-3",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"grid gap-2 "+a,children:React.Children.toArray(lodashEs.reject(lodashEs.filter(lodashEs.values(n),{group:u}),{hidden:!0}).map(x=>jsxRuntime.jsxRuntimeExports.jsx(CoreBlock,{parentId:r,block:x,disabled:!canAcceptChildBlock(c,x.type)||!canBeNestedInside(c,x.type)})))})})]})}):null))},addBlockTabAtom=atomWithStorage("__add_block_tab","library"),AddBlocksPanel=({className:o,showHeading:n=!0,parentId:r=void 0})=>{const{t:a}=reactI18next.useTranslation(),[i,l]=jotai.useAtom(addBlockTabAtom),[,c]=jotai.useAtom(showPredefinedBlockCategoryAtom),d=useBuilderProp("importHTMLSupport",!0);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:iconBase.cn("flex h-full w-full flex-col overflow-hidden",o),children:[n?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1",children:[jsxRuntime.jsxRuntimeExports.jsx("h1",{className:"flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col",children:a("Add block")}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"p-0 text-xs font-light leading-3 opacity-80 xl:pl-1",children:a(i==="html"?"enter_paste_tailwind_html":"click_to_add_block")})]}):null,jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Tabs,{onValueChange:u=>{c(""),l(u)},value:i,className:iconBase.cn("h-max"),children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.TabsList,{className:"grid w-full "+(d?"grid-cols-3":"grid-cols-2"),children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"library",children:a("library")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"core",children:a("blocks")}),d?jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"html",children:a("import")}):null]})}),i==="core"&&jsxRuntime.jsxRuntimeExports.jsx(contextMenu.ScrollArea,{className:"-mx-1.5 h-[calc(100vh-156px)] overflow-y-auto",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-2 w-full",children:jsxRuntime.jsxRuntimeExports.jsx(DefaultChaiBlocks,{gridCols:"grid-cols-4",parentId:r})})}),i==="library"&&jsxRuntime.jsxRuntimeExports.jsx(UILibraries,{parentId:r}),i==="html"&&d?jsxRuntime.jsxRuntimeExports.jsx(ImportHTML$1,{parentId:r}):null]})},AddBlocksPanel$1=AddBlocksPanel,AddBlocksDialog=()=>{const{t:o}=reactI18next.useTranslation(),[n,r]=React.useState(""),[a,i]=React.useState(!1);return useChaiBuilderMsgListener(({name:l,data:c=void 0})=>{l===CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK&&(r(c==null?void 0:c._id),i(!0)),l===CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK&&(r(""),i(!1))}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialog,{open:a,onOpenChange:()=>a?i(!1):"",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{className:"max-w-5xl overflow-hidden border-border",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{className:"flex flex-row items-center justify-between",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTitle,{className:"text-foreground",children:o("Add blocks")}),jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:()=>i(!1),className:"text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Cross2Icon,{className:"h-6 w-6"})})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar h-[500px] max-h-full overflow-hidden",children:jsxRuntime.jsxRuntimeExports.jsx(AddBlocksPanel$1,{parentId:n,showHeading:!1})})]})})};function FaCheck(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"},child:[]}]})(o)}function FaFilePen(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M0 64C0 28.7 28.7 0 64 0H224V128c0 17.7 14.3 32 32 32H384V299.6l-94.7 94.7c-8.2 8.2-14 18.5-16.8 29.7l-15 60.1c-2.3 9.4-1.8 19 1.4 27.8H64c-35.3 0-64-28.7-64-64V64zm384 64H256V0L384 128zM549.8 235.7l14.4 14.4c15.6 15.6 15.6 40.9 0 56.6l-29.4 29.4-71-71 29.4-29.4c15.6-15.6 40.9-15.6 56.6 0zM311.9 417L441.1 287.8l71 71L382.9 487.9c-4.1 4.1-9.2 7-14.9 8.4l-60.1 15c-5.5 1.4-11.2-.2-15.2-4.2s-5.6-9.7-4.2-15.2l15-60.1c1.4-5.6 4.3-10.8 8.4-14.9z"},child:[]}]})(o)}function FaLanguage(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M0 128C0 92.7 28.7 64 64 64H256h48 16H576c35.3 0 64 28.7 64 64V384c0 35.3-28.7 64-64 64H320 304 256 64c-35.3 0-64-28.7-64-64V128zm320 0V384H576V128H320zM178.3 175.9c-3.2-7.2-10.4-11.9-18.3-11.9s-15.1 4.7-18.3 11.9l-64 144c-4.5 10.1 .1 21.9 10.2 26.4s21.9-.1 26.4-10.2l8.9-20.1h73.6l8.9 20.1c4.5 10.1 16.3 14.6 26.4 10.2s14.6-16.3 10.2-26.4l-64-144zM160 233.2L179 276H141l19-42.8zM448 164c11 0 20 9 20 20v4h44 16c11 0 20 9 20 20s-9 20-20 20h-2l-1.6 4.5c-8.9 24.4-22.4 46.6-39.6 65.4c.9 .6 1.8 1.1 2.7 1.6l18.9 11.3c9.5 5.7 12.5 18 6.9 27.4s-18 12.5-27.4 6.9l-18.9-11.3c-4.5-2.7-8.8-5.5-13.1-8.5c-10.6 7.5-21.9 14-34 19.4l-3.6 1.6c-10.1 4.5-21.9-.1-26.4-10.2s.1-21.9 10.2-26.4l3.6-1.6c6.4-2.9 12.6-6.1 18.5-9.8l-12.2-12.2c-7.8-7.8-7.8-20.5 0-28.3s20.5-7.8 28.3 0l14.6 14.6 .5 .5c12.4-13.1 22.5-28.3 29.8-45H448 376c-11 0-20-9-20-20s9-20 20-20h52v-4c0-11 9-20 20-20z"},child:[]}]})(o)}function FaStar(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M316.9 18C311.6 7 300.4 0 288.1 0s-23.4 7-28.8 18L195 150.3 51.4 171.5c-12 1.8-22 10.2-25.7 21.7s-.7 24.2 7.9 32.7L137.8 329 113.2 474.7c-2 12 3 24.2 12.9 31.3s23 8 33.8 2.3l128.3-68.5 128.3 68.5c10.8 5.7 23.9 4.9 33.8-2.3s14.9-19.3 12.9-31.3L438.5 329 542.7 225.9c8.6-8.5 11.7-21.2 7.9-32.7s-13.7-19.9-25.7-21.7L381.2 150.3 316.9 18z"},child:[]}]})(o)}const LANGUAGES={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"},QUICK_PROMPTS=[{name:"Improve writing",icon:FaFilePen,prompt:"Improving writing in all text elements. Replacing placeholder content with meaningful relevant content."},{name:"Replace placeholder content",icon:FaRecycle,prompt:"Discard current placeholder content and replace with meaningful relevant content."},{name:"Fix grammar",icon:reactIcons.CheckIcon,prompt:"Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors."},{name:"Make longer",icon:reactIcons.ArrowUpIcon,prompt:"Make all text elements longer."},{name:"Make shorter",icon:reactIcons.ArrowDownIcon,prompt:"Make all text elements shorter."},{name:"Add emojis",icon:lucideReact.SmileIcon,prompt:"Add emojis to text elements if relevant."},{name:"Randomize",icon:lucideReact.ShuffleIcon,prompt:"Randomize all text elements."}];function QuickPrompts({onClick:o}){const{loading:n}=useAskAi(),{t:r}=reactI18next.useTranslation(),{selectedLang:a,fallbackLang:i}=useLanguages(),l=[...QUICK_PROMPTS];return a&&a!==i&&l.splice(0,0,{name:`Translate to ${lodashEs.get(LANGUAGES,a,a)}`,icon:FaLanguage$1,prompt:`Translate the content to ${lodashEs.get(LANGUAGES,a,a)}. Maintain same tone, style and length.`}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:n?"pointer-events-none opacity-50":"",children:jsxRuntime.jsxRuntimeExports.jsx("ul",{className:"space-y-2",children:l.map(({name:c,icon:d,subMenus:u,prompt:x})=>u?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Popover,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("li",{className:"flex cursor-pointer items-center space-x-2 rounded p-1 pl-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",children:[jsxRuntime.jsxRuntimeExports.jsx(d,{className:"h-4 w-4"}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:c})]},c)}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverContent,{side:"right",children:jsxRuntime.jsxRuntimeExports.jsx("ul",{children:jsxRuntime.jsxRuntimeExports.jsx("li",{children:"Happy"})})})]}):jsxRuntime.jsxRuntimeExports.jsxs("li",{onClick:()=>o(x),className:"flex cursor-pointer items-center space-x-2 rounded p-1 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",children:[jsxRuntime.jsxRuntimeExports.jsx(d,{className:"h-4 w-4"}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:r(c)})]},c))})})}const AIUserPrompt=({blockId:o})=>{const{t:n}=reactI18next.useTranslation(),{askAi:r,loading:a,error:i}=useAskAi(),[l,c]=React.useState(""),[d,u]=React.useState(!0),[x,m]=React.useState(),h=React.useRef(null),p=React.useRef(null);React.useEffect(()=>{var R;(R=h.current)==null||R.focus()},[]);const f=R=>{const{usage:j}=R||{};!i&&j&&m(j),p.current=setTimeout(()=>m(void 0),1e4),i||c("")};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{onClick:()=>u(!d),className:"flex cursor-pointer items-center justify-between border-b border-border py-2 text-sm font-bold text-muted-foreground hover:underline",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:n("Ask AI")}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 text-gray-500 "+(d?"rotate-180":"")})})]}),d&&o?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{ref:h,value:l,onChange:R=>c(R.target.value),placeholder:n("Ask AI to edit content"),className:"w-full",rows:3,onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),p.current&&clearTimeout(p.current),m(void 0),r("content",o,l,f))}}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"my-2 flex items-center gap-2",children:[a?null:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:l.trim().length<5||a,onClick:()=>{p.current&&clearTimeout(p.current),m(void 0),r("content",o,l,f)},variant:"default",className:"w-fit",size:"sm",children:a?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),n("generating_please_wait")]}):n("edit_with_ai")}),a?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Skeleton,{className:"flex w-full items-center space-x-1 px-4 py-1 pl-2",children:[jsxRuntime.jsxRuntimeExports.jsx(FaSpinner,{className:"h-4 w-4 animate-spin text-gray-500"}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs",children:n("Generating... Please wait...")})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"destructive",onClick:()=>stop(),className:"hidden w-fit",size:"sm",children:n("Stop")})]}):null]}),x?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"max-w-full",children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500",children:[jsxRuntime.jsxRuntimeExports.jsxs("span",{children:[n("Total tokens used"),": ",x.totalTokens]}),jsxRuntime.jsxRuntimeExports.jsx(Countdown,{})]})}):null,jsxRuntime.jsxRuntimeExports.jsx("div",{className:"max-w-full",children:i&&jsxRuntime.jsxRuntimeExports.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:i.message})}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx(QuickPrompts,{onClick:R=>{p.current&&clearTimeout(p.current),m(void 0),r("content",o,R,f)}})]}):d?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"p-4 text-center",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.SparklesIcon,{className:"mx-auto text-3xl text-muted-foreground"}),jsxRuntime.jsxRuntimeExports.jsx("h1",{children:n("Please select a block to Ask AI")})]})}):null]})},AISetContext=()=>{const{t:o}=reactI18next.useTranslation(),n=useBuilderProp("aiContext",""),[r,a]=React.useState(n),i=React.useRef(null),l=useBuilderProp("saveAiContextCallback",lodashEs.noop),[c,d]=React.useState(!1),[u,x]=React.useState(null),[,m]=React.useState(!1),{toast:h}=contextMenu.useToast(),p=React.useRef(null);React.useEffect(()=>{n&&a(n)},[n]);const f=async()=>{try{d(!0),x(null),await l(r),h({title:o("Updated AI Context"),description:o("You can now Ask AI to edit your content"),variant:"default"}),p.current.click()}catch(R){x(R)}finally{d(!1)}};return jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Accordion,{onValueChange:R=>{m(R!=="")},type:"single",collapsible:!0,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:"set-context",className:"border-none",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{ref:p,className:"border-b border-border py-2",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-full items-center justify-between",children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"font-bold text-muted-foreground",children:o("AI Context")})})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionContent,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{ref:i,value:r,onChange:R=>a(R.target.value),placeholder:o("Tell about this page eg this page is about"),className:"mt-1 w-full",rows:10,onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),f())}}),n.trim().length===0?jsxRuntime.jsxRuntimeExports.jsx("p",{className:"mt-2 text-xs text-gray-500",children:o("Eg: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI.")}):null,jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2 flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:r.trim().length<5,onClick:()=>f(),variant:"default",className:"w-fit",size:"sm",children:c?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),o("Generating... Please wait...")]}):o("Save")}),n.trim().length>0?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:n.trim().length===0,variant:"ghost",className:"w-fit",size:"sm",children:c?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),o("Generating... Please wait...")]}):o("Delete")})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogTitle,{children:[o("Delete context")," ?"]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogDescription,{})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogFooter,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogCancel,{children:o("Cancel")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogAction,{onClick:()=>{a(""),f()},children:o("Yes, Delete")})]})]})]}):null]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-2 max-w-full",children:u&&jsxRuntime.jsxRuntimeExports.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:u.message})})]})]})})},AskAI=()=>{const[o]=useSelectedBlockIds();return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2",children:[jsxRuntime.jsxRuntimeExports.jsx(AISetContext,{}),jsxRuntime.jsxRuntimeExports.jsx(AIUserPrompt,{blockId:lodashEs.first(o)})]})},AttrsEditor=React.memo(function o({preloadedAttributes:n=[],onAttributesChange:r}){const[a,i]=React.useState([]),[l,c]=React.useState(""),[d,u]=React.useState(""),[x,m]=React.useState(null),[h,p]=React.useState(""),f=React.useRef(null),R=React.useRef(null);React.useEffect(()=>{i(n)},[n]);const j=()=>{if(l.startsWith("@")){p("Attribute keys cannot start with '@'");return}if(l){const k=[...a,{key:l,value:d}];r(k),i(a),c(""),u(""),p("")}},E=k=>{const C=a.filter((I,N)=>N!==k);r(C),i(C)},y=k=>{m(k),c(a[k].key),u(a[k].value)},v=()=>{if(l.startsWith("@")){p("Attribute keys cannot start with '@'");return}if(x!==null&&l){const k=[...a];k[x]={key:l,value:d},r(k),i(k),m(null),c(""),u(""),p("")}},w=k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),x!==null?v():j())};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"max-w-full",children:[jsxRuntime.jsxRuntimeExports.jsxs("form",{onSubmit:k=>{k.preventDefault(),x!==null?v():j()},className:"space-y-3",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"w-full",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Label,{htmlFor:"attrKey",className:"text-xs",children:"Key"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Input,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrKey",ref:f,value:l,onChange:k=>c(k.target.value),placeholder:"Key",className:"h-8 text-sm"})]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"w-full",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Label,{htmlFor:"attrValue",className:"text-xs",children:"Value"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrValue",rows:2,ref:R,value:d,onChange:k=>u(k.target.value),onKeyDown:w,placeholder:"Value",className:"bg-background text-sm"})]})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{type:"submit",variant:"secondary",className:"h-8 w-fit text-sm",children:x!==null?"Save":"Add"}),h&&jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs text-red-500",children:h})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-4 space-y-1 overflow-y-auto",children:a.map((k,C)=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between rounded bg-muted p-1.5 text-sm",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mr-2 flex flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"truncate font-semibold",children:k.key}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"text-wrap max-w-[200px] text-muted-foreground",children:k.value.toString()})]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex-shrink-0",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>y(C),children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Edit2,{className:"h-3 w-3"}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Edit attribute"})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>E(C),children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.X,{className:"h-3 w-3"}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Remove attribute"})]})]})]},C))})]})}),BlockAttributesEditor=React__namespace.memo(()=>{const o=useSelectedBlock(),[n,r]=React.useState([]),[a]=useSelectedStylingBlocks(),i=useUpdateBlocksProps(),l=`${lodashEs.get(a,"0.prop")}_attrs`;React__namespace.useEffect(()=>{const d=lodashEs.map(lodashEs.get(o,l),(u,x)=>({key:x,value:u}));lodashEs.isEmpty(d)?r([]):r(d)},[lodashEs.get(o,l)]);const c=React__namespace.useCallback((d=[])=>{const u={};lodashEs.forEach(d,x=>{lodashEs.isEmpty(x.key)||lodashEs.set(u,x.key,x.value)}),i([lodashEs.get(o,"_id")],{[l]:u})},[o,i,l]);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex-col gap-y-2",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx(AttrsEditor,{preloadedAttributes:n,onAttributesChange:c})})})})});function getDNDSupport(){return new URLSearchParams(window.location.search).has("dnd")}const FEATURE_TOGGLES={dnd:getDNDSupport()},UndoRedo=()=>{const{hasUndo:o,hasRedo:n,undo:r,redo:a}=useUndoManager();return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:!o(),size:"sm",onClick:r,className:"rounded-full",variant:"ghost",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ResetIcon,{})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:!n(),onClick:a,size:"sm",className:"rounded-full",variant:"ghost",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ResetIcon,{className:"rotate-180 scale-y-[-1] transform"})})]})};function DarkMode(){const[o,n]=useDarkMode();return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.SunIcon,{className:"size-4 shrink-0"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Switch,{id:"dark-mode-switch",checked:o,onCheckedChange:()=>{n(!o)},className:`${o?"bg-violet-600":"bg-violet-300"} relative ml-2 inline-flex h-[20px] w-[40px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`,children:jsxRuntime.jsxRuntimeExports.jsx("span",{"aria-hidden":"true",className:`${o?"translate-x-5":"translate-x-0"} pointer-events-none -mt-px inline-block h-[18px] w-[20px] transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`})}),jsxRuntime.jsxRuntimeExports.jsx(FaMoon,{className:"size-4 ml-3 shrink-0"})]})}const TabletIcon=({landscape:o=!1})=>jsxRuntime.jsxRuntimeExports.jsx("svg",{className:o?"rotate-90":"",stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 448 512",height:"14px",width:"14px",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M400 0H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V48c0-26.5-21.5-48-48-48zM224 480c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm176-108c0 6.6-5.4 12-12 12H60c-6.6 0-12-5.4-12-12V60c0-6.6 5.4-12 12-12h328c6.6 0 12 5.4 12 12v312z"})}),WEB_BREAKPOINTS=[{title:"mobile_xs_title",content:"mobile_xs_content",breakpoint:"xs",icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.MobileIcon,{}),width:400},{title:"mobile_sm_title",content:"mobile_sm_content",breakpoint:"sm",icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.MobileIcon,{className:"rotate-90"}),width:640},{title:"tablet_md_title",content:"tablet_md_content",breakpoint:"md",icon:jsxRuntime.jsxRuntimeExports.jsx(TabletIcon,{}),width:800},{title:"tablet_lg_title",content:"tablet_lg_content",breakpoint:"lg",icon:jsxRuntime.jsxRuntimeExports.jsx(TabletIcon,{landscape:!0}),width:1024},{title:"desktop_xl_title",content:"desktop_xl_content",breakpoint:"xl",icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.LaptopIcon,{}),width:1420},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",breakpoint:"2xl",icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DesktopIcon,{}),width:1920}],BreakpointCard=({title:o,content:n,currentBreakpoint:r,breakpoint:a,width:i,icon:l,onClick:c})=>{const{t:d}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.HoverCard,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.HoverCardTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{onClick:()=>c(i),size:"sm",variant:a===r?"secondary":"ghost",children:l})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.HoverCardContent,{className:"w-52 border-border",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsxRuntimeExports.jsx("h4",{className:"text-sm font-semibold",children:d(o)}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs",children:d(n)})]})})})]})},Breakpoints=()=>{const[,o,n]=useCanvasWidth(),[r,a]=useSelectedBreakpoints(),{t:i}=reactI18next.useTranslation(),l=useBuilderProp("breakpoints",WEB_BREAKPOINTS),c=d=>{r.includes(d)?r.length>2&&a(r.filter(u=>u!==d)):a(u=>[...u,d])};return l.length<4?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center rounded-md",children:lodashEs.map(l,d=>React.createElement(BreakpointCard,{...d,onClick:n,key:d.breakpoint,currentBreakpoint:o}))}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center rounded-md",children:[lodashEs.map(l.filter(d=>lodashEs.includes(r,lodashEs.toUpper(d.breakpoint))),d=>React.createElement(BreakpointCard,{...d,onClick:n,key:d.breakpoint,currentBreakpoint:o})),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenu,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"cursor-pointer px-2.5 hover:opacity-80",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DotsVerticalIcon,{className:"scale-90 transform"})})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenuContent,{className:"w-56 border-border text-xs",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuLabel,{children:i("Breakpoints")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuSeparator,{}),lodashEs.map(l,d=>jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuCheckboxItem,{disabled:d.breakpoint==="xs",onCheckedChange:()=>c(lodashEs.toUpper(d.breakpoint)),checked:lodashEs.includes(r,lodashEs.toUpper(d.breakpoint)),children:i(d.title)},d.breakpoint))]})]})]})},ClearCanvas=()=>{const{t:o}=reactI18next.useTranslation(),{setNewBlocks:n}=useBlocksStoreUndoableActions(),[,r]=useSelectedBlockIds(),[,a]=useSelectedStylingBlocks(),i=React.useCallback(()=>{n([]),r([]),a([])},[n]);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{size:"sm",variant:"ghost",className:"flex items-center gap-x-1",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.EraserIcon,{})," ",o("Clear")]})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{className:"border-border",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTitle,{className:"text-foreground",children:o("Clear Canvas")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogDescription,{children:o("Are you sure you want to clear the page?")})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogFooter,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogCancel,{className:"text-foreground",children:o("Cancel")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogAction,{onClick:i,children:o("Yes")})]})]})]})})},LanguageSelector=()=>{const{fallbackLang:o,languages:n,selectedLang:r,setSelectedLang:a}=useLanguages(),i=(r==null?void 0:r.length)>0?r:o,l=React.useMemo(()=>{const c=[];return lodashEs.forEach(lodashEs.uniq([o,...n]),d=>{const u=lodashEs.get(LANGUAGES,d);u&&c.push({key:d,value:u,default:d===o})}),c},[o,n]);return lodashEs.isEmpty(n)&&i==="en"?null:lodashEs.isEmpty(n)&&i!=="en"?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-1 text-sm text-blue-500 hover:text-blue-600",children:[jsxRuntime.jsxRuntimeExports.jsx(FaLanguage,{className:"h-4 w-4"}),lodashEs.get(LANGUAGES,i)]}):jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenu,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{size:"sm",variant:"ghost",className:"flex items-center gap-x-1 text-blue-500 hover:text-blue-600",children:[jsxRuntime.jsxRuntimeExports.jsx(FaLanguage,{className:"h-4 w-4"}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{children:[" ",lodashEs.get(LANGUAGES,i)]}),jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ChevronDownIcon,{className:"h-4 w-4"})]})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuContent,{className:"border-border",children:lodashEs.map(l,c=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenuItem,{className:iconBase.cn("flex cursor-pointer items-center text-sm",c.key===i&&"!bg-blue-500 text-white hover:!text-white"),onClick:()=>a(c.key),children:[jsxRuntime.jsxRuntimeExports.jsx("div",{children:c.value}),c.key===o?jsxRuntime.jsxRuntimeExports.jsx(FaStar,{className:"ml-2 h-4 w-4 text-yellow-400"}):null]}))})]})},CanvasTopBar=()=>{const o=useBuilderProp("darkMode",!0),[n]=useCanvasZoom();return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-10 items-center justify-between border-b border-border bg-background/70 px-2",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full space-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx(Breakpoints,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Separator,{orientation:"vertical"}),o?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(DarkMode,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Separator,{orientation:"vertical"})]}):null,jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex w-12 cursor-not-allowed items-center justify-center gap-x-1 space-x-0 font-medium text-gray-400",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"text-xs leading-3",children:[lodashEs.round(n,0),"%"]})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Separator,{orientation:"vertical"}),jsxRuntime.jsxRuntimeExports.jsx(UndoRedo,{})]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full items-center space-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx(LanguageSelector,{}),jsxRuntime.jsxRuntimeExports.jsx(ClearCanvas,{})]})]})};function BlockAttributesToggle(){const{t:o}=reactI18next.useTranslation(),[n,r]=React.useState(!0),[a]=useSelectedStylingBlocks();return lodashEs.isEmpty(a)?null:jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{onClick:()=>r(!n),className:"flex cursor-pointer items-center justify-between border-b border-border py-2 text-sm font-bold text-muted-foreground hover:underline",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:o("Attributes")}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 text-gray-500 "+(n?"rotate-180":"")})})]}),n&&jsxRuntime.jsxRuntimeExports.jsx(BlockAttributesEditor,{})]})}const SettingsPanel=()=>{const o=useSelectedBlock(),{t:n}=reactI18next.useTranslation(),r=useBuilderProp("onError",lodashEs.noop);return lodashEs.isNull(o)?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"p-4 text-center",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.MixerHorizontalIcon,{className:"mx-auto text-3xl"}),jsxRuntime.jsxRuntimeExports.jsx("h1",{children:n("please_select_a_block_to_edit")})]})}):jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:r,children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex max-h-full w-full flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx(BlockSettings,{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx(BlockStyling,{}),jsxRuntime.jsxRuntimeExports.jsx(BlockAttributesToggle,{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{})]})})},SettingsPanel$1=SettingsPanel;function LayoutCard({disabled:o=!1,description:n,title:r,selected:a,onSelect:i,children:l}){const{t:c}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Card,{"aria-disabled":o,className:`cursor-pointer border-border transition-all ${a?"ring-2 ring-secondary":""} ${o?"cursor-not-allowed opacity-50":""}`,onClick:i,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.CardContent,{className:"p-4",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxRuntimeExports.jsx("h3",{className:"text-lg font-semibold",children:r}),a&&jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CheckIcon,{className:"h-6 w-6 rounded-full bg-background p-px text-foreground"})]}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:n}),l,jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:o,className:"mt-4 w-full",variant:a?"default":"outline",children:c(o?"Coming soon":a?"Selected":"Select")})]})})}const ChooseLayout=({open:o,close:n})=>{const{t:r}=reactI18next.useTranslation(),[a,i]=useLayoutVariant(),l=c=>{i(c),n()};return jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialog,{open:o,onOpenChange:()=>o?n():"",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{className:"max-w-4xl overflow-hidden border-border",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{className:"flex flex-row items-center justify-between",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTitle,{className:"text-foreground",children:r("Choose Builder Layout")}),jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:()=>n(),className:"text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Cross2Icon,{className:"h-6 w-6"})})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar max-h-full overflow-hidden",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[jsxRuntime.jsxRuntimeExports.jsx(LayoutCard,{title:r("Single side panel"),description:r("Suitable for smaller screens. Bigger canvas size."),selected:a==="SINGLE_SIDE_PANEL",onSelect:()=>l("SINGLE_SIDE_PANEL"),children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col rounded border border-border",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"borde-b h-4 border-b border-border"}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-32",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-3/4 border-l border-border bg-background"})]})]})}),jsxRuntime.jsxRuntimeExports.jsx(LayoutCard,{title:r("Dual side panel"),description:r("Suitable for larger screens. Blocks settings is always visible."),selected:a==="DUAL_SIDE_PANEL",onSelect:()=>l("DUAL_SIDE_PANEL"),children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col rounded border border-border",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"borde-b h-4 border-b border-border"}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-32",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-2/4 border-x border-border bg-background"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"})]})]})}),jsxRuntime.jsxRuntimeExports.jsx(LayoutCard,{disabled:!0,title:r("Dual side panel advanced"),description:r("Suitable for heavy styling & block editing. Setting are always visible."),selected:!1,onSelect:()=>{},children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col rounded border border-border",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"borde-b h-4 border-b border-border"}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-32",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-2/4 border-x border-border bg-background"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"})]})]})})]})})]})})},HotKeys=()=>{const{t:o}=reactI18next.useTranslation(),n={"ctrl + Z":"Undo","ctrl + Y":"Redo","ctrl + D":"Duplicate"},r={"ctrl + S":"Save page",esc:"Deselect blocks",del:"Delete block"};return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Dialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTrigger,{children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{className:"mb-2 rounded-lg p-2 transition-colors",variant:"ghost",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.KeyboardIcon,{className:"size-4"})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{side:"right",children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:o("Keyboard shortcuts")})})]})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogContent,{className:"border-border sm:max-w-[525px]",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogHeader,{children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTitle,{className:"text-foreground",children:o("Keyboard shortcuts")})}),jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mr-8 flex flex-col space-y-2 border-r border-border",children:Object.keys(n).map(a=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-4",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Badge,{variant:"outline",className:"border border-border p-1 px-2",children:o(a)}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-muted-foreground",children:o(n[a])})]},a))}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col space-y-2",children:Object.keys(r).map(a=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-4",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Badge,{variant:"outline",className:"border border-border p-1 px-2",children:o(a)}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-muted-foreground",children:o(r[a])})]},a))})]})})]})]})},ViewProviderData=({provider:o,onClose:n})=>{const{t:r}=reactI18next.useTranslation(),[a,i]=React.useState(null),l=useBuilderProp("onError",lodashEs.noop);return React.useEffect(()=>{o&&(o.mockFn?o.mockFn:o.dataFn)().then(d=>i(d))},[o]),o?jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Dialog,{onOpenChange:c=>c?"":n(),defaultOpen:!0,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogContent,{className:"border-border",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogTitle,{className:"text-foreground",children:[r("data_provider"),": ",o.name]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogDescription,{children:o.description})]}),jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:l,children:jsxRuntime.jsxRuntimeExports.jsx(JsonView,{data:a,shouldExpandNode:allExpanded,style:{...defaultStyles,container:"max-h-[80vh] overflow-y-auto text-[12px] leading-[1.5] tracking-wide font-mono",stringValue:"text-orange-600",label:"text-green-900 font-semibold pr-1 tracking-wider"}})})]})}):null};function RemoveProviderConfirmation({children:o,name:n,onRemove:r}){const{t:a}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTrigger,{asChild:!0,children:o}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTitle,{dangerouslySetInnerHTML:{__html:a("remove_provider_confirmation").replace("{name}",n)}}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogDescription,{children:a("remove_provider_warning")})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogFooter,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogCancel,{children:a("cancel")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogAction,{onClick:r,className:"bg-red-600 hover:bg-red-700",children:a("remove")})]})]})]})}const PageDataProviders=()=>{const{t:o}=reactI18next.useTranslation(),n=React.useMemo(()=>runtime.getChaiDataProviders(),[]),[r,a]=usePageDataProviders(),[,i]=jotai.useAtom(builderSaveStateAtom),[l,c]=React.useState(lodashEs.filter(n,j=>lodashEs.map(r,"providerKey").includes(j.providerKey))),[d,u]=React.useState(""),[x,m]=React.useState(null),h=lodashEs.filter(n.map(j=>lodashEs.map(l,"providerKey").includes(j.providerKey)?null:{value:j.providerKey,label:j.name}),j=>!lodashEs.isNull(j)),p=j=>{const E=lodashEs.find(n,{providerKey:j});c(y=>[...y,E]),a(y=>[...y,{providerKey:E.providerKey,args:{}}]),u(""),i("UNSAVED")},f=j=>{c(E=>lodashEs.filter(E,y=>y.providerKey!==j.providerKey)),a(E=>lodashEs.filter(E,y=>y.providerKey!==j.providerKey)),i("UNSAVED")},R=j=>m(j);return lodashEs.isEmpty(n)?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1.5 p-4 text-xs text-gray-500",children:[o("no_data_providers"),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("a",{className:"text-blue-500",href:"https://chaibuilder.com/docs/registering-data-providers",target:"_blank",children:o("learn_more")})]})}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"px-1",children:[jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("label",{children:jsxRuntime.jsxRuntimeExports.jsx("p",{className:"mb-1.5 text-xs text-gray-500",children:o("add_data_providers")})}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center space-x-1",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Select,{value:d,onValueChange:j=>p(j),children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.SelectTrigger,{className:"w-full",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.SelectValue,{placeholder:o("select_provider")})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.SelectContent,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.SelectItem,{value:"",children:o("choose")}),h.map(j=>jsxRuntime.jsxRuntimeExports.jsx(contextMenu.SelectItem,{value:j.value,children:j.label},j.value))]})]})}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:`border-t border-border ${l.length?"block":"hidden"}`,children:[jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"flex-1 pb-1.5 pt-4 text-xs font-medium text-gray-500",children:[o("page_data_providers"),":"]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:l.map(j=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"w-full rounded-lg border border-border bg-card text-card-foreground shadow-sm","data-v0-t":"card",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col space-y-1.5 px-4 pt-4",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{children:[jsxRuntime.jsxRuntimeExports.jsx("h3",{className:"font-medium leading-4",children:j.name}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"pt-1 text-xs text-gray-400",children:j.description})]})})}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between p-2 py-2",children:[jsxRuntime.jsxRuntimeExports.jsxs("button",{onClick:()=>R(j),className:"inline-flex h-9 items-center justify-center rounded-md px-3 text-xs font-medium text-blue-500 underline-offset-4 ring-offset-background transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",children:[jsxRuntime.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"mr-2 h-4 w-4",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),jsxRuntime.jsxRuntimeExports.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),o("view_data")]}),jsxRuntime.jsxRuntimeExports.jsx(RemoveProviderConfirmation,{onRemove:()=>f(j),name:j.name,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{className:"inline-flex h-9 items-center justify-center rounded-md px-3 text-xs font-medium text-red-500 underline-offset-4 ring-offset-background transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",children:[jsxRuntime.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"mr-2 h-4 w-4",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M3 6h18"}),jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),o("remove")]})})]})]},j.providerKey))}),jsxRuntime.jsxRuntimeExports.jsx(ViewProviderData,{onClose:()=>m(null),provider:x})]})]})};function AiFillDatabase(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M832 64H192c-17.7 0-32 14.3-32 32v224h704V96c0-17.7-14.3-32-32-32zM288 232c-22.1 0-40-17.9-40-40s17.9-40 40-40 40 17.9 40 40-17.9 40-40 40zM160 928c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V704H160v224zm128-136c22.1 0 40 17.9 40 40s-17.9 40-40 40-40-17.9-40-40 17.9-40 40-40zM160 640h704V384H160v256zm128-168c22.1 0 40 17.9 40 40s-17.9 40-40 40-40-17.9-40-40 17.9-40 40-40z"},child:[]}]})(o)}const TopBar=React.lazy(()=>Promise.resolve().then(()=>require("./Topbar-mnYBenY0.cjs")));function useSidebarMenuItems(o){const n=o==="SINGLE_SIDE_PANEL",{t:r}=reactI18next.useTranslation(),a=useBuilderProp("dataBindingSupport",!1),i=useBuilderProp("askAiCallBack",null);return React.useMemo(()=>{const l=[{icon:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Layers,{size:20}),label:"sidebar.outline",component:()=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mt-8",children:jsxRuntime.jsxRuntimeExports.jsx(Outline$1,{})})},n?{icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.GearIcon,{className:"size-5"}),label:"sidebar.edit_block",component:SettingsPanel$1}:null,a?{icon:jsxRuntime.jsxRuntimeExports.jsx(AiFillDatabase,{className:"size-3"}),label:r("Data Providers"),component:PageDataProviders}:null,i?{icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.LightningBoltIcon,{className:"size-5"}),label:"sidebar.ai_assistant",component:AskAI}:null,{icon:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.PaintBucketIcon,{size:20}),label:"sidebar.theme",component:()=>jsxRuntime.jsxRuntimeExports.jsx(ThemeOptions,{showHeading:!1})}];return lodashEs.compact(l)},[n,a,r,i])}function isDualLayout(o){return o!=="SINGLE_SIDE_PANEL"}const RootLayout=()=>{const[o,n]=React.useState(0),[r]=useLayoutVariant(),[a,i]=React.useState(!1);useChaiBuilderMsgListener(({name:p})=>{p===CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS&&n(1)});const l=useBuilderProp("sideBarComponents.top",[]),c=p=>{p.preventDefault()},d=p=>{n(o===p?null:p)},u=useSidebarMenuItems(r),{t:x}=reactI18next.useTranslation(),m=[...u,...l],h=useBuilderProp("htmlDir","ltr");return jsxRuntime.jsxRuntimeExports.jsx("div",{dir:h,className:"h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.TooltipProvider,{children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{onContextMenu:c,className:"flex h-screen max-h-full flex-col bg-background text-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-14 w-screen shrink-0 border-b border-border",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{children:jsxRuntime.jsxRuntimeExports.jsx(TopBar,{})})}),jsxRuntime.jsxRuntimeExports.jsxs("main",{className:"relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex w-12 flex-col items-center justify-between border-r border-border py-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col",children:m.map((p,f)=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:o===f?"default":"ghost",className:"mb-2 rounded-lg p-2 transition-colors",onClick:()=>d(f),children:lodashEs.get(p,"icon",null)},f)}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{side:"right",children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:x(p.label)})})]},"button"+f))}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col space-y-1",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"ghost",onClick:()=>i(!0),children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.LayoutTemplate,{size:20})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{side:"right",children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:x("Choose Builder Layout")})})]}),jsxRuntime.jsxRuntimeExports.jsx(HotKeys,{})]})]}),jsxRuntime.jsxRuntimeExports.jsx(framerMotion.motion.div,{className:"h-full max-h-full border-r border-border",initial:{width:280},animate:{width:o!==null?280:0},transition:{duration:.3,ease:"easeInOut"},children:o!==null&&jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar overflow h-full overflow-x-hidden",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col p-3",children:[jsxRuntime.jsxRuntimeExports.jsxs("h2",{className:"-mt-1 flex h-10 items-center space-x-1 text-base font-bold",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"rtl:ml-2 rtl:inline-block",children:lodashEs.get(m,`${o}.icon`,null)}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:x(m[o].label)})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex-1",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx("div",{children:"Loading..."}),children:React.createElement(lodashEs.get(m,`${o}.component`,null),{})})})]})})}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full max-h-full flex-1 flex-col bg-slate-800/20",children:[jsxRuntime.jsxRuntimeExports.jsx(CanvasTopBar,{}),jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{children:jsxRuntime.jsxRuntimeExports.jsx(CanvasArea$1,{})})]}),isDualLayout(r)?jsxRuntime.jsxRuntimeExports.jsx(framerMotion.motion.div,{className:"h-full max-h-full border-l border-border",initial:{width:280},animate:{width:280},transition:{duration:.3,ease:"easeInOut"},children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar overflow h-full max-h-full overflow-x-hidden",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex max-h-full flex-col p-3",children:[jsxRuntime.jsxRuntimeExports.jsxs("h2",{className:"-mt-1 flex h-10 items-center space-x-1 text-base font-bold",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.EditIcon,{size:"16",className:"rtl:ml-2"}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:x("Block Settings")})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex-1",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx("div",{children:"Loading..."}),children:jsxRuntime.jsxRuntimeExports.jsx(SettingsPanel$1,{})})})]})})}):null]})]}),jsxRuntime.jsxRuntimeExports.jsx(AddBlocksDialog,{}),jsxRuntime.jsxRuntimeExports.jsx(ChooseLayout,{open:a,close:()=>i(!1)})]})})},builderStore=jotai.getDefaultStore(),SmallScreenMessage=()=>jsxRuntime.jsxRuntimeExports.jsx("section",{className:"h-screen w-screen bg-gray-900 py-12 sm:py-16 lg:py-20 xl:hidden",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mx-auto max-w-md text-center",children:[jsxRuntime.jsxRuntimeExports.jsx("img",{src:"https://fldwljgzcktqnysdkxnn.supabase.co/storage/v1/object/public/chaibuilder-blob-storage/175ac8d8-37fe-4707-bb4a-3c0cd6a6db75/gVH7O-Ir_400x400.png",alt:"Chai Builder",className:"mx-auto w-14 rounded-full"}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("h2",{className:"text-4xl font-bold text-white",children:"Screen too small"}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"mt-6 text-sm font-medium leading-6 text-white text-opacity-70",children:"Please view this page on greater than 1280px screen width."})]})})}),setDebugLogs=o=>{},PreviewScreen=()=>{const[o,n]=usePreviewMode(),{t:r}=reactI18next.useTranslation(),a=useBuilderProp("previewComponent",null);return o?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:iconBase.cn("fixed inset-0 z-[999] bg-background",o?"block":"hidden"),children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{size:"sm",className:"absolute right-0 top-0 m-4 space-x-2",onClick:()=>n(!1),children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.EyeClosedIcon,{}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:r("close_preview")})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{children:a?jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-96 w-full"}),children:React.createElement(a)}):null})]}):null},getParentNodeIds=(o,n)=>{const r=[];let a=lodashEs.find(o,{_id:n}),i=lodashEs.get(a,"_parent","");for(;lodashEs.isString(i)&&!lodashEs.isEmpty(i);)r.push(a==null?void 0:a._parent),a=lodashEs.find(o,{_id:i}),i=a==null?void 0:a._parent;return lodashEs.flatten(r)},expandedIdsAtom=jotai.atom([]),useExpandTree=()=>{const[o]=useSelectedBlockIds(),n=jotai.useAtomValue(presentBlocksAtom),[,r]=jotai.useAtom(expandedIdsAtom);React.useEffect(()=>{let a=[];const i=lodashEs.first(o);lodashEs.isString(i)&&(a=[i,...getParentNodeIds(n,i)]),r(a)},[o,n,r])},useAutoSave=()=>{const{savePage:o}=useSavePage(),n=useBuilderProp("autoSaveSupport",!0),r=useBuilderProp("autoSaveInterval",60);web.useIntervalEffect(()=>{n&&o()},r*1e3)},ChaiBuilderComponent=o=>{const[,n]=useBlocksStore(),[,r]=useBrandingOptions(),a=useBuilderReset(),[i]=useAtom(builderSaveStateAtom),l=React.useMemo(()=>o.layout||RootLayout,[o.layout]);return useAtom(selectedLibraryAtom),useKeyEventWatcher(),useExpandTree(),useAutoSave(),useWatchGlobalBlocks(),useWatchRSCBlocks(),React.useEffect(()=>{builderStore.set(chaiBuilderPropsAtom,lodashEs.omit(o,["blocks","subPages","brandingOptions","dataProviders","customRootLayout","translations"]))},[o]),React.useEffect(()=>{builderStore.set(dataProvidersAtom,o.dataProviders||[])},[o.dataProviders]),React.useEffect(()=>{n(o.blocks||[]),a()},[o.blocks]),React.useEffect(()=>{i18n.changeLanguage(o.locale||"en")},[o.locale]),React.useEffect(()=>{setDebugLogs(o.showDebugLogs)},[o.showDebugLogs]),React.useEffect(()=>{o.translations&&lodashEs.each(o.translations,(c,d)=>{i18n.addResourceBundle(d,"translation",c,!0,!0)})},[o.translations]),React.useEffect(()=>{r(o.brandingOptions)},[o.brandingOptions,r]),React.useEffect(()=>(i!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[i]),jsxRuntime.jsxRuntimeExports.jsx(l,{})},ChaiBuilderEditor=o=>{const n=o._flags||{},r=o.onError||lodashEs.noop;return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen",children:jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:r,children:jsxRuntime.jsxRuntimeExports.jsxs(flagged.FlagsProvider,{features:{...FEATURE_TOGGLES,...n},children:[jsxRuntime.jsxRuntimeExports.jsx(SmallScreenMessage,{}),jsxRuntime.jsxRuntimeExports.jsx(ChaiBuilderComponent,{...o}),jsxRuntime.jsxRuntimeExports.jsx(PreviewScreen,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Toaster,{})]})})})};exports.AISetContext=AISetContext;exports.AIUserPrompt=AIUserPrompt;exports.AddBlocksDialog=AddBlocksDialog;exports.AddBlocksPanel=AddBlocksPanel$1;exports.BlockAttributesEditor=BlockAttributesEditor;exports.BlockSettings=BlockSettings;exports.BlockStyling=BlockStyling;exports.Breakpoints=Breakpoints;exports.CHAI_BUILDER_EVENTS=CHAI_BUILDER_EVENTS;exports.CanvasArea=CanvasArea$1;exports.ChaiBuilderEditor=ChaiBuilderEditor;exports.ChaiSelect=ChaiSelect$1;exports.DarkMode=DarkMode;exports.DefaultChaiBlocks=DefaultChaiBlocks;exports.FaCheck=FaCheck;exports.ImportHTML=ImportHTML$1;exports.Outline=Outline$1;exports.ThemeOptions=ThemeOptions;exports.UILibraries=UILibraries;exports.UndoRedo=UndoRedo;exports.emitChaiBuilderMsg=emitChaiBuilderMsg;exports.getBlocksFromHTML=getBlocksFromHTML;exports.getClassValueAndUnit=getClassValueAndUnit;exports.useAddBlock=useAddBlock;exports.useAddClassesToBlocks=useAddClassesToBlocks;exports.useBlockHighlight=useBlockHighlight;exports.useBlocksStore=useBlocksStore;exports.useBlocksStoreUndoableActions=useBlocksStoreUndoableActions;exports.useBrandingOptions=useBrandingOptions;exports.useBuilderProp=useBuilderProp;exports.useBuilderReset=useBuilderReset;exports.useCanvasWidth=useCanvasWidth;exports.useCanvasZoom=useCanvasZoom;exports.useChaiBuilderMsgListener=useChaiBuilderMsgListener;exports.useCodeEditor=useCodeEditor;exports.useCopyBlockIds=useCopyBlockIds;exports.useCopyToClipboard=useCopyToClipboard;exports.useCurrentPage=useCurrentPage;exports.useCutBlockIds=useCutBlockIds;exports.useDarkMode=useDarkMode;exports.useDuplicateBlocks=useDuplicateBlocks;exports.useGlobalBlocksList=useGlobalBlocksList;exports.useGlobalBlocksStore=useGlobalBlocksStore;exports.useHiddenBlockIds=useHiddenBlockIds;exports.useHighlightBlockId=useHighlightBlockId;exports.useLanguages=useLanguages;exports.useLayoutVariant=useLayoutVariant;exports.usePasteBlocks=usePasteBlocks;exports.usePreviewMode=usePreviewMode;exports.useRemoveBlocks=useRemoveBlocks;exports.useRemoveClassesFromBlocks=useRemoveClassesFromBlocks;exports.useSavePage=useSavePage;exports.useSelectedBlock=useSelectedBlock;exports.useSelectedBlockAllClasses=useSelectedBlockAllClasses;exports.useSelectedBlockCurrentClasses=useSelectedBlockCurrentClasses;exports.useSelectedBlockIds=useSelectedBlockIds;exports.useSelectedBlocksDisplayChild=useSelectedBlocksDisplayChild;exports.useSelectedBreakpoints=useSelectedBreakpoints;exports.useSelectedStylingBlocks=useSelectedStylingBlocks;exports.useStylingBreakpoint=useStylingBreakpoint;exports.useStylingState=useStylingState;exports.useUILibraryBlocks=useUILibraryBlocks;exports.useUndoManager=useUndoManager;exports.useUpdateBlocksProps=useUpdateBlocksProps;exports.useUpdateBlocksPropsRealtime=useUpdateBlocksPropsRealtime;
63
+ ${a}`}const askAiProcessingAtom=jotai.atom(!1),useAskAi=()=>{const[o,n]=jotai.useAtom(askAiProcessingAtom),[r,a]=React.useState(null),i=useBuilderProp("askAiCallBack",null),l=useStreamMultipleBlocksProps(),c=useUpdateMultipleBlocksProps(),[d]=useBlocksStore(),{selectedLang:u,fallbackLang:x}=useLanguages(),m=u.length?u:x;return{askAi:React.useCallback(async(h,p,f,R)=>{if(i){n(!0),a(null);try{const j=h==="content"?lodashEs.cloneDeep(getBlockWithChildren(p,d)):[lodashEs.cloneDeep(d.find(k=>k._id===p))];lodashEs.set(j,"0._parent",null);const E=u===x?"":u,y=await i(h,promptWithLanguage(f,m,h),j,E),{blocks:v,error:w}=y;if(w){a(w);return}h==="styles"?c(v):l(v),R&&R(y)}catch(j){a(j)}finally{n(!1),R&&R()}}},[i,n,d,u,x,m,c,l]),loading:o,error:r}};function FaLanguage$1(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M152.1 236.2c-3.5-12.1-7.8-33.2-7.8-33.2h-.5s-4.3 21.1-7.8 33.2l-11.1 37.5H163zM616 96H336v320h280c13.3 0 24-10.7 24-24V120c0-13.3-10.7-24-24-24zm-24 120c0 6.6-5.4 12-12 12h-11.4c-6.9 23.6-21.7 47.4-42.7 69.9 8.4 6.4 17.1 12.5 26.1 18 5.5 3.4 7.3 10.5 4.1 16.2l-7.9 13.9c-3.4 5.9-10.9 7.8-16.7 4.3-12.6-7.8-24.5-16.1-35.4-24.9-10.9 8.7-22.7 17.1-35.4 24.9-5.8 3.5-13.3 1.6-16.7-4.3l-7.9-13.9c-3.2-5.6-1.4-12.8 4.2-16.2 9.3-5.7 18-11.7 26.1-18-7.9-8.4-14.9-17-21-25.7-4-5.7-2.2-13.6 3.7-17.1l6.5-3.9 7.3-4.3c5.4-3.2 12.4-1.7 16 3.4 5 7 10.8 14 17.4 20.9 13.5-14.2 23.8-28.9 30-43.2H412c-6.6 0-12-5.4-12-12v-16c0-6.6 5.4-12 12-12h64v-16c0-6.6 5.4-12 12-12h16c6.6 0 12 5.4 12 12v16h64c6.6 0 12 5.4 12 12zM0 120v272c0 13.3 10.7 24 24 24h280V96H24c-13.3 0-24 10.7-24 24zm58.9 216.1L116.4 167c1.7-4.9 6.2-8.1 11.4-8.1h32.5c5.1 0 9.7 3.3 11.4 8.1l57.5 169.1c2.6 7.8-3.1 15.9-11.4 15.9h-22.9a12 12 0 0 1-11.5-8.6l-9.4-31.9h-60.2l-9.1 31.8c-1.5 5.1-6.2 8.7-11.5 8.7H70.3c-8.2 0-14-8.1-11.4-15.9z"},child:[]}]})(o)}function FaMoon(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"},child:[]}]})(o)}function FaRecycle(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M184.561 261.903c3.232 13.997-12.123 24.635-24.068 17.168l-40.736-25.455-50.867 81.402C55.606 356.273 70.96 384 96.012 384H148c6.627 0 12 5.373 12 12v40c0 6.627-5.373 12-12 12H96.115c-75.334 0-121.302-83.048-81.408-146.88l50.822-81.388-40.725-25.448c-12.081-7.547-8.966-25.961 4.879-29.158l110.237-25.45c8.611-1.988 17.201 3.381 19.189 11.99l25.452 110.237zm98.561-182.915l41.289 66.076-40.74 25.457c-12.051 7.528-9 25.953 4.879 29.158l110.237 25.45c8.672 1.999 17.215-3.438 19.189-11.99l25.45-110.237c3.197-13.844-11.99-24.719-24.068-17.168l-40.687 25.424-41.263-66.082c-37.521-60.033-125.209-60.171-162.816 0l-17.963 28.766c-3.51 5.62-1.8 13.021 3.82 16.533l33.919 21.195c5.62 3.512 13.024 1.803 16.536-3.817l17.961-28.743c12.712-20.341 41.973-19.676 54.257-.022zM497.288 301.12l-27.515-44.065c-3.511-5.623-10.916-7.334-16.538-3.821l-33.861 21.159c-5.62 3.512-7.33 10.915-3.818 16.536l27.564 44.112c13.257 21.211-2.057 48.96-27.136 48.96H320V336.02c0-14.213-17.242-21.383-27.313-11.313l-80 79.981c-6.249 6.248-6.249 16.379 0 22.627l80 79.989C302.689 517.308 320 510.3 320 495.989V448h95.88c75.274 0 121.335-82.997 81.408-146.88z"},child:[]}]})(o)}function FaSpinner(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z"},child:[]}]})(o)}const SECONDS=10;function Countdown(){const[o,n]=React.useState(SECONDS),[r,a]=React.useState(!1);React.useEffect(()=>{if(r&&o>0){const u=setTimeout(()=>{n(o-.1)},100);return()=>clearTimeout(u)}else o<=0&&(a(!1),n(SECONDS))},[r,o]);const i=()=>{a(!0),n(SECONDS)};React.useEffect(()=>{o===SECONDS&&i()},[o]);const l=18,c=2*Math.PI*l,d=c*(1-(SECONDS-o)/SECONDS);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative h-4 w-4",children:[jsxRuntime.jsxRuntimeExports.jsxs("svg",{className:"h-full w-full",viewBox:"0 0 40 40",children:[jsxRuntime.jsxRuntimeExports.jsx("circle",{className:"text-gray-300",strokeWidth:"4",stroke:"currentColor",fill:"transparent",r:l,cx:"20",cy:"20"}),jsxRuntime.jsxRuntimeExports.jsx("circle",{className:"text-blue-600",strokeWidth:"4",strokeDasharray:c,strokeDashoffset:d,strokeLinecap:"round",stroke:"currentColor",fill:"transparent",r:l,cx:"20",cy:"20"})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"text-xs font-semibold",children:" "})})]})}const AskAIStyles=({blockId:o})=>{const{t:n}=reactI18next.useTranslation(),{askAi:r,loading:a,error:i}=useAskAi(),[l,c]=React.useState(""),d=React.useRef(null),u=React.useRef(null),[x,m]=React.useState();React.useEffect(()=>{var p;(p=d.current)==null||p.focus()},[]);const h=p=>{const{usage:f}=p||{};!i&&f&&m(f),u.current=setTimeout(()=>m(void 0),1e4),i||c("")};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"",children:[jsxRuntime.jsxRuntimeExports.jsx("h2",{className:"mb-1 text-sm font-semibold leading-none tracking-tight",children:n("ask_ai")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{ref:d,value:l,onChange:p=>c(p.target.value),placeholder:n("ask_ai_to_edit_styles"),className:"w-full border border-border focus:border-0",rows:3,onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),u.current&&clearTimeout(u.current),m(void 0),r("styles",o,l,h))}}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"my-2 flex items-center gap-2",children:[a?null:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:l.trim().length<5||a,onClick:()=>{u.current&&clearTimeout(u.current),m(void 0),r("styles",o,l,h)},variant:"default",className:"w-fit",size:"sm",children:a?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),n("generating_please_wait")]}):n("edit_with_ai")}),a?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Skeleton,{className:"flex w-full items-center space-x-1 px-4 py-1 pl-2",children:[jsxRuntime.jsxRuntimeExports.jsx(FaSpinner,{className:"h-4 w-4 animate-spin text-gray-500"}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs",children:n("generating_please_wait")})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"destructive",onClick:()=>stop(),className:"hidden w-fit",size:"sm",children:n("stop")})]}):null]}),x?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"max-w-full",children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500",children:[jsxRuntime.jsxRuntimeExports.jsxs("span",{children:[n("Total tokens used"),": ",x.totalTokens]}),jsxRuntime.jsxRuntimeExports.jsx(Countdown,{})]})}):null,jsxRuntime.jsxRuntimeExports.jsx("div",{className:"max-w-full",children:i&&jsxRuntime.jsxRuntimeExports.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:i.message})})]})},fuse=new Fuse(ALL_TW_CLASSES,{isCaseSensitive:!1,threshold:.2,minMatchCharLength:2,keys:["name"]});function ManualClasses(){var C;const{t:o}=reactI18next.useTranslation(),[n]=useSelectedStylingBlocks(),r=useSelectedBlock(),a=useAddClassesToBlocks(),i=useRemoveClassesFromBlocks(),[l]=useSelectedBlockIds(),c=useBuilderProp("askAiCallBack",null),[d,u]=React.useState(""),{toast:x}=contextMenu.useToast(),m=(C=lodashEs.first(n))==null?void 0:C.prop,h=lodashEs.reject((lodashEs.get(r,m,"").replace(STRINGS.STYLES_KEY,"").split(",").pop()||"").split(" "),lodashEs.isEmpty),p=()=>{const I=d.trim().toLowerCase().replace(/ +(?= )/g,"").split(" ");a(l,I,!0),u("")},[f,R]=React.useState([]),j=({value:I})=>{const N=I.trim().toLowerCase(),L=N.match(/.+:/g);let g=[];if(L&&L.length>0){const[b]=L,_=N.replace(b,"");g=fuse.search(_).map(B=>({...B,item:{...B.item,name:b+B.item.name}}))}else g=fuse.search(N);return R(lodashEs.map(g,"item"))},E=()=>{R([])},y=I=>I.name,v=I=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"rounded-md p-1",children:I.name}),w={autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,placeholder:o("enter_classes_separated_by_space"),value:d,onKeyDown:I=>{I.key==="Enter"&&d.trim()!==""&&p()},onChange:(I,{newValue:N})=>u(N),className:"w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"},k=()=>{if(navigator.clipboard===void 0){x({title:o("clipboard_not_supported"),description:o("please_use_chrome_firefox_or_safari"),variant:"destructive"});return}navigator.clipboard.writeText(h.join(" ")),x({title:o("copied"),description:o("classes_copied_to_clipboard")})};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:`flex ${f.length>0?"min-h-[300px]":"min-h-max"} w-full flex-col gap-y-1.5 overflow-y-auto pb-4`,children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:o("classes")}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CopyIcon,{onClick:k,className:"cursor-pointer"})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:o("copy_classes_to_clipboard")})})]})]}),c?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Popover,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{variant:"default",className:"h-6 w-fit",size:"sm",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.SparklesIcon,{className:"h-4 w-4"}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"ml-2",children:o("Ask AI")})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverContent,{side:"left",className:"p-2",children:jsxRuntime.jsxRuntimeExports.jsx(AskAIStyles,{blockId:r==null?void 0:r._id})})]}):null]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex items-center gap-x-3",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"relative flex w-full items-center gap-x-3",children:jsxRuntime.jsxRuntimeExports.jsx(Autosuggest,{suggestions:f,onSuggestionsFetchRequested:j,onSuggestionsClearRequested:E,getSuggestionValue:y,renderSuggestion:v,inputProps:w,containerProps:{className:"relative h-8 w-full gap-y-1 py-1 border-border"},theme:{suggestion:"bg-transparent",suggestionHighlighted:"!bg-gray-300 dark:!bg-gray-800 cursor-pointer",suggestionsContainerOpen:"absolute bg-background no-scrollbar z-50 max-h-[230px] overflow-y-auto w-full border border-border rounded-md"}})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"outline",className:"h-6 border-border",onClick:p,disabled:d.trim()==="",size:"sm",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.PlusIcon,{})})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-full flex-wrap gap-2 overflow-x-hidden",children:React__namespace.Children.toArray(h.map(I=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate rounded border border-border bg-gray-200 p-px px-1.5 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",children:[I,jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Cross2Icon,{onClick:()=>i(l,[I]),className:"invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"})]},I)))})]})}const BASIC_UNITS=["px","%","em","rem","ch","vh","vw"],FLEX_CHILD_SECTION={heading:"flex.heading",items:[{type:"arbitrary",label:"flex.basis",units:BASIC_UNITS,property:"flexBasis"},{type:"range",label:"flex.order",property:"order"},{type:"dropdown",label:"flex.flex",property:"flexGrowShrink"},{type:"dropdown",label:"flex.grow",property:"flexGrow"},{type:"dropdown",label:"flex.shrink",property:"flexShrink"}]},GRID_CHILD_SECTION={heading:"grid.heading",items:[{type:"range",label:"grid.col_span",property:"gridColSpan"},{type:"range",label:"grid.col_start",property:"gridColStart"},{type:"range",label:"grid.col_end",property:"gridColEnd"},{type:"range",label:"grid.row_span",property:"gridRowSpan"},{type:"range",label:"grid.row_start",property:"gridRowStart"},{type:"range",label:"grid.row_end",property:"gridRowEnd"},{type:"range",label:"grid.order",property:"order"}]},SETTINGS_SECTIONS=[{heading:"Styles",items:[{component:ManualClasses},{type:"arbitrary",label:"layout.width",units:BASIC_UNITS.concat("auto"),property:"width"},{type:"arbitrary",label:"layout.height",units:BASIC_UNITS.concat("auto"),property:"height"},{styleType:"multiple",label:"layout.margin",negative:!0,units:[...BASIC_UNITS,"auto"],options:[{key:"margin",label:"layout.margin_all"},{key:"marginX",label:"layout.margin_lr"},{key:"marginY",label:"layout.margin_tb"},{key:"marginTop",label:"layout.margin_top"},{key:"marginRight",label:"layout.margin_right"},{key:"marginBottom",label:"layout.margin_bottom"},{key:"marginLeft",label:"layout.margin_left"}]},{styleType:"multiple",label:"layout.padding",options:[{key:"padding",label:"layout.padding_all"},{key:"paddingX",label:"layout.padding_lr"},{key:"paddingY",label:"layout.padding_tb"},{key:"paddingTop",label:"layout.padding_top"},{key:"paddingRight",label:"layout.padding_right"},{key:"paddingBottom",label:"layout.padding_bottom"},{key:"paddingLeft",label:"layout.padding_left"}]},{styleType:"accordion",heading:"Typography",items:[{type:"dropdown",property:"textAlign",label:"typography.align"},{type:"dropdown",property:"fontFamily",label:"typography.font"},{type:"arbitrary",property:"fontSize",label:"typography.size",units:BASIC_UNITS},{type:"arbitrary",property:"lineHeight",label:"typography.height",units:BASIC_UNITS.concat("-")},{type:"range",property:"fontWeight",label:"typography.weight"},{type:"color",property:"textColor",label:"typography.color"}]},{styleType:"accordion",heading:"Background",items:[{type:"color",label:"background.bgcolor",property:"backgroundColor"},{type:"dropdown",label:"background.attachment",property:"backgroundAttachment"},{type:"dropdown",label:"background.clipping",property:"backgroundClip"},{type:"dropdown",label:"background.origin",property:"backgroundOrigin"},{type:"dropdown",label:"background.position",property:"backgroundPosition"},{type:"dropdown",label:"background.repeat",property:"backgroundRepeat"},{type:"dropdown",label:"background.size",property:"backgroundSize"}]}]}];BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),[...BASIC_UNITS],BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("auto"),BASIC_UNITS.concat("-");const EDITOR_ICONS={"not-italic":()=>jsxRuntime.jsxRuntimeExports.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z",fill:"white"})}),visible:reactIcons.EyeOpenIcon,invisible:reactIcons.EyeClosedIcon,hidden:reactIcons.EyeClosedIcon,gap:reactIcons.BorderAllIcon,gapX:reactIcons.WidthIcon,gapY:reactIcons.HeightIcon,spaceX:reactIcons.WidthIcon,spaceY:reactIcons.HeightIcon,overscroll:reactIcons.BorderAllIcon,overscrollX:reactIcons.WidthIcon,overscrollY:reactIcons.HeightIcon,overflow:reactIcons.BorderAllIcon,overflowX:reactIcons.WidthIcon,overflowY:reactIcons.HeightIcon,top:reactIcons.ArrowUpIcon,right:reactIcons.ArrowRightIcon,bottom:reactIcons.ArrowDownIcon,left:reactIcons.ArrowLeftIcon,inset:reactIcons.BorderAllIcon,insetX:reactIcons.WidthIcon,insetY:reactIcons.HeightIcon,border:reactIcons.BorderAllIcon,borderX:reactIcons.WidthIcon,borderY:reactIcons.HeightIcon,borderTop:reactIcons.ArrowUpIcon,borderRight:reactIcons.ArrowRightIcon,borderBottom:reactIcons.ArrowDownIcon,borderLeft:reactIcons.ArrowLeftIcon,borderRadius:reactIcons.BorderAllIcon,borderRadiusX:reactIcons.WidthIcon,borderRadiusY:reactIcons.HeightIcon,borderRadiusTop:reactIcons.ArrowUpIcon,borderRadiusRight:reactIcons.ArrowRightIcon,borderRadiusBottom:reactIcons.ArrowDownIcon,borderRadiusLeft:reactIcons.ArrowLeftIcon,borderRadiusTopLeft:reactIcons.ArrowTopLeftIcon,borderRadiusTopRight:reactIcons.ArrowTopRightIcon,borderRadiusBottomRight:reactIcons.ArrowBottomRightIcon,borderRadiusBottomLeft:reactIcons.ArrowBottomLeftIcon,divideXWidth:reactIcons.WidthIcon,divideYWidth:reactIcons.HeightIcon,scale:reactIcons.BorderAllIcon,scaleX:reactIcons.WidthIcon,scaleY:reactIcons.HeightIcon,skewX:reactIcons.WidthIcon,skewY:reactIcons.HeightIcon,translateX:reactIcons.WidthIcon,translateY:reactIcons.HeightIcon,padding:reactIcons.BorderAllIcon,paddingX:reactIcons.WidthIcon,paddingY:reactIcons.HeightIcon,paddingTop:reactIcons.ArrowUpIcon,paddingRight:reactIcons.ArrowRightIcon,paddingBottom:reactIcons.ArrowDownIcon,paddingLeft:reactIcons.ArrowLeftIcon,margin:reactIcons.BorderAllIcon,marginX:reactIcons.WidthIcon,marginY:reactIcons.HeightIcon,marginTop:reactIcons.ArrowUpIcon,marginRight:reactIcons.ArrowRightIcon,marginBottom:reactIcons.ArrowDownIcon,marginLeft:reactIcons.ArrowLeftIcon,textLeft:reactIcons.AlignLeftIcon,textCenter:reactIcons.AlignCenterHorizontallyIcon,textRight:reactIcons.AlignRightIcon,textJustify:reactIcons.StretchHorizontallyIcon,italic:reactIcons.FontItalicIcon,underline:reactIcons.UnderlineIcon,overline:reactIcons.OverlineIcon,uppercase:reactIcons.LetterCaseUppercaseIcon,block:()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M2 2H14V14H2V2ZM1 1H15V15H1V1Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4H4V12H7V4ZM9 4H12V12H9V4Z",fill:"currentColor"})]}),"float-right":()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M8 4H16V12H8V4Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M0 4H6V6H0V4ZM0 7H6V9H0V7ZM4 10H0V12H4V10Z",fill:"currentColor"})]}),"float-left":()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M0 4H8V12H0V4Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M10 4H16V6H10V4ZM10 7H16V9H10V7ZM14 10H10V12H14V10Z",fill:"currentColor"})]}),"float-none":reactIcons.Cross2Icon,fixed:()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M15 2H14V4H13V5H14V6H15V2ZM10 5V4H9V2H1V8H2V5H10ZM7 4V3H5V4H7ZM4 4V3H2V4H4ZM1 13H7V14H1V13Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),absolute:()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M14 2H15V6H14V2ZM9 3V2H1V8H2V3H9ZM7 13H1V14H7V13Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),relative:()=>jsxRuntime.jsxRuntimeExports.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsxRuntimeExports.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H9V3H11V6H12V3H14V2H11ZM2 8H1V13H2V11H7V10H2V8ZM15 7H8V14H15V7Z",fill:"currentColor"})}),sticky:()=>jsxRuntime.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M12.9998 7C13.6558 7 14.2937 6.78498 14.8158 6.38787C15.338 5.99076 15.7156 5.43345 15.8908 4.80128C16.066 4.16912 16.0292 3.49694 15.7859 2.8877C15.5427 2.27846 15.1065 1.76573 14.5441 1.42804C13.9817 1.09034 13.3241 0.946293 12.672 1.01795C12.02 1.08961 11.4094 1.37303 10.9337 1.8248C10.4581 2.27658 10.1436 2.8718 10.0385 3.51932C9.93341 4.16685 10.0434 4.83097 10.3518 5.41L6.88176 8.88C6.80034 8.96122 6.73572 9.05769 6.69158 9.16388C6.64744 9.27008 6.62465 9.38393 6.62451 9.49894C6.62437 9.61395 6.64689 9.72785 6.69077 9.83416C6.73465 9.94046 6.79904 10.0371 6.88026 10.1185C6.96149 10.1999 7.05795 10.2645 7.16415 10.3087C7.27035 10.3528 7.3842 10.3756 7.4992 10.3758C7.61421 10.3759 7.72812 10.3534 7.83442 10.3095C7.94072 10.2656 8.03734 10.2012 8.11876 10.12L11.5888 6.648C12.0088 6.873 12.4888 7 12.9988 7H12.9998Z",fill:"currentColor"}),jsxRuntime.jsxRuntimeExports.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M9.535 2H1V14H15V7.465C14.69 7.645 14.355 7.783 14 7.875V13H2V5H9.126C8.86504 3.98486 9.01223 2.90789 9.536 2H9.535ZM7 3V4H5V3H7ZM4 3V4H2V3H4Z",fill:"currentColor"})]}),static:reactIcons.Cross1Icon},StyleContext=React.createContext({canReset:!1,canChange:!0}),BlockStyleProvider=({children:o,canReset:n=!1,canChange:r=!0})=>jsxRuntime.jsxRuntimeExports.jsx(StyleContext.Provider,{value:{canReset:n,canChange:r},children:o}),DropDownChoices=({label:o,property:n,onChange:r})=>{const a=React.useMemo(()=>lodashEs.get(CLASSES_LIST,`${n}.classes`,[""]),[n]),i=useCurrentClassByProperty(n),l=React.useMemo(()=>lodashEs.get(i,"cls",""),[i]),{canChange:c}=React.useContext(StyleContext),d=/\[.*\]/g.test(l);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:o?"w-full rounded":"grow",children:d?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Input,{className:"w-[70%] rounded py-1",readOnly:!0,value:l}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{delayDuration:100,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:"Current value is using a Tailwind arbitrary value."})]})]}):jsxRuntime.jsxRuntimeExports.jsx(DropDown,{rounded:o,onChange:u=>r(u,n),selected:l,options:a,disabled:!c})})};function DropDown({selected:o,onChange:n,rounded:r=!1,options:a,disabled:i=!1}){const l=o.replace(/.*:/g,"").trim(),{undo:c,redo:d}=useUndoManager();return jsxRuntime.jsxRuntimeExports.jsxs("select",{disabled:!a.length||i,className:`${r?"rounded-md border border-border":"border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,onChange:u=>n(u.target.value),onKeyDown:u=>{u.ctrlKey&&(u.key==="z"&&c(),u.key==="y"&&d())},value:l,children:[jsxRuntime.jsxRuntimeExports.jsx("option",{className:"bg-transparent",value:""}),React.Children.toArray(a.map(u=>jsxRuntime.jsxRuntimeExports.jsx("option",{className:"bg-transparent",value:u,children:u})))]})}const RangeChoices=({property:o,onChange:n})=>{const{canReset:r,canChange:a}=React.useContext(StyleContext),i=useCurrentClassByProperty(o),l=React.useMemo(()=>lodashEs.get(i,"cls",""),[i]),c=React.useMemo(()=>lodashEs.get(CLASSES_LIST,`${o}.classes`,[""]),[o]),d=c.indexOf(l)>-1?c.indexOf(l):0,u=/\[.*\]/g.test(l);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs",children:u?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"py-[5px] px-2",children:l}):jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"box-border w-2/12 rounded-tl rounded-bl bg-background px-1 text-center hover:bg-bg-gray-700 disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!a&&(!r||d-1<0),onClick:()=>n(lodashEs.nth(c,d-1),o),children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"flex items-center justify-center",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.MinusIcon,{className:!a&&(!r||d-1<0)?"text-gray-500":"text-black/60 dark:text-white/60"})})}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-8/12 text-center",children:jsxRuntime.jsxRuntimeExports.jsx(DropDownChoices,{label:!1,property:o,onChange:n})}),jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"w-2/12 rounded-tr rounded-br bg-background px-1 text-center hover:bg-bg-gray-700 disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!a&&(!r||d+1>=c.length),onClick:()=>n(lodashEs.nth(c,d+1),o),children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"flex items-center justify-center",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.PlusIcon,{className:!a&&(!r||d+1>=c.length)?"text-gray-500":"text-black/60 dark:text-white/60"})})})]})})},IconChoices=({property:o,onChange:n})=>{const r=React.useMemo(()=>lodashEs.get(CLASSES_LIST,`${o}.classes`,[""]),[o]),{canChange:a}=React.useContext(StyleContext),i=useCurrentClassByProperty(o),l=React.useMemo(()=>lodashEs.get(i,"cls",""),[i]);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex grow flex-wrap gap-1",children:lodashEs.map(r,c=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",disabled:!a,onClick:()=>n(c,o),className:`cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${l===c?"bg-blue-500 text-white":"disabled:bg-gray-600 disabled:text-gray-400"}`,children:React.createElement(lodashEs.get(EDITOR_ICONS,c,reactIcons.BoxIcon))})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:lodashEs.startCase(lodashEs.toLower(c))})]}))})},COLOR_PROP={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},ColorChoice=({property:o,onChange:n})=>{const r=useCurrentClassByProperty(o),a=React.useMemo(()=>lodashEs.get(r,"cls",""),[r]),{canChange:i}=React.useContext(StyleContext),[l,c]=React.useState([]),[d,u]=React.useState({color:"",shade:""}),x=a.split("-"),m=lodashEs.get(x,"1",""),h=lodashEs.get(x,"2",""),p=React.useCallback(R=>{["current","inherit","transparent","black","white"].includes(R)?(c([]),u({color:R})):(c(["50","100","200","300","400","500","600","700","800","900"]),u(j=>({...j,color:R,shade:j.shade?j.shade:"500"})))},[c,u]);React.useEffect(()=>{if(["current","inherit","transparent","black","white"].includes(m))return c([]);c(["50","100","200","300","400","500","600","700","800","900"])},[m]);const f=React.useCallback(R=>{u({color:m,shade:R})},[m]);return React.useEffect(()=>{u({color:"",shade:""})},[r]),React.useEffect(()=>{const j=`${lodashEs.get(COLOR_PROP,o,"")}-${d.color}${d.shade?`-${d.shade}`:""}`;j.match(new RegExp(lodashEs.get(CLASSES_LIST,`${o}.regExp`,"")))&&n(j,o)},[d,n,o]),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"grow text-center",children:jsxRuntime.jsxRuntimeExports.jsx(DropDown,{disabled:!i,rounded:!0,selected:m,onChange:p,options:["current","transparent","primary","secondary","black","white","slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"]})}),jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"grow text-center",children:jsxRuntime.jsxRuntimeExports.jsx(DropDown,{rounded:!0,selected:h,disabled:!m||!i,onChange:f,options:l})})]})},getUserInputValues=(o,n)=>{o=o.toLowerCase();let r=o.trim().replace(/ |\+/g,"");if((r==="auto"||r==="none")&&n.includes(r))return{value:"",unit:r};const a=n.length?new RegExp(n.join("|"),"g"):/XXXXXX/g;r=r.replace(a,"");const i=o.match(a),l=i&&i.length>1,c=!lodashEs.isEmpty(r)&&Number.isNaN(Number(r));return l||c?{error:"Invalid value"}:i&&(i[0]==="auto"||i[0]==="none")?{value:i[0],unit:""}:{value:r,unit:i?i[0]:""}},getTwClassValue=o=>{const n=o.startsWith("-")?"-":"",r=o.split("-").pop();if(["auto","none"].includes(r))return{value:"",unit:r};if(r==="px")return{value:"1",unit:"px"};if(r==="screen")return{value:"100",unit:o.indexOf("w-")!==-1?"vw":"vh"};if(r==="full")return{value:"100",unit:"%"};if(lodashEs.includes(o,"skew-"))return{value:`${n}${r}`,unit:"deg"};if(lodashEs.includes(o,"rotate-"))return{value:`${n}${r}`,unit:"deg"};if(lodashEs.includes(o,"opacity-"))return{value:`${r/100}`,unit:"-"};if(lodashEs.includes(o,"duration-")||lodashEs.includes(o,"delay-"))return{value:`${r}`,unit:"ms"};if(lodashEs.includes(o,"translate-")&&!r.includes("/"))return{value:`${n}${`${r/4}`}`,unit:"rem"};if(lodashEs.includes(o,"scale-"))return{value:`${n}${`${r/100}`}`,unit:"-"};if(lodashEs.startsWith(o,"border")){const a=o.match(/border-?(x|y|t|r|b|l)?\d+/g);if(a)return{value:a[0].split("-").pop(),unit:"px"};if(o.match(/border-?(x|y|t|r|b|l)?/g))return{value:"1",unit:"px"}}if(lodashEs.startsWith(o,"max-w-")){if(o==="max-w-screen-sm")return{value:"640",unit:"px"};if(o==="max-w-screen-md")return{value:"768",unit:"px"};if(o==="max-w-screen-lg")return{value:"1024",unit:"px"};if(o==="max-w-screen-xl")return{value:"1280",unit:"px"};if(o==="max-w-screen-2xl")return{value:"1536",unit:"px"};if(r==="xs")return{value:"320",unit:"px"};if(r==="sm")return{value:"384",unit:"px"};if(r==="md")return{value:"448",unit:"px"};if(r==="lg")return{value:"512",unit:"px"};if(r==="xl")return{value:"576",unit:"px"};if(r==="2xl")return{value:"672",unit:"px"};if(r==="3xl")return{value:"768",unit:"px"};if(r==="4xl")return{value:"896",unit:"px"};if(r==="5xl")return{value:"1024",unit:"px"};if(r==="6xl")return{value:"1152",unit:"px"};if(r==="7xl")return{value:"1280",unit:"px"};if(r==="prose")return{value:"65",unit:"ch"}}if(lodashEs.startsWith(o,"text-")){if(r==="xs")return{value:"12",unit:"px"};if(r==="sm")return{value:"14",unit:"px"};if(r==="base")return{value:"16",unit:"px"};if(r==="lg")return{value:"18",unit:"px"};if(r==="xl")return{value:"20",unit:"px"};if(r==="2xl")return{value:"24",unit:"px"};if(r==="3xl")return{value:"30",unit:"px"};if(r==="4xl")return{value:"36",unit:"px"};if(r==="5xl")return{value:"48",unit:"px"};if(r==="6xl")return{value:"60",unit:"px"};if(r==="7xl")return{value:"72",unit:"px"};if(r==="8xl")return{value:"96",unit:"px"};if(r==="9xl")return{value:"128",unit:"px"}}if(lodashEs.startsWith(o,"leading-")){if(r==="none")return{value:"1",unit:"-"};if(r==="tight")return{value:"1.25",unit:"-"};if(r==="snug")return{value:"1.375",unit:"-"};if(r==="normal")return{value:"1.5",unit:"-"};if(r==="relaxed")return{value:"1.625",unit:"-"};if(r==="loose")return{value:"2",unit:"-"}}if(lodashEs.startsWith(o,"tracking-")){if(r==="tighter")return{value:"-0.05",unit:"em"};if(r==="tight")return{value:"-0.025",unit:"em"};if(r==="normal")return{value:"0",unit:"em"};if(r==="wide")return{value:"0.025",unit:"em"};if(r==="wider")return{value:"0.05",unit:"em"};if(r==="widest")return{value:"0.1",unit:"em"}}if(["max","min","fit"].includes(r))return{value:o,unit:"class"};if(r.includes("/")){const[a,i]=lodashEs.map(r.split("/"),l=>parseInt(l,10));return{value:n+(a/i*100).toFixed(2).replace(".00",""),unit:"%"}}return lodashEs.isNumber(parseFloat(r))?{value:`${n+parseFloat(r)*4}`,unit:"px"}:{value:r,unit:"class"}},getClassValueAndUnit=o=>{if(lodashEs.isEmpty(o))return{value:"",unit:""};const n=o.match(/\[.*\]/g);if(n===null)return getValueAndUnitForTWClass(o);const r=lodashEs.get(n,"0","").replace(/\[|\]/g,""),a=o.startsWith("-")?"-":"",i=lodashEs.first(r.match(/\d+.\d+|\d+/g));return{value:`${a}${i}`,unit:r.replace(i,"")}},getValueAndUnitForTWClass=o=>lodashEs.isEmpty(o)?{value:"",unit:""}:getTwClassValue(o),BlockSettingsContext=React.createContext({setDragData:()=>{}}),DragStyleButton=({unit:o,currentValue:n,onDrag:r,onDragEnd:a,onDragStart:i,negative:l,cssProperty:c})=>{const{setDragData:d}=React.useContext(BlockSettingsContext);return jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",onMouseDown:u=>{const x={onDrag:r,onDragEnd:a,dragging:!0,dragStartY:u.pageY,dragStartValue:`${n}`,dragUnit:o,negative:l,cssProperty:c};i(x),d(x)},color:void 0,className:"relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.RowSpacingIcon,{})})},UnitSelection=({onSelect:o,current:n,units:r})=>jsxRuntime.jsxRuntimeExports.jsx("div",{"data-theme":"light",className:"-m-[7px] -mx-[13px] flex w-9 flex-col",children:r.map(a=>jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{className:"h-max rounded-none px-1 py-1 text-right text-[11px] hover:bg-blue-400",color:n===a?"primary":void 0,size:"sm",onClick:i=>{i.stopPropagation(),o(a)},children:a},a))}),THROTTLE_TIME=50,AdvanceChoices=o=>{const[n,r]=React.useState(!1),[a,i]=React.useState(""),{currentClass:l,onChange:c,classPrefix:d,cssProperty:u,units:x,negative:m}=o,[h,p]=React.useState(u!=null&&u.toLowerCase().includes("width")?"%":x[0]),[f,R]=React.useState(!1),[j,E]=React.useState(""),[y,v]=React.useState(!1),[w,k]=React.useState(!1);React.useEffect(()=>{const{value:g,unit:b}=getClassValueAndUnit(l);if(b===""){i(g),p(u!=null&&u.toLowerCase().includes("width")?"%":lodashEs.first(x));return}p(b),i(b==="class"||lodashEs.isEmpty(g)?"":g)},[l,u,x]);const C=web.useThrottledCallback(g=>c(g),[c],THROTTLE_TIME),I=web.useThrottledCallback(g=>c(g,!1),[c],THROTTLE_TIME),N=React.useCallback((g=!1)=>{const b=getUserInputValues(`${a}`,x);if(lodashEs.get(b,"error",!1)){R(!0);return}const _=lodashEs.get(b,"unit")!==""?lodashEs.get(b,"unit"):h;if(_==="auto"||_==="none"){C(`${d}${_}`);return}if(lodashEs.get(b,"value")==="")return;const B=`${lodashEs.get(b,"value","").startsWith("-")?"-":""}${d}[${lodashEs.get(b,"value","").replace("-","")}${_==="-"?"":_}]`;g?I(B):C(B)},[C,I,a,h,d,x]),L=React.useCallback(g=>{const b=getUserInputValues(`${a}`,x);if(lodashEs.get(b,"error",!1)){R(!0);return}if(g==="auto"||g==="none"){C(`${d}${g}`);return}if(lodashEs.get(b,"value")==="")return;const _=lodashEs.get(b,"unit")!==""?lodashEs.get(b,"unit"):g,B=`${lodashEs.get(b,"value","").startsWith("-")?"-":""}${d}[${lodashEs.get(b,"value","").replace("-","")}${_==="-"?"":_}]`;C(B)},[C,a,d,x]);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-full flex-col",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-start",children:h==="class"?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx("input",{className:"w-20 rounded py-1",readOnly:!0,value:l}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:"Current value is using a Tailwind preset class."})]})]}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:`group relative flex items-center ${y?"z-auto":""}`,children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center rounded-md border border-border",children:[["none","auto"].indexOf(h)!==-1?null:jsxRuntime.jsxRuntimeExports.jsx("input",{readOnly:h==="class",onKeyPress:g=>{g.key==="Enter"&&N()},onKeyDown:g=>{if(g.keyCode!==38&&g.keyCode!==40)return;g.preventDefault(),k(!0);const b=lodashEs.parseInt(g.target.value);let _=lodashEs.isNaN(b)?0:b;g.keyCode===38&&(_+=1),g.keyCode===40&&(_-=1);const S=`${_}`,A=`${S.startsWith("-")?"-":""}${d}[${S.replace("-","")}${h==="-"?"":h}]`;I(A)},onKeyUp:g=>{w&&(g.preventDefault(),k(!1))},onBlur:()=>N(),onChange:g=>{R(!1),i(g.target.value)},onClick:g=>{var b;(b=g==null?void 0:g.target)==null||b.select(),r(!1)},value:y?j:a,className:"h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(" ",f?"border-red-500 text-red-500":"border-foreground/20")}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{open:n,delayDuration:100,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:`inline-block ${x.length===1?"px-2 font-semibold":""}`,children:h}),x.length>1?jsxRuntime.jsxRuntimeExports.jsx(reactIcons.TriangleDownIcon,{}):null]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipPortal,{children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{className:"bg-background",children:jsxRuntime.jsxRuntimeExports.jsx(UnitSelection,{units:x,current:h,onSelect:g=>{r(!1),p(g),L(g)}})})})]})]}),["none","auto"].indexOf(h)!==-1||y?null:jsxRuntime.jsxRuntimeExports.jsx(DragStyleButton,{onDragStart:()=>v(!0),onDragEnd:g=>{if(E(()=>""),v(!1),lodashEs.isEmpty(g))return;const b=`${g}`,S=`${b.startsWith("-")?"-":""}${d}[${b.replace("-","")}${h==="-"?"":h}]`;C(S)},onDrag:g=>{if(lodashEs.isEmpty(g))return;E(g);const b=`${g}`,S=`${b.startsWith("-")?"-":""}${d}[${b.replace("-","")}${h==="-"?"":h}]`;I(S)},currentValue:a,unit:h,negative:m,cssProperty:u})]})})})},useCurrentClassByProperty=o=>{const n=useSelectedBlockCurrentClasses();return lodashEs.findLast(n,{property:o})},canChangeClass=(o,n)=>{const r={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5};return r[lodashEs.get(o,"mq","xs")]<=r[n]},CLASS_PREFIXES={width:"w-",height:"h-",minWidth:"min-w-",minHeight:"min-h-",maxWidth:"max-w-",maxHeight:"max-h-",zIndex:"z-",gap:"gap-",gapX:"gap-x-",gapY:"gap-y-",margin:"m-",marginX:"mx-",marginY:"my-",marginTop:"mt-",marginBottom:"mb-",marginLeft:"ml-",marginRight:"mr-",padding:"p-",paddingX:"px-",paddingY:"py-",paddingTop:"pt-",paddingBottom:"pb-",paddingLeft:"pl-",paddingRight:"pr-",spaceX:"space-x-",spaceY:"space-y-",border:"border-",borderTop:"border-t-",borderBottom:"border-b-",borderLeft:"border-l-",borderRight:"border-r-",borderX:"border-x-",borderY:"border-y-",borderRadius:"rounded-",borderRadiusTop:"rounded-t-",borderRadiusRight:"rounded-r-",borderRadiusBottom:"rounded-b-",borderRadiusLeft:"rounded-l-",borderRadiusTopLeft:"rounded-tl-",borderRadiusTopRight:"rounded-tr-",borderRadiusBottomRight:"rounded-br-",borderRadiusBottomLeft:"rounded-bl-",fontSize:"text-",lineHeight:"leading-",letterSpacing:"tracking-",textIndent:"indent-",rotate:"rotate-",duration:"duration-",transitionDelay:"delay-",scale:"scale-",scaleX:"scale-x-",scaleY:"scale-y-",translateX:"translate-x-",translateY:"translate-y-",skewX:"skew-x-",skewY:"skew-y-",top:"top-",bottom:"bottom-",left:"left-",right:"right-",inset:"inset-",insetX:"inset-x-",insetY:"inset-y-",opacity:"opacity-",flexBasis:"basis-"},BREAKPOINTS={xs:"",sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"},getBreakpoint=o=>`${o.toUpperCase()} ${BREAKPOINTS[o]?`(${BREAKPOINTS[o]} & up)`:""}`,BlockStyle=o=>{const{t:n}=reactI18next.useTranslation(),{type:r="icons",label:a,property:i,onEmitChange:l=()=>{},units:c,negative:d=!1}=o,[u]=useDarkMode(),[x]=useStylingState(),[,m]=useCanvasWidth(),h=useCurrentClassByProperty(i),p=useAddClassesToBlocks(),f=useRemoveClassesFromBlocks(),[R]=useSelectedBlockIds(),j=React.useMemo(()=>lodashEs.get(h,"fullCls",""),[h]),E=React.useCallback((I,N=!0)=>{const L={dark:u,mq:m,mod:x,cls:I,property:i,fullCls:""};(u||x!=="")&&(L.mq="xs");const g=generateFullClsName(L);p(R,[g],N)},[R,u,m,x,i,p]),y=React.useCallback(()=>{f(R,[j])},[R,j,f]),v=React.useMemo(()=>canChangeClass(h,m),[h,m]);React.useEffect(()=>{l(v,h)},[v,l,h]);const[,,w]=useCanvasWidth(),k=React.useCallback(I=>{w({xs:400,sm:640,md:800,lg:1024,xl:1420,"2xl":1920}[I])},[w]),C=lodashEs.get(h,"dark",null)===u&&lodashEs.get(h,"mod",null)===x&&lodashEs.get(h,"mq",null)===m;return jsxRuntime.jsxRuntimeExports.jsx(BlockStyleProvider,{canChange:v,canReset:h&&C,children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"group flex flex-row items-center py-2 first:pt-0 last:pb-0",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"relative w-[70px] truncate text-xs text-foreground",children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:`text-[11px] ${h&&!C?"text-foreground":""}`,children:n(a)})}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-row items-center",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"w-[150px]",children:[r==="arbitrary"?jsxRuntime.jsxRuntimeExports.jsx(AdvanceChoices,{currentClass:lodashEs.get(h,"cls",""),classPrefix:lodashEs.get(CLASS_PREFIXES,i,""),units:c||[],onChange:E,negative:d,cssProperty:i}):null,r==="icons"&&jsxRuntime.jsxRuntimeExports.jsx(IconChoices,{property:i,onChange:E}),r==="range"&&jsxRuntime.jsxRuntimeExports.jsx(RangeChoices,{property:i,onChange:E}),r==="color"&&jsxRuntime.jsxRuntimeExports.jsx(ColorChoice,{property:i,onChange:E}),r==="dropdown"&&jsxRuntime.jsxRuntimeExports.jsx(DropDownChoices,{label:a,property:i,onChange:E})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:`w-[30px] cursor-pointer ${j?"visible":"invisible"}`,children:C?jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>y(),title:"Reset",className:"flex px-1.5 text-xs",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CrossCircledIcon,{className:"h-5 w-5 text-blue-500 hover:opacity-80"})}):v&&h?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{delayDuration:100,children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("button",{type:"button",className:"invisible ml-3 mt-1 rounded-full bg-blue-500 text-white group-hover:visible",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.InfoCircledIcon,{})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-right",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{children:["Current style is set at  ",jsxRuntime.jsxRuntimeExports.jsxs("span",{className:"font-bold",children:[getBreakpoint(lodashEs.get(h,"mq")),u&&!h.dark?"(Light mode)":""]}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>k(lodashEs.get(h,"mq")),className:"block w-full cursor-default text-right font-semibold text-blue-500",children:["Switch to ",lodashEs.get(h,"mq").toUpperCase()]})]})})})]}):null})]})]})})},basicUnits=["px","%","em","rem","ch","vh","vw"],MultipleChoices=({label:o,options:n,borderB:r=!1,borderT:a=!1,type:i="arbitrary",units:l=basicUnits,negative:c=!1})=>{const{t:d}=reactI18next.useTranslation(),[u,x]=React.useState(n[0].key),m=useSelectedBlockCurrentClasses(),h=React.useCallback(p=>lodashEs.map(m,"property").includes(p),[m]);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:`mb-2 border-border py-2 first:pt-0 last:pb-0 ${r?"border-b":""} ${a?"border-t":""}`,children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-row text-xs",children:[o&&jsxRuntime.jsxRuntimeExports.jsx("span",{className:"relative w-[70px] flex-none text-xs text-foreground",children:d(o)}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mb-3 flex grow flex-row flex-wrap gap-x-px",children:React.Children.toArray(n.map(({label:p,key:f})=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"first:rounded-l last:rounded-r",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>x(f),className:`relative cursor-pointer rounded-full p-1 text-[8px] ${f===u?"bg-[#3E57F0] text-white":"text-gray-600 dark:text-gray-300"}`,children:[React.createElement("div",{className:h(f)?"-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full":""}),React.createElement(lodashEs.get(EDITOR_ICONS,f,reactIcons.BoxIcon),{className:"text-inherit w-3 h-3"})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:lodashEs.startCase(lodashEs.toLower(p))})]})})))})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-0 flex items-center",children:jsxRuntime.jsxRuntimeExports.jsx(BlockStyle,{type:i,units:[...l],label:"",property:u,negative:c})})]})},NestedOptions=({heading:o,items:n})=>{const{t:r}=reactI18next.useTranslation(),a=useSelectedBlockCurrentClasses(),i=React.useMemo(()=>{const l=u=>lodashEs.flatten(u.map(x=>x.styleType==="multiple"?lodashEs.map(x.options,"key"):x.property)),c=lodashEs.flatten(n.map(u=>u.styleType==="accordion"?l(u.items):u.styleType==="multiple"?lodashEs.map(u.options,"key"):u.property)),d=lodashEs.map(a,"property");return lodashEs.intersection(c,d).length>0},[a,n]);return jsxRuntime.jsxRuntimeExports.jsxs("details",{children:[jsxRuntime.jsxRuntimeExports.jsx("summary",{className:"my-px cursor-default rounded-md bg-gray-50 p-px px-2 text-[11px] text-foreground dark:bg-gray-800",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"inline",children:[r(o.toLowerCase()),i?jsxRuntime.jsxRuntimeExports.jsx("span",{className:`ml-1 mr-2 inline-block h-[8px] w-[8px] rounded-full ${i?"bg-blue-500":"bg-gray-300"}`}):null]})}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"p-2",children:n.map(l=>l.styleType==="multiple"?jsxRuntime.jsxRuntimeExports.jsx(MultipleChoices,{...l},l.label):jsxRuntime.jsxRuntimeExports.jsx(BlockStyle,{...l},l.label))})]})},SectionContext=React.createContext({}),StylingGroup=({section:o})=>{const{t:n}=reactI18next.useTranslation(),r=useSelectedBlockCurrentClasses(),a=React.useCallback((l=[])=>{const c={};for(let u=0;u<r.length;u++)c[r[u].property]=r[u].cls;let d=!0;for(const u in l)if(!lodashEs.has(c,u)||c[u]!==l[u]){d=!1;break}return d},[r]),i=React.useMemo(()=>({}),[]);return jsxRuntime.jsxRuntimeExports.jsx(SectionContext.Provider,{value:i,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:o.heading,className:"border-none",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{className:"border-b border-border py-2 text-xs",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-x-2 text-sm font-bold",children:n(o.heading)})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionContent,{className:"py-2",children:React.Children.toArray(o.items.map(l=>lodashEs.has(l,"component")?React.createElement(l.component,{key:l.label}):lodashEs.has(l,"styleType")?l.styleType==="multiple"?jsxRuntime.jsxRuntimeExports.jsx(MultipleChoices,{...l},l.label):l.styleType==="accordion"&&a(l==null?void 0:l.conditions)?jsxRuntime.jsxRuntimeExports.jsx(NestedOptions,{...l},l.label):null:jsxRuntime.jsxRuntimeExports.jsx(BlockStyle,{...l},l.label)))})]})})},StylingHelpers=()=>{const o=useSelectedBlock(),[n]=useSelectedStylingBlocks(),{t:r}=reactI18next.useTranslation(),a=runtime.useGlobalStylingPresets(),i=useAddClassesToBlocks(),l=runtime.getBlockComponent(o._type),c=lodashEs.get(lodashEs.first(n),"prop"),d=lodashEs.get(l.props,`${c}.presets`,{});if(lodashEs.isEmpty(a)&&(!lodashEs.has(l,"props")||lodashEs.isEmpty(d)))return null;const u=x=>{const m=x.trim().toLowerCase().replace(/ +(?= )/g,"").split(" ");i([o._id],m,!0)};return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-10",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenu,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"px-4",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{variant:"default",className:"w-full",size:"sm",children:[r("Apply Presets"),jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CaretDownIcon,{})]})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuContent,{className:"max-h-80 w-56",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ScrollArea,{className:"no-scrollbar h-full",children:[lodashEs.isEmpty(d)?null:jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenuLabel,{children:[l.type," ",r("presets")]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuSeparator,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuGroup,{children:lodashEs.keys(d).map(x=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenuItem,{className:"group text-xs",onClick:()=>u(d[x]),children:[lodashEs.capitalize(lodashEs.startCase(r(x))),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuShortcut,{className:"invisible hover:font-bold hover:text-blue-600 group-hover:visible",children:r("apply")})]}))})]}),lodashEs.isEmpty(a)?null:jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuLabel,{children:r("Global presets")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuSeparator,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuGroup,{children:lodashEs.keys(a).map(x=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenuItem,{className:"group text-xs",onClick:()=>u(a[x]),children:[lodashEs.capitalize(lodashEs.startCase(r(x))),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuShortcut,{className:"invisible hover:font-bold hover:text-blue-600 group-hover:visible",children:r("apply")})]}))})]})]})})]})})},MAPPER={px:1,"%":1,em:100,rem:100,ch:1,vw:1,vh:1,"-":1,deg:1,ms:.1};function BlockStyling(){const{flexChild:o,gridChild:n}=useSelectedBlocksDisplayChild(),[r]=useSelectedStylingBlocks(),[a,i]=React.useState(""),[l,c]=React.useState({onDrag:x=>x,onDragEnd:x=>x,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""}),d=web.useThrottledCallback(x=>{const m=!lodashEs.get(l,"negative",!1),h=lodashEs.get(l,"cssProperty","");let p=parseFloat(l.dragStartValue);p=isNaN(p)?0:p;let f=MAPPER[l.dragUnit];(lodashEs.startsWith(h,"scale")||h==="opacity")&&(f=10);let j=(l.dragStartY-x.pageY)/f+p;m&&j<0&&(j=0),h==="opacity"&&j>1&&(j=1),l.onDrag(`${j}`),i(`${j}`)},[l],50),u=React.useCallback(()=>{setTimeout(()=>l.onDragEnd(`${a}`),100),c({onDrag:x=>x,onDragEnd:x=>x,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""})},[l,a,c]);return lodashEs.isEmpty(r)?null:jsxRuntime.jsxRuntimeExports.jsxs(BlockSettingsContext.Provider,{value:{setDragData:c},children:[l.dragging?jsxRuntime.jsxRuntimeExports.jsx("div",{onMouseMove:d,onMouseUp:()=>u(),className:"absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"}):null,jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx(StylingHelpers,{}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Accordion,{defaultValue:["Styles"],type:"multiple",className:"w-full",children:[o&&jsxRuntime.jsxRuntimeExports.jsx(StylingGroup,{section:FLEX_CHILD_SECTION}),n?jsxRuntime.jsxRuntimeExports.jsx(StylingGroup,{section:GRID_CHILD_SECTION}):null,SETTINGS_SECTIONS.map(x=>jsxRuntime.jsxRuntimeExports.jsx(StylingGroup,{section:x},x.heading))]})]})]})}const ChaiSelect=({defaultValue:o="",onValueChange:n,options:r,placeholder:a="Select",className:i=""})=>{const[l,c]=React.useState(o),d=u=>{const x=u.target.value;c(x),n(x)};return jsxRuntime.jsxRuntimeExports.jsx("div",{className:iconBase.cn("relative inline-block w-full",i),children:jsxRuntime.jsxRuntimeExports.jsxs("select",{className:"mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm text-foreground shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",value:l,onChange:d,children:[jsxRuntime.jsxRuntimeExports.jsx("option",{value:"",disabled:!0,children:a}),r.map(u=>jsxRuntime.jsxRuntimeExports.jsx("option",{value:u.value,children:u.label},u.value))]})})},ChaiSelect$1=ChaiSelect;function UILibrariesSelect({uiLibraries:o,library:n,setLibrary:r}){const{t:a}=reactI18next.useTranslation();return n?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"h-12",children:[jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs font-bold text-gray-500",children:a("choose_library")}),jsxRuntime.jsxRuntimeExports.jsx(ChaiSelect$1,{className:"mt-1",options:o.map(i=>({value:i.uuid,label:i.name})),defaultValue:n,onValueChange:i=>r(i)})]}):null}const BlockCard=({block:o,library:n,parentId:r=void 0})=>{const[a,i]=React.useState(!1),l=useBuilderProp("getUILibraryBlock",lodashEs.noop),{addCoreBlock:c,addPredefinedBlock:d}=useAddBlock(),[,u]=useSelectedBlockIds(),{clearHighlight:x}=useBlockHighlight(),m=lodashEs.get(o,"name",lodashEs.get(o,"label")),h=flagged.useFeature("dnd"),[,p]=jotai.useAtom(draggedBlockAtom),f=E=>{const y=lodashEs.has(E,"styles_attrs.data-page-section");return E._type==="Box"&&y},R=React.useCallback(async E=>{if(E.stopPropagation(),lodashEs.has(o,"component")){c(o,r),emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK});return}i(!0);const y=await l(n,o);lodashEs.isEmpty(y)||d(runtime.syncBlocksWithDefaults(y),r),emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK})},[o]),j=async E=>{const y=await l(n,o);let v=r;if(f(lodashEs.first(y))&&(v=null),!lodashEs.isEmpty(y)){const w={blocks:y,uiLibrary:!0,parent:v};if(E.dataTransfer.setData("text/plain",JSON.stringify(w)),o.preview){const k=new Image;k.src=o.preview,k.onload=()=>{E.dataTransfer.setDragImage(k,0,0)}}else E.dataTransfer.setDragImage(new Image,0,0);p(w),setTimeout(()=>{u([]),x(),emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK})},200)}};return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("div",{onClick:a?()=>{}:R,draggable:h?"true":"false",onDragStart:j,className:clsx("relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"),children:[a&&jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"absolute flex h-full w-full items-center justify-center bg-black/70",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"animate-spin",size:15,color:"white"}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"pl-2 text-sm text-white",children:"Adding..."})]}),o.preview?jsxRuntime.jsxRuntimeExports.jsx("img",{src:o.preview,className:"min-h-[45px] w-full rounded-md",alt:m}):jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex h-20 items-center justify-center rounded-md border border-border bg-gray-200",children:jsxRuntime.jsxRuntimeExports.jsx("p",{className:"max-w-xs text-center text-sm text-gray-700",children:m})})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:m})})]})},libraryBlocksAtom=jotai.atom({}),useLibraryBlocks=o=>{const[n,r]=jotai.useAtom(libraryBlocksAtom),a=useBuilderProp("getUILibraryBlocks",lodashEs.noop),i=lodashEs.get(n,`${o==null?void 0:o.uuid}.blocks`,null),l=lodashEs.get(n,`${o==null?void 0:o.uuid}.loading`,"idle"),c=React.useRef("idle");return React.useEffect(()=>{(async()=>{if(l==="complete"||c.current==="loading")return;c.current="loading",r(u=>({...u,[o==null?void 0:o.uuid]:{loading:"loading",blocks:[]}}));const d=await a(o);c.current="idle",r(u=>({...u,[o==null?void 0:o.uuid]:{loading:"complete",blocks:d||[]}}))})()},[o,i,l,c]),{data:i||[],isLoading:l==="loading"}},UILibrarySection=({parentId:o})=>{const[n,r]=jotai.useAtom(selectedLibraryAtom),a=useBuilderProp("uiLibraries",[]),i=runtime.useChaiBlocks(),l=lodashEs.values(i).filter(v=>v.category==="custom"),c=a.find(v=>v.uuid===n)||lodashEs.first(a),{data:d,isLoading:u}=useLibraryBlocks(c),x=lodashEs.groupBy([...d,...l],"group"),[m,h]=React.useState("Hero"),p=lodashEs.get(x,m,[]),f=React.useRef(null),{t:R}=reactI18next.useTranslation(),j=v=>{f.current&&(clearTimeout(f.current),f.current=null),f.current=setTimeout(()=>{f.current&&h(v)},300)};if(u)return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-4 grid h-full w-full grid-cols-12 gap-2",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"col-span-3 h-full"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"col-span-9 h-full"})]});const E=lodashEs.filter(p,(v,w)=>w%2===0),y=lodashEs.filter(p,(v,w)=>w%2===1);return jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"relative mt-2 flex h-full max-h-full overflow-hidden bg-background",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full pt-2",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2",children:[jsxRuntime.jsxRuntimeExports.jsx(UILibrariesSelect,{library:c==null?void 0:c.uuid,setLibrary:r,uiLibraries:a}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2 flex h-full max-h-full w-full flex-1 flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"text-xs font-bold text-gray-500",children:R("groups")}),jsxRuntime.jsxRuntimeExports.jsx("hr",{className:"mt-1 border-border"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20",children:React.Children.toArray(lodashEs.map(x,(v,w)=>jsxRuntime.jsxRuntimeExports.jsxs("div",{onMouseEnter:()=>j(w),onMouseLeave:()=>clearTimeout(f.current),onClick:()=>h(w),className:iconBase.cn("flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",w===m?"bg-blue-500 text-white hover:bg-blue-600":""),children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:lodashEs.capitalize(R(w.toLowerCase()))}),jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CaretRightIcon,{className:"ml-2 h-5 w-5"})]},w)))})]})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.ScrollArea,{onMouseEnter:()=>f.current?clearTimeout(f.current):null,className:"z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-2 px-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-1",children:React.Children.toArray(E.map(v=>jsxRuntime.jsxRuntimeExports.jsx(BlockCard,{parentId:o,block:v,library:c})))}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-1",children:React.Children.toArray(y.map(v=>jsxRuntime.jsxRuntimeExports.jsx(BlockCard,{parentId:o,block:v,library:c})))})]}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{})]})]})})})},UILibrariesPanel=({parentId:o})=>jsxRuntime.jsxRuntimeExports.jsx(UILibrarySection,{parentId:o}),UILibraries=UILibrariesPanel,add_block="Add block",enter_paste_tailwind_html="(Enter or paste TailwindCSS HTML snippet)",click_to_add_block="(Click to add block to page)",core="Core",custom_blocks="Custom Blocks",ui_library="UI Library",html_snippet_description="Use HTML snippets from Tailwind CSS component libraries etc. or just copy paste your own HTML code.",tailwind_html_snippet="Tailwind HTML snippet:",enter_code_snippet="Enter your code snippet here...",import_html="Import HTML",note_imported_html="NOTE: Imported html will be added to the currently selected block. If no block is selected, the html will be added to the page.",dark_mode="Dark mode",tree_view_no_blocks="This page has no blocks. Add a block by clicking the + button",canvas_empty="This page is empty",no_block_selected_for_styling="Please select a block to edit settings or styles",no_block_selected_for_ask_ai="Please select a block to ask AI",no_styling_block_selected="Please select a styling block",drop_here_message="Drop your block here",use_setting="Use setting",mobile_xs_title="Mobile (XS)",mobile_xs_content="Styles set here are applied to all screen unless edited at higher breakpoint",mobile_sm_title="Mobile landscape (SM)",mobile_sm_content="Styles set here are applied at 640px and up unless edited at higher breakpoint",tablet_md_title="Tablet (MD)",tablet_md_content="Styles set here are applied at 768px and up",tablet_lg_title="Tablet Landscape (LG)",tablet_lg_content="Styles set here are applied at 1024px and up unless edited at higher breakpoint",desktop_xl_title="Desktop (XL)",desktop_xl_content="Styles set here are applied at 1280px and up unless edited at higher breakpoint",large_desktop_2xl_title="Large Desktop (2XL)",large_desktop_2xl_content="Styles set here are applied at 1536px and up",Breakpoints$1="Breakpoints",clear="Clear",clear_canvas_title="Clear whole canvas?",clear_canvas_description="Are you sure you want to clear the whole canvas?",cancel="Cancel",yes="Yes",preview="Preview",settings="Settings",styling="Styling",data_provider="Data Provider",remove_provider_confirmation="Are you sure you want to remove <span class='text-blue-500'>{name}</span> provider?",remove_provider_warning="Your data provider will be removed from this page and all added data binding will be not visible on blocks.",remove="Remove",no_data_providers="You have no data providers registered. Please add a data provider to your project.",learn_more="Learn more",add_data_providers="Add data providers:",select_provider="Select a provider",choose="Choose",page_data_providers="Page data providers:",view_data="View Data",mark_as_global="Mark as Global",global_block_note="Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.",global_block_indicator="Global blocks are indicated with",global_block_category="Global blocks are available under 'Global' category",enter_global_block_name="Enter global block name",eg_header_footer="Eg: Header, Footer",blocks_selected="{{length}} blocks selected.",cut="Cut",copy="Copy",clear_selection="Clear Selection",dev_mode_message="This is dev mode. Visit",to_see_page_preview="to see page preview",theme_config={heading_font:"Heading Font",body_font:"Body Font",rounded_corner:"Rounded Corners",primary:"Primary",secondary:"Secondary",background:"Background",text_color:"Text Color",background_dark_mode:"Background (Dark Mode)",text_color_dark_mode:"Text Color (Dark Mode)"},web_blocks={box:"box",tag:"Tag",div:"div",level:"Level",header:"header",footer:"footer",section:"section",article:"article",aside:"aside",main:"main",nav:"navigation",figure:"figure",details:"details",summary:"summary",dialog:"dialog",strike:"strike",caption:"caption",legend:"legend",figcaption:"figure caption",mark:"mark",background_image:"Background Image",label:"Label",default:"default",icon_size:"Icon Size",icon_position:"Icon Position",start:"Start",end:"End",button:"Button",custom_html:"Custom HTML",html_code:"HTML Code",default_snippet:"The HTML snippet goes here...",placeholder:"Enter custom HTML code here",custom_script:"Custom Script",dark_mode:"Dark Mode",divider:"Divider",empty_box:"Empty Box",heading:"Heading",image:"Image",alt:"Alt",width:"Width",height:"Height",video:"Video",span:"Span",content:"Content",icon:"Icon",richtext:"Rich Text",list:"List",list_type:"List Type",listitem:"List Item",link:"Link",list_item:"List Item",none:"None",disc:"Disc",number:"Number",paragraph:"Paragraph",lightbox_link:"Lightbox Link",href:"Link",type:"Type",iframe:"iframe",inline:"inline",ajax:"ajax",autoplay:"Video autoplay",max_width:"Max Width",backdrop_color:"Background Color",gallery_name:"Gallery Name",slot:"Slot",empty_slot:"Empty Slot",text:"Text",video_url:"Video URL",controls:"Show Controls",loop:"Loop",muted:"Muted",checkbox:"Checkbox",required:"Required",checked:"Checked",submit_button:"Submit Button",form:"Form",submit_url:"Submit URL",error_message:"Error Message",success_message:"Success Message",input:"Input",value:"Value",show_label:"Show Label",field_name:"Field Name",radio:"Radio",multiple:"Multiple",options:"Options",select:"Select",multiple_choice:"Multiple Choice",textarea:"Textarea",rows:"Rows"},ai_assistant="AI Assistant",close_preview="Close Preview",saved="Saved",unsaved="Unsaved",saving="Saving...",page_is_empty="This page is empty.",Theme="Theme",Outline="Outline",clipboard_not_supported="Not supported",please_use_chrome_firefox_or_safari="Please use Chrome, Firefox or Safari",classes_copied_to_clipboard="Classes copied to clipboard",download_complete="Download complete",copied="Copied",enter_classes_separated_by_space="Enter classes separated by space",copy_classes_to_clipboard="Copy classes to clipboard",classes="Classes",ask_ai="Ask AI",edit_with_ai="Edit with AI",generating_please_wait="Generating... Please wait",stop$1="Stop",eg_this_page_is_about_an_ai_assistant_app_called_chai_studio_it_allows_users_to_create_beautiful_webpages_and_edit_content_with_ai="E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI.",ask_ai_to_edit_styles="Ask AI to edit styles",ask_ai_to_edit_content="Ask AI to edit content",ai_context="AI Context",please_select_a_block_to_ask_ai="Select a block to edit with AI",please_select_a_block_to_edit="Please select a block to edit",edit="Edit",tell_about_this_page_eg_this_page_is_about="Describe this page. E.g.: This page is about...",tag="Tag",value="Value",background_image="Background Image",enter_image_url="Enter image URL",replace_image="Replace image",choose_image="Choose image",images="Images",typography="Typography",background="Background",library="Library",blocks="Blocks",basic="Basic",media="Media",advanced="Advanced",form="Form",choose_icon_or_enter_svg="Choose an icon or enter SVG",groups="Groups",ui_libraries="UI Libraries",accordions="Accordions",buttons="Buttons",layouts="Layouts",choose_library="Choose library",no_library_found="No library found.",faq="FAQ",hero="Hero",features="Features",footer="Footer",navbar="Navbar",icons="Icons",testimonials="Testimonials",blog="Blog",ai_quick_prompts={improve_writing:"Improve writing",replace_placeholder_content:"Replace placeholder content",fix_grammar:"Fix grammar",make_longer:"Make longer",make_shorter:"Make shorter",add_emojis:"Add emojis",randomize:"Randomize"},sidebar={outline:"Outline",edit_block:"Edit Block",ai_assistant:"AI Assistant",theme:"Theme"},remove_context="Remove context",yes_delete="Yes, Delete",ai_context_updated="AI Context Updated",you_can_now_ask_ai_to_edit_your_content="You can now ask AI to edit your content.",lngEn={add_block,enter_paste_tailwind_html,click_to_add_block,core,custom_blocks,ui_library,import:"Import",html_snippet_description,tailwind_html_snippet,enter_code_snippet,import_html,note_imported_html,dark_mode,tree_view_no_blocks,canvas_empty,no_block_selected_for_styling,no_block_selected_for_ask_ai,no_styling_block_selected,drop_here_message,use_setting,mobile_xs_title,mobile_xs_content,mobile_sm_title,mobile_sm_content,tablet_md_title,tablet_md_content,tablet_lg_title,tablet_lg_content,desktop_xl_title,desktop_xl_content,large_desktop_2xl_title,large_desktop_2xl_content,Breakpoints:Breakpoints$1,clear,clear_canvas_title,clear_canvas_description,cancel,yes,preview,settings,styling,data_provider,remove_provider_confirmation,remove_provider_warning,remove,no_data_providers,learn_more,add_data_providers,select_provider,choose,page_data_providers,view_data,mark_as_global,global_block_note,global_block_indicator,global_block_category,enter_global_block_name,eg_header_footer,blocks_selected,cut,copy,delete:"Delete",clear_selection,dev_mode_message,to_see_page_preview,"flex.heading":"Flex Child","flex.basis":"Basis","flex.order":"Order","flex.flex":"Flex","flex.grow":"Grow","flex.shrink":"Shrink","grid.heading":"Grid Child","grid.col_span":"Col Span","grid.col_start":"Col Start","grid.col_end":"Col End","grid.row_span":"Row Span","grid.row_start":"Row Start","grid.row_end":"Row End","grid.order":"Order","layout.heading":"Layout","layout.width":"Width","layout.height":"Height","layout.margin":"Margin","layout.margin_all":"All","layout.margin_lr":"Left-Right","layout.margin_tb":"Top-Bottom","layout.margin_top":"Top","layout.margin_right":"Right","layout.margin_bottom":"Bottom","layout.margin_left":"Left","layout.padding":"Padding","layout.padding_all":"All","layout.padding_lr":"Left-Right","layout.padding_tb":"Top-Bottom","layout.padding_top":"Top","layout.padding_right":"Right","layout.padding_bottom":"Bottom","layout.padding_left":"Left","layout.space_bt":"Space Bt.","layout.space_lr":"Left-Right","layout.space_tb":"Top-Bottom","size.heading":"Size","size.min_width_height":"Min width & height","size.min_width":"Min Width","size.min_height":"Min Height","size.max_width_height":"Max width & height","size.max_width":"Max Width","size.max_height":"Max Height","size.object_options_aspect_ratio":"Object options & aspect ratio","size.aspect":"Aspect","size.fit":"Fit","size.position":"Position","display.heading":"Display","display.display":"Display","display.flex_options":"Flex options","display.flex_direction":"Direction","display.flex_wrap":"Wrap","display.justify_content":"Justify","display.align_content":"Content","display.align_items":"Items","display.gap":"Gap","display.gap_all":"All","display.gap_lr":"Left-Right","display.gap_tb":"Top-Bottom","display.grid_options":"Grid options","display.grid_columns":"Columns","display.grid_rows":"Rows","display.grid_auto_flow":"Auto Flow","display.grid_auto_cols":"Auto Cols","display.grid_auto_rows":"Auto Rows","display.visibility_opacity":"Visibility & Opacity","display.visibility":"Visibility","display.opacity":"Opacity","position.heading":"Position","position.position":"Position","position.options":"Position options","position.direction":"Direction","position.top":"Top","position.right":"Right","position.bottom":"Bottom","position.left":"Left","position.inset":"Inset","position.all":"All","position.lr":"Left Right","position.tb":"Top Bottom","position.z_index":"Z-Index","position.float_clear":"Float & Clear","position.float":"Float","position.clear":"Clear","position.overflow_overscroll":"Overflow & Overscroll","position.overflow":"Overflow","position.overscroll":"Overscroll","typography.heading":"Typography","typography.font":"Font","typography.size":"Size","typography.height":"Height","typography.weight":"Weight","typography.color":"Color","typography.alignments":"Alignments","typography.align":"Align","typography.valign":"V. Align","typography.spacing_decoration_more":"Spacing, decoration & more","typography.spacing":"Spacing","typography.decoration":"Decoration","typography.thickness":"Thickness","typography.transform":"Transform","typography.whitespace_breaks":"White space & breaks","typography.whitespace":"Whitespace","typography.wordbreak":"Wordbreak","background.heading":"Background","background.bgcolor":"Bg. Color","background.position_size_more":"Position, Size & more","background.attachment":"Attachment","background.clipping":"Clipping","background.origin":"Origin","background.position":"Position","background.repeat":"Repeat","background.size":"Size","background.gradient":"Gradient","background.gradient_colors":"Gradient colors","background.from_color":"From","background.via_color":"Via","background.to_color":"To","border.heading":"Border & Outline","border.width":"Width","border.all":"All","border.lr":"Left Right","border.tb":"Top bottom","border.top":"Top","border.right":"Right","border.bottom":"Bottom","border.left":"Left","border.corners":"Corners","border.top_left":"Top Left","border.top_right":"Top right","border.bottom_right":"Bottom right","border.bottom_left":"Bottom left","border.color":"Color","border.style":"Style","border.divide_options":"Divide options","border.divide_color":"Color","border.divide_style":"Style","border.outline_styling":"Outline styling","border.outline_width":"Width","border.outline_offset":"Offset","border.outline_style":"Style","border.ring_options":"Ring options","border.ring_width":"Width","border.ring_color":"Color","border.ring_offset_width":"Offset","border.ring_offset_color":"Off. color","effect.heading":"Effect & Animation","effect.shadow":"Shadow","effect.color":"Color","effect.cursor":"Cursor","effect.blend_cursor":"Blend & Cursor","effect.mix_blend":"Mix Blend","effect.bg_blend":"Bg. Blend","effect.transform":"Transform","effect.origin":"Origin","effect.scale":"Scale","effect.all":"All","effect.lr":"Left-Right","effect.tb":"Top-Bottom","effect.skew":"Skew","effect.translate":"Translate","effect.rotate":"Rotate","effect.animation":"Animation","effect.transition":"Transition","effect.easing":"Easing","effect.duration":"Duration","effect.delay":"Delay","classes.heading":"Classes",theme_config,web_blocks,ai_assistant,close_preview,saved,unsaved,saving,page_is_empty,Theme,Outline,clipboard_not_supported,please_use_chrome_firefox_or_safari,classes_copied_to_clipboard,download_complete,copied,enter_classes_separated_by_space,copy_classes_to_clipboard,classes,ask_ai,edit_with_ai,generating_please_wait,stop:stop$1,eg_this_page_is_about_an_ai_assistant_app_called_chai_studio_it_allows_users_to_create_beautiful_webpages_and_edit_content_with_ai,ask_ai_to_edit_styles,ask_ai_to_edit_content,ai_context,please_select_a_block_to_ask_ai,please_select_a_block_to_edit,edit,tell_about_this_page_eg_this_page_is_about,tag,value,background_image,enter_image_url,replace_image,choose_image,images,typography,background,library,blocks,basic,media,advanced,form,choose_icon_or_enter_svg,groups,ui_libraries,accordions,buttons,layouts,choose_library,no_library_found,faq,hero,features,footer,navbar,icons,testimonials,blog,ai_quick_prompts,sidebar,remove_context,yes_delete,ai_context_updated,you_can_now_ask_ai_to_edit_your_content};i18n.use(reactI18next.initReactI18next).init({resources:{en:{translation:lngEn}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const CoreBlock=({block:o,disabled:n,parentId:r})=>{const[,a]=jotai.useAtom(draggedBlockAtom),{type:i,icon:l,label:c}=o,{addCoreBlock:d,addPredefinedBlock:u}=useAddBlock(),[,x]=useSelectedBlockIds(),{clearHighlight:m}=useBlockHighlight(),h=()=>{if(lodashEs.has(o,"blocks")){const R=lodashEs.isFunction(o.blocks)?o.blocks():o.blocks;u(runtime.syncBlocksWithDefaults(R),r||null)}else d(o,r||null);emitChaiBuilderMsg({name:CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK})},p=flagged.useFeature("dnd"),{t:f}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment,{children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{disabled:n,onClick:h,type:"button",onDragStart:R=>{R.dataTransfer.setData("text/plain",JSON.stringify(lodashEs.omit(o,["component","icon"]))),R.dataTransfer.setDragImage(new Image,0,0),a(lodashEs.omit(o,["component","icon"])),setTimeout(()=>{x([]),m()},200)},draggable:p?"true":"false",className:"cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",children:[React.createElement(l||reactIcons.BoxIcon,{className:"w-4 h-4 mx-auto"}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"truncate text-xs",children:lodashEs.capitalize(f(c||i))})]})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:f(c||i)})})]})})},DefaultChaiBlocks=({parentId:o,gridCols:n="grid-cols-2"})=>{const r=runtime.useChaiBlocks(),a=useBuilderProp("filterChaiBlock",()=>!0),i=lodashEs.filter(r,a),l=lodashEs.groupBy(i,"category"),c=lodashEs.uniq(lodashEs.map(l.core,"group"));return jsxRuntime.jsxRuntimeExports.jsx(ChaiBuilderBlocks,{gridCols:n,parentId:o,groups:c,blocks:l.core})},CORE_GROUPS=["basic","typography","media","layout","form","advanced","other"],ChaiBuilderBlocks=({groups:o,blocks:n,parentId:r,gridCols:a="grid-cols-4"})=>{var d;const{t:i}=reactI18next.useTranslation(),[l]=useBlocksStore(),c=(d=lodashEs.find(l,u=>u._id===r))==null?void 0:d._type;return React.Children.toArray(lodashEs.map(lodashEs.sortBy(o,u=>CORE_GROUPS.indexOf(u)===-1?99:CORE_GROUPS.indexOf(u)),u=>lodashEs.reject(lodashEs.filter(lodashEs.values(n),{group:u}),{hidden:!0}).length?jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Accordion,{type:"single",value:u,collapsible:!0,className:"w-full",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:u,className:"border-border",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{className:"rounded-md bg-background px-4 py-2 capitalize text-foreground hover:no-underline",children:lodashEs.capitalize(i(u.toLowerCase()))}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionContent,{className:"mx-auto max-w-xl p-3",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"grid gap-2 "+a,children:React.Children.toArray(lodashEs.reject(lodashEs.filter(lodashEs.values(n),{group:u}),{hidden:!0}).map(x=>jsxRuntime.jsxRuntimeExports.jsx(CoreBlock,{parentId:r,block:x,disabled:!canAcceptChildBlock(c,x.type)||!canBeNestedInside(c,x.type)})))})})]})}):null))},addBlockTabAtom=atomWithStorage("__add_block_tab","library"),AddBlocksPanel=({className:o,showHeading:n=!0,parentId:r=void 0})=>{const{t:a}=reactI18next.useTranslation(),[i,l]=jotai.useAtom(addBlockTabAtom),[,c]=jotai.useAtom(showPredefinedBlockCategoryAtom),d=useBuilderProp("importHTMLSupport",!0);return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:iconBase.cn("flex h-full w-full flex-col overflow-hidden",o),children:[n?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1",children:[jsxRuntime.jsxRuntimeExports.jsx("h1",{className:"flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col",children:a("Add block")}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"p-0 text-xs font-light leading-3 opacity-80 xl:pl-1",children:a(i==="html"?"enter_paste_tailwind_html":"click_to_add_block")})]}):null,jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Tabs,{onValueChange:u=>{c(""),l(u)},value:i,className:iconBase.cn("h-max"),children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.TabsList,{className:"grid w-full "+(d?"grid-cols-3":"grid-cols-2"),children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"library",children:a("library")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"core",children:a("blocks")}),d?jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TabsTrigger,{value:"html",children:a("import")}):null]})}),i==="core"&&jsxRuntime.jsxRuntimeExports.jsx(contextMenu.ScrollArea,{className:"-mx-1.5 h-[calc(100vh-156px)] overflow-y-auto",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-2 w-full",children:jsxRuntime.jsxRuntimeExports.jsx(DefaultChaiBlocks,{gridCols:"grid-cols-4",parentId:r})})}),i==="library"&&jsxRuntime.jsxRuntimeExports.jsx(UILibraries,{parentId:r}),i==="html"&&d?jsxRuntime.jsxRuntimeExports.jsx(ImportHTML$1,{parentId:r}):null]})},AddBlocksPanel$1=AddBlocksPanel,AddBlocksDialog=()=>{const{t:o}=reactI18next.useTranslation(),[n,r]=React.useState(""),[a,i]=React.useState(!1);return useChaiBuilderMsgListener(({name:l,data:c=void 0})=>{l===CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK&&(r(c==null?void 0:c._id),i(!0)),l===CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK&&(r(""),i(!1))}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialog,{open:a,onOpenChange:()=>a?i(!1):"",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{className:"max-w-5xl overflow-hidden border-border",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{className:"flex flex-row items-center justify-between",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTitle,{className:"text-foreground",children:o("Add blocks")}),jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:()=>i(!1),className:"text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Cross2Icon,{className:"h-6 w-6"})})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar h-[500px] max-h-full overflow-hidden",children:jsxRuntime.jsxRuntimeExports.jsx(AddBlocksPanel$1,{parentId:n,showHeading:!1})})]})})};function FaCheck(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"},child:[]}]})(o)}function FaFilePen(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M0 64C0 28.7 28.7 0 64 0H224V128c0 17.7 14.3 32 32 32H384V299.6l-94.7 94.7c-8.2 8.2-14 18.5-16.8 29.7l-15 60.1c-2.3 9.4-1.8 19 1.4 27.8H64c-35.3 0-64-28.7-64-64V64zm384 64H256V0L384 128zM549.8 235.7l14.4 14.4c15.6 15.6 15.6 40.9 0 56.6l-29.4 29.4-71-71 29.4-29.4c15.6-15.6 40.9-15.6 56.6 0zM311.9 417L441.1 287.8l71 71L382.9 487.9c-4.1 4.1-9.2 7-14.9 8.4l-60.1 15c-5.5 1.4-11.2-.2-15.2-4.2s-5.6-9.7-4.2-15.2l15-60.1c1.4-5.6 4.3-10.8 8.4-14.9z"},child:[]}]})(o)}function FaLanguage(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M0 128C0 92.7 28.7 64 64 64H256h48 16H576c35.3 0 64 28.7 64 64V384c0 35.3-28.7 64-64 64H320 304 256 64c-35.3 0-64-28.7-64-64V128zm320 0V384H576V128H320zM178.3 175.9c-3.2-7.2-10.4-11.9-18.3-11.9s-15.1 4.7-18.3 11.9l-64 144c-4.5 10.1 .1 21.9 10.2 26.4s21.9-.1 26.4-10.2l8.9-20.1h73.6l8.9 20.1c4.5 10.1 16.3 14.6 26.4 10.2s14.6-16.3 10.2-26.4l-64-144zM160 233.2L179 276H141l19-42.8zM448 164c11 0 20 9 20 20v4h44 16c11 0 20 9 20 20s-9 20-20 20h-2l-1.6 4.5c-8.9 24.4-22.4 46.6-39.6 65.4c.9 .6 1.8 1.1 2.7 1.6l18.9 11.3c9.5 5.7 12.5 18 6.9 27.4s-18 12.5-27.4 6.9l-18.9-11.3c-4.5-2.7-8.8-5.5-13.1-8.5c-10.6 7.5-21.9 14-34 19.4l-3.6 1.6c-10.1 4.5-21.9-.1-26.4-10.2s.1-21.9 10.2-26.4l3.6-1.6c6.4-2.9 12.6-6.1 18.5-9.8l-12.2-12.2c-7.8-7.8-7.8-20.5 0-28.3s20.5-7.8 28.3 0l14.6 14.6 .5 .5c12.4-13.1 22.5-28.3 29.8-45H448 376c-11 0-20-9-20-20s9-20 20-20h52v-4c0-11 9-20 20-20z"},child:[]}]})(o)}function FaStar(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M316.9 18C311.6 7 300.4 0 288.1 0s-23.4 7-28.8 18L195 150.3 51.4 171.5c-12 1.8-22 10.2-25.7 21.7s-.7 24.2 7.9 32.7L137.8 329 113.2 474.7c-2 12 3 24.2 12.9 31.3s23 8 33.8 2.3l128.3-68.5 128.3 68.5c10.8 5.7 23.9 4.9 33.8-2.3s14.9-19.3 12.9-31.3L438.5 329 542.7 225.9c8.6-8.5 11.7-21.2 7.9-32.7s-13.7-19.9-25.7-21.7L381.2 150.3 316.9 18z"},child:[]}]})(o)}const LANGUAGES={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"},QUICK_PROMPTS=[{name:"Improve writing",icon:FaFilePen,prompt:"Improving writing in all text elements. Replacing placeholder content with meaningful relevant content."},{name:"Replace placeholder content",icon:FaRecycle,prompt:"Discard current placeholder content and replace with meaningful relevant content."},{name:"Fix grammar",icon:reactIcons.CheckIcon,prompt:"Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors."},{name:"Make longer",icon:reactIcons.ArrowUpIcon,prompt:"Make all text elements longer."},{name:"Make shorter",icon:reactIcons.ArrowDownIcon,prompt:"Make all text elements shorter."},{name:"Add emojis",icon:lucideReact.SmileIcon,prompt:"Add emojis to text elements if relevant."},{name:"Randomize",icon:lucideReact.ShuffleIcon,prompt:"Randomize all text elements."}];function QuickPrompts({onClick:o}){const{loading:n}=useAskAi(),{t:r}=reactI18next.useTranslation(),{selectedLang:a,fallbackLang:i}=useLanguages(),l=[...QUICK_PROMPTS];return a&&a!==i&&l.splice(0,0,{name:`Translate to ${lodashEs.get(LANGUAGES,a,a)}`,icon:FaLanguage$1,prompt:`Translate the content to ${lodashEs.get(LANGUAGES,a,a)}. Maintain same tone, style and length.`}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:n?"pointer-events-none opacity-50":"",children:jsxRuntime.jsxRuntimeExports.jsx("ul",{className:"space-y-2",children:l.map(({name:c,icon:d,subMenus:u,prompt:x})=>u?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Popover,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs("li",{className:"flex cursor-pointer items-center space-x-2 rounded p-1 pl-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",children:[jsxRuntime.jsxRuntimeExports.jsx(d,{className:"h-4 w-4"}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:c})]},c)}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.PopoverContent,{side:"right",children:jsxRuntime.jsxRuntimeExports.jsx("ul",{children:jsxRuntime.jsxRuntimeExports.jsx("li",{children:"Happy"})})})]}):jsxRuntime.jsxRuntimeExports.jsxs("li",{onClick:()=>o(x),className:"flex cursor-pointer items-center space-x-2 rounded p-1 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",children:[jsxRuntime.jsxRuntimeExports.jsx(d,{className:"h-4 w-4"}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:r(c)})]},c))})})}const AIUserPrompt=({blockId:o})=>{const{t:n}=reactI18next.useTranslation(),{askAi:r,loading:a,error:i}=useAskAi(),[l,c]=React.useState(""),[d,u]=React.useState(!0),[x,m]=React.useState(),h=React.useRef(null),p=React.useRef(null);React.useEffect(()=>{var R;(R=h.current)==null||R.focus()},[]);const f=R=>{const{usage:j}=R||{};!i&&j&&m(j),p.current=setTimeout(()=>m(void 0),1e4),i||c("")};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{onClick:()=>u(!d),className:"flex cursor-pointer items-center justify-between border-b border-border py-2 text-sm font-bold text-muted-foreground hover:underline",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:n("Ask AI")}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 text-gray-500 "+(d?"rotate-180":"")})})]}),d&&o?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{ref:h,value:l,onChange:R=>c(R.target.value),placeholder:n("Ask AI to edit content"),className:"w-full",rows:3,onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),p.current&&clearTimeout(p.current),m(void 0),r("content",o,l,f))}}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"my-2 flex items-center gap-2",children:[a?null:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:l.trim().length<5||a,onClick:()=>{p.current&&clearTimeout(p.current),m(void 0),r("content",o,l,f)},variant:"default",className:"w-fit",size:"sm",children:a?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),n("generating_please_wait")]}):n("edit_with_ai")}),a?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Skeleton,{className:"flex w-full items-center space-x-1 px-4 py-1 pl-2",children:[jsxRuntime.jsxRuntimeExports.jsx(FaSpinner,{className:"h-4 w-4 animate-spin text-gray-500"}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs",children:n("Generating... Please wait...")})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"destructive",onClick:()=>stop(),className:"hidden w-fit",size:"sm",children:n("Stop")})]}):null]}),x?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"max-w-full",children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500",children:[jsxRuntime.jsxRuntimeExports.jsxs("span",{children:[n("Total tokens used"),": ",x.totalTokens]}),jsxRuntime.jsxRuntimeExports.jsx(Countdown,{})]})}):null,jsxRuntime.jsxRuntimeExports.jsx("div",{className:"max-w-full",children:i&&jsxRuntime.jsxRuntimeExports.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:i.message})}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx(QuickPrompts,{onClick:R=>{p.current&&clearTimeout(p.current),m(void 0),r("content",o,R,f)}})]}):d?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"p-4 text-center",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.SparklesIcon,{className:"mx-auto text-3xl text-muted-foreground"}),jsxRuntime.jsxRuntimeExports.jsx("h1",{children:n("Please select a block to Ask AI")})]})}):null]})},AISetContext=()=>{const{t:o}=reactI18next.useTranslation(),n=useBuilderProp("aiContext",""),[r,a]=React.useState(n),i=React.useRef(null),l=useBuilderProp("saveAiContextCallback",lodashEs.noop),[c,d]=React.useState(!1),[u,x]=React.useState(null),[,m]=React.useState(!1),{toast:h}=contextMenu.useToast(),p=React.useRef(null);React.useEffect(()=>{n&&a(n)},[n]);const f=async()=>{try{d(!0),x(null),await l(r),h({title:o("Updated AI Context"),description:o("You can now Ask AI to edit your content"),variant:"default"}),p.current.click()}catch(R){x(R)}finally{d(!1)}};return jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Accordion,{onValueChange:R=>{m(R!=="")},type:"single",collapsible:!0,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionItem,{value:"set-context",className:"border-none",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AccordionTrigger,{ref:p,className:"border-b border-border py-2",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex w-full items-center justify-between",children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"font-bold text-muted-foreground",children:o("AI Context")})})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AccordionContent,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{ref:i,value:r,onChange:R=>a(R.target.value),placeholder:o("Tell about this page eg this page is about"),className:"mt-1 w-full",rows:10,onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),f())}}),n.trim().length===0?jsxRuntime.jsxRuntimeExports.jsx("p",{className:"mt-2 text-xs text-gray-500",children:o("Eg: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI.")}):null,jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2 flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:r.trim().length<5,onClick:()=>f(),variant:"default",className:"w-fit",size:"sm",children:c?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),o("Saving... Please wait...")]}):o("Save")}),n.trim().length>0?jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:n.trim().length===0,variant:"ghost",className:"w-fit",size:"sm",children:c?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Loader,{className:"h-5 w-5 animate-spin"}),o("Deleting... Please wait...")]}):o("Delete")})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogTitle,{children:[o("Delete context")," ?"]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogDescription,{})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogFooter,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogCancel,{children:o("Cancel")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogAction,{onClick:()=>{a(""),f()},children:o("Yes, Delete")})]})]})]}):null]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-2 max-w-full",children:u&&jsxRuntime.jsxRuntimeExports.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:u.message})})]})]})})},AskAI=()=>{const[o]=useSelectedBlockIds();return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mt-2",children:[jsxRuntime.jsxRuntimeExports.jsx(AISetContext,{}),jsxRuntime.jsxRuntimeExports.jsx(AIUserPrompt,{blockId:lodashEs.first(o)})]})},AttrsEditor=React.memo(function o({preloadedAttributes:n=[],onAttributesChange:r}){const[a,i]=React.useState([]),[l,c]=React.useState(""),[d,u]=React.useState(""),[x,m]=React.useState(null),[h,p]=React.useState(""),f=React.useRef(null),R=React.useRef(null);React.useEffect(()=>{i(n)},[n]);const j=()=>{if(l.startsWith("@")){p("Attribute keys cannot start with '@'");return}if(l){const k=[...a,{key:l,value:d}];r(k),i(a),c(""),u(""),p("")}},E=k=>{const C=a.filter((I,N)=>N!==k);r(C),i(C)},y=k=>{m(k),c(a[k].key),u(a[k].value)},v=()=>{if(l.startsWith("@")){p("Attribute keys cannot start with '@'");return}if(x!==null&&l){const k=[...a];k[x]={key:l,value:d},r(k),i(k),m(null),c(""),u(""),p("")}},w=k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),x!==null?v():j())};return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"max-w-full",children:[jsxRuntime.jsxRuntimeExports.jsxs("form",{onSubmit:k=>{k.preventDefault(),x!==null?v():j()},className:"space-y-3",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"w-full",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Label,{htmlFor:"attrKey",className:"text-xs",children:"Key"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Input,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrKey",ref:f,value:l,onChange:k=>c(k.target.value),placeholder:"Key",className:"h-8 text-sm"})]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"w-full",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Label,{htmlFor:"attrValue",className:"text-xs",children:"Value"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Textarea,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrValue",rows:2,ref:R,value:d,onChange:k=>u(k.target.value),onKeyDown:w,placeholder:"Value",className:"bg-background text-sm"})]})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{type:"submit",variant:"secondary",className:"h-8 w-fit text-sm",children:x!==null?"Save":"Add"}),h&&jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs text-red-500",children:h})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mt-4 space-y-1 overflow-y-auto",children:a.map((k,C)=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between rounded bg-muted p-1.5 text-sm",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mr-2 flex flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"truncate font-semibold",children:k.key}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"text-wrap max-w-[200px] text-muted-foreground",children:k.value.toString()})]}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex-shrink-0",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>y(C),children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Edit2,{className:"h-3 w-3"}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Edit attribute"})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>E(C),children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.X,{className:"h-3 w-3"}),jsxRuntime.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Remove attribute"})]})]})]},C))})]})}),BlockAttributesEditor=React__namespace.memo(()=>{const o=useSelectedBlock(),[n,r]=React.useState([]),[a]=useSelectedStylingBlocks(),i=useUpdateBlocksProps(),l=`${lodashEs.get(a,"0.prop")}_attrs`;React__namespace.useEffect(()=>{const d=lodashEs.map(lodashEs.get(o,l),(u,x)=>({key:x,value:u}));lodashEs.isEmpty(d)?r([]):r(d)},[lodashEs.get(o,l)]);const c=React__namespace.useCallback((d=[])=>{const u={};lodashEs.forEach(d,x=>{lodashEs.isEmpty(x.key)||lodashEs.set(u,x.key,x.value)}),i([lodashEs.get(o,"_id")],{[l]:u})},[o,i,l]);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex-col gap-y-2",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsx(AttrsEditor,{preloadedAttributes:n,onAttributesChange:c})})})})});function getDNDSupport(){return new URLSearchParams(window.location.search).has("dnd")}const FEATURE_TOGGLES={dnd:getDNDSupport()},UndoRedo=()=>{const{hasUndo:o,hasRedo:n,undo:r,redo:a}=useUndoManager();return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:!o(),size:"sm",onClick:r,className:"rounded-full",variant:"ghost",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ResetIcon,{})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:!n(),onClick:a,size:"sm",className:"rounded-full",variant:"ghost",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ResetIcon,{className:"rotate-180 scale-y-[-1] transform"})})]})};function DarkMode(){const[o,n]=useDarkMode();return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.SunIcon,{className:"size-4 shrink-0"}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Switch,{id:"dark-mode-switch",checked:o,onCheckedChange:()=>{n(!o)},className:`${o?"bg-violet-600":"bg-violet-300"} relative ml-2 inline-flex h-[20px] w-[40px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`,children:jsxRuntime.jsxRuntimeExports.jsx("span",{"aria-hidden":"true",className:`${o?"translate-x-5":"translate-x-0"} pointer-events-none -mt-px inline-block h-[18px] w-[20px] transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`})}),jsxRuntime.jsxRuntimeExports.jsx(FaMoon,{className:"size-4 ml-3 shrink-0"})]})}const TabletIcon=({landscape:o=!1})=>jsxRuntime.jsxRuntimeExports.jsx("svg",{className:o?"rotate-90":"",stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 448 512",height:"14px",width:"14px",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M400 0H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V48c0-26.5-21.5-48-48-48zM224 480c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm176-108c0 6.6-5.4 12-12 12H60c-6.6 0-12-5.4-12-12V60c0-6.6 5.4-12 12-12h328c6.6 0 12 5.4 12 12v312z"})}),WEB_BREAKPOINTS=[{title:"mobile_xs_title",content:"mobile_xs_content",breakpoint:"xs",icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.MobileIcon,{}),width:400},{title:"mobile_sm_title",content:"mobile_sm_content",breakpoint:"sm",icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.MobileIcon,{className:"rotate-90"}),width:640},{title:"tablet_md_title",content:"tablet_md_content",breakpoint:"md",icon:jsxRuntime.jsxRuntimeExports.jsx(TabletIcon,{}),width:800},{title:"tablet_lg_title",content:"tablet_lg_content",breakpoint:"lg",icon:jsxRuntime.jsxRuntimeExports.jsx(TabletIcon,{landscape:!0}),width:1024},{title:"desktop_xl_title",content:"desktop_xl_content",breakpoint:"xl",icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.LaptopIcon,{}),width:1420},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",breakpoint:"2xl",icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DesktopIcon,{}),width:1920}],BreakpointCard=({title:o,content:n,currentBreakpoint:r,breakpoint:a,width:i,icon:l,onClick:c})=>{const{t:d}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.HoverCard,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.HoverCardTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{onClick:()=>c(i),size:"sm",variant:a===r?"secondary":"ghost",children:l})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.HoverCardContent,{className:"w-52 border-border",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsxRuntimeExports.jsx("h4",{className:"text-sm font-semibold",children:d(o)}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"text-xs",children:d(n)})]})})})]})},Breakpoints=()=>{const[,o,n]=useCanvasWidth(),[r,a]=useSelectedBreakpoints(),{t:i}=reactI18next.useTranslation(),l=useBuilderProp("breakpoints",WEB_BREAKPOINTS),c=d=>{r.includes(d)?r.length>2&&a(r.filter(u=>u!==d)):a(u=>[...u,d])};return l.length<4?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center rounded-md",children:lodashEs.map(l,d=>React.createElement(BreakpointCard,{...d,onClick:n,key:d.breakpoint,currentBreakpoint:o}))}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center rounded-md",children:[lodashEs.map(l.filter(d=>lodashEs.includes(r,lodashEs.toUpper(d.breakpoint))),d=>React.createElement(BreakpointCard,{...d,onClick:n,key:d.breakpoint,currentBreakpoint:o})),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenu,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx("span",{className:"cursor-pointer px-2.5 hover:opacity-80",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.DotsVerticalIcon,{className:"scale-90 transform"})})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DropdownMenuContent,{className:"w-56 border-border text-xs",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuLabel,{children:i("Breakpoints")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuSeparator,{}),lodashEs.map(l,d=>jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DropdownMenuCheckboxItem,{disabled:d.breakpoint==="xs",onCheckedChange:()=>c(lodashEs.toUpper(d.breakpoint)),checked:lodashEs.includes(r,lodashEs.toUpper(d.breakpoint)),children:i(d.title)},d.breakpoint))]})]})]})},ClearCanvas=()=>{const{t:o}=reactI18next.useTranslation(),{setNewBlocks:n}=useBlocksStoreUndoableActions(),[,r]=useSelectedBlockIds(),[,a]=useSelectedStylingBlocks(),i=React.useCallback(()=>{n([]),r([]),a([])},[n]);return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{size:"sm",variant:"ghost",className:"flex items-center gap-x-1",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.EraserIcon,{})," ",o("Clear")]})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{className:"border-border",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTitle,{className:"text-foreground",children:o("Clear Canvas")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogDescription,{children:o("Are you sure you want to clear the page?")})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogFooter,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogCancel,{className:"text-foreground",children:o("Cancel")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogAction,{onClick:i,children:o("Yes")})]})]})]})})},CanvasTopBar=()=>{const o=useBuilderProp("darkMode",!0),[n]=useCanvasZoom();return jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-10 items-center justify-between border-b border-border bg-background/70 px-2",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full space-x-2",children:[jsxRuntime.jsxRuntimeExports.jsx(Breakpoints,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Separator,{orientation:"vertical"}),o?jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsx(DarkMode,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Separator,{orientation:"vertical"})]}):null,jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex w-12 cursor-not-allowed items-center justify-center gap-x-1 space-x-0 font-medium text-gray-400",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"text-xs leading-3",children:[lodashEs.round(n,0),"%"]})]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Separator,{orientation:"vertical"}),jsxRuntime.jsxRuntimeExports.jsx(UndoRedo,{})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex h-full items-center space-x-2",children:jsxRuntime.jsxRuntimeExports.jsx(ClearCanvas,{})})]})};function BlockAttributesToggle(){const{t:o}=reactI18next.useTranslation(),[n,r]=React.useState(!0),[a]=useSelectedStylingBlocks();return lodashEs.isEmpty(a)?null:jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment,{children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{onClick:()=>r(!n),className:"flex cursor-pointer items-center justify-between border-b border-border py-2 text-sm font-bold text-muted-foreground hover:underline",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{children:o("Attributes")}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 text-gray-500 "+(n?"rotate-180":"")})})]}),n&&jsxRuntime.jsxRuntimeExports.jsx(BlockAttributesEditor,{})]})}const SettingsPanel=()=>{const o=useSelectedBlock(),{t:n}=reactI18next.useTranslation(),r=useBuilderProp("onError",lodashEs.noop);return lodashEs.isNull(o)?jsxRuntime.jsxRuntimeExports.jsx("div",{className:"p-4 text-center",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.MixerHorizontalIcon,{className:"mx-auto text-3xl"}),jsxRuntime.jsxRuntimeExports.jsx("h1",{children:n("please_select_a_block_to_edit")})]})}):jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:r,children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"relative flex max-h-full w-full flex-col",children:[jsxRuntime.jsxRuntimeExports.jsx(BlockSettings,{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx(BlockStyling,{}),jsxRuntime.jsxRuntimeExports.jsx(BlockAttributesToggle,{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("br",{})]})})},SettingsPanel$1=SettingsPanel;function LayoutCard({disabled:o=!1,description:n,title:r,selected:a,onSelect:i,children:l}){const{t:c}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Card,{"aria-disabled":o,className:`cursor-pointer border-border transition-all ${a?"ring-2 ring-secondary":""} ${o?"cursor-not-allowed opacity-50":""}`,onClick:i,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.CardContent,{className:"p-4",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxRuntimeExports.jsx("h3",{className:"text-lg font-semibold",children:r}),a&&jsxRuntime.jsxRuntimeExports.jsx(reactIcons.CheckIcon,{className:"h-6 w-6 rounded-full bg-background p-px text-foreground"})]}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:n}),l,jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{disabled:o,className:"mt-4 w-full",variant:a?"default":"outline",children:c(o?"Coming soon":a?"Selected":"Select")})]})})}const ChooseLayout=({open:o,close:n})=>{const{t:r}=reactI18next.useTranslation(),[a,i]=useLayoutVariant(),l=c=>{i(c),n()};return jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialog,{open:o,onOpenChange:()=>o?n():"",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{className:"max-w-4xl overflow-hidden border-border",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{className:"flex flex-row items-center justify-between",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTitle,{className:"text-foreground",children:r("Choose Builder Layout")}),jsxRuntime.jsxRuntimeExports.jsx("button",{onClick:()=>n(),className:"text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.Cross2Icon,{className:"h-6 w-6"})})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar max-h-full overflow-hidden",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[jsxRuntime.jsxRuntimeExports.jsx(LayoutCard,{title:r("Single side panel"),description:r("Suitable for smaller screens. Bigger canvas size."),selected:a==="SINGLE_SIDE_PANEL",onSelect:()=>l("SINGLE_SIDE_PANEL"),children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col rounded border border-border",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"borde-b h-4 border-b border-border"}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-32",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-3/4 border-l border-border bg-background"})]})]})}),jsxRuntime.jsxRuntimeExports.jsx(LayoutCard,{title:r("Dual side panel"),description:r("Suitable for larger screens. Blocks settings is always visible."),selected:a==="DUAL_SIDE_PANEL",onSelect:()=>l("DUAL_SIDE_PANEL"),children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col rounded border border-border",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"borde-b h-4 border-b border-border"}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-32",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-2/4 border-x border-border bg-background"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"})]})]})}),jsxRuntime.jsxRuntimeExports.jsx(LayoutCard,{disabled:!0,title:r("Dual side panel advanced"),description:r("Suitable for heavy styling & block editing. Setting are always visible."),selected:!1,onSelect:()=>{},children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col rounded border border-border",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"borde-b h-4 border-b border-border"}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-32",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-2/4 border-x border-border bg-background"}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"w-1/4 bg-secondary"})]})]})})]})})]})})},HotKeys=()=>{const{t:o}=reactI18next.useTranslation(),n={"ctrl + Z":"Undo","ctrl + Y":"Redo","ctrl + D":"Duplicate"},r={"ctrl + S":"Save page",esc:"Deselect blocks",del:"Delete block"};return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Dialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTrigger,{children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{className:"mb-2 rounded-lg p-2 transition-colors",variant:"ghost",children:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.KeyboardIcon,{className:"size-4"})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{side:"right",children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:o("Keyboard shortcuts")})})]})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogContent,{className:"border-border sm:max-w-[525px]",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogHeader,{children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogTitle,{className:"text-foreground",children:o("Keyboard shortcuts")})}),jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mr-8 flex flex-col space-y-2 border-r border-border",children:Object.keys(n).map(a=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-4",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Badge,{variant:"outline",className:"border border-border p-1 px-2",children:o(a)}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-muted-foreground",children:o(n[a])})]},a))}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col space-y-2",children:Object.keys(r).map(a=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-4",children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Badge,{variant:"outline",className:"border border-border p-1 px-2",children:o(a)}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"text-muted-foreground",children:o(r[a])})]},a))})]})})]})]})},ViewProviderData=({provider:o,onClose:n})=>{const{t:r}=reactI18next.useTranslation(),[a,i]=React.useState(null),l=useBuilderProp("onError",lodashEs.noop);return React.useEffect(()=>{o&&(o.mockFn?o.mockFn:o.dataFn)().then(d=>i(d))},[o]),o?jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Dialog,{onOpenChange:c=>c?"":n(),defaultOpen:!0,children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogContent,{className:"border-border",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.DialogTitle,{className:"text-foreground",children:[r("data_provider"),": ",o.name]}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.DialogDescription,{children:o.description})]}),jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:l,children:jsxRuntime.jsxRuntimeExports.jsx(JsonView,{data:a,shouldExpandNode:allExpanded,style:{...defaultStyles,container:"max-h-[80vh] overflow-y-auto text-[12px] leading-[1.5] tracking-wide font-mono",stringValue:"text-orange-600",label:"text-green-900 font-semibold pr-1 tracking-wider"}})})]})}):null};function RemoveProviderConfirmation({children:o,name:n,onRemove:r}){const{t:a}=reactI18next.useTranslation();return jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialog,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTrigger,{asChild:!0,children:o}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogContent,{children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogHeader,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogTitle,{dangerouslySetInnerHTML:{__html:a("remove_provider_confirmation").replace("{name}",n)}}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogDescription,{children:a("remove_provider_warning")})]}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.AlertDialogFooter,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogCancel,{children:a("cancel")}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.AlertDialogAction,{onClick:r,className:"bg-red-600 hover:bg-red-700",children:a("remove")})]})]})]})}const PageDataProviders=()=>{const{t:o}=reactI18next.useTranslation(),n=React.useMemo(()=>runtime.getChaiDataProviders(),[]),[r,a]=usePageDataProviders(),[,i]=jotai.useAtom(builderSaveStateAtom),[l,c]=React.useState(lodashEs.filter(n,j=>lodashEs.map(r,"providerKey").includes(j.providerKey))),[d,u]=React.useState(""),[x,m]=React.useState(null),h=lodashEs.filter(n.map(j=>lodashEs.map(l,"providerKey").includes(j.providerKey)?null:{value:j.providerKey,label:j.name}),j=>!lodashEs.isNull(j)),p=j=>{const E=lodashEs.find(n,{providerKey:j});c(y=>[...y,E]),a(y=>[...y,{providerKey:E.providerKey,args:{}}]),u(""),i("UNSAVED")},f=j=>{c(E=>lodashEs.filter(E,y=>y.providerKey!==j.providerKey)),a(E=>lodashEs.filter(E,y=>y.providerKey!==j.providerKey)),i("UNSAVED")},R=j=>m(j);return lodashEs.isEmpty(n)?jsxRuntime.jsxRuntimeExports.jsx("div",{children:jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"mb-1.5 p-4 text-xs text-gray-500",children:[o("no_data_providers"),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("a",{className:"text-blue-500",href:"https://chaibuilder.com/docs/registering-data-providers",target:"_blank",children:o("learn_more")})]})}):jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"px-1",children:[jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("label",{children:jsxRuntime.jsxRuntimeExports.jsx("p",{className:"mb-1.5 text-xs text-gray-500",children:o("add_data_providers")})}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center space-x-1",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Select,{value:d,onValueChange:j=>p(j),children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.SelectTrigger,{className:"w-full",children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.SelectValue,{placeholder:o("select_provider")})}),jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.SelectContent,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.SelectItem,{value:"",children:o("choose")}),h.map(j=>jsxRuntime.jsxRuntimeExports.jsx(contextMenu.SelectItem,{value:j.value,children:j.label},j.value))]})]})}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:`border-t border-border ${l.length?"block":"hidden"}`,children:[jsxRuntime.jsxRuntimeExports.jsxs("p",{className:"flex-1 pb-1.5 pt-4 text-xs font-medium text-gray-500",children:[o("page_data_providers"),":"]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:l.map(j=>jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"w-full rounded-lg border border-border bg-card text-card-foreground shadow-sm","data-v0-t":"card",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col space-y-1.5 px-4 pt-4",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{children:[jsxRuntime.jsxRuntimeExports.jsx("h3",{className:"font-medium leading-4",children:j.name}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"pt-1 text-xs text-gray-400",children:j.description})]})})}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between p-2 py-2",children:[jsxRuntime.jsxRuntimeExports.jsxs("button",{onClick:()=>R(j),className:"inline-flex h-9 items-center justify-center rounded-md px-3 text-xs font-medium text-blue-500 underline-offset-4 ring-offset-background transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",children:[jsxRuntime.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"mr-2 h-4 w-4",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),jsxRuntime.jsxRuntimeExports.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),o("view_data")]}),jsxRuntime.jsxRuntimeExports.jsx(RemoveProviderConfirmation,{onRemove:()=>f(j),name:j.name,children:jsxRuntime.jsxRuntimeExports.jsxs("button",{className:"inline-flex h-9 items-center justify-center rounded-md px-3 text-xs font-medium text-red-500 underline-offset-4 ring-offset-background transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",children:[jsxRuntime.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"mr-2 h-4 w-4",children:[jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M3 6h18"}),jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),jsxRuntime.jsxRuntimeExports.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),o("remove")]})})]})]},j.providerKey))}),jsxRuntime.jsxRuntimeExports.jsx(ViewProviderData,{onClose:()=>m(null),provider:x})]})]})};function AiFillDatabase(o){return iconBase.GenIcon({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M832 64H192c-17.7 0-32 14.3-32 32v224h704V96c0-17.7-14.3-32-32-32zM288 232c-22.1 0-40-17.9-40-40s17.9-40 40-40 40 17.9 40 40-17.9 40-40 40zM160 928c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V704H160v224zm128-136c22.1 0 40 17.9 40 40s-17.9 40-40 40-40-17.9-40-40 17.9-40 40-40zM160 640h704V384H160v256zm128-168c22.1 0 40 17.9 40 40s-17.9 40-40 40-40-17.9-40-40 17.9-40 40-40z"},child:[]}]})(o)}const TopBar=React.lazy(()=>Promise.resolve().then(()=>require("./Topbar-sxJsvNJQ.cjs")));function useSidebarMenuItems(o){const n=o==="SINGLE_SIDE_PANEL",{t:r}=reactI18next.useTranslation(),a=useBuilderProp("dataBindingSupport",!1),i=useBuilderProp("askAiCallBack",null);return React.useMemo(()=>{const l=[{icon:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.Layers,{size:20}),label:"sidebar.outline",component:()=>jsxRuntime.jsxRuntimeExports.jsx("div",{className:"-mt-8",children:jsxRuntime.jsxRuntimeExports.jsx(Outline$1,{})})},n?{icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.GearIcon,{className:"size-5"}),label:"sidebar.edit_block",component:SettingsPanel$1}:null,a?{icon:jsxRuntime.jsxRuntimeExports.jsx(AiFillDatabase,{className:"size-3"}),label:r("Data Providers"),component:PageDataProviders}:null,i?{icon:jsxRuntime.jsxRuntimeExports.jsx(reactIcons.LightningBoltIcon,{className:"size-5"}),label:"sidebar.ai_assistant",component:AskAI}:null,{icon:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.PaintBucketIcon,{size:20}),label:"sidebar.theme",component:()=>jsxRuntime.jsxRuntimeExports.jsx(ThemeOptions,{showHeading:!1})}];return lodashEs.compact(l)},[n,a,r,i])}function isDualLayout(o){return o!=="SINGLE_SIDE_PANEL"}const RootLayout=()=>{const[o,n]=React.useState(0),[r]=useLayoutVariant(),[a,i]=React.useState(!1);useChaiBuilderMsgListener(({name:p})=>{p===CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS&&n(1)});const l=useBuilderProp("sideBarComponents.top",[]),c=p=>{p.preventDefault()},d=p=>{n(o===p?null:p)},u=useSidebarMenuItems(r),{t:x}=reactI18next.useTranslation(),m=[...u,...l],h=useBuilderProp("htmlDir","ltr");return jsxRuntime.jsxRuntimeExports.jsx("div",{dir:h,className:"h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground",children:jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.TooltipProvider,{children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{onContextMenu:c,className:"flex h-screen max-h-full flex-col bg-background text-foreground",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-14 w-screen shrink-0 border-b border-border",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{children:jsxRuntime.jsxRuntimeExports.jsx(TopBar,{})})}),jsxRuntime.jsxRuntimeExports.jsxs("main",{className:"relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row",children:[jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex w-12 flex-col items-center justify-between border-r border-border py-2",children:[jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex flex-col",children:m.map((p,f)=>jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:o===f?"default":"ghost",className:"mb-2 rounded-lg p-2 transition-colors",onClick:()=>d(f),children:lodashEs.get(p,"icon",null)},f)}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{side:"right",children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:x(p.label)})})]},"button"+f))}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col space-y-1",children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Tooltip,{children:[jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Button,{variant:"ghost",onClick:()=>i(!0),children:jsxRuntime.jsxRuntimeExports.jsx(lucideReact.LayoutTemplate,{size:20})})}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.TooltipContent,{side:"right",children:jsxRuntime.jsxRuntimeExports.jsx("p",{children:x("Choose Builder Layout")})})]}),jsxRuntime.jsxRuntimeExports.jsx(HotKeys,{})]})]}),jsxRuntime.jsxRuntimeExports.jsx(framerMotion.motion.div,{className:"h-full max-h-full border-r border-border",initial:{width:280},animate:{width:o!==null?280:0},transition:{duration:.3,ease:"easeInOut"},children:o!==null&&jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar overflow h-full overflow-x-hidden",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex flex-col p-3",children:[jsxRuntime.jsxRuntimeExports.jsxs("h2",{className:"-mt-1 flex h-10 items-center space-x-1 text-base font-bold",children:[jsxRuntime.jsxRuntimeExports.jsx("span",{className:"rtl:ml-2 rtl:inline-block",children:lodashEs.get(m,`${o}.icon`,null)}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:x(m[o].label)})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex-1",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx("div",{children:"Loading..."}),children:React.createElement(lodashEs.get(m,`${o}.component`,null),{})})})]})})}),jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex h-full max-h-full flex-1 flex-col bg-slate-800/20",children:[jsxRuntime.jsxRuntimeExports.jsx(CanvasTopBar,{}),jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{children:jsxRuntime.jsxRuntimeExports.jsx(CanvasArea$1,{})})]}),isDualLayout(r)?jsxRuntime.jsxRuntimeExports.jsx(framerMotion.motion.div,{className:"h-full max-h-full border-l border-border",initial:{width:280},animate:{width:280},transition:{duration:.3,ease:"easeInOut"},children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"no-scrollbar overflow h-full max-h-full overflow-x-hidden",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"flex max-h-full flex-col p-3",children:[jsxRuntime.jsxRuntimeExports.jsxs("h2",{className:"-mt-1 flex h-10 items-center space-x-1 text-base font-bold",children:[jsxRuntime.jsxRuntimeExports.jsx(lucideReact.EditIcon,{size:"16",className:"rtl:ml-2"}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:x("Block Settings")})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{className:"flex-1",children:jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx("div",{children:"Loading..."}),children:jsxRuntime.jsxRuntimeExports.jsx(SettingsPanel$1,{})})})]})})}):null]})]}),jsxRuntime.jsxRuntimeExports.jsx(AddBlocksDialog,{}),jsxRuntime.jsxRuntimeExports.jsx(ChooseLayout,{open:a,close:()=>i(!1)})]})})},builderStore=jotai.getDefaultStore(),SmallScreenMessage=()=>jsxRuntime.jsxRuntimeExports.jsx("section",{className:"h-screen w-screen bg-gray-900 py-12 sm:py-16 lg:py-20 xl:hidden",children:jsxRuntime.jsxRuntimeExports.jsx("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:jsxRuntime.jsxRuntimeExports.jsxs("div",{className:"mx-auto max-w-md text-center",children:[jsxRuntime.jsxRuntimeExports.jsx("img",{src:"https://fldwljgzcktqnysdkxnn.supabase.co/storage/v1/object/public/chaibuilder-blob-storage/175ac8d8-37fe-4707-bb4a-3c0cd6a6db75/gVH7O-Ir_400x400.png",alt:"Chai Builder",className:"mx-auto w-14 rounded-full"}),jsxRuntime.jsxRuntimeExports.jsx("br",{}),jsxRuntime.jsxRuntimeExports.jsx("h2",{className:"text-4xl font-bold text-white",children:"Screen too small"}),jsxRuntime.jsxRuntimeExports.jsx("p",{className:"mt-6 text-sm font-medium leading-6 text-white text-opacity-70",children:"Please view this page on greater than 1280px screen width."})]})})}),setDebugLogs=o=>{},PreviewScreen=()=>{const[o,n]=usePreviewMode(),{t:r}=reactI18next.useTranslation(),a=useBuilderProp("previewComponent",null);return o?jsxRuntime.jsxRuntimeExports.jsxs("div",{className:iconBase.cn("fixed inset-0 z-[999] bg-background",o?"block":"hidden"),children:[jsxRuntime.jsxRuntimeExports.jsxs(contextMenu.Button,{size:"sm",className:"absolute right-0 top-0 m-4 space-x-2",onClick:()=>n(!1),children:[jsxRuntime.jsxRuntimeExports.jsx(reactIcons.EyeClosedIcon,{}),jsxRuntime.jsxRuntimeExports.jsx("span",{children:r("close_preview")})]}),jsxRuntime.jsxRuntimeExports.jsx("div",{children:a?jsxRuntime.jsxRuntimeExports.jsx(React.Suspense,{fallback:jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Skeleton,{className:"h-96 w-full"}),children:React.createElement(a)}):null})]}):null},getParentNodeIds=(o,n)=>{const r=[];let a=lodashEs.find(o,{_id:n}),i=lodashEs.get(a,"_parent","");for(;lodashEs.isString(i)&&!lodashEs.isEmpty(i);)r.push(a==null?void 0:a._parent),a=lodashEs.find(o,{_id:i}),i=a==null?void 0:a._parent;return lodashEs.flatten(r)},expandedIdsAtom=jotai.atom([]),useExpandTree=()=>{const[o]=useSelectedBlockIds(),n=jotai.useAtomValue(presentBlocksAtom),[,r]=jotai.useAtom(expandedIdsAtom);React.useEffect(()=>{let a=[];const i=lodashEs.first(o);lodashEs.isString(i)&&(a=[i,...getParentNodeIds(n,i)]),r(a)},[o,n,r])},useAutoSave=()=>{const{savePage:o}=useSavePage(),n=useBuilderProp("autoSaveSupport",!0),r=useBuilderProp("autoSaveInterval",60);web.useIntervalEffect(()=>{n&&o()},r*1e3)},ChaiBuilderComponent=o=>{const[,n]=useBlocksStore(),[,r]=useBrandingOptions(),a=useBuilderReset(),[i]=useAtom(builderSaveStateAtom),l=React.useMemo(()=>o.layout||RootLayout,[o.layout]);return useAtom(selectedLibraryAtom),useKeyEventWatcher(),useExpandTree(),useAutoSave(),useWatchGlobalBlocks(),useWatchRSCBlocks(),React.useEffect(()=>{builderStore.set(chaiBuilderPropsAtom,lodashEs.omit(o,["blocks","subPages","brandingOptions","dataProviders","customRootLayout","translations"]))},[o]),React.useEffect(()=>{builderStore.set(dataProvidersAtom,o.dataProviders||[])},[o.dataProviders]),React.useEffect(()=>{n(o.blocks||[]),a()},[o.blocks]),React.useEffect(()=>{i18n.changeLanguage(o.locale||"en")},[o.locale]),React.useEffect(()=>{setDebugLogs(o.showDebugLogs)},[o.showDebugLogs]),React.useEffect(()=>{o.translations&&lodashEs.each(o.translations,(c,d)=>{i18n.addResourceBundle(d,"translation",c,!0,!0)})},[o.translations]),React.useEffect(()=>{r(o.brandingOptions)},[o.brandingOptions,r]),React.useEffect(()=>(i!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[i]),jsxRuntime.jsxRuntimeExports.jsx(l,{})},ChaiBuilderEditor=o=>{const n=o._flags||{},r=o.onError||lodashEs.noop;return jsxRuntime.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen",children:jsxRuntime.jsxRuntimeExports.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsxRuntimeExports.jsx(FallbackError,{}),onError:r,children:jsxRuntime.jsxRuntimeExports.jsxs(flagged.FlagsProvider,{features:{...FEATURE_TOGGLES,...n},children:[jsxRuntime.jsxRuntimeExports.jsx(SmallScreenMessage,{}),jsxRuntime.jsxRuntimeExports.jsx(ChaiBuilderComponent,{...o}),jsxRuntime.jsxRuntimeExports.jsx(PreviewScreen,{}),jsxRuntime.jsxRuntimeExports.jsx(contextMenu.Toaster,{})]})})})};exports.AISetContext=AISetContext;exports.AIUserPrompt=AIUserPrompt;exports.AddBlocksDialog=AddBlocksDialog;exports.AddBlocksPanel=AddBlocksPanel$1;exports.BlockAttributesEditor=BlockAttributesEditor;exports.BlockSettings=BlockSettings;exports.BlockStyling=BlockStyling;exports.Breakpoints=Breakpoints;exports.CHAI_BUILDER_EVENTS=CHAI_BUILDER_EVENTS;exports.CanvasArea=CanvasArea$1;exports.ChaiBuilderEditor=ChaiBuilderEditor;exports.ChaiSelect=ChaiSelect$1;exports.DarkMode=DarkMode;exports.DefaultChaiBlocks=DefaultChaiBlocks;exports.FaCheck=FaCheck;exports.FaLanguage=FaLanguage;exports.FaStar=FaStar;exports.ImportHTML=ImportHTML$1;exports.LANGUAGES=LANGUAGES;exports.Outline=Outline$1;exports.ThemeOptions=ThemeOptions;exports.UILibraries=UILibraries;exports.UndoRedo=UndoRedo;exports.emitChaiBuilderMsg=emitChaiBuilderMsg;exports.getBlocksFromHTML=getBlocksFromHTML;exports.getClassValueAndUnit=getClassValueAndUnit;exports.useAddBlock=useAddBlock;exports.useAddClassesToBlocks=useAddClassesToBlocks;exports.useBlockHighlight=useBlockHighlight;exports.useBlocksStore=useBlocksStore;exports.useBlocksStoreUndoableActions=useBlocksStoreUndoableActions;exports.useBrandingOptions=useBrandingOptions;exports.useBuilderProp=useBuilderProp;exports.useBuilderReset=useBuilderReset;exports.useCanvasWidth=useCanvasWidth;exports.useCanvasZoom=useCanvasZoom;exports.useChaiBuilderMsgListener=useChaiBuilderMsgListener;exports.useCodeEditor=useCodeEditor;exports.useCopyBlockIds=useCopyBlockIds;exports.useCopyToClipboard=useCopyToClipboard;exports.useCurrentPage=useCurrentPage;exports.useCutBlockIds=useCutBlockIds;exports.useDarkMode=useDarkMode;exports.useDuplicateBlocks=useDuplicateBlocks;exports.useGlobalBlocksList=useGlobalBlocksList;exports.useGlobalBlocksStore=useGlobalBlocksStore;exports.useHiddenBlockIds=useHiddenBlockIds;exports.useHighlightBlockId=useHighlightBlockId;exports.useLanguages=useLanguages;exports.useLayoutVariant=useLayoutVariant;exports.usePasteBlocks=usePasteBlocks;exports.usePreviewMode=usePreviewMode;exports.useRemoveBlocks=useRemoveBlocks;exports.useRemoveClassesFromBlocks=useRemoveClassesFromBlocks;exports.useSavePage=useSavePage;exports.useSelectedBlock=useSelectedBlock;exports.useSelectedBlockAllClasses=useSelectedBlockAllClasses;exports.useSelectedBlockCurrentClasses=useSelectedBlockCurrentClasses;exports.useSelectedBlockIds=useSelectedBlockIds;exports.useSelectedBlocksDisplayChild=useSelectedBlocksDisplayChild;exports.useSelectedBreakpoints=useSelectedBreakpoints;exports.useSelectedStylingBlocks=useSelectedStylingBlocks;exports.useStylingBreakpoint=useStylingBreakpoint;exports.useStylingState=useStylingState;exports.useUILibraryBlocks=useUILibraryBlocks;exports.useUndoManager=useUndoManager;exports.useUpdateBlocksProps=useUpdateBlocksProps;exports.useUpdateBlocksPropsRealtime=useUpdateBlocksPropsRealtime;