@chaibuilder/sdk 1.2.46 → 1.2.48

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.
Files changed (71) hide show
  1. package/README.md +1 -1
  2. package/dist/{AddBlocks-Jse1nYBd.cjs → AddBlocks-_fhhS7Lm.cjs} +1 -1
  3. package/dist/{AddBlocks-wY7YpsXy.js → AddBlocks-cX8vIt0V.js} +7 -7
  4. package/dist/{CanvasArea-2widR9Ry.js → CanvasArea-HRipTJFS.js} +271 -263
  5. package/dist/CanvasArea-N3rYeBJV.cjs +55 -0
  6. package/dist/{ChaiBuilderEditor-74s7jELl.cjs → ChaiBuilderEditor-EtQOC5uy.cjs} +1 -1
  7. package/dist/{ChaiBuilderEditor-wriVkIG1.js → ChaiBuilderEditor-dKHRL-Es.js} +20 -20
  8. package/dist/{CurrentPage-UozVUoj8.cjs → CurrentPage-9FijxWbn.cjs} +1 -1
  9. package/dist/{CurrentPage--JhcSlGs.js → CurrentPage-U8ms8Hs7.js} +2 -2
  10. package/dist/{ListTree-qTfVR-jh.js → ListTree-OgLdyfQs.js} +1 -1
  11. package/dist/{ListTree-aFX8fD7v.cjs → ListTree-jOvHpo3_.cjs} +1 -1
  12. package/dist/{PagesPanel-1ZzPulaC.cjs → PagesPanel-8Cd6UYsh.cjs} +1 -1
  13. package/dist/{PagesPanel-qatBt4Nf.js → PagesPanel-MsUBq9Xx.js} +3 -3
  14. package/dist/{ProjectPanel-QUIcKWwM.cjs → ProjectPanel-KmnXPfxx.cjs} +1 -1
  15. package/dist/{ProjectPanel-Vp-EZS_Y.js → ProjectPanel-hsZG_Btj.js} +3 -3
  16. package/dist/{Settings-E_xif3_e.js → Settings-WcLqIeQy.js} +7 -7
  17. package/dist/{Settings-jKpJi5Wy.cjs → Settings-xVjTnVSf.cjs} +1 -1
  18. package/dist/{SidePanels-s_Yl7HhG.cjs → SidePanels-6zRgfZpi.cjs} +1 -1
  19. package/dist/{SidePanels-UEa90HOL.js → SidePanels-PmCljlnf.js} +2 -2
  20. package/dist/{ThemeConfiguration-IUuxGaDf.js → ThemeConfiguration-mkbFdePB.js} +17 -17
  21. package/dist/{ThemeConfiguration-YkPc6RGq.cjs → ThemeConfiguration-pt7TTAty.cjs} +1 -1
  22. package/dist/{Topbar-YzdQKElx.cjs → Topbar--m1E08Jl.cjs} +1 -1
  23. package/dist/{Topbar-C7Qfcatg.js → Topbar-FPywhpub.js} +1 -1
  24. package/dist/{UILibrariesPanel-qv8AiOn1.cjs → UILibrariesPanel-HhHGcexY.cjs} +1 -1
  25. package/dist/{UILibrariesPanel-didKK7tC.js → UILibrariesPanel-VrA2X4LO.js} +1 -1
  26. package/dist/{UnsplashImages-VkZ_KszK.js → UnsplashImages-7uAXYHPH.js} +1 -1
  27. package/dist/{UnsplashImages-QeZ65lKC.cjs → UnsplashImages-Yu0msAD8.cjs} +1 -1
  28. package/dist/{UploadImages-6drauLA-.js → UploadImages-5M0Q27R-.js} +1 -1
  29. package/dist/{UploadImages-igQroUtu.cjs → UploadImages-jS51ZcPG.cjs} +1 -1
  30. package/dist/{add-page-modal-rJ7OwdoX.js → add-page-modal-6o7MAbq-.js} +3 -3
  31. package/dist/{add-page-modal-esHlLYay.cjs → add-page-modal-KAbflupJ.cjs} +1 -1
  32. package/dist/{confirm-alert-08q_BmL6.cjs → confirm-alert-dow0GlxC.cjs} +1 -1
  33. package/dist/{confirm-alert-HfChUtfw.js → confirm-alert-jL0z_gFv.js} +1 -1
  34. package/dist/core.cjs +1 -1
  35. package/dist/core.js +1 -1
  36. package/dist/{delete-page-modal-SOCB_9UB.cjs → delete-page-modal-EDQZneVM.cjs} +1 -1
  37. package/dist/{delete-page-modal-E3tO5Q1p.js → delete-page-modal-U5_JYYp7.js} +2 -2
  38. package/dist/email.cjs +1 -1
  39. package/dist/email.js +1 -1
  40. package/dist/{form-gRWwpKzq.cjs → form-KBtrnNWh.cjs} +1 -1
  41. package/dist/{form-hi_RCepy.js → form-Sgpl2fXL.js} +1 -1
  42. package/dist/functions-7ybAMUuA.js +31 -0
  43. package/dist/functions-yvRwasT2.cjs +1 -0
  44. package/dist/{index-3j3SZ9Pb.cjs → index-HjN7LtDT.cjs} +1 -1
  45. package/dist/{index-OnzJQ25d.js → index-po-naEa5.js} +2 -2
  46. package/dist/lib.cjs +2 -3
  47. package/dist/lib.d.ts +11 -11
  48. package/dist/lib.js +175 -100
  49. package/dist/{page-viewer-S3xZLu53.cjs → page-viewer-PfZEbcDZ.cjs} +1 -1
  50. package/dist/{page-viewer-K_8dfU3A.js → page-viewer-nLRRk7DR.js} +3 -3
  51. package/dist/{project-general-setting-vSkiqVk-.js → project-general-setting-D1UJdZ2D.js} +3 -3
  52. package/dist/{project-general-setting-IRQ9TNAd.cjs → project-general-setting-HO6zeum2.cjs} +1 -1
  53. package/dist/{project-seo-setting-b9jZC0dr.js → project-seo-setting-VIZWEMRk.js} +2 -2
  54. package/dist/{project-seo-setting-XHFqgtW9.cjs → project-seo-setting-gT9N1tnB.cjs} +1 -1
  55. package/dist/render.cjs +1 -1
  56. package/dist/render.d.ts +2 -1
  57. package/dist/render.js +82 -80
  58. package/dist/{single-page-detail-RG82dk4d.cjs → single-page-detail-To8TcpgJ.cjs} +1 -1
  59. package/dist/{single-page-detail-zHbO3vOI.js → single-page-detail-lQ8fujC5.js} +4 -4
  60. package/dist/studio.cjs +1 -1
  61. package/dist/studio.js +2 -2
  62. package/dist/ui.cjs +1 -1
  63. package/dist/ui.js +1 -1
  64. package/dist/{useCanvasSettings-2Wzyf2PK.cjs → useCanvasSettings-7BXlDuLG.cjs} +1 -1
  65. package/dist/{useCanvasSettings-L2pW5boY.js → useCanvasSettings-UzjYHFG5.js} +1 -1
  66. package/dist/web-blocks.cjs +1 -1
  67. package/dist/web-blocks.js +1 -1
  68. package/package.json +1 -1
  69. package/dist/CanvasArea-pQP-jR11.cjs +0 -57
  70. package/dist/functions-ge87TVcc.js +0 -30
  71. package/dist/functions-sBiIevFh.cjs +0 -1
