@chaibuilder/sdk 1.0.9 → 1.0.11

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 (167) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +123 -21
  3. package/dist/AddBlocks-7ACJv8LW.cjs +3 -0
  4. package/dist/{AddBlocks-d10b7b87.js → AddBlocks-H7BZYHUC.js} +43 -40
  5. package/dist/BrandingOptions-5j-XszLM.cjs +1 -0
  6. package/dist/{BrandingOptions-f4ab5d9f.js → BrandingOptions-PAgY-kvj.js} +19 -22
  7. package/dist/CanvasArea-Dnm-yeus.cjs +46 -0
  8. package/dist/{CanvasArea-10356200.js → CanvasArea-zn2ox-5h.js} +492 -503
  9. package/dist/ChaiBuilderEditor-BoE-sArB.cjs +163 -0
  10. package/dist/{index-aa42febc.js → ChaiBuilderEditor-hEuUONQ3.js} +11215 -15404
  11. package/dist/Class-_uCzl5v1.cjs +1 -0
  12. package/dist/{html-to-json-45e0e3b5.js → Class-l7qYbuoN.js} +185 -366
  13. package/dist/{CurrentPage-35e14043.js → CurrentPage-6Jp4xAWK.js} +27 -24
  14. package/dist/CurrentPage-YMpqOqx7.cjs +1 -0
  15. package/dist/{ImagesPanel-8b7a989d.cjs → ImagesPanel-6us7hiLN.cjs} +1 -1
  16. package/dist/{ImagesPanel-47ac13c3.js → ImagesPanel-oaHOD-Ex.js} +4 -4
  17. package/dist/Layers-EzOZdWvd.cjs +1 -0
  18. package/dist/{Layers-c3dd4fc8.js → Layers-WkZ48AUm.js} +43 -42
  19. package/dist/{MarkAsGlobalBlock-505ae793.js → MarkAsGlobalBlock-0HubcRkY.js} +18 -21
  20. package/dist/MarkAsGlobalBlock-HmeIyLCP.cjs +1 -0
  21. package/dist/{PagesPanel-bafc506f.js → PagesPanel-6JuwBLFQ.js} +17 -14
  22. package/dist/PagesPanel-zJq8p1ja.cjs +1 -0
  23. package/dist/ProjectPanel-Zml2F8b9.cjs +1 -0
  24. package/dist/{ProjectPanel-6113f394.js → ProjectPanel-cu2QSDW9.js} +23 -20
  25. package/dist/{Settings-1c41c514.js → Settings-fH8fZKpm.js} +266 -264
  26. package/dist/Settings-lc9PfnmG.cjs +1 -0
  27. package/dist/SidePanels-VH72zFE2.cjs +1 -0
  28. package/dist/{SidePanels-c13f87dc.js → SidePanels-w8ZHKJaR.js} +34 -42
  29. package/dist/{Topbar-b38d5d50.js → Topbar-hm1D_5sb.js} +34 -36
  30. package/dist/Topbar-vQPo9xSY.cjs +1 -0
  31. package/dist/UnsplashImages-BoBBSi1a.cjs +1 -0
  32. package/dist/{UnsplashImages-4edb97e7.js → UnsplashImages-gPcBLjgB.js} +13 -14
  33. package/dist/UploadImages-T6kW0s3G.cjs +1 -0
  34. package/dist/{UploadImages-52181c3e.js → UploadImages-_ZyUU66E.js} +11 -12
  35. package/dist/{accordion-c0176dc5.js → accordion-oPUeqPCZ.js} +2 -2
  36. package/dist/{accordion-0afd8143.cjs → accordion-ynvFtV_p.cjs} +1 -1
  37. package/dist/add-page-modal--qZSwJuB.cjs +1 -0
  38. package/dist/{add-page-modal-08a19915.js → add-page-modal-bj7qbZuK.js} +27 -23
  39. package/dist/alert-dialog-GNfnpqFB.js +64 -0
  40. package/dist/alert-dialog-Mv0-wAvS.cjs +1 -0
  41. package/dist/{command-b1103666.cjs → command-ThdTuUxt.cjs} +1 -1
  42. package/dist/{command-6f260f61.js → command-VHca6CcN.js} +3 -3
  43. package/dist/confirm-alert-8EHe0OOd.cjs +1 -0
  44. package/dist/confirm-alert-b0e_BLhF.js +36 -0
  45. package/dist/{context-menu-e1c240ce.js → context-menu-8dC9uGXj.js} +2 -2
  46. package/dist/{context-menu-fec580f2.cjs → context-menu-IgLbIuth.cjs} +1 -1
  47. package/dist/controls-Ni5kEzLz.js +103 -0
  48. package/dist/controls-W97-POR_.cjs +1 -0
  49. package/dist/controls-enQY7NI8.js +118 -0
  50. package/dist/controls-xUKa23ic.cjs +1 -0
  51. package/dist/core.cjs +1 -1
  52. package/dist/core.d.ts +1 -10
  53. package/dist/core.js +117 -70
  54. package/dist/delete-page-modal-2LuDLEiP.cjs +1 -0
  55. package/dist/{delete-page-modal-9b37665b.js → delete-page-modal-cnrR8tWH.js} +26 -23
  56. package/dist/{dialog-170eaad9.cjs → dialog-S_QbL1iq.cjs} +1 -1
  57. package/dist/{dialog-18207bef.js → dialog-jrw9DF1f.js} +2 -2
  58. package/dist/{dropdown-menu-ae3ed09b.js → dropdown-menu-S03K_fNs.js} +2 -2
  59. package/dist/{dropdown-menu-84b2439e.cjs → dropdown-menu-sMXR59cB.cjs} +1 -1
  60. package/dist/{form-25e1af37.js → form-dVpOAyRl.js} +2 -2
  61. package/dist/{form-ea21db6c.cjs → form-nRAvKPQj.cjs} +1 -1
  62. package/dist/{functions-83b1de8d.js → functions-nNTuSTsR.js} +1 -1
  63. package/dist/functions-pcUZhFJM.js +12 -0
  64. package/dist/{functions-f84d5e2a.cjs → functions-sCuB7nvZ.cjs} +1 -1
  65. package/dist/functions-uw7QP2kT.cjs +1 -0
  66. package/dist/html-to-json-P6GpbcQX.cjs +1 -0
  67. package/dist/html-to-json-pdHQfRkN.js +178 -0
  68. package/dist/index-HAue58ea.cjs +1 -0
  69. package/dist/index-T4_wfKl5.js +2256 -0
  70. package/dist/index-X9ZgD09V.cjs +1 -0
  71. package/dist/index-ehKdBRUK.js +18 -0
  72. package/dist/{label-e770a087.js → label-KaP7MRrs.js} +2 -2
  73. package/dist/{label-167415e5.cjs → label-tFm8HZdb.cjs} +1 -1
  74. package/dist/lib.cjs +1 -1
  75. package/dist/lib.d.ts +20 -13
  76. package/dist/lib.js +24 -23
  77. package/dist/{link-57de608a.js → link-6o6n2Tnd.js} +4 -4
  78. package/dist/link-ece8dZGH.cjs +1 -0
  79. package/dist/page-viewer-IARz6OSp.cjs +1 -0
  80. package/dist/{page-viewer-5c733179.js → page-viewer-Y4YiaZ_m.js} +30 -27
  81. package/dist/{popover-f7addcf4.js → popover-a84pbVhQ.js} +2 -2
  82. package/dist/{popover-7cb9079b.cjs → popover-fKjgcRUx.cjs} +1 -1
  83. package/dist/{project-general-setting-d9736056.js → project-general-setting-U4S_KlhU.js} +29 -25
  84. package/dist/project-general-setting-eSl3t-VH.cjs +1 -0
  85. package/dist/{project-seo-setting-d81fc1e3.js → project-seo-setting-Ga9v_ECU.js} +18 -19
  86. package/dist/project-seo-setting-rankm1z3.cjs +1 -0
  87. package/dist/render.cjs +1 -1
  88. package/dist/render.d.ts +7 -7
  89. package/dist/render.js +36 -36
  90. package/dist/{scroll-area-bb343b86.cjs → scroll-area-FiHvy-TZ.cjs} +1 -1
  91. package/dist/{scroll-area-83bd9e8f.js → scroll-area-ewXbxc3n.js} +2 -2
  92. package/dist/{select-0e32300c.cjs → select-7bjg-rr9.cjs} +1 -1
  93. package/dist/{select-7fddd7c3.js → select-POGdEDHT.js} +2 -2
  94. package/dist/{separator-a597dba7.cjs → separator-3Civ-6hb.cjs} +1 -1
  95. package/dist/{separator-a80d065b.js → separator-SctTn0Qi.js} +2 -2
  96. package/dist/server.cjs +1 -1
  97. package/dist/server.d.ts +7 -10
  98. package/dist/server.js +1 -4
  99. package/dist/{single-page-detail-04410e64.js → single-page-detail-pAxCy_Pe.js} +69 -65
  100. package/dist/single-page-detail-yPgnu2AI.cjs +1 -0
  101. package/dist/skeleton-CU_FIbg3.js +239 -0
  102. package/dist/skeleton-JHP9zwL2.cjs +1 -0
  103. package/dist/studio.cjs +1 -0
  104. package/dist/studio.d.ts +13 -0
  105. package/dist/studio.js +39 -0
  106. package/dist/{tabs-85caa1e8.js → tabs-Gb9v5dVb.js} +2 -2
  107. package/dist/{tabs-860e37aa.cjs → tabs-iWeaaVrg.cjs} +1 -1
  108. package/dist/{textarea-a338ede6.cjs → textarea-1kZEh7ki.cjs} +1 -1
  109. package/dist/{textarea-0750bcd2.js → textarea-b2QvVhrK.js} +2 -2
  110. package/dist/{toggle-00c9d11e.js → toggle-ASJRAaGP.js} +2 -2
  111. package/dist/{toggle-b90fed97.cjs → toggle-ehNIPmme.cjs} +1 -1
  112. package/dist/ui.cjs +1 -1
  113. package/dist/ui.d.ts +72 -7
  114. package/dist/ui.js +272 -212
  115. package/dist/useAddBlock-WJc3OgG8.js +86 -0
  116. package/dist/useAddBlock-dCKRFPRU.cjs +1 -0
  117. package/dist/useAllBlocks-6hvuNuyw.cjs +1 -0
  118. package/dist/useAllBlocks-PQKYvs-e.js +20 -0
  119. package/dist/useChaiExternalData-4K9WxANa.js +6 -0
  120. package/dist/useChaiExternalData-DkyBJ81C.cjs +1 -0
  121. package/dist/useDarkMode-ZKCO_gkt.js +23 -0
  122. package/dist/useDarkMode-dV6FM6l-.cjs +1 -0
  123. package/dist/useFeatureSupport-OLwNgEZb.js +16 -0
  124. package/dist/useFeatureSupport-c9IgPW2t.cjs +1 -0
  125. package/dist/useHiddenBlocks-3MsGOJ1s.js +15 -0
  126. package/dist/useHiddenBlocks-oJuQDmTy.cjs +1 -0
  127. package/dist/useLanguage-NKKKaxVM.cjs +1 -0
  128. package/dist/useLanguage-gVC5rxO5.js +216 -0
  129. package/dist/useMarkAsGlobalBlock-X73Vny8u.js +25 -0
  130. package/dist/useMarkAsGlobalBlock-ebBVGHg4.cjs +1 -0
  131. package/dist/useUiLibraries-4hPOi8DI.js +12 -0
  132. package/dist/useUiLibraries-9FhQCpKo.cjs +1 -0
  133. package/package.json +20 -6
  134. package/dist/AddBlocks-76275943.cjs +0 -3
  135. package/dist/BrandingOptions-d3b3309a.cjs +0 -1
  136. package/dist/CanvasArea-9f94cd28.cjs +0 -46
  137. package/dist/CurrentPage-edb509db.cjs +0 -1
  138. package/dist/Layers-ecba52c1.cjs +0 -1
  139. package/dist/MarkAsGlobalBlock-3a06a159.cjs +0 -1
  140. package/dist/PagesPanel-f4329082.cjs +0 -1
  141. package/dist/ProjectPanel-ce3116d3.cjs +0 -1
  142. package/dist/Settings-b6a2bef6.cjs +0 -1
  143. package/dist/SidePanels-2cc72c0b.cjs +0 -1
  144. package/dist/Topbar-3b9db9f3.cjs +0 -1
  145. package/dist/UnsplashImages-98c085c2.cjs +0 -1
  146. package/dist/UploadImages-61ef83ad.cjs +0 -1
  147. package/dist/add-page-modal-7f9ff733.cjs +0 -1
  148. package/dist/confirm-alert-c1fdf1e4.js +0 -35
  149. package/dist/confirm-alert-e1ea5110.cjs +0 -1
  150. package/dist/delete-page-modal-7066b01f.cjs +0 -1
  151. package/dist/html-to-json-aadcbf66.cjs +0 -1
  152. package/dist/index-c535cc95.cjs +0 -164
  153. package/dist/link-24679521.cjs +0 -1
  154. package/dist/page-viewer-da99c71e.cjs +0 -1
  155. package/dist/project-general-setting-90f8416d.cjs +0 -1
  156. package/dist/project-seo-setting-6eef8387.cjs +0 -1
  157. package/dist/single-page-detail-90f49d7a.cjs +0 -1
  158. package/dist/useBuilderProp-21feb2da.js +0 -296
  159. package/dist/useBuilderProp-adacf42f.cjs +0 -1
  160. package/dist/useChaiExternalData-192c7896.js +0 -5
  161. package/dist/useChaiExternalData-a90e8aac.cjs +0 -1
  162. /package/dist/{MODIFIERS-2f19c314.js → MODIFIERS-DsEzQ3aH.js} +0 -0
  163. /package/dist/{MODIFIERS-4716c669.cjs → MODIFIERS-Fx6WAZcw.cjs} +0 -0
  164. /package/dist/{jsx-runtime-5c3ac4f7.cjs → jsx-runtime-JYMCiFoE.cjs} +0 -0
  165. /package/dist/{jsx-runtime-944c88e2.js → jsx-runtime-Sp0orL4X.js} +0 -0
  166. /package/dist/{utils-ac68b2c8.js → utils-dze1SGvB.js} +0 -0
  167. /package/dist/{utils-3c452dd0.cjs → utils-qK_SjzzV.cjs} +0 -0
