@trycourier/react-designer 0.0.0-canary-20251016130317 → 0.0.0-canary-20251016145020
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/cjs/index.js +3 -3
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/styles.css +3 -0
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/styles.css +3 -0
- package/dist/styles.css +3 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -177,7 +177,7 @@ if (typeof require !== "undefined") {
|
|
|
177
177
|
`&&("text_style"in o&&(o.text_style==="h1"||o.text_style==="h2")?r||(r=n):t||(t=n))}if(o.type==="channel"&&"elements"in o&&o.elements){let n=nc(o.elements);if(n)return n}}return r||t||""}s(nc,"getTitle");function ic(e,t){if(!e||!e.elements)return"";let r=e.elements.find(o=>o.type==="channel"&&o.channel===t);if(!r||r.type!=="channel")return"";if("raw"in r&&r.raw){if("subject"in r.raw&&r.raw.subject)return r.raw.subject;if("title"in r.raw&&r.raw.title)return r.raw.title}if("elements"in r&&r.elements){if(t==="email"){let o=r.elements.find(n=>n.type==="meta");return o&&"title"in o&&o.title?o.title:""}return nc(r.elements)}return""}s(ic,"getTitleForChannel");function _t(e,t){var a;let r=e||{version:"2022-01-01",elements:[]},o={...r,elements:[]},n;typeof t.channel=="string"?n=t.channel:t.channel&&typeof t.channel.channel=="string"?n=t.channel.channel:t.channel;let i=!1;if(r.elements&&Array.isArray(r.elements)&&r.elements.forEach(c=>{var l;if(c.type!=="meta")if(c.type==="channel"){let u=c,d=!1;if(n?u.channel===n&&(d=!0):i||(d=!0),d){let p={};if(t.channel&&typeof t.channel=="object")for(let g in t.channel)g!=="type"&&g!=="elements"&&g!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,g)&&(p[g]=t.channel[g]);let m={type:"channel",channel:u.channel,...Object.fromEntries(Object.entries(u).filter(([g])=>!["type","channel","elements"].includes(g))),...p};if(t.elements!==void 0){let g=[],b=t.elements.find(y=>y.type==="meta");if(b)g.push(b);else{let y=(l=u.elements)==null?void 0:l.find(P=>P.type==="meta");y&&g.push(y)}let h=t.elements.filter(y=>y.type!=="meta");g.push(...h),m.elements=g}o.elements.push(m),i=!0}else o.elements.push(c)}else o.elements.push(c)}),n&&!i||!((a=r.elements)!=null&&a.some(c=>c.type==="channel"))&&!i){let c;n?c=n:t.channel&&typeof t.channel=="object"&&t.channel.channel?c=t.channel.channel:c="email";let l={};if(t.channel&&typeof t.channel=="object")for(let d in t.channel)d!=="type"&&d!=="elements"&&d!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,d)&&(l[d]=t.channel[d]);let u={type:"channel",channel:c,...l};if(t.elements!==void 0){let d=[],p=t.elements.find(g=>g.type==="meta");p&&d.push(p);let m=t.elements.filter(g=>g.type!=="meta");d.push(...m),u.elements=d}o.elements.push(u)}return o}s(_t,"updateElemental");function N(...e){return(0,Xd.twMerge)((0,Kd.clsx)(e))}s(N,"cn");var Yd=require("@radix-ui/react-slot"),Qd=require("class-variance-authority"),ep=require("react"),tp=require("react/jsx-runtime"),Ja=(0,Qd.cva)("courier-flex courier-group courier-items-center courier-justify-center courier-border courier-border-transparent courier-gap-2 courier-text-sm courier-font-semibold courier-rounded-md disabled:courier-opacity-50 courier-whitespace-nowrap courier-outline-none",{variants:{variant:{primary:"courier-text-white courier-bg-[#3B82F6] courier-border-[#3B82F6] dark:courier-text-foreground dark:courier-bg-white dark:courier-border-white",secondary:"courier-text-foreground courier-bg-[#F5F5F5]",tertiary:"courier-bg-neutral-50 courier-text-foreground dark:courier-bg-foreground dark:courier-text-white dark:courier-border-foreground",quaternary:"courier-bg-transparent courier-border-transparent courier-text-neutral-500 dark:courier-text-neutral-400",ghost:"hover:courier-bg-accent hover:courier-text-accent-foreground",link:"courier-text-foreground !courier-font-normal hover:courier-text-accent-foreground !courier-p-0 courier-border-none",outline:"!courier-border-border courier-text-foreground dark:courier-text-white dark:courier-border-foreground hover:courier-bg-neutral-100 dark:hover:courier-bg-neutral-800"},size:{medium:"courier-py-2 courier-px-3",small:"courier-py-1 courier-px-2",icon:"courier-w-8 courier-h-8",iconSmall:"courier-w-6 courier-h-6"},active:{true:"",false:""},disabled:{true:"",false:""}},compoundVariants:[{variant:"primary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-800 active:courier-bg-neutral-900 dark:hover:courier-bg-neutral-200 dark:active:courier-bg-neutral-300"},{variant:"primary",active:!0,class:"courier-bg-neutral-900 dark:courier-bg-neutral-300"},{variant:"secondary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-900 dark:active:courier-bg-neutral-800"},{variant:"secondary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"tertiary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-800 dark:active:courier-bg-neutral-700"},{variant:"tertiary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"ghost",disabled:!1,active:!1,class:"hover:courier-bg-black/5 hover:courier-text-neutral-700 active:courier-bg-black/10 active:courier-text-neutral-800 dark:hover:courier-bg-white/10 dark:hover:courier-text-neutral-300 dark:active:courier-text-neutral-200"},{variant:"ghost",active:!0,class:"courier-bg-accent courier-text-accent-foreground [&_svg]:courier-text-accent-foreground dark:courier-bg-white/20 dark:courier-text-neutral-200"}]}),Ne=(0,ep.forwardRef)(({active:e,buttonSize:t="medium",disabled:r,variant:o="primary",className:n,asChild:i=!1,...a},c)=>(0,tp.jsx)(i?Yd.Slot:"button",{ref:c,disabled:r,className:N(Ja({variant:o,size:t,disabled:r,active:e}),n),...a}));Ne.displayName="Button";var rp=require("react"),op=require("react/jsx-runtime"),le=(0,rp.forwardRef)((e,t)=>(0,op.jsx)("hr",{...e,ref:t,className:N("courier-my-1 courier-border-border dark:courier-border-neutral-800",e.className)}));le.displayName="Divider";var Ro=Me(require("react"),1),me=Me(require("@radix-ui/react-dropdown-menu"),1),si=require("lucide-react");var st=require("react/jsx-runtime"),Ka=me.Root,Xa=me.Trigger;var $5=Ro.forwardRef(({className:e,inset:t,children:r,...o},n)=>(0,st.jsxs)(me.SubTrigger,{ref:n,className:N("courier-flex courier-cursor-default courier-gap-2 courier-select-none courier-items-center courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent data-[state=open]:courier-bg-accent [&_svg]:courier-pointer-events-none [&_svg]:courier-size-4 [&_svg]:courier-shrink-0",t&&"courier-pl-8",e),...o,children:[r,(0,st.jsx)(si.ChevronRight,{className:"courier-ml-auto"})]}));$5.displayName=me.SubTrigger.displayName;var _5=Ro.forwardRef(({className:e,...t},r)=>(0,st.jsx)(me.SubContent,{ref:r,className:N("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-lg data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...t}));_5.displayName=me.SubContent.displayName;var Gi=Ro.forwardRef(({className:e,sideOffset:t=4,portalProps:r,...o},n)=>(0,st.jsx)(me.Portal,{...r,children:(0,st.jsx)(me.Content,{ref:n,sideOffset:t,className:N("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-md","data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...o})}));Gi.displayName=me.Content.displayName;var Ji=Ro.forwardRef(({className:e,inset:t,...r},o)=>(0,st.jsx)(me.Item,{ref:o,className:N("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-gap-2 courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50 [&>svg]:courier-size-4 [&>svg]:courier-shrink-0",t&&"courier-pl-8",e),...r}));Ji.displayName=me.Item.displayName;var Z5=Ro.forwardRef(({className:e,children:t,checked:r,...o},n)=>(0,st.jsxs)(me.CheckboxItem,{ref:n,className:N("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),checked:r,...o,children:[(0,st.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,st.jsx)(me.ItemIndicator,{children:(0,st.jsx)(si.Check,{className:"courier-h-4 courier-w-4"})})}),t]}));Z5.displayName=me.CheckboxItem.displayName;var q5=Ro.forwardRef(({className:e,children:t,...r},o)=>(0,st.jsxs)(me.RadioItem,{ref:o,className:N("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),...r,children:[(0,st.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,st.jsx)(me.ItemIndicator,{children:(0,st.jsx)(si.Circle,{className:"courier-h-2 courier-w-2 courier-fill-current"})})}),t]}));q5.displayName=me.RadioItem.displayName;var j5=Ro.forwardRef(({className:e,inset:t,...r},o)=>(0,st.jsx)(me.Label,{ref:o,className:N("courier-px-2 courier-py-1.5 courier-text-sm courier-font-semibold",t&&"courier-pl-8",e),...r}));j5.displayName=me.Label.displayName;var G5=Ro.forwardRef(({className:e,...t},r)=>(0,st.jsx)(me.Separator,{ref:r,className:N("courier-mx-1 courier-my-1 courier-h-px courier-bg-muted",e),...t}));G5.displayName=me.Separator.displayName;var J5=s(({className:e,...t})=>(0,st.jsx)("span",{className:N("courier-ml-auto courier-text-xs courier-tracking-widest courier-opacity-60",e),...t}),"DropdownMenuShortcut");J5.displayName="DropdownMenuShortcut";var np=require("react");var li=require("react/jsx-runtime"),ac=class ac extends np.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){var o,n;console.error("ErrorBoundary caught an error:",t,r),(n=(o=this.props).onError)==null||n.call(o,t,r)}render(){return this.state.hasError?this.props.fallback||(0,li.jsx)(K5,{error:this.state.error}):this.props.children}};s(ac,"ErrorBoundary");var Ya=ac,K5=s(({error:e})=>(0,li.jsxs)("div",{className:"courier-p-6 courier-border courier-border-red-200 courier-bg-red-50 courier-rounded-lg courier-text-center",children:[(0,li.jsx)("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),(0,li.jsx)("p",{className:"courier-text-red-600 courier-mb-4",children:"An unexpected error occurred in the editor. Please refresh the page or contact support if the problem persists."}),!1]}),"DefaultErrorFallback");var lp=require("@radix-ui/react-slot"),er=Me(require("react"),1),ci=require("react-hook-form");var sc=Me(require("@radix-ui/react-label"),1),ip=require("class-variance-authority"),ap=Me(require("react"),1),sp=require("react/jsx-runtime"),X5=(0,ip.cva)("courier-text-sm courier-font-medium courier-leading-none peer-disabled:courier-cursor-not-allowed peer-disabled:courier-opacity-70"),lc=ap.forwardRef(({className:e,...t},r)=>(0,sp.jsx)(sc.Root,{ref:r,className:N(X5(),e),...t}));lc.displayName=sc.Root.displayName;var Bo=require("react/jsx-runtime"),Ye=ci.FormProvider,cp=er.createContext({}),q=s(({...e})=>(0,Bo.jsx)(cp.Provider,{value:{name:e.name},children:(0,Bo.jsx)(ci.Controller,{...e})}),"FormField"),Qa=s(()=>{let e=er.useContext(cp),t=er.useContext(up),{getFieldState:r,formState:o}=(0,ci.useFormContext)(),n=r(e.name,o);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...n}},"useFormField"),up=er.createContext({}),_=er.forwardRef(({className:e,...t},r)=>{let o=er.useId();return(0,Bo.jsx)(up.Provider,{value:{id:o},children:(0,Bo.jsx)("div",{ref:r,className:N("courier-space-y-2",e),...t})})});_.displayName="FormItem";var Br=er.forwardRef(({className:e,...t},r)=>{let{error:o,formItemId:n}=Qa();return(0,Bo.jsx)(lc,{ref:r,className:N(o&&"courier-text-destructive",e),htmlFor:n,...t})});Br.displayName="FormLabel";var Z=er.forwardRef(({...e},t)=>{let{error:r,formItemId:o,formDescriptionId:n,formMessageId:i}=Qa();return(0,Bo.jsx)(lp.Slot,{ref:t,id:o,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...e})});Z.displayName="FormControl";var Y5=er.forwardRef(({className:e,...t},r)=>{let{formDescriptionId:o}=Qa();return(0,Bo.jsx)("p",{ref:r,id:o,className:N("courier-text-[0.8rem] courier-text-muted-foreground",e),...t})});Y5.displayName="FormDescription";var G=er.forwardRef(({className:e,children:t,...r},o)=>{let{error:n,formMessageId:i}=Qa(),a=n?String(n==null?void 0:n.message):t;return a?(0,Bo.jsx)("p",{ref:o,id:i,className:N("courier-text-[0.8rem] courier-font-medium courier-text-destructive",e),...r,children:a}):null});G.displayName="FormMessage";var Be=Me(require("@radix-ui/react-alert-dialog"),1),wn=Me(require("react"),1);var dp=require("react");var Er=require("react/jsx-runtime"),pp=Be.Root,mp=Be.Trigger,Q5=Be.Portal,fp=wn.forwardRef(({className:e,...t},r)=>(0,Er.jsx)("div",{className:"courier-absolute courier-inset-0 courier-z-50 courier-bg-[#0a0a0a52] data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",children:(0,Er.jsx)(Be.Overlay,{asChild:!0,className:N("courier-fixed courier-inset-0 courier-z-50 courier-bg-black/80 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",e),...t,ref:r})}));fp.displayName=Be.Overlay.displayName;var cc=wn.forwardRef(({className:e,...t},r)=>{let o=(0,dp.useCallback)(()=>{var i;let n=(i=r==null?void 0:r.current)==null?void 0:i.parentElement;for(;n;){if(n.classList.contains("theme-container"))return n;n=n.parentElement}return document.body},[r]);return(0,Er.jsxs)(Q5,{container:typeof window!="undefined"?o():void 0,children:[(0,Er.jsx)(fp,{}),(0,Er.jsx)(Be.Content,{ref:r,className:N("courier-fixed courier-left-[50%] courier-top-[50%] courier-z-50 courier-grid courier-w-full courier-max-w-lg courier-translate-x-[-50%] courier-translate-y-[-50%] courier-gap-4 courier-border courier-bg-background courier-p-6 courier-shadow-lg courier-duration-200 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[state=closed]:courier-slide-out-to-left-1/2 data-[state=closed]:courier-slide-out-to-top-[48%] data-[state=open]:courier-slide-in-from-left-1/2 data-[state=open]:courier-slide-in-from-top-[48%] sm:courier-rounded-lg",e),...t})]})});cc.displayName=Be.Content.displayName;var uc=s(({className:e,...t})=>(0,Er.jsx)("div",{className:N("courier-flex courier-flex-col courier-space-y-2 courier-text-center sm:courier-text-left",e),...t}),"AlertDialogHeader");uc.displayName="AlertDialogHeader";var dc=s(({className:e,...t})=>(0,Er.jsx)("div",{className:N("courier-flex courier-flex-col-reverse sm:courier-flex-row sm:courier-justify-end sm:courier-space-x-2",e),...t}),"AlertDialogFooter");dc.displayName="AlertDialogFooter";var eh=wn.forwardRef(({className:e,...t},r)=>(0,Er.jsx)(Be.Title,{ref:r,className:N("courier-text-lg courier-font-semibold",e),...t}));eh.displayName=Be.Title.displayName;var th=wn.forwardRef(({className:e,...t},r)=>(0,Er.jsx)(Be.Description,{ref:r,className:N("courier-text-sm courier-text-muted-foreground",e),...t}));th.displayName=Be.Description.displayName;var pc=wn.forwardRef(({className:e,...t},r)=>(0,Er.jsx)(Be.Action,{ref:r,className:N(Ja(),e),...t}));pc.displayName=Be.Action.displayName;var mc=wn.forwardRef(({className:e,...t},r)=>(0,Er.jsx)(Be.Cancel,{ref:r,className:N(Ja({variant:"outline"}),"courier-mt-2 sm:courier-mt-0",e),...t}));mc.displayName=Be.Cancel.displayName;var gp=Me(require("react"),1),ui=require("react/jsx-runtime"),ce=gp.forwardRef(({className:e,type:t,startAdornment:r,endAdornment:o,...n},i)=>(0,ui.jsxs)("div",{className:"courier-relative courier-flex courier-w-full courier-items-center",children:[r&&(0,ui.jsx)("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),(0,ui.jsx)("input",{type:t,className:N("courier-flex courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base file:courier-border-0 file:courier-bg-transparent file:courier-text-sm file:courier-font-medium file:courier-text-foreground placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm",r&&"courier-pl-8",o&&"courier-pr-8",e),ref:i,...n}),o&&(0,ui.jsx)("div",{className:"courier-absolute courier-right-2 courier-flex courier-items-center courier-pointer-events-none",children:o})]}));ce.displayName="Input";var Qo=require("react");var Zt=require("react");var hp=require("lucide-react");var tr=require("react/jsx-runtime"),rh=s(e=>e==="transparent"||/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e),"isValidHex"),bp=s(({color:e,onChange:t,className:r,presetColors:o,defaultValue:n="transparent"})=>{let[i,a]=(0,Zt.useState)(()=>Ki(e)),[c,l]=(0,Zt.useState)(e),u=(0,Zt.useRef)(null),d=(0,Zt.useRef)(null),p=(0,Zt.useRef)(null),m=(0,Zt.useRef)(!1),g=e!==n,b=(0,Zt.useCallback)(v=>{m.current=!0;let f=oh(v);l(f),t(f),m.current=!1},[t]),h=s(v=>f=>{p.current=v,y(f)},"handleMouseDown"),y=(0,Zt.useCallback)(v=>{if(p.current){if(p.current==="gradient"&&u.current){let f=u.current.getBoundingClientRect(),C=Math.max(0,Math.min(1,(v.clientX-f.left)/f.width)),T=Math.max(0,Math.min(1,(v.clientY-f.top)/f.height)),R={...i,s:C*100,v:(1-T)*100};a(R),b(R)}else if(p.current==="hue"&&d.current){let f=d.current.getBoundingClientRect(),C=Math.max(0,Math.min(1,(v.clientX-f.left)/f.width)),T={...i,h:C*360};a(T),b(T)}}},[i,b]),P=(0,Zt.useCallback)(()=>{p.current=null},[]);(0,Zt.useEffect)(()=>{if(p.current)return window.addEventListener("mousemove",y),window.addEventListener("mouseup",P),()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",P)}},[y,P]),(0,Zt.useEffect)(()=>{m.current||(a(Ki(e)),l(e))},[e]);let w=s(v=>{let f=v.target.value;if(l(f),rh(f)){let C=Ki(f);a(C),b(C)}},"handleInputChange");return(0,tr.jsxs)("div",{className:N("w-full",r),children:[(0,tr.jsx)("div",{ref:u,className:"courier-relative courier-h-[160px] courier-w-full courier-cursor-crosshair courier-rounded-lg",style:{backgroundColor:`hsl(${i.h}, 100%, 50%)`,backgroundImage:"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)"},onMouseDown:h("gradient"),children:(0,tr.jsx)("div",{className:"courier-absolute courier-h-3 courier-w-3 courier-translate-x-[-50%] courier-translate-y-[-50%] courier-rounded-full courier-border-2 courier-border-white",style:{left:`${i.s}%`,top:`${100-i.v}%`}})}),(0,tr.jsx)("div",{ref:d,className:"courier-relative courier-mt-2 courier-h-3 courier-w-full courier-cursor-pointer courier-rounded",style:{background:"linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)"},onMouseDown:h("hue"),children:(0,tr.jsx)("div",{className:"courier-absolute courier-h-full courier-w-1 courier-translate-x-[-50%] courier-rounded courier-border courier-border-input courier-bg-background",style:{left:`${i.h/360*100}%`}})}),(0,tr.jsxs)("div",{className:"courier-mt-3 courier-relative courier-flex courier-items-center",children:[(0,tr.jsx)(ce,{value:c,onChange:w,placeholder:"#000000",className:"courier-flex-1"}),g&&(0,tr.jsx)("button",{onClick:v=>{if(v.preventDefault(),n==="transparent"){t("transparent"),l("transparent"),a({h:0,s:0,v:0});return}let f=Ki(n);a(f),b(f)},className:"courier-absolute courier-right-3 courier-flex courier-cursor-pointer courier-items-center courier-justify-center courier-transition-colors",children:(0,tr.jsx)(hp.CircleX,{size:14,strokeWidth:1.25})})]}),(0,tr.jsx)(le,{className:"courier-my-3"}),(0,tr.jsx)("div",{className:"courier-flex courier-flex-wrap courier-gap-1",children:o.map(v=>(0,tr.jsx)("button",{className:N("courier-h-6 courier-w-6 courier-rounded-md courier-border courier-border-input courier-shrink-0",v==="transparent"&&fc),style:{backgroundColor:v==="transparent"?void 0:v},onClick:f=>{if(f.preventDefault(),v==="transparent"){t("transparent"),l("transparent"),a({h:0,s:0,v:0});return}let C=Ki(v);a(C),b(C)}},v))})]})},"ColorPicker");function Ki(e){if(e==="transparent")return{h:0,s:0,v:0};let t=parseInt(e.slice(1,3),16)/255,r=parseInt(e.slice(3,5),16)/255,o=parseInt(e.slice(5,7),16)/255,n=Math.max(t,r,o),i=Math.min(t,r,o),a=n-i,c=0,l=n===0?0:a/n,u=n;if(n!==i){switch(n){case t:c=(r-o)/a+(r<o?6:0);break;case r:c=(o-t)/a+2;break;case o:c=(t-r)/a+4;break}c/=6}return{h:c*360,s:l*100,v:u*100}}s(Ki,"hexToHsv");function oh({h:e,s:t,v:r}){t/=100,r/=100,e=e%360/360;let o=s(c=>{let l=(c+e*6)%6;return r-r*t*Math.max(0,Math.min(l,4-l,1))},"f"),n=Math.round(o(5)*255),i=Math.round(o(3)*255),a=Math.round(o(1)*255);return`#${[n,i,a].map(c=>c.toString(16).padStart(2,"0")).join("")}`}s(oh,"hsvToHex");var bo=Me(require("@radix-ui/react-popover"),1),yp=Me(require("react"),1);var gc=require("react/jsx-runtime"),vp=bo.Root,xp=bo.Trigger;var hc=yp.forwardRef(({className:e,align:t="center",side:r="bottom",sideOffset:o=4,collisionPadding:n=10,avoidCollisions:i=!0,portalProps:a,...c},l)=>(0,gc.jsx)(bo.Portal,{...a,children:(0,gc.jsx)(bo.Content,{ref:l,side:r,align:t,sideOffset:o,collisionPadding:n,avoidCollisions:i,className:N("courier-z-50 courier-w-72 courier-rounded-md courier-border courier-bg-popover courier-p-4 courier-text-popover-foreground courier-shadow-md courier-outline-none data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...c})}));hc.displayName=bo.Content.displayName;var Ho=require("react/jsx-runtime"),fc="bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAwSDBWOEg4VjBaIiBmaWxsPSIjRDlEOUQ5Ii8+PHBhdGggZD0iTTE2IDhIOFYxNkgxNlY4WiIgZmlsbD0iI0Q5RDlEOSIvPjwvc3ZnPg==')]",nh=["#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#000000","#525252","#a3a3a3","#ffffff","transparent"],pt=(0,Qo.forwardRef)(({className:e,value:t="",onChange:r,defaultValue:o,transparent:n=!0,presetColors:i=nh,...a},c)=>{let l=t!=="transparent",u=(0,Qo.useRef)(null),d=(0,Qo.useMemo)(()=>n?i:i.filter(m=>m!=="transparent"),[i,n]),p=(0,Qo.useCallback)(()=>{var g;let m=(g=u.current)==null?void 0:g.parentElement;for(;m;){if(m.classList.contains("theme-container"))return m;m=m.parentElement}return document.body},[]);return(0,Ho.jsxs)(vp,{children:[(0,Ho.jsx)(xp,{asChild:!0,children:(0,Ho.jsxs)("div",{className:"courier-relative courier-flex courier-items-center",ref:u,children:[(0,Ho.jsx)("div",{className:N("courier-absolute courier-left-2 courier-flex courier-h-4 courier-w-4 courier-cursor-pointer courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-input courier-transition-colors courier-z-10",l?"":fc),style:{backgroundColor:l?t:void 0}}),(0,Ho.jsx)(ce,{...a,ref:c,readOnly:!0,type:"text",value:t==="transparent"?"Transparent":t,className:N("courier-relative courier-cursor-pointer courier-pl-8",e)})]})}),(0,Ho.jsx)(hc,{portalProps:{container:typeof window!="undefined"?p():void 0},className:"courier-w-[230px]",children:(0,Ho.jsx)(bp,{color:t,onChange:r,presetColors:d,defaultValue:o})})]})});pt.displayName="InputColor";var Cp=Me(require("react"),1),bc=Me(require("@radix-ui/react-separator"),1);var Tp=require("react/jsx-runtime"),yc=Cp.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>(0,Tp.jsx)(bc.Root,{ref:n,decorative:r,orientation:t,className:N("courier-shrink-0 courier-bg-border",t==="horizontal"?"courier-h-[1px] courier-w-full":"courier-h-full courier-w-[1px]",e),...o}));yc.displayName=bc.Root.displayName;var wp=Me(require("react"),1),Do=Me(require("@radix-ui/react-slider"),1);var di=require("react/jsx-runtime"),vc=wp.forwardRef(({className:e,...t},r)=>(0,di.jsxs)(Do.Root,{ref:r,className:N("courier-relative courier-flex courier-w-full courier-touch-none courier-select-none courier-items-center",e),...t,children:[(0,di.jsx)(Do.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:(0,di.jsx)(Do.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),(0,di.jsx)(Do.Thumb,{className:"courier-block courier-h-4 courier-w-4 courier-rounded-full courier-bg-accent-foreground courier-shadow courier-transition-colors focus-visible:courier-outline-none focus-visible:courier-ring-1 focus-visible:courier-ring-ring disabled:courier-pointer-events-none disabled:courier-opacity-50"})]}));vc.displayName=Do.Root.displayName;var Ep=Me(require("react"),1),Xi=Me(require("@radix-ui/react-switch"),1);var xc=require("react/jsx-runtime"),pi=Ep.forwardRef(({className:e,...t},r)=>(0,xc.jsx)(Xi.Root,{className:N("courier-peer courier-inline-flex courier-h-5 courier-w-9 courier-shrink-0 courier-cursor-pointer courier-items-center courier-rounded-full courier-border-2 courier-border-transparent courier-shadow-sm courier-transition-colors focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2 focus-visible:courier-ring-offset-background disabled:courier-cursor-not-allowed disabled:courier-opacity-50 data-[state=checked]:courier-bg-accent-foreground data-[state=unchecked]:courier-bg-input",e),...t,ref:r,children:(0,xc.jsx)(Xi.Thumb,{className:N("courier-pointer-events-none courier-block courier-h-4 courier-w-4 courier-rounded-full courier-bg-background courier-shadow-lg courier-ring-0 courier-transition-transform data-[state=checked]:courier-translate-x-4 data-[state=unchecked]:courier-translate-x-0")})}));pi.displayName=Xi.Root.displayName;var es=Me(require("react"),1),eo=Me(require("@radix-ui/react-tabs"),1);var os=require("react/jsx-runtime"),ts=eo.Root,Yi=es.forwardRef(({className:e,...t},r)=>(0,os.jsx)(eo.List,{ref:r,className:N("courier-inline-flex courier-h-9 courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-border courier-bg-background courier-p-[3px] courier-text-muted-foreground",e),...t}));Yi.displayName=eo.List.displayName;var mi=es.forwardRef(({className:e,...t},r)=>(0,os.jsx)(eo.Trigger,{ref:r,className:N("courier-inline-flex courier-items-center courier-justify-center courier-whitespace-nowrap courier-rounded-sm courier-px-3 courier-py-1 courier-text-sm courier-font-medium courier-ring-offset-background courier-transition-all focus-visible:courier-outline-none disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=active]:courier-bg-accent data-[state=active]:courier-text-accent-foreground",e),...t}));mi.displayName=eo.Trigger.displayName;var rs=es.forwardRef(({className:e,...t},r)=>(0,os.jsx)(eo.Content,{ref:r,className:N("courier-mt-2 courier-ring-offset-background focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2",e),...t}));rs.displayName=eo.Content.displayName;var fi=Me(require("react"),1);var kp=require("react/jsx-runtime"),Cc=fi.forwardRef(({className:e,autoResize:t=!1,...r},o)=>{let n=fi.useRef(null),i=s(a=>{n.current=a,typeof o=="function"?o(a):o&&(o.current=a)},"combinedRef");return fi.useEffect(()=>{if(!t)return;let a=n.current;if(!a)return;let c=s(()=>{a.style.height="auto",a.style.height=`${a.scrollHeight}px`},"adjustHeight");return c(),a.addEventListener("input",c),()=>{a.removeEventListener("input",c)}},[t]),(0,kp.jsx)("textarea",{className:N("courier-flex courier-min-h-[44px] courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base courier-placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm",t&&"courier-resize-none",e),ref:i,...r})});Cc.displayName="Textarea";var wc=require("react");var Np=require("react");var ns={colorScheme:"light",background:"#ffffff",foreground:"#404040",muted:"#D9D9D9",mutedForeground:"#A3A3A3",popover:"#ffffff",popoverForeground:"#292929",border:"#DCDEE4",input:"#DCDEE4",card:"#FAF9F8",cardForeground:"#292929",primary:"#ffffff",primaryForeground:"#696F8C",secondary:"#F5F5F5",secondaryForeground:"#171717",accent:"#E5F3FF",accentForeground:"#1D4ED8",destructive:"#292929",destructiveForeground:"#FF3363",ring:"#80849D",radius:"6px"},Pp={...ns},Mp={...ns,colorScheme:"dark",foreground:"#d4d4d4",background:"#262626",card:"#262626",primary:"#262626"};var Sp=(0,Np.createContext)(ns);var Tc=require("react/jsx-runtime"),Ap=(0,wc.forwardRef)(({children:e,theme:t,dataMode:r="light",className:o},n)=>{let i=r==="light"?Pp:Mp,a=i;t&&(a=typeof t=="string"?t:{...i,...t});let c=typeof t=="string"?{}:Object.entries(a).reduce((l,[u,d])=>{let p=u.replace(/[A-Z]/g,m=>`-${m.toLowerCase()}`);return{...l,[`--${p}`]:d}},{});return(0,Tc.jsx)(Sp.Provider,{value:typeof a=="object"?a:{},children:(0,Tc.jsx)("div",{style:c,className:N("courier-flex courier-flex-col courier-relative",typeof t=="string"?t:"","theme-container",o),ref:n,children:e})})});var Ip=Me(require("react"),1),Ec=Me(require("@radix-ui/react-toggle"),1),Lp=require("class-variance-authority");var Rp=require("react/jsx-runtime"),kc=(0,Lp.cva)("courier-inline-flex courier-items-center courier-justify-center courier-gap-2 courier-rounded-md courier-text-sm courier-font-medium courier-transition-colors hover:courier-bg-secondary hover:courier-text-foreground focus-visible:courier-outline-none focus-visible:courier-ring-1 focus-visible:courier-ring-ring disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=on]:courier-bg-accent data-[state=on]:courier-text-accent-foreground [&_svg]:courier-pointer-events-none [&_svg]:courier-size-[30px] [&_svg]:courier-shrink-0",{variants:{variant:{default:"courier-bg-transparent",outline:"courier-border courier-border-input courier-bg-transparent courier-shadow-sm hover:courier-bg-accent hover:courier-text-accent-foreground"},size:{default:"courier-h-9 courier-min-w-9",sm:"courier-h-8 courier-px-1.5 courier-min-w-8",lg:"courier-h-10 courier-px-2.5 courier-min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),ih=Ip.forwardRef(({className:e,variant:t,size:r,...o},n)=>(0,Rp.jsx)(Ec.Root,{ref:n,className:N(kc({variant:t,size:r,className:e})),...o}));ih.displayName=Ec.Root.displayName;var gi=Me(require("@radix-ui/react-toggle-group"),1),En=Me(require("react"),1);var is=require("react/jsx-runtime"),Bp=En.createContext({size:"default",variant:"default"}),rr=En.forwardRef(({className:e,variant:t,size:r,children:o,...n},i)=>(0,is.jsx)(gi.Root,{ref:i,className:N("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:(0,is.jsx)(Bp.Provider,{value:{variant:t,size:r},children:o})}));rr.displayName=gi.Root.displayName;var Qe=En.forwardRef(({className:e,children:t,variant:r,size:o,...n},i)=>{let a=En.useContext(Bp);return(0,is.jsx)(gi.Item,{ref:i,className:N(kc({variant:a.variant||r,size:a.size||o}),e),...n,children:t})});Qe.displayName=gi.Item.displayName;var as=require("react/jsx-runtime"),Te=s(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?(0,as.jsx)("path",{className:N(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):(0,as.jsx)("path",{className:N(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),J=s(({width:e=28,height:t=28,...r})=>(0,as.jsx)("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");var hi=require("react/jsx-runtime"),Hp=s(({color:e="#000000",width:t=19,height:r=10,...o})=>(0,hi.jsxs)(J,{...o,width:t,height:r,children:[(0,hi.jsx)("rect",{opacity:"0.6",x:"0.553621",y:"0.876863",width:"16.4923",height:"7.87692",rx:"1.6",stroke:e,strokeWidth:"0.738462"}),(0,hi.jsx)("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),(0,hi.jsx)("path",{opacity:"0.6",d:"M17.9075 3.70703C18.4513 3.70703 18.8921 4.14786 18.8921 4.69165V4.9378C18.8921 5.48159 18.4513 5.92242 17.9075 5.92242V3.70703Z",fill:e})]}),"BatteryIcon");var Pc=require("react/jsx-runtime"),Qi=s(({color:e="#DC2626",width:t=13,height:r=13,...o})=>(0,Pc.jsx)(J,{...o,fill:"none",width:t,height:r,children:(0,Pc.jsx)("path",{d:"M4.89844 1.625C4.82812 1.625 4.78125 1.67188 4.73438 1.71875L4.28906 2.375H7.6875L7.24219 1.71875C7.21875 1.67188 7.14844 1.625 7.07812 1.625H4.89844ZM9.04688 2.375H9.35156H10.5H10.6875C10.9922 2.375 11.25 2.63281 11.25 2.9375C11.25 3.26562 10.9922 3.5 10.6875 3.5H10.4062L9.84375 11.1172C9.77344 11.9141 9.14062 12.5 8.34375 12.5H3.63281C2.83594 12.5 2.20312 11.9141 2.13281 11.1172L1.57031 3.5H1.3125C0.984375 3.5 0.75 3.26562 0.75 2.9375C0.75 2.63281 0.984375 2.375 1.3125 2.375H1.5H2.625H2.92969L3.79688 1.08594C4.03125 0.734375 4.45312 0.5 4.89844 0.5H7.07812C7.52344 0.5 7.94531 0.734375 8.17969 1.08594L9.04688 2.375ZM9.28125 3.5H2.69531L3.25781 11.0469C3.28125 11.2344 3.44531 11.375 3.63281 11.375H8.34375C8.53125 11.375 8.69531 11.2344 8.71875 11.0469L9.28125 3.5Z",fill:e})}),"BinIcon");var Mc=require("react/jsx-runtime"),kn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Mc.jsx)(J,{...n,width:r,height:o,children:(0,Mc.jsx)(Te,{active:t,colorProp:"stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",d:"M1 15V11C1 5.47715 5.47715 1 11 1H15"})}),"BorderRadiusIcon");var bi=require("react/jsx-runtime"),to=s(({color:e="#A3A3A3",width:t=16,height:r=16,...o})=>(0,bi.jsxs)(J,{...o,width:t,height:r,children:[(0,bi.jsx)("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),(0,bi.jsx)("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),(0,bi.jsx)("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");var Nc=require("react/jsx-runtime"),Sc=s(({color:e,width:t=21,height:r=16,...o})=>(0,Nc.jsx)(J,{...o,width:t,height:r,children:(0,Nc.jsx)("path",{d:"M2.5 1.5C2.21875 1.5 2 1.75 2 2V11C2 11.2812 2.21875 11.5 2.5 11.5H18.5C18.75 11.5 19 11.2812 19 11V2C19 1.75 18.75 1.5 18.5 1.5H2.5ZM0.5 2C0.5 0.90625 1.375 0 2.5 0H18.5C19.5938 0 20.5 0.90625 20.5 2V11C20.5 12.125 19.5938 13 18.5 13H2.5C1.375 13 0.5 12.125 0.5 11V2ZM4.25 14.5H16.75C17.1562 14.5 17.5 14.8438 17.5 15.25C17.5 15.6875 17.1562 16 16.75 16H4.25C3.8125 16 3.5 15.6875 3.5 15.25C3.5 14.8438 3.8125 14.5 4.25 14.5Z",fill:e})}),"DesktopIcon");var Ac=require("react/jsx-runtime"),Ic=s(({color:e="#171717",width:t=12,height:r=13,...o})=>(0,Ac.jsx)(J,{...o,fill:"none",width:t,height:r,children:(0,Ac.jsx)("path",{d:"M1.5 11.375H6.75C6.9375 11.375 7.125 11.2109 7.125 11V9.5H8.25V11C8.25 11.8438 7.57031 12.5 6.75 12.5H1.5C0.65625 12.5 0 11.8438 0 11V5.75C0 4.92969 0.65625 4.25 1.5 4.25H3V5.375H1.5C1.28906 5.375 1.125 5.5625 1.125 5.75V11C1.125 11.2109 1.28906 11.375 1.5 11.375ZM5.25 7.625H10.5C10.6875 7.625 10.875 7.46094 10.875 7.25V2C10.875 1.8125 10.6875 1.625 10.5 1.625H5.25C5.03906 1.625 4.875 1.8125 4.875 2V7.25C4.875 7.46094 5.03906 7.625 5.25 7.625ZM3.75 7.25V2C3.75 1.17969 4.40625 0.5 5.25 0.5H10.5C11.3203 0.5 12 1.17969 12 2V7.25C12 8.09375 11.3203 8.75 10.5 8.75H5.25C4.40625 8.75 3.75 8.09375 3.75 7.25Z",fill:e})}),"DuplicateIcon");var Lc=require("react/jsx-runtime"),ea=s(({color:e="#737373",width:t=16,height:r=16,...o})=>(0,Lc.jsx)(J,{...o,width:t,height:r,children:(0,Lc.jsx)(Te,{d:"M10.25 1H14.25C14.6562 1 15 1.34375 15 1.75V5.75C15 6.1875 14.6562 6.5 14.25 6.5C13.8125 6.5 13.5 6.1875 13.5 5.75V3.5625L9.03125 8L13.5 12.4688V10.25C13.5 9.84375 13.8125 9.5 14.25 9.5C14.6562 9.5 15 9.84375 15 10.25V14.25C15 14.6875 14.6562 15 14.25 15H10.25C9.8125 15 9.5 14.6875 9.5 14.25C9.5 13.8438 9.8125 13.5 10.25 13.5H12.4375L8 9.0625L3.53125 13.5H5.75C6.15625 13.5 6.5 13.8438 6.5 14.25C6.5 14.6875 6.15625 15 5.75 15H1.75C1.3125 15 1 14.6875 1 14.25V10.25C1 9.84375 1.3125 9.5 1.75 9.5C2.15625 9.5 2.5 9.84375 2.5 10.25V12.4688L6.9375 8L2.5 3.5625V5.75C2.5 6.1875 2.15625 6.5 1.75 6.5C1.3125 6.5 1 6.1875 1 5.75V1.75C1 1.34375 1.3125 1 1.75 1H5.75C6.15625 1 6.5 1.34375 6.5 1.75C6.5 2.1875 6.15625 2.5 5.75 2.5H3.53125L8 6.96875L12.4375 2.5H10.25C9.8125 2.5 9.5 2.1875 9.5 1.75C9.5 1.34375 9.8125 1 10.25 1Z",fill:e})}),"ExpandIcon");var Rc=require("react/jsx-runtime"),ta=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Rc.jsx)(J,{...n,width:r,height:o,children:(0,Rc.jsx)(Te,{d:"M16 8C16 12.0938 12.9062 15.4688 8.96875 15.9688V10.4688H11.125L11.5625 8H8.96875V7.15625C8.96875 5.84375 9.46875 5.34375 10.7812 5.34375C11.1875 5.34375 11.5 5.375 11.6875 5.375V3.1875C11.3438 3.0625 10.4688 2.96875 9.96875 2.96875C7.28125 2.96875 6.0625 4.25 6.0625 6.96875V8H4.40625V10.4688H6.0625V15.7812C2.5625 14.9062 0 11.75 0 8C0 3.59375 3.5625 0 8 0C12.4062 0 16 3.59375 16 8Z",active:t,fill:e})}),"FacebookIcon");var Bc=require("react/jsx-runtime"),Hc=s(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,Bc.jsx)(J,{...o,width:t,height:r,children:(0,Bc.jsx)(Te,{d:"M0 2.75C0 2.34375 0.3125 2 0.75 2H13.25C13.6562 2 14 2.34375 14 2.75C14 3.1875 13.6562 3.5 13.25 3.5H0.75C0.3125 3.5 0 3.1875 0 2.75ZM2 7.75C2 7.34375 2.3125 7 2.75 7H11.25C11.6562 7 12 7.34375 12 7.75C12 8.1875 11.6562 8.5 11.25 8.5H2.75C2.3125 8.5 2 8.1875 2 7.75ZM9 12.75C9 13.1875 8.65625 13.5 8.25 13.5H5.75C5.3125 13.5 5 13.1875 5 12.75C5 12.3438 5.3125 12 5.75 12H8.25C8.65625 12 9 12.3438 9 12.75Z",fill:e})}),"HamburgerMenuIcon");var ra=require("react/jsx-runtime"),ss=s(({color:e="#404040",width:t=18,height:r=20,...o})=>(0,ra.jsxs)(J,{...o,width:t,height:r,children:[(0,ra.jsx)("path",{d:"M13 4.5H3C2.71875 4.5 2.5 4.75 2.5 5V15C2.5 15.2812 2.71875 15.5 3 15.5H13C13.25 15.5 13.5 15.2812 13.5 15V5C13.5 4.75 13.25 4.5 13 4.5ZM3 3H13C14.0938 3 15 3.90625 15 5V15C15 16.125 14.0938 17 13 17H3C1.875 17 1 16.125 1 15V5C1 3.90625 1.875 3 3 3Z",fill:e}),(0,ra.jsx)("circle",{cx:"2",cy:"2",r:"3",transform:"matrix(-1 0 0 1 16 2)",fill:e,stroke:"white",strokeWidth:"2"})]}),"InAppIcon");var Dc=require("react/jsx-runtime"),Fc=s(({color:e="#404040",width:t=16,height:r=20,...o})=>(0,Dc.jsx)(J,{...o,width:t,height:r,children:(0,Dc.jsx)(Te,{d:"M1.5 12.5V15C1.5 15.2812 1.71875 15.5 2 15.5H14C14.25 15.5 14.5 15.2812 14.5 15V12.5H11.9375L11.2812 13.8125C11.0938 14.25 10.6562 14.5 10.1875 14.5H5.78125C5.3125 14.5 4.875 14.25 4.6875 13.8125L4.03125 12.5H1.5ZM14.1875 11L12.6562 4.90625C12.5938 4.65625 12.4062 4.5 12.1875 4.5H3.8125C3.5625 4.5 3.375 4.65625 3.3125 4.90625L1.78125 11H4.1875C4.65625 11 5.09375 11.2812 5.3125 11.7188L5.9375 13H10.0312L10.6875 11.7188C10.875 11.2812 11.3125 11 11.7812 11H14.1875ZM0 12.25C0 12.0938 0 11.9375 0.03125 11.7812L1.84375 4.53125C2.09375 3.625 2.875 3 3.8125 3H12.1875C13.0938 3 13.9062 3.625 14.125 4.53125L15.9375 11.7812C15.9688 11.9375 16 12.0938 16 12.25V15C16 16.125 15.0938 17 14 17H2C0.875 17 0 16.125 0 15V12.25Z",fill:e})}),"InboxIcon");var Vc=require("react/jsx-runtime"),oa=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Vc.jsx)(J,{...n,width:r,height:o,children:(0,Vc.jsx)(Te,{d:"M8 4.40625C9.96875 4.40625 11.5938 6.03125 11.5938 8C11.5938 10 9.96875 11.5938 8 11.5938C6 11.5938 4.40625 10 4.40625 8C4.40625 6.03125 6 4.40625 8 4.40625ZM8 10.3438C9.28125 10.3438 10.3125 9.3125 10.3125 8C10.3125 6.71875 9.28125 5.6875 8 5.6875C6.6875 5.6875 5.65625 6.71875 5.65625 8C5.65625 9.3125 6.71875 10.3438 8 10.3438ZM12.5625 4.28125C12.5625 3.8125 12.1875 3.4375 11.7188 3.4375C11.25 3.4375 10.875 3.8125 10.875 4.28125C10.875 4.75 11.25 5.125 11.7188 5.125C12.1875 5.125 12.5625 4.75 12.5625 4.28125ZM14.9375 5.125C15 6.28125 15 9.75 14.9375 10.9062C14.875 12.0312 14.625 13 13.8125 13.8438C13 14.6562 12 14.9062 10.875 14.9688C9.71875 15.0312 6.25 15.0312 5.09375 14.9688C3.96875 14.9062 3 14.6562 2.15625 13.8438C1.34375 13 1.09375 12.0312 1.03125 10.9062C0.96875 9.75 0.96875 6.28125 1.03125 5.125C1.09375 4 1.34375 3 2.15625 2.1875C3 1.375 3.96875 1.125 5.09375 1.0625C6.25 1 9.71875 1 10.875 1.0625C12 1.125 13 1.375 13.8125 2.1875C14.625 3 14.875 4 14.9375 5.125ZM13.4375 12.125C13.8125 11.2188 13.7188 9.03125 13.7188 8C13.7188 7 13.8125 4.8125 13.4375 3.875C13.1875 3.28125 12.7188 2.78125 12.125 2.5625C11.1875 2.1875 9 2.28125 8 2.28125C6.96875 2.28125 4.78125 2.1875 3.875 2.5625C3.25 2.8125 2.78125 3.28125 2.53125 3.875C2.15625 4.8125 2.25 7 2.25 8C2.25 9.03125 2.15625 11.2188 2.53125 12.125C2.78125 12.75 3.25 13.2188 3.875 13.4688C4.78125 13.8438 6.96875 13.75 8 13.75C9 13.75 11.1875 13.8438 12.125 13.4688C12.7188 13.2188 13.2188 12.75 13.4375 12.125Z",active:t,fill:e})}),"InstagramIcon");var Oc=require("react/jsx-runtime"),na=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Oc.jsx)(J,{...n,width:r,height:o,children:(0,Oc.jsx)(Te,{d:"M14 1C14.5312 1 15 1.46875 15 2.03125V14C15 14.5625 14.5312 15 14 15H1.96875C1.4375 15 1 14.5625 1 14V2.03125C1 1.46875 1.4375 1 1.96875 1H14ZM5.21875 13V6.34375H3.15625V13H5.21875ZM4.1875 5.40625C4.84375 5.40625 5.375 4.875 5.375 4.21875C5.375 3.5625 4.84375 3 4.1875 3C3.5 3 2.96875 3.5625 2.96875 4.21875C2.96875 4.875 3.5 5.40625 4.1875 5.40625ZM13 13V9.34375C13 7.5625 12.5938 6.15625 10.5 6.15625C9.5 6.15625 8.8125 6.71875 8.53125 7.25H8.5V6.34375H6.53125V13H8.59375V9.71875C8.59375 8.84375 8.75 8 9.84375 8C10.9062 8 10.9062 9 10.9062 9.75V13H13Z",active:t,fill:e})}),"LinkedinIcon");var Wc=require("react/jsx-runtime"),Uc=s(({color:e="#404040",width:t=16,height:r=16,...o})=>(0,Wc.jsx)(J,{...o,width:t,height:r,children:(0,Wc.jsx)("path",{d:"M13.5 0.5H2.5C1.39844 0.5 0.5 1.39844 0.5 2.5V13.5C0.5 14.6016 1.39844 15.5 2.5 15.5H13.5C14.6016 15.5 15.5 14.6016 15.5 13.5V2.5C15.5 1.39844 14.6016 0.5 13.5 0.5ZM10 11.75H6C5.58594 11.75 5.25 11.4141 5.25 11C5.25 10.5859 5.58594 10.25 6 10.25H10C10.4141 10.25 10.75 10.5859 10.75 11C10.75 11.4141 10.4141 11.75 10 11.75ZM12 8.75H4C3.58594 8.75 3.25 8.41406 3.25 8C3.25 7.58594 3.58594 7.25 4 7.25H12C12.4141 7.25 12.75 7.58594 12.75 8C12.75 8.41406 12.4141 8.75 12 8.75ZM12 5.75H4C3.58594 5.75 3.25 5.41406 3.25 5C3.25 4.58594 3.58594 4.25 4 4.25H12C12.4141 4.25 12.75 4.58594 12.75 5C12.75 5.41406 12.4141 5.75 12 5.75Z",fill:e})}),"MSTeamsIcon");var zc=require("react/jsx-runtime"),ia=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,zc.jsx)(J,{...n,width:r,height:o,children:(0,zc.jsx)(Te,{d:"M5.625 2.34375C8.75 2.34375 11.2812 4.875 11.2812 8C11.2812 11.1562 8.75 13.6875 5.625 13.6875C2.5 13.6875 0 11.1562 0 8C0 4.875 2.5 2.34375 5.625 2.34375ZM14.625 2.65625C16.1875 2.65625 17.4688 5.0625 17.4688 8.03125C17.4688 10.9688 16.1875 13.375 14.625 13.375C13.0625 13.375 11.8125 10.9688 11.8125 8.03125C11.8125 5.0625 13.0625 2.65625 14.625 2.65625ZM19 3.21875C19.5312 3.21875 20 5.375 20 8C20 10.6562 19.5312 12.8125 19 12.8125C18.4375 12.8125 18 10.6562 18 8.03125C18 5.375 18.4375 3.21875 19 3.21875Z",active:t,fill:e})}),"MediumIcon");var ls=require("react/jsx-runtime"),$c=s(({color:e,width:t=21,height:r=16,...o})=>(0,ls.jsx)(J,{...o,width:t,height:r,children:(0,ls.jsx)("g",{transform:"translate(4, 0)",children:(0,ls.jsx)("path",{d:"M8.5 1.5V2C8.5 2.28125 8.25 2.5 8 2.5H5C4.71875 2.5 4.5 2.28125 4.5 2V1.5H3.5C2.9375 1.5 2.5 1.96875 2.5 2.5V13.5C2.5 14.0625 2.9375 14.5 3.5 14.5H9.5C10.0312 14.5 10.5 14.0625 10.5 13.5V2.5C10.5 1.96875 10.0312 1.5 9.5 1.5H8.5ZM1 2.5C1 1.125 2.09375 0 3.5 0H9.5C10.875 0 12 1.125 12 2.5V13.5C12 14.9062 10.875 16 9.5 16H3.5C2.09375 16 1 14.9062 1 13.5V2.5Z",fill:e})})}),"MobileIcon");var _c=require("react/jsx-runtime"),Zc=s(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,_c.jsx)(J,{...o,width:t,height:r,children:(0,_c.jsx)(Te,{d:"M13.5 8C13.5 8.5625 13.1875 9.03125 12.75 9.3125C12.2812 9.59375 11.6875 9.59375 11.25 9.3125C10.7812 9.03125 10.5 8.5625 10.5 8C10.5 7.46875 10.7812 7 11.25 6.71875C11.6875 6.4375 12.2812 6.4375 12.75 6.71875C13.1875 7 13.5 7.46875 13.5 8ZM8.5 8C8.5 8.5625 8.1875 9.03125 7.75 9.3125C7.28125 9.59375 6.6875 9.59375 6.25 9.3125C5.78125 9.03125 5.5 8.5625 5.5 8C5.5 7.46875 5.78125 7 6.25 6.71875C6.6875 6.4375 7.28125 6.4375 7.75 6.71875C8.1875 7 8.5 7.46875 8.5 8ZM2 9.5C1.4375 9.5 0.96875 9.21875 0.6875 8.75C0.40625 8.3125 0.40625 7.71875 0.6875 7.25C0.96875 6.8125 1.4375 6.5 2 6.5C2.53125 6.5 3 6.8125 3.28125 7.25C3.5625 7.71875 3.5625 8.3125 3.28125 8.75C3 9.21875 2.53125 9.5 2 9.5Z",fill:e})}),"MoreMenuIcon");var qc=require("react/jsx-runtime"),aa=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,qc.jsx)(J,{...n,width:r,height:o,children:(0,qc.jsx)(Te,{d:"M14.25 0C14.6562 0 15 0.34375 15 0.75V15.25C15 15.6875 14.6562 16 14.25 16C13.8125 16 13.5 15.6875 13.5 15.25V0.75C13.5 0.34375 13.8125 0 14.25 0ZM9.5 11.5V4.5H6.5V11.5H9.5ZM11 4.5V11.5C11 12.3438 10.3125 13 9.5 13H6.5C5.65625 13 5 12.3438 5 11.5V4.5C5 3.6875 5.65625 3 6.5 3H9.5C10.3125 3 11 3.6875 11 4.5ZM2.5 0.75V15.25C2.5 15.6875 2.15625 16 1.75 16C1.3125 16 1 15.6875 1 15.25V0.75C1 0.34375 1.3125 0 1.75 0C2.15625 0 2.5 0.34375 2.5 0.75Z",active:t,fill:e})}),"PaddingHorizontalIcon");var jc=require("react/jsx-runtime"),Pn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,jc.jsx)(J,{...n,width:r,height:o,children:(0,jc.jsx)(Te,{d:"M0 1.75C0 1.34375 0.3125 1 0.75 1H15.25C15.6562 1 16 1.34375 16 1.75C16 2.1875 15.6562 2.5 15.25 2.5H0.75C0.3125 2.5 0 2.1875 0 1.75ZM11.5 6.5H4.5V9.5H11.5V6.5ZM4.5 5H11.5C12.3125 5 13 5.6875 13 6.5V9.5C13 10.3438 12.3125 11 11.5 11H4.5C3.65625 11 3 10.3438 3 9.5V6.5C3 5.6875 3.65625 5 4.5 5ZM0.75 13.5H15.25C15.6562 13.5 16 13.8438 16 14.25C16 14.6875 15.6562 15 15.25 15H0.75C0.3125 15 0 14.6875 0 14.25C0 13.8438 0.3125 13.5 0.75 13.5Z",active:t,fill:e})}),"PaddingVerticalIcon");var Gc=require("react/jsx-runtime"),Jc=s(({color:e="#404040",width:t=16,height:r=20,...o})=>(0,Gc.jsx)(J,{...o,width:t,height:r,children:(0,Gc.jsx)("path",{d:"M8 2C8.53125 2 9 2.46875 9 3V3.625C11.2812 4.0625 13 6.09375 13 8.5V9.3125C13 10.7188 13.4688 12.0938 14.3438 13.2188L14.8125 13.7812C15 14.0312 15.0312 14.3438 14.9062 14.5938C14.7812 14.8438 14.5312 15 14.25 15H1.75C1.4375 15 1.1875 14.8438 1.0625 14.5938C0.9375 14.3438 0.96875 14.0312 1.15625 13.7812L1.625 13.2188C2.5 12.0938 3 10.7188 3 9.3125V8.5C3 6.09375 4.71875 4.0625 7 3.625V3C7 2.46875 7.4375 2 8 2ZM8 5C6.0625 5 4.5 6.59375 4.5 8.5V9.3125C4.5 10.8125 4.0625 12.25 3.25 13.5H12.7188C11.9062 12.25 11.5 10.8125 11.5 9.3125V8.5C11.5 6.59375 9.90625 5 8 5ZM10 16C10 16.5312 9.78125 17.0625 9.40625 17.4375C9.03125 17.8125 8.53125 18 8 18C7.46875 18 6.9375 17.8125 6.5625 17.4375C6.1875 17.0625 6 16.5312 6 16H8H10Z",fill:e})}),"PushIcon");var Kc=require("react/jsx-runtime"),Xc=s(({color:e="#171717",width:t=16,height:r=13,...o})=>(0,Kc.jsx)(J,{...o,fill:"none",width:t,height:r,children:(0,Kc.jsx)("path",{d:"M1.39062 0.640625L4.01562 2.67969L4.17969 1.97656C4.29688 1.55469 4.67188 1.25 5.09375 1.25H12.9453C13.5547 1.25 14 1.83594 13.8594 2.42188L13.6016 3.45312C13.5312 3.75781 13.2266 3.94531 12.9219 3.875C12.6172 3.80469 12.4297 3.5 12.5 3.19531L12.7109 2.375H9.78125L8.65625 6.33594L15.2656 11.5156C15.5234 11.7031 15.5703 12.0547 15.3594 12.2891C15.1719 12.5469 14.8203 12.5938 14.5859 12.3828L0.710938 1.50781C0.453125 1.32031 0.40625 0.96875 0.617188 0.734375C0.804688 0.476562 1.15625 0.429688 1.39062 0.640625ZM4.97656 3.42969L7.71875 5.58594L8.60938 2.375H5.23438L4.97656 3.42969ZM8 8.67969L7.4375 10.625H8.75C9.05469 10.625 9.3125 10.8828 9.3125 11.1875C9.3125 11.5156 9.05469 11.75 8.75 11.75H5C4.67188 11.75 4.4375 11.5156 4.4375 11.1875C4.4375 10.8828 4.67188 10.625 5 10.625H6.28906L6.3125 10.4844L7.03906 7.92969L8 8.67969Z",fill:e})}),"RemoveFormattingIcon");var Yc=require("react/jsx-runtime"),Qc=s(({color:e="#171717",width:t=11,height:r=12,...o})=>(0,Yc.jsx)(J,{...o,width:t,height:r,children:(0,Yc.jsx)(Te,{d:"M10.75 2.75V10.25C10.75 10.6719 10.3984 11 10 11C9.57812 11 9.25 10.6719 9.25 10.25V2.75C9.25 2.35156 9.57812 2 10 2C10.3984 2 10.75 2.35156 10.75 2.75ZM7.51562 7.03906L4.51562 10.0391C4.23438 10.3438 3.74219 10.3438 3.46094 10.0391C3.15625 9.75781 3.15625 9.26562 3.46094 8.98438L5.17188 7.25H1C0.578125 7.25 0.25 6.92188 0.25 6.5C0.25 6.10156 0.578125 5.75 1 5.75H5.17188L3.46094 4.03906C3.15625 3.75781 3.15625 3.26562 3.46094 2.98438C3.74219 2.67969 4.23438 2.67969 4.51562 2.98438L7.51562 5.98438C7.82031 6.26562 7.82031 6.75781 7.51562 7.03906Z",fill:e})}),"RightToLineIcon");var eu=require("react/jsx-runtime"),tu=s(({color:e="#404040",width:t=16,height:r=20,...o})=>(0,eu.jsx)(J,{...o,width:t,height:r,children:(0,eu.jsx)("path",{d:"M5 13.5C5.8125 13.5 6.5 14.1875 6.5 15V15.5L8.75 13.8125C9 13.625 9.3125 13.5 9.65625 13.5H14C14.25 13.5 14.5 13.2812 14.5 13V4C14.5 3.75 14.25 3.5 14 3.5H2C1.71875 3.5 1.5 3.75 1.5 4V13C1.5 13.2812 1.71875 13.5 2 13.5H5ZM6.5 17.375L6.46875 17.4062L6.3125 17.5L5.78125 17.9062C5.625 18.0312 5.4375 18.0312 5.25 17.9688C5.09375 17.875 5 17.7188 5 17.5V16.8438V16.6562V16.625V16.5V15H3.5H2C0.875 15 0 14.125 0 13V4C0 2.90625 0.875 2 2 2H14C15.0938 2 16 2.90625 16 4V13C16 14.125 15.0938 15 14 15H9.65625L6.5 17.375Z",fill:e})}),"SMSIcon");var en=require("react/jsx-runtime"),Dp=s(({color:e="#000000",width:t=14,height:r=9,...o})=>(0,en.jsx)(J,{...o,width:t,height:r,children:(0,en.jsxs)("g",{opacity:"0.9",children:[(0,en.jsx)("rect",{x:"0.799805",y:"5.92188",width:"2.46154",height:"2.95385",rx:"0.246154",fill:e}),(0,en.jsx)("rect",{x:"4.24609",y:"4.44531",width:"2.46154",height:"4.43077",rx:"0.246154",fill:e}),(0,en.jsx)("rect",{x:"7.93823",y:"2.72266",width:"2.46154",height:"6.15385",rx:"0.246154",fill:e}),(0,en.jsx)("rect",{x:"11.3845",y:"0.753906",width:"2.46154",height:"8.12308",rx:"0.246154",fill:e})]})}),"SignalIcon");var ru=require("react/jsx-runtime"),ou=s(({color:e="#404040",width:t=16,height:r=16,...o})=>(0,ru.jsx)(J,{...o,width:t,height:r,children:(0,ru.jsx)("path",{d:"M3.5 10C3.5 10.8281 2.8125 11.5 2 11.5C1.16406 11.5 0.5 10.8281 0.5 10C0.5 9.19531 1.16406 8.5 2 8.5H3.5V10ZM4.25 10C4.25 9.19531 4.91406 8.5 5.75 8.5C6.5625 8.5 7.25 9.19531 7.25 10V14C7.25 14.8281 6.5625 15.5 5.75 15.5C4.91406 15.5 4.25 14.8281 4.25 14V10ZM5.75 3.5C4.91406 3.5 4.25 2.83594 4.25 2C4.25 1.1875 4.91406 0.5 5.75 0.5C6.5625 0.5 7.25 1.1875 7.25 2V3.5H5.75ZM5.75 4.25C6.5625 4.25 7.25 4.91406 7.25 5.75C7.25 6.5625 6.5625 7.25 5.75 7.25H2C1.16406 7.25 0.5 6.5625 0.5 5.75C0.5 4.91406 1.16406 4.25 2 4.25H5.75ZM12.5 5.75C12.5 4.91406 13.1641 4.25 14 4.25C14.8125 4.25 15.5 4.91406 15.5 5.75C15.5 6.5625 14.8125 7.25 14 7.25H12.5V5.75ZM11.75 5.75C11.75 6.5625 11.0859 7.25 10.25 7.25C9.41406 7.25 8.75 6.5625 8.75 5.75V2C8.75 1.1875 9.41406 0.5 10.25 0.5C11.0859 0.5 11.75 1.1875 11.75 2V5.75ZM10.25 12.5C11.0859 12.5 11.75 13.1641 11.75 14C11.75 14.8125 11.0859 15.5 10.25 15.5C9.41406 15.5 8.75 14.8125 8.75 14V12.5H10.25ZM10.25 11.75C9.41406 11.75 8.75 11.0859 8.75 10.25C8.75 9.41406 9.41406 8.75 10.25 8.75H14C14.8125 8.75 15.5 9.41406 15.5 10.25C15.5 11.0859 14.8125 11.75 14 11.75H10.25Z",fill:e})}),"SlackIcon");var nu=require("react/jsx-runtime"),sa=s(({color:e="#FFFFFF",width:t=24,height:r=24,...o})=>(0,nu.jsx)(J,{...o,width:t,height:r,viewBox:"0 0 24 24",children:(0,nu.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.9302 18.0041C16.7152 19.4687 17.3201 20.6536 17.6716 21.4225C22.7992 18.3395 24.5289 11.7034 21.525 6.5012C18.5211 1.29895 11.9084 -0.521541 6.67543 2.3769C7.30667 3.26444 8.32896 4.86524 9.56215 6.89518C10.4351 8.33194 11.4134 9.98401 12.4328 11.7503C13.7758 14.0761 14.9841 16.2422 15.9302 18.0041ZM4.20759 16.4985C2.25528 13.1182 1.73242 9.41428 2.51159 6.43383C0.579784 9.73503 0.426001 13.9501 2.47497 17.4989C4.52394 21.0476 8.25134 23.0233 12.0769 22.9999C9.1052 22.1856 6.1599 19.8803 4.20759 16.4985ZM1.6094 17.9983C4.92231 23.738 12.2599 25.7035 17.9997 22.3906C23.738 19.0777 25.7035 11.7401 22.3906 6.00031C19.0776 0.262019 11.74 -1.70347 6.00172 1.60945C0.261966 4.92236 -1.70352 12.26 1.6094 17.9983ZM11.1249 21.6085C12.4884 22.1914 13.8534 22.4228 15.1188 22.2896C12.7711 21.2717 9.91951 18.3937 7.66989 14.4994C5.42174 10.605 4.35551 6.69599 4.6499 4.15492C3.90002 5.18306 3.41817 6.48069 3.24096 7.95408C2.94364 10.4131 3.51483 13.2999 5.07317 15.9991C6.6315 18.6998 8.84597 20.636 11.1249 21.6085ZM16.913 21.6876C16.6889 21.6993 16.4238 21.67 16.1089 21.5836C15.4513 21.402 14.6604 20.9861 13.7875 20.3197C12.0461 18.9898 10.1436 16.7827 8.53694 13.9999C6.92881 11.2157 5.9695 8.46376 5.6883 6.29176C5.62971 5.83334 5.60188 5.41008 5.60188 5.02342C5.60188 4.49324 5.65461 4.03335 5.7542 3.65109C5.89334 3.11945 6.10278 2.78845 6.33565 2.59219C7.11481 4.29259 9.11545 8.00387 11.5672 12.2497C14.0189 16.4956 16.2319 20.0853 17.3157 21.61C17.2 21.651 17.0667 21.6788 16.913 21.6876Z",fill:e})}),"UnionIcon");var iu=require("react/jsx-runtime"),la=s(({color:e="#A3A3A3",width:t=24,height:r=24,...o})=>(0,iu.jsx)(J,{...o,width:t,height:r,children:(0,iu.jsx)(Te,{d:"M12 12C10.2031 12 8.5625 11.0625 7.66406 9.5C6.76562 7.97656 6.76562 6.0625 7.66406 4.5C8.5625 2.97656 10.2031 2 12 2C13.7578 2 15.3984 2.97656 16.2969 4.5C17.1953 6.0625 17.1953 7.97656 16.2969 9.5C15.3984 11.0625 13.7578 12 12 12ZM10.2031 13.875H13.7578C17.625 13.875 20.75 17 20.75 20.8672C20.75 21.4922 20.2031 22 19.5781 22H4.38281C3.75781 22 3.25 21.4922 3.25 20.8672C3.25 17 6.33594 13.875 10.2031 13.875Z",fill:e})}),"UserIcon");var Mn=require("react/jsx-runtime"),Fp=s(({color:e="#000000",width:t=14,height:r=10,...o})=>(0,Mn.jsx)(J,{...o,width:t,height:r,children:(0,Mn.jsxs)("g",{opacity:"0.9",children:[(0,Mn.jsx)("path",{d:"M13.3282 2.87894C11.7229 1.26255 9.4985 0.261719 7.04045 0.261719C4.57494 0.261719 2.34465 1.26857 0.738281 2.89354L2.13071 4.28604C3.38071 3.01741 5.11881 2.23095 7.04045 2.23095C8.95475 2.23095 10.6867 3.01137 11.9356 4.27141L13.3282 2.87894Z",fill:e}),(0,Mn.jsx)("path",{d:"M11.0654 5.14169C10.0392 4.10437 8.61484 3.46172 7.04045 3.46172C5.45859 3.46172 4.02831 4.11043 3.00102 5.15634L4.39357 6.5489C5.06436 5.85932 6.00246 5.43095 7.04045 5.43095C8.07109 5.43095 9.00307 5.85322 9.6729 6.5342L11.0654 5.14169Z",fill:e}),(0,Mn.jsx)("path",{d:"M8.80258 7.40452C8.35559 6.94626 7.73119 6.66172 7.04045 6.66172C6.34225 6.66172 5.71196 6.95239 5.264 7.41931L7.0259 9.18121L8.80258 7.40452Z",fill:e})]})}),"WiFiIcon");var au=require("react/jsx-runtime"),ca=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,au.jsx)(J,{...n,width:r,height:o,children:(0,au.jsx)(Te,{d:"M12.1562 1.5H14.3438L9.53125 7.03125L15.2188 14.5H10.7812L7.28125 9.96875L3.3125 14.5H1.09375L6.25 8.625L0.8125 1.5H5.375L8.5 5.65625L12.1562 1.5ZM11.375 13.1875H12.5938L4.71875 2.75H3.40625L11.375 13.1875Z",active:t,fill:e})}),"XIcon");var Vp=require("lucide-react"),An=require("react");var cs=require("react/jsx-runtime"),Nn=s(({className:e})=>(0,cs.jsx)("div",{className:N("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:(0,cs.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"courier-w-6 courier-h-6 courier-animate-spin",children:(0,cs.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");var Sn=require("react/jsx-runtime"),yi=s(({isError:e,isSaving:t,isLoading:r,renderIsSaving:o,renderIsError:n,renderSaved:i})=>{let[a,c]=(0,An.useState)(!1),l=(0,An.useRef)(t),u=(0,An.useRef)(null);return(0,An.useEffect)(()=>(r||e||t&&t!==l.current?(u.current&&(clearTimeout(u.current),u.current=null),c(!1)):l.current===!0&&t===!1&&!e&&!r&&(c(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{c(!1),u.current=null},5e3)),l.current=t,()=>{u.current&&clearTimeout(u.current)}),[t,e,r]),r||t===null?null:t?o?o(t):(0,Sn.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,Sn.jsx)(Nn,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):(0,Sn.jsx)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:"Error"}):a?i?i(a):(0,Sn.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,Sn.jsx)(Vp.CircleCheck,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Saved"]}):null},"Status");var su=require("jotai");var In=require("react/jsx-runtime"),vi=[{label:"Email",value:"email",icon:(0,In.jsx)(ss,{})},{label:"SMS",value:"sms",icon:(0,In.jsx)(tu,{})},{label:"Push",value:"push",icon:(0,In.jsx)(Jc,{})},{label:"In-app",value:"inbox",icon:(0,In.jsx)(ss,{})},{label:"Slack",value:"slack",icon:(0,In.jsx)(ou,{})},{label:"Teams",value:"msteams",icon:(0,In.jsx)(Uc,{})}];var us=(0,su.atom)("email"),xi=(0,su.atom)("template");var u5=require("@radix-ui/react-alert-dialog"),Jo=require("jotai"),No=require("react");var or=require("jotai");var lu={contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"enabled"},alignCenter:{state:"enabled"},alignRight:{state:"enabled"},alignJustify:{state:"enabled"},quote:{state:"enabled"},link:{state:"enabled"},variable:{state:"enabled"}},ds=s((e,t=!1)=>{let r=["paragraph","heading","blockquote"].includes(e);if(r&&t)return{contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"enabled"},variable:{state:"enabled"}};if(r&&!t)return{contentType:{state:"enabled"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"enabled"},alignCenter:{state:"enabled"},alignRight:{state:"enabled"},alignJustify:{state:"enabled"},quote:{state:"enabled"},link:{state:"hidden"},variable:{state:"enabled"}};switch(e){case"button":return{bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"}};default:return{contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"}}}},"getTextMenuConfigForNode");var ah={paragraph:lu,heading:lu},ua=(0,or.atom)(ah),ge=(0,or.atom)(null),mt=(0,or.atom)(null,(e,t,r)=>{t(ge,r)}),sh=(0,or.atom)({ref:null,caretPosition:null}),ps=(0,or.atom)({ref:null,caretPosition:null}),da=(0,or.atom)({isFocused:!1,hasVariables:!1,showVariablePopup:!1}),Op=(0,or.atom)(e=>(t,r=!1)=>{let o=e(ua),n=e(da),i=ds(t,r),a=o[t],c=i;return a&&Object.keys(a).forEach(l=>{var d,p;let u=l;((d=i[u])==null?void 0:d.state)==="enabled"&&((p=a[u])==null?void 0:p.state)==="enabled"&&(c[u]=a[u])}),n.isFocused&&n.hasVariables&&(c={...c,variable:{state:"enabled"}}),c}),Wp=(0,or.atom)(null,(e,t,{nodeName:r,config:o})=>{let n=e(ua);t(ua,{...n,[r]:{...n[r],...Object.fromEntries(Object.entries(o).map(([i,a])=>[i,{state:(a==null?void 0:a.state)||"hidden"}]))}})}),Lx=(0,or.atom)(null,(e,t,r)=>{let o=e(ua),{[r]:n,...i}=o;t(ua,i)}),Up=(0,or.atom)(null,(e,t,{ref:r,caretPosition:o})=>{t(sh,{ref:r,caretPosition:o})}),Rx=(0,or.atom)(null,(e,t,r)=>{let o=e(da);t(da,{...o,showVariablePopup:r})}),cu=(0,or.atom)(null),ms=(0,or.atom)(null,(e,t,r)=>{t(cu,r)});var fn=require("jotai"),Zr=require("react");var uu=require("jotai"),ro=(0,uu.atom)(null),yo=(0,uu.atom)(null);var pa=require("react/jsx-runtime"),Dt=s(({draggable:e=!1,icon:t,draggableLabel:r,label:o})=>(0,pa.jsxs)("div",{className:"courier-flex courier-flex-row courier-items-center courier-gap-2",children:[(0,pa.jsx)("div",{className:N("courier-w-8 courier-h-8 courier-rounded-md courier-flex courier-items-center courier-justify-center",e?"courier-cursor-grab courier-bg-[#F5F5F5]":"courier-border"),children:t}),(0,pa.jsx)("span",{className:"courier-text-sm courier-font-medium",children:e?r:o})]}),"BlockBase");var ma=require("react/jsx-runtime"),lh=s(()=>(0,ma.jsx)("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ma.jsx)("path",{d:"M18 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V10C1.5 10.2812 1.71875 10.5 2 10.5H18C18.25 10.5 18.5 10.2812 18.5 10V2C18.5 1.75 18.25 1.5 18 1.5ZM2 0H18C19.0938 0 20 0.90625 20 2V10C20 11.125 19.0938 12 18 12H2C0.875 12 0 11.125 0 10V2C0 0.90625 0.875 0 2 0Z",fill:"#171717"})}),"ButtonBlockIcon"),Hr=s(({draggable:e=!1})=>(0,ma.jsx)(Dt,{draggable:e,icon:(0,ma.jsx)(lh,{}),draggableLabel:"Button",label:"Button block"}),"ButtonBlock");var fa=require("react/jsx-runtime"),ch=s(()=>(0,fa.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,fa.jsx)("path",{d:"M6.5 3.5L3 7L6.5 10.5M13.5 3.5L17 7L13.5 10.5M11.5 1L8.5 13",stroke:"#171717",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"CustomCodeBlockIcon"),Ln=s(({draggable:e=!1})=>(0,fa.jsx)(Dt,{draggable:e,icon:(0,fa.jsx)(ch,{}),draggableLabel:"Custom code",label:"Custom code"}),"CustomCodeBlock");var ga=require("react/jsx-runtime"),uh=s(()=>(0,ga.jsx)("svg",{width:"16",height:"2",viewBox:"0 0 16 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ga.jsx)("path",{d:"M0 1C0 0.59375 0.3125 0.25 0.75 0.25H15.25C15.6562 0.25 16 0.59375 16 1C16 1.4375 15.6562 1.75 15.25 1.75H0.75C0.3125 1.75 0 1.4375 0 1Z",fill:"#171717"})}),"DividerBlockIcon"),nr=s(({draggable:e=!1})=>(0,ga.jsx)(Dt,{draggable:e,icon:(0,ga.jsx)(uh,{}),draggableLabel:"Divider",label:"Divider block"}),"DividerBlock");var ha=require("react/jsx-runtime"),dh=s(()=>(0,ha.jsx)("svg",{width:"18",height:"13",viewBox:"0 0 18 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ha.jsx)("path",{d:"M1.5 1.75V6H8.5V1.75C8.5 1.34375 8.8125 1 9.25 1C9.65625 1 10 1.34375 10 1.75V6.75V12.25C10 12.6875 9.65625 13 9.25 13C8.8125 13 8.5 12.6875 8.5 12.25V7.5H1.5V12.25C1.5 12.6875 1.15625 13 0.75 13C0.3125 13 0 12.6875 0 12.25V6.75V1.75C0 1.34375 0.3125 1 0.75 1C1.15625 1 1.5 1.34375 1.5 1.75ZM15.75 1.75V11.5H17.25C17.6562 11.5 18 11.8438 18 12.25C18 12.6875 17.6562 13 17.25 13H15H12.75C12.3125 13 12 12.6875 12 12.25C12 11.8438 12.3125 11.5 12.75 11.5H14.25V3.03125L13.0938 3.65625C12.75 3.875 12.2812 3.75 12.0938 3.375C11.875 3 12 2.5625 12.375 2.34375L14.625 1.09375C14.8438 0.96875 15.125 0.96875 15.375 1.125C15.5938 1.25 15.75 1.5 15.75 1.75Z",fill:"#171717"})}),"HeadingBlockIcon"),Ci=s(({draggable:e=!1})=>(0,ha.jsx)(Dt,{draggable:e,icon:(0,ha.jsx)(dh,{}),draggableLabel:"Heading",label:"Heading block"}),"HeadingBlock");var ba=require("react/jsx-runtime"),ph=s(()=>(0,ba.jsx)("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ba.jsx)("path",{d:"M14 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12V12.0312L1.625 11.8438L4.125 8.34375C4.28125 8.125 4.5 8 4.75 8C4.96875 8 5.21875 8.125 5.34375 8.3125L6.3125 9.65625L8.90625 6.3125C9.03125 6.125 9.25 6 9.5 6C9.71875 6 9.9375 6.125 10.0938 6.3125L14.3438 11.8125L14.5 12V2C14.5 1.75 14.25 1.5 14 1.5ZM2 0H14C15.0938 0 16 0.90625 16 2V12C16 13.125 15.0938 14 14 14H2C0.875 14 0 13.125 0 12V2C0 0.90625 0.875 0 2 0ZM4.5 6C3.9375 6 3.46875 5.71875 3.1875 5.25C2.90625 4.8125 2.90625 4.21875 3.1875 3.75C3.46875 3.3125 3.9375 3 4.5 3C5.03125 3 5.5 3.3125 5.78125 3.75C6.0625 4.21875 6.0625 4.8125 5.78125 5.25C5.5 5.71875 5.03125 6 4.5 6Z",fill:"#171717"})}),"ImageBlockIcon"),Ti=s(({draggable:e=!1})=>(0,ba.jsx)(Dt,{draggable:e,icon:(0,ba.jsx)(ph,{}),draggableLabel:"Image",label:"Image block"}),"ImageBlock");var zp=require("lucide-react");var du=require("react/jsx-runtime"),wi=s(({draggable:e=!1})=>(0,du.jsx)(Dt,{draggable:e,icon:(0,du.jsx)(zp.AlignVerticalSpaceAround,{className:"courier-w-4 courier-h-4"}),draggableLabel:"Spacer",label:"Spacer block"}),"SpacerBlock");var ya=require("react/jsx-runtime"),mh=s(()=>(0,ya.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ya.jsx)("path",{d:"M1.5 1.5V3C1.5 3.4375 1.15625 3.75 0.75 3.75C0.3125 3.75 0 3.4375 0 3V1.25C0 0.5625 0.53125 0 1.25 0H12.75C13.4375 0 14 0.5625 14 1.25V3C14 3.4375 13.6562 3.75 13.25 3.75C12.8125 3.75 12.5 3.4375 12.5 3V1.5H7.75V12.5H9.25C9.65625 12.5 10 12.8438 10 13.25C10 13.6875 9.65625 14 9.25 14H4.75C4.3125 14 4 13.6875 4 13.25C4 12.8438 4.3125 12.5 4.75 12.5H6.25V1.5H1.5Z",fill:"#171717"})}),"TextBlockIcon"),ir=s(({draggable:e=!1})=>(0,ya.jsx)(Dt,{draggable:e,icon:(0,ya.jsx)(mh,{}),draggableLabel:"Text",label:"Text block"}),"TextBlock");var $p=require("react"),_p=require("sonner");var tn=require("react/jsx-runtime"),ar=(0,$p.forwardRef)(({theme:e,children:t,isLoading:r,Header:o,dataMode:n="light",className:i,...a},c)=>(0,tn.jsx)(Ap,{theme:e,ref:c,dataMode:n,className:i,children:(0,tn.jsxs)("div",{...Object.fromEntries(Object.entries(a).filter(([l])=>l!=="variables")),className:"courier-main-layout",children:[o&&(0,tn.jsx)("div",{className:"courier-flex courier-flex-row courier-h-12 courier-flex-shrink-0 courier-w-full courier-bg-primary courier-border-b courier-px-4 courier-items-center courier-gap-4 courier-self-stretch dark:courier-bg-primary",children:o}),r&&(0,tn.jsx)("div",{className:"courier-editor-loading",children:(0,tn.jsx)(Nn,{})}),(0,tn.jsx)(_p.Toaster,{position:"top-center",expand:!0,visibleToasts:2,style:{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)"}}),t]})}));var ll=require("@dnd-kit/core"),W1=require("@dnd-kit/sortable"),mr=require("jotai"),ve=require("react");var Qu=require("@tiptap/extension-color");var Zp=require("@tiptap/core"),qp=require("@tiptap/pm/dropcursor"),pu=Zp.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[(0,qp.dropCursor)(this.options)]}});var ed=require("@tiptap/extension-hard-break");var jp=require("@tiptap/core"),Ei=require("@tiptap/pm/history"),fh=jp.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>(0,Ei.undo)(e,t),redo:()=>({state:e,dispatch:t})=>(0,Ei.redo)(e,t)}},addProseMirrorPlugins(){return[(0,Ei.history)(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var td=require("@tiptap/extension-placeholder"),rd=require("@tiptap/extension-text-align"),od=require("@tiptap/extension-typography"),nd=require("@tiptap/extension-underline"),id=require("@tiptap/starter-kit");var sm=require("@tiptap/core");var ki=require("@tiptap/core"),gh=/^\s*>\s$/,Gp=ki.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,ki.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[(0,ki.wrappingInputRule)({find:gh,type:this.type})]}});var lm=require("@tiptap/react");var Jp=require("uuid");function Ft(e,t){let r=e.state.tr,o=!1;e.state.doc.descendants((n,i)=>{if(n.type.name===t&&!n.attrs.id){let a=`node-${(0,Jp.v4)()}`;r.setNodeMarkup(i,void 0,{...n.attrs,id:a}),o=!0}return!1}),o&&e.view.dispatch(r)}s(Ft,"generateNodeIds");var Qp=require("@dnd-kit/sortable"),em=require("@tiptap/react"),tm=require("jotai"),kr=require("react"),rm=require("uuid");var Kp=require("lucide-react"),Xp=require("react"),mu=require("react/jsx-runtime"),Yp=(0,Xp.forwardRef)((e,t)=>(0,mu.jsx)("button",{...e,ref:t,"data-cypress":"draggable-handle",className:N("courier-flex-shrink-0 courier-p-1 courier-w-7 courier-h-7 courier-rounded-md courier-border courier-border-border courier-flex courier-items-center courier-justify-center courier-shadow-sm courier-bg-background hover:courier-bg-card courier-cursor-grab",e.className),children:(0,mu.jsx)(Kp.GripVertical,{strokeWidth:1,className:"courier-w-5 courier-stroke-ring courier-fill-ring"})}));var fs=require("jotai"),sr=require("react");var gs=s(e=>{let t=(0,fs.useSetAtom)(mt),r=(0,fs.useAtomValue)(ge),o=(0,sr.useCallback)(y=>{let P=-1;return e.state.doc.descendants((w,v)=>{var f;return((f=w.attrs)==null?void 0:f.id)===y?(P=v,!1):!0}),P},[e]),n=(0,sr.useCallback)((y,P)=>{var w,v,f;if(((w=r==null?void 0:r.type)==null?void 0:w.name)==="button"&&((v=r.attrs)!=null&&v.id)){let C=r.attrs.id,T=o(C);if(T>=0){let R=e.state.tr;return R.setNodeMarkup(T,void 0,{...(f=e.state.doc.nodeAt(T))==null?void 0:f.attrs,[y]:P}),e.view.dispatch(R),setTimeout(()=>{let M=o(C);if(M>=0){let k=e.state.doc.nodeAt(M);k&&t(k)}},0),!0}}return!1},[e,r,o,t]),i=(0,sr.useCallback)(()=>{var y,P;if(((y=r==null?void 0:r.type)==null?void 0:y.name)==="button"&&((P=r.attrs)!=null&&P.id)){let w=r.attrs.id,v=o(w);if(v>=0){let f=e.state.doc.nodeAt(v);if(!f)return!1;let C={...f.attrs,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},T=e.state.tr;return T.setNodeMarkup(v,void 0,C),e.view.dispatch(T),setTimeout(()=>{let R=o(w);if(R>=0){let M=e.state.doc.nodeAt(R);M&&t(M)}},0),!0}}return!1},[e,r,o,t]),a=(0,sr.useCallback)(()=>{var y;if(((y=r==null?void 0:r.type)==null?void 0:y.name)==="button"){let P=r.attrs.fontWeight==="bold"?"normal":"bold";if(n("fontWeight",P))return!0}return e.chain().focus().toggleBold().run()},[e,r,n]),c=(0,sr.useCallback)(()=>{var y;if(((y=r==null?void 0:r.type)==null?void 0:y.name)==="button"){let P=r.attrs.fontStyle==="italic"?"normal":"italic";if(n("fontStyle",P))return!0}return e.chain().focus().toggleItalic().run()},[e,r,n]),l=(0,sr.useCallback)(()=>{var y;if(((y=r==null?void 0:r.type)==null?void 0:y.name)==="button"){let P=!r.attrs.isStrike;if(n("isStrike",P))return!0}return e.chain().focus().toggleMark("strike").run()},[e,r,n]),u=(0,sr.useCallback)(()=>{var y;if(((y=r==null?void 0:r.type)==null?void 0:y.name)==="button"){let P=!r.attrs.isUnderline;if(n("isUnderline",P))return!0}return e.chain().focus().toggleMark("underline").run()},[e,r,n]),d=(0,sr.useCallback)(()=>e.chain().focus().setTextAlign("left").run(),[e]),p=(0,sr.useCallback)(()=>e.chain().focus().setTextAlign("center").run(),[e]),m=(0,sr.useCallback)(()=>e.chain().focus().setTextAlign("right").run(),[e]),g=(0,sr.useCallback)(()=>e.chain().focus().setTextAlign("justify").run(),[e]),b=(0,sr.useCallback)((y,P)=>e.chain().focus().setLink({href:y,target:P?"_blank":""}).run(),[e]),h=(0,sr.useCallback)(()=>{let y=e.isActive("blockquote");if(e.chain().focus().toggleBlockquote().run()){let{selection:v}=e.state,f=v.$anchor;if(y){let C=f.node();(C.type.name==="paragraph"||C.type.name==="heading")&&t(C)}else for(let C=f.depth;C>0;C--){let T=f.node(C);if(T.type.name==="blockquote"){t(T);break}}}},[e,t]);return{onBold:a,onItalic:c,onStrike:l,onUnderline:u,onAlignLeft:d,onAlignCenter:p,onAlignRight:m,onAlignJustify:g,onLink:b,onQuote:h,resetButtonFormatting:i}},"useTextmenuCommands");var Pt=require("react/jsx-runtime");function hh(){let[e,t]=(0,kr.useState)(!1);return(0,kr.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(hh,"useMountStatus");var lr=s(({children:e,id:t,className:r,...o})=>{let{setNodeRef:n,setActivatorNodeRef:i,listeners:a,isDragging:c,transform:l,transition:u}=(0,Qp.useSortable)({id:t}),d=hh();return(0,Pt.jsx)(bh,{ref:n,id:t,transition:u,transform:l,fadeIn:c&&!d,listeners:a,className:r,handleProps:{ref:i},...o,children:e})},"SortableItemWrapper"),bh=(0,kr.forwardRef)(({children:e,className:t,dragOverlay:r,handleProps:o,listeners:n,id:i,transition:a,transform:c,editor:l,fadeIn:u,...d},p)=>{(0,kr.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let m=(0,tm.useSetAtom)(ge),{resetButtonFormatting:g}=gs(l),b=s((C,T)=>{let R=null;return C.doc.descendants((M,k)=>{var S;return R!==null?!1:((S=M.attrs)==null?void 0:S.id)===T?(R=k,!1):!0}),R},"findNodePositionById"),h=(0,kr.useCallback)(()=>{if(!l||!i)return{node:null,pos:null};let C=b(l.state,i);return C===null?{node:null,pos:null}:{node:l.state.doc.nodeAt(C),pos:C}},[l,i]),y=(0,kr.useCallback)(()=>{l.commands.blur(),m(null)},[l,m]),P=(0,kr.useCallback)(()=>{if(!(!l||!i))try{y(),setTimeout(()=>{let{node:C,pos:T}=h();if(!C||T===null)return;let R=l.state.doc.childCount===1,M=l.state.tr;M.delete(T,T+(C==null?void 0:C.nodeSize)),M.setMeta("addToHistory",!0),l.view.dispatch(M),R&&setTimeout(()=>{let k=l.state.doc.nodeAt(0);if(k&&k.type.name==="paragraph"&&!k.attrs.id){let S=`node-${(0,rm.v4)()}`,E=l.state.tr;E.setNodeMarkup(0,void 0,{...k.attrs,id:S}),l.view.dispatch(E);let x=new CustomEvent("node-duplicated",{detail:{newNodeId:S}});document.dispatchEvent(x)}},50),m(null)},100)}catch(C){console.error("Error deleting node:",C)}},[l,i,h,y,m]),w=(0,kr.useCallback)(()=>{if(!(!l||!i))try{let{node:C,pos:T}=h();if(!C||T===null)return;if(C.type.name==="button"){g();return}y(),setTimeout(()=>{let R=l.chain();R.setNodeSelection(T).unsetAllMarks(),C.type.name==="blockquote"&&C.content&&C.content.firstChild?C.content.firstChild.type.name!=="paragraph"&&R.setParagraph():C.type.name!=="paragraph"&&C.type.name!=="blockquote"&&R.setParagraph(),R.run()},100)}catch(C){console.error("Error removing formatting:",C)}},[l,i,h,y,g]),v=(0,kr.useCallback)(()=>{if(!(!l||!i))try{y(),setTimeout(()=>{let{node:C,pos:T}=h();if(!C||T===null)return;let R=C.type.name,M={...C.attrs};delete M.id;let k=T+(C==null?void 0:C.nodeSize);hs(l,R,k,M,S=>m(S),C.content)},100)}catch(C){console.error("Error duplicating node:",C)}},[l,i,h,y,m]),{node:f}=h();return(0,Pt.jsxs)(em.NodeViewWrapper,{ref:p,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":i,className:N("courier-flex courier-items-center courier-justify-center courier-gap-2 courier-pl-6 draggable-item",t),style:{transition:[a].filter(Boolean).join(", "),"--translate-x":c?`${Math.round(c.x)}px`:void 0,"--translate-y":c?`${Math.round(c.y)}px`:void 0,"--scale-x":c!=null&&c.scaleX?`${c.scaleX}`:void 0,"--scale-y":c!=null&&c.scaleY?`${c.scaleY}`:void 0,transform:"translate3d(var(--translate-x, 0), var(--translate-y, 0), 0) scaleX(var(--scale-x, 1)) scaleY(var(--scale-y, 1))"},...d,children:[(0,Pt.jsx)(Yp,{className:"courier-absolute courier-left-[-20px]",tabIndex:-1,...o,...n}),e,(0,Pt.jsxs)("div",{className:"courier-actions-panel courier-absolute courier-right-[-50px] courier-rounded-lg courier-border courier-border-border courier-bg-background courier-shadow-md courier-flex courier-items-center courier-justify-center courier-hidden",children:[(f==null?void 0:f.type.name)!=="imageBlock"&&(f==null?void 0:f.type.name)!=="divider"&&(f==null?void 0:f.type.name)!=="spacer"&&(f==null?void 0:f.type.name)!=="button"&&(0,Pt.jsxs)(Pt.Fragment,{children:[(0,Pt.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center",onClick:w,tabIndex:-1,children:(0,Pt.jsx)(Xc,{})}),(0,Pt.jsx)(le,{className:"courier-m-0"})]}),(0,Pt.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center",onClick:v,tabIndex:-1,children:(0,Pt.jsx)(Ic,{})}),(0,Pt.jsx)(le,{className:"courier-m-0"}),(0,Pt.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center",onClick:P,tabIndex:-1,children:(0,Pt.jsx)(Qi,{})})]})]})});var om=require("@tiptap/react"),nm=require("jotai"),im=require("react");var Pi=require("react/jsx-runtime"),yh=s(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderLeftWidth:o,borderColor:n})=>(0,Pi.jsx)("div",{className:"courier-w-full node-element",children:(0,Pi.jsx)("div",{style:{zIndex:-15,position:"relative",padding:`${t}px ${e}px`,backgroundColor:r,borderLeftWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",whiteSpace:"pre-wrap"},children:(0,Pi.jsx)(om.NodeViewContent,{})})}),"BlockquoteComponent"),am=s(e=>{let t=(0,nm.useSetAtom)(mt),r=(0,im.useCallback)(n=>{if(!e.editor.isEditable)return;if(!n.target.closest('[contenteditable="true"]')){let c=ft(e);c&&(e.editor.commands.blur(),t(c))}},[e,t]),o=!e.node.content||e.node.content.size===0;return(0,Pi.jsx)(lr,{id:e.node.attrs.id,className:N(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:(0,Pi.jsx)(yh,{...e.node.attrs})})},"BlockquoteComponentNode");var Fo={paddingHorizontal:8,paddingVertical:6,backgroundColor:"transparent",borderLeftWidth:4,borderColor:"#e0e0e0"},fu=Gp.extend({content:"block+",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){Ft(this.editor,this.name)},addAttributes(){return{id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},paddingHorizontal:{default:Fo.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:Fo.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:Fo.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderLeftWidth:{default:Fo.borderLeftWidth,parseHTML:e=>e.getAttribute("data-border-left-width"),renderHTML:e=>({"data-border-left-width":e.borderLeftWidth})},borderColor:{default:Fo.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})}}},parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,sm.mergeAttributes)(e,{"data-type":"blockquote","data-id":e.id}),0]},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let{selection:t}=e.state,{empty:r}=t;if(!r)return!1;let o=e.isActive("blockquote");return!e.isActive("paragraph")||!o?!1:e.chain().command(({tr:i})=>{i.split(t.from);let a=i.selection.from,c=i.doc.resolve(a);if(c.depth>1){let l=c.blockRange();l&&i.lift(l,0)}return!0}).focus().run()}}},addNodeView(){return(0,lm.ReactNodeViewRenderer)(am)}});var mm=require("@hookform/resolvers/zod"),fm=require("react-hook-form");var va=require("react");var cr=s(({editor:e,element:t,form:r,nodeType:o})=>{let n=(0,va.useRef)(null),i=(0,va.useRef)(null);return(0,va.useEffect)(()=>{if(!e||!t)return;let c=s(()=>{let l=null;if(e.state.doc.descendants((u,d)=>u.attrs.id===t.attrs.id?(l=d,!1):!0),l!==null){let u=e.state.doc.nodeAt(l);(u==null?void 0:u.type.name)===o&&(n.current=u,i.current=l,Object.entries(u.attrs).forEach(([d,p])=>{r.getValues(d)!==p&&r.setValue(d,p)}))}},"updateCurrentNode");return c(),e.on("update",c),()=>{e.off("update",c)}},[e,t,r,o]),{updateNodeAttributes:s(c=>{!e||i.current===null||e.commands.command(({tr:l})=>{let u=l.doc.nodeAt(i.current);if((u==null?void 0:u.type.name)===o){let d={...u.attrs,...c,id:u.attrs.id};return l.setNodeMarkup(i.current,u.type,d),!0}return!1})},"updateNodeAttributes")}},"useNodeAttributes");var dm=require("jotai");var cm=require("lucide-react");var gu=require("react/jsx-runtime"),um=s(({draggable:e=!1})=>(0,gu.jsx)(Dt,{draggable:e,icon:(0,gu.jsx)(cm.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),draggableLabel:"Blockquote",label:"Blockquote block"}),"BlockquoteBlock");var Pr=require("react/jsx-runtime"),ur=s(({type:e})=>{let t=(0,dm.useSetAtom)(mt);return(0,Pr.jsxs)("div",{className:"courier-flex courier-gap-4 courier-flex-col",children:[(0,Pr.jsx)(Ne,{className:"courier-w-fit",variant:"secondary",buttonSize:"small",onClick:()=>{t(null)},children:"Close"}),e==="heading"&&(0,Pr.jsx)(Ci,{}),e==="text"&&(0,Pr.jsx)(ir,{}),e==="image"&&(0,Pr.jsx)(Ti,{}),e==="spacer"&&(0,Pr.jsx)(wi,{}),e==="divider"&&(0,Pr.jsx)(nr,{}),e==="button"&&(0,Pr.jsx)(Hr,{}),e==="blockquote"&&(0,Pr.jsx)(um,{}),e==="customCode"&&(0,Pr.jsx)(Ln,{}),(0,Pr.jsx)(le,{className:"courier-m-0"})]})},"FormHeader");var rn=require("zod"),pm=rn.z.object({paddingHorizontal:rn.z.coerce.number().min(0),paddingVertical:rn.z.coerce.number().min(0),backgroundColor:rn.z.string(),borderLeftWidth:rn.z.coerce.number().min(0),borderColor:rn.z.string(),id:rn.z.string().optional()});var pe=require("react/jsx-runtime"),gm=s(({element:e,editor:t})=>{let r=(0,fm.useForm)({resolver:(0,mm.zodResolver)(pm),defaultValues:{...Fo,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=cr({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"blockquote"});return e?(0,pe.jsxs)(Ye,{...r,children:[(0,pe.jsx)(ur,{type:"blockquote"}),(0,pe.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,pe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,pe.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,pe.jsx)(q,{control:r.control,name:"paddingHorizontal",render:({field:n})=>(0,pe.jsxs)(_,{children:[(0,pe.jsx)(Z,{children:(0,pe.jsx)(ce,{startAdornment:(0,pe.jsx)(aa,{}),type:"number",min:0,...n})}),(0,pe.jsx)(G,{})]})}),(0,pe.jsx)(q,{control:r.control,name:"paddingVertical",render:({field:n})=>(0,pe.jsxs)(_,{children:[(0,pe.jsx)(Z,{children:(0,pe.jsx)(ce,{startAdornment:(0,pe.jsx)(Pn,{}),type:"number",min:0,...n})}),(0,pe.jsx)(G,{})]})})]}),(0,pe.jsx)(q,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,pe.jsxs)(_,{className:"courier-mb-3",children:[(0,pe.jsx)(Z,{children:(0,pe.jsx)(pt,{...n,defaultValue:Fo.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,pe.jsx)(G,{})]})}),(0,pe.jsx)(le,{className:"courier-mb-4"}),(0,pe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,pe.jsx)(q,{control:r.control,name:"borderLeftWidth",render:({field:n})=>(0,pe.jsxs)(_,{className:"courier-mb-3",children:[(0,pe.jsx)(Z,{children:(0,pe.jsx)(ce,{startAdornment:(0,pe.jsx)(to,{}),type:"number",min:0,...n})}),(0,pe.jsx)(G,{})]})}),(0,pe.jsx)(q,{control:r.control,name:"borderColor",render:({field:n})=>(0,pe.jsxs)(_,{className:"courier-mb-3",children:[(0,pe.jsx)(Z,{children:(0,pe.jsx)(pt,{...n,defaultValue:Fo.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,pe.jsx)(G,{})]})})]})]}):null},"BlockquoteForm");var bs=require("@tiptap/core"),vm=require("@tiptap/react"),ys=require("@tiptap/pm/state");var hm=require("jotai"),bm=require("react");var Vo=require("react/jsx-runtime"),vh=s(({label:e,alignment:t,size:r,backgroundColor:o,textColor:n,borderWidth:i,borderRadius:a,borderColor:c,padding:l,fontWeight:u,fontStyle:d,isUnderline:p,isStrike:m})=>(0,Vo.jsx)("div",{className:"courier-w-full node-element",children:(0,Vo.jsx)("div",{className:"courier-flex",style:{marginTop:`${l}px`,marginBottom:`${l}px`},children:(0,Vo.jsx)("div",{className:N("courier-inline-flex courier-justify-center courier-px-4 courier-py-2 courier-cursor-pointer courier-text-base",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[t],r==="full"&&"courier-w-full"),style:{backgroundColor:o,color:n,borderWidth:`${i}px`,borderRadius:`${a}px`,borderColor:c,borderStyle:i>0?"solid":"none",caretColor:"#ff0000",fontWeight:u,fontStyle:d},children:m?(0,Vo.jsx)("s",{children:p?(0,Vo.jsx)("u",{children:e}):e}):p?(0,Vo.jsx)("u",{children:e}):e})})}),"ButtonComponent"),ym=s(e=>{let t=(0,hm.useSetAtom)(mt),r=(0,bm.useCallback)(()=>{if(!e.editor.isEditable)return;let o=ft(e);if(o){e.editor.commands.blur();let n=o.attrs.id;e.editor.state.doc.descendants(i=>i.type.name==="button"&&i.attrs.id===n?(t(i),!1):!0)}},[e,t]);return(0,Vo.jsx)(lr,{id:e.node.attrs.id,className:N(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,"data-node-type":"button",children:(0,Vo.jsx)(vh,{...e.node.attrs})})},"ButtonComponentNode");var xm=require("uuid");var Ve={label:"Button",link:"",alignment:"center",size:"default",backgroundColor:"#0085FF",textColor:"#ffffff",borderWidth:0,borderRadius:0,borderColor:"#000000",padding:6,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},vs=bs.Node.create({name:"button",group:"block",atom:!0,selectable:!1,onCreate(){Ft(this.editor,this.name)},addAttributes(){return{label:{default:Ve.label,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},link:{default:Ve.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alignment:{default:Ve.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},size:{default:Ve.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},backgroundColor:{default:Ve.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},textColor:{default:Ve.textColor,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.textColor})},borderWidth:{default:Ve.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:Ve.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:Ve.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},padding:{default:Ve.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.padding})},fontWeight:{default:Ve.fontWeight,parseHTML:e=>e.getAttribute("data-font-weight"),renderHTML:e=>({"data-font-weight":e.fontWeight})},fontStyle:{default:Ve.fontStyle,parseHTML:e=>e.getAttribute("data-font-style"),renderHTML:e=>({"data-font-style":e.fontStyle})},isUnderline:{default:Ve.isUnderline,parseHTML:e=>e.getAttribute("data-is-underline"),renderHTML:e=>({"data-is-underline":e.isUnderline})},isStrike:{default:Ve.isStrike,parseHTML:e=>e.getAttribute("data-is-strike"),renderHTML:e=>({"data-is-strike":e.isStrike})},id:{default:()=>`node-${(0,xm.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})}}},parseHTML(){return[{tag:'div[data-type="button"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,bs.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return(0,vm.ReactNodeViewRenderer)(ym)},addCommands(){return{toggleBold:()=>({editor:e,chain:t})=>{let{selection:r}=e.state,o=e.state.doc.nodeAt(r.$anchor.pos);if((o==null?void 0:o.type.name)==="button"){let n=o.attrs.fontWeight==="bold"?"normal":"bold";return t().updateAttributes(o.type,{fontWeight:n}).run()}return t().focus().toggleMark("bold").run()},toggleItalic:()=>({editor:e,chain:t})=>{let{selection:r}=e.state,o=e.state.doc.nodeAt(r.$anchor.pos);if((o==null?void 0:o.type.name)==="button"){let n=o.attrs.fontStyle==="italic"?"normal":"italic";return t().updateAttributes(o.type,{fontStyle:n}).run()}return t().focus().toggleMark("italic").run()},toggleUnderline:()=>({editor:e,chain:t})=>{let{selection:r}=e.state,o=e.state.doc.nodeAt(r.$anchor.pos);if((o==null?void 0:o.type.name)==="button"){let n=!o.attrs.isUnderline;return t().updateAttributes(o.type,{isUnderline:n}).run()}return t().focus().toggleMark("underline").run()},toggleStrike:()=>({editor:e,chain:t})=>{let{selection:r}=e.state,o=e.state.doc.nodeAt(r.$anchor.pos);if((o==null?void 0:o.type.name)==="button"){let n=!o.attrs.isStrike;return t().updateAttributes(o.type,{isStrike:n}).run()}return t().focus().toggleMark("strike").run()}}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="button"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="button"},Space:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="button"},Enter:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="button"}}},addProseMirrorPlugins(){return[new ys.Plugin({key:new ys.PluginKey("preventButtonTextInput"),props:{handleTextInput:(e,t,r,o)=>{let n=e.state.doc.nodeAt(t);return(n==null?void 0:n.type.name)==="button"},handleKeyDown:(e,t)=>{let{selection:r}=e.state,o=e.state.doc.nodeAt(r.$anchor.pos);return(o==null?void 0:o.type.name)==="button"&&t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey?(t.preventDefault(),t.stopPropagation(),!0):!1}}})]}});var Vt=require("zod"),xs=Vt.z.object({label:Vt.z.string(),link:Vt.z.string().optional(),alignment:Vt.z.enum(["left","center","right"]),size:Vt.z.enum(["default","full"]),backgroundColor:Vt.z.string(),textColor:Vt.z.string(),borderWidth:Vt.z.number(),borderRadius:Vt.z.number(),borderColor:Vt.z.string(),padding:Vt.z.number(),fontWeight:Vt.z.enum(["normal","bold"]),fontStyle:Vt.z.enum(["normal","italic"]),isUnderline:Vt.z.boolean(),isStrike:Vt.z.boolean()});var wm=require("@hookform/resolvers/zod"),Em=require("react-hook-form");var Cs=require("jotai"),Bn=Me(require("react"),1),Rn=require("react");var hu=require("react/jsx-runtime"),xa=s(({items:e,command:t,selected:r=0})=>(0,hu.jsx)("div",{className:"courier-bg-white courier-rounded-md courier-shadow-lg courier-border courier-border-border courier-max-h-60 courier-overflow-y-auto",children:e.map((o,n)=>(0,hu.jsx)("button",{className:N("courier-w-full courier-px-4 courier-py-2 courier-text-left hover:courier-bg-gray-100 focus:courier-bg-gray-100 focus:courier-outline-none",n===r?"courier-bg-gray-100":""),onClick:()=>t(o),children:o},n))}),"VariableSuggestions");var vo=require("react/jsx-runtime"),Ot=Bn.forwardRef(({as:e="Input",variables:t=[],autoResize:r,onChange:o,...n},i)=>{let[a,c]=(0,Rn.useState)(!1),[l,u]=(0,Rn.useState)(null),[d,p]=(0,Rn.useState)(0),m=(0,Rn.useRef)(null),g=(0,Rn.useRef)(null),b=(0,Cs.useSetAtom)(da),h=(0,Cs.useSetAtom)(Up),y=(0,Cs.useSetAtom)(ps),P=Bn.useCallback(()=>{if(!g.current)return;let k={ref:g.current,caretPosition:g.current.selectionStart};h(k),y(k);let S={isFocused:!0,hasVariables:t.length>0,showVariablePopup:!1};b(S)},[b,h,y,t]),w=Bn.useCallback(k=>{var x,A;let S=k.relatedTarget&&((x=m.current)==null?void 0:x.contains(k.relatedTarget)),E=(A=k.relatedTarget)==null?void 0:A.closest("[data-variable-button]");!S&&!E&&(h({ref:null,caretPosition:null}),b({isFocused:!1,hasVariables:!1,showVariablePopup:!1}))},[b,h]),v=s(k=>{let S=k.target,E={ref:S,caretPosition:S.selectionStart};h(E),y(E)},"handleSelect"),f=s(k=>{var S;if(a)switch(k.key){case"ArrowUp":k.preventDefault(),p(E=>E>0?E-1:t.length-1);break;case"ArrowDown":k.preventDefault(),p(E=>E<t.length-1?E+1:0);break;case"Enter":if(t[d]){k.preventDefault(),k.stopPropagation(),C(t[d]);return}break;case"Escape":c(!1),k.preventDefault(),k.stopPropagation();break}(S=n.onKeyDown)==null||S.call(n,k)},"handleKeyDown"),C=s(k=>{let S=g.current;if(!S)return;let E=S.value,x=S.selectionStart||0,A=E.substring(0,x-2),I=E.substring(x),H=`${A}{{${k}}}${I}`,D=x+k.length+3;if(o){let B={target:{...S,value:H}};o(B)}setTimeout(()=>{S.value=H,S.setSelectionRange(D,D)},0),c(!1)},"insertVariable"),T=s(k=>{var A;let S=k.target,E=S.value,x=S.selectionStart||0;if(E.slice(x-2,x)==="{{"&&((A=m.current)==null?void 0:A.getBoundingClientRect())){let H=E.slice(0,x),D=document.createElement("span");D.style.font=window.getComputedStyle(S).font,D.style.whiteSpace="pre-wrap",D.textContent=H,document.body.appendChild(D);let B=D.offsetWidth;document.body.removeChild(D);let z=parseInt(window.getComputedStyle(S).lineHeight),X=H.split(`
|
|
178
178
|
`).length-1;u({left:Math.min(B%S.offsetWidth,S.offsetWidth-200),top:X*z+30}),c(!0),p(0)}o&&o({target:S,currentTarget:S,type:"change",preventDefault:()=>{},stopPropagation:()=>{}})},"handleChange"),R=s(k=>{var A;let S=k.target,E=S.value,x=S.selectionStart||0;if(E.slice(x-2,x)==="{{"&&((A=m.current)==null?void 0:A.getBoundingClientRect())){let H=E.slice(0,x),D=document.createElement("span");D.style.font=window.getComputedStyle(S).font,D.style.whiteSpace="pre-wrap",D.textContent=H,document.body.appendChild(D);let B=D.offsetWidth;document.body.removeChild(D);let z=parseInt(window.getComputedStyle(S).lineHeight),X=H.split(`
|
|
179
179
|
`).length-1;u({left:Math.min(B%S.offsetWidth,S.offsetWidth-200),top:X*z+30}),c(!0),p(0)}o&&o({target:S,currentTarget:S,type:"change",preventDefault:()=>{},stopPropagation:()=>{}})},"handleInput");if(Bn.useEffect(()=>{let k=g.current;if(!k)return;let S=s(E=>{u(E.detail.cursorPosition),c(!0),p(0)},"handleShowSuggestions");return k.addEventListener("showVariableSuggestions",S),()=>{k.removeEventListener("showVariableSuggestions",S)}},[]),e==="Input"){let k={...n,ref:S=>{g.current=S,typeof i=="function"?i(S):i&&(i.current=S)},onChange:T,onInput:R,onKeyDown:f,onFocus:P,onBlur:w,onSelect:v};return(0,vo.jsxs)("div",{ref:m,className:"courier-relative",children:[(0,vo.jsx)(ce,{...k}),a&&l&&(0,vo.jsx)("div",{style:{position:"absolute",left:`${l.left}px`,top:`${l.top}px`,zIndex:50},children:(0,vo.jsx)(xa,{items:t,command:C,selected:d})})]})}let M={...n,ref:k=>{g.current=k,typeof i=="function"?i(k):i&&(i.current=k)},onChange:T,onInput:R,onKeyDown:f,onFocus:P,onBlur:w,autoResize:r,onSelect:v};return(0,vo.jsxs)("div",{ref:m,className:"courier-relative",children:[(0,vo.jsx)(Cc,{...M}),a&&l&&(0,vo.jsx)("div",{style:{position:"absolute",left:`${l.left}px`,top:`${l.top}px`,zIndex:50},children:(0,vo.jsx)(xa,{items:t,command:C,selected:d})})]})});Ot.displayName="TextInput";var Mr=s((e={},t="")=>Object.entries(e).reduce((r,[o,n])=>{let i=t?`${t}.${o}`:o;return n&&typeof n=="object"&&!Array.isArray(n)?[...r,...Mr(n,i)]:[...r,i]},[]),"getFlattenedVariables");var dr=require("react/jsx-runtime"),Ca="#80849D",xo=30,Ts=s(({color:e=Ca,width:t=xo,height:r=xo,...o})=>(0,dr.jsx)(J,{...o,width:t,height:r,children:(0,dr.jsx)("path",{d:"M6.375 23.9998C6.375 24.345 6.65482 24.6248 7 24.6248C7.34518 24.6248 7.625 24.345 7.625 23.9998H6.375ZM7.625 7.33317C7.625 6.98799 7.34518 6.70817 7 6.70817C6.65482 6.70817 6.375 6.98799 6.375 7.33317H7.625ZM7.625 23.9998V7.33317H6.375V23.9998H7.625ZM10.4583 16.4995V14.8328H9.20834V16.4995H10.4583ZM11.5 13.7912H21.5V12.5412H11.5V13.7912ZM22.5417 14.8328V16.4995H23.7917V14.8328H22.5417ZM21.5 17.5412H11.5V18.7912H21.5V17.5412ZM22.5417 16.4995C22.5417 16.91 22.5403 17.155 22.5167 17.3306C22.5059 17.4111 22.4932 17.4514 22.4857 17.4695C22.484 17.4737 22.4826 17.4765 22.4818 17.4781C22.481 17.4797 22.4805 17.4804 22.4805 17.4805C22.4804 17.4805 22.4805 17.4803 22.4808 17.4801C22.481 17.4798 22.481 17.4798 22.4807 17.4802L23.3645 18.364C23.6221 18.1065 23.7158 17.7934 23.7556 17.4972C23.793 17.2189 23.7917 16.8747 23.7917 16.4995H22.5417ZM21.5 18.7912C21.8752 18.7912 22.2194 18.7925 22.4977 18.7551C22.7939 18.7153 23.107 18.6216 23.3645 18.364L22.4807 17.4802C22.4803 17.4805 22.4803 17.4805 22.4806 17.4803C22.4808 17.48 22.481 17.4799 22.481 17.48C22.4809 17.48 22.4802 17.4805 22.4786 17.4813C22.477 17.4821 22.4742 17.4835 22.47 17.4852C22.4519 17.4927 22.4116 17.5054 22.3311 17.5162C22.1555 17.5398 21.9105 17.5412 21.5 17.5412V18.7912ZM21.5 13.7912C21.9105 13.7912 22.1555 13.7925 22.3311 13.8161C22.4116 13.8269 22.4519 13.8397 22.47 13.8471C22.4742 13.8489 22.477 13.8502 22.4786 13.8511C22.4802 13.8519 22.4809 13.8524 22.481 13.8524C22.481 13.8524 22.4808 13.8523 22.4806 13.8521C22.4803 13.8518 22.4803 13.8518 22.4807 13.8522L23.3645 12.9683C23.107 12.7108 22.7939 12.6171 22.4977 12.5773C22.2194 12.5398 21.8752 12.5412 21.5 12.5412V13.7912ZM23.7917 14.8328C23.7917 14.4577 23.793 14.1134 23.7556 13.8352C23.7158 13.5389 23.6221 13.2258 23.3645 12.9683L22.4807 13.8522C22.481 13.8526 22.481 13.8526 22.4808 13.8523C22.4805 13.852 22.4804 13.8518 22.4805 13.8519C22.4805 13.8519 22.481 13.8526 22.4818 13.8542C22.4826 13.8558 22.484 13.8586 22.4857 13.8628C22.4932 13.881 22.5059 13.9213 22.5167 14.0017C22.5403 14.1773 22.5417 14.4223 22.5417 14.8328H23.7917ZM10.4583 14.8328C10.4583 14.4223 10.4597 14.1773 10.4833 14.0017C10.4941 13.9213 10.5068 13.881 10.5143 13.8628C10.516 13.8586 10.5174 13.8558 10.5182 13.8542C10.5191 13.8526 10.5195 13.8519 10.5196 13.8519C10.5196 13.8518 10.5195 13.852 10.5192 13.8523C10.519 13.8526 10.519 13.8526 10.5194 13.8522L9.63548 12.9683C9.37796 13.2258 9.28425 13.5389 9.24443 13.8352C9.20702 14.1134 9.20834 14.4577 9.20834 14.8328H10.4583ZM11.5 12.5412C11.1248 12.5412 10.7806 12.5398 10.5023 12.5773C10.2061 12.6171 9.893 12.7108 9.63548 12.9683L10.5194 13.8522C10.5197 13.8518 10.5198 13.8518 10.5195 13.8521C10.5192 13.8523 10.519 13.8524 10.519 13.8524C10.5191 13.8524 10.5198 13.8519 10.5214 13.8511C10.523 13.8502 10.5258 13.8489 10.53 13.8471C10.5481 13.8397 10.5884 13.8269 10.6689 13.8161C10.8445 13.7925 11.0895 13.7912 11.5 13.7912V12.5412ZM9.20834 16.4995C9.20834 16.8747 9.20702 17.2189 9.24443 17.4972C9.28425 17.7934 9.37796 18.1065 9.63548 18.364L10.5194 17.4802C10.519 17.4798 10.519 17.4798 10.5192 17.4801C10.5195 17.4803 10.5196 17.4805 10.5196 17.4805C10.5195 17.4804 10.5191 17.4797 10.5182 17.4781C10.5174 17.4765 10.516 17.4737 10.5143 17.4695C10.5068 17.4514 10.4941 17.4111 10.4833 17.3306C10.4597 17.155 10.4583 16.91 10.4583 16.4995H9.20834ZM11.5 17.5412C11.0895 17.5412 10.8445 17.5398 10.6689 17.5162C10.5884 17.5054 10.5481 17.4927 10.53 17.4852C10.5258 17.4835 10.523 17.4821 10.5214 17.4813C10.5198 17.4805 10.5191 17.48 10.519 17.48C10.519 17.4799 10.5192 17.48 10.5195 17.4803C10.5198 17.4805 10.5197 17.4805 10.5194 17.4802L9.63548 18.364C9.893 18.6216 10.2061 18.7153 10.5023 18.7551C10.7806 18.7925 11.1248 18.7912 11.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignLeftIcon"),ws=s(({color:e=Ca,width:t=xo,height:r=xo,...o})=>(0,dr.jsx)(J,{...o,width:t,height:r,children:(0,dr.jsx)("path",{d:"M14.9583 7C14.9583 6.65482 14.6785 6.375 14.3333 6.375C13.9881 6.375 13.7083 6.65482 13.7083 7L14.9583 7ZM13.7083 23.3333C13.7083 23.6785 13.9881 23.9583 14.3333 23.9583C14.6785 23.9583 14.9583 23.6785 14.9583 23.3333L13.7083 23.3333ZM13.7083 7L13.7083 12.6665L14.9583 12.6665L14.9583 7L13.7083 7ZM20.375 14.3332L20.375 15.9998L21.625 15.9998L21.625 14.3332L20.375 14.3332ZM19.3333 17.0415L9.33333 17.0415L9.33333 18.2915L19.3333 18.2915L19.3333 17.0415ZM8.29167 15.9998L8.29167 14.3332L7.04167 14.3332L7.04167 15.9998L8.29167 15.9998ZM9.33333 13.2915L19.3333 13.2915L19.3333 12.0415L9.33333 12.0415L9.33333 13.2915ZM8.29167 14.3332C8.29167 13.9227 8.29299 13.6777 8.3166 13.5021C8.32742 13.4216 8.34016 13.3813 8.34763 13.3631C8.34936 13.3589 8.35071 13.3562 8.35155 13.3546C8.35238 13.353 8.35284 13.3523 8.35289 13.3522C8.35292 13.3521 8.35279 13.3523 8.35256 13.3526C8.35232 13.3529 8.35231 13.3529 8.35269 13.3525L7.4688 12.4686C7.21128 12.7262 7.11758 13.0393 7.07775 13.3355C7.04034 13.6138 7.04167 13.958 7.04167 14.3332L8.29167 14.3332ZM9.33333 12.0415C8.95816 12.0415 8.61391 12.0402 8.33566 12.0776C8.03943 12.1174 7.72632 12.2111 7.4688 12.4686L8.35269 13.3525C8.35307 13.3521 8.35308 13.3522 8.35279 13.3524C8.3525 13.3526 8.3523 13.3528 8.35236 13.3527C8.35243 13.3527 8.35313 13.3522 8.35472 13.3514C8.35634 13.3505 8.3591 13.3492 8.3633 13.3475C8.38145 13.34 8.42175 13.3273 8.50222 13.3164C8.67782 13.2928 8.92283 13.2915 9.33333 13.2915L9.33333 12.0415ZM9.33333 17.0415C8.92283 17.0415 8.67782 17.0402 8.50222 17.0166C8.42175 17.0057 8.38145 16.993 8.3633 16.9855C8.3591 16.9838 8.35634 16.9825 8.35472 16.9816C8.35313 16.9808 8.35243 16.9803 8.35236 16.9803C8.3523 16.9802 8.3525 16.9804 8.35279 16.9806C8.35308 16.9808 8.35307 16.9809 8.35269 16.9805L7.4688 17.8644C7.72632 18.1219 8.03943 18.2156 8.33566 18.2554C8.61391 18.2928 8.95816 18.2915 9.33333 18.2915L9.33333 17.0415ZM7.04167 15.9998C7.04167 16.375 7.04034 16.7193 7.07775 16.9975C7.11758 17.2937 7.21128 17.6068 7.4688 17.8644L8.35269 16.9805C8.3523 16.9801 8.35232 16.9801 8.35256 16.9804C8.35279 16.9807 8.35292 16.9809 8.35289 16.9808C8.35284 16.9807 8.35238 16.98 8.35155 16.9784C8.35071 16.9768 8.34936 16.9741 8.34763 16.9699C8.34016 16.9517 8.32742 16.9114 8.3166 16.8309C8.29299 16.6553 8.29167 16.4103 8.29167 15.9998L7.04167 15.9998ZM20.375 15.9998C20.375 16.4103 20.3737 16.6553 20.3501 16.8309C20.3392 16.9114 20.3265 16.9517 20.319 16.9699C20.3173 16.9741 20.316 16.9768 20.3151 16.9784C20.3143 16.98 20.3138 16.9807 20.3138 16.9808C20.3137 16.9809 20.3139 16.9807 20.3141 16.9804C20.3143 16.9801 20.3144 16.9801 20.314 16.9805L21.1979 17.8644C21.4554 17.6068 21.5491 17.2937 21.5889 16.9975C21.6263 16.7193 21.625 16.375 21.625 15.9998L20.375 15.9998ZM19.3333 18.2915C19.7085 18.2915 20.0528 18.2928 20.331 18.2554C20.6272 18.2156 20.9403 18.1219 21.1979 17.8644L20.314 16.9805C20.3136 16.9809 20.3136 16.9808 20.3139 16.9806C20.3142 16.9804 20.3144 16.9802 20.3143 16.9803C20.3142 16.9803 20.3135 16.9808 20.3119 16.9816C20.3103 16.9825 20.3076 16.9838 20.3034 16.9855C20.2852 16.993 20.2449 17.0057 20.1644 17.0166C19.9888 17.0402 19.7438 17.0415 19.3333 17.0415L19.3333 18.2915ZM21.625 14.3332C21.625 13.958 21.6263 13.6138 21.5889 13.3355C21.5491 13.0393 21.4554 12.7262 21.1979 12.4686L20.314 13.3525C20.3144 13.3529 20.3143 13.3529 20.3141 13.3526C20.3139 13.3523 20.3137 13.3521 20.3138 13.3522C20.3138 13.3523 20.3143 13.353 20.3151 13.3546C20.316 13.3562 20.3173 13.3589 20.319 13.3631C20.3265 13.3813 20.3392 13.4216 20.3501 13.5021C20.3737 13.6777 20.375 13.9227 20.375 14.3332L21.625 14.3332ZM19.3333 13.2915C19.7438 13.2915 19.9888 13.2928 20.1644 13.3164C20.2449 13.3273 20.2852 13.34 20.3034 13.3475C20.3076 13.3492 20.3103 13.3505 20.3119 13.3514C20.3135 13.3522 20.3142 13.3527 20.3143 13.3527C20.3144 13.3528 20.3142 13.3526 20.3139 13.3524C20.3136 13.3522 20.3136 13.3521 20.314 13.3525L21.1979 12.4686C20.9403 12.2111 20.6272 12.1174 20.331 12.0776C20.0528 12.0402 19.7085 12.0415 19.3333 12.0415L19.3333 13.2915ZM13.7083 17.6665L13.7083 23.3333L14.9583 23.3333L14.9583 17.6665L13.7083 17.6665Z",fill:e})}),"ButtonAlignCenterIcon"),Es=s(({color:e=Ca,width:t=xo,height:r=xo,...o})=>(0,dr.jsx)(J,{...o,width:t,height:r,children:(0,dr.jsx)("path",{d:"M23.625 23.9998C23.625 24.345 23.3452 24.6248 23 24.6248C22.6548 24.6248 22.375 24.345 22.375 23.9998H23.625ZM22.375 7.33317C22.375 6.98799 22.6548 6.70817 23 6.70817C23.3452 6.70817 23.625 6.98799 23.625 7.33317H22.375ZM22.375 23.9998V7.33317H23.625V23.9998H22.375ZM19.5417 16.4995V14.8328H20.7917V16.4995H19.5417ZM18.5 13.7912H8.49999V12.5412H18.5V13.7912ZM7.45832 14.8328V16.4995H6.20832V14.8328H7.45832ZM8.49999 17.5412H18.5V18.7912H8.49999V17.5412ZM7.45832 16.4995C7.45832 16.91 7.45965 17.155 7.48326 17.3306C7.49408 17.4111 7.50682 17.4514 7.51429 17.4695C7.51602 17.4737 7.51737 17.4765 7.51821 17.4781C7.51904 17.4797 7.5195 17.4804 7.51955 17.4805C7.51958 17.4805 7.51945 17.4803 7.51922 17.4801C7.51898 17.4798 7.51896 17.4798 7.51934 17.4802L6.63546 18.364C6.37794 18.1065 6.28424 17.7934 6.24441 17.4972C6.207 17.2189 6.20832 16.8747 6.20832 16.4995H7.45832ZM8.49999 18.7912C8.12482 18.7912 7.78057 18.7925 7.50232 18.7551C7.20608 18.7153 6.89298 18.6216 6.63546 18.364L7.51934 17.4802C7.51972 17.4805 7.51974 17.4805 7.51945 17.4803C7.51916 17.48 7.51896 17.4799 7.51902 17.48C7.51909 17.48 7.51979 17.4805 7.52138 17.4813C7.52299 17.4821 7.52576 17.4835 7.52996 17.4852C7.54811 17.4927 7.58841 17.5054 7.66888 17.5162C7.84448 17.5398 8.08948 17.5412 8.49999 17.5412V18.7912ZM8.49999 13.7912C8.08948 13.7912 7.84448 13.7925 7.66888 13.8161C7.58841 13.8269 7.54811 13.8397 7.52996 13.8471C7.52576 13.8489 7.52299 13.8502 7.52138 13.8511C7.51979 13.8519 7.51909 13.8524 7.51902 13.8524C7.51896 13.8524 7.51916 13.8523 7.51945 13.8521C7.51974 13.8518 7.51972 13.8518 7.51934 13.8522L6.63546 12.9683C6.89298 12.7108 7.20608 12.6171 7.50232 12.5773C7.78057 12.5398 8.12482 12.5412 8.49999 12.5412V13.7912ZM6.20832 14.8328C6.20832 14.4577 6.207 14.1134 6.24441 13.8352C6.28424 13.5389 6.37794 13.2258 6.63546 12.9683L7.51934 13.8522C7.51896 13.8526 7.51898 13.8526 7.51922 13.8523C7.51945 13.852 7.51958 13.8518 7.51955 13.8519C7.5195 13.8519 7.51904 13.8526 7.51821 13.8542C7.51737 13.8558 7.51602 13.8586 7.51429 13.8628C7.50682 13.881 7.49408 13.9213 7.48326 14.0017C7.45965 14.1773 7.45832 14.4223 7.45832 14.8328H6.20832ZM19.5417 14.8328C19.5417 14.4223 19.5403 14.1773 19.5167 14.0017C19.5059 13.9213 19.4932 13.881 19.4857 13.8628C19.484 13.8586 19.4826 13.8558 19.4818 13.8542C19.4809 13.8526 19.4805 13.8519 19.4804 13.8519C19.4804 13.8518 19.4805 13.852 19.4808 13.8523C19.481 13.8526 19.481 13.8526 19.4806 13.8522L20.3645 12.9683C20.622 13.2258 20.7157 13.5389 20.7556 13.8352C20.793 14.1134 20.7917 14.4577 20.7917 14.8328H19.5417ZM18.5 12.5412C18.8752 12.5412 19.2194 12.5398 19.4977 12.5773C19.7939 12.6171 20.107 12.7108 20.3645 12.9683L19.4806 13.8522C19.4803 13.8518 19.4802 13.8518 19.4805 13.8521C19.4808 13.8523 19.481 13.8524 19.481 13.8524C19.4809 13.8524 19.4802 13.8519 19.4786 13.8511C19.477 13.8502 19.4742 13.8489 19.47 13.8471C19.4519 13.8397 19.4116 13.8269 19.3311 13.8161C19.1555 13.7925 18.9105 13.7912 18.5 13.7912V12.5412ZM20.7917 16.4995C20.7917 16.8747 20.793 17.2189 20.7556 17.4972C20.7157 17.7934 20.622 18.1065 20.3645 18.364L19.4806 17.4802C19.481 17.4798 19.481 17.4798 19.4808 17.4801C19.4805 17.4803 19.4804 17.4805 19.4804 17.4805C19.4805 17.4804 19.4809 17.4797 19.4818 17.4781C19.4826 17.4765 19.484 17.4737 19.4857 17.4695C19.4932 17.4514 19.5059 17.4111 19.5167 17.3306C19.5403 17.155 19.5417 16.91 19.5417 16.4995H20.7917ZM18.5 17.5412C18.9105 17.5412 19.1555 17.5398 19.3311 17.5162C19.4116 17.5054 19.4519 17.4927 19.47 17.4852C19.4742 17.4835 19.477 17.4821 19.4786 17.4813C19.4802 17.4805 19.4809 17.48 19.481 17.48C19.481 17.4799 19.4808 17.48 19.4805 17.4803C19.4802 17.4805 19.4803 17.4805 19.4806 17.4802L20.3645 18.364C20.107 18.6216 19.7939 18.7153 19.4977 18.7551C19.2194 18.7925 18.8752 18.7912 18.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignRightIcon"),Cm=s(({color:e=Ca,width:t=xo,height:r=xo,...o})=>(0,dr.jsxs)(J,{...o,width:t,height:r,children:[(0,dr.jsx)("path",{d:"M10.3007 18.8007C10.0566 19.0448 10.0566 19.4405 10.3007 19.6846C10.5448 19.9287 10.9405 19.9287 11.1846 19.6846L10.3007 18.8007ZM11.1846 10.3154C10.9405 10.0713 10.5448 10.0713 10.3007 10.3154C10.0566 10.5595 10.0566 10.9552 10.3007 11.1993L11.1846 10.3154ZM8.11464 14.375C7.76946 14.375 7.48964 14.6548 7.48964 15C7.48964 15.3452 7.76946 15.625 8.11464 15.625L8.11464 14.375ZM13.5092 15.625C13.8544 15.625 14.1342 15.3452 14.1342 15C14.1342 14.6548 13.8544 14.375 13.5092 14.375L13.5092 15.625ZM11.1846 19.6846L13.9512 16.918L13.0673 16.0341L10.3007 18.8007L11.1846 19.6846ZM13.9512 13.082L11.1846 10.3154L10.3007 11.1993L13.0673 13.9659L13.9512 13.082ZM13.9512 16.918C14.2866 16.5826 14.5836 16.2875 14.7889 16.0183C15.0053 15.7347 15.178 15.4078 15.178 15L13.928 15C13.928 15.0246 13.9267 15.0877 13.7951 15.2601C13.6526 15.4469 13.4277 15.6737 13.0673 16.0341L13.9512 16.918ZM13.0673 13.9659C13.4277 14.3263 13.6526 14.5531 13.7951 14.7399C13.9267 14.9123 13.928 14.9754 13.928 15L15.178 15C15.178 14.5922 15.0053 14.2653 14.7889 13.9817C14.5836 13.7125 14.2866 13.4174 13.9512 13.082L13.0673 13.9659ZM8.11464 15.625L13.5092 15.625L13.5092 14.375L8.11464 14.375L8.11464 15.625Z",fill:e}),(0,dr.jsx)("path",{d:"M21.6993 18.8007C21.9434 19.0448 21.9434 19.4405 21.6993 19.6846C21.4552 19.9287 21.0595 19.9287 20.8154 19.6846L21.6993 18.8007ZM20.8154 10.3154C21.0595 10.0713 21.4552 10.0713 21.6993 10.3154C21.9434 10.5595 21.9434 10.9552 21.6993 11.1993L20.8154 10.3154ZM23.8854 14.375C24.2305 14.375 24.5104 14.6548 24.5104 15C24.5104 15.3452 24.2305 15.625 23.8854 15.625L23.8854 14.375ZM18.4908 15.625C18.1456 15.625 17.8658 15.3452 17.8658 15C17.8658 14.6548 18.1456 14.375 18.4908 14.375L18.4908 15.625ZM20.8154 19.6846L18.0488 16.918L18.9327 16.0341L21.6993 18.8007L20.8154 19.6846ZM18.0488 13.082L20.8154 10.3154L21.6993 11.1993L18.9327 13.9659L18.0488 13.082ZM18.0488 16.918C17.7134 16.5826 17.4164 16.2875 17.2111 16.0183C16.9947 15.7347 16.822 15.4078 16.822 15L18.072 15C18.072 15.0246 18.0733 15.0877 18.2049 15.2601C18.3474 15.4469 18.5723 15.6737 18.9327 16.0341L18.0488 16.918ZM18.9327 13.9659C18.5723 14.3263 18.3474 14.5531 18.2049 14.7399C18.0733 14.9123 18.072 14.9754 18.072 15L16.822 15C16.822 14.5922 16.9947 14.2653 17.2111 13.9817C17.4164 13.7125 17.7134 13.4174 18.0488 13.082L18.9327 13.9659ZM23.8854 15.625L18.4908 15.625L18.4908 14.375L23.8854 14.375L23.8854 15.625Z",fill:e})]}),"ButtonSizeDefaultIcon"),Tm=s(({color:e=Ca,width:t=xo,height:r=xo,...o})=>(0,dr.jsxs)(J,{...o,width:t,height:r,children:[(0,dr.jsx)("path",{d:"M9.18459 18.8007C9.42867 19.0448 9.42867 19.4405 9.18459 19.6846C8.94051 19.9287 8.54479 19.9287 8.30071 19.6846L9.18459 18.8007ZM8.30071 10.3154C8.54479 10.0713 8.94051 10.0713 9.18459 10.3154C9.42867 10.5595 9.42867 10.9552 9.18459 11.1993L8.30071 10.3154ZM11.3707 14.375C11.7158 14.375 11.9957 14.6548 11.9957 15C11.9957 15.3452 11.7158 15.625 11.3707 15.625L11.3707 14.375ZM5.97605 15.625C5.63087 15.625 5.35105 15.3452 5.35105 15C5.35105 14.6548 5.63087 14.375 5.97605 14.375L5.97605 15.625ZM8.30071 19.6846L5.5341 16.918L6.41799 16.0341L9.18459 18.8007L8.30071 19.6846ZM5.5341 13.082L8.30071 10.3154L9.18459 11.1993L6.41799 13.9659L5.5341 13.082ZM5.5341 16.918C5.19869 16.5826 4.90174 16.2875 4.69637 16.0183C4.48 15.7347 4.30733 15.4078 4.30733 15L5.55733 15C5.55733 15.0246 5.55861 15.0877 5.69015 15.2601C5.83269 15.4469 6.05759 15.6737 6.41799 16.0341L5.5341 16.918ZM6.41799 13.9659C6.05759 14.3263 5.83269 14.5531 5.69015 14.7399C5.55861 14.9123 5.55733 14.9754 5.55733 15L4.30733 15C4.30733 14.5922 4.48 14.2653 4.69637 13.9817C4.90174 13.7125 5.19869 13.4174 5.5341 13.082L6.41799 13.9659ZM11.3707 15.625L5.97605 15.625L5.97605 14.375L11.3707 14.375L11.3707 15.625Z",fill:e}),(0,dr.jsx)("path",{d:"M22.8154 18.8007C22.5713 19.0448 22.5713 19.4405 22.8154 19.6846C23.0595 19.9287 23.4552 19.9287 23.6993 19.6846L22.8154 18.8007ZM23.6993 10.3154C23.4552 10.0713 23.0595 10.0713 22.8154 10.3154C22.5713 10.5595 22.5713 10.9552 22.8154 11.1993L23.6993 10.3154ZM20.6293 14.375C20.2842 14.375 20.0043 14.6548 20.0043 15C20.0043 15.3452 20.2842 15.625 20.6293 15.625L20.6293 14.375ZM26.024 15.625C26.3691 15.625 26.649 15.3452 26.649 15C26.649 14.6548 26.3691 14.375 26.024 14.375L26.024 15.625ZM23.6993 19.6846L26.4659 16.918L25.582 16.0341L22.8154 18.8007L23.6993 19.6846ZM26.4659 13.082L23.6993 10.3154L22.8154 11.1993L25.582 13.9659L26.4659 13.082ZM26.4659 16.918C26.8013 16.5826 27.0983 16.2875 27.3036 16.0183C27.52 15.7347 27.6927 15.4078 27.6927 15L26.4427 15C26.4427 15.0246 26.4414 15.0877 26.3099 15.2601C26.1673 15.4469 25.9424 15.6737 25.582 16.0341L26.4659 16.918ZM25.582 13.9659C25.9424 14.3263 26.1673 14.5531 26.3099 14.7399C26.4414 14.9123 26.4427 14.9754 26.4427 15L27.6927 15C27.6927 14.5922 27.52 14.2653 27.3036 13.9817C27.0983 13.7125 26.8013 13.4174 26.4659 13.082L25.582 13.9659ZM20.6293 15.625L26.024 15.625L26.024 14.375L20.6293 14.375L20.6293 15.625Z",fill:e})]}),"ButtonSizeFullIcon");var W=require("react/jsx-runtime"),km=s(({element:e,editor:t})=>{var a,c;let r=(0,Em.useForm)({resolver:(0,wm.zodResolver)(xs),defaultValues:{...Ve,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=cr({editor:t,element:e,form:r,nodeType:"button"}),n=((c=(a=t==null?void 0:t.extensionManager.extensions.find(l=>l.name==="variableSuggestion"))==null?void 0:a.options)==null?void 0:c.variables)||{},i=Mr(n);return e?(0,W.jsxs)(Ye,{...r,children:[(0,W.jsx)(ur,{type:"button"}),(0,W.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,W.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,W.jsx)(q,{control:r.control,name:"link",render:({field:l})=>(0,W.jsxs)(_,{children:[(0,W.jsx)(Z,{children:(0,W.jsx)(Ot,{as:"Textarea",...l,variables:i,onChange:u=>{l.onChange(u),o({...r.getValues(),link:u.target.value})}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,W.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Text"}),(0,W.jsx)(q,{control:r.control,name:"label",render:({field:l})=>(0,W.jsxs)(_,{className:"courier-mb-2",children:[(0,W.jsx)(Z,{children:(0,W.jsx)(Ot,{...l,variables:i,onChange:u=>{l.onChange(u),o({...r.getValues(),label:u.target.value})}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(q,{control:r.control,name:"textColor",render:({field:l})=>(0,W.jsxs)(_,{className:"courier-mb-4",children:[(0,W.jsx)(Z,{children:(0,W.jsx)(pt,{...l,defaultValue:Ve.textColor,onChange:u=>{l.onChange(u),o({...r.getValues(),[l.name]:u})}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,W.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Background"}),(0,W.jsx)(q,{control:r.control,name:"backgroundColor",render:({field:l})=>(0,W.jsxs)(_,{className:"courier-mb-4",children:[(0,W.jsx)(Z,{children:(0,W.jsx)(pt,{...l,defaultValue:Ve.backgroundColor,onChange:u=>{l.onChange(u),o({...r.getValues(),[l.name]:u})}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,W.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,W.jsx)(q,{control:r.control,name:"padding",render:({field:l})=>(0,W.jsxs)(_,{className:"courier-mb-2",children:[(0,W.jsx)(Z,{children:(0,W.jsx)(ce,{type:"number",min:0,...l})}),(0,W.jsx)(G,{})]})}),(0,W.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-6",children:[(0,W.jsx)(q,{control:r.control,name:"alignment",render:({field:l})=>(0,W.jsxs)(_,{children:[(0,W.jsx)(Z,{children:(0,W.jsxs)(rr,{type:"single",value:l.value,onValueChange:u=>{l.onChange(u),o({...r.getValues(),alignment:u})},children:[(0,W.jsx)(Qe,{value:"left",children:(0,W.jsx)(Ts,{})}),(0,W.jsx)(Qe,{value:"center",children:(0,W.jsx)(ws,{})}),(0,W.jsx)(Qe,{value:"right",children:(0,W.jsx)(Es,{})})]})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(q,{control:r.control,name:"size",render:({field:l})=>(0,W.jsxs)(_,{children:[(0,W.jsx)(Z,{children:(0,W.jsxs)(rr,{type:"single",value:l.value,onValueChange:u=>{l.onChange(u),o({...r.getValues(),size:u})},children:[(0,W.jsx)(Qe,{value:"default",children:(0,W.jsx)(Cm,{})}),(0,W.jsx)(Qe,{value:"full",children:(0,W.jsx)(Tm,{})})]})}),(0,W.jsx)(G,{})]})})]}),(0,W.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,W.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,W.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,W.jsx)(q,{control:r.control,name:"borderWidth",render:({field:l})=>(0,W.jsxs)(_,{children:[(0,W.jsx)(Z,{children:(0,W.jsx)(ce,{startAdornment:(0,W.jsx)(to,{}),type:"number",min:0,...l})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(q,{control:r.control,name:"borderRadius",render:({field:l})=>(0,W.jsxs)(_,{children:[(0,W.jsx)(Z,{children:(0,W.jsx)(ce,{startAdornment:(0,W.jsx)(kn,{}),type:"number",min:0,...l})}),(0,W.jsx)(G,{})]})})]}),(0,W.jsx)(q,{control:r.control,name:"borderColor",render:({field:l})=>(0,W.jsxs)(_,{className:"courier-mb-4",children:[(0,W.jsx)(Z,{children:(0,W.jsx)(pt,{...l,defaultValue:Ve.borderColor,onChange:u=>{l.onChange(u),o({...r.getValues(),[l.name]:u})}})}),(0,W.jsx)(G,{})]})})]})]}):null},"ButtonForm");var ks=require("@tiptap/core"),Sm=require("@tiptap/react"),Am=require("uuid");var Pm=require("jotai"),Mm=require("react");var on=require("react/jsx-runtime"),xh=s(({button1Label:e,button1Link:t,button1BackgroundColor:r,button1TextColor:o,button2Label:n,button2Link:i,button2BackgroundColor:a,button2TextColor:c,padding:l=6})=>(0,on.jsx)("div",{className:"node-element",children:(0,on.jsxs)("div",{className:"courier-flex courier-gap-1 courier-justify-start",style:{marginTop:`${l}px`,marginBottom:`${l}px`},children:[(0,on.jsx)("div",{className:N("courier-inline-flex courier-justify-start courier-px-2 courier-py-1 courier-cursor-pointer courier-text-sm courier-rounded-sm courier-border courier-border-border"),style:{backgroundColor:r,color:o,borderColor:"#000000",borderRadius:"4px"},children:e}),(0,on.jsx)("div",{className:N("courier-inline-flex courier-justify-start courier-px-2 courier-py-1 courier-cursor-pointer courier-text-sm courier-rounded-sm courier-border courier-border-border"),style:{backgroundColor:a,color:c,borderColor:"#000000",borderRadius:"4px"},children:n})]})}),"ButtonRowComponent"),Nm=s(e=>{let t=(0,Pm.useSetAtom)(mt),r=(0,Mm.useCallback)(()=>{if(!e.editor.isEditable)return;let o=ft(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return(0,on.jsx)(lr,{id:e.node.attrs.id,className:N(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,"data-node-type":"buttonRow",children:(0,on.jsx)(xh,{...e.node.attrs})})},"ButtonRowComponentNode");var oo={button1Label:"Register",button1Link:"",button1BackgroundColor:"#000000",button1TextColor:"#ffffff",button2Label:"Learn more",button2Link:"",button2BackgroundColor:"#ffffff",button2TextColor:"#000000",padding:6},Ps=ks.Node.create({name:"buttonRow",group:"block",atom:!0,onCreate(){Ft(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${(0,Am.v4)()}`,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.id})},button1Label:{default:oo.button1Label,parseHTML:e=>e.getAttribute("data-button1-label"),renderHTML:e=>({"data-button1-label":e.button1Label})},button1Link:{default:oo.button1Link,parseHTML:e=>e.getAttribute("data-button1-link"),renderHTML:e=>({"data-button1-link":e.button1Link})},button1BackgroundColor:{default:oo.button1BackgroundColor,parseHTML:e=>e.getAttribute("data-button1-bg"),renderHTML:e=>({"data-button1-bg":e.button1BackgroundColor})},button1TextColor:{default:oo.button1TextColor,parseHTML:e=>e.getAttribute("data-button1-color"),renderHTML:e=>({"data-button1-color":e.button1TextColor})},button2Label:{default:oo.button2Label,parseHTML:e=>e.getAttribute("data-button2-label"),renderHTML:e=>({"data-button2-label":e.button2Label})},button2Link:{default:oo.button2Link,parseHTML:e=>e.getAttribute("data-button2-link"),renderHTML:e=>({"data-button2-link":e.button2Link})},button2BackgroundColor:{default:oo.button2BackgroundColor,parseHTML:e=>e.getAttribute("data-button2-bg"),renderHTML:e=>({"data-button2-bg":e.button2BackgroundColor})},button2TextColor:{default:oo.button2TextColor,parseHTML:e=>e.getAttribute("data-button2-color"),renderHTML:e=>({"data-button2-color":e.button2TextColor})},padding:{default:oo.padding,parseHTML:e=>parseInt(e.getAttribute("data-padding")||"6"),renderHTML:e=>({"data-padding":e.padding})}}},parseHTML(){return[{tag:'div[data-type="buttonRow"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,ks.mergeAttributes)(e,{"data-type":"buttonRow"})]},addNodeView(){return(0,Sm.ReactNodeViewRenderer)(Nm)},addCommands(){return{setButtonRow:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...oo,...e}}).run()}}});var Ms=require("@tiptap/core"),Bm=require("@tiptap/react"),Hm=require("uuid");var Im=require("jotai"),Lm=require("react");var Ta=require("react/jsx-runtime"),Ch=s(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return(0,Ta.jsx)("div",{className:"courier-w-full node-element",children:(0,Ta.jsx)("div",{className:"courier-custom-code courier-py-1.5 courier-overflow-auto",dangerouslySetInnerHTML:t?{__html:e}:{__html:" "}})})},"CustomCodeComponent"),Rm=s(e=>{let t=(0,Im.useSetAtom)(mt),r=(0,Lm.useCallback)(()=>{if(!e.editor.isEditable)return;let i=ft(e);if(i){e.editor.commands.blur();let a=i.attrs.id;e.editor.state.doc.descendants(c=>c.type.name==="customCode"&&c.attrs.id===a?(t(c),!1):!0)}},[e,t]),o=e.node.attrs.code,n=!o||o.trim()===""||o==="<!-- Add your HTML code here -->";return(0,Ta.jsx)(lr,{id:e.node.attrs.id,className:N(e.node.attrs.isSelected&&"selected-element",n&&"is-empty"),onClick:r,editor:e.editor,"data-node-type":"customCode",children:(0,Ta.jsx)(Ch,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var Hn={code:"<!-- Add your HTML code here -->"},Ns=Ms.Node.create({name:"customCode",group:"block",atom:!0,selectable:!1,onCreate(){Ft(this.editor,this.name)},addAttributes(){return{code:{default:Hn.code,parseHTML:e=>e.getAttribute("data-code")||"",renderHTML:e=>({"data-code":e.code})},id:{default:()=>`node-${(0,Hm.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})}}},parseHTML(){return[{tag:'div[data-type="custom-code"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Ms.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"custom-code"}),["div",{innerHTML:e.code||Hn.code}]]},addNodeView(){return(0,Bm.ReactNodeViewRenderer)(Rm)},addCommands(){return{setCustomCode:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e}).run()}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"}}}});var Nr=require("react");var Dm=require("react"),Fm=require("react/jsx-runtime"),bu=(0,Dm.forwardRef)(({className:e,...t},r)=>{let o=N("courier-animate-spin courier-rounded-full courier-border-2 courier-border-current courier-border-t-transparent courier-h-4 courier-w-4",e);return(0,Fm.jsx)("div",{className:o,ref:r,...t})});bu.displayName="Spinner";var Dn=require("react/jsx-runtime"),Th=(0,Nr.lazy)(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function wh(e,t){let r=(0,Nr.useRef)();return(0,Nr.useCallback)((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}s(wh,"useDebounce");var Eh=s((e,t,r)=>{if(!t||!r)return!0;let o=t.getModel();if(!o)return!0;if(r.editor.getModelMarkers({resource:o.uri}).filter(a=>a.severity===8).length>0)return!1;if(!e.trim())return!0;try{if(/<[a-z][a-z0-9]*\s[^>]*$/i.test(e.trim()))return!1;let c=(e.match(/</g)||[]).length,l=(e.match(/>/g)||[]).length;if(c!==l||new DOMParser().parseFromString(e,"text/html").getElementsByTagName("parsererror").length>0)return!1;let m=(e.match(/<([a-z][a-z0-9]*)\b[^>]*(?<!\/\/)>/gi)||[]).map(y=>{var P,w;return(w=(P=y.match(/<([a-z][a-z0-9]*)/i))==null?void 0:P[1])==null?void 0:w.toLowerCase()}).filter(Boolean),g=(e.match(/<\/([a-z][a-z0-9]*)\s*>/gi)||[]).map(y=>{var P,w;return(w=(P=y.match(/<\/([a-z][a-z0-9]*)/i))==null?void 0:P[1])==null?void 0:w.toLowerCase()}).filter(Boolean),b=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],h=m.filter(y=>y&&!b.includes(y));for(let y of h){let P=m.filter(v=>v===y).length,w=g.filter(v=>v===y).length;if(P!==w)return!1}return!0}catch{return!1}},"defaultHTMLValidator"),Ss=s(({code:e,onSave:t,onValidationChange:r,validator:o=Eh})=>{let n=(0,Nr.useRef)(null),i=(0,Nr.useRef)(null),[a,c]=(0,Nr.useState)(!0),l=(0,Nr.useCallback)(()=>{if(!n.current||!i.current)return!0;let m=n.current.getModel();if(!m)return!0;let g=m.getValue(),b=o(g,n.current,i.current);return b!==a&&(c(b),r==null||r(b)),b},[a,r,o]),u=wh(m=>{setTimeout(()=>{l()&&t(m)},150)},500);return(0,Dn.jsx)("div",{className:"courier-border courier-border-gray-300 courier-rounded courier-overflow-hidden",children:(0,Dn.jsx)("div",{className:"courier-h-[300px] courier-p-2",children:(0,Dn.jsx)(Nr.Suspense,{fallback:(0,Dn.jsx)("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:(0,Dn.jsx)(bu,{})}),children:(0,Dn.jsx)(Th,{height:"100%",defaultLanguage:"html",value:e,onChange:s(m=>{u(m||"")},"handleCodeChange"),onMount:s((m,g)=>{n.current=m,i.current=g,m.focus(),m.onDidChangeModelContent(()=>{setTimeout(l,100)}),setTimeout(l,100)},"handleEditorDidMount"),theme:"vs-light",options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,wordWrap:"on",automaticLayout:!0,tabSize:2,insertSpaces:!0,formatOnPaste:!0,formatOnType:!0,glyphMargin:!1,folding:!1,lineDecorationsWidth:10,lineNumbersMinChars:0,fixedOverflowWidgets:!0}})})})})},"MonacoCodeEditor");var Om=require("@hookform/resolvers/zod"),Wm=require("react-hook-form");var yu=require("zod"),Vm=yu.z.object({code:yu.z.string()});var Um=require("react"),zm=require("jotai");var et=require("react/jsx-runtime"),vu=s(({element:e,editor:t})=>{let r=(0,Wm.useForm)({resolver:(0,Om.zodResolver)(Vm),defaultValues:{...Hn,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=cr({editor:t,element:e,form:r,nodeType:"customCode"}),[n,i]=(0,zm.useAtom)(ho),a=(0,Um.useCallback)(c=>{r.setValue("code",c),o({code:c})},[r,o]);return e?(0,et.jsxs)(Ye,{...r,children:[!n&&(0,et.jsx)(ur,{type:"customCode"}),(0,et.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[(0,et.jsx)(Ne,{className:"courier-w-fit",variant:"outline",buttonSize:"small",onClick:()=>i(!n),children:n?(0,et.jsxs)(et.Fragment,{children:[(0,et.jsx)(Qc,{className:"courier-w-3 courier-h-3"}),"Minimize"]}):(0,et.jsxs)(et.Fragment,{children:[(0,et.jsx)(ea,{className:"courier-w-3 courier-h-3"}),"Expand Editor"]})}),(0,et.jsx)("div",{className:"courier-h-[300px] courier-mb-4",children:(0,et.jsx)("form",{onChange:()=>{o(r.getValues())},className:"courier-h-full",children:(0,et.jsx)(q,{control:r.control,name:"code",render:({field:c})=>(0,et.jsxs)(_,{className:"courier-h-full",children:[(0,et.jsx)(Z,{children:(0,et.jsx)(Ss,{code:c.value,onSave:l=>{c.onChange(l),a(l)},onCancel:()=>{}})}),(0,et.jsx)(G,{})]})})})})]})]}):null},"CustomCodeForm");var jm=require("@tiptap/core");var nn=require("@tiptap/core"),Mi=require("@tiptap/pm/state"),$m=nn.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",(0,nn.mergeAttributes)(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{let{selection:r}=t,{$from:o,$to:n}=r,i=e();return o.parentOffset===0?i.insertContentAt({from:Math.max(o.pos-1,0),to:n.pos},{type:this.name}):(0,nn.isNodeSelection)(r)?i.insertContentAt(n.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:a,dispatch:c})=>{var l;if(c){let{$to:u}=a.selection,d=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?a.setSelection(Mi.TextSelection.create(a.doc,u.pos+1)):u.nodeAfter.isBlock?a.setSelection(Mi.NodeSelection.create(a.doc,u.pos)):a.setSelection(Mi.TextSelection.create(a.doc,u.pos));else{let p=(l=u.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();p&&(a.insert(d,p),a.setSelection(Mi.TextSelection.create(a.doc,d+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(0,nn.nodeInputRule)({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Gm=require("@tiptap/react"),Jm=require("uuid");var _m=require("jotai"),Zm=require("react");var wa=require("react/jsx-runtime"),kh=s(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>(0,wa.jsx)("div",{className:"courier-w-full node-element",children:(0,wa.jsx)("hr",{style:{marginTop:`${e}px`,marginBottom:`${e}px`,backgroundColor:n==="spacer"?"transparent":t,height:`${r}px`,borderRadius:`${o}px`,border:"none"},"data-variant":n})}),"DividerComponent"),qm=s(e=>{let t=(0,_m.useSetAtom)(mt),r=(0,Zm.useCallback)(()=>{if(!e.editor.isEditable)return;let o=ft(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return(0,wa.jsx)(lr,{id:e.node.attrs.id,className:N(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:(0,wa.jsx)(kh,{...e.node.attrs})})},"DividerComponentNode");var no={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},Km={padding:6,color:"transparent",size:1,radius:0,variant:"spacer"},xu=$m.extend({name:"divider",atom:!0,onCreate(){Ft(this.editor,this.name)},addAttributes(){return{padding:{default:no.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.margin})},size:{default:no.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},color:{default:no.color,parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color})},width:{default:no.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},radius:{default:no.radius,parseHTML:e=>e.getAttribute("data-radius"),renderHTML:e=>({"data-radius":e.radius})},variant:{default:no.variant,parseHTML:e=>e.getAttribute("data-variant"),renderHTML:e=>({"data-variant":e.variant})},id:{default:()=>`node-${(0,Jm.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})}}},parseHTML(){return[{tag:'div[data-type="divider"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,jm.mergeAttributes)(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return(0,Gm.ReactNodeViewRenderer)(qm)}});var Fn=require("zod"),Xm=Fn.z.object({padding:Fn.z.number(),color:Fn.z.string(),size:Fn.z.number(),radius:Fn.z.number(),variant:Fn.z.enum(["divider","spacer"]).default("divider")});var Ym=require("@hookform/resolvers/zod"),Qm=require("react-hook-form");var we=require("react/jsx-runtime"),ef=s(({element:e,editor:t})=>{let r=(0,Qm.useForm)({resolver:(0,Ym.zodResolver)(Xm),defaultValues:{...no,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=cr({editor:t,element:e,form:r,nodeType:"divider"});if(!e)return null;let n=r.watch("variant");return(0,we.jsxs)(Ye,{...r,children:[(0,we.jsx)(ur,{type:n}),(0,we.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,we.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,we.jsx)(q,{control:r.control,name:"padding",render:({field:i})=>(0,we.jsxs)(_,{children:[(0,we.jsx)(Z,{children:(0,we.jsx)(ce,{startAdornment:(0,we.jsx)(Pn,{}),type:"number",...i,onChange:a=>{i.onChange(a),o({...r.getValues(),margin:a.target.value})}})}),(0,we.jsx)(G,{})]})}),n==="divider"&&(0,we.jsxs)(we.Fragment,{children:[(0,we.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,we.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Line"}),(0,we.jsx)(q,{control:r.control,name:"size",render:({field:i})=>(0,we.jsxs)(_,{className:"courier-mb-4",children:[(0,we.jsx)(Z,{children:(0,we.jsx)(ce,{startAdornment:(0,we.jsx)(to,{}),type:"number",min:0,...i,onChange:a=>{i.onChange(a),o({...r.getValues(),width:a.target.value})}})}),(0,we.jsx)(G,{})]})}),(0,we.jsx)(q,{control:r.control,name:"color",render:({field:i})=>(0,we.jsxs)(_,{className:"courier-mb-4",children:[(0,we.jsx)(Z,{children:(0,we.jsx)(pt,{...i,defaultValue:no.color,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),(0,we.jsx)(G,{})]})})]})]})]})},"DividerForm");var tf=require("@tiptap/core"),rf=tf.Node.create({name:"doc",topNode:!0,content:"block+"});var Cu=rf.extend({content:"(block)+"});var sf=require("@tiptap/core"),lf=require("@tiptap/react");var of=require("@dnd-kit/sortable"),nf=require("@tiptap/react"),Vn=require("react");var Ea=require("react/jsx-runtime");function Ph(){let[e,t]=(0,Vn.useState)(!1);return(0,Vn.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(Ph,"useMountStatus");var Mh=(0,Vn.forwardRef)(({children:e,className:t,dragOverlay:r,id:o},n)=>((0,Vn.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),(0,Ea.jsx)(nf.NodeViewWrapper,{ref:n,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":o,className:N("courier-flex courier-items-start courier-gap-2 courier-pl-6",t),children:e}))),af=s(({node:e})=>{let t=e.attrs.type,r=e.attrs.id,{setNodeRef:o,setActivatorNodeRef:n,listeners:i,isDragging:a,transform:c,transition:l}=(0,of.useSortable)({id:r}),u=Ph();return(0,Ea.jsx)(Mh,{ref:o,id:r,transition:l,transform:c,fadeIn:a&&!u,listeners:i,handleProps:{ref:n},children:(0,Ea.jsx)("div",{className:N("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md"),children:(0,Ea.jsx)("div",{className:"courier-text-accent-foreground",children:t==="text"?"Text":t==="heading"?"Heading":t==="spacer"?"Spacer":t==="divider"?"Divider":t==="button"?"Button":t==="image"?"Image":t})})})},"DragPlaceholderComponent");var cf=sf.Node.create({name:"dragPlaceholder",group:"block",atom:!0,draggable:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},type:{default:"text",parseHTML:e=>e.getAttribute("data-type"),renderHTML:e=>({"data-type":e.type})}}},parseHTML(){return[{tag:'div[data-type="drag-placeholder"]'}]},renderHTML({HTMLAttributes:e}){return["div",{"data-type":"drag-placeholder",...e},0]},addCommands(){return{setDragPlaceholder:e=>({tr:t,dispatch:r})=>{if(r){let o=this.type.create(e);typeof e.pos=="number"?t.insert(e.pos,o):t.replaceSelectionWith(o)}return!0},removeDragPlaceholder:()=>({tr:e,state:t,dispatch:r})=>{let o=!1;return t.doc.descendants((n,i)=>n.type.name===this.name?(r&&(n!=null&&n.nodeSize)&&(e.delete(i,i+n.nodeSize),o=!0),!1):!0),o}}},addNodeView(){return(0,lf.ReactNodeViewRenderer)(af,{as:"div",className:"drag-placeholder-wrapper"})}});var uf=require("@tiptap/core"),As=require("@tiptap/pm/state"),Nh=new As.PluginKey("file-handler"),Sh=uf.Extension.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new As.Plugin({key:Nh,props:{handleDrop:(o,n,i,a)=>{var d;if(!((d=n.dataTransfer)!=null&&d.files)||a)return!1;let{files:c}=n.dataTransfer,l=o.posAtCoords({left:n.clientX,top:n.clientY});if(!l)return!1;let u=Array.from(c).filter(p=>e==null?void 0:e.includes(p.type));return u.length===0?!1:(n.preventDefault(),t&&t(this.editor,u,l.pos),!0)},handlePaste:(o,n)=>{var c;if(!((c=n.clipboardData)!=null&&c.files))return!1;let{files:i}=n.clipboardData,a=Array.from(i).filter(l=>e==null?void 0:e.includes(l.type));return a.length===0?!1:(n.preventDefault(),r&&r(this.editor,a),!0)}}})]}}),Is=Sh;var df=require("@tiptap/core"),Ls=require("@tiptap/pm/state");var Ah=new Ls.PluginKey("fixedChannelPaste"),Ih=s(e=>{let t=e.view.dom.closest(".courier-push-editor"),r=e.view.dom.closest(".courier-sms-editor"),o=e.view.dom.closest(".courier-inbox-editor");if(t||r||o)return!0;let n=e.state.doc,i=0,a=0;n.forEach(d=>{d.type.name==="paragraph"||d.type.name==="heading"?i++:d.type.name==="button"&&a++});let c=i===1&&a===0,l=i===2&&a===0,u=i>=2&&i+a<=4;return c||l||u},"isInFixedChannel"),Lh=s(e=>{let t=[],r=s(o=>{if(o.type.name==="text")t.push(o.text||"");else if(o.type.name==="paragraph"||o.type.name==="heading"){let n=o.textContent||"";n.trim()&&t.push(n)}else o.content&&o.content.forEach(n=>{r(n)})},"extractTextFromNode");return e.content.forEach(o=>{r(o)}),t.filter(o=>o.trim()).join(`
|
|
180
|
-
`).trim()},"extractTextFromSlice"),Rs=df.Extension.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new Ls.Plugin({key:Ah,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!Ih(e))return!1;let c=i.$from.node();if(!(c.type.name==="paragraph"||c.type.name==="heading")||o.content.childCount<=1)return!1;let u=Lh(o);if(!u)return!1;r.preventDefault();let d=n.tr.replaceSelectionWith(n.schema.text(u),!1);return t.dispatch(d),!0}}})]},addStorage(){return{currentChannel:null}}});var pf=require("@tiptap/core"),an=require("@tiptap/pm/state");var On=s((e,t)=>{if(t.length===0)return!1;let r={push:()=>e.view.dom.closest(".courier-push-editor"),sms:()=>e.view.dom.closest(".courier-sms-editor"),inbox:()=>e.view.dom.closest(".courier-inbox-editor")};return t.some(o=>{var n;return(n=r[o])==null?void 0:n.call(r)})},"isInFixedChannel"),ka=s(e=>{let{selection:t}=e.state,{$anchor:r}=t,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),a=r.end(o);return{start:i,end:a,node:n}}o--}return null},"getCurrentElementBounds"),Bs=s(e=>{let{selection:t}=e.state,{$from:r,$to:o}=t;if(t.empty)return!1;let n=r.depth,i=o.depth,a=null,c=null;for(;n>0;){let l=r.node(n);if(l.type.name==="paragraph"||l.type.name==="heading"){a={node:l,depth:n};break}n--}for(;i>0;){let l=o.node(i);if(l.type.name==="paragraph"||l.type.name==="heading"){c={node:l,depth:i};break}i--}return!!(a&&c&&a.node!==c.node)},"isMultiElementSelection"),Hs=new an.PluginKey("fixedChannelSelection"),Ds=pf.Extension.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!On(e,this.options.channels))return!1;let o=ka(e);if(!o)return!1;let{start:n,end:i}=o,{selection:a}=e.state;if(a.from>=n&&a.to<=i)return!1;let c=Math.max(a.from,n),l=Math.min(a.to,i);return r&&t.setSelection(an.TextSelection.create(t.doc,c,l)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!On(e,this.options.channels))return!1;let t=ka(e);if(!t)return!1;let{start:r,end:o}=t;return e.commands.setTextSelection({from:r,to:o}),!0},Backspace:({editor:e})=>{if(!On(e,this.options.channels))return!1;if(Bs(e)){let t=ka(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),a=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:a})}return!0}return!1},Delete:({editor:e})=>{if(!On(e,this.options.channels))return!1;if(Bs(e)){let t=ka(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),a=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:a})}return!0}return!1}}},addProseMirrorPlugins(){return[new an.Plugin({key:Hs,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!On(o,this.options.channels))return!1;if(Bs(o)){let n=ka(o);if(n){let{start:i,end:a}=n,c=Math.max(t,i),l=Math.min(r,a),u=e.state.tr;u.setSelection(an.TextSelection.create(u.doc,c,l)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!On(r,this.options.channels))return!1;let o=e.posAtCoords({left:t.clientX,top:t.clientY});if(o!==null){let n=e.state.doc.resolve(o.pos),i=n.depth;for(;i>0;){let a=n.node(i);if(a.type.name==="paragraph"||a.type.name==="heading"){e.dispatch(e.state.tr.setMeta(Hs,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!On(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&Bs(r)){let n=Hs.getState(e.state);if(n!=null&&n.elementStart&&(n!=null&&n.elementEnd)){let{selection:i}=e.state,a=Math.max(i.from,n.elementStart),c=Math.min(i.to,n.elementEnd),l=e.state.tr;return l.setSelection(an.TextSelection.create(l.doc,a,c)),e.dispatch(l),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(Hs)||t}}})]}});var Cf=require("@tiptap/core");var Ni=require("@tiptap/core"),mf=Ni.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,(0,Ni.mergeAttributes)(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>(0,Ni.textblockTypeInputRule)({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var Dr=require("zod"),ff=Dr.z.object({paddingVertical:Dr.z.number(),paddingHorizontal:Dr.z.number(),backgroundColor:Dr.z.string(),borderWidth:Dr.z.number(),borderRadius:Dr.z.number(),borderColor:Dr.z.string(),textColor:Dr.z.string(),textAlign:Dr.z.enum(["left","center","right","justify"]).default("left"),selected:Dr.z.boolean().default(!1),id:Dr.z.string().optional()}),ne={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"#000000",textColor:"#292929",textAlign:"left",selected:!1};var Fs=require("@tiptap/react"),hf=require("jotai"),bf=require("react");var sn=require("react/jsx-runtime"),gf=s(({paddingVertical:e,paddingHorizontal:t,textAlign:r,backgroundColor:o,borderWidth:n,borderRadius:i,borderColor:a,textColor:c,level:l,type:u})=>{let d=u==="heading"?`h${l}`:"p";return(0,sn.jsx)("div",{className:"courier-w-full node-element",children:(0,sn.jsx)("div",{className:N(!c&&"is-empty"),style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderRadius:`${i}px`,borderColor:a,borderStyle:n>0?"solid":"none",color:c},children:(0,sn.jsx)(Fs.NodeViewContent,{as:d})})})},"TextBlockComponent"),Vs=s(e=>{let t=(0,hf.useSetAtom)(mt),r=(0,bf.useCallback)(()=>{if(!e.editor.isEditable)return;let c=ft(e);c&&t(c)},[e,t]),o=!e.node.content||e.node.content.size===0,n=ln(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null;return(i==null?void 0:i.parent.type.name)==="blockquote"?(0,sn.jsx)(Fs.NodeViewWrapper,{className:N(e.node.attrs.isSelected&&"selected-element"),onClick:r,children:(0,sn.jsx)(gf,{...e.node.attrs,type:e.node.type.name})}):(0,sn.jsx)(lr,{id:e.node.attrs.id,className:N(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:(0,sn.jsx)(gf,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");var yf=require("@hookform/resolvers/zod"),vf=require("react-hook-form");var Y=require("react/jsx-runtime"),xf=s(({element:e,editor:t})=>{let r=(0,vf.useForm)({resolver:(0,yf.zodResolver)(ff),defaultValues:{...ne,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=cr({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?(0,Y.jsxs)(Ye,{...r,children:[(0,Y.jsx)(ur,{type:"text"}),(0,Y.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Y.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,Y.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,Y.jsx)(q,{control:r.control,name:"paddingHorizontal",render:({field:n})=>(0,Y.jsxs)(_,{children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(ce,{startAdornment:(0,Y.jsx)(aa,{}),type:"number",min:0,...n})}),(0,Y.jsx)(G,{})]})}),(0,Y.jsx)(q,{control:r.control,name:"paddingVertical",render:({field:n})=>(0,Y.jsxs)(_,{children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(ce,{startAdornment:(0,Y.jsx)(Pn,{}),type:"number",min:0,...n})}),(0,Y.jsx)(G,{})]})})]}),(0,Y.jsx)(q,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,Y.jsxs)(_,{className:"courier-mb-4",children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(pt,{...n,defaultValue:ne.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,Y.jsx)(G,{})]})}),(0,Y.jsx)(le,{className:"courier-mb-4"}),(0,Y.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Text"}),(0,Y.jsx)(q,{control:r.control,name:"textColor",render:({field:n})=>(0,Y.jsxs)(_,{className:"courier-mb-4",children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(pt,{...n,transparent:!1,defaultValue:ne.textColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,Y.jsx)(G,{})]})}),(0,Y.jsx)(le,{className:"courier-mb-4"}),(0,Y.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,Y.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,Y.jsx)(q,{control:r.control,name:"borderWidth",render:({field:n})=>(0,Y.jsxs)(_,{children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(ce,{startAdornment:(0,Y.jsx)(to,{}),type:"number",min:0,...n})}),(0,Y.jsx)(G,{})]})}),(0,Y.jsx)(q,{control:r.control,name:"borderRadius",render:({field:n})=>(0,Y.jsxs)(_,{children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(ce,{startAdornment:(0,Y.jsx)(kn,{}),type:"number",min:0,...n})}),(0,Y.jsx)(G,{})]})})]}),(0,Y.jsx)(q,{control:r.control,name:"borderColor",render:({field:n})=>(0,Y.jsxs)(_,{className:"courier-mb-4",children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(pt,{...n,defaultValue:ne.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,Y.jsx)(G,{})]})})]})]}):null},"TextBlockForm");var Tf=require("@tiptap/react");var Tu=mf.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){Ft(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:ne.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):ne.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:ne.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):ne.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:ne.textAlign,parseHTML:t=>t.style.textAlign||ne.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:ne.backgroundColor,parseHTML:t=>t.style.backgroundColor||ne.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:ne.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):ne.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderRadius:{default:ne.borderRadius,parseHTML:t=>t.style.borderRadius?parseInt(t.style.borderRadius):ne.borderRadius,renderHTML:t=>({style:`border-radius: ${t.borderRadius}px`})},borderColor:{default:ne.borderColor,parseHTML:t=>t.style.borderColor||ne.borderColor,renderHTML:t=>({style:`border-color: ${t.borderColor}`})},textColor:{default:ne.textColor,parseHTML:t=>t.style.color||ne.textColor,renderHTML:t=>({style:`color: ${t.textColor}`})},id:{default:()=>null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>({"data-id":t.id})}}},addCommands(){return{setTextAlign:e=>({chain:t})=>t().updateAttributes(this.name,{textAlign:e}).run()}},parseHTML(){return[{tag:'div[data-type="heading"]'}]},renderHTML({node:e,HTMLAttributes:t}){let r=parseInt(e.attrs.level,10);return[`h${this.options.levels.includes(r)?r:this.options.levels[0]}`,(0,Cf.mergeAttributes)(this.options.HTMLAttributes,t),0]},addNodeView(){return(0,Tf.ReactNodeViewRenderer)(Vs)}});var Os=require("@tiptap/core"),Ef=require("@tiptap/react");var wu=require("jotai"),Oe=require("react");var Mt=require("react/jsx-runtime"),Rh=s(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderRadius:n,borderColor:i,isUploading:a,width:c,imageNaturalWidth:l,onFileSelect:u,editor:d})=>{let[p,m]=(0,Oe.useState)(!1),[g,b]=(0,Oe.useState)(!0),h=(0,Oe.useRef)(null),y=(0,Oe.useRef)(null);(0,Oe.useEffect)(()=>{e&&b(!0)},[e]),(0,Oe.useEffect)(()=>{if(e&&!l&&d){let k=new Image;k.onload=()=>{try{if(!d.view||!d.state)return;let S=d.view.state.selection.from;d.chain().setNodeSelection(S).updateAttributes("imageBlock",{imageNaturalWidth:k.naturalWidth}).run()}catch{}},k.src=e}},[e,l,d]);let P=(0,Oe.useCallback)(k=>{var A,I;let S=(I=(A=d==null?void 0:d.view)==null?void 0:A.dom)==null?void 0:I.closest(".ProseMirror"),E=(S==null?void 0:S.clientWidth)||1e3,x=Math.min(100,k/E*100);return Math.round(x)},[d]),w=(0,Oe.useMemo)(()=>P(l),[P,l]),v=(0,Oe.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),k.dataTransfer.types.includes("Files")&&Array.from(k.dataTransfer.items).some(x=>x.type.startsWith("image/"))&&(m(!0),k.dataTransfer.dropEffect="copy")},[]),f=(0,Oe.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),m(!1)},[]),C=(0,Oe.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),k.dataTransfer.types.includes("Files")&&Array.from(k.dataTransfer.items).some(x=>x.type.startsWith("image/"))&&m(!0)},[]),T=(0,Oe.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),m(!1);let E=Array.from(k.dataTransfer.files).find(x=>x.type.startsWith("image/"));E&&u&&u(E)},[u]),R=(0,Oe.useCallback)(k=>{var E;let S=(E=k.target.files)==null?void 0:E[0];S&&u&&u(S)},[u]),M=(0,Oe.useCallback)(()=>{var k;(k=h.current)==null||k.click()},[]);return e?(0,Mt.jsx)("div",{className:"courier-w-full node-element",children:(0,Mt.jsxs)("div",{className:N("courier-relative courier-p-1",(a||g)&&"courier-min-h-[200px] courier-min-w-[300px] courier-bg-gray-100"),children:[(a||g)&&(0,Mt.jsx)("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:(0,Mt.jsx)(Nn,{className:"courier-w-8 courier-h-8"})}),(0,Mt.jsx)("img",{ref:y,src:e,alt:t,className:N("courier-h-auto courier-inline-block courier-w-full",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[r],a&&"courier-opacity-50",(a||g)&&"courier-invisible"),style:{maxWidth:c===w?`${l}px`:`${c}%`,borderWidth:`${o}px`,borderRadius:`${n}px`,borderColor:i,borderStyle:o>0?"solid":"none",display:"block"},loading:"lazy",decoding:"async",draggable:!1,onLoad:k=>{if(b(!1),!l&&d)try{if(!d.view||!d.state)return;setTimeout(()=>{let S=d.view.state.selection.from;d.chain().setNodeSelection(S).updateAttributes("imageBlock",{imageNaturalWidth:k.target.naturalWidth}).run()},100)}catch(S){console.warn("Editor not ready for image update:",S)}},onError:()=>b(!1)})]})}):(0,Mt.jsxs)("div",{className:N("courier-w-full node-element courier-empty-image courier-h-[160px] courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-justify-center courier-cursor-pointer courier-transition-colors courier-flex-1",p&&"courier-border-primary courier-bg-gray-50"),onDragOver:v,onDragEnter:C,onDragLeave:f,onDrop:T,style:{pointerEvents:"all"},children:[a?(0,Mt.jsx)(Nn,{className:"courier-w-8 courier-h-8"}):(0,Mt.jsxs)(Mt.Fragment,{children:[(0,Mt.jsx)("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),(0,Mt.jsx)("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:M,children:"Browse"})]}),(0,Mt.jsx)("input",{ref:h,type:"file",accept:"image/*",className:"courier-hidden",onChange:R})]})},"ImageBlockComponent"),wf=s(e=>{let t=(0,wu.useSetAtom)(mt),r=(0,wu.useSetAtom)(re),{uploadImage:o}=ai(),n=(0,Oe.useCallback)(c=>{var p,m,g;let l=(g=(m=(p=e.editor)==null?void 0:p.view)==null?void 0:m.dom)==null?void 0:g.closest(".ProseMirror"),u=(l==null?void 0:l.clientWidth)||1e3,d=Math.min(100,c/u*100);return Math.round(d)},[e.editor]);(0,Oe.useEffect)(()=>{var l,u;let c=ft(e);if((l=c==null?void 0:c.attrs)!=null&&l.sourcePath&&!((u=c==null?void 0:c.attrs)!=null&&u.imageNaturalWidth)){let d=new Image;d.onload=()=>{let p=c.attrs.width||n(d.naturalWidth),m=ln(e.getPos);m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{width:p,imageNaturalWidth:d.naturalWidth}).run()},d.src=c.attrs.sourcePath}},[e,n]);let i=(0,Oe.useCallback)(()=>{if(!e.editor.isEditable)return;let c=ft(e);c&&(e.editor.commands.blur(),t(c))},[e,t]),a=(0,Oe.useCallback)(async c=>{let l=ln(e.getPos);ft(e)&&l!==null&&e.editor.chain().focus().setNodeSelection(l).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!c.type.startsWith("image/"))throw new Error("Only image files are supported");let d=new FileReader;d.readAsDataURL(c),await new Promise((h,y)=>{d.onload=h,d.onerror=y});let m=(await o({file:c})).url,g=ln(e.getPos);if(ft(e)&&g!==null){let h=new Image;h.src=m,await new Promise(P=>{h.onload=P});let y=n(h.naturalWidth);e.editor.chain().focus().setNodeSelection(g).updateAttributes("imageBlock",{sourcePath:m,isUploading:!1,width:y,imageNaturalWidth:h.naturalWidth}).run()}}catch(d){console.error("Error uploading image:",d);let p="Failed to upload image: "+d;if(d instanceof Error){let b=d.message;b.includes("GraphQL error")?p="Server error: Could not process image":(b.includes("network")||b.includes("fetch"))&&(p="Network error: Could not upload image")}r({message:`Upload failed: ${p}`,toastProps:{duration:6e3,description:`File: ${c.name} (${(c.size/1024/1024).toFixed(2)}MB)`}});let m=ln(e.getPos);ft(e)&&m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return(0,Mt.jsx)(lr,{id:e.node.attrs.id,className:N(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:(0,Mt.jsx)(Rh,{...e.node.attrs,onFileSelect:a,editor:e.editor})})},"ImageBlockView");var gt={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderRadius:0,borderColor:"#000000",isUploading:!1,imageNaturalWidth:0},Ws=Os.Node.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){Ft(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:gt.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:gt.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:gt.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:gt.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:gt.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:gt.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:gt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:gt.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:gt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:gt.isUploading,parseHTML:e=>e.getAttribute("data-is-uploading"),renderHTML:e=>({"data-is-uploading":e.isUploading})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})}}},parseHTML(){return[{tag:'div[data-type="image-block"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Os.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return(0,Ef.ReactNodeViewRenderer)(wf)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...gt,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...gt,sourcePath:t||""}}).run(),setImageBlockAlign:e=>({commands:t})=>t.updateAttributes(this.name,{alignment:e}),setImageBlockWidth:e=>({commands:t})=>t.updateAttributes(this.name,{width:e}),uploadImage:e=>({chain:t})=>{let r=new FileReader;return r.onload=()=>{t().setImageBlock({sourcePath:r.result,isUploading:!0}).run()},r.readAsDataURL(e),!0}}}});var Fr=require("zod"),kf=Fr.z.object({sourcePath:Fr.z.string(),link:Fr.z.string().optional(),alt:Fr.z.string().optional(),alignment:Fr.z.enum(["left","center","right"]),width:Fr.z.number().min(1).max(100),borderWidth:Fr.z.number(),borderRadius:Fr.z.number(),borderColor:Fr.z.string(),isUploading:Fr.z.boolean().optional(),imageNaturalWidth:Fr.z.number()});var Pf=require("@hookform/resolvers/zod"),Mf=require("jotai"),Nf=require("lucide-react"),qt=require("react"),Sf=require("react-hook-form");var O=require("react/jsx-runtime"),Af=s(({element:e,editor:t})=>{var R,M,k,S;let r=(0,qt.useRef)(null),o=(0,qt.useRef)(null),[n,i]=(0,qt.useState)(""),[a,c]=(0,qt.useState)(!1),[l,u]=(0,qt.useState)(((R=e==null?void 0:e.attrs)==null?void 0:R.imageNaturalWidth)||0),[d,p]=(0,qt.useState)(!1),m=(0,Mf.useSetAtom)(re),{uploadImage:g}=ai(),b=(0,Sf.useForm)({resolver:(0,Pf.zodResolver)(kf),defaultValues:{...gt,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:h}=cr({editor:t,element:e,form:b,nodeType:"imageBlock"});(0,qt.useEffect)(()=>{var x;let E=(x=e==null?void 0:e.attrs)==null?void 0:x.sourcePath;if(E&&!l){let A=new Image;A.onload=()=>{u(A.naturalWidth);let I={...b.getValues(),imageNaturalWidth:A.naturalWidth};b.setValue("imageNaturalWidth",A.naturalWidth),h(I)},A.src=E}},[(M=e==null?void 0:e.attrs)==null?void 0:M.sourcePath,l,b,h]);let y=(0,qt.useCallback)(E=>{var D,B;let x=(B=(D=t==null?void 0:t.view)==null?void 0:D.dom)==null?void 0:B.closest(".ProseMirror"),A=(x==null?void 0:x.clientWidth)||1e3;if(E||(E=l),!E)return 0;let I=Math.min(100,E/A*100);return Math.round(I)},[t,l]),P=(0,qt.useCallback)(E=>{var x;E.preventDefault(),(x=r.current)==null||x.click()},[]),w=(0,qt.useCallback)((E,x)=>{let A=y(E.naturalWidth);i(`${A}%`),c(!1),b.setValue("sourcePath",x),b.setValue("imageNaturalWidth",E.naturalWidth),b.setValue("width",A);let I={...b.getValues(),sourcePath:x,width:A,imageNaturalWidth:E.naturalWidth,isUploading:!1};h(I)},[b,h,y]),v=(0,qt.useCallback)(E=>{if(!E)return;let x=new Image;x.onload=()=>{let A=y(x.naturalWidth);b.setValue("sourcePath",E),b.setValue("imageNaturalWidth",x.naturalWidth),b.setValue("width",A);let I={...b.getValues(),sourcePath:E,width:A,imageNaturalWidth:x.naturalWidth};h(I)},x.src=E},[b,h,y]),f=((S=(k=t==null?void 0:t.extensionManager.extensions.find(E=>E.name==="variableSuggestion"))==null?void 0:k.options)==null?void 0:S.variables)||{},C=Mr(f),T=b.getValues().sourcePath;return e?(0,O.jsxs)(Ye,{...b,children:[(0,O.jsx)(ur,{type:"image"}),(0,O.jsxs)("form",{ref:o,onChange:()=>{let E=b.getValues();h(E)},children:[(0,O.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),(0,O.jsxs)(ts,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[(0,O.jsxs)(Yi,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[(0,O.jsx)(mi,{value:"file",className:"courier-flex-1",children:"From file"}),(0,O.jsx)(mi,{value:"url",className:"courier-flex-1",children:"From URL"})]}),(0,O.jsx)(rs,{value:"file",children:(0,O.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,O.jsx)(Ne,{onClick:P,className:"courier-w-full",variant:"outline",type:"button",disabled:d,children:d?(0,O.jsx)(O.Fragment,{children:"Uploading..."}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Nf.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),(0,O.jsx)("input",{ref:r,type:"file",accept:"image/*",className:"courier-hidden",onChange:E=>{var A;let x=(A=E.target.files)==null?void 0:A[0];if(x){p(!0),b.setValue("sourcePath",""),h({...b.getValues(),sourcePath:"",isUploading:!0});let I=new FileReader;I.onload=async()=>{try{let D=(await g({file:x})).url,B=new Image;B.onload=()=>{w(B,D),p(!1)},B.onerror=()=>{m({message:"Upload failed: Failed to load uploaded image",toastProps:{duration:6e3,description:`File: ${x.name} (${(x.size/1024/1024).toFixed(2)}MB)`}}),p(!1),h({...b.getValues(),isUploading:!1})},B.src=D}catch(H){console.error("Error uploading image:",H),m({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${x.name} (${(x.size/1024/1024).toFixed(2)}MB)`}}),p(!1),h({...b.getValues(),isUploading:!1})}},I.onerror=()=>{m({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${x.name} (${(x.size/1024/1024).toFixed(2)}MB)`}}),p(!1),h({...b.getValues(),isUploading:!1})},I.readAsDataURL(x)}}})]})}),(0,O.jsx)(rs,{value:"url",children:(0,O.jsx)(q,{control:b.control,name:"sourcePath",render:({field:E})=>(0,O.jsxs)(_,{className:"courier-mb-3",children:[(0,O.jsx)(Z,{children:(0,O.jsx)(Ot,{as:"Textarea",...E,autoResize:!0,className:"courier-max-h-[88px]",variables:C,onChange:x=>v(x.target.value)})}),(0,O.jsx)(G,{})]})})})]}),(0,O.jsx)(q,{control:b.control,name:"link",render:({field:E})=>(0,O.jsxs)(_,{className:"courier-mb-3",children:[(0,O.jsx)(Z,{children:(0,O.jsx)(Ot,{as:"Textarea",placeholder:"Link",...E,variables:C,onChange:x=>{E.onChange(x),h({...b.getValues(),link:x.target.value})}})}),(0,O.jsx)(G,{})]})}),(0,O.jsx)(q,{control:b.control,name:"alt",render:({field:E})=>(0,O.jsxs)(_,{className:"courier-mb-4",children:[(0,O.jsx)(Z,{children:(0,O.jsx)(Ot,{as:"Textarea",...E,placeholder:"Alt text...",variables:C,onChange:x=>{E.onChange(x),h({...b.getValues(),alt:x.target.value})}})}),(0,O.jsx)(G,{})]})}),(0,O.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,O.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Width"}),(()=>{let E=b.getValues().width,x=b.getValues().imageNaturalWidth,A=y(x),I=E===A,H=I?"original":"fill";return(0,O.jsxs)(rr,{type:"single",value:T?H:"original",onValueChange:D=>{if(!D||D===H)return;let B=D==="fill"?100:y(x);B>0&&(b.setValue("width",B),h({...b.getValues(),width:B}))},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",disabled:!T,children:[(0,O.jsx)(Qe,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),(0,O.jsx)(Qe,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:I||!T,children:"Fill"})]})})(),(0,O.jsx)(q,{control:b.control,name:"width",render:({field:E})=>(0,O.jsxs)(_,{className:"courier-flex-1 courier-mb-3",children:[(0,O.jsx)(Z,{children:(0,O.jsx)(ce,{type:"text",inputMode:"numeric",pattern:"[0-9]*",min:1,max:100,...E,value:b.getValues().sourcePath?a?n:`${E.value}%`:"0%",className:"courier-text-2xl courier-font-normal",disabled:!b.getValues().sourcePath,onFocus:x=>{c(!0),i(x.target.value)},onChange:x=>{i(x.target.value)},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),x.currentTarget.blur())},onBlur:x=>{c(!1);let A=parseFloat(x.target.value.replace("%",""));if(!isNaN(A)){let I=Math.min(100,Math.max(1,A));E.onChange(I),h({...b.getValues(),width:Math.round(I)})}}})}),(0,O.jsx)(G,{})]})}),(0,O.jsx)(q,{control:b.control,name:"width",render:({field:E})=>(0,O.jsxs)(_,{className:"courier-flex-1 courier-mb-3",children:[(0,O.jsx)(Z,{children:(0,O.jsx)(vc,{min:1,max:100,value:[T?E.value:0],disabled:!T,onValueChange:x=>{E.onChange(x[0]),h({...b.getValues(),width:x[0]})}})}),(0,O.jsx)(G,{})]})}),(0,O.jsx)(q,{control:b.control,name:"alignment",render:({field:E})=>(0,O.jsxs)(_,{children:[(0,O.jsx)(Z,{children:(0,O.jsxs)(rr,{disabled:!T,type:"single",value:E.value,onValueChange:x=>{E.onChange(x),h({...b.getValues(),alignment:x})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,O.jsx)(Qe,{size:"sm",value:"left",className:"courier-w-full",children:(0,O.jsx)(Ts,{className:"courier-h-4 courier-w-4"})}),(0,O.jsx)(Qe,{size:"sm",value:"center",className:"courier-w-full",children:(0,O.jsx)(ws,{className:"courier-h-4 courier-w-4"})}),(0,O.jsx)(Qe,{size:"sm",value:"right",className:"courier-w-full",children:(0,O.jsx)(Es,{className:"courier-h-4 courier-w-4"})})]})}),(0,O.jsx)(G,{})]})}),(0,O.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,O.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,O.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,O.jsx)(q,{control:b.control,name:"borderWidth",render:({field:E})=>(0,O.jsxs)(_,{children:[(0,O.jsx)(Z,{children:(0,O.jsx)(ce,{startAdornment:(0,O.jsx)(to,{}),type:"number",disabled:!T,min:0,...E,onChange:x=>{let A=parseInt(x.target.value)||0;E.onChange(A),h({...b.getValues(),borderWidth:A})}})}),(0,O.jsx)(G,{})]})}),(0,O.jsx)(q,{control:b.control,name:"borderRadius",render:({field:E})=>(0,O.jsxs)(_,{children:[(0,O.jsx)(Z,{children:(0,O.jsx)(ce,{startAdornment:(0,O.jsx)(kn,{}),type:"number",disabled:!T,min:0,...E,onChange:x=>{let A=parseInt(x.target.value)||0;E.onChange(A),h({...b.getValues(),borderRadius:A})}})}),(0,O.jsx)(G,{})]})})]}),(0,O.jsx)(q,{control:b.control,name:"borderColor",render:({field:E})=>(0,O.jsxs)(_,{className:"courier-mb-4",children:[(0,O.jsx)(Z,{children:(0,O.jsx)(pt,{...E,disabled:!T,defaultValue:gt.borderColor,onChange:x=>{E.onChange(x),h({...b.getValues(),[E.name]:x})}})}),(0,O.jsx)(G,{})]})})]})]}):null},"ImageBlockForm");var Pa=require("@tiptap/core"),If=Me(require("@tiptap/extension-link"),1),Si=require("@tiptap/pm/state"),Eu=If.default.extend({inclusive:!0,addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),hasVariables:{default:!1},originalHref:{default:null}}},parseHTML(){return[{tag:'a[href]:not([data-type="button"]):not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:e}){if(e.hasVariables&&e.originalHref)e.href=e.originalHref,delete e.hasVariables,delete e.originalHref;else if(e.href){let t=e.href;t.includes("__VAR_")&&(e.href=t.replace(/__VAR_([^_]+)__/g,"{{$1}}"))}return["a",(0,Pa.mergeAttributes)(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new Si.Plugin({props:{handleClick:(r,o,n)=>{if(n.button!==0)return!1;let{state:i}=r,{doc:a}=i,c=a.resolve(o),l=c.marks().find(u=>u.type.name==="link");if(l||o>0&&(l=a.resolve(o-1).marks().find(d=>d.type.name==="link")),l||o<a.content.size&&(l=a.resolve(o+1).marks().find(d=>d.type.name==="link")),l){let u=(0,Pa.getMarkRange)(c,l.type);return u?(r.dispatch(i.tr.setSelection(Si.TextSelection.create(a,u.from,u.to))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:u.from,to:u.to,href:l.attrs.originalHref||l.attrs.href})),!0):(r.dispatch(i.tr.setSelection(Si.TextSelection.create(a,o,o+1))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:o,to:o+1,href:l.attrs.originalHref||l.attrs.href})),!0)}return!1}}}),new Si.Plugin({appendTransaction(r,o,n){if(!r.some(c=>c.docChanged))return null;let i=n.tr,a=!1;return n.doc.descendants((c,l)=>(c.marks.forEach(u=>{if(u.type.name==="link"&&u.attrs.href){let d=u.attrs.href;if(d.includes("__VAR_")){let p=d.replace(/__VAR_([^_]+)__/g,"{{$1}}");if(p!==d){let m=(0,Pa.getMarkRange)(n.doc.resolve(l),u.type);m&&(i.removeMark(m.from,m.to,u.type),i.addMark(m.from,m.to,u.type.create({...u.attrs,href:p,hasVariables:!0,originalHref:p})),a=!0)}}}}),!0)),a?i:null}})]}});var Lf=require("@hookform/resolvers/zod"),Rf=require("jotai"),zs=require("react"),Bf=require("react-hook-form"),Us=require("zod");var io=require("react/jsx-runtime"),Bh=Us.z.object({href:Us.z.string(),openInNewTab:Us.z.boolean().default(!1)}),Hf=s(({editor:e,mark:t,pendingLink:r})=>{var u,d;let o=(0,Rf.useSetAtom)(ms),n=(0,zs.useRef)(null),i=(0,Bf.useForm)({resolver:(0,Lf.zodResolver)(Bh),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1}});(0,zs.useEffect)(()=>{i.reset({href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1})},[t,i]);let a=((d=(u=e==null?void 0:e.extensionManager.extensions.find(p=>p.name==="variableSuggestion"))==null?void 0:u.options)==null?void 0:d.variables)||{},c=Mr(a),l=s(async p=>{let m=p.href.trim();if(!m){r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),e==null||e.commands.unsetLink(),o(null);return}r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),await(e==null?void 0:e.chain().focus().unsetLink().setTextSelection({from:(r==null?void 0:r.from)||0,to:(r==null?void 0:r.to)||0}).setLink({href:m,target:p.openInNewTab?"_blank":null}).run()),e==null||e.commands.setTextSelection((r==null?void 0:r.to)||0),o(null)},"updateLink");return(0,io.jsxs)(Ye,{...i,children:[(0,io.jsx)("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),(0,io.jsx)("div",{className:"courier-space-y-4",children:(0,io.jsx)(q,{control:i.control,name:"href",render:({field:p})=>(0,io.jsxs)(_,{children:[(0,io.jsx)(Br,{children:"URL"}),(0,io.jsx)(Z,{children:(0,io.jsx)(Ot,{as:"Textarea",autoResize:!0,...p,variables:c,ref:m=>{typeof p.ref=="function"&&p.ref(m),n.current=m},onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),m.stopPropagation(),i.handleSubmit(l)())},onBlur:()=>{p.onBlur(),i.handleSubmit(l)()}})}),(0,io.jsx)(G,{})]})})})]})},"LinkForm");var $s=require("@tiptap/core"),Df=$s.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",(0,$s.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var qs=require("@tiptap/react"),Ai=require("prosemirror-state");var Oo={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Zs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Hh=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Dh=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(tt=0;tt<10;tt++)Oo[48+tt]=Oo[96+tt]=String(tt);var tt;for(tt=1;tt<=24;tt++)Oo[tt+111]="F"+tt;var tt;for(tt=65;tt<=90;tt++)Oo[tt]=String.fromCharCode(tt+32),Zs[tt]=String.fromCharCode(tt);var tt;for(_s in Oo)Zs.hasOwnProperty(_s)||(Zs[_s]=Oo[_s]);var _s;function Ff(e){var t=Hh&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Dh&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?Zs:Oo)[e.keyCode]||e.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}s(Ff,"keyName");var Vf=require("prosemirror-state");var Fh=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Vh(e){let t=e.split(/-(?!$)/),r=t[t.length-1];r=="Space"&&(r=" ");let o,n,i,a;for(let c=0;c<t.length-1;c++){let l=t[c];if(/^(cmd|meta|m)$/i.test(l))a=!0;else if(/^a(lt)?$/i.test(l))o=!0;else if(/^(c|ctrl|control)$/i.test(l))n=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))Fh?a=!0:n=!0;else throw new Error("Unrecognized modifier name: "+l)}return o&&(r="Alt-"+r),n&&(r="Ctrl-"+r),a&&(r="Meta-"+r),i&&(r="Shift-"+r),r}s(Vh,"normalizeKeyName");function Oh(e){let t=Object.create(null);for(let r in e)t[Vh(r)]=e[r];return t}s(Oh,"normalize");function ku(e,t,r=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),r&&t.shiftKey&&(e="Shift-"+e),e}s(ku,"modifiers");function Of(e){return new Vf.Plugin({props:{handleKeyDown:Wh(e)}})}s(Of,"keymap");function Wh(e){let t=Oh(e);return function(r,o){let n=Ff(o),i,a=t[ku(n,o)];if(a&&a(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let c=t[ku(n,o,!1)];if(c&&c(r.state,r.dispatch,r))return!0}if((o.shiftKey||o.altKey||o.metaKey||n.charCodeAt(0)>127)&&(i=Oo[o.keyCode])&&i!=n){let c=t[ku(i,o)];if(c&&c(r.state,r.dispatch,r))return!0}}return!1}}s(Wh,"keydownHandler");var Wf=require("uuid");var Pu=Df.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){Ft(this.editor,this.name)},onTransaction(){let e=this.editor.state.tr,t=!1;this.editor.state.doc.descendants((r,o)=>{if(r.type.name===this.name&&!r.attrs.id){let n=`node-${(0,Wf.v4)()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:ne.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):ne.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:ne.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):ne.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:ne.textAlign,parseHTML:e=>e.style.textAlign||ne.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:ne.backgroundColor,parseHTML:e=>e.style.backgroundColor||ne.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:ne.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):ne.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:ne.borderRadius,parseHTML:e=>e.style.borderRadius?parseInt(e.style.borderRadius):ne.borderRadius,renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:ne.borderColor,parseHTML:e=>e.style.borderColor||ne.borderColor,renderHTML:e=>({"data-border-color":e.borderColor})},textColor:{default:ne.textColor,parseHTML:e=>e.style.color||ne.textColor,renderHTML:e=>({"data-text-color":e.textColor})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})}}},parseHTML(){return[{tag:'div[data-type="paragraph"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,qs.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return(0,qs.ReactNodeViewRenderer)(Vs)},addProseMirrorPlugins(){return[Of({"Mod-a":({selection:e,tr:t})=>{document.execCommand("selectAll");let{$from:r}=e,o=r.depth,n=null;for(;o>0;){let i=r.node(o);if(i.type.name==="paragraph"||i.type.name==="heading"){n=i;break}o--}if(n){let i=r.start(o),a=r.end(o);if(e.from!==i||e.to!==a)return t.setSelection(Ai.TextSelection.create(t.doc,i,a)),!0}return!1}}),new Ai.Plugin({key:new Ai.PluginKey("preventElementDeletion"),props:{handleKeyDown:(e,t)=>{let r=t.key==="Delete"||t.key==="Backspace"||t.keyCode===8||t.keyCode===46||t.code==="Delete"||t.code==="Backspace",o=t.metaKey||t.ctrlKey||t.altKey;if(r){let{state:n}=e,{selection:i}=n,{$anchor:a}=i,c=a.depth,l=null;for(;c>0;){let u=a.node(c);if(u.type.name==="paragraph"||u.type.name==="heading"){l=u;break}c--}if(l){let u=l.textContent,d=a.parentOffset===0,p=a.parentOffset===u.length,m=u.length===0,g=t.key==="Delete"||t.keyCode===46||t.code==="Delete";if(o||m||!g&&d||g&&p)return t.preventDefault(),t.stopPropagation(),!0}}return!1}}})]},addKeyboardShortcuts(){let e=s((t,r=!0)=>{let{empty:o,$anchor:n,$head:i}=t.state.selection,a=n.depth,c=null;for(;a>0;){let d=n.node(a);if(d.type.name==="paragraph"||d.type.name==="heading"){c=d;break}a--}if(!c)return!1;let l=r?n.pos===i.pos&&n.parentOffset===0:n.pos===i.pos&&n.parentOffset===c.textContent.length,u=c.textContent.length===0;return l||u?!0:o?!1:(t.commands.command(({tr:d,dispatch:p})=>p?(d.insertText("",t.state.selection.from,t.state.selection.to),!0):!1),!0)},"handleDeletion");return{Enter:({editor:t})=>{if(t.view.dom.querySelector(".variable-suggestion")||t.view.state.selection.$from.node().type.spec.code)return!1;let{state:o,dispatch:n}=t.view,{tr:i}=o;return i.replaceSelectionWith(o.schema.nodes.hardBreak.create()).scrollIntoView(),n(i),!0},"Mod-a":({editor:t})=>{let{$from:r}=t.state.selection,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),a=r.end(o);return t.commands.setTextSelection({from:i,to:a}),!0}o--}return!1},Backspace:({editor:t})=>e(t,!0),Delete:({editor:t})=>e(t,!1),Tab:()=>!0,"Shift-Tab":()=>!0}},addCommands(){return{setTextAlign:e=>({chain:t})=>t().updateAttributes(this.name,{textAlign:e}).run()}}});var Uf=require("@tiptap/core"),js=require("@tiptap/pm/state"),Uh=new js.PluginKey("selection"),Mu=Uf.Extension.create({name:"selection",addOptions(){return{HTMLAttributes:{},setSelectedNode:()=>{}}},addGlobalAttributes(){return[{types:["paragraph","heading","button","spacer","divider","imageBlock","blockquote","customCode"],attributes:{isSelected:{default:!1,parseHTML:()=>!1,renderHTML:e=>e.isSelected?{class:"selected-element"}:{}}}}]},addCommands(){return{updateSelectionState:e=>({tr:t,dispatch:r})=>(r&&t.doc.descendants((o,n)=>{var i;return o.type.name!=="text"&&((i=o.type.spec.attrs)==null?void 0:i.isSelected)!==void 0&&(o===e?t.setNodeAttribute(n,"isSelected",!0):t.setNodeAttribute(n,"isSelected",!1)),!0}),!0)}},addProseMirrorPlugins(){return[new js.Plugin({key:Uh,props:{handleClick:(e,t,r)=>{var c;let{state:o}=e;if(!this.editor.isEditable)return!1;try{let l=window.getSelection();if(l&&l.rangeCount>0){let d=l.getRangeAt(0).startContainer.parentElement;if(d&&(["P","H1","H2","H3","BLOCKQUOTE"].includes(d.tagName)||["P","H1","H2","H3","BLOCKQUOTE"].some(p=>d.closest(p)))){let p=e.posAtDOM(d,0),m=o.doc.resolve(p);if(((c=m.node(1))==null?void 0:c.type.name)==="blockquote")return this.options.setSelectedNode(m.node(1)),this.editor.commands.updateSelectionState(m.node(1)),!0;let g=m.node();if(g&&["paragraph","heading","blockquote"].includes(g.type.name))return this.options.setSelectedNode(g),this.editor.commands.updateSelectionState(g),!0}}}catch(l){console.error("Error handling click:",l)}let n=r.target,i=e.posAtDOM(n,0),a=o.doc.resolve(i).node();return a&&["paragraph","heading","blockquote"].includes(a.type.name)?(this.options.setSelectedNode(a),this.editor.commands.updateSelectionState(a),!0):!1}}})]}});var _e="top",lt="bottom",rt="right",Ge="left",Gs="auto",cn=[_e,lt,rt,Ge],Wo="start",Wn="end",zf="clippingParents",Js="viewport",Ii="popper",$f="reference",Nu=cn.reduce(function(e,t){return e.concat([t+"-"+Wo,t+"-"+Wn])},[]),Ks=[].concat(cn,[Gs]).reduce(function(e,t){return e.concat([t,t+"-"+Wo,t+"-"+Wn])},[]),zh="beforeRead",$h="read",_h="afterRead",Zh="beforeMain",qh="main",jh="afterMain",Gh="beforeWrite",Jh="write",Kh="afterWrite",_f=[zh,$h,_h,Zh,qh,jh,Gh,Jh,Kh];function ht(e){return e?(e.nodeName||"").toLowerCase():null}s(ht,"getNodeName");function He(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}s(He,"getWindow");function Vr(e){var t=He(e).Element;return e instanceof t||e instanceof Element}s(Vr,"isElement");function ct(e){var t=He(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}s(ct,"isHTMLElement");function Li(e){if(typeof ShadowRoot=="undefined")return!1;var t=He(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}s(Li,"isShadowRoot");function Xh(e){var t=e.state;Object.keys(t.elements).forEach(function(r){var o=t.styles[r]||{},n=t.attributes[r]||{},i=t.elements[r];!ct(i)||!ht(i)||(Object.assign(i.style,o),Object.keys(n).forEach(function(a){var c=n[a];c===!1?i.removeAttribute(a):i.setAttribute(a,c===!0?"":c)}))})}s(Xh,"applyStyles");function Yh(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow),function(){Object.keys(t.elements).forEach(function(o){var n=t.elements[o],i=t.attributes[o]||{},a=Object.keys(t.styles.hasOwnProperty(o)?t.styles[o]:r[o]),c=a.reduce(function(l,u){return l[u]="",l},{});!ct(n)||!ht(n)||(Object.assign(n.style,c),Object.keys(i).forEach(function(l){n.removeAttribute(l)}))})}}s(Yh,"effect");var Ma={name:"applyStyles",enabled:!0,phase:"write",fn:Xh,effect:Yh,requires:["computeStyles"]};function bt(e){return e.split("-")[0]}s(bt,"getBasePlacement");var ao=Math.max,Un=Math.min,Uo=Math.round;function Ri(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}s(Ri,"getUAString");function Na(){return!/^((?!chrome|android).)*safari/i.test(Ri())}s(Na,"isLayoutViewport");function Or(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!1);var o=e.getBoundingClientRect(),n=1,i=1;t&&ct(e)&&(n=e.offsetWidth>0&&Uo(o.width)/e.offsetWidth||1,i=e.offsetHeight>0&&Uo(o.height)/e.offsetHeight||1);var a=Vr(e)?He(e):window,c=a.visualViewport,l=!Na()&&r,u=(o.left+(l&&c?c.offsetLeft:0))/n,d=(o.top+(l&&c?c.offsetTop:0))/i,p=o.width/n,m=o.height/i;return{width:p,height:m,top:d,right:u+p,bottom:d+m,left:u,x:u,y:d}}s(Or,"getBoundingClientRect");function zn(e){var t=Or(e),r=e.offsetWidth,o=e.offsetHeight;return Math.abs(t.width-r)<=1&&(r=t.width),Math.abs(t.height-o)<=1&&(o=t.height),{x:e.offsetLeft,y:e.offsetTop,width:r,height:o}}s(zn,"getLayoutRect");function Sa(e,t){var r=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(r&&Li(r)){var o=t;do{if(o&&e.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}s(Sa,"contains");function jt(e){return He(e).getComputedStyle(e)}s(jt,"getComputedStyle");function Su(e){return["table","td","th"].indexOf(ht(e))>=0}s(Su,"isTableElement");function Nt(e){return((Vr(e)?e.ownerDocument:e.document)||window.document).documentElement}s(Nt,"getDocumentElement");function zo(e){return ht(e)==="html"?e:e.assignedSlot||e.parentNode||(Li(e)?e.host:null)||Nt(e)}s(zo,"getParentNode");function Zf(e){return!ct(e)||jt(e).position==="fixed"?null:e.offsetParent}s(Zf,"getTrueOffsetParent");function Qh(e){var t=/firefox/i.test(Ri()),r=/Trident/i.test(Ri());if(r&&ct(e)){var o=jt(e);if(o.position==="fixed")return null}var n=zo(e);for(Li(n)&&(n=n.host);ct(n)&&["html","body"].indexOf(ht(n))<0;){var i=jt(n);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||t&&i.willChange==="filter"||t&&i.filter&&i.filter!=="none")return n;n=n.parentNode}return null}s(Qh,"getContainingBlock");function so(e){for(var t=He(e),r=Zf(e);r&&Su(r)&&jt(r).position==="static";)r=Zf(r);return r&&(ht(r)==="html"||ht(r)==="body"&&jt(r).position==="static")?t:r||Qh(e)||t}s(so,"getOffsetParent");function $n(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}s($n,"getMainAxisFromPlacement");function _n(e,t,r){return ao(e,Un(t,r))}s(_n,"within");function qf(e,t,r){var o=_n(e,t,r);return o>r?r:o}s(qf,"withinMaxClamp");function Aa(){return{top:0,right:0,bottom:0,left:0}}s(Aa,"getFreshSideObject");function Ia(e){return Object.assign({},Aa(),e)}s(Ia,"mergePaddingObject");function La(e,t){return t.reduce(function(r,o){return r[o]=e,r},{})}s(La,"expandToHashMap");var e2=s(function(t,r){return t=typeof t=="function"?t(Object.assign({},r.rects,{placement:r.placement})):t,Ia(typeof t!="number"?t:La(t,cn))},"toPaddingObject");function t2(e){var t,r=e.state,o=e.name,n=e.options,i=r.elements.arrow,a=r.modifiersData.popperOffsets,c=bt(r.placement),l=$n(c),u=[Ge,rt].indexOf(c)>=0,d=u?"height":"width";if(!(!i||!a)){var p=e2(n.padding,r),m=zn(i),g=l==="y"?_e:Ge,b=l==="y"?lt:rt,h=r.rects.reference[d]+r.rects.reference[l]-a[l]-r.rects.popper[d],y=a[l]-r.rects.reference[l],P=so(i),w=P?l==="y"?P.clientHeight||0:P.clientWidth||0:0,v=h/2-y/2,f=p[g],C=w-m[d]-p[b],T=w/2-m[d]/2+v,R=_n(f,T,C),M=l;r.modifiersData[o]=(t={},t[M]=R,t.centerOffset=R-T,t)}}s(t2,"arrow");function r2(e){var t=e.state,r=e.options,o=r.element,n=o===void 0?"[data-popper-arrow]":o;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||Sa(t.elements.popper,n)&&(t.elements.arrow=n))}s(r2,"effect");var jf={name:"arrow",enabled:!0,phase:"main",fn:t2,effect:r2,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Wr(e){return e.split("-")[1]}s(Wr,"getVariation");var o2={top:"auto",right:"auto",bottom:"auto",left:"auto"};function n2(e,t){var r=e.x,o=e.y,n=t.devicePixelRatio||1;return{x:Uo(r*n)/n||0,y:Uo(o*n)/n||0}}s(n2,"roundOffsetsByDPR");function Gf(e){var t,r=e.popper,o=e.popperRect,n=e.placement,i=e.variation,a=e.offsets,c=e.position,l=e.gpuAcceleration,u=e.adaptive,d=e.roundOffsets,p=e.isFixed,m=a.x,g=m===void 0?0:m,b=a.y,h=b===void 0?0:b,y=typeof d=="function"?d({x:g,y:h}):{x:g,y:h};g=y.x,h=y.y;var P=a.hasOwnProperty("x"),w=a.hasOwnProperty("y"),v=Ge,f=_e,C=window;if(u){var T=so(r),R="clientHeight",M="clientWidth";if(T===He(r)&&(T=Nt(r),jt(T).position!=="static"&&c==="absolute"&&(R="scrollHeight",M="scrollWidth")),T=T,n===_e||(n===Ge||n===rt)&&i===Wn){f=lt;var k=p&&T===C&&C.visualViewport?C.visualViewport.height:T[R];h-=k-o.height,h*=l?1:-1}if(n===Ge||(n===_e||n===lt)&&i===Wn){v=rt;var S=p&&T===C&&C.visualViewport?C.visualViewport.width:T[M];g-=S-o.width,g*=l?1:-1}}var E=Object.assign({position:c},u&&o2),x=d===!0?n2({x:g,y:h},He(r)):{x:g,y:h};if(g=x.x,h=x.y,l){var A;return Object.assign({},E,(A={},A[f]=w?"0":"",A[v]=P?"0":"",A.transform=(C.devicePixelRatio||1)<=1?"translate("+g+"px, "+h+"px)":"translate3d("+g+"px, "+h+"px, 0)",A))}return Object.assign({},E,(t={},t[f]=w?h+"px":"",t[v]=P?g+"px":"",t.transform="",t))}s(Gf,"mapToStyles");function i2(e){var t=e.state,r=e.options,o=r.gpuAcceleration,n=o===void 0?!0:o,i=r.adaptive,a=i===void 0?!0:i,c=r.roundOffsets,l=c===void 0?!0:c,u={placement:bt(t.placement),variation:Wr(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Gf(Object.assign({},u,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:a,roundOffsets:l})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,Gf(Object.assign({},u,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}s(i2,"computeStyles");var Jf={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:i2,data:{}};var Xs={passive:!0};function a2(e){var t=e.state,r=e.instance,o=e.options,n=o.scroll,i=n===void 0?!0:n,a=o.resize,c=a===void 0?!0:a,l=He(t.elements.popper),u=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&u.forEach(function(d){d.addEventListener("scroll",r.update,Xs)}),c&&l.addEventListener("resize",r.update,Xs),function(){i&&u.forEach(function(d){d.removeEventListener("scroll",r.update,Xs)}),c&&l.removeEventListener("resize",r.update,Xs)}}s(a2,"effect");var Kf={name:"eventListeners",enabled:!0,phase:"write",fn:s(function(){},"fn"),effect:a2,data:{}};var s2={left:"right",right:"left",bottom:"top",top:"bottom"};function Bi(e){return e.replace(/left|right|bottom|top/g,function(t){return s2[t]})}s(Bi,"getOppositePlacement");var l2={start:"end",end:"start"};function Ys(e){return e.replace(/start|end/g,function(t){return l2[t]})}s(Ys,"getOppositeVariationPlacement");function Zn(e){var t=He(e),r=t.pageXOffset,o=t.pageYOffset;return{scrollLeft:r,scrollTop:o}}s(Zn,"getWindowScroll");function qn(e){return Or(Nt(e)).left+Zn(e).scrollLeft}s(qn,"getWindowScrollBarX");function Au(e,t){var r=He(e),o=Nt(e),n=r.visualViewport,i=o.clientWidth,a=o.clientHeight,c=0,l=0;if(n){i=n.width,a=n.height;var u=Na();(u||!u&&t==="fixed")&&(c=n.offsetLeft,l=n.offsetTop)}return{width:i,height:a,x:c+qn(e),y:l}}s(Au,"getViewportRect");function Iu(e){var t,r=Nt(e),o=Zn(e),n=(t=e.ownerDocument)==null?void 0:t.body,i=ao(r.scrollWidth,r.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),a=ao(r.scrollHeight,r.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),c=-o.scrollLeft+qn(e),l=-o.scrollTop;return jt(n||r).direction==="rtl"&&(c+=ao(r.clientWidth,n?n.clientWidth:0)-i),{width:i,height:a,x:c,y:l}}s(Iu,"getDocumentRect");function jn(e){var t=jt(e),r=t.overflow,o=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(r+n+o)}s(jn,"isScrollParent");function Qs(e){return["html","body","#document"].indexOf(ht(e))>=0?e.ownerDocument.body:ct(e)&&jn(e)?e:Qs(zo(e))}s(Qs,"getScrollParent");function un(e,t){var r;t===void 0&&(t=[]);var o=Qs(e),n=o===((r=e.ownerDocument)==null?void 0:r.body),i=He(o),a=n?[i].concat(i.visualViewport||[],jn(o)?o:[]):o,c=t.concat(a);return n?c:c.concat(un(zo(a)))}s(un,"listScrollParents");function Hi(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}s(Hi,"rectToClientRect");function c2(e,t){var r=Or(e,!1,t==="fixed");return r.top=r.top+e.clientTop,r.left=r.left+e.clientLeft,r.bottom=r.top+e.clientHeight,r.right=r.left+e.clientWidth,r.width=e.clientWidth,r.height=e.clientHeight,r.x=r.left,r.y=r.top,r}s(c2,"getInnerBoundingClientRect");function Xf(e,t,r){return t===Js?Hi(Au(e,r)):Vr(t)?c2(t,r):Hi(Iu(Nt(e)))}s(Xf,"getClientRectFromMixedType");function u2(e){var t=un(zo(e)),r=["absolute","fixed"].indexOf(jt(e).position)>=0,o=r&&ct(e)?so(e):e;return Vr(o)?t.filter(function(n){return Vr(n)&&Sa(n,o)&&ht(n)!=="body"}):[]}s(u2,"getClippingParents");function Lu(e,t,r,o){var n=t==="clippingParents"?u2(e):[].concat(t),i=[].concat(n,[r]),a=i[0],c=i.reduce(function(l,u){var d=Xf(e,u,o);return l.top=ao(d.top,l.top),l.right=Un(d.right,l.right),l.bottom=Un(d.bottom,l.bottom),l.left=ao(d.left,l.left),l},Xf(e,a,o));return c.width=c.right-c.left,c.height=c.bottom-c.top,c.x=c.left,c.y=c.top,c}s(Lu,"getClippingRect");function Ra(e){var t=e.reference,r=e.element,o=e.placement,n=o?bt(o):null,i=o?Wr(o):null,a=t.x+t.width/2-r.width/2,c=t.y+t.height/2-r.height/2,l;switch(n){case _e:l={x:a,y:t.y-r.height};break;case lt:l={x:a,y:t.y+t.height};break;case rt:l={x:t.x+t.width,y:c};break;case Ge:l={x:t.x-r.width,y:c};break;default:l={x:t.x,y:t.y}}var u=n?$n(n):null;if(u!=null){var d=u==="y"?"height":"width";switch(i){case Wo:l[u]=l[u]-(t[d]/2-r[d]/2);break;case Wn:l[u]=l[u]+(t[d]/2-r[d]/2);break;default:}}return l}s(Ra,"computeOffsets");function lo(e,t){t===void 0&&(t={});var r=t,o=r.placement,n=o===void 0?e.placement:o,i=r.strategy,a=i===void 0?e.strategy:i,c=r.boundary,l=c===void 0?zf:c,u=r.rootBoundary,d=u===void 0?Js:u,p=r.elementContext,m=p===void 0?Ii:p,g=r.altBoundary,b=g===void 0?!1:g,h=r.padding,y=h===void 0?0:h,P=Ia(typeof y!="number"?y:La(y,cn)),w=m===Ii?$f:Ii,v=e.rects.popper,f=e.elements[b?w:m],C=Lu(Vr(f)?f:f.contextElement||Nt(e.elements.popper),l,d,a),T=Or(e.elements.reference),R=Ra({reference:T,element:v,strategy:"absolute",placement:n}),M=Hi(Object.assign({},v,R)),k=m===Ii?M:T,S={top:C.top-k.top+P.top,bottom:k.bottom-C.bottom+P.bottom,left:C.left-k.left+P.left,right:k.right-C.right+P.right},E=e.modifiersData.offset;if(m===Ii&&E){var x=E[n];Object.keys(S).forEach(function(A){var I=[rt,lt].indexOf(A)>=0?1:-1,H=[_e,lt].indexOf(A)>=0?"y":"x";S[A]+=x[H]*I})}return S}s(lo,"detectOverflow");function Ru(e,t){t===void 0&&(t={});var r=t,o=r.placement,n=r.boundary,i=r.rootBoundary,a=r.padding,c=r.flipVariations,l=r.allowedAutoPlacements,u=l===void 0?Ks:l,d=Wr(o),p=d?c?Nu:Nu.filter(function(b){return Wr(b)===d}):cn,m=p.filter(function(b){return u.indexOf(b)>=0});m.length===0&&(m=p);var g=m.reduce(function(b,h){return b[h]=lo(e,{placement:h,boundary:n,rootBoundary:i,padding:a})[bt(h)],b},{});return Object.keys(g).sort(function(b,h){return g[b]-g[h]})}s(Ru,"computeAutoPlacement");function d2(e){if(bt(e)===Gs)return[];var t=Bi(e);return[Ys(e),t,Ys(t)]}s(d2,"getExpandedFallbackPlacements");function p2(e){var t=e.state,r=e.options,o=e.name;if(!t.modifiersData[o]._skip){for(var n=r.mainAxis,i=n===void 0?!0:n,a=r.altAxis,c=a===void 0?!0:a,l=r.fallbackPlacements,u=r.padding,d=r.boundary,p=r.rootBoundary,m=r.altBoundary,g=r.flipVariations,b=g===void 0?!0:g,h=r.allowedAutoPlacements,y=t.options.placement,P=bt(y),w=P===y,v=l||(w||!b?[Bi(y)]:d2(y)),f=[y].concat(v).reduce(function(Ce,Pe){return Ce.concat(bt(Pe)===Gs?Ru(t,{placement:Pe,boundary:d,rootBoundary:p,padding:u,flipVariations:b,allowedAutoPlacements:h}):Pe)},[]),C=t.rects.reference,T=t.rects.popper,R=new Map,M=!0,k=f[0],S=0;S<f.length;S++){var E=f[S],x=bt(E),A=Wr(E)===Wo,I=[_e,lt].indexOf(x)>=0,H=I?"width":"height",D=lo(t,{placement:E,boundary:d,rootBoundary:p,altBoundary:m,padding:u}),B=I?A?rt:Ge:A?lt:_e;C[H]>T[H]&&(B=Bi(B));var z=Bi(B),X=[];if(i&&X.push(D[x]<=0),c&&X.push(D[B]<=0,D[z]<=0),X.every(function(Ce){return Ce})){k=E,M=!1;break}R.set(E,X)}if(M)for(var ue=b?3:1,ie=s(function(Pe){var qe=f.find(function(Bt){var Fe=R.get(Bt);if(Fe)return Fe.slice(0,Pe).every(function(V){return V})});if(qe)return k=qe,"break"},"_loop"),he=ue;he>0;he--){var ye=ie(he);if(ye==="break")break}t.placement!==k&&(t.modifiersData[o]._skip=!0,t.placement=k,t.reset=!0)}}s(p2,"flip");var Yf={name:"flip",enabled:!0,phase:"main",fn:p2,requiresIfExists:["offset"],data:{_skip:!1}};function Qf(e,t,r){return r===void 0&&(r={x:0,y:0}),{top:e.top-t.height-r.y,right:e.right-t.width+r.x,bottom:e.bottom-t.height+r.y,left:e.left-t.width-r.x}}s(Qf,"getSideOffsets");function e1(e){return[_e,rt,lt,Ge].some(function(t){return e[t]>=0})}s(e1,"isAnySideFullyClipped");function m2(e){var t=e.state,r=e.name,o=t.rects.reference,n=t.rects.popper,i=t.modifiersData.preventOverflow,a=lo(t,{elementContext:"reference"}),c=lo(t,{altBoundary:!0}),l=Qf(a,o),u=Qf(c,n,i),d=e1(l),p=e1(u);t.modifiersData[r]={referenceClippingOffsets:l,popperEscapeOffsets:u,isReferenceHidden:d,hasPopperEscaped:p},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":p})}s(m2,"hide");var t1={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:m2};function f2(e,t,r){var o=bt(e),n=[Ge,_e].indexOf(o)>=0?-1:1,i=typeof r=="function"?r(Object.assign({},t,{placement:e})):r,a=i[0],c=i[1];return a=a||0,c=(c||0)*n,[Ge,rt].indexOf(o)>=0?{x:c,y:a}:{x:a,y:c}}s(f2,"distanceAndSkiddingToXY");function g2(e){var t=e.state,r=e.options,o=e.name,n=r.offset,i=n===void 0?[0,0]:n,a=Ks.reduce(function(d,p){return d[p]=f2(p,t.rects,i),d},{}),c=a[t.placement],l=c.x,u=c.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=u),t.modifiersData[o]=a}s(g2,"offset");var r1={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:g2};function h2(e){var t=e.state,r=e.name;t.modifiersData[r]=Ra({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}s(h2,"popperOffsets");var o1={name:"popperOffsets",enabled:!0,phase:"read",fn:h2,data:{}};function Bu(e){return e==="x"?"y":"x"}s(Bu,"getAltAxis");function b2(e){var t=e.state,r=e.options,o=e.name,n=r.mainAxis,i=n===void 0?!0:n,a=r.altAxis,c=a===void 0?!1:a,l=r.boundary,u=r.rootBoundary,d=r.altBoundary,p=r.padding,m=r.tether,g=m===void 0?!0:m,b=r.tetherOffset,h=b===void 0?0:b,y=lo(t,{boundary:l,rootBoundary:u,padding:p,altBoundary:d}),P=bt(t.placement),w=Wr(t.placement),v=!w,f=$n(P),C=Bu(f),T=t.modifiersData.popperOffsets,R=t.rects.reference,M=t.rects.popper,k=typeof h=="function"?h(Object.assign({},t.rects,{placement:t.placement})):h,S=typeof k=="number"?{mainAxis:k,altAxis:k}:Object.assign({mainAxis:0,altAxis:0},k),E=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,x={x:0,y:0};if(T){if(i){var A,I=f==="y"?_e:Ge,H=f==="y"?lt:rt,D=f==="y"?"height":"width",B=T[f],z=B+y[I],X=B-y[H],ue=g?-M[D]/2:0,ie=w===Wo?R[D]:M[D],he=w===Wo?-M[D]:-R[D],ye=t.elements.arrow,Ce=g&&ye?zn(ye):{width:0,height:0},Pe=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:Aa(),qe=Pe[I],Bt=Pe[H],Fe=_n(0,R[D],Ce[D]),V=v?R[D]/2-ue-Fe-qe-S.mainAxis:ie-Fe-qe-S.mainAxis,ee=v?-R[D]/2+ue+Fe+Bt+S.mainAxis:he+Fe+Bt+S.mainAxis,ae=t.elements.arrow&&so(t.elements.arrow),Se=ae?f==="y"?ae.clientTop||0:ae.clientLeft||0:0,ze=(A=E==null?void 0:E[f])!=null?A:0,Ke=B+V-ze-Se,xt=B+ee-ze,it=_n(g?Un(z,Ke):z,B,g?ao(X,xt):X);T[f]=it,x[f]=it-B}if(c){var Ct,Tr=f==="x"?_e:Ge,wr=f==="x"?lt:rt,dt=T[C],Tt=C==="y"?"height":"width",Yt=dt+y[Tr],Ht=dt-y[wr],te=[_e,Ge].indexOf(P)!==-1,Qt=(Ct=E==null?void 0:E[C])!=null?Ct:0,Ir=te?Yt:dt-R[Tt]-M[Tt]-Qt+S.altAxis,Lr=te?dt+R[Tt]+M[Tt]-Qt-S.altAxis:Ht,mo=g&&te?qf(Ir,dt,Lr):_n(g?Ir:Yt,dt,g?Lr:Ht);T[C]=mo,x[C]=mo-dt}t.modifiersData[o]=x}}s(b2,"preventOverflow");var n1={name:"preventOverflow",enabled:!0,phase:"main",fn:b2,requiresIfExists:["offset"]};function Hu(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}s(Hu,"getHTMLElementScroll");function Du(e){return e===He(e)||!ct(e)?Zn(e):Hu(e)}s(Du,"getNodeScroll");function y2(e){var t=e.getBoundingClientRect(),r=Uo(t.width)/e.offsetWidth||1,o=Uo(t.height)/e.offsetHeight||1;return r!==1||o!==1}s(y2,"isElementScaled");function Fu(e,t,r){r===void 0&&(r=!1);var o=ct(t),n=ct(t)&&y2(t),i=Nt(t),a=Or(e,n,r),c={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(o||!o&&!r)&&((ht(t)!=="body"||jn(i))&&(c=Du(t)),ct(t)?(l=Or(t,!0),l.x+=t.clientLeft,l.y+=t.clientTop):i&&(l.x=qn(i))),{x:a.left+c.scrollLeft-l.x,y:a.top+c.scrollTop-l.y,width:a.width,height:a.height}}s(Fu,"getCompositeRect");function v2(e){var t=new Map,r=new Set,o=[];e.forEach(function(i){t.set(i.name,i)});function n(i){r.add(i.name);var a=[].concat(i.requires||[],i.requiresIfExists||[]);a.forEach(function(c){if(!r.has(c)){var l=t.get(c);l&&n(l)}}),o.push(i)}return s(n,"sort"),e.forEach(function(i){r.has(i.name)||n(i)}),o}s(v2,"order");function Vu(e){var t=v2(e);return _f.reduce(function(r,o){return r.concat(t.filter(function(n){return n.phase===o}))},[])}s(Vu,"orderModifiers");function Ou(e){var t;return function(){return t||(t=new Promise(function(r){Promise.resolve().then(function(){t=void 0,r(e())})})),t}}s(Ou,"debounce");function Wu(e){var t=e.reduce(function(r,o){var n=r[o.name];return r[o.name]=n?Object.assign({},n,o,{options:Object.assign({},n.options,o.options),data:Object.assign({},n.data,o.data)}):o,r},{});return Object.keys(t).map(function(r){return t[r]})}s(Wu,"mergeByName");var i1={placement:"bottom",modifiers:[],strategy:"absolute"};function a1(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return!t.some(function(o){return!(o&&typeof o.getBoundingClientRect=="function")})}s(a1,"areValidElements");function s1(e){e===void 0&&(e={});var t=e,r=t.defaultModifiers,o=r===void 0?[]:r,n=t.defaultOptions,i=n===void 0?i1:n;return s(function(c,l,u){u===void 0&&(u=i);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},i1,i),modifiersData:{},elements:{reference:c,popper:l},attributes:{},styles:{}},p=[],m=!1,g={state:d,setOptions:s(function(P){var w=typeof P=="function"?P(d.options):P;h(),d.options=Object.assign({},i,d.options,w),d.scrollParents={reference:Vr(c)?un(c):c.contextElement?un(c.contextElement):[],popper:un(l)};var v=Vu(Wu([].concat(o,d.options.modifiers)));return d.orderedModifiers=v.filter(function(f){return f.enabled}),b(),g.update()},"setOptions"),forceUpdate:s(function(){if(!m){var P=d.elements,w=P.reference,v=P.popper;if(a1(w,v)){d.rects={reference:Fu(w,so(v),d.options.strategy==="fixed"),popper:zn(v)},d.reset=!1,d.placement=d.options.placement,d.orderedModifiers.forEach(function(S){return d.modifiersData[S.name]=Object.assign({},S.data)});for(var f=0;f<d.orderedModifiers.length;f++){if(d.reset===!0){d.reset=!1,f=-1;continue}var C=d.orderedModifiers[f],T=C.fn,R=C.options,M=R===void 0?{}:R,k=C.name;typeof T=="function"&&(d=T({state:d,options:M,name:k,instance:g})||d)}}}},"forceUpdate"),update:Ou(function(){return new Promise(function(y){g.forceUpdate(),y(d)})}),destroy:s(function(){h(),m=!0},"destroy")};if(!a1(c,l))return g;g.setOptions(u).then(function(y){!m&&u.onFirstUpdate&&u.onFirstUpdate(y)});function b(){d.orderedModifiers.forEach(function(y){var P=y.name,w=y.options,v=w===void 0?{}:w,f=y.effect;if(typeof f=="function"){var C=f({state:d,name:P,instance:g,options:v}),T=s(function(){},"noopFn");p.push(C||T)}})}s(b,"runModifierEffects");function h(){p.forEach(function(y){return y()}),p=[]}return s(h,"cleanupModifierEffects"),g},"createPopper")}s(s1,"popperGenerator");var x2=[Kf,o1,Jf,Ma,r1,Yf,n1,jf,t1],Uu=s1({defaultModifiers:x2});var C2="tippy-box",b1="tippy-content",T2="tippy-backdrop",y1="tippy-arrow",v1="tippy-svg-arrow",Gn={passive:!0,capture:!0},x1=s(function(){return document.body},"TIPPY_DEFAULT_APPEND_TO");function zu(e,t,r){if(Array.isArray(e)){var o=e[t];return o==null?Array.isArray(r)?r[t]:r:o}return e}s(zu,"getValueAtIndexOrReturn");function Gu(e,t){var r={}.toString.call(e);return r.indexOf("[object")===0&&r.indexOf(t+"]")>-1}s(Gu,"isType");function C1(e,t){return typeof e=="function"?e.apply(void 0,t):e}s(C1,"invokeWithArgsOrReturn");function l1(e,t){if(t===0)return e;var r;return function(o){clearTimeout(r),r=setTimeout(function(){e(o)},t)}}s(l1,"debounce");function w2(e){return e.split(/\s+/).filter(Boolean)}s(w2,"splitBySpaces");function Di(e){return[].concat(e)}s(Di,"normalizeToArray");function c1(e,t){e.indexOf(t)===-1&&e.push(t)}s(c1,"pushIfUnique");function E2(e){return e.filter(function(t,r){return e.indexOf(t)===r})}s(E2,"unique");function k2(e){return e.split("-")[0]}s(k2,"getBasePlacement");function tl(e){return[].slice.call(e)}s(tl,"arrayFrom");function u1(e){return Object.keys(e).reduce(function(t,r){return e[r]!==void 0&&(t[r]=e[r]),t},{})}s(u1,"removeUndefinedProps");function Ba(){return document.createElement("div")}s(Ba,"div");function rl(e){return["Element","Fragment"].some(function(t){return Gu(e,t)})}s(rl,"isElement");function P2(e){return Gu(e,"NodeList")}s(P2,"isNodeList");function M2(e){return Gu(e,"MouseEvent")}s(M2,"isMouseEvent");function N2(e){return!!(e&&e._tippy&&e._tippy.reference===e)}s(N2,"isReferenceElement");function S2(e){return rl(e)?[e]:P2(e)?tl(e):Array.isArray(e)?e:tl(document.querySelectorAll(e))}s(S2,"getArrayOfElements");function $u(e,t){e.forEach(function(r){r&&(r.style.transitionDuration=t+"ms")})}s($u,"setTransitionDuration");function d1(e,t){e.forEach(function(r){r&&r.setAttribute("data-state",t)})}s(d1,"setVisibilityState");function A2(e){var t,r=Di(e),o=r[0];return o!=null&&(t=o.ownerDocument)!=null&&t.body?o.ownerDocument:document}s(A2,"getOwnerDocument");function I2(e,t){var r=t.clientX,o=t.clientY;return e.every(function(n){var i=n.popperRect,a=n.popperState,c=n.props,l=c.interactiveBorder,u=k2(a.placement),d=a.modifiersData.offset;if(!d)return!0;var p=u==="bottom"?d.top.y:0,m=u==="top"?d.bottom.y:0,g=u==="right"?d.left.x:0,b=u==="left"?d.right.x:0,h=i.top-o+p>l,y=o-i.bottom-m>l,P=i.left-r+g>l,w=r-i.right-b>l;return h||y||P||w})}s(I2,"isCursorOutsideInteractiveBorder");function _u(e,t,r){var o=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){e[o](n,r)})}s(_u,"updateTransitionEndListener");function p1(e,t){for(var r=t;r;){var o;if(e.contains(r))return!0;r=r.getRootNode==null||(o=r.getRootNode())==null?void 0:o.host}return!1}s(p1,"actualContains");var Co={isTouch:!1},m1=0;function L2(){Co.isTouch||(Co.isTouch=!0,window.performance&&document.addEventListener("mousemove",T1))}s(L2,"onDocumentTouchStart");function T1(){var e=performance.now();e-m1<20&&(Co.isTouch=!1,document.removeEventListener("mousemove",T1)),m1=e}s(T1,"onDocumentMouseMove");function R2(){var e=document.activeElement;if(N2(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}s(R2,"onWindowBlur");function B2(){document.addEventListener("touchstart",L2,Gn),window.addEventListener("blur",R2)}s(B2,"bindGlobalEventListeners");var H2=typeof window!="undefined"&&typeof document!="undefined",D2=H2?!!window.msCrypto:!1;var F2={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},V2={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},co=Object.assign({appendTo:x1,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:s(function(){},"onAfterUpdate"),onBeforeUpdate:s(function(){},"onBeforeUpdate"),onCreate:s(function(){},"onCreate"),onDestroy:s(function(){},"onDestroy"),onHidden:s(function(){},"onHidden"),onHide:s(function(){},"onHide"),onMount:s(function(){},"onMount"),onShow:s(function(){},"onShow"),onShown:s(function(){},"onShown"),onTrigger:s(function(){},"onTrigger"),onUntrigger:s(function(){},"onUntrigger"),onClickOutside:s(function(){},"onClickOutside"),placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},F2,V2),O2=Object.keys(co),W2=s(function(t){var r=Object.keys(t);r.forEach(function(o){co[o]=t[o]})},"setDefaultProps");function w1(e){var t=e.plugins||[],r=t.reduce(function(o,n){var i=n.name,a=n.defaultValue;if(i){var c;o[i]=e[i]!==void 0?e[i]:(c=co[i])!=null?c:a}return o},{});return Object.assign({},e,r)}s(w1,"getExtendedPassedProps");function U2(e,t){var r=t?Object.keys(w1(Object.assign({},co,{plugins:t}))):O2,o=r.reduce(function(n,i){var a=(e.getAttribute("data-tippy-"+i)||"").trim();if(!a)return n;if(i==="content")n[i]=a;else try{n[i]=JSON.parse(a)}catch{n[i]=a}return n},{});return o}s(U2,"getDataAttributeProps");function f1(e,t){var r=Object.assign({},t,{content:C1(t.content,[e])},t.ignoreAttributes?{}:U2(e,t.plugins));return r.aria=Object.assign({},co.aria,r.aria),r.aria={expanded:r.aria.expanded==="auto"?t.interactive:r.aria.expanded,content:r.aria.content==="auto"?t.interactive?null:"describedby":r.aria.content},r}s(f1,"evaluateProps");var z2=s(function(){return"innerHTML"},"innerHTML");function qu(e,t){e[z2()]=t}s(qu,"dangerouslySetInnerHTML");function g1(e){var t=Ba();return e===!0?t.className=y1:(t.className=v1,rl(e)?t.appendChild(e):qu(t,e)),t}s(g1,"createArrowElement");function h1(e,t){rl(t.content)?(qu(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?qu(e,t.content):e.textContent=t.content)}s(h1,"setContent");function ju(e){var t=e.firstElementChild,r=tl(t.children);return{box:t,content:r.find(function(o){return o.classList.contains(b1)}),arrow:r.find(function(o){return o.classList.contains(y1)||o.classList.contains(v1)}),backdrop:r.find(function(o){return o.classList.contains(T2)})}}s(ju,"getChildren");function E1(e){var t=Ba(),r=Ba();r.className=C2,r.setAttribute("data-state","hidden"),r.setAttribute("tabindex","-1");var o=Ba();o.className=b1,o.setAttribute("data-state","hidden"),h1(o,e.props),t.appendChild(r),r.appendChild(o),n(e.props,e.props);function n(i,a){var c=ju(t),l=c.box,u=c.content,d=c.arrow;a.theme?l.setAttribute("data-theme",a.theme):l.removeAttribute("data-theme"),typeof a.animation=="string"?l.setAttribute("data-animation",a.animation):l.removeAttribute("data-animation"),a.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof a.maxWidth=="number"?a.maxWidth+"px":a.maxWidth,a.role?l.setAttribute("role",a.role):l.removeAttribute("role"),(i.content!==a.content||i.allowHTML!==a.allowHTML)&&h1(u,e.props),a.arrow?d?i.arrow!==a.arrow&&(l.removeChild(d),l.appendChild(g1(a.arrow))):l.appendChild(g1(a.arrow)):d&&l.removeChild(d)}return s(n,"onUpdate"),{popper:t,onUpdate:n}}s(E1,"render");E1.$$tippy=!0;var $2=1,el=[],Zu=[];function _2(e,t){var r=f1(e,Object.assign({},co,w1(u1(t)))),o,n,i,a=!1,c=!1,l=!1,u=!1,d,p,m,g=[],b=l1(Ke,r.interactiveDebounce),h,y=$2++,P=null,w=E2(r.plugins),v={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},f={id:y,reference:e,popper:Ba(),popperInstance:P,props:r,state:v,plugins:w,clearDelayTimeouts:Ir,setProps:Lr,setContent:mo,show:hn,hide:bn,hideWithInteractivity:yn,enable:te,disable:Qt,unmount:vn,destroy:xn};if(!r.render)return f;var C=r.render(f),T=C.popper,R=C.onUpdate;T.setAttribute("data-tippy-root",""),T.id="tippy-"+f.id,f.popper=T,e._tippy=f,T._tippy=f;var M=w.map(function(L){return L.fn(f)}),k=e.hasAttribute("aria-expanded");return ae(),ue(),B(),z("onCreate",[f]),r.showOnCreate&&Yt(),T.addEventListener("mouseenter",function(){f.props.interactive&&f.state.isVisible&&f.clearDelayTimeouts()}),T.addEventListener("mouseleave",function(){f.props.interactive&&f.props.trigger.indexOf("mouseenter")>=0&&I().addEventListener("mousemove",b)}),f;function S(){var L=f.props.touch;return Array.isArray(L)?L:[L,0]}s(S,"getNormalizedTouchSettings");function E(){return S()[0]==="hold"}s(E,"getIsCustomTouchBehavior");function x(){var L;return!!((L=f.props.render)!=null&&L.$$tippy)}s(x,"getIsDefaultRenderFn");function A(){return h||e}s(A,"getCurrentTarget");function I(){var L=A().parentNode;return L?A2(L):document}s(I,"getDocument");function H(){return ju(T)}s(H,"getDefaultTemplateChildren");function D(L){return f.state.isMounted&&!f.state.isVisible||Co.isTouch||d&&d.type==="focus"?0:zu(f.props.delay,L?0:1,co.delay)}s(D,"getDelay");function B(L){L===void 0&&(L=!1),T.style.pointerEvents=f.props.interactive&&!L?"":"none",T.style.zIndex=""+f.props.zIndex}s(B,"handleStyles");function z(L,$,F){if(F===void 0&&(F=!0),M.forEach(function(j){j[L]&&j[L].apply(j,$)}),F){var Q;(Q=f.props)[L].apply(Q,$)}}s(z,"invokeHook");function X(){var L=f.props.aria;if(L.content){var $="aria-"+L.content,F=T.id,Q=Di(f.props.triggerTarget||e);Q.forEach(function(j){var Xe=j.getAttribute($);if(f.state.isVisible)j.setAttribute($,Xe?Xe+" "+F:F);else{var de=Xe&&Xe.replace(F,"").trim();de?j.setAttribute($,de):j.removeAttribute($)}})}}s(X,"handleAriaContentAttribute");function ue(){if(!(k||!f.props.aria.expanded)){var L=Di(f.props.triggerTarget||e);L.forEach(function($){f.props.interactive?$.setAttribute("aria-expanded",f.state.isVisible&&$===A()?"true":"false"):$.removeAttribute("aria-expanded")})}}s(ue,"handleAriaExpandedAttribute");function ie(){I().removeEventListener("mousemove",b),el=el.filter(function(L){return L!==b})}s(ie,"cleanupInteractiveMouseListeners");function he(L){if(!(Co.isTouch&&(l||L.type==="mousedown"))){var $=L.composedPath&&L.composedPath()[0]||L.target;if(!(f.props.interactive&&p1(T,$))){if(Di(f.props.triggerTarget||e).some(function(F){return p1(F,$)})){if(Co.isTouch||f.state.isVisible&&f.props.trigger.indexOf("click")>=0)return}else z("onClickOutside",[f,L]);f.props.hideOnClick===!0&&(f.clearDelayTimeouts(),f.hide(),c=!0,setTimeout(function(){c=!1}),f.state.isMounted||qe())}}}s(he,"onDocumentPress");function ye(){l=!0}s(ye,"onTouchMove");function Ce(){l=!1}s(Ce,"onTouchStart");function Pe(){var L=I();L.addEventListener("mousedown",he,!0),L.addEventListener("touchend",he,Gn),L.addEventListener("touchstart",Ce,Gn),L.addEventListener("touchmove",ye,Gn)}s(Pe,"addDocumentPress");function qe(){var L=I();L.removeEventListener("mousedown",he,!0),L.removeEventListener("touchend",he,Gn),L.removeEventListener("touchstart",Ce,Gn),L.removeEventListener("touchmove",ye,Gn)}s(qe,"removeDocumentPress");function Bt(L,$){V(L,function(){!f.state.isVisible&&T.parentNode&&T.parentNode.contains(T)&&$()})}s(Bt,"onTransitionedOut");function Fe(L,$){V(L,$)}s(Fe,"onTransitionedIn");function V(L,$){var F=H().box;function Q(j){j.target===F&&(_u(F,"remove",Q),$())}if(s(Q,"listener"),L===0)return $();_u(F,"remove",p),_u(F,"add",Q),p=Q}s(V,"onTransitionEnd");function ee(L,$,F){F===void 0&&(F=!1);var Q=Di(f.props.triggerTarget||e);Q.forEach(function(j){j.addEventListener(L,$,F),g.push({node:j,eventType:L,handler:$,options:F})})}s(ee,"on");function ae(){E()&&(ee("touchstart",ze,{passive:!0}),ee("touchend",xt,{passive:!0})),w2(f.props.trigger).forEach(function(L){if(L!=="manual")switch(ee(L,ze),L){case"mouseenter":ee("mouseleave",xt);break;case"focus":ee(D2?"focusout":"blur",it);break;case"focusin":ee("focusout",it);break}})}s(ae,"addListeners");function Se(){g.forEach(function(L){var $=L.node,F=L.eventType,Q=L.handler,j=L.options;$.removeEventListener(F,Q,j)}),g=[]}s(Se,"removeListeners");function ze(L){var $,F=!1;if(!(!f.state.isEnabled||Ct(L)||c)){var Q=(($=d)==null?void 0:$.type)==="focus";d=L,h=L.currentTarget,ue(),!f.state.isVisible&&M2(L)&&el.forEach(function(j){return j(L)}),L.type==="click"&&(f.props.trigger.indexOf("mouseenter")<0||a)&&f.props.hideOnClick!==!1&&f.state.isVisible?F=!0:Yt(L),L.type==="click"&&(a=!F),F&&!Q&&Ht(L)}}s(ze,"onTrigger");function Ke(L){var $=L.target,F=A().contains($)||T.contains($);if(!(L.type==="mousemove"&&F)){var Q=Tt().concat(T).map(function(j){var Xe,de=j._tippy,Ao=(Xe=de.popperInstance)==null?void 0:Xe.state;return Ao?{popperRect:j.getBoundingClientRect(),popperState:Ao,props:r}:null}).filter(Boolean);I2(Q,L)&&(ie(),Ht(L))}}s(Ke,"onMouseMove");function xt(L){var $=Ct(L)||f.props.trigger.indexOf("click")>=0&&a;if(!$){if(f.props.interactive){f.hideWithInteractivity(L);return}Ht(L)}}s(xt,"onMouseLeave");function it(L){f.props.trigger.indexOf("focusin")<0&&L.target!==A()||f.props.interactive&&L.relatedTarget&&T.contains(L.relatedTarget)||Ht(L)}s(it,"onBlurOrFocusOut");function Ct(L){return Co.isTouch?E()!==L.type.indexOf("touch")>=0:!1}s(Ct,"isEventListenerStopped");function Tr(){wr();var L=f.props,$=L.popperOptions,F=L.placement,Q=L.offset,j=L.getReferenceClientRect,Xe=L.moveTransition,de=x()?ju(T).arrow:null,Ao=j?{getBoundingClientRect:j,contextElement:j.contextElement||A()}:e,Zi={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:s(function($a){var Yn=$a.state;if(x()){var E5=H(),Kl=E5.box;["placement","reference-hidden","escaped"].forEach(function(_a){_a==="placement"?Kl.setAttribute("data-placement",Yn.placement):Yn.attributes.popper["data-popper-"+_a]?Kl.setAttribute("data-"+_a,""):Kl.removeAttribute("data-"+_a)}),Yn.attributes.popper={}}},"fn")},fo=[{name:"offset",options:{offset:Q}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!Xe}},Zi];x()&&de&&fo.push({name:"arrow",options:{element:de,padding:3}}),fo.push.apply(fo,($==null?void 0:$.modifiers)||[]),f.popperInstance=Uu(Ao,T,Object.assign({},$,{placement:F,onFirstUpdate:m,modifiers:fo}))}s(Tr,"createPopperInstance");function wr(){f.popperInstance&&(f.popperInstance.destroy(),f.popperInstance=null)}s(wr,"destroyPopperInstance");function dt(){var L=f.props.appendTo,$,F=A();f.props.interactive&&L===x1||L==="parent"?$=F.parentNode:$=C1(L,[F]),$.contains(T)||$.appendChild(T),f.state.isMounted=!0,Tr()}s(dt,"mount");function Tt(){return tl(T.querySelectorAll("[data-tippy-root]"))}s(Tt,"getNestedPopperTree");function Yt(L){f.clearDelayTimeouts(),L&&z("onTrigger",[f,L]),Pe();var $=D(!0),F=S(),Q=F[0],j=F[1];Co.isTouch&&Q==="hold"&&j&&($=j),$?o=setTimeout(function(){f.show()},$):f.show()}s(Yt,"scheduleShow");function Ht(L){if(f.clearDelayTimeouts(),z("onUntrigger",[f,L]),!f.state.isVisible){qe();return}if(!(f.props.trigger.indexOf("mouseenter")>=0&&f.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(L.type)>=0&&a)){var $=D(!1);$?n=setTimeout(function(){f.state.isVisible&&f.hide()},$):i=requestAnimationFrame(function(){f.hide()})}}s(Ht,"scheduleHide");function te(){f.state.isEnabled=!0}s(te,"enable");function Qt(){f.hide(),f.state.isEnabled=!1}s(Qt,"disable");function Ir(){clearTimeout(o),clearTimeout(n),cancelAnimationFrame(i)}s(Ir,"clearDelayTimeouts");function Lr(L){if(!f.state.isDestroyed){z("onBeforeUpdate",[f,L]),Se();var $=f.props,F=f1(e,Object.assign({},$,u1(L),{ignoreAttributes:!0}));f.props=F,ae(),$.interactiveDebounce!==F.interactiveDebounce&&(ie(),b=l1(Ke,F.interactiveDebounce)),$.triggerTarget&&!F.triggerTarget?Di($.triggerTarget).forEach(function(Q){Q.removeAttribute("aria-expanded")}):F.triggerTarget&&e.removeAttribute("aria-expanded"),ue(),B(),R&&R($,F),f.popperInstance&&(Tr(),Tt().forEach(function(Q){requestAnimationFrame(Q._tippy.popperInstance.forceUpdate)})),z("onAfterUpdate",[f,L])}}s(Lr,"setProps");function mo(L){f.setProps({content:L})}s(mo,"setContent");function hn(){var L=f.state.isVisible,$=f.state.isDestroyed,F=!f.state.isEnabled,Q=Co.isTouch&&!f.props.touch,j=zu(f.props.duration,0,co.duration);if(!(L||$||F||Q)&&!A().hasAttribute("disabled")&&(z("onShow",[f],!1),f.props.onShow(f)!==!1)){if(f.state.isVisible=!0,x()&&(T.style.visibility="visible"),B(),Pe(),f.state.isMounted||(T.style.transition="none"),x()){var Xe=H(),de=Xe.box,Ao=Xe.content;$u([de,Ao],0)}m=s(function(){var fo;if(!(!f.state.isVisible||u)){if(u=!0,T.offsetHeight,T.style.transition=f.props.moveTransition,x()&&f.props.animation){var Jl=H(),$a=Jl.box,Yn=Jl.content;$u([$a,Yn],j),d1([$a,Yn],"visible")}X(),ue(),c1(Zu,f),(fo=f.popperInstance)==null||fo.forceUpdate(),z("onMount",[f]),f.props.animation&&x()&&Fe(j,function(){f.state.isShown=!0,z("onShown",[f])})}},"onFirstUpdate"),dt()}}s(hn,"show");function bn(){var L=!f.state.isVisible,$=f.state.isDestroyed,F=!f.state.isEnabled,Q=zu(f.props.duration,1,co.duration);if(!(L||$||F)&&(z("onHide",[f],!1),f.props.onHide(f)!==!1)){if(f.state.isVisible=!1,f.state.isShown=!1,u=!1,a=!1,x()&&(T.style.visibility="hidden"),ie(),qe(),B(!0),x()){var j=H(),Xe=j.box,de=j.content;f.props.animation&&($u([Xe,de],Q),d1([Xe,de],"hidden"))}X(),ue(),f.props.animation?x()&&Bt(Q,f.unmount):f.unmount()}}s(bn,"hide");function yn(L){I().addEventListener("mousemove",b),c1(el,b),b(L)}s(yn,"hideWithInteractivity");function vn(){f.state.isVisible&&f.hide(),f.state.isMounted&&(wr(),Tt().forEach(function(L){L._tippy.unmount()}),T.parentNode&&T.parentNode.removeChild(T),Zu=Zu.filter(function(L){return L!==f}),f.state.isMounted=!1,z("onHidden",[f]))}s(vn,"unmount");function xn(){f.state.isDestroyed||(f.clearDelayTimeouts(),f.unmount(),Se(),delete e._tippy,f.state.isDestroyed=!0,z("onDestroy",[f]))}s(xn,"destroy")}s(_2,"createTippy");function Ha(e,t){t===void 0&&(t={});var r=co.plugins.concat(t.plugins||[]);B2();var o=Object.assign({},t,{plugins:r}),n=S2(e);if(0)var i,a;var c=n.reduce(function(l,u){var d=u&&_2(u,o);return d&&l.push(d),l},[]);return rl(e)?c[0]:c}s(Ha,"tippy");Ha.defaultProps=co;Ha.setDefaultProps=W2;Ha.currentInput=Co;var Bk=Object.assign({},Ma,{effect:s(function(t){var r=t.state,o={popper:{position:r.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(r.elements.popper.style,o.popper),r.styles=o,r.elements.arrow&&Object.assign(r.elements.arrow.style,o.arrow)},"effect")});Ha.setDefaultProps({render:E1});var k1=Ha;var P1=require("react"),M1=require("react/jsx-runtime"),Ju=(0,P1.forwardRef)(({children:e,className:t,withShadow:r=!0,withBorder:o=!0,...n},i)=>{let a=N("courier-bg-white courier-rounded-lg dark:courier-bg-black",r?"courier-shadow-sm":"",o?"courier-border courier-border-border dark:courier-border-neutral-800":"",t);return(0,M1.jsx)("div",{className:a,...n,ref:i,children:e})});Ju.displayName="Surface";var ol=require("@tiptap/core"),L1=require("@tiptap/react"),R1=require("@tiptap/suggestion");var N1=require("@tiptap/react");var uo={items:({query:e,editor:t})=>{var n,i;let r=((i=(n=t.extensionManager.extensions.find(a=>a.name==="variableSuggestion"))==null?void 0:n.options)==null?void 0:i.variables)||{};return Mr(r).filter(a=>a.toLowerCase().includes(e.toLowerCase()))},char:"{{",allowSpaces:!1,allowedPrefixes:null,startOfLine:!1,decorationTag:"span",decorationClass:"variable-suggestion",command:({editor:e,range:t,props:r})=>{e.chain().focus().deleteRange(t).insertContent([{type:"variable",attrs:{id:r}},{type:"text",text:" "}]).run()},render:()=>{let e=null,t=null,r=null,o=s((i,a)=>{e==null||e.updateProps({...i,selected:a})},"updateComponent"),n=s(i=>{var l,u;if(!r)return!1;let c=((l=uo.items)==null?void 0:l.call(uo,{query:(e==null?void 0:e.props).query||"",editor:(e==null?void 0:e.props).editor}))[i];return c?((u=uo.command)==null||u.call(uo,{editor:r.editor,range:r.range,props:c}),!0):!1},"selectItem");return{onStart:i=>{r=i,e=new N1.ReactRenderer(xa,{props:{...i,selected:0},editor:i.editor}),i.clientRect&&(t=k1(i.editor.options.element,{getReferenceClientRect:()=>{var a;return((a=i.clientRect)==null?void 0:a.call(i))||new DOMRect},appendTo:()=>i.editor.options.element,content:e==null?void 0:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",theme:"variable"}),e!=null&&e.element&&e.element.focus())},onUpdate(i){r=i,e==null||e.updateProps({...i,selected:e.props.selected}),i.clientRect&&(t==null||t.setProps({getReferenceClientRect:()=>{var a;return((a=i.clientRect)==null?void 0:a.call(i))||new DOMRect}}))},onKeyDown(i){var l;if(!e||!r)return!1;let a=(l=uo.items)==null?void 0:l.call(uo,{query:e.props.query||"",editor:e.props.editor}),c=e.props.selected;if(i.event.key==="ArrowUp"){let u=(c-1+a.length)%a.length;return o(r,u),!0}if(i.event.key==="ArrowDown"){let u=(c+1)%a.length;return o(r,u),!0}return i.event.key==="Enter"?(i.event.preventDefault(),n(c)):i.event.key==="Escape"?(r.editor.chain().focus().deleteRange(r.range).run(),!0):!1},onExit(){t==null||t.destroy(),e==null||e.destroy(),r=null}}}};var S1=require("@tiptap/react"),A1=require("lucide-react");var Da=require("react/jsx-runtime"),I1=s(({node:e})=>(0,Da.jsx)(S1.NodeViewWrapper,{className:"courier-inline-block",children:(0,Da.jsxs)("span",{className:"courier-group courier-text-sm courier-variable-node courier-bg-gray-200 courier-pl-2 courier-pr-3 courier-py-[1px] courier-rounded courier-border courier-border-gray-400 hover:courier-bg-[#3B82F6] hover:courier-border-[#3B82F6] hover:courier-text-[#ffffff] courier-flex courier-items-center courier-gap-1",children:[(0,Da.jsx)(A1.Braces,{size:16,className:"courier-text-gray-500 group-hover:courier-stroke-primary"}),e.attrs.id]})}),"VariableView");var Ku=ol.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})}}},parseHTML(){return[{tag:"span[data-variable]",getAttrs:e=>{let t=e.getAttribute("data-id");return t?{id:t}:!1}}]},renderHTML({HTMLAttributes:e,node:t}){return["span",{"data-variable":!0,...e},`{{${t.attrs.id}}}`]},renderText({node:e}){return`{{${e.attrs.id}}}`},addNodeView(){return(0,L1.ReactNodeViewRenderer)(I1)}}),Xu=ol.Extension.create({name:"variableSuggestion",addOptions(){return{HTMLAttributes:{},suggestion:{char:"{{",...uo}}},addProseMirrorPlugins(){return[(0,R1.Suggestion)({editor:this.editor,...this.options.suggestion})]}});var B1=require("@tiptap/core"),H1=require("@tiptap/pm/state"),nl=require("@tiptap/pm/model"),Yu=B1.Extension.create({name:"variablePaste",addProseMirrorPlugins(){return[new H1.Plugin({props:{transformPastedHTML:e=>e.replace(/\{\{([^}]+)\}\}/g,'<span data-variable="true" data-id="$1"></span>'),transformPastedText:(e,t,r)=>{let o=/\{\{([^}]+)\}\}/g;if(!o.test(e))return e;let{schema:n}=r.state,i=[],a=0,c;for(o.lastIndex=0;(c=o.exec(e))!==null;){if(c.index>a){let u=e.substring(a,c.index);u&&i.push(n.text(u))}let l=c[1];n.nodes.variable&&i.push(n.nodes.variable.create({id:l})),a=c.index+c[0].length}if(a<e.length){let l=e.substring(a);l&&i.push(n.text(l))}if(i.length>0){let l=nl.Fragment.from(i),u=new nl.Slice(l,0,0),d=r.state.tr.replaceSelection(u);return r.dispatch(d),e}return e}}})]}});var D1=require("uuid");var Z2=s((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),hs=s((e,t,r,o,n,i)=>{let a=`node-${(0,D1.v4)()}`,l={heading:()=>e.schema.nodes.heading.create({...ne,...o,id:a},i),paragraph:()=>e.schema.nodes.paragraph.create({...ne,...o,id:a},i),text:()=>e.schema.nodes.paragraph.create({...ne,...o,id:a},i),spacer:()=>e.schema.nodes.divider.create({...Km,...o,id:a}),divider:()=>e.schema.nodes.divider.create({...no,...o,id:a}),button:()=>e.schema.nodes.button.create({...Ve,...o,id:a},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...gt,...o,id:a}),image:()=>e.schema.nodes.imageBlock.create({...gt,...o,id:a}),customCode:()=>e.schema.nodes.customCode.create({...Hn,...o,id:a})}[t];if(l)try{let u=e.state.tr,d=l();u.insert(r,d),e.view.dispatch(u),n&&n(d),(t==="text"||t==="paragraph"||t==="heading")&&setTimeout(()=>{let m=Z2(e,a);m!==null&&e.commands.setTextSelection(m+1),e.view.focus()},50);let p=new CustomEvent("node-duplicated",{detail:{newNodeId:a}});document.dispatchEvent(p)}catch(u){console.error("Error creating node:",u)}else try{if(e.schema.nodes[t]){let u=e.state.tr,d=e.schema.nodes[t].create({...o,id:a},i);u.insert(r,d),e.view.dispatch(u),n&&n(d);let p=new CustomEvent("node-duplicated",{detail:{newNodeId:a}});document.dispatchEvent(p)}else console.error(`Cannot duplicate node: type "${t}" not found in schema`)}catch(u){console.error("Error creating fallback node:",u)}return a},"createOrDuplicateNode");var Sr=require("@dnd-kit/core");var q2=[Sr.KeyboardCode.Down,Sr.KeyboardCode.Right,Sr.KeyboardCode.Up,Sr.KeyboardCode.Left],F1=s((e,{context:{active:t,droppableRects:r,droppableContainers:o,collisionRect:n}})=>{var i;if(q2.includes(e.code)){if(e.preventDefault(),!t||!n)return;let a=[];o.getEnabled().forEach(u=>{var m;if(!u||u!=null&&u.disabled)return;let d=r.get(u.id);if(!d)return;let p=u.data.current;if(p){let{type:g,children:b}=p;if(g==="container"&&(b==null?void 0:b.length)>0&&((m=t.data.current)==null?void 0:m.type)!=="container")return}switch(e.code){case Sr.KeyboardCode.Down:n.top<d.top&&a.push(u);break;case Sr.KeyboardCode.Up:n.top>d.top&&a.push(u);break;case Sr.KeyboardCode.Left:n.left>=d.left+d.width&&a.push(u);break;case Sr.KeyboardCode.Right:n.left+n.width<=d.left&&a.push(u);break}});let c=(0,Sr.closestCorners)({active:t,collisionRect:n,droppableRects:r,droppableContainers:a,pointerCoordinates:null}),l=(0,Sr.getFirstCollision)(c,"id");if(l!=null){let u=o.get(l),d=u==null?void 0:u.node.current,p=u==null?void 0:u.rect.current;if(d&&p)return u.id==="placeholder"?{x:p.left+(p.width-n.width)/2,y:p.top+(p.height-n.height)/2}:((i=u.data.current)==null?void 0:i.type)==="container"?{x:p.left+20,y:p.top+74}:{x:p.left,y:p.top}}}},"coordinateGetter");var ln=s(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),ft=s(e=>{let t=ln(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");var We=require("@dnd-kit/core"),V1=require("@dnd-kit/sortable"),il=require("jotai"),yt=require("react");var Fi=s(({items:e,setItems:t,editor:r})=>{let[o,n]=(0,yt.useState)(null),[i,a]=(0,yt.useState)(null),[c,l]=(0,yt.useState)(null),u=(0,yt.useRef)(null),d=(0,yt.useRef)(!1),p=(0,il.useAtomValue)(je),[,m]=(0,il.useAtom)(ge),g=r||p,b=(0,We.useSensors)((0,We.useSensor)(We.MouseSensor,{activationConstraint:{distance:8}}),(0,We.useSensor)(We.TouchSensor,{activationConstraint:{delay:200,tolerance:6}}),(0,We.useSensor)(We.KeyboardSensor,{coordinateGetter:F1})),h=(0,yt.useMemo)(()=>({droppable:{strategy:We.MeasuringStrategy.Always}}),[]),y=(0,yt.useCallback)(()=>{g==null||g.commands.removeDragPlaceholder(),t(M=>({...M,Editor:M.Editor.filter(k=>!k.toString().includes("_temp"))}))},[g==null?void 0:g.commands,t]),P=(0,yt.useCallback)(M=>{var k,S;try{let E=g==null?void 0:g.state.doc;if(!E||M===0)return 0;if(M>=E.childCount)return E.content.size;let x=0;for(let A=0;A<Math.min(M,E.childCount);A++)x+=(k=E.child(A))==null?void 0:k.nodeSize;return x}catch(E){return console.warn("Error calculating document position:",E),(S=g==null?void 0:g.state.doc.content.size)!=null?S:0}},[g]),w=(0,yt.useCallback)(M=>M in e?M:Object.keys(e).find(k=>e[k].includes(M)),[e]),v=(0,yt.useCallback)(M=>{var A;if(c&&c in e)return(0,We.closestCenter)({...M,droppableContainers:M.droppableContainers.filter(I=>I.id in e)});let k=(0,We.pointerWithin)(M),E=(k.length>0?k:(0,We.rectIntersection)(M)).filter(I=>I.id!==void 0),x=(0,We.getFirstCollision)(E,"id");if(x!=null){if(x==="Editor")return u.current=x,[{id:x}];if(x in e){let I=e[x];if(I.length>0){let H=(A=(0,We.closestCenter)({...M,droppableContainers:M.droppableContainers.filter(D=>D.id!==x&&I.includes(D.id))})[0])==null?void 0:A.id;H&&(x=H)}}return u.current=x,[{id:x}]}return d.current&&(u.current=c),u.current?[{id:u.current}]:[]},[c,e]),f=(0,yt.useCallback)(({active:M})=>{l(M.id),(M.id==="text"||M.id==="divider"||M.id==="button")&&a(M.id)},[]),C=(0,yt.useCallback)(({active:M,over:k})=>{if(!k)return;let S=w(k.id);if(!(w(M.id)==="Sidebar"&&S==="Editor"))return;let x=M.rect.current;if(!(x!=null&&x.translated))return;let A=g==null?void 0:g.view.dom.querySelectorAll("[data-node-view-wrapper]");if(!A)return;let I=A.length;for(let H=0;H<A.length;H++){let B=A[H].getBoundingClientRect();if(x.translated.top<B.top+B.height/2){I=H;break}}if(I!==o){let H=`${M.id}_temp_${Date.now()}`;n(I),requestAnimationFrame(()=>{g==null||g.commands.removeDragPlaceholder();let D=P(I);g==null||g.commands.setDragPlaceholder({id:H,type:M.id,pos:D}),t(B=>({...B,Editor:[...B.Editor.filter(z=>!z.toString().includes("_temp")),H]}))})}},[g,w,P,o,t]),T=(0,yt.useCallback)(({active:M,over:k})=>{var A;y();let S=k==null?void 0:k.id;if(!S){t(I=>({...I,Editor:I.Editor.filter(H=>!H.toString().includes("_temp"))})),l(null),a(null);return}if(!g)return;let E=w(S),x=w(M.id);if(x==="Sidebar"&&E==="Editor"&&o!==null){let I=P(o);hs(g,M.id,I,void 0,H=>{m(H)})}else if(x===E){let I=e[x].indexOf(M.id),H=e[E].indexOf(S);if(I!==-1&&H!==-1&&I!==H){t(B=>({...B,[E]:(0,V1.arrayMove)(B[E],I,H)}));let D=(A=g.getJSON())==null?void 0:A.content;if(Array.isArray(D)){let B=[...D],[z]=B.splice(I,1);B.splice(H,0,z),g.view.dispatch(g.view.state.tr.replaceWith(0,g.view.state.doc.content.size,g.state.schema.nodeFromJSON({type:"doc",content:B})))}}}l(null),a(null),n(null)},[t,m,g,y,w,P,o,e]),R=(0,yt.useCallback)(()=>{y(),l(null),a(null)},[y]);return{dndProps:{sensors:b,collisionDetection:v,measuring:h,onDragStart:f,onDragMove:C,onDragEnd:T,onDragCancel:R},activeDragType:i,activeId:c}},"useEditorDnd");var al=require("react");var O1=require("jotai");var sl=s(({setItems:e,rafId:t,editor:r})=>{let o=(0,O1.useAtomValue)(je),n=r||o,i=(0,al.useCallback)(a=>{t.current&&typeof cancelAnimationFrame!="undefined"&&cancelAnimationFrame(t.current);let c=setTimeout(()=>{if(typeof requestAnimationFrame!="undefined")t.current=requestAnimationFrame(()=>{try{let l=a==null?void 0:a.view.dom;if(!l){console.warn("syncEditorItems: Editor DOM element not found");return}let u=l.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(p=>{let m=p.dataset.id;m&&d.push(m)}),e(p=>({Editor:d,Sidebar:p.Sidebar}))}catch(l){console.error("Error syncing editor items:",l),e(u=>({...u}))}});else try{let l=a==null?void 0:a.view.dom;if(!l)return;let u=l.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(p=>{let m=p.dataset.id;m&&d.push(m)}),e(p=>({Editor:d,Sidebar:p.Sidebar}))}catch(l){console.error("Error syncing editor items:",l)}},50);return()=>clearTimeout(c)},[e,t]);return(0,al.useEffect)(()=>{if(!n||typeof n.on!="function")return;let a=s(()=>{n&&i(n)},"updateItems");n.on("update",a),n.on("selectionUpdate",a),n.on("create",a),n.on("transaction",a),n&&!n.isDestroyed&&a();let c=s(l=>{a()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",c),()=>{n==null||n.off("update",a),n==null||n.off("selectionUpdate",a),n==null||n.off("create",a),n==null||n.off("transaction",a),document.removeEventListener("node-duplicated",c),t.current&&typeof cancelAnimationFrame!="undefined"&&(cancelAnimationFrame(t.current),t.current=null)}},[n,i,t]),{syncEditorItems:i}},"useSyncEditorItems");var pr=require("react/jsx-runtime"),ad=[{type:"text",align:"left",content:`
|
|
180
|
+
`).trim()},"extractTextFromSlice"),Rs=df.Extension.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new Ls.Plugin({key:Ah,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!Ih(e))return!1;let c=i.$from.node();if(!(c.type.name==="paragraph"||c.type.name==="heading")||o.content.childCount<=1)return!1;let u=Lh(o);if(!u)return!1;r.preventDefault();let d=n.tr.replaceSelectionWith(n.schema.text(u),!1);return t.dispatch(d),!0}}})]},addStorage(){return{currentChannel:null}}});var pf=require("@tiptap/core"),an=require("@tiptap/pm/state");var On=s((e,t)=>{if(t.length===0)return!1;let r={push:()=>e.view.dom.closest(".courier-push-editor"),sms:()=>e.view.dom.closest(".courier-sms-editor"),inbox:()=>e.view.dom.closest(".courier-inbox-editor")};return t.some(o=>{var n;return(n=r[o])==null?void 0:n.call(r)})},"isInFixedChannel"),ka=s(e=>{let{selection:t}=e.state,{$anchor:r}=t,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),a=r.end(o);return{start:i,end:a,node:n}}o--}return null},"getCurrentElementBounds"),Bs=s(e=>{let{selection:t}=e.state,{$from:r,$to:o}=t;if(t.empty)return!1;let n=r.depth,i=o.depth,a=null,c=null;for(;n>0;){let l=r.node(n);if(l.type.name==="paragraph"||l.type.name==="heading"){a={node:l,depth:n};break}n--}for(;i>0;){let l=o.node(i);if(l.type.name==="paragraph"||l.type.name==="heading"){c={node:l,depth:i};break}i--}return!!(a&&c&&a.node!==c.node)},"isMultiElementSelection"),Hs=new an.PluginKey("fixedChannelSelection"),Ds=pf.Extension.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!On(e,this.options.channels))return!1;let o=ka(e);if(!o)return!1;let{start:n,end:i}=o,{selection:a}=e.state;if(a.from>=n&&a.to<=i)return!1;let c=Math.max(a.from,n),l=Math.min(a.to,i);return r&&t.setSelection(an.TextSelection.create(t.doc,c,l)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!On(e,this.options.channels))return!1;let t=ka(e);if(!t)return!1;let{start:r,end:o}=t;return e.commands.setTextSelection({from:r,to:o}),!0},Backspace:({editor:e})=>{if(!On(e,this.options.channels))return!1;if(Bs(e)){let t=ka(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),a=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:a})}return!0}return!1},Delete:({editor:e})=>{if(!On(e,this.options.channels))return!1;if(Bs(e)){let t=ka(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),a=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:a})}return!0}return!1}}},addProseMirrorPlugins(){return[new an.Plugin({key:Hs,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!On(o,this.options.channels))return!1;if(Bs(o)){let n=ka(o);if(n){let{start:i,end:a}=n,c=Math.max(t,i),l=Math.min(r,a),u=e.state.tr;u.setSelection(an.TextSelection.create(u.doc,c,l)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!On(r,this.options.channels))return!1;let o=e.posAtCoords({left:t.clientX,top:t.clientY});if(o!==null){let n=e.state.doc.resolve(o.pos),i=n.depth;for(;i>0;){let a=n.node(i);if(a.type.name==="paragraph"||a.type.name==="heading"){e.dispatch(e.state.tr.setMeta(Hs,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!On(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&Bs(r)){let n=Hs.getState(e.state);if(n!=null&&n.elementStart&&(n!=null&&n.elementEnd)){let{selection:i}=e.state,a=Math.max(i.from,n.elementStart),c=Math.min(i.to,n.elementEnd),l=e.state.tr;return l.setSelection(an.TextSelection.create(l.doc,a,c)),e.dispatch(l),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(Hs)||t}}})]}});var Cf=require("@tiptap/core");var Ni=require("@tiptap/core"),mf=Ni.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,(0,Ni.mergeAttributes)(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>(0,Ni.textblockTypeInputRule)({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var Dr=require("zod"),ff=Dr.z.object({paddingVertical:Dr.z.number(),paddingHorizontal:Dr.z.number(),backgroundColor:Dr.z.string(),borderWidth:Dr.z.number(),borderRadius:Dr.z.number(),borderColor:Dr.z.string(),textColor:Dr.z.string(),textAlign:Dr.z.enum(["left","center","right","justify"]).default("left"),selected:Dr.z.boolean().default(!1),id:Dr.z.string().optional()}),ne={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"#000000",textColor:"#292929",textAlign:"left",selected:!1};var Fs=require("@tiptap/react"),hf=require("jotai"),bf=require("react");var sn=require("react/jsx-runtime"),gf=s(({paddingVertical:e,paddingHorizontal:t,textAlign:r,backgroundColor:o,borderWidth:n,borderRadius:i,borderColor:a,textColor:c,level:l,type:u})=>{let d=u==="heading"?`h${l}`:"p";return(0,sn.jsx)("div",{className:"courier-w-full node-element",children:(0,sn.jsx)("div",{className:N(!c&&"is-empty"),style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderRadius:`${i}px`,borderColor:a,borderStyle:n>0?"solid":"none",color:c},children:(0,sn.jsx)(Fs.NodeViewContent,{as:d})})})},"TextBlockComponent"),Vs=s(e=>{let t=(0,hf.useSetAtom)(mt),r=(0,bf.useCallback)(()=>{if(!e.editor.isEditable)return;let c=ft(e);c&&t(c)},[e,t]),o=!e.node.content||e.node.content.size===0,n=ln(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null;return(i==null?void 0:i.parent.type.name)==="blockquote"?(0,sn.jsx)(Fs.NodeViewWrapper,{className:N(e.node.attrs.isSelected&&"selected-element"),onClick:r,children:(0,sn.jsx)(gf,{...e.node.attrs,type:e.node.type.name})}):(0,sn.jsx)(lr,{id:e.node.attrs.id,className:N(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:(0,sn.jsx)(gf,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");var yf=require("@hookform/resolvers/zod"),vf=require("react-hook-form");var Y=require("react/jsx-runtime"),xf=s(({element:e,editor:t})=>{let r=(0,vf.useForm)({resolver:(0,yf.zodResolver)(ff),defaultValues:{...ne,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=cr({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?(0,Y.jsxs)(Ye,{...r,children:[(0,Y.jsx)(ur,{type:"text"}),(0,Y.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Y.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,Y.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,Y.jsx)(q,{control:r.control,name:"paddingHorizontal",render:({field:n})=>(0,Y.jsxs)(_,{children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(ce,{startAdornment:(0,Y.jsx)(aa,{}),type:"number",min:0,...n})}),(0,Y.jsx)(G,{})]})}),(0,Y.jsx)(q,{control:r.control,name:"paddingVertical",render:({field:n})=>(0,Y.jsxs)(_,{children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(ce,{startAdornment:(0,Y.jsx)(Pn,{}),type:"number",min:0,...n})}),(0,Y.jsx)(G,{})]})})]}),(0,Y.jsx)(q,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,Y.jsxs)(_,{className:"courier-mb-4",children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(pt,{...n,defaultValue:ne.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,Y.jsx)(G,{})]})}),(0,Y.jsx)(le,{className:"courier-mb-4"}),(0,Y.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Text"}),(0,Y.jsx)(q,{control:r.control,name:"textColor",render:({field:n})=>(0,Y.jsxs)(_,{className:"courier-mb-4",children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(pt,{...n,transparent:!1,defaultValue:ne.textColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,Y.jsx)(G,{})]})}),(0,Y.jsx)(le,{className:"courier-mb-4"}),(0,Y.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,Y.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,Y.jsx)(q,{control:r.control,name:"borderWidth",render:({field:n})=>(0,Y.jsxs)(_,{children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(ce,{startAdornment:(0,Y.jsx)(to,{}),type:"number",min:0,...n})}),(0,Y.jsx)(G,{})]})}),(0,Y.jsx)(q,{control:r.control,name:"borderRadius",render:({field:n})=>(0,Y.jsxs)(_,{children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(ce,{startAdornment:(0,Y.jsx)(kn,{}),type:"number",min:0,...n})}),(0,Y.jsx)(G,{})]})})]}),(0,Y.jsx)(q,{control:r.control,name:"borderColor",render:({field:n})=>(0,Y.jsxs)(_,{className:"courier-mb-4",children:[(0,Y.jsx)(Z,{children:(0,Y.jsx)(pt,{...n,defaultValue:ne.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,Y.jsx)(G,{})]})})]})]}):null},"TextBlockForm");var Tf=require("@tiptap/react");var Tu=mf.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){Ft(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:ne.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):ne.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:ne.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):ne.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:ne.textAlign,parseHTML:t=>t.style.textAlign||ne.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:ne.backgroundColor,parseHTML:t=>t.style.backgroundColor||ne.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:ne.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):ne.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderRadius:{default:ne.borderRadius,parseHTML:t=>t.style.borderRadius?parseInt(t.style.borderRadius):ne.borderRadius,renderHTML:t=>({style:`border-radius: ${t.borderRadius}px`})},borderColor:{default:ne.borderColor,parseHTML:t=>t.style.borderColor||ne.borderColor,renderHTML:t=>({style:`border-color: ${t.borderColor}`})},textColor:{default:ne.textColor,parseHTML:t=>t.style.color||ne.textColor,renderHTML:t=>({style:`color: ${t.textColor}`})},id:{default:()=>null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>({"data-id":t.id})}}},addCommands(){return{setTextAlign:e=>({chain:t})=>t().updateAttributes(this.name,{textAlign:e}).run()}},parseHTML(){return[{tag:'div[data-type="heading"]'}]},renderHTML({node:e,HTMLAttributes:t}){let r=parseInt(e.attrs.level,10);return[`h${this.options.levels.includes(r)?r:this.options.levels[0]}`,(0,Cf.mergeAttributes)(this.options.HTMLAttributes,t),0]},addNodeView(){return(0,Tf.ReactNodeViewRenderer)(Vs)}});var Os=require("@tiptap/core"),Ef=require("@tiptap/react");var wu=require("jotai"),Oe=require("react");var Mt=require("react/jsx-runtime"),Rh=s(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderRadius:n,borderColor:i,isUploading:a,width:c,imageNaturalWidth:l,onFileSelect:u,editor:d})=>{let[p,m]=(0,Oe.useState)(!1),[g,b]=(0,Oe.useState)(!0),h=(0,Oe.useRef)(null),y=(0,Oe.useRef)(null);(0,Oe.useEffect)(()=>{e&&b(!0)},[e]),(0,Oe.useEffect)(()=>{if(e&&!l&&d){let k=new Image;k.onload=()=>{try{if(!d.view||!d.state)return;let S=d.view.state.selection.from;d.chain().setNodeSelection(S).updateAttributes("imageBlock",{imageNaturalWidth:k.naturalWidth}).run()}catch{}},k.src=e}},[e,l,d]);let P=(0,Oe.useCallback)(k=>{var A,I;let S=(I=(A=d==null?void 0:d.view)==null?void 0:A.dom)==null?void 0:I.closest(".ProseMirror"),E=(S==null?void 0:S.clientWidth)||1e3,x=Math.min(100,k/E*100);return Math.round(x)},[d]),w=(0,Oe.useMemo)(()=>P(l),[P,l]),v=(0,Oe.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),k.dataTransfer.types.includes("Files")&&Array.from(k.dataTransfer.items).some(x=>x.type.startsWith("image/"))&&(m(!0),k.dataTransfer.dropEffect="copy")},[]),f=(0,Oe.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),m(!1)},[]),C=(0,Oe.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),k.dataTransfer.types.includes("Files")&&Array.from(k.dataTransfer.items).some(x=>x.type.startsWith("image/"))&&m(!0)},[]),T=(0,Oe.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),m(!1);let E=Array.from(k.dataTransfer.files).find(x=>x.type.startsWith("image/"));E&&u&&u(E)},[u]),R=(0,Oe.useCallback)(k=>{var E;let S=(E=k.target.files)==null?void 0:E[0];S&&u&&u(S)},[u]),M=(0,Oe.useCallback)(()=>{var k;(k=h.current)==null||k.click()},[]);return e?(0,Mt.jsx)("div",{className:"courier-w-full node-element",children:(0,Mt.jsxs)("div",{className:N("courier-relative courier-p-1",(a||g)&&"courier-min-h-[200px] courier-min-w-[300px] courier-bg-gray-100"),children:[(a||g)&&(0,Mt.jsx)("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:(0,Mt.jsx)(Nn,{className:"courier-w-8 courier-h-8"})}),(0,Mt.jsx)("img",{ref:y,src:e,alt:t,className:N("courier-h-auto courier-inline-block courier-w-full",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[r],a&&"courier-opacity-50",(a||g)&&"courier-invisible"),style:{maxWidth:c===w?`${l}px`:`${c}%`,borderWidth:`${o}px`,borderRadius:`${n}px`,borderColor:i,borderStyle:o>0?"solid":"none",display:"block"},loading:"lazy",decoding:"async",draggable:!1,onLoad:k=>{if(b(!1),!l&&d)try{if(!d.view||!d.state)return;setTimeout(()=>{let S=d.view.state.selection.from;d.chain().setNodeSelection(S).updateAttributes("imageBlock",{imageNaturalWidth:k.target.naturalWidth}).run()},100)}catch(S){console.warn("Editor not ready for image update:",S)}},onError:()=>b(!1)})]})}):(0,Mt.jsxs)("div",{className:N("courier-w-full node-element courier-empty-image courier-h-[160px] courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-justify-center courier-cursor-pointer courier-transition-colors courier-flex-1",p&&"courier-border-primary courier-bg-gray-50"),onDragOver:v,onDragEnter:C,onDragLeave:f,onDrop:T,style:{pointerEvents:"all"},children:[a?(0,Mt.jsx)(Nn,{className:"courier-w-8 courier-h-8"}):(0,Mt.jsxs)(Mt.Fragment,{children:[(0,Mt.jsx)("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),(0,Mt.jsx)("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:M,children:"Browse"})]}),(0,Mt.jsx)("input",{ref:h,type:"file",accept:"image/*",className:"courier-hidden",onChange:R})]})},"ImageBlockComponent"),wf=s(e=>{let t=(0,wu.useSetAtom)(mt),r=(0,wu.useSetAtom)(re),{uploadImage:o}=ai(),n=(0,Oe.useCallback)(c=>{var p,m,g;let l=(g=(m=(p=e.editor)==null?void 0:p.view)==null?void 0:m.dom)==null?void 0:g.closest(".ProseMirror"),u=(l==null?void 0:l.clientWidth)||1e3,d=Math.min(100,c/u*100);return Math.round(d)},[e.editor]);(0,Oe.useEffect)(()=>{var l,u;let c=ft(e);if((l=c==null?void 0:c.attrs)!=null&&l.sourcePath&&!((u=c==null?void 0:c.attrs)!=null&&u.imageNaturalWidth)){let d=new Image;d.onload=()=>{let p=c.attrs.width||n(d.naturalWidth),m=ln(e.getPos);m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{width:p,imageNaturalWidth:d.naturalWidth}).run()},d.src=c.attrs.sourcePath}},[e,n]);let i=(0,Oe.useCallback)(()=>{if(!e.editor.isEditable)return;let c=ft(e);c&&(e.editor.commands.blur(),t(c))},[e,t]),a=(0,Oe.useCallback)(async c=>{let l=ln(e.getPos);ft(e)&&l!==null&&e.editor.chain().focus().setNodeSelection(l).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!c.type.startsWith("image/"))throw new Error("Only image files are supported");let d=new FileReader;d.readAsDataURL(c),await new Promise((h,y)=>{d.onload=h,d.onerror=y});let m=(await o({file:c})).url,g=ln(e.getPos);if(ft(e)&&g!==null){let h=new Image;h.src=m,await new Promise(P=>{h.onload=P});let y=n(h.naturalWidth);e.editor.chain().focus().setNodeSelection(g).updateAttributes("imageBlock",{sourcePath:m,isUploading:!1,width:y,imageNaturalWidth:h.naturalWidth}).run()}}catch(d){console.error("Error uploading image:",d);let p="Failed to upload image: "+d;if(d instanceof Error){let b=d.message;b.includes("GraphQL error")?p="Server error: Could not process image":(b.includes("network")||b.includes("fetch"))&&(p="Network error: Could not upload image")}r({message:`Upload failed: ${p}`,toastProps:{duration:6e3,description:`File: ${c.name} (${(c.size/1024/1024).toFixed(2)}MB)`}});let m=ln(e.getPos);ft(e)&&m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return(0,Mt.jsx)(lr,{id:e.node.attrs.id,className:N(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:(0,Mt.jsx)(Rh,{...e.node.attrs,onFileSelect:a,editor:e.editor})})},"ImageBlockView");var gt={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderRadius:0,borderColor:"#000000",isUploading:!1,imageNaturalWidth:0},Ws=Os.Node.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){Ft(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:gt.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:gt.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:gt.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:gt.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:gt.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:gt.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:gt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:gt.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:gt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:gt.isUploading,parseHTML:e=>e.getAttribute("data-is-uploading"),renderHTML:e=>({"data-is-uploading":e.isUploading})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})}}},parseHTML(){return[{tag:'div[data-type="image-block"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Os.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return(0,Ef.ReactNodeViewRenderer)(wf)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...gt,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...gt,sourcePath:t||""}}).run(),setImageBlockAlign:e=>({commands:t})=>t.updateAttributes(this.name,{alignment:e}),setImageBlockWidth:e=>({commands:t})=>t.updateAttributes(this.name,{width:e}),uploadImage:e=>({chain:t})=>{let r=new FileReader;return r.onload=()=>{t().setImageBlock({sourcePath:r.result,isUploading:!0}).run()},r.readAsDataURL(e),!0}}}});var Fr=require("zod"),kf=Fr.z.object({sourcePath:Fr.z.string(),link:Fr.z.string().optional(),alt:Fr.z.string().optional(),alignment:Fr.z.enum(["left","center","right"]),width:Fr.z.number().min(1).max(100),borderWidth:Fr.z.number(),borderRadius:Fr.z.number(),borderColor:Fr.z.string(),isUploading:Fr.z.boolean().optional(),imageNaturalWidth:Fr.z.number()});var Pf=require("@hookform/resolvers/zod"),Mf=require("jotai"),Nf=require("lucide-react"),qt=require("react"),Sf=require("react-hook-form");var O=require("react/jsx-runtime"),Af=s(({element:e,editor:t})=>{var R,M,k,S;let r=(0,qt.useRef)(null),o=(0,qt.useRef)(null),[n,i]=(0,qt.useState)(""),[a,c]=(0,qt.useState)(!1),[l,u]=(0,qt.useState)(((R=e==null?void 0:e.attrs)==null?void 0:R.imageNaturalWidth)||0),[d,p]=(0,qt.useState)(!1),m=(0,Mf.useSetAtom)(re),{uploadImage:g}=ai(),b=(0,Sf.useForm)({resolver:(0,Pf.zodResolver)(kf),defaultValues:{...gt,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:h}=cr({editor:t,element:e,form:b,nodeType:"imageBlock"});(0,qt.useEffect)(()=>{var x;let E=(x=e==null?void 0:e.attrs)==null?void 0:x.sourcePath;if(E&&!l){let A=new Image;A.onload=()=>{u(A.naturalWidth);let I={...b.getValues(),imageNaturalWidth:A.naturalWidth};b.setValue("imageNaturalWidth",A.naturalWidth),h(I)},A.src=E}},[(M=e==null?void 0:e.attrs)==null?void 0:M.sourcePath,l,b,h]);let y=(0,qt.useCallback)(E=>{var D,B;let x=(B=(D=t==null?void 0:t.view)==null?void 0:D.dom)==null?void 0:B.closest(".ProseMirror"),A=(x==null?void 0:x.clientWidth)||1e3;if(E||(E=l),!E)return 0;let I=Math.min(100,E/A*100);return Math.round(I)},[t,l]),P=(0,qt.useCallback)(E=>{var x;E.preventDefault(),(x=r.current)==null||x.click()},[]),w=(0,qt.useCallback)((E,x)=>{let A=y(E.naturalWidth);i(`${A}%`),c(!1),b.setValue("sourcePath",x),b.setValue("imageNaturalWidth",E.naturalWidth),b.setValue("width",A);let I={...b.getValues(),sourcePath:x,width:A,imageNaturalWidth:E.naturalWidth,isUploading:!1};h(I)},[b,h,y]),v=(0,qt.useCallback)(E=>{if(!E)return;let x=new Image;x.onload=()=>{let A=y(x.naturalWidth);b.setValue("sourcePath",E),b.setValue("imageNaturalWidth",x.naturalWidth),b.setValue("width",A);let I={...b.getValues(),sourcePath:E,width:A,imageNaturalWidth:x.naturalWidth};h(I)},x.src=E},[b,h,y]),f=((S=(k=t==null?void 0:t.extensionManager.extensions.find(E=>E.name==="variableSuggestion"))==null?void 0:k.options)==null?void 0:S.variables)||{},C=Mr(f),T=b.getValues().sourcePath;return e?(0,O.jsxs)(Ye,{...b,children:[(0,O.jsx)(ur,{type:"image"}),(0,O.jsxs)("form",{ref:o,onChange:()=>{let E=b.getValues();h(E)},children:[(0,O.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),(0,O.jsxs)(ts,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[(0,O.jsxs)(Yi,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[(0,O.jsx)(mi,{value:"file",className:"courier-flex-1",children:"From file"}),(0,O.jsx)(mi,{value:"url",className:"courier-flex-1",children:"From URL"})]}),(0,O.jsx)(rs,{value:"file",children:(0,O.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,O.jsx)(Ne,{onClick:P,className:"courier-w-full",variant:"outline",type:"button",disabled:d,children:d?(0,O.jsx)(O.Fragment,{children:"Uploading..."}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Nf.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),(0,O.jsx)("input",{ref:r,type:"file",accept:"image/*",className:"courier-hidden",onChange:E=>{var A;let x=(A=E.target.files)==null?void 0:A[0];if(x){p(!0),b.setValue("sourcePath",""),h({...b.getValues(),sourcePath:"",isUploading:!0});let I=new FileReader;I.onload=async()=>{try{let D=(await g({file:x})).url,B=new Image;B.onload=()=>{w(B,D),p(!1)},B.onerror=()=>{m({message:"Upload failed: Failed to load uploaded image",toastProps:{duration:6e3,description:`File: ${x.name} (${(x.size/1024/1024).toFixed(2)}MB)`}}),p(!1),h({...b.getValues(),isUploading:!1})},B.src=D}catch(H){console.error("Error uploading image:",H),m({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${x.name} (${(x.size/1024/1024).toFixed(2)}MB)`}}),p(!1),h({...b.getValues(),isUploading:!1})}},I.onerror=()=>{m({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${x.name} (${(x.size/1024/1024).toFixed(2)}MB)`}}),p(!1),h({...b.getValues(),isUploading:!1})},I.readAsDataURL(x)}}})]})}),(0,O.jsx)(rs,{value:"url",children:(0,O.jsx)(q,{control:b.control,name:"sourcePath",render:({field:E})=>(0,O.jsxs)(_,{className:"courier-mb-3",children:[(0,O.jsx)(Z,{children:(0,O.jsx)(Ot,{as:"Textarea",...E,autoResize:!0,className:"courier-max-h-[88px]",variables:C,onChange:x=>v(x.target.value)})}),(0,O.jsx)(G,{})]})})})]}),(0,O.jsx)(q,{control:b.control,name:"link",render:({field:E})=>(0,O.jsxs)(_,{className:"courier-mb-3",children:[(0,O.jsx)(Z,{children:(0,O.jsx)(Ot,{as:"Textarea",placeholder:"Link",...E,variables:C,onChange:x=>{E.onChange(x),h({...b.getValues(),link:x.target.value})}})}),(0,O.jsx)(G,{})]})}),(0,O.jsx)(q,{control:b.control,name:"alt",render:({field:E})=>(0,O.jsxs)(_,{className:"courier-mb-4",children:[(0,O.jsx)(Z,{children:(0,O.jsx)(Ot,{as:"Textarea",...E,placeholder:"Alt text...",variables:C,onChange:x=>{E.onChange(x),h({...b.getValues(),alt:x.target.value})}})}),(0,O.jsx)(G,{})]})}),(0,O.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,O.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Width"}),(()=>{let E=b.getValues().width,x=b.getValues().imageNaturalWidth,A=y(x),I=E===A,H=I?"original":"fill";return(0,O.jsxs)(rr,{type:"single",value:T?H:"original",onValueChange:D=>{if(!D||D===H)return;let B=D==="fill"?100:y(x);B>0&&(b.setValue("width",B),h({...b.getValues(),width:B}))},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",disabled:!T,children:[(0,O.jsx)(Qe,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),(0,O.jsx)(Qe,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:I||!T,children:"Fill"})]})})(),(0,O.jsx)(q,{control:b.control,name:"width",render:({field:E})=>(0,O.jsxs)(_,{className:"courier-flex-1 courier-mb-3",children:[(0,O.jsx)(Z,{children:(0,O.jsx)(ce,{type:"text",inputMode:"numeric",pattern:"[0-9]*",min:1,max:100,...E,value:b.getValues().sourcePath?a?n:`${E.value}%`:"0%",className:"courier-text-2xl courier-font-normal",disabled:!b.getValues().sourcePath,onFocus:x=>{c(!0),i(x.target.value)},onChange:x=>{i(x.target.value)},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),x.currentTarget.blur())},onBlur:x=>{c(!1);let A=parseFloat(x.target.value.replace("%",""));if(!isNaN(A)){let I=Math.min(100,Math.max(1,A));E.onChange(I),h({...b.getValues(),width:Math.round(I)})}}})}),(0,O.jsx)(G,{})]})}),(0,O.jsx)(q,{control:b.control,name:"width",render:({field:E})=>(0,O.jsxs)(_,{className:"courier-flex-1 courier-mb-3",children:[(0,O.jsx)(Z,{children:(0,O.jsx)(vc,{min:1,max:100,value:[T?E.value:0],disabled:!T,onValueChange:x=>{E.onChange(x[0]),h({...b.getValues(),width:x[0]})}})}),(0,O.jsx)(G,{})]})}),(0,O.jsx)(q,{control:b.control,name:"alignment",render:({field:E})=>(0,O.jsxs)(_,{children:[(0,O.jsx)(Z,{children:(0,O.jsxs)(rr,{disabled:!T,type:"single",value:E.value,onValueChange:x=>{E.onChange(x),h({...b.getValues(),alignment:x})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,O.jsx)(Qe,{size:"sm",value:"left",className:"courier-w-full",children:(0,O.jsx)(Ts,{className:"courier-h-4 courier-w-4"})}),(0,O.jsx)(Qe,{size:"sm",value:"center",className:"courier-w-full",children:(0,O.jsx)(ws,{className:"courier-h-4 courier-w-4"})}),(0,O.jsx)(Qe,{size:"sm",value:"right",className:"courier-w-full",children:(0,O.jsx)(Es,{className:"courier-h-4 courier-w-4"})})]})}),(0,O.jsx)(G,{})]})}),(0,O.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,O.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,O.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,O.jsx)(q,{control:b.control,name:"borderWidth",render:({field:E})=>(0,O.jsxs)(_,{children:[(0,O.jsx)(Z,{children:(0,O.jsx)(ce,{startAdornment:(0,O.jsx)(to,{}),type:"number",disabled:!T,min:0,...E,onChange:x=>{let A=parseInt(x.target.value)||0;E.onChange(A),h({...b.getValues(),borderWidth:A})}})}),(0,O.jsx)(G,{})]})}),(0,O.jsx)(q,{control:b.control,name:"borderRadius",render:({field:E})=>(0,O.jsxs)(_,{children:[(0,O.jsx)(Z,{children:(0,O.jsx)(ce,{startAdornment:(0,O.jsx)(kn,{}),type:"number",disabled:!T,min:0,...E,onChange:x=>{let A=parseInt(x.target.value)||0;E.onChange(A),h({...b.getValues(),borderRadius:A})}})}),(0,O.jsx)(G,{})]})})]}),(0,O.jsx)(q,{control:b.control,name:"borderColor",render:({field:E})=>(0,O.jsxs)(_,{className:"courier-mb-4",children:[(0,O.jsx)(Z,{children:(0,O.jsx)(pt,{...E,disabled:!T,defaultValue:gt.borderColor,onChange:x=>{E.onChange(x),h({...b.getValues(),[E.name]:x})}})}),(0,O.jsx)(G,{})]})})]})]}):null},"ImageBlockForm");var Pa=require("@tiptap/core"),If=Me(require("@tiptap/extension-link"),1),Si=require("@tiptap/pm/state"),Eu=If.default.extend({inclusive:!0,addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),hasVariables:{default:!1},originalHref:{default:null}}},parseHTML(){return[{tag:'a[href]:not([data-type="button"]):not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:e}){if(e.hasVariables&&e.originalHref)e.href=e.originalHref,delete e.hasVariables,delete e.originalHref;else if(e.href){let t=e.href;t.includes("__VAR_")&&(e.href=t.replace(/__VAR_([^_]+)__/g,"{{$1}}"))}return["a",(0,Pa.mergeAttributes)(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new Si.Plugin({props:{handleClick:(r,o,n)=>{if(n.button!==0)return!1;let{state:i}=r,{doc:a}=i,c=a.resolve(o),l=c.marks().find(u=>u.type.name==="link");if(l||o>0&&(l=a.resolve(o-1).marks().find(d=>d.type.name==="link")),l||o<a.content.size&&(l=a.resolve(o+1).marks().find(d=>d.type.name==="link")),l){let u=(0,Pa.getMarkRange)(c,l.type);return u?(r.dispatch(i.tr.setSelection(Si.TextSelection.create(a,u.from,u.to))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:u.from,to:u.to,href:l.attrs.originalHref||l.attrs.href})),!0):(r.dispatch(i.tr.setSelection(Si.TextSelection.create(a,o,o+1))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:o,to:o+1,href:l.attrs.originalHref||l.attrs.href})),!0)}return!1}}}),new Si.Plugin({appendTransaction(r,o,n){if(!r.some(c=>c.docChanged))return null;let i=n.tr,a=!1;return n.doc.descendants((c,l)=>(c.marks.forEach(u=>{if(u.type.name==="link"&&u.attrs.href){let d=u.attrs.href;if(d.includes("__VAR_")){let p=d.replace(/__VAR_([^_]+)__/g,"{{$1}}");if(p!==d){let m=(0,Pa.getMarkRange)(n.doc.resolve(l),u.type);m&&(i.removeMark(m.from,m.to,u.type),i.addMark(m.from,m.to,u.type.create({...u.attrs,href:p,hasVariables:!0,originalHref:p})),a=!0)}}}}),!0)),a?i:null}})]}});var Lf=require("@hookform/resolvers/zod"),Rf=require("jotai"),zs=require("react"),Bf=require("react-hook-form"),Us=require("zod");var io=require("react/jsx-runtime"),Bh=Us.z.object({href:Us.z.string(),openInNewTab:Us.z.boolean().default(!1)}),Hf=s(({editor:e,mark:t,pendingLink:r})=>{var u,d;let o=(0,Rf.useSetAtom)(ms),n=(0,zs.useRef)(null),i=(0,Bf.useForm)({resolver:(0,Lf.zodResolver)(Bh),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1}});(0,zs.useEffect)(()=>{i.reset({href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1})},[t,i]);let a=((d=(u=e==null?void 0:e.extensionManager.extensions.find(p=>p.name==="variableSuggestion"))==null?void 0:u.options)==null?void 0:d.variables)||{},c=Mr(a),l=s(async p=>{let m=p.href.trim();if(!m){r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),e==null||e.commands.unsetLink(),o(null);return}r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),await(e==null?void 0:e.chain().focus().unsetLink().setTextSelection({from:(r==null?void 0:r.from)||0,to:(r==null?void 0:r.to)||0}).setLink({href:m,target:p.openInNewTab?"_blank":null}).run()),e==null||e.commands.setTextSelection((r==null?void 0:r.to)||0),o(null)},"updateLink");return(0,io.jsxs)(Ye,{...i,children:[(0,io.jsx)("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),(0,io.jsx)("div",{className:"courier-space-y-4",children:(0,io.jsx)(q,{control:i.control,name:"href",render:({field:p})=>(0,io.jsxs)(_,{children:[(0,io.jsx)(Br,{children:"URL"}),(0,io.jsx)(Z,{children:(0,io.jsx)(Ot,{as:"Textarea",autoResize:!0,...p,variables:c,ref:m=>{typeof p.ref=="function"&&p.ref(m),n.current=m},onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),m.stopPropagation(),i.handleSubmit(l)())},onBlur:()=>{p.onBlur(),i.handleSubmit(l)()}})}),(0,io.jsx)(G,{})]})})})]})},"LinkForm");var $s=require("@tiptap/core"),Df=$s.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",(0,$s.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var qs=require("@tiptap/react"),Ai=require("prosemirror-state");var Oo={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Zs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Hh=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Dh=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(tt=0;tt<10;tt++)Oo[48+tt]=Oo[96+tt]=String(tt);var tt;for(tt=1;tt<=24;tt++)Oo[tt+111]="F"+tt;var tt;for(tt=65;tt<=90;tt++)Oo[tt]=String.fromCharCode(tt+32),Zs[tt]=String.fromCharCode(tt);var tt;for(_s in Oo)Zs.hasOwnProperty(_s)||(Zs[_s]=Oo[_s]);var _s;function Ff(e){var t=Hh&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Dh&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?Zs:Oo)[e.keyCode]||e.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}s(Ff,"keyName");var Vf=require("prosemirror-state");var Fh=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Vh(e){let t=e.split(/-(?!$)/),r=t[t.length-1];r=="Space"&&(r=" ");let o,n,i,a;for(let c=0;c<t.length-1;c++){let l=t[c];if(/^(cmd|meta|m)$/i.test(l))a=!0;else if(/^a(lt)?$/i.test(l))o=!0;else if(/^(c|ctrl|control)$/i.test(l))n=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))Fh?a=!0:n=!0;else throw new Error("Unrecognized modifier name: "+l)}return o&&(r="Alt-"+r),n&&(r="Ctrl-"+r),a&&(r="Meta-"+r),i&&(r="Shift-"+r),r}s(Vh,"normalizeKeyName");function Oh(e){let t=Object.create(null);for(let r in e)t[Vh(r)]=e[r];return t}s(Oh,"normalize");function ku(e,t,r=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),r&&t.shiftKey&&(e="Shift-"+e),e}s(ku,"modifiers");function Of(e){return new Vf.Plugin({props:{handleKeyDown:Wh(e)}})}s(Of,"keymap");function Wh(e){let t=Oh(e);return function(r,o){let n=Ff(o),i,a=t[ku(n,o)];if(a&&a(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let c=t[ku(n,o,!1)];if(c&&c(r.state,r.dispatch,r))return!0}if((o.shiftKey||o.altKey||o.metaKey||n.charCodeAt(0)>127)&&(i=Oo[o.keyCode])&&i!=n){let c=t[ku(i,o)];if(c&&c(r.state,r.dispatch,r))return!0}}return!1}}s(Wh,"keydownHandler");var Wf=require("uuid");var Pu=Df.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){Ft(this.editor,this.name)},onTransaction(){let e=this.editor.state.tr,t=!1;this.editor.state.doc.descendants((r,o)=>{if(r.type.name===this.name&&!r.attrs.id){let n=`node-${(0,Wf.v4)()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:ne.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):ne.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:ne.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):ne.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:ne.textAlign,parseHTML:e=>e.style.textAlign||ne.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:ne.backgroundColor,parseHTML:e=>e.style.backgroundColor||ne.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:ne.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):ne.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:ne.borderRadius,parseHTML:e=>e.style.borderRadius?parseInt(e.style.borderRadius):ne.borderRadius,renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:ne.borderColor,parseHTML:e=>e.style.borderColor||ne.borderColor,renderHTML:e=>({"data-border-color":e.borderColor})},textColor:{default:ne.textColor,parseHTML:e=>e.style.color||ne.textColor,renderHTML:e=>({"data-text-color":e.textColor})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})}}},parseHTML(){return[{tag:'div[data-type="paragraph"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,qs.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return(0,qs.ReactNodeViewRenderer)(Vs)},addProseMirrorPlugins(){return[Of({"Mod-a":({selection:e,tr:t})=>{document.execCommand("selectAll");let{$from:r}=e,o=r.depth,n=null;for(;o>0;){let i=r.node(o);if(i.type.name==="paragraph"||i.type.name==="heading"){n=i;break}o--}if(n){let i=r.start(o),a=r.end(o);if(e.from!==i||e.to!==a)return t.setSelection(Ai.TextSelection.create(t.doc,i,a)),!0}return!1}}),new Ai.Plugin({key:new Ai.PluginKey("preventElementDeletion"),props:{handleKeyDown:(e,t)=>{let r=t.key==="Delete"||t.key==="Backspace"||t.keyCode===8||t.keyCode===46||t.code==="Delete"||t.code==="Backspace",o=t.metaKey||t.ctrlKey||t.altKey;if(r){let{state:n}=e,{selection:i}=n,{$anchor:a}=i,c=a.depth,l=null;for(;c>0;){let u=a.node(c);if(u.type.name==="paragraph"||u.type.name==="heading"){l=u;break}c--}if(l){let u=l.textContent,d=a.parentOffset===0,p=a.parentOffset===u.length,m=u.length===0,g=t.key==="Delete"||t.keyCode===46||t.code==="Delete";if(o||m||!g&&d||g&&p)return t.preventDefault(),t.stopPropagation(),!0}}return!1}}})]},addKeyboardShortcuts(){let e=s((t,r=!0)=>{let{empty:o,$anchor:n,$head:i}=t.state.selection,a=n.depth,c=null;for(;a>0;){let d=n.node(a);if(d.type.name==="paragraph"||d.type.name==="heading"){c=d;break}a--}if(!c)return!1;let l=r?n.pos===i.pos&&n.parentOffset===0:n.pos===i.pos&&n.parentOffset===c.textContent.length,u=c.textContent.length===0;return l||u?!0:o?!1:(t.commands.command(({tr:d,dispatch:p})=>p?(d.insertText("",t.state.selection.from,t.state.selection.to),!0):!1),!0)},"handleDeletion");return{Enter:({editor:t})=>{if(t.view.dom.querySelector(".variable-suggestion")||t.view.state.selection.$from.node().type.spec.code)return!1;let{state:o,dispatch:n}=t.view,{tr:i}=o;return i.replaceSelectionWith(o.schema.nodes.hardBreak.create()).scrollIntoView(),n(i),!0},"Mod-a":({editor:t})=>{let{$from:r}=t.state.selection,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),a=r.end(o);return t.commands.setTextSelection({from:i,to:a}),!0}o--}return!1},Backspace:({editor:t})=>e(t,!0),Delete:({editor:t})=>e(t,!1),Tab:()=>!0,"Shift-Tab":()=>!0}},addCommands(){return{setTextAlign:e=>({chain:t})=>t().updateAttributes(this.name,{textAlign:e}).run()}}});var Uf=require("@tiptap/core"),js=require("@tiptap/pm/state"),Uh=new js.PluginKey("selection"),Mu=Uf.Extension.create({name:"selection",addOptions(){return{HTMLAttributes:{},setSelectedNode:()=>{}}},addGlobalAttributes(){return[{types:["paragraph","heading","button","spacer","divider","imageBlock","blockquote","customCode"],attributes:{isSelected:{default:!1,parseHTML:()=>!1,renderHTML:e=>e.isSelected?{class:"selected-element"}:{}}}}]},addCommands(){return{updateSelectionState:e=>({tr:t,dispatch:r})=>(r&&t.doc.descendants((o,n)=>{var i;return o.type.name!=="text"&&((i=o.type.spec.attrs)==null?void 0:i.isSelected)!==void 0&&(o===e?t.setNodeAttribute(n,"isSelected",!0):t.setNodeAttribute(n,"isSelected",!1)),!0}),!0)}},addProseMirrorPlugins(){return[new js.Plugin({key:Uh,props:{handleClick:(e,t,r)=>{var c;let{state:o}=e;if(!this.editor.isEditable)return!1;try{let l=window.getSelection();if(l&&l.rangeCount>0){let d=l.getRangeAt(0).startContainer.parentElement;if(d&&(["P","H1","H2","H3","BLOCKQUOTE"].includes(d.tagName)||["P","H1","H2","H3","BLOCKQUOTE"].some(p=>d.closest(p)))){let p=e.posAtDOM(d,0),m=o.doc.resolve(p);if(((c=m.node(1))==null?void 0:c.type.name)==="blockquote")return this.options.setSelectedNode(m.node(1)),this.editor.commands.updateSelectionState(m.node(1)),!0;let g=m.node();if(g&&["paragraph","heading","blockquote"].includes(g.type.name))return this.options.setSelectedNode(g),this.editor.commands.updateSelectionState(g),!0}}}catch(l){console.error("Error handling click:",l)}let n=r.target,i=e.posAtDOM(n,0),a=o.doc.resolve(i).node();return a&&["paragraph","heading","blockquote"].includes(a.type.name)?(this.options.setSelectedNode(a),this.editor.commands.updateSelectionState(a),!0):!1}}})]}});var _e="top",lt="bottom",rt="right",Ge="left",Gs="auto",cn=[_e,lt,rt,Ge],Wo="start",Wn="end",zf="clippingParents",Js="viewport",Ii="popper",$f="reference",Nu=cn.reduce(function(e,t){return e.concat([t+"-"+Wo,t+"-"+Wn])},[]),Ks=[].concat(cn,[Gs]).reduce(function(e,t){return e.concat([t,t+"-"+Wo,t+"-"+Wn])},[]),zh="beforeRead",$h="read",_h="afterRead",Zh="beforeMain",qh="main",jh="afterMain",Gh="beforeWrite",Jh="write",Kh="afterWrite",_f=[zh,$h,_h,Zh,qh,jh,Gh,Jh,Kh];function ht(e){return e?(e.nodeName||"").toLowerCase():null}s(ht,"getNodeName");function He(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}s(He,"getWindow");function Vr(e){var t=He(e).Element;return e instanceof t||e instanceof Element}s(Vr,"isElement");function ct(e){var t=He(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}s(ct,"isHTMLElement");function Li(e){if(typeof ShadowRoot=="undefined")return!1;var t=He(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}s(Li,"isShadowRoot");function Xh(e){var t=e.state;Object.keys(t.elements).forEach(function(r){var o=t.styles[r]||{},n=t.attributes[r]||{},i=t.elements[r];!ct(i)||!ht(i)||(Object.assign(i.style,o),Object.keys(n).forEach(function(a){var c=n[a];c===!1?i.removeAttribute(a):i.setAttribute(a,c===!0?"":c)}))})}s(Xh,"applyStyles");function Yh(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow),function(){Object.keys(t.elements).forEach(function(o){var n=t.elements[o],i=t.attributes[o]||{},a=Object.keys(t.styles.hasOwnProperty(o)?t.styles[o]:r[o]),c=a.reduce(function(l,u){return l[u]="",l},{});!ct(n)||!ht(n)||(Object.assign(n.style,c),Object.keys(i).forEach(function(l){n.removeAttribute(l)}))})}}s(Yh,"effect");var Ma={name:"applyStyles",enabled:!0,phase:"write",fn:Xh,effect:Yh,requires:["computeStyles"]};function bt(e){return e.split("-")[0]}s(bt,"getBasePlacement");var ao=Math.max,Un=Math.min,Uo=Math.round;function Ri(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}s(Ri,"getUAString");function Na(){return!/^((?!chrome|android).)*safari/i.test(Ri())}s(Na,"isLayoutViewport");function Or(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!1);var o=e.getBoundingClientRect(),n=1,i=1;t&&ct(e)&&(n=e.offsetWidth>0&&Uo(o.width)/e.offsetWidth||1,i=e.offsetHeight>0&&Uo(o.height)/e.offsetHeight||1);var a=Vr(e)?He(e):window,c=a.visualViewport,l=!Na()&&r,u=(o.left+(l&&c?c.offsetLeft:0))/n,d=(o.top+(l&&c?c.offsetTop:0))/i,p=o.width/n,m=o.height/i;return{width:p,height:m,top:d,right:u+p,bottom:d+m,left:u,x:u,y:d}}s(Or,"getBoundingClientRect");function zn(e){var t=Or(e),r=e.offsetWidth,o=e.offsetHeight;return Math.abs(t.width-r)<=1&&(r=t.width),Math.abs(t.height-o)<=1&&(o=t.height),{x:e.offsetLeft,y:e.offsetTop,width:r,height:o}}s(zn,"getLayoutRect");function Sa(e,t){var r=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(r&&Li(r)){var o=t;do{if(o&&e.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}s(Sa,"contains");function jt(e){return He(e).getComputedStyle(e)}s(jt,"getComputedStyle");function Su(e){return["table","td","th"].indexOf(ht(e))>=0}s(Su,"isTableElement");function Nt(e){return((Vr(e)?e.ownerDocument:e.document)||window.document).documentElement}s(Nt,"getDocumentElement");function zo(e){return ht(e)==="html"?e:e.assignedSlot||e.parentNode||(Li(e)?e.host:null)||Nt(e)}s(zo,"getParentNode");function Zf(e){return!ct(e)||jt(e).position==="fixed"?null:e.offsetParent}s(Zf,"getTrueOffsetParent");function Qh(e){var t=/firefox/i.test(Ri()),r=/Trident/i.test(Ri());if(r&&ct(e)){var o=jt(e);if(o.position==="fixed")return null}var n=zo(e);for(Li(n)&&(n=n.host);ct(n)&&["html","body"].indexOf(ht(n))<0;){var i=jt(n);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||t&&i.willChange==="filter"||t&&i.filter&&i.filter!=="none")return n;n=n.parentNode}return null}s(Qh,"getContainingBlock");function so(e){for(var t=He(e),r=Zf(e);r&&Su(r)&&jt(r).position==="static";)r=Zf(r);return r&&(ht(r)==="html"||ht(r)==="body"&&jt(r).position==="static")?t:r||Qh(e)||t}s(so,"getOffsetParent");function $n(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}s($n,"getMainAxisFromPlacement");function _n(e,t,r){return ao(e,Un(t,r))}s(_n,"within");function qf(e,t,r){var o=_n(e,t,r);return o>r?r:o}s(qf,"withinMaxClamp");function Aa(){return{top:0,right:0,bottom:0,left:0}}s(Aa,"getFreshSideObject");function Ia(e){return Object.assign({},Aa(),e)}s(Ia,"mergePaddingObject");function La(e,t){return t.reduce(function(r,o){return r[o]=e,r},{})}s(La,"expandToHashMap");var e2=s(function(t,r){return t=typeof t=="function"?t(Object.assign({},r.rects,{placement:r.placement})):t,Ia(typeof t!="number"?t:La(t,cn))},"toPaddingObject");function t2(e){var t,r=e.state,o=e.name,n=e.options,i=r.elements.arrow,a=r.modifiersData.popperOffsets,c=bt(r.placement),l=$n(c),u=[Ge,rt].indexOf(c)>=0,d=u?"height":"width";if(!(!i||!a)){var p=e2(n.padding,r),m=zn(i),g=l==="y"?_e:Ge,b=l==="y"?lt:rt,h=r.rects.reference[d]+r.rects.reference[l]-a[l]-r.rects.popper[d],y=a[l]-r.rects.reference[l],P=so(i),w=P?l==="y"?P.clientHeight||0:P.clientWidth||0:0,v=h/2-y/2,f=p[g],C=w-m[d]-p[b],T=w/2-m[d]/2+v,R=_n(f,T,C),M=l;r.modifiersData[o]=(t={},t[M]=R,t.centerOffset=R-T,t)}}s(t2,"arrow");function r2(e){var t=e.state,r=e.options,o=r.element,n=o===void 0?"[data-popper-arrow]":o;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||Sa(t.elements.popper,n)&&(t.elements.arrow=n))}s(r2,"effect");var jf={name:"arrow",enabled:!0,phase:"main",fn:t2,effect:r2,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Wr(e){return e.split("-")[1]}s(Wr,"getVariation");var o2={top:"auto",right:"auto",bottom:"auto",left:"auto"};function n2(e,t){var r=e.x,o=e.y,n=t.devicePixelRatio||1;return{x:Uo(r*n)/n||0,y:Uo(o*n)/n||0}}s(n2,"roundOffsetsByDPR");function Gf(e){var t,r=e.popper,o=e.popperRect,n=e.placement,i=e.variation,a=e.offsets,c=e.position,l=e.gpuAcceleration,u=e.adaptive,d=e.roundOffsets,p=e.isFixed,m=a.x,g=m===void 0?0:m,b=a.y,h=b===void 0?0:b,y=typeof d=="function"?d({x:g,y:h}):{x:g,y:h};g=y.x,h=y.y;var P=a.hasOwnProperty("x"),w=a.hasOwnProperty("y"),v=Ge,f=_e,C=window;if(u){var T=so(r),R="clientHeight",M="clientWidth";if(T===He(r)&&(T=Nt(r),jt(T).position!=="static"&&c==="absolute"&&(R="scrollHeight",M="scrollWidth")),T=T,n===_e||(n===Ge||n===rt)&&i===Wn){f=lt;var k=p&&T===C&&C.visualViewport?C.visualViewport.height:T[R];h-=k-o.height,h*=l?1:-1}if(n===Ge||(n===_e||n===lt)&&i===Wn){v=rt;var S=p&&T===C&&C.visualViewport?C.visualViewport.width:T[M];g-=S-o.width,g*=l?1:-1}}var E=Object.assign({position:c},u&&o2),x=d===!0?n2({x:g,y:h},He(r)):{x:g,y:h};if(g=x.x,h=x.y,l){var A;return Object.assign({},E,(A={},A[f]=w?"0":"",A[v]=P?"0":"",A.transform=(C.devicePixelRatio||1)<=1?"translate("+g+"px, "+h+"px)":"translate3d("+g+"px, "+h+"px, 0)",A))}return Object.assign({},E,(t={},t[f]=w?h+"px":"",t[v]=P?g+"px":"",t.transform="",t))}s(Gf,"mapToStyles");function i2(e){var t=e.state,r=e.options,o=r.gpuAcceleration,n=o===void 0?!0:o,i=r.adaptive,a=i===void 0?!0:i,c=r.roundOffsets,l=c===void 0?!0:c,u={placement:bt(t.placement),variation:Wr(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Gf(Object.assign({},u,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:a,roundOffsets:l})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,Gf(Object.assign({},u,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}s(i2,"computeStyles");var Jf={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:i2,data:{}};var Xs={passive:!0};function a2(e){var t=e.state,r=e.instance,o=e.options,n=o.scroll,i=n===void 0?!0:n,a=o.resize,c=a===void 0?!0:a,l=He(t.elements.popper),u=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&u.forEach(function(d){d.addEventListener("scroll",r.update,Xs)}),c&&l.addEventListener("resize",r.update,Xs),function(){i&&u.forEach(function(d){d.removeEventListener("scroll",r.update,Xs)}),c&&l.removeEventListener("resize",r.update,Xs)}}s(a2,"effect");var Kf={name:"eventListeners",enabled:!0,phase:"write",fn:s(function(){},"fn"),effect:a2,data:{}};var s2={left:"right",right:"left",bottom:"top",top:"bottom"};function Bi(e){return e.replace(/left|right|bottom|top/g,function(t){return s2[t]})}s(Bi,"getOppositePlacement");var l2={start:"end",end:"start"};function Ys(e){return e.replace(/start|end/g,function(t){return l2[t]})}s(Ys,"getOppositeVariationPlacement");function Zn(e){var t=He(e),r=t.pageXOffset,o=t.pageYOffset;return{scrollLeft:r,scrollTop:o}}s(Zn,"getWindowScroll");function qn(e){return Or(Nt(e)).left+Zn(e).scrollLeft}s(qn,"getWindowScrollBarX");function Au(e,t){var r=He(e),o=Nt(e),n=r.visualViewport,i=o.clientWidth,a=o.clientHeight,c=0,l=0;if(n){i=n.width,a=n.height;var u=Na();(u||!u&&t==="fixed")&&(c=n.offsetLeft,l=n.offsetTop)}return{width:i,height:a,x:c+qn(e),y:l}}s(Au,"getViewportRect");function Iu(e){var t,r=Nt(e),o=Zn(e),n=(t=e.ownerDocument)==null?void 0:t.body,i=ao(r.scrollWidth,r.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),a=ao(r.scrollHeight,r.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),c=-o.scrollLeft+qn(e),l=-o.scrollTop;return jt(n||r).direction==="rtl"&&(c+=ao(r.clientWidth,n?n.clientWidth:0)-i),{width:i,height:a,x:c,y:l}}s(Iu,"getDocumentRect");function jn(e){var t=jt(e),r=t.overflow,o=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(r+n+o)}s(jn,"isScrollParent");function Qs(e){return["html","body","#document"].indexOf(ht(e))>=0?e.ownerDocument.body:ct(e)&&jn(e)?e:Qs(zo(e))}s(Qs,"getScrollParent");function un(e,t){var r;t===void 0&&(t=[]);var o=Qs(e),n=o===((r=e.ownerDocument)==null?void 0:r.body),i=He(o),a=n?[i].concat(i.visualViewport||[],jn(o)?o:[]):o,c=t.concat(a);return n?c:c.concat(un(zo(a)))}s(un,"listScrollParents");function Hi(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}s(Hi,"rectToClientRect");function c2(e,t){var r=Or(e,!1,t==="fixed");return r.top=r.top+e.clientTop,r.left=r.left+e.clientLeft,r.bottom=r.top+e.clientHeight,r.right=r.left+e.clientWidth,r.width=e.clientWidth,r.height=e.clientHeight,r.x=r.left,r.y=r.top,r}s(c2,"getInnerBoundingClientRect");function Xf(e,t,r){return t===Js?Hi(Au(e,r)):Vr(t)?c2(t,r):Hi(Iu(Nt(e)))}s(Xf,"getClientRectFromMixedType");function u2(e){var t=un(zo(e)),r=["absolute","fixed"].indexOf(jt(e).position)>=0,o=r&&ct(e)?so(e):e;return Vr(o)?t.filter(function(n){return Vr(n)&&Sa(n,o)&&ht(n)!=="body"}):[]}s(u2,"getClippingParents");function Lu(e,t,r,o){var n=t==="clippingParents"?u2(e):[].concat(t),i=[].concat(n,[r]),a=i[0],c=i.reduce(function(l,u){var d=Xf(e,u,o);return l.top=ao(d.top,l.top),l.right=Un(d.right,l.right),l.bottom=Un(d.bottom,l.bottom),l.left=ao(d.left,l.left),l},Xf(e,a,o));return c.width=c.right-c.left,c.height=c.bottom-c.top,c.x=c.left,c.y=c.top,c}s(Lu,"getClippingRect");function Ra(e){var t=e.reference,r=e.element,o=e.placement,n=o?bt(o):null,i=o?Wr(o):null,a=t.x+t.width/2-r.width/2,c=t.y+t.height/2-r.height/2,l;switch(n){case _e:l={x:a,y:t.y-r.height};break;case lt:l={x:a,y:t.y+t.height};break;case rt:l={x:t.x+t.width,y:c};break;case Ge:l={x:t.x-r.width,y:c};break;default:l={x:t.x,y:t.y}}var u=n?$n(n):null;if(u!=null){var d=u==="y"?"height":"width";switch(i){case Wo:l[u]=l[u]-(t[d]/2-r[d]/2);break;case Wn:l[u]=l[u]+(t[d]/2-r[d]/2);break;default:}}return l}s(Ra,"computeOffsets");function lo(e,t){t===void 0&&(t={});var r=t,o=r.placement,n=o===void 0?e.placement:o,i=r.strategy,a=i===void 0?e.strategy:i,c=r.boundary,l=c===void 0?zf:c,u=r.rootBoundary,d=u===void 0?Js:u,p=r.elementContext,m=p===void 0?Ii:p,g=r.altBoundary,b=g===void 0?!1:g,h=r.padding,y=h===void 0?0:h,P=Ia(typeof y!="number"?y:La(y,cn)),w=m===Ii?$f:Ii,v=e.rects.popper,f=e.elements[b?w:m],C=Lu(Vr(f)?f:f.contextElement||Nt(e.elements.popper),l,d,a),T=Or(e.elements.reference),R=Ra({reference:T,element:v,strategy:"absolute",placement:n}),M=Hi(Object.assign({},v,R)),k=m===Ii?M:T,S={top:C.top-k.top+P.top,bottom:k.bottom-C.bottom+P.bottom,left:C.left-k.left+P.left,right:k.right-C.right+P.right},E=e.modifiersData.offset;if(m===Ii&&E){var x=E[n];Object.keys(S).forEach(function(A){var I=[rt,lt].indexOf(A)>=0?1:-1,H=[_e,lt].indexOf(A)>=0?"y":"x";S[A]+=x[H]*I})}return S}s(lo,"detectOverflow");function Ru(e,t){t===void 0&&(t={});var r=t,o=r.placement,n=r.boundary,i=r.rootBoundary,a=r.padding,c=r.flipVariations,l=r.allowedAutoPlacements,u=l===void 0?Ks:l,d=Wr(o),p=d?c?Nu:Nu.filter(function(b){return Wr(b)===d}):cn,m=p.filter(function(b){return u.indexOf(b)>=0});m.length===0&&(m=p);var g=m.reduce(function(b,h){return b[h]=lo(e,{placement:h,boundary:n,rootBoundary:i,padding:a})[bt(h)],b},{});return Object.keys(g).sort(function(b,h){return g[b]-g[h]})}s(Ru,"computeAutoPlacement");function d2(e){if(bt(e)===Gs)return[];var t=Bi(e);return[Ys(e),t,Ys(t)]}s(d2,"getExpandedFallbackPlacements");function p2(e){var t=e.state,r=e.options,o=e.name;if(!t.modifiersData[o]._skip){for(var n=r.mainAxis,i=n===void 0?!0:n,a=r.altAxis,c=a===void 0?!0:a,l=r.fallbackPlacements,u=r.padding,d=r.boundary,p=r.rootBoundary,m=r.altBoundary,g=r.flipVariations,b=g===void 0?!0:g,h=r.allowedAutoPlacements,y=t.options.placement,P=bt(y),w=P===y,v=l||(w||!b?[Bi(y)]:d2(y)),f=[y].concat(v).reduce(function(Ce,Pe){return Ce.concat(bt(Pe)===Gs?Ru(t,{placement:Pe,boundary:d,rootBoundary:p,padding:u,flipVariations:b,allowedAutoPlacements:h}):Pe)},[]),C=t.rects.reference,T=t.rects.popper,R=new Map,M=!0,k=f[0],S=0;S<f.length;S++){var E=f[S],x=bt(E),A=Wr(E)===Wo,I=[_e,lt].indexOf(x)>=0,H=I?"width":"height",D=lo(t,{placement:E,boundary:d,rootBoundary:p,altBoundary:m,padding:u}),B=I?A?rt:Ge:A?lt:_e;C[H]>T[H]&&(B=Bi(B));var z=Bi(B),X=[];if(i&&X.push(D[x]<=0),c&&X.push(D[B]<=0,D[z]<=0),X.every(function(Ce){return Ce})){k=E,M=!1;break}R.set(E,X)}if(M)for(var ue=b?3:1,ie=s(function(Pe){var qe=f.find(function(Bt){var Fe=R.get(Bt);if(Fe)return Fe.slice(0,Pe).every(function(V){return V})});if(qe)return k=qe,"break"},"_loop"),he=ue;he>0;he--){var ye=ie(he);if(ye==="break")break}t.placement!==k&&(t.modifiersData[o]._skip=!0,t.placement=k,t.reset=!0)}}s(p2,"flip");var Yf={name:"flip",enabled:!0,phase:"main",fn:p2,requiresIfExists:["offset"],data:{_skip:!1}};function Qf(e,t,r){return r===void 0&&(r={x:0,y:0}),{top:e.top-t.height-r.y,right:e.right-t.width+r.x,bottom:e.bottom-t.height+r.y,left:e.left-t.width-r.x}}s(Qf,"getSideOffsets");function e1(e){return[_e,rt,lt,Ge].some(function(t){return e[t]>=0})}s(e1,"isAnySideFullyClipped");function m2(e){var t=e.state,r=e.name,o=t.rects.reference,n=t.rects.popper,i=t.modifiersData.preventOverflow,a=lo(t,{elementContext:"reference"}),c=lo(t,{altBoundary:!0}),l=Qf(a,o),u=Qf(c,n,i),d=e1(l),p=e1(u);t.modifiersData[r]={referenceClippingOffsets:l,popperEscapeOffsets:u,isReferenceHidden:d,hasPopperEscaped:p},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":p})}s(m2,"hide");var t1={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:m2};function f2(e,t,r){var o=bt(e),n=[Ge,_e].indexOf(o)>=0?-1:1,i=typeof r=="function"?r(Object.assign({},t,{placement:e})):r,a=i[0],c=i[1];return a=a||0,c=(c||0)*n,[Ge,rt].indexOf(o)>=0?{x:c,y:a}:{x:a,y:c}}s(f2,"distanceAndSkiddingToXY");function g2(e){var t=e.state,r=e.options,o=e.name,n=r.offset,i=n===void 0?[0,0]:n,a=Ks.reduce(function(d,p){return d[p]=f2(p,t.rects,i),d},{}),c=a[t.placement],l=c.x,u=c.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=u),t.modifiersData[o]=a}s(g2,"offset");var r1={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:g2};function h2(e){var t=e.state,r=e.name;t.modifiersData[r]=Ra({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}s(h2,"popperOffsets");var o1={name:"popperOffsets",enabled:!0,phase:"read",fn:h2,data:{}};function Bu(e){return e==="x"?"y":"x"}s(Bu,"getAltAxis");function b2(e){var t=e.state,r=e.options,o=e.name,n=r.mainAxis,i=n===void 0?!0:n,a=r.altAxis,c=a===void 0?!1:a,l=r.boundary,u=r.rootBoundary,d=r.altBoundary,p=r.padding,m=r.tether,g=m===void 0?!0:m,b=r.tetherOffset,h=b===void 0?0:b,y=lo(t,{boundary:l,rootBoundary:u,padding:p,altBoundary:d}),P=bt(t.placement),w=Wr(t.placement),v=!w,f=$n(P),C=Bu(f),T=t.modifiersData.popperOffsets,R=t.rects.reference,M=t.rects.popper,k=typeof h=="function"?h(Object.assign({},t.rects,{placement:t.placement})):h,S=typeof k=="number"?{mainAxis:k,altAxis:k}:Object.assign({mainAxis:0,altAxis:0},k),E=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,x={x:0,y:0};if(T){if(i){var A,I=f==="y"?_e:Ge,H=f==="y"?lt:rt,D=f==="y"?"height":"width",B=T[f],z=B+y[I],X=B-y[H],ue=g?-M[D]/2:0,ie=w===Wo?R[D]:M[D],he=w===Wo?-M[D]:-R[D],ye=t.elements.arrow,Ce=g&&ye?zn(ye):{width:0,height:0},Pe=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:Aa(),qe=Pe[I],Bt=Pe[H],Fe=_n(0,R[D],Ce[D]),V=v?R[D]/2-ue-Fe-qe-S.mainAxis:ie-Fe-qe-S.mainAxis,ee=v?-R[D]/2+ue+Fe+Bt+S.mainAxis:he+Fe+Bt+S.mainAxis,ae=t.elements.arrow&&so(t.elements.arrow),Se=ae?f==="y"?ae.clientTop||0:ae.clientLeft||0:0,ze=(A=E==null?void 0:E[f])!=null?A:0,Ke=B+V-ze-Se,xt=B+ee-ze,it=_n(g?Un(z,Ke):z,B,g?ao(X,xt):X);T[f]=it,x[f]=it-B}if(c){var Ct,Tr=f==="x"?_e:Ge,wr=f==="x"?lt:rt,dt=T[C],Tt=C==="y"?"height":"width",Yt=dt+y[Tr],Ht=dt-y[wr],te=[_e,Ge].indexOf(P)!==-1,Qt=(Ct=E==null?void 0:E[C])!=null?Ct:0,Ir=te?Yt:dt-R[Tt]-M[Tt]-Qt+S.altAxis,Lr=te?dt+R[Tt]+M[Tt]-Qt-S.altAxis:Ht,mo=g&&te?qf(Ir,dt,Lr):_n(g?Ir:Yt,dt,g?Lr:Ht);T[C]=mo,x[C]=mo-dt}t.modifiersData[o]=x}}s(b2,"preventOverflow");var n1={name:"preventOverflow",enabled:!0,phase:"main",fn:b2,requiresIfExists:["offset"]};function Hu(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}s(Hu,"getHTMLElementScroll");function Du(e){return e===He(e)||!ct(e)?Zn(e):Hu(e)}s(Du,"getNodeScroll");function y2(e){var t=e.getBoundingClientRect(),r=Uo(t.width)/e.offsetWidth||1,o=Uo(t.height)/e.offsetHeight||1;return r!==1||o!==1}s(y2,"isElementScaled");function Fu(e,t,r){r===void 0&&(r=!1);var o=ct(t),n=ct(t)&&y2(t),i=Nt(t),a=Or(e,n,r),c={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(o||!o&&!r)&&((ht(t)!=="body"||jn(i))&&(c=Du(t)),ct(t)?(l=Or(t,!0),l.x+=t.clientLeft,l.y+=t.clientTop):i&&(l.x=qn(i))),{x:a.left+c.scrollLeft-l.x,y:a.top+c.scrollTop-l.y,width:a.width,height:a.height}}s(Fu,"getCompositeRect");function v2(e){var t=new Map,r=new Set,o=[];e.forEach(function(i){t.set(i.name,i)});function n(i){r.add(i.name);var a=[].concat(i.requires||[],i.requiresIfExists||[]);a.forEach(function(c){if(!r.has(c)){var l=t.get(c);l&&n(l)}}),o.push(i)}return s(n,"sort"),e.forEach(function(i){r.has(i.name)||n(i)}),o}s(v2,"order");function Vu(e){var t=v2(e);return _f.reduce(function(r,o){return r.concat(t.filter(function(n){return n.phase===o}))},[])}s(Vu,"orderModifiers");function Ou(e){var t;return function(){return t||(t=new Promise(function(r){Promise.resolve().then(function(){t=void 0,r(e())})})),t}}s(Ou,"debounce");function Wu(e){var t=e.reduce(function(r,o){var n=r[o.name];return r[o.name]=n?Object.assign({},n,o,{options:Object.assign({},n.options,o.options),data:Object.assign({},n.data,o.data)}):o,r},{});return Object.keys(t).map(function(r){return t[r]})}s(Wu,"mergeByName");var i1={placement:"bottom",modifiers:[],strategy:"absolute"};function a1(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return!t.some(function(o){return!(o&&typeof o.getBoundingClientRect=="function")})}s(a1,"areValidElements");function s1(e){e===void 0&&(e={});var t=e,r=t.defaultModifiers,o=r===void 0?[]:r,n=t.defaultOptions,i=n===void 0?i1:n;return s(function(c,l,u){u===void 0&&(u=i);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},i1,i),modifiersData:{},elements:{reference:c,popper:l},attributes:{},styles:{}},p=[],m=!1,g={state:d,setOptions:s(function(P){var w=typeof P=="function"?P(d.options):P;h(),d.options=Object.assign({},i,d.options,w),d.scrollParents={reference:Vr(c)?un(c):c.contextElement?un(c.contextElement):[],popper:un(l)};var v=Vu(Wu([].concat(o,d.options.modifiers)));return d.orderedModifiers=v.filter(function(f){return f.enabled}),b(),g.update()},"setOptions"),forceUpdate:s(function(){if(!m){var P=d.elements,w=P.reference,v=P.popper;if(a1(w,v)){d.rects={reference:Fu(w,so(v),d.options.strategy==="fixed"),popper:zn(v)},d.reset=!1,d.placement=d.options.placement,d.orderedModifiers.forEach(function(S){return d.modifiersData[S.name]=Object.assign({},S.data)});for(var f=0;f<d.orderedModifiers.length;f++){if(d.reset===!0){d.reset=!1,f=-1;continue}var C=d.orderedModifiers[f],T=C.fn,R=C.options,M=R===void 0?{}:R,k=C.name;typeof T=="function"&&(d=T({state:d,options:M,name:k,instance:g})||d)}}}},"forceUpdate"),update:Ou(function(){return new Promise(function(y){g.forceUpdate(),y(d)})}),destroy:s(function(){h(),m=!0},"destroy")};if(!a1(c,l))return g;g.setOptions(u).then(function(y){!m&&u.onFirstUpdate&&u.onFirstUpdate(y)});function b(){d.orderedModifiers.forEach(function(y){var P=y.name,w=y.options,v=w===void 0?{}:w,f=y.effect;if(typeof f=="function"){var C=f({state:d,name:P,instance:g,options:v}),T=s(function(){},"noopFn");p.push(C||T)}})}s(b,"runModifierEffects");function h(){p.forEach(function(y){return y()}),p=[]}return s(h,"cleanupModifierEffects"),g},"createPopper")}s(s1,"popperGenerator");var x2=[Kf,o1,Jf,Ma,r1,Yf,n1,jf,t1],Uu=s1({defaultModifiers:x2});var C2="tippy-box",b1="tippy-content",T2="tippy-backdrop",y1="tippy-arrow",v1="tippy-svg-arrow",Gn={passive:!0,capture:!0},x1=s(function(){return document.body},"TIPPY_DEFAULT_APPEND_TO");function zu(e,t,r){if(Array.isArray(e)){var o=e[t];return o==null?Array.isArray(r)?r[t]:r:o}return e}s(zu,"getValueAtIndexOrReturn");function Gu(e,t){var r={}.toString.call(e);return r.indexOf("[object")===0&&r.indexOf(t+"]")>-1}s(Gu,"isType");function C1(e,t){return typeof e=="function"?e.apply(void 0,t):e}s(C1,"invokeWithArgsOrReturn");function l1(e,t){if(t===0)return e;var r;return function(o){clearTimeout(r),r=setTimeout(function(){e(o)},t)}}s(l1,"debounce");function w2(e){return e.split(/\s+/).filter(Boolean)}s(w2,"splitBySpaces");function Di(e){return[].concat(e)}s(Di,"normalizeToArray");function c1(e,t){e.indexOf(t)===-1&&e.push(t)}s(c1,"pushIfUnique");function E2(e){return e.filter(function(t,r){return e.indexOf(t)===r})}s(E2,"unique");function k2(e){return e.split("-")[0]}s(k2,"getBasePlacement");function tl(e){return[].slice.call(e)}s(tl,"arrayFrom");function u1(e){return Object.keys(e).reduce(function(t,r){return e[r]!==void 0&&(t[r]=e[r]),t},{})}s(u1,"removeUndefinedProps");function Ba(){return document.createElement("div")}s(Ba,"div");function rl(e){return["Element","Fragment"].some(function(t){return Gu(e,t)})}s(rl,"isElement");function P2(e){return Gu(e,"NodeList")}s(P2,"isNodeList");function M2(e){return Gu(e,"MouseEvent")}s(M2,"isMouseEvent");function N2(e){return!!(e&&e._tippy&&e._tippy.reference===e)}s(N2,"isReferenceElement");function S2(e){return rl(e)?[e]:P2(e)?tl(e):Array.isArray(e)?e:tl(document.querySelectorAll(e))}s(S2,"getArrayOfElements");function $u(e,t){e.forEach(function(r){r&&(r.style.transitionDuration=t+"ms")})}s($u,"setTransitionDuration");function d1(e,t){e.forEach(function(r){r&&r.setAttribute("data-state",t)})}s(d1,"setVisibilityState");function A2(e){var t,r=Di(e),o=r[0];return o!=null&&(t=o.ownerDocument)!=null&&t.body?o.ownerDocument:document}s(A2,"getOwnerDocument");function I2(e,t){var r=t.clientX,o=t.clientY;return e.every(function(n){var i=n.popperRect,a=n.popperState,c=n.props,l=c.interactiveBorder,u=k2(a.placement),d=a.modifiersData.offset;if(!d)return!0;var p=u==="bottom"?d.top.y:0,m=u==="top"?d.bottom.y:0,g=u==="right"?d.left.x:0,b=u==="left"?d.right.x:0,h=i.top-o+p>l,y=o-i.bottom-m>l,P=i.left-r+g>l,w=r-i.right-b>l;return h||y||P||w})}s(I2,"isCursorOutsideInteractiveBorder");function _u(e,t,r){var o=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){e[o](n,r)})}s(_u,"updateTransitionEndListener");function p1(e,t){for(var r=t;r;){var o;if(e.contains(r))return!0;r=r.getRootNode==null||(o=r.getRootNode())==null?void 0:o.host}return!1}s(p1,"actualContains");var Co={isTouch:!1},m1=0;function L2(){Co.isTouch||(Co.isTouch=!0,window.performance&&document.addEventListener("mousemove",T1))}s(L2,"onDocumentTouchStart");function T1(){var e=performance.now();e-m1<20&&(Co.isTouch=!1,document.removeEventListener("mousemove",T1)),m1=e}s(T1,"onDocumentMouseMove");function R2(){var e=document.activeElement;if(N2(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}s(R2,"onWindowBlur");function B2(){document.addEventListener("touchstart",L2,Gn),window.addEventListener("blur",R2)}s(B2,"bindGlobalEventListeners");var H2=typeof window!="undefined"&&typeof document!="undefined",D2=H2?!!window.msCrypto:!1;var F2={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},V2={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},co=Object.assign({appendTo:x1,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:s(function(){},"onAfterUpdate"),onBeforeUpdate:s(function(){},"onBeforeUpdate"),onCreate:s(function(){},"onCreate"),onDestroy:s(function(){},"onDestroy"),onHidden:s(function(){},"onHidden"),onHide:s(function(){},"onHide"),onMount:s(function(){},"onMount"),onShow:s(function(){},"onShow"),onShown:s(function(){},"onShown"),onTrigger:s(function(){},"onTrigger"),onUntrigger:s(function(){},"onUntrigger"),onClickOutside:s(function(){},"onClickOutside"),placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},F2,V2),O2=Object.keys(co),W2=s(function(t){var r=Object.keys(t);r.forEach(function(o){co[o]=t[o]})},"setDefaultProps");function w1(e){var t=e.plugins||[],r=t.reduce(function(o,n){var i=n.name,a=n.defaultValue;if(i){var c;o[i]=e[i]!==void 0?e[i]:(c=co[i])!=null?c:a}return o},{});return Object.assign({},e,r)}s(w1,"getExtendedPassedProps");function U2(e,t){var r=t?Object.keys(w1(Object.assign({},co,{plugins:t}))):O2,o=r.reduce(function(n,i){var a=(e.getAttribute("data-tippy-"+i)||"").trim();if(!a)return n;if(i==="content")n[i]=a;else try{n[i]=JSON.parse(a)}catch{n[i]=a}return n},{});return o}s(U2,"getDataAttributeProps");function f1(e,t){var r=Object.assign({},t,{content:C1(t.content,[e])},t.ignoreAttributes?{}:U2(e,t.plugins));return r.aria=Object.assign({},co.aria,r.aria),r.aria={expanded:r.aria.expanded==="auto"?t.interactive:r.aria.expanded,content:r.aria.content==="auto"?t.interactive?null:"describedby":r.aria.content},r}s(f1,"evaluateProps");var z2=s(function(){return"innerHTML"},"innerHTML");function qu(e,t){e[z2()]=t}s(qu,"dangerouslySetInnerHTML");function g1(e){var t=Ba();return e===!0?t.className=y1:(t.className=v1,rl(e)?t.appendChild(e):qu(t,e)),t}s(g1,"createArrowElement");function h1(e,t){rl(t.content)?(qu(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?qu(e,t.content):e.textContent=t.content)}s(h1,"setContent");function ju(e){var t=e.firstElementChild,r=tl(t.children);return{box:t,content:r.find(function(o){return o.classList.contains(b1)}),arrow:r.find(function(o){return o.classList.contains(y1)||o.classList.contains(v1)}),backdrop:r.find(function(o){return o.classList.contains(T2)})}}s(ju,"getChildren");function E1(e){var t=Ba(),r=Ba();r.className=C2,r.setAttribute("data-state","hidden"),r.setAttribute("tabindex","-1");var o=Ba();o.className=b1,o.setAttribute("data-state","hidden"),h1(o,e.props),t.appendChild(r),r.appendChild(o),n(e.props,e.props);function n(i,a){var c=ju(t),l=c.box,u=c.content,d=c.arrow;a.theme?l.setAttribute("data-theme",a.theme):l.removeAttribute("data-theme"),typeof a.animation=="string"?l.setAttribute("data-animation",a.animation):l.removeAttribute("data-animation"),a.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof a.maxWidth=="number"?a.maxWidth+"px":a.maxWidth,a.role?l.setAttribute("role",a.role):l.removeAttribute("role"),(i.content!==a.content||i.allowHTML!==a.allowHTML)&&h1(u,e.props),a.arrow?d?i.arrow!==a.arrow&&(l.removeChild(d),l.appendChild(g1(a.arrow))):l.appendChild(g1(a.arrow)):d&&l.removeChild(d)}return s(n,"onUpdate"),{popper:t,onUpdate:n}}s(E1,"render");E1.$$tippy=!0;var $2=1,el=[],Zu=[];function _2(e,t){var r=f1(e,Object.assign({},co,w1(u1(t)))),o,n,i,a=!1,c=!1,l=!1,u=!1,d,p,m,g=[],b=l1(Ke,r.interactiveDebounce),h,y=$2++,P=null,w=E2(r.plugins),v={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},f={id:y,reference:e,popper:Ba(),popperInstance:P,props:r,state:v,plugins:w,clearDelayTimeouts:Ir,setProps:Lr,setContent:mo,show:hn,hide:bn,hideWithInteractivity:yn,enable:te,disable:Qt,unmount:vn,destroy:xn};if(!r.render)return f;var C=r.render(f),T=C.popper,R=C.onUpdate;T.setAttribute("data-tippy-root",""),T.id="tippy-"+f.id,f.popper=T,e._tippy=f,T._tippy=f;var M=w.map(function(L){return L.fn(f)}),k=e.hasAttribute("aria-expanded");return ae(),ue(),B(),z("onCreate",[f]),r.showOnCreate&&Yt(),T.addEventListener("mouseenter",function(){f.props.interactive&&f.state.isVisible&&f.clearDelayTimeouts()}),T.addEventListener("mouseleave",function(){f.props.interactive&&f.props.trigger.indexOf("mouseenter")>=0&&I().addEventListener("mousemove",b)}),f;function S(){var L=f.props.touch;return Array.isArray(L)?L:[L,0]}s(S,"getNormalizedTouchSettings");function E(){return S()[0]==="hold"}s(E,"getIsCustomTouchBehavior");function x(){var L;return!!((L=f.props.render)!=null&&L.$$tippy)}s(x,"getIsDefaultRenderFn");function A(){return h||e}s(A,"getCurrentTarget");function I(){var L=A().parentNode;return L?A2(L):document}s(I,"getDocument");function H(){return ju(T)}s(H,"getDefaultTemplateChildren");function D(L){return f.state.isMounted&&!f.state.isVisible||Co.isTouch||d&&d.type==="focus"?0:zu(f.props.delay,L?0:1,co.delay)}s(D,"getDelay");function B(L){L===void 0&&(L=!1),T.style.pointerEvents=f.props.interactive&&!L?"":"none",T.style.zIndex=""+f.props.zIndex}s(B,"handleStyles");function z(L,$,F){if(F===void 0&&(F=!0),M.forEach(function(j){j[L]&&j[L].apply(j,$)}),F){var Q;(Q=f.props)[L].apply(Q,$)}}s(z,"invokeHook");function X(){var L=f.props.aria;if(L.content){var $="aria-"+L.content,F=T.id,Q=Di(f.props.triggerTarget||e);Q.forEach(function(j){var Xe=j.getAttribute($);if(f.state.isVisible)j.setAttribute($,Xe?Xe+" "+F:F);else{var de=Xe&&Xe.replace(F,"").trim();de?j.setAttribute($,de):j.removeAttribute($)}})}}s(X,"handleAriaContentAttribute");function ue(){if(!(k||!f.props.aria.expanded)){var L=Di(f.props.triggerTarget||e);L.forEach(function($){f.props.interactive?$.setAttribute("aria-expanded",f.state.isVisible&&$===A()?"true":"false"):$.removeAttribute("aria-expanded")})}}s(ue,"handleAriaExpandedAttribute");function ie(){I().removeEventListener("mousemove",b),el=el.filter(function(L){return L!==b})}s(ie,"cleanupInteractiveMouseListeners");function he(L){if(!(Co.isTouch&&(l||L.type==="mousedown"))){var $=L.composedPath&&L.composedPath()[0]||L.target;if(!(f.props.interactive&&p1(T,$))){if(Di(f.props.triggerTarget||e).some(function(F){return p1(F,$)})){if(Co.isTouch||f.state.isVisible&&f.props.trigger.indexOf("click")>=0)return}else z("onClickOutside",[f,L]);f.props.hideOnClick===!0&&(f.clearDelayTimeouts(),f.hide(),c=!0,setTimeout(function(){c=!1}),f.state.isMounted||qe())}}}s(he,"onDocumentPress");function ye(){l=!0}s(ye,"onTouchMove");function Ce(){l=!1}s(Ce,"onTouchStart");function Pe(){var L=I();L.addEventListener("mousedown",he,!0),L.addEventListener("touchend",he,Gn),L.addEventListener("touchstart",Ce,Gn),L.addEventListener("touchmove",ye,Gn)}s(Pe,"addDocumentPress");function qe(){var L=I();L.removeEventListener("mousedown",he,!0),L.removeEventListener("touchend",he,Gn),L.removeEventListener("touchstart",Ce,Gn),L.removeEventListener("touchmove",ye,Gn)}s(qe,"removeDocumentPress");function Bt(L,$){V(L,function(){!f.state.isVisible&&T.parentNode&&T.parentNode.contains(T)&&$()})}s(Bt,"onTransitionedOut");function Fe(L,$){V(L,$)}s(Fe,"onTransitionedIn");function V(L,$){var F=H().box;function Q(j){j.target===F&&(_u(F,"remove",Q),$())}if(s(Q,"listener"),L===0)return $();_u(F,"remove",p),_u(F,"add",Q),p=Q}s(V,"onTransitionEnd");function ee(L,$,F){F===void 0&&(F=!1);var Q=Di(f.props.triggerTarget||e);Q.forEach(function(j){j.addEventListener(L,$,F),g.push({node:j,eventType:L,handler:$,options:F})})}s(ee,"on");function ae(){E()&&(ee("touchstart",ze,{passive:!0}),ee("touchend",xt,{passive:!0})),w2(f.props.trigger).forEach(function(L){if(L!=="manual")switch(ee(L,ze),L){case"mouseenter":ee("mouseleave",xt);break;case"focus":ee(D2?"focusout":"blur",it);break;case"focusin":ee("focusout",it);break}})}s(ae,"addListeners");function Se(){g.forEach(function(L){var $=L.node,F=L.eventType,Q=L.handler,j=L.options;$.removeEventListener(F,Q,j)}),g=[]}s(Se,"removeListeners");function ze(L){var $,F=!1;if(!(!f.state.isEnabled||Ct(L)||c)){var Q=(($=d)==null?void 0:$.type)==="focus";d=L,h=L.currentTarget,ue(),!f.state.isVisible&&M2(L)&&el.forEach(function(j){return j(L)}),L.type==="click"&&(f.props.trigger.indexOf("mouseenter")<0||a)&&f.props.hideOnClick!==!1&&f.state.isVisible?F=!0:Yt(L),L.type==="click"&&(a=!F),F&&!Q&&Ht(L)}}s(ze,"onTrigger");function Ke(L){var $=L.target,F=A().contains($)||T.contains($);if(!(L.type==="mousemove"&&F)){var Q=Tt().concat(T).map(function(j){var Xe,de=j._tippy,Ao=(Xe=de.popperInstance)==null?void 0:Xe.state;return Ao?{popperRect:j.getBoundingClientRect(),popperState:Ao,props:r}:null}).filter(Boolean);I2(Q,L)&&(ie(),Ht(L))}}s(Ke,"onMouseMove");function xt(L){var $=Ct(L)||f.props.trigger.indexOf("click")>=0&&a;if(!$){if(f.props.interactive){f.hideWithInteractivity(L);return}Ht(L)}}s(xt,"onMouseLeave");function it(L){f.props.trigger.indexOf("focusin")<0&&L.target!==A()||f.props.interactive&&L.relatedTarget&&T.contains(L.relatedTarget)||Ht(L)}s(it,"onBlurOrFocusOut");function Ct(L){return Co.isTouch?E()!==L.type.indexOf("touch")>=0:!1}s(Ct,"isEventListenerStopped");function Tr(){wr();var L=f.props,$=L.popperOptions,F=L.placement,Q=L.offset,j=L.getReferenceClientRect,Xe=L.moveTransition,de=x()?ju(T).arrow:null,Ao=j?{getBoundingClientRect:j,contextElement:j.contextElement||A()}:e,Zi={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:s(function($a){var Yn=$a.state;if(x()){var E5=H(),Kl=E5.box;["placement","reference-hidden","escaped"].forEach(function(_a){_a==="placement"?Kl.setAttribute("data-placement",Yn.placement):Yn.attributes.popper["data-popper-"+_a]?Kl.setAttribute("data-"+_a,""):Kl.removeAttribute("data-"+_a)}),Yn.attributes.popper={}}},"fn")},fo=[{name:"offset",options:{offset:Q}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!Xe}},Zi];x()&&de&&fo.push({name:"arrow",options:{element:de,padding:3}}),fo.push.apply(fo,($==null?void 0:$.modifiers)||[]),f.popperInstance=Uu(Ao,T,Object.assign({},$,{placement:F,onFirstUpdate:m,modifiers:fo}))}s(Tr,"createPopperInstance");function wr(){f.popperInstance&&(f.popperInstance.destroy(),f.popperInstance=null)}s(wr,"destroyPopperInstance");function dt(){var L=f.props.appendTo,$,F=A();f.props.interactive&&L===x1||L==="parent"?$=F.parentNode:$=C1(L,[F]),$.contains(T)||$.appendChild(T),f.state.isMounted=!0,Tr()}s(dt,"mount");function Tt(){return tl(T.querySelectorAll("[data-tippy-root]"))}s(Tt,"getNestedPopperTree");function Yt(L){f.clearDelayTimeouts(),L&&z("onTrigger",[f,L]),Pe();var $=D(!0),F=S(),Q=F[0],j=F[1];Co.isTouch&&Q==="hold"&&j&&($=j),$?o=setTimeout(function(){f.show()},$):f.show()}s(Yt,"scheduleShow");function Ht(L){if(f.clearDelayTimeouts(),z("onUntrigger",[f,L]),!f.state.isVisible){qe();return}if(!(f.props.trigger.indexOf("mouseenter")>=0&&f.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(L.type)>=0&&a)){var $=D(!1);$?n=setTimeout(function(){f.state.isVisible&&f.hide()},$):i=requestAnimationFrame(function(){f.hide()})}}s(Ht,"scheduleHide");function te(){f.state.isEnabled=!0}s(te,"enable");function Qt(){f.hide(),f.state.isEnabled=!1}s(Qt,"disable");function Ir(){clearTimeout(o),clearTimeout(n),cancelAnimationFrame(i)}s(Ir,"clearDelayTimeouts");function Lr(L){if(!f.state.isDestroyed){z("onBeforeUpdate",[f,L]),Se();var $=f.props,F=f1(e,Object.assign({},$,u1(L),{ignoreAttributes:!0}));f.props=F,ae(),$.interactiveDebounce!==F.interactiveDebounce&&(ie(),b=l1(Ke,F.interactiveDebounce)),$.triggerTarget&&!F.triggerTarget?Di($.triggerTarget).forEach(function(Q){Q.removeAttribute("aria-expanded")}):F.triggerTarget&&e.removeAttribute("aria-expanded"),ue(),B(),R&&R($,F),f.popperInstance&&(Tr(),Tt().forEach(function(Q){requestAnimationFrame(Q._tippy.popperInstance.forceUpdate)})),z("onAfterUpdate",[f,L])}}s(Lr,"setProps");function mo(L){f.setProps({content:L})}s(mo,"setContent");function hn(){var L=f.state.isVisible,$=f.state.isDestroyed,F=!f.state.isEnabled,Q=Co.isTouch&&!f.props.touch,j=zu(f.props.duration,0,co.duration);if(!(L||$||F||Q)&&!A().hasAttribute("disabled")&&(z("onShow",[f],!1),f.props.onShow(f)!==!1)){if(f.state.isVisible=!0,x()&&(T.style.visibility="visible"),B(),Pe(),f.state.isMounted||(T.style.transition="none"),x()){var Xe=H(),de=Xe.box,Ao=Xe.content;$u([de,Ao],0)}m=s(function(){var fo;if(!(!f.state.isVisible||u)){if(u=!0,T.offsetHeight,T.style.transition=f.props.moveTransition,x()&&f.props.animation){var Jl=H(),$a=Jl.box,Yn=Jl.content;$u([$a,Yn],j),d1([$a,Yn],"visible")}X(),ue(),c1(Zu,f),(fo=f.popperInstance)==null||fo.forceUpdate(),z("onMount",[f]),f.props.animation&&x()&&Fe(j,function(){f.state.isShown=!0,z("onShown",[f])})}},"onFirstUpdate"),dt()}}s(hn,"show");function bn(){var L=!f.state.isVisible,$=f.state.isDestroyed,F=!f.state.isEnabled,Q=zu(f.props.duration,1,co.duration);if(!(L||$||F)&&(z("onHide",[f],!1),f.props.onHide(f)!==!1)){if(f.state.isVisible=!1,f.state.isShown=!1,u=!1,a=!1,x()&&(T.style.visibility="hidden"),ie(),qe(),B(!0),x()){var j=H(),Xe=j.box,de=j.content;f.props.animation&&($u([Xe,de],Q),d1([Xe,de],"hidden"))}X(),ue(),f.props.animation?x()&&Bt(Q,f.unmount):f.unmount()}}s(bn,"hide");function yn(L){I().addEventListener("mousemove",b),c1(el,b),b(L)}s(yn,"hideWithInteractivity");function vn(){f.state.isVisible&&f.hide(),f.state.isMounted&&(wr(),Tt().forEach(function(L){L._tippy.unmount()}),T.parentNode&&T.parentNode.removeChild(T),Zu=Zu.filter(function(L){return L!==f}),f.state.isMounted=!1,z("onHidden",[f]))}s(vn,"unmount");function xn(){f.state.isDestroyed||(f.clearDelayTimeouts(),f.unmount(),Se(),delete e._tippy,f.state.isDestroyed=!0,z("onDestroy",[f]))}s(xn,"destroy")}s(_2,"createTippy");function Ha(e,t){t===void 0&&(t={});var r=co.plugins.concat(t.plugins||[]);B2();var o=Object.assign({},t,{plugins:r}),n=S2(e);if(0)var i,a;var c=n.reduce(function(l,u){var d=u&&_2(u,o);return d&&l.push(d),l},[]);return rl(e)?c[0]:c}s(Ha,"tippy");Ha.defaultProps=co;Ha.setDefaultProps=W2;Ha.currentInput=Co;var Bk=Object.assign({},Ma,{effect:s(function(t){var r=t.state,o={popper:{position:r.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(r.elements.popper.style,o.popper),r.styles=o,r.elements.arrow&&Object.assign(r.elements.arrow.style,o.arrow)},"effect")});Ha.setDefaultProps({render:E1});var k1=Ha;var P1=require("react"),M1=require("react/jsx-runtime"),Ju=(0,P1.forwardRef)(({children:e,className:t,withShadow:r=!0,withBorder:o=!0,...n},i)=>{let a=N("courier-bg-white courier-rounded-lg dark:courier-bg-black",r?"courier-shadow-sm":"",o?"courier-border courier-border-border dark:courier-border-neutral-800":"",t);return(0,M1.jsx)("div",{className:a,...n,ref:i,children:e})});Ju.displayName="Surface";var ol=require("@tiptap/core"),L1=require("@tiptap/react"),R1=require("@tiptap/suggestion");var N1=require("@tiptap/react");var uo={items:({query:e,editor:t})=>{var n,i;let r=((i=(n=t.extensionManager.extensions.find(a=>a.name==="variableSuggestion"))==null?void 0:n.options)==null?void 0:i.variables)||{};return Mr(r).filter(a=>a.toLowerCase().includes(e.toLowerCase()))},char:"{{",allowSpaces:!1,allowedPrefixes:null,startOfLine:!1,decorationTag:"span",decorationClass:"variable-suggestion",command:({editor:e,range:t,props:r})=>{e.chain().focus().deleteRange(t).insertContent([{type:"variable",attrs:{id:r}},{type:"text",text:" "}]).run()},render:()=>{let e=null,t=null,r=null,o=s((i,a)=>{e==null||e.updateProps({...i,selected:a})},"updateComponent"),n=s(i=>{var l,u;if(!r)return!1;let c=((l=uo.items)==null?void 0:l.call(uo,{query:(e==null?void 0:e.props).query||"",editor:(e==null?void 0:e.props).editor}))[i];return c?((u=uo.command)==null||u.call(uo,{editor:r.editor,range:r.range,props:c}),!0):!1},"selectItem");return{onStart:i=>{r=i,e=new N1.ReactRenderer(xa,{props:{...i,selected:0},editor:i.editor}),i.clientRect&&(t=k1(i.editor.options.element,{getReferenceClientRect:()=>{var a;return((a=i.clientRect)==null?void 0:a.call(i))||new DOMRect},appendTo:()=>i.editor.options.element,content:e==null?void 0:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",theme:"variable"}),e!=null&&e.element&&e.element.focus())},onUpdate(i){r=i,e==null||e.updateProps({...i,selected:e.props.selected}),i.clientRect&&(t==null||t.setProps({getReferenceClientRect:()=>{var a;return((a=i.clientRect)==null?void 0:a.call(i))||new DOMRect}}))},onKeyDown(i){var l;if(!e||!r)return!1;let a=(l=uo.items)==null?void 0:l.call(uo,{query:e.props.query||"",editor:e.props.editor}),c=e.props.selected;if(i.event.key==="ArrowUp"){let u=(c-1+a.length)%a.length;return o(r,u),!0}if(i.event.key==="ArrowDown"){let u=(c+1)%a.length;return o(r,u),!0}return i.event.key==="Enter"?(i.event.preventDefault(),n(c)):i.event.key==="Escape"?(r.editor.chain().focus().deleteRange(r.range).run(),!0):!1},onExit(){t==null||t.destroy(),e==null||e.destroy(),r=null}}}};var S1=require("@tiptap/react"),A1=require("lucide-react");var Da=require("react/jsx-runtime"),I1=s(({node:e})=>(0,Da.jsx)(S1.NodeViewWrapper,{className:"courier-inline-block",children:(0,Da.jsxs)("span",{className:"courier-group courier-text-sm courier-variable-node courier-bg-gray-200 courier-pl-2 courier-pr-3 courier-py-[1px] courier-rounded courier-border courier-border-gray-400 hover:courier-bg-[#3B82F6] hover:courier-border-[#3B82F6] hover:courier-text-[#ffffff] courier-flex courier-items-center courier-gap-1",children:[(0,Da.jsx)(A1.Braces,{size:16,className:"courier-text-gray-500 group-hover:courier-stroke-primary"}),e.attrs.id]})}),"VariableView");var Ku=ol.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})}}},parseHTML(){return[{tag:"span[data-variable]",getAttrs:e=>{let t=e.getAttribute("data-id");return t?{id:t}:!1}}]},renderHTML({HTMLAttributes:e,node:t}){return["span",{"data-variable":!0,...e},`{{${t.attrs.id}}}`]},renderText({node:e}){return`{{${e.attrs.id}}}`},addNodeView(){return(0,L1.ReactNodeViewRenderer)(I1)}}),Xu=ol.Extension.create({name:"variableSuggestion",addOptions(){return{HTMLAttributes:{},suggestion:{char:"{{",...uo}}},addProseMirrorPlugins(){return[(0,R1.Suggestion)({editor:this.editor,...this.options.suggestion})]}});var B1=require("@tiptap/core"),H1=require("@tiptap/pm/state"),nl=require("@tiptap/pm/model"),Yu=B1.Extension.create({name:"variablePaste",addProseMirrorPlugins(){return[new H1.Plugin({props:{transformPastedHTML:e=>e.replace(/\{\{([^}]+)\}\}/g,'<span data-variable="true" data-id="$1"></span>'),transformPastedText:(e,t,r)=>{let o=/\{\{([^}]+)\}\}/g;if(!o.test(e))return e;let{schema:n}=r.state,i=[],a=0,c;for(o.lastIndex=0;(c=o.exec(e))!==null;){if(c.index>a){let u=e.substring(a,c.index);u&&i.push(n.text(u))}let l=c[1];n.nodes.variable&&i.push(n.nodes.variable.create({id:l})),a=c.index+c[0].length}if(a<e.length){let l=e.substring(a);l&&i.push(n.text(l))}if(i.length>0){let l=nl.Fragment.from(i),u=new nl.Slice(l,0,0),d=r.state.tr.replaceSelection(u);return r.dispatch(d),e}return e}}})]}});var D1=require("uuid");var Z2=s((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),hs=s((e,t,r,o,n,i)=>{let a=`node-${(0,D1.v4)()}`,l={heading:()=>e.schema.nodes.heading.create({...ne,...o,id:a},i),paragraph:()=>e.schema.nodes.paragraph.create({...ne,...o,id:a},i),text:()=>e.schema.nodes.paragraph.create({...ne,...o,id:a},i),spacer:()=>e.schema.nodes.divider.create({...Km,...o,id:a}),divider:()=>e.schema.nodes.divider.create({...no,...o,id:a}),button:()=>e.schema.nodes.button.create({...Ve,...o,id:a},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...gt,...o,id:a}),image:()=>e.schema.nodes.imageBlock.create({...gt,...o,id:a}),customCode:()=>e.schema.nodes.customCode.create({...Hn,...o,id:a})}[t];if(l)try{let u=e.state.tr,d=l();u.insert(r,d),e.view.dispatch(u),n&&n(d),(t==="text"||t==="paragraph"||t==="heading")&&setTimeout(()=>{let m=Z2(e,a);m!==null&&e.commands.setTextSelection(m+1),e.view.focus()},50);let p=new CustomEvent("node-duplicated",{detail:{newNodeId:a}});document.dispatchEvent(p)}catch(u){console.error("Error creating node:",u)}else try{if(e.schema.nodes[t]){let u=e.state.tr,d=e.schema.nodes[t].create({...o,id:a},i);u.insert(r,d),e.view.dispatch(u),n&&n(d);let p=new CustomEvent("node-duplicated",{detail:{newNodeId:a}});document.dispatchEvent(p)}else console.error(`Cannot duplicate node: type "${t}" not found in schema`)}catch(u){console.error("Error creating fallback node:",u)}return a},"createOrDuplicateNode");var Sr=require("@dnd-kit/core");var q2=[Sr.KeyboardCode.Down,Sr.KeyboardCode.Right,Sr.KeyboardCode.Up,Sr.KeyboardCode.Left],F1=s((e,{context:{active:t,droppableRects:r,droppableContainers:o,collisionRect:n}})=>{var i;if(q2.includes(e.code)){if(e.preventDefault(),!t||!n)return;let a=[];o.getEnabled().forEach(u=>{var m;if(!u||u!=null&&u.disabled)return;let d=r.get(u.id);if(!d)return;let p=u.data.current;if(p){let{type:g,children:b}=p;if(g==="container"&&(b==null?void 0:b.length)>0&&((m=t.data.current)==null?void 0:m.type)!=="container")return}switch(e.code){case Sr.KeyboardCode.Down:n.top<d.top&&a.push(u);break;case Sr.KeyboardCode.Up:n.top>d.top&&a.push(u);break;case Sr.KeyboardCode.Left:n.left>=d.left+d.width&&a.push(u);break;case Sr.KeyboardCode.Right:n.left+n.width<=d.left&&a.push(u);break}});let c=(0,Sr.closestCorners)({active:t,collisionRect:n,droppableRects:r,droppableContainers:a,pointerCoordinates:null}),l=(0,Sr.getFirstCollision)(c,"id");if(l!=null){let u=o.get(l),d=u==null?void 0:u.node.current,p=u==null?void 0:u.rect.current;if(d&&p)return u.id==="placeholder"?{x:p.left+(p.width-n.width)/2,y:p.top+(p.height-n.height)/2}:((i=u.data.current)==null?void 0:i.type)==="container"?{x:p.left+20,y:p.top+74}:{x:p.left,y:p.top}}}},"coordinateGetter");var ln=s(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),ft=s(e=>{let t=ln(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");var We=require("@dnd-kit/core"),V1=require("@dnd-kit/sortable"),il=require("jotai"),yt=require("react");var Fi=s(({items:e,setItems:t,editor:r})=>{let[o,n]=(0,yt.useState)(null),[i,a]=(0,yt.useState)(null),[c,l]=(0,yt.useState)(null),u=(0,yt.useRef)(null),d=(0,yt.useRef)(!1),p=(0,il.useAtomValue)(je),[,m]=(0,il.useAtom)(ge),g=r||p,b=(0,We.useSensors)((0,We.useSensor)(We.MouseSensor,{activationConstraint:{distance:8}}),(0,We.useSensor)(We.TouchSensor,{activationConstraint:{delay:200,tolerance:6}}),(0,We.useSensor)(We.KeyboardSensor,{coordinateGetter:F1})),h=(0,yt.useMemo)(()=>({droppable:{strategy:We.MeasuringStrategy.Always}}),[]),y=(0,yt.useCallback)(()=>{g==null||g.commands.removeDragPlaceholder(),t(M=>({...M,Editor:M.Editor.filter(k=>!k.toString().includes("_temp"))}))},[g==null?void 0:g.commands,t]),P=(0,yt.useCallback)(M=>{var k,S;try{let E=g==null?void 0:g.state.doc;if(!E||M===0)return 0;if(M>=E.childCount)return E.content.size;let x=0;for(let A=0;A<Math.min(M,E.childCount);A++)x+=(k=E.child(A))==null?void 0:k.nodeSize;return x}catch(E){return console.warn("Error calculating document position:",E),(S=g==null?void 0:g.state.doc.content.size)!=null?S:0}},[g]),w=(0,yt.useCallback)(M=>M in e?M:Object.keys(e).find(k=>e[k].includes(M)),[e]),v=(0,yt.useCallback)(M=>{var A;if(c&&c in e)return(0,We.closestCenter)({...M,droppableContainers:M.droppableContainers.filter(I=>I.id in e)});let k=(0,We.pointerWithin)(M),E=(k.length>0?k:(0,We.rectIntersection)(M)).filter(I=>I.id!==void 0),x=(0,We.getFirstCollision)(E,"id");if(x!=null){if(x==="Editor")return u.current=x,[{id:x}];if(x in e){let I=e[x];if(I.length>0){let H=(A=(0,We.closestCenter)({...M,droppableContainers:M.droppableContainers.filter(D=>D.id!==x&&I.includes(D.id))})[0])==null?void 0:A.id;H&&(x=H)}}return u.current=x,[{id:x}]}return d.current&&(u.current=c),u.current?[{id:u.current}]:[]},[c,e]),f=(0,yt.useCallback)(({active:M})=>{l(M.id),(M.id==="text"||M.id==="divider"||M.id==="button"||M.id==="heading"||M.id==="image"||M.id==="spacer"||M.id==="customCode")&&a(M.id)},[]),C=(0,yt.useCallback)(({active:M,over:k})=>{if(!k)return;let S=w(k.id);if(!(w(M.id)==="Sidebar"&&S==="Editor"))return;let x=M.rect.current;if(!(x!=null&&x.translated))return;let A=g==null?void 0:g.view.dom.querySelectorAll("[data-node-view-wrapper]");if(!A)return;let I=A.length;for(let H=0;H<A.length;H++){let B=A[H].getBoundingClientRect();if(x.translated.top<B.top+B.height/2){I=H;break}}if(I!==o){let H=`${M.id}_temp_${Date.now()}`;n(I),requestAnimationFrame(()=>{g==null||g.commands.removeDragPlaceholder();let D=P(I);g==null||g.commands.setDragPlaceholder({id:H,type:M.id,pos:D}),t(B=>({...B,Editor:[...B.Editor.filter(z=>!z.toString().includes("_temp")),H]}))})}},[g,w,P,o,t]),T=(0,yt.useCallback)(({active:M,over:k})=>{var A;y();let S=k==null?void 0:k.id;if(!S){t(I=>({...I,Editor:I.Editor.filter(H=>!H.toString().includes("_temp"))})),l(null),a(null);return}if(!g)return;let E=w(S),x=w(M.id);if(x==="Sidebar"&&E==="Editor"&&o!==null){let I=P(o);hs(g,M.id,I,void 0,H=>{m(H)})}else if(x===E){let I=e[x].indexOf(M.id),H=e[E].indexOf(S);if(I!==-1&&H!==-1&&I!==H){t(B=>({...B,[E]:(0,V1.arrayMove)(B[E],I,H)}));let D=(A=g.getJSON())==null?void 0:A.content;if(Array.isArray(D)){let B=[...D],[z]=B.splice(I,1);B.splice(H,0,z),g.view.dispatch(g.view.state.tr.replaceWith(0,g.view.state.doc.content.size,g.state.schema.nodeFromJSON({type:"doc",content:B})))}}}l(null),a(null),n(null)},[t,m,g,y,w,P,o,e]),R=(0,yt.useCallback)(()=>{y(),l(null),a(null)},[y]);return{dndProps:{sensors:b,collisionDetection:v,measuring:h,onDragStart:f,onDragMove:C,onDragEnd:T,onDragCancel:R},activeDragType:i,activeId:c}},"useEditorDnd");var al=require("react");var O1=require("jotai");var sl=s(({setItems:e,rafId:t,editor:r})=>{let o=(0,O1.useAtomValue)(je),n=r||o,i=(0,al.useCallback)(a=>{t.current&&typeof cancelAnimationFrame!="undefined"&&cancelAnimationFrame(t.current);let c=setTimeout(()=>{if(typeof requestAnimationFrame!="undefined")t.current=requestAnimationFrame(()=>{try{let l=a==null?void 0:a.view.dom;if(!l){console.warn("syncEditorItems: Editor DOM element not found");return}let u=l.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(p=>{let m=p.dataset.id;m&&d.push(m)}),e(p=>({Editor:d,Sidebar:p.Sidebar}))}catch(l){console.error("Error syncing editor items:",l),e(u=>({...u}))}});else try{let l=a==null?void 0:a.view.dom;if(!l)return;let u=l.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(p=>{let m=p.dataset.id;m&&d.push(m)}),e(p=>({Editor:d,Sidebar:p.Sidebar}))}catch(l){console.error("Error syncing editor items:",l)}},50);return()=>clearTimeout(c)},[e,t]);return(0,al.useEffect)(()=>{if(!n||typeof n.on!="function")return;let a=s(()=>{n&&i(n)},"updateItems");n.on("update",a),n.on("selectionUpdate",a),n.on("create",a),n.on("transaction",a),n&&!n.isDestroyed&&a();let c=s(l=>{a()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",c),()=>{n==null||n.off("update",a),n==null||n.off("selectionUpdate",a),n==null||n.off("create",a),n==null||n.off("transaction",a),document.removeEventListener("node-duplicated",c),t.current&&typeof cancelAnimationFrame!="undefined"&&(cancelAnimationFrame(t.current),t.current=null)}},[n,i,t]),{syncEditorItems:i}},"useSyncEditorItems");var pr=require("react/jsx-runtime"),ad=[{type:"text",align:"left",content:`
|
|
181
181
|
`,text_style:"h1"},{type:"text",align:"left",content:""},{type:"image",src:""}],j2=(0,ve.forwardRef)(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:a,dataMode:c,...l},u)=>{let d=(0,mr.useAtomValue)(je),[p,m]=(0,mr.useAtom)(ge),[g,b]=(0,mr.useAtom)(Cn),h=(0,ve.useRef)({}),[y,P]=(0,ve.useState)(void 0),w=(0,mr.useAtomValue)(at),v=(0,mr.useAtomValue)(se),f=(0,mr.useAtomValue)(Xl),C=(0,mr.useAtomValue)(yo),T=(0,ve.useRef)(-1),R=(0,mr.useSetAtom)(Wp),M=(0,ve.useRef)(!1),k=(0,ve.useRef)(!1),[S]=(0,mr.useAtom)(oe),E=(0,mr.useAtomValue)(ro),x=(0,mr.useAtomValue)(kt),[A,I]=(0,ve.useState)({Editor:[],Sidebar:["heading","text","image","spacer","divider","button","customCode"]}),H=(0,ve.useRef)(null),{dndProps:D,activeDragType:B,activeId:z}=Fi({items:A,setItems:I,editor:d}),{syncEditorItems:X}=sl({setItems:I,rafId:H,editor:d});(0,ve.useEffect)(()=>{x&&(k.current=!1)},[x]);let[ue,ie]=(0,ve.useState)(!1);(0,ve.useEffect)(()=>{if(v===!1||v===null){let V=setTimeout(()=>{ie(!0)},100);return()=>clearTimeout(V)}else ie(!1)},[v]),(0,ve.useEffect)(()=>{if(p){let V=p.type.name,ee=ds(V);R({nodeName:V,config:ee})}},[p,R]);let he=(0,ve.useMemo)(()=>{var ee,ae,Se,ze,Ke,xt,it,Ct,Tr,wr,dt,Tt,Yt,Ht,te,Qt,Ir,Lr,mo,hn,bn,yn,vn,xn,L,$,F,Q,j,Xe,de,Ao,Zi,fo;if(C)return C;let V=(Se=(ae=(ee=w==null?void 0:w.data)==null?void 0:ee.tenant)==null?void 0:ae.brand)==null?void 0:Se.settings;return{brandColor:((ze=V==null?void 0:V.colors)==null?void 0:ze.primary)||"#000000",textColor:((Ke=V==null?void 0:V.colors)==null?void 0:Ke.secondary)||"#000000",subtleColor:((xt=V==null?void 0:V.colors)==null?void 0:xt.tertiary)||"#666666",headerStyle:(Ct=(it=V==null?void 0:V.email)==null?void 0:it.header)!=null&&Ct.barColor?"border":"plain",logo:(dt=(wr=(Tr=V==null?void 0:V.email)==null?void 0:Tr.header)==null?void 0:wr.logo)==null?void 0:dt.image,link:(Ht=(Yt=(Tt=V==null?void 0:V.email)==null?void 0:Tt.header)==null?void 0:Yt.logo)==null?void 0:Ht.href,facebookLink:(Lr=(Ir=(Qt=(te=V==null?void 0:V.email)==null?void 0:te.footer)==null?void 0:Qt.social)==null?void 0:Ir.facebook)==null?void 0:Lr.url,linkedinLink:(yn=(bn=(hn=(mo=V==null?void 0:V.email)==null?void 0:mo.footer)==null?void 0:hn.social)==null?void 0:bn.linkedin)==null?void 0:yn.url,instagramLink:($=(L=(xn=(vn=V==null?void 0:V.email)==null?void 0:vn.footer)==null?void 0:xn.social)==null?void 0:L.instagram)==null?void 0:$.url,mediumLink:(Xe=(j=(Q=(F=V==null?void 0:V.email)==null?void 0:F.footer)==null?void 0:Q.social)==null?void 0:j.medium)==null?void 0:Xe.url,xLink:(fo=(Zi=(Ao=(de=V==null?void 0:V.email)==null?void 0:de.footer)==null?void 0:Ao.social)==null?void 0:Zi.twitter)==null?void 0:fo.url}},[C,w]),ye=f&&!!he,Ce=W1.verticalListSortingStrategy,Pe=(0,ve.useCallback)(()=>{Object.values(h.current).forEach(V=>clearTimeout(V)),h.current={}},[]);(0,ve.useEffect)(()=>()=>{Pe()},[Pe]),(0,ve.useEffect)(()=>{let V=s(ee=>{if(ee.key==="Escape"&&(m(null),d==null||d.commands.blur(),T.current=-1),ee.key==="Tab"&&d){ee.preventDefault();let ae=-1;p&&d.state.doc.content.forEach((Ke,xt,it)=>{p.attrs.id===Ke.attrs.id&&(ae=it)}),ae===-1&&(ae=0);let Se=d.state.doc,ze;if(ee.shiftKey?ze=(ae-1+Se.childCount)%Se.childCount:ze=(ae+1)%Se.childCount,ze!==ae||p===null){let Ke=Se.child(ze);m(Ke),d.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",V),()=>{document.removeEventListener("keydown",V)}},[d,p,m]),(0,ve.useEffect)(()=>{if(v!==!1||x)return;let V=S!=null?S:"";if(V){let ee=ic(V,"email");b(ee||"")}setTimeout(()=>{if(!(!d||d.isDestroyed)&&d.state.doc.childCount===1){let ee=d.state.doc.child(0);m(ee)}},0)},[w,v,x,d,b,m,S]),(0,ve.useEffect)(()=>{v===!1&&w&&!k.current&&(k.current=!0,setTimeout(()=>{d&&!d.isDestroyed&&X(d)},300))},[v,w,d,X]),(0,ve.useEffect)(()=>(M.current=!0,()=>{M.current=!1}),[]);let qe=(0,ve.useCallback)(V=>{let ae=V||(y===void 0?"desktop":void 0);P(ae),m(null),ae?d==null||d.setEditable(!1):d==null||d.setEditable(!0)},[d,y,P,m]),Bt=s(V=>{b(V.target.value)},"handleSubjectChange"),Fe=(0,ve.useMemo)(()=>{if(v!==!1||!ue)return null;let V=a&&a.elements&&a.elements.length>0;V&&(k.current=!0);let ee;return V&&(ee=a.elements.find(Se=>Se.type==="channel"&&Se.channel==="email")),ee||(ee={type:"channel",channel:"email",elements:ad}),$e({version:"2022-01-01",elements:[ee]},{channel:"email"})},[a,v,ue]);return x&&(S===null||Fe===null)?null:(0,pr.jsx)(ar,{theme:t,dataMode:c,isLoading:!!v,Header:i?i({hidePublish:e,channels:r,routing:o}):(0,pr.jsx)(Ur,{hidePublish:e,channels:r,routing:o}),...l,children:(0,pr.jsxs)(ll.DndContext,{...D,children:[n==null?void 0:n({subject:g,handleSubjectChange:Bt,selectedNode:p,setSelectedNode:m,previewMode:y,templateEditor:d,ref:u,isBrandApply:ye,brandSettings:he,items:A,content:Fe,strategy:Ce,syncEditorItems:X,brandEditorContent:E,templateData:w,togglePreviewMode:qe}),(0,pr.jsx)(ll.DragOverlay,{dropAnimation:null,children:z&&(z==="text"||z==="divider"||z==="spacer"||z==="button"||z==="image"||z==="heading"||z==="customCode")?(0,pr.jsxs)("div",{className:N("courier-bg-white courier-border courier-border-border courier-rounded-lg courier-p-4 courier-shadow-lg","courier-opacity-90 courier-scale-105 courier-transition-transform"),children:[B==="heading"&&(0,pr.jsx)(Ci,{draggable:!0}),B==="text"&&(0,pr.jsx)(ir,{draggable:!0}),B==="spacer"&&(0,pr.jsx)(wi,{draggable:!0}),B==="divider"&&(0,pr.jsx)(nr,{draggable:!0}),B==="button"&&(0,pr.jsx)(Hr,{draggable:!0}),B==="image"&&(0,pr.jsx)(Ti,{draggable:!0}),B==="customCode"&&(0,pr.jsx)(Ln,{draggable:!0})]}):null})]})})}),cl=(0,ve.memo)(j2);var ul=class ul{};s(ul,"UploadImageAPI"),ul.uploadImage=s(async t=>new Promise((r,o)=>{let n=new FileReader;n.onload=()=>{typeof n.result=="string"?r(n.result):o(new Error("Failed to convert image to data URL"))},n.onerror=()=>{o(new Error("Failed to read image file"))},n.readAsDataURL(t)}),"uploadImage");var sd=ul,ld=sd;var fr=s(e=>[Cu,id.StarterKit.configure({document:!1,dropcursor:!1,gapcursor:!1,heading:!1,horizontalRule:!1,paragraph:!1,blockquote:!1,hardBreak:!1}),Mu.configure({setSelectedNode:e==null?void 0:e.setSelectedNode}),ed.HardBreak.configure({keepMarks:!0,HTMLAttributes:{class:"my-line-break"}}),cf,xu,Pu,fu,Tu.configure({levels:[1,2,3,4,5,6]}),vs,Ps,Qu.Color,Ns,Eu.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),nd.Underline,Ws.configure(),Is.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(t,r,o)=>{r.forEach(async n=>{let i=await ld.uploadImage(n);t.chain().setImageBlockAt({pos:o,src:i}).focus().run()})},onPaste:(t,r)=>{r.forEach(async o=>{let n=await ld.uploadImage(o);return t.chain().setImageBlockAt({pos:t.state.selection.anchor,src:n}).focus().run()})}}),rd.TextAlign.extend({addKeyboardShortcuts(){return{}}}).configure({types:["paragraph","heading"]}),od.Typography,td.Placeholder.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:"",emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",showOnlyWhenEditable:!0}),pu.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),Xu.configure({variables:e==null?void 0:e.variables}),Ku,Yu,Rs,Ds],"ExtensionKit");var hl=require("@tiptap/react");var U1=require("jotai"),Jn=require("react");var dl=s(e=>{let t=(0,U1.useAtomValue)(ge),[r,o]=(0,Jn.useState)({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1}),n=(0,Jn.useCallback)(()=>{if(e){if((t==null?void 0:t.type.name)==="button"){o({isBold:t.attrs.fontWeight==="bold",isItalic:t.attrs.fontStyle==="italic",isUnderline:t.attrs.isUnderline,isStrike:t.attrs.isStrike,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1});return}o({isBold:e.isActive("bold"),isItalic:e.isActive("italic"),isUnderline:e.isActive("underline"),isStrike:e.isActive("strike"),isAlignLeft:e.isActive({textAlign:"left"}),isAlignCenter:e.isActive({textAlign:"center"}),isAlignRight:e.isActive({textAlign:"right"}),isAlignJustify:e.isActive({textAlign:"justify"}),isQuote:e.isActive("blockquote"),isLink:e.isActive("link")})}},[e,t]);return(0,Jn.useEffect)(()=>{if(e)return n(),e.on("selectionUpdate",n),e.on("transaction",n),()=>{e.off("selectionUpdate",n),e.off("transaction",n)}},[e,n]),{shouldShow:(0,Jn.useCallback)(({editor:a})=>{let c=["paragraph","heading","blockquote"],{$head:l,$anchor:u}=a.state.selection,d=l.node();if(c.includes(d.type.name)&&d.attrs.isSelected)return!0;for(let p=1;p<=l.depth;p++){let m=l.node(p);if(m.type.name==="blockquote"){if(m.attrs.isSelected)return!0;let g=a.isFocused&&(l.pos!==u.pos||a.state.selection.from!==a.state.selection.to),b=a.isFocused;return g||b}}return!1},[]),...r}},"useTextmenuStates");var fl=require("jotai"),Ze=require("lucide-react"),hr=require("react");var pl=require("react");var $1=Me(require("@tippyjs/react"),1),_1=require("react");var Gt=require("react/jsx-runtime"),z1=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,G2=s(({children:e})=>{let t="courier-inline-flex courier-items-center courier-justify-center courier-w-5 courier-h-5 courier-p-1 courier-text-[0.625rem] courier-rounded courier-font-semibold courier-leading-none courier-border courier-border-border courier-text-neutral-500 courier-border-b-2";return e==="Mod"?(0,Gt.jsx)("kbd",{className:t,children:z1?"\u2318":"Ctrl"}):e==="Shift"?(0,Gt.jsx)("kbd",{className:t,children:"\u21E7"}):e==="Alt"?(0,Gt.jsx)("kbd",{className:t,children:z1?"\u2325":"Alt"}):(0,Gt.jsx)("kbd",{className:t,children:e})},"ShortcutKey"),Z1=s(({children:e,enabled:t=!0,title:r,shortcut:o,tippyOptions:n={}})=>{let i=(0,_1.useCallback)(a=>(0,Gt.jsxs)("span",{className:"courier-flex courier-items-center courier-gap-2 courier-px-2.5 courier-py-1 courier-bg-white courier-border courier-border-neutral-100 courier-rounded-lg courier-shadow-sm courier-z-[999]",tabIndex:-1,"data-placement":a["data-placement"],"data-reference-hidden":a["data-reference-hidden"],"data-escaped":a["data-escaped"],children:[r&&(0,Gt.jsx)("span",{className:"courier-text-xs courier-font-medium courier-text-neutral-500",children:r}),o&&(0,Gt.jsx)("span",{className:"courier-flex courier-items-center courier-gap-0.5",children:o.map(c=>(0,Gt.jsx)(G2,{children:c},c))})]}),[o,r]);return t?(0,Gt.jsx)($1.default,{...n,delay:500,offset:[0,8],touch:!1,zIndex:99999,appendTo:document.body,trigger:"mouseenter focus",showOnCreate:!1,render:i,animation:!1,children:(0,Gt.jsx)("span",{children:e})}):(0,Gt.jsx)(Gt.Fragment,{children:e})},"Tooltip");var Fa=require("react/jsx-runtime"),q1=(0,pl.forwardRef)(({shouldShowContent:e=!0,children:t,isVertical:r=!1,className:o,...n},i)=>{let a=N("courier-text-foreground courier-inline-flex courier-h-full courier-leading-none courier-gap-0.5",r?"courier-flex-col courier-p-2":"courier-flex-row courier-p-0.5 courier-items-center",o);return e&&(0,Fa.jsx)(Ju,{className:a,...n,ref:i,children:t})});q1.displayName="Toolbar";var j1=(0,pl.forwardRef)(({horizontal:e,className:t,...r},o)=>{let n=N("courier-bg-neutral-200 dark:courier-bg-neutral-800",e?"courier-w-full courier-min-w-[1.5rem] courier-h-[1px] courier-my-1 first:courier-mt-0 last:courier-mt-0":"courier-h-full courier-min-h-[1.5rem] courier-w-[1px] courier-mx-1 first:courier-ml-0 last:courier-mr-0",t);return(0,Fa.jsx)("div",{className:n,ref:o,...r})});j1.displayName="Toolbar.Divider";var G1=(0,pl.forwardRef)(({children:e,buttonSize:t="icon",variant:r="ghost",className:o,tooltip:n,tooltipShortcut:i,...a},c)=>{let l=N("courier-gap-1 courier-min-w-[2rem] courier-w-auto",o),u=(0,Fa.jsx)(Ne,{className:l,variant:r,buttonSize:t,ref:c,...a,children:e});return n?(0,Fa.jsx)(Z1,{title:n,shortcut:i,children:u}):u});G1.displayName="ToolbarButton";var ml={Wrapper:q1,Divider:j1,Button:G1};var J1=require("lucide-react"),K1=require("react");var gr=require("react/jsx-runtime"),J2=s(e=>e.type==="option","isOption"),X1=s(({options:e,containerRef:t})=>{let r=(0,K1.useMemo)(()=>e.find(o=>o.type==="option"&&o.isActive()),[e]);return(0,gr.jsxs)(Ka,{children:[(0,gr.jsx)(Xa,{asChild:!0,children:(0,gr.jsxs)(Ne,{variant:"ghost",className:"courier-flex courier-items-center courier-justify-center courier-font-normal !courier-py-[5px]",children:[(r==null?void 0:r.label)||"Normal text",(0,gr.jsx)(J1.ChevronDown,{className:"courier-w-3 courier-h-3"})]})}),(0,gr.jsx)(Gi,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(J2(o))return(0,gr.jsx)(Ji,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?(0,gr.jsx)(gr.Fragment,{children:o.id==="heading1"?(0,gr.jsx)("h1",{className:"courier-text-2xl courier-font-bold",children:o.label}):o.id==="heading2"?(0,gr.jsx)("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading3"?(0,gr.jsx)("h3",{className:"courier-text-lg courier-font-bold",children:o.label}):o.label}):o.label},o.id)})})]})},"ContentTypePicker");var Y1=require("@tiptap/react");var Q1=s(e=>(0,Y1.useEditorState)({editor:e,selector:t=>[{label:"Normal text",onClick:()=>{t.editor.chain().focus().setNode("paragraph").run()},id:"paragraph",disabled:()=>!t.editor.can().setParagraph(),isActive:()=>t.editor.isActive("paragraph")&&!t.editor.isActive("heading"),type:"option"},{label:"Heading 1",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:1}).run()},id:"heading1",disabled:()=>!t.editor.can().setHeading({level:1}),isActive:()=>t.editor.isActive("heading",{level:1}),type:"option"},{label:"Heading 2",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:2}).run()},id:"heading2",disabled:()=>!t.editor.can().setHeading({level:2}),isActive:()=>t.editor.isActive("heading",{level:2}),type:"option"},{label:"Heading 3",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:3}).run()},id:"heading3",disabled:()=>!t.editor.can().setHeading({level:3}),isActive:()=>t.editor.isActive("heading",{level:3}),type:"option"}]}),"useTextmenuContentTypes");var ut=require("react/jsx-runtime"),K2=(0,hr.memo)(ml.Button),X2=(0,hr.memo)(X1),gl=s(({editor:e,config:t})=>{var R;let r=gs(e),o=dl(e),n=Q1(e),i=(0,hr.useRef)(null),a=(0,fl.useAtomValue)(ps),c=(0,fl.useAtomValue)(ge),l=c==null?void 0:c.type.name,u=(0,fl.useAtomValue)(Op),[d,p]=(0,hr.useState)(()=>{let{selection:M}=e.state;return{from:M.from,to:M.to,empty:M.empty}});(0,hr.useEffect)(()=>{let M=s(()=>{let{selection:k}=e.state;p({from:k.from,to:k.to,empty:k.empty})},"updateSelection");return e.on("selectionUpdate",M),e.on("transaction",M),()=>{e.off("selectionUpdate",M),e.off("transaction",M)}},[e]);let m=(0,hr.useMemo)(()=>!d.empty&&d.from!==d.to,[d]),g=(0,hr.useMemo)(()=>t||u(l||"",m),[t,u,l,m]),b=s(()=>{let{selection:M}=e.state;if(!(M.empty&&!o.isLink&&!e.can().setLink({href:""})))if(o.isLink){let k=e.state.tr.setMeta("showLinkForm",{from:M.from,to:M.to});e.view.dispatch(k)}else{let k=e.state.tr.setMeta("showLinkForm",{from:M.from,to:M.to});e.view.dispatch(k)}},"handleLinkToggle"),h=s(()=>{if(a.ref){let x=a.ref,A=x.value,I=a.caretPosition||x.selectionStart||0,H=A.substring(0,I),D=A.substring(I),B=`${H}{{${D}`,z=I+2;x.focus();let X=new Event("input",{bubbles:!0,cancelable:!0});if(Object.defineProperty(X,"target",{writable:!1,value:{...x,value:B}}),x.value=B,x.dispatchEvent(X),x.setSelectionRange(z,z),x.getBoundingClientRect()){let ie=B.slice(0,z),he=document.createElement("span");he.style.font=window.getComputedStyle(x).font,he.style.whiteSpace="pre-wrap",he.textContent=ie,document.body.appendChild(he);let ye=he.offsetWidth;document.body.removeChild(he);let Ce=parseInt(window.getComputedStyle(x).lineHeight),Pe=ie.split(`
|
|
182
182
|
`).length-1,qe=new CustomEvent("showVariableSuggestions",{detail:{cursorPosition:{left:Math.min(ye%x.offsetWidth,x.offsetWidth-200),top:Pe*Ce+30}},bubbles:!0});x.dispatchEvent(qe)}return}let{state:M,dispatch:k}=e.view,{tr:S}=M;S.insertText("{{"),k(S),e.commands.focus();let E=e.state.tr.setMeta("showVariableSuggestions",{from:e.state.selection.from,to:e.state.selection.to});e.view.dispatch(E)},"handleVariableClick"),y=s((M,k,S,E,x,A,I)=>{let H=g[M];return!H||H.state==="hidden"?null:(0,ut.jsx)(K2,{tooltip:S,tooltipShortcut:A,onClick:E,active:x,disabled:H.state==="disabled",...I,children:k},M)},"renderButton"),P=s((M,k)=>{let S=M.filter(E=>!!E);return S.length>0?(0,ut.jsx)("div",{className:"courier-flex courier-items-center courier-gap-0.5",children:S},k):null},"renderGroup"),w=P([((R=g.contentType)==null?void 0:R.state)==="enabled"&&(0,ut.jsx)(X2,{options:n,containerRef:i},"content-type")],"content-type-group"),v=P([y("bold",(0,ut.jsx)(Ze.Bold,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",r.onBold,o.isBold,["Mod","B"]),y("italic",(0,ut.jsx)(Ze.Italic,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",r.onItalic,o.isItalic,["Mod","I"]),y("underline",(0,ut.jsx)(Ze.Underline,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",r.onUnderline,o.isUnderline,["Mod","U"]),y("strike",(0,ut.jsx)(Ze.Strikethrough,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Strikethrough",r.onStrike,o.isStrike,["Mod","Shift","S"])],"text-style-group"),f=P([y("alignLeft",(0,ut.jsx)(Ze.AlignLeft,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",r.onAlignLeft,o.isAlignLeft,["Shift","Mod","L"]),y("alignCenter",(0,ut.jsx)(Ze.AlignCenter,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",r.onAlignCenter,o.isAlignCenter,["Shift","Mod","E"]),y("alignRight",(0,ut.jsx)(Ze.AlignRight,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",r.onAlignRight,o.isAlignRight,["Shift","Mod","R"]),y("alignJustify",(0,ut.jsx)(Ze.AlignJustify,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",r.onAlignJustify,o.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),C=P([y("quote",(0,ut.jsx)(Ze.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Quote",r.onQuote,o.isQuote,["Mod","Shift","B"])],"block-style-group"),T=P([y("link",(0,ut.jsx)(Ze.Link,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",b,o.isLink,["Mod","K"]),y("variable",(0,ut.jsx)(Ze.Braces,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Variable",h,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return(0,ut.jsx)(ml.Wrapper,{ref:i,className:"courier-border-b rounded-b-none rounded-t-sm !courier-shadow-md courier-justify-center courier-rounded-lg",children:[w,v,f,C,T].filter(Boolean).map((M,k)=>(0,ut.jsxs)(hr.Fragment,{children:[M,k<[w,v,f,C,T].filter(Boolean).length-1&&(0,ut.jsx)(ml.Divider,{})]},`item-${k}`))})},"TextMenu");var cd=require("react/jsx-runtime"),br=s(({config:e})=>{let{editor:t}=(0,hl.useCurrentEditor)(),r=dl(t);return t?(0,cd.jsx)(hl.BubbleMenu,{editor:t,tippyOptions:{appendTo:o=>{var n;return(n=o.closest(".bubble-text-menu-container"))!=null?n:o},getReferenceClientRect:()=>{var a,c,l,u;let o=(l=(c=(a=t==null?void 0:t.state)==null?void 0:a.selection)==null?void 0:c.from)!=null?l:0,n=(u=t==null?void 0:t.view)==null?void 0:u.domAtPos(o),i=(n==null?void 0:n.node.parentNode).getBoundingClientRect();return{width:i==null?void 0:i.width,height:i==null?void 0:i.height,left:(i==null?void 0:i.left)-12,right:i==null?void 0:i.right,top:i==null?void 0:i.top,bottom:i==null?void 0:i.bottom,x:i==null?void 0:i.left,y:i==null?void 0:i.top,toJSON:()=>({})}},placement:"top",offset:[0,12]},shouldShow:r.shouldShow,updateDelay:100,"data-testid":"bubble-text-menu",children:t&&(0,cd.jsx)(gl,{editor:t,config:e})}):null},"BubbleTextMenu");var eg=require("@tiptap/pm/state"),Vi=require("@tiptap/react"),Va=require("jotai"),zr=require("react");var St=require("react/jsx-runtime"),Y2=s(({value:e,readOnly:t})=>{let{editor:r}=(0,Vi.useCurrentEditor)(),o=(0,Va.useSetAtom)(ni),n=(0,Va.useAtomValue)(se),i=(0,zr.useRef)(!1);return(0,zr.useEffect)(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(rc(e!=null?e:"")))},[r,e,n,t]),(0,zr.useEffect)(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),Q2=s(({variables:e,facebookLink:t,linkedinLink:r,instagramLink:o,mediumLink:n,xLink:i,readOnly:a=!1,value:c,onUpdate:l})=>{let u=(0,zr.useRef)(!1),d=(0,Va.useSetAtom)(ge),p=(0,zr.useMemo)(()=>({urls:{unsubscribe:!0,preferences:!0},...e}),[e]),m=Vi.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:b})=>{let{state:h,dispatch:y}=b.view;return y(h.tr.setSelection(eg.TextSelection.create(h.doc,h.selection.$anchor.pos))),d&&d(null),!1}}}});(0,zr.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let g=(0,zr.useMemo)(()=>[...fr({variables:p,setSelectedNode:d}),m].filter(b=>b!==void 0),[m,p,d]);return(0,St.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[(0,St.jsxs)(Vi.EditorProvider,{content:rc(c!=null?c:""),extensions:g,editable:!a,autofocus:!a,onUpdate:l,editorContainerProps:{className:N("courier-py-2 courier-flex-grow",a&&"courier-brand-editor-readonly")},immediatelyRender:!1,children:[(0,St.jsx)(Y2,{value:c,readOnly:a}),(0,St.jsx)(br,{})]}),(0,St.jsxs)("div",{className:"courier-flex courier-justify-end courier-items-center courier-gap-2 courier-mt-3",children:[t&&(0,St.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:(0,St.jsx)(ta,{className:"courier-w-5 courier-h-5"})}),r&&(0,St.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:(0,St.jsx)(na,{className:"courier-w-5 courier-h-5"})}),o&&(0,St.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:(0,St.jsx)(oa,{className:"courier-w-5 courier-h-5"})}),n&&(0,St.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:(0,St.jsx)(ia,{className:"courier-w-5 courier-h-5"})}),i&&(0,St.jsx)("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:(0,St.jsx)(ca,{className:"courier-w-5 courier-h-5"})})]})]})},"BrandFooterComponent"),Oi=(0,zr.memo)(Q2);var yr=require("react/jsx-runtime"),tg=s(({value:e,icon:t,...r})=>(0,yr.jsx)(Qe,{value:e,...r,className:"!courier-w-10 !courier-h-6 [&_svg]:!courier-size-5 [&_svg]:courier-fill-accent hover:courier-bg-transparent courier-rounded-sm data-[state=on]:courier-bg-background [&_svg]:data-[state=on]:courier-fill-foreground",children:t}),"PreviewItem"),bl=s(({previewMode:e,togglePreviewMode:t,hideMobileToggle:r=!1,...o})=>(0,yr.jsxs)("div",{...o,className:N("courier-sticky courier-bottom-0 courier-mt-auto courier-self-center courier-bg-background courier-px-3 courier-py-2 courier-shadow-lg courier-border courier-border-border courier-rounded-md courier-z-10 courier-flex courier-items-center courier-gap-2",o.className),children:[e&&!r&&(0,yr.jsxs)(yr.Fragment,{children:[(0,yr.jsxs)(rr,{type:"single",value:e,onValueChange:n=>{n!==""&&t(n)},className:"courier-w-full courier-rounded-md !courier-p-0.5 courier-bg-[#3B82F6] !courier-gap-0",children:[(0,yr.jsx)(tg,{value:"desktop",icon:(0,yr.jsx)(Sc,{})}),(0,yr.jsx)(tg,{value:"mobile",icon:(0,yr.jsx)($c,{})})]}),(0,yr.jsx)("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),(0,yr.jsxs)(Ne,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");var dd=require("@dnd-kit/sortable"),pd=require("react");function eb(){typeof window!="undefined"&&(window.__COURIER_CREATE_TEST__||(window.__COURIER_CREATE_TEST__={editors:{email:null,sms:null,push:null,inbox:null,slack:null,teams:null},currentEditor:null,activeChannel:null}))}s(eb,"initTestHelpers");function vr(e,t){typeof window!="undefined"&&(eb(),window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.editors[e]=t,window.__COURIER_CREATE_TEST__.currentEditor=t,window.__COURIER_CREATE_TEST__.activeChannel=t?e:null))}s(vr,"setTestEditor");var rg=require("@tiptap/core"),og=require("@tiptap/pm/state"),Oa=require("@tiptap/react"),Wt=require("jotai"),xe=require("react");var $o=require("react/jsx-runtime"),tb=s(({value:e})=>{let{editor:t}=(0,Oa.useCurrentEditor)();return(0,xe.useEffect)(()=>{t&&t.commands.setContent(e||{type:"doc",content:[{type:"paragraph"}]})},[t,e]),null},"ReadOnlyEditorContent"),rb=s(({value:e})=>{let{editor:t}=(0,Oa.useCurrentEditor)(),[r,o]=(0,Wt.useAtom)(oe),n=(0,Wt.useAtomValue)(Cn),i=(0,Wt.useAtomValue)(ge),a=(0,Wt.useSetAtom)(je),c=(0,xe.useRef)(!1),l=(0,Wt.useAtomValue)(se),u=(0,Wt.useAtomValue)(at),d=(0,xe.useRef)(!1),p=(0,Wt.useAtomValue)(kt);return(0,xe.useEffect)(()=>{l&&(d.current=!1)},[l]),(0,xe.useEffect)(()=>{!t||l!==!1||d.current||!e||(a(t),d.current=!0,t.commands.setContent(e))},[t,e,a,l]),(0,xe.useEffect)(()=>{if(!(t&&n!==null)||l!==!1||p||t.isFocused)return;let m=fe(t.getJSON());if(!m||!Array.isArray(m))return;let g=n;if(!n&&r){let P=r.elements.find(w=>w.type==="channel"&&w.channel==="email");P&&(g=ja(P,"email"))}let b=Tn(r,"email",g||"",m),h={elements:b.elements,channel:"email",...b.raw&&{raw:b.raw}},y=_t(r,h);JSON.stringify(r)!==JSON.stringify(y)&&o(y)},[u,t,n,o,l,r,p]),(0,xe.useEffect)(()=>()=>{t&&!t.isDestroyed&&t.setEditable(!0)},[t]),(0,xe.useEffect)(()=>{t&&c.current&&t.commands.updateSelectionState(i)},[t,i]),(0,xe.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]),null},"EditorContent"),ob=s(({value:e,readOnly:t=!1,variables:r,onDestroy:o,onUpdate:n,subject:i})=>{let a=(0,Wt.useSetAtom)(ms),c=(0,xe.useRef)(),[l,u]=(0,Wt.useAtom)(oe),d=(0,Wt.useAtomValue)(Cn),p=i!=null?i:d,m=(0,Wt.useSetAtom)(ge),g=(0,Wt.useAtomValue)(je),b=(0,Wt.useAtomValue)(kt),h=(0,xe.useRef)(l),y=(0,xe.useRef)(p);(0,xe.useEffect)(()=>{h.current=l},[l]),(0,xe.useEffect)(()=>{y.current=p},[p]),(0,xe.useEffect)(()=>{g==null||g.setEditable(!t)},[t,g]);let P=rg.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:I})=>{let{state:H,dispatch:D}=I.view;return D(H.tr.setSelection(og.TextSelection.create(H.doc,H.selection.$anchor.pos))),m&&m(null),!1}}}}),w=(0,xe.useCallback)(({editor:I})=>{n==null||n(I),vr("email",I),m&&setTimeout(()=>{m(null)},100)},[m,n]),v=(0,xe.useRef)(),f=(0,xe.useRef)(null),C=(0,xe.useCallback)((I,H)=>{var he;if(b)return;let D=h.current,B=y.current;if(!D){u({version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:H}]});return}let z=D.elements.find(ye=>ye.type==="channel"&&ye.channel==="email"),X={...z};X.elements=(he=X.elements)==null?void 0:he.filter(ye=>ye.type!=="meta");let ue={type:"channel",channel:"email",elements:H};if(JSON.stringify(X)!==JSON.stringify(ue)){let ye=B;!B&&z&&(ye=ja(z,"email"));let Ce=Tn(D,"email",ye||"",H);ue.elements=Ce.elements,Ce.raw&&(ue.raw=Ce.raw);let Pe=_t(D,ue);u(Pe)}n==null||n(I),vr("email",I)},[u,n,b]),T=(0,xe.useCallback)(({editor:I})=>{let H=fe(I.getJSON());f.current={editor:I,elemental:H},v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{if(f.current){let{editor:D,elemental:B}=f.current;C(D,B),f.current=null}},200)},[C]),R=(0,xe.useCallback)(({editor:I})=>{let{selection:H}=I.state,{$anchor:D}=H,z=H.$head.marks().find(ie=>ie.type.name==="link");z||I.isActive("link")?a({mark:z}):a(null);let X=D.depth,ue=null;for(;X>0;){let ie=D.node(X);if(ie.type.name==="paragraph"||ie.type.name==="heading"){ue=ie;break}X--}ue&&m(ue)},[a,m]),M=(0,xe.useCallback)(({editor:I,transaction:H})=>{let D=H==null?void 0:H.getMeta("showLinkForm");if(D){let{selection:B}=I.state,X=B.$head.marks().find(ue=>ue.type.name==="link");a({mark:X,link:{from:D.from,to:D.to}})}},[a]),k=(0,xe.useCallback)(()=>{c.current&&clearTimeout(c.current),v.current&&clearTimeout(v.current),o==null||o(),vr("email",null)},[o]),S=(0,xe.useCallback)(I=>{var X;let H=(X=I.view)==null?void 0:X.editor;if(!H||!H.isEditable)return;let D=I.target,B=H.view.posAtDOM(D,0),z=H.state.doc.resolve(B).node();z.type.name==="paragraph"&&m(z)},[m]),E=(0,xe.useMemo)(()=>[...fr({variables:r,setSelectedNode:m}),P].filter(I=>I!==void 0),[P,r,m]),x=e||{type:"doc",content:[{type:"paragraph"}]};return(0,$o.jsx)(Oa.EditorProvider,{content:x,extensions:E,...t?{editable:!1,autofocus:!1}:{editable:!0,autofocus:!0,onCreate:w,onUpdate:T,onSelectionUpdate:R,onTransaction:M},onDestroy:k,editorContainerProps:{onClick:S},"data-testid":"editor-provider",immediatelyRender:!1,children:t?(0,$o.jsx)(tb,{value:x}):(0,$o.jsxs)($o.Fragment,{children:[(0,$o.jsx)(rb,{value:x}),(0,$o.jsx)(br,{})]})})},"EmailEditor"),yl=ob;var Wa=require("jotai"),ig=require("lucide-react");var ng=require("@dnd-kit/sortable"),Kn=require("react");var vl=require("react/jsx-runtime");function nb(){let[e,t]=(0,Kn.useState)(!1);return(0,Kn.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(nb,"useMountStatus");var Wi=s(({children:e,id:t,className:r})=>{let{setNodeRef:o,setActivatorNodeRef:n,listeners:i,isDragging:a,transform:c,transition:l}=(0,ng.useSortable)({id:t}),u=nb();return(0,vl.jsx)(ib,{ref:o,id:t,transition:l,transform:c,fadeIn:a&&!u,listeners:i,className:r,handleProps:{ref:n},children:e})},"SideBarSortableItemWrapper"),ib=(0,Kn.forwardRef)(({children:e,className:t,dragOverlay:r,handleProps:o,listeners:n,id:i},a)=>((0,Kn.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),(0,vl.jsx)("div",{ref:a,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":i,className:N(t,"courier-relative"),children:(0,vl.jsx)("div",{...o,...n,children:e})})));var Ee=require("react/jsx-runtime"),xl=s(({items:e,brandEditor:t,label:r})=>{var a,c;let o=(0,Wa.useAtomValue)(at),n=(0,Wa.useSetAtom)(xi),i=(0,Wa.useAtomValue)(Et);return(0,Ee.jsxs)("div",{className:"courier-flex courier-flex-col courier-h-full",children:[(0,Ee.jsxs)("div",{className:"courier-flex-1",children:[r&&(0,Ee.jsxs)(Ee.Fragment,{children:[(0,Ee.jsx)("p",{children:r}),(0,Ee.jsx)(le,{className:"courier-my-4"})]}),(0,Ee.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(l=>(0,Ee.jsx)(Wi,{id:l.toString(),children:(0,Ee.jsxs)("div",{className:N("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-white courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Ee.jsx)(ig.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-ring courier-fill-ring"}),l==="heading"&&(0,Ee.jsx)(Ci,{draggable:!0}),l==="text"&&(0,Ee.jsx)(ir,{draggable:!0}),l==="image"&&(0,Ee.jsx)(Ti,{draggable:!0}),l==="spacer"&&(0,Ee.jsx)(wi,{draggable:!0}),l==="divider"&&(0,Ee.jsx)(nr,{draggable:!0}),l==="button"&&(0,Ee.jsx)(Hr,{draggable:!0}),l==="customCode"&&(0,Ee.jsx)(Ln,{draggable:!0})]})},l))})]}),t&&(0,Ee.jsxs)("div",{className:"courier-mt-auto courier-pt-4",children:[(0,Ee.jsx)(le,{className:"courier-mb-4 -courier-mx-4"}),(c=(a=o==null?void 0:o.data)==null?void 0:a.tenant)!=null&&c.brand?(0,Ee.jsx)("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:(0,Ee.jsx)(Ne,{variant:"link",className:"courier-underline",onClick:()=>n("brand"),disabled:!!i,children:"Edit brand"})}):(0,Ee.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,Ee.jsx)("h3",{className:"courier-text-md courier-font-medium",children:"Customize brand theme"}),(0,Ee.jsx)("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),(0,Ee.jsx)(Ne,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>n("brand"),children:"Customize"})]})]})]})},"SideBar");var ag=require("jotai");var To=require("react/jsx-runtime"),Cl=s(({element:e,editor:t})=>{var i,a;let r=(0,ag.useAtomValue)(cu);if(!e)return null;if(r!=null&&r.link||((i=r==null?void 0:r.mark)==null?void 0:i.type.name)==="link"&&((a=e.marks)!=null&&a.some(c=>c.type.name==="link")))return(0,To.jsx)(Hf,{editor:t,mark:r==null?void 0:r.mark,pendingLink:r==null?void 0:r.link});let o=t==null?void 0:t.isActive("blockquote"),n=s(()=>{if(!t)return;let{$anchor:c}=t.state.selection,l=c.depth;for(;l>0;){let u=c.node(l);if(u.type.name==="blockquote")return u;l--}},"getBlockquoteElement");return(0,To.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[e.type.name==="button"&&(0,To.jsx)(km,{element:e,editor:t},e.attrs.id),e.type.name==="divider"&&(0,To.jsx)(ef,{element:e,editor:t},e.attrs.id),["paragraph","heading"].includes(e.type.name)&&!o&&(0,To.jsx)(xf,{element:e,editor:t},e.attrs.id),e.type.name==="imageBlock"&&(0,To.jsx)(Af,{element:e,editor:t},e.attrs.id),e.type.name==="customCode"&&(0,To.jsx)(vu,{element:e,editor:t},e.attrs.id),(e.type.name==="blockquote"||e.type.name==="paragraph"&&o||e.type.name==="heading"&&o)&&(0,To.jsx)(gm,{element:n()||e,editor:t},e.attrs.id)]})},"SideBarItemDetails");var ud=require("react"),sg=require("jotai");var _o=require("react/jsx-runtime"),Ui=(0,ud.forwardRef)(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>(0,_o.jsx)("div",{className:N("courier-flex courier-flex-1 courier-overflow-hidden courier-root-container courier-relative",o&&"courier-editor-readonly",t&&"courier-editor-preview-mode",t==="mobile"&&"courier-editor-preview-mode-mobile",r),...n,ref:i,children:e})),dn=(0,ud.forwardRef)(({children:e,className:t,previewMode:r,skipExpanded:o=!1,width:n,...i},a)=>{let[c,l]=(0,sg.useAtom)(ho),u=o?!1:c,d=n||"courier-w-64";return r?null:(0,_o.jsxs)(_o.Fragment,{children:[u&&(0,_o.jsx)("div",{className:"courier-absolute courier-inset-0 courier-bg-black/50 courier-z-[9] courier-transition-opacity courier-duration-300 courier-cursor-pointer",onClick:()=>l(!1),"aria-hidden":"true"}),(0,_o.jsx)("div",{className:N("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch courier-relative",d,t),children:(0,_o.jsx)("div",{className:N("courier-editor-sidebar courier-absolute courier-top-0 courier-bottom-0 courier-right-0 courier-p-4 courier-h-full courier-overflow-y-auto courier-bg-white","courier-transition-all courier-duration-300 courier-ease-in-out",u?"courier-w-[80vw] courier-z-10 courier-shadow-xl courier-translate-x-0":d+" courier-translate-x-0"),...i,ref:a,children:e})})]})});var Ua=require("jotai");var Le=require("react/jsx-runtime"),md=(0,pd.forwardRef)(({children:e,className:t,...r},o)=>(0,Le.jsx)("div",{className:N("courier-editor-container courier-relative",t),...r,ref:o,children:e})),fd=(0,pd.forwardRef)(({children:e,previewMode:t,...r},o)=>(0,Le.jsx)("div",{className:N("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",t&&"courier-max-w-4xl courier-mx-auto"),...r,ref:o,children:e})),lg=s(({variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:a,dataMode:c,...l})=>{let u=(0,Ua.useAtomValue)(oe),d=(0,Ua.useAtomValue)(ho),p=(0,Ua.useSetAtom)(ho),m=s(()=>{d&&p(!1)},"handleSubjectAreaClick");return(0,Le.jsx)(cl,{value:u,variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:a,dataMode:c,render:({subject:g,handleSubjectChange:b,selectedNode:h,setSelectedNode:y,previewMode:P,templateEditor:w,ref:v,isBrandApply:f,brandSettings:C,items:T,content:R,strategy:M,syncEditorItems:k,brandEditorContent:S,templateData:E,togglePreviewMode:x})=>{var A,I,H,D,B,z;return(0,Le.jsxs)(Ui,{previewMode:P,children:[(0,Le.jsxs)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:[(0,Le.jsxs)("div",{className:"courier-bg-primary courier-h-12 courier-flex courier-items-center courier-gap-2 courier-px-4 courier-border-b",onClick:m,children:[(0,Le.jsx)("h4",{className:"courier-text-sm",children:"Subject: "}),(0,Le.jsx)(ce,{value:g!=null?g:"",onChange:b,onFocus:()=>y(null),className:"!courier-bg-background read-only:courier-cursor-default read-only:courier-border-transparent md:courier-text-md courier-py-1 courier-border-transparent !courier-border-none courier-font-medium",placeholder:"Write subject...",readOnly:P!==void 0})]}),(0,Le.jsxs)(md,{ref:v,children:[(0,Le.jsxs)(fd,{previewMode:P,children:[f&&(0,Le.jsxs)("div",{className:N("courier-py-5 courier-px-9 courier-pb-0 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(C==null?void 0:C.headerStyle)==="border"&&"courier-pt-6"),children:[(C==null?void 0:C.headerStyle)==="border"&&(0,Le.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:C==null?void 0:C.brandColor}}),(C==null?void 0:C.logo)&&(0,Le.jsx)("img",{src:C.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),(0,Le.jsx)(dd.SortableContext,{items:T.Editor,strategy:M,children:R&&(0,Le.jsx)(yl,{value:R,onUpdate:k,variables:e})}),f&&E&&(0,Le.jsx)("div",{className:"courier-py-5 courier-px-9 courier-pt-0 courier-flex courier-flex-col",children:(0,Le.jsx)(Oi,{readOnly:!0,value:S!=null?S:(z=(B=(D=(H=(I=(A=E==null?void 0:E.data)==null?void 0:A.tenant)==null?void 0:I.brand)==null?void 0:H.settings)==null?void 0:D.email)==null?void 0:B.footer)==null?void 0:z.markdown,variables:e,facebookLink:C==null?void 0:C.facebookLink,linkedinLink:C==null?void 0:C.linkedinLink,instagramLink:C==null?void 0:C.instagramLink,mediumLink:C==null?void 0:C.mediumLink,xLink:C==null?void 0:C.xLink})})]}),(0,Le.jsx)(bl,{previewMode:P,togglePreviewMode:x})]})]}),(0,Le.jsx)(dn,{previewMode:P,children:(0,Le.jsx)("div",{className:"courier-p-1 courier-h-full",children:h?(0,Le.jsx)(Cl,{element:h,editor:w}):(0,Le.jsx)(dd.SortableContext,{items:T.Sidebar,strategy:M,children:(0,Le.jsx)(xl,{items:T.Sidebar,brandEditor:i,label:"Blocks library"})})})})]})},...l})},"EmailLayout");var cg=require("@tiptap/react"),wo=require("jotai"),ot=require("react");var gd=require("react/jsx-runtime"),hd=[{type:"text",content:`
|
|
183
183
|
`,text_style:"h2"},{type:"text",content:`
|
|
@@ -189,10 +189,10 @@ if (typeof require !== "undefined") {
|
|
|
189
189
|
`}]}]}),m=fe(p),g=fe(t.getJSON());JSON.stringify(m)!==JSON.stringify(g)&&setTimeout(()=>{t.isFocused||t.commands.setContent(p)},1)},[t,o]),null},"PushEditorContent"),Cg={raw:{title:"",text:""}},Tg=s(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="push");return t||(t={type:"channel",channel:"push",raw:{title:"",text:""}}),t},"getOrCreatePushElement"),wg={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},cb=(0,nt.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:a,render:c,value:l,...u},d)=>{let p=(0,ko.useAtomValue)(se),m=(0,nt.useRef)(!0),g=(0,nt.useRef)(!1),b=(0,ko.useSetAtom)(ge),[h,y]=(0,ko.useAtom)(oe),P=(0,ko.useAtomValue)(kt),w=(0,nt.useMemo)(()=>({urls:{unsubscribe:!0,preferences:!0},...r}),[r]);(0,nt.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]);let v=(0,nt.useMemo)(()=>[...fr({variables:w,setSelectedNode:b})].filter(T=>T!==void 0),[w,b]),f=(0,nt.useCallback)(({editor:T})=>{if(P)return;if(!h){let I=fe(T.getJSON()).filter(X=>X.type==="text"),H=s(X=>"content"in X&&X.content?X.content.trim():"","getTextContent"),D=I[0]?H(I[0]):"",B=I[1]?H(I[1]):"";y({version:"2022-01-01",elements:[{type:"channel",channel:"push",raw:{title:D,text:B}}]});return}let M=fe(T.getJSON()).filter(A=>A.type==="text"),k=s(A=>"content"in A&&A.content?A.content.trim():"","getTextContent"),S=M[0]?k(M[0]):"",E=M[1]?k(M[1]):"",x=_t(h,{channel:{channel:"push",raw:{title:S,text:E}}});JSON.stringify(h)!==JSON.stringify(x)&&y(x)},[h,y,P]),C=(0,nt.useMemo)(()=>{var E,x;if(p!==!1)return null;let T=l==null?void 0:l.elements.find(A=>A.type==="channel"&&A.channel==="push");!T&&h&&(T=Tg(h));let R=(T==null?void 0:T.type)==="channel"&&"raw"in T&&((E=T.raw)==null?void 0:E.title)||"",M=(T==null?void 0:T.type)==="channel"&&"raw"in T&&((x=T.raw)==null?void 0:x.text)||"";return $e({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:[{type:"text",content:R||`
|
|
190
190
|
`,text_style:"h2"},{type:"text",content:M||`
|
|
191
191
|
`}]}]})},[l,h,p]);return(0,bd.jsx)(ar,{theme:e,isLoading:!!(p&&m.current),Header:a?a({hidePublish:t,channels:n,routing:i}):(0,bd.jsx)(Ur,{hidePublish:t,channels:n,routing:i}),...u,ref:d,children:c==null?void 0:c({content:C,extensions:v,editable:!o,autofocus:!o,onUpdate:f})})}),kl=(0,nt.memo)(cb);var Eg=require("@tiptap/react");var Jt=require("react/jsx-runtime"),Pl=s(({children:e})=>(0,Jt.jsxs)("div",{className:"courier-relative",children:[(0,Jt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-6 courier-bg-border -courier-left-[2px] courier-top-[136px]"}),(0,Jt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[178px]"}),(0,Jt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[245px]"}),(0,Jt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[78px] courier-bg-border -courier-right-[2px] courier-top-[200px]"}),(0,Jt.jsxs)("div",{className:"courier-py-2 courier-border-8 courier-border-b-0 courier-w-[306px] courier-h-[500px] courier-rounded-[40px] courier-rounded-b-none courier-bg-background courier-pb-6 courier-relative",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,Jt.jsxs)("div",{className:"courier-my-6 courier-mx-11 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,Jt.jsx)("span",{className:"courier-text-xs courier-font-semibold",children:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),(0,Jt.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2",children:[(0,Jt.jsx)(Dp,{}),(0,Jt.jsx)(Fp,{}),(0,Jt.jsx)(Hp,{})]})]}),(0,Jt.jsx)("div",{className:"courier-flex-1 courier-overflow-auto courier-h-[calc(90%-56px)] courier-mb-6",children:e})]})]}),"IPhoneFrame");var jo=require("react/jsx-runtime"),Ml=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:a=!1})=>{let c=e||{type:"doc",content:[{type:"paragraph"}]},l=a?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,jo.jsxs)(Pl,{children:[(0,jo.jsxs)("div",{className:N("courier-px-4 courier-py-2 courier-text-[#A3A3A3] courier-text-center courier-my-8",i),children:[(0,jo.jsx)("p",{className:"courier-text-lg courier-font-medium",children:new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}),(0,jo.jsx)("p",{className:"courier-text-5xl courier-font-semibold courier-mt-1",children:new Date().toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})})]}),(0,jo.jsxs)(Eg.EditorProvider,{content:c,extensions:t,...l,editorContainerProps:{className:N("courier-push-editor")},"data-testid":"editor-provider",immediatelyRender:!1,children:[(0,jo.jsx)(xg,{value:c}),!a&&(0,jo.jsx)(br,{config:wg})]})]})},"PushEditor");var kg=require("jotai");var Nl=require("react/jsx-runtime"),Pg=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,...i})=>{let a=(0,kg.useAtomValue)(oe);return(0,Nl.jsx)(kl,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:c=>(0,Nl.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,Nl.jsx)(Ml,{...c})}),...i})},"PushLayout");var Sl=require("@dnd-kit/core"),Mg=require("@tiptap/react"),$r=require("jotai"),Ae=require("react");var Po=require("react/jsx-runtime"),yd=[{type:"text",content:`
|
|
192
|
-
`}],Ng=s(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="slack");return t||(t={type:"channel",channel:"slack",elements:yd}),t},"getOrCreateSlackElement"),Sg=s(({value:e})=>{let{editor:t}=(0,Mg.useCurrentEditor)(),r=(0,$r.useSetAtom)(je),o=(0,$r.useAtomValue)(oe),n=(0,$r.useAtomValue)(se),i=(0,$r.useAtomValue)(ge),a=(0,Ae.useRef)(!1),c=(0,Ae.useRef)(!1);return(0,Ae.useEffect)(()=>{n&&(a.current=!1)},[n]),(0,Ae.useEffect)(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Ae.useEffect)(()=>{t&&(r(t),vr("slack",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ae.useEffect)(()=>{t&&c.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Ae.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]),(0,Ae.useEffect)(()=>{if(!t||!o||t.isFocused)return;let l=Ng(o),u=$e({version:"2022-01-01",elements:[l]},{channel:"slack"}),d=fe(u),p=fe(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"SlackEditorContent"),Ag={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"}},ub=(0,Ae.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:a,render:c,value:l},u)=>{let d=(0,$r.useAtomValue)(se),p=(0,$r.useAtomValue)(kt),m=(0,$r.useAtomValue)(je),[g,b]=(0,$r.useAtom)(ge),[h,y]=(0,$r.useAtom)(oe),P=(0,Ae.useRef)(!0),w=(0,Ae.useRef)(!1),v=(0,Ae.useRef)(null),[f,C]=(0,Ae.useState)({Sidebar:["text","divider","button"],Editor:[]}),{dndProps:T,activeDragType:R,activeId:M}=Fi({items:f,setItems:C}),{syncEditorItems:k}=sl({setItems:C,rafId:v});(0,Ae.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]),(0,Ae.useEffect)(()=>{d===!1&&h&&setTimeout(()=>{m&&!m.isDestroyed&&k(m)},300)},[d,h,m,k]);let S=(0,Ae.useMemo)(()=>[...fr({variables:r,setSelectedNode:b})].filter(A=>A!==void 0),[r,b]),E=(0,Ae.useCallback)(({editor:A})=>{if(!A||p)return;if(!h){let ue={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:fe(A.getJSON())}]};y(ue);return}let I=A.getJSON(),H=fe(I),D=_t(h,{elements:H,channel:"slack"}),B=JSON.stringify(h.elements),z=JSON.stringify(D.elements);B!==z&&setTimeout(()=>{w.current&&y(D)},100)},[h,y,p]),x=(0,Ae.useMemo)(()=>{let A=Ng(l);return $e({version:"2022-01-01",elements:[A]},{channel:"slack"})},[l]);return(0,Po.jsx)(ar,{theme:e,isLoading:!!(d&&P.current),Header:a?a({hidePublish:t,channels:n,routing:i}):(0,Po.jsx)(Ur,{hidePublish:t,channels:n,routing:i}),ref:u,children:(0,Po.jsxs)(Sl.DndContext,{...T,children:[c==null?void 0:c({content:x,extensions:S,editable:!o,autofocus:!o,onUpdate:E,items:f,selectedNode:g,slackEditor:m}),(0,Po.jsx)(Sl.DragOverlay,{dropAnimation:null,children:M&&(M==="text"||M==="divider"||M==="button")?(0,Po.jsxs)("div",{className:N("courier-bg-white courier-border courier-border-border courier-rounded-lg courier-p-4 courier-shadow-lg","courier-opacity-90 courier-scale-105 courier-transition-transform"),children:[R==="text"&&(0,Po.jsx)(ir,{draggable:!0}),R==="divider"&&(0,Po.jsx)(nr,{draggable:!0}),R==="button"&&(0,Po.jsx)(Hr,{draggable:!0})]}):null})]})})}),Al=(0,Ae.memo)(ub);var Rg=require("@tiptap/react");var De=require("react/jsx-runtime"),db=s(()=>(0,De.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-col courier-w-full",children:[(0,De.jsx)("div",{className:"courier-w-3/12 courier-h-[16px] courier-bg-[#F5F5F5] courier-rounded-md"}),(0,De.jsx)("div",{className:"courier-w-full courier-h-[16px] courier-bg-[#F5F5F5] courier-rounded-md"}),(0,De.jsx)("div",{className:"courier-w-6/12 courier-h-[16px] courier-bg-[#F5F5F5] courier-rounded-md"})]}),"TextSkeleton"),pb=s(()=>(0,De.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] courier-rounded-lg",children:(0,De.jsx)(la,{className:"courier-mx-auto courier-h-full"})}),"AvatarSkeleton"),Ig=s(()=>(0,De.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row",children:[(0,De.jsx)(pb,{}),(0,De.jsx)(db,{})]}),"InteractionSkeleton"),Lg=s(({children:e,className:t})=>(0,De.jsxs)("div",{className:N("courier-w-full courier-max-w-[800px] courier-bg-white courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,De.jsx)(Ig,{}),(0,De.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,De.jsx)("div",{className:"courier-flex-shrink-0",children:(0,De.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-md courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,De.jsx)(sa,{color:"#FFFFFF"})})}),(0,De.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,De.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mb-1",children:[(0,De.jsx)("span",{className:"courier-font-semibold courier-text-sm courier-text-gray-900",children:"Circle"}),(0,De.jsx)("span",{className:"courier-inline-flex courier-items-center courier-px-1.5 courier-py-0.5 courier-rounded courier-text-xs courier-font-medium courier-bg-gray-200 courier-text-gray-700",children:"APP"}),(0,De.jsx)("span",{className:"courier-text-xs courier-text-gray-500",children:"Now"})]}),(0,De.jsx)("div",{className:"courier-text-sm courier-text-gray-900 courier-leading-relaxed",children:e})]})]}),(0,De.jsx)(Ig,{})]}),"SlackFrame");var Il=require("@dnd-kit/sortable"),Bg=require("@dnd-kit/core");var pn=require("react/jsx-runtime"),Ll=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,items:i})=>{let{setNodeRef:a}=(0,Bg.useDroppable)({id:"Editor"});return e?(0,pn.jsx)(Lg,{children:(0,pn.jsx)("div",{ref:a,children:(0,pn.jsx)(Il.SortableContext,{items:i.Editor,strategy:Il.verticalListSortingStrategy,children:(0,pn.jsxs)(Rg.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:N("courier-slack-editor")},immediatelyRender:!1,children:[(0,pn.jsx)(Sg,{value:e}),(0,pn.jsx)(br,{config:Ag})]})})})}):null},"SlackEditor");var Wg=require("jotai");var Hg=require("@dnd-kit/core"),Rl=require("@dnd-kit/sortable"),Dg=require("lucide-react");var At=require("react/jsx-runtime"),Bl=s(({items:e,label:t})=>{let{setNodeRef:r}=(0,Hg.useDroppable)({id:"Sidebar"});return(0,At.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",ref:r,children:(0,At.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,At.jsxs)(At.Fragment,{children:[(0,At.jsx)("p",{children:t}),(0,At.jsx)(le,{className:"courier-my-4"})]}),(0,At.jsx)(Rl.SortableContext,{items:e,strategy:Rl.verticalListSortingStrategy,children:(0,At.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,At.jsx)(Wi,{id:o.toString(),children:(0,At.jsxs)("div",{className:N("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-white courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,At.jsx)(Dg.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-ring courier-fill-ring"}),o==="text"&&(0,At.jsx)(ir,{draggable:!0}),o==="divider"&&(0,At.jsx)(nr,{draggable:!0}),o==="button"&&(0,At.jsx)(Hr,{draggable:!0})]})},o))})})]})})},"SlackSideBar");var Fg=require("@hookform/resolvers/zod"),Vg=require("react-hook-form");var vt=require("react/jsx-runtime"),Og=s(({element:e,editor:t})=>{var a,c;let r=(0,Vg.useForm)({resolver:(0,Fg.zodResolver)(xs),defaultValues:{...Ve,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=cr({editor:t,element:e,form:r,nodeType:"button"}),n=((c=(a=t==null?void 0:t.extensionManager.extensions.find(l=>l.name==="variableSuggestion"))==null?void 0:a.options)==null?void 0:c.variables)||{},i=Mr(n);return e?(0,vt.jsxs)(Ye,{...r,children:[(0,vt.jsx)(ur,{type:"button"}),(0,vt.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,vt.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,vt.jsx)(q,{control:r.control,name:"link",render:({field:l})=>(0,vt.jsxs)(_,{children:[(0,vt.jsx)(Z,{children:(0,vt.jsx)(Ot,{as:"Textarea",...l,variables:i,onChange:u=>{l.onChange(u),o({...r.getValues(),link:u.target.value})}})}),(0,vt.jsx)(G,{})]})}),(0,vt.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,vt.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Text"}),(0,vt.jsx)(q,{control:r.control,name:"label",render:({field:l})=>(0,vt.jsxs)(_,{className:"courier-mb-2",children:[(0,vt.jsx)(Z,{children:(0,vt.jsx)(Ot,{...l,variables:i,onChange:u=>{l.onChange(u),o({...r.getValues(),label:u.target.value})}})}),(0,vt.jsx)(G,{})]})})]})]}):null},"SlackButtonForm");var vd=require("react/jsx-runtime"),Hl=s(({element:e,editor:t,defaultElement:r})=>e&&e.type.name==="button"?(0,vd.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:(0,vd.jsx)(Og,{element:e,editor:t},e.attrs.id)}):r,"SlackSideBarItemDetails");var xd=require("react");var Cr=require("react/jsx-runtime"),mb=(0,xd.forwardRef)(({children:e,className:t,...r},o)=>(0,Cr.jsx)("div",{className:N("courier-editor-container courier-relative",t),...r,ref:o,children:e})),fb=(0,xd.forwardRef)(({children:e,...t},r)=>(0,Cr.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),Ug=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n})=>{let i=(0,Wg.useAtomValue)(oe);return(0,Cr.jsx)(Al,{value:i,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:a=>(0,Cr.jsxs)(Ui,{children:[(0,Cr.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Cr.jsx)(mb,{children:(0,Cr.jsx)(fb,{children:(0,Cr.jsx)(Ll,{...a})})})}),(0,Cr.jsx)(dn,{children:(0,Cr.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,Cr.jsx)(Hl,{element:a.selectedNode,editor:a.slackEditor,defaultElement:(0,Cr.jsx)(Bl,{items:a.items.Sidebar,label:"Blocks library"})})})})]})})},"SlackLayout");var zg=require("@tiptap/react"),Mo=require("jotai"),Je=require("react"),$g=require("sms-segments-calculator");var Dl=require("react/jsx-runtime"),_g={raw:{text:""}},Zg=s(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="sms");return t||(t={type:"channel",channel:"sms",raw:{text:""}}),t},"getOrCreateSMSElement"),qg=s(({value:e})=>{var l;let{editor:t}=(0,zg.useCurrentEditor)(),r=(0,Mo.useSetAtom)(je),o=(0,Mo.useAtomValue)(oe),n=(l=t==null?void 0:t.getText())!=null?l:"",i=(0,Je.useMemo)(()=>new $g.SegmentedMessage(n),[n]),a=(0,Mo.useAtomValue)(se),c=(0,Je.useRef)(!1);return(0,Je.useEffect)(()=>{a&&(c.current=!1)},[a]),(0,Je.useEffect)(()=>{!t||a!==!1||c.current||!e||(c.current=!0,t.commands.setContent(e))},[t,e,a]),(0,Je.useEffect)(()=>{t&&(r(t),vr("sms",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Je.useEffect)(()=>{var y;if(!t||!o||t.isFocused)return;let u=Zg(o),d=u.type==="channel"&&"raw"in u&&((y=u.raw)==null?void 0:y.text)||"",g=$e({version:"2022-01-01",elements:[{type:"channel",channel:"sms",elements:d?[{type:"text",content:d}]:[{type:"text",content:`
|
|
192
|
+
`}],Ng=s(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="slack");return t||(t={type:"channel",channel:"slack",elements:yd}),t},"getOrCreateSlackElement"),Sg=s(({value:e})=>{let{editor:t}=(0,Mg.useCurrentEditor)(),r=(0,$r.useSetAtom)(je),o=(0,$r.useAtomValue)(oe),n=(0,$r.useAtomValue)(se),i=(0,$r.useAtomValue)(ge),a=(0,Ae.useRef)(!1),c=(0,Ae.useRef)(!1);return(0,Ae.useEffect)(()=>{n&&(a.current=!1)},[n]),(0,Ae.useEffect)(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Ae.useEffect)(()=>{t&&(r(t),vr("slack",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ae.useEffect)(()=>{t&&c.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Ae.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]),(0,Ae.useEffect)(()=>{if(!t||!o||t.isFocused)return;let l=Ng(o),u=$e({version:"2022-01-01",elements:[l]},{channel:"slack"}),d=fe(u),p=fe(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"SlackEditorContent"),Ag={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"}},ub=(0,Ae.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:a,render:c,value:l},u)=>{let d=(0,$r.useAtomValue)(se),p=(0,$r.useAtomValue)(kt),m=(0,$r.useAtomValue)(je),[g,b]=(0,$r.useAtom)(ge),[h,y]=(0,$r.useAtom)(oe),P=(0,Ae.useRef)(!0),w=(0,Ae.useRef)(!1),v=(0,Ae.useRef)(null),[f,C]=(0,Ae.useState)({Sidebar:["text","divider","button"],Editor:[]}),{dndProps:T,activeDragType:R,activeId:M}=Fi({items:f,setItems:C}),{syncEditorItems:k}=sl({setItems:C,rafId:v});(0,Ae.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]),(0,Ae.useEffect)(()=>{d===!1&&h&&setTimeout(()=>{m&&!m.isDestroyed&&k(m)},300)},[d,h,m,k]);let S=(0,Ae.useMemo)(()=>[...fr({variables:r,setSelectedNode:b})].filter(A=>A!==void 0),[r,b]),E=(0,Ae.useCallback)(({editor:A})=>{if(!A||p)return;if(!h){let ue={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:fe(A.getJSON())}]};y(ue);return}let I=A.getJSON(),H=fe(I),D=_t(h,{elements:H,channel:"slack"}),B=JSON.stringify(h.elements),z=JSON.stringify(D.elements);B!==z&&setTimeout(()=>{w.current&&y(D)},100)},[h,y,p]),x=(0,Ae.useMemo)(()=>{let A=Ng(l);return $e({version:"2022-01-01",elements:[A]},{channel:"slack"})},[l]);return(0,Po.jsx)(ar,{theme:e,isLoading:!!(d&&P.current),Header:a?a({hidePublish:t,channels:n,routing:i}):(0,Po.jsx)(Ur,{hidePublish:t,channels:n,routing:i}),ref:u,children:(0,Po.jsxs)(Sl.DndContext,{...T,children:[c==null?void 0:c({content:x,extensions:S,editable:!o,autofocus:!o,onUpdate:E,items:f,selectedNode:g,slackEditor:m}),(0,Po.jsx)(Sl.DragOverlay,{dropAnimation:null,children:M&&(M==="text"||M==="divider"||M==="button")?(0,Po.jsxs)("div",{className:N("courier-bg-white courier-border courier-border-border courier-rounded-lg courier-p-4 courier-shadow-lg","courier-opacity-90 courier-scale-105 courier-transition-transform"),children:[R==="text"&&(0,Po.jsx)(ir,{draggable:!0}),R==="divider"&&(0,Po.jsx)(nr,{draggable:!0}),R==="button"&&(0,Po.jsx)(Hr,{draggable:!0})]}):null})]})})}),Al=(0,Ae.memo)(ub);var Rg=require("@tiptap/react");var De=require("react/jsx-runtime"),db=s(()=>(0,De.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-col courier-w-full",children:[(0,De.jsx)("div",{className:"courier-w-3/12 courier-h-[16px] courier-bg-[#F5F5F5] courier-rounded-md"}),(0,De.jsx)("div",{className:"courier-w-full courier-h-[16px] courier-bg-[#F5F5F5] courier-rounded-md"}),(0,De.jsx)("div",{className:"courier-w-6/12 courier-h-[16px] courier-bg-[#F5F5F5] courier-rounded-md"})]}),"TextSkeleton"),pb=s(()=>(0,De.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] courier-rounded-lg",children:(0,De.jsx)(la,{className:"courier-mx-auto courier-h-full"})}),"AvatarSkeleton"),Ig=s(()=>(0,De.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row",children:[(0,De.jsx)(pb,{}),(0,De.jsx)(db,{})]}),"InteractionSkeleton"),Lg=s(({children:e,className:t})=>(0,De.jsxs)("div",{className:N("courier-w-full courier-max-w-[800px] courier-bg-white courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,De.jsx)(Ig,{}),(0,De.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,De.jsx)("div",{className:"courier-flex-shrink-0",children:(0,De.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-md courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,De.jsx)(sa,{color:"#FFFFFF"})})}),(0,De.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,De.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mb-1",children:[(0,De.jsx)("span",{className:"courier-font-semibold courier-text-sm courier-text-gray-900",children:"Circle"}),(0,De.jsx)("span",{className:"courier-inline-flex courier-items-center courier-px-1.5 courier-py-0.5 courier-rounded courier-text-xs courier-font-medium courier-bg-gray-200 courier-text-gray-700",children:"APP"}),(0,De.jsx)("span",{className:"courier-text-xs courier-text-gray-500",children:"Now"})]}),(0,De.jsx)("div",{className:"courier-text-sm courier-text-gray-900 courier-leading-relaxed courier-pr-4",children:e})]})]}),(0,De.jsx)(Ig,{})]}),"SlackFrame");var Il=require("@dnd-kit/sortable"),Bg=require("@dnd-kit/core");var pn=require("react/jsx-runtime"),Ll=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,items:i})=>{let{setNodeRef:a}=(0,Bg.useDroppable)({id:"Editor"});return e?(0,pn.jsx)(Lg,{children:(0,pn.jsx)("div",{ref:a,children:(0,pn.jsx)(Il.SortableContext,{items:i.Editor,strategy:Il.verticalListSortingStrategy,children:(0,pn.jsxs)(Rg.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:N("courier-slack-editor")},immediatelyRender:!1,children:[(0,pn.jsx)(Sg,{value:e}),(0,pn.jsx)(br,{config:Ag})]})})})}):null},"SlackEditor");var Wg=require("jotai");var Hg=require("@dnd-kit/core"),Rl=require("@dnd-kit/sortable"),Dg=require("lucide-react");var At=require("react/jsx-runtime"),Bl=s(({items:e,label:t})=>{let{setNodeRef:r}=(0,Hg.useDroppable)({id:"Sidebar"});return(0,At.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",ref:r,children:(0,At.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,At.jsxs)(At.Fragment,{children:[(0,At.jsx)("p",{children:t}),(0,At.jsx)(le,{className:"courier-my-4"})]}),(0,At.jsx)(Rl.SortableContext,{items:e,strategy:Rl.verticalListSortingStrategy,children:(0,At.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,At.jsx)(Wi,{id:o.toString(),children:(0,At.jsxs)("div",{className:N("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-white courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,At.jsx)(Dg.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-ring courier-fill-ring"}),o==="text"&&(0,At.jsx)(ir,{draggable:!0}),o==="divider"&&(0,At.jsx)(nr,{draggable:!0}),o==="button"&&(0,At.jsx)(Hr,{draggable:!0})]})},o))})})]})})},"SlackSideBar");var Fg=require("@hookform/resolvers/zod"),Vg=require("react-hook-form");var vt=require("react/jsx-runtime"),Og=s(({element:e,editor:t})=>{var a,c;let r=(0,Vg.useForm)({resolver:(0,Fg.zodResolver)(xs),defaultValues:{...Ve,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=cr({editor:t,element:e,form:r,nodeType:"button"}),n=((c=(a=t==null?void 0:t.extensionManager.extensions.find(l=>l.name==="variableSuggestion"))==null?void 0:a.options)==null?void 0:c.variables)||{},i=Mr(n);return e?(0,vt.jsxs)(Ye,{...r,children:[(0,vt.jsx)(ur,{type:"button"}),(0,vt.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,vt.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,vt.jsx)(q,{control:r.control,name:"link",render:({field:l})=>(0,vt.jsxs)(_,{children:[(0,vt.jsx)(Z,{children:(0,vt.jsx)(Ot,{as:"Textarea",...l,variables:i,onChange:u=>{l.onChange(u),o({...r.getValues(),link:u.target.value})}})}),(0,vt.jsx)(G,{})]})}),(0,vt.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,vt.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Text"}),(0,vt.jsx)(q,{control:r.control,name:"label",render:({field:l})=>(0,vt.jsxs)(_,{className:"courier-mb-2",children:[(0,vt.jsx)(Z,{children:(0,vt.jsx)(Ot,{...l,variables:i,onChange:u=>{l.onChange(u),o({...r.getValues(),label:u.target.value})}})}),(0,vt.jsx)(G,{})]})})]})]}):null},"SlackButtonForm");var vd=require("react/jsx-runtime"),Hl=s(({element:e,editor:t,defaultElement:r})=>e&&e.type.name==="button"?(0,vd.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:(0,vd.jsx)(Og,{element:e,editor:t},e.attrs.id)}):r,"SlackSideBarItemDetails");var xd=require("react");var Cr=require("react/jsx-runtime"),mb=(0,xd.forwardRef)(({children:e,className:t,...r},o)=>(0,Cr.jsx)("div",{className:N("courier-editor-container courier-relative",t),...r,ref:o,children:e})),fb=(0,xd.forwardRef)(({children:e,...t},r)=>(0,Cr.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),Ug=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n})=>{let i=(0,Wg.useAtomValue)(oe);return(0,Cr.jsx)(Al,{value:i,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:a=>(0,Cr.jsxs)(Ui,{children:[(0,Cr.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Cr.jsx)(mb,{children:(0,Cr.jsx)(fb,{children:(0,Cr.jsx)(Ll,{...a})})})}),(0,Cr.jsx)(dn,{children:(0,Cr.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,Cr.jsx)(Hl,{element:a.selectedNode,editor:a.slackEditor,defaultElement:(0,Cr.jsx)(Bl,{items:a.items.Sidebar,label:"Blocks library"})})})})]})})},"SlackLayout");var zg=require("@tiptap/react"),Mo=require("jotai"),Je=require("react"),$g=require("sms-segments-calculator");var Dl=require("react/jsx-runtime"),_g={raw:{text:""}},Zg=s(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="sms");return t||(t={type:"channel",channel:"sms",raw:{text:""}}),t},"getOrCreateSMSElement"),qg=s(({value:e})=>{var l;let{editor:t}=(0,zg.useCurrentEditor)(),r=(0,Mo.useSetAtom)(je),o=(0,Mo.useAtomValue)(oe),n=(l=t==null?void 0:t.getText())!=null?l:"",i=(0,Je.useMemo)(()=>new $g.SegmentedMessage(n),[n]),a=(0,Mo.useAtomValue)(se),c=(0,Je.useRef)(!1);return(0,Je.useEffect)(()=>{a&&(c.current=!1)},[a]),(0,Je.useEffect)(()=>{!t||a!==!1||c.current||!e||(c.current=!0,t.commands.setContent(e))},[t,e,a]),(0,Je.useEffect)(()=>{t&&(r(t),vr("sms",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Je.useEffect)(()=>{var y;if(!t||!o||t.isFocused)return;let u=Zg(o),d=u.type==="channel"&&"raw"in u&&((y=u.raw)==null?void 0:y.text)||"",g=$e({version:"2022-01-01",elements:[{type:"channel",channel:"sms",elements:d?[{type:"text",content:d}]:[{type:"text",content:`
|
|
193
193
|
`}]}]}),b=fe(g),h=fe(t.getJSON());JSON.stringify(b)!==JSON.stringify(h)&&setTimeout(()=>{t.isFocused||t.commands.setContent(g)},1)},[t,o]),(0,Dl.jsx)("span",{className:"courier-self-end courier-pr-2 courier-text-xs courier-color-gray-500",children:Math.ceil(((i==null?void 0:i.messageSize)||0)/8)})},"SMSEditorContent"),jg={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},gb=(0,Je.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,render:a,headerRenderer:c,value:l,...u},d)=>{let p=(0,Mo.useAtomValue)(se),m=(0,Je.useRef)(!0),g=(0,Je.useRef)(!1),b=(0,Mo.useSetAtom)(ge),[h,y]=(0,Mo.useAtom)(oe),P=(0,Mo.useAtomValue)(kt),w=(0,Je.useMemo)(()=>({urls:{unsubscribe:!0,preferences:!0},...r}),[r]);(0,Je.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]);let v=(0,Je.useMemo)(()=>[...fr({variables:w,setSelectedNode:b})].filter(T=>T!==void 0),[w,b]),f=(0,Je.useCallback)(({editor:T})=>{if(P)return;if(!h){let A=fe(T.getJSON()).filter(B=>B.type==="text"),I=s(B=>"content"in B&&B.content?B.content.trim():"","getTextContent"),D={version:"2022-01-01",elements:[{type:"channel",channel:"sms",raw:{text:A.map(I).join(" ").trim()}}]};y(D);return}let M=fe(T.getJSON()).filter(x=>x.type==="text"),k=s(x=>"content"in x&&x.content?x.content.trim():"","getTextContent"),S=M.map(k).join(" ").trim(),E=_t(h,{channel:{channel:"sms",raw:{text:S}}});JSON.stringify(h)!==JSON.stringify(E)&&y(E)},[h,y,P]),C=(0,Je.useMemo)(()=>{var S;if(p!==!1)return null;let T=l==null?void 0:l.elements.find(E=>E.type==="channel"&&E.channel==="sms");!T&&h&&(T=Zg(h));let R=(T==null?void 0:T.type)==="channel"&&"raw"in T&&((S=T.raw)==null?void 0:S.text)||"";return $e({version:"2022-01-01",elements:[{type:"channel",channel:"sms",elements:R?[{type:"text",content:R}]:[{type:"text",content:`
|
|
194
194
|
`}]}]})},[l,h,p]);return(0,Dl.jsx)(ar,{theme:e,isLoading:!!(p&&m.current),Header:c?c({hidePublish:t,channels:n,routing:i}):(0,Dl.jsx)(Ur,{hidePublish:t,channels:n,routing:i}),...u,ref:d,children:a==null?void 0:a({content:C,extensions:v,editable:!o,autofocus:!o,onUpdate:f})})}),Fl=(0,Je.memo)(gb);var Gg=require("@tiptap/react");var Xn=require("react/jsx-runtime"),Vl=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:a=!1})=>{let c=e||{type:"doc",content:[{type:"paragraph"}]},l=a?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,Xn.jsx)(Pl,{children:(0,Xn.jsx)("div",{className:N("courier-sms-editor",i),children:(0,Xn.jsxs)(Gg.EditorProvider,{content:c,extensions:t,...l,"data-testid":"editor-provider",immediatelyRender:!1,children:[(0,Xn.jsx)(qg,{value:c}),!a&&(0,Xn.jsx)(br,{config:jg})]})})})},"SMSEditor");var Jg=require("jotai");var Ol=require("react/jsx-runtime"),Kg=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,dataMode:i,...a})=>{let c=(0,Jg.useAtomValue)(oe);return(0,Ol.jsx)(Fl,{value:c,variables:r,theme:t,hidePublish:e,channels:o,routing:n,dataMode:i,render:l=>(0,Ol.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,Ol.jsx)(Vl,{...l})}),...a})},"SMSLayout");var Wl=require("@dnd-kit/core"),Xg=require("@tiptap/react"),_r=require("jotai"),ke=require("react");var Go=require("react/jsx-runtime"),Cd=[{type:"text",content:`
|
|
195
|
-
`}],Yg=s(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="msteams");return t||(t={type:"channel",channel:"msteams",elements:Cd}),t},"getOrCreateMSTeamsElement"),Qg=s(({value:e})=>{let{editor:t}=(0,Xg.useCurrentEditor)(),r=(0,_r.useSetAtom)(je),o=(0,_r.useAtomValue)(oe),n=(0,_r.useAtomValue)(se),i=(0,_r.useAtomValue)(ge),a=(0,ke.useRef)(!1),c=(0,ke.useRef)(!1);return(0,ke.useEffect)(()=>{n&&(a.current=!1)},[n]),(0,ke.useEffect)(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),(0,ke.useEffect)(()=>{t&&(r(t),vr("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,ke.useEffect)(()=>{t&&c.current&&t.commands.updateSelectionState(i)},[t,i]),(0,ke.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]),(0,ke.useEffect)(()=>{if(!t||!o||t.isFocused)return;let l=Yg(o),u=$e({version:"2022-01-01",elements:[l]},{channel:"msteams"}),d=fe(u),p=fe(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"MSTeamsEditorContent"),e5={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"}},hb=(0,ke.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:a,render:c,value:l},u)=>{let d=(0,_r.useAtomValue)(se),p=(0,ke.useRef)(!0),m=(0,ke.useRef)(!1),[g,b]=(0,_r.useAtom)(ge),[h,y]=(0,_r.useAtom)(oe),P=(0,_r.useAtomValue)(kt),w=(0,_r.useAtomValue)(je),[v,f]=(0,ke.useState)({Sidebar:["text","divider"],Editor:[]}),C=(0,ke.useRef)(null),{dndProps:T,activeDragType:R,activeId:M}=Fi({items:v,setItems:f}),k=(0,ke.useCallback)(A=>{C.current&&cancelAnimationFrame(C.current),setTimeout(()=>{C.current=requestAnimationFrame(()=>{try{let I=A==null?void 0:A.view.dom;if(!I){console.warn("syncEditorItems: Editor DOM element not found");return}let H=I.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),D=[];H.forEach(B=>{let z=B.dataset.id;z&&D.push(z)}),f(B=>({Editor:D,Sidebar:B.Sidebar}))}catch(I){console.error("Error syncing editor items:",I),f(H=>({...H}))}})},50)},[]);(0,ke.useEffect)(()=>(m.current=!0,()=>{m.current=!1}),[]),(0,ke.useEffect)(()=>{let A=s(()=>{w&&k(w)},"updateItems");w==null||w.on("update",A),w==null||w.on("selectionUpdate",A),w==null||w.on("create",A),w==null||w.on("transaction",A),w&&!w.isDestroyed&&A();let I=s(H=>{A()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",I),()=>{w==null||w.off("update",A),w==null||w.off("selectionUpdate",A),w==null||w.off("create",A),w==null||w.off("transaction",A),document.removeEventListener("node-duplicated",I),C.current&&cancelAnimationFrame(C.current)}},[w,k]),(0,ke.useEffect)(()=>{d===!1&&h&&setTimeout(()=>{w&&!w.isDestroyed&&k(w)},300)},[d,h,w,k]);let S=(0,ke.useMemo)(()=>[...fr({variables:r,setSelectedNode:b})].filter(A=>A!==void 0),[r,b]),E=(0,ke.useCallback)(({editor:A})=>{if(!A||P)return;if(!h){let ue={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:fe(A.getJSON())}]};y(ue);return}let I=A.getJSON(),H=fe(I),D=_t(h,{elements:H,channel:"msteams"}),B=JSON.stringify(h.elements),z=JSON.stringify(D.elements);B!==z&&setTimeout(()=>{m.current&&y(D)},100)},[h,y,P]),x=(0,ke.useMemo)(()=>{let A=Yg(l);return $e({version:"2022-01-01",elements:[A]},{channel:"msteams"})},[l]);return(0,Go.jsx)(ar,{theme:e,isLoading:!!(d&&p.current),Header:a?a({hidePublish:t,channels:n,routing:i}):(0,Go.jsx)(Ur,{hidePublish:t,channels:n,routing:i}),ref:u,children:(0,Go.jsxs)(Wl.DndContext,{...T,children:[c==null?void 0:c({content:x,extensions:S,editable:!o,autofocus:!o,onUpdate:E,items:v,selectedNode:g,msteamsEditor:w}),(0,Go.jsx)(Wl.DragOverlay,{dropAnimation:null,children:M&&(M==="text"||M==="divider")?(0,Go.jsxs)("div",{className:N("courier-bg-white courier-border courier-border-border courier-rounded-lg courier-p-4 courier-shadow-lg","courier-opacity-90 courier-scale-105 courier-transition-transform"),children:[R==="text"&&(0,Go.jsx)(ir,{draggable:!0}),R==="divider"&&(0,Go.jsx)(nr,{draggable:!0})]}):null})]})})}),Ul=(0,ke.memo)(hb);var r5=require("@tiptap/react");var Ue=require("react/jsx-runtime"),bb=s(()=>(0,Ue.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] courier-rounded-full",children:(0,Ue.jsx)(la,{className:"courier-mx-auto courier-h-full"})}),"AvatarSkeleton"),yb=s(()=>(0,Ue.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[(0,Ue.jsx)(bb,{}),(0,Ue.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[(0,Ue.jsx)("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] courier-rounded-[12px]"}),(0,Ue.jsx)("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),vb=s(()=>(0,Ue.jsx)("div",{className:"courier-flex courier-justify-end courier-w-full",children:(0,Ue.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:(0,Ue.jsx)("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),t5=s(({children:e,className:t})=>(0,Ue.jsxs)("div",{className:N("courier-w-full courier-max-w-[800px] courier-bg-white courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Ue.jsx)(yb,{}),(0,Ue.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Ue.jsx)("div",{className:"courier-flex-shrink-0 courier-mt-6",children:(0,Ue.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-full courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,Ue.jsx)(sa,{color:"#FFFFFF"})})}),(0,Ue.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Ue.jsx)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:(0,Ue.jsx)("span",{className:"courier-text-sm courier-text-[#A3A3A3]",children:"Circle"})}),(0,Ue.jsx)("div",{className:"courier-bg-[#F5F5F5] courier-rounded-[12px] courier-px-3 courier-py-2 courier-text-sm courier-text-gray-900 courier-leading-relaxed courier-max-w-full",children:e})]})]}),(0,Ue.jsx)(vb,{})]}),"MSTeamsFrame");var zl=require("@dnd-kit/sortable"),o5=require("@dnd-kit/core");var mn=require("react/jsx-runtime"),$l=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,items:i})=>{let{setNodeRef:a}=(0,o5.useDroppable)({id:"Editor"});return e?(0,mn.jsx)(t5,{children:(0,mn.jsx)("div",{ref:a,children:(0,mn.jsx)(zl.SortableContext,{items:i.Editor,strategy:zl.verticalListSortingStrategy,children:(0,mn.jsxs)(r5.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:N("courier-msteams-editor")},immediatelyRender:!1,children:[(0,mn.jsx)(Qg,{value:e}),(0,mn.jsx)(br,{config:e5})]})})})}):null},"MSTeamsEditor");var a5=require("jotai");var n5=require("@dnd-kit/core"),_l=require("@dnd-kit/sortable"),i5=require("lucide-react");var It=require("react/jsx-runtime"),Zl=s(({items:e,label:t})=>{let{setNodeRef:r}=(0,n5.useDroppable)({id:"Sidebar"});return(0,It.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",ref:r,children:(0,It.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,It.jsxs)(It.Fragment,{children:[(0,It.jsx)("p",{children:t}),(0,It.jsx)(le,{className:"courier-my-4"})]}),(0,It.jsx)(_l.SortableContext,{items:e,strategy:_l.verticalListSortingStrategy,children:(0,It.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,It.jsx)(Wi,{id:o.toString(),children:(0,It.jsxs)("div",{className:N("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-white courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,It.jsx)(i5.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-ring courier-fill-ring"}),o==="text"&&(0,It.jsx)(ir,{draggable:!0}),o==="divider"&&(0,It.jsx)(nr,{draggable:!0}),o==="button"&&(0,It.jsx)(Hr,{draggable:!0})]})},o))})})]})})},"MSTeamsSideBar");var Td=require("react");var Ar=require("react/jsx-runtime"),xb=(0,Td.forwardRef)(({children:e,className:t,...r},o)=>(0,Ar.jsx)("div",{className:N("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Cb=(0,Td.forwardRef)(({children:e,...t},r)=>(0,Ar.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),s5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n})=>{let i=(0,a5.useAtomValue)(oe);return(0,Ar.jsx)(Ul,{value:i,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:a=>(0,Ar.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,Ar.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Ar.jsx)(xb,{children:(0,Ar.jsx)(Cb,{children:(0,Ar.jsx)($l,{...a})})})}),(0,Ar.jsx)(dn,{children:(0,Ar.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,Ar.jsx)(Zl,{items:a.items.Sidebar,label:"Blocks library"})})})]})})},"MSTeamsLayout");var l5={sms:{elements:[],raw:_g.raw},push:{elements:[],raw:Cg.raw},inbox:{elements:hd},slack:{elements:yd},email:{elements:ad},msteams:{elements:Cd}},c5=s(e=>{var t;return(t=l5[e])!=null?t:l5.email},"getChannelDefaults"),Tb=s((e,t)=>{if(e!=null&&e.channels&&e.channels.length>0){let r=e.channels.filter(o=>typeof o=="string");if(r.length>0)return r}return t!=null?t:["email"]},"resolveChannels"),ql=s(({channels:e=["email"],routing:t})=>{let[r,o]=(0,Zr.useState)([]),n=(0,fn.useAtomValue)(oe),i=(0,fn.useSetAtom)(oe),[a,c]=(0,fn.useAtom)(us),l=(0,fn.useSetAtom)(ge),u=(0,fn.useAtomValue)(se),{saveTemplate:d}=Yo(),p=Tb(t,e),m=(0,Zr.useRef)(p);m.current=p,(0,Zr.useEffect)(()=>{if(u)return;let P=m.current;if(!n||!n.elements){let f=P.map(C=>vi.find(T=>T.value===C)).filter(C=>!!C);o(f),f.length>0&&c(f[0].value);return}let w=n.elements.filter(f=>f.type==="channel").map(f=>f.channel).filter(f=>P.includes(f)),v=P.filter(f=>w.includes(f)).map(f=>vi.find(C=>C.value===f)).filter(f=>!!f);o(v)},[n,u,c]);let g=(0,Zr.useMemo)(()=>(p==null?void 0:p.filter(P=>!r.some(w=>w.value===P)).map(P=>vi.find(w=>w.value===P)).filter(P=>!!P))||[],[r,p]),b=(0,Zr.useCallback)(P=>{let w=[],v,{elements:f,raw:C}=c5(P);if(w=f,v=C,!n){let M=[];for(let E of r){let{elements:x,raw:A}=c5(E.value),I={type:"channel",channel:E.value,...E.value==="push"?{}:{elements:x}};A&&(I.raw=A),M.push(I)}let k={type:"channel",channel:P,...P==="push"||P==="sms"?{}:{elements:w}};v&&(k.raw=v),M.push(k),i({version:"2022-01-01",elements:M}),c(P);return}let T={...P==="push"||P==="sms"?{}:{elements:w},channel:v?{channel:P,raw:v}:P},R=_t(n,T);i(R),c(P)},[n,i,c,r]),h=(0,Zr.useCallback)(async P=>{if(!n)return;let w=n.elements.filter(C=>C.type==="channel"?C.channel!==P:!0),v={...n,elements:w};i(v),l(null);let f=r.filter(C=>C.value!==P);if(a===P&&f.length>0&&c(f[0].value),t)try{await d(t)}catch(C){console.error("Failed to save template after removing channel:",C)}},[n,i,r,a,c,l,t,d]),y=(0,Zr.useMemo)(()=>[...r,...g],[r,g]);return{enabledChannels:r,disabledChannels:g,channel:a,channelOptions:y,setChannel:c,addChannel:b,removeChannel:h}},"useChannels");var be=require("react/jsx-runtime"),Ur=s(({hidePublish:e=!1,channels:t,routing:r})=>{let o=(0,No.useRef)(null),n=(0,Jo.useAtomValue)(Et),i=(0,Jo.useAtomValue)(se),a=(0,Jo.useAtomValue)(re),{publishTemplate:c,isTemplatePublishing:l}=Yo(),[u,d]=(0,Jo.useAtom)(ri),p=(0,Jo.useSetAtom)(ho),m=(0,Jo.useAtomValue)(ho),{enabledChannels:g,disabledChannels:b,channel:h,setChannel:y,addChannel:P,removeChannel:w}=ql({channels:t,routing:r});(0,No.useEffect)(()=>{n===!0&&d(null)},[n,d]);let v=(0,No.useCallback)(()=>{m&&p(!1),c()},[c,m,p]),f=(0,No.useCallback)(M=>{m&&p(!1),y(M)},[m,p,y]),C=(0,No.useCallback)(M=>{m&&p(!1),P(M)},[m,p,P]),T=(0,No.useCallback)(M=>{m&&p(!1),w(M)},[m,p,w]),R=(0,No.useCallback)(()=>{m&&p(!1)},[m,p]);return(0,be.jsxs)("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:R,children:[(0,be.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[(0,be.jsx)(ts,{value:h,onValueChange:f,className:"courier-h-full",ref:o,children:(0,be.jsx)(Yi,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${vi.length}, fit-content(100%))`},children:g.map(M=>(0,be.jsxs)(mi,{value:M.value,className:"!courier-px-2 courier-w-full courier-flex courier-items-center courier-justify-between courier-h-full courier-border-b-2 courier-border-b-transparent !courier-rounded-none data-[state=active]:courier-bg-transparent data-[state=active]:courier-text-foreground data-[state=active]:courier-border-b-accent-foreground",children:[M.label,M.value===h&&g.length>1&&(0,be.jsxs)(pp,{children:[(0,be.jsx)(mp,{asChild:!0,children:(0,be.jsx)("div",{className:"courier-pl-2",children:(0,be.jsx)(Qi,{color:"#A3A3A3"})})}),(0,be.jsxs)(cc,{ref:o,children:[(0,be.jsx)(uc,{children:(0,be.jsx)(u5.AlertDialogDescription,{children:"Are you sure you want to delete this channel?"})}),(0,be.jsxs)(dc,{children:[(0,be.jsx)(mc,{asChild:!0,children:(0,be.jsx)(Ne,{buttonSize:"small",variant:"outline",children:"Cancel"})}),(0,be.jsx)(pc,{asChild:!0,children:(0,be.jsx)(Ne,{buttonSize:"small",variant:"primary",onClick:()=>T(M.value),children:"Delete"})})]})]})]})]},M.value))})}),b.length>0&&(0,be.jsxs)(be.Fragment,{children:[(0,be.jsx)(yc,{orientation:"vertical",className:"!courier-h-5"}),(0,be.jsxs)(Ka,{children:[(0,be.jsx)(Xa,{asChild:!0,children:(0,be.jsx)(Ne,{variant:"link",children:"+ Add channel"})}),(0,be.jsx)(Gi,{portalProps:{container:o.current},children:b.map(M=>(0,be.jsxs)(Ji,{onClick:()=>C(M.value),children:[M.icon,M.label]},M.value))})]})]})]}),(0,be.jsxs)("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&(0,be.jsx)(yi,{isLoading:!!i,isSaving:!!n,isError:!!a}),!e&&i!==null&&(0,be.jsx)(Ne,{variant:"primary",buttonSize:"small",disabled:l===!0||n===!0||u!==null,onClick:v,children:l?"Publishing...":"Publish changes"})]})]})},"Channels");var w5=require("@dnd-kit/sortable");var po=require("react");function zi({onSave:e,debounceMs:t=200,enabled:r=!0,onError:o,initialContent:n}){let[i,a]=(0,po.useState)(!1),c=(0,po.useRef)(null),l=(0,po.useRef)(),u=(0,po.useRef)(0),d=(0,po.useRef)();(0,po.useEffect)(()=>{n&&(l.current=JSON.stringify(n))},[n]);let p=(0,po.useCallback)(async m=>{if(!r)return;c.current=m,d.current&&(clearTimeout(d.current),d.current=void 0);let g=s(async()=>{let P=c.current;if(c.current=null,!!P){try{let w=JSON.stringify(P);if(w===l.current)return;a(!0),l.current=w,u.current=Date.now(),await e(P)}catch(w){o==null||o(w),a(!1);return}a(!1),c.current&&p(c.current)}},"processPendingContent");if(i)return;let h=Date.now()-u.current,y=Math.max(0,t-h);d.current=setTimeout(()=>{d.current=void 0,g()},y)},[t,r,i,o,e]);return{handleAutoSave:p,isSaving:i}}s(zi,"useAutoSave");var Rt=require("jotai"),Re=require("react");var So=require("jotai"),Lt=require("react");var Kt=require("zod"),d5=Kt.z.object({headerStyle:Kt.z.enum(["plain","border"]),isUnsubscribe:Kt.z.boolean().optional(),isPreferences:Kt.z.boolean().optional(),link:Kt.z.string().optional(),brandColor:Kt.z.string(),textColor:Kt.z.string(),subtleColor:Kt.z.string(),logo:Kt.z.string().optional(),facebookLink:Kt.z.string().optional(),linkedinLink:Kt.z.string().optional(),instagramLink:Kt.z.string().optional(),mediumLink:Kt.z.string().optional(),xLink:Kt.z.string().optional()}),Xt={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};var wb=s(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),za=s(e=>{var t,r,o,n,i,a,c,l,u,d,p,m,g,b;switch(e.type){case"variable":return`{{${(t=e.attrs)==null?void 0:t.id}}}`;case"text":{let h=e.text||"";if((r=e.marks)!=null&&r.length){let P=e.marks.map(wb).filter(Boolean);h=P.join("")+h+P.reverse().join("")}let y=(o=e.marks)==null?void 0:o.find(P=>P.type==="link");return y&&(h=`[${h}](${(n=y.attrs)==null?void 0:n.href})`),h}case"hardBreak":return`
|
|
195
|
+
`}],Yg=s(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="msteams");return t||(t={type:"channel",channel:"msteams",elements:Cd}),t},"getOrCreateMSTeamsElement"),Qg=s(({value:e})=>{let{editor:t}=(0,Xg.useCurrentEditor)(),r=(0,_r.useSetAtom)(je),o=(0,_r.useAtomValue)(oe),n=(0,_r.useAtomValue)(se),i=(0,_r.useAtomValue)(ge),a=(0,ke.useRef)(!1),c=(0,ke.useRef)(!1);return(0,ke.useEffect)(()=>{n&&(a.current=!1)},[n]),(0,ke.useEffect)(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),(0,ke.useEffect)(()=>{t&&(r(t),vr("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,ke.useEffect)(()=>{t&&c.current&&t.commands.updateSelectionState(i)},[t,i]),(0,ke.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]),(0,ke.useEffect)(()=>{if(!t||!o||t.isFocused)return;let l=Yg(o),u=$e({version:"2022-01-01",elements:[l]},{channel:"msteams"}),d=fe(u),p=fe(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"MSTeamsEditorContent"),e5={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"}},hb=(0,ke.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:a,render:c,value:l},u)=>{let d=(0,_r.useAtomValue)(se),p=(0,ke.useRef)(!0),m=(0,ke.useRef)(!1),[g,b]=(0,_r.useAtom)(ge),[h,y]=(0,_r.useAtom)(oe),P=(0,_r.useAtomValue)(kt),w=(0,_r.useAtomValue)(je),[v,f]=(0,ke.useState)({Sidebar:["text","divider"],Editor:[]}),C=(0,ke.useRef)(null),{dndProps:T,activeDragType:R,activeId:M}=Fi({items:v,setItems:f}),k=(0,ke.useCallback)(A=>{C.current&&cancelAnimationFrame(C.current),setTimeout(()=>{C.current=requestAnimationFrame(()=>{try{let I=A==null?void 0:A.view.dom;if(!I){console.warn("syncEditorItems: Editor DOM element not found");return}let H=I.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),D=[];H.forEach(B=>{let z=B.dataset.id;z&&D.push(z)}),f(B=>({Editor:D,Sidebar:B.Sidebar}))}catch(I){console.error("Error syncing editor items:",I),f(H=>({...H}))}})},50)},[]);(0,ke.useEffect)(()=>(m.current=!0,()=>{m.current=!1}),[]),(0,ke.useEffect)(()=>{let A=s(()=>{w&&k(w)},"updateItems");w==null||w.on("update",A),w==null||w.on("selectionUpdate",A),w==null||w.on("create",A),w==null||w.on("transaction",A),w&&!w.isDestroyed&&A();let I=s(H=>{A()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",I),()=>{w==null||w.off("update",A),w==null||w.off("selectionUpdate",A),w==null||w.off("create",A),w==null||w.off("transaction",A),document.removeEventListener("node-duplicated",I),C.current&&cancelAnimationFrame(C.current)}},[w,k]),(0,ke.useEffect)(()=>{d===!1&&h&&setTimeout(()=>{w&&!w.isDestroyed&&k(w)},300)},[d,h,w,k]);let S=(0,ke.useMemo)(()=>[...fr({variables:r,setSelectedNode:b})].filter(A=>A!==void 0),[r,b]),E=(0,ke.useCallback)(({editor:A})=>{if(!A||P)return;if(!h){let ue={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:fe(A.getJSON())}]};y(ue);return}let I=A.getJSON(),H=fe(I),D=_t(h,{elements:H,channel:"msteams"}),B=JSON.stringify(h.elements),z=JSON.stringify(D.elements);B!==z&&setTimeout(()=>{m.current&&y(D)},100)},[h,y,P]),x=(0,ke.useMemo)(()=>{let A=Yg(l);return $e({version:"2022-01-01",elements:[A]},{channel:"msteams"})},[l]);return(0,Go.jsx)(ar,{theme:e,isLoading:!!(d&&p.current),Header:a?a({hidePublish:t,channels:n,routing:i}):(0,Go.jsx)(Ur,{hidePublish:t,channels:n,routing:i}),ref:u,children:(0,Go.jsxs)(Wl.DndContext,{...T,children:[c==null?void 0:c({content:x,extensions:S,editable:!o,autofocus:!o,onUpdate:E,items:v,selectedNode:g,msteamsEditor:w}),(0,Go.jsx)(Wl.DragOverlay,{dropAnimation:null,children:M&&(M==="text"||M==="divider")?(0,Go.jsxs)("div",{className:N("courier-bg-white courier-border courier-border-border courier-rounded-lg courier-p-4 courier-shadow-lg","courier-opacity-90 courier-scale-105 courier-transition-transform"),children:[R==="text"&&(0,Go.jsx)(ir,{draggable:!0}),R==="divider"&&(0,Go.jsx)(nr,{draggable:!0})]}):null})]})})}),Ul=(0,ke.memo)(hb);var r5=require("@tiptap/react");var Ue=require("react/jsx-runtime"),bb=s(()=>(0,Ue.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] courier-rounded-full",children:(0,Ue.jsx)(la,{className:"courier-mx-auto courier-h-full"})}),"AvatarSkeleton"),yb=s(()=>(0,Ue.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[(0,Ue.jsx)(bb,{}),(0,Ue.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[(0,Ue.jsx)("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] courier-rounded-[12px]"}),(0,Ue.jsx)("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),vb=s(()=>(0,Ue.jsx)("div",{className:"courier-flex courier-justify-end courier-w-full",children:(0,Ue.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:(0,Ue.jsx)("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),t5=s(({children:e,className:t})=>(0,Ue.jsxs)("div",{className:N("courier-w-full courier-max-w-[800px] courier-bg-white courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Ue.jsx)(yb,{}),(0,Ue.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Ue.jsx)("div",{className:"courier-flex-shrink-0 courier-mt-6",children:(0,Ue.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-full courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,Ue.jsx)(sa,{color:"#FFFFFF"})})}),(0,Ue.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Ue.jsx)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:(0,Ue.jsx)("span",{className:"courier-text-sm courier-text-[#A3A3A3]",children:"Circle"})}),(0,Ue.jsx)("div",{className:"courier-bg-[#F5F5F5] courier-rounded-[12px] courier-px-3 courier-py-2 courier-text-sm courier-text-gray-900 courier-leading-relaxed courier-max-w-full courier-pr-5",children:e})]})]}),(0,Ue.jsx)(vb,{})]}),"MSTeamsFrame");var zl=require("@dnd-kit/sortable"),o5=require("@dnd-kit/core");var mn=require("react/jsx-runtime"),$l=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,items:i})=>{let{setNodeRef:a}=(0,o5.useDroppable)({id:"Editor"});return e?(0,mn.jsx)(t5,{children:(0,mn.jsx)("div",{ref:a,children:(0,mn.jsx)(zl.SortableContext,{items:i.Editor,strategy:zl.verticalListSortingStrategy,children:(0,mn.jsxs)(r5.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:N("courier-msteams-editor")},immediatelyRender:!1,children:[(0,mn.jsx)(Qg,{value:e}),(0,mn.jsx)(br,{config:e5})]})})})}):null},"MSTeamsEditor");var a5=require("jotai");var n5=require("@dnd-kit/core"),_l=require("@dnd-kit/sortable"),i5=require("lucide-react");var It=require("react/jsx-runtime"),Zl=s(({items:e,label:t})=>{let{setNodeRef:r}=(0,n5.useDroppable)({id:"Sidebar"});return(0,It.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",ref:r,children:(0,It.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,It.jsxs)(It.Fragment,{children:[(0,It.jsx)("p",{children:t}),(0,It.jsx)(le,{className:"courier-my-4"})]}),(0,It.jsx)(_l.SortableContext,{items:e,strategy:_l.verticalListSortingStrategy,children:(0,It.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,It.jsx)(Wi,{id:o.toString(),children:(0,It.jsxs)("div",{className:N("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-white courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,It.jsx)(i5.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-ring courier-fill-ring"}),o==="text"&&(0,It.jsx)(ir,{draggable:!0}),o==="divider"&&(0,It.jsx)(nr,{draggable:!0}),o==="button"&&(0,It.jsx)(Hr,{draggable:!0})]})},o))})})]})})},"MSTeamsSideBar");var Td=require("react");var Ar=require("react/jsx-runtime"),xb=(0,Td.forwardRef)(({children:e,className:t,...r},o)=>(0,Ar.jsx)("div",{className:N("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Cb=(0,Td.forwardRef)(({children:e,...t},r)=>(0,Ar.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),s5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n})=>{let i=(0,a5.useAtomValue)(oe);return(0,Ar.jsx)(Ul,{value:i,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:a=>(0,Ar.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,Ar.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Ar.jsx)(xb,{children:(0,Ar.jsx)(Cb,{children:(0,Ar.jsx)($l,{...a})})})}),(0,Ar.jsx)(dn,{children:(0,Ar.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,Ar.jsx)(Zl,{items:a.items.Sidebar,label:"Blocks library"})})})]})})},"MSTeamsLayout");var l5={sms:{elements:[],raw:_g.raw},push:{elements:[],raw:Cg.raw},inbox:{elements:hd},slack:{elements:yd},email:{elements:ad},msteams:{elements:Cd}},c5=s(e=>{var t;return(t=l5[e])!=null?t:l5.email},"getChannelDefaults"),Tb=s((e,t)=>{if(e!=null&&e.channels&&e.channels.length>0){let r=e.channels.filter(o=>typeof o=="string");if(r.length>0)return r}return t!=null?t:["email"]},"resolveChannels"),ql=s(({channels:e=["email"],routing:t})=>{let[r,o]=(0,Zr.useState)([]),n=(0,fn.useAtomValue)(oe),i=(0,fn.useSetAtom)(oe),[a,c]=(0,fn.useAtom)(us),l=(0,fn.useSetAtom)(ge),u=(0,fn.useAtomValue)(se),{saveTemplate:d}=Yo(),p=Tb(t,e),m=(0,Zr.useRef)(p);m.current=p,(0,Zr.useEffect)(()=>{if(u)return;let P=m.current;if(!n||!n.elements){let f=P.map(C=>vi.find(T=>T.value===C)).filter(C=>!!C);o(f),f.length>0&&c(f[0].value);return}let w=n.elements.filter(f=>f.type==="channel").map(f=>f.channel).filter(f=>P.includes(f)),v=P.filter(f=>w.includes(f)).map(f=>vi.find(C=>C.value===f)).filter(f=>!!f);o(v)},[n,u,c]);let g=(0,Zr.useMemo)(()=>(p==null?void 0:p.filter(P=>!r.some(w=>w.value===P)).map(P=>vi.find(w=>w.value===P)).filter(P=>!!P))||[],[r,p]),b=(0,Zr.useCallback)(P=>{let w=[],v,{elements:f,raw:C}=c5(P);if(w=f,v=C,!n){let M=[];for(let E of r){let{elements:x,raw:A}=c5(E.value),I={type:"channel",channel:E.value,...E.value==="push"?{}:{elements:x}};A&&(I.raw=A),M.push(I)}let k={type:"channel",channel:P,...P==="push"||P==="sms"?{}:{elements:w}};v&&(k.raw=v),M.push(k),i({version:"2022-01-01",elements:M}),c(P);return}let T={...P==="push"||P==="sms"?{}:{elements:w},channel:v?{channel:P,raw:v}:P},R=_t(n,T);i(R),c(P)},[n,i,c,r]),h=(0,Zr.useCallback)(async P=>{if(!n)return;let w=n.elements.filter(C=>C.type==="channel"?C.channel!==P:!0),v={...n,elements:w};i(v),l(null);let f=r.filter(C=>C.value!==P);if(a===P&&f.length>0&&c(f[0].value),t)try{await d(t)}catch(C){console.error("Failed to save template after removing channel:",C)}},[n,i,r,a,c,l,t,d]),y=(0,Zr.useMemo)(()=>[...r,...g],[r,g]);return{enabledChannels:r,disabledChannels:g,channel:a,channelOptions:y,setChannel:c,addChannel:b,removeChannel:h}},"useChannels");var be=require("react/jsx-runtime"),Ur=s(({hidePublish:e=!1,channels:t,routing:r})=>{let o=(0,No.useRef)(null),n=(0,Jo.useAtomValue)(Et),i=(0,Jo.useAtomValue)(se),a=(0,Jo.useAtomValue)(re),{publishTemplate:c,isTemplatePublishing:l}=Yo(),[u,d]=(0,Jo.useAtom)(ri),p=(0,Jo.useSetAtom)(ho),m=(0,Jo.useAtomValue)(ho),{enabledChannels:g,disabledChannels:b,channel:h,setChannel:y,addChannel:P,removeChannel:w}=ql({channels:t,routing:r});(0,No.useEffect)(()=>{n===!0&&d(null)},[n,d]);let v=(0,No.useCallback)(()=>{m&&p(!1),c()},[c,m,p]),f=(0,No.useCallback)(M=>{m&&p(!1),y(M)},[m,p,y]),C=(0,No.useCallback)(M=>{m&&p(!1),P(M)},[m,p,P]),T=(0,No.useCallback)(M=>{m&&p(!1),w(M)},[m,p,w]),R=(0,No.useCallback)(()=>{m&&p(!1)},[m,p]);return(0,be.jsxs)("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:R,children:[(0,be.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[(0,be.jsx)(ts,{value:h,onValueChange:f,className:"courier-h-full",ref:o,children:(0,be.jsx)(Yi,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${vi.length}, fit-content(100%))`},children:g.map(M=>(0,be.jsxs)(mi,{value:M.value,className:"!courier-px-2 courier-w-full courier-flex courier-items-center courier-justify-between courier-h-full courier-border-b-2 courier-border-b-transparent !courier-rounded-none data-[state=active]:courier-bg-transparent data-[state=active]:courier-text-foreground data-[state=active]:courier-border-b-accent-foreground",children:[M.label,M.value===h&&g.length>1&&(0,be.jsxs)(pp,{children:[(0,be.jsx)(mp,{asChild:!0,children:(0,be.jsx)("div",{className:"courier-pl-2",children:(0,be.jsx)(Qi,{color:"#A3A3A3"})})}),(0,be.jsxs)(cc,{ref:o,children:[(0,be.jsx)(uc,{children:(0,be.jsx)(u5.AlertDialogDescription,{children:"Are you sure you want to delete this channel?"})}),(0,be.jsxs)(dc,{children:[(0,be.jsx)(mc,{asChild:!0,children:(0,be.jsx)(Ne,{buttonSize:"small",variant:"outline",children:"Cancel"})}),(0,be.jsx)(pc,{asChild:!0,children:(0,be.jsx)(Ne,{buttonSize:"small",variant:"primary",onClick:()=>T(M.value),children:"Delete"})})]})]})]})]},M.value))})}),b.length>0&&(0,be.jsxs)(be.Fragment,{children:[(0,be.jsx)(yc,{orientation:"vertical",className:"!courier-h-5"}),(0,be.jsxs)(Ka,{children:[(0,be.jsx)(Xa,{asChild:!0,children:(0,be.jsx)(Ne,{variant:"link",children:"+ Add channel"})}),(0,be.jsx)(Gi,{portalProps:{container:o.current},children:b.map(M=>(0,be.jsxs)(Ji,{onClick:()=>C(M.value),children:[M.icon,M.label]},M.value))})]})]})]}),(0,be.jsxs)("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&(0,be.jsx)(yi,{isLoading:!!i,isSaving:!!n,isError:!!a}),!e&&i!==null&&(0,be.jsx)(Ne,{variant:"primary",buttonSize:"small",disabled:l===!0||n===!0||u!==null,onClick:v,children:l?"Publishing...":"Publish changes"})]})]})},"Channels");var w5=require("@dnd-kit/sortable");var po=require("react");function zi({onSave:e,debounceMs:t=200,enabled:r=!0,onError:o,initialContent:n}){let[i,a]=(0,po.useState)(!1),c=(0,po.useRef)(null),l=(0,po.useRef)(),u=(0,po.useRef)(0),d=(0,po.useRef)();(0,po.useEffect)(()=>{n&&(l.current=JSON.stringify(n))},[n]);let p=(0,po.useCallback)(async m=>{if(!r)return;c.current=m,d.current&&(clearTimeout(d.current),d.current=void 0);let g=s(async()=>{let P=c.current;if(c.current=null,!!P){try{let w=JSON.stringify(P);if(w===l.current)return;a(!0),l.current=w,u.current=Date.now(),await e(P)}catch(w){o==null||o(w),a(!1);return}a(!1),c.current&&p(c.current)}},"processPendingContent");if(i)return;let h=Date.now()-u.current,y=Math.max(0,t-h);d.current=setTimeout(()=>{d.current=void 0,g()},y)},[t,r,i,o,e]);return{handleAutoSave:p,isSaving:i}}s(zi,"useAutoSave");var Rt=require("jotai"),Re=require("react");var So=require("jotai"),Lt=require("react");var Kt=require("zod"),d5=Kt.z.object({headerStyle:Kt.z.enum(["plain","border"]),isUnsubscribe:Kt.z.boolean().optional(),isPreferences:Kt.z.boolean().optional(),link:Kt.z.string().optional(),brandColor:Kt.z.string(),textColor:Kt.z.string(),subtleColor:Kt.z.string(),logo:Kt.z.string().optional(),facebookLink:Kt.z.string().optional(),linkedinLink:Kt.z.string().optional(),instagramLink:Kt.z.string().optional(),mediumLink:Kt.z.string().optional(),xLink:Kt.z.string().optional()}),Xt={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};var wb=s(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),za=s(e=>{var t,r,o,n,i,a,c,l,u,d,p,m,g,b;switch(e.type){case"variable":return`{{${(t=e.attrs)==null?void 0:t.id}}}`;case"text":{let h=e.text||"";if((r=e.marks)!=null&&r.length){let P=e.marks.map(wb).filter(Boolean);h=P.join("")+h+P.reverse().join("")}let y=(o=e.marks)==null?void 0:o.find(P=>P.type==="link");return y&&(h=`[${h}](${(n=y.attrs)==null?void 0:n.href})`),h}case"hardBreak":return`
|
|
196
196
|
`;case"paragraph":return(((i=e.content)==null?void 0:i.map(za).join(""))||"")+`
|
|
197
197
|
|
|
198
198
|
`;case"heading":{let h=((a=e.attrs)==null?void 0:a.level)||1,y="#".repeat(h)+" ",P=((c=e.content)==null?void 0:c.map(za).join(""))||"";return y+P+`
|