@@ -0,0 +1,55 @@
1
+ "use strict";var ne=Object.defineProperty;var oe=(o,s,e)=>s in o?ne(o,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[s]=e;var I=(o,s,e)=>(oe(o,typeof s!="symbol"?s+"":s,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./jsx-runtime-Z_BpKhVy.cjs"),h=require("react"),c=require("lodash-es"),E=require("@radix-ui/react-icons"),i=require("./ChaiBuilderEditor-EtQOC5uy.cjs"),U=require("react-i18next"),b=require("jotai"),re=require("lucide-react"),Y=require("react-dom"),R=require("prop-types"),ie=require("react-quill"),T=require("./atoms-a0H_593V.cjs"),le=require("@floating-ui/dom"),G=require("@floating-ui/react-dom"),ce=require("@react-hookz/web"),ae=require("flagged"),de=require("@tailwindcss/typography"),ue=require("@tailwindcss/forms"),pe=require("@tailwindcss/aspect-ratio"),he=require("tailwindcss-palette-generator"),xe=require("tailwind-merge"),M=require("./STRINGS-gPz7CUOk.cjs"),me=require("@chaibuilder/runtime"),ge=require("./useCanvasSettings-7BXlDuLG.cjs"),fe=require("react-wrap-balancer");require("./_commonjsHelpers-wDK0ZLPo.cjs");require("clsx");require("@radix-ui/react-scroll-area");require("i18next");require("./Functions-N3yhPYKY.cjs");require("./MODIFIERS-YPHRtwrM.cjs");require("tree-model");require("./utils-K3Zk762G.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");require("@radix-ui/react-switch");require("@radix-ui/react-slot");require("@radix-ui/react-accordion");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-menubar");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-context-menu");require("react-icons-picker");require("react-hotkeys-hook");const ve=()=>{const{hasUndo:o,hasRedo:s,undo:e,redo:t}=i.useUndoManager();return r.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[r.jsxRuntimeExports.jsx(i.Button,{disabled:!o(),size:"sm",onClick:e,className:"rounded-full",variant:"ghost",children:r.jsxRuntimeExports.jsx(E.ResetIcon,{})}),r.jsxRuntimeExports.jsx(i.Button,{disabled:!s(),onClick:t,size:"sm",className:"rounded-full",variant:"ghost",children:r.jsxRuntimeExports.jsx(E.ResetIcon,{className:"rotate-180 scale-y-[-1] transform"})})]})};function je(){const[o,s]=i.useDarkMode();return r.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[r.jsxRuntimeExports.jsx(E.SunIcon,{className:"size-4 shrink-0"}),r.jsxRuntimeExports.jsx(i.Switch,{id:"dark-mode-switch",checked:o,onCheckedChange:()=>{s(!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:r.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`})}),r.jsxRuntimeExports.jsx(E.MoonIcon,{className:"size-4 ml-3 shrink-0"})]})}const X=({landscape:o=!1})=>r.jsxRuntimeExports.jsxs("svg",{className:o?"rotate-90":"",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 13 13",xmlSpace:"preserve",width:13,height:13,children:[r.jsxRuntimeExports.jsx("g",{strokeWidth:0}),r.jsxRuntimeExports.jsx("g",{strokeLinecap:"round",strokeLinejoin:"round"}),r.jsxRuntimeExports.jsx("path",{d:"M10.65 0H2.349a.851.851 0 0 0-.851.852v11.299c0 .47.382.852.851.852h8.3a.851.851 0 0 0 .851-.852V.852A.851.851 0 0 0 10.65 0zM6.599 12.466a.367.367 0 1 1 0-.735.367.367 0 0 1 0 .735zm3.9-1.267H2.5V1h8.001v10.199z",style:{fill:"#000"}})]}),$e=[{title:"mobile_xs_title",content:"mobile_xs_content",breakpoint:"xs",icon:r.jsxRuntimeExports.jsx(E.MobileIcon,{}),width:400},{title:"mobile_sm_title",content:"mobile_sm_content",breakpoint:"sm",icon:r.jsxRuntimeExports.jsx(E.MobileIcon,{className:"rotate-90"}),width:640},{title:"tablet_md_title",content:"tablet_md_content",breakpoint:"md",icon:r.jsxRuntimeExports.jsx(X,{}),width:800},{title:"tablet_lg_title",content:"tablet_lg_content",breakpoint:"lg",icon:r.jsxRuntimeExports.jsx(X,{landscape:!0}),width:1024},{title:"desktop_xl_title",content:"desktop_xl_content",breakpoint:"xl",icon:r.jsxRuntimeExports.jsx(E.LaptopIcon,{}),width:1420},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",breakpoint:"2xl",icon:r.jsxRuntimeExports.jsx(E.DesktopIcon,{}),width:1920}],Z=({title:o,content:s,currentBreakpoint:e,breakpoint:t,width:n,icon:u,onClick:a})=>{const{t:l}=U.useTranslation();return r.jsxRuntimeExports.jsxs(i.HoverCard,{children:[r.jsxRuntimeExports.jsx(i.HoverCardTrigger,{asChild:!0,children:r.jsxRuntimeExports.jsx(i.Button,{onClick:()=>a(n),size:"sm",variant:t===e?"secondary":"ghost",children:u})}),r.jsxRuntimeExports.jsx(i.HoverCardContent,{className:"w-52 border-border",children:r.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:r.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[r.jsxRuntimeExports.jsx("h4",{className:"text-sm font-semibold",children:l(o)}),r.jsxRuntimeExports.jsx("p",{className:"text-xs",children:l(s)})]})})})]})},ye=()=>{const[,o,s]=i.useCanvasWidth(),[e,t]=i.useSelectedBreakpoints(),{t:n}=U.useTranslation(),u=i.useBuilderProp("breakpoints",$e),a=l=>{e.includes(l)?e.length>2&&t(e.filter(p=>p!==l)):t(p=>[...p,l])};return u.length<4?r.jsxRuntimeExports.jsx("div",{className:"flex items-center rounded-md",children:c.map(u,l=>h.createElement(Z,{...l,onClick:s,key:l.breakpoint,currentBreakpoint:o}))}):r.jsxRuntimeExports.jsxs("div",{className:"flex items-center rounded-md",children:[c.map(u.filter(l=>c.includes(e,c.toUpper(l.breakpoint))),l=>h.createElement(Z,{...l,onClick:s,key:l.breakpoint,currentBreakpoint:o})),r.jsxRuntimeExports.jsxs(i.DropdownMenu,{children:[r.jsxRuntimeExports.jsx(i.DropdownMenuTrigger,{asChild:!0,children:r.jsxRuntimeExports.jsx("span",{className:"cursor-pointer px-2.5 hover:opacity-80",children:r.jsxRuntimeExports.jsx(E.DotsVerticalIcon,{className:"scale-90 transform"})})}),r.jsxRuntimeExports.jsxs(i.DropdownMenuContent,{className:"w-56 border-border text-xs",children:[r.jsxRuntimeExports.jsx(i.DropdownMenuLabel,{children:n("Breakpoints")}),r.jsxRuntimeExports.jsx(i.DropdownMenuSeparator,{}),c.map(u,l=>r.jsxRuntimeExports.jsx(i.DropdownMenuCheckboxItem,{disabled:l.breakpoint==="xs",onCheckedChange:()=>a(c.toUpper(l.breakpoint)),checked:c.includes(e,c.toUpper(l.breakpoint)),children:n(l.title)},l.breakpoint))]})]})]})},be=()=>{const{t:o}=U.useTranslation(),{setNewBlocks:s}=i.useBlocksStoreUndoableActions(),[,e]=i.useSelectedBlockIds(),[,t]=i.useSelectedStylingBlocks(),n=h.useCallback(()=>{s([]),e([]),t([])},[s]);return r.jsxRuntimeExports.jsx("div",{className:"flex items-center",children:r.jsxRuntimeExports.jsxs(i.AlertDialog,{children:[r.jsxRuntimeExports.jsx(i.AlertDialogTrigger,{asChild:!0,children:r.jsxRuntimeExports.jsxs(i.Button,{size:"sm",variant:"ghost",className:"flex items-center gap-x-1",children:[r.jsxRuntimeExports.jsx(E.EraserIcon,{})," ",o("clear")]})}),r.jsxRuntimeExports.jsxs(i.AlertDialogContent,{className:"border-border",children:[r.jsxRuntimeExports.jsxs(i.AlertDialogHeader,{children:[r.jsxRuntimeExports.jsx(i.AlertDialogTitle,{children:o("clear_canvas_title")}),r.jsxRuntimeExports.jsx(i.AlertDialogDescription,{children:o("clear_canvas_description")})]}),r.jsxRuntimeExports.jsxs(i.AlertDialogFooter,{children:[r.jsxRuntimeExports.jsx(i.AlertDialogCancel,{children:o("cancel")}),r.jsxRuntimeExports.jsx(i.AlertDialogAction,{onClick:n,children:o("yes")})]})]})]})})},ke=()=>{const[o,s]=b.useAtom(i.aiAssistantActiveAtom);return i.useBuilderProp("askAiCallBack",null)?r.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsxRuntimeExports.jsxs(i.Label,{htmlFor:"ai-assistant",className:"flex items-center gap-x-1 text-sm text-yellow-600",children:[r.jsxRuntimeExports.jsx(re.SparklesIcon,{className:"w-4"}),"AI Assistant"]}),r.jsxRuntimeExports.jsx(i.Switch,{className:"scale-90",checked:o,onCheckedChange:t=>{s(t)},id:"ai-assitantt"})]}):null},Ee=()=>{const o=i.useBuilderProp("darkMode",!0),[s]=i.useCanvasZoom();return r.jsxRuntimeExports.jsxs("div",{className:"flex h-10 items-center justify-between border-b bg-background/70 px-2",children:[r.jsxRuntimeExports.jsxs("div",{className:"flex h-full space-x-2",children:[r.jsxRuntimeExports.jsx(ye,{}),r.jsxRuntimeExports.jsx(i.Separator,{orientation:"vertical"}),o?r.jsxRuntimeExports.jsxs(r.jsxRuntimeExports.Fragment,{children:[r.jsxRuntimeExports.jsx(je,{}),r.jsxRuntimeExports.jsx(i.Separator,{orientation:"vertical"})]}):null,r.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:[r.jsxRuntimeExports.jsx(E.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",r.jsxRuntimeExports.jsxs("div",{className:"text-xs leading-3",children:[c.round(s,0),"%"]})]}),r.jsxRuntimeExports.jsx(i.Separator,{orientation:"vertical"}),r.jsxRuntimeExports.jsx(ve,{})]}),r.jsxRuntimeExports.jsxs("div",{className:"flex h-full items-center space-x-2",children:[r.jsxRuntimeExports.jsx(be,{}),r.jsxRuntimeExports.jsx(i.Separator,{orientation:"vertical"}),r.jsxRuntimeExports.jsx(ke,{})]})]})},Re=`<!doctype html>
2
+ <html lang="en" dir="__HTML_DIR__" class="scroll-smooth h-full overflow-y-auto">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"><\/script>
7
+ <style>
8
+ html { height: 100%; overflow:auto; }
9
+ body { height: 100%; }
10
+ .air-highlight{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}
11
+ .air-highlight-multi{ outline: 1px solid #29e503 !important; outline-offset: -1px;}
12
+ body{ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none;
13
+ -moz-user-select: none;-ms-user-select: none; user-select: none; }
14
+ html{
15
+ -ms-overflow-style: none; /* IE and Edge */
16
+ scrollbar-width: none; /* Firefox */
17
+ }
18
+ /** IMPORTANT: Make fields content editable in SAFARI */
19
+ [contenteditable] {-webkit-user-select: text;user-select: text;}
20
+
21
+ html::-webkit-scrollbar { width: 0 !important }
22
+ .aspect-auto{aspect-ratio: auto;}
23
+ .aspect-square{aspect-ratio: 1/1;}
24
+ .aspect-video{aspect-ratio: 16/9;}
25
+ .dragging [data-dnd="leaf"] { pointer-events: none; } .dragging [data-dnd="leaf"] * { pointer-events: none; }
26
+ .dragging [data-dnd="ignore"], .dragging [data-dnd="ignore"] * { pointer-events: none; }
27
+ a{ pointer-events: none !important; }
28
+ [contenteditable="true"], [contenteditable="true"] * { cursor: text !important; }
29
+ [contenteditable="true"] {
30
+ outline: none;
31
+ box-shadow: 0 0 0px 4px rgba(36, 150, 255, 0.2);
32
+ -webkit-user-select: text;
33
+ -moz-user-select: text;
34
+ user-select: text;
35
+ }
36
+ .frame-root .frame-content { height: 100%; }
37
+ [data-drop="yes"] { outline: 2px dashed orange !important; outline-offset: -2px }
38
+ [data-dnd="no"] { pointer-events: none !important; }
39
+ </style>
40
+ <style id="hidden-blocks"></style>
41
+ <style id="selected-block"></style>
42
+ <style id="selected-styling-block"></style>
43
+ <style id="highlighted-block"></style>
44
+ <style id="dragged-block"></style>
45
+
46
+ </head>
47
+ <body class="font-body antialiased h-full">
48
+ <div class="frame-root h-full"></div>
49
+ <script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"><\/script>
50
+ </body>
51
+ </html>`,we=o=>{const[s]=i.useCanvasWidth(),[,e]=i.useCanvasZoom(),[t,n]=h.useState({}),u=h.useCallback(()=>{const{width:a,height:l}=o;if(a<s){const p=parseFloat((a/s).toFixed(2).toString());let d={};const g=l*p;l&&(d={height:100+(l-g)/g*100+"%"}),n({position:"relative",top:0,transform:`scale(${p})`,transformOrigin:"top left",...d,maxWidth:"none"}),e(p*100)}else n({}),e(100)},[s,o,e]);return h.useEffect(()=>{u()},[s,o,e,u]),t};let J,V;typeof document<"u"&&(J=document);typeof window<"u"&&(V=window);const ee=h.createContext({document:J,window:V}),N=()=>h.useContext(ee),{Provider:Se,Consumer:tt}=ee;class te extends h.Component{componentDidMount(){this.props.contentDidMount()}componentDidUpdate(){this.props.contentDidUpdate()}render(){return h.Children.only(this.props.children)}}I(te,"propTypes",{children:R.element.isRequired,contentDidMount:R.func.isRequired,contentDidUpdate:R.func.isRequired});class O extends h.Component{constructor(e,t){super(e,t);I(this,"setRef",e=>{this.nodeRef.current=e;const{forwardedRef:t}=this.props;typeof t=="function"?t(e):t&&(t.current=e)});I(this,"handleLoad",()=>{clearInterval(this.loadCheck),this.state.iframeLoaded||this.setState({iframeLoaded:!0})});I(this,"loadCheck",()=>setInterval(()=>{this.handleLoad()},500));this._isMounted=!1,this.nodeRef=h.createRef(),this.state={iframeLoaded:!1}}componentDidMount(){this._isMounted=!0,this.getDoc()&&this.nodeRef.current.contentWindow.addEventListener("DOMContentLoaded",this.handleLoad)}componentWillUnmount(){this._isMounted=!1,this.nodeRef.current.removeEventListener("DOMContentLoaded",this.handleLoad)}getDoc(){return this.nodeRef.current?this.nodeRef.current.contentDocument:null}getMountTarget(){const e=this.getDoc();return this.props.mountTarget?e.querySelector(this.props.mountTarget):e.body.children[0]}renderFrameContents(){if(!this._isMounted)return null;const e=this.getDoc();if(!e)return null;const t=this.props.contentDidMount,n=this.props.contentDidUpdate,u=e.defaultView||e.parentView,a=r.jsxRuntimeExports.jsx(te,{contentDidMount:t,contentDidUpdate:n,children:r.jsxRuntimeExports.jsx(Se,{value:{document:e,window:u},children:r.jsxRuntimeExports.jsx("div",{className:"frame-content",children:this.props.children})})}),l=this.getMountTarget();return[Y.createPortal(this.props.head,this.getDoc().head),Y.createPortal(a,l)]}render(){const e={...this.props,srcDoc:this.props.initialContent,children:void 0};return delete e.head,delete e.initialContent,delete e.mountTarget,delete e.contentDidMount,delete e.contentDidUpdate,delete e.forwardedRef,r.jsxRuntimeExports.jsx("iframe",{...e,ref:this.setRef,onLoad:this.handleLoad,children:this.state.iframeLoaded&&this.renderFrameContents()})}}I(O,"propTypes",{style:R.object,head:R.node,initialContent:R.string,mountTarget:R.string,contentDidMount:R.func,contentDidUpdate:R.func,children:R.oneOfType([R.element,R.arrayOf(R.element)])}),I(O,"defaultProps",{style:{},head:null,children:void 0,mountTarget:void 0,contentDidMount:()=>{},contentDidUpdate:()=>{},initialContent:'<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'});const Be=h.forwardRef((o,s)=>r.jsxRuntimeExports.jsx(O,{...o,forwardedRef:s}));function W(o){const s=window.getComputedStyle(o),e=s.display;if(e==="flex"){const t=s.flexDirection;return t==="column"||t==="column-reverse"?"vertical":"horizontal"}else if(e==="grid"){const t=s.gridAutoFlow,n=s.gridTemplateRows,u=s.gridTemplateColumns;return t.includes("column")||n.split(" ").length>u.split(" ").length?"vertical":"horizontal"}else if(e==="block"||e==="inline-block")return"vertical";return"horizontal"}let S=null,B=[],_=null,P=null;const Q=(o,s,e)=>{if(!S||!o)return;const t=S==null?void 0:S.getElementById("placeholder"),u=B.map(([l])=>l).reduce((l,p)=>Math.abs(p-e)<Math.abs(l-e)?p:l,0);if(!B[u])return;const a=B[u];t.style.width=s==="vertical"?a[2]+"px":"2px",t.style.height=s==="vertical"?"2px":a[2]+"px",t.style.display="block",s==="vertical"?(t.style.top=a[0]+"px",t.style.left=a[1]+"px"):(t.style.top=a[1]+"px",t.style.left=a[0]+"px")};function Ce(o,s){let e=0,t=1/0;return s.forEach((n,u)=>{const a=Math.abs(n[0]-o);a<t&&(t=a,e=u)}),e}const Ae=o=>{const e=W(o)==="horizontal";B=[],Array.from(o.children).forEach(t=>{if(t.classList.contains("pointer-events-none"))return;const n=e?t.offsetLeft:t.offsetTop,u=e?[t.offsetTop,t.clientHeight]:[t.offsetLeft,t.clientWidth];B.push([n,u[0],u[1]])})},Ie=c.throttle(o=>{const s=o.target,e=W(s);if(e==="vertical"){const t=o.clientY-s.offsetTop;Q(s,e,t)}else{const t=o.clientX-s.offsetLeft;Q(s,e,t)}},200);function H(){const o=S==null?void 0:S.getElementById("placeholder");o.style.display="none",De("pointer-none")}function De(o){document.querySelectorAll(`.${o}`).forEach(e=>{e.classList.remove(o)})}const _e=()=>{const{document:o}=N(),[s,e]=b.useAtom(i.draggingFlagAtom),{addCoreBlock:t}=i.useAddBlock(),[,n]=i.useHighlightBlockId(),[,u]=i.useSelectedBlockIds(),{moveBlocks:a}=i.useBlocksStoreUndoableActions(),[,l]=b.useAtom(i.draggedBlockIdAtom),[p,d]=b.useAtom(T.draggedBlockAtom),[,g]=b.useAtom(T.dropTargetAtom);return S=o,{isDragging:s,onDragOver:x=>{x.preventDefault(),x.stopPropagation(),Ie(x)},onDrop:x=>{_==null||_.classList.remove("drop-target");const m=_,y=W(m)==="vertical"?x.clientY:x.clientX;P=Ce(y,B);const v=p,f=m.getAttribute("data-block-id");if(!c.has(v,"_id")){t(v,f==="canvas"?null:f,P),setTimeout(()=>{H()},300),B=[],e(!1),l(""),d(null),g(null);return}let k=m.getAttribute("data-block-id");k===null&&(k=x.target.parentElement.getAttribute("data-block-id")),a([v._id],k,P),H(),e(!1),l(""),setTimeout(()=>H(),300)},onDragEnter:x=>{const m=x,$=m.target;_=$;const y=$.getAttribute("data-block-id");g(y),m.stopPropagation(),m.preventDefault(),B=[],Ae($),$.classList.add("drop-target"),e(!0),n(""),u([])}}};function K(o){return o.getAttribute("data-block-id")?o:o.closest("[data-block-id]")}function Te(o){o.container.innerHTML="",o.container.parentNode.removeChild(o.container);var s=document.querySelector(".ql-toolbar");s&&s.parentNode.removeChild(s),o=null}const Me=()=>{const o=["Heading","Paragraph","Text","Link","Span","Button"],s=i.useUpdateBlocksProps(),[,e]=i.useHighlightBlockId(),[t,n]=b.useAtom(i.inlineEditingActiveAtom);return u=>{var x;if(t)return;const a=K(u.target),l=a.getAttribute("data-block-type");if(!l||!o.includes(l))return;const p=a.cloneNode(!0);a.style.display="none",Array.from(p.attributes).forEach(m=>{m.name!=="class"&&p.removeAttribute(m.name)}),l==="Text"&&(p.style.display="inline-block"),a.parentNode.insertBefore(p,a.nextSibling);const d=new ie.Quill(p,{placeholder:"Type here..."});function g(){const m=d.getText(0,d.getLength());s([a.getAttribute("data-block-id")],{content:m}),a.removeAttribute("style"),p.removeEventListener("blur",g,!0),Te(d),n(""),e("")}p.addEventListener("blur",g,!0),p.addEventListener("keydown",m=>{(m.key==="Enter"||m.key==="Escape")&&g()}),d.focus(),(x=p.querySelector(".ql-clipboard"))==null||x.remove(),n(a.getAttribute("data-block-id"))}},Ne=()=>{const[,o]=i.useSelectedStylingBlocks(),[s,e]=i.useSelectedBlockIds(),[,t]=i.useHighlightBlockId(),[n]=b.useAtom(i.inlineEditingActiveAtom),[u]=b.useAtom(i.treeRefAtom);return a=>{if(n)return;a.stopPropagation();const l=K(a.target);if(l!=null&&l.getAttribute("data-block-id")&&(l==null?void 0:l.getAttribute("data-block-id"))==="container"){e([]),o([]),t("");return}if(l!=null&&l.getAttribute("data-block-parent")){const p=l.getAttribute("data-style-prop"),d=l.getAttribute("data-style-id"),g=l.getAttribute("data-block-parent");s.includes(g)||u.closeAll(),o([{id:d,prop:p,blockId:g}]),e([g])}else if(l!=null&&l.getAttribute("data-block-id")){let p=l.getAttribute("data-block-id");s.includes(p)||u.closeAll(),e([p])}t("")}},qe=c.throttle((o,s)=>{const e=K(o.target);e!=null&&e.getAttribute("data-style-id")&&s(e.getAttribute("data-style-id"))},100),Le=()=>{const[,o]=i.useHighlightBlockId(),[s]=b.useAtom(i.inlineEditingActiveAtom);return e=>{s||qe(e,o)}},Fe=({children:o})=>{const{document:s}=N(),[e]=i.useSelectedBlockIds(),[t,n]=i.useSelectedStylingBlocks();h.useEffect(()=>{setTimeout(()=>{if(!c.isEmpty(t))return;const d=se(s,c.first(e));if(d){const g=d.getAttribute("data-style-prop");if(g){const x=d.getAttribute("data-style-id"),m=d.getAttribute("data-block-parent");n([{id:x,prop:g,blockId:m}])}}},100)},[s,e,n,t]);const u=Me(),a=Ne(),l=Le(),p=_e();return r.jsxRuntimeExports.jsx("div",{"data-block-id":"canvas",id:"canvas",onClick:a,onDoubleClick:u,onMouseMove:l,...c.omit(p,"isDragging"),className:"relative mb-5 h-full max-w-full "+(p.isDragging?"dragging":""),children:o})},se=(o,s)=>o.querySelector(`[data-block-id="${s}"]`),Pe=()=>{const{window:o}=N(),[s,e]=i.useSelectedBlockIds(),[t]=i.useBlocksStore(),[,n]=i.useSelectedStylingBlocks(),{undo:u,redo:a}=i.useUndoManager(),l=i.useDuplicateBlocks(),[,p]=i.usePreviewMode(),d=i.useRemoveBlocks(),{savePage:g}=i.useSavePage(),[x]=b.useAtom(i.inlineEditingActiveAtom),[,m]=b.useAtom(i.editLayerNameAtom),$=v=>{v.key==="Enter"&&(v.preventDefault(),s.length===1&&m(c.first(s)))},y=v=>{const f=t.find(k=>k._id===v);return f?f._parent:null};return h.useEffect(()=>{const v=f=>{if(f.key==="Escape"){e([]),n([]);return}if($(f),!x&&(f.key==="Delete"||f.key==="Backspace")&&(f.preventDefault(),d(s)),f.ctrlKey||f.metaKey){if(f.key==="ArrowUp"){f.preventDefault();const k=s.length>0?y(s[0]):null;k&&e([k])}if(["z","y","d","x","c","p","s","v"].includes(f.key)){if(x&&["x","z","v"].includes(f.key))return!0;f.preventDefault()}f.key==="s"&&(f.stopPropagation(),f.preventDefault(),g()),f.key==="z"&&u(),f.key==="y"&&a(),f.key==="d"&&l(s)}};return o.removeEventListener("keydown",v),o.addEventListener("keydown",v),()=>{o.removeEventListener("keydown",v)}},[s,e,u,d,p,a,l,x,g,o]),null},He=({block:o,label:s})=>{const[,e]=i.useSelectedBlockIds(),[,t]=i.useHighlightBlockId(),[,n]=b.useAtom(T.draggedBlockAtom),u=ae.useFeature("dnd");return r.jsxRuntimeExports.jsxs("div",{className:"mr-10 flex cursor-grab items-center space-x-1 px-1",draggable:u?"true":"false",onDragStart:a=>{a.dataTransfer.setData("text/plain",JSON.stringify(c.pick(o,["_id","_type","_name"]))),n(o),setTimeout(()=>{e([]),t(null)},200)},children:[r.jsxRuntimeExports.jsx(E.DragHandleDots2Icon,{}),s]})},Oe=({selectedBlockElement:o,block:s})=>{const e=i.useRemoveBlocks(),t=i.useDuplicateBlocks(),[,n]=i.useSelectedBlockIds(),[,u]=i.useSelectedStylingBlocks(),[a]=b.useAtom(i.inlineEditingActiveAtom),{floatingStyles:l,refs:p,update:d}=G.useFloating({placement:"top-start",middleware:[G.shift(),le.flip()],elements:{reference:o}});ce.useResizeObserver(o,()=>d(),o!==null);const g=c.get(s,"_parent",null),x=c.isEmpty(c.get(s,"_name",""))?c.get(s,"_type",""):c.get(s,"_name","");return!o||!s||a?null:r.jsxRuntimeExports.jsx(r.jsxRuntimeExports.Fragment,{children:r.jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,ref:p.setFloating,style:l,onClick:m=>{m.stopPropagation(),m.preventDefault()},onKeyDown:m=>m.stopPropagation(),className:"z-[99999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",children:[r.jsxRuntimeExports.jsx(He,{label:x,block:s}),r.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 px-1",children:[g&&r.jsxRuntimeExports.jsx(E.ArrowUpIcon,{className:"hover:scale-105",onClick:()=>{u([]),n([g])}}),i.canDuplicateBlock(c.get(s,"_type",""))?r.jsxRuntimeExports.jsx(E.CopyIcon,{className:"hover:scale-105",onClick:()=>t([s==null?void 0:s._id])}):null,i.canDeleteBlock(c.get(s,"_type",""))?r.jsxRuntimeExports.jsx(E.TrashIcon,{className:"hover:scale-105",onClick:()=>e([s==null?void 0:s._id])}):null]})]})})},ze=({addVariant:o,e:s})=>{o("hs-dropdown-open",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-dropdown.open > .${s(`hs-dropdown-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-dropdown.open .hs-dropdown-toggle .${s(`hs-dropdown-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-dropdown.open > .hs-dropdown-menu > .${s(`hs-dropdown-open${t}${n}`)}`)}]),o("hs-removing",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-removing.${s(`hs-removing${t}${n}`)}`)}),o("hs-tooltip-shown",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-tooltip.show .${s(`hs-tooltip-shown${t}${n}`)}`)}),o("hs-accordion-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion.active.${s(`hs-accordion-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion.active > .${s(`hs-accordion-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion.active > .hs-accordion-toggle .${s(`hs-accordion-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion.active > .hs-accordion-heading > .hs-accordion-toggle .${s(`hs-accordion-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion.active > .hs-accordion-toggle.${s(`hs-accordion-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion.active > .hs-accordion-heading > .hs-accordion-toggle.${s(`hs-accordion-active${t}${n}`)}`)}]),o("hs-accordion-selected",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-accordion .selected.${s(`hs-accordion-selected${t}${n}`)}`)}),o("hs-collapse-open",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-collapse.open .${s(`hs-collapse-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-collapse.open.${s(`hs-collapse-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-collapse-toggle.open .${s(`hs-collapse-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-collapse-toggle.open.${s(`hs-collapse-open${t}${n}`)}`)}]),o("hs-tab-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`[data-hs-tab].active.${s(`hs-tab-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`[data-hs-tab].active .${s(`hs-tab-active${t}${n}`)}`)}]),o("hs-overlay-open",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.open.${s(`hs-overlay-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.open .${s(`hs-overlay-open${t}${n}`)}`)}]),o("hs-overlay-layout-open",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-overlay-body-open.${s(`hs-overlay-layout-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-overlay-body-open .${s(`hs-overlay-layout-open${t}${n}`)}`)}]),o("hs-overlay-backdrop-open",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-overlay-backdrop.${s(`hs-overlay-backdrop-open${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.hs-overlay-backdrop .${s(`hs-overlay-backdrop-open${t}${n}`)}`)}]),o("hs-scrollspy-active",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-scrollspy-active${t}${n}`)}`)}),o("hs-carousel-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-carousel-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active .${s(`hs-carousel-active${t}${n}`)}`)}]),o("hs-carousel-disabled",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled.${s(`hs-carousel${t}disabled${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled .${s(`hs-carousel${t}disabled${t}${n}`)}`)}]),o("hs-selected",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.selected.${s(`hs-selected${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.selected .${s(`hs-selected${t}${n}`)}`)}]),o("hs-select-disabled",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled.${s(`hs-select-disabled${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled .${s(`hs-select-disabled${t}${n}`)}`)}]),o("hs-select-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-select-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active .${s(`hs-select-active${t}${n}`)}`)}]),o("hs-input-number-disabled",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled.${s(`hs-input-number-disabled${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled .${s(`hs-input-number-disabled${t}${n}`)}`)}]),o("hs-pin-input-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-pin-input-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active .${s(`hs-pin-input-active${t}${n}`)}`)}]),o("hs-select-opened",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.opened.${s(`hs-select-opened${t}${n}`)}`)}]),o("hs-password-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-password-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active .${s(`hs-password-active${t}${n}`)}`)}]),o("hs-stepper-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-stepper-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active .${s(`hs-stepper-active${t}${n}`)}`)}]),o("hs-stepper-success",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.success.${s(`hs-stepper-success${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.success .${s(`hs-stepper-success${t}${n}`)}`)}]),o("hs-stepper-completed",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.completed.${s(`hs-stepper-completed${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.completed .${s(`hs-stepper-completed${t}${n}`)}`)}]),o("hs-stepper-error",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.error.${s(`hs-stepper-error${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.error .${s(`hs-stepper-error${t}${n}`)}`)}]),o("hs-stepper-processed",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.processed.${s(`hs-stepper-processed${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.processed .${s(`hs-stepper-processed${t}${n}`)}`)}]),o("hs-stepper-disabled",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled.${s(`hs-stepper-disabled${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.disabled .${s(`hs-stepper-disabled${t}${n}`)}`)}]),o("hs-stepper-skipped",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.skipped.${s(`hs-stepper-skipped${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.skipped .${s(`hs-stepper-skipped${t}${n}`)}`)}]),o("hs-strong-password",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.passed.${s(`hs-strong-password${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.passed .${s(`hs-strong-password${t}${n}`)}`)}]),o("hs-strong-password-accepted",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.accepted.${s(`hs-strong-password-accepted${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.accepted .${s(`hs-strong-password-accepted${t}${n}`)}`)}]),o("hs-strong-password-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-strong-password-active${t}${n}`)}`)}]),o("hs-combo-box-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active .${s(`hs-combo-box-active${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-combo-box-active${t}${n}`)}`)}]),o("hs-combo-box-selected",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.selected .${s(`hs-combo-box-selected${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.selected.${s(`hs-combo-box-selected${t}${n}`)}`)}]),o("hs-combo-box-tab-active",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.active.${s(`hs-combo-box-tab-active${t}${n}`)}`)}]),o("hs-apexcharts-tooltip-dark",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.dark.${s(`hs-apexcharts-tooltip-dark${t}${n}`)}`)}]),o("hs-success",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.success .${s(`hs-success${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.success.${s(`hs-success${t}${n}`)}`)}]),o("hs-error",[({modifySelectors:e,separator:t})=>{e(({className:n})=>`.error .${s(`hs-error${t}${n}`)}`)},({modifySelectors:e,separator:t})=>{e(({className:n})=>`.error.${s(`hs-error${t}${n}`)}`)}]),o("hs-default-mode-active",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.default .${s(`hs-default-mode-active${t}${n}`)}`)}),o("hs-dark-mode-active",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.dark .${s(`hs-dark-mode-active${t}${n}`)}`)}),o("hs-auto-mode-active",({modifySelectors:e,separator:t})=>{e(({className:n})=>`.auto .${s(`hs-auto-mode-active${t}${n}`)}`)})},Ue=({model:o})=>{const[s]=i.useBrandingOptions(),[e]=i.useSelectedBlockIds(),[t]=i.useDarkMode(),[n]=i.useHighlightBlockId(),[u]=i.useSelectedStylingBlocks(),[a]=b.useAtom(i.draggedBlockIdAtom),{document:l,window:p}=N(),[d]=h.useState(l==null?void 0:l.getElementById("highlighted-block")),[g]=h.useState(l==null?void 0:l.getElementById("selected-block")),[x]=h.useState(l==null?void 0:l.getElementById("selected-styling-block")),[m]=h.useState(l==null?void 0:l.getElementById("dragged-block"));h.useEffect(()=>{t?l==null||l.documentElement.classList.add("dark"):l==null||l.documentElement.classList.remove("dark")},[t,l]);const $=c.get(s,"headingFont","DM Sans"),y=c.get(s,"bodyFont","DM Sans");return h.useEffect(()=>{const v=c.get(s,"primaryColor","#000"),f=c.get(s,"secondaryColor","#FFF"),k=c.get(s,"bodyBgLightColor","#fff"),w=c.get(s,"bodyBgDarkColor","#000"),D=c.get(s,"bodyTextDarkColor","#000"),q=c.get(s,"bodyTextLightColor","#fff"),L=he([{color:v,name:"primary"},{color:f,name:"secondary"}]),F={"bg-light":k,"bg-dark":w,"text-dark":D,"text-light":q},j=c.get(s,"roundedCorners","0");!p||!p.tailwind||(p.tailwind.config={darkMode:"class",theme:{extend:{container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},fontFamily:{heading:[$],body:[y]},borderRadius:{DEFAULT:`${j||"0"}px`},colors:{...F,...L}}},plugins:[de,ue,pe,p.tailwind.plugin.withOptions(()=>ze)]})},[s,p,$,y]),h.useEffect(()=>{g&&(g.textContent=`${c.map(e,v=>`[data-block-id="${v}"]`).join(",")}{
52
+ outline: 1px solid ${e.length===1?"#42a1fc":"orange"} !important; outline-offset: -1px;
53
+ }`)},[e,g]),h.useEffect(()=>{if(!a){m.textContent="";return}m.textContent=`[data-block-id="${a}"]{ pointer-events: none !important; opacity: 0.2 !important}`},[a]),h.useEffect(()=>{d&&(d.textContent=n?`[data-style-id="${n}"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}`:"")},[n,e,d]),h.useEffect(()=>{x&&(x.textContent=`${c.map(u,({id:v})=>`[data-style-id="${v}"]`).join(",")}{
54
+ outline: 1px solid #42a1fc !important; outline-offset: -1px;
55
+ }`)},[u,x]),h.useEffect(()=>{const v=c.get(s,"bodyTextLightColor","#64748b"),f=c.get(s,"bodyTextDarkColor","#94a3b8"),k=c.get(s,"bodyBgLightColor","#FFFFFF"),w=c.get(s,"bodyBgDarkColor","#0f172a");l.body.className=`font-body antialiased text-[${v}] bg-[${k}] dark:text-[${f}] dark:bg-[${w}]`},[s,l,o]),o==="page"?r.jsxRuntimeExports.jsxs(r.jsxRuntimeExports.Fragment,{children:[$&&r.jsxRuntimeExports.jsx("link",{id:"heading-font",rel:"stylesheet",type:"text/css",href:`https://fonts.googleapis.com/css2?family=${$.replace(/ /g,"+")}:wght@300;400;500;600;700;800;900&display=swap`,media:"all"}),y&&$!==y&&r.jsxRuntimeExports.jsx("link",{id:"body-font",rel:"stylesheet",type:"text/css",href:`https://fonts.googleapis.com/css2?family=${y.replace(/ /g,"+")}:wght@300;400;500;600;700;800;900&display=swap`,media:"all"}),$&&r.jsxRuntimeExports.jsx("style",{children:`h1,h2,h3,h4,h5,h6{font-family: "${$}",ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";}`})]}):null},We=o=>{const s={};return Object.keys(o).forEach(e=>{c.isString(o[e])&&o[e].startsWith(M.SLOT_KEY)&&(s[e]=o[e].replace(M.SLOT_KEY,"").split(","))}),s},Ke=c.memoize(o=>{const s=o.replace(M.STYLES_KEY,"").split(",");return xe.twMerge(s[0],s[1])});function Ye(o,s){return c.get(o,`${s}_attrs`,{})}function Ge(o){const s={};return Object.keys(o).forEach(e=>{if(c.isString(o[e])&&o[e].startsWith(M.STYLES_KEY)){const t=Ke(o[e]);s[e]={className:t,"data-style-prop":e,"data-block-parent":o._id,"data-style-id":`${e}-${o._id}`,...Ye(o,e)}}}),s}function Xe(o,s){const e=c.get(o,"_bindings",{});return c.isEmpty(e)?{...o}:(c.each(e,(t,n)=>{c.isString(t)&&c.get(s,t,null)&&(o[n]=c.get(s,t,null))}),o)}function z({blocks:o}){const[s]=i.useBlocksStore(),[e]=b.useAtom(T.draggedBlockAtom),[t]=b.useAtom(T.dropTargetAtom),[n]=ge.useCanvasSettings(),u=h.useCallback(d=>Ge(d),[]),[a]=i.useChaiExternalData(),[l]=b.useAtom(i.inlineEditingActiveAtom),p=h.useCallback(d=>d.reduce((g,x)=>{const m=c.get(n,x,{});return{...g,...m}},{}),[n,s]);return r.jsxRuntimeExports.jsx(r.jsxRuntimeExports.Fragment,{children:h.Children.toArray(o.map((d,g)=>{if(l===d._id)return null;const x=We(d),m={};c.isEmpty(x)||Object.keys(x).forEach(w=>{m[w]=h.Children.toArray(x[w].map(D=>r.jsxRuntimeExports.jsx(z,{blocks:[c.find(s,{_id:D})]})))});const $=c.filter(s,{_parent:d._id});m.children=$.length?r.jsxRuntimeExports.jsx(z,{blocks:$}):null;const y=me.getBlockComponent(d._type),v=c.get(y,"builderComponent",c.get(y,"component",null));if(c.isNull(v))return r.jsxRuntimeExports.jsx("noscript",{children:`<!-- ${d==null?void 0:d._type} not registered -->`});const f=c.has(y,"getBlockStateFrom")?y==null?void 0:y.getBlockStateFrom(d,s):[],k=p(f);return r.jsxRuntimeExports.jsx(h.Suspense,{children:h.createElement(v,{blockProps:{"data-block-id":d._id,"data-block-type":d._type,...e?{"data-dnd":i.canAcceptChildBlock(d._type,e==null?void 0:e._type)?"yes":"no"}:{},...t===d._id?{"data-drop":"yes"}:{}},index:g,...Xe(d,a),...u(d),...m,inBuilder:!0,blockState:k})})}))})}const Ze=()=>{const[o]=i.useBlocksStore(),s=c.isEmpty(o)?null:r.jsxRuntimeExports.jsx(i.BlocksExternalDataProvider,{children:r.jsxRuntimeExports.jsx(z,{blocks:c.filter(o,e=>c.isEmpty(e._parent))})});return r.jsxRuntimeExports.jsx(r.jsxRuntimeExports.Fragment,{children:s})},Qe=(o,s)=>o.querySelector(`[data-style-id="${s}"]`),Je=()=>{const[o]=b.useAtom(i.networkModeAtom),[s]=i.usePreviewMode(),[e]=i.useCanvasWidth(),[,t]=i.useSelectedBlockIds(),n=i.useSelectedBlock(),[,u]=i.useHighlightBlockId(),a=h.useRef(null),l=h.useRef(null),[p,d]=h.useState({width:0,height:0}),g=we(p),[x,m]=h.useState(0),[$,y]=h.useState([]),[,v]=h.useState([]),[,f]=b.useAtom(i.canvasIframeAtom),[k,w]=i.useSelectedStylingBlocks(),D=i.useBuilderProp("loading",!1),q=i.useBuilderProp("htmlDir","ltr");h.useEffect(()=>{const{clientWidth:j,clientHeight:C}=l.current;d({width:j,height:C}),x===0&&m(j)},[l,e,x]);const L=(j,C=0)=>{const{top:A}=j.getBoundingClientRect();return A+C>=0&&A-C<=window.innerHeight};h.useEffect(()=>{var j,C;if(n&&n.type!=="Multiple"&&a.current){const A=se(a.current.contentDocument,n._id);A&&(L(A)||(C=(j=a.current)==null?void 0:j.contentWindow)==null||C.scrollTo({top:A.offsetTop,behavior:"smooth"}),y([A]))}},[n]),h.useEffect(()=>{if(!c.isEmpty(k)&&a.current){const j=Qe(a.current.contentDocument,c.first(k).id);v(j?[j]:[null])}else v([null])},[k]);const F=h.useMemo(()=>{let j=Re;return j=j.replace("__HTML_DIR__",q),o==="offline"&&(j=j.replace("https://old.chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js"),j=j.replace("https://unpkg.com/aos@next/dist/aos.css","/offline/aos.css"),j=j.replace("https://unpkg.com/aos@next/dist/aos.js","/offline/aos.js")),j},[o]);return r.jsxRuntimeExports.jsx("div",{onClick:()=>{t([]),w([])},onMouseLeave:()=>setTimeout(()=>u(""),300),className:"relative mx-auto h-full w-full overflow-hidden",style:x>0&&!c.isEmpty(g)?{width:s?"100%":x}:{},ref:l,children:r.jsxRuntimeExports.jsxs(Be,{contentDidMount:()=>f(a.current),ref:a,id:"canvas-iframe",style:{width:`${e}px`,...g},className:"relative mx-auto box-content h-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:F,children:[r.jsxRuntimeExports.jsx(Pe,{}),r.jsxRuntimeExports.jsx(Oe,{block:n,selectedBlockElement:c.first($)}),r.jsxRuntimeExports.jsx(Ue,{model:"page"}),r.jsxRuntimeExports.jsx(fe.Provider,{children:r.jsxRuntimeExports.jsx(Fe,{children:D?r.jsxRuntimeExports.jsx("div",{className:"h-full p-4",children:r.jsxRuntimeExports.jsx(i.Skeleton,{className:"h-full"})}):r.jsxRuntimeExports.jsx(Ze,{})})}),r.jsxRuntimeExports.jsx("br",{}),r.jsxRuntimeExports.jsx("div",{id:"placeholder",className:"pointer-events-none absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})},Ve=()=>r.jsxRuntimeExports.jsxs("div",{className:"flex h-full w-full flex-col",children:[r.jsxRuntimeExports.jsx(Ee,{}),r.jsxRuntimeExports.jsx("div",{className:"relative h-full overflow-hidden bg-slate-800/90 bg-[linear-gradient(to_right,#222_0.5px,transparent_0.5px),linear-gradient(to_bottom,#222_0.5px,transparent_0.5px)] bg-[size:12px_12px] px-2",children:r.jsxRuntimeExports.jsx(h.Suspense,{fallback:r.jsxRuntimeExports.jsx(i.Skeleton,{className:"h-full"}),children:r.jsxRuntimeExports.jsx(i.ErrorBoundary,{children:r.jsxRuntimeExports.jsx(Je,{})})})})]});exports.default=Ve;