@@ -0,0 +1,46 @@
1
+ "use strict";var $e=Object.defineProperty;var Ue=(n,t,s)=>t in n?$e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var z=(n,t,s)=>(Ue(n,typeof t!="symbol"?t+"":t,s),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-JYMCiFoE.cjs"),x=require("react"),u=require("lodash"),M=require("@radix-ui/react-icons"),K=require("./skeleton-JHP9zwL2.cjs"),h=require("./ChaiBuilderEditor-BoE-sArB.cjs"),Se=require("react-i18next"),Q=require("./separator-3Civ-6hb.cjs"),G=require("./useDarkMode-dV6FM6l-.cjs"),L=require("./dropdown-menu-sMXR59cB.cjs"),He=require("./label-tFm8HZdb.cjs"),ee=require("./useFeatureSupport-c9IgPW2t.cjs"),$=require("./alert-dialog-Mv0-wAvS.cjs"),X=require("jotai"),ze=require("@floating-ui/dom"),me=require("@floating-ui/react-dom"),Ke=require("react-dnd"),te=require("./useAllBlocks-6hvuNuyw.cjs"),Ye=require("@react-hookz/web"),Ve=require("@bobthered/tailwindcss-palette-generator"),Xe=require("react-wrap-balancer"),Ze=require("tailwind-merge"),Z=require("./MODIFIERS-Fx6WAZcw.cjs"),Ce=require("./index-HAue58ea.cjs"),Te=require("./useChaiExternalData-DkyBJ81C.cjs"),ye=require("react-dom");require("@radix-ui/react-slot");require("class-variance-authority");require("./utils-qK_SjzzV.cjs");require("clsx");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("@radix-ui/react-scroll-area");require("i18next");require("flagged");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");require("flat-to-nested");require("./functions-uw7QP2kT.cjs");require("redux-undo");require("@radix-ui/react-separator");require("@radix-ui/react-switch");require("@radix-ui/react-hover-card");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-label");require("@radix-ui/react-alert-dialog");const Ge=()=>x.useMemo(()=>Ce.A(),[]),Je=({children:n})=>{const[,t]=Te.useChaiExternalData(),[s]=h.usePageDataProviders(),a=Ge();return x.useEffect(()=>(t({}),u.each(s,l=>{const r=u.find(a,{providerKey:l.providerKey});if(r){const i=(r==null?void 0:r.mockFn)||(r==null?void 0:r.dataFn);i&&i(l.args).then(d=>t(v=>({...v,[l.providerKey]:d})))}}),()=>{u.each(s,l=>{t(r=>(delete r[l.providerKey],r))})}),[a,s,t]),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:n})},Qe=()=>{const{undoCount:n,redoCount:t,undo:s,redo:a}=h.useCanvasHistory();return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(K.Button,{disabled:!n,size:"sm",onClick:s,className:"rounded-full",variant:"ghost",children:e.jsxRuntimeExports.jsx(M.ResetIcon,{})}),e.jsxRuntimeExports.jsx(K.Button,{disabled:!t,onClick:a,size:"sm",className:"rounded-full",variant:"ghost",children:e.jsxRuntimeExports.jsx(M.ResetIcon,{className:"rotate-180 scale-y-[-1] transform"})})]})};function et(){const[n,t]=G.useDarkMode(),{t:s}=Se.useTranslation();return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(He.Label,{htmlFor:"dark-mode-switch",children:s("dark_mode")}),e.jsxRuntimeExports.jsxs(L.Switch,{id:"dark-mode-switch",checked:n,onCheckedChange:()=>{t(!n)},className:`${n?"bg-violet-600":"bg-violet-300"}
2
+ 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:[e.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Use setting"}),e.jsxRuntimeExports.jsx("span",{"aria-hidden":"true",className:`${n?"translate-x-5":"translate-x-0"}
3
+ 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`})]})]})}const ge=({landscape:n=!1})=>e.jsxRuntimeExports.jsxs("svg",{className:n?"rotate-90":"",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 13 13",xmlSpace:"preserve",width:13,height:13,children:[e.jsxRuntimeExports.jsx("g",{strokeWidth:0}),e.jsxRuntimeExports.jsx("g",{strokeLinecap:"round",strokeLinejoin:"round"}),e.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"}})]}),ve=[{title:"Mobile (XS)",content:"Styles set here are applied to all screen unless edited at higher breakpoint",breakpoint:"xs",icon:e.jsxRuntimeExports.jsx(M.MobileIcon,{}),width:400},{title:"Mobile landscape (SM)",content:"Styles set here are applied at 640px and up unless edited at higher breakpoint",breakpoint:"sm",icon:e.jsxRuntimeExports.jsx(M.MobileIcon,{className:"rotate-90"}),width:640},{title:"Tablet (MD)",content:"Styles set here are applied at 768px and up",breakpoint:"md",icon:e.jsxRuntimeExports.jsx(ge,{}),width:800},{title:"Tablet Landscape (LG)",content:"Styles set here are applied at 1024px and up unless edited at higher breakpoint",breakpoint:"lg",icon:e.jsxRuntimeExports.jsx(ge,{landscape:!0}),width:1024},{title:"Desktop (XL)",content:"Styles set here are applied at 1280px and up unless edited at higher breakpoint",breakpoint:"xl",icon:e.jsxRuntimeExports.jsx(M.LaptopIcon,{}),width:1420},{title:"Large Desktop (2XL)",content:"Styles set here are applied at 1536px and up",breakpoint:"2xl",icon:e.jsxRuntimeExports.jsx(M.DesktopIcon,{}),width:1920}],tt=({title:n,content:t,currentBreakpoint:s,breakpoint:a,width:l,icon:r,onClick:i})=>e.jsxRuntimeExports.jsxs(L.HoverCard,{children:[e.jsxRuntimeExports.jsx(L.HoverCardTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(K.Button,{onClick:()=>i(l),size:"sm",variant:a===s?"secondary":"ghost",children:r})}),e.jsxRuntimeExports.jsx(L.HoverCardContent,{className:"w-52 border-border",children:e.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx("h4",{className:"text-sm font-semibold",children:n}),e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:t})]})})})]}),nt=()=>{const[,n,t]=G.useCanvasWidth(),[s,a]=ee.useSelectedBreakpoints(),l=r=>{s.includes(r)?s.length>2&&a(s.filter(i=>i!==r)):a(i=>[...i,r])};return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center rounded-md",children:[u.map(ve.filter(r=>u.includes(s,u.toUpper(r.breakpoint))),r=>x.createElement(tt,{...r,onClick:t,key:r.breakpoint,currentBreakpoint:n})),e.jsxRuntimeExports.jsxs(L.DropdownMenu,{children:[e.jsxRuntimeExports.jsx(L.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx("span",{className:"cursor-pointer px-2.5 hover:opacity-80",children:e.jsxRuntimeExports.jsx(M.DotsVerticalIcon,{className:"scale-90 transform"})})}),e.jsxRuntimeExports.jsxs(L.DropdownMenuContent,{className:"w-56 border-border text-xs",children:[e.jsxRuntimeExports.jsx(L.DropdownMenuLabel,{children:"Breakpoints"}),e.jsxRuntimeExports.jsx(L.DropdownMenuSeparator,{}),u.map(ve,r=>e.jsxRuntimeExports.jsx(L.DropdownMenuCheckboxItem,{disabled:r.breakpoint==="xs",onCheckedChange:()=>l(u.toUpper(r.breakpoint)),checked:u.includes(s,u.toUpper(r.breakpoint)),children:r.title},r.breakpoint))]})]})]})},st=()=>{const[n]=h.useSetAllBlocks(),{createSnapshot:t}=h.useCanvasHistory(),[,s]=h.useSelectedBlockIds(),[,a]=h.useSelectedStylingBlocks(),l=x.useCallback(()=>{n([]),s([]),a([]),t()},[n,t]);return e.jsxRuntimeExports.jsx("div",{className:"flex items-center",children:e.jsxRuntimeExports.jsxs($.AlertDialog,{children:[e.jsxRuntimeExports.jsx($.AlertDialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(K.Button,{size:"sm",variant:"ghost",className:"flex items-center gap-x-1",children:[e.jsxRuntimeExports.jsx(M.EraserIcon,{})," Clear"]})}),e.jsxRuntimeExports.jsxs($.AlertDialogContent,{className:"border-border",children:[e.jsxRuntimeExports.jsxs($.AlertDialogHeader,{children:[e.jsxRuntimeExports.jsx($.AlertDialogTitle,{children:"Clear whole canvas?"}),e.jsxRuntimeExports.jsx($.AlertDialogDescription,{children:"Are you sure you want to clear the whole canvas?"})]}),e.jsxRuntimeExports.jsxs($.AlertDialogFooter,{children:[e.jsxRuntimeExports.jsx($.AlertDialogCancel,{children:"Cancel"}),e.jsxRuntimeExports.jsx($.AlertDialogAction,{onClick:l,children:"Yes"})]})]})]})})},rt=()=>{const n=ee.useFeatureSupport("darkMode",!1),[t]=ee.useCanvasZoom();return e.jsxRuntimeExports.jsxs("div",{className:"flex h-10 items-center justify-between border-b bg-background/70 px-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex h-full space-x-2",children:[n?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(et,{}),e.jsxRuntimeExports.jsx(Q.Separator,{orientation:"vertical"})]}):null,e.jsxRuntimeExports.jsx(nt,{}),e.jsxRuntimeExports.jsx(Q.Separator,{orientation:"vertical"}),e.jsxRuntimeExports.jsxs("div",{className:"flex w-12 items-center justify-center gap-x-1 space-x-0 font-medium",children:[e.jsxRuntimeExports.jsx(M.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",e.jsxRuntimeExports.jsxs("div",{className:"text-xs leading-3",children:[u.round(t,0),"%"]})]}),e.jsxRuntimeExports.jsx(Q.Separator,{orientation:"vertical"}),e.jsxRuntimeExports.jsx(Qe,{})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex h-full items-center space-x-2",children:[e.jsxRuntimeExports.jsx(Q.Separator,{orientation:"vertical"}),e.jsxRuntimeExports.jsx(st,{})]})]})},ot=`<!doctype html>
4
+ <html class="scroll-smooth h-full overflow-y-auto">
5
+ <head>
6
+ <meta charset="UTF-8">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
+ <script src="https://old.chaibuilder.com/offline/tailwind.cdn.js"><\/script>
9
+ <style>
10
+ html { height: 100%; overflow:auto; }
11
+ body { height: 100%; }
12
+ .air-highlight{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}
13
+ .air-highlight-multi{ outline: 1px solid #29e503 !important; outline-offset: -1px;}
14
+ body{ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none;
15
+ -moz-user-select: none;-ms-user-select: none; user-select: none; }
16
+ html{
17
+ -ms-overflow-style: none; /* IE and Edge */
18
+ scrollbar-width: none; /* Firefox */
19
+ }
20
+ /** IMPORTANT: Make fields content editable in SAFARI */
21
+ [contenteditable] {-webkit-user-select: text;user-select: text;}
22
+
23
+ html::-webkit-scrollbar { width: 0 !important }
24
+ .aspect-auto{aspect-ratio: auto;}
25
+ .aspect-square{aspect-ratio: 1/1;}
26
+ .aspect-video{aspect-ratio: 16/9;}
27
+ a{ pointer-events: none !important; }
28
+ </style>
29
+ <style id="hidden-blocks"></style>
30
+ <style id="selected-block"></style>
31
+ <style id="selected-styling-block"></style>
32
+ <style id="highlighted-block"></style>
33
+ </head>
34
+ <body class="font-body antialiased h-full">
35
+ <div class="frame-root"></div>
36
+ </body>
37
+ </html>`,it=n=>{const[t]=G.useCanvasWidth(),[,s]=ee.useCanvasZoom(),[a,l]=x.useState({}),r=x.useCallback(()=>{const{width:i,height:d}=n;if(i<t){const v=parseFloat((i/t).toString());let R={};d&&(R={height:d+2*d*(1-v)}),l({transform:`scale(${v})`,transformOrigin:"top left",...R,maxWidth:"none"}),s(v*100)}else l({}),s(100)},[t,n,s]);return x.useEffect(()=>{r()},[t,n,s,r]),a};var ue={exports:{}};/*
38
+ object-assign
39
+ (c) Sindre Sorhus
40
+ @license MIT
41
+ */var re,je;function at(){if(je)return re;je=1;var n=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function a(r){if(r==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(r)}function l(){try{if(!Object.assign)return!1;var r=new String("abc");if(r[5]="de",Object.getOwnPropertyNames(r)[0]==="5")return!1;for(var i={},d=0;d<10;d++)i["_"+String.fromCharCode(d)]=d;var v=Object.getOwnPropertyNames(i).map(function(f){return i[f]});if(v.join("")!=="0123456789")return!1;var R={};return"abcdefghijklmnopqrst".split("").forEach(function(f){R[f]=f}),Object.keys(Object.assign({},R)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return re=l()?Object.assign:function(r,i){for(var d,v=a(r),R,f=1;f<arguments.length;f++){d=Object(arguments[f]);for(var p in d)t.call(d,p)&&(v[p]=d[p]);if(n){R=n(d);for(var g=0;g<R.length;g++)s.call(d,R[g])&&(v[R[g]]=d[R[g]])}}return v},re}var oe,Ee;function fe(){if(Ee)return oe;Ee=1;var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return oe=n,oe}var ie,be;function Ie(){return be||(be=1,ie=Function.call.bind(Object.prototype.hasOwnProperty)),ie}var ae,Re;function ct(){if(Re)return ae;Re=1;var n=function(){};if(process.env.NODE_ENV!=="production"){var t=fe(),s={},a=Ie();n=function(r){var i="Warning: "+r;typeof console<"u"&&console.error(i);try{throw new Error(i)}catch{}}}function l(r,i,d,v,R){if(process.env.NODE_ENV!=="production"){for(var f in r)if(a(r,f)){var p;try{if(typeof r[f]!="function"){var g=Error((v||"React class")+": "+d+" type `"+f+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[f]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw g.name="Invariant Violation",g}p=r[f](i,f,v,d,null,t)}catch(O){p=O}if(p&&!(p instanceof Error)&&n((v||"React class")+": type specification of "+d+" `"+f+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof p+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),p instanceof Error&&!(p.message in s)){s[p.message]=!0;var S=R?R():"";n("Failed "+d+" type: "+p.message+(S??""))}}}}return l.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(s={})},ae=l,ae}var ce,ke;function lt(){if(ke)return ce;ke=1;var n=h.reactIsExports,t=at(),s=fe(),a=Ie(),l=ct(),r=function(){};process.env.NODE_ENV!=="production"&&(r=function(d){var v="Warning: "+d;typeof console<"u"&&console.error(v);try{throw new Error(v)}catch{}});function i(){return null}return ce=function(d,v){var R=typeof Symbol=="function"&&Symbol.iterator,f="@@iterator";function p(o){var c=o&&(R&&o[R]||o[f]);if(typeof c=="function")return c}var g="<<anonymous>>",S={array:m("array"),bigint:m("bigint"),bool:m("boolean"),func:m("function"),number:m("number"),object:m("object"),string:m("string"),symbol:m("symbol"),any:U(),arrayOf:N,element:ne(),elementType:se(),instanceOf:A,node:Me(),objectOf:W,oneOf:F,oneOfType:qe,shape:_e,exact:Ne};function O(o,c){return o===c?o!==0||1/o===1/c:o!==o&&c!==c}function w(o,c){this.message=o,this.data=c&&typeof c=="object"?c:{},this.stack=""}w.prototype=Error.prototype;function D(o){if(process.env.NODE_ENV!=="production")var c={},k=0;function E(C,j,b,T,B,I,_){if(T=T||g,I=I||b,_!==s){if(v){var P=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw P.name="Invariant Violation",P}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Y=T+":"+b;!c[Y]&&k<3&&(r("You are manually calling a React.PropTypes validation function for the `"+I+"` prop on `"+T+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),c[Y]=!0,k++)}}return j[b]==null?C?j[b]===null?new w("The "+B+" `"+I+"` is marked as required "+("in `"+T+"`, but its value is `null`.")):new w("The "+B+" `"+I+"` is marked as required in "+("`"+T+"`, but its value is `undefined`.")):null:o(j,b,T,B,I)}var y=E.bind(null,!1);return y.isRequired=E.bind(null,!0),y}function m(o){function c(k,E,y,C,j,b){var T=k[E],B=H(T);if(B!==o){var I=V(T);return new w("Invalid "+C+" `"+j+"` of type "+("`"+I+"` supplied to `"+y+"`, expected ")+("`"+o+"`."),{expectedType:o})}return null}return D(c)}function U(){return D(i)}function N(o){function c(k,E,y,C,j){if(typeof o!="function")return new w("Property `"+j+"` of component `"+y+"` has invalid PropType notation inside arrayOf.");var b=k[E];if(!Array.isArray(b)){var T=H(b);return new w("Invalid "+C+" `"+j+"` of type "+("`"+T+"` supplied to `"+y+"`, expected an array."))}for(var B=0;B<b.length;B++){var I=o(b,B,y,C,j+"["+B+"]",s);if(I instanceof Error)return I}return null}return D(c)}function ne(){function o(c,k,E,y,C){var j=c[k];if(!d(j)){var b=H(j);return new w("Invalid "+y+" `"+C+"` of type "+("`"+b+"` supplied to `"+E+"`, expected a single ReactElement."))}return null}return D(o)}function se(){function o(c,k,E,y,C){var j=c[k];if(!n.isValidElementType(j)){var b=H(j);return new w("Invalid "+y+" `"+C+"` of type "+("`"+b+"` supplied to `"+E+"`, expected a single ReactElement type."))}return null}return D(o)}function A(o){function c(k,E,y,C,j){if(!(k[E]instanceof o)){var b=o.name||g,T=We(k[E]);return new w("Invalid "+C+" `"+j+"` of type "+("`"+T+"` supplied to `"+y+"`, expected ")+("instance of `"+b+"`."))}return null}return D(c)}function F(o){if(!Array.isArray(o))return process.env.NODE_ENV!=="production"&&(arguments.length>1?r("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):r("Invalid argument supplied to oneOf, expected an array.")),i;function c(k,E,y,C,j){for(var b=k[E],T=0;T<o.length;T++)if(O(b,o[T]))return null;var B=JSON.stringify(o,function(_,P){var Y=V(P);return Y==="symbol"?String(P):P});return new w("Invalid "+C+" `"+j+"` of value `"+String(b)+"` "+("supplied to `"+y+"`, expected one of "+B+"."))}return D(c)}function W(o){function c(k,E,y,C,j){if(typeof o!="function")return new w("Property `"+j+"` of component `"+y+"` has invalid PropType notation inside objectOf.");var b=k[E],T=H(b);if(T!=="object")return new w("Invalid "+C+" `"+j+"` of type "+("`"+T+"` supplied to `"+y+"`, expected an object."));for(var B in b)if(a(b,B)){var I=o(b,B,y,C,j+"."+B,s);if(I instanceof Error)return I}return null}return D(c)}function qe(o){if(!Array.isArray(o))return process.env.NODE_ENV!=="production"&&r("Invalid argument supplied to oneOfType, expected an instance of array."),i;for(var c=0;c<o.length;c++){var k=o[c];if(typeof k!="function")return r("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+Fe(k)+" at index "+c+"."),i}function E(y,C,j,b,T){for(var B=[],I=0;I<o.length;I++){var _=o[I],P=_(y,C,j,b,T,s);if(P==null)return null;P.data&&a(P.data,"expectedType")&&B.push(P.data.expectedType)}var Y=B.length>0?", expected one of type ["+B.join(", ")+"]":"";return new w("Invalid "+b+" `"+T+"` supplied to "+("`"+j+"`"+Y+"."))}return D(E)}function Me(){function o(c,k,E,y,C){return J(c[k])?null:new w("Invalid "+y+" `"+C+"` supplied to "+("`"+E+"`, expected a ReactNode."))}return D(o)}function he(o,c,k,E,y){return new w((o||"React class")+": "+c+" type `"+k+"."+E+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+y+"`.")}function _e(o){function c(k,E,y,C,j){var b=k[E],T=H(b);if(T!=="object")return new w("Invalid "+C+" `"+j+"` of type `"+T+"` "+("supplied to `"+y+"`, expected `object`."));for(var B in o){var I=o[B];if(typeof I!="function")return he(y,C,j,B,V(I));var _=I(b,B,y,C,j+"."+B,s);if(_)return _}return null}return D(c)}function Ne(o){function c(k,E,y,C,j){var b=k[E],T=H(b);if(T!=="object")return new w("Invalid "+C+" `"+j+"` of type `"+T+"` "+("supplied to `"+y+"`, expected `object`."));var B=t({},k[E],o);for(var I in B){var _=o[I];if(a(o,I)&&typeof _!="function")return he(y,C,j,I,V(_));if(!_)return new w("Invalid "+C+" `"+j+"` key `"+I+"` supplied to `"+y+"`.\nBad object: "+JSON.stringify(k[E],null," ")+`
42
+ Valid keys: `+JSON.stringify(Object.keys(o),null," "));var P=_(b,I,y,C,j+"."+I,s);if(P)return P}return null}return D(c)}function J(o){switch(typeof o){case"number":case"string":case"undefined":return!0;case"boolean":return!o;case"object":if(Array.isArray(o))return o.every(J);if(o===null||d(o))return!0;var c=p(o);if(c){var k=c.call(o),E;if(c!==o.entries){for(;!(E=k.next()).done;)if(!J(E.value))return!1}else for(;!(E=k.next()).done;){var y=E.value;if(y&&!J(y[1]))return!1}}else return!1;return!0;default:return!1}}function Le(o,c){return o==="symbol"?!0:c?c["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&c instanceof Symbol:!1}function H(o){var c=typeof o;return Array.isArray(o)?"array":o instanceof RegExp?"object":Le(c,o)?"symbol":c}function V(o){if(typeof o>"u"||o===null)return""+o;var c=H(o);if(c==="object"){if(o instanceof Date)return"date";if(o instanceof RegExp)return"regexp"}return c}function Fe(o){var c=V(o);switch(c){case"array":case"object":return"an "+c;case"boolean":case"date":case"regexp":return"a "+c;default:return c}}function We(o){return!o.constructor||!o.constructor.name?g:o.constructor.name}return S.checkPropTypes=l,S.resetWarningCache=l.resetWarningCache,S.PropTypes=S,S},ce}var le,we;function ut(){if(we)return le;we=1;var n=fe();function t(){}function s(){}return s.resetWarningCache=t,le=function(){function a(i,d,v,R,f,p){if(p!==n){var g=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw g.name="Invariant Violation",g}}a.isRequired=a;function l(){return a}var r={array:a,bigint:a,bool:a,func:a,number:a,object:a,string:a,symbol:a,any:a,arrayOf:l,element:a,elementType:a,instanceOf:l,node:a,objectOf:l,oneOf:l,oneOfType:l,shape:l,exact:l,checkPropTypes:s,resetWarningCache:t};return r.PropTypes=r,r},le}if(process.env.NODE_ENV!=="production"){var dt=h.reactIsExports,pt=!0;ue.exports=lt()(dt.isElement,pt)}else ue.exports=ut()();var ft=ue.exports;const q=Z.getDefaultExportFromCjs(ft);let De,Be;typeof document<"u"&&(De=document);typeof window<"u"&&(Be=window);const Oe=x.createContext({document:De,window:Be}),xe=()=>x.useContext(Oe),{Provider:xt,Consumer:At}=Oe;class Ae extends x.Component{componentDidMount(){this.props.contentDidMount()}componentDidUpdate(){this.props.contentDidUpdate()}render(){return x.Children.only(this.props.children)}}z(Ae,"propTypes",{children:q.element.isRequired,contentDidMount:q.func.isRequired,contentDidUpdate:q.func.isRequired});class de extends x.Component{constructor(s,a){super(s,a);z(this,"setRef",s=>{this.nodeRef.current=s;const{forwardedRef:a}=this.props;typeof a=="function"?a(s):a&&(a.current=s)});z(this,"handleLoad",()=>{clearInterval(this.loadCheck),this.state.iframeLoaded||this.setState({iframeLoaded:!0})});z(this,"loadCheck",()=>setInterval(()=>{this.handleLoad()},500));this._isMounted=!1,this.nodeRef=x.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 s=this.getDoc();return this.props.mountTarget?s.querySelector(this.props.mountTarget):s.body.children[0]}renderFrameContents(){if(!this._isMounted)return null;const s=this.getDoc();if(!s)return null;const a=this.props.contentDidMount,l=this.props.contentDidUpdate,r=s.defaultView||s.parentView,i=e.jsxRuntimeExports.jsx(Ae,{contentDidMount:a,contentDidUpdate:l,children:e.jsxRuntimeExports.jsx(xt,{value:{document:s,window:r},children:e.jsxRuntimeExports.jsx("div",{className:"frame-content",children:this.props.children})})}),d=this.getMountTarget();return[ye.createPortal(this.props.head,this.getDoc().head),ye.createPortal(i,d)]}render(){const s={...this.props,srcDoc:this.props.initialContent,children:void 0};return delete s.head,delete s.initialContent,delete s.mountTarget,delete s.contentDidMount,delete s.contentDidUpdate,delete s.forwardedRef,e.jsxRuntimeExports.jsx("iframe",{...s,ref:this.setRef,onLoad:this.handleLoad,children:this.state.iframeLoaded&&this.renderFrameContents()})}}z(de,"propTypes",{style:q.object,head:q.node,initialContent:q.string,mountTarget:q.string,contentDidMount:q.func,contentDidUpdate:q.func,children:q.oneOfType([q.element,q.arrayOf(q.element)])}),z(de,"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 ht=x.forwardRef((n,t)=>e.jsxRuntimeExports.jsx(de,{...n,forwardedRef:t})),mt=({children:n})=>{const{document:t}=xe(),[s]=h.useSelectedBlockIds(),[a,l]=h.useSelectedStylingBlocks();return x.useEffect(()=>{setTimeout(()=>{if(!u.isEmpty(a))return;const r=Pe(t,u.first(s));if(r){const i=r.getAttribute("data-style-prop");if(i){const d=r.getAttribute("data-style-id"),v=r.getAttribute("data-block-parent");l([{id:d,prop:i,blockId:v}])}}},100)},[t,s,l,a]),e.jsxRuntimeExports.jsx("div",{id:"canvas",className:"relative h-screen max-w-full outline-2",children:n})},Pe=(n,t)=>n.querySelector(`[data-block-id="${t}"]`),yt=()=>{const{window:n}=xe(),[t,s]=h.useSelectedBlockIds(),[,a]=h.useSelectedStylingBlocks(),{undo:l,redo:r}=h.useCanvasHistory(),i=h.useDuplicateBlocks(),[,d]=h.useCutBlockIds(),[,v]=h.useCopyBlockIds(),{pasteBlocks:R}=h.usePasteBlocks(),[,f]=h.usePreviewMode(),p=h.useRemoveBlocks(),{savePage:g}=h.useSavePage(),[S]=X.useAtom(h.inlineEditingActiveAtom),[,O]=X.useAtom(h.editLayerNameAtom),w=D=>{D.key==="Enter"&&(D.preventDefault(),t.length===1&&O(u.first(t)))};return x.useEffect(()=>{const D=m=>{if(m.key==="Escape"){s([]),a([]);return}if(w(m),!S&&(m.key==="Delete"||m.key==="Backspace")&&(m.preventDefault(),p(t)),m.ctrlKey||m.metaKey){if(["z","y","d","x","c","p","s","v"].includes(m.key)){if(S&&["x","z","v"].includes(m.key))return!0;m.preventDefault()}m.key==="s"&&(m.stopPropagation(),m.preventDefault(),g()),m.key==="z"&&l(),m.key==="y"&&r(),m.key==="d"&&i(t),m.key==="x"&&d(t),m.key==="c"&&v(t),m.key==="v"&&t.length>0&&R(t[0])}};return n.removeEventListener("keydown",D),n.addEventListener("keydown",D),()=>{n.removeEventListener("keydown",D)}},[t,s,l,p,f,r,i,d,v,R,S,g,n]),null},gt=({block:n,label:t})=>{const[,s]=Ke.useDrag(()=>({type:"CANVAS_BLOCK",item:n}));return e.jsxRuntimeExports.jsxs("div",{className:"mr-10 flex cursor-grab items-center space-x-1 px-1",ref:s,onDragStart:()=>{console.log("drag start")},children:[e.jsxRuntimeExports.jsx(M.DragHandleDots2Icon,{}),t]})},vt=({selectedBlockElement:n,block:t})=>{const s=h.useRemoveBlocks(),a=h.useDuplicateBlocks(),[,l]=h.useSelectedBlockIds(),[,r]=h.useSelectedStylingBlocks(),{floatingStyles:i,refs:d,update:v}=me.useFloating({placement:"top-start",middleware:[me.shift(),ze.flip()],elements:{reference:n}});Ye.useResizeObserver(n,()=>v(),n!==null);const R=u.get(t,"_parent",null),f=u.isEmpty(u.get(t,"_name",""))?u.get(t,"_type",""):u.get(t,"_name","");return!n||!t?null:e.jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,ref:d.setFloating,style:i,onClick:p=>{p.stopPropagation(),p.preventDefault()},onKeyDown:p=>p.stopPropagation(),className:"z-50 flex h-6 items-center bg-blue-500 py-2 text-xs text-white",children:[e.jsxRuntimeExports.jsx(gt,{label:f,block:t}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 px-1 ",children:[R&&e.jsxRuntimeExports.jsx(M.ArrowUpIcon,{className:"hover:scale-105 ",onClick:()=>{r([]),l([R])}}),te.canDuplicateBlock(u.get(t,"_type",""))?e.jsxRuntimeExports.jsx(M.CopyIcon,{className:"hover:scale-105 ",onClick:()=>a([t==null?void 0:t._id])}):null,te.canDeleteBlock(u.get(t,"_type",""))?e.jsxRuntimeExports.jsx(M.TrashIcon,{className:"hover:scale-105 ",onClick:()=>s([t==null?void 0:t._id])}):null]})]})},jt=({model:n})=>{const[t]=h.useBrandingOptions(),[s]=h.useSelectedBlockIds(),[a]=G.useDarkMode(),[l]=h.useHighlightBlockId(),[r]=h.useSelectedStylingBlocks(),{document:i,window:d}=xe(),[v]=x.useState(i==null?void 0:i.getElementById("highlighted-block")),[R]=x.useState(i==null?void 0:i.getElementById("selected-block")),[f]=x.useState(i==null?void 0:i.getElementById("selected-styling-block"));x.useEffect(()=>{a?i==null||i.documentElement.classList.add("dark"):i==null||i.documentElement.classList.remove("dark")},[a,i]);const p=u.get(t,"headingFont","DM Sans"),g=u.get(t,"bodyFont","DM Sans");return x.useEffect(()=>{const S=u.get(t,"primaryColor","#000"),O=u.get(t,"secondaryColor","#FFF"),w=Ve.tailwindcssPaletteGenerator({colors:[S,O],names:["primary","secondary"]});w.primary.DEFAULT=S,w.secondary.DEFAULT=O;const D=u.get(t,"roundedCorners","0");!d||!d.tailwind||(d.tailwind.config={darkMode:"class",theme:{fontFamily:{heading:[p],body:[g]},extend:{borderRadius:{global:`${D||"0"}px`},colors:w}},plugins:[d.tailwind.plugin.withOptions(({prefix:m="ui"}={})=>({addVariant:U})=>{for(const N of["open","checked","selected","active","disabled"])U(`${m}-${N}`,[`&[data-headlessui-state~="${N}"]`,`:where([data-headlessui-state~="${N}"]) &`]),U(`${m}-not-${N}`,[`&[data-headlessui-state]:not([data-headlessui-state~="${N}"])`,`:where([data-headlessui-state]:not([data-headlessui-state~="${N}"])) &:not([data-headlessui-state])`])})]})},[t,d,p,g]),x.useEffect(()=>{R&&(R.textContent=`${u.map(s,S=>`[data-block-id="${S}"]`).join(",")}{
43
+ outline: 1px solid ${s.length===1?"#42a1fc":"orange"} !important; outline-offset: -1px;
44
+ }`)},[s,R]),x.useEffect(()=>{v&&(v.textContent=l?`[data-style-id="${l}"]{ outline: 1px solid orange !important; outline-offset: -1px;}`:"")},[l,s,v]),x.useEffect(()=>{f&&(f.textContent=`${u.map(r,({id:S})=>`[data-style-id="${S}"]`).join(",")}{
45
+ outline: 1px solid orange !important; outline-offset: -1px;
46
+ }`)},[r,f]),x.useEffect(()=>{if(n==="section")return;const S=u.get(t,"bodyTextLightColor","#64748b"),O=u.get(t,"bodyTextDarkColor","#94a3b8"),w=u.get(t,"bodyBgLightColor","#FFFFFF"),D=u.get(t,"bodyBgDarkColor","#0f172a");i.body.className=`font-body antialiased text-[${S}] bg-[${w}] dark:text-[${O}] dark:bg-[${D}]`},[t,i,n]),n==="page"?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[p&&e.jsxRuntimeExports.jsx("link",{id:"heading-font",rel:"stylesheet",type:"text/css",href:`https://fonts.googleapis.com/css2?family=${p.replace(/ /g,"+")}:wght@300;400;500;600;700;800;900&display=swap`,media:"all"}),g&&p!==g&&e.jsxRuntimeExports.jsx("link",{id:"body-font",rel:"stylesheet",type:"text/css",href:`https://fonts.googleapis.com/css2?family=${g.replace(/ /g,"+")}:wght@300;400;500;600;700;800;900&display=swap`,media:"all"}),p&&e.jsxRuntimeExports.jsx("style",{children:`h1,h2,h3,h4,h5,h6{font-family: "${p}",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},Et=()=>{const{t:n}=Se.useTranslation();return e.jsxRuntimeExports.jsx("div",{className:"my-auto py-24 text-center text-gray-600 dark:text-white",children:e.jsxRuntimeExports.jsx("h1",{className:"mb-10 text-4xl ",children:n("canvas_empty")})})},bt=n=>{const t={};return Object.keys(n).forEach(s=>{u.isString(n[s])&&n[s].startsWith(Z.SLOT_KEY)&&(t[s]=n[s].replace(Z.SLOT_KEY,"").split(","))}),t},Rt=u.memoize(n=>{const t=n.replace(Z.STYLES_KEY,"").split(",");return Ze.twMerge(t[0],t[1])});function kt(n,t){return u.get(n,`${t}_attrs`,{})}function wt(n,t,s,a){const l={};return Object.keys(n).forEach(r=>{if(u.isString(n[r])&&n[r].startsWith(Z.STYLES_KEY)){const i=Rt(n[r]);l[r]={className:i,"data-style-prop":r,"data-block-parent":n._id,"data-style-id":`${r}-${n._id}`,onMouseEnter:t,onMouseLeave:s,onClick:a,...kt(n,r)}}}),l}function St(n,t){const s=u.get(n,"_bindings",{});return u.isEmpty(s)?{...n}:(u.each(s,(a,l)=>{u.isString(a)&&u.get(t,a,null)&&(n[l]=u.get(t,a,null))}),n)}function pe({blocks:n}){const t=te.useAllBlocks(),[,s]=h.useHighlightBlockId(),[,a]=h.useSelectedStylingBlocks(),[,l]=h.useSelectedBlockIds(),r=x.useCallback(f=>{var g;const p=(g=f.currentTarget)==null?void 0:g.getAttribute("data-style-id");s(p||""),f.stopPropagation()},[s]),i=x.useCallback(f=>{s(""),f.stopPropagation()},[s]),d=x.useCallback(f=>{f.stopPropagation();const p=f.currentTarget;if(p.getAttribute("data-block-parent")){const g=p.getAttribute("data-style-prop"),S=p.getAttribute("data-style-id"),O=p.getAttribute("data-block-parent");a([{id:S,prop:g,blockId:O}]),l([O])}else if(p.getAttribute("data-block-id")&&(l([p.getAttribute("data-block-id")]),p.getAttribute("data-block-parent"))){const g=p.getAttribute("data-style-prop"),S=p.getAttribute("data-style-id"),O=p.getAttribute("data-block-parent");a([{id:S,prop:g,blockId:O}])}},[a,l]),v=x.useCallback(f=>wt(f,r,i,d),[d,r,i]),[R]=Te.useChaiExternalData();return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:x.Children.toArray(n.map((f,p)=>{const g=bt(f),S={};u.isEmpty(g)||Object.keys(g).forEach(m=>{S[m]=x.Children.toArray(g[m].map(U=>e.jsxRuntimeExports.jsx(pe,{blocks:[u.find(t,{_id:U})]})))});const O=u.filter(t,{_parent:f._id});S.children=O.length?e.jsxRuntimeExports.jsx(pe,{blocks:O}):null;const w=Ce.h(f._type),D=u.get(w,"component",null);return u.isNull(D)?e.jsxRuntimeExports.jsx("noscript",{children:`<!-- ${f==null?void 0:f._type} not registered -->`}):e.jsxRuntimeExports.jsx(x.Suspense,{children:x.createElement(D,{blockProps:{onClick:d,"data-block-id":f._id,"data-block-type":f._type},inBuilder:!0,index:p,...St(f,R),...v(f),...S})})}))})}const Ct=()=>{const n=te.useAllBlocks();return e.jsxRuntimeExports.jsx(Xe.Provider,{children:u.isEmpty(n)?e.jsxRuntimeExports.jsx(Et,{}):e.jsxRuntimeExports.jsx(Je,{children:e.jsxRuntimeExports.jsx(pe,{blocks:u.filter(n,t=>u.isEmpty(t._parent))})})})},Tt=(n,t)=>n.querySelector(`[data-style-id="${t}"]`),It=()=>{const[n]=X.useAtom(h.networkModeAtom),[t]=h.usePreviewMode(),[s]=G.useCanvasWidth(),[,a]=h.useSelectedBlockIds(),l=h.useSelectedBlock(),[,r]=h.useHighlightBlockId(),i=x.useRef(null),d=x.useRef(null),[v,R]=x.useState({width:0,height:0}),f=it(v),[p,g]=x.useState(0),[S,O]=x.useState([]),[,w]=x.useState([]),[,D]=X.useAtom(h.canvasIframeAtom),[m,U]=h.useSelectedStylingBlocks(),N=K.useBuilderProp("loadingCanvas",!1);x.useEffect(()=>{const{clientWidth:A,clientHeight:F}=d.current;R({width:A,height:F}),p===0&&g(A)},[d,s,p]);const ne=(A,F=0)=>{const{top:W}=A.getBoundingClientRect();return W+F>=0&&W-F<=window.innerHeight};x.useEffect(()=>{var A,F;if(l&&l.type!=="Multiple"&&i.current){const W=Pe(i.current.contentDocument,l._id);W&&(ne(W)||(F=(A=i.current)==null?void 0:A.contentWindow)==null||F.scrollTo({top:W.offsetTop,behavior:"smooth"}),O([W]))}},[l]),x.useEffect(()=>{if(!u.isEmpty(m)&&i.current){const A=Tt(i.current.contentDocument,u.first(m).id);w(A?[A]:[null])}else w([null])},[m]);const se=x.useMemo(()=>{let A=ot;return n==="offline"&&(A=A.replace("https://old.chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js"),A=A.replace("https://unpkg.com/aos@next/dist/aos.css","/offline/aos.css"),A=A.replace("https://unpkg.com/aos@next/dist/aos.js","/offline/aos.js")),A},[n]);return e.jsxRuntimeExports.jsx("div",{onClick:()=>{a([]),U([])},onMouseLeave:()=>setTimeout(()=>r(""),300),className:"relative mx-auto h-full w-full",style:p>0&&!u.isEmpty(f)?{width:t?"100%":p}:{},ref:d,children:e.jsxRuntimeExports.jsxs(ht,{contentDidMount:()=>D(i.current),ref:i,id:"canvas-iframe",style:{width:`${s}px`,...f},className:"relative mx-auto box-content h-full max-w-full shadow-md transition-all duration-300 ease-linear",initialContent:se,children:[e.jsxRuntimeExports.jsx(yt,{}),e.jsxRuntimeExports.jsx(vt,{block:l,selectedBlockElement:u.first(S)}),e.jsxRuntimeExports.jsx(jt,{model:"page"}),e.jsxRuntimeExports.jsxs(mt,{children:[N?e.jsxRuntimeExports.jsx("div",{className:"h-full p-4",children:e.jsxRuntimeExports.jsx(K.Skeleton,{className:"h-full"})}):e.jsxRuntimeExports.jsx(Ct,{}),e.jsxRuntimeExports.jsx("div",{className:"h-60"})]})]})})},Dt=x.lazy(()=>Promise.resolve().then(()=>require("./AddBlocks-7ACJv8LW.cjs"))),Bt=()=>{const[n,t]=X.useAtom(h.addBlocksModalAtom);return e.jsxRuntimeExports.jsxs("div",{className:"flex h-full w-full flex-col",children:[e.jsxRuntimeExports.jsx(rt,{}),e.jsxRuntimeExports.jsxs("div",{className:"relative flex-1 overflow-hidden bg-slate-800/80 px-2 bg-[linear-gradient(to_right,#EEE_0.5px,transparent_0.5px),linear-gradient(to_bottom,#EEE_0.5px,transparent_0.5px)] bg-[size:12px_12px]",children:[e.jsxRuntimeExports.jsx(x.Suspense,{fallback:e.jsxRuntimeExports.jsx(K.Skeleton,{className:"h-full"}),children:e.jsxRuntimeExports.jsx(h.ErrorBoundary,{children:e.jsxRuntimeExports.jsx(It,{})})}),n?e.jsxRuntimeExports.jsx("div",{onClick:()=>t(!1),className:"absolute inset-0 z-50 flex items-center bg-black/30 backdrop-blur-sm",children:e.jsxRuntimeExports.jsx("div",{onClick:s=>s.stopPropagation(),className:"mx-auto h-[90%] w-[90%] max-w-3xl rounded-md bg-white p-4 shadow-lg shadow-black/10 xl:w-[65%]",children:e.jsxRuntimeExports.jsx(Dt,{})})}):null]})]})};exports.default=Bt;