@trycourier/react-designer 0.0.0-canary-20251210083502 → 0.0.0-canary-20251210115724
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 +50 -52
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/styles.css +13 -25
- package/dist/components/BrandEditor/BrandEditor.d.ts +1 -1
- package/dist/components/BrandEditor/Editor/BrandFooter/BrandFooter.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/Email/EmailEditor.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/Email/SideBar/SideBarItemDetails/SideBarItemDetails.d.ts +1 -3
- package/dist/components/extensions/Button/ButtonForm.d.ts +1 -3
- package/dist/components/extensions/ImageBlock/components/ImageBlockForm.d.ts +1 -3
- package/dist/components/extensions/Variable/Variable.d.ts +5 -2
- package/dist/components/extensions/Variable/Variable.types.d.ts +0 -35
- package/dist/components/extensions/Variable/index.d.ts +0 -1
- package/dist/components/extensions/extension-kit.d.ts +0 -2
- package/dist/components/extensions/index.d.ts +1 -1
- package/dist/components/ui/TextInput/TextInput.d.ts +0 -3
- package/dist/components/ui/VariableEditor/VariableChipBase.d.ts +35 -0
- package/dist/components/ui/VariableEditor/shared.d.ts +2 -6
- package/dist/esm/index.js +52 -54
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/styles.css +13 -25
- package/dist/styles.css +13 -25
- package/package.json +1 -1
- package/dist/components/extensions/Variable/VariableSuggestions.d.ts +0 -7
- package/dist/components/extensions/Variable/VariableTypeHandler.d.ts +0 -6
- package/dist/components/extensions/Variable/suggestion.d.ts +0 -2
package/dist/cjs/index.js
CHANGED
|
@@ -43,7 +43,7 @@ if (typeof require !== "undefined") {
|
|
|
43
43
|
console.warn('Unable to setup tippy imports polyfill');
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
"use strict";var
|
|
46
|
+
"use strict";var X5=Object.create;var Oi=Object.defineProperty;var Q5=Object.getOwnPropertyDescriptor;var e2=Object.getOwnPropertyNames;var t2=Object.getPrototypeOf,r2=Object.prototype.hasOwnProperty;var s=(e,t)=>Oi(e,"name",{value:t,configurable:!0});var Ec=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),o2=(e,t)=>{for(var r in t)Oi(e,r,{get:t[r],enumerable:!0})},jd=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of e2(t))!r2.call(e,n)&&n!==r&&Oi(e,n,{get:()=>t[n],enumerable:!(o=Q5(t,n))||o.enumerable});return e};var he=(e,t,r)=>(r=e!=null?X5(t2(e)):{},jd(t||!e||!e.__esModule?Oi(r,"default",{value:e,enumerable:!0}):r,e)),n2=e=>jd(Oi({},"__esModule",{value:!0}),e);var _u=Ec(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.bind=void 0;function D2(e,t){var r=t.type,o=t.listener,n=t.options;return e.addEventListener(r,o,n),s(function(){e.removeEventListener(r,o,n)},"unbind")}s(D2,"bind");Ts.bind=D2});var gp=Ec(si=>{"use strict";var ai=si&&si.__assign||function(){return ai=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},ai.apply(this,arguments)};Object.defineProperty(si,"__esModule",{value:!0});si.bindAll=void 0;var F2=_u();function fp(e){if(typeof e!="undefined")return typeof e=="boolean"?{capture:e}:e}s(fp,"toOptions");function V2(e,t){if(t==null)return e;var r=ai(ai({},e),{options:ai(ai({},fp(t)),fp(e.options))});return r}s(V2,"getBinding");function O2(e,t,r){var o=t.map(function(n){var i=V2(n,r);return(0,F2.bind)(e,i)});return s(function(){o.forEach(function(i){return i()})},"unbindAll")}s(O2,"bindAll");si.bindAll=O2});var ua=Ec(li=>{"use strict";Object.defineProperty(li,"__esModule",{value:!0});li.bindAll=li.bind=void 0;var U2=_u();Object.defineProperty(li,"bind",{enumerable:!0,get:function(){return U2.bind}});var W2=gp();Object.defineProperty(li,"bindAll",{enumerable:!0,get:function(){return W2.bindAll}})});var Zb={};o2(Zb,{BrandEditor:()=>Jd,BrandFooter:()=>ki,BrandProvider:()=>Gd,CHANNELS:()=>Oo,ChannelRootContainer:()=>nn,EditorSidebar:()=>an,EmailChannel:()=>Ob,EmailEditor:()=>Kl,EmailEditorContainer:()=>Vd,EmailEditorMain:()=>Od,EmailSideBar:()=>Xl,EmailSideBarItemDetails:()=>Ql,ErrorBoundary:()=>is,InboxChannel:()=>_b,InboxEditor:()=>tc,InboxSideBar:()=>oc,MSTeamsChannel:()=>zb,MSTeamsEditor:()=>Cc,MSTeamsSideBar:()=>vc,MonacoCodeEditor:()=>ml,PreviewPanel:()=>jl,PushChannel:()=>Wb,PushEditor:()=>ac,SMSChannel:()=>Ub,SMSEditor:()=>gc,SlackChannel:()=>$b,SlackEditor:()=>uc,SlackSideBar:()=>dc,SlackSideBarItemDetails:()=>mc,TemplateEditor:()=>Vb,TemplateProvider:()=>Qd,TemplateStatus:()=>ni,TextMenu:()=>ql,ToggleGroup:()=>Pr,VariableInput:()=>hi,VariableTextarea:()=>$r,apiUrlAtom:()=>Vt,brandApplyAtom:()=>wc,cn:()=>I,convertElementalToTiptap:()=>Ze,convertLegacyError:()=>Ui,convertTiptapToElemental:()=>de,createCustomError:()=>no,extractErrorMessage:()=>u2,getFlattenedVariables:()=>ha,isRetryableError:()=>c2,isTemplateLoadingAtom:()=>ae,isTemplatePublishingAtom:()=>Ut,isTemplateSavingAtom:()=>bt,templateDataAtom:()=>nt,templateErrorAtom:()=>Q,templateIdAtom:()=>Fr,tenantIdAtom:()=>ht,tokenAtom:()=>Ot,useAutoSave:()=>Si,useBrandActions:()=>$n,useChannels:()=>xc,useDebouncedFlush:()=>rc,useImageUpload:()=>qn,useNodeAttributes:()=>Tt,useTemplateActions:()=>Zn,useTemplateStore:()=>Un,useVariables:()=>mh});module.exports=n2(Zb);var Do=require("jotai"),On=require("react");var Dr=require("jotai"),Vt=(0,Dr.atom)("https://api.courier.com/client/q"),Ot=(0,Dr.atom)(""),ht=(0,Dr.atom)(""),Fr=(0,Dr.atom)(""),nt=(0,Dr.atom)(null),ae=(0,Dr.atom)(null),bt=(0,Dr.atom)(null),Ut=(0,Dr.atom)(null),Q=(0,Dr.atom)(null),wc=(0,Dr.atom)(!0);var Vn=require("react/jsx-runtime"),i2=s(({children:e,tenantId:t,token:r,apiUrl:o})=>{let[,n]=(0,Do.useAtom)(Vt),[,i]=(0,Do.useAtom)(Ot),[,a]=(0,Do.useAtom)(ht);return(0,On.useEffect)(()=>{i(r),a(t),o&&n(o)},[r,t,o,n,i,a]),(0,Vn.jsx)(Vn.Fragment,{children:e})},"BrandProviderContext"),a2=s(e=>{let t=(0,On.useMemo)(()=>(0,Do.createStore)(),[]);return(0,Vn.jsx)(Do.Provider,{store:t,children:(0,Vn.jsx)(i2,{...e})})},"BrandProviderComponent"),Gd=(0,On.memo)(a2);var wr=require("jotai"),Vr=require("react"),Kd=require("sonner");var ja=require("react/jsx-runtime"),Un=s(()=>({store:(0,wr.useStore)()}),"useTemplateStore"),Yd=(0,Vr.createContext)(null),Xd=s(()=>(0,Vr.useContext)(Yd),"useUploadImage"),s2=s(({children:e,templateId:t,tenantId:r,token:o,apiUrl:n,uploadImage:i})=>{let[,a]=(0,wr.useAtom)(Vt),[,l]=(0,wr.useAtom)(Ot),[,c]=(0,wr.useAtom)(ht),[,u]=(0,wr.useAtom)(Fr),[d]=(0,wr.useAtom)(Q);return(0,Vr.useEffect)(()=>{l(o),c(r),u(t),n&&a(n)},[o,r,t,n,a,l,c,u]),(0,Vr.useEffect)(()=>{d&&Kd.toast.error(d.message,d.toastProps)},[d]),(0,ja.jsx)(Yd.Provider,{value:i||null,children:e})},"TemplateProviderContext"),l2=s(e=>{let t=(0,Vr.useMemo)(()=>(0,wr.createStore)(),[]);return(0,ja.jsx)(wr.Provider,{store:t,children:(0,ja.jsx)(s2,{...e})})},"TemplateProviderComponent"),Qd=(0,Vr.memo)(l2);var Ur=require("jotai");var no=s((e,t)=>({message:e,toastProps:t}),"createCustomError"),c2=s(e=>{var t;return((t=e.toastProps)==null?void 0:t.action)!==void 0},"isRetryableError"),u2=s(e=>typeof e=="string"?e:e&&typeof e=="object"&&"message"in e?String(e.message):e instanceof Error?e.message:"Unknown error","extractErrorMessage"),Ui=s(e=>typeof e=="string"?no(e):e,"convertLegacyError");var kc=require("jotai"),em=require("sonner");var tm=(0,kc.atom)(null,async(e,t,r)=>{var a;let o=e(Vt),n=e(Ot),i=e(ht);if(!o){t(Q,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(bt,!0),t(Q,null);try{let c=await(await fetch(o,{method:"POST",headers:{Authorization:`Bearer ${n}`,"x-courier-client-key":`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
|
|
47
47
|
mutation SaveTenantBrand($input: SaveBrandSettingsInput!) {
|
|
48
48
|
tenant {
|
|
49
49
|
brand {
|
|
@@ -53,8 +53,8 @@ if (typeof require !== "undefined") {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
`,variables:{input:{tenantId:i,settings:r}}})})).json();if(!c.data)if(c.errors){let u=(a=c.errors)==null?void 0:a.map(d=>d.message);t(
|
|
57
|
-
`),toastProps:{duration:4e3}})}else t(
|
|
56
|
+
`,variables:{input:{tenantId:i,settings:r}}})})).json();if(!c.data)if(c.errors){let u=(a=c.errors)==null?void 0:a.map(d=>d.message);t(Q,{message:u.join(`
|
|
57
|
+
`),toastProps:{duration:4e3}})}else t(Q,{message:"Error saving brand settings",toastProps:{duration:4e3}});return c}catch(l){throw t(Q,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save brand settings"}}),l}finally{t(bt,!1)}}),rm=(0,kc.atom)(null,async(e,t)=>{let r=e(Vt),o=e(Ot),n=e(ht);if(!r){t(Q,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(Ut,!0),t(Q,null);try{let i=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
|
|
58
58
|
mutation PublishNotification($input: PublishBrandInput!) {
|
|
59
59
|
tenant {
|
|
60
60
|
brand {
|
|
@@ -64,7 +64,7 @@ if (typeof require !== "undefined") {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
`,variables:{input:{tenantId:n}}})}),a=await i.json();return i.status===200?
|
|
67
|
+
`,variables:{input:{tenantId:n}}})}),a=await i.json();return i.status===200?em.toast.success("Brand published"):t(Q,{message:"Error publishing brand",toastProps:{duration:4e3}}),a}catch(i){throw t(Q,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish brand"}}),i}finally{t(Ut,!1)}});var im=require("jotai");var yt=require("jotai");var dn=(0,yt.atom)(null),Nc=(0,yt.atom)(null),Ga=(0,yt.atom)(null),ee=(0,yt.atom)(e=>e(Ga),(e,t,r)=>{if(!r){t(Ga,r);return}let o=e(Nc),n=r;if(o)try{n=o(r)}catch(a){console.error("[ContentTransformer] Error applying transformer:",a),n=r}let i=e(Ga);JSON.stringify(i)!==JSON.stringify(n)&&t(Ga,n)}),Wn=(0,yt.atom)(null),_n=(0,yt.atom)(null),He=(0,yt.atom)(null),zn=(0,yt.atom)(null),Ct=(0,yt.atom)(!1),io=(0,yt.atom)(!1),mn=(0,yt.atom)({}),jt=(0,yt.atom)(!1),je=(0,yt.atom)(null),om=(0,yt.atom)(null),Pc=(0,yt.atom)(new Map),pn=(0,yt.atom)(e=>e(Pc),(e,t,r)=>{let o=new Map(e(Pc));r.action==="register"&&r.fn?o.set(r.id,r.fn):r.action==="unregister"&&o.delete(r.id),t(Pc,o)}),nm=s(e=>{e.forEach(t=>{try{t()}catch(r){console.error("[FlushPendingUpdates] Error flushing updates:",r)}})},"flushAllPendingUpdates");var Ka=(0,im.atom)(null,async(e,t,r)=>{var c,u,d,m,p;let o=e(Vt),n=e(Ot),i=e(ht),a=e(Fr),l=(c=r==null?void 0:r.includeBrand)!=null?c:!0;if(!o||!n||!i){let f=[];o||f.push("API URL"),n||f.push("token"),i||f.push("tenant ID"),t(Q,{message:"Missing configuration",toastProps:{description:`Missing: ${f.join(", ")}`,duration:5e3}});return}t(ae,!0),t(Q,null);try{let f=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,"x-courier-client-key":`Bearer ${n}`},body:JSON.stringify({query:`
|
|
68
68
|
query GetTenant($tenantId: String!, $input: GetNotificationInput!, $brandInput: GetTenantBrandInput!, $includeBrand: Boolean!) {
|
|
69
69
|
tenant(tenantId: $tenantId) {
|
|
70
70
|
tenantId
|
|
@@ -122,13 +122,13 @@ if (typeof require !== "undefined") {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
`,variables:{tenantId:i,input:{notificationId:a,version:"latest"},brandInput:{version:"latest"},includeBrand:l}})}),
|
|
126
|
-
`),toastProps:{duration:4e3}})}}catch{t(
|
|
127
|
-
`}]};if(t==="inbox"){let i=
|
|
125
|
+
`,variables:{tenantId:i,input:{notificationId:a,version:"latest"},brandInput:{version:"latest"},includeBrand:l}})}),v=await f.json(),h=f.status,b=(u=v.data)==null?void 0:u.tenant;if(b?(t(nt,v),t(Wn,(d=b==null?void 0:b.notification)==null?void 0:d.publishedAt),t(_n,(m=b==null?void 0:b.notification)==null?void 0:m.version)):h===401?t(Q,{message:"Authentication failed",toastProps:{duration:6e3}}):t(Q,{message:"Error fetching template data",toastProps:{duration:4e3}}),v.errors){let y=(p=v.errors)==null?void 0:p.map(N=>N.message);t(Q,{message:y.join(`
|
|
126
|
+
`),toastProps:{duration:4e3}})}}catch{t(Q,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to fetch template data"}})}finally{t(ae,!1)}});var Ac=require("jotai"),cm=require("sonner");function Mc(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t.type==="action"&&"content"in t&&"href"in t?{type:"action",content:t.content,href:t.href,...t.align&&{align:t.align},...t.background_color&&{background_color:t.background_color},...t.color&&{color:t.color},...t.style&&{style:t.style},...t.border&&{border:t.border}}:t)}s(Mc,"cleanInboxElements");function am(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}s(am,"cleanPushElements");function Ya(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}s(Ya,"cleanSMSElements");function sm(e){return{...e,elements:e.elements.map(t=>t.type==="channel"&&t.channel==="inbox"&&t.elements?{...t,elements:Mc(t.elements)}:t)}}s(sm,"cleanTemplateContent");function lm(e,t){if(!(e!=null&&e.elements))return"none";let r=e.elements.find(o=>o.type==="channel"&&o.channel===t);if(!r||r.type!=="channel")return"none";if("raw"in r&&r.raw&&("subject"in r.raw&&r.raw.subject||"title"in r.raw&&r.raw.title))return"raw";if("elements"in r&&r.elements){let o=r.elements.find(n=>n.type==="meta");if(o&&"title"in o&&o.title)return"meta"}return"none"}s(lm,"getSubjectStorageFormat");function Or(e,t,r,o){let n=lm(e,t);if(t==="push"){let i=o.find(d=>d.type==="meta"&&"title"in d),a=i&&"title"in i?i.title:r,l=o.filter(d=>d.type!=="meta"),c=am(l);return{elements:[{type:"meta",title:a},...c]}}if(t==="sms")return{elements:o.length>0?o:[{type:"text",content:`
|
|
127
|
+
`}]};if(t==="inbox"){let i=d2(o),a=i||r,l=i?o.slice(1):o,c=l.filter(v=>v.type==="text"),u=l.filter(v=>v.type==="action"),d=c[0],m=d?{type:"text",content:"content"in d?d.content:`
|
|
128
128
|
`}:{type:"text",content:`
|
|
129
|
-
`},
|
|
130
|
-
`)return r}return null}s(
|
|
131
|
-
`&&("text_style"in a&&(a.text_style==="h1"||a.text_style==="h2")?n||(n=l):o||(o=l))}let i=n||o;if(i)return i}return""}s(
|
|
129
|
+
`},p=Mc(u);return{elements:[{type:"meta",title:a},m,...p]}}if(n==="raw"){let i={};return t==="email"?i.subject=r:i.title=r,{elements:o,raw:i}}else return{elements:[{type:"meta",title:r},...o]}}s(Or,"createTitleUpdate");function d2(e){if(e.length===0)return null;let t=e[0];if(t.type==="text"&&"content"in t&&t.content){let r=t.content.trim();if(r&&r!==`
|
|
130
|
+
`)return r}return null}s(d2,"extractTitleFromFirstElement");function Wi(e,t){if(!e||e.type!=="channel")return"";if("raw"in e&&e.raw){if(t==="email"&&"subject"in e.raw&&e.raw.subject)return e.raw.subject;if("title"in e.raw&&e.raw.title)return e.raw.title}if("elements"in e&&e.elements){let r=e.elements.find(a=>a.type==="meta");if(r&&"title"in r&&typeof r.title=="string")return r.title;if(t==="email")return"";let o="",n="";for(let a of e.elements)if(a.type==="text"&&"content"in a&&a.content){let l=a.content.trim();l&&l!==`
|
|
131
|
+
`&&("text_style"in a&&(a.text_style==="h1"||a.text_style==="h2")?n||(n=l):o||(o=l))}let i=n||o;if(i)return i}return""}s(Wi,"extractCurrentTitle");var Xa=(0,Ac.atom)(null,async(e,t,r)=>{var p;let o,n;r&&typeof r=="object"&&"content"in r?(o=r.routing,n=r.content):o=r;let i=e(Vt),a=e(Ot),l=e(ht),c=e(Fr),u=n||e(ee);if(!u)return;let d=sm(u);if(!i){t(Q,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(bt,!0),t(Q,null);let m={content:d,routing:o};try{let v=await(await fetch(i,{method:"POST",headers:{Authorization:`Bearer ${a}`,"x-courier-client-key":`Bearer ${a}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
|
|
132
132
|
mutation SaveNotification($input: SaveNotificationInput!) {
|
|
133
133
|
tenant {
|
|
134
134
|
notification {
|
|
@@ -141,8 +141,8 @@ if (typeof require !== "undefined") {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
`,variables:{input:{tenantId:l,notificationId:c,name:c,data:
|
|
145
|
-
`),toastProps:{duration:4e3}})}else t(
|
|
144
|
+
`,variables:{input:{tenantId:l,notificationId:c,name:c,data:m}}})})).json();if(v.data)t(_n,v.data.tenant.notification.save.version);else if(v.errors){let h=(p=v.errors)==null?void 0:p.map(b=>b.message);t(Q,{message:h.join(`
|
|
145
|
+
`),toastProps:{duration:4e3}})}else t(Q,{message:"Error saving template",toastProps:{duration:4e3}});return v}catch(f){throw t(Q,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save template"}}),f}finally{t(bt,!1)}}),um=(0,Ac.atom)(null,async(e,t)=>{let r=e(Vt),o=e(Ot),n=e(ht),i=e(Fr),a=e(_n);if(!a){t(Q,{message:"Version not defined",toastProps:{duration:5e3}});return}if(!r){t(Q,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(Ut,!0),t(Q,null);try{let l=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
|
|
146
146
|
mutation PublishNotification($input: PublishNotificationInput!) {
|
|
147
147
|
tenant {
|
|
148
148
|
notification {
|
|
@@ -154,7 +154,7 @@ if (typeof require !== "undefined") {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
`,variables:{input:{tenantId:n,notificationId:i,version:a}}})}),c=await l.json();return l.status===200?(
|
|
157
|
+
`,variables:{input:{tenantId:n,notificationId:i,version:a}}})}),c=await l.json();return l.status===200?(cm.toast.success("Template published"),t(Wn,new Date().toISOString()),t(_n,c.data.tenant.notification.publish.version)):t(Q,{message:"Error publishing template",toastProps:{duration:4e3}}),c}catch(l){throw t(Q,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish template"}}),l}finally{t(Ut,!1)}});function $n(){Un();let e=(0,Ur.useSetAtom)(Ka),t=(0,Ur.useSetAtom)(tm),r=(0,Ur.useSetAtom)(Xa),o=(0,Ur.useSetAtom)(rm),[n,i]=(0,Ur.useAtom)(ae),[a,l]=(0,Ur.useAtom)(bt),[c,u]=(0,Ur.useAtom)(Ut),[d,m]=(0,Ur.useAtom)(Q),[p,f]=(0,Ur.useAtom)(nt);return{getTemplate:e,saveTemplate:r,saveBrand:t,publishBrand:o,isTemplateLoading:n,setIsTemplateLoading:i,isTemplateSaving:a,setIsTemplateSaving:l,isTemplatePublishing:c,setIsTemplatePublishing:u,templateError:d,setTemplateError:s(h=>{m(h===null?null:typeof h=="string"?no(h):h)},"setTemplateError"),templateData:p,setTemplateData:f,createCustomError:no,convertLegacyError:Ui}}s($n,"useBrandActions");var kr=require("jotai");var dm=require("react");function Zn(){let e=(0,kr.useSetAtom)(Ka),t=(0,kr.useSetAtom)(Xa),r=(0,kr.useSetAtom)(um),[o,n]=(0,kr.useAtom)(ae),[i,a]=(0,kr.useAtom)(bt),[l,c]=(0,kr.useAtom)(Ut),[u,d]=(0,kr.useAtom)(Q),[m,p]=(0,kr.useAtom)(nt),[f,v]=(0,kr.useAtom)(ee),[h,b]=(0,kr.useAtom)(Nc),y=(0,dm.useCallback)(N=>{d(N===null?null:typeof N=="string"?no(N):N)},[d]);return{getTemplate:e,saveTemplate:t,publishTemplate:r,isTemplateLoading:o,setIsTemplateLoading:n,isTemplateSaving:i,setIsTemplateSaving:a,isTemplatePublishing:l,setIsTemplatePublishing:c,templateError:u,setTemplateError:y,templateData:m,setTemplateData:p,templateEditorContent:f,setTemplateEditorContent:v,createCustomError:no,convertLegacyError:Ui,contentTransformer:h,setContentTransformer:b}}s(Zn,"useTemplateActions");var Sc=require("jotai"),pm=require("react");var m2=["image/png","image/jpeg","image/gif","image/webp"],mm=s(async(e,t)=>{var c,u,d;let{apiUrl:r,token:o}=t;if(!m2.includes(e.type))throw new Error(`Invalid file type: ${e.type}. Only PNG, JPEG, GIF, and WebP images are supported.`);let n=e.name.split(".").pop()||"",i=`image_${Date.now()}_${Math.random().toString(36).substring(2,10)}.${n}`,l=(await new Promise((m,p)=>{let f=new FileReader;f.onload=()=>{typeof f.result=="string"?m(f.result):p(new Error("Failed to read file as data URL"))},f.onerror=()=>p(f.error),f.readAsDataURL(e)})).split(",")[1];try{let p=await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({query:`
|
|
158
158
|
mutation UploadImage($input: UploadImageInput!) {
|
|
159
159
|
tenant {
|
|
160
160
|
notification {
|
|
@@ -164,59 +164,57 @@ if (typeof require !== "undefined") {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
`,variables:{input:{name:i,type:e.type,data:l}}})})).json();if(
|
|
168
|
-
`));let f=
|
|
169
|
-
`);for(let o=0;o<r.length;o++)
|
|
167
|
+
`,variables:{input:{name:i,type:e.type,data:l}}})})).json();if(p.errors)throw new Error(p.errors.map(v=>v.message).join(`
|
|
168
|
+
`));let f=p.data;return(d=(u=(c=f==null?void 0:f.tenant)==null?void 0:c.notification)==null?void 0:u.uploadImage)==null?void 0:d.url}catch(m){throw console.error("Error uploading image:",m),m}},"uploadImage");function qn(){let[e]=(0,Sc.useAtom)(Vt),[t]=(0,Sc.useAtom)(Ot),r=Xd();return{uploadImage:(0,pm.useCallback)(async n=>{if(typeof r=="function"){let i,a;try{i=await r(n),i===void 0&&(i=await r(n.file))}catch(u){a=u;try{i=await r(n.file)}catch{throw a}}let l="",c;if(typeof i=="string")l=i;else if(i){c=i==null?void 0:i.message;let u=i.url;typeof u=="string"?l=u:u&&typeof u=="object"&&(c=c||(u==null?void 0:u.message))}if(c)throw new Error(c);if(!l)throw a||new Error("Error uploading image");return{url:l}}else{if(!e||!t)throw new Error("Upload failed: Missing configuration for image upload");let i=n.file instanceof File?n.file:new File([n.file],"upload",{type:n.file.type}),a=await mm(i,{apiUrl:e,token:t});if(!a)throw new Error("Upload failed: No URL returned from server");return{url:a}}},[e,t,r])}}s(qn,"useImageUpload");var hm=require("clsx"),bm=require("tailwind-merge");var gr=require("uuid");function vt(e){let t=e.trim();if(!t||t.startsWith(".")||t.endsWith(".")||t.includes("..")||t.includes(" "))return!1;let r=t.split("."),o=/^[a-zA-Z_][a-zA-Z0-9_]*$/;for(let n of r)if(!n||!o.test(n))return!1;return!0}s(vt,"isValidVariableName");var p2="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function Qa(e){return e?e===p2:!0}s(Qa,"isBlankImageSrc");var es=s((e,t)=>new Promise(r=>{let o=new FileReader;o.onload=n=>{var a;let i=new Image;i.onload=()=>{var m;let l,c;i.width>i.height?(l=Math.min(t,i.width),c=Math.round(i.height/i.width*l)):(c=Math.min(t,i.height),l=Math.round(i.width/i.height*c));let u=document.createElement("canvas");u.width=l,u.height=c;let d=u.getContext("2d");if(d){d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(i,0,0,l,c);let p=.8,f=u.toDataURL(e.type||"image/jpeg",p),v=0,h=5;for(;f.length>512e3&&v<h;)v++,p-=.1,p<.3&&(p=.3),f=u.toDataURL(e.type||"image/jpeg",p);r({dataUrl:f,width:l,height:c})}else r({dataUrl:(m=n.target)==null?void 0:m.result,width:i.width,height:i.height})},i.src=(a=n.target)==null?void 0:a.result},o.readAsDataURL(e)}),"resizeImage");function fm(e){let t=[],r=e.replace(/\n$/,"").split(`
|
|
169
|
+
`);for(let o=0;o<r.length;o++)f2(r[o],t),o<r.length-1&&t.push({type:"hardBreak"});return t}s(fm,"parseMDContent");function f2(e,t){Ic(e,t)}s(f2,"parseTextLine");function Ic(e,t){var c;if(!e)return;let r=[{regex:/\{\{([^}]+)\}\}/g,type:"variable"},{regex:/\{\}([^{}]+)\{\}/g,type:"variable"},{regex:/\[([^\]]+)\]\(([^)]+)\)/g,type:"link"},{regex:/\*\*([^*]+)\*\*/g,type:"bold"},{regex:/__([^_]+)__/g,type:"bold"},{regex:/(?<!\*)\*([^*]+)\*(?!\*)/g,type:"italic"},{regex:/(?<!_)_([^_]+)_(?!_)/g,type:"italic"},{regex:/~([^~]+)~/g,type:"strike"},{regex:/\+([^+]+)\+/g,type:"underline"}],o=[];for(let u of r){let d=new RegExp(u.regex.source,u.regex.flags),m;for(;(m=d.exec(e))!==null;)if(u.type==="variable"){let p=m[1].trim();vt(p)&&o.push({start:m.index,end:m.index+m[0].length,text:m[1],type:"variable",attrs:{id:p}})}else u.type==="link"?o.push({start:m.index,end:m.index+m[0].length,text:m[1],type:"link",attrs:{href:m[2]}}):o.push({start:m.index,end:m.index+m[0].length,text:m[1],type:u.type})}o.sort((u,d)=>u.start-d.start);let n=[],i=0;for(let u of o)u.start>=i&&(n.push(u),i=u.end);let a=[],l=0;for(let u of n){if(u.start>l){let d=e.substring(l,u.start);d&&Lc(d,[],a)}if(u.type==="variable")a.push({type:"variable",attrs:{id:(c=u.attrs)==null?void 0:c.id}});else if(u.type==="link"){let d=[];Ic(u.text,d),d.forEach(m=>{var p;m.marks=m.marks||[],m.marks.push({type:"link",attrs:{href:(p=u.attrs)==null?void 0:p.href}})}),a.push(...d)}else{let d=[];Ic(u.text,d),d.forEach(m=>{m.marks=m.marks||[],m.marks.push({type:u.type})}),a.push(...d)}l=u.end}if(l<e.length){let u=e.substring(l);u&&Lc(u,[],a)}t.push(...a)}s(Ic,"processMarkdownFormatting");function Lc(e,t,r){if(!e)return;let o=/\{\{([^}]+)\}\}/g,n,i=0;for(o.lastIndex=0;(n=o.exec(e))!==null;){if(!n[0].startsWith("{{")||!n[0].endsWith("}}"))continue;if(n.index>i){let c=e.substring(i,n.index);c&&r.push({type:"text",text:c,...t.length>0&&{marks:t}})}let a=n[1].trim(),l=t.some(c=>c.type==="link");a&&vt(a)?r.push({type:"variable",attrs:{id:a,...l&&{inUrlContext:!0}},...t.length>0&&{marks:t}}):r.push({type:"text",text:n[0],...t.length>0&&{marks:t}}),i=n.index+n[0].length}if(i<e.length){let a=e.substring(i);a&&r.push({type:"text",text:a,...t.length>0&&{marks:t}})}}s(Lc,"parseTextWithVariables");function Ze(e,t){var d,m,p,f,v,h,b,y,N;let r={type:"doc",content:[]};if(!e||!e.elements||e.elements.length===0)return r;let o,n=t==null?void 0:t.channel,i;for(let g of e.elements)if(g.type==="channel"){let P=g;if(n){if(P.channel===n){i=P;break}}else{i=P;break}}if(!i||i.type!=="channel")return r;let a=i;if(a.elements&&a.elements.length>0?(o=a.elements,a.channel==="push"&&(o=o.map(g=>g.type==="meta"&&"title"in g?{type:"text",content:g.title||`
|
|
170
170
|
`,text_style:"h2"}:g))):o=[{type:"text",content:`
|
|
171
|
-
`}],!o||o.length===0)return r;let l=s(g=>{var
|
|
172
|
-
`:X+=ts(
|
|
173
|
-
`;let ge={};(o=r.attrs)!=null&&o.borderWidth&&(ge.border_size=`${r.attrs.borderWidth}px`),(n=r.attrs)!=null&&n.borderColor&&(ge.border_color=r.attrs.borderColor),((i=r.attrs)==null?void 0:i.paddingVertical)!==void 0&&((a=r.attrs)==null?void 0:a.paddingHorizontal)!==void 0&&(ge.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(l=r.attrs)!=null&&l.backgroundColor&&(ge.background_color=r.attrs.backgroundColor),ge.type="text",ge.align=((c=r.attrs)==null?void 0:c.textAlign)||"left",ge.content=X;let
|
|
174
|
-
`:X+=ts(
|
|
175
|
-
`;let ge={};(d=r.attrs)!=null&&d.borderWidth&&(ge.border_size=`${r.attrs.borderWidth}px`),(
|
|
176
|
-
`:X+=ts(
|
|
177
|
-
`}X=X.trim();let
|
|
178
|
-
`,align:"left"}):Ja.length===1?
|
|
179
|
-
`,align:"left"})}else for(let
|
|
180
|
-
`,align:"left"});let
|
|
181
|
-
`&&("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=Hc(o.elements);if(n)return n}}return r||t||""}s(Hc,"getTitle");function Dc(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 Hc(r.elements)}return""}s(Dc,"getTitleForChannel");function ut(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(l=>{var c;if(l.type!=="meta")if(l.type==="channel"){let u=l,d=!1;if(n?u.channel===n&&(d=!0):i||(d=!0),d){let p={};if(t.channel&&typeof t.channel=="object")for(let f in t.channel)f!=="type"&&f!=="elements"&&f!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,f)&&(p[f]=t.channel[f]);let m={type:"channel",channel:u.channel,...Object.fromEntries(Object.entries(u).filter(([f])=>!["type","channel","elements"].includes(f))),...p};if(t.elements!==void 0){let f=[],C=t.elements.find(h=>h.type==="meta");if(C)f.push(C);else{let h=(c=u.elements)==null?void 0:c.find(b=>b.type==="meta");h&&f.push(h)}let y=t.elements.filter(h=>h.type!=="meta");f.push(...y),m.elements=f}o.elements.push(m),i=!0}else o.elements.push(l)}else o.elements.push(l)}),n&&!i||!((a=r.elements)!=null&&a.some(l=>l.type==="channel"))&&!i){let l;n?l=n:t.channel&&typeof t.channel=="object"&&t.channel.channel?l=t.channel.channel:l="email";let c={};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)&&(c[d]=t.channel[d]);let u={type:"channel",channel:l,...c};if(t.elements!==void 0){let d=[],p=t.elements.find(f=>f.type==="meta");p&&d.push(p);let m=t.elements.filter(f=>f.type!=="meta");d.push(...m),u.elements=d}o.elements.push(u)}return o}s(ut,"updateElemental");function L(...e){return(0,hm.twMerge)((0,gm.clsx)(e))}s(L,"cn");var bm=require("@radix-ui/react-slot"),ym=require("class-variance-authority"),Cm=require("react"),vm=require("react/jsx-runtime"),rs=(0,ym.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]",secondary:"courier-text-foreground courier-bg-[#F5F5F5] dark:courier-bg-neutral-700 dark:courier-text-white",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-blue-600 active:courier-bg-blue-700"},{variant:"primary",active:!0,class:"courier-bg-blue-700"},{variant:"secondary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-600 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-[#3B82F6] dark:courier-text-white [&_svg]:dark:courier-text-white"}]}),Ie=(0,Cm.forwardRef)(({active:e,buttonSize:t="medium",disabled:r,variant:o="primary",className:n,asChild:i=!1,...a},l)=>(0,vm.jsx)(i?bm.Slot:"button",{ref:l,disabled:r,className:L(rs({variant:o,size:t,disabled:r,active:e}),n),...a}));Ie.displayName="Button";var xm=require("react"),Tm=require("react/jsx-runtime"),le=(0,xm.forwardRef)((e,t)=>(0,Tm.jsx)("hr",{...e,ref:t,className:L("courier-my-1 courier-border-border dark:courier-border-neutral-600 courier-w-full",e.className)}));le.displayName="Divider";var vo=he(require("react"),1),de=he(require("@radix-ui/react-dropdown-menu"),1),Yn=require("lucide-react");var st=require("react/jsx-runtime"),os=de.Root,ns=de.Trigger;var C2=vo.forwardRef(({className:e,inset:t,children:r,...o},n)=>(0,st.jsxs)(de.SubTrigger,{ref:n,className:L("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)(Yn.ChevronRight,{className:"courier-ml-auto"})]}));C2.displayName=de.SubTrigger.displayName;var v2=vo.forwardRef(({className:e,...t},r)=>(0,st.jsx)(de.SubContent,{ref:r,className:L("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}));v2.displayName=de.SubContent.displayName;var qi=vo.forwardRef(({className:e,sideOffset:t=4,portalProps:r,...o},n)=>(0,st.jsx)(de.Portal,{...r,children:(0,st.jsx)(de.Content,{ref:n,sideOffset:t,className:L("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})}));qi.displayName=de.Content.displayName;var Ji=vo.forwardRef(({className:e,inset:t,...r},o)=>(0,st.jsx)(de.Item,{ref:o,className:L("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=de.Item.displayName;var x2=vo.forwardRef(({className:e,children:t,checked:r,...o},n)=>(0,st.jsxs)(de.CheckboxItem,{ref:n,className:L("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)(de.ItemIndicator,{children:(0,st.jsx)(Yn.Check,{className:"courier-h-4 courier-w-4"})})}),t]}));x2.displayName=de.CheckboxItem.displayName;var T2=vo.forwardRef(({className:e,children:t,...r},o)=>(0,st.jsxs)(de.RadioItem,{ref:o,className:L("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)(de.ItemIndicator,{children:(0,st.jsx)(Yn.Circle,{className:"courier-h-2 courier-w-2 courier-fill-current"})})}),t]}));T2.displayName=de.RadioItem.displayName;var E2=vo.forwardRef(({className:e,inset:t,...r},o)=>(0,st.jsx)(de.Label,{ref:o,className:L("courier-px-2 courier-py-1.5 courier-text-sm courier-font-semibold",t&&"courier-pl-8",e),...r}));E2.displayName=de.Label.displayName;var w2=vo.forwardRef(({className:e,...t},r)=>(0,st.jsx)(de.Separator,{ref:r,className:L("courier-mx-1 courier-my-1 courier-h-px courier-bg-muted",e),...t}));w2.displayName=de.Separator.displayName;var P2=s(({className:e,...t})=>(0,st.jsx)("span",{className:L("courier-ml-auto courier-text-xs courier-tracking-widest courier-opacity-60",e),...t}),"DropdownMenuShortcut");P2.displayName="DropdownMenuShortcut";var Em=require("react");var Xn=require("react/jsx-runtime"),Bc=class Bc extends Em.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,Xn.jsx)(k2,{error:this.state.error}):this.props.children}};s(Bc,"ErrorBoundary");var is=Bc,k2=s(({error:e})=>(0,Xn.jsxs)("div",{className:"courier-p-6 courier-border courier-border-red-200 courier-bg-red-50 courier-rounded-lg courier-text-center",children:[(0,Xn.jsx)("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),(0,Xn.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 Nm=require("@radix-ui/react-slot"),Yt=he(require("react"),1),Qn=require("react-hook-form");var Fc=he(require("@radix-ui/react-label"),1),wm=require("class-variance-authority"),Pm=he(require("react"),1),km=require("react/jsx-runtime"),N2=(0,wm.cva)("courier-text-sm courier-font-medium courier-leading-none peer-disabled:courier-cursor-not-allowed peer-disabled:courier-opacity-70"),Vc=Pm.forwardRef(({className:e,...t},r)=>(0,km.jsx)(Fc.Root,{ref:r,className:L(N2(),e),...t}));Vc.displayName=Fc.Root.displayName;var xo=require("react/jsx-runtime"),Je=Qn.FormProvider,Mm=Yt.createContext({}),j=s(({...e})=>(0,xo.jsx)(Mm.Provider,{value:{name:e.name},children:(0,xo.jsx)(Qn.Controller,{...e})}),"FormField"),as=s(()=>{let e=Yt.useContext(Mm),t=Yt.useContext(Am),{getFieldState:r,formState:o}=(0,Qn.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"),Am=Yt.createContext({}),q=Yt.forwardRef(({className:e,...t},r)=>{let o=Yt.useId();return(0,xo.jsx)(Am.Provider,{value:{id:o},children:(0,xo.jsx)("div",{ref:r,className:L("courier-space-y-2",e),...t})})});q.displayName="FormItem";var lo=Yt.forwardRef(({className:e,...t},r)=>{let{error:o,formItemId:n}=as();return(0,xo.jsx)(Vc,{ref:r,className:L(o&&"courier-text-destructive",e),htmlFor:n,...t})});lo.displayName="FormLabel";var J=Yt.forwardRef(({...e},t)=>{let{error:r,formItemId:o,formDescriptionId:n,formMessageId:i}=as();return(0,xo.jsx)(Nm.Slot,{ref:t,id:o,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...e})});J.displayName="FormControl";var M2=Yt.forwardRef(({className:e,...t},r)=>{let{formDescriptionId:o}=as();return(0,xo.jsx)("p",{ref:r,id:o,className:L("courier-text-[0.8rem] courier-text-muted-foreground",e),...t})});M2.displayName="FormDescription";var K=Yt.forwardRef(({className:e,children:t,...r},o)=>{let{error:n,formMessageId:i}=as(),a=n?String(n==null?void 0:n.message):t;return a?(0,xo.jsx)("p",{ref:o,id:i,className:L("courier-text-[0.8rem] courier-font-medium courier-text-destructive",e),...r,children:a}):null});K.displayName="FormMessage";var We=he(require("@radix-ui/react-alert-dialog"),1),hn=he(require("react"),1);var Sm=require("react");var br=require("react/jsx-runtime"),Im=We.Root,Lm=We.Trigger,A2=We.Portal,Rm=hn.forwardRef(({className:e,...t},r)=>(0,br.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,br.jsx)(We.Overlay,{asChild:!0,className:L("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})}));Rm.displayName=We.Overlay.displayName;var Oc=hn.forwardRef(({className:e,...t},r)=>{let o=(0,Sm.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,br.jsxs)(A2,{container:typeof window!="undefined"?o():void 0,children:[(0,br.jsx)(Rm,{}),(0,br.jsx)(We.Content,{ref:r,className:L("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})]})});Oc.displayName=We.Content.displayName;var Wc=s(({className:e,...t})=>(0,br.jsx)("div",{className:L("courier-flex courier-flex-col courier-space-y-2 courier-text-center sm:courier-text-left",e),...t}),"AlertDialogHeader");Wc.displayName="AlertDialogHeader";var _c=s(({className:e,...t})=>(0,br.jsx)("div",{className:L("courier-flex courier-flex-col-reverse sm:courier-flex-row sm:courier-justify-end sm:courier-space-x-2",e),...t}),"AlertDialogFooter");_c.displayName="AlertDialogFooter";var S2=hn.forwardRef(({className:e,...t},r)=>(0,br.jsx)(We.Title,{ref:r,className:L("courier-text-lg courier-font-semibold",e),...t}));S2.displayName=We.Title.displayName;var I2=hn.forwardRef(({className:e,...t},r)=>(0,br.jsx)(We.Description,{ref:r,className:L("courier-text-sm courier-text-muted-foreground",e),...t}));I2.displayName=We.Description.displayName;var Uc=hn.forwardRef(({className:e,...t},r)=>(0,br.jsx)(We.Action,{ref:r,className:L(rs(),e),...t}));Uc.displayName=We.Action.displayName;var zc=hn.forwardRef(({className:e,...t},r)=>(0,br.jsx)(We.Cancel,{ref:r,className:L(rs({variant:"outline"}),"courier-mt-2 sm:courier-mt-0",e),...t}));zc.displayName=We.Cancel.displayName;var Hm=he(require("react"),1),ei=require("react/jsx-runtime"),ye=Hm.forwardRef(({className:e,type:t,startAdornment:r,endAdornment:o,...n},i)=>(0,ei.jsxs)("div",{className:"courier-relative courier-flex courier-w-full courier-items-center",children:[r&&(0,ei.jsx)("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),(0,ei.jsx)("input",{type:t,className:L("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 dark:courier-[color-scheme:dark]",r&&"courier-pl-8",o&&"courier-pr-8",e),ref:i,...n}),o&&(0,ei.jsx)("div",{className:"courier-absolute courier-right-2 courier-flex courier-items-center courier-pointer-events-none",children:o})]}));ye.displayName="Input";var Oo=require("react");var zt=require("react");var Dm=require("lucide-react");var Xt=require("react/jsx-runtime"),L2=s(e=>e==="transparent"||/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e),"isValidHex"),Bm=s(({color:e,onChange:t,className:r,presetColors:o,defaultValue:n="transparent"})=>{let[i,a]=(0,zt.useState)(()=>ji(e)),[l,c]=(0,zt.useState)(e),u=(0,zt.useRef)(null),d=(0,zt.useRef)(null),p=(0,zt.useRef)(null),m=(0,zt.useRef)(!1),f=e!==n,C=(0,zt.useCallback)(g=>{m.current=!0;let w=R2(g);c(w),t(w),m.current=!1},[t]),y=s(g=>w=>{p.current=g,h(w)},"handleMouseDown"),h=(0,zt.useCallback)(g=>{if(p.current){if(p.current==="gradient"&&u.current){let w=u.current.getBoundingClientRect(),M=Math.max(0,Math.min(1,(g.clientX-w.left)/w.width)),k=Math.max(0,Math.min(1,(g.clientY-w.top)/w.height)),D={...i,s:M*100,v:(1-k)*100};a(D),C(D)}else if(p.current==="hue"&&d.current){let w=d.current.getBoundingClientRect(),M=Math.max(0,Math.min(1,(g.clientX-w.left)/w.width)),k={...i,h:M*360};a(k),C(k)}}},[i,C]),b=(0,zt.useCallback)(()=>{p.current=null},[]);(0,zt.useEffect)(()=>{if(p.current)return window.addEventListener("mousemove",h),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",b)}},[h,b]),(0,zt.useEffect)(()=>{m.current||(a(ji(e)),c(e))},[e]);let N=s(g=>{let w=g.target.value;if(c(w),L2(w)){let M=ji(w);a(M),C(M)}},"handleInputChange");return(0,Xt.jsxs)("div",{className:L("w-full",r),children:[(0,Xt.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:y("gradient"),children:(0,Xt.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,Xt.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:y("hue"),children:(0,Xt.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,Xt.jsxs)("div",{className:"courier-mt-3 courier-relative courier-flex courier-items-center",children:[(0,Xt.jsx)(ye,{value:l,onChange:N,placeholder:"#000000",className:"courier-flex-1"}),f&&(0,Xt.jsx)("button",{onClick:g=>{if(g.preventDefault(),n==="transparent"){t("transparent"),c("transparent"),a({h:0,s:0,v:0});return}let w=ji(n);a(w),C(w)},className:"courier-absolute courier-right-3 courier-flex courier-cursor-pointer courier-items-center courier-justify-center courier-transition-colors",children:(0,Xt.jsx)(Dm.CircleX,{size:14,strokeWidth:1.25})})]}),(0,Xt.jsx)(le,{className:"courier-my-3"}),(0,Xt.jsx)("div",{className:"courier-flex courier-flex-wrap courier-gap-1",children:o.map(g=>(0,Xt.jsx)("button",{className:L("courier-h-6 courier-w-6 courier-rounded-md courier-border courier-border-input courier-shrink-0",g==="transparent"&&$c),style:{backgroundColor:g==="transparent"?void 0:g},onClick:w=>{if(w.preventDefault(),g==="transparent"){t("transparent"),c("transparent"),a({h:0,s:0,v:0});return}let M=ji(g);a(M),C(M)}},g))})]})},"ColorPicker");function ji(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,l=0,c=n===0?0:a/n,u=n;if(n!==i){switch(n){case t:l=(r-o)/a+(r<o?6:0);break;case r:l=(o-t)/a+2;break;case o:l=(t-r)/a+4;break}l/=6}return{h:l*360,s:c*100,v:u*100}}s(ji,"hexToHsv");function R2({h:e,s:t,v:r}){t/=100,r/=100,e=e%360/360;let o=s(l=>{let c=(l+e*6)%6;return r-r*t*Math.max(0,Math.min(c,4-c,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(l=>l.toString(16).padStart(2,"0")).join("")}`}s(R2,"hsvToHex");var co=he(require("@radix-ui/react-popover"),1),Fm=he(require("react"),1);var Zc=require("react/jsx-runtime"),Vm=co.Root,Om=co.Trigger;var qc=Fm.forwardRef(({className:e,align:t="center",side:r="bottom",sideOffset:o=4,collisionPadding:n=10,avoidCollisions:i=!0,portalProps:a,...l},c)=>(0,Zc.jsx)(co.Portal,{...a,children:(0,Zc.jsx)(co.Content,{ref:c,side:r,align:t,sideOffset:o,collisionPadding:n,avoidCollisions:i,className:L("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),...l})}));qc.displayName=co.Content.displayName;var To=require("react/jsx-runtime"),$c="bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAwSDBWOEg4VjBaIiBmaWxsPSIjRDlEOUQ5Ii8+PHBhdGggZD0iTTE2IDhIOFYxNkgxNlY4WiIgZmlsbD0iI0Q5RDlEOSIvPjwvc3ZnPg==')]",H2=["#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#000000","#525252","#a3a3a3","#ffffff","transparent"],vt=(0,Oo.forwardRef)(({className:e,value:t="",onChange:r,defaultValue:o,transparent:n=!0,presetColors:i=H2,...a},l)=>{let c=t!=="transparent",u=(0,Oo.useRef)(null),d=(0,Oo.useMemo)(()=>n?i:i.filter(m=>m!=="transparent"),[i,n]),p=(0,Oo.useCallback)(()=>{var f;let m=(f=u.current)==null?void 0:f.parentElement;for(;m;){if(m.classList.contains("theme-container"))return m;m=m.parentElement}return document.body},[]);return(0,To.jsxs)(Vm,{children:[(0,To.jsx)(Om,{asChild:!0,children:(0,To.jsxs)("div",{className:"courier-relative courier-flex courier-items-center",ref:u,children:[(0,To.jsx)("div",{className:L("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",c?"":$c),style:{backgroundColor:c?t:void 0}}),(0,To.jsx)(ye,{...a,ref:l,readOnly:!0,type:"text",value:t==="transparent"?"Transparent":t,className:L("courier-relative courier-cursor-pointer courier-pl-8",e)})]})}),(0,To.jsx)(qc,{portalProps:{container:typeof window!="undefined"?p():void 0},className:"courier-w-[230px]",children:(0,To.jsx)(Bm,{color:t,onChange:r,presetColors:d,defaultValue:o})})]})});vt.displayName="InputColor";var Wm=he(require("react"),1),Jc=he(require("@radix-ui/react-separator"),1);var _m=require("react/jsx-runtime"),jc=Wm.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>(0,_m.jsx)(Jc.Root,{ref:n,decorative:r,orientation:t,className:L("courier-shrink-0 courier-bg-border",t==="horizontal"?"courier-h-[1px] courier-w-full":"courier-h-full courier-w-[1px]",e),...o}));jc.displayName=Jc.Root.displayName;var Um=he(require("react"),1),Eo=he(require("@radix-ui/react-slider"),1);var ti=require("react/jsx-runtime"),Kc=Um.forwardRef(({className:e,...t},r)=>(0,ti.jsxs)(Eo.Root,{ref:r,className:L("courier-relative courier-flex courier-w-full courier-touch-none courier-select-none courier-items-center",e),...t,children:[(0,ti.jsx)(Eo.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:(0,ti.jsx)(Eo.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),(0,ti.jsx)(Eo.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"})]}));Kc.displayName=Eo.Root.displayName;var zm=he(require("react"),1),Ki=he(require("@radix-ui/react-switch"),1);var Gc=require("react/jsx-runtime"),ri=zm.forwardRef(({className:e,...t},r)=>(0,Gc.jsx)(Ki.Root,{className:L("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,Gc.jsx)(Ki.Thumb,{className:L("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")})}));ri.displayName=Ki.Root.displayName;var ss=he(require("react"),1),$r=he(require("@radix-ui/react-tabs"),1);var us=require("react/jsx-runtime"),ls=$r.Root,Gi=ss.forwardRef(({className:e,...t},r)=>(0,us.jsx)($r.List,{ref:r,className:L("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}));Gi.displayName=$r.List.displayName;var oi=ss.forwardRef(({className:e,...t},r)=>(0,us.jsx)($r.Trigger,{ref:r,className:L("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}));oi.displayName=$r.Trigger.displayName;var cs=ss.forwardRef(({className:e,...t},r)=>(0,us.jsx)($r.Content,{ref:r,className:L("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}));cs.displayName=$r.Content.displayName;var ni=he(require("react"),1);var $m=require("react/jsx-runtime"),Yc=ni.forwardRef(({className:e,autoResize:t=!1,...r},o)=>{let n=ni.useRef(null),i=s(a=>{n.current=a,typeof o=="function"?o(a):o&&(o.current=a)},"combinedRef");return ni.useEffect(()=>{if(!t)return;let a=n.current;if(!a)return;let l=s(()=>{a.style.height="auto",a.style.height=`${a.scrollHeight}px`},"adjustHeight");return l(),a.addEventListener("input",l),()=>{a.removeEventListener("input",l)}},[t]),(0,$m.jsx)("textarea",{className:L("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})});Yc.displayName="Textarea";var ms=require("react");var Jm=require("react");var ds={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"},Zm={...ds},qm={...ds,colorScheme:"dark",background:"#262626",foreground:"#ffffff",muted:"#48465B",mutedForeground:"#C9C8E1",popover:"#171717",popoverForeground:"#ffffff",border:"#48465B",input:"#48465B",card:"#171717",cardForeground:"#ffffff",primary:"#2E333F",primaryForeground:"#ffffff",secondary:"#2E333F",secondaryForeground:"#C9C8E1",accent:"#0085FF",accentForeground:"#ffffff",destructive:"#FF3363",destructiveForeground:"#ffffff",ring:"#0085FF"};var Xc=(0,Jm.createContext)(ds);var Qc=require("react/jsx-runtime"),jm=(0,ms.forwardRef)(({children:e,theme:t,colorScheme:r,className:o},n)=>{let i=r!=null?r:"light",a=i==="light"?Zm:qm,l=a;t&&(l=typeof t=="string"?t:{...a,...t});let c=typeof t=="string"?{}:Object.entries(l).reduce((u,[d,p])=>{let m=d.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`);return{...u,[`--${m}`]:p}},{});return(0,Qc.jsx)(Xc.Provider,{value:typeof l=="object"?l:{},children:(0,Qc.jsx)("div",{style:c,className:L("courier-flex courier-flex-col courier-relative",typeof t=="string"?t:"","theme-container",i==="dark"?"dark courier-dark":"",o),ref:n,children:e})})}),Km=s(()=>(0,ms.useContext)(Xc),"useTheme");var Gm=he(require("react"),1),eu=he(require("@radix-ui/react-toggle"),1),Ym=require("class-variance-authority");var Xm=require("react/jsx-runtime"),tu=(0,Ym.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 data-[state=on]:dark:courier-text-white [&_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"}}),D2=Gm.forwardRef(({className:e,variant:t,size:r,...o},n)=>(0,Xm.jsx)(eu.Root,{ref:n,className:L(tu({variant:t,size:r,className:e})),...o}));D2.displayName=eu.Root.displayName;var ii=he(require("@radix-ui/react-toggle-group"),1),bn=he(require("react"),1);var ps=require("react/jsx-runtime"),Qm=bn.createContext({size:"default",variant:"default"}),Nr=bn.forwardRef(({className:e,variant:t,size:r,children:o,...n},i)=>(0,ps.jsx)(ii.Root,{ref:i,className:L("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:(0,ps.jsx)(Qm.Provider,{value:{variant:t,size:r},children:o})}));Nr.displayName=ii.Root.displayName;var $t=bn.forwardRef(({className:e,children:t,variant:r,size:o,...n},i)=>{let a=bn.useContext(Qm);return(0,ps.jsx)(ii.Item,{ref:i,className:L(tu({variant:a.variant||r,size:a.size||o}),e),...n,children:t})});$t.displayName=ii.Item.displayName;var fs=require("react/jsx-runtime"),Re=s(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?(0,fs.jsx)("path",{className:L(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):(0,fs.jsx)("path",{className:L(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),Z=s(({width:e=28,height:t=28,...r})=>(0,fs.jsx)("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");var ai=require("react/jsx-runtime"),ep=s(({color:e="#000000",width:t=19,height:r=10,...o})=>(0,ai.jsxs)(Z,{...o,width:t,height:r,children:[(0,ai.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,ai.jsx)("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),(0,ai.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 ru=require("react/jsx-runtime"),Yi=s(({color:e="#DC2626",width:t=13,height:r=13,...o})=>(0,ru.jsx)(Z,{...o,fill:"none",width:t,height:r,children:(0,ru.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 ou=require("react/jsx-runtime"),Xi=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,ou.jsx)(Z,{...n,width:r,height:o,children:(0,ou.jsx)(Re,{active:t,colorProp:"stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",d:"M1 15V11C1 5.47715 5.47715 1 11 1H15"})}),"BorderRadiusIcon");var si=require("react/jsx-runtime"),wo=s(({color:e="#A3A3A3",width:t=16,height:r=16,...o})=>(0,si.jsxs)(Z,{...o,width:t,height:r,children:[(0,si.jsx)("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),(0,si.jsx)("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),(0,si.jsx)("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");var nu=require("react/jsx-runtime"),iu=s(({color:e,width:t=21,height:r=16,...o})=>(0,nu.jsx)(Z,{...o,width:t,height:r,children:(0,nu.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 au=require("react/jsx-runtime"),su=s(({color:e="#171717",width:t=12,height:r=13,...o})=>(0,au.jsx)(Z,{...o,fill:"none",width:t,height:r,children:(0,au.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 lu=require("react/jsx-runtime"),cu=s(({color:e="#404040",width:t=20,height:r=15,viewBox:o="0 0 20 15",...n})=>(0,lu.jsx)(Z,{...n,width:t,height:r,viewBox:o,children:(0,lu.jsx)("path",{d:"M1.875 0H18.125C19.1406 0 20 0.859375 20 1.875C20 2.5 19.6875 3.04688 19.2188 3.39844L10.7422 9.76562C10.2734 10.1172 9.6875 10.1172 9.21875 9.76562L0.742188 3.39844C0.273438 3.04688 0 2.5 0 1.875C0 0.859375 0.820312 0 1.875 0ZM0 4.375L8.47656 10.7812C9.375 11.4453 10.5859 11.4453 11.4844 10.7812L20 4.375V12.5C20 13.9062 18.8672 15 17.5 15H2.5C1.09375 15 0 13.9062 0 12.5V4.375Z",fill:e})}),"EmailIcon");var uu=require("react/jsx-runtime"),Qi=s(({color:e="#737373",width:t=16,height:r=16,...o})=>(0,uu.jsx)(Z,{...o,width:t,height:r,children:(0,uu.jsx)(Re,{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 du=require("react/jsx-runtime"),ea=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,du.jsx)(Z,{...n,width:r,height:o,children:(0,du.jsx)(Re,{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 mu=require("react/jsx-runtime"),pu=s(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,mu.jsx)(Z,{...o,width:t,height:r,children:(0,mu.jsx)(Re,{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 fu=require("react/jsx-runtime"),ta=s(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,fu.jsx)(Z,{...o,width:t,height:r,children:(0,fu.jsx)("path",{d:"M2 5.75C2 4.38281 3.09375 3.25 4.5 3.25H19.5C20.8672 3.25 22 4.38281 22 5.75V8.25V10.125V10.75V18.25C22 19.6562 20.8672 20.75 19.5 20.75H4.5C3.09375 20.75 2 19.6562 2 18.25V10.75V10.125V8.25V5.75ZM20.125 10.75H3.875V18.25C3.875 18.6016 4.14844 18.875 4.5 18.875H19.5C19.8125 18.875 20.125 18.6016 20.125 18.25V10.75ZM5.75 8.25C6.41406 8.25 7 7.70312 7 7C7 6.33594 6.41406 5.75 5.75 5.75C5.04688 5.75 4.5 6.33594 4.5 7C4.5 7.70312 5.04688 8.25 5.75 8.25ZM10.75 7C10.75 6.33594 10.1641 5.75 9.5 5.75C8.79688 5.75 8.25 6.33594 8.25 7C8.25 7.70312 8.79688 8.25 9.5 8.25C10.1641 8.25 10.75 7.70312 10.75 7ZM13.25 8.25C13.9141 8.25 14.5 7.70312 14.5 7C14.5 6.33594 13.9141 5.75 13.25 5.75C12.5469 5.75 12 6.33594 12 7C12 7.70312 12.5469 8.25 13.25 8.25Z",fill:e})}),"InboxIcon");var gu=require("react/jsx-runtime"),ra=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,gu.jsx)(Z,{...n,width:r,height:o,children:(0,gu.jsx)(Re,{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 hu=require("react/jsx-runtime"),oa=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,hu.jsx)(Z,{...n,width:r,height:o,children:(0,hu.jsx)(Re,{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 bu=require("react/jsx-runtime"),yu=s(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 256 239",...n})=>(0,bu.jsx)(Z,{...n,width:t,height:r,viewBox:o,children:(0,bu.jsx)("path",{d:"M244.688 89.3027C250.936 89.3028 256 94.367 256 100.614V160.846C256 183.806 237.387 202.419 214.427 202.419H214.23C207.916 202.42 201.932 201.009 196.571 198.491C186.31 221.332 163.63 237.486 136.931 238.14C107.972 237.431 83.7409 218.49 74.9551 192.558H120.063C130.509 192.558 138.977 184.09 138.977 173.645V89.3027H244.688ZM120.082 53.5811C120.127 53.5812 120.172 53.5842 120.217 53.585C125.988 53.6645 130.676 58.2209 130.962 63.9395C130.971 64.1173 130.976 64.2966 130.977 64.4766V173.646C130.976 179.672 126.09 184.558 120.063 184.558H10.9131C4.88618 184.558 9.07128e-05 179.672 0 173.646V64.4941C0 58.4673 4.88624 53.5811 10.9131 53.5811H120.082ZM36.7686 95.125H58.4873V154.541H72.3887V95.125H94.208V83.5986H36.7686V95.125ZM139.907 0C161.279 0.000200803 178.604 17.3254 178.604 38.6973C178.604 60.0693 161.279 77.3953 139.907 77.3955C139.596 77.3955 139.286 77.3901 138.977 77.3828V64.4941C138.976 54.0493 130.509 45.5811 120.063 45.5811H101.82C101.419 43.3471 101.209 41.0467 101.209 38.6973C101.209 17.3253 118.535 0 139.907 0ZM223.256 23.8145C238.052 23.8145 250.047 35.8085 250.047 50.6045C250.047 65.4005 238.052 77.3954 223.256 77.3955C208.46 77.3955 196.465 65.4006 196.465 50.6045C196.465 35.8085 208.46 23.8145 223.256 23.8145Z",fill:e})}),"MSTeamsIcon");var Cu=require("react/jsx-runtime"),na=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Cu.jsx)(Z,{...n,width:r,height:o,children:(0,Cu.jsx)(Re,{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 gs=require("react/jsx-runtime"),vu=s(({color:e,width:t=21,height:r=16,...o})=>(0,gs.jsx)(Z,{...o,width:t,height:r,children:(0,gs.jsx)("g",{transform:"translate(4, 0)",children:(0,gs.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 xu=require("react/jsx-runtime"),Tu=s(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,xu.jsx)(Z,{...o,width:t,height:r,children:(0,xu.jsx)(Re,{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 Eu=require("react/jsx-runtime"),ia=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Eu.jsx)(Z,{...n,width:r,height:o,children:(0,Eu.jsx)(Re,{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 wu=require("react/jsx-runtime"),yn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,wu.jsx)(Z,{...n,width:r,height:o,children:(0,wu.jsx)(Re,{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 aa=require("react/jsx-runtime"),Pu=s(({width:e=20,height:t=21,viewBox:r="0 0 20 21",...o})=>(0,aa.jsxs)(Z,{...o,width:e,height:t,viewBox:r,children:[(0,aa.jsx)("path",{d:"M15 4.625H2.5C2.14844 4.625 1.875 4.9375 1.875 5.25V17.75C1.875 18.1016 2.14844 18.375 2.5 18.375H15C15.3125 18.375 15.625 18.1016 15.625 17.75V5.25C15.625 4.9375 15.3125 4.625 15 4.625ZM2.5 2.75H15C16.3672 2.75 17.5 3.88281 17.5 5.25V17.75C17.5 19.1562 16.3672 20.25 15 20.25H2.5C1.09375 20.25 0 19.1562 0 17.75V5.25C0 3.88281 1.09375 2.75 2.5 2.75Z",fill:"currentColor"}),(0,aa.jsx)("circle",{cx:"2",cy:"2",r:"3",transform:"matrix(-1 0 0 1 17.75 2)",fill:"currentColor",stroke:"white",strokeWidth:"2"})]}),"PushIcon");var ku=require("react/jsx-runtime"),Nu=s(({color:e="#171717",width:t=16,height:r=13,...o})=>(0,ku.jsx)(Z,{...o,fill:"none",width:t,height:r,children:(0,ku.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 Mu=require("react/jsx-runtime"),Au=s(({color:e="#171717",width:t=11,height:r=12,...o})=>(0,Mu.jsx)(Z,{...o,width:t,height:r,children:(0,Mu.jsx)(Re,{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 Su=require("react/jsx-runtime"),Iu=s(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,Su.jsx)(Z,{...o,width:t,height:r,children:(0,Su.jsx)("path",{d:"M6.80469 17.3125C7.3125 16.9219 7.97656 16.8438 8.5625 17.0391C9.57812 17.4297 10.75 17.625 12 17.625C16.8438 17.625 20.125 14.5 20.125 11.375C20.125 8.28906 16.8438 5.125 12 5.125C7.11719 5.125 3.875 8.28906 3.875 11.375C3.875 12.625 4.34375 13.8359 5.24219 14.8906C5.59375 15.2422 5.75 15.75 5.71094 16.2578C5.67188 16.9609 5.47656 17.625 5.28125 18.2109C5.94531 17.8984 6.49219 17.5469 6.80469 17.3125ZM2.82031 18.875C2.89844 18.7969 2.9375 18.6797 3.01562 18.5625C3.40625 17.9375 3.75781 17.0781 3.83594 16.1016C2.66406 14.7734 2 13.1719 2 11.375C2 6.92188 6.45312 3.25 12 3.25C17.5078 3.25 22 6.92188 22 11.375C22 15.8672 17.5078 19.5 12 19.5C10.5156 19.5 9.14844 19.2656 7.89844 18.8359C7.46875 19.1484 6.6875 19.6172 5.78906 20.0078C5.20312 20.2812 4.53906 20.5156 3.83594 20.6328C3.79688 20.6328 3.75781 20.6719 3.75781 20.6719C3.5625 20.7109 3.40625 20.7109 3.21094 20.75C3.01562 20.75 2.82031 20.7891 2.58594 20.7891C2.35156 20.7891 2.11719 20.6328 2.03906 20.3984C1.92188 20.1641 2 19.8906 2.15625 19.6953C2.3125 19.5391 2.46875 19.3828 2.58594 19.1875C2.66406 19.0703 2.74219 18.9922 2.78125 18.9141V18.875H2.82031Z",fill:e})}),"SMSIcon");var Wo=require("react/jsx-runtime"),tp=s(({color:e="#000000",width:t=14,height:r=9,...o})=>(0,Wo.jsx)(Z,{...o,width:t,height:r,children:(0,Wo.jsxs)("g",{opacity:"0.9",children:[(0,Wo.jsx)("rect",{x:"0.799805",y:"5.92188",width:"2.46154",height:"2.95385",rx:"0.246154",fill:e}),(0,Wo.jsx)("rect",{x:"4.24609",y:"4.44531",width:"2.46154",height:"4.43077",rx:"0.246154",fill:e}),(0,Wo.jsx)("rect",{x:"7.93823",y:"2.72266",width:"2.46154",height:"6.15385",rx:"0.246154",fill:e}),(0,Wo.jsx)("rect",{x:"11.3845",y:"0.753906",width:"2.46154",height:"8.12308",rx:"0.246154",fill:e})]})}),"SignalIcon");var Lu=require("react/jsx-runtime"),Ru=s(({color:e="#404040",width:t=16,height:r=16,...o})=>(0,Lu.jsx)(Z,{...o,width:t,height:r,children:(0,Lu.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 Hu=require("react/jsx-runtime"),sa=s(({color:e="#FFFFFF",width:t=24,height:r=24,...o})=>(0,Hu.jsx)(Z,{...o,width:t,height:r,viewBox:"0 0 24 24",children:(0,Hu.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 Du=require("react/jsx-runtime"),la=s(({color:e="#A3A3A3",width:t=24,height:r=24,...o})=>(0,Du.jsx)(Z,{...o,width:t,height:r,children:(0,Du.jsx)(Re,{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 Bu=require("react/jsx-runtime"),rp=s(({width:e=24,height:t=20,...r})=>(0,Bu.jsx)(Z,{...r,width:e,height:t,viewBox:"0 0 24 20",children:(0,Bu.jsx)("path",{d:"M6 1H5C4.46957 1 3.96086 1.21071 3.58579 1.58579C3.21071 1.96086 3 2.46957 3 3V8C3 8.53043 2.78929 9.03914 2.41421 9.41421C2.03914 9.78929 1.53043 10 1 10C1.53043 10 2.03914 10.2107 2.41421 10.5858C2.78929 10.9609 3 11.4696 3 12V17C3 18.1 3.9 19 5 19H6M18 19H19C19.5304 19 20.0391 18.7893 20.4142 18.4142C20.7893 18.0391 21 17.5304 21 17V12C21 10.9 21.9 10 23 10C22.4696 10 21.9609 9.78929 21.5858 9.41421C21.2107 9.03914 21 8.53043 21 8V3C21 2.46957 20.7893 1.96086 20.4142 1.58579C20.0391 1.21071 19.5304 1 19 1H18M10 16.5C10 16.7761 9.77614 17 9.5 17C9.22386 17 9 16.7761 9 16.5C9 16.2239 9.22386 16 9.5 16C9.77614 16 10 16.2239 10 16.5ZM15 16.5C15 16.7761 14.7761 17 14.5 17C14.2239 17 14 16.7761 14 16.5C14 16.2239 14.2239 16 14.5 16C14.7761 16 15 16.2239 15 16.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"VariableIcon");var Cn=require("react/jsx-runtime"),op=s(({color:e="#000000",width:t=14,height:r=10,...o})=>(0,Cn.jsx)(Z,{...o,width:t,height:r,children:(0,Cn.jsxs)("g",{opacity:"0.9",children:[(0,Cn.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,Cn.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,Cn.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 Fu=require("react/jsx-runtime"),ca=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Fu.jsx)(Z,{...n,width:r,height:o,children:(0,Fu.jsx)(Re,{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 np=require("lucide-react"),Tn=require("react");var hs=require("react/jsx-runtime"),vn=s(({className:e})=>(0,hs.jsx)("div",{className:L("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:(0,hs.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,hs.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");var xn=require("react/jsx-runtime"),li=s(({isError:e,isSaving:t,isLoading:r,renderIsSaving:o,renderIsError:n,renderSaved:i})=>{let[a,l]=(0,Tn.useState)(!1),c=(0,Tn.useRef)(t),u=(0,Tn.useRef)(null);return(0,Tn.useEffect)(()=>(r||e||t&&t!==c.current?(u.current&&(clearTimeout(u.current),u.current=null),l(!1)):c.current===!0&&t===!1&&!e&&!r&&(l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l(!1),u.current=null},5e3)),c.current=t,()=>{u.current&&clearTimeout(u.current)}),[t,e,r]),r||t===null?null:t?o?o(t):(0,xn.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,xn.jsx)(vn,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):(0,xn.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,xn.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,xn.jsx)(np.CircleCheck,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Saved"]}):null},"Status");var Vu=require("jotai");var En=require("react/jsx-runtime"),_o=[{label:"Email",value:"email",icon:(0,En.jsx)(cu,{})},{label:"SMS",value:"sms",icon:(0,En.jsx)(Iu,{})},{label:"Push",value:"push",icon:(0,En.jsx)(Pu,{})},{label:"In-app",value:"inbox",icon:(0,En.jsx)(ta,{})},{label:"Slack",value:"slack",icon:(0,En.jsx)(Ru,{})},{label:"Teams",value:"msteams",icon:(0,En.jsx)(yu,{})}];var Uo=(0,Vu.atom)("email"),ci=(0,Vu.atom)("template");var _5=require("@radix-ui/react-alert-dialog"),Ho=require("jotai"),bo=require("react");var Qt=require("jotai");var Ou={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"}},bs=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 B2={paragraph:Ou,heading:Ou},ua=(0,Qt.atom)(B2),Ce=(0,Qt.atom)(null),Xe=(0,Qt.atom)(null,(e,t,r)=>{t(Ce,r)}),F2=(0,Qt.atom)({ref:null,caretPosition:null}),ys=(0,Qt.atom)({ref:null,caretPosition:null}),da=(0,Qt.atom)({isFocused:!1,hasVariables:!1,showVariablePopup:!1}),ip=(0,Qt.atom)(e=>(t,r=!1)=>{let o=e(ua),n=e(da),i=bs(t,r),a=o[t],l=i;return a&&Object.keys(a).forEach(c=>{var d,p;let u=c;u!=="conditionalRules"&&((d=i[u])==null?void 0:d.state)==="enabled"&&((p=a[u])==null?void 0:p.state)==="enabled"&&(l[u]=a[u])}),n.isFocused&&n.hasVariables&&(l={...l,variable:{state:"enabled"}}),l}),ap=(0,Qt.atom)(null,(e,t,{nodeName:r,config:o})=>{let n=e(ua);t(ua,{...n,[r]:{...n[r],...Object.fromEntries(Object.entries(o).filter(([i])=>i!=="conditionalRules").map(([i,a])=>[i,{state:!Array.isArray(a)&&(a!=null&&a.state)?a.state:"hidden"}]))}})}),X8=(0,Qt.atom)(null,(e,t,r)=>{let o=e(ua),{[r]:n,...i}=o;t(ua,i)}),sp=(0,Qt.atom)(null,(e,t,{ref:r,caretPosition:o})=>{t(F2,{ref:r,caretPosition:o})}),Q8=(0,Qt.atom)(null,(e,t,r)=>{let o=e(da);t(da,{...o,showVariablePopup:r})}),Wu=(0,Qt.atom)(null),Cs=(0,Qt.atom)(null,(e,t,r)=>{t(Wu,r)});var Ro=require("jotai"),fr=require("react");var _u=require("jotai"),Zr=(0,_u.atom)(null),uo=(0,_u.atom)(null);var lp=require("react"),cp=require("sonner");var zo=require("react/jsx-runtime"),er=(0,lp.forwardRef)(({theme:e,children:t,isLoading:r,Header:o,colorScheme:n,className:i,...a},l)=>(0,zo.jsx)(jm,{theme:e,ref:l,colorScheme:n,className:i,children:(0,zo.jsxs)("div",{...Object.fromEntries(Object.entries(a).filter(([c])=>c!=="variables"&&c!=="brandEditor")),className:"courier-main-layout",children:[o&&(0,zo.jsx)("div",{className:"courier-main-header 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-background",children:o}),r&&(0,zo.jsx)("div",{className:"courier-editor-loading",children:(0,zo.jsx)(vn,{})}),(0,zo.jsx)(cp.Toaster,{position:"top-center",expand:!0,visibleToasts:2,style:{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)"}}),t]})}));var nr=require("jotai"),Ee=require("react");function up(e){if(Array.isArray(e))return e}s(up,"_arrayWithHoles");function dp(e,t){var r=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,n,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(o=i.call(r)).done)&&(l.push(o.value),l.length!==t);c=!0);}catch(d){u=!0,n=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw n}}return l}}s(dp,"_iterableToArrayLimit");function ma(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}s(ma,"_arrayLikeToArray");function vs(e,t){if(e){if(typeof e=="string")return ma(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ma(e,t):void 0}}s(vs,"_unsupportedIterableToArray");function mp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
182
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}s(
|
|
183
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}s(
|
|
184
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,a=!0,l=!1;return{s:s(function(){r=r.call(e)},"s"),n:s(function(){var u=r.next();return a=u.done,u},"n"),e:s(function(u){l=!0,i=u},"e"),f:s(function(){try{a||r.return==null||r.return()}finally{if(l)throw i}},"f")}}s(
|
|
185
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,a=!0,l=!1;return{s:s(function(){r=r.call(e)},"s"),n:s(function(){var u=r.next();return a=u.done,u},"n"),e:s(function(u){l=!0,i=u},"e"),f:s(function(){try{a||r.return==null||r.return()}finally{if(l)throw i}},"f")}}s(nh,"_createForOfIteratorHelper");function ih(e,t){if(e){if(typeof e=="string")return _p(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_p(e,t):void 0}}s(ih,"_unsupportedIterableToArray");function _p(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}s(_p,"_arrayLikeToArray");function Up(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}s(Up,"ownKeys");function ah(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Up(Object(r),!0).forEach(function(o){Po(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Up(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(ah,"_objectSpread");function zp(){var e=new Set,t=null;function r(i){t&&(!i.canMonitor||i.canMonitor(t.canMonitorArgs))&&t.active.add(i)}s(r,"tryAddToActive");function o(i){var a=ah({},i);e.add(a),r(a);function l(){e.delete(a),t&&t.active.delete(a)}return s(l,"cleanup"),Mr(l)}s(o,"monitorForConsumers");function n(i){var a=i.eventName,l=i.payload;if(a==="onGenerateDragPreview"){t={canMonitorArgs:{initial:l.location.initial,source:l.source},active:new Set};var c=nh(e),u;try{for(c.s();!(u=c.n()).done;){var d=u.value;r(d)}}catch(h){c.e(h)}finally{c.f()}}if(t){for(var p=Array.from(t.active),m=0,f=p;m<f.length;m++){var C=f[m];if(t.active.has(C)){var y;(y=C[a])===null||y===void 0||y.call(C,l)}}a==="onDrop"&&(t.active.clear(),t=null)}}return s(n,"dispatchEvent"),{dispatchEvent:n,monitorForConsumers:o}}s(zp,"makeMonitor");function $p(e){var t=e.typeKey,r=e.mount,o=e.dispatchEventToSource,n=e.onPostDispatch,i=e.defaultDropEffect,a=zp(),l=Wp({typeKey:t,defaultDropEffect:i});function c(p){o==null||o(p),l.dispatchEvent(p),a.dispatchEvent(p),n==null||n(p)}s(c,"dispatchEvent");function u(p){var m=p.event,f=p.dragType;Ju.start({event:m,dragType:f,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}s(u,"start");function d(){function p(){var m={canStart:Ju.canStart,start:u};return r(m)}return s(p,"mountAdapter"),Fp({typeKey:t,mount:p})}return s(d,"registerUsage"),{registerUsage:d,dropTarget:l.dropTargetForConsumers,monitor:a.monitorForConsumers}}s($p,"makeAdapter");var Zp=Mr(s(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")},"isAndroid")),qp="pdnd:android-fallback";var Yu="text/plain";var Jp="text/uri-list";var jp="application/vnd.pdnd";var As=new WeakMap;function sh(e){return As.set(e.element,e),s(function(){As.delete(e.element)},"cleanup")}s(sh,"addToRegistry");var Kp=Ep(),Xu=$p({typeKey:"element",defaultDropEffect:"move",mount:s(function(t){return mo(Kp.bindEvents(),(0,Gp.bind)(document,{type:"dragstart",listener:s(function(o){var n,i,a,l,c,u;if(t.canStart(o)&&!o.defaultPrevented&&o.dataTransfer){var d=o.target;if(d instanceof HTMLElement){var p=As.get(d);if(p){var m=Pn(o),f={element:p.element,dragHandle:(n=p.dragHandle)!==null&&n!==void 0?n:null,input:m};if(p.canDrag&&!p.canDrag(f)){o.preventDefault();return}if(p.dragHandle){var C=Ps({x:m.clientX,y:m.clientY});if(!p.dragHandle.contains(C)){o.preventDefault();return}}var y=(i=(a=p.getInitialDataForExternal)===null||a===void 0?void 0:a.call(p,f))!==null&&i!==void 0?i:null;if(y)for(var h=0,b=Object.entries(y);h<b.length;h++){var N=xs(b[h],2),g=N[0],w=N[1];o.dataTransfer.setData(g,w!=null?w:"")}Zp()&&!o.dataTransfer.types.includes(Yu)&&!o.dataTransfer.types.includes(Jp)&&o.dataTransfer.setData(Yu,qp),o.dataTransfer.setData(jp,"");var M={element:p.element,dragHandle:(l=p.dragHandle)!==null&&l!==void 0?l:null,data:(c=(u=p.getInitialData)===null||u===void 0?void 0:u.call(p,f))!==null&&c!==void 0?c:{}},k={type:"element",payload:M,startedFrom:"internal"};t.start({event:o,dragType:k})}}}},"listener")}))},"mount"),dispatchEventToSource:s(function(t){var r,o,n=t.eventName,i=t.payload;(r=As.get(i.source.element))===null||r===void 0||(o=r[n])===null||o===void 0||o.call(r,i)},"dispatchEventToSource"),onPostDispatch:Kp.getOnPostDispatch()}),yr=Xu.dropTarget,Qu=Xu.monitor;function ba(e){if(0)var t;var r=mo(Xu.registerUsage(),sh(e),Ms(e.element,{attribute:"draggable",value:"true"}));return Mr(r)}s(ba,"draggable");function Yp(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}s(Yp,"ownKeys");function Xp(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Yp(Object(r),!0).forEach(function(o){Po(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Yp(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(Xp,"_objectSpread");var lh={top:s(function(t,r){return Math.abs(r.y-t.top)},"top"),right:s(function(t,r){return Math.abs(t.right-r.x)},"right"),bottom:s(function(t,r){return Math.abs(t.bottom-r.y)},"bottom"),left:s(function(t,r){return Math.abs(r.x-t.left)},"left")},Qp=Symbol("closestEdge");function ef(e,t){var r,o,n=t.element,i=t.input,a=t.allowedEdges,l={x:i.clientX,y:i.clientY},c=n.getBoundingClientRect(),u=a.map(function(p){return{edge:p,value:lh[p](c,l)}}),d=(r=(o=u.sort(function(p,m){return p.value-m.value})[0])===null||o===void 0?void 0:o.edge)!==null&&r!==void 0?r:null;return Xp(Xp({},e),{},Po({},Qp,d))}s(ef,"attachClosestEdge");function ya(e){var t;return(t=e[Qp])!==null&&t!==void 0?t:null}s(ya,"extractClosestEdge");var Fl=require("@tiptap/core"),Cg=require("@tiptap/react");var gg=require("@tiptap/react"),hg=require("jotai"),bg=require("react");var mg=require("@tiptap/react"),pg=require("jotai"),Me=require("react"),fg=require("uuid");var wd=require("@tiptap/extension-color");var tf=require("@tiptap/core"),rf=require("@tiptap/pm/dropcursor"),ed=tf.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[(0,rf.dropCursor)(this.options)]}});var Pd=require("@tiptap/extension-hard-break");var of=require("@tiptap/core"),pi=require("@tiptap/pm/history"),ch=of.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>(0,pi.undo)(e,t),redo:()=>({state:e,dispatch:t})=>(0,pi.redo)(e,t)}},addProseMirrorPlugins(){return[(0,pi.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 kd=require("@tiptap/extension-placeholder"),Nd=require("@tiptap/extension-text-align"),Md=require("@tiptap/extension-typography"),Ad=require("@tiptap/extension-underline"),Sd=require("@tiptap/starter-kit");var lf=require("@tiptap/core");var fi=require("@tiptap/core"),uh=/^\s*>\s$/,nf=fi.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,fi.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,fi.wrappingInputRule)({find:uh,type:this.type})]}});var cf=require("@tiptap/react");var af=require("uuid");function dt(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,af.v4)()}`;r.setNodeMarkup(i,void 0,{...n.attrs,id:a}),o=!0}return!1}),o&&e.view.dispatch(r)}s(dt,"generateNodeIds");var Ss=require("@tiptap/react"),Is=require("jotai"),gi=require("react");var Zo=require("react/jsx-runtime"),dh=s(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderLeftWidth:o,borderColor:n})=>(0,Zo.jsx)("div",{className:"courier-w-full node-element",children:(0,Zo.jsx)("div",{style:{position:"relative",padding:`${t}px ${e}px`,backgroundColor:r,borderLeftWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",whiteSpace:"pre-wrap"},children:(0,Zo.jsx)(Ss.NodeViewContent,{})})}),"BlockquoteComponent"),sf=s(e=>{var l,c,u;let t=(0,Is.useSetAtom)(Xe),r=(0,Is.useAtomValue)(Ce),o=(0,gi.useRef)(null),n=((l=r==null?void 0:r.type)==null?void 0:l.name)==="blockquote"&&(((c=r==null?void 0:r.attrs)==null?void 0:c.id)===e.node.attrs.id||!((u=r==null?void 0:r.attrs)!=null&&u.id)&&!e.node.attrs.id&&r===e.node),i=(0,gi.useCallback)(()=>{if(!e.editor.isEditable)return;let d=e.node;d&&(t(d),e.editor.commands.updateSelectionState(d))},[e.editor.isEditable,e.node,e.editor.commands,t]);(0,gi.useEffect)(()=>{let d=o.current;if(!d)return;let p=s(m=>{let f=m.target;f.closest(".courier-actions-panel")||f.closest("[data-no-drag-preview]")||i()},"handleClick");return d.addEventListener("click",p,!0),()=>{d.removeEventListener("click",p,!0)}},[i]);let a=!e.node.content||e.node.content.size===0;return(0,Zo.jsx)(Ss.NodeViewWrapper,{children:(0,Zo.jsx)("div",{ref:o,children:(0,Zo.jsx)(Rt,{id:e.node.attrs.id,className:L(n&&"selected-element",a&&"is-empty"),editor:e.editor,children:(0,Zo.jsx)(dh,{...e.node.attrs})})})})},"BlockquoteComponentNode");var qo={paddingHorizontal:8,paddingVertical:6,backgroundColor:"transparent",borderLeftWidth:4,borderColor:"#e0e0e0"},td=nf.extend({content:"block+",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){dt(this.editor,this.name)},addAttributes(){return{id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},paddingHorizontal:{default:qo.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:qo.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:qo.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderLeftWidth:{default:qo.borderLeftWidth,parseHTML:e=>e.getAttribute("data-border-left-width"),renderHTML:e=>({"data-border-left-width":e.borderLeftWidth})},borderColor:{default:qo.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,lf.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,l=i.doc.resolve(a);if(l.depth>1){let c=l.blockRange();c&&i.lift(c,0)}return!0}).focus().run()}}},addNodeView(){return(0,cf.ReactNodeViewRenderer)(sf)}});var hf=require("@hookform/resolvers/zod"),bf=require("react-hook-form");var kn=require("react");var xt=s(({editor:e,element:t,form:r,nodeType:o})=>{let n=(0,kn.useRef)(null),i=(0,kn.useRef)(null);return(0,kn.useEffect)(()=>{if(!e||!t)return;let l=s(()=>{let c=null;if(e.state.doc.descendants((u,d)=>u.attrs.id===t.attrs.id?(c=d,!1):!0),c!==null){let u=e.state.doc.nodeAt(c);(u==null?void 0:u.type.name)===o&&(n.current=u,i.current=c,Object.entries(u.attrs).forEach(([d,p])=>{r.getValues(d)!==p&&r.setValue(d,p)}))}},"updateCurrentNode");return l(),e.on("update",l),()=>{e.off("update",l)}},[e,t,r,o]),{updateNodeAttributes:(0,kn.useCallback)(l=>{if(!e||i.current===null)return;let c=e.state.doc.nodeAt(i.current);if(!c||c.type.name!==o)return;let u={...c.attrs,...l,id:c.attrs.id};JSON.stringify(c.attrs)!==JSON.stringify(u)&&e.chain().command(({tr:p,dispatch:m})=>{let f=p.doc.nodeAt(i.current);return(f==null?void 0:f.type.name)===o&&m?(p.setNodeMarkup(i.current,f.type,u),p.setMeta("addToHistory",!0),!0):!1}).run()},[e,o])}},"useNodeAttributes");var Nn=require("jotai"),Ca=require("react");var Tt=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,...Tt(n,i)]:[...r,i]},[]),"getFlattenedVariables");var mh={link:["href","content"],img:["src","href","alt_text"],image:["src","href","alt_text"],action:["href","content"],meta:["title"],list:["imgSrc","imgHref"],quote:["content"],html:[]},ph=["content","href","src","title"],uf=s((e=[])=>{let t=new Set,r=/\{\{([^}]+)\}\}/g,o=s(i=>{let a=i.matchAll(r);for(let l of a){let c=l[1].trim();c&&at(c)&&t.add(c)}},"extractFromString"),n=s(i=>{let a=i;a.type==="string"&&typeof a.content=="string"&&o(a.content),a.type==="text"&&typeof a.content=="string"&&o(a.content);let l=a.type,c=mh[l];c&&c.forEach(u=>{typeof a[u]=="string"&&o(a[u])}),typeof a.if=="string"&&o(a.if),typeof a.loop=="string"&&o(a.loop),a.type==="channel"&&a.raw&&typeof a.raw=="object"&&a.raw!==null&&Object.values(a.raw).forEach(u=>{typeof u=="string"&&o(u)}),a.elements&&Array.isArray(a.elements)&&a.elements.forEach(u=>n(u)),a.locales&&typeof a.locales=="object"&&a.locales!==null&&Object.values(a.locales).forEach(u=>{if(u&&typeof u=="object"){let d=u;ph.forEach(p=>{typeof d[p]=="string"&&o(d[p])}),d.elements&&Array.isArray(d.elements)&&d.elements.forEach(p=>{p&&n(p)}),d.raw&&typeof d.raw=="object"&&d.raw!==null&&Object.values(d.raw).forEach(p=>{typeof p=="string"&&o(p)})}})},"processNode");return e.forEach(i=>n(i)),Array.from(t).sort()},"extractVariablesFromContent");var fh=s(e=>{let t=(0,Nn.useAtomValue)(Be),r=(0,Nn.useAtomValue)(te),o=(0,Nn.useAtomValue)(Uo),n=(0,Nn.useAtomValue)(fn),i=(0,Nn.useSetAtom)(fn),a=e!=null?e:o,l=(0,Ca.useMemo)(()=>{var p,m;if(!t)return[];let d=((m=(p=t.extensionManager.extensions.find(f=>f.name==="variableSuggestion"))==null?void 0:p.options)==null?void 0:m.variables)||{};return Tt(d)},[t]),c=(0,Ca.useMemo)(()=>{if(!r||!a)return[];let d=r.elements.find(p=>p.type==="channel"&&p.channel===a);return d?uf(d.elements||[]):[]},[r,a]),u=(0,Ca.useCallback)((d,p)=>{i(m=>({...m,[d]:p}))},[i]);return{availableVariables:l,usedVariables:c,variableValues:n,addVariableValue:u}},"useVariables");var ff=require("jotai");var va=require("react/jsx-runtime"),mt=s(({draggable:e=!1,icon:t,draggableLabel:r,label:o})=>(0,va.jsxs)("div",{className:"courier-flex courier-flex-row courier-items-center courier-gap-2",children:[(0,va.jsx)("div",{className:L("courier-w-8 courier-h-8 courier-rounded-md courier-flex courier-items-center courier-justify-center",e?"courier-cursor-grab courier-bg-secondary":"courier-border courier-border-border"),children:t}),(0,va.jsx)("span",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:e?r:o})]}),"BlockBase");var df=require("lucide-react");var rd=require("react/jsx-runtime"),mf=s(({draggable:e=!1})=>(0,rd.jsx)(mt,{draggable:e,icon:(0,rd.jsx)(df.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),draggableLabel:"Blockquote",label:"Blockquote block"}),"BlockquoteBlock");var xa=require("react/jsx-runtime"),gh=s(()=>(0,xa.jsx)("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,xa.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:"currentColor"})}),"ButtonBlockIcon"),Jo=s(({draggable:e=!1})=>(0,xa.jsx)(mt,{draggable:e,icon:(0,xa.jsx)(gh,{}),draggableLabel:"Button",label:"Button block"}),"ButtonBlock");var Ta=require("react/jsx-runtime"),hh=s(()=>(0,Ta.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ta.jsx)("path",{d:"M14 1.5V12.5H18C18.25 12.5 18.5 12.2812 18.5 12V2C18.5 1.75 18.25 1.5 18 1.5H14ZM12.5 1.5H7.5V12.5H12.5V1.5ZM6 12.5V1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12C1.5 12.2812 1.71875 12.5 2 12.5H6ZM0 2C0 0.90625 0.875 0 2 0H18C19.0938 0 20 0.90625 20 2V12C20 13.125 19.0938 14 18 14H2C0.875 14 0 13.125 0 12V2Z",fill:"currentColor"})}),"ColumnBlockIcon"),Ls=s(({draggable:e=!1})=>(0,Ta.jsx)(mt,{draggable:e,icon:(0,Ta.jsx)(hh,{}),draggableLabel:"Column layout",label:"Column layout"}),"ColumnBlock");var Ea=require("react/jsx-runtime"),bh=s(()=>(0,Ea.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ea.jsx)("path",{d:"M6.5 3.5L3 7L6.5 10.5M13.5 3.5L17 7L13.5 10.5M11.5 1L8.5 13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"CustomCodeBlockIcon"),wa=s(({draggable:e=!1})=>(0,Ea.jsx)(mt,{draggable:e,icon:(0,Ea.jsx)(bh,{}),draggableLabel:"Custom code",label:"Custom code"}),"CustomCodeBlock");var Pa=require("react/jsx-runtime"),yh=s(()=>(0,Pa.jsx)("svg",{width:"16",height:"2",viewBox:"0 0 16 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Pa.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:"currentColor"})}),"DividerBlockIcon"),jo=s(({draggable:e=!1})=>(0,Pa.jsx)(mt,{draggable:e,icon:(0,Pa.jsx)(yh,{}),draggableLabel:"Divider",label:"Divider block"}),"DividerBlock");var ka=require("react/jsx-runtime"),Ch=s(()=>(0,ka.jsx)("svg",{width:"18",height:"13",viewBox:"0 0 18 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ka.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:"currentColor"})}),"HeadingBlockIcon"),Rs=s(({draggable:e=!1})=>(0,ka.jsx)(mt,{draggable:e,icon:(0,ka.jsx)(Ch,{}),draggableLabel:"Heading",label:"Heading block"}),"HeadingBlock");var Na=require("react/jsx-runtime"),vh=s(()=>(0,Na.jsx)("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Na.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:"currentColor"})}),"ImageBlockIcon"),Hs=s(({draggable:e=!1})=>(0,Na.jsx)(mt,{draggable:e,icon:(0,Na.jsx)(vh,{}),draggableLabel:"Image",label:"Image block"}),"ImageBlock");var pf=require("lucide-react");var od=require("react/jsx-runtime"),Ds=s(({draggable:e=!1})=>(0,od.jsx)(mt,{draggable:e,icon:(0,od.jsx)(pf.AlignVerticalSpaceAround,{className:"courier-w-4 courier-h-4"}),draggableLabel:"Spacer",label:"Spacer block"}),"SpacerBlock");var Ma=require("react/jsx-runtime"),xh=s(()=>(0,Ma.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ma.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:"currentColor"})}),"TextBlockIcon"),Ko=s(({draggable:e=!1})=>(0,Ma.jsx)(mt,{draggable:e,icon:(0,Ma.jsx)(xh,{}),draggableLabel:"Text",label:"Text block"}),"TextBlock");var tr=require("react/jsx-runtime"),Ht=s(({type:e})=>{let t=(0,ff.useSetAtom)(Xe);return(0,tr.jsxs)("div",{className:"courier-flex courier-gap-4 courier-flex-col",children:[(0,tr.jsx)(Ie,{className:"courier-w-fit",variant:"secondary",buttonSize:"small",onClick:()=>{t(null)},children:"Close"}),e==="heading"&&(0,tr.jsx)(Rs,{}),e==="text"&&(0,tr.jsx)(Ko,{}),e==="image"&&(0,tr.jsx)(Hs,{}),e==="spacer"&&(0,tr.jsx)(Ds,{}),e==="divider"&&(0,tr.jsx)(jo,{}),e==="button"&&(0,tr.jsx)(Jo,{}),e==="blockquote"&&(0,tr.jsx)(mf,{}),e==="customCode"&&(0,tr.jsx)(wa,{}),e==="column"&&(0,tr.jsx)(Ls,{}),(0,tr.jsx)(le,{className:"courier-m-0"})]})},"FormHeader");var Go=require("zod"),gf=Go.z.object({paddingHorizontal:Go.z.coerce.number().min(0),paddingVertical:Go.z.coerce.number().min(0),backgroundColor:Go.z.string(),borderLeftWidth:Go.z.coerce.number().min(0),borderColor:Go.z.string(),id:Go.z.string().optional()});var qr=require("react/jsx-runtime"),yf=s(({element:e,editor:t})=>{let r=(0,bf.useForm)({resolver:(0,hf.zodResolver)(gf),defaultValues:{...qo,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=xt({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"blockquote"});return e?(0,qr.jsxs)(Je,{...r,children:[(0,qr.jsx)(Ht,{type:"blockquote"}),(0,qr.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,qr.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,qr.jsx)(j,{control:r.control,name:"borderColor",render:({field:n})=>(0,qr.jsxs)(q,{className:"courier-mb-3",children:[(0,qr.jsx)(J,{children:(0,qr.jsx)(vt,{...n,defaultValue:qo.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,qr.jsx)(K,{})]})})]})]}):null},"BlockquoteForm");var rr=require("zod"),Bs=rr.z.object({label:rr.z.string(),link:rr.z.string().optional(),alignment:rr.z.enum(["left","center","right"]),backgroundColor:rr.z.string(),borderRadius:rr.z.number(),padding:rr.z.number(),fontWeight:rr.z.enum(["normal","bold"]),fontStyle:rr.z.enum(["normal","italic"]),isUnderline:rr.z.boolean(),isStrike:rr.z.boolean(),textColor:rr.z.string().optional(),borderColor:rr.z.string().optional()});var Hf=require("@hookform/resolvers/zod"),Df=require("react-hook-form");var Cf=require("@tiptap/core"),hi=Cf.Node.create({name:"doc",topNode:!0,content:"block+"});var Fs=require("@tiptap/core"),bi=Fs.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",(0,Fs.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 Lf=he(require("@tiptap/extension-placeholder"),1);var vf=require("@tiptap/core"),Vs=vf.Node.create({name:"text",group:"inline"});var qs=require("@tiptap/react"),Sn=he(require("react"),1),Ia=require("react");var Ws=require("@tiptap/core"),kf=require("@tiptap/react"),Nf=require("@tiptap/suggestion");var xf={char:"{{",allowSpaces:!1,allowedPrefixes:null,startOfLine:!1,items:()=>[],command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()},render:()=>({onStart:e=>{e.editor.chain().focus().deleteRange(e.range).insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()},onUpdate(){},onKeyDown(){return!1},onExit(){}})};var Ef=require("@tiptap/react"),Et=require("react"),wf=require("jotai");var Aa=require("react/jsx-runtime"),Os=s(({color:e="#1D4ED8"})=>(0,Aa.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,Aa.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,Aa.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableIcon");var Yo=require("react/jsx-runtime"),Tf=50,nd=24,Pf=s(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=(0,wf.useAtomValue)(fn),i=e.attrs.id||"",a=n[i],l=e.attrs.isInvalid,[c,u]=(0,Et.useState)(!1),[d,p]=(0,Et.useState)(!1),[m,f]=(0,Et.useState)(i),C=(0,Et.useRef)(null);(0,Et.useEffect)(()=>{i===""&&!d&&(p(!0),f(""))},[i,d]),(0,Et.useEffect)(()=>{d&&C.current&&C.current.focus()},[d]);let y=(0,Et.useCallback)(()=>{if(typeof r=="function")try{let x=r();if(x==null){u(!1);return}let v=t.state.doc.resolve(x).parent;u(v&&v.type.name==="button")}catch{u(!1)}else u(!1)},[t,r]);(0,Et.useEffect)(()=>{y();let x=s(()=>{y()},"handleUpdate");return t.on("update",x),t.on("selectionUpdate",x),()=>{t.off("update",x),t.off("selectionUpdate",x)}},[t,y]);let h=(0,Et.useCallback)(()=>{p(!1);let x=m.trim();if(x===""){if(typeof r=="function"){let v=r();typeof v=="number"&&t.chain().focus().deleteRange({from:v,to:v+e.nodeSize}).run()}return}let E=at(x);o({id:x,isInvalid:!E})},[m,t,r,e.nodeSize,o]),b=(0,Et.useCallback)(x=>{var E;x.key==="Enter"?(x.preventDefault(),(E=C.current)==null||E.blur()):x.key==="Escape"&&(x.preventDefault(),f(i),p(!1))},[i]),N=(0,Et.useCallback)(()=>{p(!0),f(i)},[i]),g=s(()=>l?{bgColor:"#FEF2F2",borderColor:"#FECACA",iconColor:"#DC2626",textColor:"#991B1B"}:a?{bgColor:"#EFF6FF",borderColor:"#BFDBFE",iconColor:void 0,textColor:"#1E40AF"}:{bgColor:"#FFFBEB",borderColor:"#FDE68A",iconColor:"#B45309",textColor:"#92400E"},"getColors"),{bgColor:w,borderColor:M,iconColor:k,textColor:D}=g(),T=(0,Et.useMemo)(()=>{let x=i,E=a?`="${a}"`:"",v=`${x}${E}`,P=x.length>nd;return{displayText:`${P?`${x.slice(0,nd)}\u2026`:x}${E}`,fullText:v,showTitle:P}},[i,a]);return(0,Yo.jsx)(Ef.NodeViewWrapper,{className:"courier-inline-block courier-max-w-full",children:(0,Yo.jsxs)("span",{className:`courier-inline-flex courier-items-center courier-gap-0.5 courier-rounded courier-border courier-px-1.5 courier-pl-1 courier-py-[1px] courier-text-sm courier-variable-node courier-font-mono courier-max-w-full courier-tracking-[0.64px] ${c?"courier-variable-in-button":""}`,style:{backgroundColor:w,borderColor:M,color:c?"#000000":D},onDoubleClick:N,title:T.showTitle?T.fullText:void 0,children:[(0,Yo.jsx)("span",{className:"courier-flex-shrink-0 courier-flex courier-items-center",children:(0,Yo.jsx)(Os,{color:k})}),d?(0,Yo.jsx)("input",{ref:C,type:"text",value:m,onChange:x=>f(x.target.value.slice(0,Tf)),onBlur:h,onKeyDown:b,className:"courier-bg-transparent courier-border-none courier-outline-none courier-font-mono courier-text-sm",style:{color:c?"#000000":D,width:`${Math.min(Math.max(m.length+1,4),nd)}ch`,padding:0,margin:0,lineHeight:"normal",boxSizing:"content-box"},maxLength:Tf}):(0,Yo.jsx)("span",{className:"courier-min-w-0 courier-cursor-text",style:c?{color:"#000000"}:void 0,children:T.displayText})]})})},"VariableView");var id=Ws.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:"",parseHTML:e=>e.getAttribute("data-id")||"",renderHTML:e=>({"data-id":e.id})},isInvalid:{default:!1,parseHTML:e=>e.getAttribute("data-invalid")==="true",renderHTML:e=>({"data-invalid":e.isInvalid?"true":void 0})}}},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,kf.ReactNodeViewRenderer)(Pf)}}),Mn=Ws.Extension.create({name:"variableSuggestion",addOptions(){return{HTMLAttributes:{},suggestion:{char:"{{",...xf}}},addProseMirrorPlugins(){return this.options.disableSuggestions?[]:[(0,Nf.Suggestion)({editor:this.editor,...this.options.suggestion})]}});var Mf=require("@tiptap/core"),Af=require("@tiptap/pm/state"),_s=require("@tiptap/pm/model");var An=Mf.Extension.create({name:"variablePaste",addProseMirrorPlugins(){return[new Af.Plugin({props:{transformPastedHTML:e=>e.replace(/\{\{([^}]+)\}\}/g,(r,o)=>{let n=o.trim();return at(n)?`<span data-variable="true" data-id="${n}"></span>`:r}),transformPastedText:(e,t,r)=>{let o=/\{\{([^}]+)\}\}/g;if(!o.test(e))return e;let{schema:n}=r.state,i=[],a=0,l;for(o.lastIndex=0;(l=o.exec(e))!==null;){if(l.index>a){let u=e.substring(a,l.index);u&&i.push(n.text(u))}let c=l[1].trim();if(n.nodes.variable&&at(c))i.push(n.nodes.variable.create({id:c,isInvalid:!1}));else{let u=l[0];i.push(n.text(u))}a=l.index+l[0].length}if(a<e.length){let c=e.substring(a);c&&i.push(n.text(c))}if(i.length>0){let c=_s.Fragment.from(i),u=new _s.Slice(c,0,0),d=r.state.tr.replaceSelection(u);return r.dispatch(d),e}return e}}})]}});var Sf=require("@tiptap/core"),Us=require("@tiptap/pm/state");var Sa=Sf.Extension.create({name:"variableTypeHandler",addProseMirrorPlugins(){return[new Us.Plugin({key:new Us.PluginKey("variableTypeHandler"),appendTransaction:(e,t,r)=>{if(!e.some(u=>u.docChanged))return null;let{schema:n,doc:i}=r,a=/\{\{([^}]+)\}\}/g,l=[];if(i.descendants((u,d)=>{if(u.isText&&u.text){let p;for(a.lastIndex=0;(p=a.exec(u.text))!==null;){let m=p[1].trim();m&&at(m)&&l.push({from:d+p.index,to:d+p.index+p[0].length,variableName:m})}}}),l.length===0)return null;let c=r.tr;for(let u=l.length-1;u>=0;u--){let{from:d,to:p,variableName:m}=l[u],f=c.doc.nodeAt(d);f&&f.isText&&n.nodes.variable&&c.replaceWith(d,p,n.nodes.variable.create({id:m}))}return c.docChanged?c:null}})]}});var If=require("@tiptap/core"),zs=require("@tiptap/react");var ko=require("react/jsx-runtime"),Th=s(({color:e="#B45309"})=>(0,ko.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,ko.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,ko.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableChipIcon"),Eh=s(({node:e})=>(0,ko.jsx)(zs.NodeViewWrapper,{as:"span",className:"courier-inline",children:(0,ko.jsxs)("span",{className:"courier-inline-flex courier-items-center courier-gap-0.5 courier-rounded courier-border courier-px-1.5 courier-pl-1 courier-py-[1px] courier-text-sm courier-font-mono courier-max-w-full courier-tracking-[0.64px] courier-text-amber-800",style:{backgroundColor:"#FFFBEB",borderColor:"#FDE68A"},children:[(0,ko.jsx)(Th,{}),(0,ko.jsx)("span",{className:"courier-truncate courier-min-w-0",children:e.attrs.id})]})}),"SimpleVariableView"),$s=If.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,zs.ReactNodeViewRenderer)(Eh)}});function yi(e){if(!e)return{type:"doc",content:[{type:"paragraph"}]};let t=/\{\{([^}]+)\}\}/g,r=[],o=0,n;for(;(n=t.exec(e))!==null;){if(n.index>o){let a=e.substring(o,n.index);a&&r.push({type:"text",text:a})}let i=n[1].trim();at(i)?r.push({type:"variable",attrs:{id:i}}):r.push({type:"text",text:n[0]}),o=n.index+n[0].length}if(o<e.length){let i=e.substring(o);i&&r.push({type:"text",text:i})}return{type:"doc",content:[{type:"paragraph",content:r.length>0?r:void 0}]}}s(yi,"parseStringToContent");function Zs(e){if(!e.content)return"";let t="",r=s(o=>{var n;o.type==="text"&&o.text?t+=o.text:o.type==="variable"&&((n=o.attrs)!=null&&n.id)?t+=`{{${o.attrs.id}}}`:(o.type==="paragraph"||o.type==="doc")&&o.content&&o.content.forEach(i=>r(i))},"processNode");return e.content.forEach(o=>r(o)),t}s(Zs,"contentToString");var ad=require("react/jsx-runtime"),Jr=Sn.forwardRef(({value:e="",onChange:t,variables:r=[],placeholder:o,className:n,disabled:i=!1,disableVariableAutocomplete:a=!1,onFocus:l,onBlur:c},u)=>{let d=Sn.useRef(!1),p=Sn.useRef(e),m=(0,qs.useEditor)({extensions:[hi,bi.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),Vs,$s,Mn.configure({variables:Object.fromEntries(r.map(C=>[C,C])),disableSuggestions:a}),An,Sa,Lf.default.configure({placeholder:o||"",emptyEditorClass:"is-editor-empty"})],content:yi(e),editable:!i,editorProps:{attributes:{class:"courier-outline-none courier-min-h-[20px]"},handleKeyDown:(C,y)=>y.key==="Enter"&&!y.shiftKey&&!document.querySelector(".variable-suggestions")?(y.preventDefault(),!0):!1},onUpdate:({editor:C})=>{if(d.current)return;let y=Zs(C.getJSON());y!==p.current&&(p.current=y,t==null||t(y))},onFocus:()=>{l==null||l()},onBlur:()=>{c==null||c()}});(0,Ia.useEffect)(()=>{if(!m||e===p.current)return;d.current=!0,p.current=e;let C=setTimeout(()=>{let y=yi(e);m.commands.setContent(y),d.current=!1},0);return()=>clearTimeout(C)},[m,e]),(0,Ia.useEffect)(()=>{m&&m.setEditable(!i)},[m,i]);let f=(0,Ia.useCallback)(()=>{m==null||m.commands.focus()},[m]);return Sn.useImperativeHandle(u,()=>{let C=m==null?void 0:m.view.dom.parentElement;return C&&(C.focus=f),C},[m,f]),(0,ad.jsx)("div",{ref:u,className:L("variable-textarea-placeholder","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 md:courier-text-sm",i&&"courier-cursor-not-allowed courier-opacity-50","[&_.ProseMirror]:courier-outline-none [&_.ProseMirror]:courier-min-h-[20px] [&_.ProseMirror]:courier-border-none [&_.ProseMirror]:courier-p-0","[&_.tiptap]:courier-outline-none [&_.tiptap]:courier-border-none",n),onClick:()=>m==null?void 0:m.commands.focus(),children:(0,ad.jsx)(qs.EditorContent,{editor:m,className:"courier-w-full"})})});Jr.displayName="VariableTextarea";var Rf=he(require("@tiptap/extension-placeholder"),1);var Js=require("@tiptap/react"),In=he(require("react"),1),La=require("react");var sd=require("react/jsx-runtime"),Ci=In.forwardRef(({value:e="",onChange:t,variables:r=[],placeholder:o,className:n,disabled:i=!1,readOnly:a=!1,disableVariableAutocomplete:l=!1,onFocus:c,onBlur:u},d)=>{let p=In.useRef(!1),m=In.useRef(e),f=(0,Js.useEditor)({extensions:[hi,bi.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),Vs,$s,Mn.configure({variables:Object.fromEntries(r.map(y=>[y,y])),disableSuggestions:l}),An,Sa,Rf.default.configure({placeholder:o||"",emptyEditorClass:"is-editor-empty"})],content:yi(e),editable:!i&&!a,editorProps:{attributes:{class:"courier-outline-none"},handleKeyDown:(y,h)=>h.key==="Enter"&&!document.querySelector(".variable-suggestions")?(h.preventDefault(),!0):!1},onUpdate:({editor:y})=>{if(p.current)return;let h=Zs(y.getJSON());h!==m.current&&(m.current=h,t==null||t(h))},onFocus:()=>{c==null||c()},onBlur:()=>{u==null||u()}});(0,La.useEffect)(()=>{if(!f||e===m.current)return;p.current=!0,m.current=e;let y=setTimeout(()=>{let h=yi(e);f.commands.setContent(h),p.current=!1},0);return()=>clearTimeout(y)},[f,e]),(0,La.useEffect)(()=>{f&&f.setEditable(!i&&!a)},[f,i,a]);let C=(0,La.useCallback)(()=>{f==null||f.commands.focus()},[f]);return In.useImperativeHandle(d,()=>{let y=f==null?void 0:f.view.dom.parentElement;return y&&(y.focus=C),y},[f,C]),(0,sd.jsx)("div",{ref:d,className:L("variable-input-placeholder","courier-flex courier-items-center courier-w-full courier-rounded-md courier-border-none courier-bg-transparent courier-text-foreground courier-py-1 courier-text-sm md:courier-text-md",(i||a)&&"courier-cursor-default",i&&"courier-opacity-50","[&_.ProseMirror]:courier-h-[25px] [&_.ProseMirror]:courier-flex [&_.ProseMirror]:courier-items-end [&_.ProseMirror]:courier-outline-none [&_.ProseMirror]:courier-border-none [&_.ProseMirror]:courier-p-0 [&_.ProseMirror]:courier-flex-1","[&_.tiptap]:courier-outline-none [&_.tiptap]:courier-border-none",n),onClick:()=>!a&&!i&&(f==null?void 0:f.commands.focus()),children:(0,sd.jsx)(Js.EditorContent,{editor:f,className:"courier-w-full courier-flex-1"})})});Ci.displayName="VariableInput";var Xo=require("react/jsx-runtime"),vi=30,js=s(({color:e="currentColor",width:t=vi,height:r=vi,...o})=>(0,Xo.jsx)(Z,{...o,width:t,height:r,children:(0,Xo.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"),Ks=s(({color:e="currentColor",width:t=vi,height:r=vi,...o})=>(0,Xo.jsx)(Z,{...o,width:t,height:r,children:(0,Xo.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"),Gs=s(({color:e="currentColor",width:t=vi,height:r=vi,...o})=>(0,Xo.jsx)(Z,{...o,width:t,height:r,children:(0,Xo.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");var oe=require("react/jsx-runtime"),Bf=s(({element:e,editor:t,disableVariableAutocomplete:r=!0})=>{var l,c;let o=(0,Df.useForm)({resolver:(0,Hf.zodResolver)(Bs),defaultValues:{...Ke,...e==null?void 0:e.attrs}}),{updateNodeAttributes:n}=xt({editor:t,element:e,form:o,nodeType:"button"}),i=((c=(l=t==null?void 0:t.extensionManager.extensions.find(u=>u.name==="variableSuggestion"))==null?void 0:l.options)==null?void 0:c.variables)||{},a=Tt(i);return e?(0,oe.jsxs)(Je,{...o,children:[(0,oe.jsx)(Ht,{type:"button"}),(0,oe.jsxs)("form",{onChange:()=>{n(o.getValues())},children:[(0,oe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,oe.jsx)(j,{control:o.control,name:"link",render:({field:u})=>(0,oe.jsxs)(q,{children:[(0,oe.jsx)(J,{children:(0,oe.jsx)(Jr,{value:u.value,variables:a,disableVariableAutocomplete:r,onChange:d=>{u.onChange(d),n({...o.getValues(),link:d})}})}),(0,oe.jsx)(K,{})]})}),(0,oe.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,oe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Background"}),(0,oe.jsx)(j,{control:o.control,name:"backgroundColor",render:({field:u})=>(0,oe.jsxs)(q,{className:"courier-mb-4",children:[(0,oe.jsx)(J,{children:(0,oe.jsx)(vt,{...u,defaultValue:Ke.backgroundColor,onChange:d=>{u.onChange(d),n({...o.getValues(),[u.name]:d})}})}),(0,oe.jsx)(K,{})]})}),(0,oe.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,oe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,oe.jsx)(j,{control:o.control,name:"padding",render:({field:u})=>(0,oe.jsxs)(q,{className:"courier-mb-2",children:[(0,oe.jsx)(J,{children:(0,oe.jsx)(ye,{type:"number",min:0,...u})}),(0,oe.jsx)(K,{})]})}),(0,oe.jsx)(j,{control:o.control,name:"alignment",render:({field:u})=>(0,oe.jsxs)(q,{children:[(0,oe.jsx)(J,{children:(0,oe.jsxs)(Nr,{type:"single",value:u.value,onValueChange:d=>{u.onChange(d),n({...o.getValues(),alignment:d})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,oe.jsx)($t,{size:"sm",value:"left",className:"courier-w-full",children:(0,oe.jsx)(js,{className:"courier-h-4 courier-w-4"})}),(0,oe.jsx)($t,{size:"sm",value:"center",className:"courier-w-full",children:(0,oe.jsx)(Ks,{className:"courier-h-4 courier-w-4"})}),(0,oe.jsx)($t,{size:"sm",value:"right",className:"courier-w-full",children:(0,oe.jsx)(Gs,{className:"courier-h-4 courier-w-4"})})]})}),(0,oe.jsx)(K,{})]})}),(0,oe.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,oe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,oe.jsx)(j,{control:o.control,name:"borderRadius",render:({field:u})=>(0,oe.jsxs)(q,{children:[(0,oe.jsx)(J,{children:(0,oe.jsx)(ye,{startAdornment:(0,oe.jsx)(Xi,{}),type:"number",min:0,...u})}),(0,oe.jsx)(K,{})]})})]})]}):null},"ButtonForm");var Qs=require("@tiptap/core"),Of=require("@tiptap/react"),Wf=require("uuid");var Xs=require("jotai"),Fe=require("react");var wt=require("react/jsx-runtime"),wh=s(e=>{if(!e)return[];let t=[],r=/\{\{([^}]+)\}\}/g,o=0,n;for(r.lastIndex=0;(n=r.exec(e))!==null;){if(!n[0].startsWith("{{")||!n[0].endsWith("}}"))continue;n.index>o&&t.push({type:"text",content:e.substring(o,n.index)});let i=n[1].trim();at(i)?t.push({type:"variable",name:i}):t.push({type:"text",content:n[0]}),o=n.index+n[0].length}return o<e.length&&t.push({type:"text",content:e.substring(o)}),t},"parseLabel"),Ph=s(({parts:e})=>{let t=(0,Xs.useAtomValue)(fn);return(0,wt.jsx)(wt.Fragment,{children:e.map((r,o)=>{if(r.type==="text")return(0,wt.jsx)("span",{children:r.content},o);let n=t[r.name];return(0,wt.jsxs)("span",{className:"courier-inline-flex courier-items-center courier-gap-0.5 courier-rounded courier-border courier-px-1.5 courier-pl-1 courier-py-[1px] courier-text-sm courier-variable-node courier-font-mono courier-max-w-full courier-tracking-[0.64px] courier-variable-in-button",style:{backgroundColor:n?"#EFF6FF":"#FFFBEB",borderColor:n?"#BFDBFE":"#FDE68A",color:"#000000"},children:[(0,wt.jsx)(Os,{color:n?void 0:"#B45309"}),(0,wt.jsxs)("span",{className:"courier-truncate courier-min-w-0",style:{color:"#000000"},children:[r.name,n?`="${n}"`:""]})]},o)})})},"ButtonLabelDisplay"),Ff=s(({label:e,backgroundColor:t,textColor:r,onLabelChange:o,editable:n})=>{let i=(0,Fe.useRef)(null),a=(0,Fe.useRef)(e),l=(0,Fe.useRef)(!1),[c,u]=(0,Fe.useState)(!1),d=wh(e),m=d.some(k=>k.type==="variable")&&!c;(0,Fe.useLayoutEffect)(()=>{if(!i.current||!m)return;Array.from(i.current.childNodes).filter(D=>D.nodeType===Node.TEXT_NODE).forEach(D=>D.remove())},[m,e]);let f=(0,Fe.useRef)(m),C=(0,Fe.useRef)(!0);(0,Fe.useEffect)(()=>{if(!i.current||m){f.current=m;return}let k=f.current&&!m;f.current=m,(C.current||k||!l.current&&e!==a.current)&&(i.current.textContent=e),C.current=!1,a.current=e},[e,m]);let y=(0,Fe.useCallback)(()=>{if(i.current&&!m){l.current=!0;let k=i.current.textContent||"";a.current=k,o(k),requestAnimationFrame(()=>{l.current=!1})}},[o,m]),h=(0,Fe.useCallback)(k=>{var D;if(m){k.preventDefault(),k.stopPropagation();return}if(k.key==="Enter"&&(k.preventDefault(),(D=i.current)==null||D.blur()),(k.metaKey||k.ctrlKey)&&k.key==="a"&&(k.preventDefault(),k.stopPropagation(),i.current)){let T=document.createRange();T.selectNodeContents(i.current);let x=window.getSelection();x==null||x.removeAllRanges(),x==null||x.addRange(T)}},[m]),b=(0,Fe.useCallback)(()=>{u(!0)},[]),N=(0,Fe.useCallback)(()=>{u(!1)},[]),g=(0,Fe.useCallback)(k=>{let D=i.current;if(!D)return;if(m&&n){k.stopPropagation(),setTimeout(()=>{D.focus();let E=document.createRange();E.selectNodeContents(D),E.collapse(!1);let v=window.getSelection();v==null||v.removeAllRanges(),v==null||v.addRange(E)},0);return}if(!n)return;let T=s(()=>{let E=window.getSelection();if(!E||E.rangeCount===0)return;let v=E.getRangeAt(0),P=D.contains(v.startContainer),S=D.contains(v.endContainer);if(P&&!S){let I=document.createRange();I.selectNodeContents(D),E.removeAllRanges(),E.addRange(I)}},"checkAndConstrainSelection"),x=s(E=>{let v=D.getBoundingClientRect();(E.clientX<v.left||E.clientX>v.right||E.clientY<v.top||E.clientY>v.bottom)&&T(),document.removeEventListener("mouseup",x)},"handleMouseUp");document.addEventListener("mouseup",x)},[n,m]),w=m?(0,wt.jsx)(Ph,{parts:d}):n?null:e,M=(0,Fe.useCallback)(k=>{m&&n&&k.stopPropagation()},[m,n]);return(0,wt.jsx)("div",{ref:i,contentEditable:n&&!m,suppressContentEditableWarning:!0,tabIndex:n&&m?0:void 0,onInput:y,onKeyDown:h,onPointerDown:g,onClick:M,onFocus:b,onBlur:N,className:L("courier-inline-flex courier-justify-start courier-px-2 courier-py-1 courier-text-sm courier-rounded-sm courier-border courier-border-border courier-outline-none",n&&!m&&"courier-cursor-text"),style:{backgroundColor:t,color:r,borderColor:"transparent",borderRadius:"4px",caretColor:r,WebkitUserSelect:"text",userSelect:"text"},children:w})},"EditableButton"),kh=s(({button1Label:e,button1Link:t,button1BackgroundColor:r,button1TextColor:o,button2Label:n,button2Link:i,button2BackgroundColor:a,button2TextColor:l,padding:c=6,onButton1LabelChange:u,onButton2LabelChange:d,editable:p=!1})=>(0,wt.jsx)("div",{className:"node-element",children:(0,wt.jsxs)("div",{className:"courier-flex courier-gap-1 courier-justify-start",style:{marginTop:`${c}px`,marginBottom:`${c}px`},children:[(0,wt.jsx)(Ff,{label:e,backgroundColor:r,textColor:o,onLabelChange:u||(()=>{}),editable:p},"button1"),(0,wt.jsx)(Ff,{label:n,backgroundColor:a,textColor:l,onLabelChange:d||(()=>{}),editable:p},"button2")]})}),"ButtonRowComponent"),Vf=s(e=>{let t=(0,Xs.useSetAtom)(Xe),r=(0,Fe.useRef)({}),o=(0,Fe.useRef)({}),n=(0,Fe.useCallback)(()=>{if(!e.editor.isEditable)return;let l=pt(e);l&&t(l)},[e,t]),i=(0,Fe.useCallback)(l=>{o.current.button1=l,r.current.button1&&clearTimeout(r.current.button1),r.current.button1=setTimeout(()=>{o.current.button1!==void 0&&e.updateAttributes({button1Label:o.current.button1})},300)},[e]),a=(0,Fe.useCallback)(l=>{o.current.button2=l,r.current.button2&&clearTimeout(r.current.button2),r.current.button2=setTimeout(()=>{o.current.button2!==void 0&&e.updateAttributes({button2Label:o.current.button2})},300)},[e]);return(0,Fe.useEffect)(()=>{let l=r.current;return()=>{l.button1&&clearTimeout(l.button1),l.button2&&clearTimeout(l.button2)}},[]),(0,wt.jsx)(Rt,{id:e.node.attrs.id,className:L(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"buttonRow",children:(0,wt.jsx)(kh,{...e.node.attrs,onButton1LabelChange:i,onButton2LabelChange:a,editable:e.editor.isEditable})})},"ButtonRowComponentNode");var jr={button1Label:"Register",button1Link:"",button1BackgroundColor:"#000000",button1TextColor:"#ffffff",button2Label:"Learn more",button2Link:"",button2BackgroundColor:"#ffffff",button2TextColor:"#000000",padding:6},el=Qs.Node.create({name:"buttonRow",group:"block",atom:!0,selectable:!1,onCreate(){dt(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${(0,Wf.v4)()}`,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.id})},button1Label:{default:jr.button1Label,parseHTML:e=>e.getAttribute("data-button1-label"),renderHTML:e=>({"data-button1-label":e.button1Label})},button1Link:{default:jr.button1Link,parseHTML:e=>e.getAttribute("data-button1-link"),renderHTML:e=>({"data-button1-link":e.button1Link})},button1BackgroundColor:{default:jr.button1BackgroundColor,parseHTML:e=>e.getAttribute("data-button1-bg"),renderHTML:e=>({"data-button1-bg":e.button1BackgroundColor})},button1TextColor:{default:jr.button1TextColor,parseHTML:e=>e.getAttribute("data-button1-color"),renderHTML:e=>({"data-button1-color":e.button1TextColor})},button2Label:{default:jr.button2Label,parseHTML:e=>e.getAttribute("data-button2-label"),renderHTML:e=>({"data-button2-label":e.button2Label})},button2Link:{default:jr.button2Link,parseHTML:e=>e.getAttribute("data-button2-link"),renderHTML:e=>({"data-button2-link":e.button2Link})},button2BackgroundColor:{default:jr.button2BackgroundColor,parseHTML:e=>e.getAttribute("data-button2-bg"),renderHTML:e=>({"data-button2-bg":e.button2BackgroundColor})},button2TextColor:{default:jr.button2TextColor,parseHTML:e=>e.getAttribute("data-button2-color"),renderHTML:e=>({"data-button2-color":e.button2TextColor})},padding:{default:jr.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,Qs.mergeAttributes)(e,{"data-type":"buttonRow"})]},addNodeView(){return(0,Of.ReactNodeViewRenderer)(Vf,{stopEvent:({event:e})=>!(e.type==="dragstart"||e.type==="drop")})},addCommands(){return{setButtonRow:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...jr,...e}}).run()}}});var rl=require("@tiptap/core"),zf=require("@tiptap/react"),$f=require("uuid");var _f=require("@tiptap/react"),tl=require("jotai"),Cr=require("react");var Kr=require("react/jsx-runtime"),Nh=s(({columnId:e,index:t,isPreviewMode:r})=>{let o=(0,Cr.useRef)(null),[n,i]=(0,Cr.useState)(!1);return(0,Cr.useEffect)(()=>{let a=o.current;if(a)return yr({element:a,getData:()=>({type:"column-cell",columnId:e,index:t,isEmpty:!0}),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e,t]),(0,Kr.jsx)("div",{ref:o,"data-placeholder-cell":"true","data-column-cell":"true","data-column-id":e,"data-cell-index":t,onClick:a=>{a.stopPropagation()},className:L("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4",!r&&"courier-border",!r&&(n?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),!r&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:!r&&(0,Kr.jsx)("span",{className:"courier-pointer-events-none",children:"Drag and drop content blocks"})})},"PlaceholderCell"),Mh=s(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderWidth:o,borderRadius:n,borderColor:i,node:a,columnsCount:l,isPreviewMode:c=!1})=>{var m;let u=!a.content||a.content.size===0,d={borderWidth:`${o}px`,borderStyle:o>0?"solid":"none",borderColor:i,borderRadius:`${n}px`},p={padding:`${t}px ${e}px`,backgroundColor:r};if(u){let f=((m=a.attrs)==null?void 0:m.id)||"";return(0,Kr.jsx)("div",{className:"courier-w-full node-element",style:p,children:(0,Kr.jsx)("div",{className:"courier-w-full courier-flex courier-gap-2 courier-p-2",style:d,children:Array.from({length:l}).map((C,y)=>(0,Kr.jsx)(Nh,{columnId:f,index:y,isPreviewMode:c},y))})})}return(0,Kr.jsx)("div",{className:"courier-w-full node-element",style:p,children:(0,Kr.jsx)("div",{className:"courier-w-full courier-p-2",style:d,children:(0,Kr.jsx)(_f.NodeViewContent,{})})})},"ColumnComponent"),Uf=s(e=>{let t=(0,tl.useSetAtom)(Xe),r=(0,tl.useAtomValue)(Gt),[o,n]=(0,Cr.useState)(!1),[i,a]=(0,Cr.useState)(e.editor.isEditable);(0,Cr.useEffect)(()=>{let p=s(()=>{a(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",p),e.editor.on("transaction",p),e.editor.on("selectionUpdate",p),()=>{e.editor.off("update",p),e.editor.off("transaction",p),e.editor.off("selectionUpdate",p)}},[e.editor]);let l=!i&&!r,c=(0,Cr.useCallback)(p=>{var M,k;if(!e.editor.isEditable)return;let m=p.target,f=p.currentTarget,C=m===f,y=m.classList.contains("node-element"),h=m.classList.contains("courier-p-2"),b=m.classList.contains("courier-gap-2"),N=m.classList.contains("draggable-item"),g=m.hasAttribute("data-drag-handle")||m.closest("[data-drag-handle]")!==null;if(C||y||h||b||N||g||((k=(M=m.closest("[data-node-view-content]"))==null?void 0:M.parentElement)==null?void 0:k.classList.contains("node-element"))){p.stopPropagation(),g||p.preventDefault();let D=pt(e);if(D){e.editor.commands.blur();let T=D.attrs.id;e.editor.state.doc.descendants(x=>x.type.name==="column"&&x.attrs.id===T?(t(x),!1):!0)}}},[e,t]),u=(0,Cr.useCallback)(p=>{let m=p.target,f=p.currentTarget;if(!(m.closest("[data-column-cell]")!==null)){n(!0);return}let y=f.getBoundingClientRect(),h=p.clientY,b=30,N=h<=y.top+b||h>=y.bottom-b;n(N)},[]),d=(0,Cr.useCallback)(()=>{n(!1)},[]);return(0,Kr.jsx)(Rt,{id:e.node.attrs.id,className:L(e.node.attrs.isSelected&&"selected-element",o&&"hover-edge-zone"),onMouseDown:c,onMouseMove:u,onMouseLeave:d,editor:e.editor,getPos:e.getPos,"data-node-type":"column",children:(0,Kr.jsx)(Mh,{...e.node.attrs,node:e.node,columnsCount:e.node.attrs.columnsCount||2,isPreviewMode:l})})},"ColumnComponentNode");var Pt={columnsCount:2,paddingHorizontal:0,paddingVertical:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"transparent",cells:[]},ol=rl.Node.create({name:"column",group:"block",content:"columnRow?",isolating:!0,selectable:!1,onCreate(){dt(this.editor,this.name)},addAttributes(){return{columnsCount:{default:Pt.columnsCount,parseHTML:e=>e.getAttribute("data-columns-count"),renderHTML:e=>({"data-columns-count":e.columnsCount})},paddingHorizontal:{default:Pt.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:Pt.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:Pt.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:Pt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:Pt.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:Pt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:()=>`node-${(0,$f.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})},cells:{default:[],parseHTML:e=>{let t=e.getAttribute("data-cells");return t?JSON.parse(t):[]},renderHTML:e=>({"data-cells":JSON.stringify(e.cells||[])})}}},parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,rl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"column"}),0]},addNodeView(){return(0,zf.ReactNodeViewRenderer)(Uf)},addCommands(){return{setColumn:e=>({chain:t})=>{let r=e.columnsCount||Pt.columnsCount,o=`node-${Date.now()}`,n=Array.from({length:r},(i,a)=>({type:"columnCell",attrs:{index:a,columnId:o},content:[{type:"paragraph"}]}));return t().insertContent({type:this.name,attrs:{...e,id:o},content:[{type:"columnRow",content:n}]}).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)==="column"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"}}}});var qf=require("@hookform/resolvers/zod"),Jf=require("react-hook-form");var vr=require("zod"),Zf=vr.z.object({columnsCount:vr.z.number().min(1).max(4).default(2),paddingHorizontal:vr.z.number().default(0),paddingVertical:vr.z.number().default(0),backgroundColor:vr.z.string().default("transparent"),borderWidth:vr.z.number().default(0),borderRadius:vr.z.number().default(0),borderColor:vr.z.string().default("transparent"),cells:vr.z.array(vr.z.object({elements:vr.z.array(vr.z.any())})).optional()});var G=require("react/jsx-runtime"),ld=s(({element:e,editor:t})=>{let r=(0,Jf.useForm)({resolver:(0,qf.zodResolver)(Zf),defaultValues:{...Pt,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=xt({editor:t,element:e,form:r,nodeType:"column"}),n=s(i=>{if(!t||!e)return;let a=null;if(t.state.doc.descendants((f,C)=>f.attrs.id===e.attrs.id&&f.type.name==="column"?(a=C,!1):!0),a===null)return;let l=t.state.doc.nodeAt(a);if(!l)return;let c=e.attrs.id,u=t.schema,d=t.state.tr,p=l.firstChild;if(!p||p.type.name!=="columnRow"){let f=Array.from({length:i},(y,h)=>u.nodes.columnCell.create({index:h,columnId:c,isEditorMode:!1})),C=u.nodes.columnRow.create({},f);d.replaceWith(a+1,a+l.nodeSize-1,C),d.setNodeMarkup(a,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d);return}let m=p.childCount;if(i!==m){if(i>m){let f=i-m,y=a+1+p.nodeSize-1;for(let h=0;h<f;h++){let b=u.nodes.columnCell.create({index:m+h,columnId:c});d.insert(y+h*b.nodeSize,b)}}else{let f=m-i,y=a+1;for(let b=0;b<m-f;b++){let N=p.child(b);y+=N.nodeSize}let h=0;for(let b=m-f;b<m;b++){let N=p.child(b);h+=N.nodeSize}d.delete(y,y+h)}d.setNodeMarkup(a,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d)}},"updateColumnCount");return e?(0,G.jsxs)(Je,{...r,children:[(0,G.jsx)(Ht,{type:"column",label:"Column layout"}),(0,G.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,G.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Columns count"}),(0,G.jsx)(j,{control:r.control,name:"columnsCount",render:({field:i})=>(0,G.jsxs)(q,{className:"courier-mb-4",children:[(0,G.jsx)(J,{children:(0,G.jsx)(Nr,{type:"single",className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-bg-secondary courier-p-0.5 courier-mb-3 courier-shadow-sm",value:i.value.toString(),onValueChange:a=>{if(a){let l=Number(a);i.onChange(l),n(l)}},children:[1,2,3,4].map(a=>(0,G.jsx)($t,{value:a.toString(),className:"courier-w-12 courier-h-7",children:(0,G.jsx)("span",{className:"courier-text-sm courier-font-medium",children:a})},a))})}),(0,G.jsx)(K,{})]})}),(0,G.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,G.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Frame"}),(0,G.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,G.jsx)(j,{control:r.control,name:"paddingHorizontal",render:({field:i})=>(0,G.jsxs)(q,{children:[(0,G.jsx)(J,{children:(0,G.jsx)(ye,{startAdornment:(0,G.jsx)(ia,{}),type:"number",min:0,...i})}),(0,G.jsx)(K,{})]})}),(0,G.jsx)(j,{control:r.control,name:"paddingVertical",render:({field:i})=>(0,G.jsxs)(q,{children:[(0,G.jsx)(J,{children:(0,G.jsx)(ye,{startAdornment:(0,G.jsx)(yn,{}),type:"number",min:0,...i})}),(0,G.jsx)(K,{})]})})]}),(0,G.jsx)(j,{control:r.control,name:"backgroundColor",render:({field:i})=>(0,G.jsxs)(q,{className:"courier-mb-4",children:[(0,G.jsx)(J,{children:(0,G.jsx)(vt,{...i,defaultValue:Pt.backgroundColor,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),(0,G.jsx)(K,{})]})}),(0,G.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,G.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Border"}),(0,G.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,G.jsx)(j,{control:r.control,name:"borderWidth",render:({field:i})=>(0,G.jsxs)(q,{children:[(0,G.jsx)(J,{children:(0,G.jsx)(ye,{startAdornment:(0,G.jsx)(wo,{}),type:"number",min:0,...i})}),(0,G.jsx)(K,{})]})}),(0,G.jsx)(j,{control:r.control,name:"borderRadius",render:({field:i})=>(0,G.jsxs)(q,{children:[(0,G.jsx)(J,{children:(0,G.jsx)(ye,{startAdornment:(0,G.jsx)(Xi,{}),type:"number",min:0,...i})}),(0,G.jsx)(K,{})]})})]}),(0,G.jsx)(j,{control:r.control,name:"borderColor",render:({field:i})=>(0,G.jsxs)(q,{className:"courier-mb-4",children:[(0,G.jsx)(J,{children:(0,G.jsx)(vt,{...i,defaultValue:Pt.borderColor,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),(0,G.jsx)(K,{})]})})]})]}):null},"ColumnForm");var nl=require("@tiptap/core"),il=nl.Node.create({name:"columnRow",group:"columnContent",content:"columnCell+",isolating:!0,parseHTML(){return[{tag:'div[data-type="column-row"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,nl.mergeAttributes)(e,{"data-type":"column-row",class:"courier-flex courier-flex-row courier-gap-2 courier-w-full",style:"display: flex; flex-direction: row; gap: 0.5rem; width: 100%;"}),0]},addCommands(){return{insertColumnRow:()=>({chain:e})=>e().insertContent({type:this.name}).run()}}});var sl=require("@tiptap/core"),Gf=require("@tiptap/react"),ll=require("@tiptap/pm/state");var al=require("@tiptap/react"),Qo=require("react");var jf=require("jotai");var Ra=require("react/jsx-runtime"),Kf=s(e=>{let t=(0,Qo.useRef)(null),[r,o]=(0,Qo.useState)(!1),n=(0,jf.useAtomValue)(Gt),i=e.node.attrs.isEditorMode===!0,[a,l]=(0,Qo.useState)(e.editor.isEditable);(0,Qo.useEffect)(()=>{let d=t.current;if(d)return yr({element:d,getData:()=>({type:"column-cell",columnId:e.node.attrs.columnId,index:e.node.attrs.index}),onDragEnter:()=>o(!0),onDragLeave:()=>o(!1),onDrop:()=>o(!1)})},[e.node.attrs.columnId,e.node.attrs.index]),(0,Qo.useEffect)(()=>{let d=s(()=>{l(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",d),e.editor.on("transaction",d),e.editor.on("selectionUpdate",d),()=>{e.editor.off("update",d),e.editor.off("transaction",d),e.editor.off("selectionUpdate",d)}},[e.editor]);let c=!a&&!n,u=!i&&!c;return(0,Ra.jsxs)(al.NodeViewWrapper,{ref:t,"data-column-cell":"true","data-column-id":e.node.attrs.columnId,"data-cell-index":e.node.attrs.index,className:L("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4 courier-pl-0 courier-w-full",!c&&"courier-border",!c&&(r?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),u&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:[u&&(0,Ra.jsx)("span",{className:"courier-pointer-events-none courier-pl-4",children:"Drag and drop content blocks"}),(0,Ra.jsx)(al.NodeViewContent,{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full"})]})},"ColumnCellComponentNode");var cl=sl.Node.create({name:"columnCell",group:"columnRow",content:"block*",isolating:!0,selectable:!1,addAttributes(){return{index:{default:0,parseHTML:e=>{let t=e.getAttribute("data-cell-index");return t?parseInt(t,10):0},renderHTML:e=>({"data-cell-index":e.index})},columnId:{default:null,parseHTML:e=>e.getAttribute("data-column-id"),renderHTML:e=>({"data-column-id":e.columnId})},isEditorMode:{default:!1,parseHTML:e=>e.getAttribute("data-editor-mode")==="true",renderHTML:e=>({"data-editor-mode":e.isEditorMode?"true":"false"})}}},parseHTML(){return[{tag:'div[data-type="column-cell"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,sl.mergeAttributes)(e,{"data-type":"column-cell",style:"flex: 1 1 0%; width: 0; min-height: 120px;"}),0]},addNodeView(){return(0,Gf.ReactNodeViewRenderer)(Kf)},addCommands(){return{insertColumnCell:()=>({chain:e})=>e().insertContent({type:this.name}).run()}},addProseMirrorPlugins(){return[new ll.Plugin({key:new ll.PluginKey("columnCellCleanup"),appendTransaction:(e,t,r)=>{if(!e.some(i=>i.docChanged))return null;let o=r.tr,n=!1;return r.doc.descendants((i,a)=>{var l,c;if(i.type.name==="columnCell"){let u=i.childCount===0,d=i.childCount===1&&((l=i.firstChild)==null?void 0:l.type.name)==="paragraph"&&((c=i.firstChild)==null?void 0:c.content.size)===0,p=i.attrs.isEditorMode;u?p=!1:u||(p=!0),p!==i.attrs.isEditorMode&&(o.setNodeAttribute(a,"isEditorMode",p),n=!0),d&&p===!1&&(o.delete(a+1,a+i.nodeSize-1),n=!0)}return!0}),n?o:null}})]}});var ul=require("@tiptap/core"),e1=require("@tiptap/react"),t1=require("uuid");var Yf=require("jotai"),Xf=require("react");var Ha=require("react/jsx-runtime"),Ah=s(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return(0,Ha.jsx)("div",{className:"courier-w-full node-element",children:(0,Ha.jsx)("div",{className:"courier-custom-code courier-py-1.5",dangerouslySetInnerHTML:t?{__html:e}:{__html:" "}})})},"CustomCodeComponent"),Qf=s(e=>{let t=(0,Yf.useSetAtom)(Xe),r=(0,Xf.useCallback)(()=>{if(!e.editor.isEditable)return;let i=pt(e);if(i){e.editor.commands.blur();let a=i.attrs.id;e.editor.state.doc.descendants(l=>l.type.name==="customCode"&&l.attrs.id===a?(t(l),!1):!0)}},[e,t]),o=e.node.attrs.code,n=!o||o.trim()===""||o==="<!-- Add your HTML code here -->";return(0,Ha.jsx)(Rt,{id:e.node.attrs.id,className:L(e.node.attrs.isSelected&&"selected-element",n&&"is-empty"),onClick:r,editor:e.editor,"data-node-type":"customCode",children:(0,Ha.jsx)(Ah,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var No={code:"<!-- Add your HTML code here -->"},dl=ul.Node.create({name:"customCode",group:"block",atom:!0,selectable:!1,onCreate(){dt(this.editor,this.name)},addAttributes(){return{code:{default:No.code,parseHTML:e=>e.getAttribute("data-code")||"",renderHTML:e=>({"data-code":e.code})},id:{default:()=>`node-${(0,t1.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="custom-code"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,ul.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"custom-code"}),["div",{innerHTML:e.code||No.code}]]},addNodeView(){return(0,e1.ReactNodeViewRenderer)(Qf)},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 kt=require("react");var r1=require("react"),o1=require("react/jsx-runtime"),cd=(0,r1.forwardRef)(({className:e,...t},r)=>{let o=L("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,o1.jsx)("div",{className:o,ref:r,...t})});cd.displayName="Spinner";var Ln=require("react/jsx-runtime"),Sh=s(()=>{let[e,t]=(0,kt.useState)(!1),r=(0,kt.useRef)(null);return(0,kt.useEffect)(()=>{var i;let o=s(()=>{if(r.current){let a=r.current.closest(".dark")!==null;t(a)}},"checkDarkMode");o();let n=new MutationObserver(o);return(i=r.current)!=null&&i.parentElement&&n.observe(document.body,{attributes:!0,attributeFilter:["class"],subtree:!0}),()=>n.disconnect()},[]),{isDark:e,containerRef:r}},"useIsDarkMode"),Ih=(0,kt.lazy)(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function Lh(e,t){let r=(0,kt.useRef)();return(0,kt.useCallback)((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}s(Lh,"useDebounce");var Rh=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 l=(e.match(/</g)||[]).length,c=(e.match(/>/g)||[]).length;if(l!==c||new DOMParser().parseFromString(e,"text/html").getElementsByTagName("parsererror").length>0)return!1;let m=(e.match(/<([a-z][a-z0-9]*)\b[^>]*(?<!\/\/)>/gi)||[]).map(h=>{var b,N;return(N=(b=h.match(/<([a-z][a-z0-9]*)/i))==null?void 0:b[1])==null?void 0:N.toLowerCase()}).filter(Boolean),f=(e.match(/<\/([a-z][a-z0-9]*)\s*>/gi)||[]).map(h=>{var b,N;return(N=(b=h.match(/<\/([a-z][a-z0-9]*)/i))==null?void 0:b[1])==null?void 0:N.toLowerCase()}).filter(Boolean),C=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],y=m.filter(h=>h&&!C.includes(h));for(let h of y){let b=m.filter(g=>g===h).length,N=f.filter(g=>g===h).length;if(b!==N)return!1}return!0}catch{return!1}},"defaultHTMLValidator"),ml=s(({code:e,onSave:t,onValidationChange:r,validator:o=Rh})=>{let n=(0,kt.useRef)(null),i=(0,kt.useRef)(null),[a,l]=(0,kt.useState)(!0),{isDark:c,containerRef:u}=Sh(),d=(0,kt.useCallback)(()=>{if(!n.current||!i.current)return!0;let C=n.current.getModel();if(!C)return!0;let y=C.getValue(),h=o(y,n.current,i.current);return h!==a&&(l(h),r==null||r(h)),h},[a,r,o]),p=Lh(C=>{setTimeout(()=>{d()&&t(C)},150)},500);return(0,Ln.jsx)("div",{ref:u,className:"courier-h-full courier-overflow-hidden",children:(0,Ln.jsx)("div",{className:"courier-h-full courier-p-2",children:(0,Ln.jsx)(kt.Suspense,{fallback:(0,Ln.jsx)("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:(0,Ln.jsx)(cd,{})}),children:(0,Ln.jsx)(Ih,{height:"100%",defaultLanguage:"html",value:e,onChange:s(C=>{p(C||"")},"handleCodeChange"),onMount:s((C,y)=>{n.current=C,i.current=y,C.focus(),C.onDidChangeModelContent(()=>{setTimeout(d,100)}),setTimeout(d,100)},"handleEditorDidMount"),theme:c?"vs-dark":"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 i1=require("@hookform/resolvers/zod"),a1=require("react-hook-form");var ud=require("zod"),n1=ud.z.object({code:ud.z.string()});var s1=require("react"),l1=require("jotai");var Qe=require("react/jsx-runtime"),dd=s(({element:e,editor:t})=>{let r=(0,a1.useForm)({resolver:(0,i1.zodResolver)(n1),defaultValues:{...No,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=xt({editor:t,element:e,form:r,nodeType:"customCode"}),[n,i]=(0,l1.useAtom)(so),a=(0,s1.useCallback)(l=>{r.setValue("code",l),o({code:l})},[r,o]);return e?(0,Qe.jsxs)(Je,{...r,children:[!n&&(0,Qe.jsx)(Ht,{type:"customCode"}),(0,Qe.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[(0,Qe.jsx)(Ie,{className:"courier-w-fit",variant:"outline",buttonSize:"small",onClick:()=>i(!n),children:n?(0,Qe.jsxs)(Qe.Fragment,{children:[(0,Qe.jsx)(Au,{className:"courier-w-3 courier-h-3"}),"Minimize"]}):(0,Qe.jsxs)(Qe.Fragment,{children:[(0,Qe.jsx)(Qi,{className:"courier-w-3 courier-h-3"}),"Expand Editor"]})}),(0,Qe.jsx)("div",{className:"courier-mb-4 courier-overflow-hidden courier-rounded-md courier-border courier-border-border",style:{minHeight:"200px",height:"300px",resize:"vertical",overflow:"auto"},children:(0,Qe.jsx)("form",{onChange:()=>{o(r.getValues())},className:"courier-h-full",children:(0,Qe.jsx)(j,{control:r.control,name:"code",render:({field:l})=>(0,Qe.jsxs)(q,{className:"courier-h-full",children:[(0,Qe.jsx)(J,{children:(0,Qe.jsx)(ml,{code:l.value,onSave:c=>{l.onChange(c),a(c)},onCancel:()=>{}})}),(0,Qe.jsx)(K,{})]})})})})]})]}):null},"CustomCodeForm");var p1=require("@tiptap/core");var en=require("@tiptap/core"),xi=require("@tiptap/pm/state"),c1=en.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",(0,en.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,en.isNodeSelection)(r)?i.insertContentAt(n.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:a,dispatch:l})=>{var c;if(l){let{$to:u}=a.selection,d=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?a.setSelection(xi.TextSelection.create(a.doc,u.pos+1)):u.nodeAfter.isBlock?a.setSelection(xi.NodeSelection.create(a.doc,u.pos)):a.setSelection(xi.TextSelection.create(a.doc,u.pos));else{let p=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();p&&(a.insert(d,p),a.setSelection(xi.TextSelection.create(a.doc,d+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(0,en.nodeInputRule)({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var f1=require("@tiptap/react"),g1=require("uuid");var u1=require("jotai"),d1=require("react");var Da=require("react/jsx-runtime"),Hh=s(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>(0,Da.jsx)("div",{className:"courier-w-full node-element courier-flex",children:(0,Da.jsx)("hr",{style:{marginTop:`${e}px`,marginBottom:`${e}px`,backgroundColor:n==="spacer"?"transparent":t,height:`${r}px`,borderRadius:`${o}px`,border:"none",width:"100%"},"data-variant":n})}),"DividerComponent"),m1=s(e=>{let t=(0,u1.useSetAtom)(Xe),r=(0,d1.useCallback)(()=>{if(!e.editor.isEditable)return;let o=pt(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return(0,Da.jsx)(Rt,{id:e.node.attrs.id,className:L(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:(0,Da.jsx)(Hh,{...e.node.attrs})})},"DividerComponentNode");var xr={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},pl={padding:24,color:"transparent",size:1,radius:0,variant:"spacer"},md=c1.extend({name:"divider",atom:!0,onCreate(){dt(this.editor,this.name)},addAttributes(){return{padding:{default:xr.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.margin})},size:{default:xr.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},color:{default:xr.color,parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color})},width:{default:xr.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},radius:{default:xr.radius,parseHTML:e=>e.getAttribute("data-radius"),renderHTML:e=>({"data-radius":e.radius})},variant:{default:xr.variant,parseHTML:e=>e.getAttribute("data-variant"),renderHTML:e=>({"data-variant":e.variant})},id:{default:()=>`node-${(0,g1.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,p1.mergeAttributes)(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return(0,f1.ReactNodeViewRenderer)(m1)},addInputRules(){return[]}});var Rn=require("zod"),h1=Rn.z.object({padding:Rn.z.number(),color:Rn.z.string(),size:Rn.z.number(),radius:Rn.z.number(),variant:Rn.z.enum(["divider","spacer"]).default("divider")});var b1=require("@hookform/resolvers/zod"),y1=require("react-hook-form");var Ne=require("react/jsx-runtime"),C1=s(({element:e,editor:t})=>{let r=(0,y1.useForm)({resolver:(0,b1.zodResolver)(h1),defaultValues:{...xr,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=xt({editor:t,element:e,form:r,nodeType:"divider"});if(!e)return null;let n=r.watch("variant");return(0,Ne.jsxs)(Je,{...r,children:[(0,Ne.jsx)(Ht,{type:n}),(0,Ne.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Ne.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,Ne.jsx)(j,{control:r.control,name:"padding",render:({field:i})=>(0,Ne.jsxs)(q,{children:[(0,Ne.jsx)(J,{children:(0,Ne.jsx)(ye,{startAdornment:(0,Ne.jsx)(yn,{}),type:"number",...i,onChange:a=>{i.onChange(a),o({...r.getValues(),margin:a.target.value})}})}),(0,Ne.jsx)(K,{})]})}),n==="divider"&&(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,Ne.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Line"}),(0,Ne.jsx)(j,{control:r.control,name:"size",render:({field:i})=>(0,Ne.jsxs)(q,{className:"courier-mb-4",children:[(0,Ne.jsx)(J,{children:(0,Ne.jsx)(ye,{startAdornment:(0,Ne.jsx)(wo,{}),type:"number",min:0,...i,onChange:a=>{i.onChange(a),o({...r.getValues(),width:a.target.value})}})}),(0,Ne.jsx)(K,{})]})}),(0,Ne.jsx)(j,{control:r.control,name:"color",render:({field:i})=>(0,Ne.jsxs)(q,{className:"courier-mb-4",children:[(0,Ne.jsx)(J,{children:(0,Ne.jsx)(vt,{...i,defaultValue:xr.color,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),(0,Ne.jsx)(K,{})]})})]})]})]})},"DividerForm");var pd=hi.extend({content:"(block)+"});var T1=require("@tiptap/core"),E1=require("@tiptap/react");var v1=require("@tiptap/react"),Hn=require("react");var Ba=require("react/jsx-runtime");function Dh(){let[e,t]=(0,Hn.useState)(!1);return(0,Hn.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(Dh,"useMountStatus");var Bh=(0,Hn.forwardRef)(({children:e,className:t,dragOverlay:r,id:o},n)=>((0,Hn.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),(0,Ba.jsx)(v1.NodeViewWrapper,{ref:n,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":o,"data-placeholder":"true",className:L("courier-flex courier-items-start courier-gap-2 courier-pl-6",t),children:e}))),Fh=s(e=>{switch(e){case"text":return"Text";case"heading":return"Heading";case"spacer":return"Spacer";case"divider":return"Divider";case"button":return"Button";case"image":return"Image";case"customCode":return"Custom code";case"column":return"Column layout";default:return e}},"getPlaceholderLabel"),x1=s(({node:e})=>{let t=e.attrs.type,r=e.attrs.id,o=Dh();return(0,Ba.jsx)(Bh,{id:r,fadeIn:!o,children:(0,Ba.jsx)("div",{className:L("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,Ba.jsx)("div",{className:"courier-text-accent-foreground",children:Fh(t)})})})},"DragPlaceholderComponent");var w1=T1.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,E1.ReactNodeViewRenderer)(x1,{as:"div",className:"drag-placeholder-wrapper"})}});var P1=require("@tiptap/core"),fl=require("@tiptap/pm/state"),Vh=new fl.PluginKey("file-handler"),Oh=P1.Extension.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new fl.Plugin({key:Vh,props:{handleDrop:(o,n,i,a)=>{var d;if(!((d=n.dataTransfer)!=null&&d.files)||a)return!1;let{files:l}=n.dataTransfer,c=o.posAtCoords({left:n.clientX,top:n.clientY});if(!c)return!1;let u=Array.from(l).filter(p=>e==null?void 0:e.includes(p.type));return u.length===0?!1:(n.preventDefault(),t&&t(this.editor,u,c.pos),!0)},handlePaste:(o,n)=>{var l;if(!((l=n.clipboardData)!=null&&l.files))return!1;let{files:i}=n.clipboardData,a=Array.from(i).filter(c=>e==null?void 0:e.includes(c.type));return a.length===0?!1:(n.preventDefault(),r&&r(this.editor,a),!0)}}})]}}),gl=Oh;var k1=require("@tiptap/core"),hl=require("@tiptap/pm/state");var Wh=new hl.PluginKey("fixedChannelPaste"),_h=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 l=i===1&&a===0,c=i===2&&a===0,u=i>=2&&i+a<=4;return l||c||u},"isInFixedChannel"),Uh=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(`
|
|
186
|
-
`).trim()},"extractTextFromSlice"),bl=k1.Extension.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new hl.Plugin({key:Wh,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!_h(e))return!1;let l=i.$from.node();if(!(l.type.name==="paragraph"||l.type.name==="heading")||o.content.childCount<=1)return!1;let u=Uh(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 M1=require("@tiptap/core"),tn=require("@tiptap/pm/state");var Dn=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"),fd=s(e=>!!e.view.dom.closest(".courier-inbox-editor"),"isInInboxChannel"),N1=s(e=>{if(!fd(e))return!1;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.node(o-1),a=r.start(o),l=0;return i.forEach((c,u)=>{if(r.start(o-1)+u+1===a)return!1;l++}),l<=1}o--}return!1},"isInFixedInboxNode"),Bn=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"),yl=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,l=null;for(;n>0;){let c=r.node(n);if(c.type.name==="paragraph"||c.type.name==="heading"){a={node:c,depth:n};break}n--}for(;i>0;){let c=o.node(i);if(c.type.name==="paragraph"||c.type.name==="heading"){l={node:c,depth:i};break}i--}return!!(a&&l&&a.node!==l.node)},"isMultiElementSelection"),Cl=new tn.PluginKey("fixedChannelSelection"),vl=M1.Extension.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!Dn(e,this.options.channels))return!1;let o=Bn(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 l=Math.max(a.from,n),c=Math.min(a.to,i);return r&&t.setSelection(tn.TextSelection.create(t.doc,l,c)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!Dn(e,this.options.channels))return!1;let t=Bn(e);if(!t)return!1;let{start:r,end:o}=t;return e.commands.setTextSelection({from:r,to:o}),!0},Backspace:({editor:e})=>{if(!Dn(e,this.options.channels))return!1;if(fd(e)){let{selection:t}=e.state;if(Bn(e)&&t.$anchor.parentOffset===0&&N1(e))return!0}if(yl(e)){let t=Bn(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(!Dn(e,this.options.channels))return!1;if(fd(e)){let{selection:t}=e.state,r=Bn(e);if(r){let o=r.node.textContent;if(t.$anchor.parentOffset===o.length&&N1(e))return!0}}if(yl(e)){let t=Bn(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 tn.Plugin({key:Cl,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!Dn(o,this.options.channels))return!1;if(yl(o)){let n=Bn(o);if(n){let{start:i,end:a}=n,l=Math.max(t,i),c=Math.min(r,a),u=e.state.tr;u.setSelection(tn.TextSelection.create(u.doc,l,c)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!Dn(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(Cl,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!Dn(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&yl(r)){let n=Cl.getState(e.state);if(n!=null&&n.elementStart&&(n!=null&&n.elementEnd)){let{selection:i}=e.state,a=Math.max(i.from,n.elementStart),l=Math.min(i.to,n.elementEnd),c=e.state.tr;return c.setSelection(tn.TextSelection.create(c.doc,a,l)),e.dispatch(c),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(Cl)||t}}})]}});var B1=require("@tiptap/core");var Ti=require("@tiptap/core"),A1=Ti.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,Ti.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,Ti.textblockTypeInputRule)({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var po=require("zod"),S1=po.z.object({paddingVertical:po.z.number(),paddingHorizontal:po.z.number(),backgroundColor:po.z.string(),borderWidth:po.z.number(),borderColor:po.z.string(),textAlign:po.z.enum(["left","center","right","justify"]).default("left"),selected:po.z.boolean().default(!1),id:po.z.string().optional()}),me={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderColor:"transparent",textAlign:"left",selected:!1};var xl=require("@tiptap/react");var Tl=require("jotai"),L1=require("react");var Mo=require("react/jsx-runtime"),I1=s(({paddingVertical:e,paddingHorizontal:t,textAlign:r,backgroundColor:o,borderWidth:n,borderColor:i,level:a,type:l})=>{let c=l==="heading"?`h${a}`:"p",u=(0,Tl.useAtomValue)(Gt);return(0,Mo.jsx)("div",{className:"courier-w-full node-element",children:(0,Mo.jsx)("div",{style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderColor:i,borderStyle:n>0?"solid":"none"},children:(0,Mo.jsx)("div",{style:{pointerEvents:u?"none":"auto"},children:(0,Mo.jsx)(xl.NodeViewContent,{as:c})})})})},"TextBlockComponent"),El=s(e=>{let t=(0,Tl.useSetAtom)(Xe),r=(0,L1.useCallback)(()=>{if(!e.editor.isEditable)return;let l=pt(e);l&&t(l)},[e,t]),o=!e.node.content||e.node.content.size===0,n=rn(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null;return(i==null?void 0:i.parent.type.name)==="blockquote"?(0,Mo.jsx)(xl.NodeViewWrapper,{children:(0,Mo.jsx)(I1,{...e.node.attrs,type:e.node.type.name})}):(0,Mo.jsx)(Rt,{id:e.node.attrs.id,className:L(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:(0,Mo.jsx)(I1,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");var R1=require("@hookform/resolvers/zod"),H1=require("react-hook-form");var ce=require("react/jsx-runtime"),D1=s(({element:e,editor:t})=>{let r=(0,H1.useForm)({resolver:(0,R1.zodResolver)(S1),defaultValues:{...me,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=xt({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?(0,ce.jsxs)(Je,{...r,children:[(0,ce.jsx)(Ht,{type:"text"}),(0,ce.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,ce.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,ce.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,ce.jsx)(j,{control:r.control,name:"paddingHorizontal",render:({field:n})=>(0,ce.jsxs)(q,{children:[(0,ce.jsx)(J,{children:(0,ce.jsx)(ye,{startAdornment:(0,ce.jsx)(ia,{}),type:"number",min:0,...n})}),(0,ce.jsx)(K,{})]})}),(0,ce.jsx)(j,{control:r.control,name:"paddingVertical",render:({field:n})=>(0,ce.jsxs)(q,{children:[(0,ce.jsx)(J,{children:(0,ce.jsx)(ye,{startAdornment:(0,ce.jsx)(yn,{}),type:"number",min:0,...n})}),(0,ce.jsx)(K,{})]})})]}),(0,ce.jsx)(j,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,ce.jsxs)(q,{className:"courier-mb-4",children:[(0,ce.jsx)(J,{children:(0,ce.jsx)(vt,{...n,defaultValue:me.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ce.jsx)(K,{})]})}),(0,ce.jsx)(le,{className:"courier-mb-4"}),(0,ce.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,ce.jsx)(j,{control:r.control,name:"borderWidth",render:({field:n})=>(0,ce.jsxs)(q,{className:"courier-mb-3",children:[(0,ce.jsx)(J,{children:(0,ce.jsx)(ye,{startAdornment:(0,ce.jsx)(wo,{}),type:"number",min:0,...n})}),(0,ce.jsx)(K,{})]})}),(0,ce.jsx)(j,{control:r.control,name:"borderColor",render:({field:n})=>(0,ce.jsxs)(q,{className:"courier-mb-4",children:[(0,ce.jsx)(J,{children:(0,ce.jsx)(vt,{...n,defaultValue:me.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ce.jsx)(K,{})]})})]})]}):null},"TextBlockForm");var F1=require("@tiptap/react");var gd=A1.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){dt(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:me.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):me.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:me.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):me.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:me.textAlign,parseHTML:t=>t.style.textAlign||me.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:me.backgroundColor,parseHTML:t=>t.style.backgroundColor||me.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:me.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):me.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderColor:{default:me.borderColor,parseHTML:t=>t.style.borderColor||me.borderColor,renderHTML:t=>({style:`border-color: ${t.borderColor}`})},id:{default:()=>null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>({"data-id":t.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},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,B1.mergeAttributes)(this.options.HTMLAttributes,t),0]},addNodeView(){return(0,F1.ReactNodeViewRenderer)(El)}});var wl=require("@tiptap/core"),O1=require("@tiptap/react");var hd=require("jotai"),_e=require("react");var Nt=require("react/jsx-runtime"),zh=["image/png","image/jpeg","image/gif","image/webp"],$h=s(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderColor:n,isUploading:i,width:a,imageNaturalWidth:l,onFileSelect:c,editor:u})=>{let[d,p]=(0,_e.useState)(!1),[m,f]=(0,_e.useState)(!0),C=(0,_e.useRef)(null),y=(0,_e.useRef)(null);(0,_e.useEffect)(()=>{e&&f(!0)},[e]),(0,_e.useEffect)(()=>{if(e&&!l&&u){let x=new Image;x.onload=()=>{try{if(!u.view||!u.state)return;let E=u.view.state.selection.from;u.chain().setNodeSelection(E).updateAttributes("imageBlock",{imageNaturalWidth:x.naturalWidth}).run()}catch{}},x.src=e}},[e,l,u]);let h=(0,_e.useCallback)(x=>{var S,I;let E=(I=(S=u==null?void 0:u.view)==null?void 0:S.dom)==null?void 0:I.closest(".ProseMirror"),v=(E==null?void 0:E.clientWidth)||1e3,P=Math.min(100,x/v*100);return Math.round(P)},[u]),b=(0,_e.useMemo)(()=>h(l),[h,l]),N=(0,_e.useCallback)(x=>zh.includes(x),[]),g=(0,_e.useCallback)(x=>{x.preventDefault(),x.stopPropagation(),x.dataTransfer.types.includes("Files")&&Array.from(x.dataTransfer.items).some(P=>N(P.type))&&(p(!0),x.dataTransfer.dropEffect="copy")},[N]),w=(0,_e.useCallback)(x=>{x.preventDefault(),x.stopPropagation(),p(!1)},[]),M=(0,_e.useCallback)(x=>{x.preventDefault(),x.stopPropagation(),x.dataTransfer.types.includes("Files")&&Array.from(x.dataTransfer.items).some(P=>N(P.type))&&p(!0)},[N]),k=(0,_e.useCallback)(x=>{x.preventDefault(),x.stopPropagation(),p(!1);let v=Array.from(x.dataTransfer.files).find(P=>N(P.type));v&&c&&c(v)},[c,N]),D=(0,_e.useCallback)(x=>{var v;let E=(v=x.target.files)==null?void 0:v[0];E&&c&&c(E),x.target&&(x.target.value="")},[c]),T=(0,_e.useCallback)(()=>{var x;(x=C.current)==null||x.click()},[]);return Qa(e)?(0,Nt.jsxs)("div",{className:L("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 courier-text-center courier-flex-wrap courier-content-center courier-p-4",d&&"courier-border-primary courier-bg-gray-50"),onDragOver:g,onDragEnter:M,onDragLeave:w,onDrop:k,style:{pointerEvents:"all"},children:[i?(0,Nt.jsx)(vn,{className:"courier-w-8 courier-h-8"}):(0,Nt.jsxs)(Nt.Fragment,{children:[(0,Nt.jsx)("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),(0,Nt.jsx)("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:T,children:"Browse"})]}),(0,Nt.jsx)("input",{ref:C,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:D})]}):(0,Nt.jsx)("div",{className:"courier-w-full node-element",children:(0,Nt.jsxs)("div",{className:L("courier-relative courier-p-1",(i||m)&&"courier-w-full courier-aspect-[4/3] courier-bg-gray-100"),children:[(i||m)&&(0,Nt.jsx)("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:(0,Nt.jsx)(vn,{className:"courier-w-8 courier-h-8"})}),(0,Nt.jsx)("img",{ref:y,src:e,alt:t,className:L("courier-h-auto courier-inline-block courier-w-full",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[r],i&&"courier-opacity-50",(i||m)&&"courier-invisible"),style:{maxWidth:a===b?`${l}px`:`${a}%`,borderWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",display:"block"},loading:"lazy",decoding:"async",draggable:!1,onLoad:x=>{if(f(!1),!l&&u)try{if(!u.view||!u.state)return;setTimeout(()=>{let E=u.view.state.selection.from;u.chain().setNodeSelection(E).updateAttributes("imageBlock",{imageNaturalWidth:x.target.naturalWidth}).run()},100)}catch(E){console.warn("Editor not ready for image update:",E)}},onError:()=>f(!1)})]})})},"ImageBlockComponent"),Zh=["image/png","image/jpeg","image/gif","image/webp"],V1=s(e=>{let t=(0,hd.useSetAtom)(Xe),r=(0,hd.useSetAtom)(ee),{uploadImage:o}=Gn(),n=(0,_e.useCallback)(l=>{var p,m,f;let c=(f=(m=(p=e.editor)==null?void 0:p.view)==null?void 0:m.dom)==null?void 0:f.closest(".ProseMirror"),u=(c==null?void 0:c.clientWidth)||1e3,d=Math.min(100,l/u*100);return Math.round(d)},[e.editor]);(0,_e.useEffect)(()=>{var c,u;let l=pt(e);if((c=l==null?void 0:l.attrs)!=null&&c.sourcePath&&!((u=l==null?void 0:l.attrs)!=null&&u.imageNaturalWidth)){let d=new Image;d.onload=()=>{let p=l.attrs.width||n(d.naturalWidth),m=rn(e.getPos);m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{width:p,imageNaturalWidth:d.naturalWidth}).run()},d.src=l.attrs.sourcePath}},[e,n]);let i=(0,_e.useCallback)(()=>{if(!e.editor.isEditable)return;let l=pt(e);l&&(e.editor.commands.blur(),t(l))},[e,t]),a=(0,_e.useCallback)(async l=>{let c=rn(e.getPos);pt(e)&&c!==null&&e.editor.chain().focus().setNodeSelection(c).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!Zh.includes(l.type))throw new Error("Only PNG, JPEG, GIF, and WebP images are supported");let d=new FileReader;d.readAsDataURL(l),await new Promise((y,h)=>{d.onload=y,d.onerror=h});let m=(await o({file:l})).url,f=rn(e.getPos);if(pt(e)&&f!==null){let y=new Image;y.src=m,await new Promise((b,N)=>{y.onload=b,y.onerror=()=>N(new Error("Failed to load uploaded image"))});let h=n(y.naturalWidth);e.editor.chain().focus().setNodeSelection(f).updateAttributes("imageBlock",{sourcePath:m,isUploading:!1,width:h,imageNaturalWidth:y.naturalWidth}).run()}}catch(d){console.error("Error uploading image:",d);let p="Error uploading image";if(d instanceof Error){let C=d.message;C.includes("GraphQL error")?p="Server error: Could not process image":C.includes("network")||C.includes("fetch")?p="Network error: Could not upload image":p=C}r({message:p,toastProps:{duration:6e3,description:`File: ${l.name} (${(l.size/1024/1024).toFixed(2)}MB)`}});let m=rn(e.getPos);pt(e)&&m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return(0,Nt.jsx)(Rt,{id:e.node.attrs.id,className:L(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:(0,Nt.jsx)($h,{...e.node.attrs,onFileSelect:a,editor:e.editor})})},"ImageBlockView");var lt={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderColor:"transparent",isUploading:!1,imageNaturalWidth:0},Pl=wl.Node.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){dt(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:lt.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:lt.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:lt.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:lt.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:lt.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:lt.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:lt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:lt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:lt.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})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="image-block"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,wl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return(0,O1.ReactNodeViewRenderer)(V1)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...lt,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...lt,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 Gr=require("zod"),W1=Gr.z.object({sourcePath:Gr.z.string(),link:Gr.z.string().optional(),alt:Gr.z.string().optional(),alignment:Gr.z.enum(["left","center","right"]),width:Gr.z.number().min(1).max(100),borderWidth:Gr.z.number(),borderColor:Gr.z.string(),isUploading:Gr.z.boolean().optional(),imageNaturalWidth:Gr.z.number()});var _1=require("@hookform/resolvers/zod"),U1=require("jotai"),z1=require("lucide-react"),ft=require("react"),$1=require("react-hook-form");var kl=require("jotai"),Vn=he(require("react"),1),Fn=require("react");var bd=require("react/jsx-runtime"),yd=s(({items:e,command:t,selected:r=0})=>(0,bd.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,bd.jsx)("button",{className:L("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 fo=require("react/jsx-runtime"),on=Vn.forwardRef(({as:e="Input",variables:t=[],autoResize:r,onChange:o,disableVariableAutocomplete:n=!1,...i},a)=>{let[l,c]=(0,Fn.useState)(!1),[u,d]=(0,Fn.useState)(null),[p,m]=(0,Fn.useState)(0),f=(0,Fn.useRef)(null),C=(0,Fn.useRef)(null),y=(0,kl.useSetAtom)(da),h=(0,kl.useSetAtom)(sp),b=(0,kl.useSetAtom)(ys),N=Vn.useCallback(()=>{if(!C.current)return;let E={ref:C.current,caretPosition:C.current.selectionStart};h(E),b(E);let v={isFocused:!0,hasVariables:t.length>0,showVariablePopup:!1};y(v)},[y,h,b,t]),g=Vn.useCallback(E=>{var S,I;let v=E.relatedTarget&&((S=f.current)==null?void 0:S.contains(E.relatedTarget)),P=(I=E.relatedTarget)==null?void 0:I.closest("[data-variable-button]");!v&&!P&&(h({ref:null,caretPosition:null}),y({isFocused:!1,hasVariables:!1,showVariablePopup:!1}))},[y,h]),w=s(E=>{let v=E.target,P={ref:v,caretPosition:v.selectionStart};h(P),b(P)},"handleSelect"),M=s(E=>{var v;if(l)switch(E.key){case"ArrowUp":E.preventDefault(),m(P=>P>0?P-1:t.length-1);break;case"ArrowDown":E.preventDefault(),m(P=>P<t.length-1?P+1:0);break;case"Enter":if(t[p]){E.preventDefault(),E.stopPropagation(),k(t[p]);return}break;case"Escape":c(!1),E.preventDefault(),E.stopPropagation();break}(v=i.onKeyDown)==null||v.call(i,E)},"handleKeyDown"),k=s(E=>{let v=C.current;if(!v)return;let P=v.value,S=v.selectionStart||0,I=P.substring(0,S-2),A=P.substring(S),H=`${I}{{${E}}}${A}`,R=S+E.length+3;if(o){let B={target:{...v,value:H}};o(B)}setTimeout(()=>{v.value=H,v.setSelectionRange(R,R)},0),c(!1)},"insertVariable"),D=s(E=>{var I;let v=E.target,P=v.value,S=v.selectionStart||0;if(!n&&P.slice(S-2,S)==="{{"&&((I=f.current)==null?void 0:I.getBoundingClientRect())){let H=P.slice(0,S),R=document.createElement("span");R.style.font=window.getComputedStyle(v).font,R.style.whiteSpace="pre-wrap",R.textContent=H,document.body.appendChild(R);let B=R.offsetWidth;document.body.removeChild(R);let _=parseInt(window.getComputedStyle(v).lineHeight),V=H.split(`
|
|
187
|
-
`).length-1;d({left:Math.min(B%v.offsetWidth,v.offsetWidth-200),top:V*_+30}),c(!0),m(0)}o&&o({target:v,currentTarget:v,type:"change",preventDefault:()=>{},stopPropagation:()=>{}})},"handleChange"),T=s(E=>{var I;let v=E.target,P=v.value,S=v.selectionStart||0;if(!n&&P.slice(S-2,S)==="{{"&&((I=f.current)==null?void 0:I.getBoundingClientRect())){let H=P.slice(0,S),R=document.createElement("span");R.style.font=window.getComputedStyle(v).font,R.style.whiteSpace="pre-wrap",R.textContent=H,document.body.appendChild(R);let B=R.offsetWidth;document.body.removeChild(R);let _=parseInt(window.getComputedStyle(v).lineHeight),V=H.split(`
|
|
188
|
-
`).length-1;d({left:Math.min(B%v.offsetWidth,v.offsetWidth-200),top:V*_+30}),c(!0),m(0)}o&&o({target:v,currentTarget:v,type:"change",preventDefault:()=>{},stopPropagation:()=>{}})},"handleInput");if(Vn.useEffect(()=>{let E=C.current;if(!E||n)return;let v=s(P=>{d(P.detail.cursorPosition),c(!0),m(0)},"handleShowSuggestions");return E.addEventListener("showVariableSuggestions",v),()=>{E.removeEventListener("showVariableSuggestions",v)}},[n]),e==="Input"){let E={...i,ref:v=>{C.current=v,typeof a=="function"?a(v):a&&(a.current=v)},onChange:D,onInput:T,onKeyDown:M,onFocus:N,onBlur:g,onSelect:w};return(0,fo.jsxs)("div",{ref:f,className:"courier-relative",children:[(0,fo.jsx)(ye,{...E}),l&&u&&(0,fo.jsx)("div",{style:{position:"absolute",left:`${u.left}px`,top:`${u.top}px`,zIndex:50},children:(0,fo.jsx)(yd,{items:t,command:k,selected:p})})]})}let x={...i,ref:E=>{C.current=E,typeof a=="function"?a(E):a&&(a.current=E)},onChange:D,onInput:T,onKeyDown:M,onFocus:N,onBlur:g,autoResize:r,onSelect:w};return(0,fo.jsxs)("div",{ref:f,className:"courier-relative",children:[(0,fo.jsx)(Yc,{...x}),l&&u&&(0,fo.jsx)("div",{style:{position:"absolute",left:`${u.left}px`,top:`${u.top}px`,zIndex:50},children:(0,fo.jsx)(yd,{items:t,command:k,selected:p})})]})});on.displayName="TextInput";var z=require("react/jsx-runtime"),Z1=s(({element:e,editor:t,disableVariableAutocomplete:r=!0})=>{var E,v,P,S;let o=(0,ft.useRef)(null),n=(0,ft.useRef)(null),i=(0,ft.useRef)(null),[a,l]=(0,ft.useState)(""),[c,u]=(0,ft.useState)(!1),[d,p]=(0,ft.useState)(((E=e==null?void 0:e.attrs)==null?void 0:E.imageNaturalWidth)||0),[m,f]=(0,ft.useState)(!1),C=(0,U1.useSetAtom)(ee),{uploadImage:y}=Gn(),h=(0,$1.useForm)({resolver:(0,_1.zodResolver)(W1),defaultValues:{...lt,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:b}=xt({editor:t,element:e,form:h,nodeType:"imageBlock"});(0,ft.useEffect)(()=>{var A;let I=(A=e==null?void 0:e.attrs)==null?void 0:A.sourcePath;if(I&&!d){let H=new Image;H.onload=()=>{p(H.naturalWidth);let R={...h.getValues(),imageNaturalWidth:H.naturalWidth};h.setValue("imageNaturalWidth",H.naturalWidth),b(R)},H.src=I}},[(v=e==null?void 0:e.attrs)==null?void 0:v.sourcePath,d,h,b]);let N=(0,ft.useCallback)(I=>{var _,V;let A=(V=(_=t==null?void 0:t.view)==null?void 0:_.dom)==null?void 0:V.closest(".ProseMirror"),H=(A==null?void 0:A.clientWidth)||1e3;if(I||(I=d),!I)return 0;let R=Math.min(100,I/H*100);return Math.round(R)},[t,d]),g=(0,ft.useCallback)(I=>{var A;I.preventDefault(),(A=o.current)==null||A.click()},[]),w=(0,ft.useCallback)((I,A)=>{let H=N(I.naturalWidth);l(`${H}%`),u(!1),h.setValue("sourcePath",A),h.setValue("imageNaturalWidth",I.naturalWidth),h.setValue("width",H);let R={...h.getValues(),sourcePath:A,width:H,imageNaturalWidth:I.naturalWidth,isUploading:!1};b(R)},[h,b,N]),M=(0,ft.useCallback)(I=>{if(!I){h.setValue("imageNaturalWidth",0),h.setValue("width",0),b({...h.getValues(),sourcePath:"",imageNaturalWidth:0,width:0});return}let A=new Image;A.onload=()=>{let H=N(A.naturalWidth);h.setValue("imageNaturalWidth",A.naturalWidth),h.setValue("width",H);let R={...h.getValues(),sourcePath:I,width:H,imageNaturalWidth:A.naturalWidth};b(R)},A.onerror=()=>{console.debug("Image failed to load:",I)},A.src=I},[h,b,N]),k=(0,ft.useCallback)(I=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{M(I)},500)},[M]);(0,ft.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]);let D=((S=(P=t==null?void 0:t.extensionManager.extensions.find(I=>I.name==="variableSuggestion"))==null?void 0:P.options)==null?void 0:S.variables)||{},T=Tt(D),x=h.getValues().sourcePath;return e?(0,z.jsxs)(Je,{...h,children:[(0,z.jsx)(Ht,{type:"image"}),(0,z.jsxs)("form",{ref:n,onChange:()=>{let I=h.getValues();b(I)},children:[(0,z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),(0,z.jsxs)(ls,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[(0,z.jsxs)(Gi,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[(0,z.jsx)(oi,{value:"file",className:"courier-flex-1",children:"From file"}),(0,z.jsx)(oi,{value:"url",className:"courier-flex-1",children:"From URL"})]}),(0,z.jsx)(cs,{value:"file",children:(0,z.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,z.jsx)(Ie,{onClick:g,className:"courier-w-full",variant:"outline",type:"button",disabled:m,children:m?(0,z.jsx)(z.Fragment,{children:"Uploading..."}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(z1.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),(0,z.jsx)("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:I=>{var H;let A=(H=I.target.files)==null?void 0:H[0];if(A){f(!0),h.setValue("sourcePath",""),b({...h.getValues(),sourcePath:"",isUploading:!0});let R=new FileReader;R.onload=async()=>{try{let _=(await y({file:A})).url,V=new Image;V.onload=()=>{w(V,_),f(!1)},V.onerror=()=>{C({message:"Upload failed: Failed to load uploaded image",toastProps:{duration:6e3,description:`File: ${A.name} (${(A.size/1024/1024).toFixed(2)}MB)`}}),f(!1),b({...h.getValues(),isUploading:!1})},V.src=_}catch(B){console.error("Error uploading image:",B),C({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${A.name} (${(A.size/1024/1024).toFixed(2)}MB)`}}),f(!1),b({...h.getValues(),isUploading:!1})}},R.onerror=()=>{C({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${A.name} (${(A.size/1024/1024).toFixed(2)}MB)`}}),f(!1),b({...h.getValues(),isUploading:!1})},R.readAsDataURL(A)}}})]})}),(0,z.jsx)(cs,{value:"url",children:(0,z.jsx)(j,{control:h.control,name:"sourcePath",render:({field:I})=>(0,z.jsxs)(q,{className:"courier-mb-3",children:[(0,z.jsx)(J,{children:(0,z.jsx)(on,{as:"Textarea",...I,autoResize:!0,className:"courier-max-h-[88px]",variables:T,disableVariableAutocomplete:r,onChange:A=>{I.onChange(A),k(A.target.value)}})}),(0,z.jsx)(K,{})]})})})]}),(0,z.jsx)(j,{control:h.control,name:"link",render:({field:I})=>(0,z.jsxs)(q,{className:"courier-mb-3",children:[(0,z.jsx)(J,{children:(0,z.jsx)(Jr,{placeholder:"Link",value:I.value,variables:T,disableVariableAutocomplete:r,onChange:A=>{I.onChange(A),b({...h.getValues(),link:A})}})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(j,{control:h.control,name:"alt",render:({field:I})=>(0,z.jsxs)(q,{className:"courier-mb-4",children:[(0,z.jsx)(J,{children:(0,z.jsx)(Jr,{placeholder:"Alt text...",value:I.value,variables:T,disableVariableAutocomplete:r,onChange:A=>{I.onChange(A),b({...h.getValues(),alt:A})}})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Width"}),(()=>{let I=h.getValues().width,A=h.getValues().imageNaturalWidth,H=N(A),R=I===H,B=R?"original":"fill";return(0,z.jsxs)(Nr,{type:"single",value:x?B:"original",onValueChange:_=>{if(!_||_===B)return;let V=_==="fill"?100:N(A);V>0&&(h.setValue("width",V),b({...h.getValues(),width:V}))},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",disabled:!x,children:[(0,z.jsx)($t,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),(0,z.jsx)($t,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:R||!x,children:"Fill"})]})})(),(0,z.jsx)(j,{control:h.control,name:"width",render:({field:I})=>(0,z.jsxs)(q,{className:"courier-flex-1 courier-mb-3",children:[(0,z.jsx)(J,{children:(0,z.jsx)(ye,{type:"text",inputMode:"numeric",pattern:"[0-9]*",min:1,max:100,...I,value:h.getValues().sourcePath?c?a:`${I.value}%`:"0%",className:"courier-text-2xl courier-font-normal",disabled:!h.getValues().sourcePath,onFocus:A=>{u(!0),l(A.target.value)},onChange:A=>{l(A.target.value)},onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),A.currentTarget.blur())},onBlur:A=>{u(!1);let H=parseFloat(A.target.value.replace("%",""));if(!isNaN(H)){let R=Math.min(100,Math.max(1,H));I.onChange(R),b({...h.getValues(),width:Math.round(R)})}}})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(j,{control:h.control,name:"width",render:({field:I})=>(0,z.jsxs)(q,{className:"courier-flex-1 courier-mb-3",children:[(0,z.jsx)(J,{children:(0,z.jsx)(Kc,{min:0,max:100,value:[x?I.value:0],disabled:!x,onValueChange:A=>{I.onChange(A[0]),b({...h.getValues(),width:A[0]})}})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(j,{control:h.control,name:"alignment",render:({field:I})=>(0,z.jsxs)(q,{children:[(0,z.jsx)(J,{children:(0,z.jsxs)(Nr,{disabled:!x,type:"single",value:I.value,onValueChange:A=>{I.onChange(A),b({...h.getValues(),alignment:A})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,z.jsx)($t,{size:"sm",value:"left",className:"courier-w-full",children:(0,z.jsx)(js,{className:"courier-h-4 courier-w-4"})}),(0,z.jsx)($t,{size:"sm",value:"center",className:"courier-w-full",children:(0,z.jsx)(Ks,{className:"courier-h-4 courier-w-4"})}),(0,z.jsx)($t,{size:"sm",value:"right",className:"courier-w-full",children:(0,z.jsx)(Gs,{className:"courier-h-4 courier-w-4"})})]})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(le,{className:"courier-mt-6 courier-mb-4"}),(0,z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,z.jsx)(j,{control:h.control,name:"borderWidth",render:({field:I})=>(0,z.jsxs)(q,{className:"courier-mb-3",children:[(0,z.jsx)(J,{children:(0,z.jsx)(ye,{startAdornment:(0,z.jsx)(wo,{}),type:"number",disabled:!x,min:0,...I,onChange:A=>{let H=parseInt(A.target.value)||0;I.onChange(H),b({...h.getValues(),borderWidth:H})}})}),(0,z.jsx)(K,{})]})}),(0,z.jsx)(j,{control:h.control,name:"borderColor",render:({field:I})=>(0,z.jsxs)(q,{className:"courier-mb-4",children:[(0,z.jsx)(J,{children:(0,z.jsx)(vt,{...I,disabled:!x,defaultValue:lt.borderColor,onChange:A=>{I.onChange(A),b({...h.getValues(),[I.name]:A})}})}),(0,z.jsx)(K,{})]})})]})]}):null},"ImageBlockForm");var Fa=require("@tiptap/core"),q1=he(require("@tiptap/extension-link"),1),Ei=require("@tiptap/pm/state"),Cd=q1.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,Fa.mergeAttributes)(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new Ei.Plugin({props:{handleClick:(r,o,n)=>{if(n.button!==0)return!1;let{state:i}=r,{doc:a}=i,l=a.resolve(o),c=l.marks().find(u=>u.type.name==="link");if(c||o>0&&(c=a.resolve(o-1).marks().find(d=>d.type.name==="link")),c||o<a.content.size&&(c=a.resolve(o+1).marks().find(d=>d.type.name==="link")),c){let u=(0,Fa.getMarkRange)(l,c.type);return u?(r.dispatch(i.tr.setSelection(Ei.TextSelection.create(a,u.from,u.to))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:u.from,to:u.to,href:c.attrs.originalHref||c.attrs.href})),!0):(r.dispatch(i.tr.setSelection(Ei.TextSelection.create(a,o,o+1))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:o,to:o+1,href:c.attrs.originalHref||c.attrs.href})),!0)}return!1}}}),new Ei.Plugin({appendTransaction(r,o,n){if(!r.some(l=>l.docChanged))return null;let i=n.tr,a=!1;return n.doc.descendants((l,c)=>(l.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,Fa.getMarkRange)(n.doc.resolve(c),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 J1=require("@hookform/resolvers/zod"),j1=require("jotai"),Ml=require("react"),K1=require("react-hook-form"),Nl=require("zod");var Yr=require("react/jsx-runtime"),qh=Nl.z.object({href:Nl.z.string(),openInNewTab:Nl.z.boolean().default(!1)}),G1=s(({editor:e,mark:t,pendingLink:r})=>{var u,d;let o=(0,j1.useSetAtom)(Cs),n=(0,Ml.useRef)(null),i=(0,K1.useForm)({resolver:(0,J1.zodResolver)(qh),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1}});(0,Ml.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)||{},l=Tt(a),c=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,Yr.jsxs)(Je,{...i,children:[(0,Yr.jsx)("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),(0,Yr.jsx)("div",{className:"courier-space-y-4",children:(0,Yr.jsx)(j,{control:i.control,name:"href",render:({field:p})=>(0,Yr.jsxs)(q,{children:[(0,Yr.jsx)(lo,{children:"URL"}),(0,Yr.jsx)(J,{children:(0,Yr.jsx)(on,{as:"Textarea",autoResize:!0,...p,variables:l,ref:m=>{typeof p.ref=="function"&&p.ref(m),n.current=m},onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),m.stopPropagation(),i.handleSubmit(c)())},onBlur:()=>{p.onBlur(),i.handleSubmit(c)()}})}),(0,Yr.jsx)(K,{})]})})})]})},"LinkForm");var Il=require("@tiptap/react"),wi=require("prosemirror-state");var Ao={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:"'"},Sl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Jh=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),jh=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(et=0;et<10;et++)Ao[48+et]=Ao[96+et]=String(et);var et;for(et=1;et<=24;et++)Ao[et+111]="F"+et;var et;for(et=65;et<=90;et++)Ao[et]=String.fromCharCode(et+32),Sl[et]=String.fromCharCode(et);var et;for(Al in Ao)Sl.hasOwnProperty(Al)||(Sl[Al]=Ao[Al]);var Al;function Y1(e){var t=Jh&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||jh&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?Sl:Ao)[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(Y1,"keyName");var X1=require("prosemirror-state");var Kh=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Gh(e){let t=e.split(/-(?!$)/),r=t[t.length-1];r=="Space"&&(r=" ");let o,n,i,a;for(let l=0;l<t.length-1;l++){let c=t[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))Kh?a=!0:n=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(r="Alt-"+r),n&&(r="Ctrl-"+r),a&&(r="Meta-"+r),i&&(r="Shift-"+r),r}s(Gh,"normalizeKeyName");function Yh(e){let t=Object.create(null);for(let r in e)t[Gh(r)]=e[r];return t}s(Yh,"normalize");function vd(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(vd,"modifiers");function Q1(e){return new X1.Plugin({props:{handleKeyDown:Xh(e)}})}s(Q1,"keymap");function Xh(e){let t=Yh(e);return function(r,o){let n=Y1(o),i,a=t[vd(n,o)];if(a&&a(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let l=t[vd(n,o,!1)];if(l&&l(r.state,r.dispatch,r))return!0}if((o.shiftKey||o.altKey||o.metaKey||n.charCodeAt(0)>127)&&(i=Ao[o.keyCode])&&i!=n){let l=t[vd(i,o)];if(l&&l(r.state,r.dispatch,r))return!0}}return!1}}s(Xh,"keydownHandler");var eg=require("uuid");var xd=bi.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){dt(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,eg.v4)()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:me.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):me.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:me.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):me.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:me.textAlign,parseHTML:e=>e.style.textAlign||me.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:me.backgroundColor,parseHTML:e=>e.style.backgroundColor||me.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:me.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):me.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:me.borderColor,parseHTML:e=>e.style.borderColor||me.borderColor,renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="paragraph"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Il.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return(0,Il.ReactNodeViewRenderer)(El)},addProseMirrorPlugins(){return[Q1({"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(wi.TextSelection.create(t.doc,i,a)),!0}return!1}}),new wi.Plugin({key:new wi.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,l=a.depth,c=null;for(;l>0;){let u=a.node(l);if(u.type.name==="paragraph"||u.type.name==="heading"){c=u;break}l--}if(c){let u=c.textContent,d=a.parentOffset===0,p=a.parentOffset===u.length,m=u.length===0,f=t.key==="Delete"||t.keyCode===46||t.code==="Delete",C=f?i.$from.nodeAfter:i.$from.nodeBefore,y=C!=null;if(y&&m)return!1;if(o||m&&!y||!f&&d&&!y||f&&p&&!y)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,l=null;for(;a>0;){let m=n.node(a);if(m.type.name==="paragraph"||m.type.name==="heading"){l=m;break}a--}if(!l)return!1;let c=r?n.pos===i.pos&&n.parentOffset===0:n.pos===i.pos&&n.parentOffset===l.textContent.length,u=l.textContent.length===0,d=r?t.state.selection.$from.nodeBefore:t.state.selection.$from.nodeAfter,p=d!=null;return p&&u?!1:c&&!p||u&&!p?!0:o?!1:(t.commands.command(({tr:m,dispatch:f})=>f?(m.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 tg=require("@tiptap/core"),Ll=require("@tiptap/pm/state"),Qh=new Ll.PluginKey("selection"),Td=tg.Extension.create({name:"selection",addOptions(){return{HTMLAttributes:{},setSelectedNode:()=>{},shouldHandleClick:()=>!0}},addGlobalAttributes(){return[{types:["paragraph","heading","button","spacer","divider","imageBlock","blockquote","customCode","column"],attributes:{isSelected:{default:!1,parseHTML:()=>!1,renderHTML:e=>e.isSelected?{class:"selected-element"}:{}}}}]},addCommands(){return{updateSelectionState:e=>({tr:t,dispatch:r})=>{var o,n;if(r){let i=(o=e==null?void 0:e.attrs)==null?void 0:o.id,a=(n=e==null?void 0:e.type)==null?void 0:n.name;t.doc.descendants((l,c)=>{var u,d,p;if(l.type.name!=="text"&&((u=l.type.spec.attrs)==null?void 0:u.isSelected)!==void 0){let m=!1;i?m=((d=l.attrs)==null?void 0:d.id)===i&&l.type.name===a:a&&(m=l.type.name===a&&l.content.size===((p=e==null?void 0:e.content)==null?void 0:p.size)),m?t.setNodeAttribute(c,"isSelected",!0):t.setNodeAttribute(c,"isSelected",!1)}return!0})}return!0}}},addProseMirrorPlugins(){return[new Ll.Plugin({key:Qh,props:{handleClick:(e,t,r)=>{let{state:o}=e;if(!this.editor.isEditable||this.options.shouldHandleClick&&!this.options.shouldHandleClick())return!1;let n=r.target;if(n.closest(".node-blockquote")||n.closest('[data-cypress="draggable-handle"]')||n.closest('button[class*="courier-cursor-grab"]'))return!1;try{let l=window.getSelection();if(l&&l.rangeCount>0){let u=l.getRangeAt(0).startContainer.parentElement;if(u&&(["P","H1","H2","H3"].includes(u.tagName)||["P","H1","H2","H3"].some(d=>u.closest(d)))){let d=e.posAtDOM(u,0),m=o.doc.resolve(d).node();if(m&&["paragraph","heading"].includes(m.type.name))return this.options.setSelectedNode(m),this.editor.commands.updateSelectionState(m),!0}}}catch(l){console.error("Error handling click:",l)}let i=e.posAtDOM(n,0),a=o.doc.resolve(i).node();return a&&["paragraph","heading"].includes(a.type.name)?(this.options.setSelectedNode(a),this.editor.commands.updateSelectionState(a),!0):!1}}})]}});var rg=require("react"),og=require("react/jsx-runtime"),Ed=(0,rg.forwardRef)(({children:e,className:t,withShadow:r=!0,withBorder:o=!0,...n},i)=>{let a=L("courier-bg-popover courier-rounded-lg courier-text-popover-foreground",r?"courier-shadow-sm":"",o?"courier-border courier-border-border":"",t);return(0,og.jsx)("div",{className:a,...n,ref:i,children:e})});Ed.displayName="Surface";var ng=require("uuid");var eb=s((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),ig=s((e,t,r,o,n,i)=>{let a=`node-${(0,ng.v4)()}`,c={heading:()=>e.schema.nodes.heading.create({...me,...o,id:a},i),paragraph:()=>e.schema.nodes.paragraph.create({...me,...o,id:a},i),text:()=>e.schema.nodes.paragraph.create({...me,...o,id:a},i),spacer:()=>e.schema.nodes.divider.create({...pl,...o,id:a}),divider:()=>e.schema.nodes.divider.create({...xr,...o,id:a}),button:()=>e.schema.nodes.button.create({...Ke,...o,id:a},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...lt,...o,id:a}),image:()=>e.schema.nodes.imageBlock.create({...lt,...o,id:a}),customCode:()=>e.schema.nodes.customCode.create({...No,...o,id:a}),column:()=>e.schema.nodes.column.create({...Pt,...o,id:a})}[t];if(c)try{let u=e.state.tr,d=c();u.insert(r,d),e.view.dispatch(u),n&&n(d),(t==="text"||t==="paragraph"||t==="heading")&&setTimeout(()=>{let m=eb(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 rn=s(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),pt=s(e=>{let t=rn(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");var ag=require("lucide-react"),sg=require("react"),Id=require("react/jsx-runtime"),lg=(0,sg.forwardRef)((e,t)=>(0,Id.jsx)("button",{...e,ref:t,"data-cypress":"draggable-handle","data-drag-handle":!0,className:L("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 courier-select-none courier-z-10 courier-touch-none",e.className),style:{WebkitUserSelect:"none",userSelect:"none",touchAction:"none"},children:(0,Id.jsx)(ag.GripVertical,{strokeWidth:1,className:"courier-w-5 courier-stroke-neutral-400 courier-fill-neutral-400 courier-pointer-events-none"})}));var Rl=require("jotai"),or=require("react"),dg=require("uuid");var cg=require("react");var ug=s((e,t,r)=>(0,cg.useMemo)(()=>{if(!(e!=null&&e.conditionalRules)||!t||!r)return null;let o=e.conditionalRules.filter(n=>n.trigger.type==="node"&&t.isActive(n.trigger.name)!==n.trigger.active?!1:n.conditions.activeItems.some(i=>i==="bold"?r.isBold:i==="italic"?r.isItalic:i==="underline"?r.isUnderline:i==="strike"?r.isStrike:!1));return{getRuleForItem:n=>o.find(i=>!i.conditions.activeItems.includes(n))}},[e,t,r]),"useConditionalRules");var Hl=s((e,t,r)=>{let o=(0,Rl.useSetAtom)(Xe),n=(0,Rl.useAtomValue)(Ce),i=ug(t,e,r),a=(0,or.useCallback)(g=>{let w=-1;return e.state.doc.descendants((M,k)=>{var D;return((D=M.attrs)==null?void 0:D.id)===g?(w=k,!1):!0}),w},[e]),l=(0,or.useCallback)((g,w)=>{var M,k,D;if(((M=n==null?void 0:n.type)==null?void 0:M.name)==="button"&&((k=n.attrs)!=null&&k.id)){let T=n.attrs.id,x=a(T);if(x>=0){let E=e.state.tr;return E.setNodeMarkup(x,void 0,{...(D=e.state.doc.nodeAt(x))==null?void 0:D.attrs,[g]:w}),e.view.dispatch(E),setTimeout(()=>{let v=a(T);if(v>=0){let P=e.state.doc.nodeAt(v);P&&o(P)}},0),!0}}return!1},[e,n,a,o]),c=(0,or.useCallback)(()=>{var g,w;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"&&((w=n.attrs)!=null&&w.id)){let M=n.attrs.id,k=a(M);if(k>=0){let D=e.state.doc.nodeAt(k);if(!D)return!1;let T={...D.attrs,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},x=e.state.tr;return x.setNodeMarkup(k,void 0,T),e.view.dispatch(x),setTimeout(()=>{let E=a(M);if(E>=0){let v=e.state.doc.nodeAt(E);v&&o(v)}},0),!0}}return!1},[e,n,a,o]),u=(0,or.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let w=n.attrs.fontWeight==="bold"?"normal":"bold";if(l("fontWeight",w))return!0}if(i&&r){let w=i.getRuleForItem("bold");if(w&&w.action.type==="toggle_off"){let M=e.chain().focus();return w.action.targets.forEach(k=>{k==="italic"&&r.isItalic&&M.toggleItalic()}),M.toggleBold().run(),!0}}return e.chain().focus().toggleBold().run()},[e,n,l,i,r]),d=(0,or.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let w=n.attrs.fontStyle==="italic"?"normal":"italic";if(l("fontStyle",w))return!0}if(i&&r){let w=i.getRuleForItem("italic");if(w&&w.action.type==="toggle_off"){let M=e.chain().focus();return w.action.targets.forEach(k=>{k==="bold"&&r.isBold&&M.toggleBold()}),M.toggleItalic().run(),!0}}return e.chain().focus().toggleItalic().run()},[e,n,l,i,r]),p=(0,or.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let w=!n.attrs.isStrike;if(l("isStrike",w))return!0}return e.chain().focus().toggleMark("strike").run()},[e,n,l]),m=(0,or.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let w=!n.attrs.isUnderline;if(l("isUnderline",w))return!0}return e.chain().focus().toggleMark("underline").run()},[e,n,l]),f=(0,or.useCallback)(()=>e.chain().focus().setTextAlign("left").run(),[e]),C=(0,or.useCallback)(()=>e.chain().focus().setTextAlign("center").run(),[e]),y=(0,or.useCallback)(()=>e.chain().focus().setTextAlign("right").run(),[e]),h=(0,or.useCallback)(()=>e.chain().focus().setTextAlign("justify").run(),[e]),b=(0,or.useCallback)((g,w)=>e.chain().focus().setLink({href:g,target:w?"_blank":""}).run(),[e]),N=(0,or.useCallback)(()=>{let g=e.isActive("blockquote");if(e.chain().focus().toggleBlockquote().run()){let{selection:k}=e.state,D=k.$anchor;if(g){let T=D.node();(T.type.name==="paragraph"||T.type.name==="heading")&&o(T)}else for(let T=D.depth;T>0;T--){let x=D.node(T);if(x.type.name==="blockquote"){if(x.attrs.id)o(x);else{let E=D.before(T),v=`node-${(0,dg.v4)()}`,P=e.state.tr;P.setNodeMarkup(E,void 0,{...x.attrs,id:v}),e.view.dispatch(P);let S=e.state.doc.nodeAt(E);S&&o(S)}break}}}},[e,o]);return{onBold:u,onItalic:d,onStrike:p,onUnderline:m,onAlignLeft:f,onAlignCenter:C,onAlignRight:y,onAlignJustify:h,onLink:b,onQuote:N,resetButtonFormatting:c}},"useTextmenuCommands");var Dl=require("react/jsx-runtime"),tb=s(e=>{switch(e){case"text":return"Text";case"heading":return"Heading";case"spacer":return"Spacer";case"divider":return"Divider";case"button":return"Button";case"image":return"Image";case"customCode":return"Custom code";case"column":return"Column layout";default:return"Drop here"}},"getPlaceholderLabel"),Bl=s(({type:e})=>(0,Dl.jsx)("div",{className:"courier-flex courier-w-full courier-pointer-events-none",children:(0,Dl.jsx)("div",{className:L("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50 courier-ml-10","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md courier-drag-indicator dark:courier-border-accent"),children:(0,Dl.jsx)("div",{className:"courier-text-accent-foreground dark:courier-text-accent",children:tb(e)})})}),"DropIndicatorPlaceholder");var Ge=require("react/jsx-runtime");function rb(){let[e,t]=(0,Me.useState)(!1);return(0,Me.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(rb,"useMountStatus");var Rt=s(({children:e,id:t,className:r,editor:o,getPos:n,...i})=>{let a=(0,Me.useRef)(null),l=(0,Me.useRef)(null),c=(0,Me.useRef)(null),[u,d]=(0,Me.useState)(!1),[p,m]=(0,Me.useState)(null),[f,C]=(0,Me.useState)(null),y=(0,Me.useRef)(null),h=(0,Me.useRef)(!1),b=(0,Me.useRef)(null),N=(0,Me.useRef)(null),g=(0,Me.useRef)(null),w=rb(),M=u&&!w,k=(0,Me.useCallback)(()=>{if(!o||!t)return null;let T=null;return o.state.doc.descendants((x,E,v)=>{var P;if(((P=x.attrs)==null?void 0:P.id)===t){let S=0;return v&&v.content.forEach((I,A,H)=>{I===x&&(S=H)}),T={node:x,pos:E,parent:v,index:S},!1}return!0}),T},[t,o]),D=(0,Me.useCallback)(()=>{if(!o)return!1;let T=k();return!T||!T.parent?!1:T.index===T.parent.childCount-1},[o,k]);return(0,Me.useEffect)(()=>{let T=a.current,x=l.current;if(!T)return;let E=mo(ba({element:T,dragHandle:x||void 0,getInitialData:()=>{var A,H,R,B,_,V;let v=k(),P="text";if(v){let W=v.node;switch(W.type.name){case"heading":P="heading";break;case"paragraph":P="text";break;case"imageBlock":P="image";break;case"divider":P=(A=W.attrs)!=null&&A.spacer?"spacer":"divider";break;case"button":P="button";break;case"customCode":P="customCode";break;case"column":P="column";break}}let S=(v==null?void 0:v.parent)===o.state.doc,I=((H=v==null?void 0:v.parent)==null?void 0:H.type.name)==="columnCell";return{id:t,type:S?"editor":I?"column-cell-item":"nested-drag",index:(R=v==null?void 0:v.index)!=null?R:0,dragType:P,pos:v==null?void 0:v.pos,originalIndex:(B=v==null?void 0:v.index)!=null?B:0,columnId:I?(_=v==null?void 0:v.parent)==null?void 0:_.attrs.columnId:void 0,cellIndex:I?(V=v==null?void 0:v.parent)==null?void 0:V.attrs.index:void 0}},onGenerateDragPreview:()=>{let v=T.querySelectorAll("[data-no-drag-preview]"),P=[];v.forEach((S,I)=>{let A=S;P[I]=A.style.display,A.style.display="none"}),requestAnimationFrame(()=>{v.forEach((S,I)=>{let A=S;A.style.display=P[I]})})},onDragStart:()=>{d(!0),document.body.style.cursor="grabbing";let v=s(P=>{N.current=P.clientY},"handleMouseMove");document.addEventListener("mousemove",v),g.current=()=>{document.removeEventListener("mousemove",v)},o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{d(!1),document.body.style.cursor="",g.current&&(g.current(),g.current=null),o&&o.setEditable(!0)}}),yr({element:T,getData:({input:v,element:P})=>{var V,W,O,Y;let S=k(),I=(S==null?void 0:S.parent)===o.state.doc,A=((V=S==null?void 0:S.parent)==null?void 0:V.type.name)==="columnCell",H={id:t,type:I?"editor":A?"column-cell-item":"nested-drag",index:(W=S==null?void 0:S.index)!=null?W:0,pos:S==null?void 0:S.pos,nodeType:S==null?void 0:S.node.type.name,columnId:A?(O=S==null?void 0:S.parent)==null?void 0:O.attrs.columnId:void 0,cellIndex:A?(Y=S==null?void 0:S.parent)==null?void 0:Y.attrs.index:void 0};if(P.getAttribute("data-node-type")==="column"){let re=P.getBoundingClientRect(),Q=v.clientY,F=30,$=Math.abs(Q-re.top),fe=Math.abs(Q-re.bottom);if($>F&&fe>F)return{...H,disableDropIndicator:!0}}let B=P.closest('[data-column-cell="true"]');if(D()&&T){let re=T.getBoundingClientRect(),Q=v.clientY,F=re.top+re.height/2;if(Q>=F&&Q>re.bottom)return{...H,[Symbol.for("closestEdge")]:"bottom"}}let _=D()?["top","bottom"]:["top"];return ef(H,{input:v,element:P,allowedEdges:_})},canDrop:({source:v})=>v.data.id!==t,onDragEnter:({self:v,source:P,location:S})=>{var W,O,Y,re,Q;if(v.data.disableDropIndicator){m(null);return}b.current&&(clearTimeout(b.current),b.current=null);let I=S.current.dropTargets;if(I.length>0&&I[0].element!==T){m(null),h.current=!1,y.current=null;return}let A=ya(v.data),H=A,R=D(),B=(Y=(O=(W=S==null?void 0:S.current)==null?void 0:W.input)==null?void 0:O.clientY)!=null?Y:N.current;B!==null&&(N.current=B);let _=P.data;C(_.dragType||null),A==="bottom"&&R&&P.data.id===t&&(H=null);let V=P.data.type==="editor"||P.data.type==="column-cell-item";if(R&&V)if(A==="top"){let F=a.current;if(F){let $=F.getBoundingClientRect(),fe=(re=B!=null?B:N.current)!=null?re:$.top+$.height/2,be=$.top+$.height/2,Te=$.height,De=Math.max(10,Math.min(30,Te*.3));fe<be-De?(h.current=!1,H="top"):h.current?H="bottom":H="top"}else h.current=!1,H="top"}else h.current?H="bottom":A==="bottom"&&(h.current=!0,H="bottom");else R&&!V&&(h.current=!1);if(!h.current&&(P.data.type==="editor"||P.data.type==="column-cell-item")&&typeof P.data.index=="number"){let F=P.data.index,$=k();((Q=$==null?void 0:$.index)!=null?Q:0)===F+1&&A==="top"&&(H=null)}H!==y.current&&(y.current=H,m(H))},onDrag:({self:v,source:P,location:S})=>{var W,O,Y,re,Q;if(v.data.disableDropIndicator){m(null);return}b.current&&(clearTimeout(b.current),b.current=null);let I=S.current.dropTargets;if(I.length>0&&I[0].element!==T){m(null);return}let A=(Y=(O=(W=S==null?void 0:S.current)==null?void 0:W.input)==null?void 0:O.clientY)!=null?Y:N.current;A!==null&&(N.current=A);let H=ya(v.data),R=H,B=D(),_=P.data;C(_.dragType||null),H==="bottom"&&B&&P.data.id===t&&(R=null);let V=P.data.type==="editor"||P.data.type==="column-cell-item";if(B&&V)if(H==="top"){let F=a.current;if(F){let $=F.getBoundingClientRect(),fe=(re=A!=null?A:N.current)!=null?re:$.top+$.height/2,be=$.top+$.height/2,Te=$.height,De=Math.max(10,Math.min(30,Te*.3));fe<be-De?(h.current=!1,R="top"):h.current?R="bottom":R="top"}else h.current=!1,R="top"}else h.current?R="bottom":H==="bottom"&&(h.current=!0,R="bottom");else B&&!V&&(h.current=!1);if(!h.current&&(P.data.type==="editor"||P.data.type==="column-cell-item")&&typeof P.data.index=="number"){let F=P.data.index,$=k();((Q=$==null?void 0:$.index)!=null?Q:0)===F+1&&H==="top"&&(R=null)}R!==y.current&&(y.current=R,m(R))},onDragLeave:()=>{if(D()&&h.current){let v=T==null?void 0:T.getBoundingClientRect(),P=N.current;if(v&&P!==null&&P>=v.bottom-10)return;b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{h.current=!1,y.current=null,m(null),C(null),b.current=null},150)}else b.current&&(clearTimeout(b.current),b.current=null),h.current=!1,y.current=null,m(null),C(null)},onDrop:()=>{b.current&&(clearTimeout(b.current),b.current=null),h.current=!1,y.current=null,m(null),C(null)}}));return()=>{b.current&&(clearTimeout(b.current),b.current=null),E()}},[t,D,o,k]),(0,Ge.jsx)(ob,{ref:a,id:t,fadeIn:M,className:r,dragging:u,closestEdge:p,dragType:f,handleRef:l,contentRef:c,editor:o,...i,children:e})},"SortableItemWrapper"),ob=(0,Me.forwardRef)(({children:e,className:t,dragOverlay:r,handleRef:o,contentRef:n,closestEdge:i,dragType:a,id:l,editor:c,fadeIn:u,dragging:d,...p},m)=>{(0,Me.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let f=(0,pg.useSetAtom)(Ce),{resetButtonFormatting:C}=Hl(c),y=s((k,D)=>{let T=null;return k.doc.descendants((x,E)=>{var v;return T!==null?!1:((v=x.attrs)==null?void 0:v.id)===D?(T=E,!1):!0}),T},"findNodePositionById"),h=(0,Me.useCallback)(()=>{if(!c||!l)return{node:null,pos:null};let k=y(c.state,l);return k===null?{node:null,pos:null}:{node:c.state.doc.nodeAt(k),pos:k}},[c,l]),b=(0,Me.useCallback)(()=>{c.commands.blur(),f(null)},[c,f]),N=(0,Me.useCallback)(()=>{if(!(!c||!l))try{let{node:k,pos:D}=h();if(!k||D===null)return;let T=k.nodeSize,x=c.state.doc.childCount===1;f(null),c.commands.updateSelectionState(null);let E=c.state.tr;E.delete(D,D+T),E.setMeta("addToHistory",!0),c.view.dispatch(E),x&&setTimeout(()=>{let v=c.state.doc.nodeAt(0);if(v&&v.type.name==="paragraph"&&!v.attrs.id){let P=`node-${(0,fg.v4)()}`,S=c.state.tr;S.setNodeMarkup(0,void 0,{...v.attrs,id:P}),c.view.dispatch(S);let I=new CustomEvent("node-duplicated",{detail:{newNodeId:P}});document.dispatchEvent(I)}},50)}catch(k){console.error("Error deleting node:",k)}},[c,l,h,f]),g=(0,Me.useCallback)(()=>{if(!(!c||!l))try{let{node:k,pos:D}=h();if(!k||D===null)return;if(k.type.name==="button"){C();return}let T=k.type.name==="blockquote";T||b(),setTimeout(()=>{let x=c.chain();if(x.setNodeSelection(D).unsetAllMarks(),T&&k.content&&k.content.firstChild?k.content.firstChild.type.name!=="paragraph"&&x.setParagraph():k.type.name!=="paragraph"&&!T&&x.setParagraph(),x.run(),T){let E=h();E.node&&E.pos!==null&&(f(E.node),c.commands.updateSelectionState(E.node))}},100)}catch(k){console.error("Error removing formatting:",k)}},[c,l,h,b,C,f]),w=(0,Me.useCallback)(()=>{if(!(!c||!l))try{b(),setTimeout(()=>{let{node:k,pos:D}=h();if(!k||D===null)return;let T=k.type.name,x={...k.attrs};delete x.id;let E=D+(k==null?void 0:k.nodeSize);ig(c,T,E,x,v=>f(v),k.content)},100)}catch(k){console.error("Error duplicating node:",k)}},[c,l,h,b,f]),{node:M}=h();return(0,Ge.jsxs)(mg.NodeViewWrapper,{ref:m,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":l,className:L("courier-flex courier-flex-col courier-relative draggable-item",t),...p,children:[i==="top"&&(0,Ge.jsx)(Bl,{type:a}),(0,Ge.jsxs)("div",{className:"courier-flex courier-items-center courier-justify-center courier-gap-2 courier-pl-10",children:[(0,Ge.jsx)(lg,{ref:o,className:"courier-absolute courier-left-[-8px]",tabIndex:-1,"data-no-drag-preview":!0}),(0,Ge.jsx)("div",{ref:n,className:"courier-flex-1 courier-grow draggable-content-wrapper",children:e}),(0,Ge.jsxs)("div",{"data-no-drag-preview":!0,className:L("courier-actions-panel courier-absolute courier-right-[-50px] courier-rounded-lg courier-border courier-border-border courier-bg-background courier-shadow-md courier-hidden courier-items-center courier-justify-center hover:courier-z-[100000]",d&&"!courier-hidden"),children:[(M==null?void 0:M.type.name)!=="imageBlock"&&(M==null?void 0:M.type.name)!=="divider"&&(M==null?void 0:M.type.name)!=="spacer"&&(M==null?void 0:M.type.name)!=="button"&&(M==null?void 0:M.type.name)!=="column"&&(M==null?void 0:M.type.name)!=="customCode"&&(0,Ge.jsxs)(Ge.Fragment,{children:[(0,Ge.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},onClick:k=>{k.stopPropagation(),g()},tabIndex:-1,children:(0,Ge.jsx)(Nu,{color:"currentColor"})}),(0,Ge.jsx)(le,{className:"!courier-my-0"})]}),(0,Ge.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},onClick:k=>{k.stopPropagation(),w()},tabIndex:-1,children:(0,Ge.jsx)(su,{color:"currentColor"})}),(0,Ge.jsx)(le,{className:"!courier-my-0"}),(0,Ge.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#DC2626] dark:courier-text-red-500 dark:hover:courier-bg-secondary",onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},onClick:k=>{k.stopPropagation(),N()},tabIndex:-1,children:(0,Ge.jsx)(Yi,{color:"currentColor"})})]})]}),i==="bottom"&&(0,Ge.jsx)(Bl,{type:a})]})});var On=require("react/jsx-runtime"),nb=s(({alignment:e,backgroundColor:t,textColor:r,borderRadius:o,padding:n,fontWeight:i,fontStyle:a,children:l})=>(0,On.jsx)("div",{className:"courier-w-full node-element",children:(0,On.jsx)("div",{className:"courier-flex",children:(0,On.jsx)("div",{className:L("courier-inline-flex courier-justify-center courier-cursor-text courier-text-sm courier-leading-tight !courier-my-1",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[e]),style:{backgroundColor:t,color:r,borderRadius:`${o}px`,caretColor:r,fontWeight:i,fontStyle:a,padding:`${Number(n)+2}px ${Number(n)+10}px`},children:l})})}),"ButtonComponent"),yg=s(e=>{let t=(0,hg.useSetAtom)(Xe),r=(0,bg.useCallback)(()=>{if(!e.editor.isEditable)return;let o=pt(e);if(o){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,On.jsx)(Rt,{id:e.node.attrs.id,className:L(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,"data-node-type":"button",children:(0,On.jsx)(nb,{...e.node.attrs,children:(0,On.jsx)(gg.NodeViewContent,{as:"span"})})})},"ButtonComponentNode");var vg=require("uuid");var Ke={label:"Button",link:"",alignment:"center",backgroundColor:"#0085FF",borderRadius:0,padding:6,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1,textColor:"#ffffff",borderColor:"transparent"},Ys=Fl.Node.create({name:"button",group:"block",content:"inline*",selectable:!1,isolating:!0,onCreate(){dt(this.editor,this.name)},addAttributes(){return{label:{default:Ke.label,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},link:{default:Ke.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alignment:{default:Ke.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},backgroundColor:{default:Ke.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},textColor:{default:Ke.textColor,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.textColor})},borderRadius:{default:Ke.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:Ke.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},padding:{default:Ke.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.padding})},fontWeight:{default:Ke.fontWeight,parseHTML:e=>e.getAttribute("data-font-weight"),renderHTML:e=>({"data-font-weight":e.fontWeight})},fontStyle:{default:Ke.fontStyle,parseHTML:e=>e.getAttribute("data-font-style"),renderHTML:e=>({"data-font-style":e.fontStyle})},isUnderline:{default:Ke.isUnderline,parseHTML:e=>e.getAttribute("data-is-underline"),renderHTML:e=>({"data-is-underline":e.isUnderline})},isStrike:{default:Ke.isStrike,parseHTML:e=>e.getAttribute("data-is-strike"),renderHTML:e=>({"data-is-strike":e.isStrike})},id:{default:()=>`node-${(0,vg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="button"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Fl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return(0,Cg.ReactNodeViewRenderer)(yg)},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{let{$from:t}=e.state.selection;for(let r=t.depth;r>=0;r--)if(t.node(r).type.name==="button"){let n=t.start(r),i=t.end(r);return e.commands.setTextSelection({from:n,to:i}),!0}return!1}}},addCommands(){return{setButton:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e,content:[{type:"text",text:e.label||"Button"}]}).run()}}});var xg=require("uuid"),nn=require("jotai"),Mt=require("react");var Pi=s(({items:e,setItems:t,editor:r})=>{let[o]=(0,Mt.useState)(null),[n,i]=(0,Mt.useState)(null),[a,l]=(0,Mt.useState)(null),[c]=(0,Mt.useState)("outer"),u=(0,Mt.useRef)([]),d=(0,Mt.useRef)([]),p=(0,nn.useAtomValue)(Be),m=(0,nn.useSetAtom)(Gt),[f,C]=(0,nn.useAtom)(te),y=(0,nn.useSetAtom)(je),h=(0,nn.useAtomValue)(Uo),b=r||p,N=(0,Mt.useCallback)(()=>{if(!b)return;let T=b.getJSON(),x=ue(T),E=ut(f,{channel:h,elements:x});C(E),y(E)},[b,h,f,C,y]),g=(0,Mt.useCallback)(()=>{b==null||b.commands.removeDragPlaceholder(),t(T=>({...T,Editor:T.Editor.filter(x=>!x.toString().includes("_temp"))}))},[b==null?void 0:b.commands,t]),w=(0,Mt.useCallback)(T=>{try{let x=b==null?void 0:b.state.doc;if(!x||T===0)return 0;if(T>=x.childCount)return x.content.size;let E=0;for(let v=0;v<Math.min(T,x.childCount);v++){let P=x.child(v);E+=P.nodeSize}return E}catch(x){return console.error("Error calculating document position:",x),0}},[b==null?void 0:b.state.doc]),M=(0,Mt.useCallback)(T=>{let x={};switch(T){case"text":x=me;break;case"heading":x={};break;case"image":x=lt;break;case"button":x=Ke;break;case"divider":x=xr;break;case"spacer":x=pl;break;case"customCode":x=No;break;case"column":x=Pt;break}let v={type:T==="text"?"paragraph":T==="image"?"imageBlock":T==="spacer"?"divider":T,attrs:{...x,id:(0,xg.v4)()}};return T==="button"&&(v.content=[{type:"text",text:"Button"}]),v},[]),k=(0,Mt.useCallback)((T,x)=>{if(!b)return;let{columnId:E,index:v,isEmpty:P}=x,S=null,I=0,A=-1;if(T.type==="sidebar"){if(!T.dragType)return;S=M(T.dragType)}else if(T.type==="editor"){if(b.state.doc.descendants((V,W)=>V.attrs.id===T.id?(A=W,S=V.toJSON(),I=V.nodeSize,!1):!0),A===-1){let V=e.Editor.findIndex(W=>W===T.id);if(V!==-1){A=w(V);let W=b.state.doc.nodeAt(A);W&&(S=W.toJSON(),I=W.nodeSize)}}if(A!==-1){let V=e.Editor.filter(W=>W!==T.id);V.length!==e.Editor.length&&t({...e,Editor:V})}}if(!S)return;let H=-1,R=null;if(b.state.doc.descendants((V,W)=>V.type.name==="column"&&V.attrs.id===E?(H=W,R=V,!1):!0),H===-1||!R)return;let B=R;A!==-1&&A<H&&(H-=I);let _=b.state.tr;if(A!==-1&&_.delete(A,A+I),P){let V=b.schema,W=Array.from({length:B.attrs.columnsCount},(Y,re)=>V.nodes.columnCell.create({index:re,columnId:E,isEditorMode:!1},re===v?[V.nodeFromJSON(S)]:[])),O=V.nodes.columnRow.create({},W);_.replaceWith(H+1,H+B.nodeSize-1,O)}else{let V=H+1;B.content.forEach(W=>{if(W.type.name==="columnRow"){let O=V+1;W.content.forEach((Y,re,Q)=>{if(Q===v){let F=O+Y.nodeSize-1;_.insert(F,b.schema.nodeFromJSON(S))}O+=Y.nodeSize})}V+=W.nodeSize})}b.view.dispatch(_),N()},[b,e,t,w,M,N]),D=(0,Mt.useCallback)((T,x)=>{try{if(T.type==="sidebar"&&(x.type==="editor"||x.type==="column-cell-item"||x.type==="nested-drag")){let E=T.dragType;if(!E||!b)return;let v=x.insertPos;if(v===void 0)if(x.type==="editor"){let I=x.index+1;v=w(I)}else{console.warn("Nested drop without position data");return}let P=M(E);if(b.commands.insertContentAt(v,P),b.state.doc.resolve(v).depth===0){let I=b.state.doc.resolve(v).index(0),A=[...e.Editor];I<=A.length&&(A.splice(I,0,P.attrs.id),t({...e,Editor:A}))}N();return}if((T.type==="editor"||T.type==="column-cell-item"||T.type==="nested-drag")&&(x.type==="editor"||x.type==="column-cell-item"||x.type==="nested-drag")){if(!b)return;let E=-1,v=null;if(T.pos!==void 0&&(E=T.pos,v=b.state.doc.nodeAt(E)),(E===-1||!v)&&b.state.doc.descendants((A,H)=>A.attrs.id===T.id?(E=H,v=A,!1):!0),E===-1||!v){let A=e.Editor.findIndex(H=>H===T.id);A!==-1&&(E=w(A),v=b.state.doc.nodeAt(E))}if(!v||E===-1)return;let P=x.insertPos;if(P===void 0){let A;x.index===void 0?A=b.state.doc.childCount:x.index===-1?A=0:A=x.index+1,P=w(A)}if(P===void 0||P>E&&P<E+v.nodeSize)return;if(P>E){let A=P-v.nodeSize;b.chain().deleteRange({from:E,to:E+v.nodeSize}).insertContentAt(A,v.toJSON()).run()}else b.chain().insertContentAt(P,v.toJSON()).deleteRange({from:E+v.nodeSize,to:E+v.nodeSize*2}).run();let S=e.Editor.includes(T.id);if(S){let A=e.Editor.filter(H=>H!==T.id);t({...e,Editor:A})}let I=b.state.doc.resolve(P).depth===0;N()}}catch(E){console.error("[Pragmatic DnD] Error in handleDrop:",E)}},[e,b,t,w,N,M]);return(0,Mt.useEffect)(()=>Qu({onDragStart:({source:T})=>{let x=T.data;m(!0),l(x.id),x.dragType&&i(x.dragType);let E=b==null?void 0:b.view.dom.querySelectorAll('[data-node-type="column"]');E&&(u.current=Array.from(E).map(P=>P.getBoundingClientRect()));let v=b==null?void 0:b.view.dom.querySelectorAll("[data-node-view-wrapper]");if(v){let P=new Set,S=Array.from(v).filter(I=>{let A=I,H=A.parentElement;if(H!=null&&H.hasAttribute("data-column-cell"))return!1;let R=A.getBoundingClientRect(),B=R.top+R.height/2;return P.has(Math.round(B))?!1:(P.add(Math.round(B)),!0)});d.current=S.map(I=>I.getBoundingClientRect())}},onDrop:({source:T,location:x})=>{let E=T.data,v=x.current.dropTargets[0];if(!v){g(),m(!1),l(null),i(null);return}let P=v.data;if(P.type==="column-cell"){k(E,P),m(!1),l(null),i(null),g();return}let S=P,I=ya(v.data);if(S.pos!==void 0&&I&&b){let A=b.state.doc.nodeAt(S.pos);A&&(I==="top"?S.insertPos=S.pos:I==="bottom"&&(S.insertPos=S.pos+A.nodeSize))}if(S.insertPos===void 0&&I&&S.index!==void 0){let A=I==="top"?S.index-1:S.index;S={...S,index:A}}else if(S.index===void 0&&S.insertPos===void 0){let H=x.current.input.clientY;if(d.current.length>0){let R=0,B=1/0;d.current.forEach((Y,re)=>{let Q=Y.top+Y.height/2,F=Math.abs(H-Q);F<B&&(B=F,R=re)});let _=d.current[R],V=_.top+_.height/2,O=H>=V?R:R-1;S={...S,index:O,fromCoordinates:!0}}else S={...S,index:(b==null?void 0:b.state.doc.childCount)||0}}D(E,S),m(!1),l(null),i(null),g()}}),[b,m,g,l,i,D,k]),{activeId:a,activeDragType:n,dndMode:c,lastPlaceholderIndex:o,cleanupPlaceholder:g}},"usePragmaticDnd");var Vl=require("react");var Tg=require("jotai");var Ol=s(({setItems:e,rafId:t,editor:r})=>{let o=(0,Tg.useAtomValue)(Be),n=r||o,i=(0,Vl.useCallback)(a=>{t.current&&typeof cancelAnimationFrame!="undefined"&&cancelAnimationFrame(t.current);let l=setTimeout(()=>{if(typeof requestAnimationFrame!="undefined")t.current=requestAnimationFrame(()=>{try{let c=a==null?void 0:a.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(p=>{let m=p,f=m.dataset.id;if(f){let C=m.parentElement,y=!1;for(;C&&C!==c;){if(C.hasAttribute("data-column-cell")){y=!0;break}C=C.parentElement}y||d.push(f)}}),e(p=>({Editor:d,Sidebar:p.Sidebar}))}catch(c){console.error("Error syncing editor items:",c),e(u=>({...u}))}});else try{let c=a==null?void 0:a.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(p=>{let m=p,f=m.dataset.id;if(f){let C=m.parentElement,y=!1;for(;C&&C!==c;){if(C.hasAttribute("data-column-cell")){y=!0;break}C=C.parentElement}y||d.push(f)}}),e(p=>({Editor:d,Sidebar:p.Sidebar}))}catch(c){console.error("Error syncing editor items:",c)}},50);return()=>clearTimeout(l)},[e,t]);return(0,Vl.useEffect)(()=>{if(!n||typeof n.on!="function")return;let a,l=s(()=>{n&&(a&&a(),a=i(n))},"updateItems");n.on("update",l),n.on("selectionUpdate",l),n.on("create",l),n.on("transaction",l),n&&!n.isDestroyed&&l();let c=s(u=>{l()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",c),()=>{n==null||n.off("update",l),n==null||n.off("selectionUpdate",l),n==null||n.off("create",l),n==null||n.off("transaction",l),document.removeEventListener("node-duplicated",c),a&&a(),t.current&&typeof cancelAnimationFrame!="undefined"&&(cancelAnimationFrame(t.current),t.current=null)}},[n,i,t]),{syncEditorItems:i}},"useSyncEditorItems");var ki=require("react/jsx-runtime"),Va=[{type:"text",align:"left",content:`
|
|
189
|
-
`,text_style:"h1"},{type:"text",align:"left",content:""},{type:"image",src:""}],ib=(0,Ee.forwardRef)(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:a,colorScheme:l,hidePreviewPanelExitButton:c,...u},d)=>{let p=(0,nr.useAtomValue)(Be),[m,f]=(0,nr.useAtom)(Ce),[C,y]=(0,nr.useAtom)(pn),h=(0,Ee.useRef)({}),[b,N]=(0,Ee.useState)(c?"desktop":void 0),g=(0,nr.useAtomValue)(it),w=(0,nr.useAtomValue)(ae),M=(0,nr.useAtomValue)(wc),k=(0,nr.useAtomValue)(uo),D=(0,Ee.useRef)(-1),T=(0,nr.useSetAtom)(ap),x=(0,Ee.useRef)(!1),E=(0,Ee.useRef)(!1),[v]=(0,nr.useAtom)(te),P=(0,nr.useAtomValue)(Zr),S=(0,nr.useAtomValue)(Ct),[I,A]=(0,Ee.useState)({Editor:[],Sidebar:["heading","text","image","spacer","divider","button","customCode"]}),H=(0,Ee.useRef)(null);Pi({items:I,setItems:A,editor:p});let{syncEditorItems:R}=Ol({setItems:A,rafId:H,editor:p});(0,Ee.useEffect)(()=>{S&&(E.current=!1)},[S]);let[B,_]=(0,Ee.useState)(!1);(0,Ee.useEffect)(()=>{if(w===!1||w===null){let F=setTimeout(()=>{_(!0)},100);return()=>clearTimeout(F)}else _(!1)},[w,B]),(0,Ee.useEffect)(()=>{if(m){let F=m.type.name,$=bs(F);T({nodeName:F,config:$})}},[m,T]);let V=(0,Ee.useMemo)(()=>{var $,fe,be,Te,De,Lt,gr,se,Oe,Se,Ft,Vt,Hr,Dr,Br,Fr,Bo,Fo,ne,Co,dn,mn,Bi,Fi,Vi,Oi,Wi,_i,X,ie,ge,ke,ze,Vr;if(k)return k;let F=(be=(fe=($=g==null?void 0:g.data)==null?void 0:$.tenant)==null?void 0:fe.brand)==null?void 0:be.settings;return{brandColor:((Te=F==null?void 0:F.colors)==null?void 0:Te.primary)||"#000000",textColor:((De=F==null?void 0:F.colors)==null?void 0:De.secondary)||"#000000",subtleColor:((Lt=F==null?void 0:F.colors)==null?void 0:Lt.tertiary)||"#666666",headerStyle:(se=(gr=F==null?void 0:F.email)==null?void 0:gr.header)!=null&&se.barColor?"border":"plain",logo:(Ft=(Se=(Oe=F==null?void 0:F.email)==null?void 0:Oe.header)==null?void 0:Se.logo)==null?void 0:Ft.image,link:(Dr=(Hr=(Vt=F==null?void 0:F.email)==null?void 0:Vt.header)==null?void 0:Hr.logo)==null?void 0:Dr.href,facebookLink:(Fo=(Bo=(Fr=(Br=F==null?void 0:F.email)==null?void 0:Br.footer)==null?void 0:Fr.social)==null?void 0:Bo.facebook)==null?void 0:Fo.url,linkedinLink:(mn=(dn=(Co=(ne=F==null?void 0:F.email)==null?void 0:ne.footer)==null?void 0:Co.social)==null?void 0:dn.linkedin)==null?void 0:mn.url,instagramLink:(Oi=(Vi=(Fi=(Bi=F==null?void 0:F.email)==null?void 0:Bi.footer)==null?void 0:Fi.social)==null?void 0:Vi.instagram)==null?void 0:Oi.url,mediumLink:(ie=(X=(_i=(Wi=F==null?void 0:F.email)==null?void 0:Wi.footer)==null?void 0:_i.social)==null?void 0:X.medium)==null?void 0:ie.url,xLink:(Vr=(ze=(ke=(ge=F==null?void 0:F.email)==null?void 0:ge.footer)==null?void 0:ke.social)==null?void 0:ze.twitter)==null?void 0:Vr.url}},[k,g]),W=M&&!!V,O=(0,Ee.useCallback)(()=>{Object.values(h.current).forEach(F=>clearTimeout(F)),h.current={}},[]);(0,Ee.useEffect)(()=>()=>{O()},[O]),(0,Ee.useEffect)(()=>{let F=s($=>{if($.key==="Escape"&&(f(null),p==null||p.commands.blur(),D.current=-1),$.key==="Tab"&&p){$.preventDefault();let fe=-1;m&&p.state.doc.content.forEach((De,Lt,gr)=>{m.attrs.id===De.attrs.id&&(fe=gr)}),fe===-1&&(fe=0);let be=p.state.doc,Te;if($.shiftKey?Te=(fe-1+be.childCount)%be.childCount:Te=(fe+1)%be.childCount,Te!==fe||m===null){let De=be.child(Te);f(De),p.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",F),()=>{document.removeEventListener("keydown",F)}},[p,m,f]),(0,Ee.useEffect)(()=>{if(w!==!1||S)return;let F=v!=null?v:"";if(F){let $=Dc(F,"email");y($||"")}setTimeout(()=>{if(!(!p||p.isDestroyed)&&p.state.doc.childCount===1){let $=p.state.doc.child(0);f($)}},0)},[g,w,S,p,y,f,v]),(0,Ee.useEffect)(()=>{w===!1&&g&&!E.current&&(E.current=!0,setTimeout(()=>{p&&!p.isDestroyed&&R(p)},300))},[w,g,p,R]),(0,Ee.useEffect)(()=>(x.current=!0,()=>{x.current=!1}),[]);let Y=(0,Ee.useCallback)(F=>{let fe=F||(b===void 0?"desktop":void 0);N(fe),f(null),fe?p==null||p.setEditable(!1):p==null||p.setEditable(!0)},[p,b,N,f]),re=s(F=>{y(F.target.value)},"handleSubjectChange"),Q=(0,Ee.useMemo)(()=>{if(w!==!1||!B)return null;let F=a&&a.elements&&a.elements.length>0;F&&(E.current=!0);let $;return F&&($=a.elements.find(be=>be.type==="channel"&&be.channel==="email")),$||($={type:"channel",channel:"email",elements:Va}),qe({version:"2022-01-01",elements:[$]},{channel:"email"})},[a,w,B]);return S&&(v===null||Q===null)?null:(0,ki.jsx)(er,{theme:t,colorScheme:l,isLoading:!!w,Header:i?i({hidePublish:e,channels:r,routing:o}):(0,ki.jsx)(Ar,{hidePublish:e,channels:r,routing:o}),...u,children:(0,ki.jsx)(ki.Fragment,{children:n==null?void 0:n({subject:C,handleSubjectChange:re,selectedNode:m,setSelectedNode:f,previewMode:b,templateEditor:p,ref:d,isBrandApply:W,brandSettings:V,items:I,content:Q,syncEditorItems:R,brandEditorContent:P,templateData:g,togglePreviewMode:Y,hidePreviewPanelExitButton:c})})})}),Wl=(0,Ee.memo)(ib);var _l=class _l{};s(_l,"UploadImageAPI"),_l.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 Ld=_l,Rd=Ld;var ir=s(e=>[pd,Sd.StarterKit.configure({document:!1,dropcursor:!1,gapcursor:!1,heading:!1,horizontalRule:!1,paragraph:!1,blockquote:!1,hardBreak:!1,code:!1}),Td.configure({setSelectedNode:e==null?void 0:e.setSelectedNode,shouldHandleClick:e==null?void 0:e.shouldHandleClick}),Pd.HardBreak.configure({keepMarks:!0,HTMLAttributes:{class:"my-line-break"}}),w1,md,xd,td,gd.configure({levels:[1,2,3,4,5,6]}),Ys,el,wd.Color,ol,il,cl,dl,Cd.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),Ad.Underline,Pl.configure(),gl.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(t,r,o)=>{r.forEach(async n=>{let i=await Rd.uploadImage(n);t.chain().setImageBlockAt({pos:o,src:i}).focus().run()})},onPaste:(t,r)=>{r.forEach(async o=>{let n=await Rd.uploadImage(o);return t.chain().setImageBlockAt({pos:t.state.selection.anchor,src:n}).focus().run()})}}),Nd.TextAlign.extend({addKeyboardShortcuts(){return{}}}).configure({types:["paragraph","heading"]}),Md.Typography,kd.Placeholder.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:"",emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",showOnlyWhenEditable:!0}),ed.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),Mn.configure({variables:e==null?void 0:e.variables,disableSuggestions:e==null?void 0:e.disableVariableAutocomplete}),id,An,bl,vl],"ExtensionKit");var Jl=require("@tiptap/react");var Eg=require("jotai"),Wn=require("react");var Ul=s(e=>{let t=(0,Eg.useAtomValue)(Ce),[r,o]=(0,Wn.useState)({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1}),n=(0,Wn.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,Wn.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,Wn.useCallback)(({editor:a})=>{let l=["paragraph","heading","blockquote"],{$head:c}=a.state.selection,u=c.node();if(l.includes(u.type.name)&&u.attrs.isSelected)return!0;for(let d=1;d<=c.depth;d++){let p=c.node(d);if(p.type.name==="blockquote"){if(p.attrs.isSelected)return!0;let m=a.state.selection.from!==a.state.selection.to;if(a.isFocused&&m)return!0}}return!1},[]),...r}},"useTextmenuStates");var Zl=require("jotai"),tt=require("lucide-react"),sr=require("react");var zl=require("react");var Pg=he(require("@tippyjs/react"),1),kg=require("react");var Zt=require("react/jsx-runtime"),wg=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,ab=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-muted-foreground courier-border-b-2";return e==="Mod"?(0,Zt.jsx)("kbd",{className:t,children:wg?"\u2318":"Ctrl"}):e==="Shift"?(0,Zt.jsx)("kbd",{className:t,children:"\u21E7"}):e==="Alt"?(0,Zt.jsx)("kbd",{className:t,children:wg?"\u2325":"Alt"}):(0,Zt.jsx)("kbd",{className:t,children:e})},"ShortcutKey"),Ng=s(({children:e,enabled:t=!0,title:r,shortcut:o,tippyOptions:n={}})=>{let i=Km(),a=(0,kg.useCallback)(l=>{let c=Object.entries(i).reduce((u,[d,p])=>{let m=d.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`);return{...u,[`--${m}`]:p}},{});return(0,Zt.jsxs)("span",{className:L("courier-flex courier-items-center courier-gap-2 courier-px-2.5 courier-py-1 courier-bg-popover courier-text-popover-foreground courier-border courier-border-border courier-rounded-lg courier-shadow-sm courier-z-[999]",i.colorScheme==="dark"?"dark":""),style:c,tabIndex:-1,"data-placement":l["data-placement"],"data-reference-hidden":l["data-reference-hidden"],"data-escaped":l["data-escaped"],children:[r&&(0,Zt.jsx)("span",{className:"courier-text-xs courier-font-medium courier-text-muted-foreground",children:r}),o&&(0,Zt.jsx)("span",{className:"courier-flex courier-items-center courier-gap-0.5",children:o.map(u=>(0,Zt.jsx)(ab,{children:u},u))})]})},[o,r,i]);return t?(0,Zt.jsx)(Pg.default,{...n,delay:500,offset:[0,8],touch:!1,zIndex:99999,appendTo:document.body,trigger:"mouseenter focus",showOnCreate:!1,render:a,animation:!1,children:(0,Zt.jsx)("span",{children:e})}):(0,Zt.jsx)(Zt.Fragment,{children:e})},"Tooltip");var Oa=require("react/jsx-runtime"),Mg=(0,zl.forwardRef)(({shouldShowContent:e=!0,children:t,isVertical:r=!1,className:o,...n},i)=>{let a=L("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,Oa.jsx)(Ed,{className:a,...n,ref:i,children:t})});Mg.displayName="Toolbar";var Ag=(0,zl.forwardRef)(({horizontal:e,className:t,...r},o)=>{let n=L("courier-bg-border",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,Oa.jsx)("div",{className:n,ref:o,...r})});Ag.displayName="Toolbar.Divider";var Sg=(0,zl.forwardRef)(({children:e,buttonSize:t="icon",variant:r="ghost",className:o,tooltip:n,tooltipShortcut:i,...a},l)=>{let c=L("courier-gap-1 courier-min-w-[2rem] courier-w-auto",o),u=(0,Oa.jsx)(Ie,{className:c,variant:r,buttonSize:t,ref:l,...a,children:e});return n?(0,Oa.jsx)(Ng,{title:n,shortcut:i,children:u}):u});Sg.displayName="ToolbarButton";var $l={Wrapper:Mg,Divider:Ag,Button:Sg};var Ig=require("lucide-react"),Lg=require("react");var ar=require("react/jsx-runtime"),sb=s(e=>e.type==="option","isOption"),Rg=s(({options:e,containerRef:t})=>{let r=(0,Lg.useMemo)(()=>e.find(o=>o.type==="option"&&o.isActive()),[e]);return(0,ar.jsxs)(os,{children:[(0,ar.jsx)(ns,{asChild:!0,children:(0,ar.jsxs)(Ie,{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,ar.jsx)(Ig.ChevronDown,{className:"courier-w-3 courier-h-3"})]})}),(0,ar.jsx)(qi,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(sb(o))return(0,ar.jsx)(Ji,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?(0,ar.jsx)(ar.Fragment,{children:o.id==="heading1"?(0,ar.jsx)("h1",{className:"courier-text-2xl courier-font-bold",children:o.label}):o.id==="heading2"?(0,ar.jsx)("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading3"?(0,ar.jsx)("h3",{className:"courier-text-lg courier-font-bold",children:o.label}):o.label}):o.label},o.id)})})]})},"ContentTypePicker");var Hg=require("@tiptap/react");var Dg=s(e=>(0,Hg.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 ct=require("react/jsx-runtime"),lb=(0,sr.memo)($l.Button),cb=(0,sr.memo)(Rg),ql=s(({editor:e,config:t})=>{var D;let r=Ul(e),o=Dg(e),n=(0,sr.useRef)(null),i=(0,Zl.useAtomValue)(ys),a=(0,Zl.useAtomValue)(Ce),l=a==null?void 0:a.type.name,c=(0,Zl.useAtomValue)(ip),[u,d]=(0,sr.useState)(()=>{let{selection:T}=e.state;return{from:T.from,to:T.to,empty:T.empty}});(0,sr.useEffect)(()=>{let T=s(()=>{let{selection:x}=e.state;d({from:x.from,to:x.to,empty:x.empty})},"updateSelection");return e.on("selectionUpdate",T),e.on("transaction",T),()=>{e.off("selectionUpdate",T),e.off("transaction",T)}},[e]);let p=(0,sr.useMemo)(()=>!u.empty&&u.from!==u.to,[u]),m=(0,sr.useMemo)(()=>t||c(l||"",p),[t,c,l,p]),f=Hl(e,m,r),C=s(()=>{let{selection:T}=e.state;if(!(T.empty&&!r.isLink&&!e.can().setLink({href:""})))if(r.isLink){let x=e.state.tr.setMeta("showLinkForm",{from:T.from,to:T.to});e.view.dispatch(x)}else{let x=e.state.tr.setMeta("showLinkForm",{from:T.from,to:T.to});e.view.dispatch(x)}},"handleLinkToggle"),y=s(()=>{if(i.ref){let T=i.ref,x=T.value,E=i.caretPosition||T.selectionStart||0,v=x.substring(0,E),P=x.substring(E),S=`${v}{{${P}`,I=E+2;T.focus();let A=new Event("input",{bubbles:!0,cancelable:!0});if(Object.defineProperty(A,"target",{writable:!1,value:{...T,value:S}}),T.value=S,T.dispatchEvent(A),T.setSelectionRange(I,I),T.getBoundingClientRect()){let R=S.slice(0,I),B=document.createElement("span");B.style.font=window.getComputedStyle(T).font,B.style.whiteSpace="pre-wrap",B.textContent=R,document.body.appendChild(B);let _=B.offsetWidth;document.body.removeChild(B);let V=parseInt(window.getComputedStyle(T).lineHeight),W=R.split(`
|
|
190
|
-
`).length-1,O=new CustomEvent("showVariableSuggestions",{detail:{cursorPosition:{left:Math.min(_%T.offsetWidth,T.offsetWidth-200),top:W*V+30}},bubbles:!0});T.dispatchEvent(O)}return}e.chain().focus().insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()},"handleVariableClick"),h=s((T,x,E,v,P,S,I)=>{let A=m[T];return!A||Array.isArray(A)||A.state==="hidden"?null:(0,ct.jsx)(lb,{tooltip:E,tooltipShortcut:S,onClick:v,active:P,disabled:A.state==="disabled",...I,children:x},T)},"renderButton"),b=s((T,x)=>{let E=T.filter(v=>!!v);return E.length>0?(0,ct.jsx)("div",{className:"courier-flex courier-items-center courier-gap-0.5",children:E},x):null},"renderGroup"),N=b([((D=m.contentType)==null?void 0:D.state)==="enabled"&&(0,ct.jsx)(cb,{options:o,containerRef:n},"content-type")],"content-type-group"),g=b([h("bold",(0,ct.jsx)(tt.Bold,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",f.onBold,r.isBold,["Mod","B"]),h("italic",(0,ct.jsx)(tt.Italic,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",f.onItalic,r.isItalic,["Mod","I"]),h("underline",(0,ct.jsx)(tt.Underline,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",f.onUnderline,r.isUnderline,["Mod","U"]),h("strike",(0,ct.jsx)(tt.Strikethrough,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Strikethrough",f.onStrike,r.isStrike,["Mod","Shift","S"])],"text-style-group"),w=b([h("alignLeft",(0,ct.jsx)(tt.AlignLeft,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",f.onAlignLeft,r.isAlignLeft,["Shift","Mod","L"]),h("alignCenter",(0,ct.jsx)(tt.AlignCenter,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",f.onAlignCenter,r.isAlignCenter,["Shift","Mod","E"]),h("alignRight",(0,ct.jsx)(tt.AlignRight,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",f.onAlignRight,r.isAlignRight,["Shift","Mod","R"]),h("alignJustify",(0,ct.jsx)(tt.AlignJustify,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",f.onAlignJustify,r.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),M=b([h("quote",(0,ct.jsx)(tt.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Quote",f.onQuote,r.isQuote,["Mod","Shift","B"])],"block-style-group"),k=b([h("link",(0,ct.jsx)(tt.Link,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",C,r.isLink,["Mod","K"]),h("variable",(0,ct.jsx)(rp,{width:16}),"Variable",y,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return(0,ct.jsx)($l.Wrapper,{ref:n,className:"courier-border-b rounded-b-none rounded-t-sm !courier-shadow-md courier-justify-center courier-rounded-lg",children:[N,g,w,M,k].filter(Boolean).map((T,x)=>(0,ct.jsxs)(sr.Fragment,{children:[T,x<[N,g,w,M,k].filter(Boolean).length-1&&(0,ct.jsx)($l.Divider,{})]},`item-${x}`))})},"TextMenu");var Hd=require("react/jsx-runtime"),lr=s(({config:e})=>{let{editor:t}=(0,Jl.useCurrentEditor)(),r=Ul(t);return t?(0,Hd.jsx)(Jl.BubbleMenu,{editor:t,tippyOptions:{appendTo:o=>{var n;return(n=o.closest(".bubble-text-menu-container"))!=null?n:o},getReferenceClientRect:()=>{var a,l,c,u;let o=(c=(l=(a=t==null?void 0:t.state)==null?void 0:a.selection)==null?void 0:l.from)!=null?c: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,Hd.jsx)(ql,{editor:t,config:e})}):null},"BubbleTextMenu");var Bg=require("@tiptap/pm/state"),Ni=require("@tiptap/react"),Wa=require("jotai"),Sr=require("react");var At=require("react/jsx-runtime"),ub=s(({value:e,readOnly:t})=>{let{editor:r}=(0,Ni.useCurrentEditor)(),o=(0,Wa.useSetAtom)(Jn),n=(0,Wa.useAtomValue)(ae),i=(0,Sr.useRef)(!1);return(0,Sr.useEffect)(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(Rc(e!=null?e:"")))},[r,e,n,t]),(0,Sr.useEffect)(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),db=s(({variables:e,facebookLink:t,linkedinLink:r,instagramLink:o,mediumLink:n,xLink:i,readOnly:a=!1,value:l,onUpdate:c})=>{let d=(0,Sr.useRef)(!1),p=(0,Wa.useSetAtom)(Ce),m=(0,Sr.useMemo)(()=>({urls:{unsubscribe:!0,preferences:!0},...e}),[e]),f=Ni.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:y})=>{let{state:h,dispatch:b}=y.view;return b(h.tr.setSelection(Bg.TextSelection.create(h.doc,h.selection.$anchor.pos))),p&&p(null),!1}}}});(0,Sr.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let C=(0,Sr.useMemo)(()=>[...ir({variables:m,setSelectedNode:p,disableVariableAutocomplete:!0}),f].filter(y=>y!==void 0),[f,m,p,!0]);return(0,At.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[(0,At.jsxs)(Ni.EditorProvider,{content:Rc(l!=null?l:""),extensions:C,editable:!a,autofocus:!a,onUpdate:c,editorContainerProps:{className:L("courier-py-2 courier-flex-grow",a&&"courier-brand-editor-readonly")},immediatelyRender:!1,children:[(0,At.jsx)(ub,{value:l,readOnly:a}),(0,At.jsx)(lr,{})]}),(0,At.jsxs)("div",{className:"courier-flex courier-justify-end courier-items-center courier-gap-2 courier-mt-3",children:[t&&(0,At.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:(0,At.jsx)(ea,{className:"courier-w-5 courier-h-5"})}),r&&(0,At.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:(0,At.jsx)(oa,{className:"courier-w-5 courier-h-5"})}),o&&(0,At.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:(0,At.jsx)(ra,{className:"courier-w-5 courier-h-5"})}),n&&(0,At.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:(0,At.jsx)(na,{className:"courier-w-5 courier-h-5"})}),i&&(0,At.jsx)("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:(0,At.jsx)(ca,{className:"courier-w-5 courier-h-5"})})]})]})},"BrandFooterComponent"),Mi=(0,Sr.memo)(db);var cr=require("react/jsx-runtime"),Fg=s(({value:e,icon:t,...r})=>(0,cr.jsx)($t,{value:e,...r,className:"!courier-w-10 !courier-h-6 [&_svg]:!courier-size-5 [&_svg]:courier-fill-accent dark:[&_svg]:courier-fill-accent-foreground hover:courier-bg-transparent courier-rounded-sm data-[state=on]:courier-bg-background [&_svg]:data-[state=on]:courier-fill-foreground",children:t}),"PreviewItem"),jl=s(({previewMode:e,togglePreviewMode:t,hideMobileToggle:r=!1,hideExitButton:o=!1,...n})=>(0,cr.jsxs)("div",{...n,className:L("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",n.className),children:[e&&!r&&(0,cr.jsxs)(cr.Fragment,{children:[(0,cr.jsxs)(Nr,{type:"single",value:e,onValueChange:i=>{i!==""&&t(i)},className:"courier-w-full courier-rounded-md !courier-p-0.5 courier-bg-[#3B82F6] !courier-gap-0",children:[(0,cr.jsx)(Fg,{value:"desktop",icon:(0,cr.jsx)(iu,{})}),(0,cr.jsx)(Fg,{value:"mobile",icon:(0,cr.jsx)(vu,{})})]}),!o&&(0,cr.jsx)("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),!o&&(0,cr.jsxs)(Ie,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");var Bd=require("react");function mb(){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,templateEditorContent:null}))}s(mb,"initTestHelpers");function ur(e,t){typeof window!="undefined"&&(mb(),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(ur,"setTestEditor");var Wg=require("@tiptap/core"),_g=require("@tiptap/pm/state"),Kl=require("@tiptap/react"),Ye=require("jotai"),pe=require("react");var Vg=require("@tiptap/react"),Og=require("react");var Ir=s(({value:e,defaultValue:t})=>{let{editor:r}=(0,Vg.useCurrentEditor)();return(0,Og.useEffect)(()=>{if(!r)return;let o=setTimeout(()=>{r.commands.setContent(e||t)},0);return()=>clearTimeout(o)},[r,e,t]),null},"ReadOnlyEditorContent");var go=require("react/jsx-runtime"),pb=s(({value:e})=>{let{editor:t}=(0,Kl.useCurrentEditor)(),[r,o]=(0,Ye.useAtom)(te),n=(0,Ye.useSetAtom)(je),i=(0,Ye.useAtomValue)(pn),a=(0,Ye.useAtomValue)(Ce),l=(0,Ye.useSetAtom)(Be),c=(0,Ye.useSetAtom)(gn),u=(0,pe.useRef)(!1),d=(0,pe.useRef)(),p=(0,Ye.useAtomValue)(ae),m=(0,Ye.useAtomValue)(it),f=(0,pe.useRef)(!1),C=(0,Ye.useAtomValue)(Ct);return(0,pe.useEffect)(()=>{p&&(f.current=!1)},[p]),(0,pe.useEffect)(()=>(c({action:"register",id:"email-subject",fn:s(()=>{var h;if(d.current&&(clearTimeout(d.current),d.current=void 0,t&&i!==null&&p===!1&&!C))try{let b=ue(t.getJSON());if(!b||!Array.isArray(b))return;let N=i;if(!i&&r){let k=(h=r==null?void 0:r.elements)==null?void 0:h.find(D=>D.type==="channel"&&D.channel==="email");k&&(N=$i(k,"email"))}let g=Ur(r,"email",N||"",b),w={elements:g.elements,channel:"email",...g.raw&&{raw:g.raw}},M=ut(r,w);JSON.stringify(r)!==JSON.stringify(M)&&(o(M),n(M))}catch(b){console.error("[FlushSubjectUpdate]",b)}},"flushSubjectUpdate")}),()=>{c({action:"unregister",id:"email-subject"})}),[t,i,p,C,r,o,n,c]),(0,pe.useEffect)(()=>{!t||p!==!1||f.current||!e||(l(t),f.current=!0,t.commands.setContent(e))},[t,e,l,p]),(0,pe.useEffect)(()=>{if(!(!(t&&i!==null)||p!==!1||C)&&!t.isFocused)return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var y;try{let h=ue(t.getJSON());if(!h||!Array.isArray(h))return;let b=i;if(!i&&r){let M=(y=r==null?void 0:r.elements)==null?void 0:y.find(k=>k.type==="channel"&&k.channel==="email");M&&(b=$i(M,"email"))}let N=Ur(r,"email",b||"",h),g={elements:N.elements,channel:"email",...N.raw&&{raw:N.raw}},w=ut(r,g);JSON.stringify(r)!==JSON.stringify(w)&&(o(w),n(w))}catch(h){console.error(h)}},500),()=>{d.current&&clearTimeout(d.current)}},[m,t,i,o,n,p,r,C]),(0,pe.useEffect)(()=>()=>{t&&!t.isDestroyed&&t.setEditable(!0)},[t]),(0,pe.useEffect)(()=>{t&&u.current&&t.commands.updateSelectionState(a)},[t,a]),(0,pe.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]),null},"EditorContent"),fb=s(({value:e,readOnly:t=!1,variables:r,onDestroy:o,onUpdate:n,subject:i})=>{let l=(0,Ye.useSetAtom)(Cs),c=(0,pe.useRef)(),[u,d]=(0,Ye.useAtom)(te),p=(0,Ye.useAtomValue)(pn),m=i!=null?i:p,f=(0,Ye.useSetAtom)(Ce),C=(0,Ye.useAtomValue)(Be),y=(0,Ye.useAtomValue)(Ct),h=(0,Ye.useAtomValue)(Gt),b=(0,Ye.useSetAtom)(gn),N=(0,Ye.useSetAtom)(je),g=(0,pe.useRef)(u),w=(0,pe.useRef)(m),M=(0,pe.useRef)(h);(0,pe.useEffect)(()=>{g.current=u},[u]),(0,pe.useEffect)(()=>{w.current=m},[m]),(0,pe.useEffect)(()=>{M.current=h},[h]),(0,pe.useEffect)(()=>{C==null||C.setEditable(!t)},[t,C]);let k=Wg.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:W})=>{let{state:O,dispatch:Y}=W.view;return Y(O.tr.setSelection(_g.TextSelection.create(O.doc,O.selection.$anchor.pos))),f&&f(null),!1}}}}),D=(0,pe.useCallback)(({editor:W})=>{n==null||n(W),ur("email",W),f&&setTimeout(()=>{f(null)},100)},[f,n]),T=(0,pe.useRef)(),x=(0,pe.useRef)(null),E=(0,pe.useCallback)((W,O)=>{var be;if(y)return;let Y=g.current,re=w.current;if(!Y){let Te={version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:O}]};d(Te),N(Te);return}let Q=Y.elements.find(Te=>Te.type==="channel"&&Te.channel==="email"),F={...Q};F.elements=(be=F.elements)==null?void 0:be.filter(Te=>Te.type!=="meta");let $={type:"channel",channel:"email",elements:O};if(JSON.stringify(F)!==JSON.stringify($)){let Te=re;!re&&Q&&(Te=$i(Q,"email"));let De=Ur(Y,"email",Te||"",O);$.elements=De.elements,De.raw&&($.raw=De.raw);let Lt=ut(Y,$);d(Lt),N(Lt)}n==null||n(W),ur("email",W)},[d,N,n,y]),v=(0,pe.useCallback)(({editor:W})=>{let O=ue(W.getJSON());x.current={editor:W,elemental:O},T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{if(x.current){let{editor:Y,elemental:re}=x.current;E(Y,re),x.current=null}},200)},[E]),P=(0,pe.useCallback)(({editor:W})=>{if(M.current)return;let{selection:O}=W.state,{$anchor:Y}=O,Q=O.$head.marks().find(be=>be.type.name==="link");Q||W.isActive("link")?l({mark:Q}):l(null);let F=Y.depth,$=null,fe=null;for(;F>0;){let be=Y.node(F);!fe&&be.type.name==="blockquote"&&(fe=be),!$&&(be.type.name==="paragraph"||be.type.name==="heading")&&($=be),F--}fe?f(fe):$&&f($)},[l,f]),S=(0,pe.useCallback)(({editor:W,transaction:O})=>{let Y=O==null?void 0:O.getMeta("showLinkForm");if(Y){let{selection:re}=W.state,F=re.$head.marks().find($=>$.type.name==="link");l({mark:F,link:{from:Y.from,to:Y.to}})}},[l]),I=(0,pe.useCallback)(()=>{c.current&&clearTimeout(c.current),T.current&&clearTimeout(T.current),o==null||o(),ur("email",null)},[o]);(0,pe.useEffect)(()=>(b({action:"register",id:"email-content",fn:s(()=>{if(T.current&&(clearTimeout(T.current),T.current=void 0,x.current)){let{editor:O,elemental:Y}=x.current;E(O,Y),x.current=null}},"flushContentUpdate")}),()=>{b({action:"unregister",id:"email-content"})}),[E,b]);let A=(0,pe.useCallback)(W=>{var F;if(M.current)return;let O=(F=W.view)==null?void 0:F.editor;if(!O||!O.isEditable)return;let Y=W.target,re=O.view.posAtDOM(Y,0),Q=O.state.doc.resolve(re).node();Q.type.name==="paragraph"&&f(Q)},[f]),H=(0,pe.useCallback)(()=>!M.current,[]),R=(0,pe.useMemo)(()=>[...ir({variables:r,setSelectedNode:f,shouldHandleClick:H,disableVariableAutocomplete:!0}),k].filter(W=>W!==void 0),[k,r,f,H,!0]),B=e||{type:"doc",content:[{type:"paragraph"}]},_=t?{editable:!1,autofocus:!1}:{editable:!0,autofocus:!0,onCreate:D,onUpdate:v,onSelectionUpdate:P,onTransaction:S},V=(0,pe.useRef)(null);return(0,pe.useEffect)(()=>{let W=V.current;if(!(!W||t))return yr({element:W,getData:()=>({type:"editor",id:"editor-drop-zone"}),canDrop:({source:O})=>O.data.type==="sidebar"?!0:O.data.type==="editor"})},[t]),(0,go.jsx)("div",{ref:V,"data-testid":"email-editor",children:(0,go.jsx)(Kl.EditorProvider,{content:B,extensions:R,..._,onDestroy:I,editorContainerProps:{onClick:A},immediatelyRender:!1,children:t?(0,go.jsx)(Ir,{value:B,defaultValue:Va}):(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(pb,{value:B}),(0,go.jsx)(lr,{})]})})})},"EmailEditor"),Gl=fb;var _a=require("jotai"),Ug=require("lucide-react");var an=require("react");var Yl=require("react/jsx-runtime"),Ai=s(({children:e,id:t,className:r,editor:o})=>(0,Yl.jsx)(gb,{id:t,className:r,editor:o,children:e}),"SideBarSortableItemWrapper"),gb=(0,an.forwardRef)(({children:e,className:t,id:r,editor:o},n)=>{let i=(0,an.useRef)(null),[a,l]=(0,an.useState)(!1);return(0,an.useEffect)(()=>{let c=i.current;if(!(!c||!r))return mo(ba({element:c,getInitialData:()=>({id:r,type:"sidebar",dragType:r}),onDragStart:()=>{l(!0),document.body.style.cursor="grabbing",o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{l(!1),document.body.style.cursor="",o&&o.setEditable(!0)}}))},[r,o]),(0,Yl.jsx)("div",{ref:i,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":r,className:L(t,"courier-relative",a&&"courier-opacity-50 courier-cursor-grabbing"),children:(0,Yl.jsx)("div",{children:e})})});var we=require("react/jsx-runtime"),Xl=s(({items:e,brandEditor:t,label:r,editor:o})=>{var l,c;let n=(0,_a.useAtomValue)(it),i=(0,_a.useSetAtom)(ci),a=(0,_a.useAtomValue)(bt);return(0,we.jsxs)("div",{className:"courier-flex courier-flex-col courier-h-full",children:[(0,we.jsxs)("div",{className:"courier-flex-1",children:[r&&(0,we.jsxs)(we.Fragment,{children:[(0,we.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:r}),(0,we.jsx)(le,{className:"courier-my-4"})]}),(0,we.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(u=>(0,we.jsx)(Ai,{id:u.toString(),editor:o,children:(0,we.jsxs)("div",{className:L("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,we.jsx)(Ug.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),u==="heading"&&(0,we.jsx)(Rs,{draggable:!0}),u==="text"&&(0,we.jsx)(Ko,{draggable:!0}),u==="image"&&(0,we.jsx)(Hs,{draggable:!0}),u==="spacer"&&(0,we.jsx)(Ds,{draggable:!0}),u==="divider"&&(0,we.jsx)(jo,{draggable:!0}),u==="button"&&(0,we.jsx)(Jo,{draggable:!0}),u==="customCode"&&(0,we.jsx)(wa,{draggable:!0}),u==="column"&&(0,we.jsx)(Ls,{draggable:!0})]})},u))})]}),t&&(0,we.jsxs)("div",{className:"courier-mt-auto courier-pt-4",children:[(0,we.jsx)(le,{className:"courier-mb-4 -courier-mx-4"}),(c=(l=n==null?void 0:n.data)==null?void 0:l.tenant)!=null&&c.brand?(0,we.jsx)("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:(0,we.jsx)(Ie,{variant:"link",className:"courier-underline",onClick:()=>i("brand"),disabled:!!a,children:"Edit brand"})}):(0,we.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,we.jsx)("h3",{className:"courier-text-md courier-font-medium courier-text-foreground",children:"Customize brand theme"}),(0,we.jsx)("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),(0,we.jsx)(Ie,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>i("brand"),children:"Customize"})]})]})]})},"SideBar");var zg=require("jotai");var Xr=require("react/jsx-runtime"),Ql=s(({element:e,editor:t,disableVariableAutocomplete:r=!0})=>{var a,l;let o=(0,zg.useAtomValue)(Wu);if(!e)return null;if(o!=null&&o.link||((a=o==null?void 0:o.mark)==null?void 0:a.type.name)==="link"&&((l=e.marks)!=null&&l.some(c=>c.type.name==="link")))return(0,Xr.jsx)(G1,{editor:t,mark:o==null?void 0:o.mark,pendingLink:o==null?void 0:o.link});let n=t==null?void 0:t.isActive("blockquote"),i=s(()=>{if(!t)return;let{$anchor:c}=t.state.selection,u=c.depth;for(;u>0;){let d=c.node(u);if(d.type.name==="blockquote")return d;u--}},"getBlockquoteElement");return(0,Xr.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[e.type.name==="button"&&(0,Xr.jsx)(Bf,{element:e,editor:t,disableVariableAutocomplete:r},e.attrs.id),e.type.name==="divider"&&(0,Xr.jsx)(C1,{element:e,editor:t},e.attrs.id),["paragraph","heading"].includes(e.type.name)&&!n&&(0,Xr.jsx)(D1,{element:e,editor:t},e.attrs.id),e.type.name==="imageBlock"&&(0,Xr.jsx)(Z1,{element:e,editor:t,disableVariableAutocomplete:r},e.attrs.id),e.type.name==="customCode"&&(0,Xr.jsx)(dd,{element:e,editor:t},e.attrs.id),(e.type.name==="blockquote"||e.type.name==="paragraph"&&n||e.type.name==="heading"&&n)&&(0,Xr.jsx)(yf,{element:i()||e,editor:t},e.attrs.id),e.type.name==="column"&&(0,Xr.jsx)(ld,{element:e,editor:t},e.attrs.id)]})},"SideBarItemDetails");var Dd=require("react"),$g=require("jotai");var So=require("react/jsx-runtime"),sn=(0,Dd.forwardRef)(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>(0,So.jsx)("div",{className:L("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})),ln=(0,Dd.forwardRef)(({children:e,className:t,previewMode:r,skipExpanded:o=!1,width:n,...i},a)=>{let[l,c]=(0,$g.useAtom)(so),u=o?!1:l,d=n||"courier-w-64";return r?null:(0,So.jsxs)(So.Fragment,{children:[u&&(0,So.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:()=>c(!1),"aria-hidden":"true"}),(0,So.jsx)("div",{className:L("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch courier-relative",d,t),children:(0,So.jsx)("div",{className:L("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-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 $e=require("react/jsx-runtime"),Fd=(0,Bd.forwardRef)(({children:e,className:t,...r},o)=>(0,$e.jsx)("div",{className:L("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Vd=(0,Bd.forwardRef)(({children:e,previewMode:t,...r},o)=>(0,$e.jsx)("div",{className:L("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})),Zg=s(({variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:a,colorScheme:l,...c})=>{let u=(0,Ua.useAtomValue)(te),d=(0,Ua.useAtomValue)(so),p=(0,Ua.useSetAtom)(so),m=s(()=>{d&&p(!1)},"handleSubjectAreaClick");return(0,$e.jsx)(Wl,{value:u,variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:a,colorScheme:l,render:({subject:f,handleSubjectChange:C,selectedNode:y,setSelectedNode:h,previewMode:b,templateEditor:N,ref:g,isBrandApply:w,brandSettings:M,items:k,content:D,syncEditorItems:T,brandEditorContent:x,templateData:E,togglePreviewMode:v,hidePreviewPanelExitButton:P})=>{var S,I,A,H,R,B;return(0,$e.jsxs)(sn,{previewMode:b,children:[(0,$e.jsxs)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:[(0,$e.jsxs)("div",{className:"courier-bg-background courier-h-12 courier-flex courier-items-center courier-gap-2 courier-px-4 courier-border-b",onClick:m,children:[(0,$e.jsxs)("h4",{className:"courier-text-sm courier-h-[25px] courier-flex courier-items-end courier-pb-px",children:["Subject:"," "]}),(0,$e.jsx)(Ci,{value:f!=null?f:"",onChange:_=>C({target:{value:_}}),onFocus:()=>h(null),variables:Tt(e),className:"!courier-bg-background courier-font-medium courier-flex-1",placeholder:"Write subject...",readOnly:b!==void 0})]}),(0,$e.jsxs)(Fd,{ref:g,children:[(0,$e.jsxs)(Vd,{previewMode:b,children:[w&&(0,$e.jsxs)("div",{className:L("courier-py-5 courier-px-9 courier-pb-0 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(M==null?void 0:M.headerStyle)==="border"&&"courier-pt-6"),children:[(M==null?void 0:M.headerStyle)==="border"&&(0,$e.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:M==null?void 0:M.brandColor}}),(M==null?void 0:M.logo)&&(0,$e.jsx)("img",{src:M.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),D&&(0,$e.jsx)(Gl,{value:D,onUpdate:T,variables:e}),w&&E&&(0,$e.jsx)("div",{className:"courier-py-5 courier-px-9 courier-pt-0 courier-flex courier-flex-col",children:(0,$e.jsx)(Mi,{readOnly:!0,value:x!=null?x:(B=(R=(H=(A=(I=(S=E==null?void 0:E.data)==null?void 0:S.tenant)==null?void 0:I.brand)==null?void 0:A.settings)==null?void 0:H.email)==null?void 0:R.footer)==null?void 0:B.markdown,variables:e,facebookLink:M==null?void 0:M.facebookLink,linkedinLink:M==null?void 0:M.linkedinLink,instagramLink:M==null?void 0:M.instagramLink,mediumLink:M==null?void 0:M.mediumLink,xLink:M==null?void 0:M.xLink})})]}),(0,$e.jsx)(jl,{previewMode:b,togglePreviewMode:v,hideExitButton:P})]})]}),(0,$e.jsx)(ln,{previewMode:b,children:(0,$e.jsx)("div",{className:"courier-p-1 courier-h-full",children:y?(0,$e.jsx)(Ql,{element:y,editor:N}):(0,$e.jsx)(Xl,{items:k.Sidebar,brandEditor:i,label:"Blocks library",editor:N!=null?N:void 0})})})]})},...c})},"EmailLayout");var qg=require("@tiptap/react"),Qr=require("jotai"),rt=require("react");var Od=require("react/jsx-runtime"),za=[{type:"text",content:`
|
|
171
|
+
`}],!o||o.length===0)return r;let l=s(g=>{var P,M,T,R,E,C,x,w,A;if(g.type==="meta")return[];switch(g.type){case"text":if("content"in g){let k=g.text_style==="h1"?1:g.text_style==="h2"?2:null,L={};if(g.padding){let[V,F]=g.padding.replace(/px/g,"").split(" "),O=parseInt(V),B=parseInt(F);!isNaN(O)&&!isNaN(B)&&(L={paddingVertical:O,paddingHorizontal:B})}let S={};if(g.border_size||(P=g.border)!=null&&P.enabled||(M=g.border)!=null&&M.size){let V=g.border_size||((T=g.border)==null?void 0:T.size),F=g.border_color||((R=g.border)==null?void 0:R.color);S={...V&&{borderWidth:parseInt(V)},...F&&{borderColor:F}}}let H=g.content.trim()?fm(g.content):[];return[{type:k?"heading":"paragraph",attrs:{textAlign:g.align||"left",level:k,id:`node-${(0,gr.v4)()}`,...L,...S,...g.background_color&&{backgroundColor:g.background_color},...g.locales&&{locales:g.locales}},content:H}]}return[];case"action":{let L=n==="inbox"?{backgroundColor:"#000000",textColor:"#ffffff",borderColor:"transparent",borderWidth:1,borderRadius:4}:{},S=g.content||"Button",H=[];Lc(S,[],H),H.length===0&&H.push({type:"text",text:S||"Button"});let V=(C=g.border_radius)!=null?C:(E=g.border)==null?void 0:E.radius,F=(x=g.border)==null?void 0:x.color,O;return typeof V=="string"?O=parseInt(V):typeof V=="number"&&(O=V),[{type:"button",content:H,attrs:{label:S,link:g.href,alignment:g.align==="full"?"center":g.align||"center",style:g.style,id:`node-${(0,gr.v4)()}`,...L,...g.background_color&&{backgroundColor:g.background_color},...g.color&&{textColor:g.color},...g.padding&&{padding:parseInt(g.padding)},...O!==void 0&&{borderRadius:O},...F&&{borderColor:F},...g.locales&&{locales:g.locales}}}]}case"quote":{let k="paragraph",L;g.text_style==="h1"?(k="heading",L=1):g.text_style==="h2"?(k="heading",L=2):g.text_style==="subtext"&&(k="heading",L=3);let S={textAlign:g.align||"left",id:`node-${(0,gr.v4)()}`};return L!==void 0&&(S.level=L),[{type:"blockquote",attrs:{textAlign:g.align||"left",id:`node-${(0,gr.v4)()}`,...g.border_color&&{borderColor:g.border_color},...g.border_left_width!==void 0&&{borderLeftWidth:g.border_left_width},...g.padding_horizontal!==void 0&&{paddingHorizontal:g.padding_horizontal},...g.padding_vertical!==void 0&&{paddingVertical:g.padding_vertical},...g.background_color&&{backgroundColor:g.background_color},...g.locales&&{locales:g.locales}},content:[{type:k,attrs:S,content:fm(g.content)}]}]}case"image":{let k={};if(g.width){let H=g.width.endsWith("px"),V=parseInt(g.width.replace(/%|px/,""));if(H&&g.image_natural_width&&g.image_natural_width>0){let F=Math.round(V/g.image_natural_width*100);k.width=Math.max(1,Math.min(100,F)),k.imageNaturalWidth=g.image_natural_width}else k.width=V,g.image_natural_width&&(k.imageNaturalWidth=g.image_natural_width)}let L=g.border_size||((w=g.border)==null?void 0:w.size),S=g.border_color||((A=g.border)==null?void 0:A.color);return[{type:"imageBlock",attrs:{sourcePath:Qa(g.src)?"":g.src,id:`node-${(0,gr.v4)()}`,...g.href&&{link:g.href},...g.align&&{alignment:g.align},...g.alt_text&&{alt:g.alt_text},...k,...L&&{borderWidth:parseInt(L),...S&&{borderColor:S}},...g.locales&&{locales:g.locales}}}]}case"divider":{let k=g.border_width||g.width;return[{type:"divider",attrs:{id:`node-${(0,gr.v4)()}`,...g.color&&{color:g.color},...k&&{size:parseInt(k)},...g.padding&&{padding:parseInt(g.padding)},variant:g.color==="transparent"?"spacer":"divider"}}]}case"html":return[{type:"customCode",attrs:{id:`node-${(0,gr.v4)()}`,code:g.content||"<!-- Add your HTML code here -->",...g.locales&&{locales:g.locales}}}];case"group":{let k=g.elements?g.elements.length:2,L=0,S=0;if(g.padding){let _=g.padding.split(" ");L=parseInt(_[0],10)||0,S=parseInt(_[1]||_[0],10)||0}let H=0,V=0,F="transparent";g.border&&(g.border.size&&(H=parseInt(g.border.size,10)||0),g.border.radius!==void 0&&(V=g.border.radius),g.border.color&&(F=g.border.color));let O=g.background_color||"transparent",B=`node-${(0,gr.v4)()}`,z=g.elements?g.elements.map((_,se)=>{var Z;if(_.type==="text"&&"content"in _&&((Z=_.content)==null?void 0:Z.trim())==="Drag and drop content blocks"&&_.align==="left")return{type:"columnCell",attrs:{index:se,columnId:B,isEditorMode:!1},content:[]};let Y;_.type==="group"&&_.elements?Y=_.elements.flatMap(l):Y=l(_);let D=Y.length>0?Y:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,gr.v4)()}`},content:[]}];return{type:"columnCell",attrs:{index:se,columnId:B,isEditorMode:Y.length>0},content:D}}):[{type:"columnCell",attrs:{index:0,columnId:B,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,gr.v4)()}`},content:[]}]},{type:"columnCell",attrs:{index:1,columnId:B,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,gr.v4)()}`},content:[]}]}];return[{type:"column",attrs:{id:B,columnsCount:Math.min(Math.max(k,1),4),paddingVertical:L,paddingHorizontal:S,backgroundColor:O,borderWidth:H,borderRadius:V,borderColor:F,...g.locales&&{locales:g.locales}},content:[{type:"columnRow",content:z}]}]}default:return[]}},"convertNode"),c=[],u=o.flatMap(l);for(let g=0;g<u.length;g++){let P=u[g],M=u[g+1];if(P.type==="button"&&(M==null?void 0:M.type)==="button"&&n==="inbox"){let T={type:"buttonRow",attrs:{id:`node-${(0,gr.v4)()}`,button1Label:((d=P.attrs)==null?void 0:d.label)||"Button 1",button1Link:((m=P.attrs)==null?void 0:m.link)||"",button1BackgroundColor:((p=P.attrs)==null?void 0:p.backgroundColor)||"#000000",button1TextColor:((f=P.attrs)==null?void 0:f.textColor)||"#ffffff",button2Label:((v=M.attrs)==null?void 0:v.label)||"Button 2",button2Link:((h=M.attrs)==null?void 0:h.link)||"",button2BackgroundColor:((b=M.attrs)==null?void 0:b.backgroundColor)||"#ffffff",button2TextColor:((y=M.attrs)==null?void 0:y.textColor)||"#000000",padding:((N=P.attrs)==null?void 0:N.padding)||6}};c.push(T),g++}else c.push(P)}return{type:"doc",content:c}}s(Ze,"convertElementalToTiptap");function gm(e,t,r){if(!e)return;let o=/{{([^}]+)}}/g,n,i=0;for(;(n=o.exec(e))!==null;){if(n.index>i){let l=e.substring(i,n.index);r.push({type:"text",text:l,...t.length>0&&{marks:t}})}let a=n[1].trim();vt(a)?r.push({type:"variable",attrs:{id:a},...t.length>0&&{marks:t}}):r.push({type:"text",text:n[0],...t.length>0&&{marks:t}}),i=n.index+n[0].length}if(i<e.length){let a=e.substring(i);r.push({type:"text",text:a,...t.length>0&&{marks:t}})}}s(gm,"parseTextWithVariables");function _i(e){var l;if(!e)return[];let t=[{regex:/\{\{([^}]+)\}\}/g,type:"variable"},{regex:/\[([^\]]+)\]\(([^)]+)\)/g,type:"link"},{regex:/\*\*([^*]+)\*\*/g,type:"bold"},{regex:/__([^_]+)__/g,type:"bold"},{regex:/(?<!\*)\*([^*]+)\*(?!\*)/g,type:"italic"},{regex:/(?<!_)_([^_]+)_(?!_)/g,type:"italic"},{regex:/~([^~]+)~/g,type:"strike"},{regex:/\+([^+]+)\+/g,type:"underline"}],r=[];for(let c of t){let u=new RegExp(c.regex.source,c.regex.flags),d;for(;(d=u.exec(e))!==null;)if(c.type==="variable"){let m=d[1].trim();vt(m)&&r.push({start:d.index,end:d.index+d[0].length,text:d[1],type:"variable",attrs:{id:m}})}else c.type==="link"?r.push({start:d.index,end:d.index+d[0].length,text:d[1],type:"link",attrs:{href:d[2]}}):r.push({start:d.index,end:d.index+d[0].length,text:d[1],type:c.type})}r.sort((c,u)=>c.start-u.start);let o=[],n=0;for(let c of r)c.start>=n&&(o.push(c),n=c.end);let i=[],a=0;for(let c of o){if(c.start>a){let u=e.substring(a,c.start);u&&gm(u,[],i)}if(c.type==="variable")i.push({type:"variable",attrs:{id:(l=c.attrs)==null?void 0:l.id}});else if(c.type==="link"){let u=[],d=_i(c.text);u.push(...d),u.forEach(m=>{var p;m.marks=m.marks||[],m.marks.push({type:"link",attrs:{href:(p=c.attrs)==null?void 0:p.href}})}),i.push(...u)}else{let u=_i(c.text);u.forEach(d=>{d.marks=d.marks||[],d.marks.push({type:c.type})}),i.push(...u)}a=c.end}if(a<e.length){let c=e.substring(a);c&&gm(c,[],i)}return i}s(_i,"processMarkdownFormatting");function g2(e){let t=[],r=e.split(/\n/);for(let o of r){if(!o.trim())continue;let n=o.match(/^(#{1,6})\s+(.*)$/);if(n){t.push({type:"heading",attrs:{level:n[1].length,textAlign:"left"},content:_i(n[2])});continue}if(o.startsWith(">")){let a=o.slice(1).trim();t.push({type:"blockquote",attrs:{textAlign:"left"},content:[{type:"paragraph",attrs:{textAlign:"left"},content:_i(a)}]});continue}if(o.match(/^-{3,}$/)){t.push({type:"divider"});continue}let i=o.match(/^!\[(.*?)\]\((.*?)(?:\s+"(.*?)")?\)$/);if(i){t.push({type:"imageBlock",attrs:{sourcePath:i[2],alt:i[1]||"",...i[3]&&{title:i[3]}}});continue}t.push({type:"paragraph",attrs:{textAlign:"left"},content:_i(o)})}return t}s(g2,"parseBlockContent");function Rc(e){return{type:"doc",content:g2(e)}}s(Rc,"convertMarkdownToTiptap");var h2=s(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),ts=s(e=>{var o,n,i,a;if(e.type==="variable")return`{{${(o=e.attrs)==null?void 0:o.id}}}`;let t=e.text||"";if((n=e.marks)!=null&&n.length){let l=e.marks.map(h2).filter(Boolean);t=l.join("")+t+l.reverse().join("")}let r=(i=e.marks)==null?void 0:i.find(l=>l.type==="link");return r&&(t=`[${t}](${(a=r.attrs)==null?void 0:a.href})`),t},"convertTextToMarkdown");function de(e){let t=s(r=>{var o,n,i,a,l,c,u,d,m,p,f,v,h,b,y,N,g,P,M,T,R,E,C,x,w,A,k,L,S,H,V,F,O,B,z,_,se,re,Y,D,Z,ie,Me,$e,Je,pr,fr,le,De,Ae,Bt,Dt,Ir,Lr,Rr,Hr,Ho,Bo,oe,ho,cn,un,Ri,Hi,Bi,Di,Fi,Vi;switch(r.type){case"paragraph":{let X="",ne=r.content||[];for(let We=0;We<ne.length;We++)ne[We].type==="hardBreak"?X+=`
|
|
172
|
+
`:X+=ts(ne[We]);X+=`
|
|
173
|
+
`;let ge={};(o=r.attrs)!=null&&o.borderWidth&&(ge.border_size=`${r.attrs.borderWidth}px`),(n=r.attrs)!=null&&n.borderColor&&(ge.border_color=r.attrs.borderColor),((i=r.attrs)==null?void 0:i.paddingVertical)!==void 0&&((a=r.attrs)==null?void 0:a.paddingHorizontal)!==void 0&&(ge.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(l=r.attrs)!=null&&l.backgroundColor&&(ge.background_color=r.attrs.backgroundColor),ge.type="text",ge.align=((c=r.attrs)==null?void 0:c.textAlign)||"left",ge.content=X;let we=ge;return(u=r.attrs)!=null&&u.locales&&(we.locales=r.attrs.locales),[we]}case"heading":{let X="",ne=r.content||[];for(let We=0;We<ne.length;We++)ne[We].type==="hardBreak"?X+=`
|
|
174
|
+
`:X+=ts(ne[We]);X+=`
|
|
175
|
+
`;let ge={};(d=r.attrs)!=null&&d.borderWidth&&(ge.border_size=`${r.attrs.borderWidth}px`),(m=r.attrs)!=null&&m.borderColor&&(ge.border_color=r.attrs.borderColor),ge.text_style=((p=r.attrs)==null?void 0:p.level)===1?"h1":"h2",((f=r.attrs)==null?void 0:f.paddingVertical)!==void 0&&((v=r.attrs)==null?void 0:v.paddingHorizontal)!==void 0&&(ge.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(h=r.attrs)!=null&&h.backgroundColor&&(ge.background_color=r.attrs.backgroundColor),ge.type="text",ge.align=((b=r.attrs)==null?void 0:b.textAlign)||"left",ge.content=X;let we=ge;return(y=r.attrs)!=null&&y.locales&&(we.locales=r.attrs.locales),[we]}case"blockquote":{let X="",ne,ge;if(r.content)for(let We of r.content){if(!ne){if(We.type==="heading"){let Br=(N=We.attrs)==null?void 0:N.level;Br===1?ne="h1":Br===2?ne="h2":ne="subtext"}ge=(g=We.attrs)==null?void 0:g.textAlign}if(We.content)for(let Br of We.content)Br.type==="hardBreak"?X+=`
|
|
176
|
+
`:X+=ts(Br);X+=`
|
|
177
|
+
`}X=X.trim();let we={type:"quote",content:X};return ge&&ge!=="left"&&(we.align=ge),(P=r.attrs)!=null&&P.borderColor&&(we.border_color=r.attrs.borderColor),((M=r.attrs)==null?void 0:M.borderLeftWidth)!==void 0&&(we.border_left_width=r.attrs.borderLeftWidth),((T=r.attrs)==null?void 0:T.paddingHorizontal)!==void 0&&(we.padding_horizontal=r.attrs.paddingHorizontal),((R=r.attrs)==null?void 0:R.paddingVertical)!==void 0&&(we.padding_vertical=r.attrs.paddingVertical),(E=r.attrs)!=null&&E.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(we.background_color=r.attrs.backgroundColor),ne&&(we.text_style=ne),(C=r.attrs)!=null&&C.locales&&(we.locales=r.attrs.locales),[we]}case"imageBlock":{let X={},ne=(x=r.attrs)==null?void 0:x.width,ge=(w=r.attrs)==null?void 0:w.imageNaturalWidth;if(ne&&ge&&ge>0){let We=Math.round(ne/100*ge);X.width=`${We}px`,X.image_natural_width=ge}else ne&&(X.width=`${ne}%`);(A=r.attrs)!=null&&A.borderWidth&&(X.border_size=`${r.attrs.borderWidth}px`),(k=r.attrs)!=null&&k.borderColor&&(X.border_color=r.attrs.borderColor),X.type="image",X.src=((L=r.attrs)==null?void 0:L.sourcePath)||"",(S=r.attrs)!=null&&S.alignment&&(X.align=r.attrs.alignment),(H=r.attrs)!=null&&H.link&&(X.href=r.attrs.link),(V=r.attrs)!=null&&V.alt&&(X.alt_text=r.attrs.alt);let we=X;return(F=r.attrs)!=null&&F.locales&&(we.locales=r.attrs.locales),[we]}case"divider":{let X={type:"divider"};return(O=r.attrs)!=null&&O.color&&(X.color=r.attrs.color),(B=r.attrs)!=null&&B.size&&(X.border_width=`${r.attrs.size}px`),(z=r.attrs)!=null&&z.padding&&(X.padding=`${r.attrs.padding}px 0px`),[X]}case"button":{let X=(se=(_=r.attrs)==null?void 0:_.label)!=null?se:"";r.content&&r.content.length>0&&(X=r.content.map(ts).join(""));let ne={type:"action",content:X,href:(Y=(re=r.attrs)==null?void 0:re.link)!=null?Y:"#"};return(D=r.attrs)!=null&&D.style&&(ne.style=r.attrs.style),ne.align=((Z=r.attrs)==null?void 0:Z.alignment)||"center",(ie=r.attrs)!=null&&ie.backgroundColor&&(ne.background_color=r.attrs.backgroundColor),(Me=r.attrs)!=null&&Me.padding&&(ne.padding=`${r.attrs.padding}px`),($e=r.attrs)!=null&&$e.borderRadius&&(ne.border_radius=`${r.attrs.borderRadius}px`),(Je=r.attrs)!=null&&Je.locales&&(ne.locales=r.attrs.locales),[ne]}case"buttonRow":{let X={type:"action",content:(fr=(pr=r.attrs)==null?void 0:pr.button1Label)!=null?fr:"Button 1",href:(De=(le=r.attrs)==null?void 0:le.button1Link)!=null?De:"#",align:"left"};(Ae=r.attrs)!=null&&Ae.button1BackgroundColor&&(X.background_color=r.attrs.button1BackgroundColor),(Bt=r.attrs)!=null&&Bt.button1TextColor&&(X.color=r.attrs.button1TextColor);let ne={type:"action",content:(Ir=(Dt=r.attrs)==null?void 0:Dt.button2Label)!=null?Ir:"Button 2",href:(Rr=(Lr=r.attrs)==null?void 0:Lr.button2Link)!=null?Rr:"#",align:"left"};return(Hr=r.attrs)!=null&&Hr.button2BackgroundColor&&(ne.background_color=r.attrs.button2BackgroundColor),(Ho=r.attrs)!=null&&Ho.button2TextColor&&(ne.color=r.attrs.button2TextColor),[X,ne]}case"customCode":{let X={type:"html",content:((Bo=r.attrs)==null?void 0:Bo.code)||"<!-- Add your HTML code here -->"};return(oe=r.attrs)!=null&&oe.locales&&(X.locales=r.attrs.locales),[X]}case"column":{let X=((ho=r.attrs)==null?void 0:ho.columnsCount)||2,ne=[],ge=(cn=r.content)==null?void 0:cn.find(Ft=>Ft.type==="columnRow");if(ge&&ge.content){for(let Ft of ge.content)if(Ft.type==="columnCell")if(Ft.content&&Ft.content.length>0){let Ja=Ft.content.flatMap(t);Ja.length===0?ne.push({type:"text",content:`Drag and drop content blocks
|
|
178
|
+
`,align:"left"}):Ja.length===1?ne.push(Ja[0]):ne.push({type:"group",elements:Ja})}else ne.push({type:"text",content:`Drag and drop content blocks
|
|
179
|
+
`,align:"left"})}else for(let Ft=0;Ft<X;Ft++)ne.push({type:"text",content:`Drag and drop content blocks
|
|
180
|
+
`,align:"left"});let we={type:"group"};if((un=r.attrs)!=null&&un.borderWidth&&r.attrs.borderWidth>0){let Ft={};(Ri=r.attrs)!=null&&Ri.borderColor&&(Ft.color=r.attrs.borderColor),Ft.enabled=!0,Ft.size=`${r.attrs.borderWidth}px`,(Hi=r.attrs)!=null&&Hi.borderRadius&&(Ft.radius=r.attrs.borderRadius),we.border=Ft}let We=((Bi=r.attrs)==null?void 0:Bi.paddingVertical)||0,Br=((Di=r.attrs)==null?void 0:Di.paddingHorizontal)||0;return(We>0||Br>0)&&(we.padding=`${We}px ${Br}px`),(Fi=r.attrs)!=null&&Fi.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(we.background_color=r.attrs.backgroundColor),we.elements=ne,(Vi=r.attrs)!=null&&Vi.locales&&(we.locales=r.attrs.locales),[we]}default:return r.content?r.content.flatMap(t):[]}},"convertNode");return e!=null&&e.content?e.content.flatMap(t):[]}s(de,"convertTiptapToElemental");function Hc(e){let t="",r="";for(let o of e)if(!("visible"in o&&o.visible===!1)){if(o.type==="meta"&&"title"in o&&o.title)return o.title;if(o.type==="channel"&&"raw"in o&&o.raw){if("subject"in o.raw&&o.raw.subject)return o.raw.subject;if("title"in o.raw&&o.raw.title)return o.raw.title}if(o.type==="text"&&"content"in o&&o.content){let n=o.content.trim();n&&n!==`
|
|
181
|
+
`&&("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=Hc(o.elements);if(n)return n}}return r||t||""}s(Hc,"getTitle");function Bc(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 Hc(r.elements)}return""}s(Bc,"getTitleForChannel");function ut(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(l=>{var c;if(l.type!=="meta")if(l.type==="channel"){let u=l,d=!1;if(n?u.channel===n&&(d=!0):i||(d=!0),d){let m={};if(t.channel&&typeof t.channel=="object")for(let f in t.channel)f!=="type"&&f!=="elements"&&f!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,f)&&(m[f]=t.channel[f]);let p={type:"channel",channel:u.channel,...Object.fromEntries(Object.entries(u).filter(([f])=>!["type","channel","elements"].includes(f))),...m};if(t.elements!==void 0){let f=[],v=t.elements.find(b=>b.type==="meta");if(v)f.push(v);else{let b=(c=u.elements)==null?void 0:c.find(y=>y.type==="meta");b&&f.push(b)}let h=t.elements.filter(b=>b.type!=="meta");f.push(...h),p.elements=f}o.elements.push(p),i=!0}else o.elements.push(l)}else o.elements.push(l)}),n&&!i||!((a=r.elements)!=null&&a.some(l=>l.type==="channel"))&&!i){let l;n?l=n:t.channel&&typeof t.channel=="object"&&t.channel.channel?l=t.channel.channel:l="email";let c={};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)&&(c[d]=t.channel[d]);let u={type:"channel",channel:l,...c};if(t.elements!==void 0){let d=[],m=t.elements.find(f=>f.type==="meta");m&&d.push(m);let p=t.elements.filter(f=>f.type!=="meta");d.push(...p),u.elements=d}o.elements.push(u)}return o}s(ut,"updateElemental");function I(...e){return(0,bm.twMerge)((0,hm.clsx)(e))}s(I,"cn");var ym=require("@radix-ui/react-slot"),Cm=require("class-variance-authority"),vm=require("react"),xm=require("react/jsx-runtime"),rs=(0,Cm.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]",secondary:"courier-text-foreground courier-bg-[#F5F5F5] dark:courier-bg-neutral-700 dark:courier-text-white",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-blue-600 active:courier-bg-blue-700"},{variant:"primary",active:!0,class:"courier-bg-blue-700"},{variant:"secondary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-600 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-[#3B82F6] dark:courier-text-white [&_svg]:dark:courier-text-white"}]}),Se=(0,vm.forwardRef)(({active:e,buttonSize:t="medium",disabled:r,variant:o="primary",className:n,asChild:i=!1,...a},l)=>(0,xm.jsx)(i?ym.Slot:"button",{ref:l,disabled:r,className:I(rs({variant:o,size:t,disabled:r,active:e}),n),...a}));Se.displayName="Button";var Tm=require("react"),Em=require("react/jsx-runtime"),ce=(0,Tm.forwardRef)((e,t)=>(0,Em.jsx)("hr",{...e,ref:t,className:I("courier-my-1 courier-border-border dark:courier-border-neutral-600 courier-w-full",e.className)}));ce.displayName="Divider";var bo=he(require("react"),1),me=he(require("@radix-ui/react-dropdown-menu"),1),Jn=require("lucide-react");var it=require("react/jsx-runtime"),os=me.Root,ns=me.Trigger;var b2=bo.forwardRef(({className:e,inset:t,children:r,...o},n)=>(0,it.jsxs)(me.SubTrigger,{ref:n,className:I("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,it.jsx)(Jn.ChevronRight,{className:"courier-ml-auto"})]}));b2.displayName=me.SubTrigger.displayName;var y2=bo.forwardRef(({className:e,...t},r)=>(0,it.jsx)(me.SubContent,{ref:r,className:I("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}));y2.displayName=me.SubContent.displayName;var zi=bo.forwardRef(({className:e,sideOffset:t=4,portalProps:r,...o},n)=>(0,it.jsx)(me.Portal,{...r,children:(0,it.jsx)(me.Content,{ref:n,sideOffset:t,className:I("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})}));zi.displayName=me.Content.displayName;var $i=bo.forwardRef(({className:e,inset:t,...r},o)=>(0,it.jsx)(me.Item,{ref:o,className:I("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}));$i.displayName=me.Item.displayName;var C2=bo.forwardRef(({className:e,children:t,checked:r,...o},n)=>(0,it.jsxs)(me.CheckboxItem,{ref:n,className:I("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,it.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,it.jsx)(me.ItemIndicator,{children:(0,it.jsx)(Jn.Check,{className:"courier-h-4 courier-w-4"})})}),t]}));C2.displayName=me.CheckboxItem.displayName;var v2=bo.forwardRef(({className:e,children:t,...r},o)=>(0,it.jsxs)(me.RadioItem,{ref:o,className:I("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,it.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,it.jsx)(me.ItemIndicator,{children:(0,it.jsx)(Jn.Circle,{className:"courier-h-2 courier-w-2 courier-fill-current"})})}),t]}));v2.displayName=me.RadioItem.displayName;var x2=bo.forwardRef(({className:e,inset:t,...r},o)=>(0,it.jsx)(me.Label,{ref:o,className:I("courier-px-2 courier-py-1.5 courier-text-sm courier-font-semibold",t&&"courier-pl-8",e),...r}));x2.displayName=me.Label.displayName;var T2=bo.forwardRef(({className:e,...t},r)=>(0,it.jsx)(me.Separator,{ref:r,className:I("courier-mx-1 courier-my-1 courier-h-px courier-bg-muted",e),...t}));T2.displayName=me.Separator.displayName;var E2=s(({className:e,...t})=>(0,it.jsx)("span",{className:I("courier-ml-auto courier-text-xs courier-tracking-widest courier-opacity-60",e),...t}),"DropdownMenuShortcut");E2.displayName="DropdownMenuShortcut";var wm=require("react");var jn=require("react/jsx-runtime"),Dc=class Dc extends wm.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,jn.jsx)(w2,{error:this.state.error}):this.props.children}};s(Dc,"ErrorBoundary");var is=Dc,w2=s(({error:e})=>(0,jn.jsxs)("div",{className:"courier-p-6 courier-border courier-border-red-200 courier-bg-red-50 courier-rounded-lg courier-text-center",children:[(0,jn.jsx)("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),(0,jn.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 Mm=require("@radix-ui/react-slot"),Gt=he(require("react"),1),Gn=require("react-hook-form");var Fc=he(require("@radix-ui/react-label"),1),km=require("class-variance-authority"),Pm=he(require("react"),1),Nm=require("react/jsx-runtime"),k2=(0,km.cva)("courier-text-sm courier-font-medium courier-leading-none peer-disabled:courier-cursor-not-allowed peer-disabled:courier-opacity-70"),Vc=Pm.forwardRef(({className:e,...t},r)=>(0,Nm.jsx)(Fc.Root,{ref:r,className:I(k2(),e),...t}));Vc.displayName=Fc.Root.displayName;var yo=require("react/jsx-runtime"),qe=Gn.FormProvider,Am=Gt.createContext({}),j=s(({...e})=>(0,yo.jsx)(Am.Provider,{value:{name:e.name},children:(0,yo.jsx)(Gn.Controller,{...e})}),"FormField"),as=s(()=>{let e=Gt.useContext(Am),t=Gt.useContext(Sm),{getFieldState:r,formState:o}=(0,Gn.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"),Sm=Gt.createContext({}),q=Gt.forwardRef(({className:e,...t},r)=>{let o=Gt.useId();return(0,yo.jsx)(Sm.Provider,{value:{id:o},children:(0,yo.jsx)("div",{ref:r,className:I("courier-space-y-2",e),...t})})});q.displayName="FormItem";var ao=Gt.forwardRef(({className:e,...t},r)=>{let{error:o,formItemId:n}=as();return(0,yo.jsx)(Vc,{ref:r,className:I(o&&"courier-text-destructive",e),htmlFor:n,...t})});ao.displayName="FormLabel";var J=Gt.forwardRef(({...e},t)=>{let{error:r,formItemId:o,formDescriptionId:n,formMessageId:i}=as();return(0,yo.jsx)(Mm.Slot,{ref:t,id:o,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...e})});J.displayName="FormControl";var P2=Gt.forwardRef(({className:e,...t},r)=>{let{formDescriptionId:o}=as();return(0,yo.jsx)("p",{ref:r,id:o,className:I("courier-text-[0.8rem] courier-text-muted-foreground",e),...t})});P2.displayName="FormDescription";var G=Gt.forwardRef(({className:e,children:t,...r},o)=>{let{error:n,formMessageId:i}=as(),a=n?String(n==null?void 0:n.message):t;return a?(0,yo.jsx)("p",{ref:o,id:i,className:I("courier-text-[0.8rem] courier-font-medium courier-text-destructive",e),...r,children:a}):null});G.displayName="FormMessage";var Fe=he(require("@radix-ui/react-alert-dialog"),1),fn=he(require("react"),1);var Im=require("react");var hr=require("react/jsx-runtime"),Lm=Fe.Root,Rm=Fe.Trigger,N2=Fe.Portal,Hm=fn.forwardRef(({className:e,...t},r)=>(0,hr.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,hr.jsx)(Fe.Overlay,{asChild:!0,className:I("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})}));Hm.displayName=Fe.Overlay.displayName;var Oc=fn.forwardRef(({className:e,...t},r)=>{let o=(0,Im.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,hr.jsxs)(N2,{container:typeof window!="undefined"?o():void 0,children:[(0,hr.jsx)(Hm,{}),(0,hr.jsx)(Fe.Content,{ref:r,className:I("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})]})});Oc.displayName=Fe.Content.displayName;var Uc=s(({className:e,...t})=>(0,hr.jsx)("div",{className:I("courier-flex courier-flex-col courier-space-y-2 courier-text-center sm:courier-text-left",e),...t}),"AlertDialogHeader");Uc.displayName="AlertDialogHeader";var Wc=s(({className:e,...t})=>(0,hr.jsx)("div",{className:I("courier-flex courier-flex-col-reverse sm:courier-flex-row sm:courier-justify-end sm:courier-space-x-2",e),...t}),"AlertDialogFooter");Wc.displayName="AlertDialogFooter";var M2=fn.forwardRef(({className:e,...t},r)=>(0,hr.jsx)(Fe.Title,{ref:r,className:I("courier-text-lg courier-font-semibold",e),...t}));M2.displayName=Fe.Title.displayName;var A2=fn.forwardRef(({className:e,...t},r)=>(0,hr.jsx)(Fe.Description,{ref:r,className:I("courier-text-sm courier-text-muted-foreground",e),...t}));A2.displayName=Fe.Description.displayName;var _c=fn.forwardRef(({className:e,...t},r)=>(0,hr.jsx)(Fe.Action,{ref:r,className:I(rs(),e),...t}));_c.displayName=Fe.Action.displayName;var zc=fn.forwardRef(({className:e,...t},r)=>(0,hr.jsx)(Fe.Cancel,{ref:r,className:I(rs({variant:"outline"}),"courier-mt-2 sm:courier-mt-0",e),...t}));zc.displayName=Fe.Cancel.displayName;var Bm=he(require("react"),1),Kn=require("react/jsx-runtime"),be=Bm.forwardRef(({className:e,type:t,startAdornment:r,endAdornment:o,...n},i)=>(0,Kn.jsxs)("div",{className:"courier-relative courier-flex courier-w-full courier-items-center",children:[r&&(0,Kn.jsx)("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),(0,Kn.jsx)("input",{type:t,className:I("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 dark:courier-[color-scheme:dark]",r&&"courier-pl-8",o&&"courier-pr-8",e),ref:i,...n}),o&&(0,Kn.jsx)("div",{className:"courier-absolute courier-right-2 courier-flex courier-items-center courier-pointer-events-none",children:o})]}));be.displayName="Input";var Fo=require("react");var Wt=require("react");var Dm=require("lucide-react");var Kt=require("react/jsx-runtime"),S2=s(e=>e==="transparent"||/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e),"isValidHex"),Fm=s(({color:e,onChange:t,className:r,presetColors:o,defaultValue:n="transparent"})=>{let[i,a]=(0,Wt.useState)(()=>Zi(e)),[l,c]=(0,Wt.useState)(e),u=(0,Wt.useRef)(null),d=(0,Wt.useRef)(null),m=(0,Wt.useRef)(null),p=(0,Wt.useRef)(!1),f=e!==n,v=(0,Wt.useCallback)(g=>{p.current=!0;let P=I2(g);c(P),t(P),p.current=!1},[t]),h=s(g=>P=>{m.current=g,b(P)},"handleMouseDown"),b=(0,Wt.useCallback)(g=>{if(m.current){if(m.current==="gradient"&&u.current){let P=u.current.getBoundingClientRect(),M=Math.max(0,Math.min(1,(g.clientX-P.left)/P.width)),T=Math.max(0,Math.min(1,(g.clientY-P.top)/P.height)),R={...i,s:M*100,v:(1-T)*100};a(R),v(R)}else if(m.current==="hue"&&d.current){let P=d.current.getBoundingClientRect(),M=Math.max(0,Math.min(1,(g.clientX-P.left)/P.width)),T={...i,h:M*360};a(T),v(T)}}},[i,v]),y=(0,Wt.useCallback)(()=>{m.current=null},[]);(0,Wt.useEffect)(()=>{if(m.current)return window.addEventListener("mousemove",b),window.addEventListener("mouseup",y),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",y)}},[b,y]),(0,Wt.useEffect)(()=>{p.current||(a(Zi(e)),c(e))},[e]);let N=s(g=>{let P=g.target.value;if(c(P),S2(P)){let M=Zi(P);a(M),v(M)}},"handleInputChange");return(0,Kt.jsxs)("div",{className:I("w-full",r),children:[(0,Kt.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,Kt.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,Kt.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,Kt.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,Kt.jsxs)("div",{className:"courier-mt-3 courier-relative courier-flex courier-items-center",children:[(0,Kt.jsx)(be,{value:l,onChange:N,placeholder:"#000000",className:"courier-flex-1"}),f&&(0,Kt.jsx)("button",{onClick:g=>{if(g.preventDefault(),n==="transparent"){t("transparent"),c("transparent"),a({h:0,s:0,v:0});return}let P=Zi(n);a(P),v(P)},className:"courier-absolute courier-right-3 courier-flex courier-cursor-pointer courier-items-center courier-justify-center courier-transition-colors",children:(0,Kt.jsx)(Dm.CircleX,{size:14,strokeWidth:1.25})})]}),(0,Kt.jsx)(ce,{className:"courier-my-3"}),(0,Kt.jsx)("div",{className:"courier-flex courier-flex-wrap courier-gap-1",children:o.map(g=>(0,Kt.jsx)("button",{className:I("courier-h-6 courier-w-6 courier-rounded-md courier-border courier-border-input courier-shrink-0",g==="transparent"&&$c),style:{backgroundColor:g==="transparent"?void 0:g},onClick:P=>{if(P.preventDefault(),g==="transparent"){t("transparent"),c("transparent"),a({h:0,s:0,v:0});return}let M=Zi(g);a(M),v(M)}},g))})]})},"ColorPicker");function Zi(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,l=0,c=n===0?0:a/n,u=n;if(n!==i){switch(n){case t:l=(r-o)/a+(r<o?6:0);break;case r:l=(o-t)/a+2;break;case o:l=(t-r)/a+4;break}l/=6}return{h:l*360,s:c*100,v:u*100}}s(Zi,"hexToHsv");function I2({h:e,s:t,v:r}){t/=100,r/=100,e=e%360/360;let o=s(l=>{let c=(l+e*6)%6;return r-r*t*Math.max(0,Math.min(c,4-c,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(l=>l.toString(16).padStart(2,"0")).join("")}`}s(I2,"hsvToHex");var so=he(require("@radix-ui/react-popover"),1),Vm=he(require("react"),1);var Zc=require("react/jsx-runtime"),Om=so.Root,Um=so.Trigger;var qc=Vm.forwardRef(({className:e,align:t="center",side:r="bottom",sideOffset:o=4,collisionPadding:n=10,avoidCollisions:i=!0,portalProps:a,...l},c)=>(0,Zc.jsx)(so.Portal,{...a,children:(0,Zc.jsx)(so.Content,{ref:c,side:r,align:t,sideOffset:o,collisionPadding:n,avoidCollisions:i,className:I("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),...l})}));qc.displayName=so.Content.displayName;var Co=require("react/jsx-runtime"),$c="bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAwSDBWOEg4VjBaIiBmaWxsPSIjRDlEOUQ5Ii8+PHBhdGggZD0iTTE2IDhIOFYxNkgxNlY4WiIgZmlsbD0iI0Q5RDlEOSIvPjwvc3ZnPg==')]",L2=["#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#000000","#525252","#a3a3a3","#ffffff","transparent"],xt=(0,Fo.forwardRef)(({className:e,value:t="",onChange:r,defaultValue:o,transparent:n=!0,presetColors:i=L2,...a},l)=>{let c=t!=="transparent",u=(0,Fo.useRef)(null),d=(0,Fo.useMemo)(()=>n?i:i.filter(p=>p!=="transparent"),[i,n]),m=(0,Fo.useCallback)(()=>{var f;let p=(f=u.current)==null?void 0:f.parentElement;for(;p;){if(p.classList.contains("theme-container"))return p;p=p.parentElement}return document.body},[]);return(0,Co.jsxs)(Om,{children:[(0,Co.jsx)(Um,{asChild:!0,children:(0,Co.jsxs)("div",{className:"courier-relative courier-flex courier-items-center",ref:u,children:[(0,Co.jsx)("div",{className:I("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",c?"":$c),style:{backgroundColor:c?t:void 0}}),(0,Co.jsx)(be,{...a,ref:l,readOnly:!0,type:"text",value:t==="transparent"?"Transparent":t,className:I("courier-relative courier-cursor-pointer courier-pl-8",e)})]})}),(0,Co.jsx)(qc,{portalProps:{container:typeof window!="undefined"?m():void 0},className:"courier-w-[230px]",children:(0,Co.jsx)(Fm,{color:t,onChange:r,presetColors:d,defaultValue:o})})]})});xt.displayName="InputColor";var Wm=he(require("react"),1),Jc=he(require("@radix-ui/react-separator"),1);var _m=require("react/jsx-runtime"),jc=Wm.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>(0,_m.jsx)(Jc.Root,{ref:n,decorative:r,orientation:t,className:I("courier-shrink-0 courier-bg-border",t==="horizontal"?"courier-h-[1px] courier-w-full":"courier-h-full courier-w-[1px]",e),...o}));jc.displayName=Jc.Root.displayName;var zm=he(require("react"),1),vo=he(require("@radix-ui/react-slider"),1);var Yn=require("react/jsx-runtime"),Gc=zm.forwardRef(({className:e,...t},r)=>(0,Yn.jsxs)(vo.Root,{ref:r,className:I("courier-relative courier-flex courier-w-full courier-touch-none courier-select-none courier-items-center",e),...t,children:[(0,Yn.jsx)(vo.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:(0,Yn.jsx)(vo.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),(0,Yn.jsx)(vo.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"})]}));Gc.displayName=vo.Root.displayName;var $m=he(require("react"),1),qi=he(require("@radix-ui/react-switch"),1);var Kc=require("react/jsx-runtime"),Xn=$m.forwardRef(({className:e,...t},r)=>(0,Kc.jsx)(qi.Root,{className:I("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,Kc.jsx)(qi.Thumb,{className:I("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")})}));Xn.displayName=qi.Root.displayName;var ss=he(require("react"),1),Wr=he(require("@radix-ui/react-tabs"),1);var us=require("react/jsx-runtime"),ls=Wr.Root,Ji=ss.forwardRef(({className:e,...t},r)=>(0,us.jsx)(Wr.List,{ref:r,className:I("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}));Ji.displayName=Wr.List.displayName;var Qn=ss.forwardRef(({className:e,...t},r)=>(0,us.jsx)(Wr.Trigger,{ref:r,className:I("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}));Qn.displayName=Wr.Trigger.displayName;var cs=ss.forwardRef(({className:e,...t},r)=>(0,us.jsx)(Wr.Content,{ref:r,className:I("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}));cs.displayName=Wr.Content.displayName;var ei=he(require("react"),1);var Zm=require("react/jsx-runtime"),Yc=ei.forwardRef(({className:e,autoResize:t=!1,...r},o)=>{let n=ei.useRef(null),i=s(a=>{n.current=a,typeof o=="function"?o(a):o&&(o.current=a)},"combinedRef");return ei.useEffect(()=>{if(!t)return;let a=n.current;if(!a)return;let l=s(()=>{a.style.height="auto",a.style.height=`${a.scrollHeight}px`},"adjustHeight");return l(),a.addEventListener("input",l),()=>{a.removeEventListener("input",l)}},[t]),(0,Zm.jsx)("textarea",{className:I("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})});Yc.displayName="Textarea";var ms=require("react");var jm=require("react");var ds={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"},qm={...ds},Jm={...ds,colorScheme:"dark",background:"#262626",foreground:"#ffffff",muted:"#48465B",mutedForeground:"#C9C8E1",popover:"#171717",popoverForeground:"#ffffff",border:"#48465B",input:"#48465B",card:"#171717",cardForeground:"#ffffff",primary:"#2E333F",primaryForeground:"#ffffff",secondary:"#2E333F",secondaryForeground:"#C9C8E1",accent:"#0085FF",accentForeground:"#ffffff",destructive:"#FF3363",destructiveForeground:"#ffffff",ring:"#0085FF"};var Xc=(0,jm.createContext)(ds);var Qc=require("react/jsx-runtime"),Gm=(0,ms.forwardRef)(({children:e,theme:t,colorScheme:r,className:o},n)=>{let i=r!=null?r:"light",a=i==="light"?qm:Jm,l=a;t&&(l=typeof t=="string"?t:{...a,...t});let c=typeof t=="string"?{}:Object.entries(l).reduce((u,[d,m])=>{let p=d.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`);return{...u,[`--${p}`]:m}},{});return(0,Qc.jsx)(Xc.Provider,{value:typeof l=="object"?l:{},children:(0,Qc.jsx)("div",{style:c,className:I("courier-flex courier-flex-col courier-relative",typeof t=="string"?t:"","theme-container",i==="dark"?"dark courier-dark":"",o),ref:n,children:e})})}),Km=s(()=>(0,ms.useContext)(Xc),"useTheme");var Ym=he(require("react"),1),eu=he(require("@radix-ui/react-toggle"),1),Xm=require("class-variance-authority");var Qm=require("react/jsx-runtime"),tu=(0,Xm.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 data-[state=on]:dark:courier-text-white [&_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"}}),R2=Ym.forwardRef(({className:e,variant:t,size:r,...o},n)=>(0,Qm.jsx)(eu.Root,{ref:n,className:I(tu({variant:t,size:r,className:e})),...o}));R2.displayName=eu.Root.displayName;var ti=he(require("@radix-ui/react-toggle-group"),1),gn=he(require("react"),1);var ps=require("react/jsx-runtime"),ep=gn.createContext({size:"default",variant:"default"}),Pr=gn.forwardRef(({className:e,variant:t,size:r,children:o,...n},i)=>(0,ps.jsx)(ti.Root,{ref:i,className:I("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:(0,ps.jsx)(ep.Provider,{value:{variant:t,size:r},children:o})}));Pr.displayName=ti.Root.displayName;var _t=gn.forwardRef(({className:e,children:t,variant:r,size:o,...n},i)=>{let a=gn.useContext(ep);return(0,ps.jsx)(ti.Item,{ref:i,className:I(tu({variant:a.variant||r,size:a.size||o}),e),...n,children:t})});_t.displayName=ti.Item.displayName;var fs=require("react/jsx-runtime"),Le=s(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?(0,fs.jsx)("path",{className:I(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):(0,fs.jsx)("path",{className:I(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),$=s(({width:e=28,height:t=28,...r})=>(0,fs.jsx)("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");var ri=require("react/jsx-runtime"),tp=s(({color:e="#000000",width:t=19,height:r=10,...o})=>(0,ri.jsxs)($,{...o,width:t,height:r,children:[(0,ri.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,ri.jsx)("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),(0,ri.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 ru=require("react/jsx-runtime"),ji=s(({color:e="#DC2626",width:t=13,height:r=13,...o})=>(0,ru.jsx)($,{...o,fill:"none",width:t,height:r,children:(0,ru.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 ou=require("react/jsx-runtime"),Gi=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,ou.jsx)($,{...n,width:r,height:o,children:(0,ou.jsx)(Le,{active:t,colorProp:"stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",d:"M1 15V11C1 5.47715 5.47715 1 11 1H15"})}),"BorderRadiusIcon");var oi=require("react/jsx-runtime"),xo=s(({color:e="#A3A3A3",width:t=16,height:r=16,...o})=>(0,oi.jsxs)($,{...o,width:t,height:r,children:[(0,oi.jsx)("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),(0,oi.jsx)("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),(0,oi.jsx)("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");var nu=require("react/jsx-runtime"),iu=s(({color:e,width:t=21,height:r=16,...o})=>(0,nu.jsx)($,{...o,width:t,height:r,children:(0,nu.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 au=require("react/jsx-runtime"),su=s(({color:e="#171717",width:t=12,height:r=13,...o})=>(0,au.jsx)($,{...o,fill:"none",width:t,height:r,children:(0,au.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 lu=require("react/jsx-runtime"),cu=s(({color:e="#404040",width:t=20,height:r=15,viewBox:o="0 0 20 15",...n})=>(0,lu.jsx)($,{...n,width:t,height:r,viewBox:o,children:(0,lu.jsx)("path",{d:"M1.875 0H18.125C19.1406 0 20 0.859375 20 1.875C20 2.5 19.6875 3.04688 19.2188 3.39844L10.7422 9.76562C10.2734 10.1172 9.6875 10.1172 9.21875 9.76562L0.742188 3.39844C0.273438 3.04688 0 2.5 0 1.875C0 0.859375 0.820312 0 1.875 0ZM0 4.375L8.47656 10.7812C9.375 11.4453 10.5859 11.4453 11.4844 10.7812L20 4.375V12.5C20 13.9062 18.8672 15 17.5 15H2.5C1.09375 15 0 13.9062 0 12.5V4.375Z",fill:e})}),"EmailIcon");var uu=require("react/jsx-runtime"),Ki=s(({color:e="#737373",width:t=16,height:r=16,...o})=>(0,uu.jsx)($,{...o,width:t,height:r,children:(0,uu.jsx)(Le,{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 du=require("react/jsx-runtime"),Yi=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,du.jsx)($,{...n,width:r,height:o,children:(0,du.jsx)(Le,{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 mu=require("react/jsx-runtime"),pu=s(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,mu.jsx)($,{...o,width:t,height:r,children:(0,mu.jsx)(Le,{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 fu=require("react/jsx-runtime"),Xi=s(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,fu.jsx)($,{...o,width:t,height:r,children:(0,fu.jsx)("path",{d:"M2 5.75C2 4.38281 3.09375 3.25 4.5 3.25H19.5C20.8672 3.25 22 4.38281 22 5.75V8.25V10.125V10.75V18.25C22 19.6562 20.8672 20.75 19.5 20.75H4.5C3.09375 20.75 2 19.6562 2 18.25V10.75V10.125V8.25V5.75ZM20.125 10.75H3.875V18.25C3.875 18.6016 4.14844 18.875 4.5 18.875H19.5C19.8125 18.875 20.125 18.6016 20.125 18.25V10.75ZM5.75 8.25C6.41406 8.25 7 7.70312 7 7C7 6.33594 6.41406 5.75 5.75 5.75C5.04688 5.75 4.5 6.33594 4.5 7C4.5 7.70312 5.04688 8.25 5.75 8.25ZM10.75 7C10.75 6.33594 10.1641 5.75 9.5 5.75C8.79688 5.75 8.25 6.33594 8.25 7C8.25 7.70312 8.79688 8.25 9.5 8.25C10.1641 8.25 10.75 7.70312 10.75 7ZM13.25 8.25C13.9141 8.25 14.5 7.70312 14.5 7C14.5 6.33594 13.9141 5.75 13.25 5.75C12.5469 5.75 12 6.33594 12 7C12 7.70312 12.5469 8.25 13.25 8.25Z",fill:e})}),"InboxIcon");var gu=require("react/jsx-runtime"),Qi=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,gu.jsx)($,{...n,width:r,height:o,children:(0,gu.jsx)(Le,{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 hu=require("react/jsx-runtime"),ea=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,hu.jsx)($,{...n,width:r,height:o,children:(0,hu.jsx)(Le,{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 bu=require("react/jsx-runtime"),yu=s(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 256 239",...n})=>(0,bu.jsx)($,{...n,width:t,height:r,viewBox:o,children:(0,bu.jsx)("path",{d:"M244.688 89.3027C250.936 89.3028 256 94.367 256 100.614V160.846C256 183.806 237.387 202.419 214.427 202.419H214.23C207.916 202.42 201.932 201.009 196.571 198.491C186.31 221.332 163.63 237.486 136.931 238.14C107.972 237.431 83.7409 218.49 74.9551 192.558H120.063C130.509 192.558 138.977 184.09 138.977 173.645V89.3027H244.688ZM120.082 53.5811C120.127 53.5812 120.172 53.5842 120.217 53.585C125.988 53.6645 130.676 58.2209 130.962 63.9395C130.971 64.1173 130.976 64.2966 130.977 64.4766V173.646C130.976 179.672 126.09 184.558 120.063 184.558H10.9131C4.88618 184.558 9.07128e-05 179.672 0 173.646V64.4941C0 58.4673 4.88624 53.5811 10.9131 53.5811H120.082ZM36.7686 95.125H58.4873V154.541H72.3887V95.125H94.208V83.5986H36.7686V95.125ZM139.907 0C161.279 0.000200803 178.604 17.3254 178.604 38.6973C178.604 60.0693 161.279 77.3953 139.907 77.3955C139.596 77.3955 139.286 77.3901 138.977 77.3828V64.4941C138.976 54.0493 130.509 45.5811 120.063 45.5811H101.82C101.419 43.3471 101.209 41.0467 101.209 38.6973C101.209 17.3253 118.535 0 139.907 0ZM223.256 23.8145C238.052 23.8145 250.047 35.8085 250.047 50.6045C250.047 65.4005 238.052 77.3954 223.256 77.3955C208.46 77.3955 196.465 65.4006 196.465 50.6045C196.465 35.8085 208.46 23.8145 223.256 23.8145Z",fill:e})}),"MSTeamsIcon");var Cu=require("react/jsx-runtime"),ta=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Cu.jsx)($,{...n,width:r,height:o,children:(0,Cu.jsx)(Le,{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 gs=require("react/jsx-runtime"),vu=s(({color:e,width:t=21,height:r=16,...o})=>(0,gs.jsx)($,{...o,width:t,height:r,children:(0,gs.jsx)("g",{transform:"translate(4, 0)",children:(0,gs.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 xu=require("react/jsx-runtime"),Tu=s(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,xu.jsx)($,{...o,width:t,height:r,children:(0,xu.jsx)(Le,{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 Eu=require("react/jsx-runtime"),ra=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Eu.jsx)($,{...n,width:r,height:o,children:(0,Eu.jsx)(Le,{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 wu=require("react/jsx-runtime"),hn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,wu.jsx)($,{...n,width:r,height:o,children:(0,wu.jsx)(Le,{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 oa=require("react/jsx-runtime"),ku=s(({width:e=20,height:t=21,viewBox:r="0 0 20 21",...o})=>(0,oa.jsxs)($,{...o,width:e,height:t,viewBox:r,children:[(0,oa.jsx)("path",{d:"M15 4.625H2.5C2.14844 4.625 1.875 4.9375 1.875 5.25V17.75C1.875 18.1016 2.14844 18.375 2.5 18.375H15C15.3125 18.375 15.625 18.1016 15.625 17.75V5.25C15.625 4.9375 15.3125 4.625 15 4.625ZM2.5 2.75H15C16.3672 2.75 17.5 3.88281 17.5 5.25V17.75C17.5 19.1562 16.3672 20.25 15 20.25H2.5C1.09375 20.25 0 19.1562 0 17.75V5.25C0 3.88281 1.09375 2.75 2.5 2.75Z",fill:"currentColor"}),(0,oa.jsx)("circle",{cx:"2",cy:"2",r:"3",transform:"matrix(-1 0 0 1 17.75 2)",fill:"currentColor",stroke:"white",strokeWidth:"2"})]}),"PushIcon");var Pu=require("react/jsx-runtime"),Nu=s(({color:e="#171717",width:t=16,height:r=13,...o})=>(0,Pu.jsx)($,{...o,fill:"none",width:t,height:r,children:(0,Pu.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 Mu=require("react/jsx-runtime"),Au=s(({color:e="#171717",width:t=11,height:r=12,...o})=>(0,Mu.jsx)($,{...o,width:t,height:r,children:(0,Mu.jsx)(Le,{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 Su=require("react/jsx-runtime"),Iu=s(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,Su.jsx)($,{...o,width:t,height:r,children:(0,Su.jsx)("path",{d:"M6.80469 17.3125C7.3125 16.9219 7.97656 16.8438 8.5625 17.0391C9.57812 17.4297 10.75 17.625 12 17.625C16.8438 17.625 20.125 14.5 20.125 11.375C20.125 8.28906 16.8438 5.125 12 5.125C7.11719 5.125 3.875 8.28906 3.875 11.375C3.875 12.625 4.34375 13.8359 5.24219 14.8906C5.59375 15.2422 5.75 15.75 5.71094 16.2578C5.67188 16.9609 5.47656 17.625 5.28125 18.2109C5.94531 17.8984 6.49219 17.5469 6.80469 17.3125ZM2.82031 18.875C2.89844 18.7969 2.9375 18.6797 3.01562 18.5625C3.40625 17.9375 3.75781 17.0781 3.83594 16.1016C2.66406 14.7734 2 13.1719 2 11.375C2 6.92188 6.45312 3.25 12 3.25C17.5078 3.25 22 6.92188 22 11.375C22 15.8672 17.5078 19.5 12 19.5C10.5156 19.5 9.14844 19.2656 7.89844 18.8359C7.46875 19.1484 6.6875 19.6172 5.78906 20.0078C5.20312 20.2812 4.53906 20.5156 3.83594 20.6328C3.79688 20.6328 3.75781 20.6719 3.75781 20.6719C3.5625 20.7109 3.40625 20.7109 3.21094 20.75C3.01562 20.75 2.82031 20.7891 2.58594 20.7891C2.35156 20.7891 2.11719 20.6328 2.03906 20.3984C1.92188 20.1641 2 19.8906 2.15625 19.6953C2.3125 19.5391 2.46875 19.3828 2.58594 19.1875C2.66406 19.0703 2.74219 18.9922 2.78125 18.9141V18.875H2.82031Z",fill:e})}),"SMSIcon");var Vo=require("react/jsx-runtime"),rp=s(({color:e="#000000",width:t=14,height:r=9,...o})=>(0,Vo.jsx)($,{...o,width:t,height:r,children:(0,Vo.jsxs)("g",{opacity:"0.9",children:[(0,Vo.jsx)("rect",{x:"0.799805",y:"5.92188",width:"2.46154",height:"2.95385",rx:"0.246154",fill:e}),(0,Vo.jsx)("rect",{x:"4.24609",y:"4.44531",width:"2.46154",height:"4.43077",rx:"0.246154",fill:e}),(0,Vo.jsx)("rect",{x:"7.93823",y:"2.72266",width:"2.46154",height:"6.15385",rx:"0.246154",fill:e}),(0,Vo.jsx)("rect",{x:"11.3845",y:"0.753906",width:"2.46154",height:"8.12308",rx:"0.246154",fill:e})]})}),"SignalIcon");var Lu=require("react/jsx-runtime"),Ru=s(({color:e="#404040",width:t=16,height:r=16,...o})=>(0,Lu.jsx)($,{...o,width:t,height:r,children:(0,Lu.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 Hu=require("react/jsx-runtime"),na=s(({color:e="#FFFFFF",width:t=24,height:r=24,...o})=>(0,Hu.jsx)($,{...o,width:t,height:r,viewBox:"0 0 24 24",children:(0,Hu.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 Bu=require("react/jsx-runtime"),ia=s(({color:e="#A3A3A3",width:t=24,height:r=24,...o})=>(0,Bu.jsx)($,{...o,width:t,height:r,children:(0,Bu.jsx)(Le,{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 Du=require("react/jsx-runtime"),op=s(({width:e=24,height:t=20,...r})=>(0,Du.jsx)($,{...r,width:e,height:t,viewBox:"0 0 24 20",children:(0,Du.jsx)("path",{d:"M6 1H5C4.46957 1 3.96086 1.21071 3.58579 1.58579C3.21071 1.96086 3 2.46957 3 3V8C3 8.53043 2.78929 9.03914 2.41421 9.41421C2.03914 9.78929 1.53043 10 1 10C1.53043 10 2.03914 10.2107 2.41421 10.5858C2.78929 10.9609 3 11.4696 3 12V17C3 18.1 3.9 19 5 19H6M18 19H19C19.5304 19 20.0391 18.7893 20.4142 18.4142C20.7893 18.0391 21 17.5304 21 17V12C21 10.9 21.9 10 23 10C22.4696 10 21.9609 9.78929 21.5858 9.41421C21.2107 9.03914 21 8.53043 21 8V3C21 2.46957 20.7893 1.96086 20.4142 1.58579C20.0391 1.21071 19.5304 1 19 1H18M10 16.5C10 16.7761 9.77614 17 9.5 17C9.22386 17 9 16.7761 9 16.5C9 16.2239 9.22386 16 9.5 16C9.77614 16 10 16.2239 10 16.5ZM15 16.5C15 16.7761 14.7761 17 14.5 17C14.2239 17 14 16.7761 14 16.5C14 16.2239 14.2239 16 14.5 16C14.7761 16 15 16.2239 15 16.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"VariableIcon");var bn=require("react/jsx-runtime"),np=s(({color:e="#000000",width:t=14,height:r=10,...o})=>(0,bn.jsx)($,{...o,width:t,height:r,children:(0,bn.jsxs)("g",{opacity:"0.9",children:[(0,bn.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,bn.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,bn.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 Fu=require("react/jsx-runtime"),aa=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Fu.jsx)($,{...n,width:r,height:o,children:(0,Fu.jsx)(Le,{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 ip=require("lucide-react"),vn=require("react");var hs=require("react/jsx-runtime"),yn=s(({className:e})=>(0,hs.jsx)("div",{className:I("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:(0,hs.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,hs.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");var Cn=require("react/jsx-runtime"),ni=s(({isError:e,isSaving:t,isLoading:r,renderIsSaving:o,renderIsError:n,renderSaved:i})=>{let[a,l]=(0,vn.useState)(!1),c=(0,vn.useRef)(t),u=(0,vn.useRef)(null);return(0,vn.useEffect)(()=>(r||e||t&&t!==c.current?(u.current&&(clearTimeout(u.current),u.current=null),l(!1)):c.current===!0&&t===!1&&!e&&!r&&(l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l(!1),u.current=null},5e3)),c.current=t,()=>{u.current&&clearTimeout(u.current)}),[t,e,r]),r||t===null?null:t?o?o(t):(0,Cn.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,Cn.jsx)(yn,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):(0,Cn.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,Cn.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,Cn.jsx)(ip.CircleCheck,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Saved"]}):null},"Status");var Vu=require("jotai");var xn=require("react/jsx-runtime"),Oo=[{label:"Email",value:"email",icon:(0,xn.jsx)(cu,{})},{label:"SMS",value:"sms",icon:(0,xn.jsx)(Iu,{})},{label:"Push",value:"push",icon:(0,xn.jsx)(ku,{})},{label:"In-app",value:"inbox",icon:(0,xn.jsx)(Xi,{})},{label:"Slack",value:"slack",icon:(0,xn.jsx)(Ru,{})},{label:"Teams",value:"msteams",icon:(0,xn.jsx)(yu,{})}];var Uo=(0,Vu.atom)("email"),ii=(0,Vu.atom)("template");var O5=require("@radix-ui/react-alert-dialog"),Io=require("jotai"),fo=require("react");var Yt=require("jotai");var Ou={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"}},bs=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 H2={paragraph:Ou,heading:Ou},sa=(0,Yt.atom)(H2),ye=(0,Yt.atom)(null),Xe=(0,Yt.atom)(null,(e,t,r)=>{t(ye,r)}),B2=(0,Yt.atom)({ref:null,caretPosition:null}),ys=(0,Yt.atom)({ref:null,caretPosition:null}),la=(0,Yt.atom)({isFocused:!1,hasVariables:!1,showVariablePopup:!1}),ap=(0,Yt.atom)(e=>(t,r=!1)=>{let o=e(sa),n=e(la),i=bs(t,r),a=o[t],l=i;return a&&Object.keys(a).forEach(c=>{var d,m;let u=c;u!=="conditionalRules"&&((d=i[u])==null?void 0:d.state)==="enabled"&&((m=a[u])==null?void 0:m.state)==="enabled"&&(l[u]=a[u])}),n.isFocused&&n.hasVariables&&(l={...l,variable:{state:"enabled"}}),l}),sp=(0,Yt.atom)(null,(e,t,{nodeName:r,config:o})=>{let n=e(sa);t(sa,{...n,[r]:{...n[r],...Object.fromEntries(Object.entries(o).filter(([i])=>i!=="conditionalRules").map(([i,a])=>[i,{state:!Array.isArray(a)&&(a!=null&&a.state)?a.state:"hidden"}]))}})}),Y8=(0,Yt.atom)(null,(e,t,r)=>{let o=e(sa),{[r]:n,...i}=o;t(sa,i)}),lp=(0,Yt.atom)(null,(e,t,{ref:r,caretPosition:o})=>{t(B2,{ref:r,caretPosition:o})}),X8=(0,Yt.atom)(null,(e,t,r)=>{let o=e(la);t(la,{...o,showVariablePopup:r})}),Uu=(0,Yt.atom)(null),Cs=(0,Yt.atom)(null,(e,t,r)=>{t(Uu,r)});var So=require("jotai"),mr=require("react");var Wu=require("jotai"),_r=(0,Wu.atom)(null),lo=(0,Wu.atom)(null);var cp=require("react"),up=require("sonner");var Wo=require("react/jsx-runtime"),Xt=(0,cp.forwardRef)(({theme:e,children:t,isLoading:r,Header:o,colorScheme:n,className:i,...a},l)=>(0,Wo.jsx)(Gm,{theme:e,ref:l,colorScheme:n,className:i,children:(0,Wo.jsxs)("div",{...Object.fromEntries(Object.entries(a).filter(([c])=>c!=="variables"&&c!=="brandEditor")),className:"courier-main-layout",children:[o&&(0,Wo.jsx)("div",{className:"courier-main-header 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-background",children:o}),r&&(0,Wo.jsx)("div",{className:"courier-editor-loading",children:(0,Wo.jsx)(yn,{})}),(0,Wo.jsx)(up.Toaster,{position:"top-center",expand:!0,visibleToasts:2,style:{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)"}}),t]})}));var rr=require("jotai"),xe=require("react");function dp(e){if(Array.isArray(e))return e}s(dp,"_arrayWithHoles");function mp(e,t){var r=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,n,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(o=i.call(r)).done)&&(l.push(o.value),l.length!==t);c=!0);}catch(d){u=!0,n=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw n}}return l}}s(mp,"_iterableToArrayLimit");function ca(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}s(ca,"_arrayLikeToArray");function vs(e,t){if(e){if(typeof e=="string")return ca(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ca(e,t):void 0}}s(vs,"_unsupportedIterableToArray");function pp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
182
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}s(pp,"_nonIterableRest");function xs(e,t){return dp(e)||mp(e,t)||vs(e,t)||pp()}s(xs,"_slicedToArray");var Yp=he(ua());var Es="data-pdnd-honey-pot";function ws(e){return e instanceof Element&&e.hasAttribute(Es)}s(ws,"isHoneyPotElement");function ks(e){var t=document.elementsFromPoint(e.x,e.y),r=xs(t,2),o=r[0],n=r[1];return o?ws(o)?n!=null?n:null:o:null}s(ks,"getElementFromPointWithoutHoneypot");function Tn(e){"@babel/helpers - typeof";return Tn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tn(e)}s(Tn,"_typeof");function hp(e,t){if(Tn(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,t||"default");if(Tn(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}s(hp,"toPrimitive");function bp(e){var t=hp(e,"string");return Tn(t)=="symbol"?t:t+""}s(bp,"toPropertyKey");function To(e,t,r){return(t=bp(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}s(To,"_defineProperty");var ma=he(ua());var yp=2147483647;function Cp(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}s(Cp,"ownKeys");function vp(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Cp(Object(r),!0).forEach(function(o){To(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Cp(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(vp,"_objectSpread");var da=2,xp=da/2;function _2(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}s(_2,"floorToClosestPixel");function z2(e){return{x:e.x-xp,y:e.y-xp}}s(z2,"pullBackByHalfHoneyPotSize");function $2(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}s($2,"preventGoingBackwardsOffScreen");function Z2(e){return{x:Math.min(e.x,window.innerWidth-da),y:Math.min(e.y,window.innerHeight-da)}}s(Z2,"preventGoingForwardsOffScreen");function Tp(e){var t=e.client,r=Z2($2(z2(_2(t))));return DOMRect.fromRect({x:r.x,y:r.y,width:da,height:da})}s(Tp,"getHoneyPotRectFor");function Ep(e){var t=e.clientRect;return{left:"".concat(t.left,"px"),top:"".concat(t.top,"px"),width:"".concat(t.width,"px"),height:"".concat(t.height,"px")}}s(Ep,"getRectStyles");function q2(e){var t=e.client,r=e.clientRect;return t.x>=r.x&&t.x<=r.x+r.width&&t.y>=r.y&&t.y<=r.y+r.height}s(q2,"isWithin");function J2(e){var t=e.initial,r=document.createElement("div");r.setAttribute(Es,"true");var o=Tp({client:t});Object.assign(r.style,vp(vp({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},Ep({clientRect:o})),{},{pointerEvents:"auto",zIndex:yp})),document.body.appendChild(r);var n=(0,ma.bind)(window,{type:"pointermove",listener:s(function(a){var l={x:a.clientX,y:a.clientY};o=Tp({client:l}),Object.assign(r.style,Ep({clientRect:o}))},"listener"),options:{capture:!0}});return s(function(a){var l=a.current;if(n(),q2({client:l,clientRect:o})){r.remove();return}function c(){u(),r.remove()}s(c,"cleanup");var u=(0,ma.bindAll)(window,[{type:"pointerdown",listener:c},{type:"pointermove",listener:c},{type:"focusin",listener:c},{type:"focusout",listener:c},{type:"dragstart",listener:c},{type:"dragenter",listener:c},{type:"dragover",listener:c}],{capture:!0})},"finish")}s(J2,"mountHoneyPot");function wp(){var e=null;function t(){return e=null,(0,ma.bind)(window,{type:"pointermove",listener:s(function(n){e={x:n.clientX,y:n.clientY}},"listener"),options:{capture:!0}})}s(t,"bindEvents");function r(){var o=null;return s(function(i){var a=i.eventName,l=i.payload;if(a==="onDragStart"){var c=l.location.initial.input,u=e!=null?e:{x:c.clientX,y:c.clientY};o=J2({initial:u})}if(a==="onDrop"){var d,m=l.location.current.input;(d=o)===null||d===void 0||d({current:{x:m.clientX,y:m.clientY}}),o=null,e=null}},"onPostEvent")}return s(r,"getOnPostDispatch"),{bindEvents:t,getOnPostDispatch:r}}s(wp,"makeHoneyPotFix");function kp(e){if(Array.isArray(e))return ca(e)}s(kp,"_arrayWithoutHoles");function Pp(e){if(typeof Symbol!="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}s(Pp,"_iterableToArray");function Np(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
183
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}s(Np,"_nonIterableSpread");function Ps(e){return kp(e)||Pp(e)||vs(e)||Np()}s(Ps,"_toConsumableArray");var Dp=he(ua());function Nr(e){var t=null;return s(function(){if(!t){for(var o=arguments.length,n=new Array(o),i=0;i<o;i++)n[i]=arguments[i];var a=e.apply(this,n);t={result:a}}return t.result},"wrapped")}s(Nr,"once");var Mp=Nr(s(function(){return navigator.userAgent.includes("Firefox")},"isFirefox"));var pa=Nr(s(function(){var t=navigator,r=t.userAgent;return r.includes("AppleWebKit")&&!r.includes("Chrome")},"isSafari"));var Ap=he(ua());var zu={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function Sp(e){var t=e.dragLeave;return pa()?t.hasOwnProperty(zu.isLeavingWindow):!1}s(Sp,"isLeavingWindowInSafari");s(function(){if(typeof window=="undefined"||!pa())return;function t(){return{enterCount:0,isOverWindow:!1}}s(t,"getInitialState");var r=t();function o(){r=t()}s(o,"resetState"),(0,Ap.bindAll)(window,[{type:"dragstart",listener:s(function(){r.enterCount=0,r.isOverWindow=!0},"listener")},{type:"drop",listener:o},{type:"dragend",listener:o},{type:"dragenter",listener:s(function(i){!r.isOverWindow&&r.enterCount===0&&(i[zu.isEnteringWindow]=!0),r.isOverWindow=!0,r.enterCount++},"listener")},{type:"dragleave",listener:s(function(i){r.enterCount--,r.isOverWindow&&r.enterCount===0&&(i[zu.isLeavingWindow]=!0,r.isOverWindow=!1)},"listener")}],{capture:!0})},"fixSafari")();function j2(e){return"nodeName"in e}s(j2,"isNodeLike");function Ip(e){return j2(e)&&e.ownerDocument!==document}s(Ip,"isFromAnotherWindow");function Lp(e){var t=e.dragLeave,r=t.type,o=t.relatedTarget;return r!=="dragleave"?!1:pa()?Sp({dragLeave:t}):o==null?!0:Mp()?Ip(o):o instanceof HTMLIFrameElement}s(Lp,"isLeavingWindow");function Rp(e){var t=e.onDragEnd;return[{type:"pointermove",listener:function(){var r=0;return s(function(){if(r<20){r++;return}t()},"listener")}()},{type:"pointerdown",listener:t}]}s(Rp,"getBindingsForBrokenDrags");function En(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}s(En,"getInput");var G2=s(function(t){var r=[],o=null,n=s(function(){for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];r=l,!o&&(o=requestAnimationFrame(function(){o=null,t.apply(void 0,r)}))},"wrapperFn");return n.cancel=function(){o&&(cancelAnimationFrame(o),o=null)},n},"rafSchd"),Hp=G2;var $u=Hp(function(e){return e()}),Ns=function(){var e=null;function t(o){var n=requestAnimationFrame(function(){e=null,o()});e={frameId:n,fn:o}}s(t,"schedule");function r(){e&&(cancelAnimationFrame(e.frameId),e.fn(),e=null)}return s(r,"flush"),{schedule:t,flush:r}}();function Bp(e){var t=e.source,r=e.initial,o=e.dispatchEvent,n={dropTargets:[]};function i(l){o(l),n={dropTargets:l.payload.location.current.dropTargets}}s(i,"safeDispatch");var a={start:s(function(c){var u=c.nativeSetDragImage,d={current:r,previous:n,initial:r};i({eventName:"onGenerateDragPreview",payload:{source:t,location:d,nativeSetDragImage:u}}),Ns.schedule(function(){i({eventName:"onDragStart",payload:{source:t,location:d}})})},"start"),dragUpdate:s(function(c){var u=c.current;Ns.flush(),$u.cancel(),i({eventName:"onDropTargetChange",payload:{source:t,location:{initial:r,previous:n,current:u}}})},"dragUpdate"),drag:s(function(c){var u=c.current;$u(function(){Ns.flush();var d={initial:r,previous:n,current:u};i({eventName:"onDrag",payload:{source:t,location:d}})})},"drag"),drop:s(function(c){var u=c.current,d=c.updatedSourcePayload;Ns.flush(),$u.cancel(),i({eventName:"onDrop",payload:{source:d!=null?d:t,location:{current:u,previous:n,initial:r}}})},"drop")};return a}s(Bp,"makeDispatch");var qu={isActive:!1};function Fp(){return!qu.isActive}s(Fp,"canStart");function K2(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}s(K2,"getNativeSetDragImage");function Y2(e){var t=e.current,r=e.next;if(t.length!==r.length)return!0;for(var o=0;o<t.length;o++)if(t[o].element!==r[o].element)return!0;return!1}s(Y2,"hasHierarchyChanged");function X2(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=e.dispatchEvent;if(!Fp())return;var i=Q2({event:t,dragType:r,getDropTargetsOver:o});qu.isActive=!0;var a={current:i};Zu({event:t,current:i.dropTargets});var l=Bp({source:r.payload,dispatchEvent:n,initial:i});function c(f){var v=Y2({current:a.current.dropTargets,next:f.dropTargets});a.current=f,v&&l.dragUpdate({current:a.current})}s(c,"updateState");function u(f){var v=En(f),h=ws(f.target)?ks({x:v.clientX,y:v.clientY}):f.target,b=o({target:h,input:v,source:r.payload,current:a.current.dropTargets});b.length&&(f.preventDefault(),Zu({event:f,current:b})),c({dropTargets:b,input:v})}s(u,"onUpdateEvent");function d(){a.current.dropTargets.length&&c({dropTargets:[],input:a.current.input}),l.drop({current:a.current,updatedSourcePayload:null}),m()}s(d,"cancel");function m(){qu.isActive=!1,p()}s(m,"finish");var p=(0,Dp.bindAll)(window,[{type:"dragover",listener:s(function(v){u(v),l.drag({current:a.current})},"listener")},{type:"dragenter",listener:u},{type:"dragleave",listener:s(function(v){Lp({dragLeave:v})&&(c({input:a.current.input,dropTargets:[]}),r.startedFrom==="external"&&d())},"listener")},{type:"drop",listener:s(function(v){if(a.current={dropTargets:a.current.dropTargets,input:En(v)},!a.current.dropTargets.length){d();return}v.preventDefault(),Zu({event:v,current:a.current.dropTargets}),l.drop({current:a.current,updatedSourcePayload:r.type==="external"?r.getDropPayload(v):null}),m()},"listener")},{type:"dragend",listener:s(function(v){a.current={dropTargets:a.current.dropTargets,input:En(v)},d()},"listener")}].concat(Ps(Rp({onDragEnd:d}))),{capture:!0});l.start({nativeSetDragImage:K2(t)})}s(X2,"start");function Zu(e){var t,r=e.event,o=e.current,n=(t=o[0])===null||t===void 0?void 0:t.dropEffect;n!=null&&r.dataTransfer&&(r.dataTransfer.dropEffect=n)}s(Zu,"setDropEffectOnEvent");function Q2(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=En(t);if(r.startedFrom==="external")return{input:n,dropTargets:[]};var i=o({input:n,source:r.payload,target:t.target,current:[]});return{input:n,dropTargets:i}}s(Q2,"getStartLocation");var Ju={canStart:Fp,start:X2};var ju=new Map;function eh(e){var t=e.typeKey,r=e.mount,o=ju.get(t);if(o)return o.usageCount++,o;var n={typeKey:t,unmount:r(),usageCount:1};return ju.set(t,n),n}s(eh,"registerUsage");function Vp(e){var t=eh(e);return s(function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),ju.delete(e.typeKey))},"unregister")}s(Vp,"register");function co(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return s(function(){t.forEach(function(n){return n()})},"cleanup")}s(co,"combine");function Ms(e,t){var r=t.attribute,o=t.value;return e.setAttribute(r,o),function(){return e.removeAttribute(r)}}s(Ms,"addAttribute");function Op(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}s(Op,"ownKeys");function _o(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Op(Object(r),!0).forEach(function(o){To(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Op(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(_o,"_objectSpread");function Gu(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=th(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var o=0,n=s(function(){},"F");return{s:n,n:s(function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},"n"),e:s(function(u){throw u},"e"),f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
184
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,a=!0,l=!1;return{s:s(function(){r=r.call(e)},"s"),n:s(function(){var u=r.next();return a=u.done,u},"n"),e:s(function(u){l=!0,i=u},"e"),f:s(function(){try{a||r.return==null||r.return()}finally{if(l)throw i}},"f")}}s(Gu,"_createForOfIteratorHelper");function th(e,t){if(e){if(typeof e=="string")return Up(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Up(e,t):void 0}}s(th,"_unsupportedIterableToArray");function Up(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}s(Up,"_arrayLikeToArray");function Ku(e){return e.slice(0).reverse()}s(Ku,"copyReverse");function Wp(e){var t=e.typeKey,r=e.defaultDropEffect,o=new WeakMap,n="data-drop-target-for-".concat(t),i="[".concat(n,"]");function a(f){return o.set(f.element,f),function(){return o.delete(f.element)}}s(a,"addToRegistry");function l(f){if(0)var v;var h=co(Ms(f.element,{attribute:n,value:"true"}),a(f));return Nr(h)}s(l,"dropTargetForConsumers");function c(f){var v,h,b,y,N=f.source,g=f.target,P=f.input,M=f.result,T=M===void 0?[]:M;if(g==null)return T;if(!(g instanceof Element))return g instanceof Node?c({source:N,target:g.parentElement,input:P,result:T}):T;var R=g.closest(i);if(R==null)return T;var E=o.get(R);if(E==null)return T;var C={input:P,source:N,element:E.element};if(E.canDrop&&!E.canDrop(C))return c({source:N,target:E.element.parentElement,input:P,result:T});var x=(v=(h=E.getData)===null||h===void 0?void 0:h.call(E,C))!==null&&v!==void 0?v:{},w=(b=(y=E.getDropEffect)===null||y===void 0?void 0:y.call(E,C))!==null&&b!==void 0?b:r,A={data:x,element:E.element,dropEffect:w,isActiveDueToStickiness:!1};return c({source:N,target:E.element.parentElement,input:P,result:[].concat(Ps(T),[A])})}s(c,"getActualDropTargets");function u(f){var v=f.eventName,h=f.payload,b=Gu(h.location.current.dropTargets),y;try{for(b.s();!(y=b.n()).done;){var N,g=y.value,P=o.get(g.element),M=_o(_o({},h),{},{self:g});P==null||(N=P[v])===null||N===void 0||N.call(P,M)}}catch(T){b.e(T)}finally{b.f()}}s(u,"notifyCurrent");var d={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:s(function(v){var h=v.payload,b=new Set(h.location.current.dropTargets.map(function(V){return V.element})),y=new Set,N=Gu(h.location.previous.dropTargets),g;try{for(N.s();!(g=N.n()).done;){var P,M=g.value;y.add(M.element);var T=o.get(M.element),R=b.has(M.element),E=_o(_o({},h),{},{self:M});if(T==null||(P=T.onDropTargetChange)===null||P===void 0||P.call(T,E),!R){var C;T==null||(C=T.onDragLeave)===null||C===void 0||C.call(T,E)}}}catch(V){N.e(V)}finally{N.f()}var x=Gu(h.location.current.dropTargets),w;try{for(x.s();!(w=x.n()).done;){var A,k,L=w.value;if(!y.has(L.element)){var S=_o(_o({},h),{},{self:L}),H=o.get(L.element);H==null||(A=H.onDropTargetChange)===null||A===void 0||A.call(H,S),H==null||(k=H.onDragEnter)===null||k===void 0||k.call(H,S)}}}catch(V){x.e(V)}finally{x.f()}},"onDropTargetChange")};function m(f){d[f.eventName](f)}s(m,"dispatchEvent");function p(f){var v=f.source,h=f.target,b=f.input,y=f.current,N=c({source:v,target:h,input:b});if(N.length>=y.length)return N;for(var g=Ku(y),P=Ku(N),M=[],T=0;T<g.length;T++){var R,E=g[T],C=P[T];if(C!=null){M.push(C);continue}var x=M[T-1],w=g[T-1];if((x==null?void 0:x.element)!==(w==null?void 0:w.element))break;var A=o.get(E.element);if(!A)break;var k={input:b,source:v,element:A.element};if(A.canDrop&&!A.canDrop(k)||!((R=A.getIsSticky)!==null&&R!==void 0&&R.call(A,k)))break;M.push(_o(_o({},E),{},{isActiveDueToStickiness:!0}))}return Ku(M)}return s(p,"getIsOver"),{dropTargetForConsumers:l,getIsOver:p,dispatchEvent:m}}s(Wp,"makeDropTarget");function rh(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=oh(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var o=0,n=s(function(){},"F");return{s:n,n:s(function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},"n"),e:s(function(u){throw u},"e"),f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
185
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,a=!0,l=!1;return{s:s(function(){r=r.call(e)},"s"),n:s(function(){var u=r.next();return a=u.done,u},"n"),e:s(function(u){l=!0,i=u},"e"),f:s(function(){try{a||r.return==null||r.return()}finally{if(l)throw i}},"f")}}s(rh,"_createForOfIteratorHelper");function oh(e,t){if(e){if(typeof e=="string")return _p(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_p(e,t):void 0}}s(oh,"_unsupportedIterableToArray");function _p(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}s(_p,"_arrayLikeToArray");function zp(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}s(zp,"ownKeys");function nh(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?zp(Object(r),!0).forEach(function(o){To(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):zp(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(nh,"_objectSpread");function $p(){var e=new Set,t=null;function r(i){t&&(!i.canMonitor||i.canMonitor(t.canMonitorArgs))&&t.active.add(i)}s(r,"tryAddToActive");function o(i){var a=nh({},i);e.add(a),r(a);function l(){e.delete(a),t&&t.active.delete(a)}return s(l,"cleanup"),Nr(l)}s(o,"monitorForConsumers");function n(i){var a=i.eventName,l=i.payload;if(a==="onGenerateDragPreview"){t={canMonitorArgs:{initial:l.location.initial,source:l.source},active:new Set};var c=rh(e),u;try{for(c.s();!(u=c.n()).done;){var d=u.value;r(d)}}catch(b){c.e(b)}finally{c.f()}}if(t){for(var m=Array.from(t.active),p=0,f=m;p<f.length;p++){var v=f[p];if(t.active.has(v)){var h;(h=v[a])===null||h===void 0||h.call(v,l)}}a==="onDrop"&&(t.active.clear(),t=null)}}return s(n,"dispatchEvent"),{dispatchEvent:n,monitorForConsumers:o}}s($p,"makeMonitor");function Zp(e){var t=e.typeKey,r=e.mount,o=e.dispatchEventToSource,n=e.onPostDispatch,i=e.defaultDropEffect,a=$p(),l=Wp({typeKey:t,defaultDropEffect:i});function c(m){o==null||o(m),l.dispatchEvent(m),a.dispatchEvent(m),n==null||n(m)}s(c,"dispatchEvent");function u(m){var p=m.event,f=m.dragType;Ju.start({event:p,dragType:f,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}s(u,"start");function d(){function m(){var p={canStart:Ju.canStart,start:u};return r(p)}return s(m,"mountAdapter"),Vp({typeKey:t,mount:m})}return s(d,"registerUsage"),{registerUsage:d,dropTarget:l.dropTargetForConsumers,monitor:a.monitorForConsumers}}s(Zp,"makeAdapter");var qp=Nr(s(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")},"isAndroid")),Jp="pdnd:android-fallback";var Yu="text/plain";var jp="text/uri-list";var Gp="application/vnd.pdnd";var As=new WeakMap;function ih(e){return As.set(e.element,e),s(function(){As.delete(e.element)},"cleanup")}s(ih,"addToRegistry");var Kp=wp(),Xu=Zp({typeKey:"element",defaultDropEffect:"move",mount:s(function(t){return co(Kp.bindEvents(),(0,Yp.bind)(document,{type:"dragstart",listener:s(function(o){var n,i,a,l,c,u;if(t.canStart(o)&&!o.defaultPrevented&&o.dataTransfer){var d=o.target;if(d instanceof HTMLElement){var m=As.get(d);if(m){var p=En(o),f={element:m.element,dragHandle:(n=m.dragHandle)!==null&&n!==void 0?n:null,input:p};if(m.canDrag&&!m.canDrag(f)){o.preventDefault();return}if(m.dragHandle){var v=ks({x:p.clientX,y:p.clientY});if(!m.dragHandle.contains(v)){o.preventDefault();return}}var h=(i=(a=m.getInitialDataForExternal)===null||a===void 0?void 0:a.call(m,f))!==null&&i!==void 0?i:null;if(h)for(var b=0,y=Object.entries(h);b<y.length;b++){var N=xs(y[b],2),g=N[0],P=N[1];o.dataTransfer.setData(g,P!=null?P:"")}qp()&&!o.dataTransfer.types.includes(Yu)&&!o.dataTransfer.types.includes(jp)&&o.dataTransfer.setData(Yu,Jp),o.dataTransfer.setData(Gp,"");var M={element:m.element,dragHandle:(l=m.dragHandle)!==null&&l!==void 0?l:null,data:(c=(u=m.getInitialData)===null||u===void 0?void 0:u.call(m,f))!==null&&c!==void 0?c:{}},T={type:"element",payload:M,startedFrom:"internal"};t.start({event:o,dragType:T})}}}},"listener")}))},"mount"),dispatchEventToSource:s(function(t){var r,o,n=t.eventName,i=t.payload;(r=As.get(i.source.element))===null||r===void 0||(o=r[n])===null||o===void 0||o.call(r,i)},"dispatchEventToSource"),onPostDispatch:Kp.getOnPostDispatch()}),br=Xu.dropTarget,Qu=Xu.monitor;function fa(e){if(0)var t;var r=co(Xu.registerUsage(),ih(e),Ms(e.element,{attribute:"draggable",value:"true"}));return Nr(r)}s(fa,"draggable");function Xp(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}s(Xp,"ownKeys");function Qp(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Xp(Object(r),!0).forEach(function(o){To(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Xp(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(Qp,"_objectSpread");var ah={top:s(function(t,r){return Math.abs(r.y-t.top)},"top"),right:s(function(t,r){return Math.abs(t.right-r.x)},"right"),bottom:s(function(t,r){return Math.abs(t.bottom-r.y)},"bottom"),left:s(function(t,r){return Math.abs(r.x-t.left)},"left")},ef=Symbol("closestEdge");function tf(e,t){var r,o,n=t.element,i=t.input,a=t.allowedEdges,l={x:i.clientX,y:i.clientY},c=n.getBoundingClientRect(),u=a.map(function(m){return{edge:m,value:ah[m](c,l)}}),d=(r=(o=u.sort(function(m,p){return m.value-p.value})[0])===null||o===void 0?void 0:o.edge)!==null&&r!==void 0?r:null;return Qp(Qp({},e),{},To({},ef,d))}s(tf,"attachClosestEdge");function ga(e){var t;return(t=e[ef])!==null&&t!==void 0?t:null}s(ga,"extractClosestEdge");var Fl=require("@tiptap/core"),bg=require("@tiptap/react");var pg=require("@tiptap/react"),fg=require("jotai"),gg=require("react");var ug=require("@tiptap/react"),dg=require("jotai"),Pe=require("react"),mg=require("uuid");var kd=require("@tiptap/extension-color");var rf=require("@tiptap/core"),of=require("@tiptap/pm/dropcursor"),ed=rf.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[(0,of.dropCursor)(this.options)]}});var Pd=require("@tiptap/extension-hard-break");var nf=require("@tiptap/core"),ci=require("@tiptap/pm/history"),sh=nf.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>(0,ci.undo)(e,t),redo:()=>({state:e,dispatch:t})=>(0,ci.redo)(e,t)}},addProseMirrorPlugins(){return[(0,ci.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 Nd=require("@tiptap/extension-placeholder"),Md=require("@tiptap/extension-text-align"),Ad=require("@tiptap/extension-typography"),Sd=require("@tiptap/extension-underline"),Id=require("@tiptap/starter-kit");var cf=require("@tiptap/core");var ui=require("@tiptap/core"),lh=/^\s*>\s$/,af=ui.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,ui.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,ui.wrappingInputRule)({find:lh,type:this.type})]}});var uf=require("@tiptap/react");var sf=require("uuid");function dt(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,sf.v4)()}`;r.setNodeMarkup(i,void 0,{...n.attrs,id:a}),o=!0}return!1}),o&&e.view.dispatch(r)}s(dt,"generateNodeIds");var Ss=require("@tiptap/react"),Is=require("jotai"),di=require("react");var zo=require("react/jsx-runtime"),ch=s(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderLeftWidth:o,borderColor:n})=>(0,zo.jsx)("div",{className:"courier-w-full node-element",children:(0,zo.jsx)("div",{style:{position:"relative",padding:`${t}px ${e}px`,backgroundColor:r,borderLeftWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",whiteSpace:"pre-wrap"},children:(0,zo.jsx)(Ss.NodeViewContent,{})})}),"BlockquoteComponent"),lf=s(e=>{var l,c,u;let t=(0,Is.useSetAtom)(Xe),r=(0,Is.useAtomValue)(ye),o=(0,di.useRef)(null),n=((l=r==null?void 0:r.type)==null?void 0:l.name)==="blockquote"&&(((c=r==null?void 0:r.attrs)==null?void 0:c.id)===e.node.attrs.id||!((u=r==null?void 0:r.attrs)!=null&&u.id)&&!e.node.attrs.id&&r===e.node),i=(0,di.useCallback)(()=>{if(!e.editor.isEditable)return;let d=e.node;d&&(t(d),e.editor.commands.updateSelectionState(d))},[e.editor.isEditable,e.node,e.editor.commands,t]);(0,di.useEffect)(()=>{let d=o.current;if(!d)return;let m=s(p=>{let f=p.target;f.closest(".courier-actions-panel")||f.closest("[data-no-drag-preview]")||i()},"handleClick");return d.addEventListener("click",m,!0),()=>{d.removeEventListener("click",m,!0)}},[i]);let a=!e.node.content||e.node.content.size===0;return(0,zo.jsx)(Ss.NodeViewWrapper,{children:(0,zo.jsx)("div",{ref:o,children:(0,zo.jsx)(It,{id:e.node.attrs.id,className:I(n&&"selected-element",a&&"is-empty"),editor:e.editor,children:(0,zo.jsx)(ch,{...e.node.attrs})})})})},"BlockquoteComponentNode");var $o={paddingHorizontal:8,paddingVertical:6,backgroundColor:"transparent",borderLeftWidth:4,borderColor:"#e0e0e0"},td=af.extend({content:"block+",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){dt(this.editor,this.name)},addAttributes(){return{id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},paddingHorizontal:{default:$o.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:$o.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:$o.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderLeftWidth:{default:$o.borderLeftWidth,parseHTML:e=>e.getAttribute("data-border-left-width"),renderHTML:e=>({"data-border-left-width":e.borderLeftWidth})},borderColor:{default:$o.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,cf.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,l=i.doc.resolve(a);if(l.depth>1){let c=l.blockRange();c&&i.lift(c,0)}return!0}).focus().run()}}},addNodeView(){return(0,uf.ReactNodeViewRenderer)(lf)}});var bf=require("@hookform/resolvers/zod"),yf=require("react-hook-form");var wn=require("react");var Tt=s(({editor:e,element:t,form:r,nodeType:o})=>{let n=(0,wn.useRef)(null),i=(0,wn.useRef)(null);return(0,wn.useEffect)(()=>{if(!e||!t)return;let l=s(()=>{let c=null;if(e.state.doc.descendants((u,d)=>u.attrs.id===t.attrs.id?(c=d,!1):!0),c!==null){let u=e.state.doc.nodeAt(c);(u==null?void 0:u.type.name)===o&&(n.current=u,i.current=c,Object.entries(u.attrs).forEach(([d,m])=>{r.getValues(d)!==m&&r.setValue(d,m)}))}},"updateCurrentNode");return l(),e.on("update",l),()=>{e.off("update",l)}},[e,t,r,o]),{updateNodeAttributes:(0,wn.useCallback)(l=>{if(!e||i.current===null)return;let c=e.state.doc.nodeAt(i.current);if(!c||c.type.name!==o)return;let u={...c.attrs,...l,id:c.attrs.id};JSON.stringify(c.attrs)!==JSON.stringify(u)&&e.chain().command(({tr:m,dispatch:p})=>{let f=m.doc.nodeAt(i.current);return(f==null?void 0:f.type.name)===o&&p?(m.setNodeMarkup(i.current,f.type,u),m.setMeta("addToHistory",!0),!0):!1}).run()},[e,o])}},"useNodeAttributes");var kn=require("jotai"),ba=require("react");var ha=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,...ha(n,i)]:[...r,i]},[]),"getFlattenedVariables");var uh={link:["href","content"],img:["src","href","alt_text"],image:["src","href","alt_text"],action:["href","content"],meta:["title"],list:["imgSrc","imgHref"],quote:["content"],html:[]},dh=["content","href","src","title"],df=s((e=[])=>{let t=new Set,r=/\{\{([^}]+)\}\}/g,o=s(i=>{let a=i.matchAll(r);for(let l of a){let c=l[1].trim();c&&vt(c)&&t.add(c)}},"extractFromString"),n=s(i=>{let a=i;a.type==="string"&&typeof a.content=="string"&&o(a.content),a.type==="text"&&typeof a.content=="string"&&o(a.content);let l=a.type,c=uh[l];c&&c.forEach(u=>{typeof a[u]=="string"&&o(a[u])}),typeof a.if=="string"&&o(a.if),typeof a.loop=="string"&&o(a.loop),a.type==="channel"&&a.raw&&typeof a.raw=="object"&&a.raw!==null&&Object.values(a.raw).forEach(u=>{typeof u=="string"&&o(u)}),a.elements&&Array.isArray(a.elements)&&a.elements.forEach(u=>n(u)),a.locales&&typeof a.locales=="object"&&a.locales!==null&&Object.values(a.locales).forEach(u=>{if(u&&typeof u=="object"){let d=u;dh.forEach(m=>{typeof d[m]=="string"&&o(d[m])}),d.elements&&Array.isArray(d.elements)&&d.elements.forEach(m=>{m&&n(m)}),d.raw&&typeof d.raw=="object"&&d.raw!==null&&Object.values(d.raw).forEach(m=>{typeof m=="string"&&o(m)})}})},"processNode");return e.forEach(i=>n(i)),Array.from(t).sort()},"extractVariablesFromContent");var mh=s(e=>{let t=(0,kn.useAtomValue)(He),r=(0,kn.useAtomValue)(ee),o=(0,kn.useAtomValue)(Uo),n=(0,kn.useAtomValue)(mn),i=(0,kn.useSetAtom)(mn),a=e!=null?e:o,l=(0,ba.useMemo)(()=>{var m,p;if(!t)return[];let d=((p=(m=t.extensionManager.extensions.find(f=>f.name==="variableSuggestion"))==null?void 0:m.options)==null?void 0:p.variables)||{};return ha(d)},[t]),c=(0,ba.useMemo)(()=>{if(!r||!a)return[];let d=r.elements.find(m=>m.type==="channel"&&m.channel===a);return d?df(d.elements||[]):[]},[r,a]),u=(0,ba.useCallback)((d,m)=>{i(p=>({...p,[d]:m}))},[i]);return{availableVariables:l,usedVariables:c,variableValues:n,addVariableValue:u}},"useVariables");var gf=require("jotai");var ya=require("react/jsx-runtime"),mt=s(({draggable:e=!1,icon:t,draggableLabel:r,label:o})=>(0,ya.jsxs)("div",{className:"courier-flex courier-flex-row courier-items-center courier-gap-2",children:[(0,ya.jsx)("div",{className:I("courier-w-8 courier-h-8 courier-rounded-md courier-flex courier-items-center courier-justify-center",e?"courier-cursor-grab courier-bg-secondary":"courier-border courier-border-border"),children:t}),(0,ya.jsx)("span",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:e?r:o})]}),"BlockBase");var mf=require("lucide-react");var rd=require("react/jsx-runtime"),pf=s(({draggable:e=!1})=>(0,rd.jsx)(mt,{draggable:e,icon:(0,rd.jsx)(mf.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),draggableLabel:"Blockquote",label:"Blockquote block"}),"BlockquoteBlock");var Ca=require("react/jsx-runtime"),ph=s(()=>(0,Ca.jsx)("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ca.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:"currentColor"})}),"ButtonBlockIcon"),Zo=s(({draggable:e=!1})=>(0,Ca.jsx)(mt,{draggable:e,icon:(0,Ca.jsx)(ph,{}),draggableLabel:"Button",label:"Button block"}),"ButtonBlock");var va=require("react/jsx-runtime"),fh=s(()=>(0,va.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,va.jsx)("path",{d:"M14 1.5V12.5H18C18.25 12.5 18.5 12.2812 18.5 12V2C18.5 1.75 18.25 1.5 18 1.5H14ZM12.5 1.5H7.5V12.5H12.5V1.5ZM6 12.5V1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12C1.5 12.2812 1.71875 12.5 2 12.5H6ZM0 2C0 0.90625 0.875 0 2 0H18C19.0938 0 20 0.90625 20 2V12C20 13.125 19.0938 14 18 14H2C0.875 14 0 13.125 0 12V2Z",fill:"currentColor"})}),"ColumnBlockIcon"),Ls=s(({draggable:e=!1})=>(0,va.jsx)(mt,{draggable:e,icon:(0,va.jsx)(fh,{}),draggableLabel:"Column layout",label:"Column layout"}),"ColumnBlock");var xa=require("react/jsx-runtime"),gh=s(()=>(0,xa.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,xa.jsx)("path",{d:"M6.5 3.5L3 7L6.5 10.5M13.5 3.5L17 7L13.5 10.5M11.5 1L8.5 13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"CustomCodeBlockIcon"),Ta=s(({draggable:e=!1})=>(0,xa.jsx)(mt,{draggable:e,icon:(0,xa.jsx)(gh,{}),draggableLabel:"Custom code",label:"Custom code"}),"CustomCodeBlock");var Ea=require("react/jsx-runtime"),hh=s(()=>(0,Ea.jsx)("svg",{width:"16",height:"2",viewBox:"0 0 16 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ea.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:"currentColor"})}),"DividerBlockIcon"),qo=s(({draggable:e=!1})=>(0,Ea.jsx)(mt,{draggable:e,icon:(0,Ea.jsx)(hh,{}),draggableLabel:"Divider",label:"Divider block"}),"DividerBlock");var wa=require("react/jsx-runtime"),bh=s(()=>(0,wa.jsx)("svg",{width:"18",height:"13",viewBox:"0 0 18 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,wa.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:"currentColor"})}),"HeadingBlockIcon"),Rs=s(({draggable:e=!1})=>(0,wa.jsx)(mt,{draggable:e,icon:(0,wa.jsx)(bh,{}),draggableLabel:"Heading",label:"Heading block"}),"HeadingBlock");var ka=require("react/jsx-runtime"),yh=s(()=>(0,ka.jsx)("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ka.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:"currentColor"})}),"ImageBlockIcon"),Hs=s(({draggable:e=!1})=>(0,ka.jsx)(mt,{draggable:e,icon:(0,ka.jsx)(yh,{}),draggableLabel:"Image",label:"Image block"}),"ImageBlock");var ff=require("lucide-react");var od=require("react/jsx-runtime"),Bs=s(({draggable:e=!1})=>(0,od.jsx)(mt,{draggable:e,icon:(0,od.jsx)(ff.AlignVerticalSpaceAround,{className:"courier-w-4 courier-h-4"}),draggableLabel:"Spacer",label:"Spacer block"}),"SpacerBlock");var Pa=require("react/jsx-runtime"),Ch=s(()=>(0,Pa.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Pa.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:"currentColor"})}),"TextBlockIcon"),Jo=s(({draggable:e=!1})=>(0,Pa.jsx)(mt,{draggable:e,icon:(0,Pa.jsx)(Ch,{}),draggableLabel:"Text",label:"Text block"}),"TextBlock");var Qt=require("react/jsx-runtime"),Lt=s(({type:e})=>{let t=(0,gf.useSetAtom)(Xe);return(0,Qt.jsxs)("div",{className:"courier-flex courier-gap-4 courier-flex-col",children:[(0,Qt.jsx)(Se,{className:"courier-w-fit",variant:"secondary",buttonSize:"small",onClick:()=>{t(null)},children:"Close"}),e==="heading"&&(0,Qt.jsx)(Rs,{}),e==="text"&&(0,Qt.jsx)(Jo,{}),e==="image"&&(0,Qt.jsx)(Hs,{}),e==="spacer"&&(0,Qt.jsx)(Bs,{}),e==="divider"&&(0,Qt.jsx)(qo,{}),e==="button"&&(0,Qt.jsx)(Zo,{}),e==="blockquote"&&(0,Qt.jsx)(pf,{}),e==="customCode"&&(0,Qt.jsx)(Ta,{}),e==="column"&&(0,Qt.jsx)(Ls,{}),(0,Qt.jsx)(ce,{className:"courier-m-0"})]})},"FormHeader");var jo=require("zod"),hf=jo.z.object({paddingHorizontal:jo.z.coerce.number().min(0),paddingVertical:jo.z.coerce.number().min(0),backgroundColor:jo.z.string(),borderLeftWidth:jo.z.coerce.number().min(0),borderColor:jo.z.string(),id:jo.z.string().optional()});var zr=require("react/jsx-runtime"),Cf=s(({element:e,editor:t})=>{let r=(0,yf.useForm)({resolver:(0,bf.zodResolver)(hf),defaultValues:{...$o,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"blockquote"});return e?(0,zr.jsxs)(qe,{...r,children:[(0,zr.jsx)(Lt,{type:"blockquote"}),(0,zr.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,zr.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,zr.jsx)(j,{control:r.control,name:"borderColor",render:({field:n})=>(0,zr.jsxs)(q,{className:"courier-mb-3",children:[(0,zr.jsx)(J,{children:(0,zr.jsx)(xt,{...n,defaultValue:$o.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,zr.jsx)(G,{})]})})]})]}):null},"BlockquoteForm");var er=require("zod"),Ds=er.z.object({label:er.z.string(),link:er.z.string().optional(),alignment:er.z.enum(["left","center","right"]),backgroundColor:er.z.string(),borderRadius:er.z.number(),padding:er.z.number(),fontWeight:er.z.enum(["normal","bold"]),fontStyle:er.z.enum(["normal","italic"]),isUnderline:er.z.boolean(),isStrike:er.z.boolean(),textColor:er.z.string().optional(),borderColor:er.z.string().optional()});var Lf=require("@hookform/resolvers/zod"),Rf=require("react-hook-form");var vf=require("@tiptap/core"),mi=vf.Node.create({name:"doc",topNode:!0,content:"block+"});var Fs=require("@tiptap/core"),pi=Fs.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",(0,Fs.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 Sf=he(require("@tiptap/extension-placeholder"),1);var xf=require("@tiptap/core"),Vs=xf.Node.create({name:"text",group:"inline"});var qs=require("@tiptap/react"),Mn=he(require("react"),1),Aa=require("react");var fi=require("@tiptap/core"),kf=require("@tiptap/react");var Tf=require("@tiptap/react"),Ef=require("jotai"),Eo=require("react");var Qe=require("react");var Na=require("react/jsx-runtime"),nd=50,id=24,vh=s((e,t)=>e?{bgColor:"#FEF2F2",borderColor:"#FECACA",iconColor:"#DC2626",textColor:"#991B1B"}:t?{bgColor:"#EFF6FF",borderColor:"#BFDBFE",iconColor:"#1E40AF",textColor:"#1E40AF"}:{bgColor:"#FFFBEB",borderColor:"#FDE68A",iconColor:"#B45309",textColor:"#92400E"},"defaultGetColors"),Os=s(({variableId:e,isInvalid:t,onUpdateAttributes:r,onDelete:o,icon:n,value:i,singleClickToEdit:a=!1,className:l,textColorOverride:c,getColors:u=vh})=>{let[d,m]=(0,Qe.useState)(!1),[p,f]=(0,Qe.useState)(e),v=(0,Qe.useRef)(null);(0,Qe.useEffect)(()=>{e===""&&!d&&(m(!0),f(""))},[e,d]),(0,Qe.useEffect)(()=>{if(d&&v.current){v.current.focus();let k=document.createRange();k.selectNodeContents(v.current),k.collapse(!1);let L=window.getSelection();L==null||L.removeAllRanges(),L==null||L.addRange(k)}},[d]),(0,Qe.useEffect)(()=>{d||f(e)},[e,d]),(0,Qe.useEffect)(()=>{v.current&&!d&&(v.current.textContent=p)},[p,d]);let h=(0,Qe.useCallback)(()=>{m(!1);let k=p.trim();if(k===""){o();return}let L=vt(k);r({id:k,isInvalid:!L})},[p,o,r]),b=(0,Qe.useCallback)(k=>{var L;k.key==="Enter"?(k.preventDefault(),(L=v.current)==null||L.blur()):k.key==="Escape"&&(k.preventDefault(),f(e),v.current&&(v.current.textContent=e),m(!1),e===""&&o())},[e,o]),y=(0,Qe.useCallback)(()=>{if(v.current){let k=v.current.textContent||"";if(k.length>nd){k=k.slice(0,nd),v.current.textContent=k;let L=document.createRange();L.selectNodeContents(v.current),L.collapse(!1);let S=window.getSelection();S==null||S.removeAllRanges(),S==null||S.addRange(L)}f(k)}},[]),N=(0,Qe.useCallback)(k=>{k.preventDefault();let L=k.clipboardData.getData("text/plain").slice(0,nd);document.execCommand("insertText",!1,L)},[]),g=(0,Qe.useCallback)(k=>{k.stopPropagation(),d||(m(!0),f(e))},[e,d]),P=u(t,!!i),{bgColor:M,borderColor:T,textColor:R}=P,E=c||R,C=(0,Qe.useMemo)(()=>{let k=e,L=i?`="${i}"`:"",S=`${k}${L}`,H=k.length>id;return{displayText:`${H?`${k.slice(0,id)}\u2026`:k}${L}`,fullText:S,showTitle:H}},[e,i]),x=(0,Qe.useCallback)(k=>{k.stopPropagation()},[]),w=(0,Qe.useCallback)(k=>{k.stopPropagation()},[]),A=a?{onClick:g}:{onClick:w,onDoubleClick:g};return(0,Na.jsxs)("span",{className:I("courier-inline-block courier-rounded courier-border courier-px-1.5 courier-pl-6 courier-py-[1px] courier-max-w-full courier-tracking-[0.64px] courier-relative courier-align-middle",l),style:{fontSize:"inherit",fontFamily:"inherit",fontWeight:"inherit",backgroundColor:M,borderColor:T,color:E,direction:"ltr"},onMouseDown:x,...A,title:C.showTitle?C.fullText:void 0,children:[(0,Na.jsx)("span",{className:"courier-flex-shrink-0 courier-flex courier-items-center courier-absolute courier-left-1 courier-top-1/2 -courier-translate-y-1/2",children:n}),(0,Na.jsx)("span",{ref:v,role:"textbox",contentEditable:d,suppressContentEditableWarning:!0,onBlur:h,onKeyDown:b,onInput:y,onPaste:N,onMouseDown:x,...a?{onClick:g}:{onClick:w,onDoubleClick:g},className:I("courier-outline-none courier-min-w-[1ch]",!d&&"courier-cursor-text"),style:{color:E,maxWidth:`${id}ch`,overflow:"hidden",textOverflow:d?"clip":"ellipsis",whiteSpace:"nowrap",direction:"ltr",unicodeBidi:"isolate"},children:p})]})},"VariableChipBase");var Ma=require("react/jsx-runtime"),Us=s(({color:e="#1D4ED8"})=>(0,Ma.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,Ma.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,Ma.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableIcon");var Ws=require("react/jsx-runtime"),wf=s(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=(0,Ef.useAtomValue)(mn),i=e.attrs.id||"",a=n[i],l=e.attrs.isInvalid,[c,u]=(0,Eo.useState)(!1),d=(0,Eo.useCallback)(()=>{if(typeof r=="function")try{let h=r();if(h==null){u(!1);return}let y=t.state.doc.resolve(h).parent;u(y&&y.type.name==="button")}catch{u(!1)}else u(!1)},[t,r]);(0,Eo.useEffect)(()=>{d();let h=s(()=>{d()},"handleUpdate");return t.on("update",h),t.on("selectionUpdate",h),()=>{t.off("update",h),t.off("selectionUpdate",h)}},[t,d]);let m=(0,Eo.useCallback)(h=>{o(h)},[o]),p=(0,Eo.useCallback)(()=>{if(typeof r=="function"){let h=r();typeof h=="number"&&t.chain().focus().deleteRange({from:h,to:h+e.nodeSize}).run()}},[t,r,e.nodeSize]),f=(0,Eo.useCallback)((h,b)=>h?{bgColor:"#FEF2F2",borderColor:"#FECACA",iconColor:"#DC2626",textColor:"#991B1B"}:b?{bgColor:"#EFF6FF",borderColor:"#BFDBFE",iconColor:"#1E40AF",textColor:"#1E40AF"}:{bgColor:"#FFFBEB",borderColor:"#FDE68A",iconColor:"#B45309",textColor:"#92400E"},[]),v=f(l,!!a);return(0,Ws.jsx)(Tf.NodeViewWrapper,{className:"courier-inline-block courier-max-w-full",children:(0,Ws.jsx)(Os,{variableId:i,isInvalid:l,value:a,onUpdateAttributes:m,onDelete:p,icon:(0,Ws.jsx)(Us,{color:v.iconColor}),getColors:f,className:I("courier-mx-1 courier-variable-node",c&&"courier-variable-in-button"),textColorOverride:c?"#000000":void 0})})},"VariableView");var ad=fi.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:"",parseHTML:e=>e.getAttribute("data-id")||"",renderHTML:e=>({"data-id":e.id})},isInvalid:{default:!1,parseHTML:e=>e.getAttribute("data-invalid")==="true",renderHTML:e=>({"data-invalid":e.isInvalid?"true":void 0})}}},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,kf.ReactNodeViewRenderer)(wf)}}),Pn=fi.Extension.create({name:"variableInputRule",addInputRules(){return[new fi.InputRule({find:/\{\{$/,handler:({range:e,chain:t})=>{t().deleteRange(e).insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()}})]}});var Pf=require("@tiptap/core"),Nf=require("@tiptap/pm/state"),_s=require("@tiptap/pm/model");var Nn=Pf.Extension.create({name:"variablePaste",addProseMirrorPlugins(){return[new Nf.Plugin({props:{transformPastedHTML:e=>e.replace(/\{\{([^}]+)\}\}/g,(r,o)=>{let n=o.trim();return vt(n)?`<span data-variable="true" data-id="${n}"></span>`:r}),transformPastedText:(e,t,r)=>{let o=/\{\{([^}]+)\}\}/g;if(!o.test(e))return e;let{schema:n}=r.state,i=[],a=0,l;for(o.lastIndex=0;(l=o.exec(e))!==null;){if(l.index>a){let u=e.substring(a,l.index);u&&i.push(n.text(u))}let c=l[1].trim();if(n.nodes.variable&&vt(c))i.push(n.nodes.variable.create({id:c,isInvalid:!1}));else{let u=l[0];i.push(n.text(u))}a=l.index+l[0].length}if(a<e.length){let c=e.substring(a);c&&i.push(n.text(c))}if(i.length>0){let c=_s.Fragment.from(i),u=new _s.Slice(c,0,0),d=r.state.tr.replaceSelection(u);return r.dispatch(d),e}return e}}})]}});var Af=require("@tiptap/core"),zs=require("@tiptap/react"),sd=require("react");var Go=require("react/jsx-runtime"),xh=s(({color:e="#B45309"})=>(0,Go.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,Go.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,Go.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableChipIcon"),Mf=s(e=>e?{bgColor:"#FEF2F2",borderColor:"#FECACA",iconColor:"#DC2626",textColor:"#991B1B"}:{bgColor:"#FFFBEB",borderColor:"#FDE68A",iconColor:"#B45309",textColor:"#92400E"},"getSimpleColors"),Th=s(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=e.attrs.id||"",i=e.attrs.isInvalid||!1,a=(0,sd.useCallback)(u=>{o(u)},[o]),l=(0,sd.useCallback)(()=>{if(typeof r=="function"){let u=r();typeof u=="number"&&t.chain().focus().deleteRange({from:u,to:u+e.nodeSize}).run()}},[t,r,e.nodeSize]),c=Mf(i);return(0,Go.jsx)(zs.NodeViewWrapper,{as:"span",className:"courier-inline",children:(0,Go.jsx)(Os,{variableId:n,isInvalid:i,onUpdateAttributes:a,onDelete:l,icon:(0,Go.jsx)(xh,{color:c.iconColor}),getColors:Mf,className:"courier-mx-0.5"})})},"SimpleVariableView"),$s=Af.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:"",parseHTML:e=>e.getAttribute("data-id")||"",renderHTML:e=>({"data-id":e.id})},isInvalid:{default:!1,parseHTML:e=>e.getAttribute("data-invalid")==="true",renderHTML:e=>({"data-invalid":e.isInvalid?"true":void 0})}}},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,zs.ReactNodeViewRenderer)(Th)}});function gi(e){if(!e)return{type:"doc",content:[{type:"paragraph"}]};let t=/\{\{([^}]+)\}\}/g,r=[],o=0,n;for(;(n=t.exec(e))!==null;){if(n.index>o){let a=e.substring(o,n.index);a&&r.push({type:"text",text:a})}let i=n[1].trim();vt(i)?r.push({type:"variable",attrs:{id:i,isInvalid:!1}}):r.push({type:"text",text:n[0]}),o=n.index+n[0].length}if(o<e.length){let i=e.substring(o);i&&r.push({type:"text",text:i})}return{type:"doc",content:[{type:"paragraph",content:r.length>0?r:void 0}]}}s(gi,"parseStringToContent");function Zs(e){if(!e.content)return"";let t="",r=s(o=>{var n;o.type==="text"&&o.text?t+=o.text:o.type==="variable"&&((n=o.attrs)!=null&&n.id)?t+=`{{${o.attrs.id}}}`:(o.type==="paragraph"||o.type==="doc")&&o.content&&o.content.forEach(i=>r(i))},"processNode");return e.content.forEach(o=>r(o)),t}s(Zs,"contentToString");var ld=require("react/jsx-runtime"),$r=Mn.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,onFocus:i,onBlur:a},l)=>{let c=Mn.useRef(!1),u=Mn.useRef(e),d=(0,qs.useEditor)({extensions:[mi,pi.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),Vs,$s,Pn,Nn,Sf.default.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:gi(e),editable:!n,editorProps:{attributes:{class:"courier-outline-none courier-min-h-[20px]"},handleKeyDown:(p,f)=>f.key==="Enter"&&!f.shiftKey?(f.preventDefault(),!0):!1},onUpdate:({editor:p})=>{if(c.current)return;let f=Zs(p.getJSON());f!==u.current&&(u.current=f,t==null||t(f))},onFocus:()=>{i==null||i()},onBlur:()=>{a==null||a()}});(0,Aa.useEffect)(()=>{if(!d||e===u.current)return;c.current=!0,u.current=e;let p=setTimeout(()=>{let f=gi(e);d.commands.setContent(f),c.current=!1},0);return()=>clearTimeout(p)},[d,e]),(0,Aa.useEffect)(()=>{d&&d.setEditable(!n)},[d,n]);let m=(0,Aa.useCallback)(()=>{d==null||d.commands.focus()},[d]);return Mn.useImperativeHandle(l,()=>{let p=d==null?void 0:d.view.dom.parentElement;return p&&(p.focus=m),p},[d,m]),(0,ld.jsx)("div",{ref:l,className:I("variable-textarea-placeholder","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 md:courier-text-sm",n&&"courier-cursor-not-allowed courier-opacity-50","[&_.ProseMirror]:courier-outline-none [&_.ProseMirror]:courier-min-h-[20px] [&_.ProseMirror]:courier-border-none [&_.ProseMirror]:courier-p-0","[&_.tiptap]:courier-outline-none [&_.tiptap]:courier-border-none",o),onClick:()=>d==null?void 0:d.commands.focus(),children:(0,ld.jsx)(qs.EditorContent,{editor:d,className:"courier-w-full"})})});$r.displayName="VariableTextarea";var If=he(require("@tiptap/extension-placeholder"),1);var Js=require("@tiptap/react"),An=he(require("react"),1),Sa=require("react");var cd=require("react/jsx-runtime"),hi=An.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,readOnly:i=!1,onFocus:a,onBlur:l},c)=>{let u=An.useRef(!1),d=An.useRef(e),m=(0,Js.useEditor)({extensions:[mi,pi.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),Vs,$s,Pn,Nn,If.default.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:gi(e),editable:!n&&!i,editorProps:{attributes:{class:"courier-outline-none"},handleKeyDown:(f,v)=>v.key==="Enter"?(v.preventDefault(),!0):!1},onUpdate:({editor:f})=>{if(u.current)return;let v=Zs(f.getJSON());v!==d.current&&(d.current=v,t==null||t(v))},onFocus:()=>{a==null||a()},onBlur:()=>{l==null||l()}});(0,Sa.useEffect)(()=>{if(!m||e===d.current)return;u.current=!0,d.current=e;let f=setTimeout(()=>{let v=gi(e);m.commands.setContent(v),u.current=!1},0);return()=>clearTimeout(f)},[m,e]),(0,Sa.useEffect)(()=>{m&&m.setEditable(!n&&!i)},[m,n,i]);let p=(0,Sa.useCallback)(()=>{m==null||m.commands.focus()},[m]);return An.useImperativeHandle(c,()=>{let f=m==null?void 0:m.view.dom.parentElement;return f&&(f.focus=p),f},[m,p]),(0,cd.jsx)("div",{ref:c,className:I("variable-input-placeholder","courier-flex courier-items-center courier-w-full courier-rounded-md courier-border-none courier-bg-transparent courier-text-foreground courier-py-1 courier-text-sm md:courier-text-md",(n||i)&&"courier-cursor-default",n&&"courier-opacity-50","[&_.ProseMirror]:courier-h-[25px] [&_.ProseMirror]:courier-outline-none [&_.ProseMirror]:courier-border-none [&_.ProseMirror]:courier-p-0 [&_.ProseMirror]:courier-flex-1","[&_.tiptap]:courier-outline-none [&_.tiptap]:courier-border-none",o),onClick:()=>!i&&!n&&(m==null?void 0:m.commands.focus()),children:(0,cd.jsx)(Js.EditorContent,{editor:m,className:"courier-w-full courier-flex-1"})})});hi.displayName="VariableInput";var Ko=require("react/jsx-runtime"),bi=30,js=s(({color:e="currentColor",width:t=bi,height:r=bi,...o})=>(0,Ko.jsx)($,{...o,width:t,height:r,children:(0,Ko.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"),Gs=s(({color:e="currentColor",width:t=bi,height:r=bi,...o})=>(0,Ko.jsx)($,{...o,width:t,height:r,children:(0,Ko.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"),Ks=s(({color:e="currentColor",width:t=bi,height:r=bi,...o})=>(0,Ko.jsx)($,{...o,width:t,height:r,children:(0,Ko.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");var te=require("react/jsx-runtime"),Hf=s(({element:e,editor:t})=>{let r=(0,Rf.useForm)({resolver:(0,Lf.zodResolver)(Ds),defaultValues:{...Ge,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:"button"});return e?(0,te.jsxs)(qe,{...r,children:[(0,te.jsx)(Lt,{type:"button"}),(0,te.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,te.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,te.jsx)(j,{control:r.control,name:"link",render:({field:n})=>(0,te.jsxs)(q,{children:[(0,te.jsx)(J,{children:(0,te.jsx)($r,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})}})}),(0,te.jsx)(G,{})]})}),(0,te.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,te.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Background"}),(0,te.jsx)(j,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,te.jsxs)(q,{className:"courier-mb-4",children:[(0,te.jsx)(J,{children:(0,te.jsx)(xt,{...n,defaultValue:Ge.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,te.jsx)(G,{})]})}),(0,te.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,te.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,te.jsx)(j,{control:r.control,name:"padding",render:({field:n})=>(0,te.jsxs)(q,{className:"courier-mb-2",children:[(0,te.jsx)(J,{children:(0,te.jsx)(be,{type:"number",min:0,...n})}),(0,te.jsx)(G,{})]})}),(0,te.jsx)(j,{control:r.control,name:"alignment",render:({field:n})=>(0,te.jsxs)(q,{children:[(0,te.jsx)(J,{children:(0,te.jsxs)(Pr,{type:"single",value:n.value,onValueChange:i=>{n.onChange(i),o({...r.getValues(),alignment:i})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,te.jsx)(_t,{size:"sm",value:"left",className:"courier-w-full",children:(0,te.jsx)(js,{className:"courier-h-4 courier-w-4"})}),(0,te.jsx)(_t,{size:"sm",value:"center",className:"courier-w-full",children:(0,te.jsx)(Gs,{className:"courier-h-4 courier-w-4"})}),(0,te.jsx)(_t,{size:"sm",value:"right",className:"courier-w-full",children:(0,te.jsx)(Ks,{className:"courier-h-4 courier-w-4"})})]})}),(0,te.jsx)(G,{})]})}),(0,te.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,te.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,te.jsx)(j,{control:r.control,name:"borderRadius",render:({field:n})=>(0,te.jsxs)(q,{children:[(0,te.jsx)(J,{children:(0,te.jsx)(be,{startAdornment:(0,te.jsx)(Gi,{}),type:"number",min:0,...n})}),(0,te.jsx)(G,{})]})})]})]}):null},"ButtonForm");var Qs=require("@tiptap/core"),Ff=require("@tiptap/react"),Vf=require("uuid");var Xs=require("jotai"),Be=require("react");var Et=require("react/jsx-runtime"),Eh=s(e=>{if(!e)return[];let t=[],r=/\{\{([^}]+)\}\}/g,o=0,n;for(r.lastIndex=0;(n=r.exec(e))!==null;){if(!n[0].startsWith("{{")||!n[0].endsWith("}}"))continue;n.index>o&&t.push({type:"text",content:e.substring(o,n.index)});let i=n[1].trim();vt(i)?t.push({type:"variable",name:i}):t.push({type:"text",content:n[0]}),o=n.index+n[0].length}return o<e.length&&t.push({type:"text",content:e.substring(o)}),t},"parseLabel"),wh=s(({parts:e})=>{let t=(0,Xs.useAtomValue)(mn);return(0,Et.jsx)(Et.Fragment,{children:e.map((r,o)=>{if(r.type==="text")return(0,Et.jsx)("span",{children:r.content},o);let n=t[r.name];return(0,Et.jsxs)("span",{className:"courier-inline-flex courier-items-center courier-gap-0.5 courier-rounded courier-border courier-px-1.5 courier-pl-1 courier-py-[1px] courier-text-sm courier-variable-node courier-font-mono courier-max-w-full courier-tracking-[0.64px] courier-variable-in-button",style:{backgroundColor:n?"#EFF6FF":"#FFFBEB",borderColor:n?"#BFDBFE":"#FDE68A",color:"#000000"},children:[(0,Et.jsx)(Us,{color:n?void 0:"#B45309"}),(0,Et.jsxs)("span",{className:"courier-truncate courier-min-w-0",style:{color:"#000000"},children:[r.name,n?`="${n}"`:""]})]},o)})})},"ButtonLabelDisplay"),Bf=s(({label:e,backgroundColor:t,textColor:r,onLabelChange:o,editable:n})=>{let i=(0,Be.useRef)(null),a=(0,Be.useRef)(e),l=(0,Be.useRef)(!1),[c,u]=(0,Be.useState)(!1),d=Eh(e),p=d.some(T=>T.type==="variable")&&!c;(0,Be.useLayoutEffect)(()=>{if(!i.current||!p)return;Array.from(i.current.childNodes).filter(R=>R.nodeType===Node.TEXT_NODE).forEach(R=>R.remove())},[p,e]);let f=(0,Be.useRef)(p),v=(0,Be.useRef)(!0);(0,Be.useEffect)(()=>{if(!i.current||p){f.current=p;return}let T=f.current&&!p;f.current=p,(v.current||T||!l.current&&e!==a.current)&&(i.current.textContent=e),v.current=!1,a.current=e},[e,p]);let h=(0,Be.useCallback)(()=>{if(i.current&&!p){l.current=!0;let T=i.current.textContent||"";a.current=T,o(T),requestAnimationFrame(()=>{l.current=!1})}},[o,p]),b=(0,Be.useCallback)(T=>{var R;if(p){T.preventDefault(),T.stopPropagation();return}if(T.key==="Enter"&&(T.preventDefault(),(R=i.current)==null||R.blur()),(T.metaKey||T.ctrlKey)&&T.key==="a"&&(T.preventDefault(),T.stopPropagation(),i.current)){let E=document.createRange();E.selectNodeContents(i.current);let C=window.getSelection();C==null||C.removeAllRanges(),C==null||C.addRange(E)}},[p]),y=(0,Be.useCallback)(()=>{u(!0)},[]),N=(0,Be.useCallback)(()=>{u(!1)},[]),g=(0,Be.useCallback)(T=>{let R=i.current;if(!R)return;if(p&&n){T.stopPropagation(),setTimeout(()=>{R.focus();let x=document.createRange();x.selectNodeContents(R),x.collapse(!1);let w=window.getSelection();w==null||w.removeAllRanges(),w==null||w.addRange(x)},0);return}if(!n)return;let E=s(()=>{let x=window.getSelection();if(!x||x.rangeCount===0)return;let w=x.getRangeAt(0),A=R.contains(w.startContainer),k=R.contains(w.endContainer);if(A&&!k){let L=document.createRange();L.selectNodeContents(R),x.removeAllRanges(),x.addRange(L)}},"checkAndConstrainSelection"),C=s(x=>{let w=R.getBoundingClientRect();(x.clientX<w.left||x.clientX>w.right||x.clientY<w.top||x.clientY>w.bottom)&&E(),document.removeEventListener("mouseup",C)},"handleMouseUp");document.addEventListener("mouseup",C)},[n,p]),P=p?(0,Et.jsx)(wh,{parts:d}):n?null:e,M=(0,Be.useCallback)(T=>{p&&n&&T.stopPropagation()},[p,n]);return(0,Et.jsx)("div",{ref:i,contentEditable:n&&!p,suppressContentEditableWarning:!0,tabIndex:n&&p?0:void 0,onInput:h,onKeyDown:b,onPointerDown:g,onClick:M,onFocus:y,onBlur:N,className:I("courier-inline-flex courier-justify-start courier-px-2 courier-py-1 courier-text-sm courier-rounded-sm courier-border courier-border-border courier-outline-none",n&&!p&&"courier-cursor-text"),style:{backgroundColor:t,color:r,borderColor:"transparent",borderRadius:"4px",caretColor:r,WebkitUserSelect:"text",userSelect:"text"},children:P})},"EditableButton"),kh=s(({button1Label:e,button1Link:t,button1BackgroundColor:r,button1TextColor:o,button2Label:n,button2Link:i,button2BackgroundColor:a,button2TextColor:l,padding:c=6,onButton1LabelChange:u,onButton2LabelChange:d,editable:m=!1})=>(0,Et.jsx)("div",{className:"node-element",children:(0,Et.jsxs)("div",{className:"courier-flex courier-gap-1 courier-justify-start",style:{marginTop:`${c}px`,marginBottom:`${c}px`},children:[(0,Et.jsx)(Bf,{label:e,backgroundColor:r,textColor:o,onLabelChange:u||(()=>{}),editable:m},"button1"),(0,Et.jsx)(Bf,{label:n,backgroundColor:a,textColor:l,onLabelChange:d||(()=>{}),editable:m},"button2")]})}),"ButtonRowComponent"),Df=s(e=>{let t=(0,Xs.useSetAtom)(Xe),r=(0,Be.useRef)({}),o=(0,Be.useRef)({}),n=(0,Be.useCallback)(()=>{if(!e.editor.isEditable)return;let l=pt(e);l&&t(l)},[e,t]),i=(0,Be.useCallback)(l=>{o.current.button1=l,r.current.button1&&clearTimeout(r.current.button1),r.current.button1=setTimeout(()=>{o.current.button1!==void 0&&e.updateAttributes({button1Label:o.current.button1})},300)},[e]),a=(0,Be.useCallback)(l=>{o.current.button2=l,r.current.button2&&clearTimeout(r.current.button2),r.current.button2=setTimeout(()=>{o.current.button2!==void 0&&e.updateAttributes({button2Label:o.current.button2})},300)},[e]);return(0,Be.useEffect)(()=>{let l=r.current;return()=>{l.button1&&clearTimeout(l.button1),l.button2&&clearTimeout(l.button2)}},[]),(0,Et.jsx)(It,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"buttonRow",children:(0,Et.jsx)(kh,{...e.node.attrs,onButton1LabelChange:i,onButton2LabelChange:a,editable:e.editor.isEditable})})},"ButtonRowComponentNode");var Zr={button1Label:"Register",button1Link:"",button1BackgroundColor:"#000000",button1TextColor:"#ffffff",button2Label:"Learn more",button2Link:"",button2BackgroundColor:"#ffffff",button2TextColor:"#000000",padding:6},el=Qs.Node.create({name:"buttonRow",group:"block",atom:!0,selectable:!1,onCreate(){dt(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${(0,Vf.v4)()}`,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.id})},button1Label:{default:Zr.button1Label,parseHTML:e=>e.getAttribute("data-button1-label"),renderHTML:e=>({"data-button1-label":e.button1Label})},button1Link:{default:Zr.button1Link,parseHTML:e=>e.getAttribute("data-button1-link"),renderHTML:e=>({"data-button1-link":e.button1Link})},button1BackgroundColor:{default:Zr.button1BackgroundColor,parseHTML:e=>e.getAttribute("data-button1-bg"),renderHTML:e=>({"data-button1-bg":e.button1BackgroundColor})},button1TextColor:{default:Zr.button1TextColor,parseHTML:e=>e.getAttribute("data-button1-color"),renderHTML:e=>({"data-button1-color":e.button1TextColor})},button2Label:{default:Zr.button2Label,parseHTML:e=>e.getAttribute("data-button2-label"),renderHTML:e=>({"data-button2-label":e.button2Label})},button2Link:{default:Zr.button2Link,parseHTML:e=>e.getAttribute("data-button2-link"),renderHTML:e=>({"data-button2-link":e.button2Link})},button2BackgroundColor:{default:Zr.button2BackgroundColor,parseHTML:e=>e.getAttribute("data-button2-bg"),renderHTML:e=>({"data-button2-bg":e.button2BackgroundColor})},button2TextColor:{default:Zr.button2TextColor,parseHTML:e=>e.getAttribute("data-button2-color"),renderHTML:e=>({"data-button2-color":e.button2TextColor})},padding:{default:Zr.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,Qs.mergeAttributes)(e,{"data-type":"buttonRow"})]},addNodeView(){return(0,Ff.ReactNodeViewRenderer)(Df,{stopEvent:({event:e})=>!(e.type==="dragstart"||e.type==="drop")})},addCommands(){return{setButtonRow:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...Zr,...e}}).run()}}});var rl=require("@tiptap/core"),Wf=require("@tiptap/react"),_f=require("uuid");var Of=require("@tiptap/react"),tl=require("jotai"),yr=require("react");var qr=require("react/jsx-runtime"),Ph=s(({columnId:e,index:t,isPreviewMode:r})=>{let o=(0,yr.useRef)(null),[n,i]=(0,yr.useState)(!1);return(0,yr.useEffect)(()=>{let a=o.current;if(a)return br({element:a,getData:()=>({type:"column-cell",columnId:e,index:t,isEmpty:!0}),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e,t]),(0,qr.jsx)("div",{ref:o,"data-placeholder-cell":"true","data-column-cell":"true","data-column-id":e,"data-cell-index":t,onClick:a=>{a.stopPropagation()},className:I("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4",!r&&"courier-border",!r&&(n?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),!r&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:!r&&(0,qr.jsx)("span",{className:"courier-pointer-events-none",children:"Drag and drop content blocks"})})},"PlaceholderCell"),Nh=s(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderWidth:o,borderRadius:n,borderColor:i,node:a,columnsCount:l,isPreviewMode:c=!1})=>{var p;let u=!a.content||a.content.size===0,d={borderWidth:`${o}px`,borderStyle:o>0?"solid":"none",borderColor:i,borderRadius:`${n}px`},m={padding:`${t}px ${e}px`,backgroundColor:r};if(u){let f=((p=a.attrs)==null?void 0:p.id)||"";return(0,qr.jsx)("div",{className:"courier-w-full node-element",style:m,children:(0,qr.jsx)("div",{className:"courier-w-full courier-flex courier-gap-2 courier-p-2",style:d,children:Array.from({length:l}).map((v,h)=>(0,qr.jsx)(Ph,{columnId:f,index:h,isPreviewMode:c},h))})})}return(0,qr.jsx)("div",{className:"courier-w-full node-element",style:m,children:(0,qr.jsx)("div",{className:"courier-w-full courier-p-2",style:d,children:(0,qr.jsx)(Of.NodeViewContent,{})})})},"ColumnComponent"),Uf=s(e=>{let t=(0,tl.useSetAtom)(Xe),r=(0,tl.useAtomValue)(jt),[o,n]=(0,yr.useState)(!1),[i,a]=(0,yr.useState)(e.editor.isEditable);(0,yr.useEffect)(()=>{let m=s(()=>{a(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",m),e.editor.on("transaction",m),e.editor.on("selectionUpdate",m),()=>{e.editor.off("update",m),e.editor.off("transaction",m),e.editor.off("selectionUpdate",m)}},[e.editor]);let l=!i&&!r,c=(0,yr.useCallback)(m=>{var M,T;if(!e.editor.isEditable)return;let p=m.target,f=m.currentTarget,v=p===f,h=p.classList.contains("node-element"),b=p.classList.contains("courier-p-2"),y=p.classList.contains("courier-gap-2"),N=p.classList.contains("draggable-item"),g=p.hasAttribute("data-drag-handle")||p.closest("[data-drag-handle]")!==null;if(v||h||b||y||N||g||((T=(M=p.closest("[data-node-view-content]"))==null?void 0:M.parentElement)==null?void 0:T.classList.contains("node-element"))){m.stopPropagation(),g||m.preventDefault();let R=pt(e);if(R){e.editor.commands.blur();let E=R.attrs.id;e.editor.state.doc.descendants(C=>C.type.name==="column"&&C.attrs.id===E?(t(C),!1):!0)}}},[e,t]),u=(0,yr.useCallback)(m=>{let p=m.target,f=m.currentTarget;if(!(p.closest("[data-column-cell]")!==null)){n(!0);return}let h=f.getBoundingClientRect(),b=m.clientY,y=30,N=b<=h.top+y||b>=h.bottom-y;n(N)},[]),d=(0,yr.useCallback)(()=>{n(!1)},[]);return(0,qr.jsx)(It,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element",o&&"hover-edge-zone"),onMouseDown:c,onMouseMove:u,onMouseLeave:d,editor:e.editor,getPos:e.getPos,"data-node-type":"column",children:(0,qr.jsx)(Nh,{...e.node.attrs,node:e.node,columnsCount:e.node.attrs.columnsCount||2,isPreviewMode:l})})},"ColumnComponentNode");var wt={columnsCount:2,paddingHorizontal:0,paddingVertical:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"transparent",cells:[]},ol=rl.Node.create({name:"column",group:"block",content:"columnRow?",isolating:!0,selectable:!1,onCreate(){dt(this.editor,this.name)},addAttributes(){return{columnsCount:{default:wt.columnsCount,parseHTML:e=>e.getAttribute("data-columns-count"),renderHTML:e=>({"data-columns-count":e.columnsCount})},paddingHorizontal:{default:wt.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:wt.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:wt.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:wt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:wt.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:wt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:()=>`node-${(0,_f.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})},cells:{default:[],parseHTML:e=>{let t=e.getAttribute("data-cells");return t?JSON.parse(t):[]},renderHTML:e=>({"data-cells":JSON.stringify(e.cells||[])})}}},parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,rl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"column"}),0]},addNodeView(){return(0,Wf.ReactNodeViewRenderer)(Uf)},addCommands(){return{setColumn:e=>({chain:t})=>{let r=e.columnsCount||wt.columnsCount,o=`node-${Date.now()}`,n=Array.from({length:r},(i,a)=>({type:"columnCell",attrs:{index:a,columnId:o},content:[{type:"paragraph"}]}));return t().insertContent({type:this.name,attrs:{...e,id:o},content:[{type:"columnRow",content:n}]}).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)==="column"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"}}}});var $f=require("@hookform/resolvers/zod"),Zf=require("react-hook-form");var Cr=require("zod"),zf=Cr.z.object({columnsCount:Cr.z.number().min(1).max(4).default(2),paddingHorizontal:Cr.z.number().default(0),paddingVertical:Cr.z.number().default(0),backgroundColor:Cr.z.string().default("transparent"),borderWidth:Cr.z.number().default(0),borderRadius:Cr.z.number().default(0),borderColor:Cr.z.string().default("transparent"),cells:Cr.z.array(Cr.z.object({elements:Cr.z.array(Cr.z.any())})).optional()});var K=require("react/jsx-runtime"),ud=s(({element:e,editor:t})=>{let r=(0,Zf.useForm)({resolver:(0,$f.zodResolver)(zf),defaultValues:{...wt,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:"column"}),n=s(i=>{if(!t||!e)return;let a=null;if(t.state.doc.descendants((f,v)=>f.attrs.id===e.attrs.id&&f.type.name==="column"?(a=v,!1):!0),a===null)return;let l=t.state.doc.nodeAt(a);if(!l)return;let c=e.attrs.id,u=t.schema,d=t.state.tr,m=l.firstChild;if(!m||m.type.name!=="columnRow"){let f=Array.from({length:i},(h,b)=>u.nodes.columnCell.create({index:b,columnId:c,isEditorMode:!1})),v=u.nodes.columnRow.create({},f);d.replaceWith(a+1,a+l.nodeSize-1,v),d.setNodeMarkup(a,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d);return}let p=m.childCount;if(i!==p){if(i>p){let f=i-p,h=a+1+m.nodeSize-1;for(let b=0;b<f;b++){let y=u.nodes.columnCell.create({index:p+b,columnId:c});d.insert(h+b*y.nodeSize,y)}}else{let f=p-i,h=a+1;for(let y=0;y<p-f;y++){let N=m.child(y);h+=N.nodeSize}let b=0;for(let y=p-f;y<p;y++){let N=m.child(y);b+=N.nodeSize}d.delete(h,h+b)}d.setNodeMarkup(a,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d)}},"updateColumnCount");return e?(0,K.jsxs)(qe,{...r,children:[(0,K.jsx)(Lt,{type:"column",label:"Column layout"}),(0,K.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,K.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Columns count"}),(0,K.jsx)(j,{control:r.control,name:"columnsCount",render:({field:i})=>(0,K.jsxs)(q,{className:"courier-mb-4",children:[(0,K.jsx)(J,{children:(0,K.jsx)(Pr,{type:"single",className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-bg-secondary courier-p-0.5 courier-mb-3 courier-shadow-sm",value:i.value.toString(),onValueChange:a=>{if(a){let l=Number(a);i.onChange(l),n(l)}},children:[1,2,3,4].map(a=>(0,K.jsx)(_t,{value:a.toString(),className:"courier-w-12 courier-h-7",children:(0,K.jsx)("span",{className:"courier-text-sm courier-font-medium",children:a})},a))})}),(0,K.jsx)(G,{})]})}),(0,K.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,K.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Frame"}),(0,K.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,K.jsx)(j,{control:r.control,name:"paddingHorizontal",render:({field:i})=>(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(be,{startAdornment:(0,K.jsx)(ra,{}),type:"number",min:0,...i})}),(0,K.jsx)(G,{})]})}),(0,K.jsx)(j,{control:r.control,name:"paddingVertical",render:({field:i})=>(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(be,{startAdornment:(0,K.jsx)(hn,{}),type:"number",min:0,...i})}),(0,K.jsx)(G,{})]})})]}),(0,K.jsx)(j,{control:r.control,name:"backgroundColor",render:({field:i})=>(0,K.jsxs)(q,{className:"courier-mb-4",children:[(0,K.jsx)(J,{children:(0,K.jsx)(xt,{...i,defaultValue:wt.backgroundColor,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),(0,K.jsx)(G,{})]})}),(0,K.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,K.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Border"}),(0,K.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,K.jsx)(j,{control:r.control,name:"borderWidth",render:({field:i})=>(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(be,{startAdornment:(0,K.jsx)(xo,{}),type:"number",min:0,...i})}),(0,K.jsx)(G,{})]})}),(0,K.jsx)(j,{control:r.control,name:"borderRadius",render:({field:i})=>(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(be,{startAdornment:(0,K.jsx)(Gi,{}),type:"number",min:0,...i})}),(0,K.jsx)(G,{})]})})]}),(0,K.jsx)(j,{control:r.control,name:"borderColor",render:({field:i})=>(0,K.jsxs)(q,{className:"courier-mb-4",children:[(0,K.jsx)(J,{children:(0,K.jsx)(xt,{...i,defaultValue:wt.borderColor,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),(0,K.jsx)(G,{})]})})]})]}):null},"ColumnForm");var nl=require("@tiptap/core"),il=nl.Node.create({name:"columnRow",group:"columnContent",content:"columnCell+",isolating:!0,parseHTML(){return[{tag:'div[data-type="column-row"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,nl.mergeAttributes)(e,{"data-type":"column-row",class:"courier-flex courier-flex-row courier-gap-2 courier-w-full",style:"display: flex; flex-direction: row; gap: 0.5rem; width: 100%;"}),0]},addCommands(){return{insertColumnRow:()=>({chain:e})=>e().insertContent({type:this.name}).run()}}});var sl=require("@tiptap/core"),jf=require("@tiptap/react"),ll=require("@tiptap/pm/state");var al=require("@tiptap/react"),Yo=require("react");var qf=require("jotai");var Ia=require("react/jsx-runtime"),Jf=s(e=>{let t=(0,Yo.useRef)(null),[r,o]=(0,Yo.useState)(!1),n=(0,qf.useAtomValue)(jt),i=e.node.attrs.isEditorMode===!0,[a,l]=(0,Yo.useState)(e.editor.isEditable);(0,Yo.useEffect)(()=>{let d=t.current;if(d)return br({element:d,getData:()=>({type:"column-cell",columnId:e.node.attrs.columnId,index:e.node.attrs.index}),onDragEnter:()=>o(!0),onDragLeave:()=>o(!1),onDrop:()=>o(!1)})},[e.node.attrs.columnId,e.node.attrs.index]),(0,Yo.useEffect)(()=>{let d=s(()=>{l(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",d),e.editor.on("transaction",d),e.editor.on("selectionUpdate",d),()=>{e.editor.off("update",d),e.editor.off("transaction",d),e.editor.off("selectionUpdate",d)}},[e.editor]);let c=!a&&!n,u=!i&&!c;return(0,Ia.jsxs)(al.NodeViewWrapper,{ref:t,"data-column-cell":"true","data-column-id":e.node.attrs.columnId,"data-cell-index":e.node.attrs.index,className:I("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4 courier-pl-0 courier-w-full",!c&&"courier-border",!c&&(r?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),u&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:[u&&(0,Ia.jsx)("span",{className:"courier-pointer-events-none courier-pl-4",children:"Drag and drop content blocks"}),(0,Ia.jsx)(al.NodeViewContent,{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full"})]})},"ColumnCellComponentNode");var cl=sl.Node.create({name:"columnCell",group:"columnRow",content:"block*",isolating:!0,selectable:!1,addAttributes(){return{index:{default:0,parseHTML:e=>{let t=e.getAttribute("data-cell-index");return t?parseInt(t,10):0},renderHTML:e=>({"data-cell-index":e.index})},columnId:{default:null,parseHTML:e=>e.getAttribute("data-column-id"),renderHTML:e=>({"data-column-id":e.columnId})},isEditorMode:{default:!1,parseHTML:e=>e.getAttribute("data-editor-mode")==="true",renderHTML:e=>({"data-editor-mode":e.isEditorMode?"true":"false"})}}},parseHTML(){return[{tag:'div[data-type="column-cell"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,sl.mergeAttributes)(e,{"data-type":"column-cell",style:"flex: 1 1 0%; width: 0; min-height: 120px;"}),0]},addNodeView(){return(0,jf.ReactNodeViewRenderer)(Jf)},addCommands(){return{insertColumnCell:()=>({chain:e})=>e().insertContent({type:this.name}).run()}},addProseMirrorPlugins(){return[new ll.Plugin({key:new ll.PluginKey("columnCellCleanup"),appendTransaction:(e,t,r)=>{if(!e.some(i=>i.docChanged))return null;let o=r.tr,n=!1;return r.doc.descendants((i,a)=>{var l,c;if(i.type.name==="columnCell"){let u=i.childCount===0,d=i.childCount===1&&((l=i.firstChild)==null?void 0:l.type.name)==="paragraph"&&((c=i.firstChild)==null?void 0:c.content.size)===0,m=i.attrs.isEditorMode;u?m=!1:u||(m=!0),m!==i.attrs.isEditorMode&&(o.setNodeAttribute(a,"isEditorMode",m),n=!0),d&&m===!1&&(o.delete(a+1,a+i.nodeSize-1),n=!0)}return!0}),n?o:null}})]}});var ul=require("@tiptap/core"),Xf=require("@tiptap/react"),Qf=require("uuid");var Gf=require("jotai"),Kf=require("react");var La=require("react/jsx-runtime"),Mh=s(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return(0,La.jsx)("div",{className:"courier-w-full node-element",children:(0,La.jsx)("div",{className:"courier-custom-code courier-py-1.5",dangerouslySetInnerHTML:t?{__html:e}:{__html:" "}})})},"CustomCodeComponent"),Yf=s(e=>{let t=(0,Gf.useSetAtom)(Xe),r=(0,Kf.useCallback)(()=>{if(!e.editor.isEditable)return;let i=pt(e);if(i){e.editor.commands.blur();let a=i.attrs.id;e.editor.state.doc.descendants(l=>l.type.name==="customCode"&&l.attrs.id===a?(t(l),!1):!0)}},[e,t]),o=e.node.attrs.code,n=!o||o.trim()===""||o==="<!-- Add your HTML code here -->";return(0,La.jsx)(It,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element",n&&"is-empty"),onClick:r,editor:e.editor,"data-node-type":"customCode",children:(0,La.jsx)(Mh,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var wo={code:"<!-- Add your HTML code here -->"},dl=ul.Node.create({name:"customCode",group:"block",atom:!0,selectable:!1,onCreate(){dt(this.editor,this.name)},addAttributes(){return{code:{default:wo.code,parseHTML:e=>e.getAttribute("data-code")||"",renderHTML:e=>({"data-code":e.code})},id:{default:()=>`node-${(0,Qf.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="custom-code"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,ul.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"custom-code"}),["div",{innerHTML:e.code||wo.code}]]},addNodeView(){return(0,Xf.ReactNodeViewRenderer)(Yf)},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 kt=require("react");var e1=require("react"),t1=require("react/jsx-runtime"),dd=(0,e1.forwardRef)(({className:e,...t},r)=>{let o=I("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,t1.jsx)("div",{className:o,ref:r,...t})});dd.displayName="Spinner";var Sn=require("react/jsx-runtime"),Ah=s(()=>{let[e,t]=(0,kt.useState)(!1),r=(0,kt.useRef)(null);return(0,kt.useEffect)(()=>{var i;let o=s(()=>{if(r.current){let a=r.current.closest(".dark")!==null;t(a)}},"checkDarkMode");o();let n=new MutationObserver(o);return(i=r.current)!=null&&i.parentElement&&n.observe(document.body,{attributes:!0,attributeFilter:["class"],subtree:!0}),()=>n.disconnect()},[]),{isDark:e,containerRef:r}},"useIsDarkMode"),Sh=(0,kt.lazy)(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function Ih(e,t){let r=(0,kt.useRef)();return(0,kt.useCallback)((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}s(Ih,"useDebounce");var Lh=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 l=(e.match(/</g)||[]).length,c=(e.match(/>/g)||[]).length;if(l!==c||new DOMParser().parseFromString(e,"text/html").getElementsByTagName("parsererror").length>0)return!1;let p=(e.match(/<([a-z][a-z0-9]*)\b[^>]*(?<!\/\/)>/gi)||[]).map(b=>{var y,N;return(N=(y=b.match(/<([a-z][a-z0-9]*)/i))==null?void 0:y[1])==null?void 0:N.toLowerCase()}).filter(Boolean),f=(e.match(/<\/([a-z][a-z0-9]*)\s*>/gi)||[]).map(b=>{var y,N;return(N=(y=b.match(/<\/([a-z][a-z0-9]*)/i))==null?void 0:y[1])==null?void 0:N.toLowerCase()}).filter(Boolean),v=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],h=p.filter(b=>b&&!v.includes(b));for(let b of h){let y=p.filter(g=>g===b).length,N=f.filter(g=>g===b).length;if(y!==N)return!1}return!0}catch{return!1}},"defaultHTMLValidator"),ml=s(({code:e,onSave:t,onValidationChange:r,validator:o=Lh})=>{let n=(0,kt.useRef)(null),i=(0,kt.useRef)(null),[a,l]=(0,kt.useState)(!0),{isDark:c,containerRef:u}=Ah(),d=(0,kt.useCallback)(()=>{if(!n.current||!i.current)return!0;let v=n.current.getModel();if(!v)return!0;let h=v.getValue(),b=o(h,n.current,i.current);return b!==a&&(l(b),r==null||r(b)),b},[a,r,o]),m=Ih(v=>{setTimeout(()=>{d()&&t(v)},150)},500);return(0,Sn.jsx)("div",{ref:u,className:"courier-h-full courier-overflow-hidden",children:(0,Sn.jsx)("div",{className:"courier-h-full courier-p-2",children:(0,Sn.jsx)(kt.Suspense,{fallback:(0,Sn.jsx)("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:(0,Sn.jsx)(dd,{})}),children:(0,Sn.jsx)(Sh,{height:"100%",defaultLanguage:"html",value:e,onChange:s(v=>{m(v||"")},"handleCodeChange"),onMount:s((v,h)=>{n.current=v,i.current=h,v.focus(),v.onDidChangeModelContent(()=>{setTimeout(d,100)}),setTimeout(d,100)},"handleEditorDidMount"),theme:c?"vs-dark":"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 o1=require("@hookform/resolvers/zod"),n1=require("react-hook-form");var md=require("zod"),r1=md.z.object({code:md.z.string()});var i1=require("react"),a1=require("jotai");var et=require("react/jsx-runtime"),pd=s(({element:e,editor:t})=>{let r=(0,n1.useForm)({resolver:(0,o1.zodResolver)(r1),defaultValues:{...wo,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:"customCode"}),[n,i]=(0,a1.useAtom)(io),a=(0,i1.useCallback)(l=>{r.setValue("code",l),o({code:l})},[r,o]);return e?(0,et.jsxs)(qe,{...r,children:[!n&&(0,et.jsx)(Lt,{type:"customCode"}),(0,et.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[(0,et.jsx)(Se,{className:"courier-w-fit",variant:"outline",buttonSize:"small",onClick:()=>i(!n),children:n?(0,et.jsxs)(et.Fragment,{children:[(0,et.jsx)(Au,{className:"courier-w-3 courier-h-3"}),"Minimize"]}):(0,et.jsxs)(et.Fragment,{children:[(0,et.jsx)(Ki,{className:"courier-w-3 courier-h-3"}),"Expand Editor"]})}),(0,et.jsx)("div",{className:"courier-mb-4 courier-overflow-hidden courier-rounded-md courier-border courier-border-border",style:{minHeight:"200px",height:"300px",resize:"vertical",overflow:"auto"},children:(0,et.jsx)("form",{onChange:()=>{o(r.getValues())},className:"courier-h-full",children:(0,et.jsx)(j,{control:r.control,name:"code",render:({field:l})=>(0,et.jsxs)(q,{className:"courier-h-full",children:[(0,et.jsx)(J,{children:(0,et.jsx)(ml,{code:l.value,onSave:c=>{l.onChange(c),a(c)},onCancel:()=>{}})}),(0,et.jsx)(G,{})]})})})})]})]}):null},"CustomCodeForm");var d1=require("@tiptap/core");var Xo=require("@tiptap/core"),yi=require("@tiptap/pm/state"),s1=Xo.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",(0,Xo.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,Xo.isNodeSelection)(r)?i.insertContentAt(n.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:a,dispatch:l})=>{var c;if(l){let{$to:u}=a.selection,d=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?a.setSelection(yi.TextSelection.create(a.doc,u.pos+1)):u.nodeAfter.isBlock?a.setSelection(yi.NodeSelection.create(a.doc,u.pos)):a.setSelection(yi.TextSelection.create(a.doc,u.pos));else{let m=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();m&&(a.insert(d,m),a.setSelection(yi.TextSelection.create(a.doc,d+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(0,Xo.nodeInputRule)({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var m1=require("@tiptap/react"),p1=require("uuid");var l1=require("jotai"),c1=require("react");var Ra=require("react/jsx-runtime"),Rh=s(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>(0,Ra.jsx)("div",{className:"courier-w-full node-element courier-flex",children:(0,Ra.jsx)("hr",{style:{marginTop:`${e}px`,marginBottom:`${e}px`,backgroundColor:n==="spacer"?"transparent":t,height:`${r}px`,borderRadius:`${o}px`,border:"none",width:"100%"},"data-variant":n})}),"DividerComponent"),u1=s(e=>{let t=(0,l1.useSetAtom)(Xe),r=(0,c1.useCallback)(()=>{if(!e.editor.isEditable)return;let o=pt(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return(0,Ra.jsx)(It,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:(0,Ra.jsx)(Rh,{...e.node.attrs})})},"DividerComponentNode");var vr={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},pl={padding:24,color:"transparent",size:1,radius:0,variant:"spacer"},fd=s1.extend({name:"divider",atom:!0,onCreate(){dt(this.editor,this.name)},addAttributes(){return{padding:{default:vr.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.margin})},size:{default:vr.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},color:{default:vr.color,parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color})},width:{default:vr.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},radius:{default:vr.radius,parseHTML:e=>e.getAttribute("data-radius"),renderHTML:e=>({"data-radius":e.radius})},variant:{default:vr.variant,parseHTML:e=>e.getAttribute("data-variant"),renderHTML:e=>({"data-variant":e.variant})},id:{default:()=>`node-${(0,p1.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,d1.mergeAttributes)(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return(0,m1.ReactNodeViewRenderer)(u1)},addInputRules(){return[]}});var In=require("zod"),f1=In.z.object({padding:In.z.number(),color:In.z.string(),size:In.z.number(),radius:In.z.number(),variant:In.z.enum(["divider","spacer"]).default("divider")});var g1=require("@hookform/resolvers/zod"),h1=require("react-hook-form");var ke=require("react/jsx-runtime"),b1=s(({element:e,editor:t})=>{let r=(0,h1.useForm)({resolver:(0,g1.zodResolver)(f1),defaultValues:{...vr,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:"divider"});if(!e)return null;let n=r.watch("variant");return(0,ke.jsxs)(qe,{...r,children:[(0,ke.jsx)(Lt,{type:n}),(0,ke.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,ke.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,ke.jsx)(j,{control:r.control,name:"padding",render:({field:i})=>(0,ke.jsxs)(q,{children:[(0,ke.jsx)(J,{children:(0,ke.jsx)(be,{startAdornment:(0,ke.jsx)(hn,{}),type:"number",...i,onChange:a=>{i.onChange(a),o({...r.getValues(),margin:a.target.value})}})}),(0,ke.jsx)(G,{})]})}),n==="divider"&&(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,ke.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Line"}),(0,ke.jsx)(j,{control:r.control,name:"size",render:({field:i})=>(0,ke.jsxs)(q,{className:"courier-mb-4",children:[(0,ke.jsx)(J,{children:(0,ke.jsx)(be,{startAdornment:(0,ke.jsx)(xo,{}),type:"number",min:0,...i,onChange:a=>{i.onChange(a),o({...r.getValues(),width:a.target.value})}})}),(0,ke.jsx)(G,{})]})}),(0,ke.jsx)(j,{control:r.control,name:"color",render:({field:i})=>(0,ke.jsxs)(q,{className:"courier-mb-4",children:[(0,ke.jsx)(J,{children:(0,ke.jsx)(xt,{...i,defaultValue:vr.color,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),(0,ke.jsx)(G,{})]})})]})]})]})},"DividerForm");var gd=mi.extend({content:"(block)+"});var v1=require("@tiptap/core"),x1=require("@tiptap/react");var y1=require("@tiptap/react"),Ln=require("react");var Ha=require("react/jsx-runtime");function Hh(){let[e,t]=(0,Ln.useState)(!1);return(0,Ln.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(Hh,"useMountStatus");var Bh=(0,Ln.forwardRef)(({children:e,className:t,dragOverlay:r,id:o},n)=>((0,Ln.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),(0,Ha.jsx)(y1.NodeViewWrapper,{ref:n,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":o,"data-placeholder":"true",className:I("courier-flex courier-items-start courier-gap-2 courier-pl-6",t),children:e}))),Dh=s(e=>{switch(e){case"text":return"Text";case"heading":return"Heading";case"spacer":return"Spacer";case"divider":return"Divider";case"button":return"Button";case"image":return"Image";case"customCode":return"Custom code";case"column":return"Column layout";default:return e}},"getPlaceholderLabel"),C1=s(({node:e})=>{let t=e.attrs.type,r=e.attrs.id,o=Hh();return(0,Ha.jsx)(Bh,{id:r,fadeIn:!o,children:(0,Ha.jsx)("div",{className:I("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,Ha.jsx)("div",{className:"courier-text-accent-foreground",children:Dh(t)})})})},"DragPlaceholderComponent");var T1=v1.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,x1.ReactNodeViewRenderer)(C1,{as:"div",className:"drag-placeholder-wrapper"})}});var E1=require("@tiptap/core"),fl=require("@tiptap/pm/state"),Fh=new fl.PluginKey("file-handler"),Vh=E1.Extension.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new fl.Plugin({key:Fh,props:{handleDrop:(o,n,i,a)=>{var d;if(!((d=n.dataTransfer)!=null&&d.files)||a)return!1;let{files:l}=n.dataTransfer,c=o.posAtCoords({left:n.clientX,top:n.clientY});if(!c)return!1;let u=Array.from(l).filter(m=>e==null?void 0:e.includes(m.type));return u.length===0?!1:(n.preventDefault(),t&&t(this.editor,u,c.pos),!0)},handlePaste:(o,n)=>{var l;if(!((l=n.clipboardData)!=null&&l.files))return!1;let{files:i}=n.clipboardData,a=Array.from(i).filter(c=>e==null?void 0:e.includes(c.type));return a.length===0?!1:(n.preventDefault(),r&&r(this.editor,a),!0)}}})]}}),gl=Vh;var w1=require("@tiptap/core"),hl=require("@tiptap/pm/state");var Oh=new hl.PluginKey("fixedChannelPaste"),Uh=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 l=i===1&&a===0,c=i===2&&a===0,u=i>=2&&i+a<=4;return l||c||u},"isInFixedChannel"),Wh=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(`
|
|
186
|
+
`).trim()},"extractTextFromSlice"),bl=w1.Extension.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new hl.Plugin({key:Oh,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!Uh(e))return!1;let l=i.$from.node();if(!(l.type.name==="paragraph"||l.type.name==="heading")||o.content.childCount<=1)return!1;let u=Wh(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 P1=require("@tiptap/core"),Qo=require("@tiptap/pm/state");var Rn=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"),hd=s(e=>!!e.view.dom.closest(".courier-inbox-editor"),"isInInboxChannel"),k1=s(e=>{if(!hd(e))return!1;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.node(o-1),a=r.start(o),l=0;return i.forEach((c,u)=>{if(r.start(o-1)+u+1===a)return!1;l++}),l<=1}o--}return!1},"isInFixedInboxNode"),Hn=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"),yl=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,l=null;for(;n>0;){let c=r.node(n);if(c.type.name==="paragraph"||c.type.name==="heading"){a={node:c,depth:n};break}n--}for(;i>0;){let c=o.node(i);if(c.type.name==="paragraph"||c.type.name==="heading"){l={node:c,depth:i};break}i--}return!!(a&&l&&a.node!==l.node)},"isMultiElementSelection"),Cl=new Qo.PluginKey("fixedChannelSelection"),vl=P1.Extension.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!Rn(e,this.options.channels))return!1;let o=Hn(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 l=Math.max(a.from,n),c=Math.min(a.to,i);return r&&t.setSelection(Qo.TextSelection.create(t.doc,l,c)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!Rn(e,this.options.channels))return!1;let t=Hn(e);if(!t)return!1;let{start:r,end:o}=t;return e.commands.setTextSelection({from:r,to:o}),!0},Backspace:({editor:e})=>{if(!Rn(e,this.options.channels))return!1;if(hd(e)){let{selection:t}=e.state;if(Hn(e)&&t.$anchor.parentOffset===0&&k1(e))return!0}if(yl(e)){let t=Hn(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(!Rn(e,this.options.channels))return!1;if(hd(e)){let{selection:t}=e.state,r=Hn(e);if(r){let o=r.node.textContent;if(t.$anchor.parentOffset===o.length&&k1(e))return!0}}if(yl(e)){let t=Hn(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 Qo.Plugin({key:Cl,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!Rn(o,this.options.channels))return!1;if(yl(o)){let n=Hn(o);if(n){let{start:i,end:a}=n,l=Math.max(t,i),c=Math.min(r,a),u=e.state.tr;u.setSelection(Qo.TextSelection.create(u.doc,l,c)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!Rn(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(Cl,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!Rn(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&yl(r)){let n=Cl.getState(e.state);if(n!=null&&n.elementStart&&(n!=null&&n.elementEnd)){let{selection:i}=e.state,a=Math.max(i.from,n.elementStart),l=Math.min(i.to,n.elementEnd),c=e.state.tr;return c.setSelection(Qo.TextSelection.create(c.doc,a,l)),e.dispatch(c),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(Cl)||t}}})]}});var H1=require("@tiptap/core");var Ci=require("@tiptap/core"),N1=Ci.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,Ci.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,Ci.textblockTypeInputRule)({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var uo=require("zod"),M1=uo.z.object({paddingVertical:uo.z.number(),paddingHorizontal:uo.z.number(),backgroundColor:uo.z.string(),borderWidth:uo.z.number(),borderColor:uo.z.string(),textAlign:uo.z.enum(["left","center","right","justify"]).default("left"),selected:uo.z.boolean().default(!1),id:uo.z.string().optional()}),pe={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderColor:"transparent",textAlign:"left",selected:!1};var xl=require("@tiptap/react");var Tl=require("jotai"),S1=require("react");var ko=require("react/jsx-runtime"),A1=s(({paddingVertical:e,paddingHorizontal:t,textAlign:r,backgroundColor:o,borderWidth:n,borderColor:i,level:a,type:l})=>{let c=l==="heading"?`h${a}`:"p",u=(0,Tl.useAtomValue)(jt);return(0,ko.jsx)("div",{className:"courier-w-full node-element",children:(0,ko.jsx)("div",{style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderColor:i,borderStyle:n>0?"solid":"none"},children:(0,ko.jsx)("div",{style:{pointerEvents:u?"none":"auto"},children:(0,ko.jsx)(xl.NodeViewContent,{as:c})})})})},"TextBlockComponent"),El=s(e=>{let t=(0,Tl.useSetAtom)(Xe),r=(0,S1.useCallback)(()=>{if(!e.editor.isEditable)return;let l=pt(e);l&&t(l)},[e,t]),o=!e.node.content||e.node.content.size===0,n=en(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null;return(i==null?void 0:i.parent.type.name)==="blockquote"?(0,ko.jsx)(xl.NodeViewWrapper,{children:(0,ko.jsx)(A1,{...e.node.attrs,type:e.node.type.name})}):(0,ko.jsx)(It,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:(0,ko.jsx)(A1,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");var I1=require("@hookform/resolvers/zod"),L1=require("react-hook-form");var ue=require("react/jsx-runtime"),R1=s(({element:e,editor:t})=>{let r=(0,L1.useForm)({resolver:(0,I1.zodResolver)(M1),defaultValues:{...pe,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?(0,ue.jsxs)(qe,{...r,children:[(0,ue.jsx)(Lt,{type:"text"}),(0,ue.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,ue.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,ue.jsx)(j,{control:r.control,name:"paddingHorizontal",render:({field:n})=>(0,ue.jsxs)(q,{children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(be,{startAdornment:(0,ue.jsx)(ra,{}),type:"number",min:0,...n})}),(0,ue.jsx)(G,{})]})}),(0,ue.jsx)(j,{control:r.control,name:"paddingVertical",render:({field:n})=>(0,ue.jsxs)(q,{children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(be,{startAdornment:(0,ue.jsx)(hn,{}),type:"number",min:0,...n})}),(0,ue.jsx)(G,{})]})})]}),(0,ue.jsx)(j,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,ue.jsxs)(q,{className:"courier-mb-4",children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(xt,{...n,defaultValue:pe.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ue.jsx)(G,{})]})}),(0,ue.jsx)(ce,{className:"courier-mb-4"}),(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,ue.jsx)(j,{control:r.control,name:"borderWidth",render:({field:n})=>(0,ue.jsxs)(q,{className:"courier-mb-3",children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(be,{startAdornment:(0,ue.jsx)(xo,{}),type:"number",min:0,...n})}),(0,ue.jsx)(G,{})]})}),(0,ue.jsx)(j,{control:r.control,name:"borderColor",render:({field:n})=>(0,ue.jsxs)(q,{className:"courier-mb-4",children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(xt,{...n,defaultValue:pe.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ue.jsx)(G,{})]})})]})]}):null},"TextBlockForm");var B1=require("@tiptap/react");var bd=N1.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){dt(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:pe.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):pe.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:pe.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):pe.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:pe.textAlign,parseHTML:t=>t.style.textAlign||pe.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:pe.backgroundColor,parseHTML:t=>t.style.backgroundColor||pe.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:pe.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):pe.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderColor:{default:pe.borderColor,parseHTML:t=>t.style.borderColor||pe.borderColor,renderHTML:t=>({style:`border-color: ${t.borderColor}`})},id:{default:()=>null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>({"data-id":t.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},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,H1.mergeAttributes)(this.options.HTMLAttributes,t),0]},addNodeView(){return(0,B1.ReactNodeViewRenderer)(El)}});var wl=require("@tiptap/core"),F1=require("@tiptap/react");var yd=require("jotai"),Ve=require("react");var Pt=require("react/jsx-runtime"),_h=["image/png","image/jpeg","image/gif","image/webp"],zh=s(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderColor:n,isUploading:i,width:a,imageNaturalWidth:l,onFileSelect:c,editor:u})=>{let[d,m]=(0,Ve.useState)(!1),[p,f]=(0,Ve.useState)(!0),v=(0,Ve.useRef)(null),h=(0,Ve.useRef)(null);(0,Ve.useEffect)(()=>{e&&f(!0)},[e]),(0,Ve.useEffect)(()=>{if(e&&!l&&u){let C=new Image;C.onload=()=>{try{if(!u.view||!u.state)return;let x=u.view.state.selection.from;u.chain().setNodeSelection(x).updateAttributes("imageBlock",{imageNaturalWidth:C.naturalWidth}).run()}catch{}},C.src=e}},[e,l,u]);let b=(0,Ve.useCallback)(C=>{var k,L;let x=(L=(k=u==null?void 0:u.view)==null?void 0:k.dom)==null?void 0:L.closest(".ProseMirror"),w=(x==null?void 0:x.clientWidth)||1e3,A=Math.min(100,C/w*100);return Math.round(A)},[u]),y=(0,Ve.useMemo)(()=>b(l),[b,l]),N=(0,Ve.useCallback)(C=>_h.includes(C),[]),g=(0,Ve.useCallback)(C=>{C.preventDefault(),C.stopPropagation(),C.dataTransfer.types.includes("Files")&&Array.from(C.dataTransfer.items).some(A=>N(A.type))&&(m(!0),C.dataTransfer.dropEffect="copy")},[N]),P=(0,Ve.useCallback)(C=>{C.preventDefault(),C.stopPropagation(),m(!1)},[]),M=(0,Ve.useCallback)(C=>{C.preventDefault(),C.stopPropagation(),C.dataTransfer.types.includes("Files")&&Array.from(C.dataTransfer.items).some(A=>N(A.type))&&m(!0)},[N]),T=(0,Ve.useCallback)(C=>{C.preventDefault(),C.stopPropagation(),m(!1);let w=Array.from(C.dataTransfer.files).find(A=>N(A.type));w&&c&&c(w)},[c,N]),R=(0,Ve.useCallback)(C=>{var w;let x=(w=C.target.files)==null?void 0:w[0];x&&c&&c(x),C.target&&(C.target.value="")},[c]),E=(0,Ve.useCallback)(()=>{var C;(C=v.current)==null||C.click()},[]);return Qa(e)?(0,Pt.jsxs)("div",{className:I("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 courier-text-center courier-flex-wrap courier-content-center courier-p-4",d&&"courier-border-primary courier-bg-gray-50"),onDragOver:g,onDragEnter:M,onDragLeave:P,onDrop:T,style:{pointerEvents:"all"},children:[i?(0,Pt.jsx)(yn,{className:"courier-w-8 courier-h-8"}):(0,Pt.jsxs)(Pt.Fragment,{children:[(0,Pt.jsx)("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),(0,Pt.jsx)("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:E,children:"Browse"})]}),(0,Pt.jsx)("input",{ref:v,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:R})]}):(0,Pt.jsx)("div",{className:"courier-w-full node-element",children:(0,Pt.jsxs)("div",{className:I("courier-relative courier-p-1",(i||p)&&"courier-w-full courier-aspect-[4/3] courier-bg-gray-100"),children:[(i||p)&&(0,Pt.jsx)("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:(0,Pt.jsx)(yn,{className:"courier-w-8 courier-h-8"})}),(0,Pt.jsx)("img",{ref:h,src:e,alt:t,className:I("courier-h-auto courier-inline-block courier-w-full",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[r],i&&"courier-opacity-50",(i||p)&&"courier-invisible"),style:{maxWidth:a===y?`${l}px`:`${a}%`,borderWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",display:"block"},loading:"lazy",decoding:"async",draggable:!1,onLoad:C=>{if(f(!1),!l&&u)try{if(!u.view||!u.state)return;setTimeout(()=>{let x=u.view.state.selection.from;u.chain().setNodeSelection(x).updateAttributes("imageBlock",{imageNaturalWidth:C.target.naturalWidth}).run()},100)}catch(x){console.warn("Editor not ready for image update:",x)}},onError:()=>f(!1)})]})})},"ImageBlockComponent"),$h=["image/png","image/jpeg","image/gif","image/webp"],D1=s(e=>{let t=(0,yd.useSetAtom)(Xe),r=(0,yd.useSetAtom)(Q),{uploadImage:o}=qn(),n=(0,Ve.useCallback)(l=>{var m,p,f;let c=(f=(p=(m=e.editor)==null?void 0:m.view)==null?void 0:p.dom)==null?void 0:f.closest(".ProseMirror"),u=(c==null?void 0:c.clientWidth)||1e3,d=Math.min(100,l/u*100);return Math.round(d)},[e.editor]);(0,Ve.useEffect)(()=>{var c,u;let l=pt(e);if((c=l==null?void 0:l.attrs)!=null&&c.sourcePath&&!((u=l==null?void 0:l.attrs)!=null&&u.imageNaturalWidth)){let d=new Image;d.onload=()=>{let m=l.attrs.width||n(d.naturalWidth),p=en(e.getPos);p!==null&&e.editor.chain().focus().setNodeSelection(p).updateAttributes("imageBlock",{width:m,imageNaturalWidth:d.naturalWidth}).run()},d.src=l.attrs.sourcePath}},[e,n]);let i=(0,Ve.useCallback)(()=>{if(!e.editor.isEditable)return;let l=pt(e);l&&(e.editor.commands.blur(),t(l))},[e,t]),a=(0,Ve.useCallback)(async l=>{let c=en(e.getPos);pt(e)&&c!==null&&e.editor.chain().focus().setNodeSelection(c).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!$h.includes(l.type))throw new Error("Only PNG, JPEG, GIF, and WebP images are supported");let d=new FileReader;d.readAsDataURL(l),await new Promise((h,b)=>{d.onload=h,d.onerror=b});let p=(await o({file:l})).url,f=en(e.getPos);if(pt(e)&&f!==null){let h=new Image;h.src=p,await new Promise((y,N)=>{h.onload=y,h.onerror=()=>N(new Error("Failed to load uploaded image"))});let b=n(h.naturalWidth);e.editor.chain().focus().setNodeSelection(f).updateAttributes("imageBlock",{sourcePath:p,isUploading:!1,width:b,imageNaturalWidth:h.naturalWidth}).run()}}catch(d){console.error("Error uploading image:",d);let m="Error uploading image";if(d instanceof Error){let v=d.message;v.includes("GraphQL error")?m="Server error: Could not process image":v.includes("network")||v.includes("fetch")?m="Network error: Could not upload image":m=v}r({message:m,toastProps:{duration:6e3,description:`File: ${l.name} (${(l.size/1024/1024).toFixed(2)}MB)`}});let p=en(e.getPos);pt(e)&&p!==null&&e.editor.chain().focus().setNodeSelection(p).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return(0,Pt.jsx)(It,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:(0,Pt.jsx)(zh,{...e.node.attrs,onFileSelect:a,editor:e.editor})})},"ImageBlockView");var at={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderColor:"transparent",isUploading:!1,imageNaturalWidth:0},kl=wl.Node.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){dt(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:at.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:at.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:at.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:at.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:at.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:at.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:at.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:at.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:at.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})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="image-block"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,wl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return(0,F1.ReactNodeViewRenderer)(D1)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...at,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...at,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 Jr=require("zod"),V1=Jr.z.object({sourcePath:Jr.z.string(),link:Jr.z.string().optional(),alt:Jr.z.string().optional(),alignment:Jr.z.enum(["left","center","right"]),width:Jr.z.number().min(1).max(100),borderWidth:Jr.z.number(),borderColor:Jr.z.string(),isUploading:Jr.z.boolean().optional(),imageNaturalWidth:Jr.z.number()});var O1=require("@hookform/resolvers/zod"),U1=require("jotai"),W1=require("lucide-react"),ft=require("react"),_1=require("react-hook-form");var Pl=require("jotai"),Da=he(require("react"),1),Cd=require("react");var Ba=require("react/jsx-runtime"),tn=Da.forwardRef(({as:e="Input",autoResize:t,onChange:r,...o},n)=>{let i=(0,Cd.useRef)(null),a=(0,Cd.useRef)(null),l=(0,Pl.useSetAtom)(la),c=(0,Pl.useSetAtom)(lp),u=(0,Pl.useSetAtom)(ys),d=Da.useCallback(()=>{if(!a.current)return;let h={ref:a.current,caretPosition:a.current.selectionStart};c(h),u(h),l({isFocused:!0,hasVariables:!1,showVariablePopup:!1})},[l,c,u]),m=Da.useCallback(h=>{var y;((y=h.relatedTarget)==null?void 0:y.closest("[data-variable-button]"))||(c({ref:null,caretPosition:null}),l({isFocused:!1,hasVariables:!1,showVariablePopup:!1}))},[l,c]),p=s(h=>{let b=h.target,y={ref:b,caretPosition:b.selectionStart};c(y),u(y)},"handleSelect"),f=s(h=>{r&&r(h)},"handleChange");if(e==="Input"){let h={...o,ref:b=>{a.current=b,typeof n=="function"?n(b):n&&(n.current=b)},onChange:f,onFocus:d,onBlur:m,onSelect:p};return(0,Ba.jsx)("div",{ref:i,className:"courier-relative",children:(0,Ba.jsx)(be,{...h})})}let v={...o,ref:h=>{a.current=h,typeof n=="function"?n(h):n&&(n.current=h)},onChange:f,onFocus:d,onBlur:m,autoResize:t,onSelect:p};return(0,Ba.jsx)("div",{ref:i,className:"courier-relative",children:(0,Ba.jsx)(Yc,{...v})})});tn.displayName="TextInput";var W=require("react/jsx-runtime"),z1=s(({element:e,editor:t})=>{var R,E;let r=(0,ft.useRef)(null),o=(0,ft.useRef)(null),n=(0,ft.useRef)(null),[i,a]=(0,ft.useState)(""),[l,c]=(0,ft.useState)(!1),[u,d]=(0,ft.useState)(((R=e==null?void 0:e.attrs)==null?void 0:R.imageNaturalWidth)||0),[m,p]=(0,ft.useState)(!1),f=(0,U1.useSetAtom)(Q),{uploadImage:v}=qn(),h=(0,_1.useForm)({resolver:(0,O1.zodResolver)(V1),defaultValues:{...at,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:b}=Tt({editor:t,element:e,form:h,nodeType:"imageBlock"});(0,ft.useEffect)(()=>{var x;let C=(x=e==null?void 0:e.attrs)==null?void 0:x.sourcePath;if(C&&!u){let w=new Image;w.onload=()=>{d(w.naturalWidth);let A={...h.getValues(),imageNaturalWidth:w.naturalWidth};h.setValue("imageNaturalWidth",w.naturalWidth),b(A)},w.src=C}},[(E=e==null?void 0:e.attrs)==null?void 0:E.sourcePath,u,h,b]);let y=(0,ft.useCallback)(C=>{var L,S;let x=(S=(L=t==null?void 0:t.view)==null?void 0:L.dom)==null?void 0:S.closest(".ProseMirror"),w=(x==null?void 0:x.clientWidth)||1e3;if(C||(C=u),!C)return 0;let A=Math.min(100,C/w*100);return Math.round(A)},[t,u]),N=(0,ft.useCallback)(C=>{var x;C.preventDefault(),(x=r.current)==null||x.click()},[]),g=(0,ft.useCallback)((C,x)=>{let w=y(C.naturalWidth);a(`${w}%`),c(!1),h.setValue("sourcePath",x),h.setValue("imageNaturalWidth",C.naturalWidth),h.setValue("width",w);let A={...h.getValues(),sourcePath:x,width:w,imageNaturalWidth:C.naturalWidth,isUploading:!1};b(A)},[h,b,y]),P=(0,ft.useCallback)(C=>{if(!C){h.setValue("imageNaturalWidth",0),h.setValue("width",0),b({...h.getValues(),sourcePath:"",imageNaturalWidth:0,width:0});return}let x=new Image;x.onload=()=>{let w=y(x.naturalWidth);h.setValue("imageNaturalWidth",x.naturalWidth),h.setValue("width",w);let A={...h.getValues(),sourcePath:C,width:w,imageNaturalWidth:x.naturalWidth};b(A)},x.onerror=()=>{console.debug("Image failed to load:",C)},x.src=C},[h,b,y]),M=(0,ft.useCallback)(C=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{P(C)},500)},[P]);(0,ft.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]);let T=h.getValues().sourcePath;return e?(0,W.jsxs)(qe,{...h,children:[(0,W.jsx)(Lt,{type:"image"}),(0,W.jsxs)("form",{ref:o,onChange:()=>{let C=h.getValues();b(C)},children:[(0,W.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),(0,W.jsxs)(ls,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[(0,W.jsxs)(Ji,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[(0,W.jsx)(Qn,{value:"file",className:"courier-flex-1",children:"From file"}),(0,W.jsx)(Qn,{value:"url",className:"courier-flex-1",children:"From URL"})]}),(0,W.jsx)(cs,{value:"file",children:(0,W.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,W.jsx)(Se,{onClick:N,className:"courier-w-full",variant:"outline",type:"button",disabled:m,children:m?(0,W.jsx)(W.Fragment,{children:"Uploading..."}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(W1.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),(0,W.jsx)("input",{ref:r,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:C=>{var w;let x=(w=C.target.files)==null?void 0:w[0];if(x){p(!0),h.setValue("sourcePath",""),b({...h.getValues(),sourcePath:"",isUploading:!0});let A=new FileReader;A.onload=async()=>{try{let L=(await v({file:x})).url,S=new Image;S.onload=()=>{g(S,L),p(!1)},S.onerror=()=>{f({message:"Upload failed: Failed to load uploaded image",toastProps:{duration:6e3,description:`File: ${x.name} (${(x.size/1024/1024).toFixed(2)}MB)`}}),p(!1),b({...h.getValues(),isUploading:!1})},S.src=L}catch(k){console.error("Error uploading image:",k),f({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${x.name} (${(x.size/1024/1024).toFixed(2)}MB)`}}),p(!1),b({...h.getValues(),isUploading:!1})}},A.onerror=()=>{f({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${x.name} (${(x.size/1024/1024).toFixed(2)}MB)`}}),p(!1),b({...h.getValues(),isUploading:!1})},A.readAsDataURL(x)}}})]})}),(0,W.jsx)(cs,{value:"url",children:(0,W.jsx)(j,{control:h.control,name:"sourcePath",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)(tn,{as:"Textarea",...C,autoResize:!0,className:"courier-max-h-[88px]",onChange:x=>{C.onChange(x),M(x.target.value)}})}),(0,W.jsx)(G,{})]})})})]}),(0,W.jsx)(j,{control:h.control,name:"link",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)($r,{placeholder:"Link",value:C.value,onChange:x=>{C.onChange(x),b({...h.getValues(),link:x})}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(j,{control:h.control,name:"alt",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-mb-4",children:[(0,W.jsx)(J,{children:(0,W.jsx)($r,{placeholder:"Alt text...",value:C.value,onChange:x=>{C.onChange(x),b({...h.getValues(),alt:x})}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,W.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Width"}),(()=>{let C=h.getValues().width,x=h.getValues().imageNaturalWidth,w=y(x),A=C===w,k=A?"original":"fill";return(0,W.jsxs)(Pr,{type:"single",value:T?k:"original",onValueChange:L=>{if(!L||L===k)return;let S=L==="fill"?100:y(x);S>0&&(h.setValue("width",S),b({...h.getValues(),width:S}))},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,W.jsx)(_t,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),(0,W.jsx)(_t,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:A||!T,children:"Fill"})]})})(),(0,W.jsx)(j,{control:h.control,name:"width",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-flex-1 courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)(be,{type:"text",inputMode:"numeric",pattern:"[0-9]*",min:1,max:100,...C,value:h.getValues().sourcePath?l?i:`${C.value}%`:"0%",className:"courier-text-2xl courier-font-normal",disabled:!h.getValues().sourcePath,onFocus:x=>{c(!0),a(x.target.value)},onChange:x=>{a(x.target.value)},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),x.currentTarget.blur())},onBlur:x=>{c(!1);let w=parseFloat(x.target.value.replace("%",""));if(!isNaN(w)){let A=Math.min(100,Math.max(1,w));C.onChange(A),b({...h.getValues(),width:Math.round(A)})}}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(j,{control:h.control,name:"width",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-flex-1 courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)(Gc,{min:0,max:100,value:[T?C.value:0],disabled:!T,onValueChange:x=>{C.onChange(x[0]),b({...h.getValues(),width:x[0]})}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(j,{control:h.control,name:"alignment",render:({field:C})=>(0,W.jsxs)(q,{children:[(0,W.jsx)(J,{children:(0,W.jsxs)(Pr,{disabled:!T,type:"single",value:C.value,onValueChange:x=>{C.onChange(x),b({...h.getValues(),alignment:x})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,W.jsx)(_t,{size:"sm",value:"left",className:"courier-w-full",children:(0,W.jsx)(js,{className:"courier-h-4 courier-w-4"})}),(0,W.jsx)(_t,{size:"sm",value:"center",className:"courier-w-full",children:(0,W.jsx)(Gs,{className:"courier-h-4 courier-w-4"})}),(0,W.jsx)(_t,{size:"sm",value:"right",className:"courier-w-full",children:(0,W.jsx)(Ks,{className:"courier-h-4 courier-w-4"})})]})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(ce,{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.jsx)(j,{control:h.control,name:"borderWidth",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)(be,{startAdornment:(0,W.jsx)(xo,{}),type:"number",disabled:!T,min:0,...C,onChange:x=>{let w=parseInt(x.target.value)||0;C.onChange(w),b({...h.getValues(),borderWidth:w})}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(j,{control:h.control,name:"borderColor",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-mb-4",children:[(0,W.jsx)(J,{children:(0,W.jsx)(xt,{...C,disabled:!T,defaultValue:at.borderColor,onChange:x=>{C.onChange(x),b({...h.getValues(),[C.name]:x})}})}),(0,W.jsx)(G,{})]})})]})]}):null},"ImageBlockForm");var Fa=require("@tiptap/core"),$1=he(require("@tiptap/extension-link"),1),vi=require("@tiptap/pm/state"),vd=$1.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,Fa.mergeAttributes)(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new vi.Plugin({props:{handleClick:(r,o,n)=>{if(n.button!==0)return!1;let{state:i}=r,{doc:a}=i,l=a.resolve(o),c=l.marks().find(u=>u.type.name==="link");if(c||o>0&&(c=a.resolve(o-1).marks().find(d=>d.type.name==="link")),c||o<a.content.size&&(c=a.resolve(o+1).marks().find(d=>d.type.name==="link")),c){let u=(0,Fa.getMarkRange)(l,c.type);return u?(r.dispatch(i.tr.setSelection(vi.TextSelection.create(a,u.from,u.to))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:u.from,to:u.to,href:c.attrs.originalHref||c.attrs.href})),!0):(r.dispatch(i.tr.setSelection(vi.TextSelection.create(a,o,o+1))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:o,to:o+1,href:c.attrs.originalHref||c.attrs.href})),!0)}return!1}}}),new vi.Plugin({appendTransaction(r,o,n){if(!r.some(l=>l.docChanged))return null;let i=n.tr,a=!1;return n.doc.descendants((l,c)=>(l.marks.forEach(u=>{if(u.type.name==="link"&&u.attrs.href){let d=u.attrs.href;if(d.includes("__VAR_")){let m=d.replace(/__VAR_([^_]+)__/g,"{{$1}}");if(m!==d){let p=(0,Fa.getMarkRange)(n.doc.resolve(c),u.type);p&&(i.removeMark(p.from,p.to,u.type),i.addMark(p.from,p.to,u.type.create({...u.attrs,href:m,hasVariables:!0,originalHref:m})),a=!0)}}}}),!0)),a?i:null}})]}});var Z1=require("@hookform/resolvers/zod"),q1=require("jotai"),Ml=require("react"),J1=require("react-hook-form"),Nl=require("zod");var jr=require("react/jsx-runtime"),Zh=Nl.z.object({href:Nl.z.string(),openInNewTab:Nl.z.boolean().default(!1)}),j1=s(({editor:e,mark:t,pendingLink:r})=>{let o=(0,q1.useSetAtom)(Cs),n=(0,Ml.useRef)(null),i=(0,J1.useForm)({resolver:(0,Z1.zodResolver)(Zh),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1}});(0,Ml.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=s(async l=>{let c=l.href.trim();if(!c){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:c,target:l.openInNewTab?"_blank":null}).run()),e==null||e.commands.setTextSelection((r==null?void 0:r.to)||0),o(null)},"updateLink");return(0,jr.jsxs)(qe,{...i,children:[(0,jr.jsx)("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),(0,jr.jsx)("div",{className:"courier-space-y-4",children:(0,jr.jsx)(j,{control:i.control,name:"href",render:({field:l})=>(0,jr.jsxs)(q,{children:[(0,jr.jsx)(ao,{children:"URL"}),(0,jr.jsx)(J,{children:(0,jr.jsx)(tn,{as:"Textarea",autoResize:!0,...l,ref:c=>{typeof l.ref=="function"&&l.ref(c),n.current=c},onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),c.stopPropagation(),i.handleSubmit(a)())},onBlur:()=>{l.onBlur(),i.handleSubmit(a)()}})}),(0,jr.jsx)(G,{})]})})})]})},"LinkForm");var Il=require("@tiptap/react"),xi=require("prosemirror-state");var Po={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:"'"},Sl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},qh=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Jh=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(tt=0;tt<10;tt++)Po[48+tt]=Po[96+tt]=String(tt);var tt;for(tt=1;tt<=24;tt++)Po[tt+111]="F"+tt;var tt;for(tt=65;tt<=90;tt++)Po[tt]=String.fromCharCode(tt+32),Sl[tt]=String.fromCharCode(tt);var tt;for(Al in Po)Sl.hasOwnProperty(Al)||(Sl[Al]=Po[Al]);var Al;function G1(e){var t=qh&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Jh&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?Sl:Po)[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(G1,"keyName");var K1=require("prosemirror-state");var jh=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Gh(e){let t=e.split(/-(?!$)/),r=t[t.length-1];r=="Space"&&(r=" ");let o,n,i,a;for(let l=0;l<t.length-1;l++){let c=t[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))jh?a=!0:n=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(r="Alt-"+r),n&&(r="Ctrl-"+r),a&&(r="Meta-"+r),i&&(r="Shift-"+r),r}s(Gh,"normalizeKeyName");function Kh(e){let t=Object.create(null);for(let r in e)t[Gh(r)]=e[r];return t}s(Kh,"normalize");function xd(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(xd,"modifiers");function Y1(e){return new K1.Plugin({props:{handleKeyDown:Yh(e)}})}s(Y1,"keymap");function Yh(e){let t=Kh(e);return function(r,o){let n=G1(o),i,a=t[xd(n,o)];if(a&&a(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let l=t[xd(n,o,!1)];if(l&&l(r.state,r.dispatch,r))return!0}if((o.shiftKey||o.altKey||o.metaKey||n.charCodeAt(0)>127)&&(i=Po[o.keyCode])&&i!=n){let l=t[xd(i,o)];if(l&&l(r.state,r.dispatch,r))return!0}}return!1}}s(Yh,"keydownHandler");var X1=require("uuid");var Td=pi.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){dt(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,X1.v4)()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:pe.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):pe.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:pe.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):pe.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:pe.textAlign,parseHTML:e=>e.style.textAlign||pe.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:pe.backgroundColor,parseHTML:e=>e.style.backgroundColor||pe.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:pe.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):pe.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:pe.borderColor,parseHTML:e=>e.style.borderColor||pe.borderColor,renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="paragraph"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Il.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return(0,Il.ReactNodeViewRenderer)(El)},addProseMirrorPlugins(){return[Y1({"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(xi.TextSelection.create(t.doc,i,a)),!0}return!1}}),new xi.Plugin({key:new xi.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,l=a.depth,c=null;for(;l>0;){let u=a.node(l);if(u.type.name==="paragraph"||u.type.name==="heading"){c=u;break}l--}if(c){let u=c.textContent,d=a.parentOffset===0,m=a.parentOffset===u.length,p=u.length===0,f=t.key==="Delete"||t.keyCode===46||t.code==="Delete",v=f?i.$from.nodeAfter:i.$from.nodeBefore,h=v!=null;if(h&&p)return!1;if(o||p&&!h||!f&&d&&!h||f&&m&&!h)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,l=null;for(;a>0;){let p=n.node(a);if(p.type.name==="paragraph"||p.type.name==="heading"){l=p;break}a--}if(!l)return!1;let c=r?n.pos===i.pos&&n.parentOffset===0:n.pos===i.pos&&n.parentOffset===l.textContent.length,u=l.textContent.length===0,d=r?t.state.selection.$from.nodeBefore:t.state.selection.$from.nodeAfter,m=d!=null;return m&&u?!1:c&&!m||u&&!m?!0:o?!1:(t.commands.command(({tr:p,dispatch:f})=>f?(p.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 Q1=require("@tiptap/core"),Ll=require("@tiptap/pm/state"),Xh=new Ll.PluginKey("selection"),Ed=Q1.Extension.create({name:"selection",addOptions(){return{HTMLAttributes:{},setSelectedNode:()=>{},shouldHandleClick:()=>!0}},addGlobalAttributes(){return[{types:["paragraph","heading","button","spacer","divider","imageBlock","blockquote","customCode","column"],attributes:{isSelected:{default:!1,parseHTML:()=>!1,renderHTML:e=>e.isSelected?{class:"selected-element"}:{}}}}]},addCommands(){return{updateSelectionState:e=>({tr:t,dispatch:r})=>{var o,n;if(r){let i=(o=e==null?void 0:e.attrs)==null?void 0:o.id,a=(n=e==null?void 0:e.type)==null?void 0:n.name;t.doc.descendants((l,c)=>{var u,d,m;if(l.type.name!=="text"&&((u=l.type.spec.attrs)==null?void 0:u.isSelected)!==void 0){let p=!1;i?p=((d=l.attrs)==null?void 0:d.id)===i&&l.type.name===a:a&&(p=l.type.name===a&&l.content.size===((m=e==null?void 0:e.content)==null?void 0:m.size)),p?t.setNodeAttribute(c,"isSelected",!0):t.setNodeAttribute(c,"isSelected",!1)}return!0})}return!0}}},addProseMirrorPlugins(){return[new Ll.Plugin({key:Xh,props:{handleClick:(e,t,r)=>{let{state:o}=e;if(!this.editor.isEditable||this.options.shouldHandleClick&&!this.options.shouldHandleClick())return!1;let n=r.target;if(n.closest(".node-blockquote")||n.closest('[data-cypress="draggable-handle"]')||n.closest('button[class*="courier-cursor-grab"]'))return!1;try{let l=window.getSelection();if(l&&l.rangeCount>0){let u=l.getRangeAt(0).startContainer.parentElement;if(u&&(["P","H1","H2","H3"].includes(u.tagName)||["P","H1","H2","H3"].some(d=>u.closest(d)))){let d=e.posAtDOM(u,0),p=o.doc.resolve(d).node();if(p&&["paragraph","heading"].includes(p.type.name))return this.options.setSelectedNode(p),this.editor.commands.updateSelectionState(p),!0}}}catch(l){console.error("Error handling click:",l)}let i=e.posAtDOM(n,0),a=o.doc.resolve(i).node();return a&&["paragraph","heading"].includes(a.type.name)?(this.options.setSelectedNode(a),this.editor.commands.updateSelectionState(a),!0):!1}}})]}});var eg=require("react"),tg=require("react/jsx-runtime"),wd=(0,eg.forwardRef)(({children:e,className:t,withShadow:r=!0,withBorder:o=!0,...n},i)=>{let a=I("courier-bg-popover courier-rounded-lg courier-text-popover-foreground",r?"courier-shadow-sm":"",o?"courier-border courier-border-border":"",t);return(0,tg.jsx)("div",{className:a,...n,ref:i,children:e})});wd.displayName="Surface";var rg=require("uuid");var Qh=s((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),og=s((e,t,r,o,n,i)=>{let a=`node-${(0,rg.v4)()}`,c={heading:()=>e.schema.nodes.heading.create({...pe,...o,id:a},i),paragraph:()=>e.schema.nodes.paragraph.create({...pe,...o,id:a},i),text:()=>e.schema.nodes.paragraph.create({...pe,...o,id:a},i),spacer:()=>e.schema.nodes.divider.create({...pl,...o,id:a}),divider:()=>e.schema.nodes.divider.create({...vr,...o,id:a}),button:()=>e.schema.nodes.button.create({...Ge,...o,id:a},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...at,...o,id:a}),image:()=>e.schema.nodes.imageBlock.create({...at,...o,id:a}),customCode:()=>e.schema.nodes.customCode.create({...wo,...o,id:a}),column:()=>e.schema.nodes.column.create({...wt,...o,id:a})}[t];if(c)try{let u=e.state.tr,d=c();u.insert(r,d),e.view.dispatch(u),n&&n(d),(t==="text"||t==="paragraph"||t==="heading")&&setTimeout(()=>{let p=Qh(e,a);p!==null&&e.commands.setTextSelection(p+1),e.view.focus()},50);let m=new CustomEvent("node-duplicated",{detail:{newNodeId:a}});document.dispatchEvent(m)}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 m=new CustomEvent("node-duplicated",{detail:{newNodeId:a}});document.dispatchEvent(m)}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 en=s(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),pt=s(e=>{let t=en(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");var ng=require("lucide-react"),ig=require("react"),Ld=require("react/jsx-runtime"),ag=(0,ig.forwardRef)((e,t)=>(0,Ld.jsx)("button",{...e,ref:t,"data-cypress":"draggable-handle","data-drag-handle":!0,className:I("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 courier-select-none courier-z-10 courier-touch-none",e.className),style:{WebkitUserSelect:"none",userSelect:"none",touchAction:"none"},children:(0,Ld.jsx)(ng.GripVertical,{strokeWidth:1,className:"courier-w-5 courier-stroke-neutral-400 courier-fill-neutral-400 courier-pointer-events-none"})}));var Rl=require("jotai"),tr=require("react"),cg=require("uuid");var sg=require("react");var lg=s((e,t,r)=>(0,sg.useMemo)(()=>{if(!(e!=null&&e.conditionalRules)||!t||!r)return null;let o=e.conditionalRules.filter(n=>n.trigger.type==="node"&&t.isActive(n.trigger.name)!==n.trigger.active?!1:n.conditions.activeItems.some(i=>i==="bold"?r.isBold:i==="italic"?r.isItalic:i==="underline"?r.isUnderline:i==="strike"?r.isStrike:!1));return{getRuleForItem:n=>o.find(i=>!i.conditions.activeItems.includes(n))}},[e,t,r]),"useConditionalRules");var Hl=s((e,t,r)=>{let o=(0,Rl.useSetAtom)(Xe),n=(0,Rl.useAtomValue)(ye),i=lg(t,e,r),a=(0,tr.useCallback)(g=>{let P=-1;return e.state.doc.descendants((M,T)=>{var R;return((R=M.attrs)==null?void 0:R.id)===g?(P=T,!1):!0}),P},[e]),l=(0,tr.useCallback)((g,P)=>{var M,T,R;if(((M=n==null?void 0:n.type)==null?void 0:M.name)==="button"&&((T=n.attrs)!=null&&T.id)){let E=n.attrs.id,C=a(E);if(C>=0){let x=e.state.tr;return x.setNodeMarkup(C,void 0,{...(R=e.state.doc.nodeAt(C))==null?void 0:R.attrs,[g]:P}),e.view.dispatch(x),setTimeout(()=>{let w=a(E);if(w>=0){let A=e.state.doc.nodeAt(w);A&&o(A)}},0),!0}}return!1},[e,n,a,o]),c=(0,tr.useCallback)(()=>{var g,P;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"&&((P=n.attrs)!=null&&P.id)){let M=n.attrs.id,T=a(M);if(T>=0){let R=e.state.doc.nodeAt(T);if(!R)return!1;let E={...R.attrs,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},C=e.state.tr;return C.setNodeMarkup(T,void 0,E),e.view.dispatch(C),setTimeout(()=>{let x=a(M);if(x>=0){let w=e.state.doc.nodeAt(x);w&&o(w)}},0),!0}}return!1},[e,n,a,o]),u=(0,tr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let P=n.attrs.fontWeight==="bold"?"normal":"bold";if(l("fontWeight",P))return!0}if(i&&r){let P=i.getRuleForItem("bold");if(P&&P.action.type==="toggle_off"){let M=e.chain().focus();return P.action.targets.forEach(T=>{T==="italic"&&r.isItalic&&M.toggleItalic()}),M.toggleBold().run(),!0}}return e.chain().focus().toggleBold().run()},[e,n,l,i,r]),d=(0,tr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let P=n.attrs.fontStyle==="italic"?"normal":"italic";if(l("fontStyle",P))return!0}if(i&&r){let P=i.getRuleForItem("italic");if(P&&P.action.type==="toggle_off"){let M=e.chain().focus();return P.action.targets.forEach(T=>{T==="bold"&&r.isBold&&M.toggleBold()}),M.toggleItalic().run(),!0}}return e.chain().focus().toggleItalic().run()},[e,n,l,i,r]),m=(0,tr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let P=!n.attrs.isStrike;if(l("isStrike",P))return!0}return e.chain().focus().toggleMark("strike").run()},[e,n,l]),p=(0,tr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let P=!n.attrs.isUnderline;if(l("isUnderline",P))return!0}return e.chain().focus().toggleMark("underline").run()},[e,n,l]),f=(0,tr.useCallback)(()=>e.chain().focus().setTextAlign("left").run(),[e]),v=(0,tr.useCallback)(()=>e.chain().focus().setTextAlign("center").run(),[e]),h=(0,tr.useCallback)(()=>e.chain().focus().setTextAlign("right").run(),[e]),b=(0,tr.useCallback)(()=>e.chain().focus().setTextAlign("justify").run(),[e]),y=(0,tr.useCallback)((g,P)=>e.chain().focus().setLink({href:g,target:P?"_blank":""}).run(),[e]),N=(0,tr.useCallback)(()=>{let g=e.isActive("blockquote");if(e.chain().focus().toggleBlockquote().run()){let{selection:T}=e.state,R=T.$anchor;if(g){let E=R.node();(E.type.name==="paragraph"||E.type.name==="heading")&&o(E)}else for(let E=R.depth;E>0;E--){let C=R.node(E);if(C.type.name==="blockquote"){if(C.attrs.id)o(C);else{let x=R.before(E),w=`node-${(0,cg.v4)()}`,A=e.state.tr;A.setNodeMarkup(x,void 0,{...C.attrs,id:w}),e.view.dispatch(A);let k=e.state.doc.nodeAt(x);k&&o(k)}break}}}},[e,o]);return{onBold:u,onItalic:d,onStrike:m,onUnderline:p,onAlignLeft:f,onAlignCenter:v,onAlignRight:h,onAlignJustify:b,onLink:y,onQuote:N,resetButtonFormatting:c}},"useTextmenuCommands");var Bl=require("react/jsx-runtime"),eb=s(e=>{switch(e){case"text":return"Text";case"heading":return"Heading";case"spacer":return"Spacer";case"divider":return"Divider";case"button":return"Button";case"image":return"Image";case"customCode":return"Custom code";case"column":return"Column layout";default:return"Drop here"}},"getPlaceholderLabel"),Dl=s(({type:e})=>(0,Bl.jsx)("div",{className:"courier-flex courier-w-full courier-pointer-events-none",children:(0,Bl.jsx)("div",{className:I("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50 courier-ml-10","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md courier-drag-indicator dark:courier-border-accent"),children:(0,Bl.jsx)("div",{className:"courier-text-accent-foreground dark:courier-text-accent",children:eb(e)})})}),"DropIndicatorPlaceholder");var Ke=require("react/jsx-runtime");function tb(){let[e,t]=(0,Pe.useState)(!1);return(0,Pe.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(tb,"useMountStatus");var It=s(({children:e,id:t,className:r,editor:o,getPos:n,...i})=>{let a=(0,Pe.useRef)(null),l=(0,Pe.useRef)(null),c=(0,Pe.useRef)(null),[u,d]=(0,Pe.useState)(!1),[m,p]=(0,Pe.useState)(null),[f,v]=(0,Pe.useState)(null),h=(0,Pe.useRef)(null),b=(0,Pe.useRef)(!1),y=(0,Pe.useRef)(null),N=(0,Pe.useRef)(null),g=(0,Pe.useRef)(null),P=tb(),M=u&&!P,T=(0,Pe.useCallback)(()=>{if(!o||!t)return null;let E=null;return o.state.doc.descendants((C,x,w)=>{var A;if(((A=C.attrs)==null?void 0:A.id)===t){let k=0;return w&&w.content.forEach((L,S,H)=>{L===C&&(k=H)}),E={node:C,pos:x,parent:w,index:k},!1}return!0}),E},[t,o]),R=(0,Pe.useCallback)(()=>{if(!o)return!1;let E=T();return!E||!E.parent?!1:E.index===E.parent.childCount-1},[o,T]);return(0,Pe.useEffect)(()=>{let E=a.current,C=l.current;if(!E)return;let x=co(fa({element:E,dragHandle:C||void 0,getInitialData:()=>{var S,H,V,F,O,B;let w=T(),A="text";if(w){let z=w.node;switch(z.type.name){case"heading":A="heading";break;case"paragraph":A="text";break;case"imageBlock":A="image";break;case"divider":A=(S=z.attrs)!=null&&S.spacer?"spacer":"divider";break;case"button":A="button";break;case"customCode":A="customCode";break;case"column":A="column";break}}let k=(w==null?void 0:w.parent)===o.state.doc,L=((H=w==null?void 0:w.parent)==null?void 0:H.type.name)==="columnCell";return{id:t,type:k?"editor":L?"column-cell-item":"nested-drag",index:(V=w==null?void 0:w.index)!=null?V:0,dragType:A,pos:w==null?void 0:w.pos,originalIndex:(F=w==null?void 0:w.index)!=null?F:0,columnId:L?(O=w==null?void 0:w.parent)==null?void 0:O.attrs.columnId:void 0,cellIndex:L?(B=w==null?void 0:w.parent)==null?void 0:B.attrs.index:void 0}},onGenerateDragPreview:()=>{let w=E.querySelectorAll("[data-no-drag-preview]"),A=[];w.forEach((k,L)=>{let S=k;A[L]=S.style.display,S.style.display="none"}),requestAnimationFrame(()=>{w.forEach((k,L)=>{let S=k;S.style.display=A[L]})})},onDragStart:()=>{d(!0),document.body.style.cursor="grabbing";let w=s(A=>{N.current=A.clientY},"handleMouseMove");document.addEventListener("mousemove",w),g.current=()=>{document.removeEventListener("mousemove",w)},o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{d(!1),document.body.style.cursor="",g.current&&(g.current(),g.current=null),o&&o.setEditable(!0)}}),br({element:E,getData:({input:w,element:A})=>{var B,z,_,se;let k=T(),L=(k==null?void 0:k.parent)===o.state.doc,S=((B=k==null?void 0:k.parent)==null?void 0:B.type.name)==="columnCell",H={id:t,type:L?"editor":S?"column-cell-item":"nested-drag",index:(z=k==null?void 0:k.index)!=null?z:0,pos:k==null?void 0:k.pos,nodeType:k==null?void 0:k.node.type.name,columnId:S?(_=k==null?void 0:k.parent)==null?void 0:_.attrs.columnId:void 0,cellIndex:S?(se=k==null?void 0:k.parent)==null?void 0:se.attrs.index:void 0};if(A.getAttribute("data-node-type")==="column"){let re=A.getBoundingClientRect(),Y=w.clientY,D=30,Z=Math.abs(Y-re.top),ie=Math.abs(Y-re.bottom);if(Z>D&&ie>D)return{...H,disableDropIndicator:!0}}let F=A.closest('[data-column-cell="true"]');if(R()&&E){let re=E.getBoundingClientRect(),Y=w.clientY,D=re.top+re.height/2;if(Y>=D&&Y>re.bottom)return{...H,[Symbol.for("closestEdge")]:"bottom"}}let O=R()?["top","bottom"]:["top"];return tf(H,{input:w,element:A,allowedEdges:O})},canDrop:({source:w})=>w.data.id!==t,onDragEnter:({self:w,source:A,location:k})=>{var z,_,se,re,Y;if(w.data.disableDropIndicator){p(null);return}y.current&&(clearTimeout(y.current),y.current=null);let L=k.current.dropTargets;if(L.length>0&&L[0].element!==E){p(null),b.current=!1,h.current=null;return}let S=ga(w.data),H=S,V=R(),F=(se=(_=(z=k==null?void 0:k.current)==null?void 0:z.input)==null?void 0:_.clientY)!=null?se:N.current;F!==null&&(N.current=F);let O=A.data;v(O.dragType||null),S==="bottom"&&V&&A.data.id===t&&(H=null);let B=A.data.type==="editor"||A.data.type==="column-cell-item";if(V&&B)if(S==="top"){let D=a.current;if(D){let Z=D.getBoundingClientRect(),ie=(re=F!=null?F:N.current)!=null?re:Z.top+Z.height/2,Me=Z.top+Z.height/2,$e=Z.height,Je=Math.max(10,Math.min(30,$e*.3));ie<Me-Je?(b.current=!1,H="top"):b.current?H="bottom":H="top"}else b.current=!1,H="top"}else b.current?H="bottom":S==="bottom"&&(b.current=!0,H="bottom");else V&&!B&&(b.current=!1);if(!b.current&&(A.data.type==="editor"||A.data.type==="column-cell-item")&&typeof A.data.index=="number"){let D=A.data.index,Z=T();((Y=Z==null?void 0:Z.index)!=null?Y:0)===D+1&&S==="top"&&(H=null)}H!==h.current&&(h.current=H,p(H))},onDrag:({self:w,source:A,location:k})=>{var z,_,se,re,Y;if(w.data.disableDropIndicator){p(null);return}y.current&&(clearTimeout(y.current),y.current=null);let L=k.current.dropTargets;if(L.length>0&&L[0].element!==E){p(null);return}let S=(se=(_=(z=k==null?void 0:k.current)==null?void 0:z.input)==null?void 0:_.clientY)!=null?se:N.current;S!==null&&(N.current=S);let H=ga(w.data),V=H,F=R(),O=A.data;v(O.dragType||null),H==="bottom"&&F&&A.data.id===t&&(V=null);let B=A.data.type==="editor"||A.data.type==="column-cell-item";if(F&&B)if(H==="top"){let D=a.current;if(D){let Z=D.getBoundingClientRect(),ie=(re=S!=null?S:N.current)!=null?re:Z.top+Z.height/2,Me=Z.top+Z.height/2,$e=Z.height,Je=Math.max(10,Math.min(30,$e*.3));ie<Me-Je?(b.current=!1,V="top"):b.current?V="bottom":V="top"}else b.current=!1,V="top"}else b.current?V="bottom":H==="bottom"&&(b.current=!0,V="bottom");else F&&!B&&(b.current=!1);if(!b.current&&(A.data.type==="editor"||A.data.type==="column-cell-item")&&typeof A.data.index=="number"){let D=A.data.index,Z=T();((Y=Z==null?void 0:Z.index)!=null?Y:0)===D+1&&H==="top"&&(V=null)}V!==h.current&&(h.current=V,p(V))},onDragLeave:()=>{if(R()&&b.current){let w=E==null?void 0:E.getBoundingClientRect(),A=N.current;if(w&&A!==null&&A>=w.bottom-10)return;y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{b.current=!1,h.current=null,p(null),v(null),y.current=null},150)}else y.current&&(clearTimeout(y.current),y.current=null),b.current=!1,h.current=null,p(null),v(null)},onDrop:()=>{y.current&&(clearTimeout(y.current),y.current=null),b.current=!1,h.current=null,p(null),v(null)}}));return()=>{y.current&&(clearTimeout(y.current),y.current=null),x()}},[t,R,o,T]),(0,Ke.jsx)(rb,{ref:a,id:t,fadeIn:M,className:r,dragging:u,closestEdge:m,dragType:f,handleRef:l,contentRef:c,editor:o,...i,children:e})},"SortableItemWrapper"),rb=(0,Pe.forwardRef)(({children:e,className:t,dragOverlay:r,handleRef:o,contentRef:n,closestEdge:i,dragType:a,id:l,editor:c,fadeIn:u,dragging:d,...m},p)=>{(0,Pe.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let f=(0,dg.useSetAtom)(ye),{resetButtonFormatting:v}=Hl(c),h=s((T,R)=>{let E=null;return T.doc.descendants((C,x)=>{var w;return E!==null?!1:((w=C.attrs)==null?void 0:w.id)===R?(E=x,!1):!0}),E},"findNodePositionById"),b=(0,Pe.useCallback)(()=>{if(!c||!l)return{node:null,pos:null};let T=h(c.state,l);return T===null?{node:null,pos:null}:{node:c.state.doc.nodeAt(T),pos:T}},[c,l]),y=(0,Pe.useCallback)(()=>{c.commands.blur(),f(null)},[c,f]),N=(0,Pe.useCallback)(()=>{if(!(!c||!l))try{let{node:T,pos:R}=b();if(!T||R===null)return;let E=T.nodeSize,C=c.state.doc.childCount===1;f(null),c.commands.updateSelectionState(null);let x=c.state.tr;x.delete(R,R+E),x.setMeta("addToHistory",!0),c.view.dispatch(x),C&&setTimeout(()=>{let w=c.state.doc.nodeAt(0);if(w&&w.type.name==="paragraph"&&!w.attrs.id){let A=`node-${(0,mg.v4)()}`,k=c.state.tr;k.setNodeMarkup(0,void 0,{...w.attrs,id:A}),c.view.dispatch(k);let L=new CustomEvent("node-duplicated",{detail:{newNodeId:A}});document.dispatchEvent(L)}},50)}catch(T){console.error("Error deleting node:",T)}},[c,l,b,f]),g=(0,Pe.useCallback)(()=>{if(!(!c||!l))try{let{node:T,pos:R}=b();if(!T||R===null)return;if(T.type.name==="button"){v();return}let E=T.type.name==="blockquote";E||y(),setTimeout(()=>{let C=c.chain();if(C.setNodeSelection(R).unsetAllMarks(),E&&T.content&&T.content.firstChild?T.content.firstChild.type.name!=="paragraph"&&C.setParagraph():T.type.name!=="paragraph"&&!E&&C.setParagraph(),C.run(),E){let x=b();x.node&&x.pos!==null&&(f(x.node),c.commands.updateSelectionState(x.node))}},100)}catch(T){console.error("Error removing formatting:",T)}},[c,l,b,y,v,f]),P=(0,Pe.useCallback)(()=>{if(!(!c||!l))try{y(),setTimeout(()=>{let{node:T,pos:R}=b();if(!T||R===null)return;let E=T.type.name,C={...T.attrs};delete C.id;let x=R+(T==null?void 0:T.nodeSize);og(c,E,x,C,w=>f(w),T.content)},100)}catch(T){console.error("Error duplicating node:",T)}},[c,l,b,y,f]),{node:M}=b();return(0,Ke.jsxs)(ug.NodeViewWrapper,{ref:p,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":l,className:I("courier-flex courier-flex-col courier-relative draggable-item",t),...m,children:[i==="top"&&(0,Ke.jsx)(Dl,{type:a}),(0,Ke.jsxs)("div",{className:"courier-flex courier-items-center courier-justify-center courier-gap-2 courier-pl-10",children:[(0,Ke.jsx)(ag,{ref:o,className:"courier-absolute courier-left-[-8px]",tabIndex:-1,"data-no-drag-preview":!0}),(0,Ke.jsx)("div",{ref:n,className:"courier-flex-1 courier-grow draggable-content-wrapper",children:e}),(0,Ke.jsxs)("div",{"data-no-drag-preview":!0,className:I("courier-actions-panel courier-absolute courier-right-[-50px] courier-rounded-lg courier-border courier-border-border courier-bg-background courier-shadow-md courier-hidden courier-items-center courier-justify-center hover:courier-z-[100000]",d&&"!courier-hidden"),children:[(M==null?void 0:M.type.name)!=="imageBlock"&&(M==null?void 0:M.type.name)!=="divider"&&(M==null?void 0:M.type.name)!=="spacer"&&(M==null?void 0:M.type.name)!=="button"&&(M==null?void 0:M.type.name)!=="column"&&(M==null?void 0:M.type.name)!=="customCode"&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:T=>{T.preventDefault(),T.stopPropagation()},onClick:T=>{T.stopPropagation(),g()},tabIndex:-1,children:(0,Ke.jsx)(Nu,{color:"currentColor"})}),(0,Ke.jsx)(ce,{className:"!courier-my-0"})]}),(0,Ke.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:T=>{T.preventDefault(),T.stopPropagation()},onClick:T=>{T.stopPropagation(),P()},tabIndex:-1,children:(0,Ke.jsx)(su,{color:"currentColor"})}),(0,Ke.jsx)(ce,{className:"!courier-my-0"}),(0,Ke.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#DC2626] dark:courier-text-red-500 dark:hover:courier-bg-secondary",onMouseDown:T=>{T.preventDefault(),T.stopPropagation()},onClick:T=>{T.stopPropagation(),N()},tabIndex:-1,children:(0,Ke.jsx)(ji,{color:"currentColor"})})]})]}),i==="bottom"&&(0,Ke.jsx)(Dl,{type:a})]})});var Bn=require("react/jsx-runtime"),ob=s(({alignment:e,backgroundColor:t,textColor:r,borderRadius:o,padding:n,fontWeight:i,fontStyle:a,children:l})=>(0,Bn.jsx)("div",{className:"courier-w-full node-element",children:(0,Bn.jsx)("div",{className:"courier-flex",children:(0,Bn.jsx)("div",{className:I("courier-inline-flex courier-justify-center courier-cursor-text courier-text-sm courier-leading-tight !courier-my-1",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[e]),style:{backgroundColor:t,color:r,borderRadius:`${o}px`,caretColor:r,fontWeight:i,fontStyle:a,padding:`${Number(n)+2}px ${Number(n)+10}px`},children:l})})}),"ButtonComponent"),hg=s(e=>{let t=(0,fg.useSetAtom)(Xe),r=(0,gg.useCallback)(()=>{if(!e.editor.isEditable)return;let o=pt(e);if(o){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,Bn.jsx)(It,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,"data-node-type":"button",children:(0,Bn.jsx)(ob,{...e.node.attrs,children:(0,Bn.jsx)(pg.NodeViewContent,{as:"span"})})})},"ButtonComponentNode");var yg=require("uuid");var Ge={label:"Button",link:"",alignment:"center",backgroundColor:"#0085FF",borderRadius:0,padding:6,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1,textColor:"#ffffff",borderColor:"transparent"},Ys=Fl.Node.create({name:"button",group:"block",content:"inline*",selectable:!1,isolating:!0,onCreate(){dt(this.editor,this.name)},addAttributes(){return{label:{default:Ge.label,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},link:{default:Ge.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alignment:{default:Ge.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},backgroundColor:{default:Ge.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},textColor:{default:Ge.textColor,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.textColor})},borderRadius:{default:Ge.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:Ge.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},padding:{default:Ge.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.padding})},fontWeight:{default:Ge.fontWeight,parseHTML:e=>e.getAttribute("data-font-weight"),renderHTML:e=>({"data-font-weight":e.fontWeight})},fontStyle:{default:Ge.fontStyle,parseHTML:e=>e.getAttribute("data-font-style"),renderHTML:e=>({"data-font-style":e.fontStyle})},isUnderline:{default:Ge.isUnderline,parseHTML:e=>e.getAttribute("data-is-underline"),renderHTML:e=>({"data-is-underline":e.isUnderline})},isStrike:{default:Ge.isStrike,parseHTML:e=>e.getAttribute("data-is-strike"),renderHTML:e=>({"data-is-strike":e.isStrike})},id:{default:()=>`node-${(0,yg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="button"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Fl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return(0,bg.ReactNodeViewRenderer)(hg)},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{let{$from:t}=e.state.selection;for(let r=t.depth;r>=0;r--)if(t.node(r).type.name==="button"){let n=t.start(r),i=t.end(r);return e.commands.setTextSelection({from:n,to:i}),!0}return!1}}},addCommands(){return{setButton:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e,content:[{type:"text",text:e.label||"Button"}]}).run()}}});var Cg=require("uuid"),rn=require("jotai"),Nt=require("react");var Ti=s(({items:e,setItems:t,editor:r})=>{let[o]=(0,Nt.useState)(null),[n,i]=(0,Nt.useState)(null),[a,l]=(0,Nt.useState)(null),[c]=(0,Nt.useState)("outer"),u=(0,Nt.useRef)([]),d=(0,Nt.useRef)([]),m=(0,rn.useAtomValue)(He),p=(0,rn.useSetAtom)(jt),[f,v]=(0,rn.useAtom)(ee),h=(0,rn.useSetAtom)(je),b=(0,rn.useAtomValue)(Uo),y=r||m,N=(0,Nt.useCallback)(()=>{if(!y)return;let E=y.getJSON(),C=de(E),x=ut(f,{channel:b,elements:C});v(x),h(x)},[y,b,f,v,h]),g=(0,Nt.useCallback)(()=>{y==null||y.commands.removeDragPlaceholder(),t(E=>({...E,Editor:E.Editor.filter(C=>!C.toString().includes("_temp"))}))},[y==null?void 0:y.commands,t]),P=(0,Nt.useCallback)(E=>{try{let C=y==null?void 0:y.state.doc;if(!C||E===0)return 0;if(E>=C.childCount)return C.content.size;let x=0;for(let w=0;w<Math.min(E,C.childCount);w++){let A=C.child(w);x+=A.nodeSize}return x}catch(C){return console.error("Error calculating document position:",C),0}},[y==null?void 0:y.state.doc]),M=(0,Nt.useCallback)(E=>{let C={};switch(E){case"text":C=pe;break;case"heading":C={};break;case"image":C=at;break;case"button":C=Ge;break;case"divider":C=vr;break;case"spacer":C=pl;break;case"customCode":C=wo;break;case"column":C=wt;break}let w={type:E==="text"?"paragraph":E==="image"?"imageBlock":E==="spacer"?"divider":E,attrs:{...C,id:(0,Cg.v4)()}};return E==="button"&&(w.content=[{type:"text",text:"Button"}]),w},[]),T=(0,Nt.useCallback)((E,C)=>{if(!y)return;let{columnId:x,index:w,isEmpty:A}=C,k=null,L=0,S=-1;if(E.type==="sidebar"){if(!E.dragType)return;k=M(E.dragType)}else if(E.type==="editor"){if(y.state.doc.descendants((B,z)=>B.attrs.id===E.id?(S=z,k=B.toJSON(),L=B.nodeSize,!1):!0),S===-1){let B=e.Editor.findIndex(z=>z===E.id);if(B!==-1){S=P(B);let z=y.state.doc.nodeAt(S);z&&(k=z.toJSON(),L=z.nodeSize)}}if(S!==-1){let B=e.Editor.filter(z=>z!==E.id);B.length!==e.Editor.length&&t({...e,Editor:B})}}if(!k)return;let H=-1,V=null;if(y.state.doc.descendants((B,z)=>B.type.name==="column"&&B.attrs.id===x?(H=z,V=B,!1):!0),H===-1||!V)return;let F=V;S!==-1&&S<H&&(H-=L);let O=y.state.tr;if(S!==-1&&O.delete(S,S+L),A){let B=y.schema,z=Array.from({length:F.attrs.columnsCount},(se,re)=>B.nodes.columnCell.create({index:re,columnId:x,isEditorMode:!1},re===w?[B.nodeFromJSON(k)]:[])),_=B.nodes.columnRow.create({},z);O.replaceWith(H+1,H+F.nodeSize-1,_)}else{let B=H+1;F.content.forEach(z=>{if(z.type.name==="columnRow"){let _=B+1;z.content.forEach((se,re,Y)=>{if(Y===w){let D=_+se.nodeSize-1;O.insert(D,y.schema.nodeFromJSON(k))}_+=se.nodeSize})}B+=z.nodeSize})}y.view.dispatch(O),N()},[y,e,t,P,M,N]),R=(0,Nt.useCallback)((E,C)=>{try{if(E.type==="sidebar"&&(C.type==="editor"||C.type==="column-cell-item"||C.type==="nested-drag")){let x=E.dragType;if(!x||!y)return;let w=C.insertPos;if(w===void 0)if(C.type==="editor"){let L=C.index+1;w=P(L)}else{console.warn("Nested drop without position data");return}let A=M(x);if(y.commands.insertContentAt(w,A),y.state.doc.resolve(w).depth===0){let L=y.state.doc.resolve(w).index(0),S=[...e.Editor];L<=S.length&&(S.splice(L,0,A.attrs.id),t({...e,Editor:S}))}N();return}if((E.type==="editor"||E.type==="column-cell-item"||E.type==="nested-drag")&&(C.type==="editor"||C.type==="column-cell-item"||C.type==="nested-drag")){if(!y)return;let x=-1,w=null;if(E.pos!==void 0&&(x=E.pos,w=y.state.doc.nodeAt(x)),(x===-1||!w)&&y.state.doc.descendants((S,H)=>S.attrs.id===E.id?(x=H,w=S,!1):!0),x===-1||!w){let S=e.Editor.findIndex(H=>H===E.id);S!==-1&&(x=P(S),w=y.state.doc.nodeAt(x))}if(!w||x===-1)return;let A=C.insertPos;if(A===void 0){let S;C.index===void 0?S=y.state.doc.childCount:C.index===-1?S=0:S=C.index+1,A=P(S)}if(A===void 0||A>x&&A<x+w.nodeSize)return;if(A>x){let S=A-w.nodeSize;y.chain().deleteRange({from:x,to:x+w.nodeSize}).insertContentAt(S,w.toJSON()).run()}else y.chain().insertContentAt(A,w.toJSON()).deleteRange({from:x+w.nodeSize,to:x+w.nodeSize*2}).run();let k=e.Editor.includes(E.id);if(k){let S=e.Editor.filter(H=>H!==E.id);t({...e,Editor:S})}let L=y.state.doc.resolve(A).depth===0;N()}}catch(x){console.error("[Pragmatic DnD] Error in handleDrop:",x)}},[e,y,t,P,N,M]);return(0,Nt.useEffect)(()=>Qu({onDragStart:({source:E})=>{let C=E.data;p(!0),l(C.id),C.dragType&&i(C.dragType);let x=y==null?void 0:y.view.dom.querySelectorAll('[data-node-type="column"]');x&&(u.current=Array.from(x).map(A=>A.getBoundingClientRect()));let w=y==null?void 0:y.view.dom.querySelectorAll("[data-node-view-wrapper]");if(w){let A=new Set,k=Array.from(w).filter(L=>{let S=L,H=S.parentElement;if(H!=null&&H.hasAttribute("data-column-cell"))return!1;let V=S.getBoundingClientRect(),F=V.top+V.height/2;return A.has(Math.round(F))?!1:(A.add(Math.round(F)),!0)});d.current=k.map(L=>L.getBoundingClientRect())}},onDrop:({source:E,location:C})=>{let x=E.data,w=C.current.dropTargets[0];if(!w){g(),p(!1),l(null),i(null);return}let A=w.data;if(A.type==="column-cell"){T(x,A),p(!1),l(null),i(null),g();return}let k=A,L=ga(w.data);if(k.pos!==void 0&&L&&y){let S=y.state.doc.nodeAt(k.pos);S&&(L==="top"?k.insertPos=k.pos:L==="bottom"&&(k.insertPos=k.pos+S.nodeSize))}if(k.insertPos===void 0&&L&&k.index!==void 0){let S=L==="top"?k.index-1:k.index;k={...k,index:S}}else if(k.index===void 0&&k.insertPos===void 0){let H=C.current.input.clientY;if(d.current.length>0){let V=0,F=1/0;d.current.forEach((se,re)=>{let Y=se.top+se.height/2,D=Math.abs(H-Y);D<F&&(F=D,V=re)});let O=d.current[V],B=O.top+O.height/2,_=H>=B?V:V-1;k={...k,index:_,fromCoordinates:!0}}else k={...k,index:(y==null?void 0:y.state.doc.childCount)||0}}R(x,k),p(!1),l(null),i(null),g()}}),[y,p,g,l,i,R,T]),{activeId:a,activeDragType:n,dndMode:c,lastPlaceholderIndex:o,cleanupPlaceholder:g}},"usePragmaticDnd");var Vl=require("react");var vg=require("jotai");var Ol=s(({setItems:e,rafId:t,editor:r})=>{let o=(0,vg.useAtomValue)(He),n=r||o,i=(0,Vl.useCallback)(a=>{t.current&&typeof cancelAnimationFrame!="undefined"&&cancelAnimationFrame(t.current);let l=setTimeout(()=>{if(typeof requestAnimationFrame!="undefined")t.current=requestAnimationFrame(()=>{try{let c=a==null?void 0:a.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(m=>{let p=m,f=p.dataset.id;if(f){let v=p.parentElement,h=!1;for(;v&&v!==c;){if(v.hasAttribute("data-column-cell")){h=!0;break}v=v.parentElement}h||d.push(f)}}),e(m=>({Editor:d,Sidebar:m.Sidebar}))}catch(c){console.error("Error syncing editor items:",c),e(u=>({...u}))}});else try{let c=a==null?void 0:a.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(m=>{let p=m,f=p.dataset.id;if(f){let v=p.parentElement,h=!1;for(;v&&v!==c;){if(v.hasAttribute("data-column-cell")){h=!0;break}v=v.parentElement}h||d.push(f)}}),e(m=>({Editor:d,Sidebar:m.Sidebar}))}catch(c){console.error("Error syncing editor items:",c)}},50);return()=>clearTimeout(l)},[e,t]);return(0,Vl.useEffect)(()=>{if(!n||typeof n.on!="function")return;let a,l=s(()=>{n&&(a&&a(),a=i(n))},"updateItems");n.on("update",l),n.on("selectionUpdate",l),n.on("create",l),n.on("transaction",l),n&&!n.isDestroyed&&l();let c=s(u=>{l()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",c),()=>{n==null||n.off("update",l),n==null||n.off("selectionUpdate",l),n==null||n.off("create",l),n==null||n.off("transaction",l),document.removeEventListener("node-duplicated",c),a&&a(),t.current&&typeof cancelAnimationFrame!="undefined"&&(cancelAnimationFrame(t.current),t.current=null)}},[n,i,t]),{syncEditorItems:i}},"useSyncEditorItems");var Ei=require("react/jsx-runtime"),Va=[{type:"text",align:"left",content:`
|
|
187
|
+
`,text_style:"h1"},{type:"text",align:"left",content:""},{type:"image",src:""}],nb=(0,xe.forwardRef)(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:a,colorScheme:l,hidePreviewPanelExitButton:c,...u},d)=>{let m=(0,rr.useAtomValue)(He),[p,f]=(0,rr.useAtom)(ye),[v,h]=(0,rr.useAtom)(dn),b=(0,xe.useRef)({}),[y,N]=(0,xe.useState)(c?"desktop":void 0),g=(0,rr.useAtomValue)(nt),P=(0,rr.useAtomValue)(ae),M=(0,rr.useAtomValue)(wc),T=(0,rr.useAtomValue)(lo),R=(0,xe.useRef)(-1),E=(0,rr.useSetAtom)(sp),C=(0,xe.useRef)(!1),x=(0,xe.useRef)(!1),[w]=(0,rr.useAtom)(ee),A=(0,rr.useAtomValue)(_r),k=(0,rr.useAtomValue)(Ct),[L,S]=(0,xe.useState)({Editor:[],Sidebar:["heading","text","image","spacer","divider","button","customCode"]}),H=(0,xe.useRef)(null);Ti({items:L,setItems:S,editor:m});let{syncEditorItems:V}=Ol({setItems:S,rafId:H,editor:m});(0,xe.useEffect)(()=>{k&&(x.current=!1)},[k]);let[F,O]=(0,xe.useState)(!1);(0,xe.useEffect)(()=>{if(P===!1||P===null){let D=setTimeout(()=>{O(!0)},100);return()=>clearTimeout(D)}else O(!1)},[P,F]),(0,xe.useEffect)(()=>{if(p){let D=p.type.name,Z=bs(D);E({nodeName:D,config:Z})}},[p,E]);let B=(0,xe.useMemo)(()=>{var Z,ie,Me,$e,Je,pr,fr,le,De,Ae,Bt,Dt,Ir,Lr,Rr,Hr,Ho,Bo,oe,ho,cn,un,Ri,Hi,Bi,Di,Fi,Vi,X,ne,ge,we,We,Br;if(T)return T;let D=(Me=(ie=(Z=g==null?void 0:g.data)==null?void 0:Z.tenant)==null?void 0:ie.brand)==null?void 0:Me.settings;return{brandColor:(($e=D==null?void 0:D.colors)==null?void 0:$e.primary)||"#000000",textColor:((Je=D==null?void 0:D.colors)==null?void 0:Je.secondary)||"#000000",subtleColor:((pr=D==null?void 0:D.colors)==null?void 0:pr.tertiary)||"#666666",headerStyle:(le=(fr=D==null?void 0:D.email)==null?void 0:fr.header)!=null&&le.barColor?"border":"plain",logo:(Bt=(Ae=(De=D==null?void 0:D.email)==null?void 0:De.header)==null?void 0:Ae.logo)==null?void 0:Bt.image,link:(Lr=(Ir=(Dt=D==null?void 0:D.email)==null?void 0:Dt.header)==null?void 0:Ir.logo)==null?void 0:Lr.href,facebookLink:(Bo=(Ho=(Hr=(Rr=D==null?void 0:D.email)==null?void 0:Rr.footer)==null?void 0:Hr.social)==null?void 0:Ho.facebook)==null?void 0:Bo.url,linkedinLink:(un=(cn=(ho=(oe=D==null?void 0:D.email)==null?void 0:oe.footer)==null?void 0:ho.social)==null?void 0:cn.linkedin)==null?void 0:un.url,instagramLink:(Di=(Bi=(Hi=(Ri=D==null?void 0:D.email)==null?void 0:Ri.footer)==null?void 0:Hi.social)==null?void 0:Bi.instagram)==null?void 0:Di.url,mediumLink:(ne=(X=(Vi=(Fi=D==null?void 0:D.email)==null?void 0:Fi.footer)==null?void 0:Vi.social)==null?void 0:X.medium)==null?void 0:ne.url,xLink:(Br=(We=(we=(ge=D==null?void 0:D.email)==null?void 0:ge.footer)==null?void 0:we.social)==null?void 0:We.twitter)==null?void 0:Br.url}},[T,g]),z=M&&!!B,_=(0,xe.useCallback)(()=>{Object.values(b.current).forEach(D=>clearTimeout(D)),b.current={}},[]);(0,xe.useEffect)(()=>()=>{_()},[_]),(0,xe.useEffect)(()=>{let D=s(Z=>{if(Z.key==="Escape"&&(f(null),m==null||m.commands.blur(),R.current=-1),Z.key==="Tab"&&m){Z.preventDefault();let ie=-1;p&&m.state.doc.content.forEach((Je,pr,fr)=>{p.attrs.id===Je.attrs.id&&(ie=fr)}),ie===-1&&(ie=0);let Me=m.state.doc,$e;if(Z.shiftKey?$e=(ie-1+Me.childCount)%Me.childCount:$e=(ie+1)%Me.childCount,$e!==ie||p===null){let Je=Me.child($e);f(Je),m.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",D),()=>{document.removeEventListener("keydown",D)}},[m,p,f]),(0,xe.useEffect)(()=>{if(P!==!1||k)return;let D=w!=null?w:"";if(D){let Z=Bc(D,"email");h(Z||"")}setTimeout(()=>{if(!(!m||m.isDestroyed)&&m.state.doc.childCount===1){let Z=m.state.doc.child(0);f(Z)}},0)},[g,P,k,m,h,f,w]),(0,xe.useEffect)(()=>{P===!1&&g&&!x.current&&(x.current=!0,setTimeout(()=>{m&&!m.isDestroyed&&V(m)},300))},[P,g,m,V]),(0,xe.useEffect)(()=>(C.current=!0,()=>{C.current=!1}),[]);let se=(0,xe.useCallback)(D=>{let ie=D||(y===void 0?"desktop":void 0);N(ie),f(null),ie?m==null||m.setEditable(!1):m==null||m.setEditable(!0)},[m,y,N,f]),re=s(D=>{h(D.target.value)},"handleSubjectChange"),Y=(0,xe.useMemo)(()=>{if(P!==!1||!F)return null;let D=a&&a.elements&&a.elements.length>0;D&&(x.current=!0);let Z;return D&&(Z=a.elements.find(Me=>Me.type==="channel"&&Me.channel==="email")),Z||(Z={type:"channel",channel:"email",elements:Va}),Ze({version:"2022-01-01",elements:[Z]},{channel:"email"})},[a,P,F]);return k&&(w===null||Y===null)?null:(0,Ei.jsx)(Xt,{theme:t,colorScheme:l,isLoading:!!P,Header:i?i({hidePublish:e,channels:r,routing:o}):(0,Ei.jsx)(Mr,{hidePublish:e,channels:r,routing:o}),...u,children:(0,Ei.jsx)(Ei.Fragment,{children:n==null?void 0:n({subject:v,handleSubjectChange:re,selectedNode:p,setSelectedNode:f,previewMode:y,templateEditor:m,ref:d,isBrandApply:z,brandSettings:B,items:L,content:Y,syncEditorItems:V,brandEditorContent:A,templateData:g,togglePreviewMode:se,hidePreviewPanelExitButton:c})})})}),Ul=(0,xe.memo)(nb);var Wl=class Wl{};s(Wl,"UploadImageAPI"),Wl.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 Rd=Wl,Hd=Rd;var or=s(e=>[gd,Id.StarterKit.configure({document:!1,dropcursor:!1,gapcursor:!1,heading:!1,horizontalRule:!1,paragraph:!1,blockquote:!1,hardBreak:!1,code:!1}),Ed.configure({setSelectedNode:e==null?void 0:e.setSelectedNode,shouldHandleClick:e==null?void 0:e.shouldHandleClick}),Pd.HardBreak.configure({keepMarks:!0,HTMLAttributes:{class:"my-line-break"}}),T1,fd,Td,td,bd.configure({levels:[1,2,3,4,5,6]}),Ys,el,kd.Color,ol,il,cl,dl,vd.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),Sd.Underline,kl.configure(),gl.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(t,r,o)=>{r.forEach(async n=>{let i=await Hd.uploadImage(n);t.chain().setImageBlockAt({pos:o,src:i}).focus().run()})},onPaste:(t,r)=>{r.forEach(async o=>{let n=await Hd.uploadImage(o);return t.chain().setImageBlockAt({pos:t.state.selection.anchor,src:n}).focus().run()})}}),Md.TextAlign.extend({addKeyboardShortcuts(){return{}}}).configure({types:["paragraph","heading"]}),Ad.Typography,Nd.Placeholder.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:"",emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",showOnlyWhenEditable:!0}),ed.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),ad,Pn,Nn,bl,vl],"ExtensionKit");var Jl=require("@tiptap/react");var xg=require("jotai"),Dn=require("react");var _l=s(e=>{let t=(0,xg.useAtomValue)(ye),[r,o]=(0,Dn.useState)({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1}),n=(0,Dn.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,Dn.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,Dn.useCallback)(({editor:a})=>{let l=["paragraph","heading","blockquote"],{$head:c}=a.state.selection,u=c.node();if(l.includes(u.type.name)&&u.attrs.isSelected)return!0;for(let d=1;d<=c.depth;d++){let m=c.node(d);if(m.type.name==="blockquote"){if(m.attrs.isSelected)return!0;let p=a.state.selection.from!==a.state.selection.to;if(a.isFocused&&p)return!0}}return!1},[]),...r}},"useTextmenuStates");var Zl=require("jotai"),rt=require("lucide-react"),ir=require("react");var zl=require("react");var Eg=he(require("@tippyjs/react"),1),wg=require("react");var zt=require("react/jsx-runtime"),Tg=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,ib=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-muted-foreground courier-border-b-2";return e==="Mod"?(0,zt.jsx)("kbd",{className:t,children:Tg?"\u2318":"Ctrl"}):e==="Shift"?(0,zt.jsx)("kbd",{className:t,children:"\u21E7"}):e==="Alt"?(0,zt.jsx)("kbd",{className:t,children:Tg?"\u2325":"Alt"}):(0,zt.jsx)("kbd",{className:t,children:e})},"ShortcutKey"),kg=s(({children:e,enabled:t=!0,title:r,shortcut:o,tippyOptions:n={}})=>{let i=Km(),a=(0,wg.useCallback)(l=>{let c=Object.entries(i).reduce((u,[d,m])=>{let p=d.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`);return{...u,[`--${p}`]:m}},{});return(0,zt.jsxs)("span",{className:I("courier-flex courier-items-center courier-gap-2 courier-px-2.5 courier-py-1 courier-bg-popover courier-text-popover-foreground courier-border courier-border-border courier-rounded-lg courier-shadow-sm courier-z-[999]",i.colorScheme==="dark"?"dark":""),style:c,tabIndex:-1,"data-placement":l["data-placement"],"data-reference-hidden":l["data-reference-hidden"],"data-escaped":l["data-escaped"],children:[r&&(0,zt.jsx)("span",{className:"courier-text-xs courier-font-medium courier-text-muted-foreground",children:r}),o&&(0,zt.jsx)("span",{className:"courier-flex courier-items-center courier-gap-0.5",children:o.map(u=>(0,zt.jsx)(ib,{children:u},u))})]})},[o,r,i]);return t?(0,zt.jsx)(Eg.default,{...n,delay:500,offset:[0,8],touch:!1,zIndex:99999,appendTo:document.body,trigger:"mouseenter focus",showOnCreate:!1,render:a,animation:!1,children:(0,zt.jsx)("span",{children:e})}):(0,zt.jsx)(zt.Fragment,{children:e})},"Tooltip");var Oa=require("react/jsx-runtime"),Pg=(0,zl.forwardRef)(({shouldShowContent:e=!0,children:t,isVertical:r=!1,className:o,...n},i)=>{let a=I("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,Oa.jsx)(wd,{className:a,...n,ref:i,children:t})});Pg.displayName="Toolbar";var Ng=(0,zl.forwardRef)(({horizontal:e,className:t,...r},o)=>{let n=I("courier-bg-border",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,Oa.jsx)("div",{className:n,ref:o,...r})});Ng.displayName="Toolbar.Divider";var Mg=(0,zl.forwardRef)(({children:e,buttonSize:t="icon",variant:r="ghost",className:o,tooltip:n,tooltipShortcut:i,...a},l)=>{let c=I("courier-gap-1 courier-min-w-[2rem] courier-w-auto",o),u=(0,Oa.jsx)(Se,{className:c,variant:r,buttonSize:t,ref:l,...a,children:e});return n?(0,Oa.jsx)(kg,{title:n,shortcut:i,children:u}):u});Mg.displayName="ToolbarButton";var $l={Wrapper:Pg,Divider:Ng,Button:Mg};var Ag=require("lucide-react"),Sg=require("react");var nr=require("react/jsx-runtime"),ab=s(e=>e.type==="option","isOption"),Ig=s(({options:e,containerRef:t})=>{let r=(0,Sg.useMemo)(()=>e.find(o=>o.type==="option"&&o.isActive()),[e]);return(0,nr.jsxs)(os,{children:[(0,nr.jsx)(ns,{asChild:!0,children:(0,nr.jsxs)(Se,{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,nr.jsx)(Ag.ChevronDown,{className:"courier-w-3 courier-h-3"})]})}),(0,nr.jsx)(zi,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(ab(o))return(0,nr.jsx)($i,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?(0,nr.jsx)(nr.Fragment,{children:o.id==="heading1"?(0,nr.jsx)("h1",{className:"courier-text-2xl courier-font-bold",children:o.label}):o.id==="heading2"?(0,nr.jsx)("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading3"?(0,nr.jsx)("h3",{className:"courier-text-lg courier-font-bold",children:o.label}):o.label}):o.label},o.id)})})]})},"ContentTypePicker");var Lg=require("@tiptap/react");var Rg=s(e=>(0,Lg.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 st=require("react/jsx-runtime"),sb=(0,ir.memo)($l.Button),lb=(0,ir.memo)(Ig),ql=s(({editor:e,config:t})=>{var R;let r=_l(e),o=Rg(e),n=(0,ir.useRef)(null),i=(0,Zl.useAtomValue)(ys),a=(0,Zl.useAtomValue)(ye),l=a==null?void 0:a.type.name,c=(0,Zl.useAtomValue)(ap),[u,d]=(0,ir.useState)(()=>{let{selection:E}=e.state;return{from:E.from,to:E.to,empty:E.empty}});(0,ir.useEffect)(()=>{let E=s(()=>{let{selection:C}=e.state;d({from:C.from,to:C.to,empty:C.empty})},"updateSelection");return e.on("selectionUpdate",E),e.on("transaction",E),()=>{e.off("selectionUpdate",E),e.off("transaction",E)}},[e]);let m=(0,ir.useMemo)(()=>!u.empty&&u.from!==u.to,[u]),p=(0,ir.useMemo)(()=>t||c(l||"",m),[t,c,l,m]),f=Hl(e,p,r),v=s(()=>{let{selection:E}=e.state;if(!(E.empty&&!r.isLink&&!e.can().setLink({href:""})))if(r.isLink){let C=e.state.tr.setMeta("showLinkForm",{from:E.from,to:E.to});e.view.dispatch(C)}else{let C=e.state.tr.setMeta("showLinkForm",{from:E.from,to:E.to});e.view.dispatch(C)}},"handleLinkToggle"),h=s(()=>{if(i.ref){let E=i.ref,C=E.value,x=i.caretPosition||E.selectionStart||0,w=C.substring(0,x),A=C.substring(x),k=`${w}{{${A}`,L=x+2;E.focus();let S=new Event("input",{bubbles:!0,cancelable:!0});if(Object.defineProperty(S,"target",{writable:!1,value:{...E,value:k}}),E.value=k,E.dispatchEvent(S),E.setSelectionRange(L,L),E.getBoundingClientRect()){let V=k.slice(0,L),F=document.createElement("span");F.style.font=window.getComputedStyle(E).font,F.style.whiteSpace="pre-wrap",F.textContent=V,document.body.appendChild(F);let O=F.offsetWidth;document.body.removeChild(F);let B=parseInt(window.getComputedStyle(E).lineHeight),z=V.split(`
|
|
188
|
+
`).length-1,_=new CustomEvent("showVariableSuggestions",{detail:{cursorPosition:{left:Math.min(O%E.offsetWidth,E.offsetWidth-200),top:z*B+30}},bubbles:!0});E.dispatchEvent(_)}return}e.chain().focus().insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()},"handleVariableClick"),b=s((E,C,x,w,A,k,L)=>{let S=p[E];return!S||Array.isArray(S)||S.state==="hidden"?null:(0,st.jsx)(sb,{tooltip:x,tooltipShortcut:k,onClick:w,active:A,disabled:S.state==="disabled",...L,children:C},E)},"renderButton"),y=s((E,C)=>{let x=E.filter(w=>!!w);return x.length>0?(0,st.jsx)("div",{className:"courier-flex courier-items-center courier-gap-0.5",children:x},C):null},"renderGroup"),N=y([((R=p.contentType)==null?void 0:R.state)==="enabled"&&(0,st.jsx)(lb,{options:o,containerRef:n},"content-type")],"content-type-group"),g=y([b("bold",(0,st.jsx)(rt.Bold,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",f.onBold,r.isBold,["Mod","B"]),b("italic",(0,st.jsx)(rt.Italic,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",f.onItalic,r.isItalic,["Mod","I"]),b("underline",(0,st.jsx)(rt.Underline,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",f.onUnderline,r.isUnderline,["Mod","U"]),b("strike",(0,st.jsx)(rt.Strikethrough,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Strikethrough",f.onStrike,r.isStrike,["Mod","Shift","S"])],"text-style-group"),P=y([b("alignLeft",(0,st.jsx)(rt.AlignLeft,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",f.onAlignLeft,r.isAlignLeft,["Shift","Mod","L"]),b("alignCenter",(0,st.jsx)(rt.AlignCenter,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",f.onAlignCenter,r.isAlignCenter,["Shift","Mod","E"]),b("alignRight",(0,st.jsx)(rt.AlignRight,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",f.onAlignRight,r.isAlignRight,["Shift","Mod","R"]),b("alignJustify",(0,st.jsx)(rt.AlignJustify,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",f.onAlignJustify,r.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),M=y([b("quote",(0,st.jsx)(rt.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Quote",f.onQuote,r.isQuote,["Mod","Shift","B"])],"block-style-group"),T=y([b("link",(0,st.jsx)(rt.Link,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",v,r.isLink,["Mod","K"]),b("variable",(0,st.jsx)(op,{width:16}),"Variable",h,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return(0,st.jsx)($l.Wrapper,{ref:n,className:"courier-border-b rounded-b-none rounded-t-sm !courier-shadow-md courier-justify-center courier-rounded-lg",children:[N,g,P,M,T].filter(Boolean).map((E,C)=>(0,st.jsxs)(ir.Fragment,{children:[E,C<[N,g,P,M,T].filter(Boolean).length-1&&(0,st.jsx)($l.Divider,{})]},`item-${C}`))})},"TextMenu");var Bd=require("react/jsx-runtime"),ar=s(({config:e})=>{let{editor:t}=(0,Jl.useCurrentEditor)(),r=_l(t);return t?(0,Bd.jsx)(Jl.BubbleMenu,{editor:t,tippyOptions:{appendTo:o=>{var n;return(n=o.closest(".bubble-text-menu-container"))!=null?n:o},getReferenceClientRect:()=>{var a,l,c,u;let o=(c=(l=(a=t==null?void 0:t.state)==null?void 0:a.selection)==null?void 0:l.from)!=null?c: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,Bd.jsx)(ql,{editor:t,config:e})}):null},"BubbleTextMenu");var Hg=require("@tiptap/pm/state"),wi=require("@tiptap/react"),Ua=require("jotai"),Gr=require("react");var Mt=require("react/jsx-runtime"),cb=s(({value:e,readOnly:t})=>{let{editor:r}=(0,wi.useCurrentEditor)(),o=(0,Ua.useSetAtom)(zn),n=(0,Ua.useAtomValue)(ae),i=(0,Gr.useRef)(!1);return(0,Gr.useEffect)(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(Rc(e!=null?e:"")))},[r,e,n,t]),(0,Gr.useEffect)(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),ub=s(({facebookLink:e,linkedinLink:t,instagramLink:r,mediumLink:o,xLink:n,readOnly:i=!1,value:a,onUpdate:l})=>{let c=(0,Gr.useRef)(!1),u=(0,Ua.useSetAtom)(ye),d=wi.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:p})=>{let{state:f,dispatch:v}=p.view;return v(f.tr.setSelection(Hg.TextSelection.create(f.doc,f.selection.$anchor.pos))),u&&u(null),!1}}}});(0,Gr.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=(0,Gr.useMemo)(()=>[...or({setSelectedNode:u}),d].filter(p=>p!==void 0),[d,u]);return(0,Mt.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[(0,Mt.jsxs)(wi.EditorProvider,{content:Rc(a!=null?a:""),extensions:m,editable:!i,autofocus:!i,onUpdate:l,editorContainerProps:{className:I("courier-py-2 courier-flex-grow",i&&"courier-brand-editor-readonly")},immediatelyRender:!1,children:[(0,Mt.jsx)(cb,{value:a,readOnly:i}),(0,Mt.jsx)(ar,{})]}),(0,Mt.jsxs)("div",{className:"courier-flex courier-justify-end courier-items-center courier-gap-2 courier-mt-3",children:[e&&(0,Mt.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:(0,Mt.jsx)(Yi,{className:"courier-w-5 courier-h-5"})}),t&&(0,Mt.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:(0,Mt.jsx)(ea,{className:"courier-w-5 courier-h-5"})}),r&&(0,Mt.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:(0,Mt.jsx)(Qi,{className:"courier-w-5 courier-h-5"})}),o&&(0,Mt.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:(0,Mt.jsx)(ta,{className:"courier-w-5 courier-h-5"})}),n&&(0,Mt.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:(0,Mt.jsx)(aa,{className:"courier-w-5 courier-h-5"})})]})]})},"BrandFooterComponent"),ki=(0,Gr.memo)(ub);var sr=require("react/jsx-runtime"),Bg=s(({value:e,icon:t,...r})=>(0,sr.jsx)(_t,{value:e,...r,className:"!courier-w-10 !courier-h-6 [&_svg]:!courier-size-5 [&_svg]:courier-fill-accent dark:[&_svg]:courier-fill-accent-foreground hover:courier-bg-transparent courier-rounded-sm data-[state=on]:courier-bg-background [&_svg]:data-[state=on]:courier-fill-foreground",children:t}),"PreviewItem"),jl=s(({previewMode:e,togglePreviewMode:t,hideMobileToggle:r=!1,hideExitButton:o=!1,...n})=>(0,sr.jsxs)("div",{...n,className:I("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",n.className),children:[e&&!r&&(0,sr.jsxs)(sr.Fragment,{children:[(0,sr.jsxs)(Pr,{type:"single",value:e,onValueChange:i=>{i!==""&&t(i)},className:"courier-w-full courier-rounded-md !courier-p-0.5 courier-bg-[#3B82F6] !courier-gap-0",children:[(0,sr.jsx)(Bg,{value:"desktop",icon:(0,sr.jsx)(iu,{})}),(0,sr.jsx)(Bg,{value:"mobile",icon:(0,sr.jsx)(vu,{})})]}),!o&&(0,sr.jsx)("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),!o&&(0,sr.jsxs)(Se,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");var Fd=require("react");function db(){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,templateEditorContent:null}))}s(db,"initTestHelpers");function lr(e,t){typeof window!="undefined"&&(db(),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(lr,"setTestEditor");var Vg=require("@tiptap/core"),Og=require("@tiptap/pm/state"),Gl=require("@tiptap/react"),Ye=require("jotai"),fe=require("react");var Dg=require("@tiptap/react"),Fg=require("react");var Ar=s(({value:e,defaultValue:t})=>{let{editor:r}=(0,Dg.useCurrentEditor)();return(0,Fg.useEffect)(()=>{if(!r)return;let o=setTimeout(()=>{r.commands.setContent(e||t)},0);return()=>clearTimeout(o)},[r,e,t]),null},"ReadOnlyEditorContent");var mo=require("react/jsx-runtime"),mb=s(({value:e})=>{let{editor:t}=(0,Gl.useCurrentEditor)(),[r,o]=(0,Ye.useAtom)(ee),n=(0,Ye.useSetAtom)(je),i=(0,Ye.useAtomValue)(dn),a=(0,Ye.useAtomValue)(ye),l=(0,Ye.useSetAtom)(He),c=(0,Ye.useSetAtom)(pn),u=(0,fe.useRef)(!1),d=(0,fe.useRef)(),m=(0,Ye.useAtomValue)(ae),p=(0,Ye.useAtomValue)(nt),f=(0,fe.useRef)(!1),v=(0,Ye.useAtomValue)(Ct);return(0,fe.useEffect)(()=>{m&&(f.current=!1)},[m]),(0,fe.useEffect)(()=>(c({action:"register",id:"email-subject",fn:s(()=>{var b;if(d.current&&(clearTimeout(d.current),d.current=void 0,t&&i!==null&&m===!1&&!v))try{let y=de(t.getJSON());if(!y||!Array.isArray(y))return;let N=i;if(!i&&r){let T=(b=r==null?void 0:r.elements)==null?void 0:b.find(R=>R.type==="channel"&&R.channel==="email");T&&(N=Wi(T,"email"))}let g=Or(r,"email",N||"",y),P={elements:g.elements,channel:"email",...g.raw&&{raw:g.raw}},M=ut(r,P);JSON.stringify(r)!==JSON.stringify(M)&&(o(M),n(M))}catch(y){console.error("[FlushSubjectUpdate]",y)}},"flushSubjectUpdate")}),()=>{c({action:"unregister",id:"email-subject"})}),[t,i,m,v,r,o,n,c]),(0,fe.useEffect)(()=>{!t||m!==!1||f.current||!e||(l(t),f.current=!0,t.commands.setContent(e))},[t,e,l,m]),(0,fe.useEffect)(()=>{if(!(!(t&&i!==null)||m!==!1||v)&&!t.isFocused)return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var h;try{let b=de(t.getJSON());if(!b||!Array.isArray(b))return;let y=i;if(!i&&r){let M=(h=r==null?void 0:r.elements)==null?void 0:h.find(T=>T.type==="channel"&&T.channel==="email");M&&(y=Wi(M,"email"))}let N=Or(r,"email",y||"",b),g={elements:N.elements,channel:"email",...N.raw&&{raw:N.raw}},P=ut(r,g);JSON.stringify(r)!==JSON.stringify(P)&&(o(P),n(P))}catch(b){console.error(b)}},500),()=>{d.current&&clearTimeout(d.current)}},[p,t,i,o,n,m,r,v]),(0,fe.useEffect)(()=>()=>{t&&!t.isDestroyed&&t.setEditable(!0)},[t]),(0,fe.useEffect)(()=>{t&&u.current&&t.commands.updateSelectionState(a)},[t,a]),(0,fe.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]),null},"EditorContent"),pb=s(({value:e,readOnly:t=!1,onDestroy:r,onUpdate:o,subject:n})=>{let i=(0,Ye.useSetAtom)(Cs),a=(0,fe.useRef)(),[l,c]=(0,Ye.useAtom)(ee),u=(0,Ye.useAtomValue)(dn),d=n!=null?n:u,m=(0,Ye.useSetAtom)(ye),p=(0,Ye.useAtomValue)(He),f=(0,Ye.useAtomValue)(Ct),v=(0,Ye.useAtomValue)(jt),h=(0,Ye.useSetAtom)(pn),b=(0,Ye.useSetAtom)(je),y=(0,fe.useRef)(l),N=(0,fe.useRef)(d),g=(0,fe.useRef)(v);(0,fe.useEffect)(()=>{y.current=l},[l]),(0,fe.useEffect)(()=>{N.current=d},[d]),(0,fe.useEffect)(()=>{g.current=v},[v]),(0,fe.useEffect)(()=>{p==null||p.setEditable(!t)},[t,p]);let P=Vg.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:O})=>{let{state:B,dispatch:z}=O.view;return z(B.tr.setSelection(Og.TextSelection.create(B.doc,B.selection.$anchor.pos))),m&&m(null),!1}}}}),M=(0,fe.useCallback)(({editor:O})=>{o==null||o(O),lr("email",O),m&&setTimeout(()=>{m(null)},100)},[m,o]),T=(0,fe.useRef)(),R=(0,fe.useRef)(null),E=(0,fe.useCallback)((O,B)=>{var Z;if(f)return;let z=y.current,_=N.current;if(!z){let ie={version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:B}]};c(ie),b(ie);return}let se=z.elements.find(ie=>ie.type==="channel"&&ie.channel==="email"),re={...se};re.elements=(Z=re.elements)==null?void 0:Z.filter(ie=>ie.type!=="meta");let Y={type:"channel",channel:"email",elements:B};if(JSON.stringify(re)!==JSON.stringify(Y)){let ie=_;!_&&se&&(ie=Wi(se,"email"));let Me=Or(z,"email",ie||"",B);Y.elements=Me.elements,Me.raw&&(Y.raw=Me.raw);let $e=ut(z,Y);c($e),b($e)}o==null||o(O),lr("email",O)},[c,b,o,f]),C=(0,fe.useCallback)(({editor:O})=>{let B=de(O.getJSON());R.current={editor:O,elemental:B},T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{if(R.current){let{editor:z,elemental:_}=R.current;E(z,_),R.current=null}},200)},[E]),x=(0,fe.useCallback)(({editor:O})=>{if(g.current)return;let{selection:B}=O.state,{$anchor:z}=B,se=B.$head.marks().find(Z=>Z.type.name==="link");se||O.isActive("link")?i({mark:se}):i(null);let re=z.depth,Y=null,D=null;for(;re>0;){let Z=z.node(re);!D&&Z.type.name==="blockquote"&&(D=Z),!Y&&(Z.type.name==="paragraph"||Z.type.name==="heading")&&(Y=Z),re--}D?m(D):Y&&m(Y)},[i,m]),w=(0,fe.useCallback)(({editor:O,transaction:B})=>{let z=B==null?void 0:B.getMeta("showLinkForm");if(z){let{selection:_}=O.state,re=_.$head.marks().find(Y=>Y.type.name==="link");i({mark:re,link:{from:z.from,to:z.to}})}},[i]),A=(0,fe.useCallback)(()=>{a.current&&clearTimeout(a.current),T.current&&clearTimeout(T.current),r==null||r(),lr("email",null)},[r]);(0,fe.useEffect)(()=>(h({action:"register",id:"email-content",fn:s(()=>{if(T.current&&(clearTimeout(T.current),T.current=void 0,R.current)){let{editor:B,elemental:z}=R.current;E(B,z),R.current=null}},"flushContentUpdate")}),()=>{h({action:"unregister",id:"email-content"})}),[E,h]);let k=(0,fe.useCallback)(O=>{var re;if(g.current)return;let B=(re=O.view)==null?void 0:re.editor;if(!B||!B.isEditable)return;let z=O.target,_=B.view.posAtDOM(z,0),se=B.state.doc.resolve(_).node();se.type.name==="paragraph"&&m(se)},[m]),L=(0,fe.useCallback)(()=>!g.current,[]),S=(0,fe.useMemo)(()=>[...or({setSelectedNode:m,shouldHandleClick:L}),P].filter(O=>O!==void 0),[P,m,L]),H=e||{type:"doc",content:[{type:"paragraph"}]},V=t?{editable:!1,autofocus:!1}:{editable:!0,autofocus:!0,onCreate:M,onUpdate:C,onSelectionUpdate:x,onTransaction:w},F=(0,fe.useRef)(null);return(0,fe.useEffect)(()=>{let O=F.current;if(!(!O||t))return br({element:O,getData:()=>({type:"editor",id:"editor-drop-zone"}),canDrop:({source:B})=>B.data.type==="sidebar"?!0:B.data.type==="editor"})},[t]),(0,mo.jsx)("div",{ref:F,"data-testid":"email-editor",children:(0,mo.jsx)(Gl.EditorProvider,{content:H,extensions:S,...V,onDestroy:A,editorContainerProps:{onClick:k},immediatelyRender:!1,children:t?(0,mo.jsx)(Ar,{value:H,defaultValue:Va}):(0,mo.jsxs)(mo.Fragment,{children:[(0,mo.jsx)(mb,{value:H}),(0,mo.jsx)(ar,{})]})})})},"EmailEditor"),Kl=pb;var Wa=require("jotai"),Ug=require("lucide-react");var on=require("react");var Yl=require("react/jsx-runtime"),Pi=s(({children:e,id:t,className:r,editor:o})=>(0,Yl.jsx)(fb,{id:t,className:r,editor:o,children:e}),"SideBarSortableItemWrapper"),fb=(0,on.forwardRef)(({children:e,className:t,id:r,editor:o},n)=>{let i=(0,on.useRef)(null),[a,l]=(0,on.useState)(!1);return(0,on.useEffect)(()=>{let c=i.current;if(!(!c||!r))return co(fa({element:c,getInitialData:()=>({id:r,type:"sidebar",dragType:r}),onDragStart:()=>{l(!0),document.body.style.cursor="grabbing",o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{l(!1),document.body.style.cursor="",o&&o.setEditable(!0)}}))},[r,o]),(0,Yl.jsx)("div",{ref:i,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":r,className:I(t,"courier-relative",a&&"courier-opacity-50 courier-cursor-grabbing"),children:(0,Yl.jsx)("div",{children:e})})});var Te=require("react/jsx-runtime"),Xl=s(({items:e,brandEditor:t,label:r,editor:o})=>{var l,c;let n=(0,Wa.useAtomValue)(nt),i=(0,Wa.useSetAtom)(ii),a=(0,Wa.useAtomValue)(bt);return(0,Te.jsxs)("div",{className:"courier-flex courier-flex-col courier-h-full",children:[(0,Te.jsxs)("div",{className:"courier-flex-1",children:[r&&(0,Te.jsxs)(Te.Fragment,{children:[(0,Te.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:r}),(0,Te.jsx)(ce,{className:"courier-my-4"})]}),(0,Te.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(u=>(0,Te.jsx)(Pi,{id:u.toString(),editor:o,children:(0,Te.jsxs)("div",{className:I("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Te.jsx)(Ug.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),u==="heading"&&(0,Te.jsx)(Rs,{draggable:!0}),u==="text"&&(0,Te.jsx)(Jo,{draggable:!0}),u==="image"&&(0,Te.jsx)(Hs,{draggable:!0}),u==="spacer"&&(0,Te.jsx)(Bs,{draggable:!0}),u==="divider"&&(0,Te.jsx)(qo,{draggable:!0}),u==="button"&&(0,Te.jsx)(Zo,{draggable:!0}),u==="customCode"&&(0,Te.jsx)(Ta,{draggable:!0}),u==="column"&&(0,Te.jsx)(Ls,{draggable:!0})]})},u))})]}),t&&(0,Te.jsxs)("div",{className:"courier-mt-auto courier-pt-4",children:[(0,Te.jsx)(ce,{className:"courier-mb-4 -courier-mx-4"}),(c=(l=n==null?void 0:n.data)==null?void 0:l.tenant)!=null&&c.brand?(0,Te.jsx)("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:(0,Te.jsx)(Se,{variant:"link",className:"courier-underline",onClick:()=>i("brand"),disabled:!!a,children:"Edit brand"})}):(0,Te.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,Te.jsx)("h3",{className:"courier-text-md courier-font-medium courier-text-foreground",children:"Customize brand theme"}),(0,Te.jsx)("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),(0,Te.jsx)(Se,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>i("brand"),children:"Customize"})]})]})]})},"SideBar");var Wg=require("jotai");var Kr=require("react/jsx-runtime"),Ql=s(({element:e,editor:t})=>{var i,a;let r=(0,Wg.useAtomValue)(Uu);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(l=>l.type.name==="link")))return(0,Kr.jsx)(j1,{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:l}=t.state.selection,c=l.depth;for(;c>0;){let u=l.node(c);if(u.type.name==="blockquote")return u;c--}},"getBlockquoteElement");return(0,Kr.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[e.type.name==="button"&&(0,Kr.jsx)(Hf,{element:e,editor:t},e.attrs.id),e.type.name==="divider"&&(0,Kr.jsx)(b1,{element:e,editor:t},e.attrs.id),["paragraph","heading"].includes(e.type.name)&&!o&&(0,Kr.jsx)(R1,{element:e,editor:t},e.attrs.id),e.type.name==="imageBlock"&&(0,Kr.jsx)(z1,{element:e,editor:t},e.attrs.id),e.type.name==="customCode"&&(0,Kr.jsx)(pd,{element:e,editor:t},e.attrs.id),(e.type.name==="blockquote"||e.type.name==="paragraph"&&o||e.type.name==="heading"&&o)&&(0,Kr.jsx)(Cf,{element:n()||e,editor:t},e.attrs.id),e.type.name==="column"&&(0,Kr.jsx)(ud,{element:e,editor:t},e.attrs.id)]})},"SideBarItemDetails");var Dd=require("react"),_g=require("jotai");var No=require("react/jsx-runtime"),nn=(0,Dd.forwardRef)(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>(0,No.jsx)("div",{className:I("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})),an=(0,Dd.forwardRef)(({children:e,className:t,previewMode:r,skipExpanded:o=!1,width:n,...i},a)=>{let[l,c]=(0,_g.useAtom)(io),u=o?!1:l,d=n||"courier-w-64";return r?null:(0,No.jsxs)(No.Fragment,{children:[u&&(0,No.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:()=>c(!1),"aria-hidden":"true"}),(0,No.jsx)("div",{className:I("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch courier-relative",d,t),children:(0,No.jsx)("div",{className:I("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-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 _a=require("jotai");var _e=require("react/jsx-runtime"),Vd=(0,Fd.forwardRef)(({children:e,className:t,...r},o)=>(0,_e.jsx)("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Od=(0,Fd.forwardRef)(({children:e,previewMode:t,...r},o)=>(0,_e.jsx)("div",{className:I("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})),zg=s(({variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:a,colorScheme:l,...c})=>{let u=(0,_a.useAtomValue)(ee),d=(0,_a.useAtomValue)(io),m=(0,_a.useSetAtom)(io),p=s(()=>{d&&m(!1)},"handleSubjectAreaClick");return(0,_e.jsx)(Ul,{value:u,variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:a,colorScheme:l,render:({subject:f,handleSubjectChange:v,selectedNode:h,setSelectedNode:b,previewMode:y,templateEditor:N,ref:g,isBrandApply:P,brandSettings:M,items:T,content:R,syncEditorItems:E,brandEditorContent:C,templateData:x,togglePreviewMode:w,hidePreviewPanelExitButton:A})=>{var k,L,S,H,V,F;return(0,_e.jsxs)(nn,{previewMode:y,children:[(0,_e.jsxs)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:[(0,_e.jsxs)("div",{className:"courier-bg-background courier-h-12 courier-flex courier-items-center courier-gap-2 courier-px-4 courier-border-b",onClick:p,children:[(0,_e.jsxs)("h4",{className:"courier-text-sm courier-h-[25px] courier-flex courier-items-end courier-pb-px",children:["Subject:"," "]}),(0,_e.jsx)(hi,{value:f!=null?f:"",onChange:O=>v({target:{value:O}}),onFocus:()=>b(null),className:"!courier-bg-background courier-font-medium courier-flex-1",placeholder:"Write subject...",readOnly:y!==void 0})]}),(0,_e.jsxs)(Vd,{ref:g,children:[(0,_e.jsxs)(Od,{previewMode:y,children:[P&&(0,_e.jsxs)("div",{className:I("courier-py-5 courier-px-9 courier-pb-0 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(M==null?void 0:M.headerStyle)==="border"&&"courier-pt-6"),children:[(M==null?void 0:M.headerStyle)==="border"&&(0,_e.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:M==null?void 0:M.brandColor}}),(M==null?void 0:M.logo)&&(0,_e.jsx)("img",{src:M.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),R&&(0,_e.jsx)(Kl,{value:R,onUpdate:E,variables:e}),P&&x&&(0,_e.jsx)("div",{className:"courier-py-5 courier-px-9 courier-pt-0 courier-flex courier-flex-col",children:(0,_e.jsx)(ki,{readOnly:!0,value:C!=null?C:(F=(V=(H=(S=(L=(k=x==null?void 0:x.data)==null?void 0:k.tenant)==null?void 0:L.brand)==null?void 0:S.settings)==null?void 0:H.email)==null?void 0:V.footer)==null?void 0:F.markdown,variables:e,facebookLink:M==null?void 0:M.facebookLink,linkedinLink:M==null?void 0:M.linkedinLink,instagramLink:M==null?void 0:M.instagramLink,mediumLink:M==null?void 0:M.mediumLink,xLink:M==null?void 0:M.xLink})})]}),(0,_e.jsx)(jl,{previewMode:y,togglePreviewMode:w,hideExitButton:A})]})]}),(0,_e.jsx)(an,{previewMode:y,children:(0,_e.jsx)("div",{className:"courier-p-1 courier-h-full",children:h?(0,_e.jsx)(Ql,{element:h,editor:N}):(0,_e.jsx)(Xl,{items:T.Sidebar,brandEditor:i,label:"Blocks library",editor:N!=null?N:void 0})})})]})},...c})},"EmailLayout");var $g=require("@tiptap/react"),Yr=require("jotai"),lt=require("react");var Ud=require("react/jsx-runtime"),za=[{type:"text",content:`
|
|
191
189
|
`,text_style:"h2"},{type:"text",content:`
|
|
192
|
-
`},{type:"action",content:"Register",align:"left",href:""}],
|
|
190
|
+
`},{type:"action",content:"Register",align:"left",href:""}],Zg=s(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="inbox");if(!t)t={type:"channel",channel:"inbox",elements:za};else if(t.type==="channel"&&"elements"in t){let r=t.elements||[],o=r.find(p=>p.type==="meta"),n=r.filter(p=>p.type!=="meta"),i=n.filter(p=>p.type==="text"),a=n.filter(p=>p.type==="action"),c={type:"text",content:(o&&"title"in o&&o.title||"")+`
|
|
193
191
|
`,text_style:"h2"},u=i[0],d={type:"text",content:u&&"content"in u?u.content:`
|
|
194
|
-
`};t={...t,elements:[c,d,...a]}}return t},"getOrCreateInboxElement"),
|
|
192
|
+
`};t={...t,elements:[c,d,...a]}}return t},"getOrCreateInboxElement"),qg={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"}},Jg=s(({value:e})=>{let{editor:t}=(0,$g.useCurrentEditor)(),r=(0,Yr.useSetAtom)(He),o=(0,Yr.useAtomValue)(ee),n=(0,Yr.useAtomValue)(ae),i=(0,lt.useRef)(!1);return(0,lt.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,lt.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,lt.useEffect)(()=>{t&&(r(t),lr("inbox",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,lt.useEffect)(()=>{if(!t||!o||t.isFocused)return;let a=Zg(o),l=Ze({version:"2022-01-01",elements:[a]},{channel:"inbox"}),c=de(l),u=de(t.getJSON());JSON.stringify(c)!==JSON.stringify(u)&&setTimeout(()=>{t.isFocused||t.commands.setContent(l)},1)},[t,o]),null},"InboxEditorContent"),gb=(0,lt.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let m=(0,Yr.useAtomValue)(ae),p=(0,lt.useRef)(!0),f=(0,lt.useRef)(!1),v=(0,Yr.useSetAtom)(ye),[h,b]=(0,Yr.useAtom)(ee),y=(0,Yr.useSetAtom)(je),N=(0,Yr.useAtomValue)(Ct);(0,lt.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=(0,lt.useMemo)(()=>[...or({setSelectedNode:v})].filter(T=>T!==void 0),[v]),P=(0,lt.useCallback)(({editor:T})=>{if(!T||N)return;if(!h){let k=de(T.getJSON()),L=Or(null,"inbox","",k),S={version:"2022-01-01",elements:[{type:"channel",channel:"inbox",elements:L.elements,...L.raw&&{raw:L.raw}}]};b(S),y(S);return}let R=T.getJSON(),E=de(R),C=Or(h,"inbox","",E),x=ut(h,{elements:C.elements,channel:"inbox",...C.raw&&{raw:C.raw}}),w=JSON.stringify(h.elements),A=JSON.stringify(x.elements);w!==A&&setTimeout(()=>{f.current&&(b(x),y(x))},100)},[h,b,y,N]),M=(0,lt.useMemo)(()=>{let T=Zg(l);return Ze({version:"2022-01-01",elements:[T]},{channel:"inbox"})},[l]);return(0,Ud.jsx)(Xt,{theme:e,colorScheme:c,isLoading:!!(m&&p.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Ud.jsx)(Mr,{hidePublish:t,channels:o,routing:n}),...u,ref:d,children:a==null?void 0:a({content:M,extensions:g,editable:!r,autofocus:!r,onUpdate:P})})}),ec=(0,lt.memo)(gb);var jg=require("@tiptap/react");var gt=require("react/jsx-runtime"),tc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>e?(0,gt.jsxs)("div",{className:"courier-py-2 courier-border courier-w-[360px] courier-h-[500px] courier-rounded-3xl courier-bg-background",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,gt.jsxs)("div",{className:"courier-my-3 courier-mx-4 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,gt.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-3",children:[(0,gt.jsx)(Xi,{}),(0,gt.jsx)("span",{className:"courier-text-xl courier-font-medium",children:"In-app"})]}),(0,gt.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-4",children:[(0,gt.jsx)(pu,{}),(0,gt.jsx)(Ki,{}),(0,gt.jsx)(Tu,{})]})]}),(0,gt.jsx)(jg.EditorProvider,{content:e,extensions:t,...i?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},editorContainerProps:{className:I("courier-inbox-editor")},immediatelyRender:!1,children:i?(0,gt.jsx)(Ar,{value:e,defaultValue:za}):(0,gt.jsxs)(gt.Fragment,{children:[(0,gt.jsx)(Jg,{value:e}),(0,gt.jsx)(ar,{config:qg})]})})]}):null,"InboxEditor");var Gg=require("jotai"),po=require("react");function rc(e,t,r=500){let o=(0,Gg.useSetAtom)(pn),n=(0,po.useRef)(),i=(0,po.useRef)(void 0),a=(0,po.useRef)(t);(0,po.useEffect)(()=>{a.current=t},[t]);let l=(0,po.useCallback)(()=>{n.current&&(clearTimeout(n.current),n.current=void 0),i.current!==void 0&&(a.current(i.current),i.current=void 0)},[]);return(0,po.useEffect)(()=>(o({action:"register",id:e,fn:l}),()=>{l(),o({action:"unregister",id:e}),n.current&&clearTimeout(n.current)}),[e,o,l]),(0,po.useCallback)(u=>{i.current=u,n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{l()},r)},[r,l])}s(rc,"useDebouncedFlush");var Kg=require("@hookform/resolvers/zod"),Ni=require("jotai"),$t=require("react"),Yg=require("react-hook-form"),sn=require("zod");var Ne=require("react/jsx-runtime"),hb=sn.z.object({enableButton:sn.z.boolean().default(!0),buttonLabel:sn.z.string().default("Try now"),buttonUrl:sn.z.string().default(""),enableSecondaryButton:sn.z.boolean().default(!1),secondaryButtonLabel:sn.z.string().default("Learn more"),secondaryButtonUrl:sn.z.string().default("")}),bb=s(()=>{let e=(0,Ni.useAtomValue)(He),[t,r]=(0,Ni.useAtom)(ee),o=(0,Ni.useSetAtom)(je),n=(0,$t.useRef)(!1),i=(0,$t.useRef)(null),a=(0,$t.useRef)(t);(0,$t.useEffect)(()=>{a.current=t},[t]);let l=(0,Yg.useForm)({resolver:(0,Kg.zodResolver)(hb),defaultValues:{enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""},mode:"onChange"});(0,$t.useEffect)(()=>{if(!e)return;let f=s(()=>{let{doc:v}=e.state,h=null,b=[];if(v.descendants(y=>y.type.name==="buttonRow"&&!h?(h=y.attrs,!1):(y.type.name==="button"&&b.length<2&&b.push(y.attrs),!0)),n.current=!0,h){let{button1Label:y,button1Link:N,button2Label:g,button2Link:P}=h,M=l.getValues();M.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),M.buttonLabel!==(y||"Try now")&&l.setValue("buttonLabel",y||"Try now",{shouldDirty:!1}),M.buttonUrl!==(N||"")&&l.setValue("buttonUrl",N||"",{shouldDirty:!1}),M.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),M.secondaryButtonLabel!==(g||"Learn more")&&l.setValue("secondaryButtonLabel",g||"Learn more",{shouldDirty:!1}),M.secondaryButtonUrl!==(P||"")&&l.setValue("secondaryButtonUrl",P||"",{shouldDirty:!1})}else if(b.length>0){let y=b[0],N=l.getValues();if(N.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),N.buttonLabel!==(y.label||"Try now")&&l.setValue("buttonLabel",y.label||"Try now",{shouldDirty:!1}),N.buttonUrl!==(y.link||"")&&l.setValue("buttonUrl",y.link||"",{shouldDirty:!1}),b.length>1){let g=b[1];N.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),N.secondaryButtonLabel!==(g.label||"Learn more")&&l.setValue("secondaryButtonLabel",g.label||"Learn more",{shouldDirty:!1}),N.secondaryButtonUrl!==(g.link||"")&&l.setValue("secondaryButtonUrl",g.link||"",{shouldDirty:!1})}else N.enableSecondaryButton&&l.setValue("enableSecondaryButton",!1,{shouldDirty:!1})}else l.reset({enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""});i.current=l.getValues(),setTimeout(()=>{n.current=!1},0)},"syncFromEditor");return f(),e.on("update",f),()=>{e.off("update",f)}},[e,l]),(0,$t.useEffect)(()=>{if(e||!t||n.current)return;n.current=!0;let f=t.elements.find(h=>h.type==="channel"&&h.channel==="inbox");if(!f||!f.elements){n.current=!1;return}let v=f.elements.filter(h=>h.type==="action");if(v.length>0){let h=v[0],b=v[1];l.setValue("enableButton",!0),l.setValue("buttonLabel",h.content||"Register"),l.setValue("buttonUrl",h.href||""),b?(l.setValue("enableSecondaryButton",!0),l.setValue("secondaryButtonLabel",b.content||"Learn more"),l.setValue("secondaryButtonUrl",b.href||"")):l.setValue("enableSecondaryButton",!1)}else l.setValue("enableButton",!1),l.setValue("enableSecondaryButton",!1);i.current=l.getValues(),n.current=!1},[t,l,e]);let c=(0,$t.useCallback)(f=>{let v=a.current;if(!v||n.current)return;let h=v.elements.find(T=>T.type==="channel"&&T.channel==="inbox");h||(h={type:"channel",channel:"inbox",elements:[{type:"text",content:`
|
|
195
193
|
`,text_style:"h2"},{type:"text",content:`
|
|
196
|
-
`}]}),
|
|
197
|
-
`,text_style:"h2"}:
|
|
198
|
-
`}],
|
|
199
|
-
`,text_style:"h2"}:
|
|
200
|
-
`}],u5=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:$a}),t},"getOrCreateSlackElement"),d5=s(({value:e})=>{let{editor:t}=(0,c5.useCurrentEditor)(),r=(0,dr.useSetAtom)(Be),o=(0,dr.useAtomValue)(te),n=(0,dr.useAtomValue)(ae),i=(0,dr.useAtomValue)(Ce),a=(0,Pe.useRef)(!1),l=(0,Pe.useRef)(!1);return(0,Pe.useEffect)(()=>{n&&(a.current=!1)},[n]),(0,Pe.useEffect)(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Pe.useEffect)(()=>{t&&(r(t),ur("slack",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Pe.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Pe.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,Pe.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=u5(o),u=qe({version:"2022-01-01",elements:[c]},{channel:"slack"}),d=ue(u),p=ue(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"SlackEditorContent"),m5={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"},conditionalRules:[{id:"slack-blockquote-bold-italic-mutex-1",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["italic"]},action:{type:"toggle_off",targets:["italic"]}},{id:"slack-blockquote-bold-italic-mutex-2",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["bold"]},action:{type:"toggle_off",targets:["bold"]}}]},vb=(0,Pe.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:a,render:l,value:c,colorScheme:u,...d},p)=>{let f=(0,dr.useAtomValue)(ae),C=(0,dr.useAtomValue)(Ct),y=(0,dr.useAtomValue)(Be),h=(0,dr.useAtomValue)(Gt),[b,N]=(0,dr.useAtom)(Ce),[g,w]=(0,dr.useAtom)(te),M=(0,dr.useSetAtom)(je),k=(0,Pe.useRef)(!0),D=(0,Pe.useRef)(!1),T=(0,Pe.useRef)(h),x=(0,Pe.useRef)(null),[E,v]=(0,Pe.useState)({Sidebar:["text","divider","button"],Editor:[]});Pi({items:E,setItems:v});let{syncEditorItems:P}=Ol({setItems:v,rafId:x});(0,Pe.useEffect)(()=>(D.current=!0,()=>{D.current=!1}),[]),(0,Pe.useEffect)(()=>{T.current=h},[h]),(0,Pe.useEffect)(()=>{f===!1&&g&&setTimeout(()=>{y&&!y.isDestroyed&&P(y)},300)},[f,g,y,P]);let S=(0,Pe.useCallback)(()=>!T.current,[]),I=(0,Pe.useMemo)(()=>[...ir({variables:r,setSelectedNode:N,shouldHandleClick:S,disableVariableAutocomplete:!0})].filter(R=>R!==void 0),[r,N,S,!0]),A=(0,Pe.useCallback)(({editor:R})=>{if(!R||C)return;if(!g){let re={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:ue(R.getJSON())}]};w(re),M(re);return}let B=R.getJSON(),_=ue(B),V=ut(g,{elements:_,channel:"slack"}),W=JSON.stringify(g.elements),O=JSON.stringify(V.elements);W!==O&&(w(V),M(V))},[g,w,M,C]),H=(0,Pe.useMemo)(()=>{let R=u5(c);return qe({version:"2022-01-01",elements:[R]},{channel:"slack"})},[c]);return(0,Ii.jsx)(er,{theme:e,colorScheme:u,isLoading:!!(f&&k.current),Header:a?a({hidePublish:t,channels:n,routing:i}):(0,Ii.jsx)(Ar,{hidePublish:t,channels:n,routing:i}),ref:p,...d,children:(0,Ii.jsx)(Ii.Fragment,{children:l==null?void 0:l({content:H,extensions:I,editable:!o,autofocus:!o,onUpdate:A,items:E,selectedNode:b,slackEditor:y})})})}),lc=(0,Pe.memo)(vb);var g5=require("@tiptap/react");var Ue=require("react/jsx-runtime"),xb=s(()=>(0,Ue.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-col courier-w-full",children:[(0,Ue.jsx)("div",{className:"courier-w-3/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),(0,Ue.jsx)("div",{className:"courier-w-full courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),(0,Ue.jsx)("div",{className:"courier-w-6/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"})]}),"TextSkeleton"),Tb=s(()=>(0,Ue.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-lg",children:(0,Ue.jsx)(la,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),p5=s(()=>(0,Ue.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row",children:[(0,Ue.jsx)(Tb,{}),(0,Ue.jsx)(xb,{})]}),"InteractionSkeleton"),f5=s(({children:e,className:t})=>(0,Ue.jsxs)("div",{className:L("courier-w-full courier-max-w-[800px] courier-bg-white dark:courier-bg-[#171717] courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Ue.jsx)(p5,{}),(0,Ue.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Ue.jsx)("div",{className:"courier-flex-shrink-0",children:(0,Ue.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,Ue.jsx)(sa,{color:"#FFFFFF"})})}),(0,Ue.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Ue.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mb-1",children:[(0,Ue.jsx)("span",{className:"courier-font-semibold courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1]",children:"Circle"}),(0,Ue.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 dark:courier-bg-[#2E333F] courier-text-gray-700 dark:courier-text-[#C9C8E1]",children:"APP"}),(0,Ue.jsx)("span",{className:"courier-text-xs courier-text-gray-500 dark:courier-text-[#8786A9]",children:"Now"})]}),(0,Ue.jsx)("div",{className:"courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-pr-4",children:e})]})]}),(0,Ue.jsx)(p5,{})]}),"SlackFrame");var cc=require("react");var to=require("react/jsx-runtime"),uc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let a=(0,cc.useRef)(null);return(0,cc.useEffect)(()=>{let l=a.current;if(!(!l||i))return yr({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,to.jsx)(f5,{children:(0,to.jsx)("div",{ref:a,children:(0,to.jsx)(g5.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:L("courier-slack-editor")},immediatelyRender:!1,children:i?(0,to.jsx)(Ir,{value:e,defaultValue:$a}):(0,to.jsxs)(to.Fragment,{children:[(0,to.jsx)(d5,{value:e}),(0,to.jsx)(lr,{config:m5})]})})})}):null},"SlackEditor");var v5=require("jotai");var h5=require("lucide-react");var Dt=require("react/jsx-runtime"),dc=s(({items:e,label:t,editor:r})=>(0,Dt.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,Dt.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,Dt.jsxs)(Dt.Fragment,{children:[(0,Dt.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),(0,Dt.jsx)(le,{className:"courier-my-4"})]}),(0,Dt.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,Dt.jsx)(Ai,{id:o.toString(),editor:r,children:(0,Dt.jsxs)("div",{className:L("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Dt.jsx)(h5.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),o==="text"&&(0,Dt.jsx)(Ko,{draggable:!0}),o==="divider"&&(0,Dt.jsx)(jo,{draggable:!0}),o==="button"&&(0,Dt.jsx)(Jo,{draggable:!0})]})},o))})]})}),"SlackSideBar");var b5=require("@hookform/resolvers/zod"),y5=require("react-hook-form");var ro=require("react/jsx-runtime"),C5=s(({element:e,editor:t})=>{var a,l;let r=(0,y5.useForm)({resolver:(0,b5.zodResolver)(Bs),defaultValues:{...Ke,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=xt({editor:t,element:e,form:r,nodeType:"button"}),n=((l=(a=t==null?void 0:t.extensionManager.extensions.find(c=>c.name==="variableSuggestion"))==null?void 0:a.options)==null?void 0:l.variables)||{},i=Tt(n);return e?(0,ro.jsxs)(Je,{...r,children:[(0,ro.jsx)(Ht,{type:"button"}),(0,ro.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,ro.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,ro.jsx)(j,{control:r.control,name:"link",render:({field:c})=>(0,ro.jsxs)(q,{children:[(0,ro.jsx)(J,{children:(0,ro.jsx)(Jr,{value:c.value,variables:i,disableVariableAutocomplete:!0,onChange:u=>{c.onChange(u),o({...r.getValues(),link:u})}})}),(0,ro.jsx)(K,{})]})})]})]}):null},"SlackButtonForm");var _d=require("react/jsx-runtime"),mc=s(({element:e,editor:t,defaultElement:r})=>e&&e.type.name==="button"?(0,_d.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:(0,_d.jsx)(C5,{element:e,editor:t},e.attrs.id)}):r,"SlackSideBarItemDetails");var Ud=require("react");var mr=require("react/jsx-runtime"),Eb=(0,Ud.forwardRef)(({children:e,className:t,...r},o)=>(0,mr.jsx)("div",{className:L("courier-editor-container courier-relative",t),...r,ref:o,children:e})),wb=(0,Ud.forwardRef)(({children:e,...t},r)=>(0,mr.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),x5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i})=>{let a=(0,v5.useAtomValue)(te);return(0,mr.jsx)(lc,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:l=>{var c;return(0,mr.jsxs)(sn,{children:[(0,mr.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,mr.jsx)(Eb,{children:(0,mr.jsx)(wb,{children:(0,mr.jsx)(uc,{...l})})})}),(0,mr.jsx)(ln,{children:(0,mr.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,mr.jsx)(mc,{element:l.selectedNode,editor:l.slackEditor,defaultElement:(0,mr.jsx)(dc,{items:l.items.Sidebar,label:"Blocks library",editor:(c=l.slackEditor)!=null?c:void 0})})})})]})}})},"SlackLayout");var T5=require("@tiptap/react"),oo=require("jotai"),Ve=require("react"),E5=require("sms-segments-calculator");var pc=require("react/jsx-runtime"),Lo=[{type:"text",content:`
|
|
201
|
-
`}],
|
|
202
|
-
`}],I5=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:Za}),t},"getOrCreateMSTeamsElement"),L5=s(({value:e})=>{let{editor:t}=(0,S5.useCurrentEditor)(),r=(0,pr.useSetAtom)(Be),o=(0,pr.useAtomValue)(te),n=(0,pr.useAtomValue)(ae),i=(0,pr.useAtomValue)(Ce),a=(0,ve.useRef)(!1),l=(0,ve.useRef)(!1);return(0,ve.useEffect)(()=>{n&&(a.current=!1)},[n]),(0,ve.useEffect)(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),(0,ve.useEffect)(()=>{t&&(r(t),ur("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,ve.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,ve.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,ve.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=I5(o),u=qe({version:"2022-01-01",elements:[c]},{channel:"msteams"}),d=ue(u),p=ue(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"MSTeamsEditorContent"),R5={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"},conditionalRules:[{id:"msteams-blockquote-bold-italic-mutex-1",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["italic"]},action:{type:"toggle_off",targets:["italic"]}},{id:"msteams-blockquote-bold-italic-mutex-2",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["bold"]},action:{type:"toggle_off",targets:["bold"]}}]},kb=(0,ve.forwardRef)(({theme:e,hidePublish:t,variables:r,readOnly:o,channels:n,routing:i,headerRenderer:a,render:l,value:c,colorScheme:u,...d},p)=>{let f=(0,pr.useAtomValue)(ae),C=(0,pr.useAtomValue)(Ct),y=(0,pr.useAtomValue)(Be),h=(0,pr.useAtomValue)(Gt),[b,N]=(0,pr.useAtom)(Ce),[g,w]=(0,pr.useAtom)(te),M=(0,pr.useSetAtom)(je),k=(0,ve.useRef)(!0),D=(0,ve.useRef)(!1),T=(0,ve.useRef)(h),[x,E]=(0,ve.useState)({Sidebar:["text","divider"],Editor:[]}),v=(0,ve.useRef)(null);Pi({items:x,setItems:E});let P=(0,ve.useCallback)(R=>{v.current&&cancelAnimationFrame(v.current),setTimeout(()=>{v.current=requestAnimationFrame(()=>{try{let B=R==null?void 0:R.view.dom;if(!B){console.warn("syncEditorItems: Editor DOM element not found");return}let _=B.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),V=[];_.forEach(W=>{let O=W.dataset.id;O&&V.push(O)}),E(W=>({Editor:V,Sidebar:W.Sidebar}))}catch(B){console.error("Error syncing editor items:",B),E(_=>({..._}))}})},50)},[]);(0,ve.useEffect)(()=>(D.current=!0,()=>{D.current=!1}),[]),(0,ve.useEffect)(()=>{T.current=h},[h]),(0,ve.useEffect)(()=>{let R=s(()=>{y&&P(y)},"updateItems");y==null||y.on("update",R),y==null||y.on("selectionUpdate",R),y==null||y.on("create",R),y==null||y.on("transaction",R),y&&!y.isDestroyed&&R();let B=s(_=>{R()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",B),()=>{y==null||y.off("update",R),y==null||y.off("selectionUpdate",R),y==null||y.off("create",R),y==null||y.off("transaction",R),document.removeEventListener("node-duplicated",B),v.current&&cancelAnimationFrame(v.current)}},[y,P]),(0,ve.useEffect)(()=>{f===!1&&g&&setTimeout(()=>{y&&!y.isDestroyed&&P(y)},300)},[f,g,y,P]);let S=(0,ve.useCallback)(()=>!T.current,[]),I=(0,ve.useMemo)(()=>[...ir({variables:r,setSelectedNode:N,shouldHandleClick:S,disableVariableAutocomplete:!0})].filter(R=>R!==void 0),[r,N,S,!0]),A=(0,ve.useCallback)(({editor:R})=>{if(!R||C)return;if(!g){let re={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:ue(R.getJSON())}]};w(re),M(re);return}let B=R.getJSON(),_=ue(B),V=ut(g,{elements:_,channel:"msteams"}),W=JSON.stringify(g.elements),O=JSON.stringify(V.elements);W!==O&&(w(V),M(V))},[g,w,M,C]),H=(0,ve.useMemo)(()=>{let R=I5(c);return qe({version:"2022-01-01",elements:[R]},{channel:"msteams"})},[c]);return(0,Li.jsx)(er,{theme:e,colorScheme:u,isLoading:!!(f&&k.current),Header:a?a({hidePublish:t,channels:n,routing:i}):(0,Li.jsx)(Ar,{hidePublish:t,channels:n,routing:i}),ref:p,...d,children:(0,Li.jsx)(Li.Fragment,{children:l==null?void 0:l({content:H,extensions:I,editable:!o,autofocus:!o,onUpdate:A,items:x,selectedNode:b,msteamsEditor:y})})})}),bc=(0,ve.memo)(kb);var D5=require("@tiptap/react");var Ze=require("react/jsx-runtime"),Nb=s(()=>(0,Ze.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-full",children:(0,Ze.jsx)(la,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),Mb=s(()=>(0,Ze.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[(0,Ze.jsx)(Nb,{}),(0,Ze.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[(0,Ze.jsx)("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"}),(0,Ze.jsx)("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),Ab=s(()=>(0,Ze.jsx)("div",{className:"courier-flex courier-justify-end courier-w-full",children:(0,Ze.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:(0,Ze.jsx)("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),H5=s(({children:e,className:t})=>(0,Ze.jsxs)("div",{className:L("courier-w-full courier-max-w-[800px] courier-bg-white dark:courier-bg-[#171717] courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Ze.jsx)(Mb,{}),(0,Ze.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Ze.jsx)("div",{className:"courier-flex-shrink-0 courier-mt-6",children:(0,Ze.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,Ze.jsx)(sa,{color:"#FFFFFF"})})}),(0,Ze.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Ze.jsx)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:(0,Ze.jsx)("span",{className:"courier-text-sm courier-text-[#A3A3A3] dark:courier-text-[#8786A9]",children:"Circle"})}),(0,Ze.jsx)("div",{className:"courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px] courier-px-3 courier-py-2 courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-max-w-full courier-pr-5",children:e})]})]}),(0,Ze.jsx)(Ab,{})]}),"MSTeamsFrame");var yc=require("react");var io=require("react/jsx-runtime"),Cc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let a=(0,yc.useRef)(null);return(0,yc.useEffect)(()=>{let l=a.current;if(!(!l||i))return yr({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,io.jsx)(H5,{children:(0,io.jsx)("div",{ref:a,children:(0,io.jsx)(D5.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:L("courier-msteams-editor")},immediatelyRender:!1,children:i?(0,io.jsx)(Ir,{value:e,defaultValue:Za}):(0,io.jsxs)(io.Fragment,{children:[(0,io.jsx)(L5,{value:e}),(0,io.jsx)(lr,{config:R5})]})})})}):null},"MSTeamsEditor");var F5=require("jotai");var B5=require("lucide-react");var Bt=require("react/jsx-runtime"),vc=s(({items:e,label:t,editor:r})=>(0,Bt.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,Bt.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,Bt.jsxs)(Bt.Fragment,{children:[(0,Bt.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),(0,Bt.jsx)(le,{className:"courier-my-4"})]}),(0,Bt.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,Bt.jsx)(Ai,{id:o.toString(),editor:r,children:(0,Bt.jsxs)("div",{className:L("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Bt.jsx)(B5.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),o==="text"&&(0,Bt.jsx)(Ko,{draggable:!0}),o==="divider"&&(0,Bt.jsx)(jo,{draggable:!0}),o==="button"&&(0,Bt.jsx)(Jo,{draggable:!0})]})},o))})]})}),"MSTeamsSideBar");var zd=require("react");var Er=require("react/jsx-runtime"),Sb=(0,zd.forwardRef)(({children:e,className:t,...r},o)=>(0,Er.jsx)("div",{className:L("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Ib=(0,zd.forwardRef)(({children:e,...t},r)=>(0,Er.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),V5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i})=>{let a=(0,F5.useAtomValue)(te);return(0,Er.jsx)(bc,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:l=>{var c;return(0,Er.jsxs)(sn,{children:[(0,Er.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Er.jsx)(Sb,{children:(0,Er.jsx)(Ib,{children:(0,Er.jsx)(Cc,{...l})})})}),(0,Er.jsx)(ln,{children:(0,Er.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,Er.jsx)(vc,{items:l.items.Sidebar,label:"Blocks library",editor:(c=l.msteamsEditor)!=null?c:void 0})})})]})}})},"MSTeamsLayout");var O5={sms:{elements:Lo},push:{elements:_n},inbox:{elements:za},slack:{elements:$a},email:{elements:Va},msteams:{elements:Za}},W5=s(e=>{var t;return(t=O5[e])!=null?t:O5.email},"getChannelDefaults"),Lb=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"),xc=s(({channels:e=["email"],routing:t})=>{let[r,o]=(0,fr.useState)([]),n=(0,Ro.useAtomValue)(te),i=(0,Ro.useSetAtom)(te),a=(0,Ro.useSetAtom)(je),[l,c]=(0,Ro.useAtom)(Uo),u=(0,Ro.useSetAtom)(Ce),d=(0,Ro.useAtomValue)(ae),p=Lb(t,e),m=(0,fr.useRef)(p);m.current=p,(0,fr.useEffect)(()=>{if(d||n!=null&&n.elements)return;let N=m.current.map(g=>_o.find(w=>w.value===g)).filter(g=>!!g);o(N),N.length>0&&!l&&c(N[0].value)},[n,d,c,l]),(0,fr.useEffect)(()=>{if(d||!(n!=null&&n.elements))return;let b=m.current,N=n.elements.filter(w=>w.type==="channel").map(w=>w.channel).filter(w=>b.includes(w)),g=b.filter(w=>N.includes(w)).map(w=>_o.find(M=>M.value===w)).filter(w=>!!w);o(g)},[n,d]),(0,fr.useEffect)(()=>{var g;if(d||r.length===0)return;let b=r.some(w=>w.value===l),N=(g=n==null?void 0:n.elements)==null?void 0:g.some(w=>w.type==="channel"&&w.channel===l);!b&&!N&&c(r[0].value)},[r,l,c,d,n]);let f=(0,fr.useMemo)(()=>(p==null?void 0:p.filter(b=>!r.some(N=>N.value===b)).map(b=>_o.find(N=>N.value===b)).filter(b=>!!b))||[],[r,p]),C=(0,fr.useCallback)(b=>{let N=[],g,{elements:w,raw:M}=W5(b);if(N=w,g=M,!n){let T=[];for(let v of r){let{elements:P,raw:S}=W5(v.value),I={type:"channel",channel:v.value,elements:P};S&&(I.raw=S),T.push(I)}let x={type:"channel",channel:b,elements:N};g&&(x.raw=g),T.push(x);let E={version:"2022-01-01",elements:T};i(E),a(E),c(b);return}let D=ut(n,{elements:N,channel:g?{channel:b,raw:g}:b});i(D),a(D),c(b)},[n,i,a,c,r]),y=(0,fr.useCallback)(b=>{if(!n)return;let N=n.elements.filter(M=>M.type==="channel"?M.channel!==b:!0),g={...n,elements:N};i(g),a(g),u(null);let w=r.filter(M=>M.value!==b);l===b&&w.length>0&&c(w[0].value)},[n,i,a,r,l,c,u]),h=(0,fr.useMemo)(()=>[...r,...f],[r,f]);return{enabledChannels:r,disabledChannels:f,channel:l,channelOptions:h,setChannel:c,addChannel:C,removeChannel:y}},"useChannels");var xe=require("react/jsx-runtime"),Ar=s(({hidePublish:e=!1,channels:t,routing:r})=>{let o=(0,bo.useRef)(null),n=(0,Ho.useAtomValue)(bt),i=(0,Ho.useAtomValue)(ae),a=(0,Ho.useAtomValue)(ee),{publishTemplate:l,isTemplatePublishing:c}=Kn(),[u,d]=(0,Ho.useAtom)(Zn),p=(0,Ho.useSetAtom)(so),m=(0,Ho.useAtomValue)(so),{enabledChannels:f,disabledChannels:C,channel:y,setChannel:h,addChannel:b,removeChannel:N}=xc({channels:t,routing:r});(0,bo.useEffect)(()=>{n===!0&&d(null)},[n,d]);let g=(0,bo.useCallback)(()=>{m&&p(!1),l()},[l,m,p]),w=(0,bo.useCallback)(T=>{m&&p(!1),h(T)},[m,p,h]),M=(0,bo.useCallback)(T=>{m&&p(!1),b(T)},[m,p,b]),k=(0,bo.useCallback)(T=>{m&&p(!1),N(T)},[m,p,N]),D=(0,bo.useCallback)(()=>{m&&p(!1)},[m,p]);return(0,xe.jsxs)("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:D,children:[(0,xe.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[(0,xe.jsx)(ls,{value:y,onValueChange:w,className:"courier-h-full",ref:o,children:(0,xe.jsx)(Gi,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${_o.length}, fit-content(100%))`},children:f.map(T=>(0,xe.jsxs)(oi,{value:T.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:[T.label,T.value===y&&f.length>1&&(0,xe.jsxs)(Im,{children:[(0,xe.jsx)(Lm,{asChild:!0,children:(0,xe.jsx)("div",{className:"courier-pl-2",children:(0,xe.jsx)(Yi,{color:"#A3A3A3"})})}),(0,xe.jsxs)(Oc,{ref:o,children:[(0,xe.jsx)(Wc,{children:(0,xe.jsx)(_5.AlertDialogDescription,{children:"Are you sure you want to delete this channel?"})}),(0,xe.jsxs)(_c,{children:[(0,xe.jsx)(zc,{asChild:!0,children:(0,xe.jsx)(Ie,{buttonSize:"small",variant:"outline",children:"Cancel"})}),(0,xe.jsx)(Uc,{asChild:!0,children:(0,xe.jsx)(Ie,{buttonSize:"small",variant:"primary",onClick:()=>k(T.value),children:"Delete"})})]})]})]})]},T.value))})}),C.length>0&&(0,xe.jsxs)(xe.Fragment,{children:[(0,xe.jsx)(jc,{orientation:"vertical",className:"!courier-h-5"}),(0,xe.jsxs)(os,{children:[(0,xe.jsx)(ns,{asChild:!0,children:(0,xe.jsx)(Ie,{variant:"link",children:"+ Add channel"})}),(0,xe.jsx)(qi,{portalProps:{container:o.current},children:C.map(T=>(0,xe.jsxs)(Ji,{onClick:()=>M(T.value),children:[T.icon,T.label]},T.value))})]})]})]}),(0,xe.jsxs)("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&(0,xe.jsx)(li,{isLoading:!!i,isSaving:!!n,isError:!!a}),!e&&i!==null&&(0,xe.jsx)(Ie,{variant:"primary",buttonSize:"small",disabled:c===!0||n===!0||u!==null,onClick:g,children:c?"Publishing...":"Publish changes"})]})]})},"Channels");var St=require("react");function Ri({onSave:e,debounceMs:t=2e3,enabled:r=!0,onError:o,initialContent:n,flushBeforeSave:i}){let[a,l]=(0,St.useState)(!1),c=(0,St.useRef)(!1),u=(0,St.useRef)(null),d=(0,St.useRef)(),p=(0,St.useRef)(0),m=(0,St.useRef)();(0,St.useEffect)(()=>{n&&(d.current=JSON.stringify(n))},[n]);let f=(0,St.useCallback)(async()=>{if(c.current)return;if(i)try{i()}catch(g){console.error("[AutoSave] Error flushing updates:",g)}let N=u.current;if(u.current=null,!!N)try{let g=JSON.stringify(N);if(g===d.current)return;c.current=!0,l(!0),d.current=g,p.current=Date.now(),await e(N)}catch(g){console.error("[AutoSave] Save failed:",g),o==null||o(g)}finally{if(c.current=!1,l(!1),u.current){let g=t;m.current=setTimeout(()=>{m.current=void 0,f()},g)}}},[t,o,e,i]),C=(0,St.useRef)(r),y=(0,St.useRef)(t),h=(0,St.useRef)(f);return(0,St.useEffect)(()=>{C.current=r,y.current=t,h.current=f}),{handleAutoSave:(0,St.useCallback)(async N=>{if(!C.current)return;let g=JSON.stringify(N);if(u.current=N,g===d.current||c.current)return;m.current&&(clearTimeout(m.current),m.current=void 0);let w=y.current;m.current=setTimeout(()=>{m.current=void 0,h.current()},w)},[]),isSaving:a}}s(Ri,"useAutoSave");var nt=require("jotai"),Le=require("react");var yo=require("jotai"),It=require("react");var jt=require("zod"),U5=jt.z.object({headerStyle:jt.z.enum(["plain","border"]),isUnsubscribe:jt.z.boolean().optional(),isPreferences:jt.z.boolean().optional(),link:jt.z.string().optional(),brandColor:jt.z.string(),textColor:jt.z.string(),subtleColor:jt.z.string(),logo:jt.z.string().optional(),facebookLink:jt.z.string().optional(),linkedinLink:jt.z.string().optional(),instagramLink:jt.z.string().optional(),mediumLink:jt.z.string().optional(),xLink:jt.z.string().optional()}),Kt={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};var Rb=s(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),qa=s(e=>{var t,r,o,n,i,a,l,c,u,d,p,m,f,C;switch(e.type){case"variable":return`{{${(t=e.attrs)==null?void 0:t.id}}}`;case"text":{let y=e.text||"";if((r=e.marks)!=null&&r.length){let b=e.marks.map(Rb).filter(Boolean);y=b.join("")+y+b.reverse().join("")}let h=(o=e.marks)==null?void 0:o.find(b=>b.type==="link");return h&&(y=`[${y}](${(n=h.attrs)==null?void 0:n.href})`),y}case"hardBreak":return`
|
|
194
|
+
`}]}),h.elements||(h.elements=[]);let y=[...h.elements.filter(T=>T.type!=="action")];if(f.enableButton){let T={type:"action",content:f.buttonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.buttonUrl};y.push(T)}if(f.enableSecondaryButton){let T={type:"action",content:f.secondaryButtonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.secondaryButtonUrl};y.push(T)}let N={...h,elements:y},g=v.elements.findIndex(T=>T.type==="channel"&&T.channel==="inbox"),P=[...v.elements];g!==-1?P[g]=N:P.push(N);let M={...v,elements:P};r(M),o(M)},[r,o]),u=(0,$t.useCallback)(f=>{if(!e)return!1;let{doc:v}=e.state,h=null,b=[];v.descendants((N,g)=>N.type.name==="buttonRow"&&h===null?(h=g,!1):(N.type.name==="button"&&b.push({pos:g,attrs:N.attrs}),!0));let y=s((N,g)=>{let P=v.nodeAt(N);return P?(e.commands.command(({tr:M})=>(M.setNodeMarkup(N,P.type,g),!0)),!0):!1},"applyAttrs");if(h!==null){let N=v.nodeAt(h);if(!N)return!1;let g={...N.attrs,button1Label:f.buttonLabel,button1Link:f.buttonUrl,button2Label:f.secondaryButtonLabel,button2Link:f.secondaryButtonUrl};return y(h,g)}if(b.length>0){let[N,g]=b,P={...N.attrs,label:f.buttonLabel,link:f.buttonUrl},M=y(N.pos,P),T=!0;if(g){let R={...g.attrs,label:f.secondaryButtonLabel,link:f.secondaryButtonUrl};T=y(g.pos,R)}return M&&T}return!1},[e]),d=(0,$t.useCallback)(f=>{if(n.current)return;let v=i.current;if(i.current=f,!v||v.enableButton!==f.enableButton||v.enableSecondaryButton!==f.enableSecondaryButton){c(f);return}u(f)||c(f)},[c,u]),m=rc("inbox-sidebar",d,500),p=(0,$t.useCallback)(()=>{let f=l.getValues();m(f)},[l,m]);return(0,Ne.jsx)(qe,{...l,children:(0,Ne.jsxs)("form",{onChange:p,children:[(0,Ne.jsx)("div",{className:"courier-pb-4",children:(0,Ne.jsx)(j,{control:l.control,name:"enableButton",render:({field:f})=>(0,Ne.jsxs)(q,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between",children:[(0,Ne.jsx)(ao,{className:"!courier-m-0",children:"Enable button"}),(0,Ne.jsx)(J,{children:(0,Ne.jsx)(Xn,{checked:f.value,onCheckedChange:f.onChange,className:"!courier-m-0"})})]})})}),l.watch("enableButton")&&(0,Ne.jsx)(j,{control:l.control,name:"buttonUrl",render:({field:f})=>(0,Ne.jsxs)(q,{className:"courier-mb-6",children:[(0,Ne.jsx)(ao,{children:"Action URL"}),(0,Ne.jsx)(J,{children:(0,Ne.jsx)(be,{placeholder:"https://example.com",...f})}),(0,Ne.jsx)(G,{})]})}),(0,Ne.jsx)(ce,{className:"courier-mb-6"}),(0,Ne.jsx)(j,{control:l.control,name:"enableSecondaryButton",render:({field:f})=>(0,Ne.jsxs)(q,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between courier-mb-4",children:[(0,Ne.jsx)(ao,{className:"!courier-m-0",children:"Enable secondary button"}),(0,Ne.jsx)(J,{children:(0,Ne.jsx)(Xn,{checked:f.value,onCheckedChange:f.onChange,className:"!courier-m-0"})})]})}),l.watch("enableSecondaryButton")&&(0,Ne.jsx)(j,{control:l.control,name:"secondaryButtonUrl",render:({field:f})=>(0,Ne.jsxs)(q,{className:"courier-mb-4",children:[(0,Ne.jsx)(ao,{children:"Action URL"}),(0,Ne.jsx)(J,{children:(0,Ne.jsx)(be,{placeholder:"https://example.com",...f})}),(0,Ne.jsx)(G,{})]})})]})})},"SideBarComponent"),oc=(0,$t.memo)(bb);var Xg=require("jotai");var Mo=require("react/jsx-runtime"),Qg=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i,...a})=>{let l=(0,Xg.useAtomValue)(ee);return(0,Mo.jsx)(ec,{value:l,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:c=>(0,Mo.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,Mo.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1 courier-py-8 courier-items-center",children:(0,Mo.jsx)(tc,{...c})}),(0,Mo.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,Mo.jsx)("div",{className:"courier-p-4 courier-h-full",children:(0,Mo.jsx)(oc,{})})})]}),...a})},"InboxLayout");var e5=require("@tiptap/react"),Xr=require("jotai"),ct=require("react");var Wd=require("react/jsx-runtime"),t5=s(({value:e})=>{let{editor:t}=(0,e5.useCurrentEditor)(),r=(0,Xr.useSetAtom)(He),o=(0,Xr.useAtomValue)(ee),n=(0,Xr.useAtomValue)(ae),i=(0,ct.useRef)(!1);return(0,ct.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,ct.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,ct.useEffect)(()=>{t&&(r(t),lr("push",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,ct.useEffect)(()=>{if(!t||!o||t.isFocused)return;let a=r5(o),l=a.type==="channel"&&"elements"in a&&a.elements||Fn;l=l.map(p=>p.type==="meta"&&"title"in p?{type:"text",content:p.title||`
|
|
195
|
+
`,text_style:"h2"}:p);let u=Ze({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:l}]}),d=de(u),m=de(t.getJSON());JSON.stringify(d)!==JSON.stringify(m)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"PushEditorContent"),Fn=[{type:"meta",title:""},{type:"text",content:`
|
|
196
|
+
`}],r5=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",elements:Fn}),t},"getOrCreatePushElement"),o5={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"}},yb=(0,ct.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let m=(0,Xr.useAtomValue)(ae),p=(0,ct.useRef)(!0),f=(0,ct.useRef)(!1),v=(0,Xr.useSetAtom)(ye),[h,b]=(0,Xr.useAtom)(ee),y=(0,Xr.useSetAtom)(je),N=(0,Xr.useAtomValue)(Ct);(0,ct.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=(0,ct.useMemo)(()=>[...or({setSelectedNode:v})].filter(T=>T!==void 0),[v]),P=(0,ct.useCallback)(({editor:T})=>{if(N)return;if(!h){let k=de(T.getJSON()),L=k[0],S="",H=k;L&&L.type==="text"&&"text_style"in L&&L.text_style==="h2"&&"content"in L&&(S=L.content.trim(),H=k.slice(1));let F={version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:Or(null,"push",S,H).elements}]};b(F),y(F);return}let R=de(T.getJSON()),E=R[0],C="",x=R;E&&E.type==="text"&&"text_style"in E&&E.text_style==="h2"&&"content"in E&&(C=E.content.trim(),x=R.slice(1));let w=Or(h,"push",C,x),A=ut(h,{channel:"push",elements:w.elements});JSON.stringify(h)!==JSON.stringify(A)&&(b(A),y(A))},[h,b,y,N]),M=(0,ct.useMemo)(()=>{if(m!==!1)return null;let T=l==null?void 0:l.elements.find(C=>C.type==="channel"&&C.channel==="push");!T&&h&&(T=r5(h));let R=(T==null?void 0:T.type)==="channel"&&"elements"in T&&T.elements||Fn;return R=R.map(C=>C.type==="meta"&&"title"in C?{type:"text",content:C.title||`
|
|
197
|
+
`,text_style:"h2"}:C),Ze({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:R}]})},[l,h,m]);return(0,Wd.jsx)(Xt,{theme:e,colorScheme:c,isLoading:!!(m&&p.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Wd.jsx)(Mr,{hidePublish:t,channels:o,routing:n}),...u,ref:d,children:a==null?void 0:a({content:M,extensions:g,editable:!r,autofocus:!r,onUpdate:P})})}),nc=(0,ct.memo)(yb);var n5=require("@tiptap/react");var Zt=require("react/jsx-runtime"),ic=s(({children:e})=>(0,Zt.jsxs)("div",{className:"courier-relative",children:[(0,Zt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-6 courier-bg-border -courier-left-[2px] courier-top-[136px]"}),(0,Zt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[178px]"}),(0,Zt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[245px]"}),(0,Zt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[78px] courier-bg-border -courier-right-[2px] courier-top-[200px]"}),(0,Zt.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,Zt.jsxs)("div",{className:"courier-my-6 courier-mx-11 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,Zt.jsx)("span",{className:"courier-text-xs courier-font-semibold",children:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),(0,Zt.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2",children:[(0,Zt.jsx)(rp,{}),(0,Zt.jsx)(np,{}),(0,Zt.jsx)(tp,{})]})]}),(0,Zt.jsx)("div",{className:"courier-flex-1 courier-overflow-auto courier-h-[calc(90%-56px)] courier-mb-6",children:e})]})]}),"IPhoneFrame");var xr=require("react/jsx-runtime"),ac=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:a=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=a?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,xr.jsxs)(ic,{children:[(0,xr.jsxs)("div",{className:I("courier-px-4 courier-py-2 courier-text-[#A3A3A3] courier-text-center courier-my-8",i),children:[(0,xr.jsx)("p",{className:"courier-text-lg courier-font-medium",children:new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}),(0,xr.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,xr.jsx)(n5.EditorProvider,{content:l,extensions:t,...c,editorContainerProps:{className:I("courier-push-editor")},"data-testid":"editor-provider",immediatelyRender:!1,children:a?(0,xr.jsx)(Ar,{value:l,defaultValue:Fn}):(0,xr.jsxs)(xr.Fragment,{children:[(0,xr.jsx)(t5,{value:l}),(0,xr.jsx)(ar,{config:o5})]})})]})},"PushEditor");var i5=require("jotai");var sc=require("react/jsx-runtime"),a5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,...i})=>{let a=(0,i5.useAtomValue)(ee);return(0,sc.jsx)(nc,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:l=>(0,sc.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,sc.jsx)(ac,{...l})}),...i})},"PushLayout");var s5=require("@tiptap/react"),cr=require("jotai"),Ee=require("react");var Mi=require("react/jsx-runtime"),$a=[{type:"text",content:`
|
|
198
|
+
`}],l5=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:$a}),t},"getOrCreateSlackElement"),c5=s(({value:e})=>{let{editor:t}=(0,s5.useCurrentEditor)(),r=(0,cr.useSetAtom)(He),o=(0,cr.useAtomValue)(ee),n=(0,cr.useAtomValue)(ae),i=(0,cr.useAtomValue)(ye),a=(0,Ee.useRef)(!1),l=(0,Ee.useRef)(!1);return(0,Ee.useEffect)(()=>{n&&(a.current=!1)},[n]),(0,Ee.useEffect)(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Ee.useEffect)(()=>{t&&(r(t),lr("slack",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ee.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Ee.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,Ee.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=l5(o),u=Ze({version:"2022-01-01",elements:[c]},{channel:"slack"}),d=de(u),m=de(t.getJSON());JSON.stringify(d)!==JSON.stringify(m)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"SlackEditorContent"),u5={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"},conditionalRules:[{id:"slack-blockquote-bold-italic-mutex-1",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["italic"]},action:{type:"toggle_off",targets:["italic"]}},{id:"slack-blockquote-bold-italic-mutex-2",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["bold"]},action:{type:"toggle_off",targets:["bold"]}}]},Cb=(0,Ee.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let m=(0,cr.useAtomValue)(ae),p=(0,cr.useAtomValue)(Ct),f=(0,cr.useAtomValue)(He),v=(0,cr.useAtomValue)(jt),[h,b]=(0,cr.useAtom)(ye),[y,N]=(0,cr.useAtom)(ee),g=(0,cr.useSetAtom)(je),P=(0,Ee.useRef)(!0),M=(0,Ee.useRef)(!1),T=(0,Ee.useRef)(v),R=(0,Ee.useRef)(null),[E,C]=(0,Ee.useState)({Sidebar:["text","divider","button"],Editor:[]});Ti({items:E,setItems:C});let{syncEditorItems:x}=Ol({setItems:C,rafId:R});(0,Ee.useEffect)(()=>(M.current=!0,()=>{M.current=!1}),[]),(0,Ee.useEffect)(()=>{T.current=v},[v]),(0,Ee.useEffect)(()=>{m===!1&&y&&setTimeout(()=>{f&&!f.isDestroyed&&x(f)},300)},[m,y,f,x]);let w=(0,Ee.useCallback)(()=>!T.current,[]),A=(0,Ee.useMemo)(()=>[...or({setSelectedNode:b,shouldHandleClick:w})].filter(S=>S!==void 0),[b,w]),k=(0,Ee.useCallback)(({editor:S})=>{if(!S||p)return;if(!y){let _={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:de(S.getJSON())}]};N(_),g(_);return}let H=S.getJSON(),V=de(H),F=ut(y,{elements:V,channel:"slack"}),O=JSON.stringify(y.elements),B=JSON.stringify(F.elements);O!==B&&(N(F),g(F))},[y,N,g,p]),L=(0,Ee.useMemo)(()=>{let S=l5(l);return Ze({version:"2022-01-01",elements:[S]},{channel:"slack"})},[l]);return(0,Mi.jsx)(Xt,{theme:e,colorScheme:c,isLoading:!!(m&&P.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Mi.jsx)(Mr,{hidePublish:t,channels:o,routing:n}),ref:d,...u,children:(0,Mi.jsx)(Mi.Fragment,{children:a==null?void 0:a({content:L,extensions:A,editable:!r,autofocus:!r,onUpdate:k,items:E,selectedNode:h,slackEditor:f})})})}),lc=(0,Ee.memo)(Cb);var p5=require("@tiptap/react");var Oe=require("react/jsx-runtime"),vb=s(()=>(0,Oe.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-col courier-w-full",children:[(0,Oe.jsx)("div",{className:"courier-w-3/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),(0,Oe.jsx)("div",{className:"courier-w-full courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),(0,Oe.jsx)("div",{className:"courier-w-6/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"})]}),"TextSkeleton"),xb=s(()=>(0,Oe.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-lg",children:(0,Oe.jsx)(ia,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),d5=s(()=>(0,Oe.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row",children:[(0,Oe.jsx)(xb,{}),(0,Oe.jsx)(vb,{})]}),"InteractionSkeleton"),m5=s(({children:e,className:t})=>(0,Oe.jsxs)("div",{className:I("courier-w-full courier-max-w-[800px] courier-bg-white dark:courier-bg-[#171717] courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Oe.jsx)(d5,{}),(0,Oe.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Oe.jsx)("div",{className:"courier-flex-shrink-0",children:(0,Oe.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,Oe.jsx)(na,{color:"#FFFFFF"})})}),(0,Oe.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Oe.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mb-1",children:[(0,Oe.jsx)("span",{className:"courier-font-semibold courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1]",children:"Circle"}),(0,Oe.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 dark:courier-bg-[#2E333F] courier-text-gray-700 dark:courier-text-[#C9C8E1]",children:"APP"}),(0,Oe.jsx)("span",{className:"courier-text-xs courier-text-gray-500 dark:courier-text-[#8786A9]",children:"Now"})]}),(0,Oe.jsx)("div",{className:"courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-pr-4",children:e})]})]}),(0,Oe.jsx)(d5,{})]}),"SlackFrame");var cc=require("react");var Qr=require("react/jsx-runtime"),uc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let a=(0,cc.useRef)(null);return(0,cc.useEffect)(()=>{let l=a.current;if(!(!l||i))return br({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,Qr.jsx)(m5,{children:(0,Qr.jsx)("div",{ref:a,children:(0,Qr.jsx)(p5.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:I("courier-slack-editor")},immediatelyRender:!1,children:i?(0,Qr.jsx)(Ar,{value:e,defaultValue:$a}):(0,Qr.jsxs)(Qr.Fragment,{children:[(0,Qr.jsx)(c5,{value:e}),(0,Qr.jsx)(ar,{config:u5})]})})})}):null},"SlackEditor");var y5=require("jotai");var f5=require("lucide-react");var Rt=require("react/jsx-runtime"),dc=s(({items:e,label:t,editor:r})=>(0,Rt.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,Rt.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,Rt.jsxs)(Rt.Fragment,{children:[(0,Rt.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),(0,Rt.jsx)(ce,{className:"courier-my-4"})]}),(0,Rt.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,Rt.jsx)(Pi,{id:o.toString(),editor:r,children:(0,Rt.jsxs)("div",{className:I("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Rt.jsx)(f5.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),o==="text"&&(0,Rt.jsx)(Jo,{draggable:!0}),o==="divider"&&(0,Rt.jsx)(qo,{draggable:!0}),o==="button"&&(0,Rt.jsx)(Zo,{draggable:!0})]})},o))})]})}),"SlackSideBar");var g5=require("@hookform/resolvers/zod"),h5=require("react-hook-form");var eo=require("react/jsx-runtime"),b5=s(({element:e,editor:t})=>{let r=(0,h5.useForm)({resolver:(0,g5.zodResolver)(Ds),defaultValues:{...Ge,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:"button"});return e?(0,eo.jsxs)(qe,{...r,children:[(0,eo.jsx)(Lt,{type:"button"}),(0,eo.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,eo.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,eo.jsx)(j,{control:r.control,name:"link",render:({field:n})=>(0,eo.jsxs)(q,{children:[(0,eo.jsx)(J,{children:(0,eo.jsx)($r,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})}})}),(0,eo.jsx)(G,{})]})})]})]}):null},"SlackButtonForm");var _d=require("react/jsx-runtime"),mc=s(({element:e,editor:t,defaultElement:r})=>e&&e.type.name==="button"?(0,_d.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:(0,_d.jsx)(b5,{element:e,editor:t},e.attrs.id)}):r,"SlackSideBarItemDetails");var zd=require("react");var ur=require("react/jsx-runtime"),Tb=(0,zd.forwardRef)(({children:e,className:t,...r},o)=>(0,ur.jsx)("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Eb=(0,zd.forwardRef)(({children:e,...t},r)=>(0,ur.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),C5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i})=>{let a=(0,y5.useAtomValue)(ee);return(0,ur.jsx)(lc,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:l=>{var c;return(0,ur.jsxs)(nn,{children:[(0,ur.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,ur.jsx)(Tb,{children:(0,ur.jsx)(Eb,{children:(0,ur.jsx)(uc,{...l})})})}),(0,ur.jsx)(an,{children:(0,ur.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,ur.jsx)(mc,{element:l.selectedNode,editor:l.slackEditor,defaultElement:(0,ur.jsx)(dc,{items:l.items.Sidebar,label:"Blocks library",editor:(c=l.slackEditor)!=null?c:void 0})})})})]})}})},"SlackLayout");var v5=require("@tiptap/react"),to=require("jotai"),Ue=require("react"),x5=require("sms-segments-calculator");var pc=require("react/jsx-runtime"),Ao=[{type:"text",content:`
|
|
199
|
+
`}],T5=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",elements:Ao}),t},"getOrCreateSMSElement"),E5=s(({value:e})=>{var c;let{editor:t}=(0,v5.useCurrentEditor)(),r=(0,to.useSetAtom)(He),o=(0,to.useAtomValue)(ee),n=(c=t==null?void 0:t.getText())!=null?c:"",i=(0,Ue.useMemo)(()=>new x5.SegmentedMessage(n),[n]),a=(0,to.useAtomValue)(ae),l=(0,Ue.useRef)(!1);return(0,Ue.useEffect)(()=>{a&&(l.current=!1)},[a]),(0,Ue.useEffect)(()=>{!t||a!==!1||l.current||!e||(l.current=!0,t.commands.setContent(e))},[t,e,a]),(0,Ue.useEffect)(()=>{t&&(r(t),lr("sms",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ue.useEffect)(()=>{if(!t||!o||t.isFocused)return;let u=T5(o),m={type:"channel",channel:"sms",elements:u.type==="channel"&&"elements"in u&&u.elements||Ao},p=Ze({version:"2022-01-01",elements:[m]}),f=de(p),v=de(t.getJSON());JSON.stringify(f)!==JSON.stringify(v)&&setTimeout(()=>{t.isFocused||t.commands.setContent(p)},1)},[t,o]),(0,pc.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"),w5={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"}},wb=(0,Ue.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,render:i,headerRenderer:a,value:l,colorScheme:c,...u},d)=>{let m=(0,to.useAtomValue)(ae),p=(0,Ue.useRef)(!0),f=(0,Ue.useRef)(!1),v=(0,to.useSetAtom)(ye),[h,b]=(0,to.useAtom)(ee),y=(0,to.useSetAtom)(je),N=(0,to.useAtomValue)(Ct);(0,Ue.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=(0,Ue.useMemo)(()=>[...or({setSelectedNode:v})].filter(C=>C!==void 0),[v]),P=(0,Ue.useRef)(!1),M=(0,Ue.useCallback)(({editor:C})=>{if(N)return;if(!h){let k=de(C.getJSON()),L=Ya(k),S={version:"2022-01-01",elements:[{type:"channel",channel:"sms",elements:L.length>0?L:Ao}]};P.current=!0,b(S),y(S);return}let x=de(C.getJSON()),w=Ya(x),A=ut(h,{channel:"sms",elements:w.length>0?w:Ao});JSON.stringify(h)!==JSON.stringify(A)&&(P.current=!0,b(A),y(A))},[h,b,y,N]),[T,R]=(0,Ue.useState)(null),E=(0,Ue.useCallback)(C=>{if(!C)return null;let x=C==null?void 0:C.elements.find(k=>k.type==="channel"&&k.channel==="sms");x||(x=T5(C));let A={type:"channel",channel:"sms",elements:(x==null?void 0:x.type)==="channel"&&"elements"in x&&x.elements||Ao};return Ze({version:"2022-01-01",elements:[A]})},[]);return(0,Ue.useEffect)(()=>{if(m!==!1)return;if(P.current){P.current=!1;return}let C=l!=null?l:h,x=E(C);x&&R(x)},[l,h,E,m]),(0,pc.jsx)(Xt,{theme:e,colorScheme:c,isLoading:!!(m&&p.current),Header:a?a({hidePublish:t,channels:o,routing:n}):(0,pc.jsx)(Mr,{hidePublish:t,channels:o,routing:n}),...u,ref:d,children:i==null?void 0:i({content:T,extensions:g,editable:!r,autofocus:!r,onUpdate:M})})}),fc=(0,Ue.memo)(wb);var k5=require("@tiptap/react");var ro=require("react/jsx-runtime"),gc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:a=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=a?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,ro.jsx)(ic,{children:(0,ro.jsx)("div",{className:I("courier-sms-editor",i),children:(0,ro.jsx)(k5.EditorProvider,{content:l,extensions:t,...c,"data-testid":"editor-provider",immediatelyRender:!1,children:a?(0,ro.jsx)(Ar,{value:l,defaultValue:Ao}):(0,ro.jsxs)(ro.Fragment,{children:[(0,ro.jsx)(E5,{value:l}),(0,ro.jsx)(ar,{config:w5})]})})})})},"SMSEditor");var P5=require("jotai");var hc=require("react/jsx-runtime"),N5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i,...a})=>{let l=(0,P5.useAtomValue)(ee);return(0,hc.jsx)(fc,{value:l,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:c=>(0,hc.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,hc.jsx)(gc,{...c})}),...a})},"SMSLayout");var M5=require("@tiptap/react"),dr=require("jotai"),Ce=require("react");var Ai=require("react/jsx-runtime"),Za=[{type:"text",content:`
|
|
200
|
+
`}],A5=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:Za}),t},"getOrCreateMSTeamsElement"),S5=s(({value:e})=>{let{editor:t}=(0,M5.useCurrentEditor)(),r=(0,dr.useSetAtom)(He),o=(0,dr.useAtomValue)(ee),n=(0,dr.useAtomValue)(ae),i=(0,dr.useAtomValue)(ye),a=(0,Ce.useRef)(!1),l=(0,Ce.useRef)(!1);return(0,Ce.useEffect)(()=>{n&&(a.current=!1)},[n]),(0,Ce.useEffect)(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Ce.useEffect)(()=>{t&&(r(t),lr("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ce.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Ce.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,Ce.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=A5(o),u=Ze({version:"2022-01-01",elements:[c]},{channel:"msteams"}),d=de(u),m=de(t.getJSON());JSON.stringify(d)!==JSON.stringify(m)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"MSTeamsEditorContent"),I5={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"},conditionalRules:[{id:"msteams-blockquote-bold-italic-mutex-1",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["italic"]},action:{type:"toggle_off",targets:["italic"]}},{id:"msteams-blockquote-bold-italic-mutex-2",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["bold"]},action:{type:"toggle_off",targets:["bold"]}}]},kb=(0,Ce.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let m=(0,dr.useAtomValue)(ae),p=(0,dr.useAtomValue)(Ct),f=(0,dr.useAtomValue)(He),v=(0,dr.useAtomValue)(jt),[h,b]=(0,dr.useAtom)(ye),[y,N]=(0,dr.useAtom)(ee),g=(0,dr.useSetAtom)(je),P=(0,Ce.useRef)(!0),M=(0,Ce.useRef)(!1),T=(0,Ce.useRef)(v),[R,E]=(0,Ce.useState)({Sidebar:["text","divider"],Editor:[]}),C=(0,Ce.useRef)(null);Ti({items:R,setItems:E});let x=(0,Ce.useCallback)(S=>{C.current&&cancelAnimationFrame(C.current),setTimeout(()=>{C.current=requestAnimationFrame(()=>{try{let H=S==null?void 0:S.view.dom;if(!H){console.warn("syncEditorItems: Editor DOM element not found");return}let V=H.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),F=[];V.forEach(O=>{let B=O.dataset.id;B&&F.push(B)}),E(O=>({Editor:F,Sidebar:O.Sidebar}))}catch(H){console.error("Error syncing editor items:",H),E(V=>({...V}))}})},50)},[]);(0,Ce.useEffect)(()=>(M.current=!0,()=>{M.current=!1}),[]),(0,Ce.useEffect)(()=>{T.current=v},[v]),(0,Ce.useEffect)(()=>{let S=s(()=>{f&&x(f)},"updateItems");f==null||f.on("update",S),f==null||f.on("selectionUpdate",S),f==null||f.on("create",S),f==null||f.on("transaction",S),f&&!f.isDestroyed&&S();let H=s(V=>{S()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",H),()=>{f==null||f.off("update",S),f==null||f.off("selectionUpdate",S),f==null||f.off("create",S),f==null||f.off("transaction",S),document.removeEventListener("node-duplicated",H),C.current&&cancelAnimationFrame(C.current)}},[f,x]),(0,Ce.useEffect)(()=>{m===!1&&y&&setTimeout(()=>{f&&!f.isDestroyed&&x(f)},300)},[m,y,f,x]);let w=(0,Ce.useCallback)(()=>!T.current,[]),A=(0,Ce.useMemo)(()=>[...or({setSelectedNode:b,shouldHandleClick:w})].filter(S=>S!==void 0),[b,w]),k=(0,Ce.useCallback)(({editor:S})=>{if(!S||p)return;if(!y){let _={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:de(S.getJSON())}]};N(_),g(_);return}let H=S.getJSON(),V=de(H),F=ut(y,{elements:V,channel:"msteams"}),O=JSON.stringify(y.elements),B=JSON.stringify(F.elements);O!==B&&(N(F),g(F))},[y,N,g,p]),L=(0,Ce.useMemo)(()=>{let S=A5(l);return Ze({version:"2022-01-01",elements:[S]},{channel:"msteams"})},[l]);return(0,Ai.jsx)(Xt,{theme:e,colorScheme:c,isLoading:!!(m&&P.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Ai.jsx)(Mr,{hidePublish:t,channels:o,routing:n}),ref:d,...u,children:(0,Ai.jsx)(Ai.Fragment,{children:a==null?void 0:a({content:L,extensions:A,editable:!r,autofocus:!r,onUpdate:k,items:R,selectedNode:h,msteamsEditor:f})})})}),bc=(0,Ce.memo)(kb);var R5=require("@tiptap/react");var ze=require("react/jsx-runtime"),Pb=s(()=>(0,ze.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-full",children:(0,ze.jsx)(ia,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),Nb=s(()=>(0,ze.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[(0,ze.jsx)(Pb,{}),(0,ze.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[(0,ze.jsx)("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"}),(0,ze.jsx)("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),Mb=s(()=>(0,ze.jsx)("div",{className:"courier-flex courier-justify-end courier-w-full",children:(0,ze.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:(0,ze.jsx)("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),L5=s(({children:e,className:t})=>(0,ze.jsxs)("div",{className:I("courier-w-full courier-max-w-[800px] courier-bg-white dark:courier-bg-[#171717] courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,ze.jsx)(Nb,{}),(0,ze.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,ze.jsx)("div",{className:"courier-flex-shrink-0 courier-mt-6",children:(0,ze.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,ze.jsx)(na,{color:"#FFFFFF"})})}),(0,ze.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,ze.jsx)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:(0,ze.jsx)("span",{className:"courier-text-sm courier-text-[#A3A3A3] dark:courier-text-[#8786A9]",children:"Circle"})}),(0,ze.jsx)("div",{className:"courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px] courier-px-3 courier-py-2 courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-max-w-full courier-pr-5",children:e})]})]}),(0,ze.jsx)(Mb,{})]}),"MSTeamsFrame");var yc=require("react");var oo=require("react/jsx-runtime"),Cc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let a=(0,yc.useRef)(null);return(0,yc.useEffect)(()=>{let l=a.current;if(!(!l||i))return br({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,oo.jsx)(L5,{children:(0,oo.jsx)("div",{ref:a,children:(0,oo.jsx)(R5.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:I("courier-msteams-editor")},immediatelyRender:!1,children:i?(0,oo.jsx)(Ar,{value:e,defaultValue:Za}):(0,oo.jsxs)(oo.Fragment,{children:[(0,oo.jsx)(S5,{value:e}),(0,oo.jsx)(ar,{config:I5})]})})})}):null},"MSTeamsEditor");var B5=require("jotai");var H5=require("lucide-react");var Ht=require("react/jsx-runtime"),vc=s(({items:e,label:t,editor:r})=>(0,Ht.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,Ht.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,Ht.jsxs)(Ht.Fragment,{children:[(0,Ht.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),(0,Ht.jsx)(ce,{className:"courier-my-4"})]}),(0,Ht.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,Ht.jsx)(Pi,{id:o.toString(),editor:r,children:(0,Ht.jsxs)("div",{className:I("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Ht.jsx)(H5.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),o==="text"&&(0,Ht.jsx)(Jo,{draggable:!0}),o==="divider"&&(0,Ht.jsx)(qo,{draggable:!0}),o==="button"&&(0,Ht.jsx)(Zo,{draggable:!0})]})},o))})]})}),"MSTeamsSideBar");var $d=require("react");var Tr=require("react/jsx-runtime"),Ab=(0,$d.forwardRef)(({children:e,className:t,...r},o)=>(0,Tr.jsx)("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Sb=(0,$d.forwardRef)(({children:e,...t},r)=>(0,Tr.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),D5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i})=>{let a=(0,B5.useAtomValue)(ee);return(0,Tr.jsx)(bc,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:l=>{var c;return(0,Tr.jsxs)(nn,{children:[(0,Tr.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Tr.jsx)(Ab,{children:(0,Tr.jsx)(Sb,{children:(0,Tr.jsx)(Cc,{...l})})})}),(0,Tr.jsx)(an,{children:(0,Tr.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,Tr.jsx)(vc,{items:l.items.Sidebar,label:"Blocks library",editor:(c=l.msteamsEditor)!=null?c:void 0})})})]})}})},"MSTeamsLayout");var F5={sms:{elements:Ao},push:{elements:Fn},inbox:{elements:za},slack:{elements:$a},email:{elements:Va},msteams:{elements:Za}},V5=s(e=>{var t;return(t=F5[e])!=null?t:F5.email},"getChannelDefaults"),Ib=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"),xc=s(({channels:e=["email"],routing:t})=>{let[r,o]=(0,mr.useState)([]),n=(0,So.useAtomValue)(ee),i=(0,So.useSetAtom)(ee),a=(0,So.useSetAtom)(je),[l,c]=(0,So.useAtom)(Uo),u=(0,So.useSetAtom)(ye),d=(0,So.useAtomValue)(ae),m=Ib(t,e),p=(0,mr.useRef)(m);p.current=m,(0,mr.useEffect)(()=>{if(d||n!=null&&n.elements)return;let N=p.current.map(g=>Oo.find(P=>P.value===g)).filter(g=>!!g);o(N),N.length>0&&!l&&c(N[0].value)},[n,d,c,l]),(0,mr.useEffect)(()=>{if(d||!(n!=null&&n.elements))return;let y=p.current,N=n.elements.filter(P=>P.type==="channel").map(P=>P.channel).filter(P=>y.includes(P)),g=y.filter(P=>N.includes(P)).map(P=>Oo.find(M=>M.value===P)).filter(P=>!!P);o(g)},[n,d]),(0,mr.useEffect)(()=>{var g;if(d||r.length===0)return;let y=r.some(P=>P.value===l),N=(g=n==null?void 0:n.elements)==null?void 0:g.some(P=>P.type==="channel"&&P.channel===l);!y&&!N&&c(r[0].value)},[r,l,c,d,n]);let f=(0,mr.useMemo)(()=>(m==null?void 0:m.filter(y=>!r.some(N=>N.value===y)).map(y=>Oo.find(N=>N.value===y)).filter(y=>!!y))||[],[r,m]),v=(0,mr.useCallback)(y=>{let N=[],g,{elements:P,raw:M}=V5(y);if(N=P,g=M,!n){let E=[];for(let w of r){let{elements:A,raw:k}=V5(w.value),L={type:"channel",channel:w.value,elements:A};k&&(L.raw=k),E.push(L)}let C={type:"channel",channel:y,elements:N};g&&(C.raw=g),E.push(C);let x={version:"2022-01-01",elements:E};i(x),a(x),c(y);return}let R=ut(n,{elements:N,channel:g?{channel:y,raw:g}:y});i(R),a(R),c(y)},[n,i,a,c,r]),h=(0,mr.useCallback)(y=>{if(!n)return;let N=n.elements.filter(M=>M.type==="channel"?M.channel!==y:!0),g={...n,elements:N};i(g),a(g),u(null);let P=r.filter(M=>M.value!==y);l===y&&P.length>0&&c(P[0].value)},[n,i,a,r,l,c,u]),b=(0,mr.useMemo)(()=>[...r,...f],[r,f]);return{enabledChannels:r,disabledChannels:f,channel:l,channelOptions:b,setChannel:c,addChannel:v,removeChannel:h}},"useChannels");var ve=require("react/jsx-runtime"),Mr=s(({hidePublish:e=!1,channels:t,routing:r})=>{let o=(0,fo.useRef)(null),n=(0,Io.useAtomValue)(bt),i=(0,Io.useAtomValue)(ae),a=(0,Io.useAtomValue)(Q),{publishTemplate:l,isTemplatePublishing:c}=Zn(),[u,d]=(0,Io.useAtom)(Wn),m=(0,Io.useSetAtom)(io),p=(0,Io.useAtomValue)(io),{enabledChannels:f,disabledChannels:v,channel:h,setChannel:b,addChannel:y,removeChannel:N}=xc({channels:t,routing:r});(0,fo.useEffect)(()=>{n===!0&&d(null)},[n,d]);let g=(0,fo.useCallback)(()=>{p&&m(!1),l()},[l,p,m]),P=(0,fo.useCallback)(E=>{p&&m(!1),b(E)},[p,m,b]),M=(0,fo.useCallback)(E=>{p&&m(!1),y(E)},[p,m,y]),T=(0,fo.useCallback)(E=>{p&&m(!1),N(E)},[p,m,N]),R=(0,fo.useCallback)(()=>{p&&m(!1)},[p,m]);return(0,ve.jsxs)("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:R,children:[(0,ve.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[(0,ve.jsx)(ls,{value:h,onValueChange:P,className:"courier-h-full",ref:o,children:(0,ve.jsx)(Ji,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${Oo.length}, fit-content(100%))`},children:f.map(E=>(0,ve.jsxs)(Qn,{value:E.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:[E.label,E.value===h&&f.length>1&&(0,ve.jsxs)(Lm,{children:[(0,ve.jsx)(Rm,{asChild:!0,children:(0,ve.jsx)("div",{className:"courier-pl-2",children:(0,ve.jsx)(ji,{color:"#A3A3A3"})})}),(0,ve.jsxs)(Oc,{ref:o,children:[(0,ve.jsx)(Uc,{children:(0,ve.jsx)(O5.AlertDialogDescription,{children:"Are you sure you want to delete this channel?"})}),(0,ve.jsxs)(Wc,{children:[(0,ve.jsx)(zc,{asChild:!0,children:(0,ve.jsx)(Se,{buttonSize:"small",variant:"outline",children:"Cancel"})}),(0,ve.jsx)(_c,{asChild:!0,children:(0,ve.jsx)(Se,{buttonSize:"small",variant:"primary",onClick:()=>T(E.value),children:"Delete"})})]})]})]})]},E.value))})}),v.length>0&&(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)(jc,{orientation:"vertical",className:"!courier-h-5"}),(0,ve.jsxs)(os,{children:[(0,ve.jsx)(ns,{asChild:!0,children:(0,ve.jsx)(Se,{variant:"link",children:"+ Add channel"})}),(0,ve.jsx)(zi,{portalProps:{container:o.current},children:v.map(E=>(0,ve.jsxs)($i,{onClick:()=>M(E.value),children:[E.icon,E.label]},E.value))})]})]})]}),(0,ve.jsxs)("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&(0,ve.jsx)(ni,{isLoading:!!i,isSaving:!!n,isError:!!a}),!e&&i!==null&&(0,ve.jsx)(Se,{variant:"primary",buttonSize:"small",disabled:c===!0||n===!0||u!==null,onClick:g,children:c?"Publishing...":"Publish changes"})]})]})},"Channels");var At=require("react");function Si({onSave:e,debounceMs:t=2e3,enabled:r=!0,onError:o,initialContent:n,flushBeforeSave:i}){let[a,l]=(0,At.useState)(!1),c=(0,At.useRef)(!1),u=(0,At.useRef)(null),d=(0,At.useRef)(),m=(0,At.useRef)(0),p=(0,At.useRef)();(0,At.useEffect)(()=>{n&&(d.current=JSON.stringify(n))},[n]);let f=(0,At.useCallback)(async()=>{if(c.current)return;if(i)try{i()}catch(g){console.error("[AutoSave] Error flushing updates:",g)}let N=u.current;if(u.current=null,!!N)try{let g=JSON.stringify(N);if(g===d.current)return;c.current=!0,l(!0),d.current=g,m.current=Date.now(),await e(N)}catch(g){console.error("[AutoSave] Save failed:",g),o==null||o(g)}finally{if(c.current=!1,l(!1),u.current){let g=t;p.current=setTimeout(()=>{p.current=void 0,f()},g)}}},[t,o,e,i]),v=(0,At.useRef)(r),h=(0,At.useRef)(t),b=(0,At.useRef)(f);return(0,At.useEffect)(()=>{v.current=r,h.current=t,b.current=f}),{handleAutoSave:(0,At.useCallback)(async N=>{if(!v.current)return;let g=JSON.stringify(N);if(u.current=N,g===d.current||c.current)return;p.current&&(clearTimeout(p.current),p.current=void 0);let P=h.current;p.current=setTimeout(()=>{p.current=void 0,b.current()},P)},[]),isSaving:a}}s(Si,"useAutoSave");var ot=require("jotai"),Ie=require("react");var go=require("jotai"),St=require("react");var qt=require("zod"),U5=qt.z.object({headerStyle:qt.z.enum(["plain","border"]),isUnsubscribe:qt.z.boolean().optional(),isPreferences:qt.z.boolean().optional(),link:qt.z.string().optional(),brandColor:qt.z.string(),textColor:qt.z.string(),subtleColor:qt.z.string(),logo:qt.z.string().optional(),facebookLink:qt.z.string().optional(),linkedinLink:qt.z.string().optional(),instagramLink:qt.z.string().optional(),mediumLink:qt.z.string().optional(),xLink:qt.z.string().optional()}),Jt={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};var Lb=s(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),qa=s(e=>{var t,r,o,n,i,a,l,c,u,d,m,p,f,v;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 y=e.marks.map(Lb).filter(Boolean);h=y.join("")+h+y.reverse().join("")}let b=(o=e.marks)==null?void 0:o.find(y=>y.type==="link");return b&&(h=`[${h}](${(n=b.attrs)==null?void 0:n.href})`),h}case"hardBreak":return`
|
|
203
201
|
`;case"paragraph":return(((i=e.content)==null?void 0:i.map(qa).join(""))||"")+`
|
|
204
202
|
|
|
205
|
-
`;case"heading":{let
|
|
203
|
+
`;case"heading":{let h=((a=e.attrs)==null?void 0:a.level)||1,b="#".repeat(h)+" ",y=((l=e.content)==null?void 0:l.map(qa).join(""))||"";return b+y+`
|
|
206
204
|
|
|
207
205
|
`}case"blockquote":return(((c=e.content)==null?void 0:c.map(qa).join(""))||"").split(`
|
|
208
|
-
`).map(
|
|
206
|
+
`).map(b=>`> ${b}`).join(`
|
|
209
207
|
`)+`
|
|
210
208
|
|
|
211
|
-
`;case"imageBlock":{let
|
|
209
|
+
`;case"imageBlock":{let h=((u=e.attrs)==null?void 0:u.alt)||"",b=((d=e.attrs)==null?void 0:d.sourcePath)||"",y=(m=e.attrs)==null?void 0:m.link,N=``;return y?`[${N}](${y})
|
|
212
210
|
|
|
213
211
|
`:N+`
|
|
214
212
|
|
|
215
213
|
`}case"divider":return`---
|
|
216
214
|
|
|
217
|
-
`;case"button":{let
|
|
215
|
+
`;case"button":{let h=((p=e.attrs)==null?void 0:p.label)||"",b=((f=e.attrs)==null?void 0:f.link)||"#";return`[${h}](${b})
|
|
218
216
|
|
|
219
|
-
`}default:return((C=e.content)==null?void 0:C.map(qa).join(""))||""}},"convertNodeToMarkdown");function Tc(e){return e.content?e.content.map(qa).join("").trim():""}s(Tc,"convertTiptapToMarkdown");var Rr=require("jotai"),Do=require("react");var z5=require("react"),Z5=require("react/jsx-runtime"),$5=(0,z5.forwardRef)(({children:e},t)=>(0,Z5.jsx)("div",{ref:t,className:"courier-z-30 courier-flex courier-w-full courier-bg-primary courier-h-12 courier-border-b rounded-b-none rounded-t-sm courier-shadow-none courier-justify-between courier-items-center courier-px-4",children:e}));var wr=require("react");var Hi=require("react/jsx-runtime"),Hb=["image/png","image/jpeg","image/gif","image/webp"],q5=s(({onFileSelect:e})=>{let[t,r]=(0,wr.useState)(!1),o=(0,wr.useRef)(null),n=(0,wr.useCallback)(m=>Hb.includes(m),[]),i=(0,wr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(y=>n(y.type))&&(r(!0),m.dataTransfer.dropEffect="copy")},[n]),a=(0,wr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),r(!1)},[]),l=(0,wr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(y=>n(y.type))&&r(!0)},[n]),c=(0,wr.useCallback)(async m=>{try{let{dataUrl:f}=await es(m,800);e==null||e(f),o.current&&(o.current.value="")}catch(f){console.error("Error processing image:",f),o.current&&(o.current.value="")}},[e]),u=(0,wr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),r(!1);let C=Array.from(m.dataTransfer.files).find(y=>n(y.type));C&&c(C)},[c,n]),d=(0,wr.useCallback)(m=>{var C;let f=(C=m.target.files)==null?void 0:C[0];f&&c(f)},[c]),p=(0,wr.useCallback)(m=>{var f;m.preventDefault(),m.stopPropagation(),(f=o.current)==null||f.click()},[]);return(0,Hi.jsxs)("div",{className:L("courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-cursor-pointer courier-transition-colors courier-py-4 courier-px-6 courier-gap-1 !courier-w-fit",t&&"courier-border-primary courier-bg-gray-50"),onDragOver:i,onDragEnter:l,onDragLeave:a,onDrop:u,style:{pointerEvents:"all"},children:[(0,Hi.jsx)("span",{className:"courier-text-sm courier-pointer-events-none",children:"Drag and drop logo, or"}),(0,Hi.jsx)("button",{className:"courier-underline courier-font-medium courier-text-sm",onClick:p,type:"button",children:"Browse"}),(0,Hi.jsx)("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:d},"logo-input")]})},"LogoUploader");var j5=require("@hookform/resolvers/zod"),Di=require("jotai"),K5=require("lucide-react"),Lr=require("react"),G5=require("react-hook-form");var U=require("react/jsx-runtime"),J5=s(({isActive:e,onClick:t,value:r})=>(0,U.jsx)("div",{className:L("courier-w-full courier-h-16 courier-rounded-md courier-border-border courier-border courier-overflow-hidden courier-bg-secondary courier-cursor-pointer",e&&"!courier-border-[#3B82F6]"),onClick:t,children:(0,U.jsx)("div",{className:"courier-h-full courier-m-2 courier-rounded-md courier-border-border courier-border courier-shadow-md courier-bg-background courier-overflow-hidden",children:r==="border"&&(0,U.jsx)("div",{className:"courier-w-full courier-bg-[#000000] courier-h-1"})})}),"HeaderStyle"),Db=s(()=>{let[e,t]=(0,Di.useAtom)(uo),r=(0,Di.useSetAtom)(Zr),o=(0,Di.useAtomValue)(Jn),n=(0,Lr.useRef)(null),i=(0,G5.useForm)({resolver:(0,j5.zodResolver)(U5),defaultValues:{...Kt,...e},mode:"onChange"});(0,Lr.useEffect)(()=>{e&&i.reset(e)},[e,i]);let a=(0,Lr.useCallback)(()=>{t(i.getValues())},[i,t]),l=(0,Lr.useCallback)(d=>{var p;if(o){if(d){let f={type:"doc",content:[...o.getJSON().content||[],{type:"paragraph",content:[{type:"text",text:"Manage Notification Preferences",marks:[{type:"link",attrs:{href:"{{urls.preferences}}"}}]}]}]};o.chain().focus().setContent(f).run()}else{let f=((p=o.getJSON().content)==null?void 0:p.filter(C=>{var h;return C.type!=="paragraph"?!0:!((h=C.content)==null?void 0:h.some(b=>{var N;return b.type==="text"&&((N=b.marks)==null?void 0:N.some(g=>{var w;return g.type==="link"&&((w=g.attrs)==null?void 0:w.href)==="{{urls.preferences}}"}))}))}))||[];o.chain().focus().setContent({type:"doc",content:f}).run()}r(Tc(o.getJSON()))}},[o,r]),c=(0,Lr.useMemo)(()=>{var d,p;return((p=(d=o==null?void 0:o.extensionManager.extensions.find(m=>m.name==="variableSuggestion"))==null?void 0:d.options)==null?void 0:p.variables)||{}},[o]),u=(0,Lr.useMemo)(()=>Tt(c),[c]);return(0,U.jsx)(Je,{...i,children:(0,U.jsx)("form",{onChange:()=>a(),children:(0,U.jsxs)("div",{className:"courier-pb-6",children:[(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Header style"}),(0,U.jsx)(j,{control:i.control,name:"headerStyle",render:({field:d})=>(0,U.jsxs)(q,{className:"courier-mb-4",children:[(0,U.jsx)(J,{children:(0,U.jsxs)("div",{className:"courier-w-full courier-flex courier-flex-row courier-gap-3",children:[(0,U.jsx)(J5,{isActive:d.value==="plain",onClick:()=>{d.onChange("plain"),t({...i.getValues(),headerStyle:"plain"})},value:"plain"}),(0,U.jsx)(J5,{isActive:d.value==="border",onClick:()=>{d.onChange("border"),t({...i.getValues(),headerStyle:"border"})},value:"border"})]})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(le,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Logo"}),(0,U.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[i.getValues().logo?(0,U.jsx)(Ie,{onClick:()=>{let d=i.getValues();d.logo="",i.reset(d),t({...d}),n.current&&(n.current.value=""),a()},className:"courier-w-full",variant:"outline",type:"button",children:"Remove logo"}):(0,U.jsxs)(Ie,{onClick:d=>{d.preventDefault(),n.current&&(n.current.value="",n.current.click())},className:"courier-w-full",variant:"outline",type:"button",children:[(0,U.jsx)(K5.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-mr-2 courier-text-foreground"}),"Upload logo"]}),(0,U.jsx)("input",{ref:n,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:async d=>{var m;let p=(m=d.target.files)==null?void 0:m[0];if(p)try{let{dataUrl:f}=await es(p,800),C=i.getValues();C.logo=f,i.reset(C),t({...C})}catch(f){console.error("Error processing image:",f)}n.current&&(n.current.value="")}})]}),(0,U.jsx)(j,{control:i.control,name:"link",render:({field:d})=>(0,U.jsxs)(q,{className:"courier-mb-3",children:[(0,U.jsx)(J,{children:(0,U.jsx)(on,{as:"Textarea",placeholder:"Link",...d,variables:u,onChange:p=>{d.onChange(p),a()}})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(le,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Brand color"}),(0,U.jsx)(j,{control:i.control,name:"brandColor",render:({field:d})=>(0,U.jsxs)(q,{className:"courier-mb-4",children:[(0,U.jsx)(J,{children:(0,U.jsx)(vt,{...d,defaultValue:d.value,onChange:p=>{d.onChange(p),a()}})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(le,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer links"}),(0,U.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-3 courier-mb-3",children:[(0,U.jsx)(j,{control:i.control,name:"facebookLink",render:({field:d})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(ye,{startAdornment:(0,U.jsx)(ea,{}),placeholder:"facebook.com/username",...d,autoFocus:!0})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(j,{control:i.control,name:"linkedinLink",render:({field:d})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(ye,{startAdornment:(0,U.jsx)(oa,{}),placeholder:"linkedin.com/username",...d})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(j,{control:i.control,name:"instagramLink",render:({field:d})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(ye,{startAdornment:(0,U.jsx)(ra,{}),placeholder:"instagram.com/username",...d})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(j,{control:i.control,name:"mediumLink",render:({field:d})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(ye,{startAdornment:(0,U.jsx)(na,{}),placeholder:"medium.com/username",...d})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(j,{control:i.control,name:"xLink",render:({field:d})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(ye,{startAdornment:(0,U.jsx)(ca,{}),placeholder:"x.com/username",...d})}),(0,U.jsx)(K,{})]})})]}),(0,U.jsx)(le,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer actions"}),(0,U.jsx)(j,{control:i.control,name:"isPreferences",render:({field:d})=>(0,U.jsxs)(q,{className:"courier-flex courier-flex-row courier-items-center courier-gap-2 courier-mb-4",children:[(0,U.jsx)(J,{children:(0,U.jsx)(ri,{checked:d.value,onCheckedChange:p=>{i.setValue("isPreferences",p),d.onChange(p),l(p);let m={...i.getValues(),isPreferences:p};t(m)}})}),(0,U.jsx)(lo,{className:"!courier-m-0",children:"Manage Preferences"}),(0,U.jsx)(K,{})]})})]})})})},"SideBarComponent"),Y5=(0,Lr.memo)(Db);var He=require("react/jsx-runtime"),Bb=(0,Do.forwardRef)(({hidePublish:e=!1,templateEditor:t,variables:r},o)=>{var w,M,k,D,T,x,E,v;let n=(0,Rr.useSetAtom)(ci),{publishBrand:i}=jn(),a=(0,Rr.useAtomValue)(it),l=(0,Rr.useAtomValue)(Ut),c=(0,Rr.useAtomValue)(bt),u=(0,Rr.useAtomValue)(ae),d=(0,Rr.useAtomValue)(ee),p=(0,Rr.useAtomValue)(Jn),[m,f]=(0,Rr.useAtom)(uo),[C,y]=(0,Rr.useAtom)(Zr),h=(0,Do.useCallback)(()=>{i()},[i]),b=(0,Do.useCallback)(({editor:P})=>{y(Tc(P.getJSON()))},[y]),N=(0,Do.useCallback)(P=>{f(S=>S?{...S,logo:P}:{...Kt,logo:P})},[f]),g=(0,Do.useCallback)(()=>{n("template")},[n]);return(0,He.jsxs)(He.Fragment,{children:[(0,He.jsx)("div",{className:"courier-z-30 courier-w-full courier-h-12",children:(0,He.jsxs)($5,{children:[(0,He.jsx)("div",{className:"courier-text-sm courier-font-medium",children:"Brand theme"}),(0,He.jsxs)("div",{className:"courier-flex courier-gap-2 courier-items-center",children:[c!==null&&(0,He.jsx)(li,{isLoading:!!u,isSaving:!!c,isError:!!d}),t&&(0,He.jsx)(Ie,{variant:"outline",buttonSize:"small",onClick:g,disabled:l===!0||c===!0,children:"Back"}),!e&&u!==null&&(0,He.jsx)(Ie,{variant:"primary",buttonSize:"small",disabled:!((M=(w=a==null?void 0:a.data)==null?void 0:w.tenant)!=null&&M.brand)||l===!0||c!==!1,onClick:h,children:l?"Publishing...":"Publish changes"})]})]})}),(0,He.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,He.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,He.jsxs)("div",{className:"courier-editor-container",ref:o,children:[(0,He.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Header"}),(0,He.jsxs)("div",{className:L("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-py-5 courier-px-9 courier-mb-8 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(m==null?void 0:m.headerStyle)==="border"&&"courier-pt-6"),children:[(m==null?void 0:m.headerStyle)==="border"&&(0,He.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:m.brandColor}}),m!=null&&m.logo?(0,He.jsx)("img",{src:m.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"}):(0,He.jsx)(q5,{onFileSelect:N})]}),(0,He.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Footer"}),(0,He.jsx)("div",{className:"courier-theme-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-pt-3 courier-pb-5 courier-px-9",children:(0,He.jsx)(Mi,{value:C!=null?C:(v=(E=(x=(T=(D=(k=a==null?void 0:a.data)==null?void 0:k.tenant)==null?void 0:D.brand)==null?void 0:T.settings)==null?void 0:x.email)==null?void 0:E.footer)==null?void 0:v.markdown,variables:r,facebookLink:m==null?void 0:m.facebookLink,linkedinLink:m==null?void 0:m.linkedinLink,instagramLink:m==null?void 0:m.instagramLink,mediumLink:m==null?void 0:m.mediumLink,xLink:m==null?void 0:m.xLink,onUpdate:b})})]})}),(0,He.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,He.jsx)("div",{className:"courier-p-4 courier-h-full",children:p&&(0,He.jsx)(Y5,{})})})]})]})}),X5=(0,Do.memo)(Bb);var Zd=require("react/jsx-runtime"),Fb=(0,It.forwardRef)(({hidePublish:e=!1,autoSaveDebounce:t=500,autoSave:r=!0,theme:o,colorScheme:n,...i},a)=>{let l=(0,yo.useAtomValue)(ae),c=(0,It.useRef)(!0),u=(0,yo.useAtomValue)(ht),{getTemplate:d,saveBrand:p}=jn(),[m,f]=(0,yo.useAtom)(it),C=(0,yo.useSetAtom)(Zr),y=(0,yo.useAtomValue)(Zr),[h,b]=(0,yo.useAtom)(uo),N=(0,It.useRef)(!1),g=(0,yo.useSetAtom)(ee);(0,It.useEffect)(()=>{var D,T;m&&u!==((T=(D=m==null?void 0:m.data)==null?void 0:D.tenant)==null?void 0:T.tenantId)&&(f(null),C(null),c.current=!1)},[m,u,f,C]);let w=(0,It.useCallback)(async D=>{await p(D)},[p]),M=(0,It.useCallback)(()=>{g(ao("Error saving theme"))},[g]),{handleAutoSave:k}=Ri({onSave:w,enabled:l!==null&&r&&y!==null,debounceMs:t,onError:M});return(0,It.useEffect)(()=>{!u||l||m&&l===!1||d()},[u,d,l,m]),(0,It.useEffect)(()=>{y&&setTimeout(()=>{N.current=!0},500)},[y]),(0,It.useEffect)(()=>{if(!N.current||!h)return;let D={colors:{primary:h==null?void 0:h.brandColor,secondary:h==null?void 0:h.textColor,tertiary:h==null?void 0:h.subtleColor},email:{header:{barColor:(h==null?void 0:h.headerStyle)==="border"?h==null?void 0:h.brandColor:"",logo:{href:h==null?void 0:h.link,image:h==null?void 0:h.logo}},footer:{markdown:y!=null?y:void 0,social:{facebook:{url:h==null?void 0:h.facebookLink},instagram:{url:h==null?void 0:h.instagramLink},linkedin:{url:h==null?void 0:h.linkedinLink},medium:{url:h==null?void 0:h.mediumLink},twitter:{url:h==null?void 0:h.xLink}}}}};k(D)},[h,y,k]),(0,It.useEffect)(()=>{l||(c.current=!1)},[l]),(0,It.useEffect)(()=>{var D,T,x,E,v,P,S,I,A,H,R,B,_,V,W,O,Y,re,Q,F,$,fe,be,Te,De,Lt,gr,se,Oe,Se,Ft,Vt,Hr,Dr,Br,Fr,Bo,Fo;if(!h){let ne=(x=(T=(D=m==null?void 0:m.data)==null?void 0:D.tenant)==null?void 0:T.brand)==null?void 0:x.settings,Co=(S=y==null?void 0:y.split(`
|
|
220
|
-
`))!=null?
|
|
221
|
-
`),
|
|
217
|
+
`}default:return((v=e.content)==null?void 0:v.map(qa).join(""))||""}},"convertNodeToMarkdown");function Tc(e){return e.content?e.content.map(qa).join("").trim():""}s(Tc,"convertTiptapToMarkdown");var Sr=require("jotai"),Ro=require("react");var W5=require("react"),z5=require("react/jsx-runtime"),_5=(0,W5.forwardRef)(({children:e},t)=>(0,z5.jsx)("div",{ref:t,className:"courier-z-30 courier-flex courier-w-full courier-bg-primary courier-h-12 courier-border-b rounded-b-none rounded-t-sm courier-shadow-none courier-justify-between courier-items-center courier-px-4",children:e}));var Er=require("react");var Ii=require("react/jsx-runtime"),Rb=["image/png","image/jpeg","image/gif","image/webp"],$5=s(({onFileSelect:e})=>{let[t,r]=(0,Er.useState)(!1),o=(0,Er.useRef)(null),n=(0,Er.useCallback)(p=>Rb.includes(p),[]),i=(0,Er.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),p.dataTransfer.types.includes("Files")&&Array.from(p.dataTransfer.items).some(h=>n(h.type))&&(r(!0),p.dataTransfer.dropEffect="copy")},[n]),a=(0,Er.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),r(!1)},[]),l=(0,Er.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),p.dataTransfer.types.includes("Files")&&Array.from(p.dataTransfer.items).some(h=>n(h.type))&&r(!0)},[n]),c=(0,Er.useCallback)(async p=>{try{let{dataUrl:f}=await es(p,800);e==null||e(f),o.current&&(o.current.value="")}catch(f){console.error("Error processing image:",f),o.current&&(o.current.value="")}},[e]),u=(0,Er.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),r(!1);let v=Array.from(p.dataTransfer.files).find(h=>n(h.type));v&&c(v)},[c,n]),d=(0,Er.useCallback)(p=>{var v;let f=(v=p.target.files)==null?void 0:v[0];f&&c(f)},[c]),m=(0,Er.useCallback)(p=>{var f;p.preventDefault(),p.stopPropagation(),(f=o.current)==null||f.click()},[]);return(0,Ii.jsxs)("div",{className:I("courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-cursor-pointer courier-transition-colors courier-py-4 courier-px-6 courier-gap-1 !courier-w-fit",t&&"courier-border-primary courier-bg-gray-50"),onDragOver:i,onDragEnter:l,onDragLeave:a,onDrop:u,style:{pointerEvents:"all"},children:[(0,Ii.jsx)("span",{className:"courier-text-sm courier-pointer-events-none",children:"Drag and drop logo, or"}),(0,Ii.jsx)("button",{className:"courier-underline courier-font-medium courier-text-sm",onClick:m,type:"button",children:"Browse"}),(0,Ii.jsx)("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:d},"logo-input")]})},"LogoUploader");var q5=require("@hookform/resolvers/zod"),Li=require("jotai"),J5=require("lucide-react"),Lo=require("react"),j5=require("react-hook-form");var U=require("react/jsx-runtime"),Z5=s(({isActive:e,onClick:t,value:r})=>(0,U.jsx)("div",{className:I("courier-w-full courier-h-16 courier-rounded-md courier-border-border courier-border courier-overflow-hidden courier-bg-secondary courier-cursor-pointer",e&&"!courier-border-[#3B82F6]"),onClick:t,children:(0,U.jsx)("div",{className:"courier-h-full courier-m-2 courier-rounded-md courier-border-border courier-border courier-shadow-md courier-bg-background courier-overflow-hidden",children:r==="border"&&(0,U.jsx)("div",{className:"courier-w-full courier-bg-[#000000] courier-h-1"})})}),"HeaderStyle"),Hb=s(()=>{let[e,t]=(0,Li.useAtom)(lo),r=(0,Li.useSetAtom)(_r),o=(0,Li.useAtomValue)(zn),n=(0,Lo.useRef)(null),i=(0,j5.useForm)({resolver:(0,q5.zodResolver)(U5),defaultValues:{...Jt,...e},mode:"onChange"});(0,Lo.useEffect)(()=>{e&&i.reset(e)},[e,i]);let a=(0,Lo.useCallback)(()=>{t(i.getValues())},[i,t]),l=(0,Lo.useCallback)(c=>{var u;if(o){if(c){let m={type:"doc",content:[...o.getJSON().content||[],{type:"paragraph",content:[{type:"text",text:"Manage Notification Preferences",marks:[{type:"link",attrs:{href:"{{urls.preferences}}"}}]}]}]};o.chain().focus().setContent(m).run()}else{let m=((u=o.getJSON().content)==null?void 0:u.filter(p=>{var v;return p.type!=="paragraph"?!0:!((v=p.content)==null?void 0:v.some(h=>{var b;return h.type==="text"&&((b=h.marks)==null?void 0:b.some(y=>{var N;return y.type==="link"&&((N=y.attrs)==null?void 0:N.href)==="{{urls.preferences}}"}))}))}))||[];o.chain().focus().setContent({type:"doc",content:m}).run()}r(Tc(o.getJSON()))}},[o,r]);return(0,U.jsx)(qe,{...i,children:(0,U.jsx)("form",{onChange:()=>a(),children:(0,U.jsxs)("div",{className:"courier-pb-6",children:[(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Header style"}),(0,U.jsx)(j,{control:i.control,name:"headerStyle",render:({field:c})=>(0,U.jsxs)(q,{className:"courier-mb-4",children:[(0,U.jsx)(J,{children:(0,U.jsxs)("div",{className:"courier-w-full courier-flex courier-flex-row courier-gap-3",children:[(0,U.jsx)(Z5,{isActive:c.value==="plain",onClick:()=>{c.onChange("plain"),t({...i.getValues(),headerStyle:"plain"})},value:"plain"}),(0,U.jsx)(Z5,{isActive:c.value==="border",onClick:()=>{c.onChange("border"),t({...i.getValues(),headerStyle:"border"})},value:"border"})]})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(ce,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Logo"}),(0,U.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[i.getValues().logo?(0,U.jsx)(Se,{onClick:()=>{let c=i.getValues();c.logo="",i.reset(c),t({...c}),n.current&&(n.current.value=""),a()},className:"courier-w-full",variant:"outline",type:"button",children:"Remove logo"}):(0,U.jsxs)(Se,{onClick:c=>{c.preventDefault(),n.current&&(n.current.value="",n.current.click())},className:"courier-w-full",variant:"outline",type:"button",children:[(0,U.jsx)(J5.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-mr-2 courier-text-foreground"}),"Upload logo"]}),(0,U.jsx)("input",{ref:n,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:async c=>{var d;let u=(d=c.target.files)==null?void 0:d[0];if(u)try{let{dataUrl:m}=await es(u,800),p=i.getValues();p.logo=m,i.reset(p),t({...p})}catch(m){console.error("Error processing image:",m)}n.current&&(n.current.value="")}})]}),(0,U.jsx)(j,{control:i.control,name:"link",render:({field:c})=>(0,U.jsxs)(q,{className:"courier-mb-3",children:[(0,U.jsx)(J,{children:(0,U.jsx)(tn,{as:"Textarea",placeholder:"Link",...c,onChange:u=>{c.onChange(u),a()}})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(ce,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Brand color"}),(0,U.jsx)(j,{control:i.control,name:"brandColor",render:({field:c})=>(0,U.jsxs)(q,{className:"courier-mb-4",children:[(0,U.jsx)(J,{children:(0,U.jsx)(xt,{...c,defaultValue:c.value,onChange:u=>{c.onChange(u),a()}})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(ce,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer links"}),(0,U.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-3 courier-mb-3",children:[(0,U.jsx)(j,{control:i.control,name:"facebookLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(Yi,{}),placeholder:"facebook.com/username",...c,autoFocus:!0})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(j,{control:i.control,name:"linkedinLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(ea,{}),placeholder:"linkedin.com/username",...c})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(j,{control:i.control,name:"instagramLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(Qi,{}),placeholder:"instagram.com/username",...c})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(j,{control:i.control,name:"mediumLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(ta,{}),placeholder:"medium.com/username",...c})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(j,{control:i.control,name:"xLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(aa,{}),placeholder:"x.com/username",...c})}),(0,U.jsx)(G,{})]})})]}),(0,U.jsx)(ce,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer actions"}),(0,U.jsx)(j,{control:i.control,name:"isPreferences",render:({field:c})=>(0,U.jsxs)(q,{className:"courier-flex courier-flex-row courier-items-center courier-gap-2 courier-mb-4",children:[(0,U.jsx)(J,{children:(0,U.jsx)(Xn,{checked:c.value,onCheckedChange:u=>{i.setValue("isPreferences",u),c.onChange(u),l(u);let d={...i.getValues(),isPreferences:u};t(d)}})}),(0,U.jsx)(ao,{className:"!courier-m-0",children:"Manage Preferences"}),(0,U.jsx)(G,{})]})})]})})})},"SideBarComponent"),G5=(0,Lo.memo)(Hb);var Re=require("react/jsx-runtime"),Bb=(0,Ro.forwardRef)(({hidePublish:e=!1,templateEditor:t,variables:r},o)=>{var P,M,T,R,E,C,x,w;let n=(0,Sr.useSetAtom)(ii),{publishBrand:i}=$n(),a=(0,Sr.useAtomValue)(nt),l=(0,Sr.useAtomValue)(Ut),c=(0,Sr.useAtomValue)(bt),u=(0,Sr.useAtomValue)(ae),d=(0,Sr.useAtomValue)(Q),m=(0,Sr.useAtomValue)(zn),[p,f]=(0,Sr.useAtom)(lo),[v,h]=(0,Sr.useAtom)(_r),b=(0,Ro.useCallback)(()=>{i()},[i]),y=(0,Ro.useCallback)(({editor:A})=>{h(Tc(A.getJSON()))},[h]),N=(0,Ro.useCallback)(A=>{f(k=>k?{...k,logo:A}:{...Jt,logo:A})},[f]),g=(0,Ro.useCallback)(()=>{n("template")},[n]);return(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.jsx)("div",{className:"courier-z-30 courier-w-full courier-h-12",children:(0,Re.jsxs)(_5,{children:[(0,Re.jsx)("div",{className:"courier-text-sm courier-font-medium",children:"Brand theme"}),(0,Re.jsxs)("div",{className:"courier-flex courier-gap-2 courier-items-center",children:[c!==null&&(0,Re.jsx)(ni,{isLoading:!!u,isSaving:!!c,isError:!!d}),t&&(0,Re.jsx)(Se,{variant:"outline",buttonSize:"small",onClick:g,disabled:l===!0||c===!0,children:"Back"}),!e&&u!==null&&(0,Re.jsx)(Se,{variant:"primary",buttonSize:"small",disabled:!((M=(P=a==null?void 0:a.data)==null?void 0:P.tenant)!=null&&M.brand)||l===!0||c!==!1,onClick:b,children:l?"Publishing...":"Publish changes"})]})]})}),(0,Re.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,Re.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Re.jsxs)("div",{className:"courier-editor-container",ref:o,children:[(0,Re.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Header"}),(0,Re.jsxs)("div",{className:I("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-py-5 courier-px-9 courier-mb-8 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(p==null?void 0:p.headerStyle)==="border"&&"courier-pt-6"),children:[(p==null?void 0:p.headerStyle)==="border"&&(0,Re.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:p.brandColor}}),p!=null&&p.logo?(0,Re.jsx)("img",{src:p.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"}):(0,Re.jsx)($5,{onFileSelect:N})]}),(0,Re.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Footer"}),(0,Re.jsx)("div",{className:"courier-theme-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-pt-3 courier-pb-5 courier-px-9",children:(0,Re.jsx)(ki,{value:v!=null?v:(w=(x=(C=(E=(R=(T=a==null?void 0:a.data)==null?void 0:T.tenant)==null?void 0:R.brand)==null?void 0:E.settings)==null?void 0:C.email)==null?void 0:x.footer)==null?void 0:w.markdown,variables:r,facebookLink:p==null?void 0:p.facebookLink,linkedinLink:p==null?void 0:p.linkedinLink,instagramLink:p==null?void 0:p.instagramLink,mediumLink:p==null?void 0:p.mediumLink,xLink:p==null?void 0:p.xLink,onUpdate:y})})]})}),(0,Re.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,Re.jsx)("div",{className:"courier-p-4 courier-h-full",children:m&&(0,Re.jsx)(G5,{})})})]})]})}),K5=(0,Ro.memo)(Bb);var qd=require("react/jsx-runtime"),Db=(0,St.forwardRef)(({hidePublish:e=!1,autoSaveDebounce:t=500,autoSave:r=!0,theme:o,colorScheme:n,...i},a)=>{let l=(0,go.useAtomValue)(ae),c=(0,St.useRef)(!0),u=(0,go.useAtomValue)(ht),{getTemplate:d,saveBrand:m}=$n(),[p,f]=(0,go.useAtom)(nt),v=(0,go.useSetAtom)(_r),h=(0,go.useAtomValue)(_r),[b,y]=(0,go.useAtom)(lo),N=(0,St.useRef)(!1),g=(0,go.useSetAtom)(Q);(0,St.useEffect)(()=>{var R,E;p&&u!==((E=(R=p==null?void 0:p.data)==null?void 0:R.tenant)==null?void 0:E.tenantId)&&(f(null),v(null),c.current=!1)},[p,u,f,v]);let P=(0,St.useCallback)(async R=>{await m(R)},[m]),M=(0,St.useCallback)(()=>{g(no("Error saving theme"))},[g]),{handleAutoSave:T}=Si({onSave:P,enabled:l!==null&&r&&h!==null,debounceMs:t,onError:M});return(0,St.useEffect)(()=>{!u||l||p&&l===!1||d()},[u,d,l,p]),(0,St.useEffect)(()=>{h&&setTimeout(()=>{N.current=!0},500)},[h]),(0,St.useEffect)(()=>{if(!N.current||!b)return;let R={colors:{primary:b==null?void 0:b.brandColor,secondary:b==null?void 0:b.textColor,tertiary:b==null?void 0:b.subtleColor},email:{header:{barColor:(b==null?void 0:b.headerStyle)==="border"?b==null?void 0:b.brandColor:"",logo:{href:b==null?void 0:b.link,image:b==null?void 0:b.logo}},footer:{markdown:h!=null?h:void 0,social:{facebook:{url:b==null?void 0:b.facebookLink},instagram:{url:b==null?void 0:b.instagramLink},linkedin:{url:b==null?void 0:b.linkedinLink},medium:{url:b==null?void 0:b.mediumLink},twitter:{url:b==null?void 0:b.xLink}}}}};T(R)},[b,h,T]),(0,St.useEffect)(()=>{l||(c.current=!1)},[l]),(0,St.useEffect)(()=>{var R,E,C,x,w,A,k,L,S,H,V,F,O,B,z,_,se,re,Y,D,Z,ie,Me,$e,Je,pr,fr,le,De,Ae,Bt,Dt,Ir,Lr,Rr,Hr,Ho,Bo;if(!b){let oe=(C=(E=(R=p==null?void 0:p.data)==null?void 0:R.tenant)==null?void 0:E.brand)==null?void 0:C.settings,ho=(k=h==null?void 0:h.split(`
|
|
218
|
+
`))!=null?k:(A=(w=(x=oe==null?void 0:oe.email)==null?void 0:x.footer)==null?void 0:w.markdown)==null?void 0:A.split(`
|
|
219
|
+
`),cn=ho==null?void 0:ho.find(un=>un.includes("{{urls.preferences}}"));y({brandColor:((L=oe==null?void 0:oe.colors)==null?void 0:L.primary)||Jt.brandColor,textColor:((S=oe==null?void 0:oe.colors)==null?void 0:S.secondary)||Jt.textColor,subtleColor:((H=oe==null?void 0:oe.colors)==null?void 0:H.tertiary)||Jt.subtleColor,headerStyle:(F=(V=oe==null?void 0:oe.email)==null?void 0:V.header)!=null&&F.barColor?"border":"plain",logo:((z=(B=(O=oe==null?void 0:oe.email)==null?void 0:O.header)==null?void 0:B.logo)==null?void 0:z.image)||Jt.logo,link:((re=(se=(_=oe==null?void 0:oe.email)==null?void 0:_.header)==null?void 0:se.logo)==null?void 0:re.href)||Jt.link,facebookLink:((ie=(Z=(D=(Y=oe==null?void 0:oe.email)==null?void 0:Y.footer)==null?void 0:D.social)==null?void 0:Z.facebook)==null?void 0:ie.url)||Jt.facebookLink,linkedinLink:((pr=(Je=($e=(Me=oe==null?void 0:oe.email)==null?void 0:Me.footer)==null?void 0:$e.social)==null?void 0:Je.linkedin)==null?void 0:pr.url)||Jt.linkedinLink,instagramLink:((Ae=(De=(le=(fr=oe==null?void 0:oe.email)==null?void 0:fr.footer)==null?void 0:le.social)==null?void 0:De.instagram)==null?void 0:Ae.url)||Jt.instagramLink,mediumLink:((Lr=(Ir=(Dt=(Bt=oe==null?void 0:oe.email)==null?void 0:Bt.footer)==null?void 0:Dt.social)==null?void 0:Ir.medium)==null?void 0:Lr.url)||Jt.mediumLink,xLink:((Bo=(Ho=(Hr=(Rr=oe==null?void 0:oe.email)==null?void 0:Rr.footer)==null?void 0:Hr.social)==null?void 0:Ho.twitter)==null?void 0:Bo.url)||Jt.xLink,isPreferences:!!cn})}},[p,y,h,b]),(0,qd.jsx)(Xt,{theme:o,colorScheme:n,isLoading:!!(l&&c.current),children:(0,qd.jsx)(K5,{ref:a,hidePublish:e,...i})})}),Jd=(0,St.memo)(Db);var ln=require("react/jsx-runtime"),Y5=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:["slack","email","sms","push","inbox"]},"resolveChannels"),Fb=s(({theme:e,value:t=null,onChange:r,variables:o,hidePublish:n=!1,autoSave:i=!0,autoSaveDebounce:a=500,brandEditor:l=!1,brandProps:c,channels:u,routing:d,colorScheme:m,...p})=>{let{store:f}=Un(),v=(0,ot.useAtomValue)(ae),h=(0,ot.useAtomValue)(Ut),b=(0,ot.useAtomValue)(Q),[y,N]=(0,ot.useAtom)(nt),g=(0,ot.useAtomValue)(Fr),P=(0,ot.useAtomValue)(ht),[M,T]=(0,ot.useAtom)(dn),{getTemplate:R,saveTemplate:E,setTemplateError:C}=Zn(),x=(0,ot.useAtomValue)(ii),w=(0,Ie.useRef)(!1),[A,k]=(0,ot.useAtom)(ee),[L,S]=(0,ot.useAtom)(Ct);(0,Ie.useEffect)(()=>{typeof window!="undefined"&&window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.templateEditorContent=A)},[A]);let H=(0,ot.useSetAtom)(_r),V=(0,ot.useSetAtom)(lo),[F,O]=(0,ot.useAtom)(Uo),B=(0,ot.useSetAtom)(ae),z=Y5(d,u),[_,se]=(0,Ie.useState)(z),re=(0,Ie.useRef)(JSON.stringify(z));(0,Ie.useEffect)(()=>{let le=Y5(d,u),De=JSON.stringify(le);De!==re.current&&(se(le),re.current=De,le.length&&!le.includes(F)&&O(le[0]))},[d,u,F,O]),(0,Ie.useEffect)(()=>{var De;if(v||!(A!=null&&A.elements))return;let le=A.elements.filter(Ae=>Ae.type==="channel").map(Ae=>Ae.channel);if(!le.includes(F)){let Ae=(De=d==null?void 0:d.channels)==null?void 0:De.find(Bt=>le.includes(Bt));!Ae&&le.length>0&&(Ae=le[0]),Ae&&O(Ae)}},[A,F,O,d==null?void 0:d.channels,v]),(0,Ie.useEffect)(()=>{var De;let le=(De=y==null?void 0:y.data)==null?void 0:De.tenant;g&&le&&!(le!=null&&le.notification)&&v===!1&&(_!=null&&_.length)&&O(_[0])},[g,y,v,_,O]);let Y=(0,Ie.useRef)(null);(0,Ie.useEffect)(()=>{Y.current&&(Y.current.templateId!==g||Y.current.tenantId!==P)&&g&&P&&(S(!0),w.current=!1,N(null),k(null),H(null),V(null),T(null),O((_==null?void 0:_[0])||"email"),B(null)),g&&P&&(Y.current={templateId:g,tenantId:P})},[g,P,_,S,N,k,H,V,T,O,B]);let D=(0,Ie.useRef)(d);(0,Ie.useEffect)(()=>{D.current=d},[d]);let Z=(0,Ie.useCallback)(async le=>{let De=le==null?void 0:le._capturedTemplateId,Ae=f.get(Fr);if(De&&De!==Ae)return;let{_capturedTemplateId:Bt,...Dt}=le;await E({routing:D.current,content:Dt})},[E,f]),ie=(0,Ie.useCallback)(()=>{C("Error saving template")},[C]),Me=(0,ot.useAtomValue)(pn),$e=(0,Ie.useCallback)(()=>{nm(Me)},[Me]),{handleAutoSave:Je}=Si({onSave:Z,debounceMs:a,enabled:v===!1&&i,onError:ie,flushBeforeSave:$e});(0,Ie.useEffect)(()=>{!g||!P||v||y&&v===!1||b||R({includeBrand:l})},[g,P,l,R,v,y,b]),(0,Ie.useEffect)(()=>{if(!(!t||i&&v!==!1)&&JSON.stringify(de(Ze(A)))!==JSON.stringify(de(Ze(t))))if(k(t),!i)B(!1);else{let le={...t,_capturedTemplateId:g};Je(le)}},[i,t,A,k,B,Je,g,v]),(0,Ie.useEffect)(()=>{var Ae,Bt,Dt,Ir,Lr,Rr,Hr;if(v!==!1)return;let le=(Dt=(Bt=(Ae=y==null?void 0:y.data)==null?void 0:Ae.tenant)==null?void 0:Bt.notification)==null?void 0:Dt.notificationId;if(y&&le&&le!==g)return;let De=t||((Hr=(Rr=(Lr=(Ir=y==null?void 0:y.data)==null?void 0:Ir.tenant)==null?void 0:Lr.notification)==null?void 0:Rr.data)==null?void 0:Hr.content);k(De),setTimeout(()=>{S(!1)},100)},[y,k,v,S,g,t]),(0,Ie.useEffect)(()=>{h===!0&&(w.current=!1)},[h]),(0,Ie.useEffect)(()=>{!A||v!==!1||setTimeout(()=>{w.current=!0},1e3)},[A,F,v]),(0,Ie.useEffect)(()=>{w.current=!1},[F]);let pr=(0,ot.useAtomValue)(je),fr=(0,ot.useAtomValue)(om);if((0,Ie.useEffect)(()=>{let le=!!pr&&v===!1&&!L,De=w.current&&!!A&&v===!1&&!L;if(!le&&!De)return;let Ae=pr||A;if(!Ae||JSON.stringify(Ae)===fr)return;let Dt={...Ae,_capturedTemplateId:g};r&&(w.current=!1,r(A||Ae)),Je(Dt)},[A,pr,Je,v,L,g,r,fr]),l&&x==="brand")return(0,ln.jsx)(Jd,{hidePublish:n,autoSave:i,templateEditor:!0,variables:o,theme:e,colorScheme:m,...c});if(x==="template"&&F==="email")return(0,ln.jsx)(zg,{variables:o,theme:e,colorScheme:m,isLoading:!!v,hidePublish:n,channels:_,brandEditor:l,routing:d,...p});if(x==="template"&&F==="sms")return(0,ln.jsx)(N5,{colorScheme:m,variables:o,theme:e,hidePublish:n,channels:_,routing:d,...p});if(x==="template"&&F==="push")return(0,ln.jsx)(a5,{variables:o,theme:e,colorScheme:m,hidePublish:n,channels:_,routing:d,...p});if(x==="template"&&F==="inbox")return(0,ln.jsx)(Qg,{variables:o,theme:e,colorScheme:m,hidePublish:n,channels:_,routing:d,...p});if(x==="template"&&F==="slack")return(0,ln.jsx)(C5,{theme:e,colorScheme:m,hidePublish:n,channels:_,routing:d,variables:o,...p});if(x==="template"&&F==="msteams")return(0,ln.jsx)(D5,{theme:e,colorScheme:m,hidePublish:n,channels:_,routing:d,variables:o,...p})},"TemplateEditorComponent"),Vb=(0,Ie.memo)(Fb);var Ob=Ul,Ub=fc,Wb=nc,_b=ec,zb=bc,$b=lc;
|
|
222
220
|
//# sourceMappingURL=index.js.map
|