@trycourier/react-designer 0.0.0-canary-20251210153829 → 0.0.0-canary-20251211163746

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/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 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:`
46
+ var ig=Object.create;var Vs=Object.defineProperty;var ag=Object.getOwnPropertyDescriptor;var sg=Object.getOwnPropertyNames;var lg=Object.getPrototypeOf,cg=Object.prototype.hasOwnProperty;var s=(e,t)=>Vs(e,"name",{value:t,configurable:!0});var Os=(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&&Vs(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?Vs(r,"default",{value:e,enumerable:!0}):r,e));var zl=Os(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=Os(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=zl();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=Os(Yo=>{"use strict";Object.defineProperty(Yo,"__esModule",{value:!0});Yo.bindAll=Yo.bind=void 0;var o2=zl();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 Us,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 Ws}from"react/jsx-runtime";var hg=s(({children:e,tenantId:t,token:r,apiUrl:o})=>{let[,n]=Us(ut),[,i]=Us(dt),[,a]=Us(je);return pg(()=>{i(r),a(t),o&&n(o)},[r,t,o,n,i,a]),Ws(Cg,{children:e})},"BrandProviderContext"),bg=s(e=>{let t=gg(()=>mg(),[]);return Ws(dg,{store:t,children:Ws(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 _s}from"react/jsx-runtime";var Hn=s(()=>({store:Tg()}),"useTemplateStore"),Hu=Eg(null),Du=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]),_s(Hu.Provider,{value:i||null,children:e})},"TemplateProviderContext"),Ag=s(e=>{let t=Pg(()=>xg(),[]);return _s(vg,{store:t,children:_s(Mg,{...e})})},"TemplateProviderComponent"),Sg=wg(Ag);import{useAtom as Bn,useSetAtom as qi}from"jotai";var vr=s((e,t)=>({message:e,toastProps:t}),"createCustomError"),Y4=s(e=>{var t;return((t=e.toastProps)==null?void 0:t.action)!==void 0},"isRetryableError"),X4=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 Bu}from"jotai";import{toast as Ig}from"sonner";var Fu=Bu(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 {
@@ -54,7 +54,7 @@ var ig=Object.create;var Os=Object.defineProperty;var ag=Object.getOwnPropertyDe
54
54
  }
55
55
  }
56
56
  `,variables:{input:{tenantId:i,settings:r}}})})).json();if(!c.data)if(c.errors){let u=(a=c.errors)==null?void 0:a.map(d=>d.message);t(Q,{message:u.join(`
57
- `),toastProps:{duration:4e3}})}else t(Q,{message:"Error saving brand settings",toastProps:{duration:4e3}});return c}catch(l){throw t(Q,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save brand settings"}}),l}finally{t(Ge,!1)}}),Vu=Du(null,async(e,t)=>{let r=e(ut),o=e(dt),n=e(je);if(!r){t(Q,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(mt,!0),t(Q,null);try{let i=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
57
+ `),toastProps:{duration:4e3}})}else t(Q,{message:"Error saving brand settings",toastProps:{duration:4e3}});return c}catch(l){throw t(Q,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save brand settings"}}),l}finally{t(Ge,!1)}}),Vu=Bu(null,async(e,t)=>{let r=e(ut),o=e(dt),n=e(je);if(!r){t(Q,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(mt,!0),t(Q,null);try{let i=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
58
58
  mutation PublishNotification($input: PublishBrandInput!) {
59
59
  tenant {
60
60
  brand {
@@ -64,7 +64,7 @@ var ig=Object.create;var Os=Object.defineProperty;var ag=Object.getOwnPropertyDe
64
64
  }
65
65
  }
66
66
  }
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:`
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),$s=Ke(null),_i=Ke(null),X=Ke(e=>e(_i),(e,t,r)=>{if(!r){t(_i,r);return}let o=e($s),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),zs=Ke(new Map),lo=Ke(e=>e(zs),(e,t,r)=>{let o=new Map(e(zs));r.action==="register"&&r.fn?o.set(r.id,r.fn):r.action==="unregister"&&o.delete(r.id),t(zs,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,p,m;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
@@ -122,13 +122,13 @@ var ig=Object.create;var Os=Object.defineProperty;var ag=Object.getOwnPropertyDe
122
122
  }
123
123
  }
124
124
  }
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 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:`
125
+ `,variables:{tenantId:i,input:{notificationId:a,version:"latest"},brandInput:{version:"latest"},includeBrand:l}})}),x=await f.json(),h=f.status,b=(u=x.data)==null?void 0:u.tenant;if(b?(t(Fe,x),t(Uo,(d=b==null?void 0:b.notification)==null?void 0:d.publishedAt),t(Wo,(p=b==null?void 0:b.notification)==null?void 0:p.version)):h===401?t(Q,{message:"Authentication failed",toastProps:{duration:6e3}}):t(Q,{message:"Error fetching template data",toastProps:{duration:4e3}}),x.errors){let y=(m=x.errors)==null?void 0:m.map(P=>P.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 Hg}from"sonner";function Zs(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(Zs,"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:Zs(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(x=>x.type==="text"),u=l.filter(x=>x.type==="action"),d=c[0],p=d?{type:"text",content:"content"in d?d.content:`
128
128
  `}:{type:"text",content:`
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
- `&&("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:`
129
+ `},m=Zs(u);return{elements:[{type:"meta",title:a},p,...m]}}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 Dn(e,t){if(!e||e.type!=="channel")return"";if("raw"in e&&e.raw){if(t==="email"&&"subject"in e.raw&&e.raw.subject)return e.raw.subject;if("title"in e.raw&&e.raw.title)return e.raw.title}if("elements"in e&&e.elements){let r=e.elements.find(a=>a.type==="meta");if(r&&"title"in r&&typeof r.title=="string")return r.title;if(t==="email")return"";let o="",n="";for(let a of e.elements)if(a.type==="text"&&"content"in a&&a.content){let l=a.content.trim();l&&l!==`
131
+ `&&("text_style"in a&&(a.text_style==="h1"||a.text_style==="h2")?n||(n=l):o||(o=l))}let i=n||o;if(i)return i}return""}s(Dn,"extractCurrentTitle");var Zi=$u(null,async(e,t,r)=>{var m;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 p={content:d,routing:o};try{let x=await(await fetch(i,{method:"POST",headers:{Authorization:`Bearer ${a}`,"x-courier-client-key":`Bearer ${a}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
132
132
  mutation SaveNotification($input: SaveNotificationInput!) {
133
133
  tenant {
134
134
  notification {
@@ -141,8 +141,8 @@ var ig=Object.create;var Os=Object.defineProperty;var ag=Object.getOwnPropertyDe
141
141
  }
142
142
  }
143
143
  }
144
- `,variables:{input:{tenantId:l,notificationId:c,name:c,data:m}}})})).json();if(v.data)t(Wo,v.data.tenant.notification.save.version);else if(v.errors){let h=(p=v.errors)==null?void 0:p.map(b=>b.message);t(Q,{message:h.join(`
145
- `),toastProps:{duration:4e3}})}else t(Q,{message:"Error saving template",toastProps:{duration:4e3}});return v}catch(f){throw t(Q,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save template"}}),f}finally{t(Ge,!1)}}),Zu=$u(null,async(e,t)=>{let r=e(ut),o=e(dt),n=e(je),i=e(er),a=e(Wo);if(!a){t(Q,{message:"Version not defined",toastProps:{duration:5e3}});return}if(!r){t(Q,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(mt,!0),t(Q,null);try{let l=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
144
+ `,variables:{input:{tenantId:l,notificationId:c,name:c,data:p}}})})).json();if(x.data)t(Wo,x.data.tenant.notification.save.version);else if(x.errors){let h=(m=x.errors)==null?void 0:m.map(b=>b.message);t(Q,{message:h.join(`
145
+ `),toastProps:{duration:4e3}})}else t(Q,{message:"Error saving template",toastProps:{duration:4e3}});return x}catch(f){throw t(Q,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save template"}}),f}finally{t(Ge,!1)}}),Zu=$u(null,async(e,t)=>{let r=e(ut),o=e(dt),n=e(je),i=e(er),a=e(Wo);if(!a){t(Q,{message:"Version not defined",toastProps:{duration:5e3}});return}if(!r){t(Q,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(mt,!0),t(Q,null);try{let l=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
146
146
  mutation PublishNotification($input: PublishNotificationInput!) {
147
147
  tenant {
148
148
  notification {
@@ -154,7 +154,7 @@ var ig=Object.create;var Os=Object.defineProperty;var ag=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?(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:`
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]=Bn(ae),[a,l]=Bn(Ge),[c,u]=Bn(mt),[d,p]=Bn(Q),[m,f]=Bn(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=>{p(h===null?null:typeof h=="string"?vr(h):h)},"setTemplateError"),templateData:m,setTemplateData:f,createCustomError:vr,convertLegacyError:Wi}}s(Fn,"useBrandActions");import{useAtom as co,useSetAtom as qs}from"jotai";import{useCallback as Dg}from"react";function Vn(){let e=qs(zi),t=qs(Zi),r=qs(Zu),[o,n]=co(ae),[i,a]=co(Ge),[l,c]=co(mt),[u,d]=co(Q),[p,m]=co(Fe),[f,x]=co(X),[h,b]=co($s),y=Dg(P=>{d(P===null?null:typeof P=="string"?vr(P):P)},[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:p,setTemplateData:m,templateEditorContent:f,setTemplateEditorContent:x,createCustomError:vr,convertLegacyError:Wi,contentTransformer:h,setContentTransformer:b}}s(Vn,"useTemplateActions");import{useAtom as Ju}from"jotai";import{useCallback as Fg}from"react";var Bg=["image/png","image/jpeg","image/gif","image/webp"],qu=s(async(e,t)=>{var c,u,d;let{apiUrl:r,token:o}=t;if(!Bg.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((p,m)=>{let f=new FileReader;f.onload=()=>{typeof f.result=="string"?p(f.result):m(new Error("Failed to read file as data URL"))},f.onerror=()=>m(f.error),f.readAsDataURL(e)})).split(",")[1];try{let m=await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({query:`
158
158
  mutation UploadImage($input: UploadImageInput!) {
159
159
  tenant {
160
160
  notification {
@@ -164,40 +164,40 @@ var ig=Object.create;var Os=Object.defineProperty;var ag=Object.getOwnPropertyDe
164
164
  }
165
165
  }
166
166
  }
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: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||`
167
+ `,variables:{input:{name:i,type:e.type,data:l}}})})).json();if(m.errors)throw new Error(m.errors.map(x=>x.message).join(`
168
+ `));let f=m.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(p){throw console.error("Error uploading image:",p),p}},"uploadImage");function On(){let[e]=Ju(ut),[t]=Ju(dt),r=Du();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 p;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 m=.8,f=u.toDataURL(e.type||"image/jpeg",m),x=0,h=5;for(;f.length>512e3&&x<h;)x++,m-=.1,m<.3&&(m=.3),f=u.toDataURL(e.type||"image/jpeg",m);r({dataUrl:f,width:l,height:c})}else r({dataUrl:(p=n.target)==null?void 0:p.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,u;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 d of r){let p=new RegExp(d.regex.source,d.regex.flags),m;for(;(m=p.exec(e))!==null;)if(d.type==="variable"){let f=m[1].trim(),x=$e(f);o.push({start:m.index,end:m.index+m[0].length,text:m[1],type:"variable",attrs:{id:f,isInvalid:!x}})}else d.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:d.type})}o.sort((d,p)=>d.start-p.start);let n=[],i=0;for(let d of o)d.start>=i&&(n.push(d),i=d.end);let a=[],l=0;for(let d of n){if(d.start>l){let p=e.substring(l,d.start);p&&js(p,[],a)}if(d.type==="variable")a.push({type:"variable",attrs:{id:(c=d.attrs)==null?void 0:c.id,isInvalid:(u=d.attrs)==null?void 0:u.isInvalid}});else if(d.type==="link"){let p=[];Js(d.text,p),p.forEach(m=>{var f;m.marks=m.marks||[],m.marks.push({type:"link",attrs:{href:(f=d.attrs)==null?void 0:f.href}})}),a.push(...p)}else{let p=[];Js(d.text,p),p.forEach(m=>{m.marks=m.marks||[],m.marks.push({type:d.type})}),a.push(...p)}l=d.end}if(l<e.length){let d=e.substring(l);d&&js(d,[],a)}t.push(...a)}s(Js,"processMarkdownFormatting");function js(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 u=e.substring(i,n.index);u&&r.push({type:"text",text:u,...t.length>0&&{marks:t}})}let a=n[1].trim(),l=t.some(u=>u.type==="link"),c=a&&$e(a);r.push({type:"variable",attrs:{id:a,isInvalid:!c,...l&&{inUrlContext:!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(js,"parseTextWithVariables");function Se(e,t){var d,p,m,f,x,h,b,y,P;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 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+=`
171
+ `}],!o||o.length===0)return r;let l=s(g=>{var k,N,v,L,E,C,T,w,M;if(g.type==="meta")return[];switch(g.type){case"text":if("content"in g){let A=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),D=parseInt(F);!isNaN(O)&&!isNaN(D)&&(R={paddingVertical:O,paddingHorizontal:D})}let I={};if(g.border_size||(k=g.border)!=null&&k.enabled||(N=g.border)!=null&&N.size){let V=g.border_size||((v=g.border)==null?void 0:v.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:A?"heading":"paragraph",attrs:{textAlign:g.align||"left",level:A,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=[];js(I,[],H),H.length===0&&H.push({type:"text",text:I||"Button"});let V=(C=g.border_radius)!=null?C:(E=g.border)==null?void 0:E.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 A="paragraph",R;g.text_style==="h1"?(A="heading",R=1):g.text_style==="h2"?(A="heading",R=2):g.text_style==="subtext"&&(A="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:A,attrs:I,content:ju(g.content)}]}]}case"image":{let A={};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);A.width=Math.max(1,Math.min(100,F)),A.imageNaturalWidth=g.image_natural_width}else A.width=V,g.image_natural_width&&(A.imageNaturalWidth=g.image_natural_width)}let R=g.border_size||((w=g.border)==null?void 0:w.size),I=g.border_color||((M=g.border)==null?void 0:M.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},...A,...R&&{borderWidth:parseInt(R),...I&&{borderColor:I}},...g.locales&&{locales:g.locales}}}]}case"divider":{let A=g.border_width||g.width;return[{type:"divider",attrs:{id:`node-${Rt()}`,...g.color&&{color:g.color},...A&&{size:parseInt(A)},...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 A=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",D=`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:D,isEditorMode:!1},content:[]};let K;U.type==="group"&&U.elements?K=U.elements.flatMap(l):K=l(U);let B=K.length>0?K:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${Rt()}`},content:[]}];return{type:"columnCell",attrs:{index:ie,columnId:D,isEditorMode:K.length>0},content:B}}):[{type:"columnCell",attrs:{index:0,columnId:D,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${Rt()}`},content:[]}]},{type:"columnCell",attrs:{index:1,columnId:D,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${Rt()}`},content:[]}]}];return[{type:"column",attrs:{id:D,columnsCount:Math.min(Math.max(A,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],N=u[g+1];if(k.type==="button"&&(N==null?void 0:N.type)==="button"&&n==="inbox"){let v={type:"buttonRow",attrs:{id:`node-${Rt()}`,button1Label:((d=k.attrs)==null?void 0:d.label)||"Button 1",button1Link:((p=k.attrs)==null?void 0:p.link)||"",button1BackgroundColor:((m=k.attrs)==null?void 0:m.backgroundColor)||"#000000",button1TextColor:((f=k.attrs)==null?void 0:f.textColor)||"#ffffff",button2Label:((x=N.attrs)==null?void 0:x.label)||"Button 2",button2Link:((h=N.attrs)==null?void 0:h.link)||"",button2BackgroundColor:((b=N.attrs)==null?void 0:b.backgroundColor)||"#ffffff",button2TextColor:((y=N.attrs)==null?void 0:y.textColor)||"#000000",padding:((P=k.attrs)==null?void 0:P.padding)||6}};c.push(v),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 p=d[1].trim();$e(p)&&r.push({start:d.index,end:d.index+d[0].length,text:d[1],type:"variable",attrs:{id:p}})}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(p=>{var m;p.marks=p.marks||[],p.marks.push({type:"link",attrs:{href:(m=c.attrs)==null?void 0:m.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 Gs(e){return{type:"doc",content:Ug(e)}}s(Gs,"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,p,m,f,x,h,b,y,P,g,k,N,v,L,E,C,T,w,M,A,R,I,H,V,F,O,D,W,U,ie,ee,K,B,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
- `;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+=`
175
+ `;let de={};(d=r.attrs)!=null&&d.borderWidth&&(de.border_size=`${r.attrs.borderWidth}px`),(p=r.attrs)!=null&&p.borderColor&&(de.border_color=r.attrs.borderColor),de.text_style=((m=r.attrs)==null?void 0:m.level)===1?"h1":"h2",((f=r.attrs)==null?void 0:f.paddingVertical)!==void 0&&((x=r.attrs)==null?void 0:x.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=(P=ke.attrs)==null?void 0:P.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),(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
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),((N=r.attrs)==null?void 0:N.borderLeftWidth)!==void 0&&(he.border_left_width=r.attrs.borderLeftWidth),((v=r.attrs)==null?void 0:v.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),(E=r.attrs)!=null&&E.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=(w=r.attrs)==null?void 0:w.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}%`);(M=r.attrs)!=null&&M.borderWidth&&(Y.border_size=`${r.attrs.borderWidth}px`),(A=r.attrs)!=null&&A.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),(D=r.attrs)!=null&&D.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(B=r.attrs)!=null&&B.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 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:"&#160;"}})})},"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",C=E.type.name==="heading";!w&&!C&&y(),setTimeout(()=>{if(C){let x=L+1,P=L+E.nodeSize-1;c.chain().setTextSelection({from:x,to:P}).unsetAllMarks().blur().run(),f(null),c.commands.updateSelectionState(null);return}let T=c.chain();if(T.setNodeSelection(L).unsetAllMarks(),w&&E.content&&E.content.firstChild?E.content.firstChild.type.name!=="paragraph"&&T.setParagraph():E.type.name!=="paragraph"&&!w&&T.setParagraph(),T.run(),w){let x=b();x.node&&x.pos!==null&&(f(x.node),c.commands.updateSelectionState(x.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:`
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 Ks(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=Ks(o.elements);if(n)return n}}return r||t||""}s(Ks,"getTitle");function Ys(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 Ks(r.elements)}return""}s(Ys,"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 p={};if(t.channel&&typeof t.channel=="object")for(let f in t.channel)f!=="type"&&f!=="elements"&&f!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,f)&&(p[f]=t.channel[f]);let m={type:"channel",channel:u.channel,...Object.fromEntries(Object.entries(u).filter(([f])=>!["type","channel","elements"].includes(f))),...p};if(t.elements!==void 0){let f=[],x=t.elements.find(b=>b.type==="meta");if(x)f.push(x);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),m.elements=f}o.elements.push(m),i=!0}else o.elements.push(l)}else o.elements.push(l)}),n&&!i||!((a=r.elements)!=null&&a.some(l=>l.type==="channel"))&&!i){let l;n?l=n:t.channel&&typeof t.channel=="object"&&t.channel.channel?l=t.channel.channel:l="email";let c={};if(t.channel&&typeof t.channel=="object")for(let d in t.channel)d!=="type"&&d!=="elements"&&d!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,d)&&(c[d]=t.channel[d]);let u={type:"channel",channel:l,...c};if(t.elements!==void 0){let d=[],p=t.elements.find(f=>f.type==="meta");p&&d.push(p);let m=t.elements.filter(f=>f.type!=="meta");d.push(...m),u.elements=d}o.elements.push(u)}return o}s(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 Xs}from"react/jsx-runtime";var Yi=ce.Root,Xi=ce.Trigger;var Qg=xr.forwardRef(({className:e,inset:t,children:r,...o},n)=>Xs(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)=>Xs(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)=>Xs(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 el,jsxs as l5}from"react/jsx-runtime";var tl=class tl 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||el(s5,{error:this.state.error}):this.props.children}};s(tl,"ErrorBoundary");var Qs=tl,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:[el("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),el("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 rl 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"),ol=Ku.forwardRef(({className:e,...t},r)=>d5(rl.Root,{ref:r,className:S(u5(),e),...t}));ol.displayName=rl.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(ol,{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 nl=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})]})});nl.displayName=we.Content.displayName;var il=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");il.displayName="AlertDialogHeader";var al=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");al.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 sl=uo.forwardRef(({className:e,...t},r)=>or(we.Action,{ref:r,className:S(Ki(),e),...t}));sl.displayName=we.Action.displayName;var ll=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}));ll.displayName=we.Cancel.displayName;import*as rd from"react";import{jsx as cl,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&&cl("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),cl("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&&cl("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 ul,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),p=ea(null),m=ea(!1),f=e!==n,x=ul(g=>{m.current=!0;let k=k5(g);c(k),t(k),m.current=!1},[t]),h=s(g=>k=>{p.current=g,b(k)},"handleMouseDown"),b=ul(g=>{if(p.current){if(p.current==="gradient"&&u.current){let k=u.current.getBoundingClientRect(),N=Math.max(0,Math.min(1,(g.clientX-k.left)/k.width)),v=Math.max(0,Math.min(1,(g.clientY-k.top)/k.height)),L={...i,s:N*100,v:(1-v)*100};a(L),x(L)}else if(p.current==="hue"&&d.current){let k=d.current.getBoundingClientRect(),N=Math.max(0,Math.min(1,(g.clientX-k.left)/k.width)),v={...i,h:N*360};a(v),x(v)}}},[i,x]),y=ul(()=>{p.current=null},[]);od(()=>{if(p.current)return window.addEventListener("mousemove",b),window.addEventListener("mouseup",y),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",y)}},[b,y]),od(()=>{m.current||(a(zn(e)),c(e))},[e]);let P=s(g=>{let k=g.target.value;if(c(k),w5(k)){let N=zn(k);a(N),x(N)}},"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:P,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),x(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"&&dl),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 N=zn(g);a(N),x(N)}},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 ml=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})}));ml.displayName=ir.Content.displayName;import{jsx as $n,jsxs as dd}from"react/jsx-runtime";var dl="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(m=>m!=="transparent"),[i,n]),p=A5(()=>{var f;let m=(f=u.current)==null?void 0:f.parentElement;for(;m;){if(m.classList.contains("theme-container"))return m;m=m.parentElement}return document.body},[]);return 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?"":dl),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(ml,{portalProps:{container:typeof window!="undefined"?p():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 pl from"@radix-ui/react-separator";import{jsx as I5}from"react/jsx-runtime";var fl=md.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>I5(pl.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}));fl.displayName=pl.Root.displayName;import*as pd from"react";import*as Tr from"@radix-ui/react-slider";import{jsx as gl,jsxs as L5}from"react/jsx-runtime";var hl=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:[gl(Tr.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:gl(Tr.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),gl(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"})]}));hl.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 bl}from"react/jsx-runtime";var ra=Zt.Root,qn=ta.forwardRef(({className:e,...t},r)=>bl(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)=>bl(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)=>bl(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 yl=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})});yl.displayName="Textarea";import{forwardRef as D5,useContext as B5}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 Cl=H5(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,p])=>{let m=d.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`);return{...u,[`--${m}`]:p}},{});return yd(Cl.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(()=>B5(Cl),"useTheme");import*as xd from"react";import*as vl from"@radix-ui/react-toggle";import{cva as F5}from"class-variance-authority";import{jsx as O5}from"react/jsx-runtime";var xl=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(vl.Root,{ref:n,className:S(xl({variant:t,size:r,className:e})),...o}));V5.displayName=vl.Root.displayName;import*as qo from"@radix-ui/react-toggle-group";import*as mo from"react";import{jsx as Tl}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)=>Tl(qo.Root,{ref:i,className:S("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:Tl(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 Tl(qo.Item,{ref:i,className:S(xl({variant:a.variant||r,size:a.size||o}),e),...n,children:t})});lt.displayName=qo.Item.displayName;import{jsx as El}from"react/jsx-runtime";var xe=s(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?El("path",{className:S(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):El("path",{className:S(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),_=s(({width:e=28,height:t=28,...r})=>El("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");import{jsx as wl,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:[wl("rect",{opacity:"0.6",x:"0.553621",y:"0.876863",width:"16.4923",height:"7.87692",rx:"1.6",stroke:e,strokeWidth:"0.738462"}),wl("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),wl("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 kl,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:[kl("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),kl("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),kl("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");import{jsx as Pd}from"react/jsx-runtime";var Pl=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 Nl=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 Ml=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 Al=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 Dd}from"react/jsx-runtime";var Sl=s(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 256 239",...n})=>Dd(_,{...n,width:t,height:r,viewBox:o,children:Dd("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 Bd}from"react/jsx-runtime";var ei=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Bd(_,{...n,width:r,height:o,children:Bd(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 Il}from"react/jsx-runtime";var Ll=s(({color:e,width:t=21,height:r=16,...o})=>Il(_,{...o,width:t,height:r,children:Il("g",{transform:"translate(4, 0)",children:Il("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 Rl=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 Hl=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 Bl=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 Fl=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 Vl=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 Ol}from"react/jsx-runtime";var fo=s(({className:e})=>Ol("div",{className:S("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:Ol("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:Ol("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");import{jsx as Ul,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:[Ul(fo,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):Ul("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:[Ul(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(Ml,{})},{label:"SMS",value:"sms",icon:Jo(Fl,{})},{label:"Push",value:"push",icon:Jo(Hl,{})},{label:"In-app",value:"inbox",icon:Jo(Yn,{})},{label:"Slack",value:"slack",icon:Jo(Vl,{})},{label:"Teams",value:"msteams",icon:Jo(Sl,{})}];var Ur=em("email"),jo=em("template");import{AlertDialogDescription as e4}from"@radix-ui/react-alert-dialog";import{useAtom as t4,useAtomValue as Hs,useSetAtom as r4}from"jotai";import{useCallback as Di,useEffect as o4,useRef as n4}from"react";import{atom as kt}from"jotai";var Wl={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:Wl,heading:Wl},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,p;let u=c;u!=="conditionalRules"&&((d=i[u])==null?void 0:d.state)==="enabled"&&((p=a[u])==null?void 0:p.state)==="enabled"&&(l[u]=a[u])}),n.isFocused&&n.hasVariables&&(l={...l,variable:{state:"enabled"}}),l}),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"}]))}})}),AE=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})}),SE=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 K8,useAtomValue as F1,useSetAtom as wu}from"jotai";import{useCallback as V1,useEffect as ku,useMemo as O1,useRef as Y8,useState as X8}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 Dc,useAtomValue as So,useSetAtom as iy}from"jotai";import{forwardRef as ay,memo as sy,useCallback as wf,useEffect as Xr,useMemo as kf,useRef as Ei,useState as Bc}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,p=l.location.current.input;(d=o)===null||d===void 0||d({current:{x:p.clientX,y:p.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 $l={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function wm(e){var t=e.dragLeave;return fi()?t.hasOwnProperty($l.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[$l.isEnteringWindow]=!0),r.isOverWindow=!0,r.enterCount++},"listener")},{type:"dragleave",listener:s(function(i){r.enterCount--,r.isOverWindow&&r.enterCount===0&&(i[$l.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 Zl=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(),Zl.cancel(),i({eventName:"onDropTargetChange",payload:{source:t,location:{initial:r,previous:n,current:u}}})},"dragUpdate"),drag:s(function(c){var u=c.current;Zl(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(),Zl.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};ql({event:t,current:i.dropTargets});var l=Am({source:r.payload,dispatchEvent:n,initial:i});function c(f){var x=f2({current:a.current.dropTargets,next:f.dropTargets});a.current=f,x&&l.dragUpdate({current:a.current})}s(c,"updateState");function u(f){var x=bo(f),h=pa(f.target)?fa({x:x.clientX,y:x.clientY}):f.target,b=o({target:h,input:x,source:r.payload,current:a.current.dropTargets});b.length&&(f.preventDefault(),ql({event:f,current:b})),c({dropTargets:b,input:x})}s(u,"onUpdateEvent");function d(){a.current.dropTargets.length&&c({dropTargets:[],input:a.current.input}),l.drop({current:a.current,updatedSourcePayload:null}),p()}s(d,"cancel");function p(){Jl.isActive=!1,m()}s(p,"finish");var m=(0,Sm.bindAll)(window,[{type:"dragover",listener:s(function(x){u(x),l.drag({current:a.current})},"listener")},{type:"dragenter",listener:u},{type:"dragleave",listener:s(function(x){Pm({dragLeave:x})&&(c({input:a.current.input,dropTargets:[]}),r.startedFrom==="external"&&d())},"listener")},{type:"drop",listener:s(function(x){if(a.current={dropTargets:a.current.dropTargets,input:bo(x)},!a.current.dropTargets.length){d();return}x.preventDefault(),ql({event:x,current:a.current.dropTargets}),l.drop({current:a.current,updatedSourcePayload:r.type==="external"?r.getDropPayload(x):null}),p()},"listener")},{type:"dragend",listener:s(function(x){a.current={dropTargets:a.current.dropTargets,input:bo(x)},d()},"listener")}].concat(ga(Nm({onDragEnd:d}))),{capture:!0});l.start({nativeSetDragImage:p2(t)})}s(g2,"start");function ql(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(ql,"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 jl={canStart:Im,start:g2};var Gl=new Map;function b2(e){var t=e.typeKey,r=e.mount,o=Gl.get(t);if(o)return o.usageCount++,o;var n={typeKey:t,unmount:r(),usageCount:1};return Gl.set(t,n),n}s(b2,"registerUsage");function Lm(e){var t=b2(e);return s(function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),Gl.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 Kl(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(Kl,"_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 Yl(e){return e.slice(0).reverse()}s(Yl,"copyReverse");function Dm(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 x;var h=sr(ba(f.element,{attribute:n,value:"true"}),a(f));return Ht(h)}s(l,"dropTargetForConsumers");function c(f){var x,h,b,y,P=f.source,g=f.target,k=f.input,N=f.result,v=N===void 0?[]:N;if(g==null)return v;if(!(g instanceof Element))return g instanceof Node?c({source:P,target:g.parentElement,input:k,result:v}):v;var L=g.closest(i);if(L==null)return v;var E=o.get(L);if(E==null)return v;var C={input:k,source:P,element:E.element};if(E.canDrop&&!E.canDrop(C))return c({source:P,target:E.element.parentElement,input:k,result:v});var T=(x=(h=E.getData)===null||h===void 0?void 0:h.call(E,C))!==null&&x!==void 0?x:{},w=(b=(y=E.getDropEffect)===null||y===void 0?void 0:y.call(E,C))!==null&&b!==void 0?b:r,M={data:T,element:E.element,dropEffect:w,isActiveDueToStickiness:!1};return c({source:P,target:E.element.parentElement,input:k,result:[].concat(ga(v),[M])})}s(c,"getActualDropTargets");function u(f){var x=f.eventName,h=f.payload,b=Kl(h.location.current.dropTargets),y;try{for(b.s();!(y=b.n()).done;){var P,g=y.value,k=o.get(g.element),N=Wr(Wr({},h),{},{self:g});k==null||(P=k[x])===null||P===void 0||P.call(k,N)}}catch(v){b.e(v)}finally{b.f()}}s(u,"notifyCurrent");var d={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:s(function(x){var h=x.payload,b=new Set(h.location.current.dropTargets.map(function(V){return V.element})),y=new Set,P=Kl(h.location.previous.dropTargets),g;try{for(P.s();!(g=P.n()).done;){var k,N=g.value;y.add(N.element);var v=o.get(N.element),L=b.has(N.element),E=Wr(Wr({},h),{},{self:N});if(v==null||(k=v.onDropTargetChange)===null||k===void 0||k.call(v,E),!L){var C;v==null||(C=v.onDragLeave)===null||C===void 0||C.call(v,E)}}}catch(V){P.e(V)}finally{P.f()}var T=Kl(h.location.current.dropTargets),w;try{for(T.s();!(w=T.n()).done;){var M,A,R=w.value;if(!y.has(R.element)){var I=Wr(Wr({},h),{},{self:R}),H=o.get(R.element);H==null||(M=H.onDropTargetChange)===null||M===void 0||M.call(H,I),H==null||(A=H.onDragEnter)===null||A===void 0||A.call(H,I)}}}catch(V){T.e(V)}finally{T.f()}},"onDropTargetChange")};function p(f){d[f.eventName](f)}s(p,"dispatchEvent");function m(f){var x=f.source,h=f.target,b=f.input,y=f.current,P=c({source:x,target:h,input:b});if(P.length>=y.length)return P;for(var g=Yl(y),k=Yl(P),N=[],v=0;v<g.length;v++){var L,E=g[v],C=k[v];if(C!=null){N.push(C);continue}var T=N[v-1],w=g[v-1];if((T==null?void 0:T.element)!==(w==null?void 0:w.element))break;var M=o.get(E.element);if(!M)break;var A={input:b,source:x,element:M.element};if(M.canDrop&&!M.canDrop(A)||!((L=M.getIsSticky)!==null&&L!==void 0&&L.call(M,A)))break;N.push(Wr(Wr({},E),{},{isActiveDueToStickiness:!0}))}return Yl(N)}return s(m,"getIsOver"),{dropTargetForConsumers:l,getIsOver:m,dispatchEvent:p}}s(Dm,"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 Bm(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)?Bm(e,t):void 0}}s(v2,"_unsupportedIterableToArray");function Bm(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(Bm,"_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 p=Array.from(t.active),m=0,f=p;m<f.length;m++){var x=f[m];if(t.active.has(x)){var h;(h=x[a])===null||h===void 0||h.call(x,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=Dm({typeKey:t,defaultDropEffect:i});function c(p){o==null||o(p),l.dispatchEvent(p),a.dispatchEvent(p),n==null||n(p)}s(c,"dispatchEvent");function u(p){var m=p.event,f=p.dragType;jl.start({event:m,dragType:f,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}s(u,"start");function d(){function p(){var m={canStart:jl.canStart,start:u};return r(m)}return s(p,"mountAdapter"),Lm({typeKey:t,mount:p})}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 Xl="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(),Ql=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 p=ya.get(d);if(p){var m=bo(o),f={element:p.element,dragHandle:(n=p.dragHandle)!==null&&n!==void 0?n:null,input:m};if(p.canDrag&&!p.canDrag(f)){o.preventDefault();return}if(p.dragHandle){var x=fa({x:m.clientX,y:m.clientY});if(!p.dragHandle.contains(x)){o.preventDefault();return}}var h=(i=(a=p.getInitialDataForExternal)===null||a===void 0?void 0:a.call(p,f))!==null&&i!==void 0?i:null;if(h)for(var b=0,y=Object.entries(h);b<y.length;b++){var P=ua(y[b],2),g=P[0],k=P[1];o.dataTransfer.setData(g,k!=null?k:"")}Um()&&!o.dataTransfer.types.includes(Xl)&&!o.dataTransfer.types.includes(_m)&&o.dataTransfer.setData(Xl,Wm),o.dataTransfer.setData(zm,"");var N={element:p.element,dragHandle:(l=p.dragHandle)!==null&&l!==void 0?l:null,data:(c=(u=p.getInitialData)===null||u===void 0?void 0:u.call(p,f))!==null&&c!==void 0?c:{}},v={type:"element",payload:N,startedFrom:"internal"};t.start({event:o,dragType:v})}}}},"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=Ql.dropTarget,ec=Ql.monitor;function gi(e){if(0)var t;var r=sr(Ql.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(p){return{edge:p,value:E2[p](c,l)}}),d=(r=(o=u.sort(function(p,m){return p.value-m.value})[0])===null||o===void 0?void 0:o.edge)!==null&&r!==void 0?r:null;return 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 G3,Node as K3}from"@tiptap/core";import{ReactNodeViewRenderer as Y3}from"@tiptap/react";import{NodeViewContent as Z3}from"@tiptap/react";import{useSetAtom as q3}from"jotai";import{useCallback as J3}from"react";import{NodeViewWrapper as V3}from"@tiptap/react";import{useSetAtom as O3}from"jotai";import{forwardRef as U3,useCallback as Ao,useEffect as Hc,useState as ms,useRef as Yr}from"react";import{v4 as W3}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 tc=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 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 B2,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(B2,{})})}),"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 p=s(m=>{let f=m.target;f.closest(".courier-actions-panel")||f.closest("[data-no-drag-preview]")||i()},"handleClick");return d.addEventListener("click",p,!0),()=>{d.removeEventListener("click",p,!0)}},[i]);let a=!e.node.content||e.node.content.size===0;return 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"},rc=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,p])=>{r.getValues(d)!==p&&r.setValue(d,p)}))}},"updateCurrentNode");return l(),e.on("update",l),()=>{e.off("update",l)}},[e,t,r,o]),{updateNodeAttributes: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:p,dispatch:m})=>{let f=p.doc.nodeAt(i.current);return(f==null?void 0:f.type.name)===o&&m?(p.setNodeMarkup(i.current,f.type,u),p.setMeta("addToHistory",!0),!0):!1}).run()},[e,o])}},"useNodeAttributes");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(p=>{typeof d[p]=="string"&&o(d[p])}),d.elements&&Array.isArray(d.elements)&&d.elements.forEach(p=>{p&&n(p)}),d.raw&&typeof d.raw=="object"&&d.raw!==null&&Object.values(d.raw).forEach(p=>{typeof p=="string"&&o(p)})}})},"processNode");return e.forEach(i=>n(i)),Array.from(t).sort()},"extractVariablesFromContent");var pN=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 m,f;if(!t)return[];let p=((f=(m=t.extensionManager.extensions.find(x=>x.name==="variableSuggestion"))==null?void 0:m.options)==null?void 0:f.variables)||{};return Ca(p)},[t]),c=ep(()=>{if(!r||!a)return[];let p=r.elements.find(m=>m.type==="channel"&&m.channel===a);return p?Qm(p.elements||[]):[]},[r,a]),u=tp((p,m)=>{i(f=>({...f,[p]:m}))},[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 oc}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?oc(Ne,{...r,children:[Xo(Qe,{type:"blockquote"}),oc("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})=>oc(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 qh}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 Vh from"@tiptap/extension-placeholder";import{Node as fh}from"@tiptap/core";var Ra=fh.create({name:"text",group:"inline"});import{EditorContent as Oh,useEditor as Uh}from"@tiptap/react";import*as Eo from"react";import{useCallback as Wh,useEffect as pp}from"react";import{Extension as wh,InputRule as kh,Node as Ph}from"@tiptap/core";import{ReactNodeViewRenderer as Nh}from"@tiptap/react";import{NodeViewWrapper as vh}from"@tiptap/react";import{useAtomValue as xh}from"jotai";import{useCallback as sc,useEffect as Th,useState as Eh}from"react";import{useCallback as vo,useEffect as nc,useMemo as gh,useRef as hh,useState as bh}from"react";import{jsx as lp,jsxs as yh}from"react/jsx-runtime";var ic=50,ac=24,Ha=s(({variableId:e,isInvalid:t,onUpdateAttributes:r,onDelete:o,icon:n,value:i,singleClickToEdit:a=!1,className:l,textColorOverride:c,getColors:u})=>{let[d,p]=bh(!1),m=hh(null);nc(()=>{e===""&&!d&&p(!0)},[e,d]),nc(()=>{if(d&&m.current){let v=m.current;v.textContent=e,v.focus(),requestAnimationFrame(()=>{if(v){let L=document.createRange();L.selectNodeContents(v),L.collapse(!1);let E=window.getSelection();E==null||E.removeAllRanges(),E==null||E.addRange(L)}})}},[d,e]);let f=vo(()=>{var E;p(!1);let v=(((E=m.current)==null?void 0:E.textContent)||"").trim();if(v===""){o();return}let L=$e(v);r({id:v,isInvalid:!L})},[o,r]),x=vo(v=>{var L;v.key==="Enter"?(v.preventDefault(),(L=m.current)==null||L.blur()):v.key==="Escape"&&(v.preventDefault(),m.current&&(m.current.textContent=e),p(!1),e===""&&o())},[e,o]),h=vo(()=>{if(m.current){let v=m.current.textContent||"";if(v.length>ic){v=v.slice(0,ic),m.current.textContent=v;let L=document.createRange();L.selectNodeContents(m.current),L.collapse(!1);let E=window.getSelection();E==null||E.removeAllRanges(),E==null||E.addRange(L)}}},[]),b=vo(v=>{v.preventDefault();let L=v.clipboardData.getData("text/plain").slice(0,ic);document.execCommand("insertText",!1,L)},[]),y=vo(v=>{v.stopPropagation(),d||p(!0)},[d]),P=gh(()=>{let v=e,L=i?`="${i}"`:"",E=`${v}${L}`,C=v.length>ac;return{displayText:`${C?`${v.slice(0,ac)}\u2026`:v}${L}`,fullText:E,showTitle:C}},[e,i]);nc(()=>{m.current&&!d&&(m.current.textContent=P.displayText)},[P.displayText,d]);let g=vo(v=>{v.stopPropagation()},[]),k=vo(v=>{v.stopPropagation()},[]),N=a?{onClick:y}:{onClick:k,onDoubleClick:y};return yh("span",{className:S("courier-variable-chip",!t&&i&&"courier-variable-chip-has-value",t&&"courier-variable-chip-invalid",l),style:{direction:"ltr"},onMouseDown:g,...N,title:P.showTitle?P.fullText:void 0,children:[lp("span",{className:"courier-flex-shrink-0 courier-flex courier-items-center courier-pt-0.5",children:n}),lp("span",{ref:m,role:"textbox",contentEditable:d,suppressContentEditableWarning:!0,onBlur:f,onKeyDown:x,onInput:h,onPaste:b,onMouseDown:g,...a?{onClick:y}:{onClick:k,onDoubleClick:y},className:S("courier-outline-none courier-min-w-[1ch]",!d&&"courier-cursor-text"),style:{...c&&{color:c},maxWidth:`${ac}ch`,overflow:"hidden",textOverflow:d?"clip":"ellipsis",whiteSpace:"nowrap",direction:"ltr",unicodeBidi:"isolate"},children:!d&&P.displayText})]})},"VariableChipBase");import{jsx as cp,jsxs as Ch}from"react/jsx-runtime";var Da=s(({color:e="#1D4ED8"})=>Ch("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=xh(so),i=e.attrs.id||"",a=n[i],l=e.attrs.isInvalid,[c,u]=Eh(!1),d=sc(()=>{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]);Th(()=>{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 p=sc(h=>{o(h)},[o]),m=sc(()=>{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]),x=s((h,b)=>h?"#DC2626":b?"#1E40AF":"#B45309","getIconColor")(l,!!a);return lc(vh,{className:"courier-inline-block courier-max-w-full",children:lc(Ha,{variableId:i,isInvalid:l,value:a,onUpdateAttributes:p,onDelete:m,icon:lc(Da,{color:x}),className:S("courier-variable-node",c&&"courier-variable-in-button"),textColorOverride:c?"#000000":void 0})})},"VariableView");var cc=Ph.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 Nh(up)}}),xo=wh.create({name:"variableInputRule",addInputRules(){return[new kh({find:/\{\{$/,handler:({range:e,chain:t})=>{t().deleteRange(e).insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()}})]}});import{Extension as Mh}from"@tiptap/core";import{Plugin as Ah}from"@tiptap/pm/state";import{Slice as Sh,Fragment as Ih}from"@tiptap/pm/model";var To=Mh.create({name:"variablePaste",addProseMirrorPlugins(){return[new Ah({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=Ih.from(i),u=new Sh(c,0,0),d=r.state.tr.replaceSelection(u);return r.dispatch(d),e}return e}}})]}});import{Node as Lh}from"@tiptap/core";import{NodeViewWrapper as Rh,ReactNodeViewRenderer as Hh}from"@tiptap/react";import{useCallback as dp}from"react";import{jsx as yi,jsxs as Fh}from"react/jsx-runtime";var Dh=s(({color:e="#B45309"})=>Fh("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"),Bh=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(Rh,{as:"span",className:"courier-inline",children:yi(Ha,{variableId:n,isInvalid:i,onUpdateAttributes:a,onDelete:l,icon:yi(Dh,{color:c.iconColor}),getColors:mp})})},"SimpleVariableView"),Ba=Lh.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 Hh(Bh)}});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 Fa(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(Fa,"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=Uh({extensions:[Qo,en.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),Ra,Ba,xo,To,Vh.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:tn(e),editable:!n,editorProps:{attributes:{class:"courier-outline-none courier-min-h-[20px]"},handleKeyDown:(m,f)=>f.key==="Enter"&&!f.shiftKey?(f.preventDefault(),!0):!1},onUpdate:({editor:m})=>{if(c.current)return;let f=Fa(m.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 m=setTimeout(()=>{let f=tn(e);d.commands.setContent(f),c.current=!1},0);return()=>clearTimeout(m)},[d,e]),pp(()=>{d&&d.setEditable(!n)},[d,n]);let p=Wh(()=>{d==null||d.commands.focus()},[d]);return Eo.useImperativeHandle(l,()=>{let m=d==null?void 0:d.view.dom.parentElement;return m&&(m.focus=p),m},[d,p]),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(Oh,{editor:d,className:"courier-w-full"})})});lr.displayName="VariableTextarea";import _h from"@tiptap/extension-placeholder";import{EditorContent as zh,useEditor as $h}from"@tiptap/react";import*as wo from"react";import{useCallback as Zh,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),p=$h({extensions:[Qo,en.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),Ra,Ba,xo,To,_h.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:tn(e),editable:!n&&!i,editorProps:{attributes:{class:"courier-outline-none"},handleKeyDown:(f,x)=>x.key==="Enter"?(x.preventDefault(),!0):!1},onUpdate:({editor:f})=>{if(u.current)return;let x=Fa(f.getJSON());x!==d.current&&(d.current=x,t==null||t(x))},onFocus:()=>{a==null||a()},onBlur:()=>{l==null||l()}});gp(()=>{if(!p||e===d.current)return;u.current=!0,d.current=e;let f=setTimeout(()=>{let x=tn(e);p.commands.setContent(x),u.current=!1},0);return()=>clearTimeout(f)},[p,e]),gp(()=>{p&&p.setEditable(!n&&!i)},[p,n,i]);let m=Zh(()=>{p==null||p.commands.focus()},[p]);return wo.useImperativeHandle(c,()=>{let f=p==null?void 0:p.view.dom.parentElement;return f&&(f.focus=m),f},[p,m]),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",(n||i)&&"courier-cursor-default",n&&"courier-opacity-50","[&_.tiptap]:courier-outline-none [&_.tiptap]:courier-border-none",o),onClick:()=>!i&&!n&&(p==null?void 0:p.commands.focus()),children:hp(zh,{editor:p,className:"courier-w-full courier-flex-1"})})});Ci.displayName="VariableInput";import{jsx as on,jsxs as $A}from"react/jsx-runtime";var rn=30,Va=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"),Oa=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"),Ua=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:qh(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(Va,{className:"courier-h-4 courier-w-4"})}),fe(lt,{size:"sm",value:"center",className:"courier-w-full",children:fe(Oa,{className:"courier-h-4 courier-w-4"})}),fe(lt,{size:"sm",value:"right",className:"courier-w-full",children:fe(Ua,{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 rb,Node as ob}from"@tiptap/core";import{ReactNodeViewRenderer as nb}from"@tiptap/react";import{v4 as ib}from"uuid";import{useAtomValue as jh,useSetAtom as Gh}from"jotai";import{useCallback as kr,useRef as ko,useEffect as Cp,useLayoutEffect as Kh,useState as Yh}from"react";import{Fragment as tb,jsx as cr,jsxs as uc}from"react/jsx-runtime";var Xh=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"),Qh=s(({parts:e})=>{let t=jh(so);return cr(tb,{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"),yp=s(({label:e,backgroundColor:t,textColor:r,onLabelChange:o,editable:n})=>{let i=ko(null),a=ko(e),l=ko(!1),[c,u]=Yh(!1),d=Xh(e),m=d.some(v=>v.type==="variable")&&!c;Kh(()=>{if(!i.current||!m)return;Array.from(i.current.childNodes).filter(L=>L.nodeType===Node.TEXT_NODE).forEach(L=>L.remove())},[m,e]);let f=ko(m),x=ko(!0);Cp(()=>{if(!i.current||m){f.current=m;return}let v=f.current&&!m;f.current=m,(x.current||v||!l.current&&e!==a.current)&&(i.current.textContent=e),x.current=!1,a.current=e},[e,m]);let h=kr(()=>{if(i.current&&!m){l.current=!0;let v=i.current.textContent||"";a.current=v,o(v),requestAnimationFrame(()=>{l.current=!1})}},[o,m]),b=kr(v=>{var L;if(m){v.preventDefault(),v.stopPropagation();return}if(v.key==="Enter"&&(v.preventDefault(),(L=i.current)==null||L.blur()),(v.metaKey||v.ctrlKey)&&v.key==="a"&&(v.preventDefault(),v.stopPropagation(),i.current)){let E=document.createRange();E.selectNodeContents(i.current);let C=window.getSelection();C==null||C.removeAllRanges(),C==null||C.addRange(E)}},[m]),y=kr(()=>{u(!0)},[]),P=kr(()=>{u(!1)},[]),g=kr(v=>{let L=i.current;if(!L)return;if(m&&n){v.stopPropagation(),setTimeout(()=>{L.focus();let T=document.createRange();T.selectNodeContents(L),T.collapse(!1);let w=window.getSelection();w==null||w.removeAllRanges(),w==null||w.addRange(T)},0);return}if(!n)return;let E=s(()=>{let T=window.getSelection();if(!T||T.rangeCount===0)return;let w=T.getRangeAt(0),M=L.contains(w.startContainer),A=L.contains(w.endContainer);if(M&&!A){let R=document.createRange();R.selectNodeContents(L),T.removeAllRanges(),T.addRange(R)}},"checkAndConstrainSelection"),C=s(T=>{let w=L.getBoundingClientRect();(T.clientX<w.left||T.clientX>w.right||T.clientY<w.top||T.clientY>w.bottom)&&E(),document.removeEventListener("mouseup",C)},"handleMouseUp");document.addEventListener("mouseup",C)},[n,m]),k=m?cr(Qh,{parts:d}):n?null:e,N=kr(v=>{m&&n&&v.stopPropagation()},[m,n]);return cr("div",{ref:i,contentEditable:n&&!m,suppressContentEditableWarning:!0,tabIndex:n&&m?0:void 0,onInput:h,onKeyDown:b,onPointerDown:g,onClick:N,onFocus:y,onBlur:P,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&&!m&&"courier-cursor-text"),style:{backgroundColor:t,color:r,borderColor:"transparent",borderRadius:"4px",caretColor:r,WebkitUserSelect:"text",userSelect:"text"},children:k})},"EditableButton"),eb=s(({button1Label:e,button1Link:t,button1BackgroundColor:r,button1TextColor:o,button2Label:n,button2Link:i,button2BackgroundColor:a,button2TextColor:l,padding:c=6,onButton1LabelChange:u,onButton2LabelChange:d,editable:p=!1})=>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:p},"button1"),cr(yp,{label:n,backgroundColor:a,textColor:l,onLabelChange:d||(()=>{}),editable:p},"button2")]})}),"ButtonRowComponent"),vp=s(e=>{let t=Gh(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(eb,{...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=ob.create({name:"buttonRow",group:"block",atom:!0,selectable:!1,onCreate(){Oe(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${ib()}`,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",rb(e,{"data-type":"buttonRow"})]},addNodeView(){return nb(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 mb,Node as pb}from"@tiptap/core";import{ReactNodeViewRenderer as fb}from"@tiptap/react";import{v4 as gb}from"uuid";import{NodeViewContent as ab}from"@tiptap/react";import{useSetAtom as sb,useAtomValue as lb}from"jotai";import{useCallback as dc,useEffect as xp,useState as mc,useRef as cb}from"react";import{jsx as ur}from"react/jsx-runtime";var ub=s(({columnId:e,index:t,isPreviewMode:r})=>{let o=cb(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"),db=s(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderWidth:o,borderRadius:n,borderColor:i,node:a,columnsCount:l,isPreviewMode:c=!1})=>{var m;let u=!a.content||a.content.size===0,d={borderWidth:`${o}px`,borderStyle:o>0?"solid":"none",borderColor:i,borderRadius:`${n}px`},p={padding:`${t}px ${e}px`,backgroundColor:r};if(u){let f=((m=a.attrs)==null?void 0:m.id)||"";return ur("div",{className:"courier-w-full node-element",style:p,children:ur("div",{className:"courier-w-full courier-flex courier-gap-2 courier-p-2",style:d,children:Array.from({length:l}).map((x,h)=>ur(ub,{columnId:f,index:h,isPreviewMode:c},h))})})}return ur("div",{className:"courier-w-full node-element",style:p,children:ur("div",{className:"courier-w-full courier-p-2",style:d,children:ur(ab,{})})})},"ColumnComponent"),Tp=s(e=>{let t=sb(Re),r=lb(pt),[o,n]=mc(!1),[i,a]=mc(e.editor.isEditable);xp(()=>{let p=s(()=>{a(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",p),e.editor.on("transaction",p),e.editor.on("selectionUpdate",p),()=>{e.editor.off("update",p),e.editor.off("transaction",p),e.editor.off("selectionUpdate",p)}},[e.editor]);let l=!i&&!r,c=dc(p=>{var N,v;if(!e.editor.isEditable)return;let m=p.target,f=p.currentTarget,x=m===f,h=m.classList.contains("node-element"),b=m.classList.contains("courier-p-2"),y=m.classList.contains("courier-gap-2"),P=m.classList.contains("draggable-item"),g=m.hasAttribute("data-drag-handle")||m.closest("[data-drag-handle]")!==null;if(x||h||b||y||P||g||((v=(N=m.closest("[data-node-view-content]"))==null?void 0:N.parentElement)==null?void 0:v.classList.contains("node-element"))){p.stopPropagation(),g||p.preventDefault();let L=We(e);if(L){e.editor.commands.blur();let E=L.attrs.id;e.editor.state.doc.descendants(C=>C.type.name==="column"&&C.attrs.id===E?(t(C),!1):!0)}}},[e,t]),u=dc(p=>{let m=p.target,f=p.currentTarget;if(!(m.closest("[data-column-cell]")!==null)){n(!0);return}let h=f.getBoundingClientRect(),b=p.clientY,y=30,P=b<=h.top+y||b>=h.bottom-y;n(P)},[]),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(db,{...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=pb.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-${gb()}`,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",mb(this.options.HTMLAttributes,e,{"data-type":"column"}),0]},addNodeView(){return fb(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 hb}from"@hookform/resolvers/zod";import{useForm as bb}from"react-hook-form";import{z as Dt}from"zod";var Ep=Dt.object({columnsCount:Dt.number().min(1).max(4).default(2),paddingHorizontal:Dt.number().default(0),paddingVertical:Dt.number().default(0),backgroundColor:Dt.string().default("transparent"),borderWidth:Dt.number().default(0),borderRadius:Dt.number().default(0),borderColor:Dt.string().default("transparent"),cells:Dt.array(Dt.object({elements:Dt.array(Dt.any())})).optional()});import{jsx as ne,jsxs as Kt}from"react/jsx-runtime";var pc=s(({element:e,editor:t})=>{let r=bb({resolver:hb(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,x)=>f.attrs.id===e.attrs.id&&f.type.name==="column"?(a=x,!1):!0),a===null)return;let l=t.state.doc.nodeAt(a);if(!l)return;let c=e.attrs.id,u=t.schema,d=t.state.tr,p=l.firstChild;if(!p||p.type.name!=="columnRow"){let f=Array.from({length:i},(h,b)=>u.nodes.columnCell.create({index:b,columnId:c,isEditorMode:!1})),x=u.nodes.columnRow.create({},f);d.replaceWith(a+1,a+l.nodeSize-1,x),d.setNodeMarkup(a,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d);return}let m=p.childCount;if(i!==m){if(i>m){let f=i-m,h=a+1+p.nodeSize-1;for(let b=0;b<f;b++){let y=u.nodes.columnCell.create({index:m+b,columnId:c});d.insert(h+b*y.nodeSize,y)}}else{let f=m-i,h=a+1;for(let y=0;y<m-f;y++){let P=p.child(y);h+=P.nodeSize}let b=0;for(let y=m-f;y<m;y++){let P=p.child(y);b+=P.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 yb,Node as Cb}from"@tiptap/core";var $a=Cb.create({name:"columnRow",group:"columnContent",content:"columnCell+",isolating:!0,parseHTML(){return[{tag:'div[data-type="column-row"]'}]},renderHTML({HTMLAttributes:e}){return["div",yb(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 kb,Node as Pb}from"@tiptap/core";import{ReactNodeViewRenderer as Nb}from"@tiptap/react";import{Plugin as Mb,PluginKey as Ab}from"@tiptap/pm/state";import{NodeViewWrapper as vb,NodeViewContent as xb}from"@tiptap/react";import{useEffect as wp,useRef as Tb,useState as kp}from"react";import{useAtomValue as Eb}from"jotai";import{jsx as Pp,jsxs as wb}from"react/jsx-runtime";var Np=s(e=>{let t=Tb(null),[r,o]=kp(!1),n=Eb(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 wb(vb,{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(xb,{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full"})]})},"ColumnCellComponentNode");var Za=Pb.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",kb(e,{"data-type":"column-cell",style:"flex: 1 1 0%; width: 0; min-height: 120px;"}),0]},addNodeView(){return Nb(Np)},addCommands(){return{insertColumnCell:()=>({chain:e})=>e().insertContent({type:this.name}).run()}},addProseMirrorPlugins(){return[new Mb({key:new Ab("columnCellCleanup"),appendTransaction:(e,t,r)=>{if(!e.some(i=>i.docChanged))return null;let o=r.tr,n=!1;return r.doc.descendants((i,a)=>{var l,c;if(i.type.name==="columnCell"){let u=i.childCount===0,d=i.childCount===1&&((l=i.firstChild)==null?void 0:l.type.name)==="paragraph"&&((c=i.firstChild)==null?void 0:c.content.size)===0,p=i.attrs.isEditorMode;u?p=!1:u||(p=!0),p!==i.attrs.isEditorMode&&(o.setNodeAttribute(a,"isEditorMode",p),n=!0),d&&p===!1&&(o.delete(a+1,a+i.nodeSize-1),n=!0)}return!0}),n?o:null}})]}});import{mergeAttributes as Rb,Node as Hb}from"@tiptap/core";import{ReactNodeViewRenderer as Db}from"@tiptap/react";import{v4 as Bb}from"uuid";import{useSetAtom as Sb}from"jotai";import{useCallback as Ib}from"react";import{jsx as qa}from"react/jsx-runtime";var Lb=s(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return qa("div",{className:"courier-w-full node-element",children:qa("div",{className:"courier-custom-code courier-py-1.5",dangerouslySetInnerHTML:t?{__html:e}:{__html:"&#160;"}})})},"CustomCodeComponent"),Mp=s(e=>{let t=Sb(Re),r=Ib(()=>{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 qa(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:qa(Lb,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var Pr={code:"<!-- Add your HTML code here -->"},Ja=Hb.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-${Bb()}`,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",Rb(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 ja,useCallback as Ap,useState as Sp,lazy as Ob,Suspense as Ub,useEffect as Wb}from"react";import{forwardRef as Fb}from"react";import{jsx as Vb}from"react/jsx-runtime";var fc=Fb(({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 Vb("div",{className:o,ref:r,...t})});fc.displayName="Spinner";import{jsx as nn}from"react/jsx-runtime";var _b=s(()=>{let[e,t]=Sp(!1),r=ja(null);return Wb(()=>{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"),zb=Ob(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function $b(e,t){let r=ja();return Ap((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}s($b,"useDebounce");var Zb=s((e,t,r)=>{if(!t||!r)return!0;let o=t.getModel();if(!o)return!0;if(r.editor.getModelMarkers({resource:o.uri}).filter(a=>a.severity===8).length>0)return!1;if(!e.trim())return!0;try{if(/<[a-z][a-z0-9]*\s[^>]*$/i.test(e.trim()))return!1;let l=(e.match(/</g)||[]).length,c=(e.match(/>/g)||[]).length;if(l!==c||new DOMParser().parseFromString(e,"text/html").getElementsByTagName("parsererror").length>0)return!1;let m=(e.match(/<([a-z][a-z0-9]*)\b[^>]*(?<!\/\/)>/gi)||[]).map(b=>{var y,P;return(P=(y=b.match(/<([a-z][a-z0-9]*)/i))==null?void 0:y[1])==null?void 0:P.toLowerCase()}).filter(Boolean),f=(e.match(/<\/([a-z][a-z0-9]*)\s*>/gi)||[]).map(b=>{var y,P;return(P=(y=b.match(/<\/([a-z][a-z0-9]*)/i))==null?void 0:y[1])==null?void 0:P.toLowerCase()}).filter(Boolean),x=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],h=m.filter(b=>b&&!x.includes(b));for(let b of h){let y=m.filter(g=>g===b).length,P=f.filter(g=>g===b).length;if(y!==P)return!1}return!0}catch{return!1}},"defaultHTMLValidator"),gc=s(({code:e,onSave:t,onValidationChange:r,validator:o=Zb})=>{let n=ja(null),i=ja(null),[a,l]=Sp(!0),{isDark:c,containerRef:u}=_b(),d=Ap(()=>{if(!n.current||!i.current)return!0;let x=n.current.getModel();if(!x)return!0;let h=x.getValue(),b=o(h,n.current,i.current);return b!==a&&(l(b),r==null||r(b)),b},[a,r,o]),p=$b(x=>{setTimeout(()=>{d()&&t(x)},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(Ub,{fallback:nn("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:nn(fc,{})}),children:nn(zb,{height:"100%",defaultLanguage:"html",value:e,onChange:s(x=>{p(x||"")},"handleCodeChange"),onMount:s((x,h)=>{n.current=x,i.current=h,x.focus(),x.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 qb}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 jb}from"react";import{useAtom as Gb}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:qb(Lp),defaultValues:{...Pr,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Xe({editor:t,element:e,form:r,nodeType:"customCode"}),[n,i]=Gb(tr),a=jb(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(Bl,{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 n0}from"@tiptap/core";import{Node as Kb,mergeAttributes as Yb,isNodeSelection as Xb,nodeInputRule as Qb}from"@tiptap/core";import{TextSelection as bc,NodeSelection as e0}from"@tiptap/pm/state";var Hp=Kb.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",Yb(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}):Xb(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(e0.create(a.doc,u.pos)):a.setSelection(bc.create(a.doc,u.pos));else{let p=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();p&&(a.insert(d,p),a.setSelection(bc.create(a.doc,d+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Qb({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});import{ReactNodeViewRenderer as i0}from"@tiptap/react";import{v4 as a0}from"uuid";import{useSetAtom as t0}from"jotai";import{useCallback as r0}from"react";import{jsx as Ga}from"react/jsx-runtime";var o0=s(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>Ga("div",{className:"courier-w-full node-element courier-flex",children:Ga("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=t0(Re),r=r0(()=>{if(!e.editor.isEditable)return;let o=We(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return Ga(Ye,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:Ga(o0,{...e.node.attrs})})},"DividerComponentNode");var Mt={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},Ka={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-${a0()}`,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",n0(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return i0(Dp)},addInputRules(){return[]}});import{z as an}from"zod";var Bp=an.object({padding:an.number(),color:an.string(),size:an.number(),radius:an.number(),variant:an.enum(["divider","spacer"]).default("divider")});import{zodResolver as s0}from"@hookform/resolvers/zod";import{useForm as l0}from"react-hook-form";import{Fragment as c0,jsx as _e,jsxs as sn}from"react/jsx-runtime";var Fp=s(({element:e,editor:t})=>{let r=l0({resolver:s0(Bp),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(c0,{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 h0}from"@tiptap/core";import{ReactNodeViewRenderer as b0}from"@tiptap/react";import{NodeViewWrapper as u0}from"@tiptap/react";import{forwardRef as d0,useEffect as Vp,useState as m0}from"react";import{jsx as Ya}from"react/jsx-runtime";function p0(){let[e,t]=m0(!1);return Vp(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(p0,"useMountStatus");var f0=d0(({children:e,className:t,dragOverlay:r,id:o},n)=>(Vp(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),Ya(u0,{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}))),g0=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=p0();return Ya(f0,{id:r,fadeIn:!o,children:Ya("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:Ya("div",{className:"courier-text-accent-foreground",children:g0(t)})})})},"DragPlaceholderComponent");var Up=h0.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 b0(Op,{as:"div",className:"drag-placeholder-wrapper"})}});import{Extension as y0}from"@tiptap/core";import{Plugin as C0,PluginKey as v0}from"@tiptap/pm/state";var x0=new v0("file-handler"),T0=y0.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new C0({key:x0,props:{handleDrop:(o,n,i,a)=>{var d;if(!((d=n.dataTransfer)!=null&&d.files)||a)return!1;let{files:l}=n.dataTransfer,c=o.posAtCoords({left:n.clientX,top:n.clientY});if(!c)return!1;let u=Array.from(l).filter(p=>e==null?void 0:e.includes(p.type));return u.length===0?!1:(n.preventDefault(),t&&t(this.editor,u,c.pos),!0)},handlePaste:(o,n)=>{var l;if(!((l=n.clipboardData)!=null&&l.files))return!1;let{files:i}=n.clipboardData,a=Array.from(i).filter(c=>e==null?void 0:e.includes(c.type));return a.length===0?!1:(n.preventDefault(),r&&r(this.editor,a),!0)}}})]}}),Xa=T0;import{Extension as E0}from"@tiptap/core";import{Plugin as w0,PluginKey as k0}from"@tiptap/pm/state";var P0=new k0("fixedChannelPaste"),N0=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"),M0=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"),Qa=E0.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new w0({key:P0,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!N0(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=M0(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 A0}from"@tiptap/core";import{Plugin as S0,PluginKey as I0,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"),es=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"),ts=new I0("fixedChannelSelection"),rs=A0.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(es(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(es(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 S0({key:ts,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!Po(o,this.options.channels))return!1;if(es(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(ts,{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&&es(r)){let n=ts.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(ts)||t}}})]}});import{mergeAttributes as _0}from"@tiptap/core";import{Node as L0,mergeAttributes as R0,textblockTypeInputRule as H0}from"@tiptap/core";var _p=L0.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]}`,R0(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=>H0({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 B0}from"@tiptap/react";import{useSetAtom as F0,useAtomValue as V0}from"jotai";import{useCallback as O0}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=V0(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"),os=s(e=>{let t=F0(Re),r=O0(()=>{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(B0,{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 U0}from"@hookform/resolvers/zod";import{useForm as W0}from"react-hook-form";import{jsx as ve,jsxs as Gr}from"react/jsx-runtime";var Zp=s(({element:e,editor:t})=>{let r=W0({resolver:U0(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 z0}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]}`,_0(this.options.HTMLAttributes,t),0]},addNodeView(){return z0(os)}});import{mergeAttributes as G0,Node as K0}from"@tiptap/core";import{ReactNodeViewRenderer as Y0}from"@tiptap/react";import{useSetAtom as qp}from"jotai";import{useCallback as Yt,useEffect as wc,useMemo as $0,useRef as Jp,useState as jp}from"react";import{Fragment as j0,jsx as mr,jsxs as Ec}from"react/jsx-runtime";var Z0=["image/png","image/jpeg","image/gif","image/webp"],q0=s(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderColor:n,isUploading:i,width:a,imageNaturalWidth:l,onFileSelect:c,editor:u})=>{let[d,p]=jp(!1),[m,f]=jp(!0),x=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 A,R;let T=(R=(A=u==null?void 0:u.view)==null?void 0:A.dom)==null?void 0:R.closest(".ProseMirror"),w=(T==null?void 0:T.clientWidth)||1e3,M=Math.min(100,C/w*100);return Math.round(M)},[u]),y=$0(()=>b(l),[b,l]),P=Yt(C=>Z0.includes(C),[]),g=Yt(C=>{C.preventDefault(),C.stopPropagation(),C.dataTransfer.types.includes("Files")&&Array.from(C.dataTransfer.items).some(M=>P(M.type))&&(p(!0),C.dataTransfer.dropEffect="copy")},[P]),k=Yt(C=>{C.preventDefault(),C.stopPropagation(),p(!1)},[]),N=Yt(C=>{C.preventDefault(),C.stopPropagation(),C.dataTransfer.types.includes("Files")&&Array.from(C.dataTransfer.items).some(M=>P(M.type))&&p(!0)},[P]),v=Yt(C=>{C.preventDefault(),C.stopPropagation(),p(!1);let w=Array.from(C.dataTransfer.files).find(M=>P(M.type));w&&c&&c(w)},[c,P]),L=Yt(C=>{var w;let T=(w=C.target.files)==null?void 0:w[0];T&&c&&c(T),C.target&&(C.target.value="")},[c]),E=Yt(()=>{var C;(C=x.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:N,onDragLeave:k,onDrop:v,style:{pointerEvents:"all"},children:[i?mr(fo,{className:"courier-w-8 courier-h-8"}):Ec(j0,{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:x,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||m)&&"courier-w-full courier-aspect-[4/3] courier-bg-gray-100"),children:[(i||m)&&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||m)&&"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 p,m,f;let c=(f=(m=(p=e.editor)==null?void 0:p.view)==null?void 0:m.dom)==null?void 0:f.closest(".ProseMirror"),u=(c==null?void 0:c.clientWidth)||1e3,d=Math.min(100,l/u*100);return Math.round(d)},[e.editor]);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 p=l.attrs.width||n(d.naturalWidth),m=jr(e.getPos);m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{width:p,imageNaturalWidth:d.naturalWidth}).run()},d.src=l.attrs.sourcePath}},[e,n]);let i=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 m=(await o({file:l})).url,f=jr(e.getPos);if(We(e)&&f!==null){let h=new Image;h.src=m,await new Promise((y,P)=>{h.onload=y,h.onerror=()=>P(new Error("Failed to load uploaded image"))});let b=n(h.naturalWidth);e.editor.chain().focus().setNodeSelection(f).updateAttributes("imageBlock",{sourcePath:m,isUploading:!1,width:b,imageNaturalWidth:h.naturalWidth}).run()}}catch(d){console.error("Error uploading image:",d);let p="Error uploading image";if(d instanceof Error){let x=d.message;x.includes("GraphQL error")?p="Server error: Could not process image":x.includes("network")||x.includes("fetch")?p="Network error: Could not upload image":p=x}r({message:p,toastProps:{duration:6e3,description:`File: ${l.name} (${(l.size/1024/1024).toFixed(2)}MB)`}});let m=jr(e.getPos);We(e)&&m!==null&&e.editor.chain().focus().setNodeSelection(m).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(q0,{...e.node.attrs,onFileSelect:a,editor:e.editor})})},"ImageBlockView");var De={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderColor:"transparent",isUploading:!1,imageNaturalWidth:0},ns=K0.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:De.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:De.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:De.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:De.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:De.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:De.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:De.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:De.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:De.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",G0(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return Y0(Gp)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...De,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...De,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 X0}from"@hookform/resolvers/zod";import{useSetAtom as Q0}from"jotai";import{ArrowUp as e3}from"lucide-react";import{useCallback as Ti,useEffect as Xp,useRef as Pc,useState as as}from"react";import{useForm as t3}from"react-hook-form";import{useSetAtom as kc}from"jotai";import*as xi from"react";import{useRef as Yp}from"react";import{jsx as is}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]),p=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]),m=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:p,onSelect:m};return is("div",{ref:i,className:"courier-relative",children:is(pe,{...h})})}let x={...o,ref:h=>{a.current=h,typeof n=="function"?n(h):n&&(n.current=h)},onChange:f,onFocus:d,onBlur:p,autoResize:t,onSelect:m};return is("div",{ref:i,className:"courier-relative",children:is(yl,{...x})})});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,E;let r=Pc(null),o=Pc(null),n=Pc(null),[i,a]=as(""),[l,c]=as(!1),[u,d]=as(((L=e==null?void 0:e.attrs)==null?void 0:L.imageNaturalWidth)||0),[p,m]=as(!1),f=Q0(Q),{uploadImage:x}=On(),h=t3({resolver:X0(Kp),defaultValues:{...De,...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 w=new Image;w.onload=()=>{d(w.naturalWidth);let M={...h.getValues(),imageNaturalWidth:w.naturalWidth};h.setValue("imageNaturalWidth",w.naturalWidth),b(M)},w.src=C}},[(E=e==null?void 0:e.attrs)==null?void 0:E.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"),w=(T==null?void 0:T.clientWidth)||1e3;if(C||(C=u),!C)return 0;let M=Math.min(100,C/w*100);return Math.round(M)},[t,u]),P=Ti(C=>{var T;C.preventDefault(),(T=r.current)==null||T.click()},[]),g=Ti((C,T)=>{let w=y(C.naturalWidth);a(`${w}%`),c(!1),h.setValue("sourcePath",T),h.setValue("imageNaturalWidth",C.naturalWidth),h.setValue("width",w);let M={...h.getValues(),sourcePath:T,width:w,imageNaturalWidth:C.naturalWidth,isUploading:!1};b(M)},[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 w=y(T.naturalWidth);h.setValue("imageNaturalWidth",T.naturalWidth),h.setValue("width",w);let M={...h.getValues(),sourcePath:C,width:w,imageNaturalWidth:T.naturalWidth};b(M)},T.onerror=()=>{console.debug("Image failed to load:",C)},T.src=C},[h,b,y]),N=Ti(C=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{k(C)},500)},[k]);Xp(()=>()=>{n.current&&clearTimeout(n.current)},[]);let v=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:P,className:"courier-w-full",variant:"outline",type:"button",disabled:p,children:p?G(Qp,{children:"Uploading..."}):et(Qp,{children:[G(e3,{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 T=(w=C.target.files)==null?void 0:w[0];if(T){m(!0),h.setValue("sourcePath",""),b({...h.getValues(),sourcePath:"",isUploading:!0});let M=new FileReader;M.onload=async()=>{try{let R=(await x({file:T})).url,I=new Image;I.onload=()=>{g(I,R),m(!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)`}}),m(!1),b({...h.getValues(),isUploading:!1})},I.src=R}catch(A){console.error("Error uploading image:",A),f({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${T.name} (${(T.size/1024/1024).toFixed(2)}MB)`}}),m(!1),b({...h.getValues(),isUploading:!1})}},M.onerror=()=>{f({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${T.name} (${(T.size/1024/1024).toFixed(2)}MB)`}}),m(!1),b({...h.getValues(),isUploading:!1})},M.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),N(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,w=y(T),M=C===w,A=M?"original":"fill";return et(qt,{type:"single",value:v?A:"original",onValueChange:R=>{if(!R||R===A)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:!v,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:M||!v,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 w=parseFloat(T.target.value.replace("%",""));if(!isNaN(w)){let M=Math.min(100,Math.max(1,w));C.onChange(M),b({...h.getValues(),width:Math.round(M)})}}})}),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(hl,{min:0,max:100,value:[v?C.value:0],disabled:!v,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:!v,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(Va,{className:"courier-h-4 courier-w-4"})}),G(lt,{size:"sm",value:"center",className:"courier-w-full",children:G(Oa,{className:"courier-h-4 courier-w-4"})}),G(lt,{size:"sm",value:"right",className:"courier-w-full",children:G(Ua,{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:!v,min:0,...C,onChange:T=>{let w=parseInt(T.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:!v,defaultValue:De.borderColor,onChange:T=>{C.onChange(T),b({...h.getValues(),[C.name]:T})}})}),G(j,{})]})})]})]}):null},"ImageBlockForm");import{getMarkRange as tf,mergeAttributes as r3}from"@tiptap/core";import o3 from"@tiptap/extension-link";import{Plugin as rf,TextSelection as of}from"@tiptap/pm/state";var Nc=o3.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",r3(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 p=d.replace(/__VAR_([^_]+)__/g,"{{$1}}");if(p!==d){let m=tf(n.doc.resolve(c),u.type);m&&(i.removeMark(m.from,m.to,u.type),i.addMark(m.from,m.to,u.type.create({...u.attrs,href:p,hasVariables:!0,originalHref:p})),a=!0)}}}}),!0)),a?i:null}})]}});import{zodResolver as n3}from"@hookform/resolvers/zod";import{useSetAtom as i3}from"jotai";import{useRef as a3,useEffect as s3}from"react";import{useForm as l3}from"react-hook-form";import{z as Mc}from"zod";import{jsx as Mo,jsxs as nf}from"react/jsx-runtime";var c3=Mc.object({href:Mc.string(),openInNewTab:Mc.boolean().default(!1)}),af=s(({editor:e,mark:t,pendingLink:r})=>{let o=i3(la),n=a3(null),i=l3({resolver:n3(c3),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1}});s3(()=>{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 b3,ReactNodeViewRenderer as y3}from"@tiptap/react";import{TextSelection as C3,Plugin as v3,PluginKey as x3}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:"'"},ls={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},u3=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),d3=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),ls[He]=String.fromCharCode(He);var He;for(ss in Mr)ls.hasOwnProperty(ss)||(ls[ss]=Mr[ss]);var ss;function sf(e){var t=u3&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||d3&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?ls: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 m3}from"prosemirror-state";var p3=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function f3(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))p3?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(f3,"normalizeKeyName");function g3(e){let t=Object.create(null);for(let r in e)t[f3(r)]=e[r];return t}s(g3,"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 m3({props:{handleKeyDown:h3(e)}})}s(lf,"keymap");function h3(e){let t=g3(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(h3,"keydownHandler");import{v4 as T3}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-${T3()}`;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",b3(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return y3(os)},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(C3.create(t.doc,i,a)),!0}return!1}}),new v3({key:new x3("preventElementDeletion"),props:{handleKeyDown:(e,t)=>{let r=t.key==="Delete"||t.key==="Backspace"||t.keyCode===8||t.keyCode===46||t.code==="Delete"||t.code==="Backspace",o=t.metaKey||t.ctrlKey||t.altKey;if(r){let{state:n}=e,{selection:i}=n,{$anchor:a}=i,l=a.depth,c=null;for(;l>0;){let u=a.node(l);if(u.type.name==="paragraph"||u.type.name==="heading"){c=u;break}l--}if(c){let u=c.textContent,d=a.parentOffset===0,p=a.parentOffset===u.length,m=u.length===0,f=t.key==="Delete"||t.keyCode===46||t.code==="Delete",x=f?i.$from.nodeAfter:i.$from.nodeBefore,h=x!=null;if(h&&m)return!1;if(o||m&&!h||!f&&d&&!h||f&&p&&!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 m=n.node(a);if(m.type.name==="paragraph"||m.type.name==="heading"){l=m;break}a--}if(!l)return!1;let c=r?n.pos===i.pos&&n.parentOffset===0:n.pos===i.pos&&n.parentOffset===l.textContent.length,u=l.textContent.length===0,d=r?t.state.selection.$from.nodeBefore:t.state.selection.$from.nodeAfter,p=d!=null;return p&&u?!1:c&&!p||u&&!p?!0:o?!1:(t.commands.command(({tr:m,dispatch:f})=>f?(m.insertText("",t.state.selection.from,t.state.selection.to),!0):!1),!0)},"handleDeletion");return{Enter:({editor:t})=>{if(t.view.dom.querySelector(".variable-suggestion")||t.view.state.selection.$from.node().type.spec.code)return!1;let{state:o,dispatch:n}=t.view,{tr:i}=o;return i.replaceSelectionWith(o.schema.nodes.hardBreak.create()).scrollIntoView(),n(i),!0},"Mod-a":({editor:t})=>{let{$from:r}=t.state.selection,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),a=r.end(o);return t.commands.setTextSelection({from:i,to:a}),!0}o--}return!1},Backspace:({editor:t})=>e(t,!0),Delete:({editor:t})=>e(t,!1),Tab:()=>!0,"Shift-Tab":()=>!0}},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setTextAlign:t=>({chain:r})=>r().updateAttributes(this.name,{textAlign:t}).run()}}});import{Extension as E3}from"@tiptap/core";import{Plugin as w3,PluginKey as k3}from"@tiptap/pm/state";var P3=new k3("selection"),Ic=E3.create({name:"selection",addOptions(){return{HTMLAttributes:{},setSelectedNode:()=>{},shouldHandleClick:()=>!0}},addGlobalAttributes(){return[{types:["paragraph","heading","button","spacer","divider","imageBlock","blockquote","customCode","column"],attributes:{isSelected:{default:!1,parseHTML:()=>!1,renderHTML:e=>e.isSelected?{class:"selected-element"}:{}}}}]},addCommands(){return{updateSelectionState:e=>({tr:t,dispatch:r})=>{var o,n;if(r){let i=(o=e==null?void 0:e.attrs)==null?void 0:o.id,a=(n=e==null?void 0:e.type)==null?void 0:n.name;t.doc.descendants((l,c)=>{var u,d,p;if(l.type.name!=="text"&&((u=l.type.spec.attrs)==null?void 0:u.isSelected)!==void 0){let m=!1;i?m=((d=l.attrs)==null?void 0:d.id)===i&&l.type.name===a:a&&(m=l.type.name===a&&l.content.size===((p=e==null?void 0:e.content)==null?void 0:p.size)),m?t.setNodeAttribute(c,"isSelected",!0):t.setNodeAttribute(c,"isSelected",!1)}return!0})}return!0}}},addProseMirrorPlugins(){return[new w3({key:P3,props:{handleClick:(e,t,r)=>{let{state:o}=e;if(!this.editor.isEditable||this.options.shouldHandleClick&&!this.options.shouldHandleClick())return!1;let n=r.target;if(n.closest(".node-blockquote")||n.closest('[data-cypress="draggable-handle"]')||n.closest('button[class*="courier-cursor-grab"]'))return!1;try{let l=window.getSelection();if(l&&l.rangeCount>0){let u=l.getRangeAt(0).startContainer.parentElement;if(u&&(["P","H1","H2","H3"].includes(u.tagName)||["P","H1","H2","H3"].some(d=>u.closest(d)))){let d=e.posAtDOM(u,0),m=o.doc.resolve(d).node();if(m&&["paragraph","heading"].includes(m.type.name))return this.options.setSelectedNode(m),this.editor.commands.updateSelectionState(m),!0}}}catch(l){console.error("Error handling click:",l)}let i=e.posAtDOM(n,0),a=o.doc.resolve(i).node();return a&&["paragraph","heading"].includes(a.type.name)?(this.options.setSelectedNode(a),this.editor.commands.updateSelectionState(a),!0):!1}}})]}});import{forwardRef as N3}from"react";import{jsx as M3}from"react/jsx-runtime";var Lc=N3(({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 M3("div",{className:a,...n,ref:i,children:e})});Lc.displayName="Surface";import{v4 as A3}from"uuid";var S3=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-${A3()}`,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({...Ka,...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({...De,...o,id:a}),image:()=>e.schema.nodes.imageBlock.create({...De,...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 m=S3(e,a);m!==null&&e.commands.setTextSelection(m+1),e.view.focus()},50);let p=new CustomEvent("node-duplicated",{detail:{newNodeId:a}});document.dispatchEvent(p)}catch(u){console.error("Error creating node:",u)}else try{if(e.schema.nodes[t]){let u=e.state.tr,d=e.schema.nodes[t].create({...o,id:a},i);u.insert(r,d),e.view.dispatch(u),n&&n(d);let p=new CustomEvent("node-duplicated",{detail:{newNodeId:a}});document.dispatchEvent(p)}else console.error(`Cannot duplicate node: type "${t}" not found in schema`)}catch(u){console.error("Error creating fallback node:",u)}return a},"createOrDuplicateNode");var 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 I3}from"lucide-react";import{forwardRef as L3}from"react";import{jsx as bf}from"react/jsx-runtime";var yf=L3((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(I3,{strokeWidth:1,className:"courier-w-5 courier-stroke-neutral-400 courier-fill-neutral-400 courier-pointer-events-none"})}));import{useAtomValue as H3,useSetAtom as D3}from"jotai";import{useCallback as At}from"react";import{v4 as B3}from"uuid";import{useMemo as R3}from"react";var Cf=s((e,t,r)=>R3(()=>{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 cs=s((e,t,r)=>{let o=D3(Re),n=H3(ge),i=Cf(t,e,r),a=At(g=>{let k=-1;return e.state.doc.descendants((N,v)=>{var L;return((L=N.attrs)==null?void 0:L.id)===g?(k=v,!1):!0}),k},[e]),l=At((g,k)=>{var N,v,L;if(((N=n==null?void 0:n.type)==null?void 0:N.name)==="button"&&((v=n.attrs)!=null&&v.id)){let E=n.attrs.id,C=a(E);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 w=a(E);if(w>=0){let M=e.state.doc.nodeAt(w);M&&o(M)}},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 N=n.attrs.id,v=a(N);if(v>=0){let L=e.state.doc.nodeAt(v);if(!L)return!1;let E={...L.attrs,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},C=e.state.tr;return C.setNodeMarkup(v,void 0,E),e.view.dispatch(C),setTimeout(()=>{let T=a(N);if(T>=0){let w=e.state.doc.nodeAt(T);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 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 N=e.chain().focus();return k.action.targets.forEach(v=>{v==="italic"&&r.isItalic&&N.toggleItalic()}),N.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 N=e.chain().focus();return k.action.targets.forEach(v=>{v==="bold"&&r.isBold&&N.toggleBold()}),N.toggleItalic().run(),!0}}return e.chain().focus().toggleItalic().run()},[e,n,l,i,r]),p=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]),m=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]),x=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]),P=At(()=>{let g=e.isActive("blockquote");if(e.chain().focus().toggleBlockquote().run()){let{selection:v}=e.state,L=v.$anchor;if(g){let E=L.node();(E.type.name==="paragraph"||E.type.name==="heading")&&o(E)}else for(let E=L.depth;E>0;E--){let C=L.node(E);if(C.type.name==="blockquote"){if(C.attrs.id)o(C);else{let T=L.before(E),w=`node-${B3()}`,M=e.state.tr;M.setNodeMarkup(T,void 0,{...C.attrs,id:w}),e.view.dispatch(M);let A=e.state.doc.nodeAt(T);A&&o(A)}break}}}},[e,o]);return{onBold:u,onItalic:d,onStrike:p,onUnderline:m,onAlignLeft:f,onAlignCenter:x,onAlignRight:h,onAlignJustify:b,onLink:y,onQuote:P,resetButtonFormatting:c}},"useTextmenuCommands");import{jsx as Rc}from"react/jsx-runtime";var F3=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"),us=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:F3(e)})})}),"DropIndicatorPlaceholder");import{Fragment as $3,jsx as St,jsxs as ds}from"react/jsx-runtime";function _3(){let[e,t]=ms(!1);return Hc(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(_3,"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]=ms(!1),[p,m]=ms(null),[f,x]=ms(null),h=Yr(null),b=Yr(!1),y=Yr(null),P=Yr(null),g=Yr(null),k=_3(),N=u&&!k,v=Ao(()=>{if(!o||!t)return null;let E=null;return o.state.doc.descendants((C,T,w)=>{var M;if(((M=C.attrs)==null?void 0:M.id)===t){let A=0;return w&&w.content.forEach((R,I,H)=>{R===C&&(A=H)}),E={node:C,pos:T,parent:w,index:A},!1}return!0}),E},[t,o]),L=Ao(()=>{if(!o)return!1;let E=v();return!E||!E.parent?!1:E.index===E.parent.childCount-1},[o,v]);return Hc(()=>{let E=a.current,C=l.current;if(!E)return;let T=sr(gi({element:E,dragHandle:C||void 0,getInitialData:()=>{var I,H,V,F,O,D;let w=v(),M="text";if(w){let W=w.node;switch(W.type.name){case"heading":M="heading";break;case"paragraph":M="text";break;case"imageBlock":M="image";break;case"divider":M=(I=W.attrs)!=null&&I.spacer?"spacer":"divider";break;case"button":M="button";break;case"customCode":M="customCode";break;case"column":M="column";break}}let A=(w==null?void 0:w.parent)===o.state.doc,R=((H=w==null?void 0:w.parent)==null?void 0:H.type.name)==="columnCell";return{id:t,type:A?"editor":R?"column-cell-item":"nested-drag",index:(V=w==null?void 0:w.index)!=null?V:0,dragType:M,pos:w==null?void 0:w.pos,originalIndex:(F=w==null?void 0:w.index)!=null?F:0,columnId:R?(O=w==null?void 0:w.parent)==null?void 0:O.attrs.columnId:void 0,cellIndex:R?(D=w==null?void 0:w.parent)==null?void 0:D.attrs.index:void 0}},onGenerateDragPreview:()=>{let w=E.querySelectorAll("[data-no-drag-preview]"),M=[];w.forEach((A,R)=>{let I=A;M[R]=I.style.display,I.style.display="none"}),requestAnimationFrame(()=>{w.forEach((A,R)=>{let I=A;I.style.display=M[R]})})},onDragStart:()=>{d(!0),document.body.style.cursor="grabbing";let w=s(M=>{P.current=M.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:M})=>{var D,W,U,ie;let A=v(),R=(A==null?void 0:A.parent)===o.state.doc,I=((D=A==null?void 0:A.parent)==null?void 0:D.type.name)==="columnCell",H={id:t,type:R?"editor":I?"column-cell-item":"nested-drag",index:(W=A==null?void 0:A.index)!=null?W:0,pos:A==null?void 0:A.pos,nodeType:A==null?void 0:A.node.type.name,columnId:I?(U=A==null?void 0:A.parent)==null?void 0:U.attrs.columnId:void 0,cellIndex:I?(ie=A==null?void 0:A.parent)==null?void 0:ie.attrs.index:void 0};if(M.getAttribute("data-node-type")==="column"){let ee=M.getBoundingClientRect(),K=w.clientY,B=30,z=Math.abs(K-ee.top),oe=Math.abs(K-ee.bottom);if(z>B&&oe>B)return{...H,disableDropIndicator:!0}}let F=M.closest('[data-column-cell="true"]');if(L()&&E){let ee=E.getBoundingClientRect(),K=w.clientY,B=ee.top+ee.height/2;if(K>=B&&K>ee.bottom)return{...H,[Symbol.for("closestEdge")]:"bottom"}}let O=L()?["top","bottom"]:["top"];return Gm(H,{input:w,element:M,allowedEdges:O})},canDrop:({source:w})=>w.data.id!==t,onDragEnter:({self:w,source:M,location:A})=>{var W,U,ie,ee,K;if(w.data.disableDropIndicator){m(null);return}y.current&&(clearTimeout(y.current),y.current=null);let R=A.current.dropTargets;if(R.length>0&&R[0].element!==E){m(null),b.current=!1,h.current=null;return}let I=hi(w.data),H=I,V=L(),F=(ie=(U=(W=A==null?void 0:A.current)==null?void 0:W.input)==null?void 0:U.clientY)!=null?ie:P.current;F!==null&&(P.current=F);let O=M.data;x(O.dragType||null),I==="bottom"&&V&&M.data.id===t&&(H=null);let D=M.data.type==="editor"||M.data.type==="column-cell-item";if(V&&D)if(I==="top"){let B=a.current;if(B){let z=B.getBoundingClientRect(),oe=(ee=F!=null?F:P.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&&!D&&(b.current=!1);if(!b.current&&(M.data.type==="editor"||M.data.type==="column-cell-item")&&typeof M.data.index=="number"){let B=M.data.index,z=v();((K=z==null?void 0:z.index)!=null?K:0)===B+1&&I==="top"&&(H=null)}H!==h.current&&(h.current=H,m(H))},onDrag:({self:w,source:M,location:A})=>{var W,U,ie,ee,K;if(w.data.disableDropIndicator){m(null);return}y.current&&(clearTimeout(y.current),y.current=null);let R=A.current.dropTargets;if(R.length>0&&R[0].element!==E){m(null);return}let I=(ie=(U=(W=A==null?void 0:A.current)==null?void 0:W.input)==null?void 0:U.clientY)!=null?ie:P.current;I!==null&&(P.current=I);let H=hi(w.data),V=H,F=L(),O=M.data;x(O.dragType||null),H==="bottom"&&F&&M.data.id===t&&(V=null);let D=M.data.type==="editor"||M.data.type==="column-cell-item";if(F&&D)if(H==="top"){let B=a.current;if(B){let z=B.getBoundingClientRect(),oe=(ee=I!=null?I:P.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&&!D&&(b.current=!1);if(!b.current&&(M.data.type==="editor"||M.data.type==="column-cell-item")&&typeof M.data.index=="number"){let B=M.data.index,z=v();((K=z==null?void 0:z.index)!=null?K:0)===B+1&&H==="top"&&(V=null)}V!==h.current&&(h.current=V,m(V))},onDragLeave:()=>{if(L()&&b.current){let w=E==null?void 0:E.getBoundingClientRect(),M=P.current;if(w&&M!==null&&M>=w.bottom-10)return;y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{b.current=!1,h.current=null,m(null),x(null),y.current=null},150)}else y.current&&(clearTimeout(y.current),y.current=null),b.current=!1,h.current=null,m(null),x(null)},onDrop:()=>{y.current&&(clearTimeout(y.current),y.current=null),b.current=!1,h.current=null,m(null),x(null)}}));return()=>{y.current&&(clearTimeout(y.current),y.current=null),T()}},[t,L,o,v]),St(z3,{ref:a,id:t,fadeIn:N,className:r,dragging:u,closestEdge:p,dragType:f,handleRef:l,contentRef:c,editor:o,...i,children:e})},"SortableItemWrapper"),z3=U3(({children:e,className:t,dragOverlay:r,handleRef:o,contentRef:n,closestEdge:i,dragType:a,id:l,editor:c,fadeIn:u,dragging:d,...p},m)=>{Hc(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let f=O3(ge),{resetButtonFormatting:x}=cs(c),h=s((v,L)=>{let E=null;return v.doc.descendants((C,T)=>{var w;return E!==null?!1:((w=C.attrs)==null?void 0:w.id)===L?(E=T,!1):!0}),E},"findNodePositionById"),b=Ao(()=>{if(!c||!l)return{node:null,pos:null};let v=h(c.state,l);return v===null?{node:null,pos:null}:{node:c.state.doc.nodeAt(v),pos:v}},[c,l]),y=Ao(()=>{c.commands.blur(),f(null)},[c,f]),P=Ao(()=>{if(!(!c||!l))try{let{node:v,pos:L}=b();if(!v||L===null)return;let E=v.nodeSize,C=c.state.doc.childCount===1;f(null),c.commands.updateSelectionState(null);let T=c.state.tr;T.delete(L,L+E),T.setMeta("addToHistory",!0),c.view.dispatch(T),C&&setTimeout(()=>{let w=c.state.doc.nodeAt(0);if(w&&w.type.name==="paragraph"&&!w.attrs.id){let M=`node-${W3()}`,A=c.state.tr;A.setNodeMarkup(0,void 0,{...w.attrs,id:M}),c.view.dispatch(A);let R=new CustomEvent("node-duplicated",{detail:{newNodeId:M}});document.dispatchEvent(R)}},50)}catch(v){console.error("Error deleting node:",v)}},[c,l,b,f]),g=Ao(()=>{if(!(!c||!l))try{let{node:v,pos:L}=b();if(!v||L===null)return;if(v.type.name==="button"){x();return}let E=v.type.name==="blockquote",C=v.type.name==="heading";!E&&!C&&y(),setTimeout(()=>{if(C){let w=L+1,M=L+v.nodeSize-1;c.chain().setTextSelection({from:w,to:M}).unsetAllMarks().blur().run(),f(null),c.commands.updateSelectionState(null);return}let T=c.chain();if(T.setNodeSelection(L).unsetAllMarks(),E&&v.content&&v.content.firstChild?v.content.firstChild.type.name!=="paragraph"&&T.setParagraph():v.type.name!=="paragraph"&&!E&&T.setParagraph(),T.run(),E){let w=b();w.node&&w.pos!==null&&(f(w.node),c.commands.updateSelectionState(w.node))}},100)}catch(v){console.error("Error removing formatting:",v)}},[c,l,b,y,x,f]),k=Ao(()=>{if(!(!c||!l))try{y(),setTimeout(()=>{let{node:v,pos:L}=b();if(!v||L===null)return;let E=v.type.name,C={...v.attrs};delete C.id;let T=L+(v==null?void 0:v.nodeSize);hf(c,E,T,C,w=>f(w),v.content)},100)}catch(v){console.error("Error duplicating node:",v)}},[c,l,b,y,f]),{node:N}=b();return ds(V3,{ref:m,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":l,className:S("courier-flex courier-flex-col courier-relative draggable-item",t),...p,children:[i==="top"&&St(us,{type:a}),ds("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}),ds("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:[(N==null?void 0:N.type.name)!=="imageBlock"&&(N==null?void 0:N.type.name)!=="divider"&&(N==null?void 0:N.type.name)!=="spacer"&&(N==null?void 0:N.type.name)!=="button"&&(N==null?void 0:N.type.name)!=="column"&&(N==null?void 0:N.type.name)!=="customCode"&&ds($3,{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:v=>{v.preventDefault(),v.stopPropagation()},onClick:v=>{v.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:v=>{v.preventDefault(),v.stopPropagation()},onClick:v=>{v.stopPropagation(),k()},tabIndex:-1,children:St(Nl,{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:v=>{v.preventDefault(),v.stopPropagation()},onClick:v=>{v.stopPropagation(),P()},tabIndex:-1,children:St(Jn,{color:"currentColor"})})]})]}),i==="bottom"&&St(us,{type:a})]})});import{jsx as ln}from"react/jsx-runtime";var j3=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=q3(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(j3,{...e.node.attrs,children:ln(Z3,{as:"span"})})})},"ButtonComponentNode");import{v4 as X3}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"},Wa=K3.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-${X3()}`,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",G3(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return Y3(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 Q3}from"uuid";import{useAtomValue as xf,useSetAtom as Tf,useAtom as ey}from"jotai";import{useCallback as cn,useRef as Ef,useState as ps,useEffect as ty}from"react";var un=s(({items:e,setItems:t,editor:r})=>{let[o]=ps(null),[n,i]=ps(null),[a,l]=ps(null),[c]=ps("outer"),u=Ef([]),d=Ef([]),p=xf(Te),m=Tf(pt),[f,x]=ey(X),h=Tf(Ae),b=xf(Ur),y=r||p,P=cn(()=>{if(!y)return;let E=y.getJSON(),C=me(E),T=Ve(f,{channel:b,elements:C});x(T),h(T)},[y,b,f,x,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]),k=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 T=0;for(let w=0;w<Math.min(E,C.childCount);w++){let M=C.child(w);T+=M.nodeSize}return T}catch(C){return console.error("Error calculating document position:",C),0}},[y==null?void 0:y.state.doc]),N=cn(E=>{let C={};switch(E){case"text":C=ue;break;case"heading":C={};break;case"image":C=De;break;case"button":C=Ie;break;case"divider":C=Mt;break;case"spacer":C=Ka;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:Q3()}};return E==="button"&&(w.content=[{type:"text",text:"Button"}]),w},[]),v=cn((E,C)=>{if(!y)return;let{columnId:T,index:w,isEmpty:M}=C,A=null,R=0,I=-1;if(E.type==="sidebar"){if(!E.dragType)return;A=N(E.dragType)}else if(E.type==="editor"){if(y.state.doc.descendants((D,W)=>D.attrs.id===E.id?(I=W,A=D.toJSON(),R=D.nodeSize,!1):!0),I===-1){let D=e.Editor.findIndex(W=>W===E.id);if(D!==-1){I=k(D);let W=y.state.doc.nodeAt(I);W&&(A=W.toJSON(),R=W.nodeSize)}}if(I!==-1){let D=e.Editor.filter(W=>W!==E.id);D.length!==e.Editor.length&&t({...e,Editor:D})}}if(!A)return;let H=-1,V=null;if(y.state.doc.descendants((D,W)=>D.type.name==="column"&&D.attrs.id===T?(H=W,V=D,!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),M){let D=y.schema,W=Array.from({length:F.attrs.columnsCount},(ie,ee)=>D.nodes.columnCell.create({index:ee,columnId:T,isEditorMode:!1},ee===w?[D.nodeFromJSON(A)]:[])),U=D.nodes.columnRow.create({},W);O.replaceWith(H+1,H+F.nodeSize-1,U)}else{let D=H+1;F.content.forEach(W=>{if(W.type.name==="columnRow"){let U=D+1;W.content.forEach((ie,ee,K)=>{if(K===w){let B=U+ie.nodeSize-1;O.insert(B,y.schema.nodeFromJSON(A))}U+=ie.nodeSize})}D+=W.nodeSize})}y.view.dispatch(O),P()},[y,e,t,k,N,P]),L=cn((E,C)=>{try{if(E.type==="sidebar"&&(C.type==="editor"||C.type==="column-cell-item"||C.type==="nested-drag")){let T=E.dragType;if(!T||!y)return;let w=C.insertPos;if(w===void 0)if(C.type==="editor"){let R=C.index+1;w=k(R)}else{console.warn("Nested drop without position data");return}let M=N(T);if(y.commands.insertContentAt(w,M),y.state.doc.resolve(w).depth===0){let R=y.state.doc.resolve(w).index(0),I=[...e.Editor];R<=I.length&&(I.splice(R,0,M.attrs.id),t({...e,Editor:I}))}P();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 T=-1,w=null;if(E.pos!==void 0&&(T=E.pos,w=y.state.doc.nodeAt(T)),(T===-1||!w)&&y.state.doc.descendants((I,H)=>I.attrs.id===E.id?(T=H,w=I,!1):!0),T===-1||!w){let I=e.Editor.findIndex(H=>H===E.id);I!==-1&&(T=k(I),w=y.state.doc.nodeAt(T))}if(!w||T===-1)return;let M=C.insertPos;if(M===void 0){let I;C.index===void 0?I=y.state.doc.childCount:C.index===-1?I=0:I=C.index+1,M=k(I)}if(M===void 0||M>T&&M<T+w.nodeSize)return;if(M>T){let I=M-w.nodeSize;y.chain().deleteRange({from:T,to:T+w.nodeSize}).insertContentAt(I,w.toJSON()).run()}else y.chain().insertContentAt(M,w.toJSON()).deleteRange({from:T+w.nodeSize,to:T+w.nodeSize*2}).run();let A=e.Editor.includes(E.id);if(A){let I=e.Editor.filter(H=>H!==E.id);t({...e,Editor:I})}let R=y.state.doc.resolve(M).depth===0;P()}}catch(T){console.error("[Pragmatic DnD] Error in handleDrop:",T)}},[e,y,t,k,P,N]);return ty(()=>ec({onDragStart:({source:E})=>{let C=E.data;m(!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(M=>M.getBoundingClientRect()));let w=y==null?void 0:y.view.dom.querySelectorAll("[data-node-view-wrapper]");if(w){let M=new Set,A=Array.from(w).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 M.has(Math.round(F))?!1:(M.add(Math.round(F)),!0)});d.current=A.map(R=>R.getBoundingClientRect())}},onDrop:({source:E,location:C})=>{let T=E.data,w=C.current.dropTargets[0];if(!w){g(),m(!1),l(null),i(null);return}let M=w.data;if(M.type==="column-cell"){v(T,M),m(!1),l(null),i(null),g();return}let A=M,R=hi(w.data);if(A.pos!==void 0&&R&&y){let I=y.state.doc.nodeAt(A.pos);I&&(R==="top"?A.insertPos=A.pos:R==="bottom"&&(A.insertPos=A.pos+I.nodeSize))}if(A.insertPos===void 0&&R&&A.index!==void 0){let I=R==="top"?A.index-1:A.index;A={...A,index:I}}else if(A.index===void 0&&A.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,B=Math.abs(H-K);B<F&&(F=B,V=ee)});let O=d.current[V],D=O.top+O.height/2,U=H>=D?V:V-1;A={...A,index:U,fromCoordinates:!0}}else A={...A,index:(y==null?void 0:y.state.doc.childCount)||0}}L(T,A),m(!1),l(null),i(null),g()}}),[y,m,g,l,i,L,v]),{activeId:a,activeDragType:n,dndMode:c,lastPlaceholderIndex:o,cleanupPlaceholder:g}},"usePragmaticDnd");import{useCallback as ry,useEffect as oy}from"react";import{useAtomValue as ny}from"jotai";var fs=s(({setItems:e,rafId:t,editor:r})=>{let o=ny(Te),n=r||o,i=ry(a=>{t.current&&typeof cancelAnimationFrame!="undefined"&&cancelAnimationFrame(t.current);let l=setTimeout(()=>{if(typeof requestAnimationFrame!="undefined")t.current=requestAnimationFrame(()=>{try{let c=a==null?void 0:a.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(p=>{let m=p,f=m.dataset.id;if(f){let x=m.parentElement,h=!1;for(;x&&x!==c;){if(x.hasAttribute("data-column-cell")){h=!0;break}x=x.parentElement}h||d.push(f)}}),e(p=>({Editor:d,Sidebar:p.Sidebar}))}catch(c){console.error("Error syncing editor items:",c),e(u=>({...u}))}});else try{let c=a==null?void 0:a.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(p=>{let m=p,f=m.dataset.id;if(f){let x=m.parentElement,h=!1;for(;x&&x!==c;){if(x.hasAttribute("data-column-cell")){h=!0;break}x=x.parentElement}h||d.push(f)}}),e(p=>({Editor:d,Sidebar:p.Sidebar}))}catch(c){console.error("Error syncing editor items:",c)}},50);return()=>clearTimeout(l)},[e,t]);return oy(()=>{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 cy,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:""}],ly=ay(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:a,colorScheme:l,hidePreviewPanelExitButton:c,...u},d)=>{let p=So(Te),[m,f]=Dc(ge),[x,h]=Dc(ao),b=Ei({}),[y,P]=Bc(c?"desktop":void 0),g=So(Fe),k=So(ae),N=So(Lu),v=So(ar),L=Ei(-1),E=iy(rm),C=Ei(!1),T=Ei(!1),[w]=Dc(X),M=So(Jt),A=So(ze),[R,I]=Bc({Editor:[],Sidebar:["heading","text","image","spacer","divider","button","customCode"]}),H=Ei(null);un({items:R,setItems:I,editor:p});let{syncEditorItems:V}=fs({setItems:I,rafId:H,editor:p});Xr(()=>{A&&(T.current=!1)},[A]);let[F,O]=Bc(!1);Xr(()=>{if(k===!1||k===null){let B=setTimeout(()=>{O(!0)},100);return()=>clearTimeout(B)}else O(!1)},[k,F]),Xr(()=>{if(m){let B=m.type.name,z=aa(B);E({nodeName:B,config:z})}},[m,E]);let D=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(v)return v;let B=(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=B==null?void 0:B.colors)==null?void 0:Pe.primary)||"#000000",textColor:((Me=B==null?void 0:B.colors)==null?void 0:Me.secondary)||"#000000",subtleColor:((Et=B==null?void 0:B.colors)==null?void 0:Et.tertiary)||"#666666",headerStyle:(se=(wt=B==null?void 0:B.email)==null?void 0:wt.header)!=null&&se.barColor?"border":"plain",logo:(it=(ye=(Ee=B==null?void 0:B.email)==null?void 0:Ee.header)==null?void 0:ye.logo)==null?void 0:it.image,link:(Ut=(Ot=(at=B==null?void 0:B.email)==null?void 0:at.header)==null?void 0:Ot.logo)==null?void 0:Ut.href,facebookLink:(Vr=(Fr=(_t=(Wt=B==null?void 0:B.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=B==null?void 0:B.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=B==null?void 0:B.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=B==null?void 0:B.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=B==null?void 0:B.email)==null?void 0:de.footer)==null?void 0:he.social)==null?void 0:ke.twitter)==null?void 0:zt.url}},[v,g]),W=N&&!!D,U=wf(()=>{Object.values(b.current).forEach(B=>clearTimeout(B)),b.current={}},[]);Xr(()=>()=>{U()},[U]),Xr(()=>{let B=s(z=>{if(z.key==="Escape"&&(f(null),p==null||p.commands.blur(),L.current=-1),z.key==="Tab"&&p){z.preventDefault();let oe=-1;m&&p.state.doc.content.forEach((Me,Et,wt)=>{m.attrs.id===Me.attrs.id&&(oe=wt)}),oe===-1&&(oe=0);let be=p.state.doc,Pe;if(z.shiftKey?Pe=(oe-1+be.childCount)%be.childCount:Pe=(oe+1)%be.childCount,Pe!==oe||m===null){let Me=be.child(Pe);f(Me),p.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",B),()=>{document.removeEventListener("keydown",B)}},[p,m,f]),Xr(()=>{if(k!==!1||A)return;let B=w!=null?w:"";if(B){let z=Ys(B,"email");h(z||"")}setTimeout(()=>{if(!(!p||p.isDestroyed)&&p.state.doc.childCount===1){let z=p.state.doc.child(0);f(z)}},0)},[g,k,A,p,h,f,w]),Xr(()=>{k===!1&&g&&!T.current&&(T.current=!0,setTimeout(()=>{p&&!p.isDestroyed&&V(p)},300))},[k,g,p,V]),Xr(()=>(C.current=!0,()=>{C.current=!1}),[]);let ie=wf(B=>{let oe=B||(y===void 0?"desktop":void 0);P(oe),f(null),oe?p==null||p.setEditable(!1):p==null||p.setEditable(!0)},[p,y,P,f]),ee=s(B=>{h(B.target.value)},"handleSubjectChange"),K=kf(()=>{if(k!==!1||!F)return null;let B=a&&a.elements&&a.elements.length>0;B&&(T.current=!0);let z;return B&&(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 A&&(w===null||K===null)?null:Fc(ht,{theme:t,colorScheme:l,isLoading:!!k,Header:i?i({hidePublish:e,channels:r,routing:o}):Fc(Bt,{hidePublish:e,channels:r,routing:o}),...u,children:Fc(cy,{children:n==null?void 0:n({subject:x,handleSubjectChange:ee,selectedNode:m,setSelectedNode:f,previewMode:y,templateEditor:p,ref:d,isBrandApply:W,brandSettings:D,items:R,content:K,syncEditorItems:V,brandEditorContent:M,templateData:g,togglePreviewMode:ie,hidePreviewPanelExitButton:c})})})}),gs=sy(ly);var hs=class hs{};s(hs,"UploadImageAPI"),hs.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=hs,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,rc,Tc.configure({levels:[1,2,3,4,5,6]}),Wa,_a,cf,za,$a,Za,Ja,Nc.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),ff,ns.configure(),Xa.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}),tc.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),cc,xo,To,Qa,rs],"ExtensionKit");import{BubbleMenu as Uy,useCurrentEditor as Wy}from"@tiptap/react";import{useAtomValue as uy}from"jotai";import{useCallback as Pf,useEffect as dy,useState as my}from"react";var bs=s(e=>{let t=uy(ge),[r,o]=my({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 dy(()=>{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 p=c.node(d);if(p.type.name==="blockquote"){if(p.attrs.isSelected)return!0;let m=a.state.selection.from!==a.state.selection.to;if(a.isFocused&&m)return!0}}return!1},[]),...r}},"useTextmenuStates");import{useAtomValue as Wc}from"jotai";import{AlignCenter as Ey,AlignJustify as wy,AlignLeft as ky,AlignRight as Py,Bold as Ny,Italic as My,Link as Ay,Quote as Sy,Strikethrough as Iy,Underline as Ly}from"lucide-react";import{Fragment as Ry,memo as Bf,useMemo as Df,useRef as Hy,useState as Dy,useEffect as By}from"react";import{forwardRef as Uc}from"react";import py from"@tippyjs/react";import{useCallback as fy}from"react";import{Fragment as by,jsx as fr,jsxs as hy}from"react/jsx-runtime";var Nf=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,gy=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=fy(l=>{let c=Object.entries(i).reduce((u,[d,p])=>{let m=d.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`);return{...u,[`--${m}`]:p}},{});return hy("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(gy,{children:u},u))})]})},[o,r,i]);return t?fr(py,{...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(by,{children:e})},"Tooltip");import{jsx as ys}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&&ys(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 ys("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=ys(Ce,{className:c,variant:r,buttonSize:t,ref:l,...a,children:e});return n?ys(Mf,{title:n,shortcut:i,children:u}):u});If.displayName="ToolbarButton";var Cs={Wrapper:Af,Divider:Sf,Button:If};import{ChevronDown as yy}from"lucide-react";import{useMemo as Cy}from"react";import{Fragment as xy,jsx as Qr,jsxs as Lf}from"react/jsx-runtime";var vy=s(e=>e.type==="option","isOption"),Rf=s(({options:e,containerRef:t})=>{let r=Cy(()=>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(yy,{className:"courier-w-3 courier-h-3"})]})}),Qr(Wn,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(vy(o))return Qr(_n,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?Qr(xy,{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 Ty}from"@tiptap/react";var Hf=s(e=>Ty({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 Oy}from"react/jsx-runtime";var Fy=Bf(Cs.Button),Vy=Bf(Rf),_c=s(({editor:e,config:t})=>{var L;let r=bs(e),o=Hf(e),n=Hy(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}});By(()=>{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 p=Df(()=>!u.empty&&u.from!==u.to,[u]),m=Df(()=>t||c(l||"",p),[t,c,l,p]),f=cs(e,m,r),x=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,T=i.caretPosition||E.selectionStart||0,w=C.substring(0,T),M=C.substring(T),A=`${w}{{${M}`,R=T+2;E.focus();let I=new Event("input",{bubbles:!0,cancelable:!0});if(Object.defineProperty(I,"target",{writable:!1,value:{...E,value:A}}),E.value=A,E.dispatchEvent(I),E.setSelectionRange(R,R),E.getBoundingClientRect()){let V=A.slice(0,R),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 D=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*D+30}},bubbles:!0});E.dispatchEvent(U)}return}e.chain().focus().insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()},"handleVariableClick"),b=s((E,C,T,w,M,A,R)=>{let I=m[E];return!I||Array.isArray(I)||I.state==="hidden"?null:tt(Fy,{tooltip:T,tooltipShortcut:A,onClick:w,active:M,disabled:I.state==="disabled",...R,children:C},E)},"renderButton"),y=s((E,C)=>{let T=E.filter(w=>!!w);return T.length>0?tt("div",{className:"courier-flex courier-items-center courier-gap-0.5",children:T},C):null},"renderGroup"),P=y([((L=m.contentType)==null?void 0:L.state)==="enabled"&&tt(Vy,{options:o,containerRef:n},"content-type")],"content-type-group"),g=y([b("bold",tt(Ny,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",f.onBold,r.isBold,["Mod","B"]),b("italic",tt(My,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",f.onItalic,r.isItalic,["Mod","I"]),b("underline",tt(Ly,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",f.onUnderline,r.isUnderline,["Mod","U"]),b("strike",tt(Iy,{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(ky,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",f.onAlignLeft,r.isAlignLeft,["Shift","Mod","L"]),b("alignCenter",tt(Ey,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",f.onAlignCenter,r.isAlignCenter,["Shift","Mod","E"]),b("alignRight",tt(Py,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",f.onAlignRight,r.isAlignRight,["Shift","Mod","R"]),b("alignJustify",tt(wy,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",f.onAlignJustify,r.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),N=y([b("quote",tt(Sy,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Quote",f.onQuote,r.isQuote,["Mod","Shift","B"])],"block-style-group"),v=y([b("link",tt(Ay,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",x,r.isLink,["Mod","K"]),b("variable",tt(Gd,{width:16}),"Variable",h,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return tt(Cs.Wrapper,{ref:n,className:"courier-border-b rounded-b-none rounded-t-sm !courier-shadow-md courier-justify-center courier-rounded-lg",children:[P,g,k,N,v].filter(Boolean).map((E,C)=>Oy(Ry,{children:[E,C<[P,g,k,N,v].filter(Boolean).length-1&&tt(Cs.Divider,{})]},`item-${C}`))})},"TextMenu");import{jsx as Ff}from"react/jsx-runtime";var yt=s(({config:e})=>{let{editor:t}=Wy(),r=bs(t);return t?Ff(Uy,{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 _y}from"@tiptap/pm/state";import{EditorProvider as zy,Extension as $y,useCurrentEditor as Zy}from"@tiptap/react";import{useAtomValue as qy,useSetAtom as Vf}from"jotai";import{memo as Jy,useEffect as $c,useMemo as jy,useRef as Of}from"react";import{jsx as Ft,jsxs as zc}from"react/jsx-runtime";var Gy=s(({value:e,readOnly:t})=>{let{editor:r}=Zy(),o=Vf(_o),n=qy(ae),i=Of(!1);return $c(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(Gs(e!=null?e:"")))},[r,e,n,t]),$c(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),Ky=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=$y.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:m})=>{let{state:f,dispatch:x}=m.view;return x(f.tr.setSelection(_y.create(f.doc,f.selection.$anchor.pos))),u&&u(null),!1}}}});$c(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=jy(()=>[...bt({setSelectedNode:u}),d].filter(m=>m!==void 0),[d,u]);return zc("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[zc(zy,{content:Gs(a!=null?a:""),extensions:p,editable:!i,autofocus:!i,onUpdate:l,editorContainerProps:{className:S("courier-py-2 courier-flex-grow",i&&"courier-brand-editor-readonly")},immediatelyRender:!1,children:[Ft(Gy,{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(Ky);import{Fragment as Yy,jsx as dn,jsxs as vs}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})=>vs("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&&vs(Yy,{children:[vs(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(Pl,{})}),dn(Uf,{value:"mobile",icon:dn(Ll,{})})]}),!o&&dn("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),!o&&vs(Ce,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");import{forwardRef as Zf}from"react";function Xy(){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(Xy,"initTestHelpers");function Ct(e,t){typeof window!="undefined"&&(Xy(),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 tC}from"@tiptap/core";import{TextSelection as rC}from"@tiptap/pm/state";import{EditorProvider as oC,useCurrentEditor as nC}from"@tiptap/react";import{useAtom as Wf,useAtomValue as Ar,useSetAtom as Io}from"jotai";import{useCallback as eo,useEffect as It,useMemo as iC,useRef as gr}from"react";import{useCurrentEditor as Qy}from"@tiptap/react";import{useEffect as eC}from"react";var Vt=s(({value:e,defaultValue:t})=>{let{editor:r}=Qy();return eC(()=>{if(!r)return;let o=setTimeout(()=>{r.commands.setContent(e||t)},0);return()=>clearTimeout(o)},[r,e,t]),null},"ReadOnlyEditorContent");import{Fragment as lC,jsx as Pi,jsxs as cC}from"react/jsx-runtime";var aC=s(({value:e})=>{let{editor:t}=nC(),[r,o]=Wf(X),n=Io(Ae),i=Ar(ao),a=Ar(ge),l=Io(Te),c=Io(lo),u=gr(!1),d=gr(),p=Ar(ae),m=Ar(Fe),f=gr(!1),x=Ar(ze);return It(()=>{p&&(f.current=!1)},[p]),It(()=>(c({action:"register",id:"email-subject",fn:s(()=>{var b;if(d.current&&(clearTimeout(d.current),d.current=void 0,t&&i!==null&&p===!1&&!x))try{let y=me(t.getJSON());if(!y||!Array.isArray(y))return;let P=i;if(!i&&r){let v=(b=r==null?void 0:r.elements)==null?void 0:b.find(L=>L.type==="channel"&&L.channel==="email");v&&(P=Dn(v,"email"))}let g=$t(r,"email",P||"",y),k={elements:g.elements,channel:"email",...g.raw&&{raw:g.raw}},N=Ve(r,k);JSON.stringify(r)!==JSON.stringify(N)&&(o(N),n(N))}catch(y){console.error("[FlushSubjectUpdate]",y)}},"flushSubjectUpdate")}),()=>{c({action:"unregister",id:"email-subject"})}),[t,i,p,x,r,o,n,c]),It(()=>{!t||p!==!1||f.current||!e||(l(t),f.current=!0,t.commands.setContent(e))},[t,e,l,p]),It(()=>{if(!(!(t&&i!==null)||p!==!1||x)&&!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 N=(h=r==null?void 0:r.elements)==null?void 0:h.find(v=>v.type==="channel"&&v.channel==="email");N&&(y=Dn(N,"email"))}let P=$t(r,"email",y||"",b),g={elements:P.elements,channel:"email",...P.raw&&{raw:P.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)}},[m,t,i,o,n,p,r,x]),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"),sC=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,p=Io(ge),m=Ar(Te),f=Ar(ze),x=Ar(pt),h=Io(lo),b=Io(Ae),y=gr(l),P=gr(d),g=gr(x);It(()=>{y.current=l},[l]),It(()=>{P.current=d},[d]),It(()=>{g.current=x},[x]),It(()=>{m==null||m.setEditable(!t)},[t,m]);let k=tC.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:O})=>{let{state:D,dispatch:W}=O.view;return W(D.tr.setSelection(rC.create(D.doc,D.selection.$anchor.pos))),p&&p(null),!1}}}}),N=eo(({editor:O})=>{o==null||o(O),Ct("email",O),p&&setTimeout(()=>{p(null)},100)},[p,o]),v=gr(),L=gr(null),E=eo((O,D)=>{var z;if(f)return;let W=y.current,U=P.current;if(!W){let oe={version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:D}]};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:D};if(JSON.stringify(ee)!==JSON.stringify(K)){let oe=U;!U&&ie&&(oe=Dn(ie,"email"));let be=$t(W,"email",oe||"",D);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 D=me(O.getJSON());L.current={editor:O,elemental:D},v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{if(L.current){let{editor:W,elemental:U}=L.current;E(W,U),L.current=null}},200)},[E]),T=eo(({editor:O})=>{if(g.current)return;let{selection:D}=O.state,{$anchor:W}=D,ie=D.$head.marks().find(z=>z.type.name==="link");ie||O.isActive("link")?i({mark:ie}):i(null);let ee=W.depth,K=null,B=null;for(;ee>0;){let z=W.node(ee);!B&&z.type.name==="blockquote"&&(B=z),!K&&(z.type.name==="paragraph"||z.type.name==="heading")&&(K=z),ee--}B?p(B):K&&p(K)},[i,p]),w=eo(({editor:O,transaction:D})=>{let W=D==null?void 0:D.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]),M=eo(()=>{a.current&&clearTimeout(a.current),v.current&&clearTimeout(v.current),r==null||r(),Ct("email",null)},[r]);It(()=>(h({action:"register",id:"email-content",fn:s(()=>{if(v.current&&(clearTimeout(v.current),v.current=void 0,L.current)){let{editor:D,elemental:W}=L.current;E(D,W),L.current=null}},"flushContentUpdate")}),()=>{h({action:"unregister",id:"email-content"})}),[E,h]);let A=eo(O=>{var ee;if(g.current)return;let D=(ee=O.view)==null?void 0:ee.editor;if(!D||!D.isEditable)return;let W=O.target,U=D.view.posAtDOM(W,0),ie=D.state.doc.resolve(U).node();ie.type.name==="paragraph"&&p(ie)},[p]),R=eo(()=>!g.current,[]),I=iC(()=>[...bt({setSelectedNode:p,shouldHandleClick:R}),k].filter(O=>O!==void 0),[k,p,R]),H=e||{type:"doc",content:[{type:"paragraph"}]},V=t?{editable:!1,autofocus:!1}:{editable:!0,autofocus:!0,onCreate:N,onUpdate:C,onSelectionUpdate:T,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:D})=>D.data.type==="sidebar"?!0:D.data.type==="editor"})},[t]),Pi("div",{ref:F,"data-testid":"email-editor",children:Pi(oC,{content:H,extensions:I,...V,onDestroy:M,editorContainerProps:{onClick:A},immediatelyRender:!1,children:t?Pi(Vt,{value:H,defaultValue:wi}):cC(lC,{children:[Pi(aC,{value:H}),Pi(yt,{})]})})})},"EmailEditor"),qc=sC;import{useAtomValue as _f,useSetAtom as gC}from"jotai";import{GripVertical as hC}from"lucide-react";import{forwardRef as uC,useEffect as dC,useRef as mC,useState as pC}from"react";import{jsx as Jc}from"react/jsx-runtime";var mn=s(({children:e,id:t,className:r,editor:o})=>Jc(fC,{id:t,className:r,editor:o,children:e}),"SideBarSortableItemWrapper"),fC=uC(({children:e,className:t,id:r,editor:o},n)=>{let i=mC(null),[a,l]=pC(!1);return dC(()=>{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 bC,jsx as Be,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=gC(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(bC,{children:[Be("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:r}),Be(le,{className:"courier-my-4"})]}),Be("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(u=>Be(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:[Be(hC,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),u==="heading"&&Be(Na,{draggable:!0}),u==="text"&&Be(Zr,{draggable:!0}),u==="image"&&Be(Aa,{draggable:!0}),u==="spacer"&&Be(Sa,{draggable:!0}),u==="divider"&&Be($r,{draggable:!0}),u==="button"&&Be(zr,{draggable:!0}),u==="customCode"&&Be(bi,{draggable:!0}),u==="column"&&Be(Ea,{draggable:!0})]})},u))})]}),t&&pn("div",{className:"courier-mt-auto courier-pt-4",children:[Be(le,{className:"courier-mb-4 -courier-mx-4"}),(c=(l=n==null?void 0:n.data)==null?void 0:l.tenant)!=null&&c.brand?Be("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:Be(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:[Be("h3",{className:"courier-text-md courier-font-medium courier-text-foreground",children:"Customize brand theme"}),Be("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),Be(Ce,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>i("brand"),children:"Customize"})]})]})]})},"SideBar");import{useAtomValue as yC}from"jotai";import{jsx as to,jsxs as CC}from"react/jsx-runtime";var Gc=s(({element:e,editor:t})=>{var i,a;let r=yC(_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(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 CC("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 vC}from"jotai";import{Fragment as xC,jsx as xs,jsxs as TC}from"react/jsx-runtime";var Lo=zf(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>xs("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]=vC(tr),u=o?!1:l,d=n||"courier-w-64";return r?null:TC(xC,{children:[u&&xs("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"}),xs("div",{className:S("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch courier-relative",d,t),children:xs("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 EC}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),p=EC(tr),m=s(()=>{d&&p(!1)},"handleSubjectAreaClick");return vt(gs,{value:u,variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:a,colorScheme:l,render:({subject:f,handleSubjectChange:x,selectedNode:h,setSelectedNode:b,previewMode:y,templateEditor:P,ref:g,isBrandApply:k,brandSettings:N,items:v,content:L,syncEditorItems:E,brandEditorContent:C,templateData:T,togglePreviewMode:w,hidePreviewPanelExitButton:M})=>{var A,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:m,children:[Ho("h4",{className:"courier-text-sm courier-h-[25px] courier-flex courier-items-end courier-pb-0.5",children:["Subject:"," "]}),vt(Ci,{value:f!=null?f:"",onChange:O=>x({target:{value:O}}),onFocus:()=>b(null),className:"!courier-bg-background courier-text-sm 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",(N==null?void 0:N.headerStyle)==="border"&&"courier-pt-6"),children:[(N==null?void 0:N.headerStyle)==="border"&&vt("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:N==null?void 0:N.brandColor}}),(N==null?void 0:N.logo)&&vt("img",{src:N.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),L&&vt(qc,{value:L,onUpdate:E,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=(A=T==null?void 0:T.data)==null?void 0:A.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:N==null?void 0:N.facebookLink,linkedinLink:N==null?void 0:N.linkedinLink,instagramLink:N==null?void 0:N.instagramLink,mediumLink:N==null?void 0:N.mediumLink,xLink:N==null?void 0:N.xLink})})]}),vt(Zc,{previewMode:y,togglePreviewMode:w,hideExitButton:M})]})]}),vt(Ro,{previewMode:y,children:vt("div",{className:"courier-p-1 courier-h-full",children:h?vt(Gc,{element:h,editor:P}):vt(jc,{items:v.Sidebar,brandEditor:i,label:"Blocks library",editor:P!=null?P:void 0})})})]})},...c})},"EmailLayout");import{useCurrentEditor as wC}from"@tiptap/react";import{useAtom as kC,useAtomValue as Ts,useSetAtom as Kc}from"jotai";import{forwardRef as PC,memo as NC,useCallback as MC,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:""}],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||"")+`
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(m=>m.type==="meta"),n=r.filter(m=>m.type!=="meta"),i=n.filter(m=>m.type==="text"),a=n.filter(m=>m.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"),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:`
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}=wC(),r=Kc(Te),o=Ts(X),n=Ts(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"),AC=PC(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let p=Ts(ae),m=Yc(!0),f=Yc(!1),x=Kc(ge),[h,b]=kC(X),y=Kc(Ae),P=Ts(ze);Ni(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=Gf(()=>[...bt({setSelectedNode:x})].filter(v=>v!==void 0),[x]),k=MC(({editor:v})=>{if(!v||P)return;if(!h){let A=me(v.getJSON()),R=$t(null,"inbox","",A),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=v.getJSON(),E=me(L),C=$t(h,"inbox","",E),T=Ve(h,{elements:C.elements,channel:"inbox",...C.raw&&{raw:C.raw}}),w=JSON.stringify(h.elements),M=JSON.stringify(T.elements);w!==M&&setTimeout(()=>{f.current&&(b(T),y(T))},100)},[h,b,y,P]),N=Gf(()=>{let v=Yf(l);return Se({version:"2022-01-01",elements:[v]},{channel:"inbox"})},[l]);return Kf(ht,{theme:e,colorScheme:c,isLoading:!!(p&&m.current),Header:i?i({hidePublish:t,channels:o,routing:n}):Kf(Bt,{hidePublish:t,channels:o,routing:n}),...u,ref:d,children:a==null?void 0:a({content:N,extensions:g,editable:!r,autofocus:!r,onUpdate:k})})}),Es=NC(AC);import{EditorProvider as SC}from"@tiptap/react";import{Fragment as IC,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(Al,{}),Sr(Gn,{}),Sr(Rl,{})]})]}),Sr(SC,{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(IC,{children:[Sr(Qf,{value:e}),Sr(yt,{config:Xf})]})})]}):null,"InboxEditor");import{useSetAtom as LC}from"jotai";import{useCallback as e1,useEffect as t1,useRef as Qc}from"react";function eu(e,t,r=500){let o=LC(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 RC}from"@hookform/resolvers/zod";import{useAtom as HC,useAtomValue as DC,useSetAtom as BC}from"jotai";import{memo as FC,useCallback as ws,useEffect as tu,useRef as ru}from"react";import{useForm as VC}from"react-hook-form";import{z as Do}from"zod";import{jsx as Le,jsxs as Si}from"react/jsx-runtime";var OC=Do.object({enableButton:Do.boolean().default(!0),buttonLabel:Do.string().default("Try now"),buttonUrl:Do.string().default(""),enableSecondaryButton:Do.boolean().default(!1),secondaryButtonLabel:Do.string().default("Learn more"),secondaryButtonUrl:Do.string().default("")}),UC=s(()=>{let e=DC(Te),[t,r]=HC(X),o=BC(Ae),n=ru(!1),i=ru(null),a=ru(t);tu(()=>{a.current=t},[t]);let l=VC({resolver:RC(OC),defaultValues:{enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""},mode:"onChange"});tu(()=>{if(!e)return;let f=s(()=>{let{doc:x}=e.state,h=null,b=[];if(x.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:P,button2Label:g,button2Link:k}=h,N=l.getValues();N.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),N.buttonLabel!==(y||"Try now")&&l.setValue("buttonLabel",y||"Try now",{shouldDirty:!1}),N.buttonUrl!==(P||"")&&l.setValue("buttonUrl",P||"",{shouldDirty:!1}),N.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),N.secondaryButtonLabel!==(g||"Learn more")&&l.setValue("secondaryButtonLabel",g||"Learn more",{shouldDirty:!1}),N.secondaryButtonUrl!==(k||"")&&l.setValue("secondaryButtonUrl",k||"",{shouldDirty:!1})}else if(b.length>0){let y=b[0],P=l.getValues();if(P.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),P.buttonLabel!==(y.label||"Try now")&&l.setValue("buttonLabel",y.label||"Try now",{shouldDirty:!1}),P.buttonUrl!==(y.link||"")&&l.setValue("buttonUrl",y.link||"",{shouldDirty:!1}),b.length>1){let g=b[1];P.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),P.secondaryButtonLabel!==(g.label||"Learn more")&&l.setValue("secondaryButtonLabel",g.label||"Learn more",{shouldDirty:!1}),P.secondaryButtonUrl!==(g.link||"")&&l.setValue("secondaryButtonUrl",g.link||"",{shouldDirty:!1})}else P.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 x=f.elements.filter(h=>h.type==="action");if(x.length>0){let h=x[0],b=x[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=ws(f=>{let x=a.current;if(!x||n.current)return;let h=x.elements.find(v=>v.type==="channel"&&v.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(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
- `,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
- `}],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`
194
+ `}]}),h.elements||(h.elements=[]);let y=[...h.elements.filter(v=>v.type!=="action")];if(f.enableButton){let v={type:"action",content:f.buttonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.buttonUrl};y.push(v)}if(f.enableSecondaryButton){let v={type:"action",content:f.secondaryButtonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.secondaryButtonUrl};y.push(v)}let P={...h,elements:y},g=x.elements.findIndex(v=>v.type==="channel"&&v.channel==="inbox"),k=[...x.elements];g!==-1?k[g]=P:k.push(P);let N={...x,elements:k};r(N),o(N)},[r,o]),u=ws(f=>{if(!e)return!1;let{doc:x}=e.state,h=null,b=[];x.descendants((P,g)=>P.type.name==="buttonRow"&&h===null?(h=g,!1):(P.type.name==="button"&&b.push({pos:g,attrs:P.attrs}),!0));let y=s((P,g)=>{let k=x.nodeAt(P);return k?(e.commands.command(({tr:N})=>(N.setNodeMarkup(P,k.type,g),!0)),!0):!1},"applyAttrs");if(h!==null){let P=x.nodeAt(h);if(!P)return!1;let g={...P.attrs,button1Label:f.buttonLabel,button1Link:f.buttonUrl,button2Label:f.secondaryButtonLabel,button2Link:f.secondaryButtonUrl};return y(h,g)}if(b.length>0){let[P,g]=b,k={...P.attrs,label:f.buttonLabel,link:f.buttonUrl},N=y(P.pos,k),v=!0;if(g){let L={...g.attrs,label:f.secondaryButtonLabel,link:f.secondaryButtonUrl};v=y(g.pos,L)}return N&&v}return!1},[e]),d=ws(f=>{if(n.current)return;let x=i.current;if(i.current=f,!x||x.enableButton!==f.enableButton||x.enableSecondaryButton!==f.enableSecondaryButton){c(f);return}u(f)||c(f)},[c,u]),p=eu("inbox-sidebar",d,500),m=ws(()=>{let f=l.getValues();p(f)},[l,p]);return Le(Ne,{...l,children:Si("form",{onChange:m,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=FC(UC);import{useAtomValue as WC}from"jotai";import{jsx as fn,jsxs as _C}from"react/jsx-runtime";var r1=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i,...a})=>{let l=WC(X);return fn(Es,{value:l,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:c=>_C("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 zC}from"@tiptap/react";import{useAtom as $C,useAtomValue as ks,useSetAtom as nu}from"jotai";import{forwardRef as ZC,memo as qC,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}=zC(),r=nu(Te),o=ks(X),n=ks(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||Bo;l=l.map(m=>m.type==="meta"&&"title"in m?{type:"text",content:m.title||`
195
+ `,text_style:"h2"}:m);let u=Se({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:l}]}),d=me(u),p=me(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"PushEditorContent"),Bo=[{type:"meta",title:""},{type:"text",content:`
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:Bo}),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"}},jC=ZC(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let p=ks(ae),m=iu(!0),f=iu(!1),x=nu(ge),[h,b]=$C(X),y=nu(Ae),P=ks(ze);Ii(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=o1(()=>[...bt({setSelectedNode:x})].filter(v=>v!==void 0),[x]),k=JC(({editor:v})=>{if(P)return;if(!h){let A=me(v.getJSON()),R=A[0],I="",H=A;R&&R.type==="text"&&"text_style"in R&&R.text_style==="h2"&&"content"in R&&(I=R.content.trim(),H=A.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(v.getJSON()),E=L[0],C="",T=L;E&&E.type==="text"&&"text_style"in E&&E.text_style==="h2"&&"content"in E&&(C=E.content.trim(),T=L.slice(1));let w=$t(h,"push",C,T),M=Ve(h,{channel:"push",elements:w.elements});JSON.stringify(h)!==JSON.stringify(M)&&(b(M),y(M))},[h,b,y,P]),N=o1(()=>{if(p!==!1)return null;let v=l==null?void 0:l.elements.find(C=>C.type==="channel"&&C.channel==="push");!v&&h&&(v=a1(h));let L=(v==null?void 0:v.type)==="channel"&&"elements"in v&&v.elements||Bo;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,p]);return n1(ht,{theme:e,colorScheme:c,isLoading:!!(p&&m.current),Header:i?i({hidePublish:t,channels:o,routing:n}):n1(Bt,{hidePublish:t,channels:o,routing:n}),...u,ref:d,children:a==null?void 0:a({content:N,extensions:g,editable:!r,autofocus:!r,onUpdate:k})})}),Ps=qC(jC);import{EditorProvider as GC}from"@tiptap/react";import{jsx as Ir,jsxs as Ns}from"react/jsx-runtime";var Ms=s(({children:e})=>Ns("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]"}),Ns("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:[Ns("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"})}),Ns("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 KC,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(Ms,{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(GC,{content:l,extensions:t,...c,editorContainerProps:{className:S("courier-push-editor")},"data-testid":"editor-provider",immediatelyRender:!1,children:a?gn(Vt,{value:l,defaultValue:Bo}):au(KC,{children:[gn(i1,{value:l}),gn(yt,{config:s1})]})})]})},"PushEditor");import{useAtomValue as YC}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=YC(X);return lu(Ps,{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 XC}from"@tiptap/react";import{useAtom as c1,useAtomValue as Fo,useSetAtom as m1}from"jotai";import{forwardRef as QC,memo as e8,useCallback as u1,useEffect as Lr,useMemo as d1,useRef as hn,useState as t8}from"react";import{Fragment as o8,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}=XC(),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),p=me(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&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"]}}]},r8=QC(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let p=Fo(ae),m=Fo(ze),f=Fo(Te),x=Fo(pt),[h,b]=c1(ge),[y,P]=c1(X),g=m1(Ae),k=hn(!0),N=hn(!1),v=hn(x),L=hn(null),[E,C]=t8({Sidebar:["text","divider","button"],Editor:[]});un({items:E,setItems:C});let{syncEditorItems:T}=fs({setItems:C,rafId:L});Lr(()=>(N.current=!0,()=>{N.current=!1}),[]),Lr(()=>{v.current=x},[x]),Lr(()=>{p===!1&&y&&setTimeout(()=>{f&&!f.isDestroyed&&T(f)},300)},[p,y,f,T]);let w=u1(()=>!v.current,[]),M=d1(()=>[...bt({setSelectedNode:b,shouldHandleClick:w})].filter(I=>I!==void 0),[b,w]),A=u1(({editor:I})=>{if(!I||m)return;if(!y){let U={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:me(I.getJSON())}]};P(U),g(U);return}let H=I.getJSON(),V=me(H),F=Ve(y,{elements:V,channel:"slack"}),O=JSON.stringify(y.elements),D=JSON.stringify(F.elements);O!==D&&(P(F),g(F))},[y,P,g,m]),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:!!(p&&k.current),Header:i?i({hidePublish:t,channels:o,routing:n}):cu(Bt,{hidePublish:t,channels:o,routing:n}),ref:d,...u,children:cu(o8,{children:a==null?void 0:a({content:R,extensions:M,editable:!r,autofocus:!r,onUpdate:A,items:E,selectedNode:h,slackEditor:f})})})}),As=e8(r8);import{EditorProvider as a8}from"@tiptap/react";import{jsx as rt,jsxs as bn}from"react/jsx-runtime";var n8=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"),i8=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(i8,{}),rt(n8,{})]}),"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 s8,useEffect as l8}from"react";import{Fragment as c8,jsx as yn,jsxs as u8}from"react/jsx-runtime";var uu=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let a=s8(null);return l8(()=>{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(a8,{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}):u8(c8,{children:[yn(f1,{value:e}),yn(yt,{config:g1})]})})})}):null},"SlackEditor");import{useAtomValue as g8}from"jotai";import{GripVertical as d8}from"lucide-react";import{Fragment as m8,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(m8,{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(d8,{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 p8}from"@hookform/resolvers/zod";import{useForm as f8}from"react-hook-form";import{jsx as Cn,jsxs as pu}from"react/jsx-runtime";var y1=s(({element:e,editor:t})=>{let r=f8({resolver:p8(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 y8}from"react/jsx-runtime";var h8=v1(({children:e,className:t,...r},o)=>Xt("div",{className:S("courier-editor-container courier-relative",t),...r,ref:o,children:e})),b8=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=g8(X);return Xt(As,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:l=>{var c;return y8(Lo,{children:[Xt("div",{className:"courier-flex courier-flex-col courier-flex-1",children:Xt(h8,{children:Xt(b8,{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 C8}from"@tiptap/react";import{useAtom as v8,useAtomValue as Is,useSetAtom as gu}from"jotai";import{forwardRef as x8,memo as T8,useCallback as T1,useEffect as vn,useMemo as E1,useRef as Ss,useState as E8}from"react";import{SegmentedMessage as w8}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}=C8(),r=gu(Te),o=Is(X),n=(c=t==null?void 0:t.getText())!=null?c:"",i=E1(()=>new w8(n),[n]),a=Is(ae),l=Ss(!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),p={type:"channel",channel:"sms",elements:u.type==="channel"&&"elements"in u&&u.elements||Hr},m=Se({version:"2022-01-01",elements:[p]}),f=me(m),x=me(t.getJSON());JSON.stringify(f)!==JSON.stringify(x)&&setTimeout(()=>{t.isFocused||t.commands.setContent(m)},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"}},k8=x8(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,render:i,headerRenderer:a,value:l,colorScheme:c,...u},d)=>{let p=Is(ae),m=Ss(!0),f=Ss(!1),x=gu(ge),[h,b]=v8(X),y=gu(Ae),P=Is(ze);vn(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=E1(()=>[...bt({setSelectedNode:x})].filter(C=>C!==void 0),[x]),k=Ss(!1),N=T1(({editor:C})=>{if(P)return;if(!h){let A=me(C.getJSON()),R=$i(A),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()),w=$i(T),M=Ve(h,{channel:"sms",elements:w.length>0?w:Hr});JSON.stringify(h)!==JSON.stringify(M)&&(k.current=!0,b(M),y(M))},[h,b,y,P]),[v,L]=E8(null),E=T1(C=>{if(!C)return null;let T=C==null?void 0:C.elements.find(A=>A.type==="channel"&&A.channel==="sms");T||(T=w1(C));let M={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:[M]})},[]);return vn(()=>{if(p!==!1)return;if(k.current){k.current=!1;return}let C=l!=null?l:h,T=E(C);T&&L(T)},[l,h,E,p]),hu(ht,{theme:e,colorScheme:c,isLoading:!!(p&&m.current),Header:a?a({hidePublish:t,channels:o,routing:n}):hu(Bt,{hidePublish:t,channels:o,routing:n}),...u,ref:d,children:i==null?void 0:i({content:v,extensions:g,editable:!r,autofocus:!r,onUpdate:N})})}),Ls=T8(k8);import{EditorProvider as P8}from"@tiptap/react";import{Fragment as N8,jsx as xn,jsxs as M8}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(Ms,{children:xn("div",{className:S("courier-sms-editor",i),children:xn(P8,{content:l,extensions:t,...c,"data-testid":"editor-provider",immediatelyRender:!1,children:a?xn(Vt,{value:l,defaultValue:Hr}):M8(N8,{children:[xn(k1,{value:l}),xn(yt,{config:P1})]})})})})},"SMSEditor");import{useAtomValue as A8}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=A8(X);return yu(Ls,{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 S8}from"@tiptap/react";import{useAtom as M1,useAtomValue as Vo,useSetAtom as S1}from"jotai";import{forwardRef as I8,memo as L8,useCallback as Cu,useEffect as hr,useMemo as A1,useRef as Tn,useState as R8}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}=S8(),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),p=me(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&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"]}}]},H8=I8(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let p=Vo(ae),m=Vo(ze),f=Vo(Te),x=Vo(pt),[h,b]=M1(ge),[y,P]=M1(X),g=S1(Ae),k=Tn(!0),N=Tn(!1),v=Tn(x),[L,E]=R8({Sidebar:["text","divider"],Editor:[]}),C=Tn(null);un({items:L,setItems:E});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 D=O.dataset.id;D&&F.push(D)}),E(O=>({Editor:F,Sidebar:O.Sidebar}))}catch(H){console.error("Error syncing editor items:",H),E(V=>({...V}))}})},50)},[]);hr(()=>(N.current=!0,()=>{N.current=!1}),[]),hr(()=>{v.current=x},[x]),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(()=>{p===!1&&y&&setTimeout(()=>{f&&!f.isDestroyed&&T(f)},300)},[p,y,f,T]);let w=Cu(()=>!v.current,[]),M=A1(()=>[...bt({setSelectedNode:b,shouldHandleClick:w})].filter(I=>I!==void 0),[b,w]),A=Cu(({editor:I})=>{if(!I||m)return;if(!y){let U={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:me(I.getJSON())}]};P(U),g(U);return}let H=I.getJSON(),V=me(H),F=Ve(y,{elements:V,channel:"msteams"}),O=JSON.stringify(y.elements),D=JSON.stringify(F.elements);O!==D&&(P(F),g(F))},[y,P,g,m]),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:!!(p&&k.current),Header:i?i({hidePublish:t,channels:o,routing:n}):vu(Bt,{hidePublish:t,channels:o,routing:n}),ref:d,...u,children:vu(D8,{children:a==null?void 0:a({content:R,extensions:M,editable:!r,autofocus:!r,onUpdate:A,items:L,selectedNode:h,msteamsEditor:f})})})}),Rs=L8(H8);import{EditorProvider as O8}from"@tiptap/react";import{jsx as ot,jsxs as Hi}from"react/jsx-runtime";var B8=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"),F8=s(()=>Hi("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[ot(B8,{}),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"),V8=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(F8,{}),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(V8,{})]}),"MSTeamsFrame");import{useRef as U8,useEffect as W8}from"react";import{Fragment as _8,jsx as En,jsxs as z8}from"react/jsx-runtime";var xu=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let a=U8(null);return W8(()=>{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(O8,{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}):z8(_8,{children:[En(L1,{value:e}),En(yt,{config:R1})]})})})}):null},"MSTeamsEditor");import{useAtomValue as q8}from"jotai";import{GripVertical as $8}from"lucide-react";import{Fragment as Z8,jsx as Dr,jsxs as Tu}from"react/jsx-runtime";var Eu=s(({items:e,label:t,editor:r})=>Dr("div",{className:"courier-flex courier-flex-col courier-h-full",children:Tu("div",{className:"courier-flex-1",children:[t&&Tu(Z8,{children:[Dr("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),Dr(le,{className:"courier-my-4"})]}),Dr("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>Dr(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:[Dr($8,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),o==="text"&&Dr(Zr,{draggable:!0}),o==="divider"&&Dr($r,{draggable:!0}),o==="button"&&Dr(zr,{draggable:!0})]})},o))})]})}),"MSTeamsSideBar");import{forwardRef as D1}from"react";import{jsx as br,jsxs as G8}from"react/jsx-runtime";var J8=D1(({children:e,className:t,...r},o)=>br("div",{className:S("courier-editor-container courier-relative",t),...r,ref:o,children:e})),j8=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})),B1=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i})=>{let a=q8(X);return br(Rs,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:l=>{var c;return G8(Lo,{children:[br("div",{className:"courier-flex courier-flex-col courier-flex-1",children:br(J8,{children:br(j8,{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:Bo},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"),Q8=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]=X8([]),n=F1(X),i=wu(X),a=wu(Ae),[l,c]=K8(Ur),u=wu(ge),d=F1(ae),p=Q8(t,e),m=Y8(p);m.current=p,ku(()=>{if(d||n!=null&&n.elements)return;let P=m.current.map(g=>go.find(k=>k.value===g)).filter(g=>!!g);o(P),P.length>0&&!l&&c(P[0].value)},[n,d,c,l]),ku(()=>{if(d||!(n!=null&&n.elements))return;let y=m.current,P=n.elements.filter(k=>k.type==="channel").map(k=>k.channel).filter(k=>y.includes(k)),g=y.filter(k=>P.includes(k)).map(k=>go.find(N=>N.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),P=(g=n==null?void 0:n.elements)==null?void 0:g.some(k=>k.type==="channel"&&k.channel===l);!y&&!P&&c(r[0].value)},[r,l,c,d,n]);let f=O1(()=>(p==null?void 0:p.filter(y=>!r.some(P=>P.value===y)).map(y=>go.find(P=>P.value===y)).filter(y=>!!y))||[],[r,p]),x=V1(y=>{let P=[],g,{elements:k,raw:N}=W1(y);if(P=k,g=N,!n){let E=[];for(let w of r){let{elements:M,raw:A}=W1(w.value),R={type:"channel",channel:w.value,elements:M};A&&(R.raw=A),E.push(R)}let C={type:"channel",channel:y,elements:P};g&&(C.raw=g),E.push(C);let T={version:"2022-01-01",elements:E};i(T),a(T),c(y);return}let L=Ve(n,{elements:P,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 P=n.elements.filter(N=>N.type==="channel"?N.channel!==y:!0),g={...n,elements:P};i(g),a(g),u(null);let k=r.filter(N=>N.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:x,removeChannel:h}},"useChannels");import{Fragment as i4,jsx as Je,jsxs as yr}from"react/jsx-runtime";var Bt=s(({hidePublish:e=!1,channels:t,routing:r})=>{let o=n4(null),n=Hs(Ge),i=Hs(ae),a=Hs(Q),{publishTemplate:l,isTemplatePublishing:c}=Vn(),[u,d]=t4(Uo),p=r4(tr),m=Hs(tr),{enabledChannels:f,disabledChannels:x,channel:h,setChannel:b,addChannel:y,removeChannel:P}=Pu({channels:t,routing:r});o4(()=>{n===!0&&d(null)},[n,d]);let g=Di(()=>{m&&p(!1),l()},[l,m,p]),k=Di(E=>{m&&p(!1),b(E)},[m,p,b]),N=Di(E=>{m&&p(!1),y(E)},[m,p,y]),v=Di(E=>{m&&p(!1),P(E)},[m,p,P]),L=Di(()=>{m&&p(!1)},[m,p]);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(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(nl,{ref:o,children:[Je(il,{children:Je(e4,{children:"Are you sure you want to delete this channel?"})}),yr(al,{children:[Je(ll,{asChild:!0,children:Je(Ce,{buttonSize:"small",variant:"outline",children:"Cancel"})}),Je(sl,{asChild:!0,children:Je(Ce,{buttonSize:"small",variant:"primary",onClick:()=>v(E.value),children:"Delete"})})]})]})]})]},E.value))})}),x.length>0&&yr(i4,{children:[Je(fl,{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:x.map(E=>yr(_n,{onClick:()=>N(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 _1,useEffect as z1,useRef as ro,useState as a4}from"react";function Bi({onSave:e,debounceMs:t=2e3,enabled:r=!0,onError:o,initialContent:n,flushBeforeSave:i}){let[a,l]=a4(!1),c=ro(!1),u=ro(null),d=ro(),p=ro(0),m=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 P=u.current;if(u.current=null,!!P)try{let g=JSON.stringify(P);if(g===d.current)return;c.current=!0,l(!0),d.current=g,p.current=Date.now(),await e(P)}catch(g){console.error("[AutoSave] Save failed:",g),o==null||o(g)}finally{if(c.current=!1,l(!1),u.current){let g=t;m.current=setTimeout(()=>{m.current=void 0,f()},g)}}},[t,o,e,i]),x=ro(r),h=ro(t),b=ro(f);return z1(()=>{x.current=r,h.current=t,b.current=f}),{handleAutoSave:_1(async P=>{if(!x.current)return;let g=JSON.stringify(P);if(u.current=P,g===d.current||c.current)return;m.current&&(clearTimeout(m.current),m.current=void 0);let k=h.current;m.current=setTimeout(()=>{m.current=void 0,b.current()},k)},[]),isSaving:a}}s(Bi,"useAutoSave");import{useAtom as Vi,useAtomValue as Br,useSetAtom as Su}from"jotai";import{memo as L4,useCallback as Iu,useEffect as Lt,useRef as Fs,useState as R4}from"react";import{useAtom as X1,useAtomValue as Au,useSetAtom as Q1}from"jotai";import{forwardRef as A4,memo as S4,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 s4=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,p,m,f,x;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(s4).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+`
@@ -206,15 +206,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
206
206
  `).map(b=>`> ${b}`).join(`
207
207
  `)+`
208
208
 
209
- `;case"imageBlock":{let h=((u=e.attrs)==null?void 0:u.alt)||"",b=((d=e.attrs)==null?void 0:d.sourcePath)||"",y=(m=e.attrs)==null?void 0:m.link,N=`![${h}](${b})`;return y?`[${N}](${y})
209
+ `;case"imageBlock":{let h=((u=e.attrs)==null?void 0:u.alt)||"",b=((d=e.attrs)==null?void 0:d.sourcePath)||"",y=(p=e.attrs)==null?void 0:p.link,P=`![${h}](${b})`;return y?`[${P}](${y})
210
210
 
211
- `:N+`
211
+ `:P+`
212
212
 
213
213
  `}case"divider":return`---
214
214
 
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})
215
+ `;case"button":{let h=((m=e.attrs)==null?void 0:m.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 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};
217
+ `}default:return((x=e.content)==null?void 0:x.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 w4}from"jotai";import{forwardRef as k4,memo as P4,useCallback as Bs}from"react";import{forwardRef as l4}from"react";import{jsx as c4}from"react/jsx-runtime";var Z1=l4(({children:e},t)=>c4("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 u4,useState as d4}from"react";import{jsx as Nu,jsxs as p4}from"react/jsx-runtime";var m4=["image/png","image/jpeg","image/gif","image/webp"],q1=s(({onFileSelect:e})=>{let[t,r]=d4(!1),o=u4(null),n=oo(m=>m4.includes(m),[]),i=oo(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(h=>n(h.type))&&(r(!0),m.dataTransfer.dropEffect="copy")},[n]),a=oo(m=>{m.preventDefault(),m.stopPropagation(),r(!1)},[]),l=oo(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(h=>n(h.type))&&r(!0)},[n]),c=oo(async m=>{try{let{dataUrl:f}=await ji(m,800);e==null||e(f),o.current&&(o.current.value="")}catch(f){console.error("Error processing image:",f),o.current&&(o.current.value="")}},[e]),u=oo(m=>{m.preventDefault(),m.stopPropagation(),r(!1);let x=Array.from(m.dataTransfer.files).find(h=>n(h.type));x&&c(x)},[c,n]),d=oo(m=>{var x;let f=(x=m.target.files)==null?void 0:x[0];f&&c(f)},[c]),p=oo(m=>{var f;m.preventDefault(),m.stopPropagation(),(f=o.current)==null||f.click()},[]);return p4("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:p,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 f4}from"@hookform/resolvers/zod";import{useAtom as g4,useAtomValue as h4,useSetAtom as b4}from"jotai";import{ArrowUp as y4}from"lucide-react";import{memo as C4,useCallback as J1,useEffect as v4,useRef as x4}from"react";import{useForm as T4}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"),E4=s(()=>{let[e,t]=g4(ar),r=b4(Jt),o=h4(_o),n=x4(null),i=T4({resolver:f4($1),defaultValues:{...ct,...e},mode:"onChange"});v4(()=>{e&&i.reset(e)},[e,i]);let a=J1(()=>{t(i.getValues())},[i,t]),l=J1(c=>{var u;if(o){if(c){let p={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(p).run()}else{let p=((u=o.getJSON().content)==null?void 0:u.filter(m=>{var x;return m.type!=="paragraph"?!0:!((x=m.content)==null?void 0:x.some(h=>{var b;return h.type==="text"&&((b=h.marks)==null?void 0:b.some(y=>{var P;return y.type==="link"&&((P=y.attrs)==null?void 0:P.href)==="{{urls.preferences}}"}))}))}))||[];o.chain().focus().setContent({type:"doc",content:p}).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:[$(y4,{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:p}=await ji(u,800),m=i.getValues();m.logo=p,i.reset(m),t({...m})}catch(p){console.error("Error processing image:",p)}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=C4(E4);import{Fragment as M4,jsx as nt,jsxs as kn}from"react/jsx-runtime";var N4=k4(({hidePublish:e=!1,templateEditor:t,variables:r},o)=>{var k,N,v,L,E,C,T,w;let n=w4(jo),{publishBrand:i}=Fn(),a=wn(Fe),l=wn(mt),c=wn(Ge),u=wn(ae),d=wn(Q),p=wn(_o),[m,f]=K1(ar),[x,h]=K1(Jt),b=Bs(()=>{i()},[i]),y=Bs(({editor:M})=>{h(Ds(M.getJSON()))},[h]),P=Bs(M=>{f(A=>A?{...A,logo:M}:{...ct,logo:M})},[f]),g=Bs(()=>{n("template")},[n]);return kn(M4,{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:!((N=(k=a==null?void 0:a.data)==null?void 0:k.tenant)!=null&&N.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",(m==null?void 0:m.headerStyle)==="border"&&"courier-pt-6"),children:[(m==null?void 0:m.headerStyle)==="border"&&nt("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:m.brandColor}}),m!=null&&m.logo?nt("img",{src:m.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"}):nt(q1,{onFileSelect:P})]}),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:x!=null?x:(w=(T=(C=(E=(L=(v=a==null?void 0:a.data)==null?void 0:v.tenant)==null?void 0:L.brand)==null?void 0:E.settings)==null?void 0:C.email)==null?void 0:T.footer)==null?void 0:w.markdown,variables:r,facebookLink:m==null?void 0:m.facebookLink,linkedinLink:m==null?void 0:m.linkedinLink,instagramLink:m==null?void 0:m.instagramLink,mediumLink:m==null?void 0:m.mediumLink,xLink:m==null?void 0:m.xLink,onUpdate: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:p&&nt(G1,{})})})]})]})}),Y1=P4(N4);import{jsx as rg}from"react/jsx-runtime";var I4=A4(({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:p}=Fn(),[m,f]=X1(Fe),x=Q1(Jt),h=Au(Jt),[b,y]=X1(ar),P=tg(!1),g=Q1(Q);Pn(()=>{var L,E;m&&u!==((E=(L=m==null?void 0:m.data)==null?void 0:L.tenant)==null?void 0:E.tenantId)&&(f(null),x(null),c.current=!1)},[m,u,f,x]);let k=eg(async L=>{await p(L)},[p]),N=eg(()=>{g(vr("Error saving theme"))},[g]),{handleAutoSave:v}=Bi({onSave:k,enabled:l!==null&&r&&h!==null,debounceMs:t,onError:N});return Pn(()=>{!u||l||m&&l===!1||d()},[u,d,l,m]),Pn(()=>{h&&setTimeout(()=>{P.current=!0},500)},[h]),Pn(()=>{if(!P.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}}}}};v(L)},[b,h,v]),Pn(()=>{l||(c.current=!1)},[l]),Pn(()=>{var L,E,C,T,w,M,A,R,I,H,V,F,O,D,W,U,ie,ee,K,B,z,oe,be,Pe,Me,Et,wt,se,Ee,ye,it,at,Ot,Ut,Wt,_t,Fr,Vr;if(!b){let te=(C=(E=(L=m==null?void 0:m.data)==null?void 0:L.tenant)==null?void 0:E.brand)==null?void 0:C.settings,Cr=(A=h==null?void 0:h.split(`
218
+ `))!=null?A:(M=(w=(T=te==null?void 0:te.email)==null?void 0:T.footer)==null?void 0:w.markdown)==null?void 0:M.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=(D=(O=te==null?void 0:te.email)==null?void 0:O.header)==null?void 0:D.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=(B=(K=te==null?void 0:te.email)==null?void 0:K.footer)==null?void 0:B.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})}},[m,y,h,b]),rg(ht,{theme:o,colorScheme:n,isLoading:!!(l&&c.current),children:rg(Y1,{ref:a,hidePublish:e,...i})})}),og=S4(I4);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"),H4=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:p,...m})=>{let{store:f}=Hn(),x=Br(ae),h=Br(mt),b=Br(Q),[y,P]=Vi(Fe),g=Br(er),k=Br(je),[N,v]=Vi(ao),{getTemplate:L,saveTemplate:E,setTemplateError:C}=Vn(),T=Br(jo),w=Fs(!1),[M,A]=Vi(X),[R,I]=Vi(ze);Lt(()=>{typeof window!="undefined"&&window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.templateEditorContent=M)},[M]);let H=Su(Jt),V=Su(ar),[F,O]=Vi(Ur),D=Su(ae),W=ng(d,u),[U,ie]=R4(W),ee=Fs(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(x||!(M!=null&&M.elements))return;let se=M.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)}},[M,F,O,d==null?void 0:d.channels,x]),Lt(()=>{var Ee;let se=(Ee=y==null?void 0:y.data)==null?void 0:Ee.tenant;g&&se&&!(se!=null&&se.notification)&&x===!1&&(U!=null&&U.length)&&O(U[0])},[g,y,x,U,O]);let K=Fs(null);Lt(()=>{K.current&&(K.current.templateId!==g||K.current.tenantId!==k)&&g&&k&&(I(!0),w.current=!1,P(null),A(null),H(null),V(null),v(null),O((U==null?void 0:U[0])||"email"),D(null)),g&&k&&(K.current={templateId:g,tenantId:k})},[g,k,U,I,P,A,H,V,v,O,D]);let B=Fs(d);Lt(()=>{B.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 E({routing:B.current,content:at})},[E,f]),oe=Iu(()=>{C("Error saving template")},[C]),be=Br(lo),Pe=Iu(()=>{Uu(be)},[be]),{handleAutoSave:Me}=Bi({onSave:z,debounceMs:a,enabled:x===!1&&i,onError:oe,flushBeforeSave:Pe});Lt(()=>{!g||!k||x||y&&x===!1||b||L({includeBrand:l})},[g,k,l,L,x,y,b]),Lt(()=>{if(!(!t||i&&x!==!1)&&JSON.stringify(me(Se(M)))!==JSON.stringify(me(Se(t))))if(A(t),!i)D(!1);else{let se={...t,_capturedTemplateId:g};Me(se)}},[i,t,M,A,D,Me,g,x]),Lt(()=>{var ye,it,at,Ot,Ut,Wt,_t;if(x!==!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);A(Ee),setTimeout(()=>{I(!1)},100)},[y,A,x,I,g,t]),Lt(()=>{h===!0&&(w.current=!1)},[h]),Lt(()=>{!M||x!==!1||setTimeout(()=>{w.current=!0},1e3)},[M,F,x]),Lt(()=>{w.current=!1},[F]);let Et=Br(Ae),wt=Br(Ou);if(Lt(()=>{let se=!!Et&&x===!1&&!R,Ee=w.current&&!!M&&x===!1&&!R;if(!se&&!Ee)return;let ye=Et||M;if(!ye||JSON.stringify(ye)===wt)return;let at={...ye,_capturedTemplateId:g};r&&(w.current=!1,r(M||ye)),Me(at)},[M,Et,Me,x,R,g,r,wt]),l&&T==="brand")return Oo(og,{hidePublish:n,autoSave:i,templateEditor:!0,variables:o,theme:e,colorScheme:p,...c});if(T==="template"&&F==="email")return Oo(jf,{variables:o,theme:e,colorScheme:p,isLoading:!!x,hidePublish:n,channels:U,brandEditor:l,routing:d,...m});if(T==="template"&&F==="sms")return Oo(N1,{colorScheme:p,variables:o,theme:e,hidePublish:n,channels:U,routing:d,...m});if(T==="template"&&F==="push")return Oo(l1,{variables:o,theme:e,colorScheme:p,hidePublish:n,channels:U,routing:d,...m});if(T==="template"&&F==="inbox")return Oo(r1,{variables:o,theme:e,colorScheme:p,hidePublish:n,channels:U,routing:d,...m});if(T==="template"&&F==="slack")return Oo(x1,{theme:e,colorScheme:p,hidePublish:n,channels:U,routing:d,variables:o,...m});if(T==="template"&&F==="msteams")return Oo(B1,{theme:e,colorScheme:p,hidePublish:n,channels:U,routing:d,variables:o,...m})},"TemplateEditorComponent"),TJ=L4(H4);var NJ=gs,MJ=Ls,AJ=Ps,SJ=Es,IJ=Rs,LJ=As;export{og as BrandEditor,ki as BrandFooter,yg as BrandProvider,go as CHANNELS,Lo as ChannelRootContainer,Ro as EditorSidebar,NJ as EmailChannel,qc as EmailEditor,qf as EmailEditorContainer,Jf as EmailEditorMain,jc as EmailSideBar,Gc as EmailSideBarItemDetails,Qs as ErrorBoundary,SJ as InboxChannel,Xc as InboxEditor,ou as InboxSideBar,IJ as MSTeamsChannel,xu as MSTeamsEditor,Eu as MSTeamsSideBar,gc as MonacoCodeEditor,Zc as PreviewPanel,AJ as PushChannel,su as PushEditor,MJ as SMSChannel,bu as SMSEditor,LJ as SlackChannel,uu as SlackEditor,mu as SlackSideBar,fu as SlackSideBarItemDetails,TJ 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,X4 as extractErrorMessage,Ca as getFlattenedVariables,Y4 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,Bi as useAutoSave,Fn as useBrandActions,Pu as useChannels,eu as useDebouncedFlush,On as useImageUpload,Xe as useNodeAttributes,Vn as useTemplateActions,Hn as useTemplateStore,pN as useVariables};
220
220
  //# sourceMappingURL=index.js.map