@trycourier/react-designer 0.0.0-canary-20251210123137 → 0.0.0-canary-20251210150148
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 +22 -22
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/styles.css +1 -1
- package/dist/esm/index.js +31 -31
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/styles.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/esm/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
|
-
var
|
|
46
|
+
var ig=Object.create;var Os=Object.defineProperty;var ag=Object.getOwnPropertyDescriptor;var sg=Object.getOwnPropertyNames;var lg=Object.getPrototypeOf,cg=Object.prototype.hasOwnProperty;var s=(e,t)=>Os(e,"name",{value:t,configurable:!0});var Us=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ug=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of sg(t))!cg.call(e,n)&&n!==r&&Os(e,n,{get:()=>t[n],enumerable:!(o=ag(t,n))||o.enumerable});return e};var Ui=(e,t,r)=>(r=e!=null?ig(lg(e)):{},ug(t||!e||!e.__esModule?Os(r,"default",{value:e,enumerable:!0}):r,e));var $l=Us(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});da.bind=void 0;function Q5(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(Q5,"bind");da.bind=Q5});var cm=Us(Ko=>{"use strict";var Go=Ko&&Ko.__assign||function(){return Go=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},Go.apply(this,arguments)};Object.defineProperty(Ko,"__esModule",{value:!0});Ko.bindAll=void 0;var e2=$l();function lm(e){if(typeof e!="undefined")return typeof e=="boolean"?{capture:e}:e}s(lm,"toOptions");function t2(e,t){if(t==null)return e;var r=Go(Go({},e),{options:Go(Go({},lm(t)),lm(e.options))});return r}s(t2,"getBinding");function r2(e,t,r){var o=t.map(function(n){var i=t2(n,r);return(0,e2.bind)(e,i)});return s(function(){o.forEach(function(i){return i()})},"unbindAll")}s(r2,"bindAll");Ko.bindAll=r2});var di=Us(Yo=>{"use strict";Object.defineProperty(Yo,"__esModule",{value:!0});Yo.bindAll=Yo.bind=void 0;var o2=$l();Object.defineProperty(Yo,"bind",{enumerable:!0,get:function(){return o2.bind}});var n2=cm();Object.defineProperty(Yo,"bindAll",{enumerable:!0,get:function(){return n2.bindAll}})});import{Provider as dg,useAtom as Ws,createStore as mg}from"jotai";import{useEffect as pg,memo as fg,useMemo as gg}from"react";import{atom as Qt}from"jotai";var ut=Qt("https://api.courier.com/client/q"),dt=Qt(""),je=Qt(""),er=Qt(""),Fe=Qt(null),ae=Qt(null),Ge=Qt(null),mt=Qt(null),Q=Qt(null),Lu=Qt(!0);import{Fragment as Cg,jsx as _s}from"react/jsx-runtime";var hg=s(({children:e,tenantId:t,token:r,apiUrl:o})=>{let[,n]=Ws(ut),[,i]=Ws(dt),[,a]=Ws(je);return pg(()=>{i(r),a(t),o&&n(o)},[r,t,o,n,i,a]),_s(Cg,{children:e})},"BrandProviderContext"),bg=s(e=>{let t=gg(()=>mg(),[]);return _s(dg,{store:t,children:_s(hg,{...e})})},"BrandProviderComponent"),yg=fg(bg);import{Provider as vg,useAtom as Rn,createStore as xg,useStore as Tg}from"jotai";import{createContext as Eg,memo as wg,useContext as kg,useEffect as Ru,useMemo as Pg}from"react";import{toast as Ng}from"sonner";import{jsx as zs}from"react/jsx-runtime";var Hn=s(()=>({store:Tg()}),"useTemplateStore"),Hu=Eg(null),Bu=s(()=>kg(Hu),"useUploadImage"),Mg=s(({children:e,templateId:t,tenantId:r,token:o,apiUrl:n,uploadImage:i})=>{let[,a]=Rn(ut),[,l]=Rn(dt),[,c]=Rn(je),[,u]=Rn(er),[d]=Rn(Q);return Ru(()=>{l(o),c(r),u(t),n&&a(n)},[o,r,t,n,a,l,c,u]),Ru(()=>{d&&Ng.error(d.message,d.toastProps)},[d]),zs(Hu.Provider,{value:i||null,children:e})},"TemplateProviderContext"),Ag=s(e=>{let t=Pg(()=>xg(),[]);return zs(vg,{store:t,children:zs(Mg,{...e})})},"TemplateProviderComponent"),Sg=wg(Ag);import{useAtom as Dn,useSetAtom as qi}from"jotai";var vr=s((e,t)=>({message:e,toastProps:t}),"createCustomError"),X4=s(e=>{var t;return((t=e.toastProps)==null?void 0:t.action)!==void 0},"isRetryableError"),Q4=s(e=>typeof e=="string"?e:e&&typeof e=="object"&&"message"in e?String(e.message):e instanceof Error?e.message:"Unknown error","extractErrorMessage"),Wi=s(e=>typeof e=="string"?vr(e):e,"convertLegacyError");import{atom as Du}from"jotai";import{toast as Ig}from"sonner";var Fu=Du(null,async(e,t,r)=>{var a;let o=e(ut),n=e(dt),i=e(je);if(!o){t(Q,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(Ge,!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 {
|
|
@@ -64,7 +64,7 @@ var ag=Object.create;var Us=Object.defineProperty;var sg=Object.getOwnPropertyDe
|
|
|
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?Ig.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(mt,!1)}});import{atom as Lg}from"jotai";import{atom as Ke}from"jotai";var ao=Ke(null),Zs=Ke(null),_i=Ke(null),X=Ke(e=>e(_i),(e,t,r)=>{if(!r){t(_i,r);return}let o=e(Zs),n=r;if(o)try{n=o(r)}catch(a){console.error("[ContentTransformer] Error applying transformer:",a),n=r}let i=e(_i);JSON.stringify(i)!==JSON.stringify(n)&&t(_i,n)}),Uo=Ke(null),Wo=Ke(null),Te=Ke(null),_o=Ke(null),ze=Ke(!1),tr=Ke(!1),so=Ke({}),pt=Ke(!1),Ae=Ke(null),Ou=Ke(null),$s=Ke(new Map),lo=Ke(e=>e($s),(e,t,r)=>{let o=new Map(e($s));r.action==="register"&&r.fn?o.set(r.id,r.fn):r.action==="unregister"&&o.delete(r.id),t($s,o)}),Uu=s(e=>{e.forEach(t=>{try{t()}catch(r){console.error("[FlushPendingUpdates] Error flushing updates:",r)}})},"flushAllPendingUpdates");var zi=Lg(null,async(e,t,r)=>{var c,u,d,m,p;let o=e(ut),n=e(dt),i=e(je),a=e(er),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
|
|
@@ -123,11 +123,11 @@ var ag=Object.create;var Us=Object.defineProperty;var sg=Object.getOwnPropertyDe
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
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(Fe,v),t(Uo,(d=b==null?void 0:b.notification)==null?void 0:d.publishedAt),t(Wo,(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)}});import{atom as $u}from"jotai";import{toast as
|
|
127
|
-
`}]};if(t==="inbox"){let i=
|
|
126
|
+
`),toastProps:{duration:4e3}})}}catch{t(Q,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to fetch template data"}})}finally{t(ae,!1)}});import{atom as $u}from"jotai";import{toast as Hg}from"sonner";function qs(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(qs,"cleanInboxElements");function Wu(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}s(Wu,"cleanPushElements");function $i(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}s($i,"cleanSMSElements");function _u(e){return{...e,elements:e.elements.map(t=>t.type==="channel"&&t.channel==="inbox"&&t.elements?{...t,elements:qs(t.elements)}:t)}}s(_u,"cleanTemplateContent");function zu(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(zu,"getSubjectStorageFormat");function $t(e,t,r,o){let n=zu(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=Wu(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=Rg(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
|
-
`},p=
|
|
130
|
-
`)return r}return null}s(
|
|
129
|
+
`},p=qs(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($t,"createTitleUpdate");function Rg(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(Rg,"extractTitleFromFirstElement");function Bn(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
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(Bn,"extractCurrentTitle");var Zi=$u(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(ut),a=e(dt),l=e(je),c=e(er),u=n||e(X);if(!u)return;let d=_u(u);if(!i){t(Q,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(Ge,!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 {
|
|
@@ -154,7 +154,7 @@ var ag=Object.create;var Us=Object.defineProperty;var sg=Object.getOwnPropertyDe
|
|
|
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?(Hg.success("Template published"),t(Uo,new Date().toISOString()),t(Wo,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(mt,!1)}});function Fn(){Hn();let e=qi(zi),t=qi(Fu),r=qi(Zi),o=qi(Vu),[n,i]=Dn(ae),[a,l]=Dn(Ge),[c,u]=Dn(mt),[d,m]=Dn(Q),[p,f]=Dn(Fe);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"?vr(h):h)},"setTemplateError"),templateData:p,setTemplateData:f,createCustomError:vr,convertLegacyError:Wi}}s(Fn,"useBrandActions");import{useAtom as co,useSetAtom as Js}from"jotai";import{useCallback as Bg}from"react";function Vn(){let e=Js(zi),t=Js(Zi),r=Js(Zu),[o,n]=co(ae),[i,a]=co(Ge),[l,c]=co(mt),[u,d]=co(Q),[m,p]=co(Fe),[f,v]=co(X),[h,b]=co(Zs),y=Bg(N=>{d(N===null?null:typeof N=="string"?vr(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:vr,convertLegacyError:Wi,contentTransformer:h,setContentTransformer:b}}s(Vn,"useTemplateActions");import{useAtom as Ju}from"jotai";import{useCallback as Fg}from"react";var Dg=["image/png","image/jpeg","image/gif","image/webp"],qu=s(async(e,t)=>{var c,u,d;let{apiUrl:r,token:o}=t;if(!Dg.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 {
|
|
@@ -165,39 +165,39 @@ var ag=Object.create;var Us=Object.defineProperty;var sg=Object.getOwnPropertyDe
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
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 On(){let[e]=Ju(ut),[t]=Ju(dt),r=Bu();return{uploadImage:
|
|
169
|
-
`);for(let o=0;o<r.length;o++)
|
|
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 On(){let[e]=Ju(ut),[t]=Ju(dt),r=Bu();return{uploadImage:Fg(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 qu(i,{apiUrl:e,token:t});if(!a)throw new Error("Upload failed: No URL returned from server");return{url:a}}},[e,t,r])}}s(On,"useImageUpload");import{clsx as _g}from"clsx";import{twMerge as zg}from"tailwind-merge";import{v4 as Rt}from"uuid";function $e(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($e,"isValidVariableName");var Vg="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function Ji(e){return e?e===Vg:!0}s(Ji,"isBlankImageSrc");var ji=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 ju(e){let t=[],r=e.replace(/\n$/,"").split(`
|
|
169
|
+
`);for(let o=0;o<r.length;o++)Og(r[o],t),o<r.length-1&&t.push({type:"hardBreak"});return t}s(ju,"parseMDContent");function Og(e,t){js(e,t)}s(Og,"parseTextLine");function js(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();$e(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&&Gs(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=[];js(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=[];js(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&&Gs(u,[],a)}t.push(...a)}s(js,"processMarkdownFormatting");function Gs(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&&$e(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(Gs,"parseTextWithVariables");function Se(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 k=g;if(n){if(k.channel===n){i=k;break}}else{i=k;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
|
|
171
|
+
`}],!o||o.length===0)return r;let l=s(g=>{var k,A,E,L,w,C,T,x,P;if(g.type==="meta")return[];switch(g.type){case"text":if("content"in g){let M=g.text_style==="h1"?1:g.text_style==="h2"?2:null,R={};if(g.padding){let[V,F]=g.padding.replace(/px/g,"").split(" "),O=parseInt(V),B=parseInt(F);!isNaN(O)&&!isNaN(B)&&(R={paddingVertical:O,paddingHorizontal:B})}let I={};if(g.border_size||(k=g.border)!=null&&k.enabled||(A=g.border)!=null&&A.size){let V=g.border_size||((E=g.border)==null?void 0:E.size),F=g.border_color||((L=g.border)==null?void 0:L.color);I={...V&&{borderWidth:parseInt(V)},...F&&{borderColor:F}}}let H=g.content.trim()?ju(g.content):[];return[{type:M?"heading":"paragraph",attrs:{textAlign:g.align||"left",level:M,id:`node-${Rt()}`,...R,...I,...g.background_color&&{backgroundColor:g.background_color},...g.locales&&{locales:g.locales}},content:H}]}return[];case"action":{let R=n==="inbox"?{backgroundColor:"#000000",textColor:"#ffffff",borderColor:"transparent",borderWidth:1,borderRadius:4}:{},I=g.content||"Button",H=[];Gs(I,[],H),H.length===0&&H.push({type:"text",text:I||"Button"});let V=(C=g.border_radius)!=null?C:(w=g.border)==null?void 0:w.radius,F=(T=g.border)==null?void 0:T.color,O;return typeof V=="string"?O=parseInt(V):typeof V=="number"&&(O=V),[{type:"button",content:H,attrs:{label:I,link:g.href,alignment:g.align==="full"?"center":g.align||"center",style:g.style,id:`node-${Rt()}`,...R,...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 M="paragraph",R;g.text_style==="h1"?(M="heading",R=1):g.text_style==="h2"?(M="heading",R=2):g.text_style==="subtext"&&(M="heading",R=3);let I={textAlign:g.align||"left",id:`node-${Rt()}`};return R!==void 0&&(I.level=R),[{type:"blockquote",attrs:{textAlign:g.align||"left",id:`node-${Rt()}`,...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:M,attrs:I,content:ju(g.content)}]}]}case"image":{let M={};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);M.width=Math.max(1,Math.min(100,F)),M.imageNaturalWidth=g.image_natural_width}else M.width=V,g.image_natural_width&&(M.imageNaturalWidth=g.image_natural_width)}let R=g.border_size||((x=g.border)==null?void 0:x.size),I=g.border_color||((P=g.border)==null?void 0:P.color);return[{type:"imageBlock",attrs:{sourcePath:Ji(g.src)?"":g.src,id:`node-${Rt()}`,...g.href&&{link:g.href},...g.align&&{alignment:g.align},...g.alt_text&&{alt:g.alt_text},...M,...R&&{borderWidth:parseInt(R),...I&&{borderColor:I}},...g.locales&&{locales:g.locales}}}]}case"divider":{let M=g.border_width||g.width;return[{type:"divider",attrs:{id:`node-${Rt()}`,...g.color&&{color:g.color},...M&&{size:parseInt(M)},...g.padding&&{padding:parseInt(g.padding)},variant:g.color==="transparent"?"spacer":"divider"}}]}case"html":return[{type:"customCode",attrs:{id:`node-${Rt()}`,code:g.content||"<!-- Add your HTML code here -->",...g.locales&&{locales:g.locales}}}];case"group":{let M=g.elements?g.elements.length:2,R=0,I=0;if(g.padding){let U=g.padding.split(" ");R=parseInt(U[0],10)||0,I=parseInt(U[1]||U[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-${Rt()}`,W=g.elements?g.elements.map((U,ie)=>{var z;if(U.type==="text"&&"content"in U&&((z=U.content)==null?void 0:z.trim())==="Drag and drop content blocks"&&U.align==="left")return{type:"columnCell",attrs:{index:ie,columnId:B,isEditorMode:!1},content:[]};let K;U.type==="group"&&U.elements?K=U.elements.flatMap(l):K=l(U);let D=K.length>0?K:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${Rt()}`},content:[]}];return{type:"columnCell",attrs:{index:ie,columnId:B,isEditorMode:K.length>0},content:D}}):[{type:"columnCell",attrs:{index:0,columnId:B,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${Rt()}`},content:[]}]},{type:"columnCell",attrs:{index:1,columnId:B,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${Rt()}`},content:[]}]}];return[{type:"column",attrs:{id:B,columnsCount:Math.min(Math.max(M,1),4),paddingVertical:R,paddingHorizontal:I,backgroundColor:O,borderWidth:H,borderRadius:V,borderColor:F,...g.locales&&{locales:g.locales}},content:[{type:"columnRow",content:W}]}]}default:return[]}},"convertNode"),c=[],u=o.flatMap(l);for(let g=0;g<u.length;g++){let k=u[g],A=u[g+1];if(k.type==="button"&&(A==null?void 0:A.type)==="button"&&n==="inbox"){let E={type:"buttonRow",attrs:{id:`node-${Rt()}`,button1Label:((d=k.attrs)==null?void 0:d.label)||"Button 1",button1Link:((m=k.attrs)==null?void 0:m.link)||"",button1BackgroundColor:((p=k.attrs)==null?void 0:p.backgroundColor)||"#000000",button1TextColor:((f=k.attrs)==null?void 0:f.textColor)||"#ffffff",button2Label:((v=A.attrs)==null?void 0:v.label)||"Button 2",button2Link:((h=A.attrs)==null?void 0:h.link)||"",button2BackgroundColor:((b=A.attrs)==null?void 0:b.backgroundColor)||"#ffffff",button2TextColor:((y=A.attrs)==null?void 0:y.textColor)||"#000000",padding:((N=k.attrs)==null?void 0:N.padding)||6}};c.push(E),g++}else c.push(k)}return{type:"doc",content:c}}s(Se,"convertElementalToTiptap");function Gu(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();$e(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(Gu,"parseTextWithVariables");function Un(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();$e(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&&Gu(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=Un(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=Un(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&&Gu(c,[],i)}return i}s(Un,"processMarkdownFormatting");function Ug(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:Un(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:Un(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:Un(o)})}return t}s(Ug,"parseBlockContent");function Ks(e){return{type:"doc",content:Ug(e)}}s(Ks,"convertMarkdownToTiptap");var Wg=s(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),Gi=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(Wg).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 me(e){let t=s(r=>{var o,n,i,a,l,c,u,d,m,p,f,v,h,b,y,N,g,k,A,E,L,w,C,T,x,P,M,R,I,H,V,F,O,B,W,U,ie,ee,K,D,z,oe,be,Pe,Me,Et,wt,se,Ee,ye,it,at,Ot,Ut,Wt,_t,Fr,Vr,te,Cr,no,io,Nn,Mn,An,Sn,In,Ln;switch(r.type){case"paragraph":{let Y="",re=r.content||[];for(let ke=0;ke<re.length;ke++)re[ke].type==="hardBreak"?Y+=`
|
|
172
172
|
`:Y+=Gi(re[ke]);Y+=`
|
|
173
173
|
`;let de={};(o=r.attrs)!=null&&o.borderWidth&&(de.border_size=`${r.attrs.borderWidth}px`),(n=r.attrs)!=null&&n.borderColor&&(de.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&&(de.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(l=r.attrs)!=null&&l.backgroundColor&&(de.background_color=r.attrs.backgroundColor),de.type="text",de.align=((c=r.attrs)==null?void 0:c.textAlign)||"left",de.content=Y;let he=de;return(u=r.attrs)!=null&&u.locales&&(he.locales=r.attrs.locales),[he]}case"heading":{let Y="",re=r.content||[];for(let ke=0;ke<re.length;ke++)re[ke].type==="hardBreak"?Y+=`
|
|
174
174
|
`:Y+=Gi(re[ke]);Y+=`
|
|
175
175
|
`;let de={};(d=r.attrs)!=null&&d.borderWidth&&(de.border_size=`${r.attrs.borderWidth}px`),(m=r.attrs)!=null&&m.borderColor&&(de.border_color=r.attrs.borderColor),de.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&&(de.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(h=r.attrs)!=null&&h.backgroundColor&&(de.background_color=r.attrs.backgroundColor),de.type="text",de.align=((b=r.attrs)==null?void 0:b.textAlign)||"left",de.content=Y;let he=de;return(y=r.attrs)!=null&&y.locales&&(he.locales=r.attrs.locales),[he]}case"blockquote":{let Y="",re,de;if(r.content)for(let ke of r.content){if(!re){if(ke.type==="heading"){let zt=(N=ke.attrs)==null?void 0:N.level;zt===1?re="h1":zt===2?re="h2":re="subtext"}de=(g=ke.attrs)==null?void 0:g.textAlign}if(ke.content)for(let zt of ke.content)zt.type==="hardBreak"?Y+=`
|
|
176
176
|
`:Y+=Gi(zt);Y+=`
|
|
177
|
-
`}Y=Y.trim();let he={type:"quote",content:Y};return de&&de!=="left"&&(he.align=de),(
|
|
177
|
+
`}Y=Y.trim();let he={type:"quote",content:Y};return de&&de!=="left"&&(he.align=de),(k=r.attrs)!=null&&k.borderColor&&(he.border_color=r.attrs.borderColor),((A=r.attrs)==null?void 0:A.borderLeftWidth)!==void 0&&(he.border_left_width=r.attrs.borderLeftWidth),((E=r.attrs)==null?void 0:E.paddingHorizontal)!==void 0&&(he.padding_horizontal=r.attrs.paddingHorizontal),((L=r.attrs)==null?void 0:L.paddingVertical)!==void 0&&(he.padding_vertical=r.attrs.paddingVertical),(w=r.attrs)!=null&&w.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(he.background_color=r.attrs.backgroundColor),re&&(he.text_style=re),(C=r.attrs)!=null&&C.locales&&(he.locales=r.attrs.locales),[he]}case"imageBlock":{let Y={},re=(T=r.attrs)==null?void 0:T.width,de=(x=r.attrs)==null?void 0:x.imageNaturalWidth;if(re&&de&&de>0){let ke=Math.round(re/100*de);Y.width=`${ke}px`,Y.image_natural_width=de}else re&&(Y.width=`${re}%`);(P=r.attrs)!=null&&P.borderWidth&&(Y.border_size=`${r.attrs.borderWidth}px`),(M=r.attrs)!=null&&M.borderColor&&(Y.border_color=r.attrs.borderColor),Y.type="image",Y.src=((R=r.attrs)==null?void 0:R.sourcePath)||"",(I=r.attrs)!=null&&I.alignment&&(Y.align=r.attrs.alignment),(H=r.attrs)!=null&&H.link&&(Y.href=r.attrs.link),(V=r.attrs)!=null&&V.alt&&(Y.alt_text=r.attrs.alt);let he=Y;return(F=r.attrs)!=null&&F.locales&&(he.locales=r.attrs.locales),[he]}case"divider":{let Y={type:"divider"};return(O=r.attrs)!=null&&O.color&&(Y.color=r.attrs.color),(B=r.attrs)!=null&&B.size&&(Y.border_width=`${r.attrs.size}px`),(W=r.attrs)!=null&&W.padding&&(Y.padding=`${r.attrs.padding}px 0px`),[Y]}case"button":{let Y=(ie=(U=r.attrs)==null?void 0:U.label)!=null?ie:"";r.content&&r.content.length>0&&(Y=r.content.map(Gi).join(""));let re={type:"action",content:Y,href:(K=(ee=r.attrs)==null?void 0:ee.link)!=null?K:"#"};return(D=r.attrs)!=null&&D.style&&(re.style=r.attrs.style),re.align=((z=r.attrs)==null?void 0:z.alignment)||"center",(oe=r.attrs)!=null&&oe.backgroundColor&&(re.background_color=r.attrs.backgroundColor),(be=r.attrs)!=null&&be.padding&&(re.padding=`${r.attrs.padding}px`),(Pe=r.attrs)!=null&&Pe.borderRadius&&(re.border_radius=`${r.attrs.borderRadius}px`),(Me=r.attrs)!=null&&Me.locales&&(re.locales=r.attrs.locales),[re]}case"buttonRow":{let Y={type:"action",content:(wt=(Et=r.attrs)==null?void 0:Et.button1Label)!=null?wt:"Button 1",href:(Ee=(se=r.attrs)==null?void 0:se.button1Link)!=null?Ee:"#",align:"left"};(ye=r.attrs)!=null&&ye.button1BackgroundColor&&(Y.background_color=r.attrs.button1BackgroundColor),(it=r.attrs)!=null&&it.button1TextColor&&(Y.color=r.attrs.button1TextColor);let re={type:"action",content:(Ot=(at=r.attrs)==null?void 0:at.button2Label)!=null?Ot:"Button 2",href:(Wt=(Ut=r.attrs)==null?void 0:Ut.button2Link)!=null?Wt:"#",align:"left"};return(_t=r.attrs)!=null&&_t.button2BackgroundColor&&(re.background_color=r.attrs.button2BackgroundColor),(Fr=r.attrs)!=null&&Fr.button2TextColor&&(re.color=r.attrs.button2TextColor),[Y,re]}case"customCode":{let Y={type:"html",content:((Vr=r.attrs)==null?void 0:Vr.code)||"<!-- Add your HTML code here -->"};return(te=r.attrs)!=null&&te.locales&&(Y.locales=r.attrs.locales),[Y]}case"column":{let Y=((Cr=r.attrs)==null?void 0:Cr.columnsCount)||2,re=[],de=(no=r.content)==null?void 0:no.find(st=>st.type==="columnRow");if(de&&de.content){for(let st of de.content)if(st.type==="columnCell")if(st.content&&st.content.length>0){let Oi=st.content.flatMap(t);Oi.length===0?re.push({type:"text",content:`Drag and drop content blocks
|
|
178
178
|
`,align:"left"}):Oi.length===1?re.push(Oi[0]):re.push({type:"group",elements:Oi})}else re.push({type:"text",content:`Drag and drop content blocks
|
|
179
179
|
`,align:"left"})}else for(let st=0;st<Y;st++)re.push({type:"text",content:`Drag and drop content blocks
|
|
180
|
-
`,align:"left"});let he={type:"group"};if((io=r.attrs)!=null&&io.borderWidth&&r.attrs.borderWidth>0){let st={};(Nn=r.attrs)!=null&&Nn.borderColor&&(st.color=r.attrs.borderColor),st.enabled=!0,st.size=`${r.attrs.borderWidth}px`,(Mn=r.attrs)!=null&&Mn.borderRadius&&(st.radius=r.attrs.borderRadius),he.border=st}let ke=((An=r.attrs)==null?void 0:An.paddingVertical)||0,zt=((Sn=r.attrs)==null?void 0:Sn.paddingHorizontal)||0;return(ke>0||zt>0)&&(he.padding=`${ke}px ${zt}px`),(In=r.attrs)!=null&&In.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(he.background_color=r.attrs.backgroundColor),he.elements=re,(Ln=r.attrs)!=null&&Ln.locales&&(he.locales=r.attrs.locales),[he]}default:return r.content?r.content.flatMap(t):[]}},"convertNode");return e!=null&&e.content?e.content.flatMap(t):[]}s(me,"convertTiptapToElemental");function
|
|
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=Xs(o.elements);if(n)return n}}return r||t||""}s(Xs,"getTitle");function Qs(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 Xs(r.elements)}return""}s(Qs,"getTitleForChannel");function Ve(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(Ve,"updateElemental");function I(...e){return $g(zg(e))}s(I,"cn");import{Slot as Zg}from"@radix-ui/react-slot";import{cva as qg}from"class-variance-authority";import{forwardRef as Jg}from"react";import{jsx as jg}from"react/jsx-runtime";var Ki=qg("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"}]}),Ce=Jg(({active:e,buttonSize:t="medium",disabled:r,variant:o="primary",className:n,asChild:i=!1,...a},l)=>jg(i?Zg:"button",{ref:l,disabled:r,className:I(Ki({variant:o,size:t,disabled:r,active:e}),n),...a}));Ce.displayName="Button";import{forwardRef as Gg}from"react";import{jsx as Kg}from"react/jsx-runtime";var le=Gg((e,t)=>Kg("hr",{...e,ref:t,className:I("courier-my-1 courier-border-border dark:courier-border-neutral-600 courier-w-full",e.className)}));le.displayName="Divider";import*as xr from"react";import*as ce from"@radix-ui/react-dropdown-menu";import{Check as Yg,ChevronRight as Xg,Circle as Qg}from"lucide-react";import{jsx as ft,jsxs as el}from"react/jsx-runtime";var Yi=ce.Root,Xi=ce.Trigger;var e5=xr.forwardRef(({className:e,inset:t,children:r,...o},n)=>el(ce.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,ft(Xg,{className:"courier-ml-auto"})]}));e5.displayName=ce.SubTrigger.displayName;var t5=xr.forwardRef(({className:e,...t},r)=>ft(ce.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}));t5.displayName=ce.SubContent.displayName;var Wn=xr.forwardRef(({className:e,sideOffset:t=4,portalProps:r,...o},n)=>ft(ce.Portal,{...r,children:ft(ce.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})}));Wn.displayName=ce.Content.displayName;var _n=xr.forwardRef(({className:e,inset:t,...r},o)=>ft(ce.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}));_n.displayName=ce.Item.displayName;var r5=xr.forwardRef(({className:e,children:t,checked:r,...o},n)=>el(ce.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:[ft("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:ft(ce.ItemIndicator,{children:ft(Yg,{className:"courier-h-4 courier-w-4"})})}),t]}));r5.displayName=ce.CheckboxItem.displayName;var o5=xr.forwardRef(({className:e,children:t,...r},o)=>el(ce.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:[ft("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:ft(ce.ItemIndicator,{children:ft(Qg,{className:"courier-h-2 courier-w-2 courier-fill-current"})})}),t]}));o5.displayName=ce.RadioItem.displayName;var n5=xr.forwardRef(({className:e,inset:t,...r},o)=>ft(ce.Label,{ref:o,className:I("courier-px-2 courier-py-1.5 courier-text-sm courier-font-semibold",t&&"courier-pl-8",e),...r}));n5.displayName=ce.Label.displayName;var i5=xr.forwardRef(({className:e,...t},r)=>ft(ce.Separator,{ref:r,className:I("courier-mx-1 courier-my-1 courier-h-px courier-bg-muted",e),...t}));i5.displayName=ce.Separator.displayName;var a5=s(({className:e,...t})=>ft("span",{className:I("courier-ml-auto courier-text-xs courier-tracking-widest courier-opacity-60",e),...t}),"DropdownMenuShortcut");a5.displayName="DropdownMenuShortcut";import{Component as s5}from"react";import{jsx as rl,jsxs as c5}from"react/jsx-runtime";var ol=class ol extends s5{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||rl(l5,{error:this.state.error}):this.props.children}};s(ol,"ErrorBoundary");var tl=ol,l5=s(({error:e})=>c5("div",{className:"courier-p-6 courier-border courier-border-red-200 courier-bg-red-50 courier-rounded-lg courier-text-center",children:[rl("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),rl("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");import{Slot as p5}from"@radix-ui/react-slot";import*as gt from"react";import{Controller as f5,FormProvider as g5,useFormContext as h5}from"react-hook-form";import*as nl from"@radix-ui/react-label";import{cva as u5}from"class-variance-authority";import*as Ku from"react";import{jsx as m5}from"react/jsx-runtime";var d5=u5("courier-text-sm courier-font-medium courier-leading-none peer-disabled:courier-cursor-not-allowed peer-disabled:courier-opacity-70"),il=Ku.forwardRef(({className:e,...t},r)=>m5(nl.Root,{ref:r,className:I(d5(),e),...t}));il.displayName=nl.Root.displayName;import{jsx as Or}from"react/jsx-runtime";var Ne=g5,Yu=gt.createContext({}),J=s(({...e})=>Or(Yu.Provider,{value:{name:e.name},children:Or(f5,{...e})}),"FormField"),Qi=s(()=>{let e=gt.useContext(Yu),t=gt.useContext(Xu),{getFieldState:r,formState:o}=h5(),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"),Xu=gt.createContext({}),Z=gt.forwardRef(({className:e,...t},r)=>{let o=gt.useId();return Or(Xu.Provider,{value:{id:o},children:Or("div",{ref:r,className:I("courier-space-y-2",e),...t})})});Z.displayName="FormItem";var rr=gt.forwardRef(({className:e,...t},r)=>{let{error:o,formItemId:n}=Qi();return Or(il,{ref:r,className:I(o&&"courier-text-destructive",e),htmlFor:n,...t})});rr.displayName="FormLabel";var q=gt.forwardRef(({...e},t)=>{let{error:r,formItemId:o,formDescriptionId:n,formMessageId:i}=Qi();return Or(p5,{ref:t,id:o,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...e})});q.displayName="FormControl";var b5=gt.forwardRef(({className:e,...t},r)=>{let{formDescriptionId:o}=Qi();return Or("p",{ref:r,id:o,className:I("courier-text-[0.8rem] courier-text-muted-foreground",e),...t})});b5.displayName="FormDescription";var j=gt.forwardRef(({className:e,children:t,...r},o)=>{let{error:n,formMessageId:i}=Qi(),a=n?String(n==null?void 0:n.message):t;return a?Or("p",{ref:o,id:i,className:I("courier-text-[0.8rem] courier-font-medium courier-text-destructive",e),...r,children:a}):null});j.displayName="FormMessage";import*as we from"@radix-ui/react-alert-dialog";import*as uo from"react";import{useCallback as y5}from"react";import{jsx as or,jsxs as T5}from"react/jsx-runtime";var Qu=we.Root,ed=we.Trigger,C5=we.Portal,td=uo.forwardRef(({className:e,...t},r)=>or("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:or(we.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})}));td.displayName=we.Overlay.displayName;var al=uo.forwardRef(({className:e,...t},r)=>{let o=y5(()=>{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 T5(C5,{container:typeof window!="undefined"?o():void 0,children:[or(td,{}),or(we.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})]})});al.displayName=we.Content.displayName;var sl=s(({className:e,...t})=>or("div",{className:I("courier-flex courier-flex-col courier-space-y-2 courier-text-center sm:courier-text-left",e),...t}),"AlertDialogHeader");sl.displayName="AlertDialogHeader";var ll=s(({className:e,...t})=>or("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");ll.displayName="AlertDialogFooter";var v5=uo.forwardRef(({className:e,...t},r)=>or(we.Title,{ref:r,className:I("courier-text-lg courier-font-semibold",e),...t}));v5.displayName=we.Title.displayName;var x5=uo.forwardRef(({className:e,...t},r)=>or(we.Description,{ref:r,className:I("courier-text-sm courier-text-muted-foreground",e),...t}));x5.displayName=we.Description.displayName;var cl=uo.forwardRef(({className:e,...t},r)=>or(we.Action,{ref:r,className:I(Ki(),e),...t}));cl.displayName=we.Action.displayName;var ul=uo.forwardRef(({className:e,...t},r)=>or(we.Cancel,{ref:r,className:I(Ki({variant:"outline"}),"courier-mt-2 sm:courier-mt-0",e),...t}));ul.displayName=we.Cancel.displayName;import*as rd from"react";import{jsx as dl,jsxs as E5}from"react/jsx-runtime";var pe=rd.forwardRef(({className:e,type:t,startAdornment:r,endAdornment:o,...n},i)=>E5("div",{className:"courier-relative courier-flex courier-w-full courier-items-center",children:[r&&dl("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),dl("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&&dl("div",{className:"courier-absolute courier-right-2 courier-flex courier-items-center courier-pointer-events-none",children:o})]}));pe.displayName="Input";import{forwardRef as N5,useRef as M5,useMemo as A5,useCallback as S5}from"react";import{useCallback as ml,useEffect as od,useRef as ea,useState as nd}from"react";import{CircleX as w5}from"lucide-react";import{jsx as nr,jsxs as id}from"react/jsx-runtime";var k5=s(e=>e==="transparent"||/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e),"isValidHex"),ad=s(({color:e,onChange:t,className:r,presetColors:o,defaultValue:n="transparent"})=>{let[i,a]=nd(()=>zn(e)),[l,c]=nd(e),u=ea(null),d=ea(null),m=ea(null),p=ea(!1),f=e!==n,v=ml(g=>{p.current=!0;let P=P5(g);c(P),t(P),p.current=!1},[t]),h=s(g=>P=>{m.current=g,b(P)},"handleMouseDown"),b=ml(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=ml(()=>{m.current=null},[]);od(()=>{if(m.current)return window.addEventListener("mousemove",b),window.addEventListener("mouseup",y),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",y)}},[b,y]),od(()=>{p.current||(a(zn(e)),c(e))},[e]);let N=s(g=>{let P=g.target.value;if(c(P),k5(P)){let M=zn(P);a(M),v(M)}},"handleInputChange");return id("div",{className:I("w-full",r),children:[nr("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:nr("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}%`}})}),nr("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:nr("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}%`}})}),id("div",{className:"courier-mt-3 courier-relative courier-flex courier-items-center",children:[nr(pe,{value:l,onChange:N,placeholder:"#000000",className:"courier-flex-1"}),f&&nr("button",{onClick:g=>{if(g.preventDefault(),n==="transparent"){t("transparent"),c("transparent"),a({h:0,s:0,v:0});return}let P=zn(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:nr(w5,{size:14,strokeWidth:1.25})})]}),nr(le,{className:"courier-my-3"}),nr("div",{className:"courier-flex courier-flex-wrap courier-gap-1",children:o.map(g=>nr("button",{className:I("courier-h-6 courier-w-6 courier-rounded-md courier-border courier-border-input courier-shrink-0",g==="transparent"&&pl),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=zn(g);a(M),v(M)}},g))})]})},"ColorPicker");function zn(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(zn,"hexToHsv");function P5({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(P5,"hsvToHex");import*as ir from"@radix-ui/react-popover";import*as ld from"react";import{jsx as sd}from"react/jsx-runtime";var cd=ir.Root,ud=ir.Trigger;var fl=ld.forwardRef(({className:e,align:t="center",side:r="bottom",sideOffset:o=4,collisionPadding:n=10,avoidCollisions:i=!0,portalProps:a,...l},c)=>sd(ir.Portal,{...a,children:sd(ir.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})}));fl.displayName=ir.Content.displayName;import{jsx as $n,jsxs as dd}from"react/jsx-runtime";var pl="bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAwSDBWOEg4VjBaIiBmaWxsPSIjRDlEOUQ5Ii8+PHBhdGggZD0iTTE2IDhIOFYxNkgxNlY4WiIgZmlsbD0iI0Q5RDlEOSIvPjwvc3ZnPg==')]",I5=["#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#000000","#525252","#a3a3a3","#ffffff","transparent"],Ze=N5(({className:e,value:t="",onChange:r,defaultValue:o,transparent:n=!0,presetColors:i=I5,...a},l)=>{let c=t!=="transparent",u=M5(null),d=A5(()=>n?i:i.filter(p=>p!=="transparent"),[i,n]),m=S5(()=>{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 dd(cd,{children:[$n(ud,{asChild:!0,children:dd("div",{className:"courier-relative courier-flex courier-items-center",ref:u,children:[$n("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?"":pl),style:{backgroundColor:c?t:void 0}}),$n(pe,{...a,ref:l,readOnly:!0,type:"text",value:t==="transparent"?"Transparent":t,className:I("courier-relative courier-cursor-pointer courier-pl-8",e)})]})}),$n(fl,{portalProps:{container:typeof window!="undefined"?m():void 0},className:"courier-w-[230px]",children:$n(ad,{color:t,onChange:r,presetColors:d,defaultValue:o})})]})});Ze.displayName="InputColor";import*as md from"react";import*as gl from"@radix-ui/react-separator";import{jsx as L5}from"react/jsx-runtime";var hl=md.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>L5(gl.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}));hl.displayName=gl.Root.displayName;import*as pd from"react";import*as Tr from"@radix-ui/react-slider";import{jsx as bl,jsxs as R5}from"react/jsx-runtime";var yl=pd.forwardRef(({className:e,...t},r)=>R5(Tr.Root,{ref:r,className:I("courier-relative courier-flex courier-w-full courier-touch-none courier-select-none courier-items-center",e),...t,children:[bl(Tr.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:bl(Tr.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),bl(Tr.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"})]}));yl.displayName=Tr.Root.displayName;import*as gd from"react";import*as Zn from"@radix-ui/react-switch";import{jsx as fd}from"react/jsx-runtime";var zo=gd.forwardRef(({className:e,...t},r)=>fd(Zn.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:fd(Zn.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")})}));zo.displayName=Zn.Root.displayName;import*as ta from"react";import*as Zt from"@radix-ui/react-tabs";import{jsx as Cl}from"react/jsx-runtime";var ra=Zt.Root,qn=ta.forwardRef(({className:e,...t},r)=>Cl(Zt.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}));qn.displayName=Zt.List.displayName;var $o=ta.forwardRef(({className:e,...t},r)=>Cl(Zt.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}));$o.displayName=Zt.Trigger.displayName;var oa=ta.forwardRef(({className:e,...t},r)=>Cl(Zt.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}));oa.displayName=Zt.Content.displayName;import*as Zo from"react";import{jsx as H5}from"react/jsx-runtime";var vl=Zo.forwardRef(({className:e,autoResize:t=!1,...r},o)=>{let n=Zo.useRef(null),i=s(a=>{n.current=a,typeof o=="function"?o(a):o&&(o.current=a)},"combinedRef");return Zo.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]),H5("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})});vl.displayName="Textarea";import{forwardRef as D5,useContext as F5}from"react";import{createContext as B5}from"react";var na={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"},hd={...na},bd={...na,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 xl=B5(na);import{jsx as yd}from"react/jsx-runtime";var Cd=D5(({children:e,theme:t,colorScheme:r,className:o},n)=>{let i=r!=null?r:"light",a=i==="light"?hd:bd,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 yd(xl.Provider,{value:typeof l=="object"?l:{},children:yd("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})})}),vd=s(()=>F5(xl),"useTheme");import*as xd from"react";import*as Tl from"@radix-ui/react-toggle";import{cva as V5}from"class-variance-authority";import{jsx as U5}from"react/jsx-runtime";var El=V5("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"}}),O5=xd.forwardRef(({className:e,variant:t,size:r,...o},n)=>U5(Tl.Root,{ref:n,className:I(El({variant:t,size:r,className:e})),...o}));O5.displayName=Tl.Root.displayName;import*as qo from"@radix-ui/react-toggle-group";import*as mo from"react";import{jsx as wl}from"react/jsx-runtime";var Td=mo.createContext({size:"default",variant:"default"}),qt=mo.forwardRef(({className:e,variant:t,size:r,children:o,...n},i)=>wl(qo.Root,{ref:i,className:I("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:wl(Td.Provider,{value:{variant:t,size:r},children:o})}));qt.displayName=qo.Root.displayName;var lt=mo.forwardRef(({className:e,children:t,variant:r,size:o,...n},i)=>{let a=mo.useContext(Td);return wl(qo.Item,{ref:i,className:I(El({variant:a.variant||r,size:a.size||o}),e),...n,children:t})});lt.displayName=qo.Item.displayName;import{jsx as kl}from"react/jsx-runtime";var xe=s(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?kl("path",{className:I(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):kl("path",{className:I(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),_=s(({width:e=28,height:t=28,...r})=>kl("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");import{jsx as Pl,jsxs as W5}from"react/jsx-runtime";var Ed=s(({color:e="#000000",width:t=19,height:r=10,...o})=>W5(_,{...o,width:t,height:r,children:[Pl("rect",{opacity:"0.6",x:"0.553621",y:"0.876863",width:"16.4923",height:"7.87692",rx:"1.6",stroke:e,strokeWidth:"0.738462"}),Pl("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),Pl("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");import{jsx as wd}from"react/jsx-runtime";var Jn=s(({color:e="#DC2626",width:t=13,height:r=13,...o})=>wd(_,{...o,fill:"none",width:t,height:r,children:wd("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");import{jsx as kd}from"react/jsx-runtime";var jn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>kd(_,{...n,width:r,height:o,children:kd(xe,{active:t,colorProp:"stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",d:"M1 15V11C1 5.47715 5.47715 1 11 1H15"})}),"BorderRadiusIcon");import{jsx as Nl,jsxs as _5}from"react/jsx-runtime";var Er=s(({color:e="#A3A3A3",width:t=16,height:r=16,...o})=>_5(_,{...o,width:t,height:r,children:[Nl("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),Nl("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),Nl("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");import{jsx as Pd}from"react/jsx-runtime";var Ml=s(({color:e,width:t=21,height:r=16,...o})=>Pd(_,{...o,width:t,height:r,children:Pd("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");import{jsx as Nd}from"react/jsx-runtime";var Al=s(({color:e="#171717",width:t=12,height:r=13,...o})=>Nd(_,{...o,fill:"none",width:t,height:r,children:Nd("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");import{jsx as Md}from"react/jsx-runtime";var Sl=s(({color:e="#404040",width:t=20,height:r=15,viewBox:o="0 0 20 15",...n})=>Md(_,{...n,width:t,height:r,viewBox:o,children:Md("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");import{jsx as Ad}from"react/jsx-runtime";var Gn=s(({color:e="#737373",width:t=16,height:r=16,...o})=>Ad(_,{...o,width:t,height:r,children:Ad(xe,{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");import{jsx as Sd}from"react/jsx-runtime";var Kn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Sd(_,{...n,width:r,height:o,children:Sd(xe,{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");import{jsx as Id}from"react/jsx-runtime";var Il=s(({color:e="#737373",width:t=14,height:r=16,...o})=>Id(_,{...o,width:t,height:r,children:Id(xe,{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");import{jsx as Ld}from"react/jsx-runtime";var Yn=s(({color:e="#404040",width:t=24,height:r=24,...o})=>Ld(_,{...o,width:t,height:r,children:Ld("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");import{jsx as Rd}from"react/jsx-runtime";var Xn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Rd(_,{...n,width:r,height:o,children:Rd(xe,{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");import{jsx as Hd}from"react/jsx-runtime";var Qn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Hd(_,{...n,width:r,height:o,children:Hd(xe,{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");import{jsx as Bd}from"react/jsx-runtime";var Ll=s(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 256 239",...n})=>Bd(_,{...n,width:t,height:r,viewBox:o,children:Bd("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");import{jsx as Dd}from"react/jsx-runtime";var ei=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Dd(_,{...n,width:r,height:o,children:Dd(xe,{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");import{jsx as Rl}from"react/jsx-runtime";var Hl=s(({color:e,width:t=21,height:r=16,...o})=>Rl(_,{...o,width:t,height:r,children:Rl("g",{transform:"translate(4, 0)",children:Rl("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");import{jsx as Fd}from"react/jsx-runtime";var Bl=s(({color:e="#737373",width:t=14,height:r=16,...o})=>Fd(_,{...o,width:t,height:r,children:Fd(xe,{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");import{jsx as Vd}from"react/jsx-runtime";var ti=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Vd(_,{...n,width:r,height:o,children:Vd(xe,{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");import{jsx as Od}from"react/jsx-runtime";var po=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Od(_,{...n,width:r,height:o,children:Od(xe,{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");import{jsx as Ud,jsxs as z5}from"react/jsx-runtime";var Dl=s(({width:e=20,height:t=21,viewBox:r="0 0 20 21",...o})=>z5(_,{...o,width:e,height:t,viewBox:r,children:[Ud("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"}),Ud("circle",{cx:"2",cy:"2",r:"3",transform:"matrix(-1 0 0 1 17.75 2)",fill:"currentColor",stroke:"white",strokeWidth:"2"})]}),"PushIcon");import{jsx as Wd}from"react/jsx-runtime";var Fl=s(({color:e="#171717",width:t=16,height:r=13,...o})=>Wd(_,{...o,fill:"none",width:t,height:r,children:Wd("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");import{jsx as _d}from"react/jsx-runtime";var Vl=s(({color:e="#171717",width:t=11,height:r=12,...o})=>_d(_,{...o,width:t,height:r,children:_d(xe,{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");import{jsx as zd}from"react/jsx-runtime";var Ol=s(({color:e="#404040",width:t=24,height:r=24,...o})=>zd(_,{...o,width:t,height:r,children:zd("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");import{jsx as ri,jsxs as $5}from"react/jsx-runtime";var $d=s(({color:e="#000000",width:t=14,height:r=9,...o})=>ri(_,{...o,width:t,height:r,children:$5("g",{opacity:"0.9",children:[ri("rect",{x:"0.799805",y:"5.92188",width:"2.46154",height:"2.95385",rx:"0.246154",fill:e}),ri("rect",{x:"4.24609",y:"4.44531",width:"2.46154",height:"4.43077",rx:"0.246154",fill:e}),ri("rect",{x:"7.93823",y:"2.72266",width:"2.46154",height:"6.15385",rx:"0.246154",fill:e}),ri("rect",{x:"11.3845",y:"0.753906",width:"2.46154",height:"8.12308",rx:"0.246154",fill:e})]})}),"SignalIcon");import{jsx as Zd}from"react/jsx-runtime";var Ul=s(({color:e="#404040",width:t=16,height:r=16,...o})=>Zd(_,{...o,width:t,height:r,children:Zd("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");import{jsx as qd}from"react/jsx-runtime";var oi=s(({color:e="#FFFFFF",width:t=24,height:r=24,...o})=>qd(_,{...o,width:t,height:r,viewBox:"0 0 24 24",children:qd("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");import{jsx as Jd}from"react/jsx-runtime";var ni=s(({color:e="#A3A3A3",width:t=24,height:r=24,...o})=>Jd(_,{...o,width:t,height:r,children:Jd(xe,{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");import{jsx as jd}from"react/jsx-runtime";var Gd=s(({width:e=24,height:t=20,...r})=>jd(_,{...r,width:e,height:t,viewBox:"0 0 24 20",children:jd("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");import{jsx as ia,jsxs as Z5}from"react/jsx-runtime";var Kd=s(({color:e="#000000",width:t=14,height:r=10,...o})=>ia(_,{...o,width:t,height:r,children:Z5("g",{opacity:"0.9",children:[ia("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}),ia("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}),ia("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");import{jsx as Yd}from"react/jsx-runtime";var ii=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Yd(_,{...n,width:r,height:o,children:Yd(xe,{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");import{CircleCheck as q5}from"lucide-react";import{useEffect as J5,useState as j5,useRef as Xd}from"react";import{jsx as Wl}from"react/jsx-runtime";var fo=s(({className:e})=>Wl("div",{className:I("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:Wl("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:Wl("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");import{jsx as _l,jsxs as Qd}from"react/jsx-runtime";var ai=s(({isError:e,isSaving:t,isLoading:r,renderIsSaving:o,renderIsError:n,renderSaved:i})=>{let[a,l]=j5(!1),c=Xd(t),u=Xd(null);return J5(()=>(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):Qd("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[_l(fo,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):_l("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):Qd("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[_l(q5,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Saved"]}):null},"Status");import{atom as em}from"jotai";import{jsx as Jo}from"react/jsx-runtime";var go=[{label:"Email",value:"email",icon:Jo(Sl,{})},{label:"SMS",value:"sms",icon:Jo(Ol,{})},{label:"Push",value:"push",icon:Jo(Dl,{})},{label:"In-app",value:"inbox",icon:Jo(Yn,{})},{label:"Slack",value:"slack",icon:Jo(Ul,{})},{label:"Teams",value:"msteams",icon:Jo(Ll,{})}];var Ur=em("email"),jo=em("template");import{AlertDialogDescription as t4}from"@radix-ui/react-alert-dialog";import{useAtom as r4,useAtomValue as Ds,useSetAtom as o4}from"jotai";import{useCallback as Bi,useEffect as n4,useRef as i4}from"react";import{atom as kt}from"jotai";var zl={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"}},aa=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 G5={paragraph:zl,heading:zl},si=kt(G5),ge=kt(null),Re=kt(null,(e,t,r)=>{t(ge,r)}),K5=kt({ref:null,caretPosition:null}),sa=kt({ref:null,caretPosition:null}),li=kt({isFocused:!1,hasVariables:!1,showVariablePopup:!1}),tm=kt(e=>(t,r=!1)=>{let o=e(si),n=e(li),i=aa(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}),rm=kt(null,(e,t,{nodeName:r,config:o})=>{let n=e(si);t(si,{...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"}]))}})}),SE=kt(null,(e,t,r)=>{let o=e(si),{[r]:n,...i}=o;t(si,i)}),om=kt(null,(e,t,{ref:r,caretPosition:o})=>{t(K5,{ref:r,caretPosition:o})}),IE=kt(null,(e,t,r)=>{let o=e(li);t(li,{...o,showVariablePopup:r})}),$l=kt(null),la=kt(null,(e,t,r)=>{t($l,r)});import{useAtom as Y8,useAtomValue as V1,useSetAtom as wu}from"jotai";import{useCallback as O1,useEffect as ku,useMemo as U1,useRef as X8,useState as Q8}from"react";import{atom as nm}from"jotai";var Jt=nm(null),ar=nm(null);import{forwardRef as Y5}from"react";import{Toaster as X5}from"sonner";import{jsx as ci,jsxs as Q5}from"react/jsx-runtime";var ht=Y5(({theme:e,children:t,isLoading:r,Header:o,colorScheme:n,className:i,...a},l)=>ci(Cd,{theme:e,ref:l,colorScheme:n,className:i,children:Q5("div",{...Object.fromEntries(Object.entries(a).filter(([c])=>c!=="variables"&&c!=="brandEditor")),className:"courier-main-layout",children:[o&&ci("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&&ci("div",{className:"courier-editor-loading",children:ci(fo,{})}),ci(X5,{position:"top-center",expand:!0,visibleToasts:2,style:{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)"}}),t]})}));import{useAtom as Bc,useAtomValue as So,useSetAtom as ay}from"jotai";import{forwardRef as sy,memo as ly,useCallback as kf,useEffect as Xr,useMemo as Pf,useRef as Ei,useState as Dc}from"react";function im(e){if(Array.isArray(e))return e}s(im,"_arrayWithHoles");function am(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(am,"_iterableToArrayLimit");function ui(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(ui,"_arrayLikeToArray");function ca(e,t){if(e){if(typeof e=="string")return ui(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)?ui(e,t):void 0}}s(ca,"_unsupportedIterableToArray");function sm(){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(sm,"_nonIterableRest");function ua(e,t){return im(e)||am(e,t)||ca(e,t)||sm()}s(ua,"_slicedToArray");var Zm=Ui(di());var ma="data-pdnd-honey-pot";function pa(e){return e instanceof Element&&e.hasAttribute(ma)}s(pa,"isHoneyPotElement");function fa(e){var t=document.elementsFromPoint(e.x,e.y),r=ua(t,2),o=r[0],n=r[1];return o?pa(o)?n!=null?n:null:o:null}s(fa,"getElementFromPointWithoutHoneypot");function ho(e){"@babel/helpers - typeof";return ho=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},ho(e)}s(ho,"_typeof");function um(e,t){if(ho(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,t||"default");if(ho(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}s(um,"toPrimitive");function dm(e){var t=um(e,"string");return ho(t)=="symbol"?t:t+""}s(dm,"toPropertyKey");function wr(e,t,r){return(t=dm(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}s(wr,"_defineProperty");var pi=Ui(di());var mm=2147483647;function pm(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(pm,"ownKeys");function fm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?pm(Object(r),!0).forEach(function(o){wr(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pm(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(fm,"_objectSpread");var mi=2,gm=mi/2;function
|
|
183
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}s(xm,"_nonIterableSpread");function ga(e){return Cm(e)||vm(e)||ca(e)||xm()}s(ga,"_toConsumableArray");var Sm=Ui(di());function Ht(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(Ht,"once");var Tm=Ht(s(function(){return navigator.userAgent.includes("Firefox")},"isFirefox"));var fi=Ht(s(function(){var t=navigator,r=t.userAgent;return r.includes("AppleWebKit")&&!r.includes("Chrome")},"isSafari"));var Em=Ui(di());var
|
|
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(v2,"_createForOfIteratorHelper");function x2(e,t){if(e){if(typeof e=="string")return Dm(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)?Dm(e,t):void 0}}s(x2,"_unsupportedIterableToArray");function Dm(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(Dm,"_arrayLikeToArray");function Fm(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(Fm,"ownKeys");function T2(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Fm(Object(r),!0).forEach(function(o){wr(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Fm(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(T2,"_objectSpread");function Vm(){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=T2({},i);e.add(a),r(a);function l(){e.delete(a),t&&t.active.delete(a)}return s(l,"cleanup"),Ht(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=v2(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(Vm,"makeMonitor");function Om(e){var t=e.typeKey,r=e.mount,o=e.dispatchEventToSource,n=e.onPostDispatch,i=e.defaultDropEffect,a=Vm(),l=Bm({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;Kl.start({event:p,dragType:f,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}s(u,"start");function d(){function m(){var p={canStart:Kl.canStart,start:u};return r(p)}return s(m,"mountAdapter"),Lm({typeKey:t,mount:m})}return s(d,"registerUsage"),{registerUsage:d,dropTarget:l.dropTargetForConsumers,monitor:a.monitorForConsumers}}s(Om,"makeAdapter");var Um=Ht(s(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")},"isAndroid")),Wm="pdnd:android-fallback";var ec="text/plain";var _m="text/uri-list";var zm="application/vnd.pdnd";var ya=new WeakMap;function E2(e){return ya.set(e.element,e),s(function(){ya.delete(e.element)},"cleanup")}s(E2,"addToRegistry");var $m=ym(),tc=Om({typeKey:"element",defaultDropEffect:"move",mount:s(function(t){return sr($m.bindEvents(),(0,Zm.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=ya.get(d);if(m){var p=bo(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=fa({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=ua(y[b],2),g=N[0],P=N[1];o.dataTransfer.setData(g,P!=null?P:"")}Um()&&!o.dataTransfer.types.includes(ec)&&!o.dataTransfer.types.includes(_m)&&o.dataTransfer.setData(ec,Wm),o.dataTransfer.setData(zm,"");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=ya.get(i.source.element))===null||r===void 0||(o=r[n])===null||o===void 0||o.call(r,i)},"dispatchEventToSource"),onPostDispatch:$m.getOnPostDispatch()}),Pt=tc.dropTarget,rc=tc.monitor;function gi(e){if(0)var t;var r=sr(tc.registerUsage(),E2(e),ba(e.element,{attribute:"draggable",value:"true"}));return Ht(r)}s(gi,"draggable");function qm(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(qm,"ownKeys");function Jm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?qm(Object(r),!0).forEach(function(o){wr(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):qm(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(Jm,"_objectSpread");var w2={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")},jm=Symbol("closestEdge");function Gm(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:w2[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 Jm(Jm({},e),{},wr({},jm,d))}s(Gm,"attachClosestEdge");function hi(e){var t;return(t=e[jm])!==null&&t!==void 0?t:null}s(hi,"extractClosestEdge");import{mergeAttributes as K3,Node as Y3}from"@tiptap/core";import{ReactNodeViewRenderer as X3}from"@tiptap/react";import{NodeViewContent as q3}from"@tiptap/react";import{useSetAtom as J3}from"jotai";import{useCallback as j3}from"react";import{NodeViewWrapper as O3}from"@tiptap/react";import{useSetAtom as U3}from"jotai";import{forwardRef as W3,useCallback as Ao,useEffect as Hc,useState as fs,useRef as Yr}from"react";import{v4 as _3}from"uuid";import{Color as uf}from"@tiptap/extension-color";import{Extension as k2}from"@tiptap/core";import{dropCursor as P2}from"@tiptap/pm/dropcursor";var oc=k2.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[P2(this.options)]}});import{HardBreak as df}from"@tiptap/extension-hard-break";import{Extension as N2}from"@tiptap/core";import{undo as M2,redo as A2,history as S2}from"@tiptap/pm/history";var I2=N2.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>M2(e,t),redo:()=>({state:e,dispatch:t})=>A2(e,t)}},addProseMirrorPlugins(){return[S2(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()}}});import{Placeholder as mf}from"@tiptap/extension-placeholder";import{TextAlign as pf}from"@tiptap/extension-text-align";import{Typography as ff}from"@tiptap/extension-typography";import{Underline as gf}from"@tiptap/extension-underline";import{StarterKit as hf}from"@tiptap/starter-kit";import{mergeAttributes as Z2}from"@tiptap/core";import{Node as L2,mergeAttributes as R2,wrappingInputRule as H2}from"@tiptap/core";var B2=/^\s*>\s$/,Km=L2.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",R2(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[H2({find:B2,type:this.type})]}});import{ReactNodeViewRenderer as q2}from"@tiptap/react";import{v4 as D2}from"uuid";function Oe(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-${D2()}`;r.setNodeMarkup(i,void 0,{...n.attrs,id:a}),o=!0}return!1}),o&&e.view.dispatch(r)}s(Oe,"generateNodeIds");import{NodeViewContent as F2,NodeViewWrapper as V2}from"@tiptap/react";import{useSetAtom as O2,useAtomValue as U2}from"jotai";import{useCallback as W2,useEffect as _2,useRef as z2}from"react";import{jsx as yo}from"react/jsx-runtime";var $2=s(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderLeftWidth:o,borderColor:n})=>yo("div",{className:"courier-w-full node-element",children:yo("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:yo(F2,{})})}),"BlockquoteComponent"),Ym=s(e=>{var l,c,u;let t=O2(Re),r=U2(ge),o=z2(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=W2(()=>{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]);_2(()=>{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 yo(V2,{children:yo("div",{ref:o,children:yo(Ye,{id:e.node.attrs.id,className:I(n&&"selected-element",a&&"is-empty"),editor:e.editor,children:yo($2,{...e.node.attrs})})})})},"BlockquoteComponentNode");var _r={paddingHorizontal:8,paddingVertical:6,backgroundColor:"transparent",borderLeftWidth:4,borderColor:"#e0e0e0"},nc=Km.extend({content:"block+",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){Oe(this.editor,this.name)},addAttributes(){return{id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},paddingHorizontal:{default:_r.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:_r.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:_r.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderLeftWidth:{default:_r.borderLeftWidth,parseHTML:e=>e.getAttribute("data-border-left-width"),renderHTML:e=>({"data-border-left-width":e.borderLeftWidth})},borderColor:{default:_r.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",Z2(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 q2(Ym)}});import{zodResolver as uh}from"@hookform/resolvers/zod";import{useForm as dh}from"react-hook-form";import{useCallback as J2,useEffect as j2,useRef as Xm}from"react";var Xe=s(({editor:e,element:t,form:r,nodeType:o})=>{let n=Xm(null),i=Xm(null);return j2(()=>{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:J2(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");import{useAtomValue as va,useSetAtom as Y2}from"jotai";import{useMemo as ep,useCallback as tp}from"react";var Ca=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,...Ca(n,i)]:[...r,i]},[]),"getFlattenedVariables");var G2={link:["href","content"],img:["src","href","alt_text"],image:["src","href","alt_text"],action:["href","content"],meta:["title"],list:["imgSrc","imgHref"],quote:["content"],html:[]},K2=["content","href","src","title"],Qm=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&&$e(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=G2[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;K2.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 fN=s(e=>{let t=va(Te),r=va(X),o=va(Ur),n=va(so),i=Y2(so),a=e!=null?e:o,l=ep(()=>{var p,f;if(!t)return[];let m=((f=(p=t.extensionManager.extensions.find(v=>v.name==="variableSuggestion"))==null?void 0:p.options)==null?void 0:f.variables)||{};return Ca(m)},[t]),c=ep(()=>{if(!r||!a)return[];let m=r.elements.find(p=>p.type==="channel"&&p.channel===a);return m?Qm(m.elements||[]):[]},[r,a]),u=tp((m,p)=>{i(f=>({...f,[m]:p}))},[i]),d=tp(()=>{i({})},[i]);return{availableVariables:l,usedVariables:c,variableValues:n,addVariableValue:u,clearAllVariableValues:d}},"useVariables");import{useSetAtom as lh}from"jotai";import{jsx as rp,jsxs as X2}from"react/jsx-runtime";var Ue=s(({draggable:e=!1,icon:t,draggableLabel:r,label:o})=>X2("div",{className:"courier-flex courier-flex-row courier-items-center courier-gap-2",children:[rp("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}),rp("span",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:e?r:o})]}),"BlockBase");import{Quote as Q2}from"lucide-react";import{jsx as op}from"react/jsx-runtime";var np=s(({draggable:e=!1})=>op(Ue,{draggable:e,icon:op(Q2,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),draggableLabel:"Blockquote",label:"Blockquote block"}),"BlockquoteBlock");import{jsx as xa}from"react/jsx-runtime";var eh=s(()=>xa("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:xa("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"),zr=s(({draggable:e=!1})=>xa(Ue,{draggable:e,icon:xa(eh,{}),draggableLabel:"Button",label:"Button block"}),"ButtonBlock");import{jsx as Ta}from"react/jsx-runtime";var th=s(()=>Ta("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Ta("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"),Ea=s(({draggable:e=!1})=>Ta(Ue,{draggable:e,icon:Ta(th,{}),draggableLabel:"Column layout",label:"Column layout"}),"ColumnBlock");import{jsx as wa}from"react/jsx-runtime";var rh=s(()=>wa("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:wa("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"),bi=s(({draggable:e=!1})=>wa(Ue,{draggable:e,icon:wa(rh,{}),draggableLabel:"Custom code",label:"Custom code"}),"CustomCodeBlock");import{jsx as ka}from"react/jsx-runtime";var oh=s(()=>ka("svg",{width:"16",height:"2",viewBox:"0 0 16 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:ka("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"),$r=s(({draggable:e=!1})=>ka(Ue,{draggable:e,icon:ka(oh,{}),draggableLabel:"Divider",label:"Divider block"}),"DividerBlock");import{jsx as Pa}from"react/jsx-runtime";var nh=s(()=>Pa("svg",{width:"18",height:"13",viewBox:"0 0 18 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Pa("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"),Na=s(({draggable:e=!1})=>Pa(Ue,{draggable:e,icon:Pa(nh,{}),draggableLabel:"Heading",label:"Heading block"}),"HeadingBlock");import{jsx as Ma}from"react/jsx-runtime";var ih=s(()=>Ma("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Ma("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"),Aa=s(({draggable:e=!1})=>Ma(Ue,{draggable:e,icon:Ma(ih,{}),draggableLabel:"Image",label:"Image block"}),"ImageBlock");import{AlignVerticalSpaceAround as ah}from"lucide-react";import{jsx as ip}from"react/jsx-runtime";var Sa=s(({draggable:e=!1})=>ip(Ue,{draggable:e,icon:ip(ah,{className:"courier-w-4 courier-h-4"}),draggableLabel:"Spacer",label:"Spacer block"}),"SpacerBlock");import{jsx as Ia}from"react/jsx-runtime";var sh=s(()=>Ia("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Ia("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"),Zr=s(({draggable:e=!1})=>Ia(Ue,{draggable:e,icon:Ia(sh,{}),draggableLabel:"Text",label:"Text block"}),"TextBlock");import{jsx as jt,jsxs as ch}from"react/jsx-runtime";var Qe=s(({type:e})=>{let t=lh(Re);return ch("div",{className:"courier-flex courier-gap-4 courier-flex-col",children:[jt(Ce,{className:"courier-w-fit",variant:"secondary",buttonSize:"small",onClick:()=>{t(null)},children:"Close"}),e==="heading"&&jt(Na,{}),e==="text"&&jt(Zr,{}),e==="image"&&jt(Aa,{}),e==="spacer"&&jt(Sa,{}),e==="divider"&&jt($r,{}),e==="button"&&jt(zr,{}),e==="blockquote"&&jt(np,{}),e==="customCode"&&jt(bi,{}),e==="column"&&jt(Ea,{}),jt(le,{className:"courier-m-0"})]})},"FormHeader");import{z as Co}from"zod";var ap=Co.object({paddingHorizontal:Co.coerce.number().min(0),paddingVertical:Co.coerce.number().min(0),backgroundColor:Co.string(),borderLeftWidth:Co.coerce.number().min(0),borderColor:Co.string(),id:Co.string().optional()});import{jsx as Xo,jsxs as ic}from"react/jsx-runtime";var sp=s(({element:e,editor:t})=>{let r=dh({resolver:uh(ap),defaultValues:{..._r,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"blockquote"});return e?ic(Ne,{...r,children:[Xo(Qe,{type:"blockquote"}),ic("form",{onChange:()=>{o(r.getValues())},children:[Xo("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),Xo(J,{control:r.control,name:"borderColor",render:({field:n})=>ic(Z,{className:"courier-mb-3",children:[Xo(q,{children:Xo(Ze,{...n,defaultValue:_r.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),Xo(j,{})]})})]})]}):null},"BlockquoteForm");import{z as Nt}from"zod";var La=Nt.object({label:Nt.string(),link:Nt.string().optional(),alignment:Nt.enum(["left","center","right"]),backgroundColor:Nt.string(),borderRadius:Nt.number(),padding:Nt.number(),fontWeight:Nt.enum(["normal","bold"]),fontStyle:Nt.enum(["normal","italic"]),isUnderline:Nt.boolean(),isStrike:Nt.boolean(),textColor:Nt.string().optional(),borderColor:Nt.string().optional()});import{zodResolver as Jh}from"@hookform/resolvers/zod";import{useForm as jh}from"react-hook-form";import{Node as mh}from"@tiptap/core";var Qo=mh.create({name:"doc",topNode:!0,content:"block+"});import{Node as ph,mergeAttributes as fh}from"@tiptap/core";var en=ph.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",fh(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});import Oh from"@tiptap/extension-placeholder";import{Node as gh}from"@tiptap/core";var Ra=gh.create({name:"text",group:"inline"});import{EditorContent as Uh,useEditor as Wh}from"@tiptap/react";import*as Eo from"react";import{useCallback as _h,useEffect as fp}from"react";import{Extension as kh,InputRule as Ph,Node as Nh}from"@tiptap/core";import{ReactNodeViewRenderer as Mh}from"@tiptap/react";import{NodeViewWrapper as xh}from"@tiptap/react";import{useAtomValue as Th}from"jotai";import{useCallback as Fa,useEffect as Eh,useState as wh}from"react";import{useCallback as vo,useEffect as Ha,useMemo as hh,useRef as bh,useState as lp}from"react";import{jsx as cp,jsxs as Ch}from"react/jsx-runtime";var ac=50,sc=24,yh=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"),Ba=s(({variableId:e,isInvalid:t,onUpdateAttributes:r,onDelete:o,icon:n,value:i,singleClickToEdit:a=!1,className:l,textColorOverride:c,getColors:u=yh})=>{let[d,m]=lp(!1),[p,f]=lp(e),v=bh(null);Ha(()=>{e===""&&!d&&(m(!0),f(""))},[e,d]),Ha(()=>{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]),Ha(()=>{d||f(e)},[e,d]);let h=vo(()=>{m(!1);let k=p.trim();if(k===""){o();return}let L=$e(k);r({id:k,isInvalid:!L})},[p,o,r]),b=vo(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=vo(()=>{if(v.current){let k=v.current.textContent||"";if(k.length>ac){k=k.slice(0,ac),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=vo(k=>{k.preventDefault();let L=k.clipboardData.getData("text/plain").slice(0,ac);document.execCommand("insertText",!1,L)},[]),g=vo(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=hh(()=>{let k=e,L=i?`="${i}"`:"",S=`${k}${L}`,H=k.length>sc;return{displayText:`${H?`${k.slice(0,sc)}\u2026`:k}${L}`,fullText:S,showTitle:H}},[e,i]);Ha(()=>{v.current&&!d&&(v.current.textContent=C.displayText)},[C.displayText,d]);let x=vo(k=>{k.stopPropagation()},[]),w=vo(k=>{k.stopPropagation()},[]),A=a?{onClick:g}:{onClick:w,onDoubleClick:g};return Ch("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:[cp("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}),cp("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:`${sc}ch`,overflow:"hidden",textOverflow:d?"clip":"ellipsis",whiteSpace:"nowrap",direction:"ltr",unicodeBidi:"isolate"},children:d?p:C.displayText})]})},"VariableChipBase");import{jsx as up,jsxs as vh}from"react/jsx-runtime";var Da=s(({color:e="#1D4ED8"})=>vh("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:[up("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}),up("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableIcon");import{jsx as lc}from"react/jsx-runtime";var dp=s(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=Th(so),i=e.attrs.id||"",a=n[i],l=e.attrs.isInvalid,[c,u]=wh(!1),d=Fa(()=>{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]);Eh(()=>{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=Fa(h=>{o(h)},[o]),p=Fa(()=>{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=Fa((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 lc(xh,{className:"courier-inline-block courier-max-w-full",children:lc(Ba,{variableId:i,isInvalid:l,value:a,onUpdateAttributes:m,onDelete:p,icon:lc(Da,{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 cc=Nh.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 Mh(dp)}}),xo=kh.create({name:"variableInputRule",addInputRules(){return[new Ph({find:/\{\{$/,handler:({range:e,chain:t})=>{t().deleteRange(e).insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()}})]}});import{Extension as Ah}from"@tiptap/core";import{Plugin as Sh}from"@tiptap/pm/state";import{Slice as Ih,Fragment as Lh}from"@tiptap/pm/model";var To=Ah.create({name:"variablePaste",addProseMirrorPlugins(){return[new Sh({props:{transformPastedHTML:e=>e.replace(/\{\{([^}]+)\}\}/g,(r,o)=>{let n=o.trim();return $e(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&&$e(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=Lh.from(i),u=new Ih(c,0,0),d=r.state.tr.replaceSelection(u);return r.dispatch(d),e}return e}}})]}});import{Node as Rh}from"@tiptap/core";import{NodeViewWrapper as Hh,ReactNodeViewRenderer as Bh}from"@tiptap/react";import{useCallback as mp}from"react";import{jsx as yi,jsxs as Vh}from"react/jsx-runtime";var Dh=s(({color:e="#B45309"})=>Vh("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:[yi("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}),yi("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableChipIcon"),pp=s(e=>e?{bgColor:"#FEF2F2",borderColor:"#FECACA",iconColor:"#DC2626",textColor:"#991B1B"}:{bgColor:"#FFFBEB",borderColor:"#FDE68A",iconColor:"#B45309",textColor:"#92400E"},"getSimpleColors"),Fh=s(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=e.attrs.id||"",i=e.attrs.isInvalid||!1,a=mp(u=>{o(u)},[o]),l=mp(()=>{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=pp(i);return yi(Hh,{as:"span",className:"courier-inline",children:yi(Ba,{variableId:n,isInvalid:i,onUpdateAttributes:a,onDelete:l,icon:yi(Dh,{color:c.iconColor}),getColors:pp,className:"courier-mx-0.5"})})},"SimpleVariableView"),Va=Rh.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 Bh(Fh)}});function tn(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();$e(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(tn,"parseStringToContent");function Oa(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(Oa,"contentToString");import{jsx as gp}from"react/jsx-runtime";var lr=Eo.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,onFocus:i,onBlur:a},l)=>{let c=Eo.useRef(!1),u=Eo.useRef(e),d=Wh({extensions:[Qo,en.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),Ra,Va,xo,To,Oh.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:tn(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=Oa(p.getJSON());f!==u.current&&(u.current=f,t==null||t(f))},onFocus:()=>{i==null||i()},onBlur:()=>{a==null||a()}});fp(()=>{if(!d||e===u.current)return;c.current=!0,u.current=e;let p=setTimeout(()=>{let f=tn(e);d.commands.setContent(f),c.current=!1},0);return()=>clearTimeout(p)},[d,e]),fp(()=>{d&&d.setEditable(!n)},[d,n]);let m=_h(()=>{d==null||d.commands.focus()},[d]);return Eo.useImperativeHandle(l,()=>{let p=d==null?void 0:d.view.dom.parentElement;return p&&(p.focus=m),p},[d,m]),gp("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:gp(Uh,{editor:d,className:"courier-w-full"})})});lr.displayName="VariableTextarea";import zh from"@tiptap/extension-placeholder";import{EditorContent as $h,useEditor as Zh}from"@tiptap/react";import*as wo from"react";import{useCallback as qh,useEffect as hp}from"react";import{jsx as bp}from"react/jsx-runtime";var Ci=wo.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,readOnly:i=!1,onFocus:a,onBlur:l},c)=>{let u=wo.useRef(!1),d=wo.useRef(e),m=Zh({extensions:[Qo,en.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),Ra,Va,xo,To,zh.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:tn(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=Oa(f.getJSON());v!==d.current&&(d.current=v,t==null||t(v))},onFocus:()=>{a==null||a()},onBlur:()=>{l==null||l()}});hp(()=>{if(!m||e===d.current)return;u.current=!0,d.current=e;let f=setTimeout(()=>{let v=tn(e);m.commands.setContent(v),u.current=!1},0);return()=>clearTimeout(f)},[m,e]),hp(()=>{m&&m.setEditable(!n&&!i)},[m,n,i]);let p=qh(()=>{m==null||m.commands.focus()},[m]);return wo.useImperativeHandle(c,()=>{let f=m==null?void 0:m.view.dom.parentElement;return f&&(f.focus=p),f},[m,p]),bp("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:bp($h,{editor:m,className:"courier-w-full courier-flex-1"})})});Ci.displayName="VariableInput";import{jsx as on,jsxs as ZA}from"react/jsx-runtime";var rn=30,Ua=s(({color:e="currentColor",width:t=rn,height:r=rn,...o})=>on(_,{...o,width:t,height:r,children:on("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"),Wa=s(({color:e="currentColor",width:t=rn,height:r=rn,...o})=>on(_,{...o,width:t,height:r,children:on("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"),_a=s(({color:e="currentColor",width:t=rn,height:r=rn,...o})=>on(_,{...o,width:t,height:r,children:on("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");import{jsx as fe,jsxs as qr}from"react/jsx-runtime";var yp=s(({element:e,editor:t})=>{let r=jh({resolver:Jh(La),defaultValues:{...Ie,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({editor:t,element:e,form:r,nodeType:"button"});return e?qr(Ne,{...r,children:[fe(Qe,{type:"button"}),qr("form",{onChange:()=>{o(r.getValues())},children:[fe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),fe(J,{control:r.control,name:"link",render:({field:n})=>qr(Z,{children:[fe(q,{children:fe(lr,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})}})}),fe(j,{})]})}),fe(le,{className:"courier-mt-6 courier-mb-4"}),fe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Background"}),fe(J,{control:r.control,name:"backgroundColor",render:({field:n})=>qr(Z,{className:"courier-mb-4",children:[fe(q,{children:fe(Ze,{...n,defaultValue:Ie.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),fe(j,{})]})}),fe(le,{className:"courier-mt-6 courier-mb-4"}),fe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),fe(J,{control:r.control,name:"padding",render:({field:n})=>qr(Z,{className:"courier-mb-2",children:[fe(q,{children:fe(pe,{type:"number",min:0,...n})}),fe(j,{})]})}),fe(J,{control:r.control,name:"alignment",render:({field:n})=>qr(Z,{children:[fe(q,{children:qr(qt,{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:[fe(lt,{size:"sm",value:"left",className:"courier-w-full",children:fe(Ua,{className:"courier-h-4 courier-w-4"})}),fe(lt,{size:"sm",value:"center",className:"courier-w-full",children:fe(Wa,{className:"courier-h-4 courier-w-4"})}),fe(lt,{size:"sm",value:"right",className:"courier-w-full",children:fe(_a,{className:"courier-h-4 courier-w-4"})})]})}),fe(j,{})]})}),fe(le,{className:"courier-mt-6 courier-mb-4"}),fe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),fe(J,{control:r.control,name:"borderRadius",render:({field:n})=>qr(Z,{children:[fe(q,{children:fe(pe,{startAdornment:fe(jn,{}),type:"number",min:0,...n})}),fe(j,{})]})})]})]}):null},"ButtonForm");import{mergeAttributes as ob,Node as nb}from"@tiptap/core";import{ReactNodeViewRenderer as ib}from"@tiptap/react";import{v4 as ab}from"uuid";import{useAtomValue as Gh,useSetAtom as Kh}from"jotai";import{useCallback as kr,useRef as ko,useEffect as vp,useLayoutEffect as Yh,useState as Xh}from"react";import{Fragment as rb,jsx as cr,jsxs as uc}from"react/jsx-runtime";var Qh=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();$e(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"),eb=s(({parts:e})=>{let t=Gh(so);return cr(rb,{children:e.map((r,o)=>{if(r.type==="text")return cr("span",{children:r.content},o);let n=t[r.name];return uc("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:[cr(Da,{color:n?void 0:"#B45309"}),uc("span",{className:"courier-truncate courier-min-w-0",style:{color:"#000000"},children:[r.name,n?`="${n}"`:""]})]},o)})})},"ButtonLabelDisplay"),Cp=s(({label:e,backgroundColor:t,textColor:r,onLabelChange:o,editable:n})=>{let i=ko(null),a=ko(e),l=ko(!1),[c,u]=Xh(!1),d=Qh(e),p=d.some(T=>T.type==="variable")&&!c;Yh(()=>{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=ko(p),v=ko(!0);vp(()=>{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=kr(()=>{if(i.current&&!p){l.current=!0;let T=i.current.textContent||"";a.current=T,o(T),requestAnimationFrame(()=>{l.current=!1})}},[o,p]),b=kr(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=kr(()=>{u(!0)},[]),N=kr(()=>{u(!1)},[]),g=kr(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?cr(eb,{parts:d}):n?null:e,M=kr(T=>{p&&n&&T.stopPropagation()},[p,n]);return cr("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"),tb=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})=>cr("div",{className:"node-element",children:uc("div",{className:"courier-flex courier-gap-1 courier-justify-start",style:{marginTop:`${c}px`,marginBottom:`${c}px`},children:[cr(Cp,{label:e,backgroundColor:r,textColor:o,onLabelChange:u||(()=>{}),editable:m},"button1"),cr(Cp,{label:n,backgroundColor:a,textColor:l,onLabelChange:d||(()=>{}),editable:m},"button2")]})}),"ButtonRowComponent"),xp=s(e=>{let t=Kh(Re),r=ko({}),o=ko({}),n=kr(()=>{if(!e.editor.isEditable)return;let l=We(e);l&&t(l)},[e,t]),i=kr(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=kr(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 vp(()=>{let l=r.current;return()=>{l.button1&&clearTimeout(l.button1),l.button2&&clearTimeout(l.button2)}},[]),cr(Ye,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"buttonRow",children:cr(tb,{...e.node.attrs,onButton1LabelChange:i,onButton2LabelChange:a,editable:e.editor.isEditable})})},"ButtonRowComponentNode");var Gt={button1Label:"Register",button1Link:"",button1BackgroundColor:"#000000",button1TextColor:"#ffffff",button2Label:"Learn more",button2Link:"",button2BackgroundColor:"#ffffff",button2TextColor:"#000000",padding:6},$a=nb.create({name:"buttonRow",group:"block",atom:!0,selectable:!1,onCreate(){Oe(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${ab()}`,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.id})},button1Label:{default:Gt.button1Label,parseHTML:e=>e.getAttribute("data-button1-label"),renderHTML:e=>({"data-button1-label":e.button1Label})},button1Link:{default:Gt.button1Link,parseHTML:e=>e.getAttribute("data-button1-link"),renderHTML:e=>({"data-button1-link":e.button1Link})},button1BackgroundColor:{default:Gt.button1BackgroundColor,parseHTML:e=>e.getAttribute("data-button1-bg"),renderHTML:e=>({"data-button1-bg":e.button1BackgroundColor})},button1TextColor:{default:Gt.button1TextColor,parseHTML:e=>e.getAttribute("data-button1-color"),renderHTML:e=>({"data-button1-color":e.button1TextColor})},button2Label:{default:Gt.button2Label,parseHTML:e=>e.getAttribute("data-button2-label"),renderHTML:e=>({"data-button2-label":e.button2Label})},button2Link:{default:Gt.button2Link,parseHTML:e=>e.getAttribute("data-button2-link"),renderHTML:e=>({"data-button2-link":e.button2Link})},button2BackgroundColor:{default:Gt.button2BackgroundColor,parseHTML:e=>e.getAttribute("data-button2-bg"),renderHTML:e=>({"data-button2-bg":e.button2BackgroundColor})},button2TextColor:{default:Gt.button2TextColor,parseHTML:e=>e.getAttribute("data-button2-color"),renderHTML:e=>({"data-button2-color":e.button2TextColor})},padding:{default:Gt.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",ob(e,{"data-type":"buttonRow"})]},addNodeView(){return ib(xp,{stopEvent:({event:e})=>!(e.type==="dragstart"||e.type==="drop")})},addCommands(){return{setButtonRow:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...Gt,...e}}).run()}}});import{mergeAttributes as pb,Node as fb}from"@tiptap/core";import{ReactNodeViewRenderer as gb}from"@tiptap/react";import{v4 as hb}from"uuid";import{NodeViewContent as sb}from"@tiptap/react";import{useSetAtom as lb,useAtomValue as cb}from"jotai";import{useCallback as dc,useEffect as Tp,useState as mc,useRef as ub}from"react";import{jsx as ur}from"react/jsx-runtime";var db=s(({columnId:e,index:t,isPreviewMode:r})=>{let o=ub(null),[n,i]=mc(!1);return Tp(()=>{let a=o.current;if(a)return Pt({element:a,getData:()=>({type:"column-cell",columnId:e,index:t,isEmpty:!0}),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e,t]),ur("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&&ur("span",{className:"courier-pointer-events-none",children:"Drag and drop content blocks"})})},"PlaceholderCell"),mb=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 ur("div",{className:"courier-w-full node-element",style:m,children:ur("div",{className:"courier-w-full courier-flex courier-gap-2 courier-p-2",style:d,children:Array.from({length:l}).map((v,h)=>ur(db,{columnId:f,index:h,isPreviewMode:c},h))})})}return ur("div",{className:"courier-w-full node-element",style:m,children:ur("div",{className:"courier-w-full courier-p-2",style:d,children:ur(sb,{})})})},"ColumnComponent"),Ep=s(e=>{let t=lb(Re),r=cb(pt),[o,n]=mc(!1),[i,a]=mc(e.editor.isEditable);Tp(()=>{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=dc(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=We(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=dc(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=dc(()=>{n(!1)},[]);return ur(Ye,{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:ur(mb,{...e.node.attrs,node:e.node,columnsCount:e.node.attrs.columnsCount||2,isPreviewMode:l})})},"ColumnComponentNode");var qe={columnsCount:2,paddingHorizontal:0,paddingVertical:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"transparent",cells:[]},Za=fb.create({name:"column",group:"block",content:"columnRow?",isolating:!0,selectable:!1,onCreate(){Oe(this.editor,this.name)},addAttributes(){return{columnsCount:{default:qe.columnsCount,parseHTML:e=>e.getAttribute("data-columns-count"),renderHTML:e=>({"data-columns-count":e.columnsCount})},paddingHorizontal:{default:qe.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:qe.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:qe.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:qe.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:qe.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:qe.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:()=>`node-${hb()}`,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",pb(this.options.HTMLAttributes,e,{"data-type":"column"}),0]},addNodeView(){return gb(Ep)},addCommands(){return{setColumn:e=>({chain:t})=>{let r=e.columnsCount||qe.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"}}}});import{zodResolver as bb}from"@hookform/resolvers/zod";import{useForm as yb}from"react-hook-form";import{z as Bt}from"zod";var wp=Bt.object({columnsCount:Bt.number().min(1).max(4).default(2),paddingHorizontal:Bt.number().default(0),paddingVertical:Bt.number().default(0),backgroundColor:Bt.string().default("transparent"),borderWidth:Bt.number().default(0),borderRadius:Bt.number().default(0),borderColor:Bt.string().default("transparent"),cells:Bt.array(Bt.object({elements:Bt.array(Bt.any())})).optional()});import{jsx as ne,jsxs as Kt}from"react/jsx-runtime";var pc=s(({element:e,editor:t})=>{let r=yb({resolver:bb(wp),defaultValues:{...qe,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({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?Kt(Ne,{...r,children:[ne(Qe,{type:"column",label:"Column layout"}),Kt("form",{onChange:()=>{o(r.getValues())},children:[ne("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Columns count"}),ne(J,{control:r.control,name:"columnsCount",render:({field:i})=>Kt(Z,{className:"courier-mb-4",children:[ne(q,{children:ne(qt,{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=>ne(lt,{value:a.toString(),className:"courier-w-12 courier-h-7",children:ne("span",{className:"courier-text-sm courier-font-medium",children:a})},a))})}),ne(j,{})]})}),ne(le,{className:"courier-mt-6 courier-mb-4"}),ne("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Frame"}),Kt("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[ne(J,{control:r.control,name:"paddingHorizontal",render:({field:i})=>Kt(Z,{children:[ne(q,{children:ne(pe,{startAdornment:ne(ti,{}),type:"number",min:0,...i})}),ne(j,{})]})}),ne(J,{control:r.control,name:"paddingVertical",render:({field:i})=>Kt(Z,{children:[ne(q,{children:ne(pe,{startAdornment:ne(po,{}),type:"number",min:0,...i})}),ne(j,{})]})})]}),ne(J,{control:r.control,name:"backgroundColor",render:({field:i})=>Kt(Z,{className:"courier-mb-4",children:[ne(q,{children:ne(Ze,{...i,defaultValue:qe.backgroundColor,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),ne(j,{})]})}),ne(le,{className:"courier-mt-6 courier-mb-4"}),ne("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Border"}),Kt("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[ne(J,{control:r.control,name:"borderWidth",render:({field:i})=>Kt(Z,{children:[ne(q,{children:ne(pe,{startAdornment:ne(Er,{}),type:"number",min:0,...i})}),ne(j,{})]})}),ne(J,{control:r.control,name:"borderRadius",render:({field:i})=>Kt(Z,{children:[ne(q,{children:ne(pe,{startAdornment:ne(jn,{}),type:"number",min:0,...i})}),ne(j,{})]})})]}),ne(J,{control:r.control,name:"borderColor",render:({field:i})=>Kt(Z,{className:"courier-mb-4",children:[ne(q,{children:ne(Ze,{...i,defaultValue:qe.borderColor,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),ne(j,{})]})})]})]}):null},"ColumnForm");import{mergeAttributes as Cb,Node as vb}from"@tiptap/core";var qa=vb.create({name:"columnRow",group:"columnContent",content:"columnCell+",isolating:!0,parseHTML(){return[{tag:'div[data-type="column-row"]'}]},renderHTML({HTMLAttributes:e}){return["div",Cb(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()}}});import{mergeAttributes as Pb,Node as Nb}from"@tiptap/core";import{ReactNodeViewRenderer as Mb}from"@tiptap/react";import{Plugin as Ab,PluginKey as Sb}from"@tiptap/pm/state";import{NodeViewWrapper as xb,NodeViewContent as Tb}from"@tiptap/react";import{useEffect as kp,useRef as Eb,useState as Pp}from"react";import{useAtomValue as wb}from"jotai";import{jsx as Np,jsxs as kb}from"react/jsx-runtime";var Mp=s(e=>{let t=Eb(null),[r,o]=Pp(!1),n=wb(pt),i=e.node.attrs.isEditorMode===!0,[a,l]=Pp(e.editor.isEditable);kp(()=>{let d=t.current;if(d)return Pt({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]),kp(()=>{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 kb(xb,{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&&Np("span",{className:"courier-pointer-events-none courier-pl-4",children:"Drag and drop content blocks"}),Np(Tb,{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full"})]})},"ColumnCellComponentNode");var Ja=Nb.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",Pb(e,{"data-type":"column-cell",style:"flex: 1 1 0%; width: 0; min-height: 120px;"}),0]},addNodeView(){return Mb(Mp)},addCommands(){return{insertColumnCell:()=>({chain:e})=>e().insertContent({type:this.name}).run()}},addProseMirrorPlugins(){return[new Ab({key:new Sb("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}})]}});import{mergeAttributes as Hb,Node as Bb}from"@tiptap/core";import{ReactNodeViewRenderer as Db}from"@tiptap/react";import{v4 as Fb}from"uuid";import{useSetAtom as Ib}from"jotai";import{useCallback as Lb}from"react";import{jsx as ja}from"react/jsx-runtime";var Rb=s(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return ja("div",{className:"courier-w-full node-element",children:ja("div",{className:"courier-custom-code courier-py-1.5",dangerouslySetInnerHTML:t?{__html:e}:{__html:" "}})})},"CustomCodeComponent"),Ap=s(e=>{let t=Ib(Re),r=Lb(()=>{if(!e.editor.isEditable)return;let i=We(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 ja(Ye,{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:ja(Rb,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var Pr={code:"<!-- Add your HTML code here -->"},Ga=Bb.create({name:"customCode",group:"block",atom:!0,selectable:!1,onCreate(){Oe(this.editor,this.name)},addAttributes(){return{code:{default:Pr.code,parseHTML:e=>e.getAttribute("data-code")||"",renderHTML:e=>({"data-code":e.code})},id:{default:()=>`node-${Fb()}`,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",Hb(this.options.HTMLAttributes,e,{"data-type":"custom-code"}),["div",{innerHTML:e.code||Pr.code}]]},addNodeView(){return Db(Ap)},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"}}}});import{useRef as Ka,useCallback as Sp,useState as Ip,lazy as Ub,Suspense as Wb,useEffect as _b}from"react";import{forwardRef as Vb}from"react";import{jsx as Ob}from"react/jsx-runtime";var fc=Vb(({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 Ob("div",{className:o,ref:r,...t})});fc.displayName="Spinner";import{jsx as nn}from"react/jsx-runtime";var zb=s(()=>{let[e,t]=Ip(!1),r=Ka(null);return _b(()=>{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"),$b=Ub(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function Zb(e,t){let r=Ka();return Sp((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}s(Zb,"useDebounce");var qb=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"),gc=s(({code:e,onSave:t,onValidationChange:r,validator:o=qb})=>{let n=Ka(null),i=Ka(null),[a,l]=Ip(!0),{isDark:c,containerRef:u}=zb(),d=Sp(()=>{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=Zb(v=>{setTimeout(()=>{d()&&t(v)},150)},500);return nn("div",{ref:u,className:"courier-h-full courier-overflow-hidden",children:nn("div",{className:"courier-h-full courier-p-2",children:nn(Wb,{fallback:nn("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:nn(fc,{})}),children:nn($b,{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");import{zodResolver as Jb}from"@hookform/resolvers/zod";import{useForm as jb}from"react-hook-form";import{z as Lp}from"zod";var Rp=Lp.object({code:Lp.string()});import{useCallback as Gb}from"react";import{useAtom as Kb}from"jotai";import{Fragment as Hp,jsx as dr,jsxs as vi}from"react/jsx-runtime";var hc=s(({element:e,editor:t})=>{let r=jb({resolver:Jb(Rp),defaultValues:{...Pr,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({editor:t,element:e,form:r,nodeType:"customCode"}),[n,i]=Kb(tr),a=Gb(l=>{r.setValue("code",l),o({code:l})},[r,o]);return e?vi(Ne,{...r,children:[!n&&dr(Qe,{type:"customCode"}),vi("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[dr(Ce,{className:"courier-w-fit",variant:"outline",buttonSize:"small",onClick:()=>i(!n),children:n?vi(Hp,{children:[dr(Vl,{className:"courier-w-3 courier-h-3"}),"Minimize"]}):vi(Hp,{children:[dr(Gn,{className:"courier-w-3 courier-h-3"}),"Expand Editor"]})}),dr("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:dr("form",{onChange:()=>{o(r.getValues())},className:"courier-h-full",children:dr(J,{control:r.control,name:"code",render:({field:l})=>vi(Z,{className:"courier-h-full",children:[dr(q,{children:dr(gc,{code:l.value,onSave:c=>{l.onChange(c),a(c)},onCancel:()=>{}})}),dr(j,{})]})})})})]})]}):null},"CustomCodeForm");import{mergeAttributes as i0}from"@tiptap/core";import{Node as Yb,mergeAttributes as Xb,isNodeSelection as Qb,nodeInputRule as e0}from"@tiptap/core";import{TextSelection as bc,NodeSelection as t0}from"@tiptap/pm/state";var Bp=Yb.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",Xb(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}):Qb(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(bc.create(a.doc,u.pos+1)):u.nodeAfter.isBlock?a.setSelection(t0.create(a.doc,u.pos)):a.setSelection(bc.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(bc.create(a.doc,d+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[e0({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});import{ReactNodeViewRenderer as a0}from"@tiptap/react";import{v4 as s0}from"uuid";import{useSetAtom as r0}from"jotai";import{useCallback as o0}from"react";import{jsx as Ya}from"react/jsx-runtime";var n0=s(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>Ya("div",{className:"courier-w-full node-element courier-flex",children:Ya("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"),Dp=s(e=>{let t=r0(Re),r=o0(()=>{if(!e.editor.isEditable)return;let o=We(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return Ya(Ye,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:Ya(n0,{...e.node.attrs})})},"DividerComponentNode");var Mt={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},Xa={padding:24,color:"transparent",size:1,radius:0,variant:"spacer"},yc=Bp.extend({name:"divider",atom:!0,onCreate(){Oe(this.editor,this.name)},addAttributes(){return{padding:{default:Mt.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.margin})},size:{default:Mt.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},color:{default:Mt.color,parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color})},width:{default:Mt.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},radius:{default:Mt.radius,parseHTML:e=>e.getAttribute("data-radius"),renderHTML:e=>({"data-radius":e.radius})},variant:{default:Mt.variant,parseHTML:e=>e.getAttribute("data-variant"),renderHTML:e=>({"data-variant":e.variant})},id:{default:()=>`node-${s0()}`,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",i0(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return a0(Dp)},addInputRules(){return[]}});import{z as an}from"zod";var Fp=an.object({padding:an.number(),color:an.string(),size:an.number(),radius:an.number(),variant:an.enum(["divider","spacer"]).default("divider")});import{zodResolver as l0}from"@hookform/resolvers/zod";import{useForm as c0}from"react-hook-form";import{Fragment as u0,jsx as _e,jsxs as sn}from"react/jsx-runtime";var Vp=s(({element:e,editor:t})=>{let r=c0({resolver:l0(Fp),defaultValues:{...Mt,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({editor:t,element:e,form:r,nodeType:"divider"});if(!e)return null;let n=r.watch("variant");return sn(Ne,{...r,children:[_e(Qe,{type:n}),sn("form",{onChange:()=>{o(r.getValues())},children:[_e("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),_e(J,{control:r.control,name:"padding",render:({field:i})=>sn(Z,{children:[_e(q,{children:_e(pe,{startAdornment:_e(po,{}),type:"number",...i,onChange:a=>{i.onChange(a),o({...r.getValues(),margin:a.target.value})}})}),_e(j,{})]})}),n==="divider"&&sn(u0,{children:[_e(le,{className:"courier-mt-6 courier-mb-4"}),_e("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Line"}),_e(J,{control:r.control,name:"size",render:({field:i})=>sn(Z,{className:"courier-mb-4",children:[_e(q,{children:_e(pe,{startAdornment:_e(Er,{}),type:"number",min:0,...i,onChange:a=>{i.onChange(a),o({...r.getValues(),width:a.target.value})}})}),_e(j,{})]})}),_e(J,{control:r.control,name:"color",render:({field:i})=>sn(Z,{className:"courier-mb-4",children:[_e(q,{children:_e(Ze,{...i,defaultValue:Mt.color,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),_e(j,{})]})})]})]})]})},"DividerForm");var Cc=Qo.extend({content:"(block)+"});import{Node as b0}from"@tiptap/core";import{ReactNodeViewRenderer as y0}from"@tiptap/react";import{NodeViewWrapper as d0}from"@tiptap/react";import{forwardRef as m0,useEffect as Op,useState as p0}from"react";import{jsx as Qa}from"react/jsx-runtime";function f0(){let[e,t]=p0(!1);return Op(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(f0,"useMountStatus");var g0=m0(({children:e,className:t,dragOverlay:r,id:o},n)=>(Op(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),Qa(d0,{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}))),h0=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"),Up=s(({node:e})=>{let t=e.attrs.type,r=e.attrs.id,o=f0();return Qa(g0,{id:r,fadeIn:!o,children:Qa("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:Qa("div",{className:"courier-text-accent-foreground",children:h0(t)})})})},"DragPlaceholderComponent");var Wp=b0.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 y0(Up,{as:"div",className:"drag-placeholder-wrapper"})}});import{Extension as C0}from"@tiptap/core";import{Plugin as v0,PluginKey as x0}from"@tiptap/pm/state";var T0=new x0("file-handler"),E0=C0.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new v0({key:T0,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)}}})]}}),es=E0;import{Extension as w0}from"@tiptap/core";import{Plugin as k0,PluginKey as P0}from"@tiptap/pm/state";var N0=new P0("fixedChannelPaste"),M0=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"),A0=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"),ts=w0.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new k0({key:N0,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!M0(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=A0(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}}});import{Extension as S0}from"@tiptap/core";import{Plugin as I0,PluginKey as L0,TextSelection as vc}from"@tiptap/pm/state";var Po=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"),xc=s(e=>!!e.view.dom.closest(".courier-inbox-editor"),"isInInboxChannel"),_p=s(e=>{if(!xc(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"),No=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"),rs=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"),os=new L0("fixedChannelSelection"),ns=S0.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!Po(e,this.options.channels))return!1;let o=No(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(vc.create(t.doc,l,c)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!Po(e,this.options.channels))return!1;let t=No(e);if(!t)return!1;let{start:r,end:o}=t;return e.commands.setTextSelection({from:r,to:o}),!0},Backspace:({editor:e})=>{if(!Po(e,this.options.channels))return!1;if(xc(e)){let{selection:t}=e.state;if(No(e)&&t.$anchor.parentOffset===0&&_p(e))return!0}if(rs(e)){let t=No(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(!Po(e,this.options.channels))return!1;if(xc(e)){let{selection:t}=e.state,r=No(e);if(r){let o=r.node.textContent;if(t.$anchor.parentOffset===o.length&&_p(e))return!0}}if(rs(e)){let t=No(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 I0({key:os,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!Po(o,this.options.channels))return!1;if(rs(o)){let n=No(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(vc.create(u.doc,l,c)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!Po(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(os,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!Po(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&rs(r)){let n=os.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(vc.create(c.doc,a,l)),e.dispatch(c),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(os)||t}}})]}});import{mergeAttributes as z0}from"@tiptap/core";import{Node as R0,mergeAttributes as H0,textblockTypeInputRule as B0}from"@tiptap/core";var zp=R0.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]}`,H0(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=>B0({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});import{z as Nr}from"zod";var $p=Nr.object({paddingVertical:Nr.number(),paddingHorizontal:Nr.number(),backgroundColor:Nr.string(),borderWidth:Nr.number(),borderColor:Nr.string(),textAlign:Nr.enum(["left","center","right","justify"]).default("left"),selected:Nr.boolean().default(!1),id:Nr.string().optional()}),ue={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderColor:"transparent",textAlign:"left",selected:!1};import{NodeViewContent as D0,NodeViewWrapper as F0}from"@tiptap/react";import{useSetAtom as V0,useAtomValue as O0}from"jotai";import{useCallback as U0}from"react";import{jsx as Jr}from"react/jsx-runtime";var Zp=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=O0(pt);return Jr("div",{className:"courier-w-full node-element",children:Jr("div",{style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderColor:i,borderStyle:n>0?"solid":"none"},children:Jr("div",{style:{pointerEvents:u?"none":"auto"},children:Jr(D0,{as:c})})})})},"TextBlockComponent"),is=s(e=>{let t=V0(Re),r=U0(()=>{if(!e.editor.isEditable)return;let l=We(e);l&&t(l)},[e,t]),o=!e.node.content||e.node.content.size===0,n=jr(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null;return(i==null?void 0:i.parent.type.name)==="blockquote"?Jr(F0,{children:Jr(Zp,{...e.node.attrs,type:e.node.type.name})}):Jr(Ye,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:Jr(Zp,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");import{zodResolver as W0}from"@hookform/resolvers/zod";import{useForm as _0}from"react-hook-form";import{jsx as ve,jsxs as Gr}from"react/jsx-runtime";var qp=s(({element:e,editor:t})=>{let r=_0({resolver:W0($p),defaultValues:{...ue,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?Gr(Ne,{...r,children:[ve(Qe,{type:"text"}),Gr("form",{onChange:()=>{o(r.getValues())},children:[ve("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),Gr("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[ve(J,{control:r.control,name:"paddingHorizontal",render:({field:n})=>Gr(Z,{children:[ve(q,{children:ve(pe,{startAdornment:ve(ti,{}),type:"number",min:0,...n})}),ve(j,{})]})}),ve(J,{control:r.control,name:"paddingVertical",render:({field:n})=>Gr(Z,{children:[ve(q,{children:ve(pe,{startAdornment:ve(po,{}),type:"number",min:0,...n})}),ve(j,{})]})})]}),ve(J,{control:r.control,name:"backgroundColor",render:({field:n})=>Gr(Z,{className:"courier-mb-4",children:[ve(q,{children:ve(Ze,{...n,defaultValue:ue.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),ve(j,{})]})}),ve(le,{className:"courier-mb-4"}),ve("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),ve(J,{control:r.control,name:"borderWidth",render:({field:n})=>Gr(Z,{className:"courier-mb-3",children:[ve(q,{children:ve(pe,{startAdornment:ve(Er,{}),type:"number",min:0,...n})}),ve(j,{})]})}),ve(J,{control:r.control,name:"borderColor",render:({field:n})=>Gr(Z,{className:"courier-mb-4",children:[ve(q,{children:ve(Ze,{...n,defaultValue:ue.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),ve(j,{})]})})]})]}):null},"TextBlockForm");import{ReactNodeViewRenderer as $0}from"@tiptap/react";var Tc=zp.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){Oe(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:ue.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):ue.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:ue.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):ue.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:ue.textAlign,parseHTML:t=>t.style.textAlign||ue.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:ue.backgroundColor,parseHTML:t=>t.style.backgroundColor||ue.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:ue.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):ue.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderColor:{default:ue.borderColor,parseHTML:t=>t.style.borderColor||ue.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]}`,z0(this.options.HTMLAttributes,t),0]},addNodeView(){return $0(is)}});import{mergeAttributes as K0,Node as Y0}from"@tiptap/core";import{ReactNodeViewRenderer as X0}from"@tiptap/react";import{useSetAtom as Jp}from"jotai";import{useCallback as Yt,useEffect as wc,useMemo as Z0,useRef as jp,useState as Gp}from"react";import{Fragment as G0,jsx as mr,jsxs as Ec}from"react/jsx-runtime";var q0=["image/png","image/jpeg","image/gif","image/webp"],J0=s(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderColor:n,isUploading:i,width:a,imageNaturalWidth:l,onFileSelect:c,editor:u})=>{let[d,m]=Gp(!1),[p,f]=Gp(!0),v=jp(null),h=jp(null);wc(()=>{e&&f(!0)},[e]),wc(()=>{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=Yt(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=Z0(()=>b(l),[b,l]),N=Yt(C=>q0.includes(C),[]),g=Yt(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=Yt(C=>{C.preventDefault(),C.stopPropagation(),m(!1)},[]),M=Yt(C=>{C.preventDefault(),C.stopPropagation(),C.dataTransfer.types.includes("Files")&&Array.from(C.dataTransfer.items).some(A=>N(A.type))&&m(!0)},[N]),T=Yt(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=Yt(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=Yt(()=>{var C;(C=v.current)==null||C.click()},[]);return Ji(e)?Ec("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?mr(fo,{className:"courier-w-8 courier-h-8"}):Ec(G0,{children:[mr("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),mr("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:E,children:"Browse"})]}),mr("input",{ref:v,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:R})]}):mr("div",{className:"courier-w-full node-element",children:Ec("div",{className:I("courier-relative courier-p-1",(i||p)&&"courier-w-full courier-aspect-[4/3] courier-bg-gray-100"),children:[(i||p)&&mr("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:mr(fo,{className:"courier-w-8 courier-h-8"})}),mr("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"),j0=["image/png","image/jpeg","image/gif","image/webp"],Kp=s(e=>{let t=Jp(Re),r=Jp(Q),{uploadImage:o}=On(),n=Yt(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]);wc(()=>{var c,u;let l=We(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=jr(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=Yt(()=>{if(!e.editor.isEditable)return;let l=We(e);l&&(e.editor.commands.blur(),t(l))},[e,t]),a=Yt(async l=>{let c=jr(e.getPos);We(e)&&c!==null&&e.editor.chain().focus().setNodeSelection(c).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!j0.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=jr(e.getPos);if(We(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=jr(e.getPos);We(e)&&p!==null&&e.editor.chain().focus().setNodeSelection(p).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return mr(Ye,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:mr(J0,{...e.node.attrs,onFileSelect:a,editor:e.editor})})},"ImageBlockView");var Be={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderColor:"transparent",isUploading:!1,imageNaturalWidth:0},as=Y0.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){Oe(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:Be.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:Be.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:Be.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:Be.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:Be.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:Be.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:Be.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:Be.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:Be.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",K0(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return X0(Kp)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...Be,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...Be,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}}}});import{z as pr}from"zod";var Yp=pr.object({sourcePath:pr.string(),link:pr.string().optional(),alt:pr.string().optional(),alignment:pr.enum(["left","center","right"]),width:pr.number().min(1).max(100),borderWidth:pr.number(),borderColor:pr.string(),isUploading:pr.boolean().optional(),imageNaturalWidth:pr.number()});import{zodResolver as Q0}from"@hookform/resolvers/zod";import{useSetAtom as e3}from"jotai";import{ArrowUp as t3}from"lucide-react";import{useCallback as Ti,useEffect as Qp,useRef as Pc,useState as ls}from"react";import{useForm as r3}from"react-hook-form";import{useSetAtom as kc}from"jotai";import*as xi from"react";import{useRef as Xp}from"react";import{jsx as ss}from"react/jsx-runtime";var Kr=xi.forwardRef(({as:e="Input",autoResize:t,onChange:r,...o},n)=>{let i=Xp(null),a=Xp(null),l=kc(li),c=kc(om),u=kc(sa),d=xi.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=xi.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 ss("div",{ref:i,className:"courier-relative",children:ss(pe,{...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 ss("div",{ref:i,className:"courier-relative",children:ss(vl,{...v})})});Kr.displayName="TextInput";import{Fragment as ef,jsx as G,jsxs as et}from"react/jsx-runtime";var tf=s(({element:e,editor:t})=>{var R,E;let r=Pc(null),o=Pc(null),n=Pc(null),[i,a]=ls(""),[l,c]=ls(!1),[u,d]=ls(((R=e==null?void 0:e.attrs)==null?void 0:R.imageNaturalWidth)||0),[m,p]=ls(!1),f=e3(Q),{uploadImage:v}=On(),h=r3({resolver:Q0(Yp),defaultValues:{...Be,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:b}=Xe({editor:t,element:e,form:h,nodeType:"imageBlock"});Qp(()=>{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=Ti(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=Ti(C=>{var x;C.preventDefault(),(x=r.current)==null||x.click()},[]),g=Ti((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=Ti(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=Ti(C=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{P(C)},500)},[P]);Qp(()=>()=>{n.current&&clearTimeout(n.current)},[]);let T=h.getValues().sourcePath;return e?et(Ne,{...h,children:[G(Qe,{type:"image"}),et("form",{ref:o,onChange:()=>{let C=h.getValues();b(C)},children:[G("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),et(ra,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[et(qn,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[G($o,{value:"file",className:"courier-flex-1",children:"From file"}),G($o,{value:"url",className:"courier-flex-1",children:"From URL"})]}),G(oa,{value:"file",children:et("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[G(Ce,{onClick:N,className:"courier-w-full",variant:"outline",type:"button",disabled:m,children:m?G(ef,{children:"Uploading..."}):et(ef,{children:[G(t3,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),G("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)}}})]})}),G(oa,{value:"url",children:G(J,{control:h.control,name:"sourcePath",render:({field:C})=>et(Z,{className:"courier-mb-3",children:[G(q,{children:G(Kr,{as:"Textarea",...C,autoResize:!0,className:"courier-max-h-[88px]",onChange:x=>{C.onChange(x),M(x.target.value)}})}),G(j,{})]})})})]}),G(J,{control:h.control,name:"link",render:({field:C})=>et(Z,{className:"courier-mb-3",children:[G(q,{children:G(lr,{placeholder:"Link",value:C.value,onChange:x=>{C.onChange(x),b({...h.getValues(),link:x})}})}),G(j,{})]})}),G(J,{control:h.control,name:"alt",render:({field:C})=>et(Z,{className:"courier-mb-4",children:[G(q,{children:G(lr,{placeholder:"Alt text...",value:C.value,onChange:x=>{C.onChange(x),b({...h.getValues(),alt:x})}})}),G(j,{})]})}),G(le,{className:"courier-mt-6 courier-mb-4"}),G("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 et(qt,{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:[G(lt,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),G(lt,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:A||!T,children:"Fill"})]})})(),G(J,{control:h.control,name:"width",render:({field:C})=>et(Z,{className:"courier-flex-1 courier-mb-3",children:[G(q,{children:G(pe,{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)})}}})}),G(j,{})]})}),G(J,{control:h.control,name:"width",render:({field:C})=>et(Z,{className:"courier-flex-1 courier-mb-3",children:[G(q,{children:G(yl,{min:0,max:100,value:[T?C.value:0],disabled:!T,onValueChange:x=>{C.onChange(x[0]),b({...h.getValues(),width:x[0]})}})}),G(j,{})]})}),G(J,{control:h.control,name:"alignment",render:({field:C})=>et(Z,{children:[G(q,{children:et(qt,{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:[G(lt,{size:"sm",value:"left",className:"courier-w-full",children:G(Ua,{className:"courier-h-4 courier-w-4"})}),G(lt,{size:"sm",value:"center",className:"courier-w-full",children:G(Wa,{className:"courier-h-4 courier-w-4"})}),G(lt,{size:"sm",value:"right",className:"courier-w-full",children:G(_a,{className:"courier-h-4 courier-w-4"})})]})}),G(j,{})]})}),G(le,{className:"courier-mt-6 courier-mb-4"}),G("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),G(J,{control:h.control,name:"borderWidth",render:({field:C})=>et(Z,{className:"courier-mb-3",children:[G(q,{children:G(pe,{startAdornment:G(Er,{}),type:"number",disabled:!T,min:0,...C,onChange:x=>{let w=parseInt(x.target.value)||0;C.onChange(w),b({...h.getValues(),borderWidth:w})}})}),G(j,{})]})}),G(J,{control:h.control,name:"borderColor",render:({field:C})=>et(Z,{className:"courier-mb-4",children:[G(q,{children:G(Ze,{...C,disabled:!T,defaultValue:Be.borderColor,onChange:x=>{C.onChange(x),b({...h.getValues(),[C.name]:x})}})}),G(j,{})]})})]})]}):null},"ImageBlockForm");import{getMarkRange as rf,mergeAttributes as o3}from"@tiptap/core";import n3 from"@tiptap/extension-link";import{Plugin as of,TextSelection as nf}from"@tiptap/pm/state";var Nc=n3.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",o3(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new of({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=rf(l,c.type);return u?(r.dispatch(i.tr.setSelection(nf.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(nf.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 of({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=rf(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}})]}});import{zodResolver as i3}from"@hookform/resolvers/zod";import{useSetAtom as a3}from"jotai";import{useRef as s3,useEffect as l3}from"react";import{useForm as c3}from"react-hook-form";import{z as Mc}from"zod";import{jsx as Mo,jsxs as af}from"react/jsx-runtime";var u3=Mc.object({href:Mc.string(),openInNewTab:Mc.boolean().default(!1)}),sf=s(({editor:e,mark:t,pendingLink:r})=>{let o=a3(la),n=s3(null),i=c3({resolver:i3(u3),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1}});l3(()=>{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 af(Ne,{...i,children:[Mo("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),Mo("div",{className:"courier-space-y-4",children:Mo(J,{control:i.control,name:"href",render:({field:l})=>af(Z,{children:[Mo(rr,{children:"URL"}),Mo(q,{children:Mo(Kr,{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)()}})}),Mo(j,{})]})})})]})},"LinkForm");import{mergeAttributes as y3,ReactNodeViewRenderer as C3}from"@tiptap/react";import{TextSelection as v3,Plugin as x3,PluginKey as T3}from"prosemirror-state";var Mr={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:"'"},us={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},d3=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),m3=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(He=0;He<10;He++)Mr[48+He]=Mr[96+He]=String(He);var He;for(He=1;He<=24;He++)Mr[He+111]="F"+He;var He;for(He=65;He<=90;He++)Mr[He]=String.fromCharCode(He+32),us[He]=String.fromCharCode(He);var He;for(cs in Mr)us.hasOwnProperty(cs)||(us[cs]=Mr[cs]);var cs;function lf(e){var t=d3&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||m3&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?us:Mr)[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(lf,"keyName");import{Plugin as p3}from"prosemirror-state";var f3=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function g3(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))f3?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(g3,"normalizeKeyName");function h3(e){let t=Object.create(null);for(let r in e)t[g3(r)]=e[r];return t}s(h3,"normalize");function Ac(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(Ac,"modifiers");function cf(e){return new p3({props:{handleKeyDown:b3(e)}})}s(cf,"keymap");function b3(e){let t=h3(e);return function(r,o){let n=lf(o),i,a=t[Ac(n,o)];if(a&&a(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let l=t[Ac(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=Mr[o.keyCode])&&i!=n){let l=t[Ac(i,o)];if(l&&l(r.state,r.dispatch,r))return!0}}return!1}}s(b3,"keydownHandler");import{v4 as E3}from"uuid";var Sc=en.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){Oe(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-${E3()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:ue.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):ue.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:ue.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):ue.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:ue.textAlign,parseHTML:e=>e.style.textAlign||ue.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:ue.backgroundColor,parseHTML:e=>e.style.backgroundColor||ue.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:ue.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):ue.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:ue.borderColor,parseHTML:e=>e.style.borderColor||ue.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",y3(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return C3(is)},addProseMirrorPlugins(){return[cf({"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(v3.create(t.doc,i,a)),!0}return!1}}),new x3({key:new T3("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()}}});import{Extension as w3}from"@tiptap/core";import{Plugin as k3,PluginKey as P3}from"@tiptap/pm/state";var N3=new P3("selection"),Ic=w3.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 k3({key:N3,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}}})]}});import{forwardRef as M3}from"react";import{jsx as A3}from"react/jsx-runtime";var Lc=M3(({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 A3("div",{className:a,...n,ref:i,children:e})});Lc.displayName="Surface";import{v4 as S3}from"uuid";var I3=s((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),bf=s((e,t,r,o,n,i)=>{let a=`node-${S3()}`,c={heading:()=>e.schema.nodes.heading.create({...ue,...o,id:a},i),paragraph:()=>e.schema.nodes.paragraph.create({...ue,...o,id:a},i),text:()=>e.schema.nodes.paragraph.create({...ue,...o,id:a},i),spacer:()=>e.schema.nodes.divider.create({...Xa,...o,id:a}),divider:()=>e.schema.nodes.divider.create({...Mt,...o,id:a}),button:()=>e.schema.nodes.button.create({...Ie,...o,id:a},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...Be,...o,id:a}),image:()=>e.schema.nodes.imageBlock.create({...Be,...o,id:a}),customCode:()=>e.schema.nodes.customCode.create({...Pr,...o,id:a}),column:()=>e.schema.nodes.column.create({...qe,...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=I3(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 jr=s(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),We=s(e=>{let t=jr(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");import{GripVertical as L3}from"lucide-react";import{forwardRef as R3}from"react";import{jsx as yf}from"react/jsx-runtime";var Cf=R3((e,t)=>yf("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:yf(L3,{strokeWidth:1,className:"courier-w-5 courier-stroke-neutral-400 courier-fill-neutral-400 courier-pointer-events-none"})}));import{useAtomValue as B3,useSetAtom as D3}from"jotai";import{useCallback as At}from"react";import{v4 as F3}from"uuid";import{useMemo as H3}from"react";var vf=s((e,t,r)=>H3(()=>{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 ds=s((e,t,r)=>{let o=D3(Re),n=B3(ge),i=vf(t,e,r),a=At(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=At((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=At(()=>{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=At(()=>{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=At(()=>{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=At(()=>{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=At(()=>{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=At(()=>e.chain().focus().setTextAlign("left").run(),[e]),v=At(()=>e.chain().focus().setTextAlign("center").run(),[e]),h=At(()=>e.chain().focus().setTextAlign("right").run(),[e]),b=At(()=>e.chain().focus().setTextAlign("justify").run(),[e]),y=At((g,P)=>e.chain().focus().setLink({href:g,target:P?"_blank":""}).run(),[e]),N=At(()=>{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-${F3()}`,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");import{jsx as Rc}from"react/jsx-runtime";var V3=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"),ms=s(({type:e})=>Rc("div",{className:"courier-flex courier-w-full courier-pointer-events-none",children:Rc("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:Rc("div",{className:"courier-text-accent-foreground dark:courier-text-accent",children:V3(e)})})}),"DropIndicatorPlaceholder");import{Fragment as Z3,jsx as St,jsxs as ps}from"react/jsx-runtime";function z3(){let[e,t]=fs(!1);return Hc(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(z3,"useMountStatus");var Ye=s(({children:e,id:t,className:r,editor:o,getPos:n,...i})=>{let a=Yr(null),l=Yr(null),c=Yr(null),[u,d]=fs(!1),[m,p]=fs(null),[f,v]=fs(null),h=Yr(null),b=Yr(!1),y=Yr(null),N=Yr(null),g=Yr(null),P=z3(),M=u&&!P,T=Ao(()=>{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=Ao(()=>{if(!o)return!1;let E=T();return!E||!E.parent?!1:E.index===E.parent.childCount-1},[o,T]);return Hc(()=>{let E=a.current,C=l.current;if(!E)return;let x=sr(gi({element:E,dragHandle:C||void 0,getInitialData:()=>{var S,H,V,F,O,B;let w=T(),A="text";if(w){let W=w.node;switch(W.type.name){case"heading":A="heading";break;case"paragraph":A="text";break;case"imageBlock":A="image";break;case"divider":A=(S=W.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)}}),Pt({element:E,getData:({input:w,element:A})=>{var B,W,U,ie;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:(W=k==null?void 0:k.index)!=null?W:0,pos:k==null?void 0:k.pos,nodeType:k==null?void 0:k.node.type.name,columnId:S?(U=k==null?void 0:k.parent)==null?void 0:U.attrs.columnId:void 0,cellIndex:S?(ie=k==null?void 0:k.parent)==null?void 0:ie.attrs.index:void 0};if(A.getAttribute("data-node-type")==="column"){let ee=A.getBoundingClientRect(),K=w.clientY,D=30,z=Math.abs(K-ee.top),oe=Math.abs(K-ee.bottom);if(z>D&&oe>D)return{...H,disableDropIndicator:!0}}let F=A.closest('[data-column-cell="true"]');if(R()&&E){let ee=E.getBoundingClientRect(),K=w.clientY,D=ee.top+ee.height/2;if(K>=D&&K>ee.bottom)return{...H,[Symbol.for("closestEdge")]:"bottom"}}let O=R()?["top","bottom"]:["top"];return Gm(H,{input:w,element:A,allowedEdges:O})},canDrop:({source:w})=>w.data.id!==t,onDragEnter:({self:w,source:A,location:k})=>{var W,U,ie,ee,K;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=hi(w.data),H=S,V=R(),F=(ie=(U=(W=k==null?void 0:k.current)==null?void 0:W.input)==null?void 0:U.clientY)!=null?ie: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(),oe=(ee=F!=null?F:N.current)!=null?ee:z.top+z.height/2,be=z.top+z.height/2,Pe=z.height,Me=Math.max(10,Math.min(30,Pe*.3));oe<be-Me?(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();((K=z==null?void 0:z.index)!=null?K:0)===D+1&&S==="top"&&(H=null)}H!==h.current&&(h.current=H,p(H))},onDrag:({self:w,source:A,location:k})=>{var W,U,ie,ee,K;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=(ie=(U=(W=k==null?void 0:k.current)==null?void 0:W.input)==null?void 0:U.clientY)!=null?ie:N.current;S!==null&&(N.current=S);let H=hi(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(),oe=(ee=S!=null?S:N.current)!=null?ee:z.top+z.height/2,be=z.top+z.height/2,Pe=z.height,Me=Math.max(10,Math.min(30,Pe*.3));oe<be-Me?(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();((K=z==null?void 0:z.index)!=null?K: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]),St($3,{ref:a,id:t,fadeIn:M,className:r,dragging:u,closestEdge:m,dragType:f,handleRef:l,contentRef:c,editor:o,...i,children:e})},"SortableItemWrapper"),$3=W3(({children:e,className:t,dragOverlay:r,handleRef:o,contentRef:n,closestEdge:i,dragType:a,id:l,editor:c,fadeIn:u,dragging:d,...m},p)=>{Hc(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let f=U3(ge),{resetButtonFormatting:v}=ds(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=Ao(()=>{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=Ao(()=>{c.commands.blur(),f(null)},[c,f]),N=Ao(()=>{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-${_3()}`,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=Ao(()=>{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=Ao(()=>{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);bf(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 ps(O3,{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"&&St(ms,{type:a}),ps("div",{className:"courier-flex courier-items-center courier-justify-center courier-gap-2 courier-pl-10",children:[St(Cf,{ref:o,className:"courier-absolute courier-left-[-8px]",tabIndex:-1,"data-no-drag-preview":!0}),St("div",{ref:n,className:"courier-flex-1 courier-grow draggable-content-wrapper",children:e}),ps("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"&&ps(Z3,{children:[St("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:St(Fl,{color:"currentColor"})}),St(le,{className:"!courier-my-0"})]}),St("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:St(Al,{color:"currentColor"})}),St(le,{className:"!courier-my-0"}),St("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:St(Jn,{color:"currentColor"})})]})]}),i==="bottom"&&St(ms,{type:a})]})});import{jsx as ln}from"react/jsx-runtime";var G3=s(({alignment:e,backgroundColor:t,textColor:r,borderRadius:o,padding:n,fontWeight:i,fontStyle:a,children:l})=>ln("div",{className:"courier-w-full node-element",children:ln("div",{className:"courier-flex",children:ln("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"),xf=s(e=>{let t=J3(Re),r=j3(()=>{if(!e.editor.isEditable)return;let o=We(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 ln(Ye,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,"data-node-type":"button",children:ln(G3,{...e.node.attrs,children:ln(q3,{as:"span"})})})},"ButtonComponentNode");import{v4 as Q3}from"uuid";var Ie={label:"Button",link:"",alignment:"center",backgroundColor:"#0085FF",borderRadius:0,padding:6,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1,textColor:"#ffffff",borderColor:"transparent"},za=Y3.create({name:"button",group:"block",content:"inline*",selectable:!1,isolating:!0,onCreate(){Oe(this.editor,this.name)},addAttributes(){return{label:{default:Ie.label,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},link:{default:Ie.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alignment:{default:Ie.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},backgroundColor:{default:Ie.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},textColor:{default:Ie.textColor,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.textColor})},borderRadius:{default:Ie.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:Ie.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},padding:{default:Ie.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.padding})},fontWeight:{default:Ie.fontWeight,parseHTML:e=>e.getAttribute("data-font-weight"),renderHTML:e=>({"data-font-weight":e.fontWeight})},fontStyle:{default:Ie.fontStyle,parseHTML:e=>e.getAttribute("data-font-style"),renderHTML:e=>({"data-font-style":e.fontStyle})},isUnderline:{default:Ie.isUnderline,parseHTML:e=>e.getAttribute("data-is-underline"),renderHTML:e=>({"data-is-underline":e.isUnderline})},isStrike:{default:Ie.isStrike,parseHTML:e=>e.getAttribute("data-is-strike"),renderHTML:e=>({"data-is-strike":e.isStrike})},id:{default:()=>`node-${Q3()}`,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",K3(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return X3(xf)},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()}}});import{v4 as ey}from"uuid";import{useAtomValue as Tf,useSetAtom as Ef,useAtom as ty}from"jotai";import{useCallback as cn,useRef as wf,useState as gs,useEffect as ry}from"react";var un=s(({items:e,setItems:t,editor:r})=>{let[o]=gs(null),[n,i]=gs(null),[a,l]=gs(null),[c]=gs("outer"),u=wf([]),d=wf([]),m=Tf(Te),p=Ef(pt),[f,v]=ty(X),h=Ef(Ae),b=Tf(Ur),y=r||m,N=cn(()=>{if(!y)return;let E=y.getJSON(),C=me(E),x=Ve(f,{channel:b,elements:C});v(x),h(x)},[y,b,f,v,h]),g=cn(()=>{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=cn(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=cn(E=>{let C={};switch(E){case"text":C=ue;break;case"heading":C={};break;case"image":C=Be;break;case"button":C=Ie;break;case"divider":C=Mt;break;case"spacer":C=Xa;break;case"customCode":C=Pr;break;case"column":C=qe;break}let w={type:E==="text"?"paragraph":E==="image"?"imageBlock":E==="spacer"?"divider":E,attrs:{...C,id:ey()}};return E==="button"&&(w.content=[{type:"text",text:"Button"}]),w},[]),T=cn((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,W)=>B.attrs.id===E.id?(S=W,k=B.toJSON(),L=B.nodeSize,!1):!0),S===-1){let B=e.Editor.findIndex(W=>W===E.id);if(B!==-1){S=P(B);let W=y.state.doc.nodeAt(S);W&&(k=W.toJSON(),L=W.nodeSize)}}if(S!==-1){let B=e.Editor.filter(W=>W!==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,W)=>B.type.name==="column"&&B.attrs.id===x?(H=W,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,W=Array.from({length:F.attrs.columnsCount},(ie,ee)=>B.nodes.columnCell.create({index:ee,columnId:x,isEditorMode:!1},ee===w?[B.nodeFromJSON(k)]:[])),U=B.nodes.columnRow.create({},W);O.replaceWith(H+1,H+F.nodeSize-1,U)}else{let B=H+1;F.content.forEach(W=>{if(W.type.name==="columnRow"){let U=B+1;W.content.forEach((ie,ee,K)=>{if(K===w){let D=U+ie.nodeSize-1;O.insert(D,y.schema.nodeFromJSON(k))}U+=ie.nodeSize})}B+=W.nodeSize})}y.view.dispatch(O),N()},[y,e,t,P,M,N]),R=cn((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 ry(()=>rc({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=hi(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((ie,ee)=>{let K=ie.top+ie.height/2,D=Math.abs(H-K);D<F&&(F=D,V=ee)});let O=d.current[V],B=O.top+O.height/2,U=H>=B?V:V-1;k={...k,index:U,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");import{useCallback as oy,useEffect as ny}from"react";import{useAtomValue as iy}from"jotai";var hs=s(({setItems:e,rafId:t,editor:r})=>{let o=iy(Te),n=r||o,i=oy(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 ny(()=>{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");import{Fragment as uy,jsx as Fc}from"react/jsx-runtime";var wi=[{type:"text",align:"left",content:`
|
|
187
|
-
`,text_style:"h1"},{type:"text",align:"left",content:""},{type:"image",src:""}],cy=sy(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:a,colorScheme:l,hidePreviewPanelExitButton:c,...u},d)=>{let m=So(Te),[p,f]=Bc(ge),[v,h]=Bc(ao),b=Ei({}),[y,N]=Dc(c?"desktop":void 0),g=So(Fe),P=So(ae),M=So(Lu),T=So(ar),R=Ei(-1),E=ay(rm),C=Ei(!1),x=Ei(!1),[w]=Bc(X),A=So(Jt),k=So(ze),[L,S]=Dc({Editor:[],Sidebar:["heading","text","image","spacer","divider","button","customCode"]}),H=Ei(null);un({items:L,setItems:S,editor:m});let{syncEditorItems:V}=hs({setItems:S,rafId:H,editor:m});Xr(()=>{k&&(x.current=!1)},[k]);let[F,O]=Dc(!1);Xr(()=>{if(P===!1||P===null){let D=setTimeout(()=>{O(!0)},100);return()=>clearTimeout(D)}else O(!1)},[P,F]),Xr(()=>{if(p){let D=p.type.name,z=aa(D);E({nodeName:D,config:z})}},[p,E]);let B=Pf(()=>{var z,oe,be,Pe,Me,Et,wt,se,Ee,ye,it,at,Ot,Ut,Wt,_t,Fr,Vr,te,Cr,no,io,Nn,Mn,An,Sn,In,Ln,Y,re,de,he,ke,zt;if(T)return T;let D=(be=(oe=(z=g==null?void 0:g.data)==null?void 0:z.tenant)==null?void 0:oe.brand)==null?void 0:be.settings;return{brandColor:((Pe=D==null?void 0:D.colors)==null?void 0:Pe.primary)||"#000000",textColor:((Me=D==null?void 0:D.colors)==null?void 0:Me.secondary)||"#000000",subtleColor:((Et=D==null?void 0:D.colors)==null?void 0:Et.tertiary)||"#666666",headerStyle:(se=(wt=D==null?void 0:D.email)==null?void 0:wt.header)!=null&&se.barColor?"border":"plain",logo:(it=(ye=(Ee=D==null?void 0:D.email)==null?void 0:Ee.header)==null?void 0:ye.logo)==null?void 0:it.image,link:(Ut=(Ot=(at=D==null?void 0:D.email)==null?void 0:at.header)==null?void 0:Ot.logo)==null?void 0:Ut.href,facebookLink:(Vr=(Fr=(_t=(Wt=D==null?void 0:D.email)==null?void 0:Wt.footer)==null?void 0:_t.social)==null?void 0:Fr.facebook)==null?void 0:Vr.url,linkedinLink:(io=(no=(Cr=(te=D==null?void 0:D.email)==null?void 0:te.footer)==null?void 0:Cr.social)==null?void 0:no.linkedin)==null?void 0:io.url,instagramLink:(Sn=(An=(Mn=(Nn=D==null?void 0:D.email)==null?void 0:Nn.footer)==null?void 0:Mn.social)==null?void 0:An.instagram)==null?void 0:Sn.url,mediumLink:(re=(Y=(Ln=(In=D==null?void 0:D.email)==null?void 0:In.footer)==null?void 0:Ln.social)==null?void 0:Y.medium)==null?void 0:re.url,xLink:(zt=(ke=(he=(de=D==null?void 0:D.email)==null?void 0:de.footer)==null?void 0:he.social)==null?void 0:ke.twitter)==null?void 0:zt.url}},[T,g]),W=M&&!!B,U=kf(()=>{Object.values(b.current).forEach(D=>clearTimeout(D)),b.current={}},[]);Xr(()=>()=>{U()},[U]),Xr(()=>{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 oe=-1;p&&m.state.doc.content.forEach((Me,Et,wt)=>{p.attrs.id===Me.attrs.id&&(oe=wt)}),oe===-1&&(oe=0);let be=m.state.doc,Pe;if(z.shiftKey?Pe=(oe-1+be.childCount)%be.childCount:Pe=(oe+1)%be.childCount,Pe!==oe||p===null){let Me=be.child(Pe);f(Me),m.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",D),()=>{document.removeEventListener("keydown",D)}},[m,p,f]),Xr(()=>{if(P!==!1||k)return;let D=w!=null?w:"";if(D){let z=Qs(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]),Xr(()=>{P===!1&&g&&!x.current&&(x.current=!0,setTimeout(()=>{m&&!m.isDestroyed&&V(m)},300))},[P,g,m,V]),Xr(()=>(C.current=!0,()=>{C.current=!1}),[]);let ie=kf(D=>{let oe=D||(y===void 0?"desktop":void 0);N(oe),f(null),oe?m==null||m.setEditable(!1):m==null||m.setEditable(!0)},[m,y,N,f]),ee=s(D=>{h(D.target.value)},"handleSubjectChange"),K=Pf(()=>{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(be=>be.type==="channel"&&be.channel==="email")),z||(z={type:"channel",channel:"email",elements:wi}),Se({version:"2022-01-01",elements:[z]},{channel:"email"})},[a,P,F]);return k&&(w===null||K===null)?null:Fc(ht,{theme:t,colorScheme:l,isLoading:!!P,Header:i?i({hidePublish:e,channels:r,routing:o}):Fc(Dt,{hidePublish:e,channels:r,routing:o}),...u,children:Fc(uy,{children:n==null?void 0:n({subject:v,handleSubjectChange:ee,selectedNode:p,setSelectedNode:f,previewMode:y,templateEditor:m,ref:d,isBrandApply:W,brandSettings:B,items:L,content:K,syncEditorItems:V,brandEditorContent:A,templateData:g,togglePreviewMode:ie,hidePreviewPanelExitButton:c})})})}),bs=ly(cy);var ys=class ys{};s(ys,"UploadImageAPI"),ys.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 Vc=ys,Oc=Vc;var bt=s(e=>[Cc,hf.configure({document:!1,dropcursor:!1,gapcursor:!1,heading:!1,horizontalRule:!1,paragraph:!1,blockquote:!1,hardBreak:!1,code:!1}),Ic.configure({setSelectedNode:e==null?void 0:e.setSelectedNode,shouldHandleClick:e==null?void 0:e.shouldHandleClick}),df.configure({keepMarks:!0,HTMLAttributes:{class:"my-line-break"}}),Wp,yc,Sc,nc,Tc.configure({levels:[1,2,3,4,5,6]}),za,$a,uf,Za,qa,Ja,Ga,Nc.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),gf,as.configure(),es.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(t,r,o)=>{r.forEach(async n=>{let i=await Oc.uploadImage(n);t.chain().setImageBlockAt({pos:o,src:i}).focus().run()})},onPaste:(t,r)=>{r.forEach(async o=>{let n=await Oc.uploadImage(o);return t.chain().setImageBlockAt({pos:t.state.selection.anchor,src:n}).focus().run()})}}),pf.extend({addKeyboardShortcuts(){return{}}}).configure({types:["paragraph","heading"]}),ff,mf.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:"",emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",showOnlyWhenEditable:!0}),oc.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),cc,xo,To,ts,ns],"ExtensionKit");import{BubbleMenu as Wy,useCurrentEditor as _y}from"@tiptap/react";import{useAtomValue as dy}from"jotai";import{useCallback as Nf,useEffect as my,useState as py}from"react";var Cs=s(e=>{let t=dy(ge),[r,o]=py({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1}),n=Nf(()=>{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 my(()=>{if(e)return n(),e.on("selectionUpdate",n),e.on("transaction",n),()=>{e.off("selectionUpdate",n),e.off("transaction",n)}},[e,n]),{shouldShow:Nf(({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");import{useAtomValue as Wc}from"jotai";import{AlignCenter as wy,AlignJustify as ky,AlignLeft as Py,AlignRight as Ny,Bold as My,Italic as Ay,Link as Sy,Quote as Iy,Strikethrough as Ly,Underline as Ry}from"lucide-react";import{Fragment as Hy,memo as Ff,useMemo as Df,useRef as By,useState as Dy,useEffect as Fy}from"react";import{forwardRef as Uc}from"react";import fy from"@tippyjs/react";import{useCallback as gy}from"react";import{Fragment as yy,jsx as fr,jsxs as by}from"react/jsx-runtime";var Mf=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,hy=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"?fr("kbd",{className:t,children:Mf?"\u2318":"Ctrl"}):e==="Shift"?fr("kbd",{className:t,children:"\u21E7"}):e==="Alt"?fr("kbd",{className:t,children:Mf?"\u2325":"Alt"}):fr("kbd",{className:t,children:e})},"ShortcutKey"),Af=s(({children:e,enabled:t=!0,title:r,shortcut:o,tippyOptions:n={}})=>{let i=vd(),a=gy(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 by("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&&fr("span",{className:"courier-text-xs courier-font-medium courier-text-muted-foreground",children:r}),o&&fr("span",{className:"courier-flex courier-items-center courier-gap-0.5",children:o.map(u=>fr(hy,{children:u},u))})]})},[o,r,i]);return t?fr(fy,{...n,delay:500,offset:[0,8],touch:!1,zIndex:99999,appendTo:document.body,trigger:"mouseenter focus",showOnCreate:!1,render:a,animation:!1,children:fr("span",{children:e})}):fr(yy,{children:e})},"Tooltip");import{jsx as vs}from"react/jsx-runtime";var Sf=Uc(({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&&vs(Lc,{className:a,...n,ref:i,children:t})});Sf.displayName="Toolbar";var If=Uc(({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 vs("div",{className:n,ref:o,...r})});If.displayName="Toolbar.Divider";var Lf=Uc(({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=vs(Ce,{className:c,variant:r,buttonSize:t,ref:l,...a,children:e});return n?vs(Af,{title:n,shortcut:i,children:u}):u});Lf.displayName="ToolbarButton";var xs={Wrapper:Sf,Divider:If,Button:Lf};import{ChevronDown as Cy}from"lucide-react";import{useMemo as vy}from"react";import{Fragment as Ty,jsx as Qr,jsxs as Rf}from"react/jsx-runtime";var xy=s(e=>e.type==="option","isOption"),Hf=s(({options:e,containerRef:t})=>{let r=vy(()=>e.find(o=>o.type==="option"&&o.isActive()),[e]);return Rf(Yi,{children:[Qr(Xi,{asChild:!0,children:Rf(Ce,{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",Qr(Cy,{className:"courier-w-3 courier-h-3"})]})}),Qr(Wn,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(xy(o))return Qr(_n,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?Qr(Ty,{children:o.id==="heading1"?Qr("h1",{className:"courier-text-2xl courier-font-bold",children:o.label}):o.id==="heading2"?Qr("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading3"?Qr("h3",{className:"courier-text-lg courier-font-bold",children:o.label}):o.label}):o.label},o.id)})})]})},"ContentTypePicker");import{useEditorState as Ey}from"@tiptap/react";var Bf=s(e=>Ey({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");import{jsx as tt,jsxs as Uy}from"react/jsx-runtime";var Vy=Ff(xs.Button),Oy=Ff(Hf),_c=s(({editor:e,config:t})=>{var R;let r=Cs(e),o=Bf(e),n=By(null),i=Wc(sa),a=Wc(ge),l=a==null?void 0:a.type.name,c=Wc(tm),[u,d]=Dy(()=>{let{selection:E}=e.state;return{from:E.from,to:E.to,empty:E.empty}});Fy(()=>{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=Df(()=>!u.empty&&u.from!==u.to,[u]),p=Df(()=>t||c(l||"",m),[t,c,l,m]),f=ds(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),W=V.split(`
|
|
188
|
-
`).length-1,U=new CustomEvent("showVariableSuggestions",{detail:{cursorPosition:{left:Math.min(O%E.offsetWidth,E.offsetWidth-200),top:W*B+30}},bubbles:!0});E.dispatchEvent(U)}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:tt(Vy,{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?tt("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"&&tt(Oy,{options:o,containerRef:n},"content-type")],"content-type-group"),g=y([b("bold",tt(My,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",f.onBold,r.isBold,["Mod","B"]),b("italic",tt(Ay,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",f.onItalic,r.isItalic,["Mod","I"]),b("underline",tt(Ry,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",f.onUnderline,r.isUnderline,["Mod","U"]),b("strike",tt(Ly,{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",tt(Py,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",f.onAlignLeft,r.isAlignLeft,["Shift","Mod","L"]),b("alignCenter",tt(wy,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",f.onAlignCenter,r.isAlignCenter,["Shift","Mod","E"]),b("alignRight",tt(Ny,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",f.onAlignRight,r.isAlignRight,["Shift","Mod","R"]),b("alignJustify",tt(ky,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",f.onAlignJustify,r.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),M=y([b("quote",tt(Iy,{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",tt(Sy,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",v,r.isLink,["Mod","K"]),b("variable",tt(Gd,{width:16}),"Variable",h,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return tt(xs.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)=>Uy(Hy,{children:[E,C<[N,g,P,M,T].filter(Boolean).length-1&&tt(xs.Divider,{})]},`item-${C}`))})},"TextMenu");import{jsx as Vf}from"react/jsx-runtime";var yt=s(({config:e})=>{let{editor:t}=_y(),r=Cs(t);return t?Vf(Wy,{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&&Vf(_c,{editor:t,config:e})}):null},"BubbleTextMenu");import{TextSelection as zy}from"@tiptap/pm/state";import{EditorProvider as $y,Extension as Zy,useCurrentEditor as qy}from"@tiptap/react";import{useAtomValue as Jy,useSetAtom as Of}from"jotai";import{memo as jy,useEffect as $c,useMemo as Gy,useRef as Uf}from"react";import{jsx as Ft,jsxs as zc}from"react/jsx-runtime";var Ky=s(({value:e,readOnly:t})=>{let{editor:r}=qy(),o=Of(_o),n=Jy(ae),i=Uf(!1);return $c(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(Ys(e!=null?e:"")))},[r,e,n,t]),$c(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),Yy=s(({facebookLink:e,linkedinLink:t,instagramLink:r,mediumLink:o,xLink:n,readOnly:i=!1,value:a,onUpdate:l})=>{let c=Uf(!1),u=Of(ge),d=Zy.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:p})=>{let{state:f,dispatch:v}=p.view;return v(f.tr.setSelection(zy.create(f.doc,f.selection.$anchor.pos))),u&&u(null),!1}}}});$c(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=Gy(()=>[...bt({setSelectedNode:u}),d].filter(p=>p!==void 0),[d,u]);return zc("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[zc($y,{content:Ys(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:[Ft(Ky,{value:a,readOnly:i}),Ft(yt,{})]}),zc("div",{className:"courier-flex courier-justify-end courier-items-center courier-gap-2 courier-mt-3",children:[e&&Ft("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:Ft(Kn,{className:"courier-w-5 courier-h-5"})}),t&&Ft("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:Ft(Qn,{className:"courier-w-5 courier-h-5"})}),r&&Ft("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:Ft(Xn,{className:"courier-w-5 courier-h-5"})}),o&&Ft("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:Ft(ei,{className:"courier-w-5 courier-h-5"})}),n&&Ft("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:Ft(ii,{className:"courier-w-5 courier-h-5"})})]})]})},"BrandFooterComponent"),ki=jy(Yy);import{Fragment as Xy,jsx as dn,jsxs as Ts}from"react/jsx-runtime";var Wf=s(({value:e,icon:t,...r})=>dn(lt,{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"),Zc=s(({previewMode:e,togglePreviewMode:t,hideMobileToggle:r=!1,hideExitButton:o=!1,...n})=>Ts("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&&Ts(Xy,{children:[Ts(qt,{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:[dn(Wf,{value:"desktop",icon:dn(Ml,{})}),dn(Wf,{value:"mobile",icon:dn(Hl,{})})]}),!o&&dn("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),!o&&Ts(Ce,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");import{forwardRef as qf}from"react";function Qy(){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(Qy,"initTestHelpers");function Ct(e,t){typeof window!="undefined"&&(Qy(),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(Ct,"setTestEditor");import{Extension as rC}from"@tiptap/core";import{TextSelection as oC}from"@tiptap/pm/state";import{EditorProvider as nC,useCurrentEditor as iC}from"@tiptap/react";import{useAtom as _f,useAtomValue as Ar,useSetAtom as Io}from"jotai";import{useCallback as eo,useEffect as It,useMemo as aC,useRef as gr}from"react";import{useCurrentEditor as eC}from"@tiptap/react";import{useEffect as tC}from"react";var Vt=s(({value:e,defaultValue:t})=>{let{editor:r}=eC();return tC(()=>{if(!r)return;let o=setTimeout(()=>{r.commands.setContent(e||t)},0);return()=>clearTimeout(o)},[r,e,t]),null},"ReadOnlyEditorContent");import{Fragment as cC,jsx as Pi,jsxs as uC}from"react/jsx-runtime";var sC=s(({value:e})=>{let{editor:t}=iC(),[r,o]=_f(X),n=Io(Ae),i=Ar(ao),a=Ar(ge),l=Io(Te),c=Io(lo),u=gr(!1),d=gr(),m=Ar(ae),p=Ar(Fe),f=gr(!1),v=Ar(ze);return It(()=>{m&&(f.current=!1)},[m]),It(()=>(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=me(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=Bn(T,"email"))}let g=$t(r,"email",N||"",y),P={elements:g.elements,channel:"email",...g.raw&&{raw:g.raw}},M=Ve(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]),It(()=>{!t||m!==!1||f.current||!e||(l(t),f.current=!0,t.commands.setContent(e))},[t,e,l,m]),It(()=>{if(!(!(t&&i!==null)||m!==!1||v)&&!t.isFocused)return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var h;try{let b=me(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=Bn(M,"email"))}let N=$t(r,"email",y||"",b),g={elements:N.elements,channel:"email",...N.raw&&{raw:N.raw}},P=Ve(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]),It(()=>()=>{t&&!t.isDestroyed&&t.setEditable(!0)},[t]),It(()=>{t&&u.current&&t.commands.updateSelectionState(a)},[t,a]),It(()=>(u.current=!0,()=>{u.current=!1}),[]),null},"EditorContent"),lC=s(({value:e,readOnly:t=!1,onDestroy:r,onUpdate:o,subject:n})=>{let i=Io(la),a=gr(),[l,c]=_f(X),u=Ar(ao),d=n!=null?n:u,m=Io(ge),p=Ar(Te),f=Ar(ze),v=Ar(pt),h=Io(lo),b=Io(Ae),y=gr(l),N=gr(d),g=gr(v);It(()=>{y.current=l},[l]),It(()=>{N.current=d},[d]),It(()=>{g.current=v},[v]),It(()=>{p==null||p.setEditable(!t)},[t,p]);let P=rC.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:O})=>{let{state:B,dispatch:W}=O.view;return W(B.tr.setSelection(oC.create(B.doc,B.selection.$anchor.pos))),m&&m(null),!1}}}}),M=eo(({editor:O})=>{o==null||o(O),Ct("email",O),m&&setTimeout(()=>{m(null)},100)},[m,o]),T=gr(),R=gr(null),E=eo((O,B)=>{var z;if(f)return;let W=y.current,U=N.current;if(!W){let oe={version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:B}]};c(oe),b(oe);return}let ie=W.elements.find(oe=>oe.type==="channel"&&oe.channel==="email"),ee={...ie};ee.elements=(z=ee.elements)==null?void 0:z.filter(oe=>oe.type!=="meta");let K={type:"channel",channel:"email",elements:B};if(JSON.stringify(ee)!==JSON.stringify(K)){let oe=U;!U&&ie&&(oe=Bn(ie,"email"));let be=$t(W,"email",oe||"",B);K.elements=be.elements,be.raw&&(K.raw=be.raw);let Pe=Ve(W,K);c(Pe),b(Pe)}o==null||o(O),Ct("email",O)},[c,b,o,f]),C=eo(({editor:O})=>{let B=me(O.getJSON());R.current={editor:O,elemental:B},T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{if(R.current){let{editor:W,elemental:U}=R.current;E(W,U),R.current=null}},200)},[E]),x=eo(({editor:O})=>{if(g.current)return;let{selection:B}=O.state,{$anchor:W}=B,ie=B.$head.marks().find(z=>z.type.name==="link");ie||O.isActive("link")?i({mark:ie}):i(null);let ee=W.depth,K=null,D=null;for(;ee>0;){let z=W.node(ee);!D&&z.type.name==="blockquote"&&(D=z),!K&&(z.type.name==="paragraph"||z.type.name==="heading")&&(K=z),ee--}D?m(D):K&&m(K)},[i,m]),w=eo(({editor:O,transaction:B})=>{let W=B==null?void 0:B.getMeta("showLinkForm");if(W){let{selection:U}=O.state,ee=U.$head.marks().find(K=>K.type.name==="link");i({mark:ee,link:{from:W.from,to:W.to}})}},[i]),A=eo(()=>{a.current&&clearTimeout(a.current),T.current&&clearTimeout(T.current),r==null||r(),Ct("email",null)},[r]);It(()=>(h({action:"register",id:"email-content",fn:s(()=>{if(T.current&&(clearTimeout(T.current),T.current=void 0,R.current)){let{editor:B,elemental:W}=R.current;E(B,W),R.current=null}},"flushContentUpdate")}),()=>{h({action:"unregister",id:"email-content"})}),[E,h]);let k=eo(O=>{var ee;if(g.current)return;let B=(ee=O.view)==null?void 0:ee.editor;if(!B||!B.isEditable)return;let W=O.target,U=B.view.posAtDOM(W,0),ie=B.state.doc.resolve(U).node();ie.type.name==="paragraph"&&m(ie)},[m]),L=eo(()=>!g.current,[]),S=aC(()=>[...bt({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=gr(null);return It(()=>{let O=F.current;if(!(!O||t))return Pt({element:O,getData:()=>({type:"editor",id:"editor-drop-zone"}),canDrop:({source:B})=>B.data.type==="sidebar"?!0:B.data.type==="editor"})},[t]),Pi("div",{ref:F,"data-testid":"email-editor",children:Pi(nC,{content:H,extensions:S,...V,onDestroy:A,editorContainerProps:{onClick:k},immediatelyRender:!1,children:t?Pi(Vt,{value:H,defaultValue:wi}):uC(cC,{children:[Pi(sC,{value:H}),Pi(yt,{})]})})})},"EmailEditor"),qc=lC;import{useAtomValue as zf,useSetAtom as hC}from"jotai";import{GripVertical as bC}from"lucide-react";import{forwardRef as dC,useEffect as mC,useRef as pC,useState as fC}from"react";import{jsx as Jc}from"react/jsx-runtime";var mn=s(({children:e,id:t,className:r,editor:o})=>Jc(gC,{id:t,className:r,editor:o,children:e}),"SideBarSortableItemWrapper"),gC=dC(({children:e,className:t,id:r,editor:o},n)=>{let i=pC(null),[a,l]=fC(!1);return mC(()=>{let c=i.current;if(!(!c||!r))return sr(gi({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]),Jc("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:Jc("div",{children:e})})});import{Fragment as yC,jsx as De,jsxs as pn}from"react/jsx-runtime";var jc=s(({items:e,brandEditor:t,label:r,editor:o})=>{var l,c;let n=zf(Fe),i=hC(jo),a=zf(Ge);return pn("div",{className:"courier-flex courier-flex-col courier-h-full",children:[pn("div",{className:"courier-flex-1",children:[r&&pn(yC,{children:[De("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:r}),De(le,{className:"courier-my-4"})]}),De("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(u=>De(mn,{id:u.toString(),editor:o,children:pn("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:[De(bC,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),u==="heading"&&De(Na,{draggable:!0}),u==="text"&&De(Zr,{draggable:!0}),u==="image"&&De(Aa,{draggable:!0}),u==="spacer"&&De(Sa,{draggable:!0}),u==="divider"&&De($r,{draggable:!0}),u==="button"&&De(zr,{draggable:!0}),u==="customCode"&&De(bi,{draggable:!0}),u==="column"&&De(Ea,{draggable:!0})]})},u))})]}),t&&pn("div",{className:"courier-mt-auto courier-pt-4",children:[De(le,{className:"courier-mb-4 -courier-mx-4"}),(c=(l=n==null?void 0:n.data)==null?void 0:l.tenant)!=null&&c.brand?De("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:De(Ce,{variant:"link",className:"courier-underline",onClick:()=>i("brand"),disabled:!!a,children:"Edit brand"})}):pn("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[De("h3",{className:"courier-text-md courier-font-medium courier-text-foreground",children:"Customize brand theme"}),De("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),De(Ce,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>i("brand"),children:"Customize"})]})]})]})},"SideBar");import{useAtomValue as CC}from"jotai";import{jsx as to,jsxs as vC}from"react/jsx-runtime";var Gc=s(({element:e,editor:t})=>{var i,a;let r=CC($l);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 to(sf,{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 vC("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[e.type.name==="button"&&to(yp,{element:e,editor:t},e.attrs.id),e.type.name==="divider"&&to(Vp,{element:e,editor:t},e.attrs.id),["paragraph","heading"].includes(e.type.name)&&!o&&to(qp,{element:e,editor:t},e.attrs.id),e.type.name==="imageBlock"&&to(tf,{element:e,editor:t},e.attrs.id),e.type.name==="customCode"&&to(hc,{element:e,editor:t},e.attrs.id),(e.type.name==="blockquote"||e.type.name==="paragraph"&&o||e.type.name==="heading"&&o)&&to(sp,{element:n()||e,editor:t},e.attrs.id),e.type.name==="column"&&to(pc,{element:e,editor:t},e.attrs.id)]})},"SideBarItemDetails");import{forwardRef as $f}from"react";import{useAtom as xC}from"jotai";import{Fragment as TC,jsx as Es,jsxs as EC}from"react/jsx-runtime";var Lo=$f(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>Es("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})),Ro=$f(({children:e,className:t,previewMode:r,skipExpanded:o=!1,width:n,...i},a)=>{let[l,c]=xC(tr),u=o?!1:l,d=n||"courier-w-64";return r?null:EC(TC,{children:[u&&Es("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"}),Es("div",{className:I("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch courier-relative",d,t),children:Es("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})})]})});import{useAtomValue as Zf,useSetAtom as wC}from"jotai";import{jsx as vt,jsxs as Ho}from"react/jsx-runtime";var Jf=qf(({children:e,className:t,...r},o)=>vt("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),jf=qf(({children:e,previewMode:t,...r},o)=>vt("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})),Gf=s(({variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:a,colorScheme:l,...c})=>{let u=Zf(X),d=Zf(tr),m=wC(tr),p=s(()=>{d&&m(!1)},"handleSubjectAreaClick");return vt(bs,{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 Ho(Lo,{previewMode:y,children:[Ho("div",{className:"courier-flex courier-flex-col courier-flex-1",children:[Ho("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:[Ho("h4",{className:"courier-text-sm courier-h-[25px] courier-flex courier-items-end courier-pb-px",children:["Subject:"," "]}),vt(Ci,{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})]}),Ho(Jf,{ref:g,children:[Ho(jf,{previewMode:y,children:[P&&Ho("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"&&vt("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)&&vt("img",{src:M.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),R&&vt(qc,{value:R,onUpdate:E,variables:e}),P&&x&&vt("div",{className:"courier-py-5 courier-px-9 courier-pt-0 courier-flex courier-flex-col",children:vt(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})})]}),vt(Zc,{previewMode:y,togglePreviewMode:w,hideExitButton:A})]})]}),vt(Ro,{previewMode:y,children:vt("div",{className:"courier-p-1 courier-h-full",children:h?vt(Gc,{element:h,editor:N}):vt(jc,{items:T.Sidebar,brandEditor:i,label:"Blocks library",editor:N!=null?N:void 0})})})]})},...c})},"EmailLayout");import{useCurrentEditor as kC}from"@tiptap/react";import{useAtom as PC,useAtomValue as ws,useSetAtom as Kc}from"jotai";import{forwardRef as NC,memo as MC,useCallback as AC,useEffect as Ni,useMemo as Kf,useRef as Yc}from"react";import{jsx as Yf}from"react/jsx-runtime";var Mi=[{type:"text",content:`
|
|
180
|
+
`,align:"left"});let he={type:"group"};if((io=r.attrs)!=null&&io.borderWidth&&r.attrs.borderWidth>0){let st={};(Nn=r.attrs)!=null&&Nn.borderColor&&(st.color=r.attrs.borderColor),st.enabled=!0,st.size=`${r.attrs.borderWidth}px`,(Mn=r.attrs)!=null&&Mn.borderRadius&&(st.radius=r.attrs.borderRadius),he.border=st}let ke=((An=r.attrs)==null?void 0:An.paddingVertical)||0,zt=((Sn=r.attrs)==null?void 0:Sn.paddingHorizontal)||0;return(ke>0||zt>0)&&(he.padding=`${ke}px ${zt}px`),(In=r.attrs)!=null&&In.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(he.background_color=r.attrs.backgroundColor),he.elements=re,(Ln=r.attrs)!=null&&Ln.locales&&(he.locales=r.attrs.locales),[he]}default:return r.content?r.content.flatMap(t):[]}},"convertNode");return e!=null&&e.content?e.content.flatMap(t):[]}s(me,"convertTiptapToElemental");function Ys(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=Ys(o.elements);if(n)return n}}return r||t||""}s(Ys,"getTitle");function Xs(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 Ys(r.elements)}return""}s(Xs,"getTitleForChannel");function Ve(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(Ve,"updateElemental");function S(...e){return zg(_g(e))}s(S,"cn");import{Slot as $g}from"@radix-ui/react-slot";import{cva as Zg}from"class-variance-authority";import{forwardRef as qg}from"react";import{jsx as Jg}from"react/jsx-runtime";var Ki=Zg("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"}]}),Ce=qg(({active:e,buttonSize:t="medium",disabled:r,variant:o="primary",className:n,asChild:i=!1,...a},l)=>Jg(i?$g:"button",{ref:l,disabled:r,className:S(Ki({variant:o,size:t,disabled:r,active:e}),n),...a}));Ce.displayName="Button";import{forwardRef as jg}from"react";import{jsx as Gg}from"react/jsx-runtime";var le=jg((e,t)=>Gg("hr",{...e,ref:t,className:S("courier-my-1 courier-border-border dark:courier-border-neutral-600 courier-w-full",e.className)}));le.displayName="Divider";import*as xr from"react";import*as ce from"@radix-ui/react-dropdown-menu";import{Check as Kg,ChevronRight as Yg,Circle as Xg}from"lucide-react";import{jsx as ft,jsxs as Qs}from"react/jsx-runtime";var Yi=ce.Root,Xi=ce.Trigger;var Qg=xr.forwardRef(({className:e,inset:t,children:r,...o},n)=>Qs(ce.SubTrigger,{ref:n,className:S("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,ft(Yg,{className:"courier-ml-auto"})]}));Qg.displayName=ce.SubTrigger.displayName;var e5=xr.forwardRef(({className:e,...t},r)=>ft(ce.SubContent,{ref:r,className:S("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}));e5.displayName=ce.SubContent.displayName;var Wn=xr.forwardRef(({className:e,sideOffset:t=4,portalProps:r,...o},n)=>ft(ce.Portal,{...r,children:ft(ce.Content,{ref:n,sideOffset:t,className:S("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})}));Wn.displayName=ce.Content.displayName;var _n=xr.forwardRef(({className:e,inset:t,...r},o)=>ft(ce.Item,{ref:o,className:S("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}));_n.displayName=ce.Item.displayName;var t5=xr.forwardRef(({className:e,children:t,checked:r,...o},n)=>Qs(ce.CheckboxItem,{ref:n,className:S("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:[ft("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:ft(ce.ItemIndicator,{children:ft(Kg,{className:"courier-h-4 courier-w-4"})})}),t]}));t5.displayName=ce.CheckboxItem.displayName;var r5=xr.forwardRef(({className:e,children:t,...r},o)=>Qs(ce.RadioItem,{ref:o,className:S("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:[ft("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:ft(ce.ItemIndicator,{children:ft(Xg,{className:"courier-h-2 courier-w-2 courier-fill-current"})})}),t]}));r5.displayName=ce.RadioItem.displayName;var o5=xr.forwardRef(({className:e,inset:t,...r},o)=>ft(ce.Label,{ref:o,className:S("courier-px-2 courier-py-1.5 courier-text-sm courier-font-semibold",t&&"courier-pl-8",e),...r}));o5.displayName=ce.Label.displayName;var n5=xr.forwardRef(({className:e,...t},r)=>ft(ce.Separator,{ref:r,className:S("courier-mx-1 courier-my-1 courier-h-px courier-bg-muted",e),...t}));n5.displayName=ce.Separator.displayName;var i5=s(({className:e,...t})=>ft("span",{className:S("courier-ml-auto courier-text-xs courier-tracking-widest courier-opacity-60",e),...t}),"DropdownMenuShortcut");i5.displayName="DropdownMenuShortcut";import{Component as a5}from"react";import{jsx as tl,jsxs as l5}from"react/jsx-runtime";var rl=class rl extends a5{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||tl(s5,{error:this.state.error}):this.props.children}};s(rl,"ErrorBoundary");var el=rl,s5=s(({error:e})=>l5("div",{className:"courier-p-6 courier-border courier-border-red-200 courier-bg-red-50 courier-rounded-lg courier-text-center",children:[tl("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),tl("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");import{Slot as m5}from"@radix-ui/react-slot";import*as gt from"react";import{Controller as p5,FormProvider as f5,useFormContext as g5}from"react-hook-form";import*as ol from"@radix-ui/react-label";import{cva as c5}from"class-variance-authority";import*as Ku from"react";import{jsx as d5}from"react/jsx-runtime";var u5=c5("courier-text-sm courier-font-medium courier-leading-none peer-disabled:courier-cursor-not-allowed peer-disabled:courier-opacity-70"),nl=Ku.forwardRef(({className:e,...t},r)=>d5(ol.Root,{ref:r,className:S(u5(),e),...t}));nl.displayName=ol.Root.displayName;import{jsx as Or}from"react/jsx-runtime";var Ne=f5,Yu=gt.createContext({}),J=s(({...e})=>Or(Yu.Provider,{value:{name:e.name},children:Or(p5,{...e})}),"FormField"),Qi=s(()=>{let e=gt.useContext(Yu),t=gt.useContext(Xu),{getFieldState:r,formState:o}=g5(),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"),Xu=gt.createContext({}),Z=gt.forwardRef(({className:e,...t},r)=>{let o=gt.useId();return Or(Xu.Provider,{value:{id:o},children:Or("div",{ref:r,className:S("courier-space-y-2",e),...t})})});Z.displayName="FormItem";var rr=gt.forwardRef(({className:e,...t},r)=>{let{error:o,formItemId:n}=Qi();return Or(nl,{ref:r,className:S(o&&"courier-text-destructive",e),htmlFor:n,...t})});rr.displayName="FormLabel";var q=gt.forwardRef(({...e},t)=>{let{error:r,formItemId:o,formDescriptionId:n,formMessageId:i}=Qi();return Or(m5,{ref:t,id:o,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...e})});q.displayName="FormControl";var h5=gt.forwardRef(({className:e,...t},r)=>{let{formDescriptionId:o}=Qi();return Or("p",{ref:r,id:o,className:S("courier-text-[0.8rem] courier-text-muted-foreground",e),...t})});h5.displayName="FormDescription";var j=gt.forwardRef(({className:e,children:t,...r},o)=>{let{error:n,formMessageId:i}=Qi(),a=n?String(n==null?void 0:n.message):t;return a?Or("p",{ref:o,id:i,className:S("courier-text-[0.8rem] courier-font-medium courier-text-destructive",e),...r,children:a}):null});j.displayName="FormMessage";import*as we from"@radix-ui/react-alert-dialog";import*as uo from"react";import{useCallback as b5}from"react";import{jsx as or,jsxs as x5}from"react/jsx-runtime";var Qu=we.Root,ed=we.Trigger,y5=we.Portal,td=uo.forwardRef(({className:e,...t},r)=>or("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:or(we.Overlay,{asChild:!0,className:S("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})}));td.displayName=we.Overlay.displayName;var il=uo.forwardRef(({className:e,...t},r)=>{let o=b5(()=>{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 x5(y5,{container:typeof window!="undefined"?o():void 0,children:[or(td,{}),or(we.Content,{ref:r,className:S("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})]})});il.displayName=we.Content.displayName;var al=s(({className:e,...t})=>or("div",{className:S("courier-flex courier-flex-col courier-space-y-2 courier-text-center sm:courier-text-left",e),...t}),"AlertDialogHeader");al.displayName="AlertDialogHeader";var sl=s(({className:e,...t})=>or("div",{className:S("courier-flex courier-flex-col-reverse sm:courier-flex-row sm:courier-justify-end sm:courier-space-x-2",e),...t}),"AlertDialogFooter");sl.displayName="AlertDialogFooter";var C5=uo.forwardRef(({className:e,...t},r)=>or(we.Title,{ref:r,className:S("courier-text-lg courier-font-semibold",e),...t}));C5.displayName=we.Title.displayName;var v5=uo.forwardRef(({className:e,...t},r)=>or(we.Description,{ref:r,className:S("courier-text-sm courier-text-muted-foreground",e),...t}));v5.displayName=we.Description.displayName;var ll=uo.forwardRef(({className:e,...t},r)=>or(we.Action,{ref:r,className:S(Ki(),e),...t}));ll.displayName=we.Action.displayName;var cl=uo.forwardRef(({className:e,...t},r)=>or(we.Cancel,{ref:r,className:S(Ki({variant:"outline"}),"courier-mt-2 sm:courier-mt-0",e),...t}));cl.displayName=we.Cancel.displayName;import*as rd from"react";import{jsx as ul,jsxs as T5}from"react/jsx-runtime";var pe=rd.forwardRef(({className:e,type:t,startAdornment:r,endAdornment:o,...n},i)=>T5("div",{className:"courier-relative courier-flex courier-w-full courier-items-center",children:[r&&ul("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),ul("input",{type:t,className:S("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&&ul("div",{className:"courier-absolute courier-right-2 courier-flex courier-items-center courier-pointer-events-none",children:o})]}));pe.displayName="Input";import{forwardRef as P5,useRef as N5,useMemo as M5,useCallback as A5}from"react";import{useCallback as dl,useEffect as od,useRef as ea,useState as nd}from"react";import{CircleX as E5}from"lucide-react";import{jsx as nr,jsxs as id}from"react/jsx-runtime";var w5=s(e=>e==="transparent"||/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e),"isValidHex"),ad=s(({color:e,onChange:t,className:r,presetColors:o,defaultValue:n="transparent"})=>{let[i,a]=nd(()=>zn(e)),[l,c]=nd(e),u=ea(null),d=ea(null),m=ea(null),p=ea(!1),f=e!==n,v=dl(g=>{p.current=!0;let k=k5(g);c(k),t(k),p.current=!1},[t]),h=s(g=>k=>{m.current=g,b(k)},"handleMouseDown"),b=dl(g=>{if(m.current){if(m.current==="gradient"&&u.current){let k=u.current.getBoundingClientRect(),A=Math.max(0,Math.min(1,(g.clientX-k.left)/k.width)),E=Math.max(0,Math.min(1,(g.clientY-k.top)/k.height)),L={...i,s:A*100,v:(1-E)*100};a(L),v(L)}else if(m.current==="hue"&&d.current){let k=d.current.getBoundingClientRect(),A=Math.max(0,Math.min(1,(g.clientX-k.left)/k.width)),E={...i,h:A*360};a(E),v(E)}}},[i,v]),y=dl(()=>{m.current=null},[]);od(()=>{if(m.current)return window.addEventListener("mousemove",b),window.addEventListener("mouseup",y),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",y)}},[b,y]),od(()=>{p.current||(a(zn(e)),c(e))},[e]);let N=s(g=>{let k=g.target.value;if(c(k),w5(k)){let A=zn(k);a(A),v(A)}},"handleInputChange");return id("div",{className:S("w-full",r),children:[nr("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:nr("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}%`}})}),nr("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:nr("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}%`}})}),id("div",{className:"courier-mt-3 courier-relative courier-flex courier-items-center",children:[nr(pe,{value:l,onChange:N,placeholder:"#000000",className:"courier-flex-1"}),f&&nr("button",{onClick:g=>{if(g.preventDefault(),n==="transparent"){t("transparent"),c("transparent"),a({h:0,s:0,v:0});return}let k=zn(n);a(k),v(k)},className:"courier-absolute courier-right-3 courier-flex courier-cursor-pointer courier-items-center courier-justify-center courier-transition-colors",children:nr(E5,{size:14,strokeWidth:1.25})})]}),nr(le,{className:"courier-my-3"}),nr("div",{className:"courier-flex courier-flex-wrap courier-gap-1",children:o.map(g=>nr("button",{className:S("courier-h-6 courier-w-6 courier-rounded-md courier-border courier-border-input courier-shrink-0",g==="transparent"&&ml),style:{backgroundColor:g==="transparent"?void 0:g},onClick:k=>{if(k.preventDefault(),g==="transparent"){t("transparent"),c("transparent"),a({h:0,s:0,v:0});return}let A=zn(g);a(A),v(A)}},g))})]})},"ColorPicker");function zn(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(zn,"hexToHsv");function k5({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(k5,"hsvToHex");import*as ir from"@radix-ui/react-popover";import*as ld from"react";import{jsx as sd}from"react/jsx-runtime";var cd=ir.Root,ud=ir.Trigger;var pl=ld.forwardRef(({className:e,align:t="center",side:r="bottom",sideOffset:o=4,collisionPadding:n=10,avoidCollisions:i=!0,portalProps:a,...l},c)=>sd(ir.Portal,{...a,children:sd(ir.Content,{ref:c,side:r,align:t,sideOffset:o,collisionPadding:n,avoidCollisions:i,className:S("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})}));pl.displayName=ir.Content.displayName;import{jsx as $n,jsxs as dd}from"react/jsx-runtime";var ml="bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAwSDBWOEg4VjBaIiBmaWxsPSIjRDlEOUQ5Ii8+PHBhdGggZD0iTTE2IDhIOFYxNkgxNlY4WiIgZmlsbD0iI0Q5RDlEOSIvPjwvc3ZnPg==')]",S5=["#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#000000","#525252","#a3a3a3","#ffffff","transparent"],Ze=P5(({className:e,value:t="",onChange:r,defaultValue:o,transparent:n=!0,presetColors:i=S5,...a},l)=>{let c=t!=="transparent",u=N5(null),d=M5(()=>n?i:i.filter(p=>p!=="transparent"),[i,n]),m=A5(()=>{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 dd(cd,{children:[$n(ud,{asChild:!0,children:dd("div",{className:"courier-relative courier-flex courier-items-center",ref:u,children:[$n("div",{className:S("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?"":ml),style:{backgroundColor:c?t:void 0}}),$n(pe,{...a,ref:l,readOnly:!0,type:"text",value:t==="transparent"?"Transparent":t,className:S("courier-relative courier-cursor-pointer courier-pl-8",e)})]})}),$n(pl,{portalProps:{container:typeof window!="undefined"?m():void 0},className:"courier-w-[230px]",children:$n(ad,{color:t,onChange:r,presetColors:d,defaultValue:o})})]})});Ze.displayName="InputColor";import*as md from"react";import*as fl from"@radix-ui/react-separator";import{jsx as I5}from"react/jsx-runtime";var gl=md.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>I5(fl.Root,{ref:n,decorative:r,orientation:t,className:S("courier-shrink-0 courier-bg-border",t==="horizontal"?"courier-h-[1px] courier-w-full":"courier-h-full courier-w-[1px]",e),...o}));gl.displayName=fl.Root.displayName;import*as pd from"react";import*as Tr from"@radix-ui/react-slider";import{jsx as hl,jsxs as L5}from"react/jsx-runtime";var bl=pd.forwardRef(({className:e,...t},r)=>L5(Tr.Root,{ref:r,className:S("courier-relative courier-flex courier-w-full courier-touch-none courier-select-none courier-items-center",e),...t,children:[hl(Tr.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:hl(Tr.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),hl(Tr.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"})]}));bl.displayName=Tr.Root.displayName;import*as gd from"react";import*as Zn from"@radix-ui/react-switch";import{jsx as fd}from"react/jsx-runtime";var zo=gd.forwardRef(({className:e,...t},r)=>fd(Zn.Root,{className:S("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:fd(Zn.Thumb,{className:S("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")})}));zo.displayName=Zn.Root.displayName;import*as ta from"react";import*as Zt from"@radix-ui/react-tabs";import{jsx as yl}from"react/jsx-runtime";var ra=Zt.Root,qn=ta.forwardRef(({className:e,...t},r)=>yl(Zt.List,{ref:r,className:S("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}));qn.displayName=Zt.List.displayName;var $o=ta.forwardRef(({className:e,...t},r)=>yl(Zt.Trigger,{ref:r,className:S("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}));$o.displayName=Zt.Trigger.displayName;var oa=ta.forwardRef(({className:e,...t},r)=>yl(Zt.Content,{ref:r,className:S("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}));oa.displayName=Zt.Content.displayName;import*as Zo from"react";import{jsx as R5}from"react/jsx-runtime";var Cl=Zo.forwardRef(({className:e,autoResize:t=!1,...r},o)=>{let n=Zo.useRef(null),i=s(a=>{n.current=a,typeof o=="function"?o(a):o&&(o.current=a)},"combinedRef");return Zo.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]),R5("textarea",{className:S("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})});Cl.displayName="Textarea";import{forwardRef as B5,useContext as D5}from"react";import{createContext as H5}from"react";var na={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"},hd={...na},bd={...na,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 vl=H5(na);import{jsx as yd}from"react/jsx-runtime";var Cd=B5(({children:e,theme:t,colorScheme:r,className:o},n)=>{let i=r!=null?r:"light",a=i==="light"?hd:bd,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 yd(vl.Provider,{value:typeof l=="object"?l:{},children:yd("div",{style:c,className:S("courier-flex courier-flex-col courier-relative",typeof t=="string"?t:"","theme-container",i==="dark"?"dark courier-dark":"",o),ref:n,children:e})})}),vd=s(()=>D5(vl),"useTheme");import*as xd from"react";import*as xl from"@radix-ui/react-toggle";import{cva as F5}from"class-variance-authority";import{jsx as O5}from"react/jsx-runtime";var Tl=F5("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"}}),V5=xd.forwardRef(({className:e,variant:t,size:r,...o},n)=>O5(xl.Root,{ref:n,className:S(Tl({variant:t,size:r,className:e})),...o}));V5.displayName=xl.Root.displayName;import*as qo from"@radix-ui/react-toggle-group";import*as mo from"react";import{jsx as El}from"react/jsx-runtime";var Td=mo.createContext({size:"default",variant:"default"}),qt=mo.forwardRef(({className:e,variant:t,size:r,children:o,...n},i)=>El(qo.Root,{ref:i,className:S("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:El(Td.Provider,{value:{variant:t,size:r},children:o})}));qt.displayName=qo.Root.displayName;var lt=mo.forwardRef(({className:e,children:t,variant:r,size:o,...n},i)=>{let a=mo.useContext(Td);return El(qo.Item,{ref:i,className:S(Tl({variant:a.variant||r,size:a.size||o}),e),...n,children:t})});lt.displayName=qo.Item.displayName;import{jsx as wl}from"react/jsx-runtime";var xe=s(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?wl("path",{className:S(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):wl("path",{className:S(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),_=s(({width:e=28,height:t=28,...r})=>wl("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");import{jsx as kl,jsxs as U5}from"react/jsx-runtime";var Ed=s(({color:e="#000000",width:t=19,height:r=10,...o})=>U5(_,{...o,width:t,height:r,children:[kl("rect",{opacity:"0.6",x:"0.553621",y:"0.876863",width:"16.4923",height:"7.87692",rx:"1.6",stroke:e,strokeWidth:"0.738462"}),kl("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),kl("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");import{jsx as wd}from"react/jsx-runtime";var Jn=s(({color:e="#DC2626",width:t=13,height:r=13,...o})=>wd(_,{...o,fill:"none",width:t,height:r,children:wd("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");import{jsx as kd}from"react/jsx-runtime";var jn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>kd(_,{...n,width:r,height:o,children:kd(xe,{active:t,colorProp:"stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",d:"M1 15V11C1 5.47715 5.47715 1 11 1H15"})}),"BorderRadiusIcon");import{jsx as Pl,jsxs as W5}from"react/jsx-runtime";var Er=s(({color:e="#A3A3A3",width:t=16,height:r=16,...o})=>W5(_,{...o,width:t,height:r,children:[Pl("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),Pl("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),Pl("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");import{jsx as Pd}from"react/jsx-runtime";var Nl=s(({color:e,width:t=21,height:r=16,...o})=>Pd(_,{...o,width:t,height:r,children:Pd("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");import{jsx as Nd}from"react/jsx-runtime";var Ml=s(({color:e="#171717",width:t=12,height:r=13,...o})=>Nd(_,{...o,fill:"none",width:t,height:r,children:Nd("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");import{jsx as Md}from"react/jsx-runtime";var Al=s(({color:e="#404040",width:t=20,height:r=15,viewBox:o="0 0 20 15",...n})=>Md(_,{...n,width:t,height:r,viewBox:o,children:Md("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");import{jsx as Ad}from"react/jsx-runtime";var Gn=s(({color:e="#737373",width:t=16,height:r=16,...o})=>Ad(_,{...o,width:t,height:r,children:Ad(xe,{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");import{jsx as Sd}from"react/jsx-runtime";var Kn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Sd(_,{...n,width:r,height:o,children:Sd(xe,{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");import{jsx as Id}from"react/jsx-runtime";var Sl=s(({color:e="#737373",width:t=14,height:r=16,...o})=>Id(_,{...o,width:t,height:r,children:Id(xe,{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");import{jsx as Ld}from"react/jsx-runtime";var Yn=s(({color:e="#404040",width:t=24,height:r=24,...o})=>Ld(_,{...o,width:t,height:r,children:Ld("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");import{jsx as Rd}from"react/jsx-runtime";var Xn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Rd(_,{...n,width:r,height:o,children:Rd(xe,{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");import{jsx as Hd}from"react/jsx-runtime";var Qn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Hd(_,{...n,width:r,height:o,children:Hd(xe,{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");import{jsx as Bd}from"react/jsx-runtime";var Il=s(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 256 239",...n})=>Bd(_,{...n,width:t,height:r,viewBox:o,children:Bd("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");import{jsx as Dd}from"react/jsx-runtime";var ei=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Dd(_,{...n,width:r,height:o,children:Dd(xe,{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");import{jsx as Ll}from"react/jsx-runtime";var Rl=s(({color:e,width:t=21,height:r=16,...o})=>Ll(_,{...o,width:t,height:r,children:Ll("g",{transform:"translate(4, 0)",children:Ll("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");import{jsx as Fd}from"react/jsx-runtime";var Hl=s(({color:e="#737373",width:t=14,height:r=16,...o})=>Fd(_,{...o,width:t,height:r,children:Fd(xe,{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");import{jsx as Vd}from"react/jsx-runtime";var ti=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Vd(_,{...n,width:r,height:o,children:Vd(xe,{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");import{jsx as Od}from"react/jsx-runtime";var po=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Od(_,{...n,width:r,height:o,children:Od(xe,{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");import{jsx as Ud,jsxs as _5}from"react/jsx-runtime";var Bl=s(({width:e=20,height:t=21,viewBox:r="0 0 20 21",...o})=>_5(_,{...o,width:e,height:t,viewBox:r,children:[Ud("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"}),Ud("circle",{cx:"2",cy:"2",r:"3",transform:"matrix(-1 0 0 1 17.75 2)",fill:"currentColor",stroke:"white",strokeWidth:"2"})]}),"PushIcon");import{jsx as Wd}from"react/jsx-runtime";var Dl=s(({color:e="#171717",width:t=16,height:r=13,...o})=>Wd(_,{...o,fill:"none",width:t,height:r,children:Wd("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");import{jsx as _d}from"react/jsx-runtime";var Fl=s(({color:e="#171717",width:t=11,height:r=12,...o})=>_d(_,{...o,width:t,height:r,children:_d(xe,{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");import{jsx as zd}from"react/jsx-runtime";var Vl=s(({color:e="#404040",width:t=24,height:r=24,...o})=>zd(_,{...o,width:t,height:r,children:zd("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");import{jsx as ri,jsxs as z5}from"react/jsx-runtime";var $d=s(({color:e="#000000",width:t=14,height:r=9,...o})=>ri(_,{...o,width:t,height:r,children:z5("g",{opacity:"0.9",children:[ri("rect",{x:"0.799805",y:"5.92188",width:"2.46154",height:"2.95385",rx:"0.246154",fill:e}),ri("rect",{x:"4.24609",y:"4.44531",width:"2.46154",height:"4.43077",rx:"0.246154",fill:e}),ri("rect",{x:"7.93823",y:"2.72266",width:"2.46154",height:"6.15385",rx:"0.246154",fill:e}),ri("rect",{x:"11.3845",y:"0.753906",width:"2.46154",height:"8.12308",rx:"0.246154",fill:e})]})}),"SignalIcon");import{jsx as Zd}from"react/jsx-runtime";var Ol=s(({color:e="#404040",width:t=16,height:r=16,...o})=>Zd(_,{...o,width:t,height:r,children:Zd("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");import{jsx as qd}from"react/jsx-runtime";var oi=s(({color:e="#FFFFFF",width:t=24,height:r=24,...o})=>qd(_,{...o,width:t,height:r,viewBox:"0 0 24 24",children:qd("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");import{jsx as Jd}from"react/jsx-runtime";var ni=s(({color:e="#A3A3A3",width:t=24,height:r=24,...o})=>Jd(_,{...o,width:t,height:r,children:Jd(xe,{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");import{jsx as jd}from"react/jsx-runtime";var Gd=s(({width:e=24,height:t=20,...r})=>jd(_,{...r,width:e,height:t,viewBox:"0 0 24 20",children:jd("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");import{jsx as ia,jsxs as $5}from"react/jsx-runtime";var Kd=s(({color:e="#000000",width:t=14,height:r=10,...o})=>ia(_,{...o,width:t,height:r,children:$5("g",{opacity:"0.9",children:[ia("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}),ia("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}),ia("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");import{jsx as Yd}from"react/jsx-runtime";var ii=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Yd(_,{...n,width:r,height:o,children:Yd(xe,{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");import{CircleCheck as Z5}from"lucide-react";import{useEffect as q5,useState as J5,useRef as Xd}from"react";import{jsx as Ul}from"react/jsx-runtime";var fo=s(({className:e})=>Ul("div",{className:S("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:Ul("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:Ul("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");import{jsx as Wl,jsxs as Qd}from"react/jsx-runtime";var ai=s(({isError:e,isSaving:t,isLoading:r,renderIsSaving:o,renderIsError:n,renderSaved:i})=>{let[a,l]=J5(!1),c=Xd(t),u=Xd(null);return q5(()=>(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):Qd("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[Wl(fo,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):Wl("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):Qd("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[Wl(Z5,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Saved"]}):null},"Status");import{atom as em}from"jotai";import{jsx as Jo}from"react/jsx-runtime";var go=[{label:"Email",value:"email",icon:Jo(Al,{})},{label:"SMS",value:"sms",icon:Jo(Vl,{})},{label:"Push",value:"push",icon:Jo(Bl,{})},{label:"In-app",value:"inbox",icon:Jo(Yn,{})},{label:"Slack",value:"slack",icon:Jo(Ol,{})},{label:"Teams",value:"msteams",icon:Jo(Il,{})}];var Ur=em("email"),jo=em("template");import{AlertDialogDescription as t4}from"@radix-ui/react-alert-dialog";import{useAtom as r4,useAtomValue as Bs,useSetAtom as o4}from"jotai";import{useCallback as Bi,useEffect as n4,useRef as i4}from"react";import{atom as kt}from"jotai";var _l={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"}},aa=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 j5={paragraph:_l,heading:_l},si=kt(j5),ge=kt(null),Re=kt(null,(e,t,r)=>{t(ge,r)}),G5=kt({ref:null,caretPosition:null}),sa=kt({ref:null,caretPosition:null}),li=kt({isFocused:!1,hasVariables:!1,showVariablePopup:!1}),tm=kt(e=>(t,r=!1)=>{let o=e(si),n=e(li),i=aa(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}),rm=kt(null,(e,t,{nodeName:r,config:o})=>{let n=e(si);t(si,{...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"}]))}})}),SE=kt(null,(e,t,r)=>{let o=e(si),{[r]:n,...i}=o;t(si,i)}),om=kt(null,(e,t,{ref:r,caretPosition:o})=>{t(G5,{ref:r,caretPosition:o})}),IE=kt(null,(e,t,r)=>{let o=e(li);t(li,{...o,showVariablePopup:r})}),zl=kt(null),la=kt(null,(e,t,r)=>{t(zl,r)});import{useAtom as Y8,useAtomValue as F1,useSetAtom as wu}from"jotai";import{useCallback as V1,useEffect as ku,useMemo as O1,useRef as X8,useState as Q8}from"react";import{atom as nm}from"jotai";var Jt=nm(null),ar=nm(null);import{forwardRef as K5}from"react";import{Toaster as Y5}from"sonner";import{jsx as ci,jsxs as X5}from"react/jsx-runtime";var ht=K5(({theme:e,children:t,isLoading:r,Header:o,colorScheme:n,className:i,...a},l)=>ci(Cd,{theme:e,ref:l,colorScheme:n,className:i,children:X5("div",{...Object.fromEntries(Object.entries(a).filter(([c])=>c!=="variables"&&c!=="brandEditor")),className:"courier-main-layout",children:[o&&ci("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&&ci("div",{className:"courier-editor-loading",children:ci(fo,{})}),ci(Y5,{position:"top-center",expand:!0,visibleToasts:2,style:{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)"}}),t]})}));import{useAtom as Bc,useAtomValue as So,useSetAtom as ay}from"jotai";import{forwardRef as sy,memo as ly,useCallback as wf,useEffect as Xr,useMemo as kf,useRef as Ei,useState as Dc}from"react";function im(e){if(Array.isArray(e))return e}s(im,"_arrayWithHoles");function am(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(am,"_iterableToArrayLimit");function ui(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(ui,"_arrayLikeToArray");function ca(e,t){if(e){if(typeof e=="string")return ui(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)?ui(e,t):void 0}}s(ca,"_unsupportedIterableToArray");function sm(){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(sm,"_nonIterableRest");function ua(e,t){return im(e)||am(e,t)||ca(e,t)||sm()}s(ua,"_slicedToArray");var Zm=Ui(di());var ma="data-pdnd-honey-pot";function pa(e){return e instanceof Element&&e.hasAttribute(ma)}s(pa,"isHoneyPotElement");function fa(e){var t=document.elementsFromPoint(e.x,e.y),r=ua(t,2),o=r[0],n=r[1];return o?pa(o)?n!=null?n:null:o:null}s(fa,"getElementFromPointWithoutHoneypot");function ho(e){"@babel/helpers - typeof";return ho=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},ho(e)}s(ho,"_typeof");function um(e,t){if(ho(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,t||"default");if(ho(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}s(um,"toPrimitive");function dm(e){var t=um(e,"string");return ho(t)=="symbol"?t:t+""}s(dm,"toPropertyKey");function wr(e,t,r){return(t=dm(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}s(wr,"_defineProperty");var pi=Ui(di());var mm=2147483647;function pm(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(pm,"ownKeys");function fm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?pm(Object(r),!0).forEach(function(o){wr(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pm(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(fm,"_objectSpread");var mi=2,gm=mi/2;function i2(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}s(i2,"floorToClosestPixel");function a2(e){return{x:e.x-gm,y:e.y-gm}}s(a2,"pullBackByHalfHoneyPotSize");function s2(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}s(s2,"preventGoingBackwardsOffScreen");function l2(e){return{x:Math.min(e.x,window.innerWidth-mi),y:Math.min(e.y,window.innerHeight-mi)}}s(l2,"preventGoingForwardsOffScreen");function hm(e){var t=e.client,r=l2(s2(a2(i2(t))));return DOMRect.fromRect({x:r.x,y:r.y,width:mi,height:mi})}s(hm,"getHoneyPotRectFor");function bm(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(bm,"getRectStyles");function c2(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(c2,"isWithin");function u2(e){var t=e.initial,r=document.createElement("div");r.setAttribute(ma,"true");var o=hm({client:t});Object.assign(r.style,fm(fm({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},bm({clientRect:o})),{},{pointerEvents:"auto",zIndex:mm})),document.body.appendChild(r);var n=(0,pi.bind)(window,{type:"pointermove",listener:s(function(a){var l={x:a.clientX,y:a.clientY};o=hm({client:l}),Object.assign(r.style,bm({clientRect:o}))},"listener"),options:{capture:!0}});return s(function(a){var l=a.current;if(n(),c2({client:l,clientRect:o})){r.remove();return}function c(){u(),r.remove()}s(c,"cleanup");var u=(0,pi.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(u2,"mountHoneyPot");function ym(){var e=null;function t(){return e=null,(0,pi.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=u2({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(ym,"makeHoneyPotFix");function Cm(e){if(Array.isArray(e))return ui(e)}s(Cm,"_arrayWithoutHoles");function vm(e){if(typeof Symbol!="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}s(vm,"_iterableToArray");function xm(){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(xm,"_nonIterableSpread");function ga(e){return Cm(e)||vm(e)||ca(e)||xm()}s(ga,"_toConsumableArray");var Sm=Ui(di());function Ht(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(Ht,"once");var Tm=Ht(s(function(){return navigator.userAgent.includes("Firefox")},"isFirefox"));var fi=Ht(s(function(){var t=navigator,r=t.userAgent;return r.includes("AppleWebKit")&&!r.includes("Chrome")},"isSafari"));var Em=Ui(di());var Zl={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function wm(e){var t=e.dragLeave;return fi()?t.hasOwnProperty(Zl.isLeavingWindow):!1}s(wm,"isLeavingWindowInSafari");s(function(){if(typeof window=="undefined"||!fi())return;function t(){return{enterCount:0,isOverWindow:!1}}s(t,"getInitialState");var r=t();function o(){r=t()}s(o,"resetState"),(0,Em.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[Zl.isEnteringWindow]=!0),r.isOverWindow=!0,r.enterCount++},"listener")},{type:"dragleave",listener:s(function(i){r.enterCount--,r.isOverWindow&&r.enterCount===0&&(i[Zl.isLeavingWindow]=!0,r.isOverWindow=!1)},"listener")}],{capture:!0})},"fixSafari")();function d2(e){return"nodeName"in e}s(d2,"isNodeLike");function km(e){return d2(e)&&e.ownerDocument!==document}s(km,"isFromAnotherWindow");function Pm(e){var t=e.dragLeave,r=t.type,o=t.relatedTarget;return r!=="dragleave"?!1:fi()?wm({dragLeave:t}):o==null?!0:Tm()?km(o):o instanceof HTMLIFrameElement}s(Pm,"isLeavingWindow");function Nm(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(Nm,"getBindingsForBrokenDrags");function bo(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(bo,"getInput");var m2=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"),Mm=m2;var ql=Mm(function(e){return e()}),ha=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 Am(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}}),ha.schedule(function(){i({eventName:"onDragStart",payload:{source:t,location:d}})})},"start"),dragUpdate:s(function(c){var u=c.current;ha.flush(),ql.cancel(),i({eventName:"onDropTargetChange",payload:{source:t,location:{initial:r,previous:n,current:u}}})},"dragUpdate"),drag:s(function(c){var u=c.current;ql(function(){ha.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;ha.flush(),ql.cancel(),i({eventName:"onDrop",payload:{source:d!=null?d:t,location:{current:u,previous:n,initial:r}}})},"drop")};return a}s(Am,"makeDispatch");var jl={isActive:!1};function Im(){return!jl.isActive}s(Im,"canStart");function p2(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}s(p2,"getNativeSetDragImage");function f2(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(f2,"hasHierarchyChanged");function g2(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=e.dispatchEvent;if(!Im())return;var i=h2({event:t,dragType:r,getDropTargetsOver:o});jl.isActive=!0;var a={current:i};Jl({event:t,current:i.dropTargets});var l=Am({source:r.payload,dispatchEvent:n,initial:i});function c(f){var v=f2({current:a.current.dropTargets,next:f.dropTargets});a.current=f,v&&l.dragUpdate({current:a.current})}s(c,"updateState");function u(f){var v=bo(f),h=pa(f.target)?fa({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(),Jl({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(){jl.isActive=!1,p()}s(m,"finish");var p=(0,Sm.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){Pm({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:bo(v)},!a.current.dropTargets.length){d();return}v.preventDefault(),Jl({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:bo(v)},d()},"listener")}].concat(ga(Nm({onDragEnd:d}))),{capture:!0});l.start({nativeSetDragImage:p2(t)})}s(g2,"start");function Jl(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(Jl,"setDropEffectOnEvent");function h2(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=bo(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(h2,"getStartLocation");var Gl={canStart:Im,start:g2};var Kl=new Map;function b2(e){var t=e.typeKey,r=e.mount,o=Kl.get(t);if(o)return o.usageCount++,o;var n={typeKey:t,unmount:r(),usageCount:1};return Kl.set(t,n),n}s(b2,"registerUsage");function Lm(e){var t=b2(e);return s(function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),Kl.delete(e.typeKey))},"unregister")}s(Lm,"register");function sr(){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(sr,"combine");function ba(e,t){var r=t.attribute,o=t.value;return e.setAttribute(r,o),function(){return e.removeAttribute(r)}}s(ba,"addAttribute");function Rm(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(Rm,"ownKeys");function Wr(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Rm(Object(r),!0).forEach(function(o){wr(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rm(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(Wr,"_objectSpread");function Yl(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=y2(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(Yl,"_createForOfIteratorHelper");function y2(e,t){if(e){if(typeof e=="string")return Hm(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)?Hm(e,t):void 0}}s(y2,"_unsupportedIterableToArray");function Hm(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(Hm,"_arrayLikeToArray");function Xl(e){return e.slice(0).reverse()}s(Xl,"copyReverse");function Bm(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=sr(ba(f.element,{attribute:n,value:"true"}),a(f));return Ht(h)}s(l,"dropTargetForConsumers");function c(f){var v,h,b,y,N=f.source,g=f.target,k=f.input,A=f.result,E=A===void 0?[]:A;if(g==null)return E;if(!(g instanceof Element))return g instanceof Node?c({source:N,target:g.parentElement,input:k,result:E}):E;var L=g.closest(i);if(L==null)return E;var w=o.get(L);if(w==null)return E;var C={input:k,source:N,element:w.element};if(w.canDrop&&!w.canDrop(C))return c({source:N,target:w.element.parentElement,input:k,result:E});var T=(v=(h=w.getData)===null||h===void 0?void 0:h.call(w,C))!==null&&v!==void 0?v:{},x=(b=(y=w.getDropEffect)===null||y===void 0?void 0:y.call(w,C))!==null&&b!==void 0?b:r,P={data:T,element:w.element,dropEffect:x,isActiveDueToStickiness:!1};return c({source:N,target:w.element.parentElement,input:k,result:[].concat(ga(E),[P])})}s(c,"getActualDropTargets");function u(f){var v=f.eventName,h=f.payload,b=Yl(h.location.current.dropTargets),y;try{for(b.s();!(y=b.n()).done;){var N,g=y.value,k=o.get(g.element),A=Wr(Wr({},h),{},{self:g});k==null||(N=k[v])===null||N===void 0||N.call(k,A)}}catch(E){b.e(E)}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=Yl(h.location.previous.dropTargets),g;try{for(N.s();!(g=N.n()).done;){var k,A=g.value;y.add(A.element);var E=o.get(A.element),L=b.has(A.element),w=Wr(Wr({},h),{},{self:A});if(E==null||(k=E.onDropTargetChange)===null||k===void 0||k.call(E,w),!L){var C;E==null||(C=E.onDragLeave)===null||C===void 0||C.call(E,w)}}}catch(V){N.e(V)}finally{N.f()}var T=Yl(h.location.current.dropTargets),x;try{for(T.s();!(x=T.n()).done;){var P,M,R=x.value;if(!y.has(R.element)){var I=Wr(Wr({},h),{},{self:R}),H=o.get(R.element);H==null||(P=H.onDropTargetChange)===null||P===void 0||P.call(H,I),H==null||(M=H.onDragEnter)===null||M===void 0||M.call(H,I)}}}catch(V){T.e(V)}finally{T.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=Xl(y),k=Xl(N),A=[],E=0;E<g.length;E++){var L,w=g[E],C=k[E];if(C!=null){A.push(C);continue}var T=A[E-1],x=g[E-1];if((T==null?void 0:T.element)!==(x==null?void 0:x.element))break;var P=o.get(w.element);if(!P)break;var M={input:b,source:v,element:P.element};if(P.canDrop&&!P.canDrop(M)||!((L=P.getIsSticky)!==null&&L!==void 0&&L.call(P,M)))break;A.push(Wr(Wr({},w),{},{isActiveDueToStickiness:!0}))}return Xl(A)}return s(p,"getIsOver"),{dropTargetForConsumers:l,getIsOver:p,dispatchEvent:m}}s(Bm,"makeDropTarget");function C2(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=v2(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(C2,"_createForOfIteratorHelper");function v2(e,t){if(e){if(typeof e=="string")return Dm(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)?Dm(e,t):void 0}}s(v2,"_unsupportedIterableToArray");function Dm(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(Dm,"_arrayLikeToArray");function Fm(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(Fm,"ownKeys");function x2(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Fm(Object(r),!0).forEach(function(o){wr(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Fm(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(x2,"_objectSpread");function Vm(){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=x2({},i);e.add(a),r(a);function l(){e.delete(a),t&&t.active.delete(a)}return s(l,"cleanup"),Ht(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=C2(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(Vm,"makeMonitor");function Om(e){var t=e.typeKey,r=e.mount,o=e.dispatchEventToSource,n=e.onPostDispatch,i=e.defaultDropEffect,a=Vm(),l=Bm({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;Gl.start({event:p,dragType:f,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}s(u,"start");function d(){function m(){var p={canStart:Gl.canStart,start:u};return r(p)}return s(m,"mountAdapter"),Lm({typeKey:t,mount:m})}return s(d,"registerUsage"),{registerUsage:d,dropTarget:l.dropTargetForConsumers,monitor:a.monitorForConsumers}}s(Om,"makeAdapter");var Um=Ht(s(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")},"isAndroid")),Wm="pdnd:android-fallback";var Ql="text/plain";var _m="text/uri-list";var zm="application/vnd.pdnd";var ya=new WeakMap;function T2(e){return ya.set(e.element,e),s(function(){ya.delete(e.element)},"cleanup")}s(T2,"addToRegistry");var $m=ym(),ec=Om({typeKey:"element",defaultDropEffect:"move",mount:s(function(t){return sr($m.bindEvents(),(0,Zm.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=ya.get(d);if(m){var p=bo(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=fa({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=ua(y[b],2),g=N[0],k=N[1];o.dataTransfer.setData(g,k!=null?k:"")}Um()&&!o.dataTransfer.types.includes(Ql)&&!o.dataTransfer.types.includes(_m)&&o.dataTransfer.setData(Ql,Wm),o.dataTransfer.setData(zm,"");var A={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:{}},E={type:"element",payload:A,startedFrom:"internal"};t.start({event:o,dragType:E})}}}},"listener")}))},"mount"),dispatchEventToSource:s(function(t){var r,o,n=t.eventName,i=t.payload;(r=ya.get(i.source.element))===null||r===void 0||(o=r[n])===null||o===void 0||o.call(r,i)},"dispatchEventToSource"),onPostDispatch:$m.getOnPostDispatch()}),Pt=ec.dropTarget,tc=ec.monitor;function gi(e){if(0)var t;var r=sr(ec.registerUsage(),T2(e),ba(e.element,{attribute:"draggable",value:"true"}));return Ht(r)}s(gi,"draggable");function qm(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(qm,"ownKeys");function Jm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?qm(Object(r),!0).forEach(function(o){wr(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):qm(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(Jm,"_objectSpread");var E2={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")},jm=Symbol("closestEdge");function Gm(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:E2[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 Jm(Jm({},e),{},wr({},jm,d))}s(Gm,"attachClosestEdge");function hi(e){var t;return(t=e[jm])!==null&&t!==void 0?t:null}s(hi,"extractClosestEdge");import{mergeAttributes as K3,Node as Y3}from"@tiptap/core";import{ReactNodeViewRenderer as X3}from"@tiptap/react";import{NodeViewContent as q3}from"@tiptap/react";import{useSetAtom as J3}from"jotai";import{useCallback as j3}from"react";import{NodeViewWrapper as O3}from"@tiptap/react";import{useSetAtom as U3}from"jotai";import{forwardRef as W3,useCallback as Ao,useEffect as Hc,useState as ps,useRef as Yr}from"react";import{v4 as _3}from"uuid";import{Color as cf}from"@tiptap/extension-color";import{Extension as w2}from"@tiptap/core";import{dropCursor as k2}from"@tiptap/pm/dropcursor";var rc=w2.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[k2(this.options)]}});import{HardBreak as uf}from"@tiptap/extension-hard-break";import{Extension as P2}from"@tiptap/core";import{undo as N2,redo as M2,history as A2}from"@tiptap/pm/history";var S2=P2.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>N2(e,t),redo:()=>({state:e,dispatch:t})=>M2(e,t)}},addProseMirrorPlugins(){return[A2(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()}}});import{Placeholder as df}from"@tiptap/extension-placeholder";import{TextAlign as mf}from"@tiptap/extension-text-align";import{Typography as pf}from"@tiptap/extension-typography";import{Underline as ff}from"@tiptap/extension-underline";import{StarterKit as gf}from"@tiptap/starter-kit";import{mergeAttributes as $2}from"@tiptap/core";import{Node as I2,mergeAttributes as L2,wrappingInputRule as R2}from"@tiptap/core";var H2=/^\s*>\s$/,Km=I2.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",L2(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[R2({find:H2,type:this.type})]}});import{ReactNodeViewRenderer as Z2}from"@tiptap/react";import{v4 as B2}from"uuid";function Oe(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-${B2()}`;r.setNodeMarkup(i,void 0,{...n.attrs,id:a}),o=!0}return!1}),o&&e.view.dispatch(r)}s(Oe,"generateNodeIds");import{NodeViewContent as D2,NodeViewWrapper as F2}from"@tiptap/react";import{useSetAtom as V2,useAtomValue as O2}from"jotai";import{useCallback as U2,useEffect as W2,useRef as _2}from"react";import{jsx as yo}from"react/jsx-runtime";var z2=s(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderLeftWidth:o,borderColor:n})=>yo("div",{className:"courier-w-full node-element",children:yo("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:yo(D2,{})})}),"BlockquoteComponent"),Ym=s(e=>{var l,c,u;let t=V2(Re),r=O2(ge),o=_2(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=U2(()=>{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]);W2(()=>{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 yo(F2,{children:yo("div",{ref:o,children:yo(Ye,{id:e.node.attrs.id,className:S(n&&"selected-element",a&&"is-empty"),editor:e.editor,children:yo(z2,{...e.node.attrs})})})})},"BlockquoteComponentNode");var _r={paddingHorizontal:8,paddingVertical:6,backgroundColor:"transparent",borderLeftWidth:4,borderColor:"#e0e0e0"},oc=Km.extend({content:"block+",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){Oe(this.editor,this.name)},addAttributes(){return{id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},paddingHorizontal:{default:_r.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:_r.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:_r.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderLeftWidth:{default:_r.borderLeftWidth,parseHTML:e=>e.getAttribute("data-border-left-width"),renderHTML:e=>({"data-border-left-width":e.borderLeftWidth})},borderColor:{default:_r.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",$2(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 Z2(Ym)}});import{zodResolver as ch}from"@hookform/resolvers/zod";import{useForm as uh}from"react-hook-form";import{useCallback as q2,useEffect as J2,useRef as Xm}from"react";var Xe=s(({editor:e,element:t,form:r,nodeType:o})=>{let n=Xm(null),i=Xm(null);return J2(()=>{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:q2(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");import{useAtomValue as va,useSetAtom as K2}from"jotai";import{useMemo as ep,useCallback as tp}from"react";var Ca=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,...Ca(n,i)]:[...r,i]},[]),"getFlattenedVariables");var j2={link:["href","content"],img:["src","href","alt_text"],image:["src","href","alt_text"],action:["href","content"],meta:["title"],list:["imgSrc","imgHref"],quote:["content"],html:[]},G2=["content","href","src","title"],Qm=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&&$e(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=j2[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;G2.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 fN=s(e=>{let t=va(Te),r=va(X),o=va(Ur),n=va(so),i=K2(so),a=e!=null?e:o,l=ep(()=>{var p,f;if(!t)return[];let m=((f=(p=t.extensionManager.extensions.find(v=>v.name==="variableSuggestion"))==null?void 0:p.options)==null?void 0:f.variables)||{};return Ca(m)},[t]),c=ep(()=>{if(!r||!a)return[];let m=r.elements.find(p=>p.type==="channel"&&p.channel===a);return m?Qm(m.elements||[]):[]},[r,a]),u=tp((m,p)=>{i(f=>({...f,[m]:p}))},[i]),d=tp(()=>{i({})},[i]);return{availableVariables:l,usedVariables:c,variableValues:n,addVariableValue:u,clearAllVariableValues:d}},"useVariables");import{useSetAtom as sh}from"jotai";import{jsx as rp,jsxs as Y2}from"react/jsx-runtime";var Ue=s(({draggable:e=!1,icon:t,draggableLabel:r,label:o})=>Y2("div",{className:"courier-flex courier-flex-row courier-items-center courier-gap-2",children:[rp("div",{className:S("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}),rp("span",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:e?r:o})]}),"BlockBase");import{Quote as X2}from"lucide-react";import{jsx as op}from"react/jsx-runtime";var np=s(({draggable:e=!1})=>op(Ue,{draggable:e,icon:op(X2,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),draggableLabel:"Blockquote",label:"Blockquote block"}),"BlockquoteBlock");import{jsx as xa}from"react/jsx-runtime";var Q2=s(()=>xa("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:xa("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"),zr=s(({draggable:e=!1})=>xa(Ue,{draggable:e,icon:xa(Q2,{}),draggableLabel:"Button",label:"Button block"}),"ButtonBlock");import{jsx as Ta}from"react/jsx-runtime";var eh=s(()=>Ta("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Ta("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"),Ea=s(({draggable:e=!1})=>Ta(Ue,{draggable:e,icon:Ta(eh,{}),draggableLabel:"Column layout",label:"Column layout"}),"ColumnBlock");import{jsx as wa}from"react/jsx-runtime";var th=s(()=>wa("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:wa("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"),bi=s(({draggable:e=!1})=>wa(Ue,{draggable:e,icon:wa(th,{}),draggableLabel:"Custom code",label:"Custom code"}),"CustomCodeBlock");import{jsx as ka}from"react/jsx-runtime";var rh=s(()=>ka("svg",{width:"16",height:"2",viewBox:"0 0 16 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:ka("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"),$r=s(({draggable:e=!1})=>ka(Ue,{draggable:e,icon:ka(rh,{}),draggableLabel:"Divider",label:"Divider block"}),"DividerBlock");import{jsx as Pa}from"react/jsx-runtime";var oh=s(()=>Pa("svg",{width:"18",height:"13",viewBox:"0 0 18 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Pa("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"),Na=s(({draggable:e=!1})=>Pa(Ue,{draggable:e,icon:Pa(oh,{}),draggableLabel:"Heading",label:"Heading block"}),"HeadingBlock");import{jsx as Ma}from"react/jsx-runtime";var nh=s(()=>Ma("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Ma("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"),Aa=s(({draggable:e=!1})=>Ma(Ue,{draggable:e,icon:Ma(nh,{}),draggableLabel:"Image",label:"Image block"}),"ImageBlock");import{AlignVerticalSpaceAround as ih}from"lucide-react";import{jsx as ip}from"react/jsx-runtime";var Sa=s(({draggable:e=!1})=>ip(Ue,{draggable:e,icon:ip(ih,{className:"courier-w-4 courier-h-4"}),draggableLabel:"Spacer",label:"Spacer block"}),"SpacerBlock");import{jsx as Ia}from"react/jsx-runtime";var ah=s(()=>Ia("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Ia("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"),Zr=s(({draggable:e=!1})=>Ia(Ue,{draggable:e,icon:Ia(ah,{}),draggableLabel:"Text",label:"Text block"}),"TextBlock");import{jsx as jt,jsxs as lh}from"react/jsx-runtime";var Qe=s(({type:e})=>{let t=sh(Re);return lh("div",{className:"courier-flex courier-gap-4 courier-flex-col",children:[jt(Ce,{className:"courier-w-fit",variant:"secondary",buttonSize:"small",onClick:()=>{t(null)},children:"Close"}),e==="heading"&&jt(Na,{}),e==="text"&&jt(Zr,{}),e==="image"&&jt(Aa,{}),e==="spacer"&&jt(Sa,{}),e==="divider"&&jt($r,{}),e==="button"&&jt(zr,{}),e==="blockquote"&&jt(np,{}),e==="customCode"&&jt(bi,{}),e==="column"&&jt(Ea,{}),jt(le,{className:"courier-m-0"})]})},"FormHeader");import{z as Co}from"zod";var ap=Co.object({paddingHorizontal:Co.coerce.number().min(0),paddingVertical:Co.coerce.number().min(0),backgroundColor:Co.string(),borderLeftWidth:Co.coerce.number().min(0),borderColor:Co.string(),id:Co.string().optional()});import{jsx as Xo,jsxs as nc}from"react/jsx-runtime";var sp=s(({element:e,editor:t})=>{let r=uh({resolver:ch(ap),defaultValues:{..._r,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"blockquote"});return e?nc(Ne,{...r,children:[Xo(Qe,{type:"blockquote"}),nc("form",{onChange:()=>{o(r.getValues())},children:[Xo("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),Xo(J,{control:r.control,name:"borderColor",render:({field:n})=>nc(Z,{className:"courier-mb-3",children:[Xo(q,{children:Xo(Ze,{...n,defaultValue:_r.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),Xo(j,{})]})})]})]}):null},"BlockquoteForm");import{z as Nt}from"zod";var La=Nt.object({label:Nt.string(),link:Nt.string().optional(),alignment:Nt.enum(["left","center","right"]),backgroundColor:Nt.string(),borderRadius:Nt.number(),padding:Nt.number(),fontWeight:Nt.enum(["normal","bold"]),fontStyle:Nt.enum(["normal","italic"]),isUnderline:Nt.boolean(),isStrike:Nt.boolean(),textColor:Nt.string().optional(),borderColor:Nt.string().optional()});import{zodResolver as Jh}from"@hookform/resolvers/zod";import{useForm as jh}from"react-hook-form";import{Node as dh}from"@tiptap/core";var Qo=dh.create({name:"doc",topNode:!0,content:"block+"});import{Node as mh,mergeAttributes as ph}from"@tiptap/core";var en=mh.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",ph(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});import Oh from"@tiptap/extension-placeholder";import{Node as fh}from"@tiptap/core";var Ra=fh.create({name:"text",group:"inline"});import{EditorContent as Uh,useEditor as Wh}from"@tiptap/react";import*as Eo from"react";import{useCallback as _h,useEffect as pp}from"react";import{Extension as kh,InputRule as Ph,Node as Nh}from"@tiptap/core";import{ReactNodeViewRenderer as Mh}from"@tiptap/react";import{NodeViewWrapper as xh}from"@tiptap/react";import{useAtomValue as Th}from"jotai";import{useCallback as Da,useEffect as Eh,useState as wh}from"react";import{useCallback as vo,useEffect as ic,useMemo as gh,useRef as hh,useState as bh}from"react";import{jsx as lp,jsxs as Ch}from"react/jsx-runtime";var ac=50,sc=24,yh=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"),Ha=s(({variableId:e,isInvalid:t,onUpdateAttributes:r,onDelete:o,icon:n,value:i,singleClickToEdit:a=!1,className:l,textColorOverride:c,getColors:u=yh})=>{let[d,m]=bh(!1),p=hh(null);ic(()=>{e===""&&!d&&m(!0)},[e,d]),ic(()=>{if(d&&p.current){let x=p.current;x.textContent=e,x.focus(),requestAnimationFrame(()=>{if(x){let P=document.createRange();P.selectNodeContents(x),P.collapse(!1);let M=window.getSelection();M==null||M.removeAllRanges(),M==null||M.addRange(P)}})}},[d,e]);let f=vo(()=>{var M;m(!1);let x=(((M=p.current)==null?void 0:M.textContent)||"").trim();if(x===""){o();return}let P=$e(x);r({id:x,isInvalid:!P})},[o,r]),v=vo(x=>{var P;x.key==="Enter"?(x.preventDefault(),(P=p.current)==null||P.blur()):x.key==="Escape"&&(x.preventDefault(),p.current&&(p.current.textContent=e),m(!1),e===""&&o())},[e,o]),h=vo(()=>{if(p.current){let x=p.current.textContent||"";if(x.length>ac){x=x.slice(0,ac),p.current.textContent=x;let P=document.createRange();P.selectNodeContents(p.current),P.collapse(!1);let M=window.getSelection();M==null||M.removeAllRanges(),M==null||M.addRange(P)}}},[]),b=vo(x=>{x.preventDefault();let P=x.clipboardData.getData("text/plain").slice(0,ac);document.execCommand("insertText",!1,P)},[]),y=vo(x=>{x.stopPropagation(),d||m(!0)},[d]),N=u(t,!!i),{bgColor:g,borderColor:k,textColor:A}=N,E=c||A,L=gh(()=>{let x=e,P=i?`="${i}"`:"",M=`${x}${P}`,R=x.length>sc;return{displayText:`${R?`${x.slice(0,sc)}\u2026`:x}${P}`,fullText:M,showTitle:R}},[e,i]);ic(()=>{p.current&&!d&&(p.current.textContent=L.displayText)},[L.displayText,d]);let w=vo(x=>{x.stopPropagation()},[]),C=vo(x=>{x.stopPropagation()},[]),T=a?{onClick:y}:{onClick:C,onDoubleClick:y};return Ch("span",{className:S("courier-inline-flex 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:g,borderColor:k,color:E,direction:"ltr"},onMouseDown:w,...T,title:L.showTitle?L.fullText:void 0,children:[lp("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}),lp("span",{ref:p,role:"textbox",contentEditable:d,suppressContentEditableWarning:!0,onBlur:f,onKeyDown:v,onInput:h,onPaste:b,onMouseDown:w,...a?{onClick:y}:{onClick:C,onDoubleClick:y},className:S("courier-outline-none courier-min-w-[1ch]",!d&&"courier-cursor-text"),style:{color:E,maxWidth:`${sc}ch`,overflow:"hidden",textOverflow:d?"clip":"ellipsis",whiteSpace:"nowrap",direction:"ltr",unicodeBidi:"isolate"},children:!d&&L.displayText})]})},"VariableChipBase");import{jsx as cp,jsxs as vh}from"react/jsx-runtime";var Ba=s(({color:e="#1D4ED8"})=>vh("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:[cp("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}),cp("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableIcon");import{jsx as lc}from"react/jsx-runtime";var up=s(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=Th(so),i=e.attrs.id||"",a=n[i],l=e.attrs.isInvalid,[c,u]=wh(!1),d=Da(()=>{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]);Eh(()=>{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=Da(h=>{o(h)},[o]),p=Da(()=>{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=Da((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 lc(xh,{className:"courier-inline-block courier-max-w-full",children:lc(Ha,{variableId:i,isInvalid:l,value:a,onUpdateAttributes:m,onDelete:p,icon:lc(Ba,{color:v.iconColor}),getColors:f,className:S("courier-mx-1 courier-variable-node",c&&"courier-variable-in-button"),textColorOverride:c?"#000000":void 0})})},"VariableView");var cc=Nh.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 Mh(up)}}),xo=kh.create({name:"variableInputRule",addInputRules(){return[new Ph({find:/\{\{$/,handler:({range:e,chain:t})=>{t().deleteRange(e).insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()}})]}});import{Extension as Ah}from"@tiptap/core";import{Plugin as Sh}from"@tiptap/pm/state";import{Slice as Ih,Fragment as Lh}from"@tiptap/pm/model";var To=Ah.create({name:"variablePaste",addProseMirrorPlugins(){return[new Sh({props:{transformPastedHTML:e=>e.replace(/\{\{([^}]+)\}\}/g,(r,o)=>{let n=o.trim();return $e(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&&$e(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=Lh.from(i),u=new Ih(c,0,0),d=r.state.tr.replaceSelection(u);return r.dispatch(d),e}return e}}})]}});import{Node as Rh}from"@tiptap/core";import{NodeViewWrapper as Hh,ReactNodeViewRenderer as Bh}from"@tiptap/react";import{useCallback as dp}from"react";import{jsx as yi,jsxs as Vh}from"react/jsx-runtime";var Dh=s(({color:e="#B45309"})=>Vh("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:[yi("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}),yi("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableChipIcon"),mp=s(e=>e?{bgColor:"#FEF2F2",borderColor:"#FECACA",iconColor:"#DC2626",textColor:"#991B1B"}:{bgColor:"#FFFBEB",borderColor:"#FDE68A",iconColor:"#B45309",textColor:"#92400E"},"getSimpleColors"),Fh=s(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=e.attrs.id||"",i=e.attrs.isInvalid||!1,a=dp(u=>{o(u)},[o]),l=dp(()=>{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=mp(i);return yi(Hh,{as:"span",className:"courier-inline",children:yi(Ha,{variableId:n,isInvalid:i,onUpdateAttributes:a,onDelete:l,icon:yi(Dh,{color:c.iconColor}),getColors:mp,className:"courier-mx-0.5"})})},"SimpleVariableView"),Fa=Rh.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 Bh(Fh)}});function tn(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();$e(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(tn,"parseStringToContent");function Va(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(Va,"contentToString");import{jsx as fp}from"react/jsx-runtime";var lr=Eo.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,onFocus:i,onBlur:a},l)=>{let c=Eo.useRef(!1),u=Eo.useRef(e),d=Wh({extensions:[Qo,en.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),Ra,Fa,xo,To,Oh.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:tn(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=Va(p.getJSON());f!==u.current&&(u.current=f,t==null||t(f))},onFocus:()=>{i==null||i()},onBlur:()=>{a==null||a()}});pp(()=>{if(!d||e===u.current)return;c.current=!0,u.current=e;let p=setTimeout(()=>{let f=tn(e);d.commands.setContent(f),c.current=!1},0);return()=>clearTimeout(p)},[d,e]),pp(()=>{d&&d.setEditable(!n)},[d,n]);let m=_h(()=>{d==null||d.commands.focus()},[d]);return Eo.useImperativeHandle(l,()=>{let p=d==null?void 0:d.view.dom.parentElement;return p&&(p.focus=m),p},[d,m]),fp("div",{ref:l,className:S("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:fp(Uh,{editor:d,className:"courier-w-full"})})});lr.displayName="VariableTextarea";import zh from"@tiptap/extension-placeholder";import{EditorContent as $h,useEditor as Zh}from"@tiptap/react";import*as wo from"react";import{useCallback as qh,useEffect as gp}from"react";import{jsx as hp}from"react/jsx-runtime";var Ci=wo.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,readOnly:i=!1,onFocus:a,onBlur:l},c)=>{let u=wo.useRef(!1),d=wo.useRef(e),m=Zh({extensions:[Qo,en.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),Ra,Fa,xo,To,zh.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:tn(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=Va(f.getJSON());v!==d.current&&(d.current=v,t==null||t(v))},onFocus:()=>{a==null||a()},onBlur:()=>{l==null||l()}});gp(()=>{if(!m||e===d.current)return;u.current=!0,d.current=e;let f=setTimeout(()=>{let v=tn(e);m.commands.setContent(v),u.current=!1},0);return()=>clearTimeout(f)},[m,e]),gp(()=>{m&&m.setEditable(!n&&!i)},[m,n,i]);let p=qh(()=>{m==null||m.commands.focus()},[m]);return wo.useImperativeHandle(c,()=>{let f=m==null?void 0:m.view.dom.parentElement;return f&&(f.focus=p),f},[m,p]),hp("div",{ref:c,className:S("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:hp($h,{editor:m,className:"courier-w-full courier-flex-1"})})});Ci.displayName="VariableInput";import{jsx as on,jsxs as ZA}from"react/jsx-runtime";var rn=30,Oa=s(({color:e="currentColor",width:t=rn,height:r=rn,...o})=>on(_,{...o,width:t,height:r,children:on("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"),Ua=s(({color:e="currentColor",width:t=rn,height:r=rn,...o})=>on(_,{...o,width:t,height:r,children:on("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"),Wa=s(({color:e="currentColor",width:t=rn,height:r=rn,...o})=>on(_,{...o,width:t,height:r,children:on("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");import{jsx as fe,jsxs as qr}from"react/jsx-runtime";var bp=s(({element:e,editor:t})=>{let r=jh({resolver:Jh(La),defaultValues:{...Ie,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({editor:t,element:e,form:r,nodeType:"button"});return e?qr(Ne,{...r,children:[fe(Qe,{type:"button"}),qr("form",{onChange:()=>{o(r.getValues())},children:[fe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),fe(J,{control:r.control,name:"link",render:({field:n})=>qr(Z,{children:[fe(q,{children:fe(lr,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})}})}),fe(j,{})]})}),fe(le,{className:"courier-mt-6 courier-mb-4"}),fe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Background"}),fe(J,{control:r.control,name:"backgroundColor",render:({field:n})=>qr(Z,{className:"courier-mb-4",children:[fe(q,{children:fe(Ze,{...n,defaultValue:Ie.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),fe(j,{})]})}),fe(le,{className:"courier-mt-6 courier-mb-4"}),fe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),fe(J,{control:r.control,name:"padding",render:({field:n})=>qr(Z,{className:"courier-mb-2",children:[fe(q,{children:fe(pe,{type:"number",min:0,...n})}),fe(j,{})]})}),fe(J,{control:r.control,name:"alignment",render:({field:n})=>qr(Z,{children:[fe(q,{children:qr(qt,{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:[fe(lt,{size:"sm",value:"left",className:"courier-w-full",children:fe(Oa,{className:"courier-h-4 courier-w-4"})}),fe(lt,{size:"sm",value:"center",className:"courier-w-full",children:fe(Ua,{className:"courier-h-4 courier-w-4"})}),fe(lt,{size:"sm",value:"right",className:"courier-w-full",children:fe(Wa,{className:"courier-h-4 courier-w-4"})})]})}),fe(j,{})]})}),fe(le,{className:"courier-mt-6 courier-mb-4"}),fe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),fe(J,{control:r.control,name:"borderRadius",render:({field:n})=>qr(Z,{children:[fe(q,{children:fe(pe,{startAdornment:fe(jn,{}),type:"number",min:0,...n})}),fe(j,{})]})})]})]}):null},"ButtonForm");import{mergeAttributes as ob,Node as nb}from"@tiptap/core";import{ReactNodeViewRenderer as ib}from"@tiptap/react";import{v4 as ab}from"uuid";import{useAtomValue as Gh,useSetAtom as Kh}from"jotai";import{useCallback as kr,useRef as ko,useEffect as Cp,useLayoutEffect as Yh,useState as Xh}from"react";import{Fragment as rb,jsx as cr,jsxs as uc}from"react/jsx-runtime";var Qh=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();$e(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"),eb=s(({parts:e})=>{let t=Gh(so);return cr(rb,{children:e.map((r,o)=>{if(r.type==="text")return cr("span",{children:r.content},o);let n=t[r.name];return uc("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:[cr(Ba,{color:n?void 0:"#B45309"}),uc("span",{className:"courier-truncate courier-min-w-0",style:{color:"#000000"},children:[r.name,n?`="${n}"`:""]})]},o)})})},"ButtonLabelDisplay"),yp=s(({label:e,backgroundColor:t,textColor:r,onLabelChange:o,editable:n})=>{let i=ko(null),a=ko(e),l=ko(!1),[c,u]=Xh(!1),d=Qh(e),p=d.some(E=>E.type==="variable")&&!c;Yh(()=>{if(!i.current||!p)return;Array.from(i.current.childNodes).filter(L=>L.nodeType===Node.TEXT_NODE).forEach(L=>L.remove())},[p,e]);let f=ko(p),v=ko(!0);Cp(()=>{if(!i.current||p){f.current=p;return}let E=f.current&&!p;f.current=p,(v.current||E||!l.current&&e!==a.current)&&(i.current.textContent=e),v.current=!1,a.current=e},[e,p]);let h=kr(()=>{if(i.current&&!p){l.current=!0;let E=i.current.textContent||"";a.current=E,o(E),requestAnimationFrame(()=>{l.current=!1})}},[o,p]),b=kr(E=>{var L;if(p){E.preventDefault(),E.stopPropagation();return}if(E.key==="Enter"&&(E.preventDefault(),(L=i.current)==null||L.blur()),(E.metaKey||E.ctrlKey)&&E.key==="a"&&(E.preventDefault(),E.stopPropagation(),i.current)){let w=document.createRange();w.selectNodeContents(i.current);let C=window.getSelection();C==null||C.removeAllRanges(),C==null||C.addRange(w)}},[p]),y=kr(()=>{u(!0)},[]),N=kr(()=>{u(!1)},[]),g=kr(E=>{let L=i.current;if(!L)return;if(p&&n){E.stopPropagation(),setTimeout(()=>{L.focus();let T=document.createRange();T.selectNodeContents(L),T.collapse(!1);let x=window.getSelection();x==null||x.removeAllRanges(),x==null||x.addRange(T)},0);return}if(!n)return;let w=s(()=>{let T=window.getSelection();if(!T||T.rangeCount===0)return;let x=T.getRangeAt(0),P=L.contains(x.startContainer),M=L.contains(x.endContainer);if(P&&!M){let R=document.createRange();R.selectNodeContents(L),T.removeAllRanges(),T.addRange(R)}},"checkAndConstrainSelection"),C=s(T=>{let x=L.getBoundingClientRect();(T.clientX<x.left||T.clientX>x.right||T.clientY<x.top||T.clientY>x.bottom)&&w(),document.removeEventListener("mouseup",C)},"handleMouseUp");document.addEventListener("mouseup",C)},[n,p]),k=p?cr(eb,{parts:d}):n?null:e,A=kr(E=>{p&&n&&E.stopPropagation()},[p,n]);return cr("div",{ref:i,contentEditable:n&&!p,suppressContentEditableWarning:!0,tabIndex:n&&p?0:void 0,onInput:h,onKeyDown:b,onPointerDown:g,onClick:A,onFocus:y,onBlur:N,className:S("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:k})},"EditableButton"),tb=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})=>cr("div",{className:"node-element",children:uc("div",{className:"courier-flex courier-gap-1 courier-justify-start",style:{marginTop:`${c}px`,marginBottom:`${c}px`},children:[cr(yp,{label:e,backgroundColor:r,textColor:o,onLabelChange:u||(()=>{}),editable:m},"button1"),cr(yp,{label:n,backgroundColor:a,textColor:l,onLabelChange:d||(()=>{}),editable:m},"button2")]})}),"ButtonRowComponent"),vp=s(e=>{let t=Kh(Re),r=ko({}),o=ko({}),n=kr(()=>{if(!e.editor.isEditable)return;let l=We(e);l&&t(l)},[e,t]),i=kr(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=kr(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 Cp(()=>{let l=r.current;return()=>{l.button1&&clearTimeout(l.button1),l.button2&&clearTimeout(l.button2)}},[]),cr(Ye,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"buttonRow",children:cr(tb,{...e.node.attrs,onButton1LabelChange:i,onButton2LabelChange:a,editable:e.editor.isEditable})})},"ButtonRowComponentNode");var Gt={button1Label:"Register",button1Link:"",button1BackgroundColor:"#000000",button1TextColor:"#ffffff",button2Label:"Learn more",button2Link:"",button2BackgroundColor:"#ffffff",button2TextColor:"#000000",padding:6},za=nb.create({name:"buttonRow",group:"block",atom:!0,selectable:!1,onCreate(){Oe(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${ab()}`,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.id})},button1Label:{default:Gt.button1Label,parseHTML:e=>e.getAttribute("data-button1-label"),renderHTML:e=>({"data-button1-label":e.button1Label})},button1Link:{default:Gt.button1Link,parseHTML:e=>e.getAttribute("data-button1-link"),renderHTML:e=>({"data-button1-link":e.button1Link})},button1BackgroundColor:{default:Gt.button1BackgroundColor,parseHTML:e=>e.getAttribute("data-button1-bg"),renderHTML:e=>({"data-button1-bg":e.button1BackgroundColor})},button1TextColor:{default:Gt.button1TextColor,parseHTML:e=>e.getAttribute("data-button1-color"),renderHTML:e=>({"data-button1-color":e.button1TextColor})},button2Label:{default:Gt.button2Label,parseHTML:e=>e.getAttribute("data-button2-label"),renderHTML:e=>({"data-button2-label":e.button2Label})},button2Link:{default:Gt.button2Link,parseHTML:e=>e.getAttribute("data-button2-link"),renderHTML:e=>({"data-button2-link":e.button2Link})},button2BackgroundColor:{default:Gt.button2BackgroundColor,parseHTML:e=>e.getAttribute("data-button2-bg"),renderHTML:e=>({"data-button2-bg":e.button2BackgroundColor})},button2TextColor:{default:Gt.button2TextColor,parseHTML:e=>e.getAttribute("data-button2-color"),renderHTML:e=>({"data-button2-color":e.button2TextColor})},padding:{default:Gt.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",ob(e,{"data-type":"buttonRow"})]},addNodeView(){return ib(vp,{stopEvent:({event:e})=>!(e.type==="dragstart"||e.type==="drop")})},addCommands(){return{setButtonRow:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...Gt,...e}}).run()}}});import{mergeAttributes as pb,Node as fb}from"@tiptap/core";import{ReactNodeViewRenderer as gb}from"@tiptap/react";import{v4 as hb}from"uuid";import{NodeViewContent as sb}from"@tiptap/react";import{useSetAtom as lb,useAtomValue as cb}from"jotai";import{useCallback as dc,useEffect as xp,useState as mc,useRef as ub}from"react";import{jsx as ur}from"react/jsx-runtime";var db=s(({columnId:e,index:t,isPreviewMode:r})=>{let o=ub(null),[n,i]=mc(!1);return xp(()=>{let a=o.current;if(a)return Pt({element:a,getData:()=>({type:"column-cell",columnId:e,index:t,isEmpty:!0}),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e,t]),ur("div",{ref:o,"data-placeholder-cell":"true","data-column-cell":"true","data-column-id":e,"data-cell-index":t,onClick:a=>{a.stopPropagation()},className:S("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&&ur("span",{className:"courier-pointer-events-none",children:"Drag and drop content blocks"})})},"PlaceholderCell"),mb=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 ur("div",{className:"courier-w-full node-element",style:m,children:ur("div",{className:"courier-w-full courier-flex courier-gap-2 courier-p-2",style:d,children:Array.from({length:l}).map((v,h)=>ur(db,{columnId:f,index:h,isPreviewMode:c},h))})})}return ur("div",{className:"courier-w-full node-element",style:m,children:ur("div",{className:"courier-w-full courier-p-2",style:d,children:ur(sb,{})})})},"ColumnComponent"),Tp=s(e=>{let t=lb(Re),r=cb(pt),[o,n]=mc(!1),[i,a]=mc(e.editor.isEditable);xp(()=>{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=dc(m=>{var A,E;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||((E=(A=p.closest("[data-node-view-content]"))==null?void 0:A.parentElement)==null?void 0:E.classList.contains("node-element"))){m.stopPropagation(),g||m.preventDefault();let L=We(e);if(L){e.editor.commands.blur();let w=L.attrs.id;e.editor.state.doc.descendants(C=>C.type.name==="column"&&C.attrs.id===w?(t(C),!1):!0)}}},[e,t]),u=dc(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=dc(()=>{n(!1)},[]);return ur(Ye,{id:e.node.attrs.id,className:S(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:ur(mb,{...e.node.attrs,node:e.node,columnsCount:e.node.attrs.columnsCount||2,isPreviewMode:l})})},"ColumnComponentNode");var qe={columnsCount:2,paddingHorizontal:0,paddingVertical:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"transparent",cells:[]},$a=fb.create({name:"column",group:"block",content:"columnRow?",isolating:!0,selectable:!1,onCreate(){Oe(this.editor,this.name)},addAttributes(){return{columnsCount:{default:qe.columnsCount,parseHTML:e=>e.getAttribute("data-columns-count"),renderHTML:e=>({"data-columns-count":e.columnsCount})},paddingHorizontal:{default:qe.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:qe.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:qe.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:qe.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:qe.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:qe.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:()=>`node-${hb()}`,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",pb(this.options.HTMLAttributes,e,{"data-type":"column"}),0]},addNodeView(){return gb(Tp)},addCommands(){return{setColumn:e=>({chain:t})=>{let r=e.columnsCount||qe.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"}}}});import{zodResolver as bb}from"@hookform/resolvers/zod";import{useForm as yb}from"react-hook-form";import{z as Bt}from"zod";var Ep=Bt.object({columnsCount:Bt.number().min(1).max(4).default(2),paddingHorizontal:Bt.number().default(0),paddingVertical:Bt.number().default(0),backgroundColor:Bt.string().default("transparent"),borderWidth:Bt.number().default(0),borderRadius:Bt.number().default(0),borderColor:Bt.string().default("transparent"),cells:Bt.array(Bt.object({elements:Bt.array(Bt.any())})).optional()});import{jsx as ne,jsxs as Kt}from"react/jsx-runtime";var pc=s(({element:e,editor:t})=>{let r=yb({resolver:bb(Ep),defaultValues:{...qe,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({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?Kt(Ne,{...r,children:[ne(Qe,{type:"column",label:"Column layout"}),Kt("form",{onChange:()=>{o(r.getValues())},children:[ne("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Columns count"}),ne(J,{control:r.control,name:"columnsCount",render:({field:i})=>Kt(Z,{className:"courier-mb-4",children:[ne(q,{children:ne(qt,{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=>ne(lt,{value:a.toString(),className:"courier-w-12 courier-h-7",children:ne("span",{className:"courier-text-sm courier-font-medium",children:a})},a))})}),ne(j,{})]})}),ne(le,{className:"courier-mt-6 courier-mb-4"}),ne("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Frame"}),Kt("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[ne(J,{control:r.control,name:"paddingHorizontal",render:({field:i})=>Kt(Z,{children:[ne(q,{children:ne(pe,{startAdornment:ne(ti,{}),type:"number",min:0,...i})}),ne(j,{})]})}),ne(J,{control:r.control,name:"paddingVertical",render:({field:i})=>Kt(Z,{children:[ne(q,{children:ne(pe,{startAdornment:ne(po,{}),type:"number",min:0,...i})}),ne(j,{})]})})]}),ne(J,{control:r.control,name:"backgroundColor",render:({field:i})=>Kt(Z,{className:"courier-mb-4",children:[ne(q,{children:ne(Ze,{...i,defaultValue:qe.backgroundColor,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),ne(j,{})]})}),ne(le,{className:"courier-mt-6 courier-mb-4"}),ne("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Border"}),Kt("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[ne(J,{control:r.control,name:"borderWidth",render:({field:i})=>Kt(Z,{children:[ne(q,{children:ne(pe,{startAdornment:ne(Er,{}),type:"number",min:0,...i})}),ne(j,{})]})}),ne(J,{control:r.control,name:"borderRadius",render:({field:i})=>Kt(Z,{children:[ne(q,{children:ne(pe,{startAdornment:ne(jn,{}),type:"number",min:0,...i})}),ne(j,{})]})})]}),ne(J,{control:r.control,name:"borderColor",render:({field:i})=>Kt(Z,{className:"courier-mb-4",children:[ne(q,{children:ne(Ze,{...i,defaultValue:qe.borderColor,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),ne(j,{})]})})]})]}):null},"ColumnForm");import{mergeAttributes as Cb,Node as vb}from"@tiptap/core";var Za=vb.create({name:"columnRow",group:"columnContent",content:"columnCell+",isolating:!0,parseHTML(){return[{tag:'div[data-type="column-row"]'}]},renderHTML({HTMLAttributes:e}){return["div",Cb(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()}}});import{mergeAttributes as Pb,Node as Nb}from"@tiptap/core";import{ReactNodeViewRenderer as Mb}from"@tiptap/react";import{Plugin as Ab,PluginKey as Sb}from"@tiptap/pm/state";import{NodeViewWrapper as xb,NodeViewContent as Tb}from"@tiptap/react";import{useEffect as wp,useRef as Eb,useState as kp}from"react";import{useAtomValue as wb}from"jotai";import{jsx as Pp,jsxs as kb}from"react/jsx-runtime";var Np=s(e=>{let t=Eb(null),[r,o]=kp(!1),n=wb(pt),i=e.node.attrs.isEditorMode===!0,[a,l]=kp(e.editor.isEditable);wp(()=>{let d=t.current;if(d)return Pt({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]),wp(()=>{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 kb(xb,{ref:t,"data-column-cell":"true","data-column-id":e.node.attrs.columnId,"data-cell-index":e.node.attrs.index,className:S("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&&Pp("span",{className:"courier-pointer-events-none courier-pl-4",children:"Drag and drop content blocks"}),Pp(Tb,{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full"})]})},"ColumnCellComponentNode");var qa=Nb.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",Pb(e,{"data-type":"column-cell",style:"flex: 1 1 0%; width: 0; min-height: 120px;"}),0]},addNodeView(){return Mb(Np)},addCommands(){return{insertColumnCell:()=>({chain:e})=>e().insertContent({type:this.name}).run()}},addProseMirrorPlugins(){return[new Ab({key:new Sb("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}})]}});import{mergeAttributes as Hb,Node as Bb}from"@tiptap/core";import{ReactNodeViewRenderer as Db}from"@tiptap/react";import{v4 as Fb}from"uuid";import{useSetAtom as Ib}from"jotai";import{useCallback as Lb}from"react";import{jsx as Ja}from"react/jsx-runtime";var Rb=s(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return Ja("div",{className:"courier-w-full node-element",children:Ja("div",{className:"courier-custom-code courier-py-1.5",dangerouslySetInnerHTML:t?{__html:e}:{__html:" "}})})},"CustomCodeComponent"),Mp=s(e=>{let t=Ib(Re),r=Lb(()=>{if(!e.editor.isEditable)return;let i=We(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 Ja(Ye,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element",n&&"is-empty"),onClick:r,editor:e.editor,"data-node-type":"customCode",children:Ja(Rb,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var Pr={code:"<!-- Add your HTML code here -->"},ja=Bb.create({name:"customCode",group:"block",atom:!0,selectable:!1,onCreate(){Oe(this.editor,this.name)},addAttributes(){return{code:{default:Pr.code,parseHTML:e=>e.getAttribute("data-code")||"",renderHTML:e=>({"data-code":e.code})},id:{default:()=>`node-${Fb()}`,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",Hb(this.options.HTMLAttributes,e,{"data-type":"custom-code"}),["div",{innerHTML:e.code||Pr.code}]]},addNodeView(){return Db(Mp)},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"}}}});import{useRef as Ga,useCallback as Ap,useState as Sp,lazy as Ub,Suspense as Wb,useEffect as _b}from"react";import{forwardRef as Vb}from"react";import{jsx as Ob}from"react/jsx-runtime";var fc=Vb(({className:e,...t},r)=>{let o=S("courier-animate-spin courier-rounded-full courier-border-2 courier-border-current courier-border-t-transparent courier-h-4 courier-w-4",e);return Ob("div",{className:o,ref:r,...t})});fc.displayName="Spinner";import{jsx as nn}from"react/jsx-runtime";var zb=s(()=>{let[e,t]=Sp(!1),r=Ga(null);return _b(()=>{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"),$b=Ub(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function Zb(e,t){let r=Ga();return Ap((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}s(Zb,"useDebounce");var qb=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"),gc=s(({code:e,onSave:t,onValidationChange:r,validator:o=qb})=>{let n=Ga(null),i=Ga(null),[a,l]=Sp(!0),{isDark:c,containerRef:u}=zb(),d=Ap(()=>{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=Zb(v=>{setTimeout(()=>{d()&&t(v)},150)},500);return nn("div",{ref:u,className:"courier-h-full courier-overflow-hidden",children:nn("div",{className:"courier-h-full courier-p-2",children:nn(Wb,{fallback:nn("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:nn(fc,{})}),children:nn($b,{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");import{zodResolver as Jb}from"@hookform/resolvers/zod";import{useForm as jb}from"react-hook-form";import{z as Ip}from"zod";var Lp=Ip.object({code:Ip.string()});import{useCallback as Gb}from"react";import{useAtom as Kb}from"jotai";import{Fragment as Rp,jsx as dr,jsxs as vi}from"react/jsx-runtime";var hc=s(({element:e,editor:t})=>{let r=jb({resolver:Jb(Lp),defaultValues:{...Pr,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({editor:t,element:e,form:r,nodeType:"customCode"}),[n,i]=Kb(tr),a=Gb(l=>{r.setValue("code",l),o({code:l})},[r,o]);return e?vi(Ne,{...r,children:[!n&&dr(Qe,{type:"customCode"}),vi("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[dr(Ce,{className:"courier-w-fit",variant:"outline",buttonSize:"small",onClick:()=>i(!n),children:n?vi(Rp,{children:[dr(Fl,{className:"courier-w-3 courier-h-3"}),"Minimize"]}):vi(Rp,{children:[dr(Gn,{className:"courier-w-3 courier-h-3"}),"Expand Editor"]})}),dr("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:dr("form",{onChange:()=>{o(r.getValues())},className:"courier-h-full",children:dr(J,{control:r.control,name:"code",render:({field:l})=>vi(Z,{className:"courier-h-full",children:[dr(q,{children:dr(gc,{code:l.value,onSave:c=>{l.onChange(c),a(c)},onCancel:()=>{}})}),dr(j,{})]})})})})]})]}):null},"CustomCodeForm");import{mergeAttributes as i0}from"@tiptap/core";import{Node as Yb,mergeAttributes as Xb,isNodeSelection as Qb,nodeInputRule as e0}from"@tiptap/core";import{TextSelection as bc,NodeSelection as t0}from"@tiptap/pm/state";var Hp=Yb.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",Xb(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}):Qb(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(bc.create(a.doc,u.pos+1)):u.nodeAfter.isBlock?a.setSelection(t0.create(a.doc,u.pos)):a.setSelection(bc.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(bc.create(a.doc,d+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[e0({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});import{ReactNodeViewRenderer as a0}from"@tiptap/react";import{v4 as s0}from"uuid";import{useSetAtom as r0}from"jotai";import{useCallback as o0}from"react";import{jsx as Ka}from"react/jsx-runtime";var n0=s(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>Ka("div",{className:"courier-w-full node-element courier-flex",children:Ka("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"),Bp=s(e=>{let t=r0(Re),r=o0(()=>{if(!e.editor.isEditable)return;let o=We(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return Ka(Ye,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:Ka(n0,{...e.node.attrs})})},"DividerComponentNode");var Mt={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},Ya={padding:24,color:"transparent",size:1,radius:0,variant:"spacer"},yc=Hp.extend({name:"divider",atom:!0,onCreate(){Oe(this.editor,this.name)},addAttributes(){return{padding:{default:Mt.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.margin})},size:{default:Mt.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},color:{default:Mt.color,parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color})},width:{default:Mt.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},radius:{default:Mt.radius,parseHTML:e=>e.getAttribute("data-radius"),renderHTML:e=>({"data-radius":e.radius})},variant:{default:Mt.variant,parseHTML:e=>e.getAttribute("data-variant"),renderHTML:e=>({"data-variant":e.variant})},id:{default:()=>`node-${s0()}`,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",i0(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return a0(Bp)},addInputRules(){return[]}});import{z as an}from"zod";var Dp=an.object({padding:an.number(),color:an.string(),size:an.number(),radius:an.number(),variant:an.enum(["divider","spacer"]).default("divider")});import{zodResolver as l0}from"@hookform/resolvers/zod";import{useForm as c0}from"react-hook-form";import{Fragment as u0,jsx as _e,jsxs as sn}from"react/jsx-runtime";var Fp=s(({element:e,editor:t})=>{let r=c0({resolver:l0(Dp),defaultValues:{...Mt,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({editor:t,element:e,form:r,nodeType:"divider"});if(!e)return null;let n=r.watch("variant");return sn(Ne,{...r,children:[_e(Qe,{type:n}),sn("form",{onChange:()=>{o(r.getValues())},children:[_e("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),_e(J,{control:r.control,name:"padding",render:({field:i})=>sn(Z,{children:[_e(q,{children:_e(pe,{startAdornment:_e(po,{}),type:"number",...i,onChange:a=>{i.onChange(a),o({...r.getValues(),margin:a.target.value})}})}),_e(j,{})]})}),n==="divider"&&sn(u0,{children:[_e(le,{className:"courier-mt-6 courier-mb-4"}),_e("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Line"}),_e(J,{control:r.control,name:"size",render:({field:i})=>sn(Z,{className:"courier-mb-4",children:[_e(q,{children:_e(pe,{startAdornment:_e(Er,{}),type:"number",min:0,...i,onChange:a=>{i.onChange(a),o({...r.getValues(),width:a.target.value})}})}),_e(j,{})]})}),_e(J,{control:r.control,name:"color",render:({field:i})=>sn(Z,{className:"courier-mb-4",children:[_e(q,{children:_e(Ze,{...i,defaultValue:Mt.color,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),_e(j,{})]})})]})]})]})},"DividerForm");var Cc=Qo.extend({content:"(block)+"});import{Node as b0}from"@tiptap/core";import{ReactNodeViewRenderer as y0}from"@tiptap/react";import{NodeViewWrapper as d0}from"@tiptap/react";import{forwardRef as m0,useEffect as Vp,useState as p0}from"react";import{jsx as Xa}from"react/jsx-runtime";function f0(){let[e,t]=p0(!1);return Vp(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(f0,"useMountStatus");var g0=m0(({children:e,className:t,dragOverlay:r,id:o},n)=>(Vp(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),Xa(d0,{ref:n,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":o,"data-placeholder":"true",className:S("courier-flex courier-items-start courier-gap-2 courier-pl-6",t),children:e}))),h0=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"),Op=s(({node:e})=>{let t=e.attrs.type,r=e.attrs.id,o=f0();return Xa(g0,{id:r,fadeIn:!o,children:Xa("div",{className:S("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:Xa("div",{className:"courier-text-accent-foreground",children:h0(t)})})})},"DragPlaceholderComponent");var Up=b0.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 y0(Op,{as:"div",className:"drag-placeholder-wrapper"})}});import{Extension as C0}from"@tiptap/core";import{Plugin as v0,PluginKey as x0}from"@tiptap/pm/state";var T0=new x0("file-handler"),E0=C0.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new v0({key:T0,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)}}})]}}),Qa=E0;import{Extension as w0}from"@tiptap/core";import{Plugin as k0,PluginKey as P0}from"@tiptap/pm/state";var N0=new P0("fixedChannelPaste"),M0=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"),A0=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"),es=w0.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new k0({key:N0,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!M0(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=A0(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}}});import{Extension as S0}from"@tiptap/core";import{Plugin as I0,PluginKey as L0,TextSelection as vc}from"@tiptap/pm/state";var Po=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"),xc=s(e=>!!e.view.dom.closest(".courier-inbox-editor"),"isInInboxChannel"),Wp=s(e=>{if(!xc(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"),No=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"),ts=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"),rs=new L0("fixedChannelSelection"),os=S0.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!Po(e,this.options.channels))return!1;let o=No(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(vc.create(t.doc,l,c)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!Po(e,this.options.channels))return!1;let t=No(e);if(!t)return!1;let{start:r,end:o}=t;return e.commands.setTextSelection({from:r,to:o}),!0},Backspace:({editor:e})=>{if(!Po(e,this.options.channels))return!1;if(xc(e)){let{selection:t}=e.state;if(No(e)&&t.$anchor.parentOffset===0&&Wp(e))return!0}if(ts(e)){let t=No(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(!Po(e,this.options.channels))return!1;if(xc(e)){let{selection:t}=e.state,r=No(e);if(r){let o=r.node.textContent;if(t.$anchor.parentOffset===o.length&&Wp(e))return!0}}if(ts(e)){let t=No(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 I0({key:rs,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!Po(o,this.options.channels))return!1;if(ts(o)){let n=No(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(vc.create(u.doc,l,c)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!Po(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(rs,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!Po(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&ts(r)){let n=rs.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(vc.create(c.doc,a,l)),e.dispatch(c),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(rs)||t}}})]}});import{mergeAttributes as z0}from"@tiptap/core";import{Node as R0,mergeAttributes as H0,textblockTypeInputRule as B0}from"@tiptap/core";var _p=R0.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]}`,H0(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=>B0({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});import{z as Nr}from"zod";var zp=Nr.object({paddingVertical:Nr.number(),paddingHorizontal:Nr.number(),backgroundColor:Nr.string(),borderWidth:Nr.number(),borderColor:Nr.string(),textAlign:Nr.enum(["left","center","right","justify"]).default("left"),selected:Nr.boolean().default(!1),id:Nr.string().optional()}),ue={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderColor:"transparent",textAlign:"left",selected:!1};import{NodeViewContent as D0,NodeViewWrapper as F0}from"@tiptap/react";import{useSetAtom as V0,useAtomValue as O0}from"jotai";import{useCallback as U0}from"react";import{jsx as Jr}from"react/jsx-runtime";var $p=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=O0(pt);return Jr("div",{className:"courier-w-full node-element",children:Jr("div",{style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderColor:i,borderStyle:n>0?"solid":"none"},children:Jr("div",{style:{pointerEvents:u?"none":"auto"},children:Jr(D0,{as:c})})})})},"TextBlockComponent"),ns=s(e=>{let t=V0(Re),r=U0(()=>{if(!e.editor.isEditable)return;let l=We(e);l&&t(l)},[e,t]),o=!e.node.content||e.node.content.size===0,n=jr(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null;return(i==null?void 0:i.parent.type.name)==="blockquote"?Jr(F0,{children:Jr($p,{...e.node.attrs,type:e.node.type.name})}):Jr(Ye,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:Jr($p,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");import{zodResolver as W0}from"@hookform/resolvers/zod";import{useForm as _0}from"react-hook-form";import{jsx as ve,jsxs as Gr}from"react/jsx-runtime";var Zp=s(({element:e,editor:t})=>{let r=_0({resolver:W0(zp),defaultValues:{...ue,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?Gr(Ne,{...r,children:[ve(Qe,{type:"text"}),Gr("form",{onChange:()=>{o(r.getValues())},children:[ve("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),Gr("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[ve(J,{control:r.control,name:"paddingHorizontal",render:({field:n})=>Gr(Z,{children:[ve(q,{children:ve(pe,{startAdornment:ve(ti,{}),type:"number",min:0,...n})}),ve(j,{})]})}),ve(J,{control:r.control,name:"paddingVertical",render:({field:n})=>Gr(Z,{children:[ve(q,{children:ve(pe,{startAdornment:ve(po,{}),type:"number",min:0,...n})}),ve(j,{})]})})]}),ve(J,{control:r.control,name:"backgroundColor",render:({field:n})=>Gr(Z,{className:"courier-mb-4",children:[ve(q,{children:ve(Ze,{...n,defaultValue:ue.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),ve(j,{})]})}),ve(le,{className:"courier-mb-4"}),ve("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),ve(J,{control:r.control,name:"borderWidth",render:({field:n})=>Gr(Z,{className:"courier-mb-3",children:[ve(q,{children:ve(pe,{startAdornment:ve(Er,{}),type:"number",min:0,...n})}),ve(j,{})]})}),ve(J,{control:r.control,name:"borderColor",render:({field:n})=>Gr(Z,{className:"courier-mb-4",children:[ve(q,{children:ve(Ze,{...n,defaultValue:ue.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),ve(j,{})]})})]})]}):null},"TextBlockForm");import{ReactNodeViewRenderer as $0}from"@tiptap/react";var Tc=_p.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){Oe(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:ue.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):ue.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:ue.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):ue.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:ue.textAlign,parseHTML:t=>t.style.textAlign||ue.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:ue.backgroundColor,parseHTML:t=>t.style.backgroundColor||ue.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:ue.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):ue.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderColor:{default:ue.borderColor,parseHTML:t=>t.style.borderColor||ue.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]}`,z0(this.options.HTMLAttributes,t),0]},addNodeView(){return $0(ns)}});import{mergeAttributes as K0,Node as Y0}from"@tiptap/core";import{ReactNodeViewRenderer as X0}from"@tiptap/react";import{useSetAtom as qp}from"jotai";import{useCallback as Yt,useEffect as wc,useMemo as Z0,useRef as Jp,useState as jp}from"react";import{Fragment as G0,jsx as mr,jsxs as Ec}from"react/jsx-runtime";var q0=["image/png","image/jpeg","image/gif","image/webp"],J0=s(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderColor:n,isUploading:i,width:a,imageNaturalWidth:l,onFileSelect:c,editor:u})=>{let[d,m]=jp(!1),[p,f]=jp(!0),v=Jp(null),h=Jp(null);wc(()=>{e&&f(!0)},[e]),wc(()=>{if(e&&!l&&u){let C=new Image;C.onload=()=>{try{if(!u.view||!u.state)return;let T=u.view.state.selection.from;u.chain().setNodeSelection(T).updateAttributes("imageBlock",{imageNaturalWidth:C.naturalWidth}).run()}catch{}},C.src=e}},[e,l,u]);let b=Yt(C=>{var M,R;let T=(R=(M=u==null?void 0:u.view)==null?void 0:M.dom)==null?void 0:R.closest(".ProseMirror"),x=(T==null?void 0:T.clientWidth)||1e3,P=Math.min(100,C/x*100);return Math.round(P)},[u]),y=Z0(()=>b(l),[b,l]),N=Yt(C=>q0.includes(C),[]),g=Yt(C=>{C.preventDefault(),C.stopPropagation(),C.dataTransfer.types.includes("Files")&&Array.from(C.dataTransfer.items).some(P=>N(P.type))&&(m(!0),C.dataTransfer.dropEffect="copy")},[N]),k=Yt(C=>{C.preventDefault(),C.stopPropagation(),m(!1)},[]),A=Yt(C=>{C.preventDefault(),C.stopPropagation(),C.dataTransfer.types.includes("Files")&&Array.from(C.dataTransfer.items).some(P=>N(P.type))&&m(!0)},[N]),E=Yt(C=>{C.preventDefault(),C.stopPropagation(),m(!1);let x=Array.from(C.dataTransfer.files).find(P=>N(P.type));x&&c&&c(x)},[c,N]),L=Yt(C=>{var x;let T=(x=C.target.files)==null?void 0:x[0];T&&c&&c(T),C.target&&(C.target.value="")},[c]),w=Yt(()=>{var C;(C=v.current)==null||C.click()},[]);return Ji(e)?Ec("div",{className:S("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:A,onDragLeave:k,onDrop:E,style:{pointerEvents:"all"},children:[i?mr(fo,{className:"courier-w-8 courier-h-8"}):Ec(G0,{children:[mr("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),mr("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:w,children:"Browse"})]}),mr("input",{ref:v,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:L})]}):mr("div",{className:"courier-w-full node-element",children:Ec("div",{className:S("courier-relative courier-p-1",(i||p)&&"courier-w-full courier-aspect-[4/3] courier-bg-gray-100"),children:[(i||p)&&mr("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:mr(fo,{className:"courier-w-8 courier-h-8"})}),mr("img",{ref:h,src:e,alt:t,className:S("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 T=u.view.state.selection.from;u.chain().setNodeSelection(T).updateAttributes("imageBlock",{imageNaturalWidth:C.target.naturalWidth}).run()},100)}catch(T){console.warn("Editor not ready for image update:",T)}},onError:()=>f(!1)})]})})},"ImageBlockComponent"),j0=["image/png","image/jpeg","image/gif","image/webp"],Gp=s(e=>{let t=qp(Re),r=qp(Q),{uploadImage:o}=On(),n=Yt(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]);wc(()=>{var c,u;let l=We(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=jr(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=Yt(()=>{if(!e.editor.isEditable)return;let l=We(e);l&&(e.editor.commands.blur(),t(l))},[e,t]),a=Yt(async l=>{let c=jr(e.getPos);We(e)&&c!==null&&e.editor.chain().focus().setNodeSelection(c).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!j0.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=jr(e.getPos);if(We(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=jr(e.getPos);We(e)&&p!==null&&e.editor.chain().focus().setNodeSelection(p).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return mr(Ye,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:mr(J0,{...e.node.attrs,onFileSelect:a,editor:e.editor})})},"ImageBlockView");var Be={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderColor:"transparent",isUploading:!1,imageNaturalWidth:0},is=Y0.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){Oe(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:Be.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:Be.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:Be.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:Be.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:Be.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:Be.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:Be.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:Be.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:Be.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",K0(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return X0(Gp)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...Be,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...Be,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}}}});import{z as pr}from"zod";var Kp=pr.object({sourcePath:pr.string(),link:pr.string().optional(),alt:pr.string().optional(),alignment:pr.enum(["left","center","right"]),width:pr.number().min(1).max(100),borderWidth:pr.number(),borderColor:pr.string(),isUploading:pr.boolean().optional(),imageNaturalWidth:pr.number()});import{zodResolver as Q0}from"@hookform/resolvers/zod";import{useSetAtom as e3}from"jotai";import{ArrowUp as t3}from"lucide-react";import{useCallback as Ti,useEffect as Xp,useRef as Pc,useState as ss}from"react";import{useForm as r3}from"react-hook-form";import{useSetAtom as kc}from"jotai";import*as xi from"react";import{useRef as Yp}from"react";import{jsx as as}from"react/jsx-runtime";var Kr=xi.forwardRef(({as:e="Input",autoResize:t,onChange:r,...o},n)=>{let i=Yp(null),a=Yp(null),l=kc(li),c=kc(om),u=kc(sa),d=xi.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=xi.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 as("div",{ref:i,className:"courier-relative",children:as(pe,{...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 as("div",{ref:i,className:"courier-relative",children:as(Cl,{...v})})});Kr.displayName="TextInput";import{Fragment as Qp,jsx as G,jsxs as et}from"react/jsx-runtime";var ef=s(({element:e,editor:t})=>{var L,w;let r=Pc(null),o=Pc(null),n=Pc(null),[i,a]=ss(""),[l,c]=ss(!1),[u,d]=ss(((L=e==null?void 0:e.attrs)==null?void 0:L.imageNaturalWidth)||0),[m,p]=ss(!1),f=e3(Q),{uploadImage:v}=On(),h=r3({resolver:Q0(Kp),defaultValues:{...Be,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:b}=Xe({editor:t,element:e,form:h,nodeType:"imageBlock"});Xp(()=>{var T;let C=(T=e==null?void 0:e.attrs)==null?void 0:T.sourcePath;if(C&&!u){let x=new Image;x.onload=()=>{d(x.naturalWidth);let P={...h.getValues(),imageNaturalWidth:x.naturalWidth};h.setValue("imageNaturalWidth",x.naturalWidth),b(P)},x.src=C}},[(w=e==null?void 0:e.attrs)==null?void 0:w.sourcePath,u,h,b]);let y=Ti(C=>{var R,I;let T=(I=(R=t==null?void 0:t.view)==null?void 0:R.dom)==null?void 0:I.closest(".ProseMirror"),x=(T==null?void 0:T.clientWidth)||1e3;if(C||(C=u),!C)return 0;let P=Math.min(100,C/x*100);return Math.round(P)},[t,u]),N=Ti(C=>{var T;C.preventDefault(),(T=r.current)==null||T.click()},[]),g=Ti((C,T)=>{let x=y(C.naturalWidth);a(`${x}%`),c(!1),h.setValue("sourcePath",T),h.setValue("imageNaturalWidth",C.naturalWidth),h.setValue("width",x);let P={...h.getValues(),sourcePath:T,width:x,imageNaturalWidth:C.naturalWidth,isUploading:!1};b(P)},[h,b,y]),k=Ti(C=>{if(!C){h.setValue("imageNaturalWidth",0),h.setValue("width",0),b({...h.getValues(),sourcePath:"",imageNaturalWidth:0,width:0});return}let T=new Image;T.onload=()=>{let x=y(T.naturalWidth);h.setValue("imageNaturalWidth",T.naturalWidth),h.setValue("width",x);let P={...h.getValues(),sourcePath:C,width:x,imageNaturalWidth:T.naturalWidth};b(P)},T.onerror=()=>{console.debug("Image failed to load:",C)},T.src=C},[h,b,y]),A=Ti(C=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{k(C)},500)},[k]);Xp(()=>()=>{n.current&&clearTimeout(n.current)},[]);let E=h.getValues().sourcePath;return e?et(Ne,{...h,children:[G(Qe,{type:"image"}),et("form",{ref:o,onChange:()=>{let C=h.getValues();b(C)},children:[G("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),et(ra,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[et(qn,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[G($o,{value:"file",className:"courier-flex-1",children:"From file"}),G($o,{value:"url",className:"courier-flex-1",children:"From URL"})]}),G(oa,{value:"file",children:et("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[G(Ce,{onClick:N,className:"courier-w-full",variant:"outline",type:"button",disabled:m,children:m?G(Qp,{children:"Uploading..."}):et(Qp,{children:[G(t3,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),G("input",{ref:r,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:C=>{var x;let T=(x=C.target.files)==null?void 0:x[0];if(T){p(!0),h.setValue("sourcePath",""),b({...h.getValues(),sourcePath:"",isUploading:!0});let P=new FileReader;P.onload=async()=>{try{let R=(await v({file:T})).url,I=new Image;I.onload=()=>{g(I,R),p(!1)},I.onerror=()=>{f({message:"Upload failed: Failed to load uploaded image",toastProps:{duration:6e3,description:`File: ${T.name} (${(T.size/1024/1024).toFixed(2)}MB)`}}),p(!1),b({...h.getValues(),isUploading:!1})},I.src=R}catch(M){console.error("Error uploading image:",M),f({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${T.name} (${(T.size/1024/1024).toFixed(2)}MB)`}}),p(!1),b({...h.getValues(),isUploading:!1})}},P.onerror=()=>{f({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${T.name} (${(T.size/1024/1024).toFixed(2)}MB)`}}),p(!1),b({...h.getValues(),isUploading:!1})},P.readAsDataURL(T)}}})]})}),G(oa,{value:"url",children:G(J,{control:h.control,name:"sourcePath",render:({field:C})=>et(Z,{className:"courier-mb-3",children:[G(q,{children:G(Kr,{as:"Textarea",...C,autoResize:!0,className:"courier-max-h-[88px]",onChange:T=>{C.onChange(T),A(T.target.value)}})}),G(j,{})]})})})]}),G(J,{control:h.control,name:"link",render:({field:C})=>et(Z,{className:"courier-mb-3",children:[G(q,{children:G(lr,{placeholder:"Link",value:C.value,onChange:T=>{C.onChange(T),b({...h.getValues(),link:T})}})}),G(j,{})]})}),G(J,{control:h.control,name:"alt",render:({field:C})=>et(Z,{className:"courier-mb-4",children:[G(q,{children:G(lr,{placeholder:"Alt text...",value:C.value,onChange:T=>{C.onChange(T),b({...h.getValues(),alt:T})}})}),G(j,{})]})}),G(le,{className:"courier-mt-6 courier-mb-4"}),G("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Width"}),(()=>{let C=h.getValues().width,T=h.getValues().imageNaturalWidth,x=y(T),P=C===x,M=P?"original":"fill";return et(qt,{type:"single",value:E?M:"original",onValueChange:R=>{if(!R||R===M)return;let I=R==="fill"?100:y(T);I>0&&(h.setValue("width",I),b({...h.getValues(),width:I}))},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",disabled:!E,children:[G(lt,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),G(lt,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:P||!E,children:"Fill"})]})})(),G(J,{control:h.control,name:"width",render:({field:C})=>et(Z,{className:"courier-flex-1 courier-mb-3",children:[G(q,{children:G(pe,{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:T=>{c(!0),a(T.target.value)},onChange:T=>{a(T.target.value)},onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),T.currentTarget.blur())},onBlur:T=>{c(!1);let x=parseFloat(T.target.value.replace("%",""));if(!isNaN(x)){let P=Math.min(100,Math.max(1,x));C.onChange(P),b({...h.getValues(),width:Math.round(P)})}}})}),G(j,{})]})}),G(J,{control:h.control,name:"width",render:({field:C})=>et(Z,{className:"courier-flex-1 courier-mb-3",children:[G(q,{children:G(bl,{min:0,max:100,value:[E?C.value:0],disabled:!E,onValueChange:T=>{C.onChange(T[0]),b({...h.getValues(),width:T[0]})}})}),G(j,{})]})}),G(J,{control:h.control,name:"alignment",render:({field:C})=>et(Z,{children:[G(q,{children:et(qt,{disabled:!E,type:"single",value:C.value,onValueChange:T=>{C.onChange(T),b({...h.getValues(),alignment:T})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[G(lt,{size:"sm",value:"left",className:"courier-w-full",children:G(Oa,{className:"courier-h-4 courier-w-4"})}),G(lt,{size:"sm",value:"center",className:"courier-w-full",children:G(Ua,{className:"courier-h-4 courier-w-4"})}),G(lt,{size:"sm",value:"right",className:"courier-w-full",children:G(Wa,{className:"courier-h-4 courier-w-4"})})]})}),G(j,{})]})}),G(le,{className:"courier-mt-6 courier-mb-4"}),G("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),G(J,{control:h.control,name:"borderWidth",render:({field:C})=>et(Z,{className:"courier-mb-3",children:[G(q,{children:G(pe,{startAdornment:G(Er,{}),type:"number",disabled:!E,min:0,...C,onChange:T=>{let x=parseInt(T.target.value)||0;C.onChange(x),b({...h.getValues(),borderWidth:x})}})}),G(j,{})]})}),G(J,{control:h.control,name:"borderColor",render:({field:C})=>et(Z,{className:"courier-mb-4",children:[G(q,{children:G(Ze,{...C,disabled:!E,defaultValue:Be.borderColor,onChange:T=>{C.onChange(T),b({...h.getValues(),[C.name]:T})}})}),G(j,{})]})})]})]}):null},"ImageBlockForm");import{getMarkRange as tf,mergeAttributes as o3}from"@tiptap/core";import n3 from"@tiptap/extension-link";import{Plugin as rf,TextSelection as of}from"@tiptap/pm/state";var Nc=n3.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",o3(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new rf({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=tf(l,c.type);return u?(r.dispatch(i.tr.setSelection(of.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(of.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 rf({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=tf(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}})]}});import{zodResolver as i3}from"@hookform/resolvers/zod";import{useSetAtom as a3}from"jotai";import{useRef as s3,useEffect as l3}from"react";import{useForm as c3}from"react-hook-form";import{z as Mc}from"zod";import{jsx as Mo,jsxs as nf}from"react/jsx-runtime";var u3=Mc.object({href:Mc.string(),openInNewTab:Mc.boolean().default(!1)}),af=s(({editor:e,mark:t,pendingLink:r})=>{let o=a3(la),n=s3(null),i=c3({resolver:i3(u3),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1}});l3(()=>{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 nf(Ne,{...i,children:[Mo("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),Mo("div",{className:"courier-space-y-4",children:Mo(J,{control:i.control,name:"href",render:({field:l})=>nf(Z,{children:[Mo(rr,{children:"URL"}),Mo(q,{children:Mo(Kr,{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)()}})}),Mo(j,{})]})})})]})},"LinkForm");import{mergeAttributes as y3,ReactNodeViewRenderer as C3}from"@tiptap/react";import{TextSelection as v3,Plugin as x3,PluginKey as T3}from"prosemirror-state";var Mr={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:"'"},cs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},d3=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),m3=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(He=0;He<10;He++)Mr[48+He]=Mr[96+He]=String(He);var He;for(He=1;He<=24;He++)Mr[He+111]="F"+He;var He;for(He=65;He<=90;He++)Mr[He]=String.fromCharCode(He+32),cs[He]=String.fromCharCode(He);var He;for(ls in Mr)cs.hasOwnProperty(ls)||(cs[ls]=Mr[ls]);var ls;function sf(e){var t=d3&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||m3&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?cs:Mr)[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(sf,"keyName");import{Plugin as p3}from"prosemirror-state";var f3=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function g3(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))f3?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(g3,"normalizeKeyName");function h3(e){let t=Object.create(null);for(let r in e)t[g3(r)]=e[r];return t}s(h3,"normalize");function Ac(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(Ac,"modifiers");function lf(e){return new p3({props:{handleKeyDown:b3(e)}})}s(lf,"keymap");function b3(e){let t=h3(e);return function(r,o){let n=sf(o),i,a=t[Ac(n,o)];if(a&&a(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let l=t[Ac(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=Mr[o.keyCode])&&i!=n){let l=t[Ac(i,o)];if(l&&l(r.state,r.dispatch,r))return!0}}return!1}}s(b3,"keydownHandler");import{v4 as E3}from"uuid";var Sc=en.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){Oe(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-${E3()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:ue.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):ue.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:ue.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):ue.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:ue.textAlign,parseHTML:e=>e.style.textAlign||ue.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:ue.backgroundColor,parseHTML:e=>e.style.backgroundColor||ue.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:ue.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):ue.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:ue.borderColor,parseHTML:e=>e.style.borderColor||ue.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",y3(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return C3(ns)},addProseMirrorPlugins(){return[lf({"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(v3.create(t.doc,i,a)),!0}return!1}}),new x3({key:new T3("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()}}});import{Extension as w3}from"@tiptap/core";import{Plugin as k3,PluginKey as P3}from"@tiptap/pm/state";var N3=new P3("selection"),Ic=w3.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 k3({key:N3,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}}})]}});import{forwardRef as M3}from"react";import{jsx as A3}from"react/jsx-runtime";var Lc=M3(({children:e,className:t,withShadow:r=!0,withBorder:o=!0,...n},i)=>{let a=S("courier-bg-popover courier-rounded-lg courier-text-popover-foreground",r?"courier-shadow-sm":"",o?"courier-border courier-border-border":"",t);return A3("div",{className:a,...n,ref:i,children:e})});Lc.displayName="Surface";import{v4 as S3}from"uuid";var I3=s((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),hf=s((e,t,r,o,n,i)=>{let a=`node-${S3()}`,c={heading:()=>e.schema.nodes.heading.create({...ue,...o,id:a},i),paragraph:()=>e.schema.nodes.paragraph.create({...ue,...o,id:a},i),text:()=>e.schema.nodes.paragraph.create({...ue,...o,id:a},i),spacer:()=>e.schema.nodes.divider.create({...Ya,...o,id:a}),divider:()=>e.schema.nodes.divider.create({...Mt,...o,id:a}),button:()=>e.schema.nodes.button.create({...Ie,...o,id:a},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...Be,...o,id:a}),image:()=>e.schema.nodes.imageBlock.create({...Be,...o,id:a}),customCode:()=>e.schema.nodes.customCode.create({...Pr,...o,id:a}),column:()=>e.schema.nodes.column.create({...qe,...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=I3(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 jr=s(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),We=s(e=>{let t=jr(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");import{GripVertical as L3}from"lucide-react";import{forwardRef as R3}from"react";import{jsx as bf}from"react/jsx-runtime";var yf=R3((e,t)=>bf("button",{...e,ref:t,"data-cypress":"draggable-handle","data-drag-handle":!0,className:S("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:bf(L3,{strokeWidth:1,className:"courier-w-5 courier-stroke-neutral-400 courier-fill-neutral-400 courier-pointer-events-none"})}));import{useAtomValue as B3,useSetAtom as D3}from"jotai";import{useCallback as At}from"react";import{v4 as F3}from"uuid";import{useMemo as H3}from"react";var Cf=s((e,t,r)=>H3(()=>{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 us=s((e,t,r)=>{let o=D3(Re),n=B3(ge),i=Cf(t,e,r),a=At(g=>{let k=-1;return e.state.doc.descendants((A,E)=>{var L;return((L=A.attrs)==null?void 0:L.id)===g?(k=E,!1):!0}),k},[e]),l=At((g,k)=>{var A,E,L;if(((A=n==null?void 0:n.type)==null?void 0:A.name)==="button"&&((E=n.attrs)!=null&&E.id)){let w=n.attrs.id,C=a(w);if(C>=0){let T=e.state.tr;return T.setNodeMarkup(C,void 0,{...(L=e.state.doc.nodeAt(C))==null?void 0:L.attrs,[g]:k}),e.view.dispatch(T),setTimeout(()=>{let x=a(w);if(x>=0){let P=e.state.doc.nodeAt(x);P&&o(P)}},0),!0}}return!1},[e,n,a,o]),c=At(()=>{var g,k;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"&&((k=n.attrs)!=null&&k.id)){let A=n.attrs.id,E=a(A);if(E>=0){let L=e.state.doc.nodeAt(E);if(!L)return!1;let w={...L.attrs,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},C=e.state.tr;return C.setNodeMarkup(E,void 0,w),e.view.dispatch(C),setTimeout(()=>{let T=a(A);if(T>=0){let x=e.state.doc.nodeAt(T);x&&o(x)}},0),!0}}return!1},[e,n,a,o]),u=At(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let k=n.attrs.fontWeight==="bold"?"normal":"bold";if(l("fontWeight",k))return!0}if(i&&r){let k=i.getRuleForItem("bold");if(k&&k.action.type==="toggle_off"){let A=e.chain().focus();return k.action.targets.forEach(E=>{E==="italic"&&r.isItalic&&A.toggleItalic()}),A.toggleBold().run(),!0}}return e.chain().focus().toggleBold().run()},[e,n,l,i,r]),d=At(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let k=n.attrs.fontStyle==="italic"?"normal":"italic";if(l("fontStyle",k))return!0}if(i&&r){let k=i.getRuleForItem("italic");if(k&&k.action.type==="toggle_off"){let A=e.chain().focus();return k.action.targets.forEach(E=>{E==="bold"&&r.isBold&&A.toggleBold()}),A.toggleItalic().run(),!0}}return e.chain().focus().toggleItalic().run()},[e,n,l,i,r]),m=At(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let k=!n.attrs.isStrike;if(l("isStrike",k))return!0}return e.chain().focus().toggleMark("strike").run()},[e,n,l]),p=At(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let k=!n.attrs.isUnderline;if(l("isUnderline",k))return!0}return e.chain().focus().toggleMark("underline").run()},[e,n,l]),f=At(()=>e.chain().focus().setTextAlign("left").run(),[e]),v=At(()=>e.chain().focus().setTextAlign("center").run(),[e]),h=At(()=>e.chain().focus().setTextAlign("right").run(),[e]),b=At(()=>e.chain().focus().setTextAlign("justify").run(),[e]),y=At((g,k)=>e.chain().focus().setLink({href:g,target:k?"_blank":""}).run(),[e]),N=At(()=>{let g=e.isActive("blockquote");if(e.chain().focus().toggleBlockquote().run()){let{selection:E}=e.state,L=E.$anchor;if(g){let w=L.node();(w.type.name==="paragraph"||w.type.name==="heading")&&o(w)}else for(let w=L.depth;w>0;w--){let C=L.node(w);if(C.type.name==="blockquote"){if(C.attrs.id)o(C);else{let T=L.before(w),x=`node-${F3()}`,P=e.state.tr;P.setNodeMarkup(T,void 0,{...C.attrs,id:x}),e.view.dispatch(P);let M=e.state.doc.nodeAt(T);M&&o(M)}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");import{jsx as Rc}from"react/jsx-runtime";var V3=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"),ds=s(({type:e})=>Rc("div",{className:"courier-flex courier-w-full courier-pointer-events-none",children:Rc("div",{className:S("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:Rc("div",{className:"courier-text-accent-foreground dark:courier-text-accent",children:V3(e)})})}),"DropIndicatorPlaceholder");import{Fragment as Z3,jsx as St,jsxs as ms}from"react/jsx-runtime";function z3(){let[e,t]=ps(!1);return Hc(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(z3,"useMountStatus");var Ye=s(({children:e,id:t,className:r,editor:o,getPos:n,...i})=>{let a=Yr(null),l=Yr(null),c=Yr(null),[u,d]=ps(!1),[m,p]=ps(null),[f,v]=ps(null),h=Yr(null),b=Yr(!1),y=Yr(null),N=Yr(null),g=Yr(null),k=z3(),A=u&&!k,E=Ao(()=>{if(!o||!t)return null;let w=null;return o.state.doc.descendants((C,T,x)=>{var P;if(((P=C.attrs)==null?void 0:P.id)===t){let M=0;return x&&x.content.forEach((R,I,H)=>{R===C&&(M=H)}),w={node:C,pos:T,parent:x,index:M},!1}return!0}),w},[t,o]),L=Ao(()=>{if(!o)return!1;let w=E();return!w||!w.parent?!1:w.index===w.parent.childCount-1},[o,E]);return Hc(()=>{let w=a.current,C=l.current;if(!w)return;let T=sr(gi({element:w,dragHandle:C||void 0,getInitialData:()=>{var I,H,V,F,O,B;let x=E(),P="text";if(x){let W=x.node;switch(W.type.name){case"heading":P="heading";break;case"paragraph":P="text";break;case"imageBlock":P="image";break;case"divider":P=(I=W.attrs)!=null&&I.spacer?"spacer":"divider";break;case"button":P="button";break;case"customCode":P="customCode";break;case"column":P="column";break}}let M=(x==null?void 0:x.parent)===o.state.doc,R=((H=x==null?void 0:x.parent)==null?void 0:H.type.name)==="columnCell";return{id:t,type:M?"editor":R?"column-cell-item":"nested-drag",index:(V=x==null?void 0:x.index)!=null?V:0,dragType:P,pos:x==null?void 0:x.pos,originalIndex:(F=x==null?void 0:x.index)!=null?F:0,columnId:R?(O=x==null?void 0:x.parent)==null?void 0:O.attrs.columnId:void 0,cellIndex:R?(B=x==null?void 0:x.parent)==null?void 0:B.attrs.index:void 0}},onGenerateDragPreview:()=>{let x=w.querySelectorAll("[data-no-drag-preview]"),P=[];x.forEach((M,R)=>{let I=M;P[R]=I.style.display,I.style.display="none"}),requestAnimationFrame(()=>{x.forEach((M,R)=>{let I=M;I.style.display=P[R]})})},onDragStart:()=>{d(!0),document.body.style.cursor="grabbing";let x=s(P=>{N.current=P.clientY},"handleMouseMove");document.addEventListener("mousemove",x),g.current=()=>{document.removeEventListener("mousemove",x)},o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{d(!1),document.body.style.cursor="",g.current&&(g.current(),g.current=null),o&&o.setEditable(!0)}}),Pt({element:w,getData:({input:x,element:P})=>{var B,W,U,ie;let M=E(),R=(M==null?void 0:M.parent)===o.state.doc,I=((B=M==null?void 0:M.parent)==null?void 0:B.type.name)==="columnCell",H={id:t,type:R?"editor":I?"column-cell-item":"nested-drag",index:(W=M==null?void 0:M.index)!=null?W:0,pos:M==null?void 0:M.pos,nodeType:M==null?void 0:M.node.type.name,columnId:I?(U=M==null?void 0:M.parent)==null?void 0:U.attrs.columnId:void 0,cellIndex:I?(ie=M==null?void 0:M.parent)==null?void 0:ie.attrs.index:void 0};if(P.getAttribute("data-node-type")==="column"){let ee=P.getBoundingClientRect(),K=x.clientY,D=30,z=Math.abs(K-ee.top),oe=Math.abs(K-ee.bottom);if(z>D&&oe>D)return{...H,disableDropIndicator:!0}}let F=P.closest('[data-column-cell="true"]');if(L()&&w){let ee=w.getBoundingClientRect(),K=x.clientY,D=ee.top+ee.height/2;if(K>=D&&K>ee.bottom)return{...H,[Symbol.for("closestEdge")]:"bottom"}}let O=L()?["top","bottom"]:["top"];return Gm(H,{input:x,element:P,allowedEdges:O})},canDrop:({source:x})=>x.data.id!==t,onDragEnter:({self:x,source:P,location:M})=>{var W,U,ie,ee,K;if(x.data.disableDropIndicator){p(null);return}y.current&&(clearTimeout(y.current),y.current=null);let R=M.current.dropTargets;if(R.length>0&&R[0].element!==w){p(null),b.current=!1,h.current=null;return}let I=hi(x.data),H=I,V=L(),F=(ie=(U=(W=M==null?void 0:M.current)==null?void 0:W.input)==null?void 0:U.clientY)!=null?ie:N.current;F!==null&&(N.current=F);let O=P.data;v(O.dragType||null),I==="bottom"&&V&&P.data.id===t&&(H=null);let B=P.data.type==="editor"||P.data.type==="column-cell-item";if(V&&B)if(I==="top"){let D=a.current;if(D){let z=D.getBoundingClientRect(),oe=(ee=F!=null?F:N.current)!=null?ee:z.top+z.height/2,be=z.top+z.height/2,Pe=z.height,Me=Math.max(10,Math.min(30,Pe*.3));oe<be-Me?(b.current=!1,H="top"):b.current?H="bottom":H="top"}else b.current=!1,H="top"}else b.current?H="bottom":I==="bottom"&&(b.current=!0,H="bottom");else V&&!B&&(b.current=!1);if(!b.current&&(P.data.type==="editor"||P.data.type==="column-cell-item")&&typeof P.data.index=="number"){let D=P.data.index,z=E();((K=z==null?void 0:z.index)!=null?K:0)===D+1&&I==="top"&&(H=null)}H!==h.current&&(h.current=H,p(H))},onDrag:({self:x,source:P,location:M})=>{var W,U,ie,ee,K;if(x.data.disableDropIndicator){p(null);return}y.current&&(clearTimeout(y.current),y.current=null);let R=M.current.dropTargets;if(R.length>0&&R[0].element!==w){p(null);return}let I=(ie=(U=(W=M==null?void 0:M.current)==null?void 0:W.input)==null?void 0:U.clientY)!=null?ie:N.current;I!==null&&(N.current=I);let H=hi(x.data),V=H,F=L(),O=P.data;v(O.dragType||null),H==="bottom"&&F&&P.data.id===t&&(V=null);let B=P.data.type==="editor"||P.data.type==="column-cell-item";if(F&&B)if(H==="top"){let D=a.current;if(D){let z=D.getBoundingClientRect(),oe=(ee=I!=null?I:N.current)!=null?ee:z.top+z.height/2,be=z.top+z.height/2,Pe=z.height,Me=Math.max(10,Math.min(30,Pe*.3));oe<be-Me?(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&&(P.data.type==="editor"||P.data.type==="column-cell-item")&&typeof P.data.index=="number"){let D=P.data.index,z=E();((K=z==null?void 0:z.index)!=null?K:0)===D+1&&H==="top"&&(V=null)}V!==h.current&&(h.current=V,p(V))},onDragLeave:()=>{if(L()&&b.current){let x=w==null?void 0:w.getBoundingClientRect(),P=N.current;if(x&&P!==null&&P>=x.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),T()}},[t,L,o,E]),St($3,{ref:a,id:t,fadeIn:A,className:r,dragging:u,closestEdge:m,dragType:f,handleRef:l,contentRef:c,editor:o,...i,children:e})},"SortableItemWrapper"),$3=W3(({children:e,className:t,dragOverlay:r,handleRef:o,contentRef:n,closestEdge:i,dragType:a,id:l,editor:c,fadeIn:u,dragging:d,...m},p)=>{Hc(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let f=U3(ge),{resetButtonFormatting:v}=us(c),h=s((E,L)=>{let w=null;return E.doc.descendants((C,T)=>{var x;return w!==null?!1:((x=C.attrs)==null?void 0:x.id)===L?(w=T,!1):!0}),w},"findNodePositionById"),b=Ao(()=>{if(!c||!l)return{node:null,pos:null};let E=h(c.state,l);return E===null?{node:null,pos:null}:{node:c.state.doc.nodeAt(E),pos:E}},[c,l]),y=Ao(()=>{c.commands.blur(),f(null)},[c,f]),N=Ao(()=>{if(!(!c||!l))try{let{node:E,pos:L}=b();if(!E||L===null)return;let w=E.nodeSize,C=c.state.doc.childCount===1;f(null),c.commands.updateSelectionState(null);let T=c.state.tr;T.delete(L,L+w),T.setMeta("addToHistory",!0),c.view.dispatch(T),C&&setTimeout(()=>{let x=c.state.doc.nodeAt(0);if(x&&x.type.name==="paragraph"&&!x.attrs.id){let P=`node-${_3()}`,M=c.state.tr;M.setNodeMarkup(0,void 0,{...x.attrs,id:P}),c.view.dispatch(M);let R=new CustomEvent("node-duplicated",{detail:{newNodeId:P}});document.dispatchEvent(R)}},50)}catch(E){console.error("Error deleting node:",E)}},[c,l,b,f]),g=Ao(()=>{if(!(!c||!l))try{let{node:E,pos:L}=b();if(!E||L===null)return;if(E.type.name==="button"){v();return}let w=E.type.name==="blockquote";w||y(),setTimeout(()=>{let C=c.chain();if(C.setNodeSelection(L).unsetAllMarks(),w&&E.content&&E.content.firstChild?E.content.firstChild.type.name!=="paragraph"&&C.setParagraph():E.type.name!=="paragraph"&&!w&&C.setParagraph(),C.run(),w){let T=b();T.node&&T.pos!==null&&(f(T.node),c.commands.updateSelectionState(T.node))}},100)}catch(E){console.error("Error removing formatting:",E)}},[c,l,b,y,v,f]),k=Ao(()=>{if(!(!c||!l))try{y(),setTimeout(()=>{let{node:E,pos:L}=b();if(!E||L===null)return;let w=E.type.name,C={...E.attrs};delete C.id;let T=L+(E==null?void 0:E.nodeSize);hf(c,w,T,C,x=>f(x),E.content)},100)}catch(E){console.error("Error duplicating node:",E)}},[c,l,b,y,f]),{node:A}=b();return ms(O3,{ref:p,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":l,className:S("courier-flex courier-flex-col courier-relative draggable-item",t),...m,children:[i==="top"&&St(ds,{type:a}),ms("div",{className:"courier-flex courier-items-center courier-justify-center courier-gap-2 courier-pl-10",children:[St(yf,{ref:o,className:"courier-absolute courier-left-[-8px]",tabIndex:-1,"data-no-drag-preview":!0}),St("div",{ref:n,className:"courier-flex-1 courier-grow draggable-content-wrapper",children:e}),ms("div",{"data-no-drag-preview":!0,className:S("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:[(A==null?void 0:A.type.name)!=="imageBlock"&&(A==null?void 0:A.type.name)!=="divider"&&(A==null?void 0:A.type.name)!=="spacer"&&(A==null?void 0:A.type.name)!=="button"&&(A==null?void 0:A.type.name)!=="column"&&(A==null?void 0:A.type.name)!=="customCode"&&ms(Z3,{children:[St("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:E=>{E.preventDefault(),E.stopPropagation()},onClick:E=>{E.stopPropagation(),g()},tabIndex:-1,children:St(Dl,{color:"currentColor"})}),St(le,{className:"!courier-my-0"})]}),St("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:E=>{E.preventDefault(),E.stopPropagation()},onClick:E=>{E.stopPropagation(),k()},tabIndex:-1,children:St(Ml,{color:"currentColor"})}),St(le,{className:"!courier-my-0"}),St("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:E=>{E.preventDefault(),E.stopPropagation()},onClick:E=>{E.stopPropagation(),N()},tabIndex:-1,children:St(Jn,{color:"currentColor"})})]})]}),i==="bottom"&&St(ds,{type:a})]})});import{jsx as ln}from"react/jsx-runtime";var G3=s(({alignment:e,backgroundColor:t,textColor:r,borderRadius:o,padding:n,fontWeight:i,fontStyle:a,children:l})=>ln("div",{className:"courier-w-full node-element",children:ln("div",{className:"courier-flex",children:ln("div",{className:S("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"),vf=s(e=>{let t=J3(Re),r=j3(()=>{if(!e.editor.isEditable)return;let o=We(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 ln(Ye,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,"data-node-type":"button",children:ln(G3,{...e.node.attrs,children:ln(q3,{as:"span"})})})},"ButtonComponentNode");import{v4 as Q3}from"uuid";var Ie={label:"Button",link:"",alignment:"center",backgroundColor:"#0085FF",borderRadius:0,padding:6,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1,textColor:"#ffffff",borderColor:"transparent"},_a=Y3.create({name:"button",group:"block",content:"inline*",selectable:!1,isolating:!0,onCreate(){Oe(this.editor,this.name)},addAttributes(){return{label:{default:Ie.label,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},link:{default:Ie.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alignment:{default:Ie.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},backgroundColor:{default:Ie.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},textColor:{default:Ie.textColor,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.textColor})},borderRadius:{default:Ie.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:Ie.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},padding:{default:Ie.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.padding})},fontWeight:{default:Ie.fontWeight,parseHTML:e=>e.getAttribute("data-font-weight"),renderHTML:e=>({"data-font-weight":e.fontWeight})},fontStyle:{default:Ie.fontStyle,parseHTML:e=>e.getAttribute("data-font-style"),renderHTML:e=>({"data-font-style":e.fontStyle})},isUnderline:{default:Ie.isUnderline,parseHTML:e=>e.getAttribute("data-is-underline"),renderHTML:e=>({"data-is-underline":e.isUnderline})},isStrike:{default:Ie.isStrike,parseHTML:e=>e.getAttribute("data-is-strike"),renderHTML:e=>({"data-is-strike":e.isStrike})},id:{default:()=>`node-${Q3()}`,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",K3(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return X3(vf)},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()}}});import{v4 as ey}from"uuid";import{useAtomValue as xf,useSetAtom as Tf,useAtom as ty}from"jotai";import{useCallback as cn,useRef as Ef,useState as fs,useEffect as ry}from"react";var un=s(({items:e,setItems:t,editor:r})=>{let[o]=fs(null),[n,i]=fs(null),[a,l]=fs(null),[c]=fs("outer"),u=Ef([]),d=Ef([]),m=xf(Te),p=Tf(pt),[f,v]=ty(X),h=Tf(Ae),b=xf(Ur),y=r||m,N=cn(()=>{if(!y)return;let w=y.getJSON(),C=me(w),T=Ve(f,{channel:b,elements:C});v(T),h(T)},[y,b,f,v,h]),g=cn(()=>{y==null||y.commands.removeDragPlaceholder(),t(w=>({...w,Editor:w.Editor.filter(C=>!C.toString().includes("_temp"))}))},[y==null?void 0:y.commands,t]),k=cn(w=>{try{let C=y==null?void 0:y.state.doc;if(!C||w===0)return 0;if(w>=C.childCount)return C.content.size;let T=0;for(let x=0;x<Math.min(w,C.childCount);x++){let P=C.child(x);T+=P.nodeSize}return T}catch(C){return console.error("Error calculating document position:",C),0}},[y==null?void 0:y.state.doc]),A=cn(w=>{let C={};switch(w){case"text":C=ue;break;case"heading":C={};break;case"image":C=Be;break;case"button":C=Ie;break;case"divider":C=Mt;break;case"spacer":C=Ya;break;case"customCode":C=Pr;break;case"column":C=qe;break}let x={type:w==="text"?"paragraph":w==="image"?"imageBlock":w==="spacer"?"divider":w,attrs:{...C,id:ey()}};return w==="button"&&(x.content=[{type:"text",text:"Button"}]),x},[]),E=cn((w,C)=>{if(!y)return;let{columnId:T,index:x,isEmpty:P}=C,M=null,R=0,I=-1;if(w.type==="sidebar"){if(!w.dragType)return;M=A(w.dragType)}else if(w.type==="editor"){if(y.state.doc.descendants((B,W)=>B.attrs.id===w.id?(I=W,M=B.toJSON(),R=B.nodeSize,!1):!0),I===-1){let B=e.Editor.findIndex(W=>W===w.id);if(B!==-1){I=k(B);let W=y.state.doc.nodeAt(I);W&&(M=W.toJSON(),R=W.nodeSize)}}if(I!==-1){let B=e.Editor.filter(W=>W!==w.id);B.length!==e.Editor.length&&t({...e,Editor:B})}}if(!M)return;let H=-1,V=null;if(y.state.doc.descendants((B,W)=>B.type.name==="column"&&B.attrs.id===T?(H=W,V=B,!1):!0),H===-1||!V)return;let F=V;I!==-1&&I<H&&(H-=R);let O=y.state.tr;if(I!==-1&&O.delete(I,I+R),P){let B=y.schema,W=Array.from({length:F.attrs.columnsCount},(ie,ee)=>B.nodes.columnCell.create({index:ee,columnId:T,isEditorMode:!1},ee===x?[B.nodeFromJSON(M)]:[])),U=B.nodes.columnRow.create({},W);O.replaceWith(H+1,H+F.nodeSize-1,U)}else{let B=H+1;F.content.forEach(W=>{if(W.type.name==="columnRow"){let U=B+1;W.content.forEach((ie,ee,K)=>{if(K===x){let D=U+ie.nodeSize-1;O.insert(D,y.schema.nodeFromJSON(M))}U+=ie.nodeSize})}B+=W.nodeSize})}y.view.dispatch(O),N()},[y,e,t,k,A,N]),L=cn((w,C)=>{try{if(w.type==="sidebar"&&(C.type==="editor"||C.type==="column-cell-item"||C.type==="nested-drag")){let T=w.dragType;if(!T||!y)return;let x=C.insertPos;if(x===void 0)if(C.type==="editor"){let R=C.index+1;x=k(R)}else{console.warn("Nested drop without position data");return}let P=A(T);if(y.commands.insertContentAt(x,P),y.state.doc.resolve(x).depth===0){let R=y.state.doc.resolve(x).index(0),I=[...e.Editor];R<=I.length&&(I.splice(R,0,P.attrs.id),t({...e,Editor:I}))}N();return}if((w.type==="editor"||w.type==="column-cell-item"||w.type==="nested-drag")&&(C.type==="editor"||C.type==="column-cell-item"||C.type==="nested-drag")){if(!y)return;let T=-1,x=null;if(w.pos!==void 0&&(T=w.pos,x=y.state.doc.nodeAt(T)),(T===-1||!x)&&y.state.doc.descendants((I,H)=>I.attrs.id===w.id?(T=H,x=I,!1):!0),T===-1||!x){let I=e.Editor.findIndex(H=>H===w.id);I!==-1&&(T=k(I),x=y.state.doc.nodeAt(T))}if(!x||T===-1)return;let P=C.insertPos;if(P===void 0){let I;C.index===void 0?I=y.state.doc.childCount:C.index===-1?I=0:I=C.index+1,P=k(I)}if(P===void 0||P>T&&P<T+x.nodeSize)return;if(P>T){let I=P-x.nodeSize;y.chain().deleteRange({from:T,to:T+x.nodeSize}).insertContentAt(I,x.toJSON()).run()}else y.chain().insertContentAt(P,x.toJSON()).deleteRange({from:T+x.nodeSize,to:T+x.nodeSize*2}).run();let M=e.Editor.includes(w.id);if(M){let I=e.Editor.filter(H=>H!==w.id);t({...e,Editor:I})}let R=y.state.doc.resolve(P).depth===0;N()}}catch(T){console.error("[Pragmatic DnD] Error in handleDrop:",T)}},[e,y,t,k,N,A]);return ry(()=>tc({onDragStart:({source:w})=>{let C=w.data;p(!0),l(C.id),C.dragType&&i(C.dragType);let T=y==null?void 0:y.view.dom.querySelectorAll('[data-node-type="column"]');T&&(u.current=Array.from(T).map(P=>P.getBoundingClientRect()));let x=y==null?void 0:y.view.dom.querySelectorAll("[data-node-view-wrapper]");if(x){let P=new Set,M=Array.from(x).filter(R=>{let I=R,H=I.parentElement;if(H!=null&&H.hasAttribute("data-column-cell"))return!1;let V=I.getBoundingClientRect(),F=V.top+V.height/2;return P.has(Math.round(F))?!1:(P.add(Math.round(F)),!0)});d.current=M.map(R=>R.getBoundingClientRect())}},onDrop:({source:w,location:C})=>{let T=w.data,x=C.current.dropTargets[0];if(!x){g(),p(!1),l(null),i(null);return}let P=x.data;if(P.type==="column-cell"){E(T,P),p(!1),l(null),i(null),g();return}let M=P,R=hi(x.data);if(M.pos!==void 0&&R&&y){let I=y.state.doc.nodeAt(M.pos);I&&(R==="top"?M.insertPos=M.pos:R==="bottom"&&(M.insertPos=M.pos+I.nodeSize))}if(M.insertPos===void 0&&R&&M.index!==void 0){let I=R==="top"?M.index-1:M.index;M={...M,index:I}}else if(M.index===void 0&&M.insertPos===void 0){let H=C.current.input.clientY;if(d.current.length>0){let V=0,F=1/0;d.current.forEach((ie,ee)=>{let K=ie.top+ie.height/2,D=Math.abs(H-K);D<F&&(F=D,V=ee)});let O=d.current[V],B=O.top+O.height/2,U=H>=B?V:V-1;M={...M,index:U,fromCoordinates:!0}}else M={...M,index:(y==null?void 0:y.state.doc.childCount)||0}}L(T,M),p(!1),l(null),i(null),g()}}),[y,p,g,l,i,L,E]),{activeId:a,activeDragType:n,dndMode:c,lastPlaceholderIndex:o,cleanupPlaceholder:g}},"usePragmaticDnd");import{useCallback as oy,useEffect as ny}from"react";import{useAtomValue as iy}from"jotai";var gs=s(({setItems:e,rafId:t,editor:r})=>{let o=iy(Te),n=r||o,i=oy(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 ny(()=>{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");import{Fragment as uy,jsx as Fc}from"react/jsx-runtime";var wi=[{type:"text",align:"left",content:`
|
|
187
|
+
`,text_style:"h1"},{type:"text",align:"left",content:""},{type:"image",src:""}],cy=sy(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:a,colorScheme:l,hidePreviewPanelExitButton:c,...u},d)=>{let m=So(Te),[p,f]=Bc(ge),[v,h]=Bc(ao),b=Ei({}),[y,N]=Dc(c?"desktop":void 0),g=So(Fe),k=So(ae),A=So(Lu),E=So(ar),L=Ei(-1),w=ay(rm),C=Ei(!1),T=Ei(!1),[x]=Bc(X),P=So(Jt),M=So(ze),[R,I]=Dc({Editor:[],Sidebar:["heading","text","image","spacer","divider","button","customCode"]}),H=Ei(null);un({items:R,setItems:I,editor:m});let{syncEditorItems:V}=gs({setItems:I,rafId:H,editor:m});Xr(()=>{M&&(T.current=!1)},[M]);let[F,O]=Dc(!1);Xr(()=>{if(k===!1||k===null){let D=setTimeout(()=>{O(!0)},100);return()=>clearTimeout(D)}else O(!1)},[k,F]),Xr(()=>{if(p){let D=p.type.name,z=aa(D);w({nodeName:D,config:z})}},[p,w]);let B=kf(()=>{var z,oe,be,Pe,Me,Et,wt,se,Ee,ye,it,at,Ot,Ut,Wt,_t,Fr,Vr,te,Cr,no,io,Nn,Mn,An,Sn,In,Ln,Y,re,de,he,ke,zt;if(E)return E;let D=(be=(oe=(z=g==null?void 0:g.data)==null?void 0:z.tenant)==null?void 0:oe.brand)==null?void 0:be.settings;return{brandColor:((Pe=D==null?void 0:D.colors)==null?void 0:Pe.primary)||"#000000",textColor:((Me=D==null?void 0:D.colors)==null?void 0:Me.secondary)||"#000000",subtleColor:((Et=D==null?void 0:D.colors)==null?void 0:Et.tertiary)||"#666666",headerStyle:(se=(wt=D==null?void 0:D.email)==null?void 0:wt.header)!=null&&se.barColor?"border":"plain",logo:(it=(ye=(Ee=D==null?void 0:D.email)==null?void 0:Ee.header)==null?void 0:ye.logo)==null?void 0:it.image,link:(Ut=(Ot=(at=D==null?void 0:D.email)==null?void 0:at.header)==null?void 0:Ot.logo)==null?void 0:Ut.href,facebookLink:(Vr=(Fr=(_t=(Wt=D==null?void 0:D.email)==null?void 0:Wt.footer)==null?void 0:_t.social)==null?void 0:Fr.facebook)==null?void 0:Vr.url,linkedinLink:(io=(no=(Cr=(te=D==null?void 0:D.email)==null?void 0:te.footer)==null?void 0:Cr.social)==null?void 0:no.linkedin)==null?void 0:io.url,instagramLink:(Sn=(An=(Mn=(Nn=D==null?void 0:D.email)==null?void 0:Nn.footer)==null?void 0:Mn.social)==null?void 0:An.instagram)==null?void 0:Sn.url,mediumLink:(re=(Y=(Ln=(In=D==null?void 0:D.email)==null?void 0:In.footer)==null?void 0:Ln.social)==null?void 0:Y.medium)==null?void 0:re.url,xLink:(zt=(ke=(he=(de=D==null?void 0:D.email)==null?void 0:de.footer)==null?void 0:he.social)==null?void 0:ke.twitter)==null?void 0:zt.url}},[E,g]),W=A&&!!B,U=wf(()=>{Object.values(b.current).forEach(D=>clearTimeout(D)),b.current={}},[]);Xr(()=>()=>{U()},[U]),Xr(()=>{let D=s(z=>{if(z.key==="Escape"&&(f(null),m==null||m.commands.blur(),L.current=-1),z.key==="Tab"&&m){z.preventDefault();let oe=-1;p&&m.state.doc.content.forEach((Me,Et,wt)=>{p.attrs.id===Me.attrs.id&&(oe=wt)}),oe===-1&&(oe=0);let be=m.state.doc,Pe;if(z.shiftKey?Pe=(oe-1+be.childCount)%be.childCount:Pe=(oe+1)%be.childCount,Pe!==oe||p===null){let Me=be.child(Pe);f(Me),m.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",D),()=>{document.removeEventListener("keydown",D)}},[m,p,f]),Xr(()=>{if(k!==!1||M)return;let D=x!=null?x:"";if(D){let z=Xs(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,k,M,m,h,f,x]),Xr(()=>{k===!1&&g&&!T.current&&(T.current=!0,setTimeout(()=>{m&&!m.isDestroyed&&V(m)},300))},[k,g,m,V]),Xr(()=>(C.current=!0,()=>{C.current=!1}),[]);let ie=wf(D=>{let oe=D||(y===void 0?"desktop":void 0);N(oe),f(null),oe?m==null||m.setEditable(!1):m==null||m.setEditable(!0)},[m,y,N,f]),ee=s(D=>{h(D.target.value)},"handleSubjectChange"),K=kf(()=>{if(k!==!1||!F)return null;let D=a&&a.elements&&a.elements.length>0;D&&(T.current=!0);let z;return D&&(z=a.elements.find(be=>be.type==="channel"&&be.channel==="email")),z||(z={type:"channel",channel:"email",elements:wi}),Se({version:"2022-01-01",elements:[z]},{channel:"email"})},[a,k,F]);return M&&(x===null||K===null)?null:Fc(ht,{theme:t,colorScheme:l,isLoading:!!k,Header:i?i({hidePublish:e,channels:r,routing:o}):Fc(Dt,{hidePublish:e,channels:r,routing:o}),...u,children:Fc(uy,{children:n==null?void 0:n({subject:v,handleSubjectChange:ee,selectedNode:p,setSelectedNode:f,previewMode:y,templateEditor:m,ref:d,isBrandApply:W,brandSettings:B,items:R,content:K,syncEditorItems:V,brandEditorContent:P,templateData:g,togglePreviewMode:ie,hidePreviewPanelExitButton:c})})})}),hs=ly(cy);var bs=class bs{};s(bs,"UploadImageAPI"),bs.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 Vc=bs,Oc=Vc;var bt=s(e=>[Cc,gf.configure({document:!1,dropcursor:!1,gapcursor:!1,heading:!1,horizontalRule:!1,paragraph:!1,blockquote:!1,hardBreak:!1,code:!1}),Ic.configure({setSelectedNode:e==null?void 0:e.setSelectedNode,shouldHandleClick:e==null?void 0:e.shouldHandleClick}),uf.configure({keepMarks:!0,HTMLAttributes:{class:"my-line-break"}}),Up,yc,Sc,oc,Tc.configure({levels:[1,2,3,4,5,6]}),_a,za,cf,$a,Za,qa,ja,Nc.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),ff,is.configure(),Qa.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(t,r,o)=>{r.forEach(async n=>{let i=await Oc.uploadImage(n);t.chain().setImageBlockAt({pos:o,src:i}).focus().run()})},onPaste:(t,r)=>{r.forEach(async o=>{let n=await Oc.uploadImage(o);return t.chain().setImageBlockAt({pos:t.state.selection.anchor,src:n}).focus().run()})}}),mf.extend({addKeyboardShortcuts(){return{}}}).configure({types:["paragraph","heading"]}),pf,df.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:"",emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",showOnlyWhenEditable:!0}),rc.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),cc,xo,To,es,os],"ExtensionKit");import{BubbleMenu as Wy,useCurrentEditor as _y}from"@tiptap/react";import{useAtomValue as dy}from"jotai";import{useCallback as Pf,useEffect as my,useState as py}from"react";var ys=s(e=>{let t=dy(ge),[r,o]=py({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1}),n=Pf(()=>{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 my(()=>{if(e)return n(),e.on("selectionUpdate",n),e.on("transaction",n),()=>{e.off("selectionUpdate",n),e.off("transaction",n)}},[e,n]),{shouldShow:Pf(({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");import{useAtomValue as Wc}from"jotai";import{AlignCenter as wy,AlignJustify as ky,AlignLeft as Py,AlignRight as Ny,Bold as My,Italic as Ay,Link as Sy,Quote as Iy,Strikethrough as Ly,Underline as Ry}from"lucide-react";import{Fragment as Hy,memo as Df,useMemo as Bf,useRef as By,useState as Dy,useEffect as Fy}from"react";import{forwardRef as Uc}from"react";import fy from"@tippyjs/react";import{useCallback as gy}from"react";import{Fragment as yy,jsx as fr,jsxs as by}from"react/jsx-runtime";var Nf=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,hy=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"?fr("kbd",{className:t,children:Nf?"\u2318":"Ctrl"}):e==="Shift"?fr("kbd",{className:t,children:"\u21E7"}):e==="Alt"?fr("kbd",{className:t,children:Nf?"\u2325":"Alt"}):fr("kbd",{className:t,children:e})},"ShortcutKey"),Mf=s(({children:e,enabled:t=!0,title:r,shortcut:o,tippyOptions:n={}})=>{let i=vd(),a=gy(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 by("span",{className:S("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&&fr("span",{className:"courier-text-xs courier-font-medium courier-text-muted-foreground",children:r}),o&&fr("span",{className:"courier-flex courier-items-center courier-gap-0.5",children:o.map(u=>fr(hy,{children:u},u))})]})},[o,r,i]);return t?fr(fy,{...n,delay:500,offset:[0,8],touch:!1,zIndex:99999,appendTo:document.body,trigger:"mouseenter focus",showOnCreate:!1,render:a,animation:!1,children:fr("span",{children:e})}):fr(yy,{children:e})},"Tooltip");import{jsx as Cs}from"react/jsx-runtime";var Af=Uc(({shouldShowContent:e=!0,children:t,isVertical:r=!1,className:o,...n},i)=>{let a=S("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&&Cs(Lc,{className:a,...n,ref:i,children:t})});Af.displayName="Toolbar";var Sf=Uc(({horizontal:e,className:t,...r},o)=>{let n=S("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 Cs("div",{className:n,ref:o,...r})});Sf.displayName="Toolbar.Divider";var If=Uc(({children:e,buttonSize:t="icon",variant:r="ghost",className:o,tooltip:n,tooltipShortcut:i,...a},l)=>{let c=S("courier-gap-1 courier-min-w-[2rem] courier-w-auto",o),u=Cs(Ce,{className:c,variant:r,buttonSize:t,ref:l,...a,children:e});return n?Cs(Mf,{title:n,shortcut:i,children:u}):u});If.displayName="ToolbarButton";var vs={Wrapper:Af,Divider:Sf,Button:If};import{ChevronDown as Cy}from"lucide-react";import{useMemo as vy}from"react";import{Fragment as Ty,jsx as Qr,jsxs as Lf}from"react/jsx-runtime";var xy=s(e=>e.type==="option","isOption"),Rf=s(({options:e,containerRef:t})=>{let r=vy(()=>e.find(o=>o.type==="option"&&o.isActive()),[e]);return Lf(Yi,{children:[Qr(Xi,{asChild:!0,children:Lf(Ce,{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",Qr(Cy,{className:"courier-w-3 courier-h-3"})]})}),Qr(Wn,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(xy(o))return Qr(_n,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?Qr(Ty,{children:o.id==="heading1"?Qr("h1",{className:"courier-text-2xl courier-font-bold",children:o.label}):o.id==="heading2"?Qr("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading3"?Qr("h3",{className:"courier-text-lg courier-font-bold",children:o.label}):o.label}):o.label},o.id)})})]})},"ContentTypePicker");import{useEditorState as Ey}from"@tiptap/react";var Hf=s(e=>Ey({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");import{jsx as tt,jsxs as Uy}from"react/jsx-runtime";var Vy=Df(vs.Button),Oy=Df(Rf),_c=s(({editor:e,config:t})=>{var L;let r=ys(e),o=Hf(e),n=By(null),i=Wc(sa),a=Wc(ge),l=a==null?void 0:a.type.name,c=Wc(tm),[u,d]=Dy(()=>{let{selection:w}=e.state;return{from:w.from,to:w.to,empty:w.empty}});Fy(()=>{let w=s(()=>{let{selection:C}=e.state;d({from:C.from,to:C.to,empty:C.empty})},"updateSelection");return e.on("selectionUpdate",w),e.on("transaction",w),()=>{e.off("selectionUpdate",w),e.off("transaction",w)}},[e]);let m=Bf(()=>!u.empty&&u.from!==u.to,[u]),p=Bf(()=>t||c(l||"",m),[t,c,l,m]),f=us(e,p,r),v=s(()=>{let{selection:w}=e.state;if(!(w.empty&&!r.isLink&&!e.can().setLink({href:""})))if(r.isLink){let C=e.state.tr.setMeta("showLinkForm",{from:w.from,to:w.to});e.view.dispatch(C)}else{let C=e.state.tr.setMeta("showLinkForm",{from:w.from,to:w.to});e.view.dispatch(C)}},"handleLinkToggle"),h=s(()=>{if(i.ref){let w=i.ref,C=w.value,T=i.caretPosition||w.selectionStart||0,x=C.substring(0,T),P=C.substring(T),M=`${x}{{${P}`,R=T+2;w.focus();let I=new Event("input",{bubbles:!0,cancelable:!0});if(Object.defineProperty(I,"target",{writable:!1,value:{...w,value:M}}),w.value=M,w.dispatchEvent(I),w.setSelectionRange(R,R),w.getBoundingClientRect()){let V=M.slice(0,R),F=document.createElement("span");F.style.font=window.getComputedStyle(w).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(w).lineHeight),W=V.split(`
|
|
188
|
+
`).length-1,U=new CustomEvent("showVariableSuggestions",{detail:{cursorPosition:{left:Math.min(O%w.offsetWidth,w.offsetWidth-200),top:W*B+30}},bubbles:!0});w.dispatchEvent(U)}return}e.chain().focus().insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()},"handleVariableClick"),b=s((w,C,T,x,P,M,R)=>{let I=p[w];return!I||Array.isArray(I)||I.state==="hidden"?null:tt(Vy,{tooltip:T,tooltipShortcut:M,onClick:x,active:P,disabled:I.state==="disabled",...R,children:C},w)},"renderButton"),y=s((w,C)=>{let T=w.filter(x=>!!x);return T.length>0?tt("div",{className:"courier-flex courier-items-center courier-gap-0.5",children:T},C):null},"renderGroup"),N=y([((L=p.contentType)==null?void 0:L.state)==="enabled"&&tt(Oy,{options:o,containerRef:n},"content-type")],"content-type-group"),g=y([b("bold",tt(My,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",f.onBold,r.isBold,["Mod","B"]),b("italic",tt(Ay,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",f.onItalic,r.isItalic,["Mod","I"]),b("underline",tt(Ry,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",f.onUnderline,r.isUnderline,["Mod","U"]),b("strike",tt(Ly,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Strikethrough",f.onStrike,r.isStrike,["Mod","Shift","S"])],"text-style-group"),k=y([b("alignLeft",tt(Py,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",f.onAlignLeft,r.isAlignLeft,["Shift","Mod","L"]),b("alignCenter",tt(wy,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",f.onAlignCenter,r.isAlignCenter,["Shift","Mod","E"]),b("alignRight",tt(Ny,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",f.onAlignRight,r.isAlignRight,["Shift","Mod","R"]),b("alignJustify",tt(ky,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",f.onAlignJustify,r.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),A=y([b("quote",tt(Iy,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Quote",f.onQuote,r.isQuote,["Mod","Shift","B"])],"block-style-group"),E=y([b("link",tt(Sy,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",v,r.isLink,["Mod","K"]),b("variable",tt(Gd,{width:16}),"Variable",h,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return tt(vs.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,k,A,E].filter(Boolean).map((w,C)=>Uy(Hy,{children:[w,C<[N,g,k,A,E].filter(Boolean).length-1&&tt(vs.Divider,{})]},`item-${C}`))})},"TextMenu");import{jsx as Ff}from"react/jsx-runtime";var yt=s(({config:e})=>{let{editor:t}=_y(),r=ys(t);return t?Ff(Wy,{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&&Ff(_c,{editor:t,config:e})}):null},"BubbleTextMenu");import{TextSelection as zy}from"@tiptap/pm/state";import{EditorProvider as $y,Extension as Zy,useCurrentEditor as qy}from"@tiptap/react";import{useAtomValue as Jy,useSetAtom as Vf}from"jotai";import{memo as jy,useEffect as $c,useMemo as Gy,useRef as Of}from"react";import{jsx as Ft,jsxs as zc}from"react/jsx-runtime";var Ky=s(({value:e,readOnly:t})=>{let{editor:r}=qy(),o=Vf(_o),n=Jy(ae),i=Of(!1);return $c(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(Ks(e!=null?e:"")))},[r,e,n,t]),$c(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),Yy=s(({facebookLink:e,linkedinLink:t,instagramLink:r,mediumLink:o,xLink:n,readOnly:i=!1,value:a,onUpdate:l})=>{let c=Of(!1),u=Vf(ge),d=Zy.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:p})=>{let{state:f,dispatch:v}=p.view;return v(f.tr.setSelection(zy.create(f.doc,f.selection.$anchor.pos))),u&&u(null),!1}}}});$c(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=Gy(()=>[...bt({setSelectedNode:u}),d].filter(p=>p!==void 0),[d,u]);return zc("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[zc($y,{content:Ks(a!=null?a:""),extensions:m,editable:!i,autofocus:!i,onUpdate:l,editorContainerProps:{className:S("courier-py-2 courier-flex-grow",i&&"courier-brand-editor-readonly")},immediatelyRender:!1,children:[Ft(Ky,{value:a,readOnly:i}),Ft(yt,{})]}),zc("div",{className:"courier-flex courier-justify-end courier-items-center courier-gap-2 courier-mt-3",children:[e&&Ft("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:Ft(Kn,{className:"courier-w-5 courier-h-5"})}),t&&Ft("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:Ft(Qn,{className:"courier-w-5 courier-h-5"})}),r&&Ft("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:Ft(Xn,{className:"courier-w-5 courier-h-5"})}),o&&Ft("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:Ft(ei,{className:"courier-w-5 courier-h-5"})}),n&&Ft("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:Ft(ii,{className:"courier-w-5 courier-h-5"})})]})]})},"BrandFooterComponent"),ki=jy(Yy);import{Fragment as Xy,jsx as dn,jsxs as xs}from"react/jsx-runtime";var Uf=s(({value:e,icon:t,...r})=>dn(lt,{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"),Zc=s(({previewMode:e,togglePreviewMode:t,hideMobileToggle:r=!1,hideExitButton:o=!1,...n})=>xs("div",{...n,className:S("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&&xs(Xy,{children:[xs(qt,{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:[dn(Uf,{value:"desktop",icon:dn(Nl,{})}),dn(Uf,{value:"mobile",icon:dn(Rl,{})})]}),!o&&dn("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),!o&&xs(Ce,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");import{forwardRef as Zf}from"react";function Qy(){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(Qy,"initTestHelpers");function Ct(e,t){typeof window!="undefined"&&(Qy(),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(Ct,"setTestEditor");import{Extension as rC}from"@tiptap/core";import{TextSelection as oC}from"@tiptap/pm/state";import{EditorProvider as nC,useCurrentEditor as iC}from"@tiptap/react";import{useAtom as Wf,useAtomValue as Ar,useSetAtom as Io}from"jotai";import{useCallback as eo,useEffect as It,useMemo as aC,useRef as gr}from"react";import{useCurrentEditor as eC}from"@tiptap/react";import{useEffect as tC}from"react";var Vt=s(({value:e,defaultValue:t})=>{let{editor:r}=eC();return tC(()=>{if(!r)return;let o=setTimeout(()=>{r.commands.setContent(e||t)},0);return()=>clearTimeout(o)},[r,e,t]),null},"ReadOnlyEditorContent");import{Fragment as cC,jsx as Pi,jsxs as uC}from"react/jsx-runtime";var sC=s(({value:e})=>{let{editor:t}=iC(),[r,o]=Wf(X),n=Io(Ae),i=Ar(ao),a=Ar(ge),l=Io(Te),c=Io(lo),u=gr(!1),d=gr(),m=Ar(ae),p=Ar(Fe),f=gr(!1),v=Ar(ze);return It(()=>{m&&(f.current=!1)},[m]),It(()=>(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=me(t.getJSON());if(!y||!Array.isArray(y))return;let N=i;if(!i&&r){let E=(b=r==null?void 0:r.elements)==null?void 0:b.find(L=>L.type==="channel"&&L.channel==="email");E&&(N=Bn(E,"email"))}let g=$t(r,"email",N||"",y),k={elements:g.elements,channel:"email",...g.raw&&{raw:g.raw}},A=Ve(r,k);JSON.stringify(r)!==JSON.stringify(A)&&(o(A),n(A))}catch(y){console.error("[FlushSubjectUpdate]",y)}},"flushSubjectUpdate")}),()=>{c({action:"unregister",id:"email-subject"})}),[t,i,m,v,r,o,n,c]),It(()=>{!t||m!==!1||f.current||!e||(l(t),f.current=!0,t.commands.setContent(e))},[t,e,l,m]),It(()=>{if(!(!(t&&i!==null)||m!==!1||v)&&!t.isFocused)return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var h;try{let b=me(t.getJSON());if(!b||!Array.isArray(b))return;let y=i;if(!i&&r){let A=(h=r==null?void 0:r.elements)==null?void 0:h.find(E=>E.type==="channel"&&E.channel==="email");A&&(y=Bn(A,"email"))}let N=$t(r,"email",y||"",b),g={elements:N.elements,channel:"email",...N.raw&&{raw:N.raw}},k=Ve(r,g);JSON.stringify(r)!==JSON.stringify(k)&&(o(k),n(k))}catch(b){console.error(b)}},500),()=>{d.current&&clearTimeout(d.current)}},[p,t,i,o,n,m,r,v]),It(()=>()=>{t&&!t.isDestroyed&&t.setEditable(!0)},[t]),It(()=>{t&&u.current&&t.commands.updateSelectionState(a)},[t,a]),It(()=>(u.current=!0,()=>{u.current=!1}),[]),null},"EditorContent"),lC=s(({value:e,readOnly:t=!1,onDestroy:r,onUpdate:o,subject:n})=>{let i=Io(la),a=gr(),[l,c]=Wf(X),u=Ar(ao),d=n!=null?n:u,m=Io(ge),p=Ar(Te),f=Ar(ze),v=Ar(pt),h=Io(lo),b=Io(Ae),y=gr(l),N=gr(d),g=gr(v);It(()=>{y.current=l},[l]),It(()=>{N.current=d},[d]),It(()=>{g.current=v},[v]),It(()=>{p==null||p.setEditable(!t)},[t,p]);let k=rC.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:O})=>{let{state:B,dispatch:W}=O.view;return W(B.tr.setSelection(oC.create(B.doc,B.selection.$anchor.pos))),m&&m(null),!1}}}}),A=eo(({editor:O})=>{o==null||o(O),Ct("email",O),m&&setTimeout(()=>{m(null)},100)},[m,o]),E=gr(),L=gr(null),w=eo((O,B)=>{var z;if(f)return;let W=y.current,U=N.current;if(!W){let oe={version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:B}]};c(oe),b(oe);return}let ie=W.elements.find(oe=>oe.type==="channel"&&oe.channel==="email"),ee={...ie};ee.elements=(z=ee.elements)==null?void 0:z.filter(oe=>oe.type!=="meta");let K={type:"channel",channel:"email",elements:B};if(JSON.stringify(ee)!==JSON.stringify(K)){let oe=U;!U&&ie&&(oe=Bn(ie,"email"));let be=$t(W,"email",oe||"",B);K.elements=be.elements,be.raw&&(K.raw=be.raw);let Pe=Ve(W,K);c(Pe),b(Pe)}o==null||o(O),Ct("email",O)},[c,b,o,f]),C=eo(({editor:O})=>{let B=me(O.getJSON());L.current={editor:O,elemental:B},E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{if(L.current){let{editor:W,elemental:U}=L.current;w(W,U),L.current=null}},200)},[w]),T=eo(({editor:O})=>{if(g.current)return;let{selection:B}=O.state,{$anchor:W}=B,ie=B.$head.marks().find(z=>z.type.name==="link");ie||O.isActive("link")?i({mark:ie}):i(null);let ee=W.depth,K=null,D=null;for(;ee>0;){let z=W.node(ee);!D&&z.type.name==="blockquote"&&(D=z),!K&&(z.type.name==="paragraph"||z.type.name==="heading")&&(K=z),ee--}D?m(D):K&&m(K)},[i,m]),x=eo(({editor:O,transaction:B})=>{let W=B==null?void 0:B.getMeta("showLinkForm");if(W){let{selection:U}=O.state,ee=U.$head.marks().find(K=>K.type.name==="link");i({mark:ee,link:{from:W.from,to:W.to}})}},[i]),P=eo(()=>{a.current&&clearTimeout(a.current),E.current&&clearTimeout(E.current),r==null||r(),Ct("email",null)},[r]);It(()=>(h({action:"register",id:"email-content",fn:s(()=>{if(E.current&&(clearTimeout(E.current),E.current=void 0,L.current)){let{editor:B,elemental:W}=L.current;w(B,W),L.current=null}},"flushContentUpdate")}),()=>{h({action:"unregister",id:"email-content"})}),[w,h]);let M=eo(O=>{var ee;if(g.current)return;let B=(ee=O.view)==null?void 0:ee.editor;if(!B||!B.isEditable)return;let W=O.target,U=B.view.posAtDOM(W,0),ie=B.state.doc.resolve(U).node();ie.type.name==="paragraph"&&m(ie)},[m]),R=eo(()=>!g.current,[]),I=aC(()=>[...bt({setSelectedNode:m,shouldHandleClick:R}),k].filter(O=>O!==void 0),[k,m,R]),H=e||{type:"doc",content:[{type:"paragraph"}]},V=t?{editable:!1,autofocus:!1}:{editable:!0,autofocus:!0,onCreate:A,onUpdate:C,onSelectionUpdate:T,onTransaction:x},F=gr(null);return It(()=>{let O=F.current;if(!(!O||t))return Pt({element:O,getData:()=>({type:"editor",id:"editor-drop-zone"}),canDrop:({source:B})=>B.data.type==="sidebar"?!0:B.data.type==="editor"})},[t]),Pi("div",{ref:F,"data-testid":"email-editor",children:Pi(nC,{content:H,extensions:I,...V,onDestroy:P,editorContainerProps:{onClick:M},immediatelyRender:!1,children:t?Pi(Vt,{value:H,defaultValue:wi}):uC(cC,{children:[Pi(sC,{value:H}),Pi(yt,{})]})})})},"EmailEditor"),qc=lC;import{useAtomValue as _f,useSetAtom as hC}from"jotai";import{GripVertical as bC}from"lucide-react";import{forwardRef as dC,useEffect as mC,useRef as pC,useState as fC}from"react";import{jsx as Jc}from"react/jsx-runtime";var mn=s(({children:e,id:t,className:r,editor:o})=>Jc(gC,{id:t,className:r,editor:o,children:e}),"SideBarSortableItemWrapper"),gC=dC(({children:e,className:t,id:r,editor:o},n)=>{let i=pC(null),[a,l]=fC(!1);return mC(()=>{let c=i.current;if(!(!c||!r))return sr(gi({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]),Jc("div",{ref:i,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":r,className:S(t,"courier-relative",a&&"courier-opacity-50 courier-cursor-grabbing"),children:Jc("div",{children:e})})});import{Fragment as yC,jsx as De,jsxs as pn}from"react/jsx-runtime";var jc=s(({items:e,brandEditor:t,label:r,editor:o})=>{var l,c;let n=_f(Fe),i=hC(jo),a=_f(Ge);return pn("div",{className:"courier-flex courier-flex-col courier-h-full",children:[pn("div",{className:"courier-flex-1",children:[r&&pn(yC,{children:[De("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:r}),De(le,{className:"courier-my-4"})]}),De("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(u=>De(mn,{id:u.toString(),editor:o,children:pn("div",{className:S("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:[De(bC,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),u==="heading"&&De(Na,{draggable:!0}),u==="text"&&De(Zr,{draggable:!0}),u==="image"&&De(Aa,{draggable:!0}),u==="spacer"&&De(Sa,{draggable:!0}),u==="divider"&&De($r,{draggable:!0}),u==="button"&&De(zr,{draggable:!0}),u==="customCode"&&De(bi,{draggable:!0}),u==="column"&&De(Ea,{draggable:!0})]})},u))})]}),t&&pn("div",{className:"courier-mt-auto courier-pt-4",children:[De(le,{className:"courier-mb-4 -courier-mx-4"}),(c=(l=n==null?void 0:n.data)==null?void 0:l.tenant)!=null&&c.brand?De("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:De(Ce,{variant:"link",className:"courier-underline",onClick:()=>i("brand"),disabled:!!a,children:"Edit brand"})}):pn("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[De("h3",{className:"courier-text-md courier-font-medium courier-text-foreground",children:"Customize brand theme"}),De("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),De(Ce,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>i("brand"),children:"Customize"})]})]})]})},"SideBar");import{useAtomValue as CC}from"jotai";import{jsx as to,jsxs as vC}from"react/jsx-runtime";var Gc=s(({element:e,editor:t})=>{var i,a;let r=CC(zl);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 to(af,{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 vC("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[e.type.name==="button"&&to(bp,{element:e,editor:t},e.attrs.id),e.type.name==="divider"&&to(Fp,{element:e,editor:t},e.attrs.id),["paragraph","heading"].includes(e.type.name)&&!o&&to(Zp,{element:e,editor:t},e.attrs.id),e.type.name==="imageBlock"&&to(ef,{element:e,editor:t},e.attrs.id),e.type.name==="customCode"&&to(hc,{element:e,editor:t},e.attrs.id),(e.type.name==="blockquote"||e.type.name==="paragraph"&&o||e.type.name==="heading"&&o)&&to(sp,{element:n()||e,editor:t},e.attrs.id),e.type.name==="column"&&to(pc,{element:e,editor:t},e.attrs.id)]})},"SideBarItemDetails");import{forwardRef as zf}from"react";import{useAtom as xC}from"jotai";import{Fragment as TC,jsx as Ts,jsxs as EC}from"react/jsx-runtime";var Lo=zf(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>Ts("div",{className:S("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})),Ro=zf(({children:e,className:t,previewMode:r,skipExpanded:o=!1,width:n,...i},a)=>{let[l,c]=xC(tr),u=o?!1:l,d=n||"courier-w-64";return r?null:EC(TC,{children:[u&&Ts("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"}),Ts("div",{className:S("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch courier-relative",d,t),children:Ts("div",{className:S("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})})]})});import{useAtomValue as $f,useSetAtom as wC}from"jotai";import{jsx as vt,jsxs as Ho}from"react/jsx-runtime";var qf=Zf(({children:e,className:t,...r},o)=>vt("div",{className:S("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Jf=Zf(({children:e,previewMode:t,...r},o)=>vt("div",{className:S("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})),jf=s(({variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:a,colorScheme:l,...c})=>{let u=$f(X),d=$f(tr),m=wC(tr),p=s(()=>{d&&m(!1)},"handleSubjectAreaClick");return vt(hs,{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:k,brandSettings:A,items:E,content:L,syncEditorItems:w,brandEditorContent:C,templateData:T,togglePreviewMode:x,hidePreviewPanelExitButton:P})=>{var M,R,I,H,V,F;return Ho(Lo,{previewMode:y,children:[Ho("div",{className:"courier-flex courier-flex-col courier-flex-1",children:[Ho("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:[Ho("h4",{className:"courier-text-sm courier-h-[25px] courier-flex courier-items-end courier-pb-px",children:["Subject:"," "]}),vt(Ci,{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})]}),Ho(qf,{ref:g,children:[Ho(Jf,{previewMode:y,children:[k&&Ho("div",{className:S("courier-py-5 courier-px-9 courier-pb-0 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(A==null?void 0:A.headerStyle)==="border"&&"courier-pt-6"),children:[(A==null?void 0:A.headerStyle)==="border"&&vt("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:A==null?void 0:A.brandColor}}),(A==null?void 0:A.logo)&&vt("img",{src:A.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),L&&vt(qc,{value:L,onUpdate:w,variables:e}),k&&T&&vt("div",{className:"courier-py-5 courier-px-9 courier-pt-0 courier-flex courier-flex-col",children:vt(ki,{readOnly:!0,value:C!=null?C:(F=(V=(H=(I=(R=(M=T==null?void 0:T.data)==null?void 0:M.tenant)==null?void 0:R.brand)==null?void 0:I.settings)==null?void 0:H.email)==null?void 0:V.footer)==null?void 0:F.markdown,variables:e,facebookLink:A==null?void 0:A.facebookLink,linkedinLink:A==null?void 0:A.linkedinLink,instagramLink:A==null?void 0:A.instagramLink,mediumLink:A==null?void 0:A.mediumLink,xLink:A==null?void 0:A.xLink})})]}),vt(Zc,{previewMode:y,togglePreviewMode:x,hideExitButton:P})]})]}),vt(Ro,{previewMode:y,children:vt("div",{className:"courier-p-1 courier-h-full",children:h?vt(Gc,{element:h,editor:N}):vt(jc,{items:E.Sidebar,brandEditor:i,label:"Blocks library",editor:N!=null?N:void 0})})})]})},...c})},"EmailLayout");import{useCurrentEditor as kC}from"@tiptap/react";import{useAtom as PC,useAtomValue as Es,useSetAtom as Kc}from"jotai";import{forwardRef as NC,memo as MC,useCallback as AC,useEffect as Ni,useMemo as Gf,useRef as Yc}from"react";import{jsx as Kf}from"react/jsx-runtime";var Mi=[{type:"text",content:`
|
|
189
189
|
`,text_style:"h2"},{type:"text",content:`
|
|
190
|
-
`},{type:"action",content:"Register",align:"left",href:""}],
|
|
190
|
+
`},{type:"action",content:"Register",align:"left",href:""}],Yf=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:Mi};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||"")+`
|
|
191
191
|
`,text_style:"h2"},u=i[0],d={type:"text",content:u&&"content"in u?u.content:`
|
|
192
|
-
`};t={...t,elements:[c,d,...a]}}return t},"getOrCreateInboxElement"),
|
|
192
|
+
`};t={...t,elements:[c,d,...a]}}return t},"getOrCreateInboxElement"),Xf={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"}},Qf=s(({value:e})=>{let{editor:t}=kC(),r=Kc(Te),o=Es(X),n=Es(ae),i=Yc(!1);return Ni(()=>{n&&(i.current=!1)},[n]),Ni(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),Ni(()=>{t&&(r(t),Ct("inbox",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),Ni(()=>{if(!t||!o||t.isFocused)return;let a=Yf(o),l=Se({version:"2022-01-01",elements:[a]},{channel:"inbox"}),c=me(l),u=me(t.getJSON());JSON.stringify(c)!==JSON.stringify(u)&&setTimeout(()=>{t.isFocused||t.commands.setContent(l)},1)},[t,o]),null},"InboxEditorContent"),SC=NC(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let m=Es(ae),p=Yc(!0),f=Yc(!1),v=Kc(ge),[h,b]=PC(X),y=Kc(Ae),N=Es(ze);Ni(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=Gf(()=>[...bt({setSelectedNode:v})].filter(E=>E!==void 0),[v]),k=AC(({editor:E})=>{if(!E||N)return;if(!h){let M=me(E.getJSON()),R=$t(null,"inbox","",M),I={version:"2022-01-01",elements:[{type:"channel",channel:"inbox",elements:R.elements,...R.raw&&{raw:R.raw}}]};b(I),y(I);return}let L=E.getJSON(),w=me(L),C=$t(h,"inbox","",w),T=Ve(h,{elements:C.elements,channel:"inbox",...C.raw&&{raw:C.raw}}),x=JSON.stringify(h.elements),P=JSON.stringify(T.elements);x!==P&&setTimeout(()=>{f.current&&(b(T),y(T))},100)},[h,b,y,N]),A=Gf(()=>{let E=Yf(l);return Se({version:"2022-01-01",elements:[E]},{channel:"inbox"})},[l]);return Kf(ht,{theme:e,colorScheme:c,isLoading:!!(m&&p.current),Header:i?i({hidePublish:t,channels:o,routing:n}):Kf(Dt,{hidePublish:t,channels:o,routing:n}),...u,ref:d,children:a==null?void 0:a({content:A,extensions:g,editable:!r,autofocus:!r,onUpdate:k})})}),ws=MC(SC);import{EditorProvider as IC}from"@tiptap/react";import{Fragment as LC,jsx as Sr,jsxs as Ai}from"react/jsx-runtime";var Xc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>e?Ai("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:[Ai("div",{className:"courier-my-3 courier-mx-4 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[Ai("div",{className:"courier-flex courier-items-center courier-gap-3",children:[Sr(Yn,{}),Sr("span",{className:"courier-text-xl courier-font-medium",children:"In-app"})]}),Ai("div",{className:"courier-flex courier-items-center courier-gap-4",children:[Sr(Sl,{}),Sr(Gn,{}),Sr(Hl,{})]})]}),Sr(IC,{content:e,extensions:t,...i?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},editorContainerProps:{className:S("courier-inbox-editor")},immediatelyRender:!1,children:i?Sr(Vt,{value:e,defaultValue:Mi}):Ai(LC,{children:[Sr(Qf,{value:e}),Sr(yt,{config:Xf})]})})]}):null,"InboxEditor");import{useSetAtom as RC}from"jotai";import{useCallback as e1,useEffect as t1,useRef as Qc}from"react";function eu(e,t,r=500){let o=RC(lo),n=Qc(),i=Qc(void 0),a=Qc(t);t1(()=>{a.current=t},[t]);let l=e1(()=>{n.current&&(clearTimeout(n.current),n.current=void 0),i.current!==void 0&&(a.current(i.current),i.current=void 0)},[]);return t1(()=>(o({action:"register",id:e,fn:l}),()=>{l(),o({action:"unregister",id:e}),n.current&&clearTimeout(n.current)}),[e,o,l]),e1(u=>{i.current=u,n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{l()},r)},[r,l])}s(eu,"useDebouncedFlush");import{zodResolver as HC}from"@hookform/resolvers/zod";import{useAtom as BC,useAtomValue as DC,useSetAtom as FC}from"jotai";import{memo as VC,useCallback as ks,useEffect as tu,useRef as ru}from"react";import{useForm as OC}from"react-hook-form";import{z as Bo}from"zod";import{jsx as Le,jsxs as Si}from"react/jsx-runtime";var UC=Bo.object({enableButton:Bo.boolean().default(!0),buttonLabel:Bo.string().default("Try now"),buttonUrl:Bo.string().default(""),enableSecondaryButton:Bo.boolean().default(!1),secondaryButtonLabel:Bo.string().default("Learn more"),secondaryButtonUrl:Bo.string().default("")}),WC=s(()=>{let e=DC(Te),[t,r]=BC(X),o=FC(Ae),n=ru(!1),i=ru(null),a=ru(t);tu(()=>{a.current=t},[t]);let l=OC({resolver:HC(UC),defaultValues:{enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""},mode:"onChange"});tu(()=>{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:k}=h,A=l.getValues();A.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),A.buttonLabel!==(y||"Try now")&&l.setValue("buttonLabel",y||"Try now",{shouldDirty:!1}),A.buttonUrl!==(N||"")&&l.setValue("buttonUrl",N||"",{shouldDirty:!1}),A.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),A.secondaryButtonLabel!==(g||"Learn more")&&l.setValue("secondaryButtonLabel",g||"Learn more",{shouldDirty:!1}),A.secondaryButtonUrl!==(k||"")&&l.setValue("secondaryButtonUrl",k||"",{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]),tu(()=>{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=ks(f=>{let v=a.current;if(!v||n.current)return;let h=v.elements.find(E=>E.type==="channel"&&E.channel==="inbox");h||(h={type:"channel",channel:"inbox",elements:[{type:"text",content:`
|
|
193
193
|
`,text_style:"h2"},{type:"text",content:`
|
|
194
|
-
`}]}),h.elements||(h.elements=[]);let y=[...h.elements.filter(
|
|
194
|
+
`}]}),h.elements||(h.elements=[]);let y=[...h.elements.filter(E=>E.type!=="action")];if(f.enableButton){let E={type:"action",content:f.buttonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.buttonUrl};y.push(E)}if(f.enableSecondaryButton){let E={type:"action",content:f.secondaryButtonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.secondaryButtonUrl};y.push(E)}let N={...h,elements:y},g=v.elements.findIndex(E=>E.type==="channel"&&E.channel==="inbox"),k=[...v.elements];g!==-1?k[g]=N:k.push(N);let A={...v,elements:k};r(A),o(A)},[r,o]),u=ks(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 k=v.nodeAt(N);return k?(e.commands.command(({tr:A})=>(A.setNodeMarkup(N,k.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,k={...N.attrs,label:f.buttonLabel,link:f.buttonUrl},A=y(N.pos,k),E=!0;if(g){let L={...g.attrs,label:f.secondaryButtonLabel,link:f.secondaryButtonUrl};E=y(g.pos,L)}return A&&E}return!1},[e]),d=ks(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=eu("inbox-sidebar",d,500),p=ks(()=>{let f=l.getValues();m(f)},[l,m]);return Le(Ne,{...l,children:Si("form",{onChange:p,children:[Le("div",{className:"courier-pb-4",children:Le(J,{control:l.control,name:"enableButton",render:({field:f})=>Si(Z,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between",children:[Le(rr,{className:"!courier-m-0",children:"Enable button"}),Le(q,{children:Le(zo,{checked:f.value,onCheckedChange:f.onChange,className:"!courier-m-0"})})]})})}),l.watch("enableButton")&&Le(J,{control:l.control,name:"buttonUrl",render:({field:f})=>Si(Z,{className:"courier-mb-6",children:[Le(rr,{children:"Action URL"}),Le(q,{children:Le(pe,{placeholder:"https://example.com",...f})}),Le(j,{})]})}),Le(le,{className:"courier-mb-6"}),Le(J,{control:l.control,name:"enableSecondaryButton",render:({field:f})=>Si(Z,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between courier-mb-4",children:[Le(rr,{className:"!courier-m-0",children:"Enable secondary button"}),Le(q,{children:Le(zo,{checked:f.value,onCheckedChange:f.onChange,className:"!courier-m-0"})})]})}),l.watch("enableSecondaryButton")&&Le(J,{control:l.control,name:"secondaryButtonUrl",render:({field:f})=>Si(Z,{className:"courier-mb-4",children:[Le(rr,{children:"Action URL"}),Le(q,{children:Le(pe,{placeholder:"https://example.com",...f})}),Le(j,{})]})})]})})},"SideBarComponent"),ou=VC(WC);import{useAtomValue as _C}from"jotai";import{jsx as fn,jsxs as zC}from"react/jsx-runtime";var r1=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i,...a})=>{let l=_C(X);return fn(ws,{value:l,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:c=>zC("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[fn("div",{className:"courier-flex courier-flex-col courier-flex-1 courier-py-8 courier-items-center",children:fn(Xc,{...c})}),fn("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:fn("div",{className:"courier-p-4 courier-h-full",children:fn(ou,{})})})]}),...a})},"InboxLayout");import{useCurrentEditor as $C}from"@tiptap/react";import{useAtom as ZC,useAtomValue as Ps,useSetAtom as nu}from"jotai";import{forwardRef as qC,memo as JC,useCallback as jC,useEffect as Ii,useMemo as o1,useRef as iu}from"react";import{jsx as n1}from"react/jsx-runtime";var i1=s(({value:e})=>{let{editor:t}=$C(),r=nu(Te),o=Ps(X),n=Ps(ae),i=iu(!1);return Ii(()=>{n&&(i.current=!1)},[n]),Ii(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),Ii(()=>{t&&(r(t),Ct("push",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),Ii(()=>{if(!t||!o||t.isFocused)return;let a=a1(o),l=a.type==="channel"&&"elements"in a&&a.elements||Do;l=l.map(p=>p.type==="meta"&&"title"in p?{type:"text",content:p.title||`
|
|
195
195
|
`,text_style:"h2"}:p);let u=Se({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:l}]}),d=me(u),m=me(t.getJSON());JSON.stringify(d)!==JSON.stringify(m)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"PushEditorContent"),Do=[{type:"meta",title:""},{type:"text",content:`
|
|
196
|
-
`}],
|
|
197
|
-
`,text_style:"h2"}:C),Se({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:
|
|
198
|
-
`}],
|
|
199
|
-
`}],
|
|
200
|
-
`}],L1=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:Ri}),t},"getOrCreateMSTeamsElement"),R1=s(({value:e})=>{let{editor:t}=I8(),r=I1(Te),o=Vo(X),n=Vo(ae),i=Vo(ge),a=Tn(!1),l=Tn(!1);return hr(()=>{n&&(a.current=!1)},[n]),hr(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),hr(()=>{t&&(r(t),Ct("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),hr(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),hr(()=>(l.current=!0,()=>{l.current=!1}),[]),hr(()=>{if(!t||!o||t.isFocused)return;let c=L1(o),u=Se({version:"2022-01-01",elements:[c]},{channel:"msteams"}),d=me(u),m=me(t.getJSON());JSON.stringify(d)!==JSON.stringify(m)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"MSTeamsEditorContent"),H1={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"]}}]},B8=L8(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let m=Vo(ae),p=Vo(ze),f=Vo(Te),v=Vo(pt),[h,b]=A1(ge),[y,N]=A1(X),g=I1(Ae),P=Tn(!0),M=Tn(!1),T=Tn(v),[R,E]=H8({Sidebar:["text","divider"],Editor:[]}),C=Tn(null);un({items:R,setItems:E});let x=Cu(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)},[]);hr(()=>(M.current=!0,()=>{M.current=!1}),[]),hr(()=>{T.current=v},[v]),hr(()=>{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]),hr(()=>{m===!1&&y&&setTimeout(()=>{f&&!f.isDestroyed&&x(f)},300)},[m,y,f,x]);let w=Cu(()=>!T.current,[]),A=S1(()=>[...bt({setSelectedNode:b,shouldHandleClick:w})].filter(S=>S!==void 0),[b,w]),k=Cu(({editor:S})=>{if(!S||p)return;if(!y){let U={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:me(S.getJSON())}]};N(U),g(U);return}let H=S.getJSON(),V=me(H),F=Ve(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=S1(()=>{let S=L1(l);return Se({version:"2022-01-01",elements:[S]},{channel:"msteams"})},[l]);return vu(ht,{theme:e,colorScheme:c,isLoading:!!(m&&P.current),Header:i?i({hidePublish:t,channels:o,routing:n}):vu(Dt,{hidePublish:t,channels:o,routing:n}),ref:d,...u,children:vu(D8,{children:a==null?void 0:a({content:L,extensions:A,editable:!r,autofocus:!r,onUpdate:k,items:R,selectedNode:h,msteamsEditor:f})})})}),Bs=R8(B8);import{EditorProvider as U8}from"@tiptap/react";import{jsx as ot,jsxs as Hi}from"react/jsx-runtime";var F8=s(()=>ot("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-full",children:ot(ni,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),V8=s(()=>Hi("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[ot(F8,{}),Hi("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[ot("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"}),ot("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),O8=s(()=>ot("div",{className:"courier-flex courier-justify-end courier-w-full",children:ot("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:ot("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),B1=s(({children:e,className:t})=>Hi("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:[ot(V8,{}),Hi("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[ot("div",{className:"courier-flex-shrink-0 courier-mt-6",children:ot("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:ot(oi,{color:"#FFFFFF"})})}),Hi("div",{className:"courier-flex-1 courier-min-w-0",children:[ot("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:ot("span",{className:"courier-text-sm courier-text-[#A3A3A3] dark:courier-text-[#8786A9]",children:"Circle"})}),ot("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})]})]}),ot(O8,{})]}),"MSTeamsFrame");import{useRef as W8,useEffect as _8}from"react";import{Fragment as z8,jsx as En,jsxs as $8}from"react/jsx-runtime";var xu=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let a=W8(null);return _8(()=>{let l=a.current;if(!(!l||i))return Pt({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?En(B1,{children:En("div",{ref:a,children:En(U8,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:I("courier-msteams-editor")},immediatelyRender:!1,children:i?En(Vt,{value:e,defaultValue:Ri}):$8(z8,{children:[En(R1,{value:e}),En(yt,{config:H1})]})})})}):null},"MSTeamsEditor");import{useAtomValue as J8}from"jotai";import{GripVertical as Z8}from"lucide-react";import{Fragment as q8,jsx as Br,jsxs as Tu}from"react/jsx-runtime";var Eu=s(({items:e,label:t,editor:r})=>Br("div",{className:"courier-flex courier-flex-col courier-h-full",children:Tu("div",{className:"courier-flex-1",children:[t&&Tu(q8,{children:[Br("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),Br(le,{className:"courier-my-4"})]}),Br("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>Br(mn,{id:o.toString(),editor:r,children:Tu("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:[Br(Z8,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),o==="text"&&Br(Zr,{draggable:!0}),o==="divider"&&Br($r,{draggable:!0}),o==="button"&&Br(zr,{draggable:!0})]})},o))})]})}),"MSTeamsSideBar");import{forwardRef as D1}from"react";import{jsx as br,jsxs as K8}from"react/jsx-runtime";var j8=D1(({children:e,className:t,...r},o)=>br("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),G8=D1(({children:e,...t},r)=>br("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),F1=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i})=>{let a=J8(X);return br(Bs,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:l=>{var c;return K8(Lo,{children:[br("div",{className:"courier-flex courier-flex-col courier-flex-1",children:br(j8,{children:br(G8,{children:br(xu,{...l})})})}),br(Ro,{children:br("div",{className:"courier-p-1 courier-h-full",children:br(Eu,{items:l.items.Sidebar,label:"Blocks library",editor:(c=l.msteamsEditor)!=null?c:void 0})})})]})}})},"MSTeamsLayout");var W1={sms:{elements:Hr},push:{elements:Do},inbox:{elements:Mi},slack:{elements:Li},email:{elements:wi},msteams:{elements:Ri}},_1=s(e=>{var t;return(t=W1[e])!=null?t:W1.email},"getChannelDefaults"),e4=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"),Pu=s(({channels:e=["email"],routing:t})=>{let[r,o]=Q8([]),n=V1(X),i=wu(X),a=wu(Ae),[l,c]=Y8(Ur),u=wu(ge),d=V1(ae),m=e4(t,e),p=X8(m);p.current=m,ku(()=>{if(d||n!=null&&n.elements)return;let N=p.current.map(g=>go.find(P=>P.value===g)).filter(g=>!!g);o(N),N.length>0&&!l&&c(N[0].value)},[n,d,c,l]),ku(()=>{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=>go.find(M=>M.value===P)).filter(P=>!!P);o(g)},[n,d]),ku(()=>{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=U1(()=>(m==null?void 0:m.filter(y=>!r.some(N=>N.value===y)).map(y=>go.find(N=>N.value===y)).filter(y=>!!y))||[],[r,m]),v=O1(y=>{let N=[],g,{elements:P,raw:M}=_1(y);if(N=P,g=M,!n){let E=[];for(let w of r){let{elements:A,raw:k}=_1(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=Ve(n,{elements:N,channel:g?{channel:y,raw:g}:y});i(R),a(R),c(y)},[n,i,a,c,r]),h=O1(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=U1(()=>[...r,...f],[r,f]);return{enabledChannels:r,disabledChannels:f,channel:l,channelOptions:b,setChannel:c,addChannel:v,removeChannel:h}},"useChannels");import{Fragment as a4,jsx as Je,jsxs as yr}from"react/jsx-runtime";var Dt=s(({hidePublish:e=!1,channels:t,routing:r})=>{let o=i4(null),n=Ds(Ge),i=Ds(ae),a=Ds(Q),{publishTemplate:l,isTemplatePublishing:c}=Vn(),[u,d]=r4(Uo),m=o4(tr),p=Ds(tr),{enabledChannels:f,disabledChannels:v,channel:h,setChannel:b,addChannel:y,removeChannel:N}=Pu({channels:t,routing:r});n4(()=>{n===!0&&d(null)},[n,d]);let g=Bi(()=>{p&&m(!1),l()},[l,p,m]),P=Bi(E=>{p&&m(!1),b(E)},[p,m,b]),M=Bi(E=>{p&&m(!1),y(E)},[p,m,y]),T=Bi(E=>{p&&m(!1),N(E)},[p,m,N]),R=Bi(()=>{p&&m(!1)},[p,m]);return yr("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:R,children:[yr("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[Je(ra,{value:h,onValueChange:P,className:"courier-h-full",ref:o,children:Je(qn,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${go.length}, fit-content(100%))`},children:f.map(E=>yr($o,{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&&yr(Qu,{children:[Je(ed,{asChild:!0,children:Je("div",{className:"courier-pl-2",children:Je(Jn,{color:"#A3A3A3"})})}),yr(al,{ref:o,children:[Je(sl,{children:Je(t4,{children:"Are you sure you want to delete this channel?"})}),yr(ll,{children:[Je(ul,{asChild:!0,children:Je(Ce,{buttonSize:"small",variant:"outline",children:"Cancel"})}),Je(cl,{asChild:!0,children:Je(Ce,{buttonSize:"small",variant:"primary",onClick:()=>T(E.value),children:"Delete"})})]})]})]})]},E.value))})}),v.length>0&&yr(a4,{children:[Je(hl,{orientation:"vertical",className:"!courier-h-5"}),yr(Yi,{children:[Je(Xi,{asChild:!0,children:Je(Ce,{variant:"link",children:"+ Add channel"})}),Je(Wn,{portalProps:{container:o.current},children:v.map(E=>yr(_n,{onClick:()=>M(E.value),children:[E.icon,E.label]},E.value))})]})]})]}),yr("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&Je(ai,{isLoading:!!i,isSaving:!!n,isError:!!a}),!e&&i!==null&&Je(Ce,{variant:"primary",buttonSize:"small",disabled:c===!0||n===!0||u!==null,onClick:g,children:c?"Publishing...":"Publish changes"})]})]})},"Channels");import{useCallback as z1,useEffect as $1,useRef as ro,useState as s4}from"react";function Di({onSave:e,debounceMs:t=2e3,enabled:r=!0,onError:o,initialContent:n,flushBeforeSave:i}){let[a,l]=s4(!1),c=ro(!1),u=ro(null),d=ro(),m=ro(0),p=ro();$1(()=>{n&&(d.current=JSON.stringify(n))},[n]);let f=z1(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=ro(r),h=ro(t),b=ro(f);return $1(()=>{v.current=r,h.current=t,b.current=f}),{handleAutoSave:z1(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(Di,"useAutoSave");import{useAtom as Vi,useAtomValue as Dr,useSetAtom as Su}from"jotai";import{memo as R4,useCallback as Iu,useEffect as Lt,useRef as Os,useState as H4}from"react";import{useAtom as Q1,useAtomValue as Au,useSetAtom as eg}from"jotai";import{forwardRef as S4,memo as I4,useCallback as tg,useEffect as Pn,useRef as rg}from"react";import{z as xt}from"zod";var Z1=xt.object({headerStyle:xt.enum(["plain","border"]),isUnsubscribe:xt.boolean().optional(),isPreferences:xt.boolean().optional(),link:xt.string().optional(),brandColor:xt.string(),textColor:xt.string(),subtleColor:xt.string(),logo:xt.string().optional(),facebookLink:xt.string().optional(),linkedinLink:xt.string().optional(),instagramLink:xt.string().optional(),mediumLink:xt.string().optional(),xLink:xt.string().optional()}),ct={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};var l4=s(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),Fi=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(l4).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`
|
|
196
|
+
`}],a1=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:Do}),t},"getOrCreatePushElement"),s1={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"}},GC=qC(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let m=Ps(ae),p=iu(!0),f=iu(!1),v=nu(ge),[h,b]=ZC(X),y=nu(Ae),N=Ps(ze);Ii(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=o1(()=>[...bt({setSelectedNode:v})].filter(E=>E!==void 0),[v]),k=jC(({editor:E})=>{if(N)return;if(!h){let M=me(E.getJSON()),R=M[0],I="",H=M;R&&R.type==="text"&&"text_style"in R&&R.text_style==="h2"&&"content"in R&&(I=R.content.trim(),H=M.slice(1));let F={version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:$t(null,"push",I,H).elements}]};b(F),y(F);return}let L=me(E.getJSON()),w=L[0],C="",T=L;w&&w.type==="text"&&"text_style"in w&&w.text_style==="h2"&&"content"in w&&(C=w.content.trim(),T=L.slice(1));let x=$t(h,"push",C,T),P=Ve(h,{channel:"push",elements:x.elements});JSON.stringify(h)!==JSON.stringify(P)&&(b(P),y(P))},[h,b,y,N]),A=o1(()=>{if(m!==!1)return null;let E=l==null?void 0:l.elements.find(C=>C.type==="channel"&&C.channel==="push");!E&&h&&(E=a1(h));let L=(E==null?void 0:E.type)==="channel"&&"elements"in E&&E.elements||Do;return L=L.map(C=>C.type==="meta"&&"title"in C?{type:"text",content:C.title||`
|
|
197
|
+
`,text_style:"h2"}:C),Se({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:L}]})},[l,h,m]);return n1(ht,{theme:e,colorScheme:c,isLoading:!!(m&&p.current),Header:i?i({hidePublish:t,channels:o,routing:n}):n1(Dt,{hidePublish:t,channels:o,routing:n}),...u,ref:d,children:a==null?void 0:a({content:A,extensions:g,editable:!r,autofocus:!r,onUpdate:k})})}),Ns=JC(GC);import{EditorProvider as KC}from"@tiptap/react";import{jsx as Ir,jsxs as Ms}from"react/jsx-runtime";var As=s(({children:e})=>Ms("div",{className:"courier-relative",children:[Ir("div",{className:"courier-absolute courier-w-0.5 courier-h-6 courier-bg-border -courier-left-[2px] courier-top-[136px]"}),Ir("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[178px]"}),Ir("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[245px]"}),Ir("div",{className:"courier-absolute courier-w-0.5 courier-h-[78px] courier-bg-border -courier-right-[2px] courier-top-[200px]"}),Ms("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:[Ms("div",{className:"courier-my-6 courier-mx-11 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[Ir("span",{className:"courier-text-xs courier-font-semibold",children:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),Ms("div",{className:"courier-flex courier-items-center courier-gap-2",children:[Ir($d,{}),Ir(Kd,{}),Ir(Ed,{})]})]}),Ir("div",{className:"courier-flex-1 courier-overflow-auto courier-h-[calc(90%-56px)] courier-mb-6",children:e})]})]}),"IPhoneFrame");import{Fragment as YC,jsx as gn,jsxs as au}from"react/jsx-runtime";var su=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 au(As,{children:[au("div",{className:S("courier-px-4 courier-py-2 courier-text-[#A3A3A3] courier-text-center courier-my-8",i),children:[gn("p",{className:"courier-text-lg courier-font-medium",children:new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}),gn("p",{className:"courier-text-5xl courier-font-semibold courier-mt-1",children:new Date().toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})})]}),gn(KC,{content:l,extensions:t,...c,editorContainerProps:{className:S("courier-push-editor")},"data-testid":"editor-provider",immediatelyRender:!1,children:a?gn(Vt,{value:l,defaultValue:Do}):au(YC,{children:[gn(i1,{value:l}),gn(yt,{config:s1})]})})]})},"PushEditor");import{useAtomValue as XC}from"jotai";import{jsx as lu}from"react/jsx-runtime";var l1=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,...i})=>{let a=XC(X);return lu(Ns,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:l=>lu("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:lu(su,{...l})}),...i})},"PushLayout");import{useCurrentEditor as QC}from"@tiptap/react";import{useAtom as c1,useAtomValue as Fo,useSetAtom as m1}from"jotai";import{forwardRef as e8,memo as t8,useCallback as u1,useEffect as Lr,useMemo as d1,useRef as hn,useState as r8}from"react";import{Fragment as n8,jsx as cu}from"react/jsx-runtime";var Li=[{type:"text",content:`
|
|
198
|
+
`}],p1=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:Li}),t},"getOrCreateSlackElement"),f1=s(({value:e})=>{let{editor:t}=QC(),r=m1(Te),o=Fo(X),n=Fo(ae),i=Fo(ge),a=hn(!1),l=hn(!1);return Lr(()=>{n&&(a.current=!1)},[n]),Lr(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),Lr(()=>{t&&(r(t),Ct("slack",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),Lr(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),Lr(()=>(l.current=!0,()=>{l.current=!1}),[]),Lr(()=>{if(!t||!o||t.isFocused)return;let c=p1(o),u=Se({version:"2022-01-01",elements:[c]},{channel:"slack"}),d=me(u),m=me(t.getJSON());JSON.stringify(d)!==JSON.stringify(m)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"SlackEditorContent"),g1={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"]}}]},o8=e8(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let m=Fo(ae),p=Fo(ze),f=Fo(Te),v=Fo(pt),[h,b]=c1(ge),[y,N]=c1(X),g=m1(Ae),k=hn(!0),A=hn(!1),E=hn(v),L=hn(null),[w,C]=r8({Sidebar:["text","divider","button"],Editor:[]});un({items:w,setItems:C});let{syncEditorItems:T}=gs({setItems:C,rafId:L});Lr(()=>(A.current=!0,()=>{A.current=!1}),[]),Lr(()=>{E.current=v},[v]),Lr(()=>{m===!1&&y&&setTimeout(()=>{f&&!f.isDestroyed&&T(f)},300)},[m,y,f,T]);let x=u1(()=>!E.current,[]),P=d1(()=>[...bt({setSelectedNode:b,shouldHandleClick:x})].filter(I=>I!==void 0),[b,x]),M=u1(({editor:I})=>{if(!I||p)return;if(!y){let U={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:me(I.getJSON())}]};N(U),g(U);return}let H=I.getJSON(),V=me(H),F=Ve(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]),R=d1(()=>{let I=p1(l);return Se({version:"2022-01-01",elements:[I]},{channel:"slack"})},[l]);return cu(ht,{theme:e,colorScheme:c,isLoading:!!(m&&k.current),Header:i?i({hidePublish:t,channels:o,routing:n}):cu(Dt,{hidePublish:t,channels:o,routing:n}),ref:d,...u,children:cu(n8,{children:a==null?void 0:a({content:R,extensions:P,editable:!r,autofocus:!r,onUpdate:M,items:w,selectedNode:h,slackEditor:f})})})}),Ss=t8(o8);import{EditorProvider as s8}from"@tiptap/react";import{jsx as rt,jsxs as bn}from"react/jsx-runtime";var i8=s(()=>bn("div",{className:"courier-flex courier-gap-2 courier-flex-col courier-w-full",children:[rt("div",{className:"courier-w-3/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),rt("div",{className:"courier-w-full courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),rt("div",{className:"courier-w-6/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"})]}),"TextSkeleton"),a8=s(()=>rt("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-lg",children:rt(ni,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),h1=s(()=>bn("div",{className:"courier-flex courier-gap-2 courier-flex-row",children:[rt(a8,{}),rt(i8,{})]}),"InteractionSkeleton"),b1=s(({children:e,className:t})=>bn("div",{className:S("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:[rt(h1,{}),bn("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[rt("div",{className:"courier-flex-shrink-0",children:rt("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:rt(oi,{color:"#FFFFFF"})})}),bn("div",{className:"courier-flex-1 courier-min-w-0",children:[bn("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mb-1",children:[rt("span",{className:"courier-font-semibold courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1]",children:"Circle"}),rt("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"}),rt("span",{className:"courier-text-xs courier-text-gray-500 dark:courier-text-[#8786A9]",children:"Now"})]}),rt("div",{className:"courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-pr-4",children:e})]})]}),rt(h1,{})]}),"SlackFrame");import{useRef as l8,useEffect as c8}from"react";import{Fragment as u8,jsx as yn,jsxs as d8}from"react/jsx-runtime";var uu=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let a=l8(null);return c8(()=>{let l=a.current;if(!(!l||i))return Pt({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?yn(b1,{children:yn("div",{ref:a,children:yn(s8,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:S("courier-slack-editor")},immediatelyRender:!1,children:i?yn(Vt,{value:e,defaultValue:Li}):d8(u8,{children:[yn(f1,{value:e}),yn(yt,{config:g1})]})})})}):null},"SlackEditor");import{useAtomValue as h8}from"jotai";import{GripVertical as m8}from"lucide-react";import{Fragment as p8,jsx as Rr,jsxs as du}from"react/jsx-runtime";var mu=s(({items:e,label:t,editor:r})=>Rr("div",{className:"courier-flex courier-flex-col courier-h-full",children:du("div",{className:"courier-flex-1",children:[t&&du(p8,{children:[Rr("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),Rr(le,{className:"courier-my-4"})]}),Rr("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>Rr(mn,{id:o.toString(),editor:r,children:du("div",{className:S("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:[Rr(m8,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),o==="text"&&Rr(Zr,{draggable:!0}),o==="divider"&&Rr($r,{draggable:!0}),o==="button"&&Rr(zr,{draggable:!0})]})},o))})]})}),"SlackSideBar");import{zodResolver as f8}from"@hookform/resolvers/zod";import{useForm as g8}from"react-hook-form";import{jsx as Cn,jsxs as pu}from"react/jsx-runtime";var y1=s(({element:e,editor:t})=>{let r=g8({resolver:f8(La),defaultValues:{...Ie,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({editor:t,element:e,form:r,nodeType:"button"});return e?pu(Ne,{...r,children:[Cn(Qe,{type:"button"}),pu("form",{onChange:()=>{o(r.getValues())},children:[Cn("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),Cn(J,{control:r.control,name:"link",render:({field:n})=>pu(Z,{children:[Cn(q,{children:Cn(lr,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})}})}),Cn(j,{})]})})]})]}):null},"SlackButtonForm");import{jsx as C1}from"react/jsx-runtime";var fu=s(({element:e,editor:t,defaultElement:r})=>e&&e.type.name==="button"?C1("div",{className:"courier-flex courier-flex-col courier-gap-4",children:C1(y1,{element:e,editor:t},e.attrs.id)}):r,"SlackSideBarItemDetails");import{forwardRef as v1}from"react";import{jsx as Xt,jsxs as C8}from"react/jsx-runtime";var b8=v1(({children:e,className:t,...r},o)=>Xt("div",{className:S("courier-editor-container courier-relative",t),...r,ref:o,children:e})),y8=v1(({children:e,...t},r)=>Xt("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),x1=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i})=>{let a=h8(X);return Xt(Ss,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:l=>{var c;return C8(Lo,{children:[Xt("div",{className:"courier-flex courier-flex-col courier-flex-1",children:Xt(b8,{children:Xt(y8,{children:Xt(uu,{...l})})})}),Xt(Ro,{children:Xt("div",{className:"courier-p-1 courier-h-full",children:Xt(fu,{element:l.selectedNode,editor:l.slackEditor,defaultElement:Xt(mu,{items:l.items.Sidebar,label:"Blocks library",editor:(c=l.slackEditor)!=null?c:void 0})})})})]})}})},"SlackLayout");import{useCurrentEditor as v8}from"@tiptap/react";import{useAtom as x8,useAtomValue as Ls,useSetAtom as gu}from"jotai";import{forwardRef as T8,memo as E8,useCallback as T1,useEffect as vn,useMemo as E1,useRef as Is,useState as w8}from"react";import{SegmentedMessage as k8}from"sms-segments-calculator";import{jsx as hu}from"react/jsx-runtime";var Hr=[{type:"text",content:`
|
|
199
|
+
`}],w1=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:Hr}),t},"getOrCreateSMSElement"),k1=s(({value:e})=>{var c;let{editor:t}=v8(),r=gu(Te),o=Ls(X),n=(c=t==null?void 0:t.getText())!=null?c:"",i=E1(()=>new k8(n),[n]),a=Ls(ae),l=Is(!1);return vn(()=>{a&&(l.current=!1)},[a]),vn(()=>{!t||a!==!1||l.current||!e||(l.current=!0,t.commands.setContent(e))},[t,e,a]),vn(()=>{t&&(r(t),Ct("sms",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),vn(()=>{if(!t||!o||t.isFocused)return;let u=w1(o),m={type:"channel",channel:"sms",elements:u.type==="channel"&&"elements"in u&&u.elements||Hr},p=Se({version:"2022-01-01",elements:[m]}),f=me(p),v=me(t.getJSON());JSON.stringify(f)!==JSON.stringify(v)&&setTimeout(()=>{t.isFocused||t.commands.setContent(p)},1)},[t,o]),hu("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"),P1={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"}},P8=T8(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,render:i,headerRenderer:a,value:l,colorScheme:c,...u},d)=>{let m=Ls(ae),p=Is(!0),f=Is(!1),v=gu(ge),[h,b]=x8(X),y=gu(Ae),N=Ls(ze);vn(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=E1(()=>[...bt({setSelectedNode:v})].filter(C=>C!==void 0),[v]),k=Is(!1),A=T1(({editor:C})=>{if(N)return;if(!h){let M=me(C.getJSON()),R=$i(M),I={version:"2022-01-01",elements:[{type:"channel",channel:"sms",elements:R.length>0?R:Hr}]};k.current=!0,b(I),y(I);return}let T=me(C.getJSON()),x=$i(T),P=Ve(h,{channel:"sms",elements:x.length>0?x:Hr});JSON.stringify(h)!==JSON.stringify(P)&&(k.current=!0,b(P),y(P))},[h,b,y,N]),[E,L]=w8(null),w=T1(C=>{if(!C)return null;let T=C==null?void 0:C.elements.find(M=>M.type==="channel"&&M.channel==="sms");T||(T=w1(C));let P={type:"channel",channel:"sms",elements:(T==null?void 0:T.type)==="channel"&&"elements"in T&&T.elements||Hr};return Se({version:"2022-01-01",elements:[P]})},[]);return vn(()=>{if(m!==!1)return;if(k.current){k.current=!1;return}let C=l!=null?l:h,T=w(C);T&&L(T)},[l,h,w,m]),hu(ht,{theme:e,colorScheme:c,isLoading:!!(m&&p.current),Header:a?a({hidePublish:t,channels:o,routing:n}):hu(Dt,{hidePublish:t,channels:o,routing:n}),...u,ref:d,children:i==null?void 0:i({content:E,extensions:g,editable:!r,autofocus:!r,onUpdate:A})})}),Rs=E8(P8);import{EditorProvider as N8}from"@tiptap/react";import{Fragment as M8,jsx as xn,jsxs as A8}from"react/jsx-runtime";var bu=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 xn(As,{children:xn("div",{className:S("courier-sms-editor",i),children:xn(N8,{content:l,extensions:t,...c,"data-testid":"editor-provider",immediatelyRender:!1,children:a?xn(Vt,{value:l,defaultValue:Hr}):A8(M8,{children:[xn(k1,{value:l}),xn(yt,{config:P1})]})})})})},"SMSEditor");import{useAtomValue as S8}from"jotai";import{jsx as yu}from"react/jsx-runtime";var N1=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i,...a})=>{let l=S8(X);return yu(Rs,{value:l,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:c=>yu("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:yu(bu,{...c})}),...a})},"SMSLayout");import{useCurrentEditor as I8}from"@tiptap/react";import{useAtom as M1,useAtomValue as Vo,useSetAtom as S1}from"jotai";import{forwardRef as L8,memo as R8,useCallback as Cu,useEffect as hr,useMemo as A1,useRef as Tn,useState as H8}from"react";import{Fragment as D8,jsx as vu}from"react/jsx-runtime";var Ri=[{type:"text",content:`
|
|
200
|
+
`}],I1=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:Ri}),t},"getOrCreateMSTeamsElement"),L1=s(({value:e})=>{let{editor:t}=I8(),r=S1(Te),o=Vo(X),n=Vo(ae),i=Vo(ge),a=Tn(!1),l=Tn(!1);return hr(()=>{n&&(a.current=!1)},[n]),hr(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),hr(()=>{t&&(r(t),Ct("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),hr(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),hr(()=>(l.current=!0,()=>{l.current=!1}),[]),hr(()=>{if(!t||!o||t.isFocused)return;let c=I1(o),u=Se({version:"2022-01-01",elements:[c]},{channel:"msteams"}),d=me(u),m=me(t.getJSON());JSON.stringify(d)!==JSON.stringify(m)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"MSTeamsEditorContent"),R1={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"]}}]},B8=L8(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let m=Vo(ae),p=Vo(ze),f=Vo(Te),v=Vo(pt),[h,b]=M1(ge),[y,N]=M1(X),g=S1(Ae),k=Tn(!0),A=Tn(!1),E=Tn(v),[L,w]=H8({Sidebar:["text","divider"],Editor:[]}),C=Tn(null);un({items:L,setItems:w});let T=Cu(I=>{C.current&&cancelAnimationFrame(C.current),setTimeout(()=>{C.current=requestAnimationFrame(()=>{try{let H=I==null?void 0:I.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)}),w(O=>({Editor:F,Sidebar:O.Sidebar}))}catch(H){console.error("Error syncing editor items:",H),w(V=>({...V}))}})},50)},[]);hr(()=>(A.current=!0,()=>{A.current=!1}),[]),hr(()=>{E.current=v},[v]),hr(()=>{let I=s(()=>{f&&T(f)},"updateItems");f==null||f.on("update",I),f==null||f.on("selectionUpdate",I),f==null||f.on("create",I),f==null||f.on("transaction",I),f&&!f.isDestroyed&&I();let H=s(V=>{I()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",H),()=>{f==null||f.off("update",I),f==null||f.off("selectionUpdate",I),f==null||f.off("create",I),f==null||f.off("transaction",I),document.removeEventListener("node-duplicated",H),C.current&&cancelAnimationFrame(C.current)}},[f,T]),hr(()=>{m===!1&&y&&setTimeout(()=>{f&&!f.isDestroyed&&T(f)},300)},[m,y,f,T]);let x=Cu(()=>!E.current,[]),P=A1(()=>[...bt({setSelectedNode:b,shouldHandleClick:x})].filter(I=>I!==void 0),[b,x]),M=Cu(({editor:I})=>{if(!I||p)return;if(!y){let U={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:me(I.getJSON())}]};N(U),g(U);return}let H=I.getJSON(),V=me(H),F=Ve(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]),R=A1(()=>{let I=I1(l);return Se({version:"2022-01-01",elements:[I]},{channel:"msteams"})},[l]);return vu(ht,{theme:e,colorScheme:c,isLoading:!!(m&&k.current),Header:i?i({hidePublish:t,channels:o,routing:n}):vu(Dt,{hidePublish:t,channels:o,routing:n}),ref:d,...u,children:vu(D8,{children:a==null?void 0:a({content:R,extensions:P,editable:!r,autofocus:!r,onUpdate:M,items:L,selectedNode:h,msteamsEditor:f})})})}),Hs=R8(B8);import{EditorProvider as U8}from"@tiptap/react";import{jsx as ot,jsxs as Hi}from"react/jsx-runtime";var F8=s(()=>ot("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-full",children:ot(ni,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),V8=s(()=>Hi("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[ot(F8,{}),Hi("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[ot("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"}),ot("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),O8=s(()=>ot("div",{className:"courier-flex courier-justify-end courier-w-full",children:ot("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:ot("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),H1=s(({children:e,className:t})=>Hi("div",{className:S("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:[ot(V8,{}),Hi("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[ot("div",{className:"courier-flex-shrink-0 courier-mt-6",children:ot("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:ot(oi,{color:"#FFFFFF"})})}),Hi("div",{className:"courier-flex-1 courier-min-w-0",children:[ot("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:ot("span",{className:"courier-text-sm courier-text-[#A3A3A3] dark:courier-text-[#8786A9]",children:"Circle"})}),ot("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})]})]}),ot(O8,{})]}),"MSTeamsFrame");import{useRef as W8,useEffect as _8}from"react";import{Fragment as z8,jsx as En,jsxs as $8}from"react/jsx-runtime";var xu=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let a=W8(null);return _8(()=>{let l=a.current;if(!(!l||i))return Pt({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?En(H1,{children:En("div",{ref:a,children:En(U8,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:S("courier-msteams-editor")},immediatelyRender:!1,children:i?En(Vt,{value:e,defaultValue:Ri}):$8(z8,{children:[En(L1,{value:e}),En(yt,{config:R1})]})})})}):null},"MSTeamsEditor");import{useAtomValue as J8}from"jotai";import{GripVertical as Z8}from"lucide-react";import{Fragment as q8,jsx as Br,jsxs as Tu}from"react/jsx-runtime";var Eu=s(({items:e,label:t,editor:r})=>Br("div",{className:"courier-flex courier-flex-col courier-h-full",children:Tu("div",{className:"courier-flex-1",children:[t&&Tu(q8,{children:[Br("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),Br(le,{className:"courier-my-4"})]}),Br("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>Br(mn,{id:o.toString(),editor:r,children:Tu("div",{className:S("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:[Br(Z8,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),o==="text"&&Br(Zr,{draggable:!0}),o==="divider"&&Br($r,{draggable:!0}),o==="button"&&Br(zr,{draggable:!0})]})},o))})]})}),"MSTeamsSideBar");import{forwardRef as B1}from"react";import{jsx as br,jsxs as K8}from"react/jsx-runtime";var j8=B1(({children:e,className:t,...r},o)=>br("div",{className:S("courier-editor-container courier-relative",t),...r,ref:o,children:e})),G8=B1(({children:e,...t},r)=>br("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),D1=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i})=>{let a=J8(X);return br(Hs,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:l=>{var c;return K8(Lo,{children:[br("div",{className:"courier-flex courier-flex-col courier-flex-1",children:br(j8,{children:br(G8,{children:br(xu,{...l})})})}),br(Ro,{children:br("div",{className:"courier-p-1 courier-h-full",children:br(Eu,{items:l.items.Sidebar,label:"Blocks library",editor:(c=l.msteamsEditor)!=null?c:void 0})})})]})}})},"MSTeamsLayout");var U1={sms:{elements:Hr},push:{elements:Do},inbox:{elements:Mi},slack:{elements:Li},email:{elements:wi},msteams:{elements:Ri}},W1=s(e=>{var t;return(t=U1[e])!=null?t:U1.email},"getChannelDefaults"),e4=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"),Pu=s(({channels:e=["email"],routing:t})=>{let[r,o]=Q8([]),n=F1(X),i=wu(X),a=wu(Ae),[l,c]=Y8(Ur),u=wu(ge),d=F1(ae),m=e4(t,e),p=X8(m);p.current=m,ku(()=>{if(d||n!=null&&n.elements)return;let N=p.current.map(g=>go.find(k=>k.value===g)).filter(g=>!!g);o(N),N.length>0&&!l&&c(N[0].value)},[n,d,c,l]),ku(()=>{if(d||!(n!=null&&n.elements))return;let y=p.current,N=n.elements.filter(k=>k.type==="channel").map(k=>k.channel).filter(k=>y.includes(k)),g=y.filter(k=>N.includes(k)).map(k=>go.find(A=>A.value===k)).filter(k=>!!k);o(g)},[n,d]),ku(()=>{var g;if(d||r.length===0)return;let y=r.some(k=>k.value===l),N=(g=n==null?void 0:n.elements)==null?void 0:g.some(k=>k.type==="channel"&&k.channel===l);!y&&!N&&c(r[0].value)},[r,l,c,d,n]);let f=O1(()=>(m==null?void 0:m.filter(y=>!r.some(N=>N.value===y)).map(y=>go.find(N=>N.value===y)).filter(y=>!!y))||[],[r,m]),v=V1(y=>{let N=[],g,{elements:k,raw:A}=W1(y);if(N=k,g=A,!n){let w=[];for(let x of r){let{elements:P,raw:M}=W1(x.value),R={type:"channel",channel:x.value,elements:P};M&&(R.raw=M),w.push(R)}let C={type:"channel",channel:y,elements:N};g&&(C.raw=g),w.push(C);let T={version:"2022-01-01",elements:w};i(T),a(T),c(y);return}let L=Ve(n,{elements:N,channel:g?{channel:y,raw:g}:y});i(L),a(L),c(y)},[n,i,a,c,r]),h=V1(y=>{if(!n)return;let N=n.elements.filter(A=>A.type==="channel"?A.channel!==y:!0),g={...n,elements:N};i(g),a(g),u(null);let k=r.filter(A=>A.value!==y);l===y&&k.length>0&&c(k[0].value)},[n,i,a,r,l,c,u]),b=O1(()=>[...r,...f],[r,f]);return{enabledChannels:r,disabledChannels:f,channel:l,channelOptions:b,setChannel:c,addChannel:v,removeChannel:h}},"useChannels");import{Fragment as a4,jsx as Je,jsxs as yr}from"react/jsx-runtime";var Dt=s(({hidePublish:e=!1,channels:t,routing:r})=>{let o=i4(null),n=Bs(Ge),i=Bs(ae),a=Bs(Q),{publishTemplate:l,isTemplatePublishing:c}=Vn(),[u,d]=r4(Uo),m=o4(tr),p=Bs(tr),{enabledChannels:f,disabledChannels:v,channel:h,setChannel:b,addChannel:y,removeChannel:N}=Pu({channels:t,routing:r});n4(()=>{n===!0&&d(null)},[n,d]);let g=Bi(()=>{p&&m(!1),l()},[l,p,m]),k=Bi(w=>{p&&m(!1),b(w)},[p,m,b]),A=Bi(w=>{p&&m(!1),y(w)},[p,m,y]),E=Bi(w=>{p&&m(!1),N(w)},[p,m,N]),L=Bi(()=>{p&&m(!1)},[p,m]);return yr("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:L,children:[yr("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[Je(ra,{value:h,onValueChange:k,className:"courier-h-full",ref:o,children:Je(qn,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${go.length}, fit-content(100%))`},children:f.map(w=>yr($o,{value:w.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:[w.label,w.value===h&&f.length>1&&yr(Qu,{children:[Je(ed,{asChild:!0,children:Je("div",{className:"courier-pl-2",children:Je(Jn,{color:"#A3A3A3"})})}),yr(il,{ref:o,children:[Je(al,{children:Je(t4,{children:"Are you sure you want to delete this channel?"})}),yr(sl,{children:[Je(cl,{asChild:!0,children:Je(Ce,{buttonSize:"small",variant:"outline",children:"Cancel"})}),Je(ll,{asChild:!0,children:Je(Ce,{buttonSize:"small",variant:"primary",onClick:()=>E(w.value),children:"Delete"})})]})]})]})]},w.value))})}),v.length>0&&yr(a4,{children:[Je(gl,{orientation:"vertical",className:"!courier-h-5"}),yr(Yi,{children:[Je(Xi,{asChild:!0,children:Je(Ce,{variant:"link",children:"+ Add channel"})}),Je(Wn,{portalProps:{container:o.current},children:v.map(w=>yr(_n,{onClick:()=>A(w.value),children:[w.icon,w.label]},w.value))})]})]})]}),yr("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&Je(ai,{isLoading:!!i,isSaving:!!n,isError:!!a}),!e&&i!==null&&Je(Ce,{variant:"primary",buttonSize:"small",disabled:c===!0||n===!0||u!==null,onClick:g,children:c?"Publishing...":"Publish changes"})]})]})},"Channels");import{useCallback as _1,useEffect as z1,useRef as ro,useState as s4}from"react";function Di({onSave:e,debounceMs:t=2e3,enabled:r=!0,onError:o,initialContent:n,flushBeforeSave:i}){let[a,l]=s4(!1),c=ro(!1),u=ro(null),d=ro(),m=ro(0),p=ro();z1(()=>{n&&(d.current=JSON.stringify(n))},[n]);let f=_1(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=ro(r),h=ro(t),b=ro(f);return z1(()=>{v.current=r,h.current=t,b.current=f}),{handleAutoSave:_1(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 k=h.current;p.current=setTimeout(()=>{p.current=void 0,b.current()},k)},[]),isSaving:a}}s(Di,"useAutoSave");import{useAtom as Vi,useAtomValue as Dr,useSetAtom as Su}from"jotai";import{memo as R4,useCallback as Iu,useEffect as Lt,useRef as Vs,useState as H4}from"react";import{useAtom as X1,useAtomValue as Au,useSetAtom as Q1}from"jotai";import{forwardRef as S4,memo as I4,useCallback as eg,useEffect as Pn,useRef as tg}from"react";import{z as xt}from"zod";var $1=xt.object({headerStyle:xt.enum(["plain","border"]),isUnsubscribe:xt.boolean().optional(),isPreferences:xt.boolean().optional(),link:xt.string().optional(),brandColor:xt.string(),textColor:xt.string(),subtleColor:xt.string(),logo:xt.string().optional(),facebookLink:xt.string().optional(),linkedinLink:xt.string().optional(),instagramLink:xt.string().optional(),mediumLink:xt.string().optional(),xLink:xt.string().optional()}),ct={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};var l4=s(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),Fi=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(l4).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`
|
|
201
201
|
`;case"paragraph":return(((i=e.content)==null?void 0:i.map(Fi).join(""))||"")+`
|
|
202
202
|
|
|
203
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(Fi).join(""))||"";return b+y+`
|
|
@@ -214,7 +214,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
214
214
|
|
|
215
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})
|
|
216
216
|
|
|
217
|
-
`}default:return((v=e.content)==null?void 0:v.map(Fi).join(""))||""}},"convertNodeToMarkdown");function Fs(e){return e.content?e.content.map(Fi).join("").trim():""}s(Fs,"convertTiptapToMarkdown");import{useAtom as Y1,useAtomValue as wn,useSetAtom as k4}from"jotai";import{forwardRef as P4,memo as N4,useCallback as Vs}from"react";import{forwardRef as c4}from"react";import{jsx as u4}from"react/jsx-runtime";var q1=c4(({children:e},t)=>u4("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}));import{useCallback as oo,useRef as d4,useState as m4}from"react";import{jsx as Nu,jsxs as f4}from"react/jsx-runtime";var p4=["image/png","image/jpeg","image/gif","image/webp"],J1=s(({onFileSelect:e})=>{let[t,r]=m4(!1),o=d4(null),n=oo(p=>p4.includes(p),[]),i=oo(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=oo(p=>{p.preventDefault(),p.stopPropagation(),r(!1)},[]),l=oo(p=>{p.preventDefault(),p.stopPropagation(),p.dataTransfer.types.includes("Files")&&Array.from(p.dataTransfer.items).some(h=>n(h.type))&&r(!0)},[n]),c=oo(async p=>{try{let{dataUrl:f}=await ji(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=oo(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=oo(p=>{var v;let f=(v=p.target.files)==null?void 0:v[0];f&&c(f)},[c]),m=oo(p=>{var f;p.preventDefault(),p.stopPropagation(),(f=o.current)==null||f.click()},[]);return f4("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:[Nu("span",{className:"courier-text-sm courier-pointer-events-none",children:"Drag and drop logo, or"}),Nu("button",{className:"courier-underline courier-font-medium courier-text-sm",onClick:m,type:"button",children:"Browse"}),Nu("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:d},"logo-input")]})},"LogoUploader");import{zodResolver as g4}from"@hookform/resolvers/zod";import{useAtom as h4,useAtomValue as b4,useSetAtom as y4}from"jotai";import{ArrowUp as C4}from"lucide-react";import{memo as v4,useCallback as j1,useEffect as x4,useRef as T4}from"react";import{useForm as E4}from"react-hook-form";import{jsx as $,jsxs as Tt}from"react/jsx-runtime";var G1=s(({isActive:e,onClick:t,value:r})=>$("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:$("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"&&$("div",{className:"courier-w-full courier-bg-[#000000] courier-h-1"})})}),"HeaderStyle"),w4=s(()=>{let[e,t]=h4(ar),r=y4(Jt),o=b4(_o),n=T4(null),i=E4({resolver:g4(Z1),defaultValues:{...ct,...e},mode:"onChange"});x4(()=>{e&&i.reset(e)},[e,i]);let a=j1(()=>{t(i.getValues())},[i,t]),l=j1(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(Fs(o.getJSON()))}},[o,r]);return $(Ne,{...i,children:$("form",{onChange:()=>a(),children:Tt("div",{className:"courier-pb-6",children:[$("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Header style"}),$(J,{control:i.control,name:"headerStyle",render:({field:c})=>Tt(Z,{className:"courier-mb-4",children:[$(q,{children:Tt("div",{className:"courier-w-full courier-flex courier-flex-row courier-gap-3",children:[$(G1,{isActive:c.value==="plain",onClick:()=>{c.onChange("plain"),t({...i.getValues(),headerStyle:"plain"})},value:"plain"}),$(G1,{isActive:c.value==="border",onClick:()=>{c.onChange("border"),t({...i.getValues(),headerStyle:"border"})},value:"border"})]})}),$(j,{})]})}),$(le,{className:"courier-mb-4"}),$("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Logo"}),Tt("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[i.getValues().logo?$(Ce,{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"}):Tt(Ce,{onClick:c=>{c.preventDefault(),n.current&&(n.current.value="",n.current.click())},className:"courier-w-full",variant:"outline",type:"button",children:[$(C4,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-mr-2 courier-text-foreground"}),"Upload logo"]}),$("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 ji(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="")}})]}),$(J,{control:i.control,name:"link",render:({field:c})=>Tt(Z,{className:"courier-mb-3",children:[$(q,{children:$(Kr,{as:"Textarea",placeholder:"Link",...c,onChange:u=>{c.onChange(u),a()}})}),$(j,{})]})}),$(le,{className:"courier-mb-4"}),$("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Brand color"}),$(J,{control:i.control,name:"brandColor",render:({field:c})=>Tt(Z,{className:"courier-mb-4",children:[$(q,{children:$(Ze,{...c,defaultValue:c.value,onChange:u=>{c.onChange(u),a()}})}),$(j,{})]})}),$(le,{className:"courier-mb-4"}),$("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer links"}),Tt("div",{className:"courier-flex courier-flex-col courier-gap-3 courier-mb-3",children:[$(J,{control:i.control,name:"facebookLink",render:({field:c})=>Tt(Z,{children:[$(q,{children:$(pe,{startAdornment:$(Kn,{}),placeholder:"facebook.com/username",...c,autoFocus:!0})}),$(j,{})]})}),$(J,{control:i.control,name:"linkedinLink",render:({field:c})=>Tt(Z,{children:[$(q,{children:$(pe,{startAdornment:$(Qn,{}),placeholder:"linkedin.com/username",...c})}),$(j,{})]})}),$(J,{control:i.control,name:"instagramLink",render:({field:c})=>Tt(Z,{children:[$(q,{children:$(pe,{startAdornment:$(Xn,{}),placeholder:"instagram.com/username",...c})}),$(j,{})]})}),$(J,{control:i.control,name:"mediumLink",render:({field:c})=>Tt(Z,{children:[$(q,{children:$(pe,{startAdornment:$(ei,{}),placeholder:"medium.com/username",...c})}),$(j,{})]})}),$(J,{control:i.control,name:"xLink",render:({field:c})=>Tt(Z,{children:[$(q,{children:$(pe,{startAdornment:$(ii,{}),placeholder:"x.com/username",...c})}),$(j,{})]})})]}),$(le,{className:"courier-mb-4"}),$("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer actions"}),$(J,{control:i.control,name:"isPreferences",render:({field:c})=>Tt(Z,{className:"courier-flex courier-flex-row courier-items-center courier-gap-2 courier-mb-4",children:[$(q,{children:$(zo,{checked:c.value,onCheckedChange:u=>{i.setValue("isPreferences",u),c.onChange(u),l(u);let d={...i.getValues(),isPreferences:u};t(d)}})}),$(rr,{className:"!courier-m-0",children:"Manage Preferences"}),$(j,{})]})})]})})})},"SideBarComponent"),K1=v4(w4);import{Fragment as A4,jsx as nt,jsxs as kn}from"react/jsx-runtime";var M4=P4(({hidePublish:e=!1,templateEditor:t,variables:r},o)=>{var P,M,T,R,E,C,x,w;let n=k4(jo),{publishBrand:i}=Fn(),a=wn(Fe),l=wn(mt),c=wn(Ge),u=wn(ae),d=wn(Q),m=wn(_o),[p,f]=Y1(ar),[v,h]=Y1(Jt),b=Vs(()=>{i()},[i]),y=Vs(({editor:A})=>{h(Fs(A.getJSON()))},[h]),N=Vs(A=>{f(k=>k?{...k,logo:A}:{...ct,logo:A})},[f]),g=Vs(()=>{n("template")},[n]);return kn(A4,{children:[nt("div",{className:"courier-z-30 courier-w-full courier-h-12",children:kn(q1,{children:[nt("div",{className:"courier-text-sm courier-font-medium",children:"Brand theme"}),kn("div",{className:"courier-flex courier-gap-2 courier-items-center",children:[c!==null&&nt(ai,{isLoading:!!u,isSaving:!!c,isError:!!d}),t&&nt(Ce,{variant:"outline",buttonSize:"small",onClick:g,disabled:l===!0||c===!0,children:"Back"}),!e&&u!==null&&nt(Ce,{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"})]})]})}),kn("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[nt("div",{className:"courier-flex courier-flex-col courier-flex-1",children:kn("div",{className:"courier-editor-container",ref:o,children:[nt("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Header"}),kn("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"&&nt("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:p.brandColor}}),p!=null&&p.logo?nt("img",{src:p.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"}):nt(J1,{onFileSelect:N})]}),nt("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Footer"}),nt("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:nt(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})})]})}),nt("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:nt("div",{className:"courier-p-4 courier-h-full",children:m&&nt(K1,{})})})]})]})}),X1=N4(M4);import{jsx as og}from"react/jsx-runtime";var L4=S4(({hidePublish:e=!1,autoSaveDebounce:t=500,autoSave:r=!0,theme:o,colorScheme:n,...i},a)=>{let l=Au(ae),c=rg(!0),u=Au(je),{getTemplate:d,saveBrand:m}=Fn(),[p,f]=Q1(Fe),v=eg(Jt),h=Au(Jt),[b,y]=Q1(ar),N=rg(!1),g=eg(Q);Pn(()=>{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=tg(async R=>{await m(R)},[m]),M=tg(()=>{g(vr("Error saving theme"))},[g]),{handleAutoSave:T}=Di({onSave:P,enabled:l!==null&&r&&h!==null,debounceMs:t,onError:M});return Pn(()=>{!u||l||p&&l===!1||d()},[u,d,l,p]),Pn(()=>{h&&setTimeout(()=>{N.current=!0},500)},[h]),Pn(()=>{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]),Pn(()=>{l||(c.current=!1)},[l]),Pn(()=>{var R,E,C,x,w,A,k,L,S,H,V,F,O,B,W,U,ie,ee,K,D,z,oe,be,Pe,Me,Et,wt,se,Ee,ye,it,at,Ot,Ut,Wt,_t,Fr,Vr;if(!b){let te=(C=(E=(R=p==null?void 0:p.data)==null?void 0:R.tenant)==null?void 0:E.brand)==null?void 0:C.settings,Cr=(k=h==null?void 0:h.split(`
|
|
218
|
-
`))!=null?
|
|
219
|
-
`),no=Cr==null?void 0:Cr.find(io=>io.includes("{{urls.preferences}}"));y({brandColor:((
|
|
217
|
+
`}default:return((v=e.content)==null?void 0:v.map(Fi).join(""))||""}},"convertNodeToMarkdown");function Ds(e){return e.content?e.content.map(Fi).join("").trim():""}s(Ds,"convertTiptapToMarkdown");import{useAtom as K1,useAtomValue as wn,useSetAtom as k4}from"jotai";import{forwardRef as P4,memo as N4,useCallback as Fs}from"react";import{forwardRef as c4}from"react";import{jsx as u4}from"react/jsx-runtime";var Z1=c4(({children:e},t)=>u4("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}));import{useCallback as oo,useRef as d4,useState as m4}from"react";import{jsx as Nu,jsxs as f4}from"react/jsx-runtime";var p4=["image/png","image/jpeg","image/gif","image/webp"],q1=s(({onFileSelect:e})=>{let[t,r]=m4(!1),o=d4(null),n=oo(p=>p4.includes(p),[]),i=oo(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=oo(p=>{p.preventDefault(),p.stopPropagation(),r(!1)},[]),l=oo(p=>{p.preventDefault(),p.stopPropagation(),p.dataTransfer.types.includes("Files")&&Array.from(p.dataTransfer.items).some(h=>n(h.type))&&r(!0)},[n]),c=oo(async p=>{try{let{dataUrl:f}=await ji(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=oo(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=oo(p=>{var v;let f=(v=p.target.files)==null?void 0:v[0];f&&c(f)},[c]),m=oo(p=>{var f;p.preventDefault(),p.stopPropagation(),(f=o.current)==null||f.click()},[]);return f4("div",{className:S("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:[Nu("span",{className:"courier-text-sm courier-pointer-events-none",children:"Drag and drop logo, or"}),Nu("button",{className:"courier-underline courier-font-medium courier-text-sm",onClick:m,type:"button",children:"Browse"}),Nu("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:d},"logo-input")]})},"LogoUploader");import{zodResolver as g4}from"@hookform/resolvers/zod";import{useAtom as h4,useAtomValue as b4,useSetAtom as y4}from"jotai";import{ArrowUp as C4}from"lucide-react";import{memo as v4,useCallback as J1,useEffect as x4,useRef as T4}from"react";import{useForm as E4}from"react-hook-form";import{jsx as $,jsxs as Tt}from"react/jsx-runtime";var j1=s(({isActive:e,onClick:t,value:r})=>$("div",{className:S("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:$("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"&&$("div",{className:"courier-w-full courier-bg-[#000000] courier-h-1"})})}),"HeaderStyle"),w4=s(()=>{let[e,t]=h4(ar),r=y4(Jt),o=b4(_o),n=T4(null),i=E4({resolver:g4($1),defaultValues:{...ct,...e},mode:"onChange"});x4(()=>{e&&i.reset(e)},[e,i]);let a=J1(()=>{t(i.getValues())},[i,t]),l=J1(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(Ds(o.getJSON()))}},[o,r]);return $(Ne,{...i,children:$("form",{onChange:()=>a(),children:Tt("div",{className:"courier-pb-6",children:[$("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Header style"}),$(J,{control:i.control,name:"headerStyle",render:({field:c})=>Tt(Z,{className:"courier-mb-4",children:[$(q,{children:Tt("div",{className:"courier-w-full courier-flex courier-flex-row courier-gap-3",children:[$(j1,{isActive:c.value==="plain",onClick:()=>{c.onChange("plain"),t({...i.getValues(),headerStyle:"plain"})},value:"plain"}),$(j1,{isActive:c.value==="border",onClick:()=>{c.onChange("border"),t({...i.getValues(),headerStyle:"border"})},value:"border"})]})}),$(j,{})]})}),$(le,{className:"courier-mb-4"}),$("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Logo"}),Tt("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[i.getValues().logo?$(Ce,{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"}):Tt(Ce,{onClick:c=>{c.preventDefault(),n.current&&(n.current.value="",n.current.click())},className:"courier-w-full",variant:"outline",type:"button",children:[$(C4,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-mr-2 courier-text-foreground"}),"Upload logo"]}),$("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 ji(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="")}})]}),$(J,{control:i.control,name:"link",render:({field:c})=>Tt(Z,{className:"courier-mb-3",children:[$(q,{children:$(Kr,{as:"Textarea",placeholder:"Link",...c,onChange:u=>{c.onChange(u),a()}})}),$(j,{})]})}),$(le,{className:"courier-mb-4"}),$("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Brand color"}),$(J,{control:i.control,name:"brandColor",render:({field:c})=>Tt(Z,{className:"courier-mb-4",children:[$(q,{children:$(Ze,{...c,defaultValue:c.value,onChange:u=>{c.onChange(u),a()}})}),$(j,{})]})}),$(le,{className:"courier-mb-4"}),$("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer links"}),Tt("div",{className:"courier-flex courier-flex-col courier-gap-3 courier-mb-3",children:[$(J,{control:i.control,name:"facebookLink",render:({field:c})=>Tt(Z,{children:[$(q,{children:$(pe,{startAdornment:$(Kn,{}),placeholder:"facebook.com/username",...c,autoFocus:!0})}),$(j,{})]})}),$(J,{control:i.control,name:"linkedinLink",render:({field:c})=>Tt(Z,{children:[$(q,{children:$(pe,{startAdornment:$(Qn,{}),placeholder:"linkedin.com/username",...c})}),$(j,{})]})}),$(J,{control:i.control,name:"instagramLink",render:({field:c})=>Tt(Z,{children:[$(q,{children:$(pe,{startAdornment:$(Xn,{}),placeholder:"instagram.com/username",...c})}),$(j,{})]})}),$(J,{control:i.control,name:"mediumLink",render:({field:c})=>Tt(Z,{children:[$(q,{children:$(pe,{startAdornment:$(ei,{}),placeholder:"medium.com/username",...c})}),$(j,{})]})}),$(J,{control:i.control,name:"xLink",render:({field:c})=>Tt(Z,{children:[$(q,{children:$(pe,{startAdornment:$(ii,{}),placeholder:"x.com/username",...c})}),$(j,{})]})})]}),$(le,{className:"courier-mb-4"}),$("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer actions"}),$(J,{control:i.control,name:"isPreferences",render:({field:c})=>Tt(Z,{className:"courier-flex courier-flex-row courier-items-center courier-gap-2 courier-mb-4",children:[$(q,{children:$(zo,{checked:c.value,onCheckedChange:u=>{i.setValue("isPreferences",u),c.onChange(u),l(u);let d={...i.getValues(),isPreferences:u};t(d)}})}),$(rr,{className:"!courier-m-0",children:"Manage Preferences"}),$(j,{})]})})]})})})},"SideBarComponent"),G1=v4(w4);import{Fragment as A4,jsx as nt,jsxs as kn}from"react/jsx-runtime";var M4=P4(({hidePublish:e=!1,templateEditor:t,variables:r},o)=>{var k,A,E,L,w,C,T,x;let n=k4(jo),{publishBrand:i}=Fn(),a=wn(Fe),l=wn(mt),c=wn(Ge),u=wn(ae),d=wn(Q),m=wn(_o),[p,f]=K1(ar),[v,h]=K1(Jt),b=Fs(()=>{i()},[i]),y=Fs(({editor:P})=>{h(Ds(P.getJSON()))},[h]),N=Fs(P=>{f(M=>M?{...M,logo:P}:{...ct,logo:P})},[f]),g=Fs(()=>{n("template")},[n]);return kn(A4,{children:[nt("div",{className:"courier-z-30 courier-w-full courier-h-12",children:kn(Z1,{children:[nt("div",{className:"courier-text-sm courier-font-medium",children:"Brand theme"}),kn("div",{className:"courier-flex courier-gap-2 courier-items-center",children:[c!==null&&nt(ai,{isLoading:!!u,isSaving:!!c,isError:!!d}),t&&nt(Ce,{variant:"outline",buttonSize:"small",onClick:g,disabled:l===!0||c===!0,children:"Back"}),!e&&u!==null&&nt(Ce,{variant:"primary",buttonSize:"small",disabled:!((A=(k=a==null?void 0:a.data)==null?void 0:k.tenant)!=null&&A.brand)||l===!0||c!==!1,onClick:b,children:l?"Publishing...":"Publish changes"})]})]})}),kn("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[nt("div",{className:"courier-flex courier-flex-col courier-flex-1",children:kn("div",{className:"courier-editor-container",ref:o,children:[nt("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Header"}),kn("div",{className:S("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"&&nt("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:p.brandColor}}),p!=null&&p.logo?nt("img",{src:p.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"}):nt(q1,{onFileSelect:N})]}),nt("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Footer"}),nt("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:nt(ki,{value:v!=null?v:(x=(T=(C=(w=(L=(E=a==null?void 0:a.data)==null?void 0:E.tenant)==null?void 0:L.brand)==null?void 0:w.settings)==null?void 0:C.email)==null?void 0:T.footer)==null?void 0:x.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})})]})}),nt("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:nt("div",{className:"courier-p-4 courier-h-full",children:m&&nt(G1,{})})})]})]})}),Y1=N4(M4);import{jsx as rg}from"react/jsx-runtime";var L4=S4(({hidePublish:e=!1,autoSaveDebounce:t=500,autoSave:r=!0,theme:o,colorScheme:n,...i},a)=>{let l=Au(ae),c=tg(!0),u=Au(je),{getTemplate:d,saveBrand:m}=Fn(),[p,f]=X1(Fe),v=Q1(Jt),h=Au(Jt),[b,y]=X1(ar),N=tg(!1),g=Q1(Q);Pn(()=>{var L,w;p&&u!==((w=(L=p==null?void 0:p.data)==null?void 0:L.tenant)==null?void 0:w.tenantId)&&(f(null),v(null),c.current=!1)},[p,u,f,v]);let k=eg(async L=>{await m(L)},[m]),A=eg(()=>{g(vr("Error saving theme"))},[g]),{handleAutoSave:E}=Di({onSave:k,enabled:l!==null&&r&&h!==null,debounceMs:t,onError:A});return Pn(()=>{!u||l||p&&l===!1||d()},[u,d,l,p]),Pn(()=>{h&&setTimeout(()=>{N.current=!0},500)},[h]),Pn(()=>{if(!N.current||!b)return;let L={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}}}}};E(L)},[b,h,E]),Pn(()=>{l||(c.current=!1)},[l]),Pn(()=>{var L,w,C,T,x,P,M,R,I,H,V,F,O,B,W,U,ie,ee,K,D,z,oe,be,Pe,Me,Et,wt,se,Ee,ye,it,at,Ot,Ut,Wt,_t,Fr,Vr;if(!b){let te=(C=(w=(L=p==null?void 0:p.data)==null?void 0:L.tenant)==null?void 0:w.brand)==null?void 0:C.settings,Cr=(M=h==null?void 0:h.split(`
|
|
218
|
+
`))!=null?M:(P=(x=(T=te==null?void 0:te.email)==null?void 0:T.footer)==null?void 0:x.markdown)==null?void 0:P.split(`
|
|
219
|
+
`),no=Cr==null?void 0:Cr.find(io=>io.includes("{{urls.preferences}}"));y({brandColor:((R=te==null?void 0:te.colors)==null?void 0:R.primary)||ct.brandColor,textColor:((I=te==null?void 0:te.colors)==null?void 0:I.secondary)||ct.textColor,subtleColor:((H=te==null?void 0:te.colors)==null?void 0:H.tertiary)||ct.subtleColor,headerStyle:(F=(V=te==null?void 0:te.email)==null?void 0:V.header)!=null&&F.barColor?"border":"plain",logo:((W=(B=(O=te==null?void 0:te.email)==null?void 0:O.header)==null?void 0:B.logo)==null?void 0:W.image)||ct.logo,link:((ee=(ie=(U=te==null?void 0:te.email)==null?void 0:U.header)==null?void 0:ie.logo)==null?void 0:ee.href)||ct.link,facebookLink:((oe=(z=(D=(K=te==null?void 0:te.email)==null?void 0:K.footer)==null?void 0:D.social)==null?void 0:z.facebook)==null?void 0:oe.url)||ct.facebookLink,linkedinLink:((Et=(Me=(Pe=(be=te==null?void 0:te.email)==null?void 0:be.footer)==null?void 0:Pe.social)==null?void 0:Me.linkedin)==null?void 0:Et.url)||ct.linkedinLink,instagramLink:((ye=(Ee=(se=(wt=te==null?void 0:te.email)==null?void 0:wt.footer)==null?void 0:se.social)==null?void 0:Ee.instagram)==null?void 0:ye.url)||ct.instagramLink,mediumLink:((Ut=(Ot=(at=(it=te==null?void 0:te.email)==null?void 0:it.footer)==null?void 0:at.social)==null?void 0:Ot.medium)==null?void 0:Ut.url)||ct.mediumLink,xLink:((Vr=(Fr=(_t=(Wt=te==null?void 0:te.email)==null?void 0:Wt.footer)==null?void 0:_t.social)==null?void 0:Fr.twitter)==null?void 0:Vr.url)||ct.xLink,isPreferences:!!no})}},[p,y,h,b]),rg(ht,{theme:o,colorScheme:n,isLoading:!!(l&&c.current),children:rg(Y1,{ref:a,hidePublish:e,...i})})}),og=I4(L4);import{jsx as Oo}from"react/jsx-runtime";var ng=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"),B4=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}=Hn(),v=Dr(ae),h=Dr(mt),b=Dr(Q),[y,N]=Vi(Fe),g=Dr(er),k=Dr(je),[A,E]=Vi(ao),{getTemplate:L,saveTemplate:w,setTemplateError:C}=Vn(),T=Dr(jo),x=Vs(!1),[P,M]=Vi(X),[R,I]=Vi(ze);Lt(()=>{typeof window!="undefined"&&window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.templateEditorContent=P)},[P]);let H=Su(Jt),V=Su(ar),[F,O]=Vi(Ur),B=Su(ae),W=ng(d,u),[U,ie]=H4(W),ee=Vs(JSON.stringify(W));Lt(()=>{let se=ng(d,u),Ee=JSON.stringify(se);Ee!==ee.current&&(ie(se),ee.current=Ee,se.length&&!se.includes(F)&&O(se[0]))},[d,u,F,O]),Lt(()=>{var Ee;if(v||!(P!=null&&P.elements))return;let se=P.elements.filter(ye=>ye.type==="channel").map(ye=>ye.channel);if(!se.includes(F)){let ye=(Ee=d==null?void 0:d.channels)==null?void 0:Ee.find(it=>se.includes(it));!ye&&se.length>0&&(ye=se[0]),ye&&O(ye)}},[P,F,O,d==null?void 0:d.channels,v]),Lt(()=>{var Ee;let se=(Ee=y==null?void 0:y.data)==null?void 0:Ee.tenant;g&&se&&!(se!=null&&se.notification)&&v===!1&&(U!=null&&U.length)&&O(U[0])},[g,y,v,U,O]);let K=Vs(null);Lt(()=>{K.current&&(K.current.templateId!==g||K.current.tenantId!==k)&&g&&k&&(I(!0),x.current=!1,N(null),M(null),H(null),V(null),E(null),O((U==null?void 0:U[0])||"email"),B(null)),g&&k&&(K.current={templateId:g,tenantId:k})},[g,k,U,I,N,M,H,V,E,O,B]);let D=Vs(d);Lt(()=>{D.current=d},[d]);let z=Iu(async se=>{let Ee=se==null?void 0:se._capturedTemplateId,ye=f.get(er);if(Ee&&Ee!==ye)return;let{_capturedTemplateId:it,...at}=se;await w({routing:D.current,content:at})},[w,f]),oe=Iu(()=>{C("Error saving template")},[C]),be=Dr(lo),Pe=Iu(()=>{Uu(be)},[be]),{handleAutoSave:Me}=Di({onSave:z,debounceMs:a,enabled:v===!1&&i,onError:oe,flushBeforeSave:Pe});Lt(()=>{!g||!k||v||y&&v===!1||b||L({includeBrand:l})},[g,k,l,L,v,y,b]),Lt(()=>{if(!(!t||i&&v!==!1)&&JSON.stringify(me(Se(P)))!==JSON.stringify(me(Se(t))))if(M(t),!i)B(!1);else{let se={...t,_capturedTemplateId:g};Me(se)}},[i,t,P,M,B,Me,g,v]),Lt(()=>{var ye,it,at,Ot,Ut,Wt,_t;if(v!==!1)return;let se=(at=(it=(ye=y==null?void 0:y.data)==null?void 0:ye.tenant)==null?void 0:it.notification)==null?void 0:at.notificationId;if(y&&se&&se!==g)return;let Ee=t||((_t=(Wt=(Ut=(Ot=y==null?void 0:y.data)==null?void 0:Ot.tenant)==null?void 0:Ut.notification)==null?void 0:Wt.data)==null?void 0:_t.content);M(Ee),setTimeout(()=>{I(!1)},100)},[y,M,v,I,g,t]),Lt(()=>{h===!0&&(x.current=!1)},[h]),Lt(()=>{!P||v!==!1||setTimeout(()=>{x.current=!0},1e3)},[P,F,v]),Lt(()=>{x.current=!1},[F]);let Et=Dr(Ae),wt=Dr(Ou);if(Lt(()=>{let se=!!Et&&v===!1&&!R,Ee=x.current&&!!P&&v===!1&&!R;if(!se&&!Ee)return;let ye=Et||P;if(!ye||JSON.stringify(ye)===wt)return;let at={...ye,_capturedTemplateId:g};r&&(x.current=!1,r(P||ye)),Me(at)},[P,Et,Me,v,R,g,r,wt]),l&&T==="brand")return Oo(og,{hidePublish:n,autoSave:i,templateEditor:!0,variables:o,theme:e,colorScheme:m,...c});if(T==="template"&&F==="email")return Oo(jf,{variables:o,theme:e,colorScheme:m,isLoading:!!v,hidePublish:n,channels:U,brandEditor:l,routing:d,...p});if(T==="template"&&F==="sms")return Oo(N1,{colorScheme:m,variables:o,theme:e,hidePublish:n,channels:U,routing:d,...p});if(T==="template"&&F==="push")return Oo(l1,{variables:o,theme:e,colorScheme:m,hidePublish:n,channels:U,routing:d,...p});if(T==="template"&&F==="inbox")return Oo(r1,{variables:o,theme:e,colorScheme:m,hidePublish:n,channels:U,routing:d,...p});if(T==="template"&&F==="slack")return Oo(x1,{theme:e,colorScheme:m,hidePublish:n,channels:U,routing:d,variables:o,...p});if(T==="template"&&F==="msteams")return Oo(D1,{theme:e,colorScheme:m,hidePublish:n,channels:U,routing:d,variables:o,...p})},"TemplateEditorComponent"),EJ=R4(B4);var MJ=hs,AJ=Rs,SJ=Ns,IJ=ws,LJ=Hs,RJ=Ss;export{og as BrandEditor,ki as BrandFooter,yg as BrandProvider,go as CHANNELS,Lo as ChannelRootContainer,Ro as EditorSidebar,MJ as EmailChannel,qc as EmailEditor,qf as EmailEditorContainer,Jf as EmailEditorMain,jc as EmailSideBar,Gc as EmailSideBarItemDetails,el as ErrorBoundary,IJ as InboxChannel,Xc as InboxEditor,ou as InboxSideBar,LJ as MSTeamsChannel,xu as MSTeamsEditor,Eu as MSTeamsSideBar,gc as MonacoCodeEditor,Zc as PreviewPanel,SJ as PushChannel,su as PushEditor,AJ as SMSChannel,bu as SMSEditor,RJ as SlackChannel,uu as SlackEditor,mu as SlackSideBar,fu as SlackSideBarItemDetails,EJ as TemplateEditor,Sg as TemplateProvider,ai as TemplateStatus,_c as TextMenu,qt as ToggleGroup,Ci as VariableInput,lr as VariableTextarea,ut as apiUrlAtom,Lu as brandApplyAtom,S as cn,Se as convertElementalToTiptap,Wi as convertLegacyError,me as convertTiptapToElemental,vr as createCustomError,Q4 as extractErrorMessage,Ca as getFlattenedVariables,X4 as isRetryableError,ae as isTemplateLoadingAtom,mt as isTemplatePublishingAtom,Ge as isTemplateSavingAtom,Fe as templateDataAtom,Q as templateErrorAtom,er as templateIdAtom,je as tenantIdAtom,dt as tokenAtom,Di as useAutoSave,Fn as useBrandActions,Pu as useChannels,eu as useDebouncedFlush,On as useImageUpload,Xe as useNodeAttributes,Vn as useTemplateActions,Hn as useTemplateStore,fN as useVariables};
|
|
220
220
|
//# sourceMappingURL=index.js.map
|