@chaibuilder/sdk 2.2.11 → 2.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +1 -1
- package/dist/core.js +7 -1
- package/package.json +1 -1
package/dist/core.cjs
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
outline: 1px solid ${a.length===1?"#42a1fc !important":"orange !important"}; outline-offset: -1px;
|
|
58
58
|
}`)},[a,m]),React.useEffect(()=>{x.textContent=i?`[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}`:""},[i,x]),React.useEffect(()=>{u&&(u.textContent='[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}')},[u]),React.useEffect(()=>{h&&(h.textContent=`${lodashEs.map(l,({id:k})=>`[data-style-id="${k}"]`).join(",")}{
|
|
59
59
|
outline: 1px solid orange !important; outline-offset: -1px;
|
|
60
|
-
}`)},[l,h]),React.useEffect(()=>{c.querySelector("#drop-target-block").innerHTML=d?`[data-block-id="${d}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}`:""},[d,c]);const f=React.useMemo(()=>{const{heading:k,body:S}={heading:lodashEs.get(o,"fontFamily.heading"),body:lodashEs.get(o,"fontFamily.body")};return g.filter(v=>v.family===k||v.family===S)},[o==null?void 0:o.fontFamily,g]),j=React.useMemo(()=>plugin.getThemeFontsLinkMarkup(lodashEs.filter(f,k=>lodashEs.has(k,"url"))),[f]),b=React.useMemo(()=>plugin.getThemeCustomFontFace(lodashEs.filter(f,k=>lodashEs.has(k,"src"))),[f]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(CssThemeVariables,{theme:o}),jsxRuntime.jsx("span",{id:"chai-fonts",dangerouslySetInnerHTML:{__html:j}}),jsxRuntime.jsx("style",{id:"chai-custom-fonts",dangerouslySetInnerHTML:{__html:b}})]})},ResizableCanvasWrapper=({children:o,onMount:n,onResize:a})=>{const[,r]=useSelectedBlockIds(),[,l]=useSelectedStylingBlocks(),i=React.useRef(null),d=web.useDebouncedCallback(()=>{const{clientWidth:p}=i.current;a(p)},[i.current],100);web.useResizeObserver(i.current,d,i.current!==null),React.useEffect(()=>{const{clientWidth:p}=i.current;n(p)},[]);const c=()=>{r([]),l([])};return jsxRuntime.jsx("div",{id:"main-content",onClick:c,className:"h-full w-full p-8 pb-0",ref:i,children:o})},useBlockRuntimeProps=()=>{const[o]=useBlocksStore();return React.useCallback((n,a)=>lodashEs.isEmpty(a)?{}:Object.entries(a).reduce((r,[l,i])=>{const d=[];let c=lodashEs.find(o,{_id:n});for(;c;)d.push(c),c=lodashEs.find(o,{_id:c._parent});const p=lodashEs.find(d,{_type:i.block});return p&&(r[l]=lodashEs.get(p,lodashEs.get(i,"prop"),null)),r},{}),[o])},RepeaterContext=React.createContext({index:-1,key:""}),BlockRenderer=({blockAtom:o,children:n})=>{const[a]=jotai.useAtom(o),r=React.useMemo(()=>runtime.getRegisteredChaiBlock(a._type),[a._type]),{selectedLang:l,fallbackLang:i}=useLanguages(),d=useBlockRuntimeProps(),c=usePageExternalData(),[p]=useHiddenBlockIds(),[u]=jotai.useAtom(dataBindingActiveAtom),m=lodashEs.get(r,"component",null),{index:h,key:x}=React.useContext(RepeaterContext),g=React.useMemo(()=>u?newBlocksRenderHelpers.applyBinding(newBlocksRenderHelpers.applyLanguage(a,l,r),c,{index:h,key:x}):newBlocksRenderHelpers.applyLanguage(a,l,r),[a,l,r,c,u,h,x]),f=React.useMemo(()=>newBlocksRenderHelpers.getBlockTagAttributes(a),[a,newBlocksRenderHelpers.getBlockTagAttributes]),j=React.useMemo(()=>d(a._id,newBlocksRenderHelpers.getBlockRuntimeProps(a._type)),[a._id,a._type,d,newBlocksRenderHelpers.getBlockRuntimeProps]),b=React.useMemo(()=>!lodashEs.has(r,"dataProvider")||!lodashEs.isFunction(r.dataProvider)?{}:r.dataProvider(a,l),[a,l,r]),k=React.useMemo(()=>({blockProps:{"data-block-id":a._id,"data-block-type":a._type},inBuilder:!0,lang:l||i,...g,...f,...j,...b}),[a._id,a._type,l,i,g,f,j,b]);return lodashEs.isNull(m)||p.includes(a._id)?null:jsxRuntime.jsx(React.Suspense,{children:React.createElement(m,{...k,children:n({_id:a._id,_type:a._type,...lodashEs.isArray(g.repeaterItems)?{repeaterItems:newBlocksRenderHelpers.applyLimit(g.repeaterItems,a),repeaterItemsBinding:g.repeaterItemsBinding}:{},...a.partialBlockId?{partialBlockId:a.partialBlockId}:"",...a.globalBlock?{partialBlockId:a.globalBlock}:""})})})},PartialBlocksRenderer=({partialBlockId:o})=>{const{getPartailBlocks:n}=usePartialBlocksStore(),a=React.useMemo(()=>n(o),[n,o]),r=React.useMemo(()=>utils.splitAtom(jotai.atom(a)),[a]);return lodashEs.isEmpty(a)?null:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:r,blocks:a})},BlocksRenderer=({blocks:o,parent:n=null,splitAtoms:a=void 0})=>{const r=useGetBlockAtom(a),l=React.useMemo(()=>lodashEs.filter(o,d=>lodashEs.has(d,"_id")&&(lodashEs.isEmpty(n)?!d._parent:d._parent===n)),[o,n]),i=React.useCallback(d=>lodashEs.filter(o,c=>c._parent===d).length>0,[o]);return lodashEs.map(l,d=>{const c=r(d._id);return c?jsxRuntime.jsx(BlockRenderer,{blockAtom:c,children:({_id:p,_type:u,partialBlockId:m,repeaterItems:h,repeaterItemsBinding:x})=>u==="Repeater"?lodashEs.isArray(h)&&h.map((g,f)=>jsxRuntime.jsx(RepeaterContext.Provider,{value:{index:f,key:x},children:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:d._id})})):u==="GlobalBlock"||u==="PartialBlock"?jsxRuntime.jsx(jotai.Provider,{store:builderStore,children:jsxRuntime.jsx(PartialBlocksRenderer,{partialBlockId:m})}):i(p)?jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:d._id}):null},d._id):null})},PageBlocksRenderer=()=>{const[o]=useBlocksStore();return jsxRuntime.jsx(BlocksRenderer,{splitAtoms:pageBlocksAtomsAtom,blocks:o})},StaticBlocksRenderer=()=>{const[o]=useBlocksStore(),n=lodashEs.isEmpty(o)?null:jsxRuntime.jsx(PageBlocksRenderer,{});return jsxRuntime.jsx(jsxRuntime.Fragment,{children:n})},useCanvasScale=o=>{const[n]=useCanvasDisplayWidth(),[,a]=useCanvasZoom(),r=useBuilderProp("htmlDir","ltr"),[l,i]=React.useState({}),d=React.useCallback(()=>{const{width:c,height:p}=o;if(c<n){const u=parseFloat((c/n).toFixed(2).toString());let m={};const h=p*u,x=c*u;p&&(m={height:100+(p-h)/h*100+"%",width:100+(c-x)/x*100+"%"}),i({position:"relative",top:0,transform:`scale(${u})`,transformOrigin:r==="rtl"?"top right":"top left",...m,maxWidth:"none"}),a(u*100)}else i({}),a(100)},[n,o,r,a]);return React.useEffect(()=>{d()},[n,o,a,d]),l},getElementByStyleId=(o,n)=>o.querySelector(`[data-style-id="${n}"]`),StaticCanvas=()=>{const[o]=jotai.useAtom(networkModeAtom),[n]=useCanvasDisplayWidth(),[,a]=useSelectedBlockIds(),r=useSelectedBlock(),[,l]=useHighlightBlockId(),i=React.useRef(null),d=React.useRef(null),[c,p]=React.useState({width:0,height:0}),u=useCanvasScale(c),[m,h]=React.useState([]),[,x]=React.useState([]),[,g]=jotai.useAtom(canvasIframeAtom),[f,j]=useSelectedStylingBlocks(),b=useBuilderProp("loading",!1),k=useBuilderProp("htmlDir","ltr"),S=B=>{p(R=>({...R,width:B}))};React.useEffect(()=>{if(!d.current)return;const{clientWidth:B,clientHeight:R}=d.current;p({width:B,height:R})},[d,n]);const v=(B,R=0)=>{const{top:C}=B.getBoundingClientRect();return C+R>=0&&C-R<=window.innerHeight};React.useEffect(()=>{var B,R;if(r!=null&&r._id&&r.type!=="Multiple"&&i.current){const C=getElementByDataBlockId(i.current.contentDocument,r._id);C&&(v(C)||(R=(B=i.current)==null?void 0:B.contentWindow)==null||R.scrollTo({top:C.offsetTop,behavior:"smooth"}),h([C]))}},[r==null?void 0:r._id,r==null?void 0:r.type]),React.useEffect(()=>{if(!lodashEs.isEmpty(f)&&i.current){const B=getElementByStyleId(i.current.contentDocument,lodashEs.first(f).id);x(B?[B]:[null])}else x([null])},[f]);const A=React.useMemo(()=>{let B=IframeInitialContent;return B=B.replace("__HTML_DIR__",k),o==="offline"&&(B=B.replace("https://chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js")),B},[o,k]);return jsxRuntime.jsx(ResizableCanvasWrapper,{onMount:S,onResize:S,children:jsxRuntime.jsx("div",{onClick:()=>{a([]),j([])},onMouseLeave:()=>setTimeout(()=>l(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:d,children:jsxRuntime.jsxs(ChaiFrame,{contentDidMount:()=>g(i.current),ref:i,id:"canvas-iframe",style:{...u,...lodashEs.isEmpty(u)?{width:`${n}px`}:{}},className:"relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:A,children:[jsxRuntime.jsx(KeyboardHandler,{}),jsxRuntime.jsx(BlockFloatingSelector,{block:r,selectedBlockElement:lodashEs.first(m)}),jsxRuntime.jsx(HeadTags,{}),jsxRuntime.jsx(reactWrapBalancer.Provider,{children:jsxRuntime.jsxs(Canvas,{children:[b?jsxRuntime.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"})}):jsxRuntime.jsx(StaticBlocksRenderer,{}),jsxRuntime.jsx(AddBlockAtBottom,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})}),jsxRuntime.jsx("div",{id:"placeholder",className:"pointer-events-none absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})})},FallbackError=()=>jsxRuntime.jsx("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[jsxRuntime.jsx("p",{className:"font-semibold",children:"Oops! Something went wrong."}),jsxRuntime.jsx("p",{children:"Please try again."})]})}),CodeEditor$1=React.lazy(()=>Promise.resolve().then(()=>require("./code-editor-Dkq7gsQH.cjs"))),CanvasArea=()=>{const[o]=useCodeEditor(),n=useBuilderProp("onError",lodashEs.noop);return jsxRuntime.jsx("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:jsxRuntime.jsxs("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2",children:[jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:n,children:jsxRuntime.jsx(StaticCanvas,{})})}),o?jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reResizable.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:jsxRuntime.jsx(CodeEditor$1,{})})}):null,jsxRuntime.jsx(Breadcrumb,{})]})})};function NestedPathSelector({data:o,onSelect:n,dataType:a="value"}){const[r,l]=React__namespace.useState(!1),[i,d]=React__namespace.useState([]),[c,p]=React__namespace.useState(o);React.useEffect(()=>{r||d([]),p(o)},[r,o]);const u=g=>Array.isArray(g)?"array":typeof g=="object"&&g!==null?"object":"value",m=React__namespace.useCallback(g=>{const f=j=>a==="value"?j==="value"||j==="object":a==="array"?j==="array":j===a;g.type==="object"?(d(j=>[...j,g.key]),p(g.value)):f(g.type)&&(n([...i,g.key].join("."),a),l(!1))},[i,n,a]),h=React__namespace.useCallback(()=>{if(i.length>0){const g=i.slice(0,-1);d(g),p(g.reduce((f,j)=>f[j],o))}},[i,o]),x=React__namespace.useMemo(()=>Object.entries(c).map(([g,f])=>({key:g,value:f,type:u(f)})).filter(g=>a==="value"?g.type==="value"||g.type==="object":a==="array"?g.type==="array"||g.type==="object":a==="object"?g.type==="object":!0),[c,a]);return jsxRuntime.jsxs(sooner.Popover,{open:r,onOpenChange:l,children:[jsxRuntime.jsxs(sooner.Tooltip,{children:[jsxRuntime.jsx(sooner.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(sooner.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(sooner.Button,{size:"sm",variant:"outline",className:"h-5 rounded-sm px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,children:jsxRuntime.jsx(lucideReact.DatabaseIcon,{className:"h-2.5 w-2.5"})})})}),jsxRuntime.jsx(sooner.TooltipContent,{children:"Add field"})]}),jsxRuntime.jsx(sooner.PopoverContent,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:jsxRuntime.jsxs(sooner.Command,{className:"fields-command",children:[jsxRuntime.jsx(sooner.CommandInput,{className:"border-none",placeholder:"Search..."}),jsxRuntime.jsxs(sooner.CommandList,{children:[jsxRuntime.jsx(sooner.CommandEmpty,{children:"No option found."}),jsxRuntime.jsxs(sooner.CommandGroup,{children:[i.length>0&&jsxRuntime.jsxs(sooner.CommandItem,{onSelect:h,className:"flex items-center text-sm",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),x.map(g=>jsxRuntime.jsxs(sooner.CommandItem,{value:g.key,disabled:!1,onSelect:()=>m(g),className:"flex items-center justify-between",children:[jsxRuntime.jsxs("span",{className:"flex items-center gap-x-2",children:[lodashEs.startsWith(g.key,"#")?jsxRuntime.jsx(reactIcons.LoopIcon,{}):null,lodashEs.startsWith(g.key,"#")?"Repeater Data":g.key]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[a==="object"&&g.type==="object"&&jsxRuntime.jsx(sooner.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:f=>{f.stopPropagation(),n([...i,g.key].join("."),a),l(!1)},children:"Select"}),g.type==="object"&&jsxRuntime.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 opacity-50"})})]})]},g.key))]})]})]})})]})}const JSONFormFieldTemplate=({id:o,classNames:n,label:a,children:r,errors:l,help:i,description:d,hidden:c,required:p,schema:u,formData:m,onChange:h})=>{const{selectedLang:x,fallbackLang:g,languages:f}=useLanguages(),j=lodashEs.isEmpty(f)?"":lodashEs.isEmpty(x)?g:x,b=lodashEs.get(LANGUAGES,j,j),k=usePageExternalData(),S=useSelectedBlock(),v=runtime.useRegisteredChaiBlocks(),A=lodashEs.get(v,[S==null?void 0:S._type,"i18nProps"],[])||[],[B,R]=React.useState(null),C=useSelectedBlockHierarchy(),N=React.useMemo(()=>C.length===1?"":`#${lodashEs.get(C.find(T=>T._type==="Repeater"),"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1")}`,[C]),E=React.useMemo(()=>lodashEs.first(lodashEs.get(k,N.replace("#",""),[])),[N,k]),y=React.useCallback((_,L)=>{if(_=lodashEs.isEmpty(N)?_:_.replace(`${N}.`,"$index."),L==="array"||L==="object"){h(`{{${_}}}`,{},o);return}const T=D=>/[.,!?;:]/.test(D),O=(D,M,U)=>{let $="",W="";const V=M>0?D[M-1]:"",F=M<D.length?D[M]:"";return M>0&&(V==="."||!T(V)&&V!==" ")&&($=" "),M<D.length&&!T(F)&&F!==" "&&(W=" "),{text:$+U+W,prefixLength:$.length,suffixLength:W.length}},H=document.getElementById(o);if(!H)return;const P=document.getElementById(`chai-rte-${o}`)||document.getElementById(`chai-rte-modal-${o}`);if(P&&(P.querySelector(".ProseMirror")||P.__chaiRTE)){const D=P.__chaiRTE;if(D){const M=`{{${_}}}`;D.commands.focus();const{from:U,to:$}=D.state.selection;if(U!==$)D.chain().deleteSelection().insertContent(M).run();else{const{state:V}=D,F=V.selection.from,K=V.doc.textBetween(Math.max(0,F-1),F),G=V.doc.textBetween(F,Math.min(F+1,V.doc.content.size));let Y="";F>0&&K!==" "&&!T(K)&&(Y=" ");let X="";G&&G!==" "&&!T(G)&&(X=" "),D.chain().insertContent(Y+M+X).run()}setTimeout(()=>h(D.getHTML(),{},o),100);return}}else{const D=H,M=D.selectionStart||0,U=D.value||"",$=D.selectionEnd||M;if($>M){const G=`{{${_}}}`,{text:Y}=O(U,M,G),X=U.slice(0,M)+Y+U.slice($);h(X,{},o);return}const V=`{{${_}}}`,{text:F}=O(U,M,V),K=U.slice(0,M)+F+U.slice(M);h(K,{},o)}},[o,h,m,S==null?void 0:S._id,N]);if(c)return null;if(u.type==="boolean")return jsxRuntime.jsx("div",{className:n,children:r});const I=A==null?void 0:A.includes(o.replace("root.",""));if(u.type==="array"){const _=B===o;return jsxRuntime.jsxs("div",{className:`${n} relative`,children:[u.title&&jsxRuntime.jsxs("label",{htmlFor:o,onClick:()=>R(_?null:o),className:"flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",children:[_?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-3 w-3"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-3 w-3"}),jsxRuntime.jsx(lucideReact.List,{className:"h-3 w-3"}),jsxRuntime.jsx("span",{className:"leading-tight",children:a})," ",jsxRuntime.jsx(sooner.Badge,{className:"m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500",children:jsxRuntime.jsx("span",{className:"text-[9px] font-medium text-slate-600",children:m==null?void 0:m.length})})]}),(m==null?void 0:m.length)===0?jsxRuntime.jsx("div",{className:"h-0 overflow-hidden",children:r}):jsxRuntime.jsxs("div",{className:`${_?"pt-0.5":"h-0 overflow-hidden"}`,children:[d,r,l,i]})]})}return jsxRuntime.jsxs("div",{className:n,children:[u.title&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("label",{htmlFor:o,className:u.type==="object"?"pb-2":"",children:[a," ",I&&jsxRuntime.jsxs("small",{className:"text-[9px] text-zinc-400",children:[" ",b]}),p&&u.type!=="object"?" *":null]}),!u.enum&&!u.oneOf&&k&&jsxRuntime.jsx(NestedPathSelector,{data:{...E&&{[N]:E},...k},onSelect:y,dataType:u.binding==="array"?"array":"value"})]}),d,r,l,i]})},RJSF_EXTENSIONS={},registerBlockSettingWidget=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"widget"}},registerBlockSettingField=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"field"}},registerBlockSettingTemplate=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"template"}},useBlockSettingComponents=o=>Object.values(RJSF_EXTENSIONS).filter(n=>n.type===o).reduce((n,a)=>(n[a.id]=a.component,n),{}),removeSizeAttributes=o=>{try{return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>")}catch{return o}},IconPickerField=({value:o,onChange:n,id:a})=>{const{t:r}=reactI18next.useTranslation(),[l,i]=React.useState(o||"");React.useEffect(()=>{i(o||"")},[o]);const d=c=>{i(c);const p=removeSizeAttributes(c);n(p)};return jsxRuntime.jsxs("div",{className:"mt-1 flex flex-col gap-2",id:"icon-picker-field",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-lg border bg-gray-50",children:l?jsxRuntime.jsx("div",{className:"h-6 w-6",dangerouslySetInnerHTML:{__html:l}}):jsxRuntime.jsx("span",{className:"text-xs text-gray-400",children:"SVG"})}),jsxRuntime.jsx("textarea",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:l,onChange:c=>d(c.target.value),placeholder:r("Enter SVG code here"),rows:2,className:"no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"})]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:r("Paste SVG code to use as an icon")})]})},DefaultMediaManager=({close:o,onSelect:n,mode:a="image"})=>{const[r,l]=React.useState(""),[i,d]=React.useState(!1),[c,p]=React.useState(!1),[u,m]=React.useState(null),h=async g=>{if(!g.trim()){p(!1),m("Please enter a URL");return}try{d(!0),m(null),p(!0),m(null)}catch{p(!1),m("Error validating URL")}finally{d(!1)}},{t:x}=reactI18next.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-96 flex-col gap-4 p-4",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:x(`${a.charAt(0).toUpperCase()+a.slice(1)} Manager`)}),u&&jsxRuntime.jsxs(sooner.Alert,{variant:"destructive",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(sooner.AlertDescription,{children:u})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsx(sooner.Input,{placeholder:x(`Enter ${a} URL`),value:r,onChange:g=>l(g.target.value),onKeyUp:()=>h(r)}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(sooner.Button,{variant:"outline",onClick:o,children:x("Cancel")}),jsxRuntime.jsx(sooner.Button,{onClick:()=>n({id:"dam-id",url:r,width:600,height:400,description:"This is image description"}),disabled:!c||i,children:x("Insert")})]})]})]})},MEDIA_MANAGER={component:DefaultMediaManager},registerChaiMediaManager=o=>{MEDIA_MANAGER.component=o},useMediaManagerComponent=()=>React.useMemo(()=>MEDIA_MANAGER.component,[]),MediaManagerModal=({assetId:o,children:n,onSelect:a,mode:r="image"})=>{const[l,i]=React.useState(!1),d=useMediaManagerComponent(),c=(...p)=>{a.call(void 0,...p),i(!1)};return jsxRuntime.jsxs(sooner.Dialog,{open:l,onOpenChange:p=>i(p),children:[jsxRuntime.jsx(sooner.DialogTrigger,{asChild:!0,children:n}),jsxRuntime.jsx(sooner.DialogContent,{className:"flex max-h-[90vh] max-w-7xl border-border md:w-fit",children:jsxRuntime.jsx("div",{className:"h-full w-full",children:d?jsxRuntime.jsx(d,{close:()=>i(!1),onSelect:c,mode:r,assetId:o}):null})})]})};MediaManagerModal.displayName="MediaManagerModal";const ImagePickerField=({value:o,onChange:n,id:a,onBlur:r})=>{const{t:l}=reactI18next.useTranslation(),i=useSelectedBlock(),d=useUpdateBlocksProps(),c=m=>{const h=lodashEs.isArray(m)?lodashEs.first(m):m;if(h){n(h==null?void 0:h.url);const x=h==null?void 0:h.width,g=h==null?void 0:h.height;if(i!=null&&i._id){const f={...x&&{width:x},...g&&{height:g},...h.description&&{alt:h.description},...h.id&&{assetId:h.id}};if(lodashEs.isEmpty(f))return;d([i._id],f)}}},p=React.useCallback(()=>{n("https://placehold.co/400"),i!=null&&i._id&&d([i._id],{assetId:""})},[n,i==null?void 0:i._id,d]),u=lodashEs.get(i,"assetId","");return jsxRuntime.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[o?jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("img",{src:o,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover",alt:""}),jsxRuntime.jsx("button",{type:"button",onClick:p,className:"absolute -right-2 -top-2 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})})]}):jsxRuntime.jsx(MediaManagerModal,{onSelect:c,mode:"image",assetId:u,children:jsxRuntime.jsx("div",{className:"h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]"})}),jsxRuntime.jsxs("div",{className:"flex w-3/5 flex-col",children:[jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MediaManagerModal,{onSelect:c,assetId:u,children:jsxRuntime.jsx("small",{className:"h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80",children:o||!lodashEs.isEmpty(o)?l("Replace image"):l("Choose image")})}),jsxRuntime.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-secondary-foreground",children:"OR"})]}),jsxRuntime.jsx("input",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"text-xs",placeholder:l("Enter image URL"),value:o,onBlur:({target:{value:m}})=>r(a,m),onChange:m=>n(m.target.value)})]})]})},PageTypeField=({href:o,pageTypes:n,onChange:a})=>{var N;const{t:r}=reactI18next.useTranslation(),l=useBuilderProp("searchPageTypeItems",(E,y)=>[]),[i,d]=React.useState(!1),[c,p]=React.useState(!1),[u,m]=React.useState("page"),[h,x]=React.useState(""),[g,f]=React.useState([]),[j,b]=React.useState(-1),k=React.useRef(null),S=(N=n==null?void 0:n.find(E=>E.key===u))==null?void 0:N.name;React.useEffect(()=>{if(x(""),f([]),b(-1),p(!1),!o||i||!lodashEs.startsWith(o,"pageType:"))return;const E=lodashEs.split(o,":"),y=lodashEs.get(E,1,"page")||"page";m(y),(async()=>{const w=await l(y,[lodashEs.get(E,2,"page")]);w&&Array.isArray(w)&&x(lodashEs.get(w,[0,"name"],""))})()},[o]);const v=web.useDebouncedCallback(async E=>{if(lodashEs.isEmpty(E))f([]);else{const y=await l(u,E);f(y)}d(!1),b(-1)},[u],300),A=E=>{const y=["pageType",u,E.id];y[1]&&(a(y.join(":")),x(E.name),p(!1),f([]),b(-1))},B=E=>{switch(E.key){case"ArrowDown":E.preventDefault(),b(y=>y<g.length-1?y+1:y);break;case"ArrowUp":E.preventDefault(),b(y=>y>0?y-1:y);break;case"Enter":if(E.preventDefault(),g.length===0)return;j>=0&&A(g[j]);break;case"Escape":E.preventDefault(),R();break}};React.useEffect(()=>{if(j>=0&&k.current){const E=k.current.children[j];E==null||E.scrollIntoView({block:"nearest"})}},[j]);const R=()=>{x(""),f([]),b(-1),p(!1),a("")},C=E=>{x(E),p(!lodashEs.isEmpty(E)),d(!0),v(E)};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("select",{name:"pageType",value:u,onChange:E=>m(E.target.value),children:lodashEs.map(n,E=>jsxRuntime.jsx("option",{value:E.key,children:E.name},E.key))}),u&&jsxRuntime.jsxs("div",{className:"group relative mt-2 flex items-center",children:[jsxRuntime.jsx("input",{type:"text",value:h,onChange:E=>C(E.target.value),onKeyDown:B,placeholder:r(`Search ${S??""}`),className:"w-full rounded-md border border-gray-300 p-2 pr-16"}),jsxRuntime.jsx("div",{className:"absolute bottom-2 right-2 top-3 flex items-center gap-1.5",children:h&&jsxRuntime.jsx("button",{onClick:R,className:"text-gray-400 hover:text-gray-600",title:r("Clear search"),children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})})]}),(i||!lodashEs.isEmpty(g)||c&&lodashEs.isEmpty(g))&&jsxRuntime.jsx("div",{className:"absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg",children:i?jsxRuntime.jsxs("div",{className:"space-y-1 p-2",children:[jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):c&&lodashEs.isEmpty(g)?jsxRuntime.jsxs("div",{className:"flex items-center justify-center p-4 text-sm text-gray-500",children:[r("No results found for"),' "',h,'"']}):jsxRuntime.jsx("ul",{ref:k,children:lodashEs.map(g==null?void 0:g.slice(0,20),(E,y)=>jsxRuntime.jsxs("li",{onClick:()=>A(E),className:`cursor-pointer p-2 text-xs ${o!=null&&o.includes(E.id)?"bg-blue-200":y===j?"bg-gray-100":"hover:bg-gray-100"}`,children:[E.name," ",E.slug&&jsxRuntime.jsxs("small",{className:"font-light text-gray-500",children:["( ",E.slug," )"]})]},E.id))})})]})},LinkField=({schema:o,formData:n,onChange:a})=>{const{t:r}=reactI18next.useTranslation(),{type:l="pageType",href:i="",target:d="self"}=n,c=useBuilderProp("pageTypes",[]),p=l==="pageType"&&lodashEs.isEmpty(c)?"url":l;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-xs font-medium",children:(o==null?void 0:o.title)??"Link"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("select",{name:"type",value:l,onChange:u=>a({...n,type:u.target.value}),children:lodashEs.map([...lodashEs.isEmpty(c)?[]:[{const:"pageType",title:r("Goto Page")}],{const:"url",title:r("Open URL")},{const:"email",title:r("Compose Email")},{const:"telephone",title:r("Call Phone")},{const:"scroll",title:r("Scroll to element")}],u=>jsxRuntime.jsx("option",{value:u.const,children:u.title},u.const))}),p==="pageType"&&!lodashEs.isEmpty(c)?jsxRuntime.jsx(PageTypeField,{href:i,pageTypes:c,onChange:u=>a({...n,href:u})}):jsxRuntime.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",value:i,onChange:u=>a({...n,href:u.target.value}),placeholder:r(l==="url"?"Enter URL":l==="scroll"?"#ElementID":"Enter details")}),p==="url"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"checkbox",defaultChecked:d==="_blank",className:"!w-fit cursor-pointer rounded-md border border-border",onChange:()=>a({...n,target:d==="_blank"?"_self":"_blank"})}),jsxRuntime.jsx("span",{className:"pt-1 text-xs",children:r("Open in new tab")})]})]})]})},RowColField=()=>{const o=useSelectedBlock(),n=useWrapperBlock(),{addCoreBlock:a}=useAddBlock();if(!o&&!n)return null;const r=(o==null?void 0:o._type)==="Row"?o:n;return jsxRuntime.jsx("div",{className:"pt-1",children:jsxRuntime.jsxs("button",{type:"button",className:"duratiom-300 flex items-center gap-x-1 rounded border border-gray-400 bg-gray-100 px-4 py-1 text-[11px] font-medium leading-tight hover:bg-slate-200",onClick:()=>a({type:"Column",styles:"#styles:,"},r==null?void 0:r._id),children:[jsxRuntime.jsx(lucideReact.Plus,{className:"h-4 w-4"})," Add Column"]})})};function cn(...o){return tailwindMerge.twMerge(clsx.clsx(o))}const MenuBar=({editor:o,onExpand:n})=>{if(!o)return null;const a=()=>{const l=window.prompt("URL");l&&o.chain().focus().extendMarkRange("link").setLink({href:l}).run()},r=()=>{o.chain().focus().unsetLink().run()};return jsxRuntime.jsxs("div",{className:"mb-1 flex flex-wrap gap-1 rounded-md border border-border p-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleBold().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("bold")}),title:"Bold",children:jsxRuntime.jsx(lucideReact.Bold,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleItalic().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("italic")}),title:"Italic",children:jsxRuntime.jsx(lucideReact.Italic,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleUnderline().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("underline")}),title:"Underline",children:jsxRuntime.jsx(lucideReact.Underline,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleStrike().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("strike")}),title:"Strike",children:jsxRuntime.jsx(lucideReact.Strikethrough,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleBulletList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("bulletList")}),title:"Bullet List",children:jsxRuntime.jsx(lucideReact.List,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleOrderedList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("orderedList")}),title:"Ordered List",children:jsxRuntime.jsx(lucideReact.ListOrdered,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("left").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"left"})}),title:"Align Left",children:jsxRuntime.jsx(lucideReact.AlignLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("center").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"center"})}),title:"Align Center",children:jsxRuntime.jsx(lucideReact.AlignCenter,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("right").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"right"})}),title:"Align Right",children:jsxRuntime.jsx(lucideReact.AlignRight,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:a,className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("link")}),title:"Add Link",children:jsxRuntime.jsx(lucideReact.Link,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:r,className:cn("rounded p-1 hover:bg-muted"),title:"Remove Link",disabled:!o.isActive("link"),children:jsxRuntime.jsx(lucideReact.Unlink,{className:"h-4 w-4"})}),n&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:n,className:"rounded p-1 hover:bg-muted",title:"Open in full screen mode",children:jsxRuntime.jsx(lucideReact.Maximize2,{className:"h-4 w-4"})})]})]})},RTEModal=({isOpen:o,onClose:n,id:a,value:r,onChange:l,onBlur:i})=>{const d=React.useRef(null),c=React.useRef(r||""),p=usePageExternalData();React.useEffect(()=>{if(o){const h=document.createElement("style");return h.id="rte-modal-styles",h.innerHTML=`
|
|
60
|
+
}`)},[l,h]),React.useEffect(()=>{c.querySelector("#drop-target-block").innerHTML=d?`[data-block-id="${d}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}`:""},[d,c]);const f=React.useMemo(()=>{const{heading:k,body:S}={heading:lodashEs.get(o,"fontFamily.heading"),body:lodashEs.get(o,"fontFamily.body")};return g.filter(v=>v.family===k||v.family===S)},[o==null?void 0:o.fontFamily,g]),j=React.useMemo(()=>plugin.getThemeFontsLinkMarkup(lodashEs.filter(f,k=>lodashEs.has(k,"url"))),[f]),b=React.useMemo(()=>plugin.getThemeCustomFontFace(lodashEs.filter(f,k=>lodashEs.has(k,"src"))),[f]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(CssThemeVariables,{theme:o}),jsxRuntime.jsx("span",{id:"chai-fonts",dangerouslySetInnerHTML:{__html:j}}),jsxRuntime.jsx("style",{id:"chai-custom-fonts",dangerouslySetInnerHTML:{__html:b}})]})},ResizableCanvasWrapper=({children:o,onMount:n,onResize:a})=>{const[,r]=useSelectedBlockIds(),[,l]=useSelectedStylingBlocks(),i=React.useRef(null),d=web.useDebouncedCallback(()=>{const{clientWidth:p}=i.current;a(p)},[i.current],100);web.useResizeObserver(i.current,d,i.current!==null),React.useEffect(()=>{const{clientWidth:p}=i.current;n(p)},[]);const c=()=>{r([]),l([])};return jsxRuntime.jsx("div",{id:"main-content",onClick:c,className:"h-full w-full p-8 pb-0",ref:i,children:o})},useBlockRuntimeProps=()=>{const[o]=useBlocksStore();return React.useCallback((n,a)=>lodashEs.isEmpty(a)?{}:Object.entries(a).reduce((r,[l,i])=>{const d=[];let c=lodashEs.find(o,{_id:n});for(;c;)d.push(c),c=lodashEs.find(o,{_id:c._parent});const p=lodashEs.find(d,{_type:i.block});return p&&(r[l]=lodashEs.get(p,lodashEs.get(i,"prop"),null)),r},{}),[o])},RepeaterContext=React.createContext({index:-1,key:""}),BlockRenderer=({blockAtom:o,children:n})=>{const[a]=jotai.useAtom(o),r=React.useMemo(()=>runtime.getRegisteredChaiBlock(a._type),[a._type]),{selectedLang:l,fallbackLang:i}=useLanguages(),d=useBlockRuntimeProps(),c=usePageExternalData(),[p]=useHiddenBlockIds(),[u]=jotai.useAtom(dataBindingActiveAtom),m=lodashEs.get(r,"component",null),{index:h,key:x}=React.useContext(RepeaterContext),g=React.useMemo(()=>u?newBlocksRenderHelpers.applyBinding(newBlocksRenderHelpers.applyLanguage(a,l,r),c,{index:h,key:x}):newBlocksRenderHelpers.applyLanguage(a,l,r),[a,l,r,c,u,h,x]),f=React.useMemo(()=>newBlocksRenderHelpers.getBlockTagAttributes(a),[a,newBlocksRenderHelpers.getBlockTagAttributes]),j=React.useMemo(()=>d(a._id,newBlocksRenderHelpers.getBlockRuntimeProps(a._type)),[a._id,a._type,d,newBlocksRenderHelpers.getBlockRuntimeProps]),b=React.useMemo(()=>!lodashEs.has(r,"dataProvider")||!lodashEs.isFunction(r.dataProvider)?{}:r.dataProvider({block:a,draft:!0,inBuilder:!0,lang:l||i,pageProps:{}}),[a,l,i,r,c]),k=React.useMemo(()=>({blockProps:{"data-block-id":a._id,"data-block-type":a._type},inBuilder:!0,lang:l||i,...g,...f,...j,...b}),[a._id,a._type,l,i,g,f,j,b]);return lodashEs.isNull(m)||p.includes(a._id)?null:jsxRuntime.jsx(React.Suspense,{children:React.createElement(m,{...k,children:n({_id:a._id,_type:a._type,...lodashEs.isArray(g.repeaterItems)?{repeaterItems:newBlocksRenderHelpers.applyLimit(g.repeaterItems,a),repeaterItemsBinding:g.repeaterItemsBinding}:{},...a.partialBlockId?{partialBlockId:a.partialBlockId}:"",...a.globalBlock?{partialBlockId:a.globalBlock}:""})})})},PartialBlocksRenderer=({partialBlockId:o})=>{const{getPartailBlocks:n}=usePartialBlocksStore(),a=React.useMemo(()=>n(o),[n,o]),r=React.useMemo(()=>utils.splitAtom(jotai.atom(a)),[a]);return lodashEs.isEmpty(a)?null:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:r,blocks:a})},BlocksRenderer=({blocks:o,parent:n=null,splitAtoms:a=void 0})=>{const r=useGetBlockAtom(a),l=React.useMemo(()=>lodashEs.filter(o,d=>lodashEs.has(d,"_id")&&(lodashEs.isEmpty(n)?!d._parent:d._parent===n)),[o,n]),i=React.useCallback(d=>lodashEs.filter(o,c=>c._parent===d).length>0,[o]);return lodashEs.map(l,d=>{const c=r(d._id);return c?jsxRuntime.jsx(BlockRenderer,{blockAtom:c,children:({_id:p,_type:u,partialBlockId:m,repeaterItems:h,repeaterItemsBinding:x})=>u==="Repeater"?lodashEs.isArray(h)&&h.map((g,f)=>jsxRuntime.jsx(RepeaterContext.Provider,{value:{index:f,key:x},children:jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:d._id})})):u==="GlobalBlock"||u==="PartialBlock"?jsxRuntime.jsx(jotai.Provider,{store:builderStore,children:jsxRuntime.jsx(PartialBlocksRenderer,{partialBlockId:m})}):i(p)?jsxRuntime.jsx(BlocksRenderer,{splitAtoms:a,blocks:o,parent:d._id}):null},d._id):null})},PageBlocksRenderer=()=>{const[o]=useBlocksStore();return jsxRuntime.jsx(BlocksRenderer,{splitAtoms:pageBlocksAtomsAtom,blocks:o})},StaticBlocksRenderer=()=>{const[o]=useBlocksStore(),n=lodashEs.isEmpty(o)?null:jsxRuntime.jsx(PageBlocksRenderer,{});return jsxRuntime.jsx(jsxRuntime.Fragment,{children:n})},useCanvasScale=o=>{const[n]=useCanvasDisplayWidth(),[,a]=useCanvasZoom(),r=useBuilderProp("htmlDir","ltr"),[l,i]=React.useState({}),d=React.useCallback(()=>{const{width:c,height:p}=o;if(c<n){const u=parseFloat((c/n).toFixed(2).toString());let m={};const h=p*u,x=c*u;p&&(m={height:100+(p-h)/h*100+"%",width:100+(c-x)/x*100+"%"}),i({position:"relative",top:0,transform:`scale(${u})`,transformOrigin:r==="rtl"?"top right":"top left",...m,maxWidth:"none"}),a(u*100)}else i({}),a(100)},[n,o,r,a]);return React.useEffect(()=>{d()},[n,o,a,d]),l},getElementByStyleId=(o,n)=>o.querySelector(`[data-style-id="${n}"]`),StaticCanvas=()=>{const[o]=jotai.useAtom(networkModeAtom),[n]=useCanvasDisplayWidth(),[,a]=useSelectedBlockIds(),r=useSelectedBlock(),[,l]=useHighlightBlockId(),i=React.useRef(null),d=React.useRef(null),[c,p]=React.useState({width:0,height:0}),u=useCanvasScale(c),[m,h]=React.useState([]),[,x]=React.useState([]),[,g]=jotai.useAtom(canvasIframeAtom),[f,j]=useSelectedStylingBlocks(),b=useBuilderProp("loading",!1),k=useBuilderProp("htmlDir","ltr"),S=B=>{p(R=>({...R,width:B}))};React.useEffect(()=>{if(!d.current)return;const{clientWidth:B,clientHeight:R}=d.current;p({width:B,height:R})},[d,n]);const v=(B,R=0)=>{const{top:C}=B.getBoundingClientRect();return C+R>=0&&C-R<=window.innerHeight};React.useEffect(()=>{var B,R;if(r!=null&&r._id&&r.type!=="Multiple"&&i.current){const C=getElementByDataBlockId(i.current.contentDocument,r._id);C&&(v(C)||(R=(B=i.current)==null?void 0:B.contentWindow)==null||R.scrollTo({top:C.offsetTop,behavior:"smooth"}),h([C]))}},[r==null?void 0:r._id,r==null?void 0:r.type]),React.useEffect(()=>{if(!lodashEs.isEmpty(f)&&i.current){const B=getElementByStyleId(i.current.contentDocument,lodashEs.first(f).id);x(B?[B]:[null])}else x([null])},[f]);const A=React.useMemo(()=>{let B=IframeInitialContent;return B=B.replace("__HTML_DIR__",k),o==="offline"&&(B=B.replace("https://chaibuilder.com/offline/tailwind.cdn.js","/offline/tailwind.cdn.js")),B},[o,k]);return jsxRuntime.jsx(ResizableCanvasWrapper,{onMount:S,onResize:S,children:jsxRuntime.jsx("div",{onClick:()=>{a([]),j([])},onMouseLeave:()=>setTimeout(()=>l(""),300),className:"relative mx-auto h-full w-full overflow-hidden",ref:d,children:jsxRuntime.jsxs(ChaiFrame,{contentDidMount:()=>g(i.current),ref:i,id:"canvas-iframe",style:{...u,...lodashEs.isEmpty(u)?{width:`${n}px`}:{}},className:"relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:A,children:[jsxRuntime.jsx(KeyboardHandler,{}),jsxRuntime.jsx(BlockFloatingSelector,{block:r,selectedBlockElement:lodashEs.first(m)}),jsxRuntime.jsx(HeadTags,{}),jsxRuntime.jsx(reactWrapBalancer.Provider,{children:jsxRuntime.jsxs(Canvas,{children:[b?jsxRuntime.jsx("div",{className:"h-full p-4",children:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"})}):jsxRuntime.jsx(StaticBlocksRenderer,{}),jsxRuntime.jsx(AddBlockAtBottom,{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("br",{})]})}),jsxRuntime.jsx("div",{id:"placeholder",className:"pointer-events-none absolute z-[99999] max-w-full bg-green-500 transition-transform"})]})})})},FallbackError=()=>jsxRuntime.jsx("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:jsxRuntime.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[jsxRuntime.jsx("p",{className:"font-semibold",children:"Oops! Something went wrong."}),jsxRuntime.jsx("p",{children:"Please try again."})]})}),CodeEditor$1=React.lazy(()=>Promise.resolve().then(()=>require("./code-editor-Dkq7gsQH.cjs"))),CanvasArea=()=>{const[o]=useCodeEditor(),n=useBuilderProp("onError",lodashEs.noop);return jsxRuntime.jsx("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:jsxRuntime.jsxs("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2",children:[jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary,{fallback:jsxRuntime.jsx(FallbackError,{}),onError:n,children:jsxRuntime.jsx(StaticCanvas,{})})}),o?jsxRuntime.jsx(React.Suspense,{fallback:jsxRuntime.jsx(sooner.Skeleton,{className:"h-full"}),children:jsxRuntime.jsx(reResizable.Resizable,{enable:{top:!0,bottom:!1},className:"max-h-[400px] min-h-[200px]",children:jsxRuntime.jsx(CodeEditor$1,{})})}):null,jsxRuntime.jsx(Breadcrumb,{})]})})};function NestedPathSelector({data:o,onSelect:n,dataType:a="value"}){const[r,l]=React__namespace.useState(!1),[i,d]=React__namespace.useState([]),[c,p]=React__namespace.useState(o);React.useEffect(()=>{r||d([]),p(o)},[r,o]);const u=g=>Array.isArray(g)?"array":typeof g=="object"&&g!==null?"object":"value",m=React__namespace.useCallback(g=>{const f=j=>a==="value"?j==="value"||j==="object":a==="array"?j==="array":j===a;g.type==="object"?(d(j=>[...j,g.key]),p(g.value)):f(g.type)&&(n([...i,g.key].join("."),a),l(!1))},[i,n,a]),h=React__namespace.useCallback(()=>{if(i.length>0){const g=i.slice(0,-1);d(g),p(g.reduce((f,j)=>f[j],o))}},[i,o]),x=React__namespace.useMemo(()=>Object.entries(c).map(([g,f])=>({key:g,value:f,type:u(f)})).filter(g=>a==="value"?g.type==="value"||g.type==="object":a==="array"?g.type==="array"||g.type==="object":a==="object"?g.type==="object":!0),[c,a]);return jsxRuntime.jsxs(sooner.Popover,{open:r,onOpenChange:l,children:[jsxRuntime.jsxs(sooner.Tooltip,{children:[jsxRuntime.jsx(sooner.TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(sooner.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(sooner.Button,{size:"sm",variant:"outline",className:"h-5 rounded-sm px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,children:jsxRuntime.jsx(lucideReact.DatabaseIcon,{className:"h-2.5 w-2.5"})})})}),jsxRuntime.jsx(sooner.TooltipContent,{children:"Add field"})]}),jsxRuntime.jsx(sooner.PopoverContent,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:jsxRuntime.jsxs(sooner.Command,{className:"fields-command",children:[jsxRuntime.jsx(sooner.CommandInput,{className:"border-none",placeholder:"Search..."}),jsxRuntime.jsxs(sooner.CommandList,{children:[jsxRuntime.jsx(sooner.CommandEmpty,{children:"No option found."}),jsxRuntime.jsxs(sooner.CommandGroup,{children:[i.length>0&&jsxRuntime.jsxs(sooner.CommandItem,{onSelect:h,className:"flex items-center text-sm",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),x.map(g=>jsxRuntime.jsxs(sooner.CommandItem,{value:g.key,disabled:!1,onSelect:()=>m(g),className:"flex items-center justify-between",children:[jsxRuntime.jsxs("span",{className:"flex items-center gap-x-2",children:[lodashEs.startsWith(g.key,"#")?jsxRuntime.jsx(reactIcons.LoopIcon,{}):null,lodashEs.startsWith(g.key,"#")?"Repeater Data":g.key]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[a==="object"&&g.type==="object"&&jsxRuntime.jsx(sooner.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:f=>{f.stopPropagation(),n([...i,g.key].join("."),a),l(!1)},children:"Select"}),g.type==="object"&&jsxRuntime.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 opacity-50"})})]})]},g.key))]})]})]})})]})}const JSONFormFieldTemplate=({id:o,classNames:n,label:a,children:r,errors:l,help:i,description:d,hidden:c,required:p,schema:u,formData:m,onChange:h})=>{const{selectedLang:x,fallbackLang:g,languages:f}=useLanguages(),j=lodashEs.isEmpty(f)?"":lodashEs.isEmpty(x)?g:x,b=lodashEs.get(LANGUAGES,j,j),k=usePageExternalData(),S=useSelectedBlock(),v=runtime.useRegisteredChaiBlocks(),A=lodashEs.get(v,[S==null?void 0:S._type,"i18nProps"],[])||[],[B,R]=React.useState(null),C=useSelectedBlockHierarchy(),N=React.useMemo(()=>C.length===1?"":`#${lodashEs.get(C.find(T=>T._type==="Repeater"),"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1")}`,[C]),E=React.useMemo(()=>lodashEs.first(lodashEs.get(k,N.replace("#",""),[])),[N,k]),y=React.useCallback((_,L)=>{if(_=lodashEs.isEmpty(N)?_:_.replace(`${N}.`,"$index."),L==="array"||L==="object"){h(`{{${_}}}`,{},o);return}const T=D=>/[.,!?;:]/.test(D),O=(D,M,U)=>{let $="",W="";const V=M>0?D[M-1]:"",F=M<D.length?D[M]:"";return M>0&&(V==="."||!T(V)&&V!==" ")&&($=" "),M<D.length&&!T(F)&&F!==" "&&(W=" "),{text:$+U+W,prefixLength:$.length,suffixLength:W.length}},H=document.getElementById(o);if(!H)return;const P=document.getElementById(`chai-rte-${o}`)||document.getElementById(`chai-rte-modal-${o}`);if(P&&(P.querySelector(".ProseMirror")||P.__chaiRTE)){const D=P.__chaiRTE;if(D){const M=`{{${_}}}`;D.commands.focus();const{from:U,to:$}=D.state.selection;if(U!==$)D.chain().deleteSelection().insertContent(M).run();else{const{state:V}=D,F=V.selection.from,K=V.doc.textBetween(Math.max(0,F-1),F),G=V.doc.textBetween(F,Math.min(F+1,V.doc.content.size));let Y="";F>0&&K!==" "&&!T(K)&&(Y=" ");let X="";G&&G!==" "&&!T(G)&&(X=" "),D.chain().insertContent(Y+M+X).run()}setTimeout(()=>h(D.getHTML(),{},o),100);return}}else{const D=H,M=D.selectionStart||0,U=D.value||"",$=D.selectionEnd||M;if($>M){const G=`{{${_}}}`,{text:Y}=O(U,M,G),X=U.slice(0,M)+Y+U.slice($);h(X,{},o);return}const V=`{{${_}}}`,{text:F}=O(U,M,V),K=U.slice(0,M)+F+U.slice(M);h(K,{},o)}},[o,h,m,S==null?void 0:S._id,N]);if(c)return null;if(u.type==="boolean")return jsxRuntime.jsx("div",{className:n,children:r});const I=A==null?void 0:A.includes(o.replace("root.",""));if(u.type==="array"){const _=B===o;return jsxRuntime.jsxs("div",{className:`${n} relative`,children:[u.title&&jsxRuntime.jsxs("label",{htmlFor:o,onClick:()=>R(_?null:o),className:"flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",children:[_?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-3 w-3"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-3 w-3"}),jsxRuntime.jsx(lucideReact.List,{className:"h-3 w-3"}),jsxRuntime.jsx("span",{className:"leading-tight",children:a})," ",jsxRuntime.jsx(sooner.Badge,{className:"m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500",children:jsxRuntime.jsx("span",{className:"text-[9px] font-medium text-slate-600",children:m==null?void 0:m.length})})]}),(m==null?void 0:m.length)===0?jsxRuntime.jsx("div",{className:"h-0 overflow-hidden",children:r}):jsxRuntime.jsxs("div",{className:`${_?"pt-0.5":"h-0 overflow-hidden"}`,children:[d,r,l,i]})]})}return jsxRuntime.jsxs("div",{className:n,children:[u.title&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("label",{htmlFor:o,className:u.type==="object"?"pb-2":"",children:[a," ",I&&jsxRuntime.jsxs("small",{className:"text-[9px] text-zinc-400",children:[" ",b]}),p&&u.type!=="object"?" *":null]}),!u.enum&&!u.oneOf&&k&&jsxRuntime.jsx(NestedPathSelector,{data:{...E&&{[N]:E},...k},onSelect:y,dataType:u.binding==="array"?"array":"value"})]}),d,r,l,i]})},RJSF_EXTENSIONS={},registerBlockSettingWidget=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"widget"}},registerBlockSettingField=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"field"}},registerBlockSettingTemplate=(o,n)=>{RJSF_EXTENSIONS[o]={id:o,component:n,type:"template"}},useBlockSettingComponents=o=>Object.values(RJSF_EXTENSIONS).filter(n=>n.type===o).reduce((n,a)=>(n[a.id]=a.component,n),{}),removeSizeAttributes=o=>{try{return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>")}catch{return o}},IconPickerField=({value:o,onChange:n,id:a})=>{const{t:r}=reactI18next.useTranslation(),[l,i]=React.useState(o||"");React.useEffect(()=>{i(o||"")},[o]);const d=c=>{i(c);const p=removeSizeAttributes(c);n(p)};return jsxRuntime.jsxs("div",{className:"mt-1 flex flex-col gap-2",id:"icon-picker-field",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-lg border bg-gray-50",children:l?jsxRuntime.jsx("div",{className:"h-6 w-6",dangerouslySetInnerHTML:{__html:l}}):jsxRuntime.jsx("span",{className:"text-xs text-gray-400",children:"SVG"})}),jsxRuntime.jsx("textarea",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:l,onChange:c=>d(c.target.value),placeholder:r("Enter SVG code here"),rows:2,className:"no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"})]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:r("Paste SVG code to use as an icon")})]})},DefaultMediaManager=({close:o,onSelect:n,mode:a="image"})=>{const[r,l]=React.useState(""),[i,d]=React.useState(!1),[c,p]=React.useState(!1),[u,m]=React.useState(null),h=async g=>{if(!g.trim()){p(!1),m("Please enter a URL");return}try{d(!0),m(null),p(!0),m(null)}catch{p(!1),m("Error validating URL")}finally{d(!1)}},{t:x}=reactI18next.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-96 flex-col gap-4 p-4",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:x(`${a.charAt(0).toUpperCase()+a.slice(1)} Manager`)}),u&&jsxRuntime.jsxs(sooner.Alert,{variant:"destructive",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(sooner.AlertDescription,{children:u})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsx(sooner.Input,{placeholder:x(`Enter ${a} URL`),value:r,onChange:g=>l(g.target.value),onKeyUp:()=>h(r)}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(sooner.Button,{variant:"outline",onClick:o,children:x("Cancel")}),jsxRuntime.jsx(sooner.Button,{onClick:()=>n({id:"dam-id",url:r,width:600,height:400,description:"This is image description"}),disabled:!c||i,children:x("Insert")})]})]})]})},MEDIA_MANAGER={component:DefaultMediaManager},registerChaiMediaManager=o=>{MEDIA_MANAGER.component=o},useMediaManagerComponent=()=>React.useMemo(()=>MEDIA_MANAGER.component,[]),MediaManagerModal=({assetId:o,children:n,onSelect:a,mode:r="image"})=>{const[l,i]=React.useState(!1),d=useMediaManagerComponent(),c=(...p)=>{a.call(void 0,...p),i(!1)};return jsxRuntime.jsxs(sooner.Dialog,{open:l,onOpenChange:p=>i(p),children:[jsxRuntime.jsx(sooner.DialogTrigger,{asChild:!0,children:n}),jsxRuntime.jsx(sooner.DialogContent,{className:"flex max-h-[90vh] max-w-7xl border-border md:w-fit",children:jsxRuntime.jsx("div",{className:"h-full w-full",children:d?jsxRuntime.jsx(d,{close:()=>i(!1),onSelect:c,mode:r,assetId:o}):null})})]})};MediaManagerModal.displayName="MediaManagerModal";const ImagePickerField=({value:o,onChange:n,id:a,onBlur:r})=>{const{t:l}=reactI18next.useTranslation(),i=useSelectedBlock(),d=useUpdateBlocksProps(),c=m=>{const h=lodashEs.isArray(m)?lodashEs.first(m):m;if(h){n(h==null?void 0:h.url);const x=h==null?void 0:h.width,g=h==null?void 0:h.height;if(i!=null&&i._id){const f={...x&&{width:x},...g&&{height:g},...h.description&&{alt:h.description},...h.id&&{assetId:h.id}};if(lodashEs.isEmpty(f))return;d([i._id],f)}}},p=React.useCallback(()=>{n("https://placehold.co/400"),i!=null&&i._id&&d([i._id],{assetId:""})},[n,i==null?void 0:i._id,d]),u=lodashEs.get(i,"assetId","");return jsxRuntime.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[o?jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("img",{src:o,className:"h-20 w-20 overflow-hidden rounded-md border border-border object-cover",alt:""}),jsxRuntime.jsx("button",{type:"button",onClick:p,className:"absolute -right-2 -top-2 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3"})})]}):jsxRuntime.jsx(MediaManagerModal,{onSelect:c,mode:"image",assetId:u,children:jsxRuntime.jsx("div",{className:"h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]"})}),jsxRuntime.jsxs("div",{className:"flex w-3/5 flex-col",children:[jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MediaManagerModal,{onSelect:c,assetId:u,children:jsxRuntime.jsx("small",{className:"h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80",children:o||!lodashEs.isEmpty(o)?l("Replace image"):l("Choose image")})}),jsxRuntime.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-secondary-foreground",children:"OR"})]}),jsxRuntime.jsx("input",{id:a,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"text-xs",placeholder:l("Enter image URL"),value:o,onBlur:({target:{value:m}})=>r(a,m),onChange:m=>n(m.target.value)})]})]})},PageTypeField=({href:o,pageTypes:n,onChange:a})=>{var N;const{t:r}=reactI18next.useTranslation(),l=useBuilderProp("searchPageTypeItems",(E,y)=>[]),[i,d]=React.useState(!1),[c,p]=React.useState(!1),[u,m]=React.useState("page"),[h,x]=React.useState(""),[g,f]=React.useState([]),[j,b]=React.useState(-1),k=React.useRef(null),S=(N=n==null?void 0:n.find(E=>E.key===u))==null?void 0:N.name;React.useEffect(()=>{if(x(""),f([]),b(-1),p(!1),!o||i||!lodashEs.startsWith(o,"pageType:"))return;const E=lodashEs.split(o,":"),y=lodashEs.get(E,1,"page")||"page";m(y),(async()=>{const w=await l(y,[lodashEs.get(E,2,"page")]);w&&Array.isArray(w)&&x(lodashEs.get(w,[0,"name"],""))})()},[o]);const v=web.useDebouncedCallback(async E=>{if(lodashEs.isEmpty(E))f([]);else{const y=await l(u,E);f(y)}d(!1),b(-1)},[u],300),A=E=>{const y=["pageType",u,E.id];y[1]&&(a(y.join(":")),x(E.name),p(!1),f([]),b(-1))},B=E=>{switch(E.key){case"ArrowDown":E.preventDefault(),b(y=>y<g.length-1?y+1:y);break;case"ArrowUp":E.preventDefault(),b(y=>y>0?y-1:y);break;case"Enter":if(E.preventDefault(),g.length===0)return;j>=0&&A(g[j]);break;case"Escape":E.preventDefault(),R();break}};React.useEffect(()=>{if(j>=0&&k.current){const E=k.current.children[j];E==null||E.scrollIntoView({block:"nearest"})}},[j]);const R=()=>{x(""),f([]),b(-1),p(!1),a("")},C=E=>{x(E),p(!lodashEs.isEmpty(E)),d(!0),v(E)};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("select",{name:"pageType",value:u,onChange:E=>m(E.target.value),children:lodashEs.map(n,E=>jsxRuntime.jsx("option",{value:E.key,children:E.name},E.key))}),u&&jsxRuntime.jsxs("div",{className:"group relative mt-2 flex items-center",children:[jsxRuntime.jsx("input",{type:"text",value:h,onChange:E=>C(E.target.value),onKeyDown:B,placeholder:r(`Search ${S??""}`),className:"w-full rounded-md border border-gray-300 p-2 pr-16"}),jsxRuntime.jsx("div",{className:"absolute bottom-2 right-2 top-3 flex items-center gap-1.5",children:h&&jsxRuntime.jsx("button",{onClick:R,className:"text-gray-400 hover:text-gray-600",title:r("Clear search"),children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})})]}),(i||!lodashEs.isEmpty(g)||c&&lodashEs.isEmpty(g))&&jsxRuntime.jsx("div",{className:"absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg",children:i?jsxRuntime.jsxs("div",{className:"space-y-1 p-2",children:[jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),jsxRuntime.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):c&&lodashEs.isEmpty(g)?jsxRuntime.jsxs("div",{className:"flex items-center justify-center p-4 text-sm text-gray-500",children:[r("No results found for"),' "',h,'"']}):jsxRuntime.jsx("ul",{ref:k,children:lodashEs.map(g==null?void 0:g.slice(0,20),(E,y)=>jsxRuntime.jsxs("li",{onClick:()=>A(E),className:`cursor-pointer p-2 text-xs ${o!=null&&o.includes(E.id)?"bg-blue-200":y===j?"bg-gray-100":"hover:bg-gray-100"}`,children:[E.name," ",E.slug&&jsxRuntime.jsxs("small",{className:"font-light text-gray-500",children:["( ",E.slug," )"]})]},E.id))})})]})},LinkField=({schema:o,formData:n,onChange:a})=>{const{t:r}=reactI18next.useTranslation(),{type:l="pageType",href:i="",target:d="self"}=n,c=useBuilderProp("pageTypes",[]),p=l==="pageType"&&lodashEs.isEmpty(c)?"url":l;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-xs font-medium",children:(o==null?void 0:o.title)??"Link"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("select",{name:"type",value:l,onChange:u=>a({...n,type:u.target.value}),children:lodashEs.map([...lodashEs.isEmpty(c)?[]:[{const:"pageType",title:r("Goto Page")}],{const:"url",title:r("Open URL")},{const:"email",title:r("Compose Email")},{const:"telephone",title:r("Call Phone")},{const:"scroll",title:r("Scroll to element")}],u=>jsxRuntime.jsx("option",{value:u.const,children:u.title},u.const))}),p==="pageType"&&!lodashEs.isEmpty(c)?jsxRuntime.jsx(PageTypeField,{href:i,pageTypes:c,onChange:u=>a({...n,href:u})}):jsxRuntime.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",value:i,onChange:u=>a({...n,href:u.target.value}),placeholder:r(l==="url"?"Enter URL":l==="scroll"?"#ElementID":"Enter details")}),p==="url"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[jsxRuntime.jsx("input",{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"checkbox",defaultChecked:d==="_blank",className:"!w-fit cursor-pointer rounded-md border border-border",onChange:()=>a({...n,target:d==="_blank"?"_self":"_blank"})}),jsxRuntime.jsx("span",{className:"pt-1 text-xs",children:r("Open in new tab")})]})]})]})},RowColField=()=>{const o=useSelectedBlock(),n=useWrapperBlock(),{addCoreBlock:a}=useAddBlock();if(!o&&!n)return null;const r=(o==null?void 0:o._type)==="Row"?o:n;return jsxRuntime.jsx("div",{className:"pt-1",children:jsxRuntime.jsxs("button",{type:"button",className:"duratiom-300 flex items-center gap-x-1 rounded border border-gray-400 bg-gray-100 px-4 py-1 text-[11px] font-medium leading-tight hover:bg-slate-200",onClick:()=>a({type:"Column",styles:"#styles:,"},r==null?void 0:r._id),children:[jsxRuntime.jsx(lucideReact.Plus,{className:"h-4 w-4"})," Add Column"]})})};function cn(...o){return tailwindMerge.twMerge(clsx.clsx(o))}const MenuBar=({editor:o,onExpand:n})=>{if(!o)return null;const a=()=>{const l=window.prompt("URL");l&&o.chain().focus().extendMarkRange("link").setLink({href:l}).run()},r=()=>{o.chain().focus().unsetLink().run()};return jsxRuntime.jsxs("div",{className:"mb-1 flex flex-wrap gap-1 rounded-md border border-border p-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleBold().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("bold")}),title:"Bold",children:jsxRuntime.jsx(lucideReact.Bold,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleItalic().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("italic")}),title:"Italic",children:jsxRuntime.jsx(lucideReact.Italic,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleUnderline().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("underline")}),title:"Underline",children:jsxRuntime.jsx(lucideReact.Underline,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleStrike().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("strike")}),title:"Strike",children:jsxRuntime.jsx(lucideReact.Strikethrough,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleBulletList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("bulletList")}),title:"Bullet List",children:jsxRuntime.jsx(lucideReact.List,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().toggleOrderedList().run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("orderedList")}),title:"Ordered List",children:jsxRuntime.jsx(lucideReact.ListOrdered,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("left").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"left"})}),title:"Align Left",children:jsxRuntime.jsx(lucideReact.AlignLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("center").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"center"})}),title:"Align Center",children:jsxRuntime.jsx(lucideReact.AlignCenter,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o.chain().focus().setTextAlign("right").run(),className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive({textAlign:"right"})}),title:"Align Right",children:jsxRuntime.jsx(lucideReact.AlignRight,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:a,className:cn("rounded p-1 hover:bg-muted",{"bg-muted":o.isActive("link")}),title:"Add Link",children:jsxRuntime.jsx(lucideReact.Link,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:r,className:cn("rounded p-1 hover:bg-muted"),title:"Remove Link",disabled:!o.isActive("link"),children:jsxRuntime.jsx(lucideReact.Unlink,{className:"h-4 w-4"})}),n&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"mx-1 h-6 w-px self-center bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:n,className:"rounded p-1 hover:bg-muted",title:"Open in full screen mode",children:jsxRuntime.jsx(lucideReact.Maximize2,{className:"h-4 w-4"})})]})]})},RTEModal=({isOpen:o,onClose:n,id:a,value:r,onChange:l,onBlur:i})=>{const d=React.useRef(null),c=React.useRef(r||""),p=usePageExternalData();React.useEffect(()=>{if(o){const h=document.createElement("style");return h.id="rte-modal-styles",h.innerHTML=`
|
|
61
61
|
/* Ensure the NestedPathSelector popover appears above the dialog */
|
|
62
62
|
.rte-path-selector + [data-radix-popper-content-wrapper],
|
|
63
63
|
[data-radix-popper-content-wrapper] {
|
package/dist/core.js
CHANGED
|
@@ -3287,7 +3287,13 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3287
3287
|
), x = useMemo(() => getBlockTagAttributes(n), [n, getBlockTagAttributes]), y = useMemo(
|
|
3288
3288
|
() => d(n._id, getBlockRuntimeProps(n._type)),
|
|
3289
3289
|
[n._id, n._type, d, getBlockRuntimeProps]
|
|
3290
|
-
), b = useMemo(() => !has(a, "dataProvider") || !isFunction(a.dataProvider) ? {} : a.dataProvider(
|
|
3290
|
+
), b = useMemo(() => !has(a, "dataProvider") || !isFunction(a.dataProvider) ? {} : a.dataProvider({
|
|
3291
|
+
block: n,
|
|
3292
|
+
draft: !0,
|
|
3293
|
+
inBuilder: !0,
|
|
3294
|
+
lang: l || i,
|
|
3295
|
+
pageProps: {}
|
|
3296
|
+
}), [n, l, i, a, c]), v = useMemo(
|
|
3291
3297
|
() => ({
|
|
3292
3298
|
blockProps: {
|
|
3293
3299
|
"data-block-id": n._id,
|