@trycourier/react-designer 0.3.0 → 0.4.0

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.
Files changed (37) hide show
  1. package/README.md +114 -2
  2. package/dist/cjs/index.js +55 -55
  3. package/dist/cjs/index.js.map +4 -4
  4. package/dist/cjs/styles.css +34 -0
  5. package/dist/components/BrandEditor/Editor/Editor.d.ts +16 -1
  6. package/dist/components/TemplateEditor/Channels/Email/Email.d.ts +1 -1
  7. package/dist/components/TemplateEditor/Channels/Email/EmailEditor.d.ts +2 -1
  8. package/dist/components/TemplateEditor/Channels/Email/EmailLayout.d.ts +1 -1
  9. package/dist/components/TemplateEditor/Channels/Inbox/Inbox.d.ts +1 -1
  10. package/dist/components/TemplateEditor/Channels/Inbox/InboxLayout.d.ts +1 -1
  11. package/dist/components/TemplateEditor/Channels/MSTeams/MSTeams.d.ts +1 -1
  12. package/dist/components/TemplateEditor/Channels/MSTeams/MSTeamsLayout.d.ts +1 -1
  13. package/dist/components/TemplateEditor/Channels/Push/Push.d.ts +1 -1
  14. package/dist/components/TemplateEditor/Channels/Push/PushLayout.d.ts +1 -1
  15. package/dist/components/TemplateEditor/Channels/SMS/SMS.d.ts +1 -1
  16. package/dist/components/TemplateEditor/Channels/SMS/SMSLayout.d.ts +1 -1
  17. package/dist/components/TemplateEditor/Channels/Slack/Slack.d.ts +1 -1
  18. package/dist/components/TemplateEditor/Channels/Slack/SlackLayout.d.ts +1 -1
  19. package/dist/components/TemplateEditor/Channels/useChannels.d.ts +8 -0
  20. package/dist/components/TemplateEditor/TemplateEditor.d.ts +16 -1
  21. package/dist/components/TemplateEditor/index.d.ts +1 -1
  22. package/dist/components/TemplateEditor/store.d.ts +10 -0
  23. package/dist/components/extensions/Variable/Variable.d.ts +8 -4
  24. package/dist/components/extensions/Variable/Variable.types.d.ts +3 -14
  25. package/dist/components/extensions/Variable/VariableSuggestions.d.ts +7 -0
  26. package/dist/components/extensions/Variable/index.d.ts +1 -0
  27. package/dist/components/extensions/Variable/suggestion.d.ts +2 -0
  28. package/dist/components/extensions/extension-kit.d.ts +7 -2
  29. package/dist/components/ui/VariableEditor/VariableAutocomplete.d.ts +16 -0
  30. package/dist/esm/index.js +55 -55
  31. package/dist/esm/index.js.map +4 -4
  32. package/dist/esm/styles.css +34 -0
  33. package/dist/index.d.ts +1 -0
  34. package/dist/styles.css +34 -0
  35. package/dist/types/index.d.ts +1 -0
  36. package/dist/types/validation.types.d.ts +53 -0
  37. package/package.json +1 -1
package/dist/cjs/index.js CHANGED
@@ -43,7 +43,7 @@ if (typeof require !== "undefined") {
43
43
  console.warn('Unable to setup tippy imports polyfill');
44
44
  }
45
45
  }
46
- "use strict";var v2=Object.create;var Ki=Object.defineProperty;var x2=Object.getOwnPropertyDescriptor;var T2=Object.getOwnPropertyNames;var E2=Object.getPrototypeOf,k2=Object.prototype.hasOwnProperty;var s=(e,t)=>Ki(e,"name",{value:t,configurable:!0});var Uc=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),w2=(e,t)=>{for(var r in t)Ki(e,r,{get:t[r],enumerable:!0})},ym=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T2(t))!k2.call(e,n)&&n!==r&&Ki(e,n,{get:()=>t[n],enumerable:!(o=x2(t,n))||o.enumerable});return e};var he=(e,t,r)=>(r=e!=null?v2(E2(e)):{},ym(t||!e||!e.__esModule?Ki(r,"default",{value:e,enumerable:!0}):r,e)),P2=e=>ym(Ki({},"__esModule",{value:!0}),e);var ad=Uc(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.bind=void 0;function nh(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(nh,"bind");Vs.bind=nh});var Fp=Uc(fi=>{"use strict";var pi=fi&&fi.__assign||function(){return pi=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},pi.apply(this,arguments)};Object.defineProperty(fi,"__esModule",{value:!0});fi.bindAll=void 0;var ih=ad();function Vp(e){if(typeof e!="undefined")return typeof e=="boolean"?{capture:e}:e}s(Vp,"toOptions");function ah(e,t){if(t==null)return e;var r=pi(pi({},e),{options:pi(pi({},Vp(t)),Vp(e.options))});return r}s(ah,"getBinding");function sh(e,t,r){var o=t.map(function(n){var i=ah(n,r);return(0,ih.bind)(e,i)});return s(function(){o.forEach(function(i){return i()})},"unbindAll")}s(sh,"bindAll");fi.bindAll=sh});var xa=Uc(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.bindAll=gi.bind=void 0;var lh=ad();Object.defineProperty(gi,"bind",{enumerable:!0,get:function(){return lh.bind}});var ch=Fp();Object.defineProperty(gi,"bindAll",{enumerable:!0,get:function(){return ch.bindAll}})});var f0={};w2(f0,{BrandEditor:()=>bm,BrandFooter:()=>Bi,BrandProvider:()=>Cm,CHANNELS:()=>$o,ChannelRootContainer:()=>cn,DEFAULT_ROUTING:()=>is,EditorSidebar:()=>un,EmailChannel:()=>l0,EmailEditor:()=>pc,EmailEditorContainer:()=>lm,EmailEditorMain:()=>cm,EmailSideBar:()=>gc,EmailSideBarItemDetails:()=>hc,ErrorBoundary:()=>vs,InboxChannel:()=>d0,InboxEditor:()=>yc,InboxSideBar:()=>vc,MSTeamsChannel:()=>m0,MSTeamsEditor:()=>Hc,MSTeamsSideBar:()=>Vc,MonacoCodeEditor:()=>Wl,PreviewPanel:()=>dc,PushChannel:()=>u0,PushEditor:()=>Ec,SMSChannel:()=>c0,SMSEditor:()=>Rc,SlackChannel:()=>p0,SlackEditor:()=>Nc,SlackSideBar:()=>Mc,SlackSideBarItemDetails:()=>Ac,TemplateEditor:()=>s0,TemplateProvider:()=>Em,TemplateStatus:()=>di,TextMenu:()=>ki,ToggleGroup:()=>Ir,VariableInput:()=>wi,VariableTextarea:()=>jr,apiUrlAtom:()=>Bt,brandApplyAtom:()=>Wc,cn:()=>I,convertElementalToTiptap:()=>Ze,convertLegacyError:()=>Yi,convertTiptapToElemental:()=>de,createCustomError:()=>so,extractErrorMessage:()=>R2,getFlattenedVariables:()=>Na,isRetryableError:()=>S2,isTemplateLoadingAtom:()=>se,isTemplatePublishingAtom:()=>_t,isTemplateSavingAtom:()=>at,routingAtom:()=>Gi,templateDataAtom:()=>it,templateErrorAtom:()=>G,templateIdAtom:()=>Mr,tenantIdAtom:()=>pt,tokenAtom:()=>Dt,useAutoSave:()=>Ui,useBlockConfig:()=>zh,useBrandActions:()=>Yn,useChannels:()=>Fc,useDebouncedFlush:()=>Cc,useImageUpload:()=>Qn,useNodeAttributes:()=>kt,useTemplateActions:()=>Xn,useTemplateStore:()=>Jn,useVariables:()=>Lh});module.exports=P2(f0);var Uo=require("jotai"),qn=require("react");var Nr=require("jotai"),is={method:"single",channels:["email"]},Bt=(0,Nr.atom)("https://api.courier.com/client/q"),Dt=(0,Nr.atom)(""),pt=(0,Nr.atom)(""),Mr=(0,Nr.atom)(""),Gi=(0,Nr.atom)(is),it=(0,Nr.atom)(null),se=(0,Nr.atom)(null),at=(0,Nr.atom)(null),_t=(0,Nr.atom)(null),G=(0,Nr.atom)(null),Wc=(0,Nr.atom)(!0);var Zn=require("react/jsx-runtime"),N2=s(({children:e,tenantId:t,token:r,apiUrl:o})=>{let[,n]=(0,Uo.useAtom)(Bt),[,i]=(0,Uo.useAtom)(Dt),[,a]=(0,Uo.useAtom)(pt);return(0,qn.useEffect)(()=>{i(r),a(t),o&&n(o)},[r,t,o,n,i,a]),(0,Zn.jsx)(Zn.Fragment,{children:e})},"BrandProviderContext"),M2=s(e=>{let t=(0,qn.useMemo)(()=>(0,Uo.createStore)(),[]);return(0,Zn.jsx)(Uo.Provider,{store:t,children:(0,Zn.jsx)(N2,{...e})})},"BrandProviderComponent"),Cm=(0,qn.memo)(M2);var Ar=require("jotai"),Ur=require("react"),vm=require("sonner");var as=require("react/jsx-runtime"),Jn=s(()=>({store:(0,Ar.useStore)()}),"useTemplateStore"),xm=(0,Ur.createContext)(null),Tm=s(()=>(0,Ur.useContext)(xm),"useUploadImage"),A2=s(({children:e,templateId:t,tenantId:r,token:o,apiUrl:n,uploadImage:i})=>{let[,a]=(0,Ar.useAtom)(Bt),[,l]=(0,Ar.useAtom)(Dt),[,c]=(0,Ar.useAtom)(pt),[,u]=(0,Ar.useAtom)(Mr),[p]=(0,Ar.useAtom)(G);return(0,Ur.useEffect)(()=>{l(o),c(r),u(t),n&&a(n)},[o,r,t,n,a,l,c,u]),(0,Ur.useEffect)(()=>{p&&vm.toast.error(p.message,p.toastProps)},[p]),(0,as.jsx)(xm.Provider,{value:i||null,children:e})},"TemplateProviderContext"),I2=s(e=>{let t=(0,Ur.useMemo)(()=>(0,Ar.createStore)(),[]);return(0,as.jsx)(Ar.Provider,{store:t,children:(0,as.jsx)(A2,{...e})})},"TemplateProviderComponent"),Em=(0,Ur.memo)(I2);var _r=require("jotai");var so=s((e,t)=>({message:e,toastProps:t}),"createCustomError"),S2=s(e=>{var t;return((t=e.toastProps)==null?void 0:t.action)!==void 0},"isRetryableError"),R2=s(e=>typeof e=="string"?e:e&&typeof e=="object"&&"message"in e?String(e.message):e instanceof Error?e.message:"Unknown error","extractErrorMessage"),Yi=s(e=>typeof e=="string"?so(e):e,"convertLegacyError");var _c=require("jotai"),km=require("sonner");var wm=(0,_c.atom)(null,async(e,t,r)=>{var a;let o=e(Bt),n=e(Dt),i=e(pt);if(!o){t(G,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(at,!0),t(G,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
+ "use strict";var J2=Object.create;var Ua=Object.defineProperty;var K2=Object.getOwnPropertyDescriptor;var G2=Object.getOwnPropertyNames;var X2=Object.getPrototypeOf,Y2=Object.prototype.hasOwnProperty;var a=(e,t)=>Ua(e,"name",{value:t,configurable:!0});var td=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Q2=(e,t)=>{for(var r in t)Ua(e,r,{get:t[r],enumerable:!0})},rf=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of G2(t))!Y2.call(e,n)&&n!==r&&Ua(e,n,{get:()=>t[n],enumerable:!(o=K2(t,n))||o.enumerable});return e};var xe=(e,t,r)=>(r=e!=null?J2(X2(e)):{},rf(t||!e||!e.__esModule?Ua(r,"default",{value:e,enumerable:!0}):r,e)),ey=e=>rf(Ua({},"__esModule",{value:!0}),e);var xm=td(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});Ol.bind=void 0;function Ry(e,t){var r=t.type,o=t.listener,n=t.options;return e.addEventListener(r,o,n),a(function(){e.removeEventListener(r,o,n)},"unbind")}a(Ry,"bind");Ol.bind=Ry});var E1=td(ia=>{"use strict";var na=ia&&ia.__assign||function(){return na=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},na.apply(this,arguments)};Object.defineProperty(ia,"__esModule",{value:!0});ia.bindAll=void 0;var Ly=xm();function T1(e){if(typeof e!="undefined")return typeof e=="boolean"?{capture:e}:e}a(T1,"toOptions");function By(e,t){if(t==null)return e;var r=na(na({},e),{options:na(na({},T1(t)),T1(e.options))});return r}a(By,"getBinding");function Dy(e,t,r){var o=t.map(function(n){var i=By(n,r);return(0,Ly.bind)(e,i)});return a(function(){o.forEach(function(i){return i()})},"unbindAll")}a(Dy,"bindAll");ia.bindAll=Dy});var ps=td(aa=>{"use strict";Object.defineProperty(aa,"__esModule",{value:!0});aa.bindAll=aa.bind=void 0;var Hy=xm();Object.defineProperty(aa,"bind",{enumerable:!0,get:function(){return Hy.bind}});var Vy=E1();Object.defineProperty(aa,"bindAll",{enumerable:!0,get:function(){return Vy.bindAll}})});var ZC={};Q2(ZC,{BrandEditor:()=>tf,BrandFooter:()=>Ra,BrandProvider:()=>of,CHANNELS:()=>Cn,ChannelRootContainer:()=>Un,DEFAULT_ROUTING:()=>il,EditorSidebar:()=>_n,EmailChannel:()=>WC,EmailEditor:()=>ku,EmailEditorContainer:()=>Zp,EmailEditorMain:()=>qp,EmailSideBar:()=>Au,EmailSideBarItemDetails:()=>Mu,ErrorBoundary:()=>Tl,InboxChannel:()=>zC,InboxEditor:()=>Su,InboxSideBar:()=>Ru,MSTeamsChannel:()=>$C,MSTeamsEditor:()=>Ju,MSTeamsSideBar:()=>Ku,MonacoCodeEditor:()=>Qc,PreviewPanel:()=>Eu,PushChannel:()=>_C,PushEditor:()=>Du,SMSChannel:()=>UC,SMSEditor:()=>$u,SlackChannel:()=>jC,SlackEditor:()=>Ou,SlackSideBar:()=>Wu,SlackSideBarItemDetails:()=>Uu,TemplateEditor:()=>OC,TemplateProvider:()=>lf,TemplateStatus:()=>ra,TextMenu:()=>Ta,ToggleGroup:()=>Xr,VariableInput:()=>Ea,VariableTextarea:()=>yo,apiUrlAtom:()=>er,brandApplyAtom:()=>rd,cn:()=>I,convertElementalToTiptap:()=>tt,convertLegacyError:()=>za,convertTiptapToElemental:()=>be,createCustomError:()=>Bo,extractErrorMessage:()=>ay,getChannelDefaults:()=>Gu,getFlattenedVariables:()=>tn,isRetryableError:()=>iy,isTemplateLoadingAtom:()=>pe,isTemplatePublishingAtom:()=>cr,isTemplateSavingAtom:()=>yt,routingAtom:()=>_a,templateDataAtom:()=>bt,templateErrorAtom:()=>ae,templateIdAtom:()=>Kr,tenantIdAtom:()=>Mt,tokenAtom:()=>tr,useAutoSave:()=>Fa,useBlockConfig:()=>b0,useBrandActions:()=>_i,useChannels:()=>Xu,useDebouncedFlush:()=>Iu,useImageUpload:()=>$i,useNodeAttributes:()=>Ut,useTemplateActions:()=>zi,useTemplateStore:()=>Vi,useVariables:()=>s0});module.exports=ey(ZC);var hn=require("jotai"),Hi=require("react");var Jr=require("jotai"),il={method:"single",channels:["email"]},er=(0,Jr.atom)("https://api.courier.com/client/q"),tr=(0,Jr.atom)(""),Mt=(0,Jr.atom)(""),Kr=(0,Jr.atom)(""),_a=(0,Jr.atom)(il),bt=(0,Jr.atom)(null),pe=(0,Jr.atom)(null),yt=(0,Jr.atom)(null),cr=(0,Jr.atom)(null),ae=(0,Jr.atom)(null),rd=(0,Jr.atom)(!0);var Di=require("react/jsx-runtime"),ty=a(({children:e,tenantId:t,token:r,apiUrl:o})=>{let[,n]=(0,hn.useAtom)(er),[,i]=(0,hn.useAtom)(tr),[,s]=(0,hn.useAtom)(Mt);return(0,Hi.useEffect)(()=>{i(r),s(t),o&&n(o)},[r,t,o,n,i,s]),(0,Di.jsx)(Di.Fragment,{children:e})},"BrandProviderContext"),ry=a(e=>{let t=(0,Hi.useMemo)(()=>(0,hn.createStore)(),[]);return(0,Di.jsx)(hn.Provider,{store:t,children:(0,Di.jsx)(ty,{...e})})},"BrandProviderComponent"),of=(0,Hi.memo)(ry);var Gr=require("jotai"),no=require("react"),nf=require("sonner");var al=require("react/jsx-runtime"),Vi=a(()=>({store:(0,Gr.useStore)()}),"useTemplateStore"),af=(0,no.createContext)(null),sf=a(()=>(0,no.useContext)(af),"useUploadImage"),oy=a(({children:e,templateId:t,tenantId:r,token:o,apiUrl:n,uploadImage:i})=>{let[,s]=(0,Gr.useAtom)(er),[,l]=(0,Gr.useAtom)(tr),[,c]=(0,Gr.useAtom)(Mt),[,u]=(0,Gr.useAtom)(Kr),[d]=(0,Gr.useAtom)(ae);return(0,no.useEffect)(()=>{l(o),c(r),u(t),n&&s(n)},[o,r,t,n,s,l,c,u]),(0,no.useEffect)(()=>{d&&nf.toast.error(d.message,d.toastProps)},[d]),(0,al.jsx)(af.Provider,{value:i||null,children:e})},"TemplateProviderContext"),ny=a(e=>{let t=(0,no.useMemo)(()=>(0,Gr.createStore)(),[]);return(0,al.jsx)(Gr.Provider,{store:t,children:(0,al.jsx)(oy,{...e})})},"TemplateProviderComponent"),lf=(0,no.memo)(ny);var ao=require("jotai");var Bo=a((e,t)=>({message:e,toastProps:t}),"createCustomError"),iy=a(e=>{var t;return((t=e.toastProps)==null?void 0:t.action)!==void 0},"isRetryableError"),ay=a(e=>typeof e=="string"?e:e&&typeof e=="object"&&"message"in e?String(e.message):e instanceof Error?e.message:"Unknown error","extractErrorMessage"),za=a(e=>typeof e=="string"?Bo(e):e,"convertLegacyError");var od=require("jotai"),cf=require("sonner");var uf=(0,od.atom)(null,async(e,t,r)=>{var s;let o=e(er),n=e(tr),i=e(Mt);if(!o){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(yt,!0),t(ae,null);try{let c=await(await fetch(o,{method:"POST",headers:{Authorization:`Bearer ${n}`,"x-courier-client-key":`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
47
47
  mutation SaveTenantBrand($input: SaveBrandSettingsInput!) {
48
48
  tenant {
49
49
  brand {
@@ -53,8 +53,8 @@ if (typeof require !== "undefined") {
53
53
  }
54
54
  }
55
55
  }
56
- `,variables:{input:{tenantId:i,settings:r}}})})).json();if(!c.data)if(c.errors){let u=(a=c.errors)==null?void 0:a.map(p=>p.message);t(G,{message:u.join(`
57
- `),toastProps:{duration:4e3}})}else t(G,{message:"Error saving brand settings",toastProps:{duration:4e3}});return c}catch(l){throw t(G,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save brand settings"}}),l}finally{t(at,!1)}}),Pm=(0,_c.atom)(null,async(e,t)=>{let r=e(Bt),o=e(Dt),n=e(pt);if(!r){t(G,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(_t,!0),t(G,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:`
56
+ `,variables:{input:{tenantId:i,settings:r}}})})).json();if(!c.data)if(c.errors){let u=(s=c.errors)==null?void 0:s.map(d=>d.message);t(ae,{message:u.join(`
57
+ `),toastProps:{duration:4e3}})}else t(ae,{message:"Error saving brand settings",toastProps:{duration:4e3}});return c}catch(l){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save brand settings"}}),l}finally{t(yt,!1)}}),df=(0,od.atom)(null,async(e,t)=>{let r=e(er),o=e(tr),n=e(Mt);if(!r){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(cr,!0),t(ae,null);try{let i=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
58
58
  mutation PublishNotification($input: PublishBrandInput!) {
59
59
  tenant {
60
60
  brand {
@@ -64,7 +64,7 @@ if (typeof require !== "undefined") {
64
64
  }
65
65
  }
66
66
  }
67
- `,variables:{input:{tenantId:n}}})}),a=await i.json();return i.status===200?km.toast.success("Brand published"):t(G,{message:"Error publishing brand",toastProps:{duration:4e3}}),a}catch(i){throw t(G,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish brand"}}),i}finally{t(_t,!1)}});var Am=require("jotai");var Xe=require("jotai");var gn=(0,Xe.atom)(null),$c=(0,Xe.atom)(null),ss=(0,Xe.atom)(null),te=(0,Xe.atom)(e=>e(ss),(e,t,r)=>{if(!r){t(ss,r);return}let o=e($c),n=r;if(o)try{n=o(r)}catch(a){console.error("[ContentTransformer] Error applying transformer:",a),n=r}let i=e(ss);JSON.stringify(i)!==JSON.stringify(n)&&t(ss,n)}),jn=(0,Xe.atom)(null),Kn=(0,Xe.atom)(null),Ie=(0,Xe.atom)(null),Gn=(0,Xe.atom)(null),xt=(0,Xe.atom)(!1),lo=(0,Xe.atom)(!1),hn=(0,Xe.atom)({}),Xt=(0,Xe.atom)(!1),Je=(0,Xe.atom)(null),Nm=(0,Xe.atom)(null),zc=(0,Xe.atom)(new Map),bn=(0,Xe.atom)(e=>e(zc),(e,t,r)=>{let o=new Map(e(zc));r.action==="register"&&r.fn?o.set(r.id,r.fn):r.action==="unregister"&&o.delete(r.id),t(zc,o)}),Mm=s(e=>{e.forEach(t=>{try{t()}catch(r){console.error("[FlushPendingUpdates] Error flushing updates:",r)}})},"flushAllPendingUpdates"),hr=s(e=>typeof e=="object"&&"preset"in e,"isPresetReference"),ls=["heading","text","image","spacer","divider","button","customCode"],co=(0,Xe.atom)(ls),cs=(0,Xe.atom)({}),Wo=(0,Xe.atom)([]);var us=(0,Am.atom)(null,async(e,t,r)=>{var c,u,p,m,d;let o=e(Bt),n=e(Dt),i=e(pt),a=e(Mr),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(G,{message:"Missing configuration",toastProps:{description:`Missing: ${f.join(", ")}`,duration:5e3}});return}t(se,!0),t(G,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}}})}),s=await i.json();return i.status===200?cf.toast.success("Brand published"):t(ae,{message:"Error publishing brand",toastProps:{duration:4e3}}),s}catch(i){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish brand"}}),i}finally{t(cr,!1)}});var ff=require("jotai");var Xe=require("jotai");var Gn=(0,Xe.atom)(null),id=(0,Xe.atom)(null),sl=(0,Xe.atom)(null),le=(0,Xe.atom)(e=>e(sl),(e,t,r)=>{if(!r){t(sl,r);return}let o=e(id),n=r;if(o)try{n=o(r)}catch(s){console.error("[ContentTransformer] Error applying transformer:",s),n=r}let i=e(sl);JSON.stringify(i)!==JSON.stringify(n)&&t(sl,n)}),Fi=(0,Xe.atom)(null),Oi=(0,Xe.atom)(null),He=(0,Xe.atom)(null),Wi=(0,Xe.atom)(null),Ft=(0,Xe.atom)(!1),Do=(0,Xe.atom)(!1),Xn=(0,Xe.atom)({}),ll=(0,Xe.atom)({}),cl=(0,Xe.atom)(!1),Ui=(0,Xe.atom)(void 0),Cr=(0,Xe.atom)(!1),it=(0,Xe.atom)(null),mf=(0,Xe.atom)(null),nd=(0,Xe.atom)(new Map),Yn=(0,Xe.atom)(e=>e(nd),(e,t,r)=>{let o=new Map(e(nd));r.action==="register"&&r.fn?o.set(r.id,r.fn):r.action==="unregister"&&o.delete(r.id),t(nd,o)}),pf=a(e=>{e.forEach(t=>{try{t()}catch(r){console.error("[FlushPendingUpdates] Error flushing updates:",r)}})},"flushAllPendingUpdates"),Hr=a(e=>typeof e=="object"&&"preset"in e,"isPresetReference"),ul=["heading","text","image","spacer","divider","button","customCode"],Ho=(0,Xe.atom)(ul),dl=(0,Xe.atom)({}),bn=(0,Xe.atom)([]);var ml=(0,ff.atom)(null,async(e,t,r)=>{var c,u,d,p,m;let o=e(er),n=e(tr),i=e(Mt),s=e(Kr),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(ae,{message:"Missing configuration",toastProps:{description:`Missing: ${f.join(", ")}`,duration:5e3}});return}t(pe,!0),t(ae,null);try{let f=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,"x-courier-client-key":`Bearer ${n}`},body:JSON.stringify({query:`
68
68
  query GetTenant($tenantId: String!, $input: GetNotificationInput!, $brandInput: GetTenantBrandInput!, $includeBrand: Boolean!) {
69
69
  tenant(tenantId: $tenantId) {
70
70
  tenantId
@@ -122,13 +122,13 @@ if (typeof require !== "undefined") {
122
122
  }
123
123
  }
124
124
  }
125
- `,variables:{tenantId:i,input:{notificationId:a,version:"latest"},brandInput:{version:"latest"},includeBrand:l}})}),C=await f.json(),h=f.status,b=(u=C.data)==null?void 0:u.tenant;if(b?(t(it,C),t(jn,(p=b==null?void 0:b.notification)==null?void 0:p.publishedAt),t(Kn,(m=b==null?void 0:b.notification)==null?void 0:m.version)):h===401?t(G,{message:"Authentication failed",toastProps:{duration:6e3}}):t(G,{message:"Error fetching template data",toastProps:{duration:4e3}}),C.errors){let v=(d=C.errors)==null?void 0:d.map(E=>E.message);t(G,{message:v.join(`
126
- `),toastProps:{duration:4e3}})}}catch{t(G,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to fetch template data"}})}finally{t(se,!1)}});var ms=require("jotai"),Jc=require("sonner");function Zc(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(Zc,"cleanInboxElements");function Im(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}s(Im,"cleanPushElements");function ds(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}s(ds,"cleanSMSElements");function qc(e){return{...e,elements:e.elements.map(t=>t.type==="channel"&&t.channel==="inbox"&&t.elements?{...t,elements:Zc(t.elements)}:t)}}s(qc,"cleanTemplateContent");function Sm(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(Sm,"getSubjectStorageFormat");function Wr(e,t,r,o){let n=Sm(e,t);if(t==="push"){let i=o.find(p=>p.type==="meta"&&"title"in p),a=i&&"title"in i?i.title:r,l=o.filter(p=>p.type!=="meta"),c=Im(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=L2(o),a=i||r,l=i?o.slice(1):o,c=l.filter(C=>C.type==="text"),u=l.filter(C=>C.type==="action"),p=c[0],m=p?{type:"text",content:"content"in p?p.content:`
125
+ `,variables:{tenantId:i,input:{notificationId:s,version:"latest"},brandInput:{version:"latest"},includeBrand:l}})}),v=await f.json(),h=f.status,y=(u=v.data)==null?void 0:u.tenant;if(y?(t(bt,v),t(Fi,(d=y==null?void 0:y.notification)==null?void 0:d.publishedAt),t(Oi,(p=y==null?void 0:y.notification)==null?void 0:p.version)):h===401?t(ae,{message:"Authentication failed",toastProps:{duration:6e3}}):t(ae,{message:"Error fetching template data",toastProps:{duration:4e3}}),v.errors){let x=(m=v.errors)==null?void 0:m.map(E=>E.message);t(ae,{message:x.join(`
126
+ `),toastProps:{duration:4e3}})}}catch{t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to fetch template data"}})}finally{t(pe,!1)}});var fl=require("jotai"),ld=require("sonner");function ad(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)}a(ad,"cleanInboxElements");function gf(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}a(gf,"cleanPushElements");function pl(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}a(pl,"cleanSMSElements");function sd(e){return{...e,elements:e.elements.map(t=>t.type==="channel"&&t.channel==="inbox"&&t.elements?{...t,elements:ad(t.elements)}:t)}}a(sd,"cleanTemplateContent");function hf(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"}a(hf,"getSubjectStorageFormat");function io(e,t,r,o){let n=hf(e,t);if(t==="push"){let i=o.find(d=>d.type==="meta"&&"title"in d),s=i&&"title"in i?i.title:r,l=o.filter(d=>d.type!=="meta"),c=gf(l);return{elements:[{type:"meta",title:s},...c]}}if(t==="sms")return{elements:o.length>0?o:[{type:"text",content:`
127
+ `}]};if(t==="inbox"){let i=sy(o),s=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],p=d?{type:"text",content:"content"in d?d.content:`
128
128
  `}:{type:"text",content:`
129
- `},d=Zc(u);return{elements:[{type:"meta",title:a},m,...d]}}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(Wr,"createTitleUpdate");function L2(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(L2,"extractTitleFromFirstElement");function Xi(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(Xi,"extractCurrentTitle");var ps=(0,ms.atom)(null,async(e,t,r)=>{var C;let o,n;if(r&&typeof r=="object"&&("content"in r||"routing"in r&&!("method"in r))){let h=r;o=h.routing,n=h.content}else o=r;let a=o!=null?o:e(Gi),l=e(Bt),c=e(Dt),u=e(pt),p=e(Mr),m=n||e(te);if(!m)return;let d=qc(m);if(!l){t(G,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(at,!0),t(G,null);let f={content:d,routing:a};try{let b=await(await fetch(l,{method:"POST",headers:{Authorization:`Bearer ${c}`,"x-courier-client-key":`Bearer ${c}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
129
+ `},m=ad(u);return{elements:[{type:"meta",title:s},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]}}a(io,"createTitleUpdate");function sy(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}a(sy,"extractTitleFromFirstElement");function $a(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(s=>s.type==="meta");if(r&&"title"in r&&typeof r.title=="string")return r.title;if(t==="email")return"";let o="",n="";for(let s of e.elements)if(s.type==="text"&&"content"in s&&s.content){let l=s.content.trim();l&&l!==`
131
+ `&&("text_style"in s&&(s.text_style==="h1"||s.text_style==="h2")?n||(n=l):o||(o=l))}let i=n||o;if(i)return i}return""}a($a,"extractCurrentTitle");var gl=(0,fl.atom)(null,async(e,t,r)=>{var v;let o,n;if(r&&typeof r=="object"&&("content"in r||"routing"in r&&!("method"in r))){let h=r;o=h.routing,n=h.content}else o=r;let s=o!=null?o:e(_a),l=e(er),c=e(tr),u=e(Mt),d=e(Kr),p=n||e(le);if(!p)return;let m=sd(p);if(!l){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(yt,!0),t(ae,null);let f={content:m,routing:s};try{let y=await(await fetch(l,{method:"POST",headers:{Authorization:`Bearer ${c}`,"x-courier-client-key":`Bearer ${c}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
132
132
  mutation SaveNotification($input: SaveNotificationInput!) {
133
133
  tenant {
134
134
  notification {
@@ -141,8 +141,8 @@ if (typeof require !== "undefined") {
141
141
  }
142
142
  }
143
143
  }
144
- `,variables:{input:{tenantId:u,notificationId:p,name:p,data:f}}})})).json();if(b.data)t(Kn,b.data.tenant.notification.save.version);else if(b.errors){let v=(C=b.errors)==null?void 0:C.map(E=>E.message);t(G,{message:v.join(`
145
- `),toastProps:{duration:4e3}})}else t(G,{message:"Error saving template",toastProps:{duration:4e3}});return b}catch(h){throw t(G,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save template"}}),h}finally{t(at,!1)}}),Rm=(0,ms.atom)(null,async(e,t)=>{let r=e(Bt),o=e(Dt),n=e(pt),i=e(Mr),a=e(Kn);if(!a){t(G,{message:"Version not defined",toastProps:{duration:5e3}});return}if(!r){t(G,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(_t,!0),t(G,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:u,notificationId:d,name:d,data:f}}})})).json();if(y.data)t(Oi,y.data.tenant.notification.save.version);else if(y.errors){let x=(v=y.errors)==null?void 0:v.map(E=>E.message);t(ae,{message:x.join(`
145
+ `),toastProps:{duration:4e3}})}else t(ae,{message:"Error saving template",toastProps:{duration:4e3}});return y}catch(h){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save template"}}),h}finally{t(yt,!1)}}),bf=(0,fl.atom)(null,async(e,t)=>{let r=e(er),o=e(tr),n=e(Mt),i=e(Kr),s=e(Oi);if(!s){t(ae,{message:"Version not defined",toastProps:{duration:5e3}});return}if(!r){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(cr,!0),t(ae,null);try{let l=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
146
146
  mutation PublishNotification($input: PublishNotificationInput!) {
147
147
  tenant {
148
148
  notification {
@@ -154,7 +154,7 @@ if (typeof require !== "undefined") {
154
154
  }
155
155
  }
156
156
  }
157
- `,variables:{input:{tenantId:n,notificationId:i,version:a}}})}),c=await l.json();return l.status===200?(Jc.toast.success("Template published"),t(jn,new Date().toISOString()),t(Kn,c.data.tenant.notification.publish.version)):t(G,{message:"Error publishing template",toastProps:{duration:4e3}}),c}catch(l){throw t(G,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish template"}}),l}finally{t(_t,!1)}}),Lm=(0,ms.atom)(null,async(e,t,r={})=>{var f,C,h,b,v;let{content:o,name:n}=r,i=e(Bt),a=e(Dt),l=e(pt),c=e(Mr);if(!r.targetTemplateId&&!c){t(G,{message:"No template is currently loaded",toastProps:{duration:5e3}});return}let u=r.targetTemplateId||`${c}-copy`,p=o||e(te);if(!p){t(G,{message:"No template content to duplicate",toastProps:{duration:5e3}});return}if(!i){t(G,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(at,!0),t(G,null);let d={content:qc(p)};try{let g=await(await fetch(i,{method:"POST",headers:{Authorization:`Bearer ${a}`,"x-courier-client-key":`Bearer ${a}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
157
+ `,variables:{input:{tenantId:n,notificationId:i,version:s}}})}),c=await l.json();return l.status===200?(ld.toast.success("Template published"),t(Fi,new Date().toISOString()),t(Oi,c.data.tenant.notification.publish.version)):t(ae,{message:"Error publishing template",toastProps:{duration:4e3}}),c}catch(l){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish template"}}),l}finally{t(cr,!1)}}),yf=(0,fl.atom)(null,async(e,t,r={})=>{var f,v,h,y,x;let{content:o,name:n}=r,i=e(er),s=e(tr),l=e(Mt),c=e(Kr);if(!r.targetTemplateId&&!c){t(ae,{message:"No template is currently loaded",toastProps:{duration:5e3}});return}let u=r.targetTemplateId||`${c}-copy`,d=o||e(le);if(!d){t(ae,{message:"No template content to duplicate",toastProps:{duration:5e3}});return}if(!i){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(yt,!0),t(ae,null);let m={content:sd(d)};try{let g=await(await fetch(i,{method:"POST",headers:{Authorization:`Bearer ${s}`,"x-courier-client-key":`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
158
158
  mutation SaveNotification($input: SaveNotificationInput!) {
159
159
  tenant {
160
160
  notification {
@@ -167,8 +167,8 @@ if (typeof require !== "undefined") {
167
167
  }
168
168
  }
169
169
  }
170
- `,variables:{input:{tenantId:l,notificationId:u,name:n||u,data:d}}})})).json();if((b=(h=(C=(f=g.data)==null?void 0:f.tenant)==null?void 0:C.notification)==null?void 0:h.save)!=null&&b.success)return Jc.toast.success("Template duplicated successfully"),{success:!0,templateId:u,version:g.data.tenant.notification.save.version};if(g.errors){let w=(v=g.errors)==null?void 0:v.map(N=>N.message);return t(G,{message:w.join(`
171
- `),toastProps:{duration:4e3}}),{success:!1,templateId:u}}else return t(G,{message:"Error duplicating template",toastProps:{duration:4e3}}),{success:!1,templateId:u}}catch(E){throw t(G,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to duplicate template"}}),E}finally{t(at,!1)}});function Yn(){Jn();let e=(0,_r.useSetAtom)(us),t=(0,_r.useSetAtom)(wm),r=(0,_r.useSetAtom)(ps),o=(0,_r.useSetAtom)(Pm),[n,i]=(0,_r.useAtom)(se),[a,l]=(0,_r.useAtom)(at),[c,u]=(0,_r.useAtom)(_t),[p,m]=(0,_r.useAtom)(G),[d,f]=(0,_r.useAtom)(it);return{getTemplate:e,saveTemplate:r,saveBrand:t,publishBrand:o,isTemplateLoading:n,setIsTemplateLoading:i,isTemplateSaving:a,setIsTemplateSaving:l,isTemplatePublishing:c,setIsTemplatePublishing:u,templateError:p,setTemplateError:s(h=>{m(h===null?null:typeof h=="string"?so(h):h)},"setTemplateError"),templateData:d,setTemplateData:f,createCustomError:so,convertLegacyError:Yi}}s(Yn,"useBrandActions");var br=require("jotai");var Bm=require("react");function Xn(){let e=(0,br.useSetAtom)(us),t=(0,br.useSetAtom)(ps),r=(0,br.useSetAtom)(Rm),o=(0,br.useSetAtom)(Lm),[n,i]=(0,br.useAtom)(se),[a,l]=(0,br.useAtom)(at),[c,u]=(0,br.useAtom)(_t),[p,m]=(0,br.useAtom)(G),[d,f]=(0,br.useAtom)(it),[C,h]=(0,br.useAtom)(te),[b,v]=(0,br.useAtom)($c),E=(0,Bm.useCallback)(g=>{m(g===null?null:typeof g=="string"?so(g):g)},[m]);return{getTemplate:e,saveTemplate:t,publishTemplate:r,duplicateTemplate:o,isTemplateLoading:n,setIsTemplateLoading:i,isTemplateSaving:a,setIsTemplateSaving:l,isTemplatePublishing:c,setIsTemplatePublishing:u,templateError:p,setTemplateError:E,templateData:d,setTemplateData:f,templateEditorContent:C,setTemplateEditorContent:h,createCustomError:so,convertLegacyError:Yi,contentTransformer:b,setContentTransformer:v}}s(Xn,"useTemplateActions");var jc=require("jotai"),Hm=require("react");var B2=["image/png","image/jpeg","image/gif","image/webp"],Dm=s(async(e,t)=>{var c,u,p;let{apiUrl:r,token:o}=t;if(!B2.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,d)=>{let f=new FileReader;f.onload=()=>{typeof f.result=="string"?m(f.result):d(new Error("Failed to read file as data URL"))},f.onerror=()=>d(f.error),f.readAsDataURL(e)})).split(",")[1];try{let d=await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({query:`
170
+ `,variables:{input:{tenantId:l,notificationId:u,name:n||u,data:m}}})})).json();if((y=(h=(v=(f=g.data)==null?void 0:f.tenant)==null?void 0:v.notification)==null?void 0:h.save)!=null&&y.success)return ld.toast.success("Template duplicated successfully"),{success:!0,templateId:u,version:g.data.tenant.notification.save.version};if(g.errors){let b=(x=g.errors)==null?void 0:x.map(M=>M.message);return t(ae,{message:b.join(`
171
+ `),toastProps:{duration:4e3}}),{success:!1,templateId:u}}else return t(ae,{message:"Error duplicating template",toastProps:{duration:4e3}}),{success:!1,templateId:u}}catch(E){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to duplicate template"}}),E}finally{t(yt,!1)}});function _i(){Vi();let e=(0,ao.useSetAtom)(ml),t=(0,ao.useSetAtom)(uf),r=(0,ao.useSetAtom)(gl),o=(0,ao.useSetAtom)(df),[n,i]=(0,ao.useAtom)(pe),[s,l]=(0,ao.useAtom)(yt),[c,u]=(0,ao.useAtom)(cr),[d,p]=(0,ao.useAtom)(ae),[m,f]=(0,ao.useAtom)(bt);return{getTemplate:e,saveTemplate:r,saveBrand:t,publishBrand:o,isTemplateLoading:n,setIsTemplateLoading:i,isTemplateSaving:s,setIsTemplateSaving:l,isTemplatePublishing:c,setIsTemplatePublishing:u,templateError:d,setTemplateError:a(h=>{p(h===null?null:typeof h=="string"?Bo(h):h)},"setTemplateError"),templateData:m,setTemplateData:f,createCustomError:Bo,convertLegacyError:za}}a(_i,"useBrandActions");var Vr=require("jotai");var vf=require("react");function zi(){let e=(0,Vr.useSetAtom)(ml),t=(0,Vr.useSetAtom)(gl),r=(0,Vr.useSetAtom)(bf),o=(0,Vr.useSetAtom)(yf),[n,i]=(0,Vr.useAtom)(pe),[s,l]=(0,Vr.useAtom)(yt),[c,u]=(0,Vr.useAtom)(cr),[d,p]=(0,Vr.useAtom)(ae),[m,f]=(0,Vr.useAtom)(bt),[v,h]=(0,Vr.useAtom)(le),[y,x]=(0,Vr.useAtom)(id),E=(0,vf.useCallback)(g=>{p(g===null?null:typeof g=="string"?Bo(g):g)},[p]);return{getTemplate:e,saveTemplate:t,publishTemplate:r,duplicateTemplate:o,isTemplateLoading:n,setIsTemplateLoading:i,isTemplateSaving:s,setIsTemplateSaving:l,isTemplatePublishing:c,setIsTemplatePublishing:u,templateError:d,setTemplateError:E,templateData:m,setTemplateData:f,templateEditorContent:v,setTemplateEditorContent:h,createCustomError:Bo,convertLegacyError:za,contentTransformer:y,setContentTransformer:x}}a(zi,"useTemplateActions");var cd=require("jotai"),xf=require("react");var ly=["image/png","image/jpeg","image/gif","image/webp"],Cf=a(async(e,t)=>{var c,u,d;let{apiUrl:r,token:o}=t;if(!ly.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:`
172
172
  mutation UploadImage($input: UploadImageInput!) {
173
173
  tenant {
174
174
  notification {
@@ -178,57 +178,57 @@ if (typeof require !== "undefined") {
178
178
  }
179
179
  }
180
180
  }
181
- `,variables:{input:{name:i,type:e.type,data:l}}})})).json();if(d.errors)throw new Error(d.errors.map(C=>C.message).join(`
182
- `));let f=d.data;return(p=(u=(c=f==null?void 0:f.tenant)==null?void 0:c.notification)==null?void 0:u.uploadImage)==null?void 0:p.url}catch(m){throw console.error("Error uploading image:",m),m}},"uploadImage");function Qn(){let[e]=(0,jc.useAtom)(Bt),[t]=(0,jc.useAtom)(Dt),r=Tm();return{uploadImage:(0,Hm.useCallback)(async n=>{if(typeof r=="function"){let i,a;try{i=await r(n),i===void 0&&(i=await r(n.file))}catch(u){a=u;try{i=await r(n.file)}catch{throw a}}let l="",c;if(typeof i=="string")l=i;else if(i){c=i==null?void 0:i.message;let u=i.url;typeof u=="string"?l=u:u&&typeof u=="object"&&(c=c||(u==null?void 0:u.message))}if(c)throw new Error(c);if(!l)throw a||new Error("Error uploading image");return{url:l}}else{if(!e||!t)throw new Error("Upload failed: Missing configuration for image upload");let i=n.file instanceof File?n.file:new File([n.file],"upload",{type:n.file.type}),a=await Dm(i,{apiUrl:e,token:t});if(!a)throw new Error("Upload failed: No URL returned from server");return{url:a}}},[e,t,r])}}s(Qn,"useImageUpload");var Om=require("clsx"),Um=require("tailwind-merge");var yr=require("uuid");function Tt(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(Tt,"isValidVariableName");var D2="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function fs(e){return e?e===D2:!0}s(fs,"isBlankImageSrc");var gs=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 p=u.getContext("2d");if(p){p.imageSmoothingEnabled=!0,p.imageSmoothingQuality="high",p.drawImage(i,0,0,l,c);let d=.8,f=u.toDataURL(e.type||"image/jpeg",d),C=0,h=5;for(;f.length>512e3&&C<h;)C++,d-=.1,d<.3&&(d=.3),f=u.toDataURL(e.type||"image/jpeg",d);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 Vm(e){let t=[],r=e.replace(/\n$/,"").split(`
183
- `);for(let o=0;o<r.length;o++)H2(r[o],t),o<r.length-1&&t.push({type:"hardBreak"});return t}s(Vm,"parseMDContent");function H2(e,t){Kc(e,t)}s(H2,"parseTextLine");function Kc(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 p of r){let m=new RegExp(p.regex.source,p.regex.flags),d;for(;(d=m.exec(e))!==null;)if(p.type==="variable"){let f=d[1].trim(),C=f===""||Tt(f);o.push({start:d.index,end:d.index+d[0].length,text:d[1],type:"variable",attrs:{id:f,isInvalid:!C}})}else p.type==="link"?o.push({start:d.index,end:d.index+d[0].length,text:d[1],type:"link",attrs:{href:d[2]}}):o.push({start:d.index,end:d.index+d[0].length,text:d[1],type:p.type})}o.sort((p,m)=>p.start-m.start);let n=[],i=0;for(let p of o)p.start>=i&&(n.push(p),i=p.end);let a=[],l=0;for(let p of n){if(p.start>l){let m=e.substring(l,p.start);m&&Gc(m,[],a)}if(p.type==="variable")a.push({type:"variable",attrs:{id:(c=p.attrs)==null?void 0:c.id,isInvalid:(u=p.attrs)==null?void 0:u.isInvalid}});else if(p.type==="link"){let m=[];Kc(p.text,m),m.forEach(d=>{var f;d.marks=d.marks||[],d.marks.push({type:"link",attrs:{href:(f=p.attrs)==null?void 0:f.href}})}),a.push(...m)}else{let m=[];Kc(p.text,m),m.forEach(d=>{d.marks=d.marks||[],d.marks.push({type:p.type})}),a.push(...m)}l=p.end}if(l<e.length){let p=e.substring(l);p&&Gc(p,[],a)}t.push(...a)}s(Kc,"processMarkdownFormatting");function Gc(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===""||Tt(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(Gc,"parseTextWithVariables");function Ze(e,t){var p,m,d,f,C,h,b,v,E;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 w=g;if(n){if(w.channel===n){i=w;break}}else{i=w;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||`
181
+ `,variables:{input:{name:i,type:e.type,data:l}}})})).json();if(m.errors)throw new Error(m.errors.map(v=>v.message).join(`
182
+ `));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 $i(){let[e]=(0,cd.useAtom)(er),[t]=(0,cd.useAtom)(tr),r=sf();return{uploadImage:(0,xf.useCallback)(async n=>{if(typeof r=="function"){let i,s;try{i=await r(n),i===void 0&&(i=await r(n.file))}catch(u){s=u;try{i=await r(n.file)}catch{throw s}}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 s||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}),s=await Cf(i,{apiUrl:e,token:t});if(!s)throw new Error("Upload failed: No URL returned from server");return{url:s}}},[e,t,r])}}a($i,"useImageUpload");var wf=require("clsx"),kf=require("tailwind-merge");var Fr=require("uuid");function Ot(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}a(Ot,"isValidVariableName");var cy="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function hl(e){return e?e===cy:!0}a(hl,"isBlankImageSrc");var bl=a((e,t)=>new Promise(r=>{let o=new FileReader;o.onload=n=>{var s;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),v=0,h=5;for(;f.length>512e3&&v<h;)v++,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=(s=n.target)==null?void 0:s.result},o.readAsDataURL(e)}),"resizeImage");function Tf(e){let t=[],r=e.replace(/\n$/,"").split(`
183
+ `);for(let o=0;o<r.length;o++)uy(r[o],t),o<r.length-1&&t.push({type:"hardBreak"});return t}a(Tf,"parseMDContent");function uy(e,t){ud(e,t)}a(uy,"parseTextLine");function ud(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(),v=f===""||Ot(f);o.push({start:m.index,end:m.index+m[0].length,text:m[1],type:"variable",attrs:{id:f,isInvalid:!v}})}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 s=[],l=0;for(let d of n){if(d.start>l){let p=e.substring(l,d.start);p&&dd(p,[],s)}if(d.type==="variable")s.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=[];ud(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}})}),s.push(...p)}else{let p=[];ud(d.text,p),p.forEach(m=>{m.marks=m.marks||[],m.marks.push({type:d.type})}),s.push(...p)}l=d.end}if(l<e.length){let d=e.substring(l);d&&dd(d,[],s)}t.push(...s)}a(ud,"processMarkdownFormatting");function dd(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 s=n[1].trim(),l=t.some(u=>u.type==="link"),c=s===""||Ot(s);r.push({type:"variable",attrs:{id:s,isInvalid:!c,...l&&{inUrlContext:!0}},...t.length>0&&{marks:t}}),i=n.index+n[0].length}if(i<e.length){let s=e.substring(i);s&&r.push({type:"text",text:s,...t.length>0&&{marks:t}})}}a(dd,"parseTextWithVariables");function tt(e,t){var d,p,m,f,v,h,y,x,E;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 b=g;if(n){if(b.channel===n){i=b;break}}else{i=b;break}}if(!i||i.type!=="channel")return r;let s=i;if(s.elements&&s.elements.length>0?(o=s.elements,s.channel==="push"&&(o=o.map(g=>g.type==="meta"&&"title"in g?{type:"text",content:g.title||`
184
184
  `,text_style:"h2"}:g))):o=[{type:"text",content:`
185
- `}],!o||o.length===0)return r;let l=s(g=>{var w,N,y,S,P,T,x,k,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[L,D]=g.padding.replace(/px/g,"").split(" "),V=parseInt(L),O=parseInt(D);!isNaN(V)&&!isNaN(O)&&(R={paddingVertical:V,paddingHorizontal:O})}let B={};if(g.border_size||(w=g.border)!=null&&w.enabled||(N=g.border)!=null&&N.size){let L=g.border_size||((y=g.border)==null?void 0:y.size),D=g.border_color||((S=g.border)==null?void 0:S.color);B={...L&&{borderWidth:parseInt(L)},...D&&{borderColor:D}}}let F=g.content.trim()?Vm(g.content):[];return[{type:A?"heading":"paragraph",attrs:{textAlign:g.align||"left",level:A,id:`node-${(0,yr.v4)()}`,...R,...B,...g.background_color&&{backgroundColor:g.background_color},...g.locales&&{locales:g.locales}},content:F}]}return[];case"action":{let R=n==="inbox"?{backgroundColor:"#000000",textColor:"#ffffff",borderColor:"transparent",borderWidth:1,borderRadius:4}:{},B=g.content||"Button",F=[];Gc(B,[],F),F.length===0&&F.push({type:"text",text:B||"Button"});let L=(T=g.border_radius)!=null?T:(P=g.border)==null?void 0:P.radius,D=(x=g.border)==null?void 0:x.color,V;return typeof L=="string"?V=parseInt(L):typeof L=="number"&&(V=L),[{type:"button",content:F,attrs:{label:B,link:g.href,alignment:g.align==="full"?"center":g.align||"center",style:g.style,id:`node-${(0,yr.v4)()}`,...R,...g.background_color&&{backgroundColor:g.background_color},...g.color&&{textColor:g.color},...g.padding&&{padding:parseInt(g.padding)},...V!==void 0&&{borderRadius:V},...D&&{borderColor:D},...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 B={textAlign:g.align||"left",id:`node-${(0,yr.v4)()}`};return R!==void 0&&(B.level=R),[{type:"blockquote",attrs:{textAlign:g.align||"left",id:`node-${(0,yr.v4)()}`,...g.border_color&&{borderColor:g.border_color},...g.border_left_width!==void 0&&{borderLeftWidth:g.border_left_width},...g.padding_horizontal!==void 0&&{paddingHorizontal:g.padding_horizontal},...g.padding_vertical!==void 0&&{paddingVertical:g.padding_vertical},...g.background_color&&{backgroundColor:g.background_color},...g.locales&&{locales:g.locales}},content:[{type:A,attrs:B,content:Vm(g.content)}]}]}case"image":{let A={};if(g.width){let F=g.width.endsWith("px"),L=parseInt(g.width.replace(/%|px/,""));if(F&&g.image_natural_width&&g.image_natural_width>0){let D=Math.round(L/g.image_natural_width*100);A.width=Math.max(1,Math.min(100,D)),A.imageNaturalWidth=g.image_natural_width}else A.width=L,g.image_natural_width&&(A.imageNaturalWidth=g.image_natural_width)}let R=g.border_size||((k=g.border)==null?void 0:k.size),B=g.border_color||((M=g.border)==null?void 0:M.color);return[{type:"imageBlock",attrs:{sourcePath:fs(g.src)?"":g.src,id:`node-${(0,yr.v4)()}`,...g.href&&{link:g.href},...g.align&&{alignment:g.align},...g.alt_text&&{alt:g.alt_text},...A,...R&&{borderWidth:parseInt(R),...B&&{borderColor:B}},...g.locales&&{locales:g.locales}}}]}case"divider":{let A=g.border_width||g.width;return[{type:"divider",attrs:{id:`node-${(0,yr.v4)()}`,...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-${(0,yr.v4)()}`,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,B=0;if(g.padding){let _=g.padding.split(" ");R=parseInt(_[0],10)||0,B=parseInt(_[1]||_[0],10)||0}let F=0,L=0,D="transparent";g.border&&(g.border.size&&(F=parseInt(g.border.size,10)||0),g.border.radius!==void 0&&(L=g.border.radius),g.border.color&&(D=g.border.color));let V=g.background_color||"transparent",O=`node-${(0,yr.v4)()}`,$=g.elements?g.elements.map((_,z)=>{var H;if(_.type==="text"&&"content"in _&&((H=_.content)==null?void 0:H.trim())==="Drag and drop content blocks"&&_.align==="left")return{type:"columnCell",attrs:{index:z,columnId:O,isEditorMode:!1},content:[]};let re;_.type==="group"&&_.elements?re=_.elements.flatMap(l):re=l(_);let ne=re.length>0?re:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,yr.v4)()}`},content:[]}];return{type:"columnCell",attrs:{index:z,columnId:O,isEditorMode:re.length>0},content:ne}}):[{type:"columnCell",attrs:{index:0,columnId:O,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,yr.v4)()}`},content:[]}]},{type:"columnCell",attrs:{index:1,columnId:O,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,yr.v4)()}`},content:[]}]}];return[{type:"column",attrs:{id:O,columnsCount:Math.min(Math.max(A,1),4),paddingVertical:R,paddingHorizontal:B,backgroundColor:V,borderWidth:F,borderRadius:L,borderColor:D,...g.locales&&{locales:g.locales}},content:[{type:"columnRow",content:$}]}]}default:return[]}},"convertNode"),c=[],u=o.flatMap(l);for(let g=0;g<u.length;g++){let w=u[g],N=u[g+1];if(w.type==="button"&&(N==null?void 0:N.type)==="button"&&n==="inbox"){let y={type:"buttonRow",attrs:{id:`node-${(0,yr.v4)()}`,button1Label:((p=w.attrs)==null?void 0:p.label)||"Button 1",button1Link:((m=w.attrs)==null?void 0:m.link)||"",button1BackgroundColor:((d=w.attrs)==null?void 0:d.backgroundColor)||"#000000",button1TextColor:((f=w.attrs)==null?void 0:f.textColor)||"#ffffff",button2Label:((C=N.attrs)==null?void 0:C.label)||"Button 2",button2Link:((h=N.attrs)==null?void 0:h.link)||"",button2BackgroundColor:((b=N.attrs)==null?void 0:b.backgroundColor)||"#ffffff",button2TextColor:((v=N.attrs)==null?void 0:v.textColor)||"#000000",padding:((E=w.attrs)==null?void 0:E.padding)||6}};c.push(y),g++}else c.push(w)}return{type:"doc",content:c}}s(Ze,"convertElementalToTiptap");function Fm(e,t,r){if(!e)return;let o=/{{([^}]*)}}/g,n,i=0;for(;(n=o.exec(e))!==null;){if(n.index>i){let c=e.substring(i,n.index);r.push({type:"text",text:c,...t.length>0&&{marks:t}})}let a=n[1].trim(),l=a===""||Tt(a);r.push({type:"variable",attrs:{id:a,isInvalid:!l},...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(Fm,"parseTextWithVariables");function Qi(e){var l,c;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 u of t){let p=new RegExp(u.regex.source,u.regex.flags),m;for(;(m=p.exec(e))!==null;)if(u.type==="variable"){let d=m[1].trim(),f=d===""||Tt(d);r.push({start:m.index,end:m.index+m[0].length,text:m[1],type:"variable",attrs:{id:d,isInvalid:!f}})}else u.type==="link"?r.push({start:m.index,end:m.index+m[0].length,text:m[1],type:"link",attrs:{href:m[2]}}):r.push({start:m.index,end:m.index+m[0].length,text:m[1],type:u.type})}r.sort((u,p)=>u.start-p.start);let o=[],n=0;for(let u of r)u.start>=n&&(o.push(u),n=u.end);let i=[],a=0;for(let u of o){if(u.start>a){let p=e.substring(a,u.start);p&&Fm(p,[],i)}if(u.type==="variable")i.push({type:"variable",attrs:{id:(l=u.attrs)==null?void 0:l.id,isInvalid:(c=u.attrs)==null?void 0:c.isInvalid}});else if(u.type==="link"){let p=[],m=Qi(u.text);p.push(...m),p.forEach(d=>{var f;d.marks=d.marks||[],d.marks.push({type:"link",attrs:{href:(f=u.attrs)==null?void 0:f.href}})}),i.push(...p)}else{let p=Qi(u.text);p.forEach(m=>{m.marks=m.marks||[],m.marks.push({type:u.type})}),i.push(...p)}a=u.end}if(a<e.length){let u=e.substring(a);u&&Fm(u,[],i)}return i}s(Qi,"processMarkdownFormatting");function V2(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:Qi(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:Qi(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:Qi(o)})}return t}s(V2,"parseBlockContent");function Yc(e){return{type:"doc",content:V2(e)}}s(Yc,"convertMarkdownToTiptap");var F2=s(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),hs=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(F2).filter(Boolean);t=l.join("")+t+l.reverse().join("")}let r=(i=e.marks)==null?void 0:i.find(l=>l.type==="link");return r&&(t=`[${t}](${(a=r.attrs)==null?void 0:a.href})`),t},"convertTextToMarkdown");function de(e){let t=s(r=>{var o,n,i,a,l,c,u,p,m,d,f,C,h,b,v,E,g,w,N,y,S,P,T,x,k,M,A,R,B,F,L,D,V,O,$,_,z,Q,re,ne,H,X,ke,Le,nt,vt,fr,gr,le,Ve,Ae,Ut,Wt,Dr,Hr,Vr,Fr,Oo,ie,To,pn,fn,zi,$i,Zi,qi,Ji,ji;switch(r.type){case"paragraph":{let ee="",ae=r.content||[];for(let _e=0;_e<ae.length;_e++)ae[_e].type==="hardBreak"?ee+=`
186
- `:ee+=hs(ae[_e]);ee+=`
187
- `;let ge={};(o=r.attrs)!=null&&o.borderWidth&&(ge.border_size=`${r.attrs.borderWidth}px`),(n=r.attrs)!=null&&n.borderColor&&(ge.border_color=r.attrs.borderColor),((i=r.attrs)==null?void 0:i.paddingVertical)!==void 0&&((a=r.attrs)==null?void 0:a.paddingHorizontal)!==void 0&&(ge.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(l=r.attrs)!=null&&l.backgroundColor&&(ge.background_color=r.attrs.backgroundColor),ge.type="text",ge.align=((c=r.attrs)==null?void 0:c.textAlign)||"left",ge.content=ee;let we=ge;return(u=r.attrs)!=null&&u.locales&&(we.locales=r.attrs.locales),[we]}case"heading":{let ee="",ae=r.content||[];for(let _e=0;_e<ae.length;_e++)ae[_e].type==="hardBreak"?ee+=`
188
- `:ee+=hs(ae[_e]);ee+=`
189
- `;let ge={};(p=r.attrs)!=null&&p.borderWidth&&(ge.border_size=`${r.attrs.borderWidth}px`),(m=r.attrs)!=null&&m.borderColor&&(ge.border_color=r.attrs.borderColor),ge.text_style=((d=r.attrs)==null?void 0:d.level)===1?"h1":"h2",((f=r.attrs)==null?void 0:f.paddingVertical)!==void 0&&((C=r.attrs)==null?void 0:C.paddingHorizontal)!==void 0&&(ge.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(h=r.attrs)!=null&&h.backgroundColor&&(ge.background_color=r.attrs.backgroundColor),ge.type="text",ge.align=((b=r.attrs)==null?void 0:b.textAlign)||"left",ge.content=ee;let we=ge;return(v=r.attrs)!=null&&v.locales&&(we.locales=r.attrs.locales),[we]}case"blockquote":{let ee="",ae,ge;if(r.content)for(let _e of r.content){if(!ae){if(_e.type==="heading"){let Or=(E=_e.attrs)==null?void 0:E.level;Or===1?ae="h1":Or===2?ae="h2":ae="subtext"}ge=(g=_e.attrs)==null?void 0:g.textAlign}if(_e.content)for(let Or of _e.content)Or.type==="hardBreak"?ee+=`
190
- `:ee+=hs(Or);ee+=`
191
- `}ee=ee.trim();let we={type:"quote",content:ee};return ge&&ge!=="left"&&(we.align=ge),(w=r.attrs)!=null&&w.borderColor&&(we.border_color=r.attrs.borderColor),((N=r.attrs)==null?void 0:N.borderLeftWidth)!==void 0&&(we.border_left_width=r.attrs.borderLeftWidth),((y=r.attrs)==null?void 0:y.paddingHorizontal)!==void 0&&(we.padding_horizontal=r.attrs.paddingHorizontal),((S=r.attrs)==null?void 0:S.paddingVertical)!==void 0&&(we.padding_vertical=r.attrs.paddingVertical),(P=r.attrs)!=null&&P.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(we.background_color=r.attrs.backgroundColor),ae&&(we.text_style=ae),(T=r.attrs)!=null&&T.locales&&(we.locales=r.attrs.locales),[we]}case"imageBlock":{let ee={},ae=(x=r.attrs)==null?void 0:x.width,ge=(k=r.attrs)==null?void 0:k.imageNaturalWidth;if(ae&&ge&&ge>0){let _e=Math.round(ae/100*ge);ee.width=`${_e}px`,ee.image_natural_width=ge}else ae&&(ee.width=`${ae}%`);(M=r.attrs)!=null&&M.borderWidth&&(ee.border_size=`${r.attrs.borderWidth}px`),(A=r.attrs)!=null&&A.borderColor&&(ee.border_color=r.attrs.borderColor),ee.type="image",ee.src=((R=r.attrs)==null?void 0:R.sourcePath)||"",(B=r.attrs)!=null&&B.alignment&&(ee.align=r.attrs.alignment),(F=r.attrs)!=null&&F.link&&(ee.href=r.attrs.link),(L=r.attrs)!=null&&L.alt&&(ee.alt_text=r.attrs.alt);let we=ee;return(D=r.attrs)!=null&&D.locales&&(we.locales=r.attrs.locales),[we]}case"divider":{let ee={type:"divider"};return(V=r.attrs)!=null&&V.color&&(ee.color=r.attrs.color),(O=r.attrs)!=null&&O.size&&(ee.border_width=`${r.attrs.size}px`),($=r.attrs)!=null&&$.padding&&(ee.padding=`${r.attrs.padding}px 0px`),[ee]}case"button":{let ee=(z=(_=r.attrs)==null?void 0:_.label)!=null?z:"";r.content&&r.content.length>0&&(ee=r.content.map(hs).join(""));let ae={type:"action",content:ee,href:(re=(Q=r.attrs)==null?void 0:Q.link)!=null?re:"#"};return(ne=r.attrs)!=null&&ne.style&&(ae.style=r.attrs.style),ae.align=((H=r.attrs)==null?void 0:H.alignment)||"center",(X=r.attrs)!=null&&X.backgroundColor&&(ae.background_color=r.attrs.backgroundColor),(ke=r.attrs)!=null&&ke.padding&&(ae.padding=`${r.attrs.padding}px`),(Le=r.attrs)!=null&&Le.borderRadius&&(ae.border_radius=`${r.attrs.borderRadius}px`),(nt=r.attrs)!=null&&nt.locales&&(ae.locales=r.attrs.locales),[ae]}case"buttonRow":{let ee={type:"action",content:(fr=(vt=r.attrs)==null?void 0:vt.button1Label)!=null?fr:"Button 1",href:(le=(gr=r.attrs)==null?void 0:gr.button1Link)!=null?le:"#",align:"left"};(Ve=r.attrs)!=null&&Ve.button1BackgroundColor&&(ee.background_color=r.attrs.button1BackgroundColor),(Ae=r.attrs)!=null&&Ae.button1TextColor&&(ee.color=r.attrs.button1TextColor);let ae={type:"action",content:(Wt=(Ut=r.attrs)==null?void 0:Ut.button2Label)!=null?Wt:"Button 2",href:(Hr=(Dr=r.attrs)==null?void 0:Dr.button2Link)!=null?Hr:"#",align:"left"};return(Vr=r.attrs)!=null&&Vr.button2BackgroundColor&&(ae.background_color=r.attrs.button2BackgroundColor),(Fr=r.attrs)!=null&&Fr.button2TextColor&&(ae.color=r.attrs.button2TextColor),[ee,ae]}case"customCode":{let ee={type:"html",content:((Oo=r.attrs)==null?void 0:Oo.code)||"<!-- Add your HTML code here -->"};return(ie=r.attrs)!=null&&ie.locales&&(ee.locales=r.attrs.locales),[ee]}case"column":{let ee=((To=r.attrs)==null?void 0:To.columnsCount)||2,ae=[],ge=(pn=r.content)==null?void 0:pn.find(mt=>mt.type==="columnRow");if(ge&&ge.content){for(let mt of ge.content)if(mt.type==="columnCell")if(mt.content&&mt.content.length>0){let ns=mt.content.flatMap(t);ns.length===0?ae.push({type:"text",content:`Drag and drop content blocks
192
- `,align:"left"}):ns.length===1?ae.push(ns[0]):ae.push({type:"group",elements:ns})}else ae.push({type:"text",content:`Drag and drop content blocks
193
- `,align:"left"})}else for(let mt=0;mt<ee;mt++)ae.push({type:"text",content:`Drag and drop content blocks
194
- `,align:"left"});let we={type:"group"};if((fn=r.attrs)!=null&&fn.borderWidth&&r.attrs.borderWidth>0){let mt={};(zi=r.attrs)!=null&&zi.borderColor&&(mt.color=r.attrs.borderColor),mt.enabled=!0,mt.size=`${r.attrs.borderWidth}px`,($i=r.attrs)!=null&&$i.borderRadius&&(mt.radius=r.attrs.borderRadius),we.border=mt}let _e=((Zi=r.attrs)==null?void 0:Zi.paddingVertical)||0,Or=((qi=r.attrs)==null?void 0:qi.paddingHorizontal)||0;return(_e>0||Or>0)&&(we.padding=`${_e}px ${Or}px`),(Ji=r.attrs)!=null&&Ji.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(we.background_color=r.attrs.backgroundColor),we.elements=ae,(ji=r.attrs)!=null&&ji.locales&&(we.locales=r.attrs.locales),[we]}default:return r.content?r.content.flatMap(t):[]}},"convertNode");return e!=null&&e.content?e.content.flatMap(t):[]}s(de,"convertTiptapToElemental");function Xc(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!==`
195
- `&&("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=Xc(o.elements);if(n)return n}}return r||t||""}s(Xc,"getTitle");function Qc(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 Xc(r.elements)}return""}s(Qc,"getTitleForChannel");function ft(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,p=!1;if(n?u.channel===n&&(p=!0):i||(p=!0),p){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 d={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=[],C=t.elements.find(b=>b.type==="meta");if(C)f.push(C);else{let b=(c=u.elements)==null?void 0:c.find(v=>v.type==="meta");b&&f.push(b)}let h=t.elements.filter(b=>b.type!=="meta");f.push(...h),d.elements=f}o.elements.push(d),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 p in t.channel)p!=="type"&&p!=="elements"&&p!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,p)&&(c[p]=t.channel[p]);let u={type:"channel",channel:l,...c};if(t.elements!==void 0){let p=[],m=t.elements.find(f=>f.type==="meta");m&&p.push(m);let d=t.elements.filter(f=>f.type!=="meta");p.push(...d),u.elements=p}o.elements.push(u)}return o}s(ft,"updateElemental");function I(...e){return(0,Um.twMerge)((0,Om.clsx)(e))}s(I,"cn");var Wm=require("@radix-ui/react-slot"),_m=require("class-variance-authority"),zm=require("react"),$m=require("react/jsx-runtime"),bs=(0,_m.cva)("courier-flex courier-group courier-items-center courier-justify-center courier-border courier-border-transparent courier-gap-2 courier-text-sm courier-font-semibold courier-rounded-md disabled:courier-opacity-50 courier-whitespace-nowrap courier-outline-none",{variants:{variant:{primary:"courier-text-white courier-bg-[#3B82F6] courier-border-[#3B82F6]",secondary:"courier-text-foreground courier-bg-[#F5F5F5] dark:courier-bg-neutral-700 dark:courier-text-white",tertiary:"courier-bg-neutral-50 courier-text-foreground dark:courier-bg-foreground dark:courier-text-white dark:courier-border-foreground",quaternary:"courier-bg-transparent courier-border-transparent courier-text-neutral-500 dark:courier-text-neutral-400",ghost:"hover:courier-bg-accent hover:courier-text-accent-foreground",link:"courier-text-foreground !courier-font-normal hover:courier-text-accent-foreground !courier-p-0 courier-border-none",outline:"!courier-border-border courier-text-foreground dark:courier-text-white dark:courier-border-foreground hover:courier-bg-neutral-100 dark:hover:courier-bg-neutral-800"},size:{medium:"courier-py-2 courier-px-3",small:"courier-py-1 courier-px-2",icon:"courier-w-8 courier-h-8",iconSmall:"courier-w-6 courier-h-6"},active:{true:"",false:""},disabled:{true:"",false:""}},compoundVariants:[{variant:"primary",disabled:!1,active:!1,class:"hover:courier-bg-blue-600 active:courier-bg-blue-700"},{variant:"primary",active:!0,class:"courier-bg-blue-700"},{variant:"secondary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-600 dark:active:courier-bg-neutral-800"},{variant:"secondary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"tertiary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-800 dark:active:courier-bg-neutral-700"},{variant:"tertiary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"ghost",disabled:!1,active:!1,class:"hover:courier-bg-black/5 hover:courier-text-neutral-700 active:courier-bg-black/10 active:courier-text-neutral-800 dark:hover:courier-bg-white/10 dark:hover:courier-text-neutral-300 dark:active:courier-text-neutral-200"},{variant:"ghost",active:!0,class:"courier-bg-accent courier-text-accent-foreground [&_svg]:courier-text-accent-foreground dark:courier-bg-[#3B82F6] dark:courier-text-white [&_svg]:dark:courier-text-white"}]}),Se=(0,zm.forwardRef)(({active:e,buttonSize:t="medium",disabled:r,variant:o="primary",className:n,asChild:i=!1,...a},l)=>(0,$m.jsx)(i?Wm.Slot:"button",{ref:l,disabled:r,className:I(bs({variant:o,size:t,disabled:r,active:e}),n),...a}));Se.displayName="Button";var Zm=require("react"),qm=require("react/jsx-runtime"),ce=(0,Zm.forwardRef)((e,t)=>(0,qm.jsx)("hr",{...e,ref:t,className:I("courier-my-1 courier-border-border dark:courier-border-neutral-600 courier-w-full",e.className)}));ce.displayName="Divider";var Eo=he(require("react"),1),me=he(require("@radix-ui/react-dropdown-menu"),1),ei=require("lucide-react");var st=require("react/jsx-runtime"),ys=me.Root,Cs=me.Trigger;var O2=Eo.forwardRef(({className:e,inset:t,children:r,...o},n)=>(0,st.jsxs)(me.SubTrigger,{ref:n,className:I("courier-flex courier-cursor-default courier-gap-2 courier-select-none courier-items-center courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent data-[state=open]:courier-bg-accent [&_svg]:courier-pointer-events-none [&_svg]:courier-size-4 [&_svg]:courier-shrink-0",t&&"courier-pl-8",e),...o,children:[r,(0,st.jsx)(ei.ChevronRight,{className:"courier-ml-auto"})]}));O2.displayName=me.SubTrigger.displayName;var U2=Eo.forwardRef(({className:e,...t},r)=>(0,st.jsx)(me.SubContent,{ref:r,className:I("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-lg data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...t}));U2.displayName=me.SubContent.displayName;var ea=Eo.forwardRef(({className:e,sideOffset:t=4,portalProps:r,...o},n)=>(0,st.jsx)(me.Portal,{...r,children:(0,st.jsx)(me.Content,{ref:n,sideOffset:t,className:I("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-md","data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...o})}));ea.displayName=me.Content.displayName;var ta=Eo.forwardRef(({className:e,inset:t,...r},o)=>(0,st.jsx)(me.Item,{ref:o,className:I("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-gap-2 courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50 [&>svg]:courier-size-4 [&>svg]:courier-shrink-0",t&&"courier-pl-8",e),...r}));ta.displayName=me.Item.displayName;var W2=Eo.forwardRef(({className:e,children:t,checked:r,...o},n)=>(0,st.jsxs)(me.CheckboxItem,{ref:n,className:I("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),checked:r,...o,children:[(0,st.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,st.jsx)(me.ItemIndicator,{children:(0,st.jsx)(ei.Check,{className:"courier-h-4 courier-w-4"})})}),t]}));W2.displayName=me.CheckboxItem.displayName;var _2=Eo.forwardRef(({className:e,children:t,...r},o)=>(0,st.jsxs)(me.RadioItem,{ref:o,className:I("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),...r,children:[(0,st.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,st.jsx)(me.ItemIndicator,{children:(0,st.jsx)(ei.Circle,{className:"courier-h-2 courier-w-2 courier-fill-current"})})}),t]}));_2.displayName=me.RadioItem.displayName;var z2=Eo.forwardRef(({className:e,inset:t,...r},o)=>(0,st.jsx)(me.Label,{ref:o,className:I("courier-px-2 courier-py-1.5 courier-text-sm courier-font-semibold",t&&"courier-pl-8",e),...r}));z2.displayName=me.Label.displayName;var $2=Eo.forwardRef(({className:e,...t},r)=>(0,st.jsx)(me.Separator,{ref:r,className:I("courier-mx-1 courier-my-1 courier-h-px courier-bg-muted",e),...t}));$2.displayName=me.Separator.displayName;var Z2=s(({className:e,...t})=>(0,st.jsx)("span",{className:I("courier-ml-auto courier-text-xs courier-tracking-widest courier-opacity-60",e),...t}),"DropdownMenuShortcut");Z2.displayName="DropdownMenuShortcut";var Jm=require("react");var ti=require("react/jsx-runtime"),eu=class eu extends Jm.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){var o,n;console.error("ErrorBoundary caught an error:",t,r),(n=(o=this.props).onError)==null||n.call(o,t,r)}render(){return this.state.hasError?this.props.fallback||(0,ti.jsx)(q2,{error:this.state.error}):this.props.children}};s(eu,"ErrorBoundary");var vs=eu,q2=s(({error:e})=>(0,ti.jsxs)("div",{className:"courier-p-6 courier-border courier-border-red-200 courier-bg-red-50 courier-rounded-lg courier-text-center",children:[(0,ti.jsx)("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),(0,ti.jsx)("p",{className:"courier-text-red-600 courier-mb-4",children:"An unexpected error occurred in the editor. Please refresh the page or contact support if the problem persists."}),!1]}),"DefaultErrorFallback");var Ym=require("@radix-ui/react-slot"),Qt=he(require("react"),1),ri=require("react-hook-form");var tu=he(require("@radix-ui/react-label"),1),jm=require("class-variance-authority"),Km=he(require("react"),1),Gm=require("react/jsx-runtime"),J2=(0,jm.cva)("courier-text-sm courier-font-medium courier-leading-none peer-disabled:courier-cursor-not-allowed peer-disabled:courier-opacity-70"),ru=Km.forwardRef(({className:e,...t},r)=>(0,Gm.jsx)(tu.Root,{ref:r,className:I(J2(),e),...t}));ru.displayName=tu.Root.displayName;var ko=require("react/jsx-runtime"),qe=ri.FormProvider,Xm=Qt.createContext({}),j=s(({...e})=>(0,ko.jsx)(Xm.Provider,{value:{name:e.name},children:(0,ko.jsx)(ri.Controller,{...e})}),"FormField"),xs=s(()=>{let e=Qt.useContext(Xm),t=Qt.useContext(Qm),{getFieldState:r,formState:o}=(0,ri.useFormContext)(),n=r(e.name,o);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...n}},"useFormField"),Qm=Qt.createContext({}),q=Qt.forwardRef(({className:e,...t},r)=>{let o=Qt.useId();return(0,ko.jsx)(Qm.Provider,{value:{id:o},children:(0,ko.jsx)("div",{ref:r,className:I("courier-space-y-2",e),...t})})});q.displayName="FormItem";var uo=Qt.forwardRef(({className:e,...t},r)=>{let{error:o,formItemId:n}=xs();return(0,ko.jsx)(ru,{ref:r,className:I(o&&"courier-text-destructive",e),htmlFor:n,...t})});uo.displayName="FormLabel";var J=Qt.forwardRef(({...e},t)=>{let{error:r,formItemId:o,formDescriptionId:n,formMessageId:i}=xs();return(0,ko.jsx)(Ym.Slot,{ref:t,id:o,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...e})});J.displayName="FormControl";var j2=Qt.forwardRef(({className:e,...t},r)=>{let{formDescriptionId:o}=xs();return(0,ko.jsx)("p",{ref:r,id:o,className:I("courier-text-[0.8rem] courier-text-muted-foreground",e),...t})});j2.displayName="FormDescription";var K=Qt.forwardRef(({className:e,children:t,...r},o)=>{let{error:n,formMessageId:i}=xs(),a=n?String(n==null?void 0:n.message):t;return a?(0,ko.jsx)("p",{ref:o,id:i,className:I("courier-text-[0.8rem] courier-font-medium courier-text-destructive",e),...r,children:a}):null});K.displayName="FormMessage";var Fe=he(require("@radix-ui/react-alert-dialog"),1),yn=he(require("react"),1);var ep=require("react");var Cr=require("react/jsx-runtime"),tp=Fe.Root,rp=Fe.Trigger,K2=Fe.Portal,op=yn.forwardRef(({className:e,...t},r)=>(0,Cr.jsx)("div",{className:"courier-absolute courier-inset-0 courier-z-50 courier-bg-[#0a0a0a52] data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",children:(0,Cr.jsx)(Fe.Overlay,{asChild:!0,className:I("courier-fixed courier-inset-0 courier-z-50 courier-bg-black/80 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",e),...t,ref:r})}));op.displayName=Fe.Overlay.displayName;var ou=yn.forwardRef(({className:e,...t},r)=>{let o=(0,ep.useCallback)(()=>{var i;let n=(i=r==null?void 0:r.current)==null?void 0:i.parentElement;for(;n;){if(n.classList.contains("theme-container"))return n;n=n.parentElement}return document.body},[r]);return(0,Cr.jsxs)(K2,{container:typeof window!="undefined"?o():void 0,children:[(0,Cr.jsx)(op,{}),(0,Cr.jsx)(Fe.Content,{ref:r,className:I("courier-fixed courier-left-[50%] courier-top-[50%] courier-z-50 courier-grid courier-w-full courier-max-w-lg courier-translate-x-[-50%] courier-translate-y-[-50%] courier-gap-4 courier-border courier-bg-background courier-p-6 courier-shadow-lg courier-duration-200 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[state=closed]:courier-slide-out-to-left-1/2 data-[state=closed]:courier-slide-out-to-top-[48%] data-[state=open]:courier-slide-in-from-left-1/2 data-[state=open]:courier-slide-in-from-top-[48%] sm:courier-rounded-lg",e),...t})]})});ou.displayName=Fe.Content.displayName;var nu=s(({className:e,...t})=>(0,Cr.jsx)("div",{className:I("courier-flex courier-flex-col courier-space-y-2 courier-text-center sm:courier-text-left",e),...t}),"AlertDialogHeader");nu.displayName="AlertDialogHeader";var iu=s(({className:e,...t})=>(0,Cr.jsx)("div",{className:I("courier-flex courier-flex-col-reverse sm:courier-flex-row sm:courier-justify-end sm:courier-space-x-2",e),...t}),"AlertDialogFooter");iu.displayName="AlertDialogFooter";var G2=yn.forwardRef(({className:e,...t},r)=>(0,Cr.jsx)(Fe.Title,{ref:r,className:I("courier-text-lg courier-font-semibold",e),...t}));G2.displayName=Fe.Title.displayName;var Y2=yn.forwardRef(({className:e,...t},r)=>(0,Cr.jsx)(Fe.Description,{ref:r,className:I("courier-text-sm courier-text-muted-foreground",e),...t}));Y2.displayName=Fe.Description.displayName;var au=yn.forwardRef(({className:e,...t},r)=>(0,Cr.jsx)(Fe.Action,{ref:r,className:I(bs(),e),...t}));au.displayName=Fe.Action.displayName;var su=yn.forwardRef(({className:e,...t},r)=>(0,Cr.jsx)(Fe.Cancel,{ref:r,className:I(bs({variant:"outline"}),"courier-mt-2 sm:courier-mt-0",e),...t}));su.displayName=Fe.Cancel.displayName;var np=he(require("react"),1),oi=require("react/jsx-runtime"),be=np.forwardRef(({className:e,type:t,startAdornment:r,endAdornment:o,...n},i)=>(0,oi.jsxs)("div",{className:"courier-relative courier-flex courier-w-full courier-items-center",children:[r&&(0,oi.jsx)("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),(0,oi.jsx)("input",{type:t,className:I("courier-flex courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base file:courier-border-0 file:courier-bg-transparent file:courier-text-sm file:courier-font-medium file:courier-text-foreground placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm dark:courier-[color-scheme:dark]",r&&"courier-pl-8",o&&"courier-pr-8",e),ref:i,...n}),o&&(0,oi.jsx)("div",{className:"courier-absolute courier-right-2 courier-flex courier-items-center courier-pointer-events-none",children:o})]}));be.displayName="Input";var _o=require("react");var zt=require("react");var ip=require("lucide-react");var er=require("react/jsx-runtime"),X2=s(e=>e==="transparent"||/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e),"isValidHex"),ap=s(({color:e,onChange:t,className:r,presetColors:o,defaultValue:n="transparent"})=>{let[i,a]=(0,zt.useState)(()=>ra(e)),[l,c]=(0,zt.useState)(e),u=(0,zt.useRef)(null),p=(0,zt.useRef)(null),m=(0,zt.useRef)(null),d=(0,zt.useRef)(!1),f=e!==n,C=(0,zt.useCallback)(g=>{d.current=!0;let w=Q2(g);c(w),t(w),d.current=!1},[t]),h=s(g=>w=>{m.current=g,b(w)},"handleMouseDown"),b=(0,zt.useCallback)(g=>{if(m.current){if(m.current==="gradient"&&u.current){let w=u.current.getBoundingClientRect(),N=Math.max(0,Math.min(1,(g.clientX-w.left)/w.width)),y=Math.max(0,Math.min(1,(g.clientY-w.top)/w.height)),S={...i,s:N*100,v:(1-y)*100};a(S),C(S)}else if(m.current==="hue"&&p.current){let w=p.current.getBoundingClientRect(),N=Math.max(0,Math.min(1,(g.clientX-w.left)/w.width)),y={...i,h:N*360};a(y),C(y)}}},[i,C]),v=(0,zt.useCallback)(()=>{m.current=null},[]);(0,zt.useEffect)(()=>{if(m.current)return window.addEventListener("mousemove",b),window.addEventListener("mouseup",v),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",v)}},[b,v]),(0,zt.useEffect)(()=>{d.current||(a(ra(e)),c(e))},[e]);let E=s(g=>{let w=g.target.value;if(c(w),X2(w)){let N=ra(w);a(N),C(N)}},"handleInputChange");return(0,er.jsxs)("div",{className:I("w-full",r),children:[(0,er.jsx)("div",{ref:u,className:"courier-relative courier-h-[160px] courier-w-full courier-cursor-crosshair courier-rounded-lg",style:{backgroundColor:`hsl(${i.h}, 100%, 50%)`,backgroundImage:"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)"},onMouseDown:h("gradient"),children:(0,er.jsx)("div",{className:"courier-absolute courier-h-3 courier-w-3 courier-translate-x-[-50%] courier-translate-y-[-50%] courier-rounded-full courier-border-2 courier-border-white",style:{left:`${i.s}%`,top:`${100-i.v}%`}})}),(0,er.jsx)("div",{ref:p,className:"courier-relative courier-mt-2 courier-h-3 courier-w-full courier-cursor-pointer courier-rounded",style:{background:"linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)"},onMouseDown:h("hue"),children:(0,er.jsx)("div",{className:"courier-absolute courier-h-full courier-w-1 courier-translate-x-[-50%] courier-rounded courier-border courier-border-input courier-bg-background",style:{left:`${i.h/360*100}%`}})}),(0,er.jsxs)("div",{className:"courier-mt-3 courier-relative courier-flex courier-items-center",children:[(0,er.jsx)(be,{value:l,onChange:E,placeholder:"#000000",className:"courier-flex-1"}),f&&(0,er.jsx)("button",{onClick:g=>{if(g.preventDefault(),n==="transparent"){t("transparent"),c("transparent"),a({h:0,s:0,v:0});return}let w=ra(n);a(w),C(w)},className:"courier-absolute courier-right-3 courier-flex courier-cursor-pointer courier-items-center courier-justify-center courier-transition-colors",children:(0,er.jsx)(ip.CircleX,{size:14,strokeWidth:1.25})})]}),(0,er.jsx)(ce,{className:"courier-my-3"}),(0,er.jsx)("div",{className:"courier-flex courier-flex-wrap courier-gap-1",children:o.map(g=>(0,er.jsx)("button",{className:I("courier-h-6 courier-w-6 courier-rounded-md courier-border courier-border-input courier-shrink-0",g==="transparent"&&lu),style:{backgroundColor:g==="transparent"?void 0:g},onClick:w=>{if(w.preventDefault(),g==="transparent"){t("transparent"),c("transparent"),a({h:0,s:0,v:0});return}let N=ra(g);a(N),C(N)}},g))})]})},"ColorPicker");function ra(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(ra,"hexToHsv");function Q2({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(Q2,"hsvToHex");var mo=he(require("@radix-ui/react-popover"),1),sp=he(require("react"),1);var cu=require("react/jsx-runtime"),lp=mo.Root,cp=mo.Trigger;var uu=sp.forwardRef(({className:e,align:t="center",side:r="bottom",sideOffset:o=4,collisionPadding:n=10,avoidCollisions:i=!0,portalProps:a,...l},c)=>(0,cu.jsx)(mo.Portal,{...a,children:(0,cu.jsx)(mo.Content,{ref:c,side:r,align:t,sideOffset:o,collisionPadding:n,avoidCollisions:i,className:I("courier-z-50 courier-w-72 courier-rounded-md courier-border courier-bg-popover courier-p-4 courier-text-popover-foreground courier-shadow-md courier-outline-none data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...l})}));uu.displayName=mo.Content.displayName;var wo=require("react/jsx-runtime"),lu="bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAwSDBWOEg4VjBaIiBmaWxsPSIjRDlEOUQ5Ii8+PHBhdGggZD0iTTE2IDhIOFYxNkgxNlY4WiIgZmlsbD0iI0Q5RDlEOSIvPjwvc3ZnPg==')]",eh=["#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#000000","#525252","#a3a3a3","#ffffff","transparent"],Et=(0,_o.forwardRef)(({className:e,value:t="",onChange:r,defaultValue:o,transparent:n=!0,presetColors:i=eh,...a},l)=>{let c=t!=="transparent",u=(0,_o.useRef)(null),p=(0,_o.useMemo)(()=>n?i:i.filter(d=>d!=="transparent"),[i,n]),m=(0,_o.useCallback)(()=>{var f;let d=(f=u.current)==null?void 0:f.parentElement;for(;d;){if(d.classList.contains("theme-container"))return d;d=d.parentElement}return document.body},[]);return(0,wo.jsxs)(lp,{children:[(0,wo.jsx)(cp,{asChild:!0,children:(0,wo.jsxs)("div",{className:"courier-relative courier-flex courier-items-center",ref:u,children:[(0,wo.jsx)("div",{className:I("courier-absolute courier-left-2 courier-flex courier-h-4 courier-w-4 courier-cursor-pointer courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-input courier-transition-colors courier-z-10",c?"":lu),style:{backgroundColor:c?t:void 0}}),(0,wo.jsx)(be,{...a,ref:l,readOnly:!0,type:"text",value:t==="transparent"?"Transparent":t,className:I("courier-relative courier-cursor-pointer courier-pl-8",e)})]})}),(0,wo.jsx)(uu,{portalProps:{container:typeof window!="undefined"?m():void 0},className:"courier-w-[230px]",children:(0,wo.jsx)(ap,{color:t,onChange:r,presetColors:p,defaultValue:o})})]})});Et.displayName="InputColor";var up=he(require("react"),1),du=he(require("@radix-ui/react-separator"),1);var dp=require("react/jsx-runtime"),mu=up.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>(0,dp.jsx)(du.Root,{ref:n,decorative:r,orientation:t,className:I("courier-shrink-0 courier-bg-border",t==="horizontal"?"courier-h-[1px] courier-w-full":"courier-h-full courier-w-[1px]",e),...o}));mu.displayName=du.Root.displayName;var mp=he(require("react"),1),Po=he(require("@radix-ui/react-slider"),1);var ni=require("react/jsx-runtime"),pu=mp.forwardRef(({className:e,...t},r)=>(0,ni.jsxs)(Po.Root,{ref:r,className:I("courier-relative courier-flex courier-w-full courier-touch-none courier-select-none courier-items-center",e),...t,children:[(0,ni.jsx)(Po.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:(0,ni.jsx)(Po.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),(0,ni.jsx)(Po.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"})]}));pu.displayName=Po.Root.displayName;var pp=he(require("react"),1),oa=he(require("@radix-ui/react-switch"),1);var fu=require("react/jsx-runtime"),ii=pp.forwardRef(({className:e,...t},r)=>(0,fu.jsx)(oa.Root,{className:I("courier-peer courier-inline-flex courier-h-5 courier-w-9 courier-shrink-0 courier-cursor-pointer courier-items-center courier-rounded-full courier-border-2 courier-border-transparent courier-shadow-sm courier-transition-colors focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2 focus-visible:courier-ring-offset-background disabled:courier-cursor-not-allowed disabled:courier-opacity-50 data-[state=checked]:courier-bg-accent-foreground data-[state=unchecked]:courier-bg-input",e),...t,ref:r,children:(0,fu.jsx)(oa.Thumb,{className:I("courier-pointer-events-none courier-block courier-h-4 courier-w-4 courier-rounded-full courier-bg-background courier-shadow-lg courier-ring-0 courier-transition-transform data-[state=checked]:courier-translate-x-4 data-[state=unchecked]:courier-translate-x-0")})}));ii.displayName=oa.Root.displayName;var Ts=he(require("react"),1),zr=he(require("@radix-ui/react-tabs"),1);var ws=require("react/jsx-runtime"),Es=zr.Root,na=Ts.forwardRef(({className:e,...t},r)=>(0,ws.jsx)(zr.List,{ref:r,className:I("courier-inline-flex courier-h-9 courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-border courier-bg-background courier-p-[3px] courier-text-muted-foreground",e),...t}));na.displayName=zr.List.displayName;var ai=Ts.forwardRef(({className:e,...t},r)=>(0,ws.jsx)(zr.Trigger,{ref:r,className:I("courier-inline-flex courier-items-center courier-justify-center courier-whitespace-nowrap courier-rounded-sm courier-px-3 courier-py-1 courier-text-sm courier-font-medium courier-ring-offset-background courier-transition-all focus-visible:courier-outline-none disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=active]:courier-bg-accent data-[state=active]:courier-text-accent-foreground",e),...t}));ai.displayName=zr.Trigger.displayName;var ks=Ts.forwardRef(({className:e,...t},r)=>(0,ws.jsx)(zr.Content,{ref:r,className:I("courier-mt-2 courier-ring-offset-background focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2",e),...t}));ks.displayName=zr.Content.displayName;var si=he(require("react"),1);var fp=require("react/jsx-runtime"),gu=si.forwardRef(({className:e,autoResize:t=!1,...r},o)=>{let n=si.useRef(null),i=s(a=>{n.current=a,typeof o=="function"?o(a):o&&(o.current=a)},"combinedRef");return si.useEffect(()=>{if(!t)return;let a=n.current;if(!a)return;let l=s(()=>{a.style.height="auto",a.style.height=`${a.scrollHeight}px`},"adjustHeight");return l(),a.addEventListener("input",l),()=>{a.removeEventListener("input",l)}},[t]),(0,fp.jsx)("textarea",{className:I("courier-flex courier-min-h-[44px] courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base courier-placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm",t&&"courier-resize-none",e),ref:i,...r})});gu.displayName="Textarea";var Ns=require("react");var bp=require("react");var Ps={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"},gp={...Ps},hp={...Ps,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 hu=(0,bp.createContext)(Ps);var bu=require("react/jsx-runtime"),yp=(0,Ns.forwardRef)(({children:e,theme:t,colorScheme:r,className:o},n)=>{let i=r!=null?r:"light",a=i==="light"?gp:hp,l=a;t&&(l=typeof t=="string"?t:{...a,...t});let c=typeof t=="string"?{}:Object.entries(l).reduce((u,[p,m])=>{let d=p.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`);return{...u,[`--${d}`]:m}},{});return(0,bu.jsx)(hu.Provider,{value:typeof l=="object"?l:{},children:(0,bu.jsx)("div",{style:c,className:I("courier-flex courier-flex-col courier-relative",typeof t=="string"?t:"","theme-container",i==="dark"?"dark courier-dark":"",o),ref:n,children:e})})}),Cp=s(()=>(0,Ns.useContext)(hu),"useTheme");var vp=he(require("react"),1),yu=he(require("@radix-ui/react-toggle"),1),xp=require("class-variance-authority");var Tp=require("react/jsx-runtime"),Cu=(0,xp.cva)("courier-inline-flex courier-items-center courier-justify-center courier-gap-2 courier-rounded-md courier-text-sm courier-font-medium courier-transition-colors hover:courier-bg-secondary hover:courier-text-foreground focus-visible:courier-outline-none focus-visible:courier-ring-1 focus-visible:courier-ring-ring disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=on]:courier-bg-accent data-[state=on]:courier-text-accent-foreground data-[state=on]:dark:courier-text-white [&_svg]:courier-pointer-events-none [&_svg]:courier-size-[30px] [&_svg]:courier-shrink-0",{variants:{variant:{default:"courier-bg-transparent",outline:"courier-border courier-border-input courier-bg-transparent courier-shadow-sm hover:courier-bg-accent hover:courier-text-accent-foreground"},size:{default:"courier-h-9 courier-min-w-9",sm:"courier-h-8 courier-px-1.5 courier-min-w-8",lg:"courier-h-10 courier-px-2.5 courier-min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),th=vp.forwardRef(({className:e,variant:t,size:r,...o},n)=>(0,Tp.jsx)(yu.Root,{ref:n,className:I(Cu({variant:t,size:r,className:e})),...o}));th.displayName=yu.Root.displayName;var li=he(require("@radix-ui/react-toggle-group"),1),Cn=he(require("react"),1);var Ms=require("react/jsx-runtime"),Ep=Cn.createContext({size:"default",variant:"default"}),Ir=Cn.forwardRef(({className:e,variant:t,size:r,children:o,...n},i)=>(0,Ms.jsx)(li.Root,{ref:i,className:I("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:(0,Ms.jsx)(Ep.Provider,{value:{variant:t,size:r},children:o})}));Ir.displayName=li.Root.displayName;var $t=Cn.forwardRef(({className:e,children:t,variant:r,size:o,...n},i)=>{let a=Cn.useContext(Ep);return(0,Ms.jsx)(li.Item,{ref:i,className:I(Cu({variant:a.variant||r,size:a.size||o}),e),...n,children:t})});$t.displayName=li.Item.displayName;var As=require("react/jsx-runtime"),Be=s(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?(0,As.jsx)("path",{className:I(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):(0,As.jsx)("path",{className:I(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),Z=s(({width:e=28,height:t=28,...r})=>(0,As.jsx)("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");var ci=require("react/jsx-runtime"),kp=s(({color:e="#000000",width:t=19,height:r=10,...o})=>(0,ci.jsxs)(Z,{...o,width:t,height:r,children:[(0,ci.jsx)("rect",{opacity:"0.6",x:"0.553621",y:"0.876863",width:"16.4923",height:"7.87692",rx:"1.6",stroke:e,strokeWidth:"0.738462"}),(0,ci.jsx)("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),(0,ci.jsx)("path",{opacity:"0.6",d:"M17.9075 3.70703C18.4513 3.70703 18.8921 4.14786 18.8921 4.69165V4.9378C18.8921 5.48159 18.4513 5.92242 17.9075 5.92242V3.70703Z",fill:e})]}),"BatteryIcon");var vu=require("react/jsx-runtime"),ia=s(({color:e="#DC2626",width:t=13,height:r=13,...o})=>(0,vu.jsx)(Z,{...o,fill:"none",width:t,height:r,children:(0,vu.jsx)("path",{d:"M4.89844 1.625C4.82812 1.625 4.78125 1.67188 4.73438 1.71875L4.28906 2.375H7.6875L7.24219 1.71875C7.21875 1.67188 7.14844 1.625 7.07812 1.625H4.89844ZM9.04688 2.375H9.35156H10.5H10.6875C10.9922 2.375 11.25 2.63281 11.25 2.9375C11.25 3.26562 10.9922 3.5 10.6875 3.5H10.4062L9.84375 11.1172C9.77344 11.9141 9.14062 12.5 8.34375 12.5H3.63281C2.83594 12.5 2.20312 11.9141 2.13281 11.1172L1.57031 3.5H1.3125C0.984375 3.5 0.75 3.26562 0.75 2.9375C0.75 2.63281 0.984375 2.375 1.3125 2.375H1.5H2.625H2.92969L3.79688 1.08594C4.03125 0.734375 4.45312 0.5 4.89844 0.5H7.07812C7.52344 0.5 7.94531 0.734375 8.17969 1.08594L9.04688 2.375ZM9.28125 3.5H2.69531L3.25781 11.0469C3.28125 11.2344 3.44531 11.375 3.63281 11.375H8.34375C8.53125 11.375 8.69531 11.2344 8.71875 11.0469L9.28125 3.5Z",fill:e})}),"BinIcon");var xu=require("react/jsx-runtime"),aa=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,xu.jsx)(Z,{...n,width:r,height:o,children:(0,xu.jsx)(Be,{active:t,colorProp:"stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",d:"M1 15V11C1 5.47715 5.47715 1 11 1H15"})}),"BorderRadiusIcon");var ui=require("react/jsx-runtime"),No=s(({color:e="#A3A3A3",width:t=16,height:r=16,...o})=>(0,ui.jsxs)(Z,{...o,width:t,height:r,children:[(0,ui.jsx)("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),(0,ui.jsx)("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),(0,ui.jsx)("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");var Tu=require("react/jsx-runtime"),Eu=s(({color:e,width:t=21,height:r=16,...o})=>(0,Tu.jsx)(Z,{...o,width:t,height:r,children:(0,Tu.jsx)("path",{d:"M2.5 1.5C2.21875 1.5 2 1.75 2 2V11C2 11.2812 2.21875 11.5 2.5 11.5H18.5C18.75 11.5 19 11.2812 19 11V2C19 1.75 18.75 1.5 18.5 1.5H2.5ZM0.5 2C0.5 0.90625 1.375 0 2.5 0H18.5C19.5938 0 20.5 0.90625 20.5 2V11C20.5 12.125 19.5938 13 18.5 13H2.5C1.375 13 0.5 12.125 0.5 11V2ZM4.25 14.5H16.75C17.1562 14.5 17.5 14.8438 17.5 15.25C17.5 15.6875 17.1562 16 16.75 16H4.25C3.8125 16 3.5 15.6875 3.5 15.25C3.5 14.8438 3.8125 14.5 4.25 14.5Z",fill:e})}),"DesktopIcon");var ku=require("react/jsx-runtime"),wu=s(({color:e="#171717",width:t=12,height:r=13,...o})=>(0,ku.jsx)(Z,{...o,fill:"none",width:t,height:r,children:(0,ku.jsx)("path",{d:"M1.5 11.375H6.75C6.9375 11.375 7.125 11.2109 7.125 11V9.5H8.25V11C8.25 11.8438 7.57031 12.5 6.75 12.5H1.5C0.65625 12.5 0 11.8438 0 11V5.75C0 4.92969 0.65625 4.25 1.5 4.25H3V5.375H1.5C1.28906 5.375 1.125 5.5625 1.125 5.75V11C1.125 11.2109 1.28906 11.375 1.5 11.375ZM5.25 7.625H10.5C10.6875 7.625 10.875 7.46094 10.875 7.25V2C10.875 1.8125 10.6875 1.625 10.5 1.625H5.25C5.03906 1.625 4.875 1.8125 4.875 2V7.25C4.875 7.46094 5.03906 7.625 5.25 7.625ZM3.75 7.25V2C3.75 1.17969 4.40625 0.5 5.25 0.5H10.5C11.3203 0.5 12 1.17969 12 2V7.25C12 8.09375 11.3203 8.75 10.5 8.75H5.25C4.40625 8.75 3.75 8.09375 3.75 7.25Z",fill:e})}),"DuplicateIcon");var Pu=require("react/jsx-runtime"),Nu=s(({color:e="#404040",width:t=20,height:r=15,viewBox:o="0 0 20 15",...n})=>(0,Pu.jsx)(Z,{...n,width:t,height:r,viewBox:o,children:(0,Pu.jsx)("path",{d:"M1.875 0H18.125C19.1406 0 20 0.859375 20 1.875C20 2.5 19.6875 3.04688 19.2188 3.39844L10.7422 9.76562C10.2734 10.1172 9.6875 10.1172 9.21875 9.76562L0.742188 3.39844C0.273438 3.04688 0 2.5 0 1.875C0 0.859375 0.820312 0 1.875 0ZM0 4.375L8.47656 10.7812C9.375 11.4453 10.5859 11.4453 11.4844 10.7812L20 4.375V12.5C20 13.9062 18.8672 15 17.5 15H2.5C1.09375 15 0 13.9062 0 12.5V4.375Z",fill:e})}),"EmailIcon");var Mu=require("react/jsx-runtime"),sa=s(({color:e="#737373",width:t=16,height:r=16,...o})=>(0,Mu.jsx)(Z,{...o,width:t,height:r,children:(0,Mu.jsx)(Be,{d:"M10.25 1H14.25C14.6562 1 15 1.34375 15 1.75V5.75C15 6.1875 14.6562 6.5 14.25 6.5C13.8125 6.5 13.5 6.1875 13.5 5.75V3.5625L9.03125 8L13.5 12.4688V10.25C13.5 9.84375 13.8125 9.5 14.25 9.5C14.6562 9.5 15 9.84375 15 10.25V14.25C15 14.6875 14.6562 15 14.25 15H10.25C9.8125 15 9.5 14.6875 9.5 14.25C9.5 13.8438 9.8125 13.5 10.25 13.5H12.4375L8 9.0625L3.53125 13.5H5.75C6.15625 13.5 6.5 13.8438 6.5 14.25C6.5 14.6875 6.15625 15 5.75 15H1.75C1.3125 15 1 14.6875 1 14.25V10.25C1 9.84375 1.3125 9.5 1.75 9.5C2.15625 9.5 2.5 9.84375 2.5 10.25V12.4688L6.9375 8L2.5 3.5625V5.75C2.5 6.1875 2.15625 6.5 1.75 6.5C1.3125 6.5 1 6.1875 1 5.75V1.75C1 1.34375 1.3125 1 1.75 1H5.75C6.15625 1 6.5 1.34375 6.5 1.75C6.5 2.1875 6.15625 2.5 5.75 2.5H3.53125L8 6.96875L12.4375 2.5H10.25C9.8125 2.5 9.5 2.1875 9.5 1.75C9.5 1.34375 9.8125 1 10.25 1Z",fill:e})}),"ExpandIcon");var Au=require("react/jsx-runtime"),la=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Au.jsx)(Z,{...n,width:r,height:o,children:(0,Au.jsx)(Be,{d:"M16 8C16 12.0938 12.9062 15.4688 8.96875 15.9688V10.4688H11.125L11.5625 8H8.96875V7.15625C8.96875 5.84375 9.46875 5.34375 10.7812 5.34375C11.1875 5.34375 11.5 5.375 11.6875 5.375V3.1875C11.3438 3.0625 10.4688 2.96875 9.96875 2.96875C7.28125 2.96875 6.0625 4.25 6.0625 6.96875V8H4.40625V10.4688H6.0625V15.7812C2.5625 14.9062 0 11.75 0 8C0 3.59375 3.5625 0 8 0C12.4062 0 16 3.59375 16 8Z",active:t,fill:e})}),"FacebookIcon");var Iu=require("react/jsx-runtime"),Su=s(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,Iu.jsx)(Z,{...o,width:t,height:r,children:(0,Iu.jsx)(Be,{d:"M0 2.75C0 2.34375 0.3125 2 0.75 2H13.25C13.6562 2 14 2.34375 14 2.75C14 3.1875 13.6562 3.5 13.25 3.5H0.75C0.3125 3.5 0 3.1875 0 2.75ZM2 7.75C2 7.34375 2.3125 7 2.75 7H11.25C11.6562 7 12 7.34375 12 7.75C12 8.1875 11.6562 8.5 11.25 8.5H2.75C2.3125 8.5 2 8.1875 2 7.75ZM9 12.75C9 13.1875 8.65625 13.5 8.25 13.5H5.75C5.3125 13.5 5 13.1875 5 12.75C5 12.3438 5.3125 12 5.75 12H8.25C8.65625 12 9 12.3438 9 12.75Z",fill:e})}),"HamburgerMenuIcon");var Ru=require("react/jsx-runtime"),ca=s(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,Ru.jsx)(Z,{...o,width:t,height:r,children:(0,Ru.jsx)("path",{d:"M2 5.75C2 4.38281 3.09375 3.25 4.5 3.25H19.5C20.8672 3.25 22 4.38281 22 5.75V8.25V10.125V10.75V18.25C22 19.6562 20.8672 20.75 19.5 20.75H4.5C3.09375 20.75 2 19.6562 2 18.25V10.75V10.125V8.25V5.75ZM20.125 10.75H3.875V18.25C3.875 18.6016 4.14844 18.875 4.5 18.875H19.5C19.8125 18.875 20.125 18.6016 20.125 18.25V10.75ZM5.75 8.25C6.41406 8.25 7 7.70312 7 7C7 6.33594 6.41406 5.75 5.75 5.75C5.04688 5.75 4.5 6.33594 4.5 7C4.5 7.70312 5.04688 8.25 5.75 8.25ZM10.75 7C10.75 6.33594 10.1641 5.75 9.5 5.75C8.79688 5.75 8.25 6.33594 8.25 7C8.25 7.70312 8.79688 8.25 9.5 8.25C10.1641 8.25 10.75 7.70312 10.75 7ZM13.25 8.25C13.9141 8.25 14.5 7.70312 14.5 7C14.5 6.33594 13.9141 5.75 13.25 5.75C12.5469 5.75 12 6.33594 12 7C12 7.70312 12.5469 8.25 13.25 8.25Z",fill:e})}),"InboxIcon");var Lu=require("react/jsx-runtime"),ua=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Lu.jsx)(Z,{...n,width:r,height:o,children:(0,Lu.jsx)(Be,{d:"M8 4.40625C9.96875 4.40625 11.5938 6.03125 11.5938 8C11.5938 10 9.96875 11.5938 8 11.5938C6 11.5938 4.40625 10 4.40625 8C4.40625 6.03125 6 4.40625 8 4.40625ZM8 10.3438C9.28125 10.3438 10.3125 9.3125 10.3125 8C10.3125 6.71875 9.28125 5.6875 8 5.6875C6.6875 5.6875 5.65625 6.71875 5.65625 8C5.65625 9.3125 6.71875 10.3438 8 10.3438ZM12.5625 4.28125C12.5625 3.8125 12.1875 3.4375 11.7188 3.4375C11.25 3.4375 10.875 3.8125 10.875 4.28125C10.875 4.75 11.25 5.125 11.7188 5.125C12.1875 5.125 12.5625 4.75 12.5625 4.28125ZM14.9375 5.125C15 6.28125 15 9.75 14.9375 10.9062C14.875 12.0312 14.625 13 13.8125 13.8438C13 14.6562 12 14.9062 10.875 14.9688C9.71875 15.0312 6.25 15.0312 5.09375 14.9688C3.96875 14.9062 3 14.6562 2.15625 13.8438C1.34375 13 1.09375 12.0312 1.03125 10.9062C0.96875 9.75 0.96875 6.28125 1.03125 5.125C1.09375 4 1.34375 3 2.15625 2.1875C3 1.375 3.96875 1.125 5.09375 1.0625C6.25 1 9.71875 1 10.875 1.0625C12 1.125 13 1.375 13.8125 2.1875C14.625 3 14.875 4 14.9375 5.125ZM13.4375 12.125C13.8125 11.2188 13.7188 9.03125 13.7188 8C13.7188 7 13.8125 4.8125 13.4375 3.875C13.1875 3.28125 12.7188 2.78125 12.125 2.5625C11.1875 2.1875 9 2.28125 8 2.28125C6.96875 2.28125 4.78125 2.1875 3.875 2.5625C3.25 2.8125 2.78125 3.28125 2.53125 3.875C2.15625 4.8125 2.25 7 2.25 8C2.25 9.03125 2.15625 11.2188 2.53125 12.125C2.78125 12.75 3.25 13.2188 3.875 13.4688C4.78125 13.8438 6.96875 13.75 8 13.75C9 13.75 11.1875 13.8438 12.125 13.4688C12.7188 13.2188 13.2188 12.75 13.4375 12.125Z",active:t,fill:e})}),"InstagramIcon");var Bu=require("react/jsx-runtime"),da=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Bu.jsx)(Z,{...n,width:r,height:o,children:(0,Bu.jsx)(Be,{d:"M14 1C14.5312 1 15 1.46875 15 2.03125V14C15 14.5625 14.5312 15 14 15H1.96875C1.4375 15 1 14.5625 1 14V2.03125C1 1.46875 1.4375 1 1.96875 1H14ZM5.21875 13V6.34375H3.15625V13H5.21875ZM4.1875 5.40625C4.84375 5.40625 5.375 4.875 5.375 4.21875C5.375 3.5625 4.84375 3 4.1875 3C3.5 3 2.96875 3.5625 2.96875 4.21875C2.96875 4.875 3.5 5.40625 4.1875 5.40625ZM13 13V9.34375C13 7.5625 12.5938 6.15625 10.5 6.15625C9.5 6.15625 8.8125 6.71875 8.53125 7.25H8.5V6.34375H6.53125V13H8.59375V9.71875C8.59375 8.84375 8.75 8 9.84375 8C10.9062 8 10.9062 9 10.9062 9.75V13H13Z",active:t,fill:e})}),"LinkedinIcon");var Du=require("react/jsx-runtime"),Hu=s(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 256 239",...n})=>(0,Du.jsx)(Z,{...n,width:t,height:r,viewBox:o,children:(0,Du.jsx)("path",{d:"M244.688 89.3027C250.936 89.3028 256 94.367 256 100.614V160.846C256 183.806 237.387 202.419 214.427 202.419H214.23C207.916 202.42 201.932 201.009 196.571 198.491C186.31 221.332 163.63 237.486 136.931 238.14C107.972 237.431 83.7409 218.49 74.9551 192.558H120.063C130.509 192.558 138.977 184.09 138.977 173.645V89.3027H244.688ZM120.082 53.5811C120.127 53.5812 120.172 53.5842 120.217 53.585C125.988 53.6645 130.676 58.2209 130.962 63.9395C130.971 64.1173 130.976 64.2966 130.977 64.4766V173.646C130.976 179.672 126.09 184.558 120.063 184.558H10.9131C4.88618 184.558 9.07128e-05 179.672 0 173.646V64.4941C0 58.4673 4.88624 53.5811 10.9131 53.5811H120.082ZM36.7686 95.125H58.4873V154.541H72.3887V95.125H94.208V83.5986H36.7686V95.125ZM139.907 0C161.279 0.000200803 178.604 17.3254 178.604 38.6973C178.604 60.0693 161.279 77.3953 139.907 77.3955C139.596 77.3955 139.286 77.3901 138.977 77.3828V64.4941C138.976 54.0493 130.509 45.5811 120.063 45.5811H101.82C101.419 43.3471 101.209 41.0467 101.209 38.6973C101.209 17.3253 118.535 0 139.907 0ZM223.256 23.8145C238.052 23.8145 250.047 35.8085 250.047 50.6045C250.047 65.4005 238.052 77.3954 223.256 77.3955C208.46 77.3955 196.465 65.4006 196.465 50.6045C196.465 35.8085 208.46 23.8145 223.256 23.8145Z",fill:e})}),"MSTeamsIcon");var Vu=require("react/jsx-runtime"),ma=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Vu.jsx)(Z,{...n,width:r,height:o,children:(0,Vu.jsx)(Be,{d:"M5.625 2.34375C8.75 2.34375 11.2812 4.875 11.2812 8C11.2812 11.1562 8.75 13.6875 5.625 13.6875C2.5 13.6875 0 11.1562 0 8C0 4.875 2.5 2.34375 5.625 2.34375ZM14.625 2.65625C16.1875 2.65625 17.4688 5.0625 17.4688 8.03125C17.4688 10.9688 16.1875 13.375 14.625 13.375C13.0625 13.375 11.8125 10.9688 11.8125 8.03125C11.8125 5.0625 13.0625 2.65625 14.625 2.65625ZM19 3.21875C19.5312 3.21875 20 5.375 20 8C20 10.6562 19.5312 12.8125 19 12.8125C18.4375 12.8125 18 10.6562 18 8.03125C18 5.375 18.4375 3.21875 19 3.21875Z",active:t,fill:e})}),"MediumIcon");var Is=require("react/jsx-runtime"),Fu=s(({color:e,width:t=21,height:r=16,...o})=>(0,Is.jsx)(Z,{...o,width:t,height:r,children:(0,Is.jsx)("g",{transform:"translate(4, 0)",children:(0,Is.jsx)("path",{d:"M8.5 1.5V2C8.5 2.28125 8.25 2.5 8 2.5H5C4.71875 2.5 4.5 2.28125 4.5 2V1.5H3.5C2.9375 1.5 2.5 1.96875 2.5 2.5V13.5C2.5 14.0625 2.9375 14.5 3.5 14.5H9.5C10.0312 14.5 10.5 14.0625 10.5 13.5V2.5C10.5 1.96875 10.0312 1.5 9.5 1.5H8.5ZM1 2.5C1 1.125 2.09375 0 3.5 0H9.5C10.875 0 12 1.125 12 2.5V13.5C12 14.9062 10.875 16 9.5 16H3.5C2.09375 16 1 14.9062 1 13.5V2.5Z",fill:e})})}),"MobileIcon");var Ou=require("react/jsx-runtime"),Uu=s(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,Ou.jsx)(Z,{...o,width:t,height:r,children:(0,Ou.jsx)(Be,{d:"M13.5 8C13.5 8.5625 13.1875 9.03125 12.75 9.3125C12.2812 9.59375 11.6875 9.59375 11.25 9.3125C10.7812 9.03125 10.5 8.5625 10.5 8C10.5 7.46875 10.7812 7 11.25 6.71875C11.6875 6.4375 12.2812 6.4375 12.75 6.71875C13.1875 7 13.5 7.46875 13.5 8ZM8.5 8C8.5 8.5625 8.1875 9.03125 7.75 9.3125C7.28125 9.59375 6.6875 9.59375 6.25 9.3125C5.78125 9.03125 5.5 8.5625 5.5 8C5.5 7.46875 5.78125 7 6.25 6.71875C6.6875 6.4375 7.28125 6.4375 7.75 6.71875C8.1875 7 8.5 7.46875 8.5 8ZM2 9.5C1.4375 9.5 0.96875 9.21875 0.6875 8.75C0.40625 8.3125 0.40625 7.71875 0.6875 7.25C0.96875 6.8125 1.4375 6.5 2 6.5C2.53125 6.5 3 6.8125 3.28125 7.25C3.5625 7.71875 3.5625 8.3125 3.28125 8.75C3 9.21875 2.53125 9.5 2 9.5Z",fill:e})}),"MoreMenuIcon");var Wu=require("react/jsx-runtime"),pa=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Wu.jsx)(Z,{...n,width:r,height:o,children:(0,Wu.jsx)(Be,{d:"M14.25 0C14.6562 0 15 0.34375 15 0.75V15.25C15 15.6875 14.6562 16 14.25 16C13.8125 16 13.5 15.6875 13.5 15.25V0.75C13.5 0.34375 13.8125 0 14.25 0ZM9.5 11.5V4.5H6.5V11.5H9.5ZM11 4.5V11.5C11 12.3438 10.3125 13 9.5 13H6.5C5.65625 13 5 12.3438 5 11.5V4.5C5 3.6875 5.65625 3 6.5 3H9.5C10.3125 3 11 3.6875 11 4.5ZM2.5 0.75V15.25C2.5 15.6875 2.15625 16 1.75 16C1.3125 16 1 15.6875 1 15.25V0.75C1 0.34375 1.3125 0 1.75 0C2.15625 0 2.5 0.34375 2.5 0.75Z",active:t,fill:e})}),"PaddingHorizontalIcon");var _u=require("react/jsx-runtime"),vn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,_u.jsx)(Z,{...n,width:r,height:o,children:(0,_u.jsx)(Be,{d:"M0 1.75C0 1.34375 0.3125 1 0.75 1H15.25C15.6562 1 16 1.34375 16 1.75C16 2.1875 15.6562 2.5 15.25 2.5H0.75C0.3125 2.5 0 2.1875 0 1.75ZM11.5 6.5H4.5V9.5H11.5V6.5ZM4.5 5H11.5C12.3125 5 13 5.6875 13 6.5V9.5C13 10.3438 12.3125 11 11.5 11H4.5C3.65625 11 3 10.3438 3 9.5V6.5C3 5.6875 3.65625 5 4.5 5ZM0.75 13.5H15.25C15.6562 13.5 16 13.8438 16 14.25C16 14.6875 15.6562 15 15.25 15H0.75C0.3125 15 0 14.6875 0 14.25C0 13.8438 0.3125 13.5 0.75 13.5Z",active:t,fill:e})}),"PaddingVerticalIcon");var fa=require("react/jsx-runtime"),zu=s(({width:e=20,height:t=21,viewBox:r="0 0 20 21",...o})=>(0,fa.jsxs)(Z,{...o,width:e,height:t,viewBox:r,children:[(0,fa.jsx)("path",{d:"M15 4.625H2.5C2.14844 4.625 1.875 4.9375 1.875 5.25V17.75C1.875 18.1016 2.14844 18.375 2.5 18.375H15C15.3125 18.375 15.625 18.1016 15.625 17.75V5.25C15.625 4.9375 15.3125 4.625 15 4.625ZM2.5 2.75H15C16.3672 2.75 17.5 3.88281 17.5 5.25V17.75C17.5 19.1562 16.3672 20.25 15 20.25H2.5C1.09375 20.25 0 19.1562 0 17.75V5.25C0 3.88281 1.09375 2.75 2.5 2.75Z",fill:"currentColor"}),(0,fa.jsx)("circle",{cx:"2",cy:"2",r:"3",transform:"matrix(-1 0 0 1 17.75 2)",fill:"currentColor",stroke:"white",strokeWidth:"2"})]}),"PushIcon");var $u=require("react/jsx-runtime"),Zu=s(({color:e="#171717",width:t=16,height:r=13,...o})=>(0,$u.jsx)(Z,{...o,fill:"none",width:t,height:r,children:(0,$u.jsx)("path",{d:"M1.39062 0.640625L4.01562 2.67969L4.17969 1.97656C4.29688 1.55469 4.67188 1.25 5.09375 1.25H12.9453C13.5547 1.25 14 1.83594 13.8594 2.42188L13.6016 3.45312C13.5312 3.75781 13.2266 3.94531 12.9219 3.875C12.6172 3.80469 12.4297 3.5 12.5 3.19531L12.7109 2.375H9.78125L8.65625 6.33594L15.2656 11.5156C15.5234 11.7031 15.5703 12.0547 15.3594 12.2891C15.1719 12.5469 14.8203 12.5938 14.5859 12.3828L0.710938 1.50781C0.453125 1.32031 0.40625 0.96875 0.617188 0.734375C0.804688 0.476562 1.15625 0.429688 1.39062 0.640625ZM4.97656 3.42969L7.71875 5.58594L8.60938 2.375H5.23438L4.97656 3.42969ZM8 8.67969L7.4375 10.625H8.75C9.05469 10.625 9.3125 10.8828 9.3125 11.1875C9.3125 11.5156 9.05469 11.75 8.75 11.75H5C4.67188 11.75 4.4375 11.5156 4.4375 11.1875C4.4375 10.8828 4.67188 10.625 5 10.625H6.28906L6.3125 10.4844L7.03906 7.92969L8 8.67969Z",fill:e})}),"RemoveFormattingIcon");var qu=require("react/jsx-runtime"),Ju=s(({color:e="#171717",width:t=11,height:r=12,...o})=>(0,qu.jsx)(Z,{...o,width:t,height:r,children:(0,qu.jsx)(Be,{d:"M10.75 2.75V10.25C10.75 10.6719 10.3984 11 10 11C9.57812 11 9.25 10.6719 9.25 10.25V2.75C9.25 2.35156 9.57812 2 10 2C10.3984 2 10.75 2.35156 10.75 2.75ZM7.51562 7.03906L4.51562 10.0391C4.23438 10.3438 3.74219 10.3438 3.46094 10.0391C3.15625 9.75781 3.15625 9.26562 3.46094 8.98438L5.17188 7.25H1C0.578125 7.25 0.25 6.92188 0.25 6.5C0.25 6.10156 0.578125 5.75 1 5.75H5.17188L3.46094 4.03906C3.15625 3.75781 3.15625 3.26562 3.46094 2.98438C3.74219 2.67969 4.23438 2.67969 4.51562 2.98438L7.51562 5.98438C7.82031 6.26562 7.82031 6.75781 7.51562 7.03906Z",fill:e})}),"RightToLineIcon");var ju=require("react/jsx-runtime"),Ku=s(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,ju.jsx)(Z,{...o,width:t,height:r,children:(0,ju.jsx)("path",{d:"M6.80469 17.3125C7.3125 16.9219 7.97656 16.8438 8.5625 17.0391C9.57812 17.4297 10.75 17.625 12 17.625C16.8438 17.625 20.125 14.5 20.125 11.375C20.125 8.28906 16.8438 5.125 12 5.125C7.11719 5.125 3.875 8.28906 3.875 11.375C3.875 12.625 4.34375 13.8359 5.24219 14.8906C5.59375 15.2422 5.75 15.75 5.71094 16.2578C5.67188 16.9609 5.47656 17.625 5.28125 18.2109C5.94531 17.8984 6.49219 17.5469 6.80469 17.3125ZM2.82031 18.875C2.89844 18.7969 2.9375 18.6797 3.01562 18.5625C3.40625 17.9375 3.75781 17.0781 3.83594 16.1016C2.66406 14.7734 2 13.1719 2 11.375C2 6.92188 6.45312 3.25 12 3.25C17.5078 3.25 22 6.92188 22 11.375C22 15.8672 17.5078 19.5 12 19.5C10.5156 19.5 9.14844 19.2656 7.89844 18.8359C7.46875 19.1484 6.6875 19.6172 5.78906 20.0078C5.20312 20.2812 4.53906 20.5156 3.83594 20.6328C3.79688 20.6328 3.75781 20.6719 3.75781 20.6719C3.5625 20.7109 3.40625 20.7109 3.21094 20.75C3.01562 20.75 2.82031 20.7891 2.58594 20.7891C2.35156 20.7891 2.11719 20.6328 2.03906 20.3984C1.92188 20.1641 2 19.8906 2.15625 19.6953C2.3125 19.5391 2.46875 19.3828 2.58594 19.1875C2.66406 19.0703 2.74219 18.9922 2.78125 18.9141V18.875H2.82031Z",fill:e})}),"SMSIcon");var zo=require("react/jsx-runtime"),wp=s(({color:e="#000000",width:t=14,height:r=9,...o})=>(0,zo.jsx)(Z,{...o,width:t,height:r,children:(0,zo.jsxs)("g",{opacity:"0.9",children:[(0,zo.jsx)("rect",{x:"0.799805",y:"5.92188",width:"2.46154",height:"2.95385",rx:"0.246154",fill:e}),(0,zo.jsx)("rect",{x:"4.24609",y:"4.44531",width:"2.46154",height:"4.43077",rx:"0.246154",fill:e}),(0,zo.jsx)("rect",{x:"7.93823",y:"2.72266",width:"2.46154",height:"6.15385",rx:"0.246154",fill:e}),(0,zo.jsx)("rect",{x:"11.3845",y:"0.753906",width:"2.46154",height:"8.12308",rx:"0.246154",fill:e})]})}),"SignalIcon");var Gu=require("react/jsx-runtime"),Yu=s(({color:e="#404040",width:t=16,height:r=16,...o})=>(0,Gu.jsx)(Z,{...o,width:t,height:r,children:(0,Gu.jsx)("path",{d:"M3.5 10C3.5 10.8281 2.8125 11.5 2 11.5C1.16406 11.5 0.5 10.8281 0.5 10C0.5 9.19531 1.16406 8.5 2 8.5H3.5V10ZM4.25 10C4.25 9.19531 4.91406 8.5 5.75 8.5C6.5625 8.5 7.25 9.19531 7.25 10V14C7.25 14.8281 6.5625 15.5 5.75 15.5C4.91406 15.5 4.25 14.8281 4.25 14V10ZM5.75 3.5C4.91406 3.5 4.25 2.83594 4.25 2C4.25 1.1875 4.91406 0.5 5.75 0.5C6.5625 0.5 7.25 1.1875 7.25 2V3.5H5.75ZM5.75 4.25C6.5625 4.25 7.25 4.91406 7.25 5.75C7.25 6.5625 6.5625 7.25 5.75 7.25H2C1.16406 7.25 0.5 6.5625 0.5 5.75C0.5 4.91406 1.16406 4.25 2 4.25H5.75ZM12.5 5.75C12.5 4.91406 13.1641 4.25 14 4.25C14.8125 4.25 15.5 4.91406 15.5 5.75C15.5 6.5625 14.8125 7.25 14 7.25H12.5V5.75ZM11.75 5.75C11.75 6.5625 11.0859 7.25 10.25 7.25C9.41406 7.25 8.75 6.5625 8.75 5.75V2C8.75 1.1875 9.41406 0.5 10.25 0.5C11.0859 0.5 11.75 1.1875 11.75 2V5.75ZM10.25 12.5C11.0859 12.5 11.75 13.1641 11.75 14C11.75 14.8125 11.0859 15.5 10.25 15.5C9.41406 15.5 8.75 14.8125 8.75 14V12.5H10.25ZM10.25 11.75C9.41406 11.75 8.75 11.0859 8.75 10.25C8.75 9.41406 9.41406 8.75 10.25 8.75H14C14.8125 8.75 15.5 9.41406 15.5 10.25C15.5 11.0859 14.8125 11.75 14 11.75H10.25Z",fill:e})}),"SlackIcon");var Xu=require("react/jsx-runtime"),ga=s(({color:e="#FFFFFF",width:t=24,height:r=24,...o})=>(0,Xu.jsx)(Z,{...o,width:t,height:r,viewBox:"0 0 24 24",children:(0,Xu.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.9302 18.0041C16.7152 19.4687 17.3201 20.6536 17.6716 21.4225C22.7992 18.3395 24.5289 11.7034 21.525 6.5012C18.5211 1.29895 11.9084 -0.521541 6.67543 2.3769C7.30667 3.26444 8.32896 4.86524 9.56215 6.89518C10.4351 8.33194 11.4134 9.98401 12.4328 11.7503C13.7758 14.0761 14.9841 16.2422 15.9302 18.0041ZM4.20759 16.4985C2.25528 13.1182 1.73242 9.41428 2.51159 6.43383C0.579784 9.73503 0.426001 13.9501 2.47497 17.4989C4.52394 21.0476 8.25134 23.0233 12.0769 22.9999C9.1052 22.1856 6.1599 19.8803 4.20759 16.4985ZM1.6094 17.9983C4.92231 23.738 12.2599 25.7035 17.9997 22.3906C23.738 19.0777 25.7035 11.7401 22.3906 6.00031C19.0776 0.262019 11.74 -1.70347 6.00172 1.60945C0.261966 4.92236 -1.70352 12.26 1.6094 17.9983ZM11.1249 21.6085C12.4884 22.1914 13.8534 22.4228 15.1188 22.2896C12.7711 21.2717 9.91951 18.3937 7.66989 14.4994C5.42174 10.605 4.35551 6.69599 4.6499 4.15492C3.90002 5.18306 3.41817 6.48069 3.24096 7.95408C2.94364 10.4131 3.51483 13.2999 5.07317 15.9991C6.6315 18.6998 8.84597 20.636 11.1249 21.6085ZM16.913 21.6876C16.6889 21.6993 16.4238 21.67 16.1089 21.5836C15.4513 21.402 14.6604 20.9861 13.7875 20.3197C12.0461 18.9898 10.1436 16.7827 8.53694 13.9999C6.92881 11.2157 5.9695 8.46376 5.6883 6.29176C5.62971 5.83334 5.60188 5.41008 5.60188 5.02342C5.60188 4.49324 5.65461 4.03335 5.7542 3.65109C5.89334 3.11945 6.10278 2.78845 6.33565 2.59219C7.11481 4.29259 9.11545 8.00387 11.5672 12.2497C14.0189 16.4956 16.2319 20.0853 17.3157 21.61C17.2 21.651 17.0667 21.6788 16.913 21.6876Z",fill:e})}),"UnionIcon");var Qu=require("react/jsx-runtime"),ha=s(({color:e="#A3A3A3",width:t=24,height:r=24,...o})=>(0,Qu.jsx)(Z,{...o,width:t,height:r,children:(0,Qu.jsx)(Be,{d:"M12 12C10.2031 12 8.5625 11.0625 7.66406 9.5C6.76562 7.97656 6.76562 6.0625 7.66406 4.5C8.5625 2.97656 10.2031 2 12 2C13.7578 2 15.3984 2.97656 16.2969 4.5C17.1953 6.0625 17.1953 7.97656 16.2969 9.5C15.3984 11.0625 13.7578 12 12 12ZM10.2031 13.875H13.7578C17.625 13.875 20.75 17 20.75 20.8672C20.75 21.4922 20.2031 22 19.5781 22H4.38281C3.75781 22 3.25 21.4922 3.25 20.8672C3.25 17 6.33594 13.875 10.2031 13.875Z",fill:e})}),"UserIcon");var ed=require("react/jsx-runtime"),Pp=s(({width:e=24,height:t=20,...r})=>(0,ed.jsx)(Z,{...r,width:e,height:t,viewBox:"0 0 24 20",children:(0,ed.jsx)("path",{d:"M6 1H5C4.46957 1 3.96086 1.21071 3.58579 1.58579C3.21071 1.96086 3 2.46957 3 3V8C3 8.53043 2.78929 9.03914 2.41421 9.41421C2.03914 9.78929 1.53043 10 1 10C1.53043 10 2.03914 10.2107 2.41421 10.5858C2.78929 10.9609 3 11.4696 3 12V17C3 18.1 3.9 19 5 19H6M18 19H19C19.5304 19 20.0391 18.7893 20.4142 18.4142C20.7893 18.0391 21 17.5304 21 17V12C21 10.9 21.9 10 23 10C22.4696 10 21.9609 9.78929 21.5858 9.41421C21.2107 9.03914 21 8.53043 21 8V3C21 2.46957 20.7893 1.96086 20.4142 1.58579C20.0391 1.21071 19.5304 1 19 1H18M10 16.5C10 16.7761 9.77614 17 9.5 17C9.22386 17 9 16.7761 9 16.5C9 16.2239 9.22386 16 9.5 16C9.77614 16 10 16.2239 10 16.5ZM15 16.5C15 16.7761 14.7761 17 14.5 17C14.2239 17 14 16.7761 14 16.5C14 16.2239 14.2239 16 14.5 16C14.7761 16 15 16.2239 15 16.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"VariableIcon");var xn=require("react/jsx-runtime"),Np=s(({color:e="#000000",width:t=14,height:r=10,...o})=>(0,xn.jsx)(Z,{...o,width:t,height:r,children:(0,xn.jsxs)("g",{opacity:"0.9",children:[(0,xn.jsx)("path",{d:"M13.3282 2.87894C11.7229 1.26255 9.4985 0.261719 7.04045 0.261719C4.57494 0.261719 2.34465 1.26857 0.738281 2.89354L2.13071 4.28604C3.38071 3.01741 5.11881 2.23095 7.04045 2.23095C8.95475 2.23095 10.6867 3.01137 11.9356 4.27141L13.3282 2.87894Z",fill:e}),(0,xn.jsx)("path",{d:"M11.0654 5.14169C10.0392 4.10437 8.61484 3.46172 7.04045 3.46172C5.45859 3.46172 4.02831 4.11043 3.00102 5.15634L4.39357 6.5489C5.06436 5.85932 6.00246 5.43095 7.04045 5.43095C8.07109 5.43095 9.00307 5.85322 9.6729 6.5342L11.0654 5.14169Z",fill:e}),(0,xn.jsx)("path",{d:"M8.80258 7.40452C8.35559 6.94626 7.73119 6.66172 7.04045 6.66172C6.34225 6.66172 5.71196 6.95239 5.264 7.41931L7.0259 9.18121L8.80258 7.40452Z",fill:e})]})}),"WiFiIcon");var td=require("react/jsx-runtime"),ba=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,td.jsx)(Z,{...n,width:r,height:o,children:(0,td.jsx)(Be,{d:"M12.1562 1.5H14.3438L9.53125 7.03125L15.2188 14.5H10.7812L7.28125 9.96875L3.3125 14.5H1.09375L6.25 8.625L0.8125 1.5H5.375L8.5 5.65625L12.1562 1.5ZM11.375 13.1875H12.5938L4.71875 2.75H3.40625L11.375 13.1875Z",active:t,fill:e})}),"XIcon");var Mp=require("lucide-react"),kn=require("react");var Ss=require("react/jsx-runtime"),Tn=s(({className:e})=>(0,Ss.jsx)("div",{className:I("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:(0,Ss.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"courier-w-6 courier-h-6 courier-animate-spin",children:(0,Ss.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");var En=require("react/jsx-runtime"),di=s(({isError:e,isSaving:t,isLoading:r,renderIsSaving:o,renderIsError:n,renderSaved:i})=>{let[a,l]=(0,kn.useState)(!1),c=(0,kn.useRef)(t),u=(0,kn.useRef)(null);return(0,kn.useEffect)(()=>(r||e||t&&t!==c.current?(u.current&&(clearTimeout(u.current),u.current=null),l(!1)):c.current===!0&&t===!1&&!e&&!r&&(l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l(!1),u.current=null},5e3)),c.current=t,()=>{u.current&&clearTimeout(u.current)}),[t,e,r]),r||t===null?null:t?o?o(t):(0,En.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,En.jsx)(Tn,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):(0,En.jsx)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:"Error"}):a?i?i(a):(0,En.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,En.jsx)(Mp.CircleCheck,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Saved"]}):null},"Status");var rd=require("jotai");var wn=require("react/jsx-runtime"),$o=[{label:"Email",value:"email",icon:(0,wn.jsx)(Nu,{})},{label:"SMS",value:"sms",icon:(0,wn.jsx)(Ku,{})},{label:"Push",value:"push",icon:(0,wn.jsx)(zu,{})},{label:"In-app",value:"inbox",icon:(0,wn.jsx)(ca,{})},{label:"Slack",value:"slack",icon:(0,wn.jsx)(Yu,{})},{label:"Teams",value:"msteams",icon:(0,wn.jsx)(Hu,{})}];var Zo=(0,rd.atom)("email"),mi=(0,rd.atom)("template");var s2=require("@radix-ui/react-alert-dialog"),Ho=require("jotai"),vo=require("react");var tr=require("jotai");var od={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"}},Rs=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 rh={paragraph:od,heading:od},ya=(0,tr.atom)(rh),ye=(0,tr.atom)(null),Qe=(0,tr.atom)(null,(e,t,r)=>{t(ye,r)}),oh=(0,tr.atom)({ref:null,caretPosition:null}),Ls=(0,tr.atom)({ref:null,caretPosition:null}),Ca=(0,tr.atom)({isFocused:!1,hasVariables:!1,showVariablePopup:!1}),Ap=(0,tr.atom)(e=>(t,r=!1)=>{let o=e(ya),n=e(Ca),i=Rs(t,r),a=o[t],l=i;return a&&Object.keys(a).forEach(c=>{var p,m;let u=c;u!=="conditionalRules"&&((p=i[u])==null?void 0:p.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}),Ip=(0,tr.atom)(null,(e,t,{nodeName:r,config:o})=>{let n=e(ya);t(ya,{...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"}]))}})}),v4=(0,tr.atom)(null,(e,t,r)=>{let o=e(ya),{[r]:n,...i}=o;t(ya,i)}),Sp=(0,tr.atom)(null,(e,t,{ref:r,caretPosition:o})=>{t(oh,{ref:r,caretPosition:o})}),x4=(0,tr.atom)(null,(e,t,r)=>{let o=e(Ca);t(Ca,{...o,showVariablePopup:r})}),nd=(0,tr.atom)(null),Bs=(0,tr.atom)(null,(e,t,r)=>{t(nd,r)});var Do=require("jotai"),pr=require("react");var id=require("jotai"),$r=(0,id.atom)(null),po=(0,id.atom)(null);var Rp=require("react"),Lp=require("sonner");var qo=require("react/jsx-runtime"),rr=(0,Rp.forwardRef)(({theme:e,children:t,isLoading:r,Header:o,colorScheme:n,className:i,...a},l)=>(0,qo.jsx)(yp,{theme:e,ref:l,colorScheme:n,className:i,children:(0,qo.jsxs)("div",{...Object.fromEntries(Object.entries(a).filter(([c])=>c!=="variables"&&c!=="brandEditor")),className:"courier-main-layout",children:[o&&(0,qo.jsx)("div",{className:"courier-main-header courier-flex courier-flex-row courier-h-12 courier-flex-shrink-0 courier-w-full courier-bg-primary courier-border-b courier-px-4 courier-items-center courier-gap-4 courier-self-stretch dark:courier-bg-background",children:o}),r&&(0,qo.jsx)("div",{className:"courier-editor-loading",children:(0,qo.jsx)(Tn,{})}),(0,qo.jsx)(Lp.Toaster,{position:"top-center",expand:!0,visibleToasts:2,style:{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)"}}),t]})}));var Zt=require("jotai"),Ee=require("react");function Bp(e){if(Array.isArray(e))return e}s(Bp,"_arrayWithHoles");function Dp(e,t){var r=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,n,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(o=i.call(r)).done)&&(l.push(o.value),l.length!==t);c=!0);}catch(p){u=!0,n=p}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw n}}return l}}s(Dp,"_iterableToArrayLimit");function va(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(va,"_arrayLikeToArray");function Ds(e,t){if(e){if(typeof e=="string")return va(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)?va(e,t):void 0}}s(Ds,"_unsupportedIterableToArray");function Hp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
196
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}s(Hp,"_nonIterableRest");function Hs(e,t){return Bp(e)||Dp(e,t)||Ds(e,t)||Hp()}s(Hs,"_slicedToArray");var xf=he(xa());var Fs="data-pdnd-honey-pot";function Os(e){return e instanceof Element&&e.hasAttribute(Fs)}s(Os,"isHoneyPotElement");function Us(e){var t=document.elementsFromPoint(e.x,e.y),r=Hs(t,2),o=r[0],n=r[1];return o?Os(o)?n!=null?n:null:o:null}s(Us,"getElementFromPointWithoutHoneypot");function Pn(e){"@babel/helpers - typeof";return Pn=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},Pn(e)}s(Pn,"_typeof");function Op(e,t){if(Pn(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,t||"default");if(Pn(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}s(Op,"toPrimitive");function Up(e){var t=Op(e,"string");return Pn(t)=="symbol"?t:t+""}s(Up,"toPropertyKey");function Mo(e,t,r){return(t=Up(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}s(Mo,"_defineProperty");var Ea=he(xa());var Wp=2147483647;function _p(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(_p,"ownKeys");function zp(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?_p(Object(r),!0).forEach(function(o){Mo(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_p(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(zp,"_objectSpread");var Ta=2,$p=Ta/2;function uh(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}s(uh,"floorToClosestPixel");function dh(e){return{x:e.x-$p,y:e.y-$p}}s(dh,"pullBackByHalfHoneyPotSize");function mh(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}s(mh,"preventGoingBackwardsOffScreen");function ph(e){return{x:Math.min(e.x,window.innerWidth-Ta),y:Math.min(e.y,window.innerHeight-Ta)}}s(ph,"preventGoingForwardsOffScreen");function Zp(e){var t=e.client,r=ph(mh(dh(uh(t))));return DOMRect.fromRect({x:r.x,y:r.y,width:Ta,height:Ta})}s(Zp,"getHoneyPotRectFor");function qp(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(qp,"getRectStyles");function fh(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(fh,"isWithin");function gh(e){var t=e.initial,r=document.createElement("div");r.setAttribute(Fs,"true");var o=Zp({client:t});Object.assign(r.style,zp(zp({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},qp({clientRect:o})),{},{pointerEvents:"auto",zIndex:Wp})),document.body.appendChild(r);var n=(0,Ea.bind)(window,{type:"pointermove",listener:s(function(a){var l={x:a.clientX,y:a.clientY};o=Zp({client:l}),Object.assign(r.style,qp({clientRect:o}))},"listener"),options:{capture:!0}});return s(function(a){var l=a.current;if(n(),fh({client:l,clientRect:o})){r.remove();return}function c(){u(),r.remove()}s(c,"cleanup");var u=(0,Ea.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(gh,"mountHoneyPot");function Jp(){var e=null;function t(){return e=null,(0,Ea.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=gh({initial:u})}if(a==="onDrop"){var p,m=l.location.current.input;(p=o)===null||p===void 0||p({current:{x:m.clientX,y:m.clientY}}),o=null,e=null}},"onPostEvent")}return s(r,"getOnPostDispatch"),{bindEvents:t,getOnPostDispatch:r}}s(Jp,"makeHoneyPotFix");function jp(e){if(Array.isArray(e))return va(e)}s(jp,"_arrayWithoutHoles");function Kp(e){if(typeof Symbol!="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}s(Kp,"_iterableToArray");function Gp(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
197
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}s(Gp,"_nonIterableSpread");function Ws(e){return jp(e)||Kp(e)||Ds(e)||Gp()}s(Ws,"_toConsumableArray");var af=he(xa());function Sr(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(Sr,"once");var Yp=Sr(s(function(){return navigator.userAgent.includes("Firefox")},"isFirefox"));var ka=Sr(s(function(){var t=navigator,r=t.userAgent;return r.includes("AppleWebKit")&&!r.includes("Chrome")},"isSafari"));var Xp=he(xa());var sd={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function Qp(e){var t=e.dragLeave;return ka()?t.hasOwnProperty(sd.isLeavingWindow):!1}s(Qp,"isLeavingWindowInSafari");s(function(){if(typeof window=="undefined"||!ka())return;function t(){return{enterCount:0,isOverWindow:!1}}s(t,"getInitialState");var r=t();function o(){r=t()}s(o,"resetState"),(0,Xp.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[sd.isEnteringWindow]=!0),r.isOverWindow=!0,r.enterCount++},"listener")},{type:"dragleave",listener:s(function(i){r.enterCount--,r.isOverWindow&&r.enterCount===0&&(i[sd.isLeavingWindow]=!0,r.isOverWindow=!1)},"listener")}],{capture:!0})},"fixSafari")();function hh(e){return"nodeName"in e}s(hh,"isNodeLike");function ef(e){return hh(e)&&e.ownerDocument!==document}s(ef,"isFromAnotherWindow");function tf(e){var t=e.dragLeave,r=t.type,o=t.relatedTarget;return r!=="dragleave"?!1:ka()?Qp({dragLeave:t}):o==null?!0:Yp()?ef(o):o instanceof HTMLIFrameElement}s(tf,"isLeavingWindow");function rf(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(rf,"getBindingsForBrokenDrags");function Nn(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(Nn,"getInput");var bh=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"),of=bh;var ld=of(function(e){return e()}),_s=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 nf(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,p={current:r,previous:n,initial:r};i({eventName:"onGenerateDragPreview",payload:{source:t,location:p,nativeSetDragImage:u}}),_s.schedule(function(){i({eventName:"onDragStart",payload:{source:t,location:p}})})},"start"),dragUpdate:s(function(c){var u=c.current;_s.flush(),ld.cancel(),i({eventName:"onDropTargetChange",payload:{source:t,location:{initial:r,previous:n,current:u}}})},"dragUpdate"),drag:s(function(c){var u=c.current;ld(function(){_s.flush();var p={initial:r,previous:n,current:u};i({eventName:"onDrag",payload:{source:t,location:p}})})},"drag"),drop:s(function(c){var u=c.current,p=c.updatedSourcePayload;_s.flush(),ld.cancel(),i({eventName:"onDrop",payload:{source:p!=null?p:t,location:{current:u,previous:n,initial:r}}})},"drop")};return a}s(nf,"makeDispatch");var ud={isActive:!1};function sf(){return!ud.isActive}s(sf,"canStart");function yh(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}s(yh,"getNativeSetDragImage");function Ch(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(Ch,"hasHierarchyChanged");function vh(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=e.dispatchEvent;if(!sf())return;var i=xh({event:t,dragType:r,getDropTargetsOver:o});ud.isActive=!0;var a={current:i};cd({event:t,current:i.dropTargets});var l=nf({source:r.payload,dispatchEvent:n,initial:i});function c(f){var C=Ch({current:a.current.dropTargets,next:f.dropTargets});a.current=f,C&&l.dragUpdate({current:a.current})}s(c,"updateState");function u(f){var C=Nn(f),h=Os(f.target)?Us({x:C.clientX,y:C.clientY}):f.target,b=o({target:h,input:C,source:r.payload,current:a.current.dropTargets});b.length&&(f.preventDefault(),cd({event:f,current:b})),c({dropTargets:b,input:C})}s(u,"onUpdateEvent");function p(){a.current.dropTargets.length&&c({dropTargets:[],input:a.current.input}),l.drop({current:a.current,updatedSourcePayload:null}),m()}s(p,"cancel");function m(){ud.isActive=!1,d()}s(m,"finish");var d=(0,af.bindAll)(window,[{type:"dragover",listener:s(function(C){u(C),l.drag({current:a.current})},"listener")},{type:"dragenter",listener:u},{type:"dragleave",listener:s(function(C){tf({dragLeave:C})&&(c({input:a.current.input,dropTargets:[]}),r.startedFrom==="external"&&p())},"listener")},{type:"drop",listener:s(function(C){if(a.current={dropTargets:a.current.dropTargets,input:Nn(C)},!a.current.dropTargets.length){p();return}C.preventDefault(),cd({event:C,current:a.current.dropTargets}),l.drop({current:a.current,updatedSourcePayload:r.type==="external"?r.getDropPayload(C):null}),m()},"listener")},{type:"dragend",listener:s(function(C){a.current={dropTargets:a.current.dropTargets,input:Nn(C)},p()},"listener")}].concat(Ws(rf({onDragEnd:p}))),{capture:!0});l.start({nativeSetDragImage:yh(t)})}s(vh,"start");function cd(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(cd,"setDropEffectOnEvent");function xh(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=Nn(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(xh,"getStartLocation");var dd={canStart:sf,start:vh};var md=new Map;function Th(e){var t=e.typeKey,r=e.mount,o=md.get(t);if(o)return o.usageCount++,o;var n={typeKey:t,unmount:r(),usageCount:1};return md.set(t,n),n}s(Th,"registerUsage");function lf(e){var t=Th(e);return s(function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),md.delete(e.typeKey))},"unregister")}s(lf,"register");function fo(){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(fo,"combine");function zs(e,t){var r=t.attribute,o=t.value;return e.setAttribute(r,o),function(){return e.removeAttribute(r)}}s(zs,"addAttribute");function cf(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(cf,"ownKeys");function Jo(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?cf(Object(r),!0).forEach(function(o){Mo(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):cf(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(Jo,"_objectSpread");function pd(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Eh(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.
198
- 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(pd,"_createForOfIteratorHelper");function Eh(e,t){if(e){if(typeof e=="string")return uf(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)?uf(e,t):void 0}}s(Eh,"_unsupportedIterableToArray");function uf(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(uf,"_arrayLikeToArray");function fd(e){return e.slice(0).reverse()}s(fd,"copyReverse");function df(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 C;var h=fo(zs(f.element,{attribute:n,value:"true"}),a(f));return Sr(h)}s(l,"dropTargetForConsumers");function c(f){var C,h,b,v,E=f.source,g=f.target,w=f.input,N=f.result,y=N===void 0?[]:N;if(g==null)return y;if(!(g instanceof Element))return g instanceof Node?c({source:E,target:g.parentElement,input:w,result:y}):y;var S=g.closest(i);if(S==null)return y;var P=o.get(S);if(P==null)return y;var T={input:w,source:E,element:P.element};if(P.canDrop&&!P.canDrop(T))return c({source:E,target:P.element.parentElement,input:w,result:y});var x=(C=(h=P.getData)===null||h===void 0?void 0:h.call(P,T))!==null&&C!==void 0?C:{},k=(b=(v=P.getDropEffect)===null||v===void 0?void 0:v.call(P,T))!==null&&b!==void 0?b:r,M={data:x,element:P.element,dropEffect:k,isActiveDueToStickiness:!1};return c({source:E,target:P.element.parentElement,input:w,result:[].concat(Ws(y),[M])})}s(c,"getActualDropTargets");function u(f){var C=f.eventName,h=f.payload,b=pd(h.location.current.dropTargets),v;try{for(b.s();!(v=b.n()).done;){var E,g=v.value,w=o.get(g.element),N=Jo(Jo({},h),{},{self:g});w==null||(E=w[C])===null||E===void 0||E.call(w,N)}}catch(y){b.e(y)}finally{b.f()}}s(u,"notifyCurrent");var p={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:s(function(C){var h=C.payload,b=new Set(h.location.current.dropTargets.map(function(L){return L.element})),v=new Set,E=pd(h.location.previous.dropTargets),g;try{for(E.s();!(g=E.n()).done;){var w,N=g.value;v.add(N.element);var y=o.get(N.element),S=b.has(N.element),P=Jo(Jo({},h),{},{self:N});if(y==null||(w=y.onDropTargetChange)===null||w===void 0||w.call(y,P),!S){var T;y==null||(T=y.onDragLeave)===null||T===void 0||T.call(y,P)}}}catch(L){E.e(L)}finally{E.f()}var x=pd(h.location.current.dropTargets),k;try{for(x.s();!(k=x.n()).done;){var M,A,R=k.value;if(!v.has(R.element)){var B=Jo(Jo({},h),{},{self:R}),F=o.get(R.element);F==null||(M=F.onDropTargetChange)===null||M===void 0||M.call(F,B),F==null||(A=F.onDragEnter)===null||A===void 0||A.call(F,B)}}}catch(L){x.e(L)}finally{x.f()}},"onDropTargetChange")};function m(f){p[f.eventName](f)}s(m,"dispatchEvent");function d(f){var C=f.source,h=f.target,b=f.input,v=f.current,E=c({source:C,target:h,input:b});if(E.length>=v.length)return E;for(var g=fd(v),w=fd(E),N=[],y=0;y<g.length;y++){var S,P=g[y],T=w[y];if(T!=null){N.push(T);continue}var x=N[y-1],k=g[y-1];if((x==null?void 0:x.element)!==(k==null?void 0:k.element))break;var M=o.get(P.element);if(!M)break;var A={input:b,source:C,element:M.element};if(M.canDrop&&!M.canDrop(A)||!((S=M.getIsSticky)!==null&&S!==void 0&&S.call(M,A)))break;N.push(Jo(Jo({},P),{},{isActiveDueToStickiness:!0}))}return fd(N)}return s(d,"getIsOver"),{dropTargetForConsumers:l,getIsOver:d,dispatchEvent:m}}s(df,"makeDropTarget");function kh(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=wh(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.
199
- 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(kh,"_createForOfIteratorHelper");function wh(e,t){if(e){if(typeof e=="string")return mf(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)?mf(e,t):void 0}}s(wh,"_unsupportedIterableToArray");function mf(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(mf,"_arrayLikeToArray");function pf(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(pf,"ownKeys");function Ph(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?pf(Object(r),!0).forEach(function(o){Mo(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pf(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(Ph,"_objectSpread");function ff(){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=Ph({},i);e.add(a),r(a);function l(){e.delete(a),t&&t.active.delete(a)}return s(l,"cleanup"),Sr(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=kh(e),u;try{for(c.s();!(u=c.n()).done;){var p=u.value;r(p)}}catch(b){c.e(b)}finally{c.f()}}if(t){for(var m=Array.from(t.active),d=0,f=m;d<f.length;d++){var C=f[d];if(t.active.has(C)){var h;(h=C[a])===null||h===void 0||h.call(C,l)}}a==="onDrop"&&(t.active.clear(),t=null)}}return s(n,"dispatchEvent"),{dispatchEvent:n,monitorForConsumers:o}}s(ff,"makeMonitor");function gf(e){var t=e.typeKey,r=e.mount,o=e.dispatchEventToSource,n=e.onPostDispatch,i=e.defaultDropEffect,a=ff(),l=df({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 d=m.event,f=m.dragType;dd.start({event:d,dragType:f,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}s(u,"start");function p(){function m(){var d={canStart:dd.canStart,start:u};return r(d)}return s(m,"mountAdapter"),lf({typeKey:t,mount:m})}return s(p,"registerUsage"),{registerUsage:p,dropTarget:l.dropTargetForConsumers,monitor:a.monitorForConsumers}}s(gf,"makeAdapter");var hf=Sr(s(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")},"isAndroid")),bf="pdnd:android-fallback";var gd="text/plain";var yf="text/uri-list";var Cf="application/vnd.pdnd";var $s=new WeakMap;function Nh(e){return $s.set(e.element,e),s(function(){$s.delete(e.element)},"cleanup")}s(Nh,"addToRegistry");var vf=Jp(),hd=gf({typeKey:"element",defaultDropEffect:"move",mount:s(function(t){return fo(vf.bindEvents(),(0,xf.bind)(document,{type:"dragstart",listener:s(function(o){var n,i,a,l,c,u;if(t.canStart(o)&&!o.defaultPrevented&&o.dataTransfer){var p=o.target;if(p instanceof HTMLElement){var m=$s.get(p);if(m){var d=Nn(o),f={element:m.element,dragHandle:(n=m.dragHandle)!==null&&n!==void 0?n:null,input:d};if(m.canDrag&&!m.canDrag(f)){o.preventDefault();return}if(m.dragHandle){var C=Us({x:d.clientX,y:d.clientY});if(!m.dragHandle.contains(C)){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,v=Object.entries(h);b<v.length;b++){var E=Hs(v[b],2),g=E[0],w=E[1];o.dataTransfer.setData(g,w!=null?w:"")}hf()&&!o.dataTransfer.types.includes(gd)&&!o.dataTransfer.types.includes(yf)&&o.dataTransfer.setData(gd,bf),o.dataTransfer.setData(Cf,"");var N={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:{}},y={type:"element",payload:N,startedFrom:"internal"};t.start({event:o,dragType:y})}}}},"listener")}))},"mount"),dispatchEventToSource:s(function(t){var r,o,n=t.eventName,i=t.payload;(r=$s.get(i.source.element))===null||r===void 0||(o=r[n])===null||o===void 0||o.call(r,i)},"dispatchEventToSource"),onPostDispatch:vf.getOnPostDispatch()}),vr=hd.dropTarget,bd=hd.monitor;function wa(e){if(0)var t;var r=fo(hd.registerUsage(),Nh(e),zs(e.element,{attribute:"draggable",value:"true"}));return Sr(r)}s(wa,"draggable");function Tf(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(Tf,"ownKeys");function Ef(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Tf(Object(r),!0).forEach(function(o){Mo(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Tf(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(Ef,"_objectSpread");var Mh={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")},kf=Symbol("closestEdge");function wf(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:Mh[m](c,l)}}),p=(r=(o=u.sort(function(m,d){return m.value-d.value})[0])===null||o===void 0?void 0:o.edge)!==null&&r!==void 0?r:null;return Ef(Ef({},e),{},Mo({},kf,p))}s(wf,"attachClosestEdge");function Pa(e){var t;return(t=e[kf])!==null&&t!==void 0?t:null}s(Pa,"extractClosestEdge");var Qg=require("@tiptap/core");var hi=require("@tiptap/core"),Ah=/^\s*>\s$/,Pf=hi.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,hi.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[(0,hi.wrappingInputRule)({find:Ah,type:this.type})]}});var e5=require("@tiptap/react");var Nf=require("uuid");function gt(e,t){let r=e.state.tr,o=!1;e.state.doc.descendants((n,i)=>{if(n.type.name===t&&!n.attrs.id){let a=`node-${(0,Nf.v4)()}`;r.setNodeMarkup(i,void 0,{...n.attrs,id:a}),o=!0}return!1}),o&&e.view.dispatch(r)}s(gt,"generateNodeIds");var Kg=require("@tiptap/react"),Gg=require("jotai"),Ne=require("react"),Yg=require("uuid");var jd=require("@tiptap/extension-color");var Mf=require("@tiptap/core"),Af=require("@tiptap/pm/dropcursor"),yd=Mf.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[(0,Af.dropCursor)(this.options)]}});var Kd=require("@tiptap/extension-hard-break");var If=require("@tiptap/core"),bi=require("@tiptap/pm/history"),Ih=If.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>(0,bi.undo)(e,t),redo:()=>({state:e,dispatch:t})=>(0,bi.redo)(e,t)}},addProseMirrorPlugins(){return[(0,bi.history)(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Gd=require("@tiptap/extension-placeholder"),Yd=require("@tiptap/extension-text-align"),Xd=require("@tiptap/extension-typography"),Qd=require("@tiptap/extension-underline"),em=require("@tiptap/starter-kit");var p1=require("@hookform/resolvers/zod"),f1=require("react-hook-form");var Mn=require("react");var kt=s(({editor:e,element:t,form:r,nodeType:o})=>{let n=(0,Mn.useRef)(null),i=(0,Mn.useRef)(null);return(0,Mn.useEffect)(()=>{if(!e||!t)return;let l=s(()=>{let c=null;if(e.state.doc.descendants((u,p)=>u.attrs.id===t.attrs.id?(c=p,!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(([p,m])=>{r.getValues(p)!==m&&r.setValue(p,m)}))}},"updateCurrentNode");return l(),e.on("update",l),()=>{e.off("update",l)}},[e,t,r,o]),{updateNodeAttributes:(0,Mn.useCallback)(l=>{if(!e||i.current===null)return;let c=e.state.doc.nodeAt(i.current);if(!c||c.type.name!==o)return;let u={...c.attrs,...l,id:c.attrs.id};JSON.stringify(c.attrs)!==JSON.stringify(u)&&e.chain().command(({tr:m,dispatch:d})=>{let f=m.doc.nodeAt(i.current);return(f==null?void 0:f.type.name)===o&&d?(m.setNodeMarkup(i.current,f.type,u),m.setMeta("addToHistory",!0),!0):!1}).run()},[e,o])}},"useNodeAttributes");var An=require("jotai"),yi=require("react");var Na=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,...Na(n,i)]:[...r,i]},[]),"getFlattenedVariables");var Sh={link:["href","content"],img:["src","href","alt_text"],image:["src","href","alt_text"],action:["href","content"],meta:["title"],list:["imgSrc","imgHref"],quote:["content"],html:[]},Rh=["content","href","src","title"],Sf=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&&Tt(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=Sh[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 p=u;Rh.forEach(m=>{typeof p[m]=="string"&&o(p[m])}),p.elements&&Array.isArray(p.elements)&&p.elements.forEach(m=>{m&&n(m)}),p.raw&&typeof p.raw=="object"&&p.raw!==null&&Object.values(p.raw).forEach(m=>{typeof m=="string"&&o(m)})}})},"processNode");return e.forEach(i=>n(i)),Array.from(t).sort()},"extractVariablesFromContent");var Lh=s(e=>{let t=(0,An.useAtomValue)(Ie),r=(0,An.useAtomValue)(te),o=(0,An.useAtomValue)(Zo),n=(0,An.useAtomValue)(hn),i=(0,An.useSetAtom)(hn),a=e!=null?e:o,l=(0,yi.useMemo)(()=>{var d,f;if(!t)return[];let m=((f=(d=t.extensionManager.extensions.find(C=>C.name==="variableSuggestion"))==null?void 0:d.options)==null?void 0:f.variables)||{};return Na(m)},[t]),c=(0,yi.useMemo)(()=>{if(!r||!a)return[];let m=r.elements.find(d=>d.type==="channel"&&d.channel===a);return m?Sf(m.elements||[]):[]},[r,a]),u=(0,yi.useCallback)((m,d)=>{i(f=>({...f,[m]:d}))},[i]),p=(0,yi.useCallback)(()=>{i({})},[i]);return{availableVariables:l,usedVariables:c,variableValues:n,addVariableValue:u,clearAllVariableValues:p}},"useVariables");var Sn=require("jotai"),qr=require("react");var d1=require("uuid");var Zs=require("@tiptap/core"),Hf=require("@tiptap/react");var Rf=require("@tiptap/react"),Lf=require("jotai"),Bf=require("react");var In=require("react/jsx-runtime"),Bh=s(({alignment:e,backgroundColor:t,textColor:r,borderRadius:o,padding:n,fontWeight:i,fontStyle:a,children:l})=>(0,In.jsx)("div",{className:"courier-w-full node-element",children:(0,In.jsx)("div",{className:"courier-flex",children:(0,In.jsx)("div",{className:I("courier-inline-flex courier-justify-center courier-cursor-text courier-text-sm courier-leading-tight !courier-my-1",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[e]),style:{backgroundColor:t,color:r,borderRadius:`${o}px`,caretColor:r,fontWeight:i,fontStyle:a,padding:`${Number(n)+2}px ${Number(n)+10}px`},children:l})})}),"ButtonComponent"),Df=s(e=>{let t=(0,Lf.useSetAtom)(Qe),r=(0,Bf.useCallback)(()=>{if(!e.editor.isEditable)return;let o=ht(e);if(o){let n=o.attrs.id;e.editor.state.doc.descendants(i=>i.type.name==="button"&&i.attrs.id===n?(t(i),!1):!0)}},[e,t]);return(0,In.jsx)(Ht,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,"data-node-type":"button",children:(0,In.jsx)(Bh,{...e.node.attrs,children:(0,In.jsx)(Rf.NodeViewContent,{as:"span"})})})},"ButtonComponentNode");var Vf=require("uuid");var je={label:"Button",link:"",alignment:"center",backgroundColor:"#0085FF",borderRadius:0,padding:6,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1,textColor:"#ffffff",borderColor:"transparent"},qs=Zs.Node.create({name:"button",group:"block",content:"inline*",selectable:!1,isolating:!0,onCreate(){gt(this.editor,this.name)},addAttributes(){return{label:{default:je.label,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},link:{default:je.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alignment:{default:je.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},backgroundColor:{default:je.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},textColor:{default:je.textColor,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.textColor})},borderRadius:{default:je.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:je.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},padding:{default:je.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.padding})},fontWeight:{default:je.fontWeight,parseHTML:e=>e.getAttribute("data-font-weight"),renderHTML:e=>({"data-font-weight":e.fontWeight})},fontStyle:{default:je.fontStyle,parseHTML:e=>e.getAttribute("data-font-style"),renderHTML:e=>({"data-font-style":e.fontStyle})},isUnderline:{default:je.isUnderline,parseHTML:e=>e.getAttribute("data-is-underline"),renderHTML:e=>({"data-is-underline":e.isUnderline})},isStrike:{default:je.isStrike,parseHTML:e=>e.getAttribute("data-is-strike"),renderHTML:e=>({"data-is-strike":e.isStrike})},id:{default:()=>`node-${(0,Vf.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="button"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Zs.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return(0,Hf.ReactNodeViewRenderer)(Df)},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{let{$from:t}=e.state.selection;for(let r=t.depth;r>=0;r--)if(t.node(r).type.name==="button"){let n=t.start(r),i=t.end(r);return e.commands.setTextSelection({from:n,to:i}),!0}return!1}}},addCommands(){return{setButton:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e,content:[{type:"text",text:e.label||"Button"}]}).run()}}});var js=require("@tiptap/core"),Uf=require("@tiptap/react"),Wf=require("uuid");var Ff=require("@tiptap/react"),Js=require("jotai"),xr=require("react");var Zr=require("react/jsx-runtime"),Dh=s(({columnId:e,index:t,isPreviewMode:r})=>{let o=(0,xr.useRef)(null),[n,i]=(0,xr.useState)(!1);return(0,xr.useEffect)(()=>{let a=o.current;if(a)return vr({element:a,getData:()=>({type:"column-cell",columnId:e,index:t,isEmpty:!0}),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e,t]),(0,Zr.jsx)("div",{ref:o,"data-placeholder-cell":"true","data-column-cell":"true","data-column-id":e,"data-cell-index":t,onClick:a=>{a.stopPropagation()},className:I("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4",!r&&"courier-border",!r&&(n?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),!r&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:!r&&(0,Zr.jsx)("span",{className:"courier-pointer-events-none",children:"Drag and drop content blocks"})})},"PlaceholderCell"),Hh=s(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderWidth:o,borderRadius:n,borderColor:i,node:a,columnsCount:l,isPreviewMode:c=!1})=>{var d;let u=!a.content||a.content.size===0,p={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=((d=a.attrs)==null?void 0:d.id)||"";return(0,Zr.jsx)("div",{className:"courier-w-full node-element",style:m,children:(0,Zr.jsx)("div",{className:"courier-w-full courier-flex courier-gap-2 courier-p-2",style:p,children:Array.from({length:l}).map((C,h)=>(0,Zr.jsx)(Dh,{columnId:f,index:h,isPreviewMode:c},h))})})}return(0,Zr.jsx)("div",{className:"courier-w-full node-element",style:m,children:(0,Zr.jsx)("div",{className:"courier-w-full courier-p-2",style:p,children:(0,Zr.jsx)(Ff.NodeViewContent,{})})})},"ColumnComponent"),Of=s(e=>{let t=(0,Js.useSetAtom)(Qe),r=(0,Js.useAtomValue)(Xt),[o,n]=(0,xr.useState)(!1),[i,a]=(0,xr.useState)(e.editor.isEditable);(0,xr.useEffect)(()=>{let m=s(()=>{a(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",m),e.editor.on("transaction",m),e.editor.on("selectionUpdate",m),()=>{e.editor.off("update",m),e.editor.off("transaction",m),e.editor.off("selectionUpdate",m)}},[e.editor]);let l=!i&&!r,c=(0,xr.useCallback)(m=>{var N,y;if(!e.editor.isEditable)return;let d=m.target,f=m.currentTarget,C=d===f,h=d.classList.contains("node-element"),b=d.classList.contains("courier-p-2"),v=d.classList.contains("courier-gap-2"),E=d.classList.contains("draggable-item"),g=d.hasAttribute("data-drag-handle")||d.closest("[data-drag-handle]")!==null;if(C||h||b||v||E||g||((y=(N=d.closest("[data-node-view-content]"))==null?void 0:N.parentElement)==null?void 0:y.classList.contains("node-element"))){m.stopPropagation(),g||m.preventDefault();let S=ht(e);if(S){e.editor.commands.blur();let P=S.attrs.id;e.editor.state.doc.descendants(T=>T.type.name==="column"&&T.attrs.id===P?(t(T),!1):!0)}}},[e,t]),u=(0,xr.useCallback)(m=>{let d=m.target,f=m.currentTarget;if(!(d.closest("[data-column-cell]")!==null)){n(!0);return}let h=f.getBoundingClientRect(),b=m.clientY,v=30,E=b<=h.top+v||b>=h.bottom-v;n(E)},[]),p=(0,xr.useCallback)(()=>{n(!1)},[]);return(0,Zr.jsx)(Ht,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element",o&&"hover-edge-zone"),onMouseDown:c,onMouseMove:u,onMouseLeave:p,editor:e.editor,getPos:e.getPos,"data-node-type":"column",children:(0,Zr.jsx)(Hh,{...e.node.attrs,node:e.node,columnsCount:e.node.attrs.columnsCount||2,isPreviewMode:l})})},"ColumnComponentNode");var wt={columnsCount:2,paddingHorizontal:0,paddingVertical:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"transparent",cells:[]},Ks=js.Node.create({name:"column",group:"block",content:"columnRow?",isolating:!0,selectable:!1,onCreate(){gt(this.editor,this.name)},addAttributes(){return{columnsCount:{default:wt.columnsCount,parseHTML:e=>e.getAttribute("data-columns-count"),renderHTML:e=>({"data-columns-count":e.columnsCount})},paddingHorizontal:{default:wt.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:wt.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:wt.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:wt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:wt.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:wt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:()=>`node-${(0,Wf.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})},cells:{default:[],parseHTML:e=>{let t=e.getAttribute("data-cells");return t?JSON.parse(t):[]},renderHTML:e=>({"data-cells":JSON.stringify(e.cells||[])})}}},parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,js.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"column"}),0]},addNodeView(){return(0,Uf.ReactNodeViewRenderer)(Of)},addCommands(){return{setColumn:e=>({chain:t})=>{let r=e.columnsCount||wt.columnsCount,o=`node-${Date.now()}`,n=Array.from({length:r},(i,a)=>({type:"columnCell",attrs:{index:a,columnId:o},content:[{type:"paragraph"}]}));return t().insertContent({type:this.name,attrs:{...e,id:o},content:[{type:"columnRow",content:n}]}).run()}}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"}}}});var Gs=require("@tiptap/core"),Zf=require("@tiptap/react"),qf=require("uuid");var _f=require("jotai"),zf=require("react");var Ma=require("react/jsx-runtime"),Vh=s(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return(0,Ma.jsx)("div",{className:"courier-w-full node-element",children:(0,Ma.jsx)("div",{className:"courier-custom-code courier-py-1.5",dangerouslySetInnerHTML:t?{__html:e}:{__html:"&#160;"}})})},"CustomCodeComponent"),$f=s(e=>{let t=(0,_f.useSetAtom)(Qe),r=(0,zf.useCallback)(()=>{if(!e.editor.isEditable)return;let i=ht(e);if(i){e.editor.commands.blur();let a=i.attrs.id;e.editor.state.doc.descendants(l=>l.type.name==="customCode"&&l.attrs.id===a?(t(l),!1):!0)}},[e,t]),o=e.node.attrs.code,n=!o||o.trim()===""||o==="<!-- Add your HTML code here -->";return(0,Ma.jsx)(Ht,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element",n&&"is-empty"),onClick:r,editor:e.editor,"data-node-type":"customCode",children:(0,Ma.jsx)(Vh,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var Ao={code:"<!-- Add your HTML code here -->"},Ys=Gs.Node.create({name:"customCode",group:"block",atom:!0,selectable:!1,onCreate(){gt(this.editor,this.name)},addAttributes(){return{code:{default:Ao.code,parseHTML:e=>e.getAttribute("data-code")||"",renderHTML:e=>({"data-code":e.code})},id:{default:()=>`node-${(0,qf.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="custom-code"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Gs.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"custom-code"}),["div",{innerHTML:e.code||Ao.code}]]},addNodeView(){return(0,Zf.ReactNodeViewRenderer)($f)},addCommands(){return{setCustomCode:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e}).run()}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"}}}});var Yf=require("@tiptap/core");var jo=require("@tiptap/core"),Ci=require("@tiptap/pm/state"),Jf=jo.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",(0,jo.mergeAttributes)(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{let{selection:r}=t,{$from:o,$to:n}=r,i=e();return o.parentOffset===0?i.insertContentAt({from:Math.max(o.pos-1,0),to:n.pos},{type:this.name}):(0,jo.isNodeSelection)(r)?i.insertContentAt(n.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:a,dispatch:l})=>{var c;if(l){let{$to:u}=a.selection,p=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?a.setSelection(Ci.TextSelection.create(a.doc,u.pos+1)):u.nodeAfter.isBlock?a.setSelection(Ci.NodeSelection.create(a.doc,u.pos)):a.setSelection(Ci.TextSelection.create(a.doc,u.pos));else{let m=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();m&&(a.insert(p,m),a.setSelection(Ci.TextSelection.create(a.doc,p+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(0,jo.nodeInputRule)({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Xf=require("@tiptap/react"),Qf=require("uuid");var jf=require("jotai"),Kf=require("react");var Aa=require("react/jsx-runtime"),Fh=s(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>(0,Aa.jsx)("div",{className:"courier-w-full node-element courier-flex",children:(0,Aa.jsx)("hr",{style:{marginTop:`${e}px`,marginBottom:`${e}px`,backgroundColor:n==="spacer"?"transparent":t,height:`${r}px`,borderRadius:`${o}px`,border:"none",width:"100%"},"data-variant":n})}),"DividerComponent"),Gf=s(e=>{let t=(0,jf.useSetAtom)(Qe),r=(0,Kf.useCallback)(()=>{if(!e.editor.isEditable)return;let o=ht(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return(0,Aa.jsx)(Ht,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:(0,Aa.jsx)(Fh,{...e.node.attrs})})},"DividerComponentNode");var Tr={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},vi={padding:24,color:"transparent",size:1,radius:0,variant:"spacer"},Cd=Jf.extend({name:"divider",atom:!0,onCreate(){gt(this.editor,this.name)},addAttributes(){return{padding:{default:Tr.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.margin})},size:{default:Tr.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},color:{default:Tr.color,parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color})},width:{default:Tr.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},radius:{default:Tr.radius,parseHTML:e=>e.getAttribute("data-radius"),renderHTML:e=>({"data-radius":e.radius})},variant:{default:Tr.variant,parseHTML:e=>e.getAttribute("data-variant"),renderHTML:e=>({"data-variant":e.variant})},id:{default:()=>`node-${(0,Qf.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})}}},parseHTML(){return[{tag:'div[data-type="divider"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Yf.mergeAttributes)(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return(0,Xf.ReactNodeViewRenderer)(Gf)},addInputRules(){return[]}});var Xs=require("@tiptap/core"),t1=require("@tiptap/react");var vd=require("jotai"),Oe=require("react");var Pt=require("react/jsx-runtime"),Oh=["image/png","image/jpeg","image/gif","image/webp"],Uh=s(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderColor:n,isUploading:i,width:a,imageNaturalWidth:l,onFileSelect:c,editor:u})=>{let[p,m]=(0,Oe.useState)(!1),[d,f]=(0,Oe.useState)(!0),C=(0,Oe.useRef)(null),h=(0,Oe.useRef)(null);(0,Oe.useEffect)(()=>{e&&f(!0)},[e]),(0,Oe.useEffect)(()=>{if(e&&!l&&u){let T=new Image;T.onload=()=>{try{if(!u.view||!u.state)return;let x=u.view.state.selection.from;u.chain().setNodeSelection(x).updateAttributes("imageBlock",{imageNaturalWidth:T.naturalWidth}).run()}catch{}},T.src=e}},[e,l,u]);let b=(0,Oe.useCallback)(T=>{var A,R;let x=(R=(A=u==null?void 0:u.view)==null?void 0:A.dom)==null?void 0:R.closest(".ProseMirror"),k=(x==null?void 0:x.clientWidth)||1e3,M=Math.min(100,T/k*100);return Math.round(M)},[u]),v=(0,Oe.useMemo)(()=>b(l),[b,l]),E=(0,Oe.useCallback)(T=>Oh.includes(T),[]),g=(0,Oe.useCallback)(T=>{T.preventDefault(),T.stopPropagation(),T.dataTransfer.types.includes("Files")&&Array.from(T.dataTransfer.items).some(M=>E(M.type))&&(m(!0),T.dataTransfer.dropEffect="copy")},[E]),w=(0,Oe.useCallback)(T=>{T.preventDefault(),T.stopPropagation(),m(!1)},[]),N=(0,Oe.useCallback)(T=>{T.preventDefault(),T.stopPropagation(),T.dataTransfer.types.includes("Files")&&Array.from(T.dataTransfer.items).some(M=>E(M.type))&&m(!0)},[E]),y=(0,Oe.useCallback)(T=>{T.preventDefault(),T.stopPropagation(),m(!1);let k=Array.from(T.dataTransfer.files).find(M=>E(M.type));k&&c&&c(k)},[c,E]),S=(0,Oe.useCallback)(T=>{var k;let x=(k=T.target.files)==null?void 0:k[0];x&&c&&c(x),T.target&&(T.target.value="")},[c]),P=(0,Oe.useCallback)(()=>{var T;(T=C.current)==null||T.click()},[]);return fs(e)?(0,Pt.jsxs)("div",{className:I("courier-w-full node-element courier-empty-image courier-h-[160px] courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-justify-center courier-cursor-pointer courier-transition-colors courier-flex-1 courier-text-center courier-flex-wrap courier-content-center courier-p-4",p&&"courier-border-primary courier-bg-gray-50"),onDragOver:g,onDragEnter:N,onDragLeave:w,onDrop:y,style:{pointerEvents:"all"},children:[i?(0,Pt.jsx)(Tn,{className:"courier-w-8 courier-h-8"}):(0,Pt.jsxs)(Pt.Fragment,{children:[(0,Pt.jsx)("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),(0,Pt.jsx)("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:P,children:"Browse"})]}),(0,Pt.jsx)("input",{ref:C,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:S})]}):(0,Pt.jsx)("div",{className:"courier-w-full node-element",children:(0,Pt.jsxs)("div",{className:I("courier-relative courier-p-1",(i||d)&&"courier-w-full courier-aspect-[4/3] courier-bg-gray-100"),children:[(i||d)&&(0,Pt.jsx)("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:(0,Pt.jsx)(Tn,{className:"courier-w-8 courier-h-8"})}),(0,Pt.jsx)("img",{ref:h,src:e,alt:t,className:I("courier-h-auto courier-inline-block courier-w-full",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[r],i&&"courier-opacity-50",(i||d)&&"courier-invisible"),style:{maxWidth:a===v?`${l}px`:`${a}%`,borderWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",display:"block"},loading:"lazy",decoding:"async",draggable:!1,onLoad:T=>{if(f(!1),!l&&u)try{if(!u.view||!u.state)return;setTimeout(()=>{let x=u.view.state.selection.from;u.chain().setNodeSelection(x).updateAttributes("imageBlock",{imageNaturalWidth:T.target.naturalWidth}).run()},100)}catch(x){console.warn("Editor not ready for image update:",x)}},onError:()=>f(!1)})]})})},"ImageBlockComponent"),Wh=["image/png","image/jpeg","image/gif","image/webp"],e1=s(e=>{let t=(0,vd.useSetAtom)(Qe),r=(0,vd.useSetAtom)(G),{uploadImage:o}=Qn(),n=(0,Oe.useCallback)(l=>{var m,d,f;let c=(f=(d=(m=e.editor)==null?void 0:m.view)==null?void 0:d.dom)==null?void 0:f.closest(".ProseMirror"),u=(c==null?void 0:c.clientWidth)||1e3,p=Math.min(100,l/u*100);return Math.round(p)},[e.editor]);(0,Oe.useEffect)(()=>{var c,u;let l=ht(e);if((c=l==null?void 0:l.attrs)!=null&&c.sourcePath&&!((u=l==null?void 0:l.attrs)!=null&&u.imageNaturalWidth)){let p=new Image;p.onload=()=>{let m=l.attrs.width||n(p.naturalWidth),d=Ko(e.getPos);d!==null&&e.editor.chain().focus().setNodeSelection(d).updateAttributes("imageBlock",{width:m,imageNaturalWidth:p.naturalWidth}).run()},p.src=l.attrs.sourcePath}},[e,n]);let i=(0,Oe.useCallback)(()=>{if(!e.editor.isEditable)return;let l=ht(e);l&&(e.editor.commands.blur(),t(l))},[e,t]),a=(0,Oe.useCallback)(async l=>{let c=Ko(e.getPos);ht(e)&&c!==null&&e.editor.chain().focus().setNodeSelection(c).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!Wh.includes(l.type))throw new Error("Only PNG, JPEG, GIF, and WebP images are supported");let p=new FileReader;p.readAsDataURL(l),await new Promise((h,b)=>{p.onload=h,p.onerror=b});let d=(await o({file:l})).url,f=Ko(e.getPos);if(ht(e)&&f!==null){let h=new Image;h.src=d,await new Promise((v,E)=>{h.onload=v,h.onerror=()=>E(new Error("Failed to load uploaded image"))});let b=n(h.naturalWidth);e.editor.chain().focus().setNodeSelection(f).updateAttributes("imageBlock",{sourcePath:d,isUploading:!1,width:b,imageNaturalWidth:h.naturalWidth}).run()}}catch(p){console.error("Error uploading image:",p);let m="Error uploading image";if(p instanceof Error){let C=p.message;C.includes("GraphQL error")?m="Server error: Could not process image":C.includes("network")||C.includes("fetch")?m="Network error: Could not upload image":m=C}r({message:m,toastProps:{duration:6e3,description:`File: ${l.name} (${(l.size/1024/1024).toFixed(2)}MB)`}});let d=Ko(e.getPos);ht(e)&&d!==null&&e.editor.chain().focus().setNodeSelection(d).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return(0,Pt.jsx)(Ht,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:(0,Pt.jsx)(Uh,{...e.node.attrs,onFileSelect:a,editor:e.editor})})},"ImageBlockView");var lt={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderColor:"transparent",isUploading:!1,imageNaturalWidth:0},Qs=Xs.Node.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){gt(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:lt.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:lt.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:lt.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:lt.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:lt.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:lt.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:lt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:lt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:lt.isUploading,parseHTML:e=>e.getAttribute("data-is-uploading"),renderHTML:e=>({"data-is-uploading":e.isUploading})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="image-block"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Xs.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return(0,t1.ReactNodeViewRenderer)(e1)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...lt,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...lt,sourcePath:t||""}}).run(),setImageBlockAlign:e=>({commands:t})=>t.updateAttributes(this.name,{alignment:e}),setImageBlockWidth:e=>({commands:t})=>t.updateAttributes(this.name,{width:e}),uploadImage:e=>({chain:t})=>{let r=new FileReader;return r.onload=()=>{t().setImageBlock({sourcePath:r.result,isUploading:!0}).run()},r.readAsDataURL(e),!0}}}});var go=require("zod"),r1=go.z.object({paddingVertical:go.z.number(),paddingHorizontal:go.z.number(),backgroundColor:go.z.string(),borderWidth:go.z.number(),borderColor:go.z.string(),textAlign:go.z.enum(["left","center","right","justify"]).default("left"),selected:go.z.boolean().default(!1),id:go.z.string().optional()}),pe={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderColor:"transparent",textAlign:"left",selected:!1};var el=require("@tiptap/react");var tl=require("jotai"),n1=require("react");var Io=require("react/jsx-runtime"),o1=s(({paddingVertical:e,paddingHorizontal:t,textAlign:r,backgroundColor:o,borderWidth:n,borderColor:i,level:a,type:l})=>{let c=l==="heading"?`h${a}`:"p",u=(0,tl.useAtomValue)(Xt);return(0,Io.jsx)("div",{className:"courier-w-full node-element",children:(0,Io.jsx)("div",{style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderColor:i,borderStyle:n>0?"solid":"none"},children:(0,Io.jsx)("div",{style:{pointerEvents:u?"none":"auto"},children:(0,Io.jsx)(el.NodeViewContent,{as:c})})})})},"TextBlockComponent"),rl=s(e=>{let t=(0,tl.useSetAtom)(Qe),r=(0,n1.useCallback)(()=>{if(!e.editor.isEditable)return;let l=ht(e);l&&t(l)},[e,t]),o=!e.node.content||e.node.content.size===0,n=Ko(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null;return(i==null?void 0:i.parent.type.name)==="blockquote"?(0,Io.jsx)(el.NodeViewWrapper,{children:(0,Io.jsx)(o1,{...e.node.attrs,type:e.node.type.name})}):(0,Io.jsx)(Ht,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:(0,Io.jsx)(o1,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");var l1=require("@hookform/resolvers/zod"),c1=require("react-hook-form");var s1=require("jotai");var Ia=require("react/jsx-runtime"),et=s(({draggable:e=!1,icon:t,draggableLabel:r,label:o})=>(0,Ia.jsxs)("div",{className:"courier-flex courier-flex-row courier-items-center courier-gap-2",children:[(0,Ia.jsx)("div",{className:I("courier-w-8 courier-h-8 courier-rounded-md courier-flex courier-items-center courier-justify-center",e?"courier-cursor-grab courier-bg-secondary":"courier-border courier-border-border"),children:t}),(0,Ia.jsx)("span",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:e?r:o})]}),"BlockBase");var i1=require("lucide-react");var xd=require("react/jsx-runtime"),ol=s(({draggable:e=!1})=>(0,xd.jsx)(et,{draggable:e,icon:(0,xd.jsx)(i1.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),draggableLabel:"Blockquote",label:"Blockquote block"}),"BlockquoteBlock");var Sa=require("react/jsx-runtime"),Td=s(()=>(0,Sa.jsx)("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Sa.jsx)("path",{d:"M18 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V10C1.5 10.2812 1.71875 10.5 2 10.5H18C18.25 10.5 18.5 10.2812 18.5 10V2C18.5 1.75 18.25 1.5 18 1.5ZM2 0H18C19.0938 0 20 0.90625 20 2V10C20 11.125 19.0938 12 18 12H2C0.875 12 0 11.125 0 10V2C0 0.90625 0.875 0 2 0Z",fill:"currentColor"})}),"ButtonBlockIcon"),Go=s(({draggable:e=!1})=>(0,Sa.jsx)(et,{draggable:e,icon:(0,Sa.jsx)(Td,{}),draggableLabel:"Button",label:"Button block"}),"ButtonBlock");var Ra=require("react/jsx-runtime"),Ed=s(()=>(0,Ra.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ra.jsx)("path",{d:"M14 1.5V12.5H18C18.25 12.5 18.5 12.2812 18.5 12V2C18.5 1.75 18.25 1.5 18 1.5H14ZM12.5 1.5H7.5V12.5H12.5V1.5ZM6 12.5V1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12C1.5 12.2812 1.71875 12.5 2 12.5H6ZM0 2C0 0.90625 0.875 0 2 0H18C19.0938 0 20 0.90625 20 2V12C20 13.125 19.0938 14 18 14H2C0.875 14 0 13.125 0 12V2Z",fill:"currentColor"})}),"ColumnBlockIcon"),nl=s(({draggable:e=!1})=>(0,Ra.jsx)(et,{draggable:e,icon:(0,Ra.jsx)(Ed,{}),draggableLabel:"Column layout",label:"Column layout"}),"ColumnBlock");var La=require("react/jsx-runtime"),kd=s(()=>(0,La.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,La.jsx)("path",{d:"M6.5 3.5L3 7L6.5 10.5M13.5 3.5L17 7L13.5 10.5M11.5 1L8.5 13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"CustomCodeBlockIcon"),il=s(({draggable:e=!1})=>(0,La.jsx)(et,{draggable:e,icon:(0,La.jsx)(kd,{}),draggableLabel:"Custom code",label:"Custom code"}),"CustomCodeBlock");var Ba=require("react/jsx-runtime"),wd=s(()=>(0,Ba.jsx)("svg",{width:"16",height:"2",viewBox:"0 0 16 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ba.jsx)("path",{d:"M0 1C0 0.59375 0.3125 0.25 0.75 0.25H15.25C15.6562 0.25 16 0.59375 16 1C16 1.4375 15.6562 1.75 15.25 1.75H0.75C0.3125 1.75 0 1.4375 0 1Z",fill:"currentColor"})}),"DividerBlockIcon"),Yo=s(({draggable:e=!1})=>(0,Ba.jsx)(et,{draggable:e,icon:(0,Ba.jsx)(wd,{}),draggableLabel:"Divider",label:"Divider block"}),"DividerBlock");var Da=require("react/jsx-runtime"),Pd=s(()=>(0,Da.jsx)("svg",{width:"18",height:"13",viewBox:"0 0 18 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Da.jsx)("path",{d:"M1.5 1.75V6H8.5V1.75C8.5 1.34375 8.8125 1 9.25 1C9.65625 1 10 1.34375 10 1.75V6.75V12.25C10 12.6875 9.65625 13 9.25 13C8.8125 13 8.5 12.6875 8.5 12.25V7.5H1.5V12.25C1.5 12.6875 1.15625 13 0.75 13C0.3125 13 0 12.6875 0 12.25V6.75V1.75C0 1.34375 0.3125 1 0.75 1C1.15625 1 1.5 1.34375 1.5 1.75ZM15.75 1.75V11.5H17.25C17.6562 11.5 18 11.8438 18 12.25C18 12.6875 17.6562 13 17.25 13H15H12.75C12.3125 13 12 12.6875 12 12.25C12 11.8438 12.3125 11.5 12.75 11.5H14.25V3.03125L13.0938 3.65625C12.75 3.875 12.2812 3.75 12.0938 3.375C11.875 3 12 2.5625 12.375 2.34375L14.625 1.09375C14.8438 0.96875 15.125 0.96875 15.375 1.125C15.5938 1.25 15.75 1.5 15.75 1.75Z",fill:"currentColor"})}),"HeadingBlockIcon"),al=s(({draggable:e=!1})=>(0,Da.jsx)(et,{draggable:e,icon:(0,Da.jsx)(Pd,{}),draggableLabel:"Heading",label:"Heading block"}),"HeadingBlock");var Ha=require("react/jsx-runtime"),Nd=s(()=>(0,Ha.jsx)("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ha.jsx)("path",{d:"M14 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12V12.0312L1.625 11.8438L4.125 8.34375C4.28125 8.125 4.5 8 4.75 8C4.96875 8 5.21875 8.125 5.34375 8.3125L6.3125 9.65625L8.90625 6.3125C9.03125 6.125 9.25 6 9.5 6C9.71875 6 9.9375 6.125 10.0938 6.3125L14.3438 11.8125L14.5 12V2C14.5 1.75 14.25 1.5 14 1.5ZM2 0H14C15.0938 0 16 0.90625 16 2V12C16 13.125 15.0938 14 14 14H2C0.875 14 0 13.125 0 12V2C0 0.90625 0.875 0 2 0ZM4.5 6C3.9375 6 3.46875 5.71875 3.1875 5.25C2.90625 4.8125 2.90625 4.21875 3.1875 3.75C3.46875 3.3125 3.9375 3 4.5 3C5.03125 3 5.5 3.3125 5.78125 3.75C6.0625 4.21875 6.0625 4.8125 5.78125 5.25C5.5 5.71875 5.03125 6 4.5 6Z",fill:"currentColor"})}),"ImageBlockIcon"),sl=s(({draggable:e=!1})=>(0,Ha.jsx)(et,{draggable:e,icon:(0,Ha.jsx)(Nd,{}),draggableLabel:"Image",label:"Image block"}),"ImageBlock");var a1=require("lucide-react");var Md=require("react/jsx-runtime"),ll=s(({draggable:e=!1})=>(0,Md.jsx)(et,{draggable:e,icon:(0,Md.jsx)(a1.AlignVerticalSpaceAround,{className:"courier-w-4 courier-h-4"}),draggableLabel:"Spacer",label:"Spacer block"}),"SpacerBlock");var Va=require("react/jsx-runtime"),Ad=s(()=>(0,Va.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Va.jsx)("path",{d:"M1.5 1.5V3C1.5 3.4375 1.15625 3.75 0.75 3.75C0.3125 3.75 0 3.4375 0 3V1.25C0 0.5625 0.53125 0 1.25 0H12.75C13.4375 0 14 0.5625 14 1.25V3C14 3.4375 13.6562 3.75 13.25 3.75C12.8125 3.75 12.5 3.4375 12.5 3V1.5H7.75V12.5H9.25C9.65625 12.5 10 12.8438 10 13.25C10 13.6875 9.65625 14 9.25 14H4.75C4.3125 14 4 13.6875 4 13.25C4 12.8438 4.3125 12.5 4.75 12.5H6.25V1.5H1.5Z",fill:"currentColor"})}),"TextBlockIcon"),Xo=s(({draggable:e=!1})=>(0,Va.jsx)(et,{draggable:e,icon:(0,Va.jsx)(Ad,{}),draggableLabel:"Text",label:"Text block"}),"TextBlock");var or=require("react/jsx-runtime"),Vt=s(({type:e})=>{let t=(0,s1.useSetAtom)(Qe);return(0,or.jsxs)("div",{className:"courier-flex courier-gap-4 courier-flex-col",children:[(0,or.jsx)(Se,{className:"courier-w-fit",variant:"secondary",buttonSize:"small",onClick:()=>{t(null)},children:"Close"}),e==="heading"&&(0,or.jsx)(al,{}),e==="text"&&(0,or.jsx)(Xo,{}),e==="image"&&(0,or.jsx)(sl,{}),e==="spacer"&&(0,or.jsx)(ll,{}),e==="divider"&&(0,or.jsx)(Yo,{}),e==="button"&&(0,or.jsx)(Go,{}),e==="blockquote"&&(0,or.jsx)(ol,{}),e==="customCode"&&(0,or.jsx)(il,{}),e==="column"&&(0,or.jsx)(nl,{}),(0,or.jsx)(ce,{className:"courier-m-0"})]})},"FormHeader");var ue=require("react/jsx-runtime"),u1=s(({element:e,editor:t})=>{let r=(0,c1.useForm)({resolver:(0,l1.zodResolver)(r1),defaultValues:{...pe,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=kt({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?(0,ue.jsxs)(qe,{...r,children:[(0,ue.jsx)(Vt,{type:"text"}),(0,ue.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,ue.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,ue.jsx)(j,{control:r.control,name:"paddingHorizontal",render:({field:n})=>(0,ue.jsxs)(q,{children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(be,{startAdornment:(0,ue.jsx)(pa,{}),type:"number",min:0,...n})}),(0,ue.jsx)(K,{})]})}),(0,ue.jsx)(j,{control:r.control,name:"paddingVertical",render:({field:n})=>(0,ue.jsxs)(q,{children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(be,{startAdornment:(0,ue.jsx)(vn,{}),type:"number",min:0,...n})}),(0,ue.jsx)(K,{})]})})]}),(0,ue.jsx)(j,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,ue.jsxs)(q,{className:"courier-mb-4",children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(Et,{...n,defaultValue:pe.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ue.jsx)(K,{})]})}),(0,ue.jsx)(ce,{className:"courier-mb-4"}),(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,ue.jsx)(j,{control:r.control,name:"borderWidth",render:({field:n})=>(0,ue.jsxs)(q,{className:"courier-mb-3",children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(be,{startAdornment:(0,ue.jsx)(No,{}),type:"number",min:0,...n})}),(0,ue.jsx)(K,{})]})}),(0,ue.jsx)(j,{control:r.control,name:"borderColor",render:({field:n})=>(0,ue.jsxs)(q,{className:"courier-mb-4",children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(Et,{...n,defaultValue:pe.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ue.jsx)(K,{})]})})]})]}):null},"TextBlockForm");var _h=s((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),cl=s((e,t,r,o,n,i)=>{let a=`node-${(0,d1.v4)()}`,c={heading:()=>e.schema.nodes.heading.create({...pe,...o,id:a},i),paragraph:()=>e.schema.nodes.paragraph.create({...pe,...o,id:a},i),text:()=>e.schema.nodes.paragraph.create({...pe,...o,id:a},i),spacer:()=>e.schema.nodes.divider.create({...vi,...o,id:a}),divider:()=>e.schema.nodes.divider.create({...Tr,...o,id:a}),button:()=>e.schema.nodes.button.create({...je,...o,id:a},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...lt,...o,id:a}),image:()=>e.schema.nodes.imageBlock.create({...lt,...o,id:a}),customCode:()=>e.schema.nodes.customCode.create({...Ao,...o,id:a}),column:()=>e.schema.nodes.column.create({...wt,...o,id:a})}[t];if(c)try{let u=e.state.tr,p=c();u.insert(r,p),e.view.dispatch(u),n&&n(p),(t==="text"||t==="paragraph"||t==="heading")&&setTimeout(()=>{let d=_h(e,a);d!==null&&e.commands.setTextSelection(d+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,p=e.schema.nodes[t].create({...o,id:a},i);u.insert(r,p),e.view.dispatch(u),n&&n(p);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 zh=s(()=>{let[e,t]=(0,Sn.useAtom)(co),[r,o]=(0,Sn.useAtom)(cs),[n,i]=(0,Sn.useAtom)(Wo),a=(0,Sn.useAtomValue)(Ie),l=(0,Sn.useAtom)(ye)[1],c=(0,qr.useCallback)(E=>{l(E)},[l]),u=(0,qr.useCallback)(E=>{t(E)},[t]),p=(0,qr.useCallback)(()=>{t(ls)},[t]),m=(0,qr.useCallback)((E,g)=>{o(w=>({...w,[E]:{...w[E],...g}}))},[o]),d=(0,qr.useCallback)(E=>r[E],[r]),f=(0,qr.useCallback)(E=>{o(g=>{let w={...g};return delete w[E],w})},[o]),C=(0,qr.useCallback)(E=>{i(g=>{let w=g.findIndex(N=>N.type===E.type&&N.key===E.key);if(w>=0){let N=[...g];return N[w]=E,N}return[...g,E]})},[i]),h=(0,qr.useCallback)((E,g)=>{i(w=>w.filter(N=>!(N.type===E&&N.key===g)))},[i]),b=(0,qr.useCallback)(E=>n.filter(g=>g.type===E),[n]),v=(0,qr.useCallback)((E,g)=>{if(!a){console.warn("[useBlockConfig] Cannot insert block: editor not available");return}let w={};E==="spacer"&&(w={...vi});let N=r[E];if(N&&(w={...w,...N}),g){let T=n.find(x=>x.type===E&&x.key===g);T?w={...w,...T.attributes}:console.warn(`[useBlockConfig] Preset "${g}" not found for type "${E}"`)}let y=a.state.doc.content.size,P={heading:"heading",text:"paragraph",image:"imageBlock",spacer:"divider",divider:"divider",button:"button",customCode:"customCode",column:"column",blockquote:"blockquote"}[E];cl(a,P,y,w,c)},[a,r,n,c]);return{visibleBlocks:e,setVisibleBlocks:u,resetVisibleBlocks:p,defaultVisibleBlocks:ls,setDefaults:m,getDefaults:d,clearDefaults:f,registerPreset:C,unregisterPreset:h,presets:n,getPresetsForType:b,insertBlock:v}},"useBlockConfig");var Qo=require("zod"),m1=Qo.z.object({paddingHorizontal:Qo.z.coerce.number().min(0),paddingVertical:Qo.z.coerce.number().min(0),backgroundColor:Qo.z.string(),borderLeftWidth:Qo.z.coerce.number().min(0),borderColor:Qo.z.string(),id:Qo.z.string().optional()});var Jr=require("react/jsx-runtime"),g1=s(({element:e,editor:t})=>{let r=(0,f1.useForm)({resolver:(0,p1.zodResolver)(m1),defaultValues:{...ho,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=kt({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"blockquote"});return e?(0,Jr.jsxs)(qe,{...r,children:[(0,Jr.jsx)(Vt,{type:"blockquote"}),(0,Jr.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Jr.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,Jr.jsx)(j,{control:r.control,name:"borderColor",render:({field:n})=>(0,Jr.jsxs)(q,{className:"courier-mb-3",children:[(0,Jr.jsx)(J,{children:(0,Jr.jsx)(Et,{...n,defaultValue:ho.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,Jr.jsx)(K,{})]})})]})]}):null},"BlockquoteForm");var nr=require("zod"),ul=nr.z.object({label:nr.z.string(),link:nr.z.string().optional(),alignment:nr.z.enum(["left","center","right"]),backgroundColor:nr.z.string(),borderRadius:nr.z.number(),padding:nr.z.number(),fontWeight:nr.z.enum(["normal","bold"]),fontStyle:nr.z.enum(["normal","italic"]),isUnderline:nr.z.boolean(),isStrike:nr.z.boolean(),textColor:nr.z.string().optional(),borderColor:nr.z.string().optional()});var q1=require("@hookform/resolvers/zod"),J1=require("react-hook-form");var h1=require("@tiptap/core"),xi=h1.Node.create({name:"doc",topNode:!0,content:"block+"});var dl=require("@tiptap/core"),Ti=dl.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",(0,dl.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var $1=he(require("@tiptap/extension-placeholder"),1);var b1=require("@tiptap/core"),ml=b1.Node.create({name:"text",group:"inline"});var Nl=require("@tiptap/react"),Hn=he(require("react"),1),_a=require("react");var Rn=require("@tiptap/core"),x1=require("@tiptap/react");var y1=require("@tiptap/react"),C1=require("jotai"),en=require("react");var bt=require("react");var Fa=require("react/jsx-runtime"),Id=50,Sd=24,pl=s(({variableId:e,isInvalid:t,onUpdateAttributes:r,onDelete:o,icon:n,value:i,singleClickToEdit:a=!1,className:l,textColorOverride:c,getColors:u})=>{let[p,m]=(0,bt.useState)(!1),d=(0,bt.useRef)(null);(0,bt.useEffect)(()=>{e===""&&!p&&m(!0)},[e,p]),(0,bt.useEffect)(()=>{if(p&&d.current){let y=d.current;y.textContent=e,y.focus(),requestAnimationFrame(()=>{if(y&&y.isConnected){let S=document.createRange();S.selectNodeContents(y),S.collapse(!1);let P=window.getSelection();P==null||P.removeAllRanges(),P==null||P.addRange(S)}})}},[p,e]);let f=(0,bt.useCallback)(()=>{var P;m(!1);let y=(((P=d.current)==null?void 0:P.textContent)||"").trim();if(y===""){o();return}let S=Tt(y);r({id:y,isInvalid:!S})},[o,r]),C=(0,bt.useCallback)(y=>{var S;y.key==="Enter"?(y.preventDefault(),(S=d.current)==null||S.blur()):y.key==="Escape"&&(y.preventDefault(),d.current&&(d.current.textContent=e),m(!1),e===""&&o())},[e,o]),h=(0,bt.useCallback)(()=>{if(d.current){let y=d.current.textContent||"";if(y.length>Id){y=y.slice(0,Id),d.current.textContent=y;let S=document.createRange();S.selectNodeContents(d.current),S.collapse(!1);let P=window.getSelection();P==null||P.removeAllRanges(),P==null||P.addRange(S)}}},[]),b=(0,bt.useCallback)(y=>{y.preventDefault();let S=y.clipboardData.getData("text/plain").slice(0,Id),P=window.getSelection();if(P&&P.rangeCount>0){let T=P.getRangeAt(0);T.deleteContents();let x=document.createTextNode(S);T.insertNode(x),T.setStartAfter(x),T.setEndAfter(x),P.removeAllRanges(),P.addRange(T),h()}},[h]),v=(0,bt.useCallback)(y=>{y.stopPropagation(),p||m(!0)},[p]),E=(0,bt.useMemo)(()=>{let y=e,S=i?`="${i}"`:"",P=`${y}${S}`,T=y.length>Sd;return{displayText:`${T?`${y.slice(0,Sd)}\u2026`:y}${S}`,fullText:P,showTitle:T}},[e,i]);(0,bt.useEffect)(()=>{d.current&&!p&&(d.current.textContent=E.displayText)},[E.displayText,p]);let g=(0,bt.useCallback)(y=>{y.stopPropagation()},[]),w=(0,bt.useCallback)(y=>{y.stopPropagation()},[]),N=a?{onClick:v}:{onClick:w,onDoubleClick:v};return(0,Fa.jsxs)("span",{className:I("courier-variable-chip",!t&&i&&"courier-variable-chip-has-value",t&&"courier-variable-chip-invalid",l),style:{direction:"ltr"},onMouseDown:g,...N,title:E.showTitle?E.fullText:void 0,children:[(0,Fa.jsx)("span",{className:"courier-flex-shrink-0 courier-flex courier-items-center courier-pt-0.5",children:n}),(0,Fa.jsx)("span",{ref:d,role:"textbox",contentEditable:p,suppressContentEditableWarning:!0,onBlur:f,onKeyDown:C,onInput:h,onPaste:b,onMouseDown:g,...a?{onClick:v}:{onClick:w,onDoubleClick:v},className:I("courier-outline-none courier-min-w-[1ch]",!p&&"courier-cursor-text"),style:{...c&&{color:c},maxWidth:`${Sd}ch`,overflow:"hidden",textOverflow:p?"clip":"ellipsis",whiteSpace:"nowrap",direction:"ltr",unicodeBidi:"isolate"},children:!p&&E.displayText})]})},"VariableChipBase");var Oa=require("react/jsx-runtime"),fl=s(({color:e="#1D4ED8"})=>(0,Oa.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,Oa.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,Oa.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableIcon");var gl=require("react/jsx-runtime"),v1=s(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=(0,C1.useAtomValue)(hn),i=e.attrs.id||"",a=n[i],l=e.attrs.isInvalid,[c,u]=(0,en.useState)(!1),p=(0,en.useCallback)(()=>{if(typeof r=="function")try{let h=r();if(h==null){u(!1);return}let v=t.state.doc.resolve(h).parent;u(v&&v.type.name==="button")}catch{u(!1)}else u(!1)},[t,r]);(0,en.useEffect)(()=>{p();let h=s(()=>{p()},"handleUpdate");return t.on("update",h),t.on("selectionUpdate",h),()=>{t.off("update",h),t.off("selectionUpdate",h)}},[t,p]);let m=(0,en.useCallback)(h=>{o(h)},[o]),d=(0,en.useCallback)(()=>{if(typeof r=="function"){let h=r();typeof h=="number"&&t.chain().focus().deleteRange({from:h,to:h+e.nodeSize}).run()}},[t,r,e.nodeSize]),C=s((h,b)=>h?"#DC2626":b?"#1E40AF":"#B45309","getIconColor")(l,!!a);return(0,gl.jsx)(y1.NodeViewWrapper,{className:"courier-inline-block courier-max-w-full",children:(0,gl.jsx)(pl,{variableId:i,isInvalid:l,value:a,onUpdateAttributes:m,onDelete:d,icon:(0,gl.jsx)(fl,{color:C}),className:I("courier-variable-node",c&&"courier-variable-in-button"),textColorOverride:c?"#000000":void 0})})},"VariableView");var Rd=Rn.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:"",parseHTML:e=>e.getAttribute("data-id")||"",renderHTML:e=>({"data-id":e.id})},isInvalid:{default:!1,parseHTML:e=>e.getAttribute("data-invalid")==="true",renderHTML:e=>({"data-invalid":e.isInvalid?"true":void 0})}}},parseHTML(){return[{tag:"span[data-variable]",getAttrs:e=>{let t=e.getAttribute("data-id");return t?{id:t}:!1}}]},renderHTML({HTMLAttributes:e,node:t}){return["span",{"data-variable":!0,...e},`{{${t.attrs.id}}}`]},renderText({node:e}){return`{{${e.attrs.id}}}`},addNodeView(){return(0,x1.ReactNodeViewRenderer)(v1)}}),Ln=Rn.Extension.create({name:"variableInputRule",addInputRules(){return[new Rn.InputRule({find:/\{\{$/,handler:({range:e,chain:t})=>{t().deleteRange(e).insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()}})]}});var $h=Rn.Extension.create({name:"variableTypeHandler"});var T1=require("@tiptap/core"),E1=require("@tiptap/pm/state"),hl=require("@tiptap/pm/model");var Bn=T1.Extension.create({name:"variablePaste",addProseMirrorPlugins(){return[new E1.Plugin({props:{transformPastedHTML:e=>e.replace(/\{\{([^}]+)\}\}/g,(r,o)=>{let n=o.trim();return Tt(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&&Tt(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=hl.Fragment.from(i),u=new hl.Slice(c,0,0),p=r.state.tr.replaceSelection(u);return r.dispatch(p),e}return e}}})]}});var k1=require("@tiptap/core"),bl=require("@tiptap/react"),Ld=require("react");var tn=require("react/jsx-runtime"),Zh=s(({color:e="#B45309"})=>(0,tn.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,tn.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,tn.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableChipIcon"),qh=s(e=>e?"#DC2626":"#B45309","getIconColor"),Jh=s(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=e.attrs.id||"",i=e.attrs.isInvalid||!1,a=(0,Ld.useCallback)(c=>{o(c)},[o]),l=(0,Ld.useCallback)(()=>{if(typeof r=="function"){let c=r();typeof c=="number"&&t.chain().focus().deleteRange({from:c,to:c+e.nodeSize}).run()}},[t,r,e.nodeSize]);return(0,tn.jsx)(bl.NodeViewWrapper,{as:"span",className:"courier-inline",children:(0,tn.jsx)(pl,{variableId:n,isInvalid:i,onUpdateAttributes:a,onDelete:l,icon:(0,tn.jsx)(Zh,{color:qh(i)})})})},"SimpleVariableView"),yl=k1.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:"",parseHTML:e=>e.getAttribute("data-id")||"",renderHTML:e=>({"data-id":e.id})},isInvalid:{default:!1,parseHTML:e=>e.getAttribute("data-invalid")==="true",renderHTML:e=>({"data-invalid":e.isInvalid?"true":void 0})}}},parseHTML(){return[{tag:"span[data-variable]",getAttrs:e=>{let t=e.getAttribute("data-id");return t?{id:t}:!1}}]},renderHTML({HTMLAttributes:e,node:t}){return["span",{"data-variable":!0,...e},`{{${t.attrs.id}}}`]},renderText({node:e}){return`{{${e.attrs.id}}}`},addNodeView(){return(0,bl.ReactNodeViewRenderer)(Jh)}});function Ei(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();Tt(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(Ei,"parseStringToContent");function Cl(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(Cl,"contentToString");var _1=require("@tiptap/react"),z1=require("react");var Pl=require("jotai"),tt=require("lucide-react"),sr=require("react");var xl=require("react");var w1=require("react"),P1=require("react/jsx-runtime"),Bd=(0,w1.forwardRef)(({children:e,className:t,withShadow:r=!0,withBorder:o=!0,...n},i)=>{let a=I("courier-bg-popover courier-rounded-lg courier-text-popover-foreground",r?"courier-shadow-sm":"",o?"courier-border courier-border-border":"",t);return(0,P1.jsx)("div",{className:a,...n,ref:i,children:e})});Bd.displayName="Surface";var M1=he(require("@tippyjs/react"),1),vl=require("react");var Nt=require("react/jsx-runtime"),N1=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,jh=s(({children:e})=>{let t="courier-inline-flex courier-items-center courier-justify-center courier-w-5 courier-h-5 courier-p-1 courier-text-[0.625rem] courier-rounded courier-font-semibold courier-leading-none courier-border courier-border-border courier-text-muted-foreground courier-border-b-2";return e==="Mod"?(0,Nt.jsx)("kbd",{className:t,children:N1?"\u2318":"Ctrl"}):e==="Shift"?(0,Nt.jsx)("kbd",{className:t,children:"\u21E7"}):e==="Alt"?(0,Nt.jsx)("kbd",{className:t,children:N1?"\u2325":"Alt"}):(0,Nt.jsx)("kbd",{className:t,children:e})},"ShortcutKey"),A1=s(({children:e,enabled:t=!0,title:r,shortcut:o,tippyOptions:n={}})=>{let i=Cp(),a=(0,vl.useCallback)(u=>{let p=Object.entries(i).reduce((m,[d,f])=>{let C=d.replace(/[A-Z]/g,h=>`-${h.toLowerCase()}`);return{...m,[`--${C}`]:f}},{});return(0,Nt.jsxs)("span",{className:I("courier-flex courier-items-center courier-gap-2 courier-px-2.5 courier-py-1 courier-bg-popover courier-text-popover-foreground courier-border courier-border-border courier-rounded-lg courier-shadow-sm courier-z-[999]",i.colorScheme==="dark"?"dark":""),style:p,tabIndex:-1,"data-placement":u["data-placement"],"data-reference-hidden":u["data-reference-hidden"],"data-escaped":u["data-escaped"],children:[r&&(0,Nt.jsx)("span",{className:"courier-text-xs courier-font-medium courier-text-muted-foreground",children:r}),o&&(0,Nt.jsx)("span",{className:"courier-flex courier-items-center courier-gap-0.5",children:o.map(m=>(0,Nt.jsx)(jh,{children:m},m))})]})},[o,r,i]),[l,c]=(0,vl.useState)(null);return t?(0,Nt.jsxs)(Nt.Fragment,{children:[(0,Nt.jsx)("span",{ref:c,children:e}),l&&(0,Nt.jsx)(M1.default,{...n,delay:500,offset:[0,8],touch:!1,zIndex:99999,appendTo:document.body,trigger:"mouseenter focus",showOnCreate:!1,render:a,animation:!1,reference:l})]}):(0,Nt.jsx)(Nt.Fragment,{children:e})},"Tooltip");var Ua=require("react/jsx-runtime"),I1=(0,xl.forwardRef)(({shouldShowContent:e=!0,children:t,isVertical:r=!1,className:o,...n},i)=>{let a=I("courier-text-foreground courier-inline-flex courier-h-full courier-leading-none courier-gap-0.5",r?"courier-flex-col courier-p-2":"courier-flex-row courier-p-0.5 courier-items-center",o);return e&&(0,Ua.jsx)(Bd,{className:a,...n,ref:i,children:t})});I1.displayName="Toolbar";var S1=(0,xl.forwardRef)(({horizontal:e,className:t,...r},o)=>{let n=I("courier-bg-border",e?"courier-w-full courier-min-w-[1.5rem] courier-h-[1px] courier-my-1 first:courier-mt-0 last:courier-mt-0":"courier-h-full courier-min-h-[1.5rem] courier-w-[1px] courier-mx-1 first:courier-ml-0 last:courier-mr-0",t);return(0,Ua.jsx)("div",{className:n,ref:o,...r})});S1.displayName="Toolbar.Divider";var R1=(0,xl.forwardRef)(({children:e,buttonSize:t="icon",variant:r="ghost",className:o,tooltip:n,tooltipShortcut:i,onMouseDown:a,...l},c)=>{let u=I("courier-gap-1 courier-min-w-[2rem] courier-w-auto",o),m=(0,Ua.jsx)(Se,{className:u,variant:r,buttonSize:t,ref:c,onMouseDown:s(d=>{d.preventDefault(),a==null||a(d)},"handleMouseDown"),...l,children:e});return n?(0,Ua.jsx)(A1,{title:n,shortcut:i,children:m}):m});R1.displayName="ToolbarButton";var Tl={Wrapper:I1,Divider:S1,Button:R1};var L1=require("lucide-react"),B1=require("react");var ir=require("react/jsx-runtime"),Kh=s(e=>e.type==="option","isOption"),D1=s(({options:e,containerRef:t})=>{let r=(0,B1.useMemo)(()=>e.find(o=>o.type==="option"&&o.isActive()),[e]);return(0,ir.jsxs)(ys,{children:[(0,ir.jsx)(Cs,{asChild:!0,children:(0,ir.jsxs)(Se,{variant:"ghost",className:"courier-flex courier-items-center courier-justify-center courier-font-normal !courier-py-[5px]",children:[(r==null?void 0:r.label)||"Normal text",(0,ir.jsx)(L1.ChevronDown,{className:"courier-w-3 courier-h-3"})]})}),(0,ir.jsx)(ea,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(Kh(o))return(0,ir.jsx)(ta,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?(0,ir.jsx)(ir.Fragment,{children:o.id==="heading1"?(0,ir.jsx)("h1",{className:"courier-text-2xl courier-font-bold",children:o.label}):o.id==="heading2"?(0,ir.jsx)("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading3"?(0,ir.jsx)("h3",{className:"courier-text-lg courier-font-bold",children:o.label}):o.label}):o.label},o.id)})})]})},"ContentTypePicker");var El=require("jotai"),ar=require("react"),F1=require("uuid");var H1=require("react");var V1=s((e,t,r)=>(0,H1.useMemo)(()=>{if(!(e!=null&&e.conditionalRules)||!t||!r)return null;let o=e.conditionalRules.filter(n=>n.trigger.type==="node"&&t.isActive(n.trigger.name)!==n.trigger.active?!1:n.conditions.activeItems.some(i=>i==="bold"?r.isBold:i==="italic"?r.isItalic:i==="underline"?r.isUnderline:i==="strike"?r.isStrike:!1));return{getRuleForItem:n=>o.find(i=>!i.conditions.activeItems.includes(n))}},[e,t,r]),"useConditionalRules");var kl=s((e,t,r)=>{let o=(0,El.useSetAtom)(Qe),n=(0,El.useAtomValue)(ye),i=V1(t,e,r),a=(0,ar.useCallback)(g=>{let w=-1;return e.state.doc.descendants((N,y)=>{var S;return((S=N.attrs)==null?void 0:S.id)===g?(w=y,!1):!0}),w},[e]),l=(0,ar.useCallback)((g,w)=>{var N,y,S;if(((N=n==null?void 0:n.type)==null?void 0:N.name)==="button"&&((y=n.attrs)!=null&&y.id)){let P=n.attrs.id,T=a(P);if(T>=0){let x=e.state.tr;return x.setNodeMarkup(T,void 0,{...(S=e.state.doc.nodeAt(T))==null?void 0:S.attrs,[g]:w}),e.view.dispatch(x),setTimeout(()=>{let k=a(P);if(k>=0){let M=e.state.doc.nodeAt(k);M&&o(M)}},0),!0}}return!1},[e,n,a,o]),c=(0,ar.useCallback)(()=>{var g,w;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"&&((w=n.attrs)!=null&&w.id)){let N=n.attrs.id,y=a(N);if(y>=0){let S=e.state.doc.nodeAt(y);if(!S)return!1;let P={...S.attrs,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},T=e.state.tr;return T.setNodeMarkup(y,void 0,P),e.view.dispatch(T),setTimeout(()=>{let x=a(N);if(x>=0){let k=e.state.doc.nodeAt(x);k&&o(k)}},0),!0}}return!1},[e,n,a,o]),u=(0,ar.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let w=n.attrs.fontWeight==="bold"?"normal":"bold";if(l("fontWeight",w))return!0}if(i&&r){let w=i.getRuleForItem("bold");if(w&&w.action.type==="toggle_off"){let N=e.chain().focus();return w.action.targets.forEach(y=>{y==="italic"&&r.isItalic&&N.toggleItalic()}),N.toggleBold().run(),!0}}return e.chain().focus().toggleBold().run()},[e,n,l,i,r]),p=(0,ar.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let w=n.attrs.fontStyle==="italic"?"normal":"italic";if(l("fontStyle",w))return!0}if(i&&r){let w=i.getRuleForItem("italic");if(w&&w.action.type==="toggle_off"){let N=e.chain().focus();return w.action.targets.forEach(y=>{y==="bold"&&r.isBold&&N.toggleBold()}),N.toggleItalic().run(),!0}}return e.chain().focus().toggleItalic().run()},[e,n,l,i,r]),m=(0,ar.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let w=!n.attrs.isStrike;if(l("isStrike",w))return!0}return e.chain().focus().toggleMark("strike").run()},[e,n,l]),d=(0,ar.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let w=!n.attrs.isUnderline;if(l("isUnderline",w))return!0}return e.chain().focus().toggleMark("underline").run()},[e,n,l]),f=(0,ar.useCallback)(()=>e.chain().focus().setTextAlign("left").run(),[e]),C=(0,ar.useCallback)(()=>e.chain().focus().setTextAlign("center").run(),[e]),h=(0,ar.useCallback)(()=>e.chain().focus().setTextAlign("right").run(),[e]),b=(0,ar.useCallback)(()=>e.chain().focus().setTextAlign("justify").run(),[e]),v=(0,ar.useCallback)((g,w)=>e.chain().focus().setLink({href:g,target:w?"_blank":""}).run(),[e]),E=(0,ar.useCallback)(()=>{let g=e.isActive("blockquote");if(e.chain().focus().toggleBlockquote().run()){let{selection:y}=e.state,S=y.$anchor;if(g){let P=S.node();(P.type.name==="paragraph"||P.type.name==="heading")&&o(P)}else for(let P=S.depth;P>0;P--){let T=S.node(P);if(T.type.name==="blockquote"){if(T.attrs.id)o(T);else{let x=S.before(P),k=`node-${(0,F1.v4)()}`,M=e.state.tr;M.setNodeMarkup(x,void 0,{...T.attrs,id:k}),e.view.dispatch(M);let A=e.state.doc.nodeAt(x);A&&o(A)}break}}}},[e,o]);return{onBold:u,onItalic:p,onStrike:m,onUnderline:d,onAlignLeft:f,onAlignCenter:C,onAlignRight:h,onAlignJustify:b,onLink:v,onQuote:E,resetButtonFormatting:c}},"useTextmenuCommands");var O1=require("@tiptap/react");var U1=s(e=>(0,O1.useEditorState)({editor:e,selector:t=>[{label:"Normal text",onClick:()=>{t.editor.chain().focus().setNode("paragraph").run()},id:"paragraph",disabled:()=>!t.editor.can().setParagraph(),isActive:()=>t.editor.isActive("paragraph")&&!t.editor.isActive("heading"),type:"option"},{label:"Heading 1",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:1}).run()},id:"heading1",disabled:()=>!t.editor.can().setHeading({level:1}),isActive:()=>t.editor.isActive("heading",{level:1}),type:"option"},{label:"Heading 2",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:2}).run()},id:"heading2",disabled:()=>!t.editor.can().setHeading({level:2}),isActive:()=>t.editor.isActive("heading",{level:2}),type:"option"},{label:"Heading 3",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:3}).run()},id:"heading3",disabled:()=>!t.editor.can().setHeading({level:3}),isActive:()=>t.editor.isActive("heading",{level:3}),type:"option"}]}),"useTextmenuContentTypes");var W1=require("jotai"),Dn=require("react");var wl=s(e=>{let t=(0,W1.useAtomValue)(ye),[r,o]=(0,Dn.useState)({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1}),n=(0,Dn.useCallback)(()=>{if(e){if((t==null?void 0:t.type.name)==="button"){o({isBold:t.attrs.fontWeight==="bold",isItalic:t.attrs.fontStyle==="italic",isUnderline:t.attrs.isUnderline,isStrike:t.attrs.isStrike,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1});return}o({isBold:e.isActive("bold"),isItalic:e.isActive("italic"),isUnderline:e.isActive("underline"),isStrike:e.isActive("strike"),isAlignLeft:e.isActive({textAlign:"left"}),isAlignCenter:e.isActive({textAlign:"center"}),isAlignRight:e.isActive({textAlign:"right"}),isAlignJustify:e.isActive({textAlign:"justify"}),isQuote:e.isActive("blockquote"),isLink:e.isActive("link")})}},[e,t]);return(0,Dn.useEffect)(()=>{if(e)return n(),e.on("selectionUpdate",n),e.on("transaction",n),()=>{e.off("selectionUpdate",n),e.off("transaction",n)}},[e,n]),{shouldShow:(0,Dn.useCallback)(({editor:a})=>{let l=["paragraph","heading","blockquote"],{$head:c}=a.state.selection,u=c.node();if(l.includes(u.type.name)&&u.attrs.isSelected)return!0;for(let p=1;p<=c.depth;p++){let m=c.node(p);if(m.type.name==="blockquote"){if(m.attrs.isSelected)return!0;let d=a.state.selection.from!==a.state.selection.to;if(a.isFocused&&d)return!0}}return!1},[]),...r}},"useTextmenuStates");var ct=require("react/jsx-runtime"),Gh=(0,sr.memo)(Tl.Button),Yh=(0,sr.memo)(D1),ki=s(({editor:e,config:t})=>{var S;let r=wl(e),o=U1(e),n=(0,sr.useRef)(null),i=(0,Pl.useAtomValue)(Ls),a=(0,Pl.useAtomValue)(ye),l=a==null?void 0:a.type.name,c=(0,Pl.useAtomValue)(Ap),[u,p]=(0,sr.useState)(()=>{let{selection:P}=e.state;return{from:P.from,to:P.to,empty:P.empty}});(0,sr.useEffect)(()=>{let P=s(()=>{let{selection:T}=e.state;p({from:T.from,to:T.to,empty:T.empty})},"updateSelection");return e.on("selectionUpdate",P),e.on("transaction",P),()=>{e.off("selectionUpdate",P),e.off("transaction",P)}},[e]);let m=(0,sr.useMemo)(()=>!u.empty&&u.from!==u.to,[u]),d=(0,sr.useMemo)(()=>t||c(l||"",m),[t,c,l,m]),f=kl(e,d,r),C=s(()=>{let{selection:P}=e.state;if(!(P.empty&&!r.isLink&&!e.can().setLink({href:""})))if(r.isLink){let T=e.state.tr.setMeta("showLinkForm",{from:P.from,to:P.to});e.view.dispatch(T)}else{let T=e.state.tr.setMeta("showLinkForm",{from:P.from,to:P.to});e.view.dispatch(T)}},"handleLinkToggle"),h=s(()=>{if(i.ref){let P=i.ref,T=P.value,x=i.caretPosition||P.selectionStart||0,k=T.substring(0,x),M=T.substring(x),A=`${k}{{${M}`,R=x+2;P.focus();let B=new Event("input",{bubbles:!0,cancelable:!0});if(Object.defineProperty(B,"target",{writable:!1,value:{...P,value:A}}),P.value=A,P.dispatchEvent(B),P.setSelectionRange(R,R),P.getBoundingClientRect()){let L=A.slice(0,R),D=document.createElement("span");D.style.font=window.getComputedStyle(P).font,D.style.whiteSpace="pre-wrap",D.textContent=L,document.body.appendChild(D);let V=D.offsetWidth;document.body.removeChild(D);let O=parseInt(window.getComputedStyle(P).lineHeight),$=L.split(`
200
- `).length-1,_=new CustomEvent("showVariableSuggestions",{detail:{cursorPosition:{left:Math.min(V%P.offsetWidth,P.offsetWidth-200),top:$*O+30}},bubbles:!0});P.dispatchEvent(_)}return}e.chain().focus().insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()},"handleVariableClick"),b=s((P,T,x,k,M,A,R)=>{let B=d[P];return!B||Array.isArray(B)||B.state==="hidden"?null:(0,ct.jsx)(Gh,{tooltip:x,tooltipShortcut:A,onClick:k,active:M,disabled:B.state==="disabled",...R,children:T},P)},"renderButton"),v=s((P,T)=>{let x=P.filter(k=>!!k);return x.length>0?(0,ct.jsx)("div",{className:"courier-flex courier-items-center courier-gap-0.5",children:x},T):null},"renderGroup"),E=v([((S=d.contentType)==null?void 0:S.state)==="enabled"&&(0,ct.jsx)(Yh,{options:o,containerRef:n},"content-type")],"content-type-group"),g=v([b("bold",(0,ct.jsx)(tt.Bold,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",f.onBold,r.isBold,["Mod","B"]),b("italic",(0,ct.jsx)(tt.Italic,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",f.onItalic,r.isItalic,["Mod","I"]),b("underline",(0,ct.jsx)(tt.Underline,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",f.onUnderline,r.isUnderline,["Mod","U"]),b("strike",(0,ct.jsx)(tt.Strikethrough,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Strikethrough",f.onStrike,r.isStrike,["Mod","Shift","S"])],"text-style-group"),w=v([b("alignLeft",(0,ct.jsx)(tt.AlignLeft,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",f.onAlignLeft,r.isAlignLeft,["Shift","Mod","L"]),b("alignCenter",(0,ct.jsx)(tt.AlignCenter,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",f.onAlignCenter,r.isAlignCenter,["Shift","Mod","E"]),b("alignRight",(0,ct.jsx)(tt.AlignRight,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",f.onAlignRight,r.isAlignRight,["Shift","Mod","R"]),b("alignJustify",(0,ct.jsx)(tt.AlignJustify,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",f.onAlignJustify,r.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),N=v([b("quote",(0,ct.jsx)(tt.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Quote",f.onQuote,r.isQuote,["Mod","Shift","B"])],"block-style-group"),y=v([b("link",(0,ct.jsx)(tt.Link,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",C,r.isLink,["Mod","K"]),b("variable",(0,ct.jsx)(Pp,{width:16}),"Variable",h,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return(0,ct.jsx)(Tl.Wrapper,{ref:n,className:"courier-border-b rounded-b-none rounded-t-sm !courier-shadow-md courier-justify-center courier-rounded-lg",children:[E,g,w,N,y].filter(Boolean).map((P,T)=>(0,ct.jsxs)(sr.Fragment,{children:[P,T<[E,g,w,N,y].filter(Boolean).length-1&&(0,ct.jsx)(Tl.Divider,{})]},`item-${T}`))})},"TextMenu");var Dd=require("react/jsx-runtime"),Xh={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"}},Wa=s(({editor:e})=>{let t=(0,z1.useCallback)(({editor:r})=>r.isFocused&&r.isEditable,[]);return e?(0,Dd.jsx)(_1.BubbleMenu,{editor:e,tippyOptions:{appendTo:r=>{var o;return(o=r.closest(".theme-container"))!=null?o:document.body},getReferenceClientRect:()=>e.view.dom.getBoundingClientRect(),placement:"top",offset:[0,8],zIndex:50,popperOptions:{modifiers:[{name:"flip",enabled:!1}]}},shouldShow:t,updateDelay:100,children:(0,Dd.jsx)(ki,{editor:e,config:Xh})}):null},"VariableEditorToolbar");Wa.displayName="VariableEditorToolbar";var za=require("react/jsx-runtime"),jr=Hn.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,showToolbar:i=!1,onFocus:a,onBlur:l},c)=>{let u=Hn.useRef(!1),p=Hn.useRef(e),m=(0,Nl.useEditor)({immediatelyRender:!1,extensions:[xi,Ti.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),ml,yl,Ln,Bn,$1.default.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:Ei(e),editable:!n,editorProps:{attributes:{class:"courier-outline-none courier-min-h-[20px]"},handleKeyDown:(f,C)=>C.key==="Enter"&&!C.shiftKey?(C.preventDefault(),!0):!1},onUpdate:({editor:f})=>{if(u.current)return;let C=Cl(f.getJSON());C!==p.current&&(p.current=C,t==null||t(C))},onFocus:()=>{a==null||a()},onBlur:()=>{l==null||l()}});(0,_a.useEffect)(()=>{if(!m||e===p.current)return;u.current=!0,p.current=e;let f=setTimeout(()=>{let C=Ei(e);m.commands.setContent(C),u.current=!1},0);return()=>clearTimeout(f)},[m,e]),(0,_a.useEffect)(()=>{m&&m.setEditable(!n)},[m,n]);let d=(0,_a.useCallback)(()=>{m==null||m.commands.focus()},[m]);return Hn.useImperativeHandle(c,()=>{let f=m==null?void 0:m.view.dom.parentElement;return f&&(f.focus=d),f},[m,d]),(0,za.jsxs)("div",{ref:c,className:I("variable-textarea-placeholder variable-editor-container","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:()=>m==null?void 0:m.commands.focus(),children:[(0,za.jsx)(Nl.EditorContent,{editor:m,className:"courier-w-full"}),i&&!n&&(0,za.jsx)(Wa,{editor:m})]})});jr.displayName="VariableTextarea";var Z1=he(require("@tiptap/extension-placeholder"),1);var Ml=require("@tiptap/react"),Vn=he(require("react"),1),$a=require("react");var Za=require("react/jsx-runtime"),wi=Vn.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,readOnly:i=!1,showToolbar:a=!1,onFocus:l,onBlur:c},u)=>{let p=Vn.useRef(!1),m=Vn.useRef(e),d=(0,Ml.useEditor)({immediatelyRender:!1,extensions:[xi,Ti.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),ml,yl,Ln,Bn,Z1.default.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:Ei(e),editable:!n&&!i,editorProps:{attributes:{class:"courier-outline-none"},handleKeyDown:(C,h)=>h.key==="Enter"?(h.preventDefault(),!0):!1},onUpdate:({editor:C})=>{if(p.current)return;let h=Cl(C.getJSON());h!==m.current&&(m.current=h,t==null||t(h))},onFocus:()=>{l==null||l()},onBlur:()=>{c==null||c()}});(0,$a.useEffect)(()=>{if(!d||e===m.current)return;p.current=!0,m.current=e;let C=setTimeout(()=>{let h=Ei(e);d.commands.setContent(h),p.current=!1},0);return()=>clearTimeout(C)},[d,e]),(0,$a.useEffect)(()=>{d&&d.setEditable(!n&&!i)},[d,n,i]);let f=(0,$a.useCallback)(()=>{d==null||d.commands.focus()},[d]);return Vn.useImperativeHandle(u,()=>{let C=d==null?void 0:d.view.dom.parentElement;return C&&(C.focus=f),C},[d,f]),(0,Za.jsxs)("div",{ref:u,className:I("variable-input-placeholder variable-editor-container","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&&(d==null?void 0:d.commands.focus()),children:[(0,Za.jsx)(Ml.EditorContent,{editor:d,className:"courier-w-full courier-flex-1"}),a&&!n&&(0,Za.jsx)(Wa,{editor:d})]})});wi.displayName="VariableInput";var rn=require("react/jsx-runtime"),Pi=30,Al=s(({color:e="currentColor",width:t=Pi,height:r=Pi,...o})=>(0,rn.jsx)(Z,{...o,width:t,height:r,children:(0,rn.jsx)("path",{d:"M6.375 23.9998C6.375 24.345 6.65482 24.6248 7 24.6248C7.34518 24.6248 7.625 24.345 7.625 23.9998H6.375ZM7.625 7.33317C7.625 6.98799 7.34518 6.70817 7 6.70817C6.65482 6.70817 6.375 6.98799 6.375 7.33317H7.625ZM7.625 23.9998V7.33317H6.375V23.9998H7.625ZM10.4583 16.4995V14.8328H9.20834V16.4995H10.4583ZM11.5 13.7912H21.5V12.5412H11.5V13.7912ZM22.5417 14.8328V16.4995H23.7917V14.8328H22.5417ZM21.5 17.5412H11.5V18.7912H21.5V17.5412ZM22.5417 16.4995C22.5417 16.91 22.5403 17.155 22.5167 17.3306C22.5059 17.4111 22.4932 17.4514 22.4857 17.4695C22.484 17.4737 22.4826 17.4765 22.4818 17.4781C22.481 17.4797 22.4805 17.4804 22.4805 17.4805C22.4804 17.4805 22.4805 17.4803 22.4808 17.4801C22.481 17.4798 22.481 17.4798 22.4807 17.4802L23.3645 18.364C23.6221 18.1065 23.7158 17.7934 23.7556 17.4972C23.793 17.2189 23.7917 16.8747 23.7917 16.4995H22.5417ZM21.5 18.7912C21.8752 18.7912 22.2194 18.7925 22.4977 18.7551C22.7939 18.7153 23.107 18.6216 23.3645 18.364L22.4807 17.4802C22.4803 17.4805 22.4803 17.4805 22.4806 17.4803C22.4808 17.48 22.481 17.4799 22.481 17.48C22.4809 17.48 22.4802 17.4805 22.4786 17.4813C22.477 17.4821 22.4742 17.4835 22.47 17.4852C22.4519 17.4927 22.4116 17.5054 22.3311 17.5162C22.1555 17.5398 21.9105 17.5412 21.5 17.5412V18.7912ZM21.5 13.7912C21.9105 13.7912 22.1555 13.7925 22.3311 13.8161C22.4116 13.8269 22.4519 13.8397 22.47 13.8471C22.4742 13.8489 22.477 13.8502 22.4786 13.8511C22.4802 13.8519 22.4809 13.8524 22.481 13.8524C22.481 13.8524 22.4808 13.8523 22.4806 13.8521C22.4803 13.8518 22.4803 13.8518 22.4807 13.8522L23.3645 12.9683C23.107 12.7108 22.7939 12.6171 22.4977 12.5773C22.2194 12.5398 21.8752 12.5412 21.5 12.5412V13.7912ZM23.7917 14.8328C23.7917 14.4577 23.793 14.1134 23.7556 13.8352C23.7158 13.5389 23.6221 13.2258 23.3645 12.9683L22.4807 13.8522C22.481 13.8526 22.481 13.8526 22.4808 13.8523C22.4805 13.852 22.4804 13.8518 22.4805 13.8519C22.4805 13.8519 22.481 13.8526 22.4818 13.8542C22.4826 13.8558 22.484 13.8586 22.4857 13.8628C22.4932 13.881 22.5059 13.9213 22.5167 14.0017C22.5403 14.1773 22.5417 14.4223 22.5417 14.8328H23.7917ZM10.4583 14.8328C10.4583 14.4223 10.4597 14.1773 10.4833 14.0017C10.4941 13.9213 10.5068 13.881 10.5143 13.8628C10.516 13.8586 10.5174 13.8558 10.5182 13.8542C10.5191 13.8526 10.5195 13.8519 10.5196 13.8519C10.5196 13.8518 10.5195 13.852 10.5192 13.8523C10.519 13.8526 10.519 13.8526 10.5194 13.8522L9.63548 12.9683C9.37796 13.2258 9.28425 13.5389 9.24443 13.8352C9.20702 14.1134 9.20834 14.4577 9.20834 14.8328H10.4583ZM11.5 12.5412C11.1248 12.5412 10.7806 12.5398 10.5023 12.5773C10.2061 12.6171 9.893 12.7108 9.63548 12.9683L10.5194 13.8522C10.5197 13.8518 10.5198 13.8518 10.5195 13.8521C10.5192 13.8523 10.519 13.8524 10.519 13.8524C10.5191 13.8524 10.5198 13.8519 10.5214 13.8511C10.523 13.8502 10.5258 13.8489 10.53 13.8471C10.5481 13.8397 10.5884 13.8269 10.6689 13.8161C10.8445 13.7925 11.0895 13.7912 11.5 13.7912V12.5412ZM9.20834 16.4995C9.20834 16.8747 9.20702 17.2189 9.24443 17.4972C9.28425 17.7934 9.37796 18.1065 9.63548 18.364L10.5194 17.4802C10.519 17.4798 10.519 17.4798 10.5192 17.4801C10.5195 17.4803 10.5196 17.4805 10.5196 17.4805C10.5195 17.4804 10.5191 17.4797 10.5182 17.4781C10.5174 17.4765 10.516 17.4737 10.5143 17.4695C10.5068 17.4514 10.4941 17.4111 10.4833 17.3306C10.4597 17.155 10.4583 16.91 10.4583 16.4995H9.20834ZM11.5 17.5412C11.0895 17.5412 10.8445 17.5398 10.6689 17.5162C10.5884 17.5054 10.5481 17.4927 10.53 17.4852C10.5258 17.4835 10.523 17.4821 10.5214 17.4813C10.5198 17.4805 10.5191 17.48 10.519 17.48C10.519 17.4799 10.5192 17.48 10.5195 17.4803C10.5198 17.4805 10.5197 17.4805 10.5194 17.4802L9.63548 18.364C9.893 18.6216 10.2061 18.7153 10.5023 18.7551C10.7806 18.7925 11.1248 18.7912 11.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignLeftIcon"),Il=s(({color:e="currentColor",width:t=Pi,height:r=Pi,...o})=>(0,rn.jsx)(Z,{...o,width:t,height:r,children:(0,rn.jsx)("path",{d:"M14.9583 7C14.9583 6.65482 14.6785 6.375 14.3333 6.375C13.9881 6.375 13.7083 6.65482 13.7083 7L14.9583 7ZM13.7083 23.3333C13.7083 23.6785 13.9881 23.9583 14.3333 23.9583C14.6785 23.9583 14.9583 23.6785 14.9583 23.3333L13.7083 23.3333ZM13.7083 7L13.7083 12.6665L14.9583 12.6665L14.9583 7L13.7083 7ZM20.375 14.3332L20.375 15.9998L21.625 15.9998L21.625 14.3332L20.375 14.3332ZM19.3333 17.0415L9.33333 17.0415L9.33333 18.2915L19.3333 18.2915L19.3333 17.0415ZM8.29167 15.9998L8.29167 14.3332L7.04167 14.3332L7.04167 15.9998L8.29167 15.9998ZM9.33333 13.2915L19.3333 13.2915L19.3333 12.0415L9.33333 12.0415L9.33333 13.2915ZM8.29167 14.3332C8.29167 13.9227 8.29299 13.6777 8.3166 13.5021C8.32742 13.4216 8.34016 13.3813 8.34763 13.3631C8.34936 13.3589 8.35071 13.3562 8.35155 13.3546C8.35238 13.353 8.35284 13.3523 8.35289 13.3522C8.35292 13.3521 8.35279 13.3523 8.35256 13.3526C8.35232 13.3529 8.35231 13.3529 8.35269 13.3525L7.4688 12.4686C7.21128 12.7262 7.11758 13.0393 7.07775 13.3355C7.04034 13.6138 7.04167 13.958 7.04167 14.3332L8.29167 14.3332ZM9.33333 12.0415C8.95816 12.0415 8.61391 12.0402 8.33566 12.0776C8.03943 12.1174 7.72632 12.2111 7.4688 12.4686L8.35269 13.3525C8.35307 13.3521 8.35308 13.3522 8.35279 13.3524C8.3525 13.3526 8.3523 13.3528 8.35236 13.3527C8.35243 13.3527 8.35313 13.3522 8.35472 13.3514C8.35634 13.3505 8.3591 13.3492 8.3633 13.3475C8.38145 13.34 8.42175 13.3273 8.50222 13.3164C8.67782 13.2928 8.92283 13.2915 9.33333 13.2915L9.33333 12.0415ZM9.33333 17.0415C8.92283 17.0415 8.67782 17.0402 8.50222 17.0166C8.42175 17.0057 8.38145 16.993 8.3633 16.9855C8.3591 16.9838 8.35634 16.9825 8.35472 16.9816C8.35313 16.9808 8.35243 16.9803 8.35236 16.9803C8.3523 16.9802 8.3525 16.9804 8.35279 16.9806C8.35308 16.9808 8.35307 16.9809 8.35269 16.9805L7.4688 17.8644C7.72632 18.1219 8.03943 18.2156 8.33566 18.2554C8.61391 18.2928 8.95816 18.2915 9.33333 18.2915L9.33333 17.0415ZM7.04167 15.9998C7.04167 16.375 7.04034 16.7193 7.07775 16.9975C7.11758 17.2937 7.21128 17.6068 7.4688 17.8644L8.35269 16.9805C8.3523 16.9801 8.35232 16.9801 8.35256 16.9804C8.35279 16.9807 8.35292 16.9809 8.35289 16.9808C8.35284 16.9807 8.35238 16.98 8.35155 16.9784C8.35071 16.9768 8.34936 16.9741 8.34763 16.9699C8.34016 16.9517 8.32742 16.9114 8.3166 16.8309C8.29299 16.6553 8.29167 16.4103 8.29167 15.9998L7.04167 15.9998ZM20.375 15.9998C20.375 16.4103 20.3737 16.6553 20.3501 16.8309C20.3392 16.9114 20.3265 16.9517 20.319 16.9699C20.3173 16.9741 20.316 16.9768 20.3151 16.9784C20.3143 16.98 20.3138 16.9807 20.3138 16.9808C20.3137 16.9809 20.3139 16.9807 20.3141 16.9804C20.3143 16.9801 20.3144 16.9801 20.314 16.9805L21.1979 17.8644C21.4554 17.6068 21.5491 17.2937 21.5889 16.9975C21.6263 16.7193 21.625 16.375 21.625 15.9998L20.375 15.9998ZM19.3333 18.2915C19.7085 18.2915 20.0528 18.2928 20.331 18.2554C20.6272 18.2156 20.9403 18.1219 21.1979 17.8644L20.314 16.9805C20.3136 16.9809 20.3136 16.9808 20.3139 16.9806C20.3142 16.9804 20.3144 16.9802 20.3143 16.9803C20.3142 16.9803 20.3135 16.9808 20.3119 16.9816C20.3103 16.9825 20.3076 16.9838 20.3034 16.9855C20.2852 16.993 20.2449 17.0057 20.1644 17.0166C19.9888 17.0402 19.7438 17.0415 19.3333 17.0415L19.3333 18.2915ZM21.625 14.3332C21.625 13.958 21.6263 13.6138 21.5889 13.3355C21.5491 13.0393 21.4554 12.7262 21.1979 12.4686L20.314 13.3525C20.3144 13.3529 20.3143 13.3529 20.3141 13.3526C20.3139 13.3523 20.3137 13.3521 20.3138 13.3522C20.3138 13.3523 20.3143 13.353 20.3151 13.3546C20.316 13.3562 20.3173 13.3589 20.319 13.3631C20.3265 13.3813 20.3392 13.4216 20.3501 13.5021C20.3737 13.6777 20.375 13.9227 20.375 14.3332L21.625 14.3332ZM19.3333 13.2915C19.7438 13.2915 19.9888 13.2928 20.1644 13.3164C20.2449 13.3273 20.2852 13.34 20.3034 13.3475C20.3076 13.3492 20.3103 13.3505 20.3119 13.3514C20.3135 13.3522 20.3142 13.3527 20.3143 13.3527C20.3144 13.3528 20.3142 13.3526 20.3139 13.3524C20.3136 13.3522 20.3136 13.3521 20.314 13.3525L21.1979 12.4686C20.9403 12.2111 20.6272 12.1174 20.331 12.0776C20.0528 12.0402 19.7085 12.0415 19.3333 12.0415L19.3333 13.2915ZM13.7083 17.6665L13.7083 23.3333L14.9583 23.3333L14.9583 17.6665L13.7083 17.6665Z",fill:e})}),"ButtonAlignCenterIcon"),Sl=s(({color:e="currentColor",width:t=Pi,height:r=Pi,...o})=>(0,rn.jsx)(Z,{...o,width:t,height:r,children:(0,rn.jsx)("path",{d:"M23.625 23.9998C23.625 24.345 23.3452 24.6248 23 24.6248C22.6548 24.6248 22.375 24.345 22.375 23.9998H23.625ZM22.375 7.33317C22.375 6.98799 22.6548 6.70817 23 6.70817C23.3452 6.70817 23.625 6.98799 23.625 7.33317H22.375ZM22.375 23.9998V7.33317H23.625V23.9998H22.375ZM19.5417 16.4995V14.8328H20.7917V16.4995H19.5417ZM18.5 13.7912H8.49999V12.5412H18.5V13.7912ZM7.45832 14.8328V16.4995H6.20832V14.8328H7.45832ZM8.49999 17.5412H18.5V18.7912H8.49999V17.5412ZM7.45832 16.4995C7.45832 16.91 7.45965 17.155 7.48326 17.3306C7.49408 17.4111 7.50682 17.4514 7.51429 17.4695C7.51602 17.4737 7.51737 17.4765 7.51821 17.4781C7.51904 17.4797 7.5195 17.4804 7.51955 17.4805C7.51958 17.4805 7.51945 17.4803 7.51922 17.4801C7.51898 17.4798 7.51896 17.4798 7.51934 17.4802L6.63546 18.364C6.37794 18.1065 6.28424 17.7934 6.24441 17.4972C6.207 17.2189 6.20832 16.8747 6.20832 16.4995H7.45832ZM8.49999 18.7912C8.12482 18.7912 7.78057 18.7925 7.50232 18.7551C7.20608 18.7153 6.89298 18.6216 6.63546 18.364L7.51934 17.4802C7.51972 17.4805 7.51974 17.4805 7.51945 17.4803C7.51916 17.48 7.51896 17.4799 7.51902 17.48C7.51909 17.48 7.51979 17.4805 7.52138 17.4813C7.52299 17.4821 7.52576 17.4835 7.52996 17.4852C7.54811 17.4927 7.58841 17.5054 7.66888 17.5162C7.84448 17.5398 8.08948 17.5412 8.49999 17.5412V18.7912ZM8.49999 13.7912C8.08948 13.7912 7.84448 13.7925 7.66888 13.8161C7.58841 13.8269 7.54811 13.8397 7.52996 13.8471C7.52576 13.8489 7.52299 13.8502 7.52138 13.8511C7.51979 13.8519 7.51909 13.8524 7.51902 13.8524C7.51896 13.8524 7.51916 13.8523 7.51945 13.8521C7.51974 13.8518 7.51972 13.8518 7.51934 13.8522L6.63546 12.9683C6.89298 12.7108 7.20608 12.6171 7.50232 12.5773C7.78057 12.5398 8.12482 12.5412 8.49999 12.5412V13.7912ZM6.20832 14.8328C6.20832 14.4577 6.207 14.1134 6.24441 13.8352C6.28424 13.5389 6.37794 13.2258 6.63546 12.9683L7.51934 13.8522C7.51896 13.8526 7.51898 13.8526 7.51922 13.8523C7.51945 13.852 7.51958 13.8518 7.51955 13.8519C7.5195 13.8519 7.51904 13.8526 7.51821 13.8542C7.51737 13.8558 7.51602 13.8586 7.51429 13.8628C7.50682 13.881 7.49408 13.9213 7.48326 14.0017C7.45965 14.1773 7.45832 14.4223 7.45832 14.8328H6.20832ZM19.5417 14.8328C19.5417 14.4223 19.5403 14.1773 19.5167 14.0017C19.5059 13.9213 19.4932 13.881 19.4857 13.8628C19.484 13.8586 19.4826 13.8558 19.4818 13.8542C19.4809 13.8526 19.4805 13.8519 19.4804 13.8519C19.4804 13.8518 19.4805 13.852 19.4808 13.8523C19.481 13.8526 19.481 13.8526 19.4806 13.8522L20.3645 12.9683C20.622 13.2258 20.7157 13.5389 20.7556 13.8352C20.793 14.1134 20.7917 14.4577 20.7917 14.8328H19.5417ZM18.5 12.5412C18.8752 12.5412 19.2194 12.5398 19.4977 12.5773C19.7939 12.6171 20.107 12.7108 20.3645 12.9683L19.4806 13.8522C19.4803 13.8518 19.4802 13.8518 19.4805 13.8521C19.4808 13.8523 19.481 13.8524 19.481 13.8524C19.4809 13.8524 19.4802 13.8519 19.4786 13.8511C19.477 13.8502 19.4742 13.8489 19.47 13.8471C19.4519 13.8397 19.4116 13.8269 19.3311 13.8161C19.1555 13.7925 18.9105 13.7912 18.5 13.7912V12.5412ZM20.7917 16.4995C20.7917 16.8747 20.793 17.2189 20.7556 17.4972C20.7157 17.7934 20.622 18.1065 20.3645 18.364L19.4806 17.4802C19.481 17.4798 19.481 17.4798 19.4808 17.4801C19.4805 17.4803 19.4804 17.4805 19.4804 17.4805C19.4805 17.4804 19.4809 17.4797 19.4818 17.4781C19.4826 17.4765 19.484 17.4737 19.4857 17.4695C19.4932 17.4514 19.5059 17.4111 19.5167 17.3306C19.5403 17.155 19.5417 16.91 19.5417 16.4995H20.7917ZM18.5 17.5412C18.9105 17.5412 19.1555 17.5398 19.3311 17.5162C19.4116 17.5054 19.4519 17.4927 19.47 17.4852C19.4742 17.4835 19.477 17.4821 19.4786 17.4813C19.4802 17.4805 19.4809 17.48 19.481 17.48C19.481 17.4799 19.4808 17.48 19.4805 17.4803C19.4802 17.4805 19.4803 17.4805 19.4806 17.4802L20.3645 18.364C20.107 18.6216 19.7939 18.7153 19.4977 18.7551C19.2194 18.7925 18.8752 18.7912 18.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignRightIcon");var oe=require("react/jsx-runtime"),j1=s(({element:e,editor:t})=>{let r=(0,J1.useForm)({resolver:(0,q1.zodResolver)(ul),defaultValues:{...je,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=kt({editor:t,element:e,form:r,nodeType:"button"});return e?(0,oe.jsxs)(qe,{...r,children:[(0,oe.jsx)(Vt,{type:"button"}),(0,oe.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,oe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,oe.jsx)(j,{control:r.control,name:"link",render:({field:n})=>(0,oe.jsxs)(q,{children:[(0,oe.jsx)(J,{children:(0,oe.jsx)(jr,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})},showToolbar:!0})}),(0,oe.jsx)(K,{})]})}),(0,oe.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,oe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Background"}),(0,oe.jsx)(j,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,oe.jsxs)(q,{className:"courier-mb-4",children:[(0,oe.jsx)(J,{children:(0,oe.jsx)(Et,{...n,defaultValue:je.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,oe.jsx)(K,{})]})}),(0,oe.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,oe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,oe.jsx)(j,{control:r.control,name:"padding",render:({field:n})=>(0,oe.jsxs)(q,{className:"courier-mb-2",children:[(0,oe.jsx)(J,{children:(0,oe.jsx)(be,{type:"number",min:0,...n})}),(0,oe.jsx)(K,{})]})}),(0,oe.jsx)(j,{control:r.control,name:"alignment",render:({field:n})=>(0,oe.jsxs)(q,{children:[(0,oe.jsx)(J,{children:(0,oe.jsxs)(Ir,{type:"single",value:n.value,onValueChange:i=>{n.onChange(i),o({...r.getValues(),alignment:i})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,oe.jsx)($t,{size:"sm",value:"left",className:"courier-w-full",children:(0,oe.jsx)(Al,{className:"courier-h-4 courier-w-4"})}),(0,oe.jsx)($t,{size:"sm",value:"center",className:"courier-w-full",children:(0,oe.jsx)(Il,{className:"courier-h-4 courier-w-4"})}),(0,oe.jsx)($t,{size:"sm",value:"right",className:"courier-w-full",children:(0,oe.jsx)(Sl,{className:"courier-h-4 courier-w-4"})})]})}),(0,oe.jsx)(K,{})]})}),(0,oe.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,oe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,oe.jsx)(j,{control:r.control,name:"borderRadius",render:({field:n})=>(0,oe.jsxs)(q,{children:[(0,oe.jsx)(J,{children:(0,oe.jsx)(be,{startAdornment:(0,oe.jsx)(aa,{}),type:"number",min:0,...n})}),(0,oe.jsx)(K,{})]})})]})]}):null},"ButtonForm");var Ll=require("@tiptap/core"),Y1=require("@tiptap/react"),X1=require("uuid");var Rl=require("jotai"),He=require("react");var Mt=require("react/jsx-runtime"),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();Tt(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=(0,Rl.useAtomValue)(hn);return(0,Mt.jsx)(Mt.Fragment,{children:e.map((r,o)=>{if(r.type==="text")return(0,Mt.jsx)("span",{children:r.content},o);let n=t[r.name];return(0,Mt.jsxs)("span",{className:"courier-inline-flex courier-items-center courier-gap-0.5 courier-rounded courier-border courier-px-1.5 courier-pl-1 courier-py-[1px] courier-text-sm courier-variable-node courier-font-mono courier-max-w-full courier-tracking-[0.64px] courier-variable-in-button",style:{backgroundColor:n?"#EFF6FF":"#FFFBEB",borderColor:n?"#BFDBFE":"#FDE68A",color:"#000000"},children:[(0,Mt.jsx)(fl,{color:n?void 0:"#B45309"}),(0,Mt.jsxs)("span",{className:"courier-truncate courier-min-w-0",style:{color:"#000000"},children:[r.name,n?`="${n}"`:""]})]},o)})})},"ButtonLabelDisplay"),K1=s(({label:e,backgroundColor:t,textColor:r,onLabelChange:o,editable:n})=>{let i=(0,He.useRef)(null),a=(0,He.useRef)(e),l=(0,He.useRef)(!1),[c,u]=(0,He.useState)(!1),p=Qh(e),d=p.some(y=>y.type==="variable")&&!c;(0,He.useLayoutEffect)(()=>{if(!i.current||!d)return;Array.from(i.current.childNodes).filter(S=>S.nodeType===Node.TEXT_NODE).forEach(S=>S.remove())},[d,e]);let f=(0,He.useRef)(d),C=(0,He.useRef)(!0);(0,He.useEffect)(()=>{if(!i.current||d){f.current=d;return}let y=f.current&&!d;f.current=d,(C.current||y||!l.current&&e!==a.current)&&(i.current.textContent=e),C.current=!1,a.current=e},[e,d]);let h=(0,He.useCallback)(()=>{if(i.current&&!d){l.current=!0;let y=i.current.textContent||"";a.current=y,o(y),requestAnimationFrame(()=>{l.current=!1})}},[o,d]),b=(0,He.useCallback)(y=>{var S;if(d){y.preventDefault(),y.stopPropagation();return}if(y.key==="Enter"&&(y.preventDefault(),(S=i.current)==null||S.blur()),(y.metaKey||y.ctrlKey)&&y.key==="a"&&(y.preventDefault(),y.stopPropagation(),i.current)){let P=document.createRange();P.selectNodeContents(i.current);let T=window.getSelection();T==null||T.removeAllRanges(),T==null||T.addRange(P)}},[d]),v=(0,He.useCallback)(()=>{u(!0)},[]),E=(0,He.useCallback)(()=>{u(!1)},[]),g=(0,He.useCallback)(y=>{let S=i.current;if(!S)return;if(d&&n){y.stopPropagation(),setTimeout(()=>{S.focus();let x=document.createRange();x.selectNodeContents(S),x.collapse(!1);let k=window.getSelection();k==null||k.removeAllRanges(),k==null||k.addRange(x)},0);return}if(!n)return;let P=s(()=>{let x=window.getSelection();if(!x||x.rangeCount===0)return;let k=x.getRangeAt(0),M=S.contains(k.startContainer),A=S.contains(k.endContainer);if(M&&!A){let R=document.createRange();R.selectNodeContents(S),x.removeAllRanges(),x.addRange(R)}},"checkAndConstrainSelection"),T=s(x=>{let k=S.getBoundingClientRect();(x.clientX<k.left||x.clientX>k.right||x.clientY<k.top||x.clientY>k.bottom)&&P(),document.removeEventListener("mouseup",T)},"handleMouseUp");document.addEventListener("mouseup",T)},[n,d]),w=d?(0,Mt.jsx)(eb,{parts:p}):n?null:e,N=(0,He.useCallback)(y=>{d&&n&&y.stopPropagation()},[d,n]);return(0,Mt.jsx)("div",{ref:i,contentEditable:n&&!d,suppressContentEditableWarning:!0,tabIndex:n&&d?0:void 0,onInput:h,onKeyDown:b,onPointerDown:g,onClick:N,onFocus:v,onBlur:E,className:I("courier-inline-flex courier-justify-start courier-px-2 courier-py-1 courier-text-sm courier-rounded-sm courier-border courier-border-border courier-outline-none",n&&!d&&"courier-cursor-text"),style:{backgroundColor:t,color:r,borderColor:"transparent",borderRadius:"4px",caretColor:r,WebkitUserSelect:"text",userSelect:"text"},children:w})},"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:p,editable:m=!1})=>(0,Mt.jsx)("div",{className:"node-element",children:(0,Mt.jsxs)("div",{className:"courier-flex courier-gap-1 courier-justify-start",style:{marginTop:`${c}px`,marginBottom:`${c}px`},children:[(0,Mt.jsx)(K1,{label:e,backgroundColor:r,textColor:o,onLabelChange:u||(()=>{}),editable:m},"button1"),(0,Mt.jsx)(K1,{label:n,backgroundColor:a,textColor:l,onLabelChange:p||(()=>{}),editable:m},"button2")]})}),"ButtonRowComponent"),G1=s(e=>{let t=(0,Rl.useSetAtom)(Qe),r=(0,He.useRef)({}),o=(0,He.useRef)({}),n=(0,He.useCallback)(()=>{if(!e.editor.isEditable)return;let l=ht(e);l&&t(l)},[e,t]),i=(0,He.useCallback)(l=>{o.current.button1=l,r.current.button1&&clearTimeout(r.current.button1),r.current.button1=setTimeout(()=>{o.current.button1!==void 0&&e.updateAttributes({button1Label:o.current.button1})},300)},[e]),a=(0,He.useCallback)(l=>{o.current.button2=l,r.current.button2&&clearTimeout(r.current.button2),r.current.button2=setTimeout(()=>{o.current.button2!==void 0&&e.updateAttributes({button2Label:o.current.button2})},300)},[e]);return(0,He.useEffect)(()=>{let l=r.current;return()=>{l.button1&&clearTimeout(l.button1),l.button2&&clearTimeout(l.button2)}},[]),(0,Mt.jsx)(Ht,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"buttonRow",children:(0,Mt.jsx)(tb,{...e.node.attrs,onButton1LabelChange:i,onButton2LabelChange:a,editable:e.editor.isEditable})})},"ButtonRowComponentNode");var Kr={button1Label:"Register",button1Link:"",button1BackgroundColor:"#000000",button1TextColor:"#ffffff",button2Label:"Learn more",button2Link:"",button2BackgroundColor:"#ffffff",button2TextColor:"#000000",padding:6},Bl=Ll.Node.create({name:"buttonRow",group:"block",atom:!0,selectable:!1,onCreate(){gt(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${(0,X1.v4)()}`,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.id})},button1Label:{default:Kr.button1Label,parseHTML:e=>e.getAttribute("data-button1-label"),renderHTML:e=>({"data-button1-label":e.button1Label})},button1Link:{default:Kr.button1Link,parseHTML:e=>e.getAttribute("data-button1-link"),renderHTML:e=>({"data-button1-link":e.button1Link})},button1BackgroundColor:{default:Kr.button1BackgroundColor,parseHTML:e=>e.getAttribute("data-button1-bg"),renderHTML:e=>({"data-button1-bg":e.button1BackgroundColor})},button1TextColor:{default:Kr.button1TextColor,parseHTML:e=>e.getAttribute("data-button1-color"),renderHTML:e=>({"data-button1-color":e.button1TextColor})},button2Label:{default:Kr.button2Label,parseHTML:e=>e.getAttribute("data-button2-label"),renderHTML:e=>({"data-button2-label":e.button2Label})},button2Link:{default:Kr.button2Link,parseHTML:e=>e.getAttribute("data-button2-link"),renderHTML:e=>({"data-button2-link":e.button2Link})},button2BackgroundColor:{default:Kr.button2BackgroundColor,parseHTML:e=>e.getAttribute("data-button2-bg"),renderHTML:e=>({"data-button2-bg":e.button2BackgroundColor})},button2TextColor:{default:Kr.button2TextColor,parseHTML:e=>e.getAttribute("data-button2-color"),renderHTML:e=>({"data-button2-color":e.button2TextColor})},padding:{default:Kr.padding,parseHTML:e=>parseInt(e.getAttribute("data-padding")||"6"),renderHTML:e=>({"data-padding":e.padding})}}},parseHTML(){return[{tag:'div[data-type="buttonRow"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Ll.mergeAttributes)(e,{"data-type":"buttonRow"})]},addNodeView(){return(0,Y1.ReactNodeViewRenderer)(G1,{stopEvent:({event:e})=>!(e.type==="dragstart"||e.type==="drop")})},addCommands(){return{setButtonRow:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...Kr,...e}}).run()}}});var eg=require("@hookform/resolvers/zod"),tg=require("react-hook-form");var Er=require("zod"),Q1=Er.z.object({columnsCount:Er.z.number().min(1).max(4).default(2),paddingHorizontal:Er.z.number().default(0),paddingVertical:Er.z.number().default(0),backgroundColor:Er.z.string().default("transparent"),borderWidth:Er.z.number().default(0),borderRadius:Er.z.number().default(0),borderColor:Er.z.string().default("transparent"),cells:Er.z.array(Er.z.object({elements:Er.z.array(Er.z.any())})).optional()});var Y=require("react/jsx-runtime"),Hd=s(({element:e,editor:t})=>{let r=(0,tg.useForm)({resolver:(0,eg.zodResolver)(Q1),defaultValues:{...wt,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=kt({editor:t,element:e,form:r,nodeType:"column"}),n=s(i=>{if(!t||!e)return;let a=null;if(t.state.doc.descendants((f,C)=>f.attrs.id===e.attrs.id&&f.type.name==="column"?(a=C,!1):!0),a===null)return;let l=t.state.doc.nodeAt(a);if(!l)return;let c=e.attrs.id,u=t.schema,p=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})),C=u.nodes.columnRow.create({},f);p.replaceWith(a+1,a+l.nodeSize-1,C),p.setNodeMarkup(a,void 0,{...l.attrs,columnsCount:i}),p.setMeta("addToHistory",!0),t.view.dispatch(p);return}let d=m.childCount;if(i!==d){if(i>d){let f=i-d,h=a+1+m.nodeSize-1;for(let b=0;b<f;b++){let v=u.nodes.columnCell.create({index:d+b,columnId:c});p.insert(h+b*v.nodeSize,v)}}else{let f=d-i,h=a+1;for(let v=0;v<d-f;v++){let E=m.child(v);h+=E.nodeSize}let b=0;for(let v=d-f;v<d;v++){let E=m.child(v);b+=E.nodeSize}p.delete(h,h+b)}p.setNodeMarkup(a,void 0,{...l.attrs,columnsCount:i}),p.setMeta("addToHistory",!0),t.view.dispatch(p)}},"updateColumnCount");return e?(0,Y.jsxs)(qe,{...r,children:[(0,Y.jsx)(Vt,{type:"column",label:"Column layout"}),(0,Y.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Y.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Columns count"}),(0,Y.jsx)(j,{control:r.control,name:"columnsCount",render:({field:i})=>(0,Y.jsxs)(q,{className:"courier-mb-4",children:[(0,Y.jsx)(J,{children:(0,Y.jsx)(Ir,{type:"single",className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-bg-secondary courier-p-0.5 courier-mb-3 courier-shadow-sm",value:i.value.toString(),onValueChange:a=>{if(a){let l=Number(a);i.onChange(l),n(l)}},children:[1,2,3,4].map(a=>(0,Y.jsx)($t,{value:a.toString(),className:"courier-w-12 courier-h-7",children:(0,Y.jsx)("span",{className:"courier-text-sm courier-font-medium",children:a})},a))})}),(0,Y.jsx)(K,{})]})}),(0,Y.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,Y.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Frame"}),(0,Y.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,Y.jsx)(j,{control:r.control,name:"paddingHorizontal",render:({field:i})=>(0,Y.jsxs)(q,{children:[(0,Y.jsx)(J,{children:(0,Y.jsx)(be,{startAdornment:(0,Y.jsx)(pa,{}),type:"number",min:0,...i})}),(0,Y.jsx)(K,{})]})}),(0,Y.jsx)(j,{control:r.control,name:"paddingVertical",render:({field:i})=>(0,Y.jsxs)(q,{children:[(0,Y.jsx)(J,{children:(0,Y.jsx)(be,{startAdornment:(0,Y.jsx)(vn,{}),type:"number",min:0,...i})}),(0,Y.jsx)(K,{})]})})]}),(0,Y.jsx)(j,{control:r.control,name:"backgroundColor",render:({field:i})=>(0,Y.jsxs)(q,{className:"courier-mb-4",children:[(0,Y.jsx)(J,{children:(0,Y.jsx)(Et,{...i,defaultValue:wt.backgroundColor,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),(0,Y.jsx)(K,{})]})}),(0,Y.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,Y.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Border"}),(0,Y.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,Y.jsx)(j,{control:r.control,name:"borderWidth",render:({field:i})=>(0,Y.jsxs)(q,{children:[(0,Y.jsx)(J,{children:(0,Y.jsx)(be,{startAdornment:(0,Y.jsx)(No,{}),type:"number",min:0,...i})}),(0,Y.jsx)(K,{})]})}),(0,Y.jsx)(j,{control:r.control,name:"borderRadius",render:({field:i})=>(0,Y.jsxs)(q,{children:[(0,Y.jsx)(J,{children:(0,Y.jsx)(be,{startAdornment:(0,Y.jsx)(aa,{}),type:"number",min:0,...i})}),(0,Y.jsx)(K,{})]})})]}),(0,Y.jsx)(j,{control:r.control,name:"borderColor",render:({field:i})=>(0,Y.jsxs)(q,{className:"courier-mb-4",children:[(0,Y.jsx)(J,{children:(0,Y.jsx)(Et,{...i,defaultValue:wt.borderColor,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),(0,Y.jsx)(K,{})]})})]})]}):null},"ColumnForm");var Dl=require("@tiptap/core"),Hl=Dl.Node.create({name:"columnRow",group:"columnContent",content:"columnCell+",isolating:!0,parseHTML(){return[{tag:'div[data-type="column-row"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Dl.mergeAttributes)(e,{"data-type":"column-row",class:"courier-flex courier-flex-row courier-gap-2 courier-w-full",style:"display: flex; flex-direction: row; gap: 0.5rem; width: 100%;"}),0]},addCommands(){return{insertColumnRow:()=>({chain:e})=>e().insertContent({type:this.name}).run()}}});var Fl=require("@tiptap/core"),ng=require("@tiptap/react"),Ol=require("@tiptap/pm/state");var Vl=require("@tiptap/react"),on=require("react");var rg=require("jotai");var qa=require("react/jsx-runtime"),og=s(e=>{let t=(0,on.useRef)(null),[r,o]=(0,on.useState)(!1),n=(0,rg.useAtomValue)(Xt),i=e.node.attrs.isEditorMode===!0,[a,l]=(0,on.useState)(e.editor.isEditable);(0,on.useEffect)(()=>{let p=t.current;if(p)return vr({element:p,getData:()=>({type:"column-cell",columnId:e.node.attrs.columnId,index:e.node.attrs.index}),onDragEnter:()=>o(!0),onDragLeave:()=>o(!1),onDrop:()=>o(!1)})},[e.node.attrs.columnId,e.node.attrs.index]),(0,on.useEffect)(()=>{let p=s(()=>{l(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 c=!a&&!n,u=!i&&!c;return(0,qa.jsxs)(Vl.NodeViewWrapper,{ref:t,"data-column-cell":"true","data-column-id":e.node.attrs.columnId,"data-cell-index":e.node.attrs.index,className:I("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4 courier-pl-0 courier-w-full",!c&&"courier-border",!c&&(r?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),u&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:[u&&(0,qa.jsx)("span",{className:"courier-pointer-events-none courier-pl-4",children:"Drag and drop content blocks"}),(0,qa.jsx)(Vl.NodeViewContent,{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full"})]})},"ColumnCellComponentNode");var Ul=Fl.Node.create({name:"columnCell",group:"columnRow",content:"block*",isolating:!0,selectable:!1,addAttributes(){return{index:{default:0,parseHTML:e=>{let t=e.getAttribute("data-cell-index");return t?parseInt(t,10):0},renderHTML:e=>({"data-cell-index":e.index})},columnId:{default:null,parseHTML:e=>e.getAttribute("data-column-id"),renderHTML:e=>({"data-column-id":e.columnId})},isEditorMode:{default:!1,parseHTML:e=>e.getAttribute("data-editor-mode")==="true",renderHTML:e=>({"data-editor-mode":e.isEditorMode?"true":"false"})}}},parseHTML(){return[{tag:'div[data-type="column-cell"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Fl.mergeAttributes)(e,{"data-type":"column-cell",style:"flex: 1 1 0%; width: 0; min-height: 120px;"}),0]},addNodeView(){return(0,ng.ReactNodeViewRenderer)(og)},addCommands(){return{insertColumnCell:()=>({chain:e})=>e().insertContent({type:this.name}).run()}},addProseMirrorPlugins(){return[new Ol.Plugin({key:new Ol.PluginKey("columnCellCleanup"),appendTransaction:(e,t,r)=>{if(!e.some(i=>i.docChanged))return null;let o=r.tr,n=!1;return r.doc.descendants((i,a)=>{var l,c;if(i.type.name==="columnCell"){let u=i.childCount===0,p=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),p&&m===!1&&(o.delete(a+1,a+i.nodeSize-1),n=!0)}return!0}),n?o:null}})]}});var At=require("react");var ig=require("react"),ag=require("react/jsx-runtime"),Vd=(0,ig.forwardRef)(({className:e,...t},r)=>{let o=I("courier-animate-spin courier-rounded-full courier-border-2 courier-border-current courier-border-t-transparent courier-h-4 courier-w-4",e);return(0,ag.jsx)("div",{className:o,ref:r,...t})});Vd.displayName="Spinner";var Fn=require("react/jsx-runtime"),rb=s(()=>{let[e,t]=(0,At.useState)(!1),r=(0,At.useRef)(null);return(0,At.useEffect)(()=>{var i;let o=s(()=>{if(r.current){let a=r.current.closest(".dark")!==null;t(a)}},"checkDarkMode");o();let n=new MutationObserver(o);return(i=r.current)!=null&&i.parentElement&&n.observe(document.body,{attributes:!0,attributeFilter:["class"],subtree:!0}),()=>n.disconnect()},[]),{isDark:e,containerRef:r}},"useIsDarkMode"),ob=(0,At.lazy)(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function nb(e,t){let r=(0,At.useRef)();return(0,At.useCallback)((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}s(nb,"useDebounce");var ib=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 d=(e.match(/<([a-z][a-z0-9]*)\b[^>]*(?<!\/\/)>/gi)||[]).map(b=>{var v,E;return(E=(v=b.match(/<([a-z][a-z0-9]*)/i))==null?void 0:v[1])==null?void 0:E.toLowerCase()}).filter(Boolean),f=(e.match(/<\/([a-z][a-z0-9]*)\s*>/gi)||[]).map(b=>{var v,E;return(E=(v=b.match(/<\/([a-z][a-z0-9]*)/i))==null?void 0:v[1])==null?void 0:E.toLowerCase()}).filter(Boolean),C=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],h=d.filter(b=>b&&!C.includes(b));for(let b of h){let v=d.filter(g=>g===b).length,E=f.filter(g=>g===b).length;if(v!==E)return!1}return!0}catch{return!1}},"defaultHTMLValidator"),Wl=s(({code:e,onSave:t,onValidationChange:r,validator:o=ib})=>{let n=(0,At.useRef)(null),i=(0,At.useRef)(null),[a,l]=(0,At.useState)(!0),{isDark:c,containerRef:u}=rb(),p=(0,At.useCallback)(()=>{if(!n.current||!i.current)return!0;let C=n.current.getModel();if(!C)return!0;let h=C.getValue(),b=o(h,n.current,i.current);return b!==a&&(l(b),r==null||r(b)),b},[a,r,o]),m=nb(C=>{setTimeout(()=>{p()&&t(C)},150)},500);return(0,Fn.jsx)("div",{ref:u,className:"courier-h-full courier-overflow-hidden",children:(0,Fn.jsx)("div",{className:"courier-h-full courier-p-2",children:(0,Fn.jsx)(At.Suspense,{fallback:(0,Fn.jsx)("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:(0,Fn.jsx)(Vd,{})}),children:(0,Fn.jsx)(ob,{height:"100%",defaultLanguage:"html",value:e,onChange:s(C=>{m(C||"")},"handleCodeChange"),onMount:s((C,h)=>{n.current=C,i.current=h,C.focus(),C.onDidChangeModelContent(()=>{setTimeout(p,100)}),setTimeout(p,100)},"handleEditorDidMount"),theme:c?"vs-dark":"vs-light",options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,wordWrap:"on",automaticLayout:!0,tabSize:2,insertSpaces:!0,formatOnPaste:!0,formatOnType:!0,glyphMargin:!1,folding:!1,lineDecorationsWidth:10,lineNumbersMinChars:0,fixedOverflowWidgets:!0}})})})})},"MonacoCodeEditor");var lg=require("@hookform/resolvers/zod"),cg=require("react-hook-form");var Fd=require("zod"),sg=Fd.z.object({code:Fd.z.string()});var ug=require("react"),dg=require("jotai");var rt=require("react/jsx-runtime"),Od=s(({element:e,editor:t})=>{let r=(0,cg.useForm)({resolver:(0,lg.zodResolver)(sg),defaultValues:{...Ao,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=kt({editor:t,element:e,form:r,nodeType:"customCode"}),[n,i]=(0,dg.useAtom)(lo),a=(0,ug.useCallback)(l=>{r.setValue("code",l),o({code:l})},[r,o]);return e?(0,rt.jsxs)(qe,{...r,children:[!n&&(0,rt.jsx)(Vt,{type:"customCode"}),(0,rt.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[(0,rt.jsx)(Se,{className:"courier-w-fit",variant:"outline",buttonSize:"small",onClick:()=>i(!n),children:n?(0,rt.jsxs)(rt.Fragment,{children:[(0,rt.jsx)(Ju,{className:"courier-w-3 courier-h-3"}),"Minimize"]}):(0,rt.jsxs)(rt.Fragment,{children:[(0,rt.jsx)(sa,{className:"courier-w-3 courier-h-3"}),"Expand Editor"]})}),(0,rt.jsx)("div",{className:"courier-mb-4 courier-overflow-hidden courier-rounded-md courier-border courier-border-border",style:{minHeight:"200px",height:"300px",resize:"vertical",overflow:"auto"},children:(0,rt.jsx)("form",{onChange:()=>{o(r.getValues())},className:"courier-h-full",children:(0,rt.jsx)(j,{control:r.control,name:"code",render:({field:l})=>(0,rt.jsxs)(q,{className:"courier-h-full",children:[(0,rt.jsx)(J,{children:(0,rt.jsx)(Wl,{code:l.value,onSave:c=>{l.onChange(c),a(c)},onCancel:()=>{}})}),(0,rt.jsx)(K,{})]})})})})]})]}):null},"CustomCodeForm");var On=require("zod"),mg=On.z.object({padding:On.z.number(),color:On.z.string(),size:On.z.number(),radius:On.z.number(),variant:On.z.enum(["divider","spacer"]).default("divider")});var pg=require("@hookform/resolvers/zod"),fg=require("react-hook-form");var Pe=require("react/jsx-runtime"),gg=s(({element:e,editor:t})=>{let r=(0,fg.useForm)({resolver:(0,pg.zodResolver)(mg),defaultValues:{...Tr,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=kt({editor:t,element:e,form:r,nodeType:"divider"});if(!e)return null;let n=r.watch("variant");return(0,Pe.jsxs)(qe,{...r,children:[(0,Pe.jsx)(Vt,{type:n}),(0,Pe.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Pe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,Pe.jsx)(j,{control:r.control,name:"padding",render:({field:i})=>(0,Pe.jsxs)(q,{children:[(0,Pe.jsx)(J,{children:(0,Pe.jsx)(be,{startAdornment:(0,Pe.jsx)(vn,{}),type:"number",...i,onChange:a=>{i.onChange(a),o({...r.getValues(),margin:a.target.value})}})}),(0,Pe.jsx)(K,{})]})}),n==="divider"&&(0,Pe.jsxs)(Pe.Fragment,{children:[(0,Pe.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,Pe.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Line"}),(0,Pe.jsx)(j,{control:r.control,name:"size",render:({field:i})=>(0,Pe.jsxs)(q,{className:"courier-mb-4",children:[(0,Pe.jsx)(J,{children:(0,Pe.jsx)(be,{startAdornment:(0,Pe.jsx)(No,{}),type:"number",min:0,...i,onChange:a=>{i.onChange(a),o({...r.getValues(),width:a.target.value})}})}),(0,Pe.jsx)(K,{})]})}),(0,Pe.jsx)(j,{control:r.control,name:"color",render:({field:i})=>(0,Pe.jsxs)(q,{className:"courier-mb-4",children:[(0,Pe.jsx)(J,{children:(0,Pe.jsx)(Et,{...i,defaultValue:Tr.color,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),(0,Pe.jsx)(K,{})]})})]})]})]})},"DividerForm");var Ud=xi.extend({content:"(block)+"});var yg=require("@tiptap/core"),Cg=require("@tiptap/react");var hg=require("@tiptap/react"),Un=require("react");var Ja=require("react/jsx-runtime");function ab(){let[e,t]=(0,Un.useState)(!1);return(0,Un.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(ab,"useMountStatus");var sb=(0,Un.forwardRef)(({children:e,className:t,dragOverlay:r,id:o},n)=>((0,Un.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),(0,Ja.jsx)(hg.NodeViewWrapper,{ref:n,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":o,"data-placeholder":"true",className:I("courier-flex courier-items-start courier-gap-2 courier-pl-6",t),children:e}))),lb=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"),bg=s(({node:e})=>{let t=e.attrs.type,r=e.attrs.id,o=ab();return(0,Ja.jsx)(sb,{id:r,fadeIn:!o,children:(0,Ja.jsx)("div",{className:I("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md"),children:(0,Ja.jsx)("div",{className:"courier-text-accent-foreground",children:lb(t)})})})},"DragPlaceholderComponent");var vg=yg.Node.create({name:"dragPlaceholder",group:"block",atom:!0,draggable:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},type:{default:"text",parseHTML:e=>e.getAttribute("data-type"),renderHTML:e=>({"data-type":e.type})}}},parseHTML(){return[{tag:'div[data-type="drag-placeholder"]'}]},renderHTML({HTMLAttributes:e}){return["div",{"data-type":"drag-placeholder",...e},0]},addCommands(){return{setDragPlaceholder:e=>({tr:t,dispatch:r})=>{if(r){let o=this.type.create(e);typeof e.pos=="number"?t.insert(e.pos,o):t.replaceSelectionWith(o)}return!0},removeDragPlaceholder:()=>({tr:e,state:t,dispatch:r})=>{let o=!1;return t.doc.descendants((n,i)=>n.type.name===this.name?(r&&(n!=null&&n.nodeSize)&&(e.delete(i,i+n.nodeSize),o=!0),!1):!0),o}}},addNodeView(){return(0,Cg.ReactNodeViewRenderer)(bg,{as:"div",className:"drag-placeholder-wrapper"})}});var xg=require("@tiptap/core"),_l=require("@tiptap/pm/state"),cb=new _l.PluginKey("file-handler"),ub=xg.Extension.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new _l.Plugin({key:cb,props:{handleDrop:(o,n,i,a)=>{var p;if(!((p=n.dataTransfer)!=null&&p.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)}}})]}}),zl=ub;var Tg=require("@tiptap/core"),$l=require("@tiptap/pm/state");var db=new $l.PluginKey("fixedChannelPaste"),mb=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(p=>{p.type.name==="paragraph"||p.type.name==="heading"?i++:p.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"),pb=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(`
201
- `).trim()},"extractTextFromSlice"),Zl=Tg.Extension.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new $l.Plugin({key:db,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!mb(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=pb(o);if(!u)return!1;r.preventDefault();let p=n.tr.replaceSelectionWith(n.schema.text(u),!1);return t.dispatch(p),!0}}})]},addStorage(){return{currentChannel:null}}});var kg=require("@tiptap/core"),nn=require("@tiptap/pm/state");var Wn=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"),Wd=s(e=>!!e.view.dom.closest(".courier-inbox-editor"),"isInInboxChannel"),Eg=s(e=>{if(!Wd(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"),_n=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"),ql=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"),Jl=new nn.PluginKey("fixedChannelSelection"),jl=kg.Extension.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!Wn(e,this.options.channels))return!1;let o=_n(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(nn.TextSelection.create(t.doc,l,c)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!Wn(e,this.options.channels))return!1;let t=_n(e);if(!t)return!1;let{start:r,end:o}=t;return e.commands.setTextSelection({from:r,to:o}),!0},Backspace:({editor:e})=>{if(!Wn(e,this.options.channels))return!1;if(Wd(e)){let{selection:t}=e.state;if(_n(e)&&t.$anchor.parentOffset===0&&Eg(e))return!0}if(ql(e)){let t=_n(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(!Wn(e,this.options.channels))return!1;if(Wd(e)){let{selection:t}=e.state,r=_n(e);if(r){let o=r.node.textContent;if(t.$anchor.parentOffset===o.length&&Eg(e))return!0}}if(ql(e)){let t=_n(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 nn.Plugin({key:Jl,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!Wn(o,this.options.channels))return!1;if(ql(o)){let n=_n(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(nn.TextSelection.create(u.doc,l,c)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!Wn(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(Jl,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!Wn(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&ql(r)){let n=Jl.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(nn.TextSelection.create(c.doc,a,l)),e.dispatch(c),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(Jl)||t}}})]}});var Pg=require("@tiptap/core");var Ni=require("@tiptap/core"),wg=Ni.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,(0,Ni.mergeAttributes)(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>(0,Ni.textblockTypeInputRule)({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var Ng=require("@tiptap/react");var _d=wg.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){gt(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:pe.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):pe.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:pe.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):pe.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:pe.textAlign,parseHTML:t=>t.style.textAlign||pe.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:pe.backgroundColor,parseHTML:t=>t.style.backgroundColor||pe.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:pe.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):pe.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderColor:{default:pe.borderColor,parseHTML:t=>t.style.borderColor||pe.borderColor,renderHTML:t=>({style:`border-color: ${t.borderColor}`})},id:{default:()=>null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>({"data-id":t.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},addCommands(){return{setTextAlign:e=>({chain:t})=>t().updateAttributes(this.name,{textAlign:e}).run()}},parseHTML(){return[{tag:'div[data-type="heading"]'}]},renderHTML({node:e,HTMLAttributes:t}){let r=parseInt(e.attrs.level,10);return[`h${this.options.levels.includes(r)?r:this.options.levels[0]}`,(0,Pg.mergeAttributes)(this.options.HTMLAttributes,t),0]},addNodeView(){return(0,Ng.ReactNodeViewRenderer)(rl)}});var Gr=require("zod"),Mg=Gr.z.object({sourcePath:Gr.z.string(),link:Gr.z.string().optional(),alt:Gr.z.string().optional(),alignment:Gr.z.enum(["left","center","right"]),width:Gr.z.number().min(1).max(100),borderWidth:Gr.z.number(),borderColor:Gr.z.string(),isUploading:Gr.z.boolean().optional(),imageNaturalWidth:Gr.z.number()});var Ag=require("@hookform/resolvers/zod"),Ig=require("jotai"),Sg=require("lucide-react"),yt=require("react"),Rg=require("react-hook-form");var Kl=require("jotai"),Ka=he(require("react"),1),zd=require("react");var ja=require("react/jsx-runtime"),an=Ka.forwardRef(({as:e="Input",autoResize:t,onChange:r,...o},n)=>{let i=(0,zd.useRef)(null),a=(0,zd.useRef)(null),l=(0,Kl.useSetAtom)(Ca),c=(0,Kl.useSetAtom)(Sp),u=(0,Kl.useSetAtom)(Ls),p=Ka.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=Ka.useCallback(h=>{var v;((v=h.relatedTarget)==null?void 0:v.closest("[data-variable-button]"))||(c({ref:null,caretPosition:null}),l({isFocused:!1,hasVariables:!1,showVariablePopup:!1}))},[l,c]),d=s(h=>{let b=h.target,v={ref:b,caretPosition:b.selectionStart};c(v),u(v)},"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:p,onBlur:m,onSelect:d};return(0,ja.jsx)("div",{ref:i,className:"courier-relative",children:(0,ja.jsx)(be,{...h})})}let C={...o,ref:h=>{a.current=h,typeof n=="function"?n(h):n&&(n.current=h)},onChange:f,onFocus:p,onBlur:m,autoResize:t,onSelect:d};return(0,ja.jsx)("div",{ref:i,className:"courier-relative",children:(0,ja.jsx)(gu,{...C})})});an.displayName="TextInput";var W=require("react/jsx-runtime"),Lg=s(({element:e,editor:t})=>{var S,P;let r=(0,yt.useRef)(null),o=(0,yt.useRef)(null),n=(0,yt.useRef)(null),[i,a]=(0,yt.useState)(""),[l,c]=(0,yt.useState)(!1),[u,p]=(0,yt.useState)(((S=e==null?void 0:e.attrs)==null?void 0:S.imageNaturalWidth)||0),[m,d]=(0,yt.useState)(!1),f=(0,Ig.useSetAtom)(G),{uploadImage:C}=Qn(),h=(0,Rg.useForm)({resolver:(0,Ag.zodResolver)(Mg),defaultValues:{...lt,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:b}=kt({editor:t,element:e,form:h,nodeType:"imageBlock"});(0,yt.useEffect)(()=>{var x;let T=(x=e==null?void 0:e.attrs)==null?void 0:x.sourcePath;if(T&&!u){let k=new Image;k.onload=()=>{p(k.naturalWidth);let M={...h.getValues(),imageNaturalWidth:k.naturalWidth};h.setValue("imageNaturalWidth",k.naturalWidth),b(M)},k.src=T}},[(P=e==null?void 0:e.attrs)==null?void 0:P.sourcePath,u,h,b]);let v=(0,yt.useCallback)(T=>{var R,B;let x=(B=(R=t==null?void 0:t.view)==null?void 0:R.dom)==null?void 0:B.closest(".ProseMirror"),k=(x==null?void 0:x.clientWidth)||1e3;if(T||(T=u),!T)return 0;let M=Math.min(100,T/k*100);return Math.round(M)},[t,u]),E=(0,yt.useCallback)(T=>{var x;T.preventDefault(),(x=r.current)==null||x.click()},[]),g=(0,yt.useCallback)((T,x)=>{let k=v(T.naturalWidth);a(`${k}%`),c(!1),h.setValue("sourcePath",x),h.setValue("imageNaturalWidth",T.naturalWidth),h.setValue("width",k);let M={...h.getValues(),sourcePath:x,width:k,imageNaturalWidth:T.naturalWidth,isUploading:!1};b(M)},[h,b,v]),w=(0,yt.useCallback)(T=>{if(!T){h.setValue("imageNaturalWidth",0),h.setValue("width",0),b({...h.getValues(),sourcePath:"",imageNaturalWidth:0,width:0});return}let x=new Image;x.onload=()=>{let k=v(x.naturalWidth);h.setValue("imageNaturalWidth",x.naturalWidth),h.setValue("width",k);let M={...h.getValues(),sourcePath:T,width:k,imageNaturalWidth:x.naturalWidth};b(M)},x.onerror=()=>{console.debug("Image failed to load:",T)},x.src=T},[h,b,v]),N=(0,yt.useCallback)(T=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{w(T)},500)},[w]);(0,yt.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]);let y=h.getValues().sourcePath;return e?(0,W.jsxs)(qe,{...h,children:[(0,W.jsx)(Vt,{type:"image"}),(0,W.jsxs)("form",{ref:o,onChange:()=>{let T=h.getValues();b(T)},children:[(0,W.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),(0,W.jsxs)(Es,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[(0,W.jsxs)(na,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[(0,W.jsx)(ai,{value:"file",className:"courier-flex-1",children:"From file"}),(0,W.jsx)(ai,{value:"url",className:"courier-flex-1",children:"From URL"})]}),(0,W.jsx)(ks,{value:"file",children:(0,W.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,W.jsx)(Se,{onClick:E,className:"courier-w-full",variant:"outline",type:"button",disabled:m,children:m?(0,W.jsx)(W.Fragment,{children:"Uploading..."}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Sg.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),(0,W.jsx)("input",{ref:r,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:T=>{var k;let x=(k=T.target.files)==null?void 0:k[0];if(x){d(!0),h.setValue("sourcePath",""),b({...h.getValues(),sourcePath:"",isUploading:!0});let M=new FileReader;M.onload=async()=>{try{let R=(await C({file:x})).url,B=new Image;B.onload=()=>{g(B,R),d(!1)},B.onerror=()=>{f({message:"Upload failed: Failed to load uploaded image",toastProps:{duration:6e3,description:`File: ${x.name} (${(x.size/1024/1024).toFixed(2)}MB)`}}),d(!1),b({...h.getValues(),isUploading:!1})},B.src=R}catch(A){console.error("Error uploading image:",A),f({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${x.name} (${(x.size/1024/1024).toFixed(2)}MB)`}}),d(!1),b({...h.getValues(),isUploading:!1})}},M.onerror=()=>{f({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${x.name} (${(x.size/1024/1024).toFixed(2)}MB)`}}),d(!1),b({...h.getValues(),isUploading:!1})},M.readAsDataURL(x)}}})]})}),(0,W.jsx)(ks,{value:"url",children:(0,W.jsx)(j,{control:h.control,name:"sourcePath",render:({field:T})=>(0,W.jsxs)(q,{className:"courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)(an,{as:"Textarea",...T,autoResize:!0,className:"courier-max-h-[88px]",onChange:x=>{T.onChange(x),N(x.target.value)}})}),(0,W.jsx)(K,{})]})})})]}),(0,W.jsx)(j,{control:h.control,name:"link",render:({field:T})=>(0,W.jsxs)(q,{className:"courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)(jr,{placeholder:"Link",value:T.value,onChange:x=>{T.onChange(x),b({...h.getValues(),link:x})},showToolbar:!0})}),(0,W.jsx)(K,{})]})}),(0,W.jsx)(j,{control:h.control,name:"alt",render:({field:T})=>(0,W.jsxs)(q,{className:"courier-mb-4",children:[(0,W.jsx)(J,{children:(0,W.jsx)(jr,{placeholder:"Alt text...",value:T.value,onChange:x=>{T.onChange(x),b({...h.getValues(),alt:x})},showToolbar:!0})}),(0,W.jsx)(K,{})]})}),(0,W.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,W.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Width"}),(()=>{let T=h.getValues().width,x=h.getValues().imageNaturalWidth,k=v(x),M=T===k,A=M?"original":"fill";return(0,W.jsxs)(Ir,{type:"single",value:y?A:"original",onValueChange:R=>{if(!R||R===A)return;let B=R==="fill"?100:v(x);B>0&&(h.setValue("width",B),b({...h.getValues(),width:B}))},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",disabled:!y,children:[(0,W.jsx)($t,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),(0,W.jsx)($t,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:M||!y,children:"Fill"})]})})(),(0,W.jsx)(j,{control:h.control,name:"width",render:({field:T})=>(0,W.jsxs)(q,{className:"courier-flex-1 courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)(be,{type:"text",inputMode:"numeric",pattern:"[0-9]*",min:1,max:100,...T,value:h.getValues().sourcePath?l?i:`${T.value}%`:"0%",className:"courier-text-2xl courier-font-normal",disabled:!h.getValues().sourcePath,onFocus:x=>{c(!0),a(x.target.value)},onChange:x=>{a(x.target.value)},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),x.currentTarget.blur())},onBlur:x=>{c(!1);let k=parseFloat(x.target.value.replace("%",""));if(!isNaN(k)){let M=Math.min(100,Math.max(1,k));T.onChange(M),b({...h.getValues(),width:Math.round(M)})}}})}),(0,W.jsx)(K,{})]})}),(0,W.jsx)(j,{control:h.control,name:"width",render:({field:T})=>(0,W.jsxs)(q,{className:"courier-flex-1 courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)(pu,{min:0,max:100,value:[y?T.value:0],disabled:!y,onValueChange:x=>{T.onChange(x[0]),b({...h.getValues(),width:x[0]})}})}),(0,W.jsx)(K,{})]})}),(0,W.jsx)(j,{control:h.control,name:"alignment",render:({field:T})=>(0,W.jsxs)(q,{children:[(0,W.jsx)(J,{children:(0,W.jsxs)(Ir,{disabled:!y,type:"single",value:T.value,onValueChange:x=>{T.onChange(x),b({...h.getValues(),alignment:x})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,W.jsx)($t,{size:"sm",value:"left",className:"courier-w-full",children:(0,W.jsx)(Al,{className:"courier-h-4 courier-w-4"})}),(0,W.jsx)($t,{size:"sm",value:"center",className:"courier-w-full",children:(0,W.jsx)(Il,{className:"courier-h-4 courier-w-4"})}),(0,W.jsx)($t,{size:"sm",value:"right",className:"courier-w-full",children:(0,W.jsx)(Sl,{className:"courier-h-4 courier-w-4"})})]})}),(0,W.jsx)(K,{})]})}),(0,W.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,W.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,W.jsx)(j,{control:h.control,name:"borderWidth",render:({field:T})=>(0,W.jsxs)(q,{className:"courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)(be,{startAdornment:(0,W.jsx)(No,{}),type:"number",disabled:!y,min:0,...T,onChange:x=>{let k=parseInt(x.target.value)||0;T.onChange(k),b({...h.getValues(),borderWidth:k})}})}),(0,W.jsx)(K,{})]})}),(0,W.jsx)(j,{control:h.control,name:"borderColor",render:({field:T})=>(0,W.jsxs)(q,{className:"courier-mb-4",children:[(0,W.jsx)(J,{children:(0,W.jsx)(Et,{...T,disabled:!y,defaultValue:lt.borderColor,onChange:x=>{T.onChange(x),b({...h.getValues(),[T.name]:x})}})}),(0,W.jsx)(K,{})]})})]})]}):null},"ImageBlockForm");var Ga=require("@tiptap/core"),Bg=he(require("@tiptap/extension-link"),1),Mi=require("@tiptap/pm/state"),$d=Bg.default.extend({inclusive:!0,addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),hasVariables:{default:!1},originalHref:{default:null}}},parseHTML(){return[{tag:'a[href]:not([data-type="button"]):not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:e}){if(e.hasVariables&&e.originalHref)e.href=e.originalHref,delete e.hasVariables,delete e.originalHref;else if(e.href){let t=e.href;t.includes("__VAR_")&&(e.href=t.replace(/__VAR_([^_]+)__/g,"{{$1}}"))}return["a",(0,Ga.mergeAttributes)(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new Mi.Plugin({props:{handleClick:(r,o,n)=>{if(n.button!==0)return!1;let{state:i}=r,{doc:a}=i,l=a.resolve(o),c=l.marks().find(u=>u.type.name==="link");if(c||o>0&&(c=a.resolve(o-1).marks().find(p=>p.type.name==="link")),c||o<a.content.size&&(c=a.resolve(o+1).marks().find(p=>p.type.name==="link")),c){let u=(0,Ga.getMarkRange)(l,c.type);return u?(r.dispatch(i.tr.setSelection(Mi.TextSelection.create(a,u.from,u.to))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:u.from,to:u.to,href:c.attrs.originalHref||c.attrs.href})),!0):(r.dispatch(i.tr.setSelection(Mi.TextSelection.create(a,o,o+1))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:o,to:o+1,href:c.attrs.originalHref||c.attrs.href})),!0)}return!1}}}),new Mi.Plugin({appendTransaction(r,o,n){if(!r.some(l=>l.docChanged))return null;let i=n.tr,a=!1;return n.doc.descendants((l,c)=>(l.marks.forEach(u=>{if(u.type.name==="link"&&u.attrs.href){let p=u.attrs.href;if(p.includes("__VAR_")){let m=p.replace(/__VAR_([^_]+)__/g,"{{$1}}");if(m!==p){let d=(0,Ga.getMarkRange)(n.doc.resolve(c),u.type);d&&(i.removeMark(d.from,d.to,u.type),i.addMark(d.from,d.to,u.type.create({...u.attrs,href:m,hasVariables:!0,originalHref:m})),a=!0)}}}}),!0)),a?i:null}})]}});var Dg=require("@hookform/resolvers/zod"),Hg=require("jotai"),Yl=require("react"),Vg=require("react-hook-form"),Gl=require("zod");var Yr=require("react/jsx-runtime"),fb=Gl.z.object({href:Gl.z.string(),openInNewTab:Gl.z.boolean().default(!1)}),Fg=s(({editor:e,mark:t,pendingLink:r})=>{let o=(0,Hg.useSetAtom)(Bs),n=(0,Yl.useRef)(null),i=(0,Vg.useForm)({resolver:(0,Dg.zodResolver)(fb),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1}});(0,Yl.useEffect)(()=>{i.reset({href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1})},[t,i]);let a=s(async l=>{let c=l.href.trim();if(!c){r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),e==null||e.commands.unsetLink(),o(null);return}r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),await(e==null?void 0:e.chain().focus().unsetLink().setTextSelection({from:(r==null?void 0:r.from)||0,to:(r==null?void 0:r.to)||0}).setLink({href:c,target:l.openInNewTab?"_blank":null}).run()),e==null||e.commands.setTextSelection((r==null?void 0:r.to)||0),o(null)},"updateLink");return(0,Yr.jsxs)(qe,{...i,children:[(0,Yr.jsx)("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),(0,Yr.jsx)("div",{className:"courier-space-y-4",children:(0,Yr.jsx)(j,{control:i.control,name:"href",render:({field:l})=>(0,Yr.jsxs)(q,{children:[(0,Yr.jsx)(uo,{children:"URL"}),(0,Yr.jsx)(J,{children:(0,Yr.jsx)(an,{as:"Textarea",autoResize:!0,...l,ref:c=>{typeof l.ref=="function"&&l.ref(c),n.current=c},onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),c.stopPropagation(),i.handleSubmit(a)())},onBlur:()=>{l.onBlur(),i.handleSubmit(a)()}})}),(0,Yr.jsx)(K,{})]})})})]})},"LinkForm");var ec=require("@tiptap/react"),Ai=require("prosemirror-state");var So={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:"'"},Ql={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},gb=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),hb=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ot=0;ot<10;ot++)So[48+ot]=So[96+ot]=String(ot);var ot;for(ot=1;ot<=24;ot++)So[ot+111]="F"+ot;var ot;for(ot=65;ot<=90;ot++)So[ot]=String.fromCharCode(ot+32),Ql[ot]=String.fromCharCode(ot);var ot;for(Xl in So)Ql.hasOwnProperty(Xl)||(Ql[Xl]=So[Xl]);var Xl;function Og(e){var t=gb&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||hb&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?Ql:So)[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(Og,"keyName");var Ug=require("prosemirror-state");var bb=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function yb(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))bb?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(yb,"normalizeKeyName");function Cb(e){let t=Object.create(null);for(let r in e)t[yb(r)]=e[r];return t}s(Cb,"normalize");function Zd(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(Zd,"modifiers");function Wg(e){return new Ug.Plugin({props:{handleKeyDown:vb(e)}})}s(Wg,"keymap");function vb(e){let t=Cb(e);return function(r,o){let n=Og(o),i,a=t[Zd(n,o)];if(a&&a(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let l=t[Zd(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=So[o.keyCode])&&i!=n){let l=t[Zd(i,o)];if(l&&l(r.state,r.dispatch,r))return!0}}return!1}}s(vb,"keydownHandler");var _g=require("uuid");var qd=Ti.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){gt(this.editor,this.name)},onTransaction(){let e=this.editor.state.tr,t=!1;this.editor.state.doc.descendants((r,o)=>{if(r.type.name===this.name&&!r.attrs.id){let n=`node-${(0,_g.v4)()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:pe.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):pe.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:pe.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):pe.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:pe.textAlign,parseHTML:e=>e.style.textAlign||pe.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:pe.backgroundColor,parseHTML:e=>e.style.backgroundColor||pe.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:pe.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):pe.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:pe.borderColor,parseHTML:e=>e.style.borderColor||pe.borderColor,renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="paragraph"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,ec.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return(0,ec.ReactNodeViewRenderer)(rl)},addProseMirrorPlugins(){return[Wg({"Mod-a":({selection:e,tr:t})=>{document.execCommand("selectAll");let{$from:r}=e,o=r.depth,n=null;for(;o>0;){let i=r.node(o);if(i.type.name==="paragraph"||i.type.name==="heading"){n=i;break}o--}if(n){let i=r.start(o),a=r.end(o);if(e.from!==i||e.to!==a)return t.setSelection(Ai.TextSelection.create(t.doc,i,a)),!0}return!1}}),new Ai.Plugin({key:new Ai.PluginKey("preventElementDeletion"),props:{handleKeyDown:(e,t)=>{let r=t.key==="Delete"||t.key==="Backspace"||t.keyCode===8||t.keyCode===46||t.code==="Delete"||t.code==="Backspace",o=t.metaKey||t.ctrlKey||t.altKey;if(r){let{state:n}=e,{selection:i}=n,{$anchor:a}=i,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,p=a.parentOffset===0,m=a.parentOffset===u.length,d=u.length===0,f=t.key==="Delete"||t.keyCode===46||t.code==="Delete",C=f?i.$from.nodeAfter:i.$from.nodeBefore,h=C!=null;if(h&&d)return!1;if(o||d&&!h||!f&&p&&!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 d=n.node(a);if(d.type.name==="paragraph"||d.type.name==="heading"){l=d;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,p=r?t.state.selection.$from.nodeBefore:t.state.selection.$from.nodeAfter,m=p!=null;return m&&u?!1:c&&!m||u&&!m?!0:o?!1:(t.commands.command(({tr:d,dispatch:f})=>f?(d.insertText("",t.state.selection.from,t.state.selection.to),!0):!1),!0)},"handleDeletion");return{Enter:({editor:t})=>{if(t.view.dom.querySelector(".variable-suggestion")||t.view.state.selection.$from.node().type.spec.code)return!1;let{state:o,dispatch:n}=t.view,{tr:i}=o;return i.replaceSelectionWith(o.schema.nodes.hardBreak.create()).scrollIntoView(),n(i),!0},"Mod-a":({editor:t})=>{let{$from:r}=t.state.selection,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),a=r.end(o);return t.commands.setTextSelection({from:i,to:a}),!0}o--}return!1},Backspace:({editor:t})=>e(t,!0),Delete:({editor:t})=>e(t,!1),Tab:()=>!0,"Shift-Tab":()=>!0}},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setTextAlign:t=>({chain:r})=>r().updateAttributes(this.name,{textAlign:t}).run()}}});var zg=require("@tiptap/core"),tc=require("@tiptap/pm/state"),xb=new tc.PluginKey("selection"),Jd=zg.Extension.create({name:"selection",addOptions(){return{HTMLAttributes:{},setSelectedNode:()=>{},shouldHandleClick:()=>!0}},addGlobalAttributes(){return[{types:["paragraph","heading","button","spacer","divider","imageBlock","blockquote","customCode","column"],attributes:{isSelected:{default:!1,parseHTML:()=>!1,renderHTML:e=>e.isSelected?{class:"selected-element"}:{}}}}]},addCommands(){return{updateSelectionState:e=>({tr:t,dispatch:r})=>{var o,n;if(r){let i=(o=e==null?void 0:e.attrs)==null?void 0:o.id,a=(n=e==null?void 0:e.type)==null?void 0:n.name;t.doc.descendants((l,c)=>{var u,p,m;if(l.type.name!=="text"&&((u=l.type.spec.attrs)==null?void 0:u.isSelected)!==void 0){let d=!1;i?d=((p=l.attrs)==null?void 0:p.id)===i&&l.type.name===a:a&&(d=l.type.name===a&&l.content.size===((m=e==null?void 0:e.content)==null?void 0:m.size)),d?t.setNodeAttribute(c,"isSelected",!0):t.setNodeAttribute(c,"isSelected",!1)}return!0})}return!0}}},addProseMirrorPlugins(){return[new tc.Plugin({key:xb,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(p=>u.closest(p)))){let p=e.posAtDOM(u,0),d=o.doc.resolve(p).node();if(d&&["paragraph","heading"].includes(d.type.name))return this.options.setSelectedNode(d),this.editor.commands.updateSelectionState(d),!0}}}catch(l){console.error("Error handling click:",l)}let i=e.posAtDOM(n,0),a=o.doc.resolve(i).node();return a&&["paragraph","heading"].includes(a.type.name)?(this.options.setSelectedNode(a),this.editor.commands.updateSelectionState(a),!0):!1}}})]}});var Ko=s(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),ht=s(e=>{let t=Ko(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");var $g=require("lucide-react"),Zg=require("react"),rm=require("react/jsx-runtime"),qg=(0,Zg.forwardRef)((e,t)=>(0,rm.jsx)("button",{...e,ref:t,"data-cypress":"draggable-handle","data-drag-handle":!0,className:I("courier-flex-shrink-0 courier-p-1 courier-w-7 courier-h-7 courier-rounded-md courier-border courier-border-border courier-flex courier-items-center courier-justify-center courier-shadow-sm courier-bg-background hover:courier-bg-card courier-cursor-grab courier-select-none courier-z-10 courier-touch-none",e.className),style:{WebkitUserSelect:"none",userSelect:"none",touchAction:"none"},children:(0,rm.jsx)($g.GripVertical,{strokeWidth:1,className:"courier-w-5 courier-stroke-neutral-400 courier-fill-neutral-400 courier-pointer-events-none"})}));var jg=require("jotai");var rc=require("react/jsx-runtime"),Jg={text:"Text",heading:"Heading",spacer:"Spacer",divider:"Divider",button:"Button",image:"Image",customCode:"Custom code",column:"Column layout",blockquote:"Blockquote"},Tb=s(e=>e.includes(":"),"isPresetType"),Eb=s(e=>{let t=e.split(":");return t.length===2?{blockType:t[0],presetKey:t[1]}:null},"parsePresetType"),oc=s(({type:e})=>{let t=(0,jg.useAtomValue)(Wo),r=s(o=>{if(!o)return"Drop here";if(Tb(o)){let n=Eb(o);if(n){let a=t.find(l=>l.type===n.blockType&&l.key===n.presetKey);if(a)return a.label}let i=o.split(":")[0];return Jg[i]||"Drop here"}return Jg[o]||"Drop here"},"getPlaceholderLabel");return(0,rc.jsx)("div",{className:"courier-flex courier-w-full courier-pointer-events-none",children:(0,rc.jsx)("div",{className:I("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50 courier-ml-10","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md courier-drag-indicator dark:courier-border-accent"),children:(0,rc.jsx)("div",{className:"courier-text-accent-foreground dark:courier-text-accent",children:r(e)})})})},"DropIndicatorPlaceholder");var Ke=require("react/jsx-runtime");function kb(){let[e,t]=(0,Ne.useState)(!1);return(0,Ne.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(kb,"useMountStatus");var Ht=s(({children:e,id:t,className:r,editor:o,getPos:n,...i})=>{let a=(0,Ne.useRef)(null),l=(0,Ne.useRef)(null),c=(0,Ne.useRef)(null),[u,p]=(0,Ne.useState)(!1),[m,d]=(0,Ne.useState)(null),[f,C]=(0,Ne.useState)(null),h=(0,Ne.useRef)(null),b=(0,Ne.useRef)(!1),v=(0,Ne.useRef)(null),E=(0,Ne.useRef)(null),g=(0,Ne.useRef)(null),w=kb(),N=u&&!w,y=(0,Ne.useCallback)(()=>{if(!o||!t)return null;let P=null;return o.state.doc.descendants((T,x,k)=>{var M;if(((M=T.attrs)==null?void 0:M.id)===t){let A=0;return k&&k.content.forEach((R,B,F)=>{R===T&&(A=F)}),P={node:T,pos:x,parent:k,index:A},!1}return!0}),P},[t,o]),S=(0,Ne.useCallback)(()=>{if(!o)return!1;let P=y();return!P||!P.parent?!1:P.index===P.parent.childCount-1},[o,y]);return(0,Ne.useEffect)(()=>{let P=a.current,T=l.current;if(!P)return;let x=fo(wa({element:P,dragHandle:T||void 0,getInitialData:()=>{var B,F,L,D,V,O;let k=y(),M="text";if(k){let $=k.node;switch($.type.name){case"heading":M="heading";break;case"paragraph":M="text";break;case"imageBlock":M="image";break;case"divider":M=(B=$.attrs)!=null&&B.spacer?"spacer":"divider";break;case"button":M="button";break;case"customCode":M="customCode";break;case"column":M="column";break}}let A=(k==null?void 0:k.parent)===o.state.doc,R=((F=k==null?void 0:k.parent)==null?void 0:F.type.name)==="columnCell";return{id:t,type:A?"editor":R?"column-cell-item":"nested-drag",index:(L=k==null?void 0:k.index)!=null?L:0,dragType:M,pos:k==null?void 0:k.pos,originalIndex:(D=k==null?void 0:k.index)!=null?D:0,columnId:R?(V=k==null?void 0:k.parent)==null?void 0:V.attrs.columnId:void 0,cellIndex:R?(O=k==null?void 0:k.parent)==null?void 0:O.attrs.index:void 0}},onGenerateDragPreview:()=>{let k=P.querySelectorAll("[data-no-drag-preview]"),M=[];k.forEach((A,R)=>{let B=A;M[R]=B.style.display,B.style.display="none"}),requestAnimationFrame(()=>{k.forEach((A,R)=>{let B=A;B.style.display=M[R]})})},onDragStart:()=>{p(!0),document.body.style.cursor="grabbing";let k=s(M=>{E.current=M.clientY},"handleMouseMove");document.addEventListener("mousemove",k),g.current=()=>{document.removeEventListener("mousemove",k)},o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{p(!1),document.body.style.cursor="",g.current&&(g.current(),g.current=null),o&&o.setEditable(!0)}}),vr({element:P,getData:({input:k,element:M})=>{var O,$,_,z;let A=y(),R=(A==null?void 0:A.parent)===o.state.doc,B=((O=A==null?void 0:A.parent)==null?void 0:O.type.name)==="columnCell",F={id:t,type:R?"editor":B?"column-cell-item":"nested-drag",index:($=A==null?void 0:A.index)!=null?$:0,pos:A==null?void 0:A.pos,nodeType:A==null?void 0:A.node.type.name,columnId:B?(_=A==null?void 0:A.parent)==null?void 0:_.attrs.columnId:void 0,cellIndex:B?(z=A==null?void 0:A.parent)==null?void 0:z.attrs.index:void 0};if(M.getAttribute("data-node-type")==="column"){let Q=M.getBoundingClientRect(),re=k.clientY,ne=30,H=Math.abs(re-Q.top),X=Math.abs(re-Q.bottom);if(H>ne&&X>ne)return{...F,disableDropIndicator:!0}}let D=M.closest('[data-column-cell="true"]');if(S()&&P){let Q=P.getBoundingClientRect(),re=k.clientY,ne=Q.top+Q.height/2;if(re>=ne&&re>Q.bottom)return{...F,[Symbol.for("closestEdge")]:"bottom"}}let V=S()?["top","bottom"]:["top"];return wf(F,{input:k,element:M,allowedEdges:V})},canDrop:({source:k})=>k.data.id!==t,onDragEnter:({self:k,source:M,location:A})=>{var $,_,z,Q,re;if(k.data.disableDropIndicator){d(null);return}v.current&&(clearTimeout(v.current),v.current=null);let R=A.current.dropTargets;if(R.length>0&&R[0].element!==P){d(null),b.current=!1,h.current=null;return}let B=Pa(k.data),F=B,L=S(),D=(z=(_=($=A==null?void 0:A.current)==null?void 0:$.input)==null?void 0:_.clientY)!=null?z:E.current;D!==null&&(E.current=D);let V=M.data;C(V.dragType||null),B==="bottom"&&L&&M.data.id===t&&(F=null);let O=M.data.type==="editor"||M.data.type==="column-cell-item";if(L&&O)if(B==="top"){let ne=a.current;if(ne){let H=ne.getBoundingClientRect(),X=(Q=D!=null?D:E.current)!=null?Q:H.top+H.height/2,ke=H.top+H.height/2,Le=H.height,nt=Math.max(10,Math.min(30,Le*.3));X<ke-nt?(b.current=!1,F="top"):b.current?F="bottom":F="top"}else b.current=!1,F="top"}else b.current?F="bottom":B==="bottom"&&(b.current=!0,F="bottom");else L&&!O&&(b.current=!1);if(!b.current&&(M.data.type==="editor"||M.data.type==="column-cell-item")&&typeof M.data.index=="number"){let ne=M.data.index,H=y();((re=H==null?void 0:H.index)!=null?re:0)===ne+1&&B==="top"&&(F=null)}F!==h.current&&(h.current=F,d(F))},onDrag:({self:k,source:M,location:A})=>{var $,_,z,Q,re;if(k.data.disableDropIndicator){d(null);return}v.current&&(clearTimeout(v.current),v.current=null);let R=A.current.dropTargets;if(R.length>0&&R[0].element!==P){d(null);return}let B=(z=(_=($=A==null?void 0:A.current)==null?void 0:$.input)==null?void 0:_.clientY)!=null?z:E.current;B!==null&&(E.current=B);let F=Pa(k.data),L=F,D=S(),V=M.data;C(V.dragType||null),F==="bottom"&&D&&M.data.id===t&&(L=null);let O=M.data.type==="editor"||M.data.type==="column-cell-item";if(D&&O)if(F==="top"){let ne=a.current;if(ne){let H=ne.getBoundingClientRect(),X=(Q=B!=null?B:E.current)!=null?Q:H.top+H.height/2,ke=H.top+H.height/2,Le=H.height,nt=Math.max(10,Math.min(30,Le*.3));X<ke-nt?(b.current=!1,L="top"):b.current?L="bottom":L="top"}else b.current=!1,L="top"}else b.current?L="bottom":F==="bottom"&&(b.current=!0,L="bottom");else D&&!O&&(b.current=!1);if(!b.current&&(M.data.type==="editor"||M.data.type==="column-cell-item")&&typeof M.data.index=="number"){let ne=M.data.index,H=y();((re=H==null?void 0:H.index)!=null?re:0)===ne+1&&F==="top"&&(L=null)}L!==h.current&&(h.current=L,d(L))},onDragLeave:()=>{if(S()&&b.current){let k=P==null?void 0:P.getBoundingClientRect(),M=E.current;if(k&&M!==null&&M>=k.bottom-10)return;v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{b.current=!1,h.current=null,d(null),C(null),v.current=null},150)}else v.current&&(clearTimeout(v.current),v.current=null),b.current=!1,h.current=null,d(null),C(null)},onDrop:()=>{v.current&&(clearTimeout(v.current),v.current=null),b.current=!1,h.current=null,d(null),C(null)}}));return()=>{v.current&&(clearTimeout(v.current),v.current=null),x()}},[t,S,o,y]),(0,Ke.jsx)(wb,{ref:a,id:t,fadeIn:N,className:r,dragging:u,closestEdge:m,dragType:f,handleRef:l,contentRef:c,editor:o,...i,children:e})},"SortableItemWrapper"),wb=(0,Ne.forwardRef)(({children:e,className:t,dragOverlay:r,handleRef:o,contentRef:n,closestEdge:i,dragType:a,id:l,editor:c,fadeIn:u,dragging:p,...m},d)=>{(0,Ne.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let f=(0,Gg.useSetAtom)(ye),{resetButtonFormatting:C}=kl(c),h=s((y,S)=>{let P=null;return y.doc.descendants((T,x)=>{var k;return P!==null?!1:((k=T.attrs)==null?void 0:k.id)===S?(P=x,!1):!0}),P},"findNodePositionById"),b=(0,Ne.useCallback)(()=>{if(!c||!l)return{node:null,pos:null};let y=h(c.state,l);return y===null?{node:null,pos:null}:{node:c.state.doc.nodeAt(y),pos:y}},[c,l]),v=(0,Ne.useCallback)(()=>{c.commands.blur(),f(null)},[c,f]),E=(0,Ne.useCallback)(()=>{if(!(!c||!l))try{let{node:y,pos:S}=b();if(!y||S===null)return;let P=y.nodeSize,T=c.state.doc.childCount===1;f(null),c.commands.updateSelectionState(null);let x=c.state.tr;x.delete(S,S+P),x.setMeta("addToHistory",!0),c.view.dispatch(x),T&&setTimeout(()=>{let k=c.state.doc.nodeAt(0);if(k&&k.type.name==="paragraph"&&!k.attrs.id){let M=`node-${(0,Yg.v4)()}`,A=c.state.tr;A.setNodeMarkup(0,void 0,{...k.attrs,id:M}),c.view.dispatch(A);let R=new CustomEvent("node-duplicated",{detail:{newNodeId:M}});document.dispatchEvent(R)}},50)}catch(y){console.error("Error deleting node:",y)}},[c,l,b,f]),g=(0,Ne.useCallback)(()=>{if(!(!c||!l))try{let{node:y,pos:S}=b();if(!y||S===null)return;if(y.type.name==="button"){C();return}let P=y.type.name==="blockquote",T=y.type.name==="heading";!P&&!T&&v(),setTimeout(()=>{if(T){let k=S+1,M=S+y.nodeSize-1;c.chain().setTextSelection({from:k,to:M}).unsetAllMarks().blur().run(),f(null),c.commands.updateSelectionState(null);return}let x=c.chain();if(x.setNodeSelection(S).unsetAllMarks(),P&&y.content&&y.content.firstChild?y.content.firstChild.type.name!=="paragraph"&&x.setParagraph():y.type.name!=="paragraph"&&!P&&x.setParagraph(),x.run(),P){let k=b();k.node&&k.pos!==null&&(f(k.node),c.commands.updateSelectionState(k.node))}},100)}catch(y){console.error("Error removing formatting:",y)}},[c,l,b,v,C,f]),w=(0,Ne.useCallback)(()=>{if(!(!c||!l))try{v(),setTimeout(()=>{let{node:y,pos:S}=b();if(!y||S===null)return;let P=y.type.name,T={...y.attrs};delete T.id;let x=S+(y==null?void 0:y.nodeSize);cl(c,P,x,T,k=>f(k),y.content)},100)}catch(y){console.error("Error duplicating node:",y)}},[c,l,b,v,f]),{node:N}=b();return(0,Ke.jsxs)(Kg.NodeViewWrapper,{ref:d,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":l,className:I("courier-flex courier-flex-col courier-relative draggable-item",t),...m,children:[i==="top"&&(0,Ke.jsx)(oc,{type:a}),(0,Ke.jsxs)("div",{className:"courier-flex courier-items-center courier-justify-center courier-gap-2 courier-pl-10",children:[(0,Ke.jsx)(qg,{ref:o,className:"courier-absolute courier-left-[-8px]",tabIndex:-1,"data-no-drag-preview":!0}),(0,Ke.jsx)("div",{ref:n,className:"courier-flex-1 courier-grow draggable-content-wrapper",children:e}),(0,Ke.jsxs)("div",{"data-no-drag-preview":!0,className:I("courier-actions-panel courier-absolute courier-right-[-50px] courier-rounded-lg courier-border courier-border-border courier-bg-background courier-shadow-md courier-hidden courier-items-center courier-justify-center hover:courier-z-[100000]",p&&"!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"&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:y=>{y.preventDefault(),y.stopPropagation()},onClick:y=>{y.stopPropagation(),g()},tabIndex:-1,children:(0,Ke.jsx)(Zu,{color:"currentColor"})}),(0,Ke.jsx)(ce,{className:"!courier-my-0"})]}),(0,Ke.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:y=>{y.preventDefault(),y.stopPropagation()},onClick:y=>{y.stopPropagation(),w()},tabIndex:-1,children:(0,Ke.jsx)(wu,{color:"currentColor"})}),(0,Ke.jsx)(ce,{className:"!courier-my-0"}),(0,Ke.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#DC2626] dark:courier-text-red-500 dark:hover:courier-bg-secondary",onMouseDown:y=>{y.preventDefault(),y.stopPropagation()},onClick:y=>{y.stopPropagation(),E()},tabIndex:-1,children:(0,Ke.jsx)(ia,{color:"currentColor"})})]})]}),i==="bottom"&&(0,Ke.jsx)(oc,{type:a})]})});var nc=require("@tiptap/react"),ic=require("jotai"),Ii=require("react");var sn=require("react/jsx-runtime"),Pb=s(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderLeftWidth:o,borderColor:n})=>(0,sn.jsx)("div",{className:"courier-w-full node-element",children:(0,sn.jsx)("div",{style:{position:"relative",padding:`${t}px ${e}px`,backgroundColor:r,borderLeftWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",whiteSpace:"pre-wrap"},children:(0,sn.jsx)(nc.NodeViewContent,{})})}),"BlockquoteComponent"),Xg=s(e=>{var l,c,u;let t=(0,ic.useSetAtom)(Qe),r=(0,ic.useAtomValue)(ye),o=(0,Ii.useRef)(null),n=((l=r==null?void 0:r.type)==null?void 0:l.name)==="blockquote"&&(((c=r==null?void 0:r.attrs)==null?void 0:c.id)===e.node.attrs.id||!((u=r==null?void 0:r.attrs)!=null&&u.id)&&!e.node.attrs.id&&r===e.node),i=(0,Ii.useCallback)(()=>{if(!e.editor.isEditable)return;let p=e.node;p&&(t(p),e.editor.commands.updateSelectionState(p))},[e.editor.isEditable,e.node,e.editor.commands,t]);(0,Ii.useEffect)(()=>{let p=o.current;if(!p)return;let m=s(d=>{let f=d.target;f.closest(".courier-actions-panel")||f.closest("[data-no-drag-preview]")||i()},"handleClick");return p.addEventListener("click",m,!0),()=>{p.removeEventListener("click",m,!0)}},[i]);let a=!e.node.content||e.node.content.size===0;return(0,sn.jsx)(nc.NodeViewWrapper,{children:(0,sn.jsx)("div",{ref:o,children:(0,sn.jsx)(Ht,{id:e.node.attrs.id,className:I(n&&"selected-element",a&&"is-empty"),editor:e.editor,children:(0,sn.jsx)(Pb,{...e.node.attrs})})})})},"BlockquoteComponentNode");var ho={paddingHorizontal:8,paddingVertical:6,backgroundColor:"transparent",borderLeftWidth:4,borderColor:"#e0e0e0"},tm=Pf.extend({content:"block+",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){gt(this.editor,this.name)},addAttributes(){return{id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},paddingHorizontal:{default:ho.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:ho.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:ho.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderLeftWidth:{default:ho.borderLeftWidth,parseHTML:e=>e.getAttribute("data-border-left-width"),renderHTML:e=>({"data-border-left-width":e.borderLeftWidth})},borderColor:{default:ho.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,Qg.mergeAttributes)(e,{"data-type":"blockquote","data-id":e.id}),0]},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let{selection:t}=e.state,{empty:r}=t;if(!r)return!1;let o=e.isActive("blockquote");return!e.isActive("paragraph")||!o?!1:e.chain().command(({tr:i})=>{i.split(t.from);let a=i.selection.from,l=i.doc.resolve(a);if(l.depth>1){let c=l.blockRange();c&&i.lift(c,0)}return!0}).focus().run()}}},addNodeView(){return(0,e5.ReactNodeViewRenderer)(Xg)}});var t5=require("uuid"),bo=require("jotai"),It=require("react");var Si=s(({items:e,setItems:t,editor:r})=>{let[o]=(0,It.useState)(null),[n,i]=(0,It.useState)(null),[a,l]=(0,It.useState)(null),[c]=(0,It.useState)("outer"),u=(0,It.useRef)([]),p=(0,It.useRef)([]),m=(0,bo.useAtomValue)(Ie),d=(0,bo.useSetAtom)(Xt),[f,C]=(0,bo.useAtom)(te),h=(0,bo.useSetAtom)(Je),b=(0,bo.useAtomValue)(Zo),v=(0,bo.useAtomValue)(Wo),E=(0,bo.useAtomValue)(cs),g=r||m,w=(0,It.useCallback)(()=>{if(!g)return;let x=g.getJSON(),k=de(x),M=ft(f,{channel:b,elements:k});C(M),h(M)},[g,b,f,C,h]),N=(0,It.useCallback)(()=>{g==null||g.commands.removeDragPlaceholder(),t(x=>({...x,Editor:x.Editor.filter(k=>!k.toString().includes("_temp"))}))},[g==null?void 0:g.commands,t]),y=(0,It.useCallback)(x=>{try{let k=g==null?void 0:g.state.doc;if(!k||x===0)return 0;if(x>=k.childCount)return k.content.size;let M=0;for(let A=0;A<Math.min(x,k.childCount);A++){let R=k.child(A);M+=R.nodeSize}return M}catch(k){return console.error("Error calculating document position:",k),0}},[g==null?void 0:g.state.doc]),S=(0,It.useCallback)(x=>{let k=x.includes(":"),M=x,A=null;if(k){let D=x.split(":");M=D[0],A=D[1]}let R={};switch(M){case"text":R=pe;break;case"heading":R={};break;case"image":R=lt;break;case"button":R=je;break;case"divider":R=Tr;break;case"spacer":R=vi;break;case"customCode":R=Ao;break;case"column":R=wt;break;case"blockquote":R=ho;break}let B=E[M];if(B&&(R={...R,...B}),k&&A){let D=v.find(V=>V.type===M&&V.key===A);D!=null&&D.attributes&&(R={...R,...D.attributes})}let L={type:M==="text"?"paragraph":M==="image"?"imageBlock":M==="spacer"?"divider":M,attrs:{...R,id:(0,t5.v4)()}};if(M==="button"){let D="Button";if(k&&A){let V=v.find(O=>O.type===M&&O.key===A);V!=null&&V.label&&(D=V.label)}L.content=[{type:"text",text:D}]}return L},[E,v]),P=(0,It.useCallback)((x,k)=>{if(!g)return;let{columnId:M,index:A,isEmpty:R}=k,B=null,F=0,L=-1;if(x.type==="sidebar"){if(!x.dragType)return;B=S(x.dragType)}else if(x.type==="editor"){if(g.state.doc.descendants((_,z)=>_.attrs.id===x.id?(L=z,B=_.toJSON(),F=_.nodeSize,!1):!0),L===-1){let _=e.Editor.findIndex(z=>z===x.id);if(_!==-1){L=y(_);let z=g.state.doc.nodeAt(L);z&&(B=z.toJSON(),F=z.nodeSize)}}if(L!==-1){let _=e.Editor.filter(z=>z!==x.id);_.length!==e.Editor.length&&t({...e,Editor:_})}}if(!B)return;let D=-1,V=null;if(g.state.doc.descendants((_,z)=>_.type.name==="column"&&_.attrs.id===M?(D=z,V=_,!1):!0),D===-1||!V)return;let O=V;L!==-1&&L<D&&(D-=F);let $=g.state.tr;if(L!==-1&&$.delete(L,L+F),R){let _=g.schema,z=Array.from({length:O.attrs.columnsCount},(re,ne)=>_.nodes.columnCell.create({index:ne,columnId:M,isEditorMode:!1},ne===A?[_.nodeFromJSON(B)]:[])),Q=_.nodes.columnRow.create({},z);$.replaceWith(D+1,D+O.nodeSize-1,Q)}else{let _=D+1;O.content.forEach(z=>{if(z.type.name==="columnRow"){let Q=_+1;z.content.forEach((re,ne,H)=>{if(H===A){let X=Q+re.nodeSize-1;$.insert(X,g.schema.nodeFromJSON(B))}Q+=re.nodeSize})}_+=z.nodeSize})}g.view.dispatch($),w()},[g,e,t,y,S,w]),T=(0,It.useCallback)((x,k)=>{try{if(x.type==="sidebar"&&(k.type==="editor"||k.type==="column-cell-item"||k.type==="nested-drag")){let M=x.dragType;if(!M||!g)return;let A=k.insertPos;if(A===void 0)if(k.type==="editor"){let F=k.index+1;A=y(F)}else{console.warn("Nested drop without position data");return}let R=S(M);if(g.commands.insertContentAt(A,R),g.state.doc.resolve(A).depth===0){let F=g.state.doc.resolve(A).index(0),L=[...e.Editor];F<=L.length&&(L.splice(F,0,R.attrs.id),t({...e,Editor:L}))}w();return}if((x.type==="editor"||x.type==="column-cell-item"||x.type==="nested-drag")&&(k.type==="editor"||k.type==="column-cell-item"||k.type==="nested-drag")){if(!g)return;let M=-1,A=null;if(x.pos!==void 0&&(M=x.pos,A=g.state.doc.nodeAt(M)),(M===-1||!A)&&g.state.doc.descendants((L,D)=>L.attrs.id===x.id?(M=D,A=L,!1):!0),M===-1||!A){let L=e.Editor.findIndex(D=>D===x.id);L!==-1&&(M=y(L),A=g.state.doc.nodeAt(M))}if(!A||M===-1)return;let R=k.insertPos;if(R===void 0){let L;k.index===void 0?L=g.state.doc.childCount:k.index===-1?L=0:L=k.index+1,R=y(L)}if(R===void 0||R>M&&R<M+A.nodeSize)return;if(R>M){let L=R-A.nodeSize;g.chain().deleteRange({from:M,to:M+A.nodeSize}).insertContentAt(L,A.toJSON()).run()}else g.chain().insertContentAt(R,A.toJSON()).deleteRange({from:M+A.nodeSize,to:M+A.nodeSize*2}).run();let B=e.Editor.includes(x.id);if(B){let L=e.Editor.filter(D=>D!==x.id);t({...e,Editor:L})}let F=g.state.doc.resolve(R).depth===0;w()}}catch(M){console.error("[Pragmatic DnD] Error in handleDrop:",M)}},[e,g,t,y,w,S]);return(0,It.useEffect)(()=>bd({onDragStart:({source:x})=>{let k=x.data;d(!0),l(k.id),k.dragType&&i(k.dragType);let M=g==null?void 0:g.view.dom.querySelectorAll('[data-node-type="column"]');M&&(u.current=Array.from(M).map(R=>R.getBoundingClientRect()));let A=g==null?void 0:g.view.dom.querySelectorAll("[data-node-view-wrapper]");if(A){let R=new Set,B=Array.from(A).filter(F=>{let L=F,D=L.parentElement;if(D!=null&&D.hasAttribute("data-column-cell"))return!1;let V=L.getBoundingClientRect(),O=V.top+V.height/2;return R.has(Math.round(O))?!1:(R.add(Math.round(O)),!0)});p.current=B.map(F=>F.getBoundingClientRect())}},onDrop:({source:x,location:k})=>{let M=x.data,A=k.current.dropTargets[0];if(!A){N(),d(!1),l(null),i(null);return}let R=A.data;if(R.type==="column-cell"){P(M,R),d(!1),l(null),i(null),N();return}let B=R,F=Pa(A.data);if(B.pos!==void 0&&F&&g){let L=g.state.doc.nodeAt(B.pos);L&&(F==="top"?B.insertPos=B.pos:F==="bottom"&&(B.insertPos=B.pos+L.nodeSize))}if(B.insertPos===void 0&&F&&B.index!==void 0){let L=F==="top"?B.index-1:B.index;B={...B,index:L}}else if(B.index===void 0&&B.insertPos===void 0){let D=k.current.input.clientY;if(p.current.length>0){let V=0,O=1/0;p.current.forEach((re,ne)=>{let H=re.top+re.height/2,X=Math.abs(D-H);X<O&&(O=X,V=ne)});let $=p.current[V],_=$.top+$.height/2,Q=D>=_?V:V-1;B={...B,index:Q,fromCoordinates:!0}}else B={...B,index:(g==null?void 0:g.state.doc.childCount)||0}}T(M,B),d(!1),l(null),i(null),N()}}),[g,d,N,l,i,T,P]),{activeId:a,activeDragType:n,dndMode:c,lastPlaceholderIndex:o,cleanupPlaceholder:N}},"usePragmaticDnd");var ac=require("react");var r5=require("jotai");var sc=s(({setItems:e,rafId:t,editor:r})=>{let o=(0,r5.useAtomValue)(Ie),n=r||o,i=(0,ac.useCallback)(a=>{t.current&&typeof cancelAnimationFrame!="undefined"&&cancelAnimationFrame(t.current);let l=setTimeout(()=>{if(typeof requestAnimationFrame!="undefined")t.current=requestAnimationFrame(()=>{try{let c=a==null?void 0:a.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),p=[];u.forEach(m=>{let d=m,f=d.dataset.id;if(f){let C=d.parentElement,h=!1;for(;C&&C!==c;){if(C.hasAttribute("data-column-cell")){h=!0;break}C=C.parentElement}h||p.push(f)}}),e(m=>({Editor:p,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]"),p=[];u.forEach(m=>{let d=m,f=d.dataset.id;if(f){let C=d.parentElement,h=!1;for(;C&&C!==c;){if(C.hasAttribute("data-column-cell")){h=!0;break}C=C.parentElement}h||p.push(f)}}),e(m=>({Editor:p,Sidebar:m.Sidebar}))}catch(c){console.error("Error syncing editor items:",c)}},50);return()=>clearTimeout(l)},[e,t]);return(0,ac.useEffect)(()=>{if(!n||typeof n.on!="function")return;let a,l=s(()=>{n&&(a&&a(),a=i(n))},"updateItems");n.on("update",l),n.on("selectionUpdate",l),n.on("create",l),n.on("transaction",l),n&&!n.isDestroyed&&l();let c=s(u=>{l()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",c),()=>{n==null||n.off("update",l),n==null||n.off("selectionUpdate",l),n==null||n.off("create",l),n==null||n.off("transaction",l),document.removeEventListener("node-duplicated",c),a&&a(),t.current&&typeof cancelAnimationFrame!="undefined"&&(cancelAnimationFrame(t.current),t.current=null)}},[n,i,t]),{syncEditorItems:i}},"useSyncEditorItems");var Ri=require("react/jsx-runtime"),Ya=[{type:"text",align:"left",content:`
202
- `,text_style:"h1"},{type:"text",align:"left",content:""},{type:"image",src:""}],Nb=(0,Ee.forwardRef)(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:a,colorScheme:l,hidePreviewPanelExitButton:c,...u},p)=>{let m=(0,Zt.useAtomValue)(Ie),[d,f]=(0,Zt.useAtom)(ye),[C,h]=(0,Zt.useAtom)(gn),b=(0,Ee.useRef)({}),[v,E]=(0,Ee.useState)(c?"desktop":void 0),g=(0,Zt.useAtomValue)(it),w=(0,Zt.useAtomValue)(se),N=(0,Zt.useAtomValue)(Wc),y=(0,Zt.useAtomValue)(po),S=(0,Ee.useRef)(-1),P=(0,Zt.useSetAtom)(Ip),T=(0,Ee.useRef)(!1),x=(0,Ee.useRef)(!1),[k]=(0,Zt.useAtom)(te),M=(0,Zt.useAtomValue)($r),A=(0,Zt.useAtomValue)(xt),R=(0,Zt.useAtomValue)(co),[B,F]=(0,Ee.useState)({Editor:[],Sidebar:R});(0,Ee.useEffect)(()=>{F(H=>({...H,Sidebar:R}))},[R]);let L=(0,Ee.useRef)(null);Si({items:B,setItems:F,editor:m});let{syncEditorItems:D}=sc({setItems:F,rafId:L,editor:m});(0,Ee.useEffect)(()=>{A&&(x.current=!1)},[A]);let[V,O]=(0,Ee.useState)(!1);(0,Ee.useEffect)(()=>{if(w===!1||w===null){let H=setTimeout(()=>{O(!0)},100);return()=>clearTimeout(H)}else O(!1)},[w,V]),(0,Ee.useEffect)(()=>{if(d){let H=d.type.name,X=Rs(H);P({nodeName:H,config:X})}},[d,P]);let $=(0,Ee.useMemo)(()=>{var X,ke,Le,nt,vt,fr,gr,le,Ve,Ae,Ut,Wt,Dr,Hr,Vr,Fr,Oo,ie,To,pn,fn,zi,$i,Zi,qi,Ji,ji,ee,ae,ge,we,_e,Or,mt;if(y)return y;let H=(Le=(ke=(X=g==null?void 0:g.data)==null?void 0:X.tenant)==null?void 0:ke.brand)==null?void 0:Le.settings;return{brandColor:((nt=H==null?void 0:H.colors)==null?void 0:nt.primary)||"#000000",textColor:((vt=H==null?void 0:H.colors)==null?void 0:vt.secondary)||"#000000",subtleColor:((fr=H==null?void 0:H.colors)==null?void 0:fr.tertiary)||"#666666",headerStyle:(le=(gr=H==null?void 0:H.email)==null?void 0:gr.header)!=null&&le.barColor?"border":"plain",logo:(Ut=(Ae=(Ve=H==null?void 0:H.email)==null?void 0:Ve.header)==null?void 0:Ae.logo)==null?void 0:Ut.image,link:(Hr=(Dr=(Wt=H==null?void 0:H.email)==null?void 0:Wt.header)==null?void 0:Dr.logo)==null?void 0:Hr.href,facebookLink:(ie=(Oo=(Fr=(Vr=H==null?void 0:H.email)==null?void 0:Vr.footer)==null?void 0:Fr.social)==null?void 0:Oo.facebook)==null?void 0:ie.url,linkedinLink:(zi=(fn=(pn=(To=H==null?void 0:H.email)==null?void 0:To.footer)==null?void 0:pn.social)==null?void 0:fn.linkedin)==null?void 0:zi.url,instagramLink:(Ji=(qi=(Zi=($i=H==null?void 0:H.email)==null?void 0:$i.footer)==null?void 0:Zi.social)==null?void 0:qi.instagram)==null?void 0:Ji.url,mediumLink:(ge=(ae=(ee=(ji=H==null?void 0:H.email)==null?void 0:ji.footer)==null?void 0:ee.social)==null?void 0:ae.medium)==null?void 0:ge.url,xLink:(mt=(Or=(_e=(we=H==null?void 0:H.email)==null?void 0:we.footer)==null?void 0:_e.social)==null?void 0:Or.twitter)==null?void 0:mt.url}},[y,g]),_=N&&!!$,z=(0,Ee.useCallback)(()=>{Object.values(b.current).forEach(H=>clearTimeout(H)),b.current={}},[]);(0,Ee.useEffect)(()=>()=>{z()},[z]),(0,Ee.useEffect)(()=>{let H=s(X=>{if(X.key==="Escape"&&(f(null),m==null||m.commands.blur(),S.current=-1),X.key==="Tab"&&m){X.preventDefault();let ke=-1;d&&m.state.doc.content.forEach((vt,fr,gr)=>{d.attrs.id===vt.attrs.id&&(ke=gr)}),ke===-1&&(ke=0);let Le=m.state.doc,nt;if(X.shiftKey?nt=(ke-1+Le.childCount)%Le.childCount:nt=(ke+1)%Le.childCount,nt!==ke||d===null){let vt=Le.child(nt);f(vt),m.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",H),()=>{document.removeEventListener("keydown",H)}},[m,d,f]),(0,Ee.useEffect)(()=>{if(w!==!1||A)return;let H=k!=null?k:"";if(H){let X=Qc(H,"email");h(X||"")}setTimeout(()=>{if(!(!m||m.isDestroyed)&&m.state.doc.childCount===1){let X=m.state.doc.child(0);f(X)}},0)},[g,w,A,m,h,f,k]),(0,Ee.useEffect)(()=>{w===!1&&g&&!x.current&&(x.current=!0,setTimeout(()=>{m&&!m.isDestroyed&&D(m)},300))},[w,g,m,D]),(0,Ee.useEffect)(()=>(T.current=!0,()=>{T.current=!1}),[]);let Q=(0,Ee.useCallback)(H=>{let ke=H||(v===void 0?"desktop":void 0);E(ke),f(null),ke?m==null||m.setEditable(!1):m==null||m.setEditable(!0)},[m,v,E,f]),re=s(H=>{h(H.target.value)},"handleSubjectChange"),ne=(0,Ee.useMemo)(()=>{if(w!==!1||!V)return null;let H=a&&a.elements&&a.elements.length>0;H&&(x.current=!0);let X;return H&&(X=a.elements.find(Le=>Le.type==="channel"&&Le.channel==="email")),X||(X={type:"channel",channel:"email",elements:Ya}),Ze({version:"2022-01-01",elements:[X]},{channel:"email"})},[a,w,V]);return A&&(k===null||ne===null)?null:(0,Ri.jsx)(rr,{theme:t,colorScheme:l,isLoading:!!w,Header:i?i({hidePublish:e,channels:r,routing:o}):(0,Ri.jsx)(Rr,{hidePublish:e,channels:r,routing:o}),...u,children:(0,Ri.jsx)(Ri.Fragment,{children:n==null?void 0:n({subject:C,handleSubjectChange:re,selectedNode:d,setSelectedNode:f,previewMode:v,templateEditor:m,ref:p,isBrandApply:_,brandSettings:$,items:B,content:ne,syncEditorItems:D,brandEditorContent:M,templateData:g,togglePreviewMode:Q,hidePreviewPanelExitButton:c})})})}),lc=(0,Ee.memo)(Nb);var cc=class cc{};s(cc,"UploadImageAPI"),cc.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 om=cc,nm=om;var lr=s(e=>[Ud,em.StarterKit.configure({document:!1,dropcursor:!1,gapcursor:!1,heading:!1,horizontalRule:!1,paragraph:!1,blockquote:!1,hardBreak:!1,code:!1}),Jd.configure({setSelectedNode:e==null?void 0:e.setSelectedNode,shouldHandleClick:e==null?void 0:e.shouldHandleClick}),Kd.HardBreak.configure({keepMarks:!0,HTMLAttributes:{class:"my-line-break"}}),vg,Cd,qd,tm,_d.configure({levels:[1,2,3,4,5,6]}),qs,Bl,jd.Color,Ks,Hl,Ul,Ys,$d.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),Qd.Underline,Qs.configure(),zl.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(t,r,o)=>{r.forEach(async n=>{let i=await nm.uploadImage(n);t.chain().setImageBlockAt({pos:o,src:i}).focus().run()})},onPaste:(t,r)=>{r.forEach(async o=>{let n=await nm.uploadImage(o);return t.chain().setImageBlockAt({pos:t.state.selection.anchor,src:n}).focus().run()})}}),Yd.TextAlign.extend({addKeyboardShortcuts(){return{}}}).configure({types:["paragraph","heading"]}),Xd.Typography,Gd.Placeholder.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:"",emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",showOnlyWhenEditable:!0}),yd.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),Rd,Ln,Bn,Zl,jl],"ExtensionKit");var uc=require("@tiptap/react");var im=require("react/jsx-runtime"),cr=s(({config:e})=>{let{editor:t}=(0,uc.useCurrentEditor)(),r=wl(t);return t?(0,im.jsx)(uc.BubbleMenu,{editor:t,tippyOptions:{appendTo:o=>{var n;return(n=o.closest(".bubble-text-menu-container"))!=null?n:o},getReferenceClientRect:()=>{var a,l,c,u;let o=(c=(l=(a=t==null?void 0:t.state)==null?void 0:a.selection)==null?void 0:l.from)!=null?c:0,n=(u=t==null?void 0:t.view)==null?void 0:u.domAtPos(o),i=(n==null?void 0:n.node.parentNode).getBoundingClientRect();return{width:i==null?void 0:i.width,height:i==null?void 0:i.height,left:(i==null?void 0:i.left)-12,right:i==null?void 0:i.right,top:i==null?void 0:i.top,bottom:i==null?void 0:i.bottom,x:i==null?void 0:i.left,y:i==null?void 0:i.top,toJSON:()=>({})}},placement:"top",offset:[0,12]},shouldShow:r.shouldShow,updateDelay:100,"data-testid":"bubble-text-menu",children:t&&(0,im.jsx)(ki,{editor:t,config:e})}):null},"BubbleTextMenu");var o5=require("@tiptap/pm/state"),Li=require("@tiptap/react"),Xa=require("jotai"),Xr=require("react");var St=require("react/jsx-runtime"),Mb=s(({value:e,readOnly:t})=>{let{editor:r}=(0,Li.useCurrentEditor)(),o=(0,Xa.useSetAtom)(Gn),n=(0,Xa.useAtomValue)(se),i=(0,Xr.useRef)(!1);return(0,Xr.useEffect)(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(Yc(e!=null?e:"")))},[r,e,n,t]),(0,Xr.useEffect)(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),Ab=s(({facebookLink:e,linkedinLink:t,instagramLink:r,mediumLink:o,xLink:n,readOnly:i=!1,value:a,onUpdate:l})=>{let c=(0,Xr.useRef)(!1),u=(0,Xa.useSetAtom)(ye),p=Li.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:d})=>{let{state:f,dispatch:C}=d.view;return C(f.tr.setSelection(o5.TextSelection.create(f.doc,f.selection.$anchor.pos))),u&&u(null),!1}}}});(0,Xr.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=(0,Xr.useMemo)(()=>[...lr({setSelectedNode:u}),p].filter(d=>d!==void 0),[p,u]);return(0,St.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[(0,St.jsxs)(Li.EditorProvider,{content:Yc(a!=null?a:""),extensions:m,editable:!i,autofocus:!i,onUpdate:l,editorContainerProps:{className:I("courier-py-2 courier-flex-grow",i&&"courier-brand-editor-readonly")},immediatelyRender:!1,children:[(0,St.jsx)(Mb,{value:a,readOnly:i}),(0,St.jsx)(cr,{})]}),(0,St.jsxs)("div",{className:"courier-flex courier-justify-end courier-items-center courier-gap-2 courier-mt-3",children:[e&&(0,St.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:(0,St.jsx)(la,{className:"courier-w-5 courier-h-5"})}),t&&(0,St.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:(0,St.jsx)(da,{className:"courier-w-5 courier-h-5"})}),r&&(0,St.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:(0,St.jsx)(ua,{className:"courier-w-5 courier-h-5"})}),o&&(0,St.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:(0,St.jsx)(ma,{className:"courier-w-5 courier-h-5"})}),n&&(0,St.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:(0,St.jsx)(ba,{className:"courier-w-5 courier-h-5"})})]})]})},"BrandFooterComponent"),Bi=(0,Xr.memo)(Ab);var ur=require("react/jsx-runtime"),n5=s(({value:e,icon:t,...r})=>(0,ur.jsx)($t,{value:e,...r,className:"!courier-w-10 !courier-h-6 [&_svg]:!courier-size-5 [&_svg]:courier-fill-accent dark:[&_svg]:courier-fill-accent-foreground hover:courier-bg-transparent courier-rounded-sm data-[state=on]:courier-bg-background [&_svg]:data-[state=on]:courier-fill-foreground",children:t}),"PreviewItem"),dc=s(({previewMode:e,togglePreviewMode:t,hideMobileToggle:r=!1,hideExitButton:o=!1,...n})=>(0,ur.jsxs)("div",{...n,className:I("courier-sticky courier-bottom-0 courier-mt-auto courier-self-center courier-bg-background courier-px-3 courier-py-2 courier-shadow-lg courier-border courier-border-border courier-rounded-md courier-z-10 courier-flex courier-items-center courier-gap-2",n.className),children:[e&&!r&&(0,ur.jsxs)(ur.Fragment,{children:[(0,ur.jsxs)(Ir,{type:"single",value:e,onValueChange:i=>{i!==""&&t(i)},className:"courier-w-full courier-rounded-md !courier-p-0.5 courier-bg-[#3B82F6] !courier-gap-0",children:[(0,ur.jsx)(n5,{value:"desktop",icon:(0,ur.jsx)(Eu,{})}),(0,ur.jsx)(n5,{value:"mobile",icon:(0,ur.jsx)(Fu,{})})]}),!o&&(0,ur.jsx)("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),!o&&(0,ur.jsxs)(Se,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");var sm=require("react");function Ib(){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(Ib,"initTestHelpers");function dr(e,t){typeof window!="undefined"&&(Ib(),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(dr,"setTestEditor");var s5=require("@tiptap/core"),l5=require("@tiptap/pm/state"),mc=require("@tiptap/react"),Ge=require("jotai"),fe=require("react");var i5=require("@tiptap/react"),a5=require("react");var Lr=s(({value:e,defaultValue:t})=>{let{editor:r}=(0,i5.useCurrentEditor)();return(0,a5.useEffect)(()=>{if(!r)return;let o=setTimeout(()=>{r.commands.setContent(e||t)},0);return()=>clearTimeout(o)},[r,e,t]),null},"ReadOnlyEditorContent");var yo=require("react/jsx-runtime"),Sb=s(({value:e})=>{let{editor:t}=(0,mc.useCurrentEditor)(),[r,o]=(0,Ge.useAtom)(te),n=(0,Ge.useSetAtom)(Je),i=(0,Ge.useAtomValue)(gn),a=(0,Ge.useAtomValue)(ye),l=(0,Ge.useSetAtom)(Ie),c=(0,Ge.useSetAtom)(bn),u=(0,fe.useRef)(!1),p=(0,fe.useRef)(),m=(0,Ge.useAtomValue)(se),d=(0,Ge.useAtomValue)(it),f=(0,fe.useRef)(!1),C=(0,Ge.useAtomValue)(xt);return(0,fe.useEffect)(()=>{m&&(f.current=!1)},[m]),(0,fe.useEffect)(()=>(c({action:"register",id:"email-subject",fn:s(()=>{var b;if(p.current&&(clearTimeout(p.current),p.current=void 0,t&&i!==null&&m===!1&&!C))try{let v=de(t.getJSON());if(!v||!Array.isArray(v))return;let E=i;if(!i&&r){let y=(b=r==null?void 0:r.elements)==null?void 0:b.find(S=>S.type==="channel"&&S.channel==="email");y&&(E=Xi(y,"email"))}let g=Wr(r,"email",E||"",v),w={elements:g.elements,channel:"email",...g.raw&&{raw:g.raw}},N=ft(r,w);JSON.stringify(r)!==JSON.stringify(N)&&(o(N),n(N))}catch(v){console.error("[FlushSubjectUpdate]",v)}},"flushSubjectUpdate")}),()=>{c({action:"unregister",id:"email-subject"})}),[t,i,m,C,r,o,n,c]),(0,fe.useEffect)(()=>{!t||m!==!1||f.current||!e||(l(t),f.current=!0,t.commands.setContent(e))},[t,e,l,m]),(0,fe.useEffect)(()=>{if(!(!(t&&i!==null)||m!==!1||C)&&!t.isFocused)return p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{var h;try{let b=de(t.getJSON());if(!b||!Array.isArray(b))return;let v=i;if(!i&&r){let N=(h=r==null?void 0:r.elements)==null?void 0:h.find(y=>y.type==="channel"&&y.channel==="email");N&&(v=Xi(N,"email"))}let E=Wr(r,"email",v||"",b),g={elements:E.elements,channel:"email",...E.raw&&{raw:E.raw}},w=ft(r,g);JSON.stringify(r)!==JSON.stringify(w)&&(o(w),n(w))}catch(b){console.error(b)}},500),()=>{p.current&&clearTimeout(p.current)}},[d,t,i,o,n,m,r,C]),(0,fe.useEffect)(()=>()=>{t&&!t.isDestroyed&&t.setEditable(!0)},[t]),(0,fe.useEffect)(()=>{t&&u.current&&t.commands.updateSelectionState(a)},[t,a]),(0,fe.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]),null},"EditorContent"),Rb=s(({value:e,readOnly:t=!1,onDestroy:r,onUpdate:o,subject:n})=>{let i=(0,Ge.useSetAtom)(Bs),a=(0,fe.useRef)(),[l,c]=(0,Ge.useAtom)(te),u=(0,Ge.useAtomValue)(gn),p=n!=null?n:u,m=(0,Ge.useSetAtom)(ye),d=(0,Ge.useAtomValue)(Ie),f=(0,Ge.useAtomValue)(xt),C=(0,Ge.useAtomValue)(Xt),h=(0,Ge.useSetAtom)(bn),b=(0,Ge.useSetAtom)(Je),v=(0,fe.useRef)(l),E=(0,fe.useRef)(p),g=(0,fe.useRef)(C);(0,fe.useEffect)(()=>{v.current=l},[l]),(0,fe.useEffect)(()=>{E.current=p},[p]),(0,fe.useEffect)(()=>{g.current=C},[C]),(0,fe.useEffect)(()=>{d==null||d.setEditable(!t)},[t,d]);let w=s5.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:V})=>{let{state:O,dispatch:$}=V.view;return $(O.tr.setSelection(l5.TextSelection.create(O.doc,O.selection.$anchor.pos))),m&&m(null),!1}}}}),N=(0,fe.useCallback)(({editor:V})=>{o==null||o(V),dr("email",V),m&&setTimeout(()=>{m(null)},100)},[m,o]),y=(0,fe.useRef)(),S=(0,fe.useRef)(null),P=(0,fe.useCallback)((V,O)=>{var H;if(f)return;let $=v.current,_=E.current;if(!$){let X={version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:O}]};c(X),b(X);return}let z=$.elements.find(X=>X.type==="channel"&&X.channel==="email"),Q={...z};Q.elements=(H=Q.elements)==null?void 0:H.filter(X=>X.type!=="meta");let re={type:"channel",channel:"email",elements:O};if(JSON.stringify(Q)!==JSON.stringify(re)){let X=_;!_&&z&&(X=Xi(z,"email"));let ke=Wr($,"email",X||"",O);re.elements=ke.elements,ke.raw&&(re.raw=ke.raw);let Le=ft($,re);c(Le),b(Le)}o==null||o(V),dr("email",V)},[c,b,o,f]),T=(0,fe.useCallback)(({editor:V})=>{let O=de(V.getJSON());S.current={editor:V,elemental:O},y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{if(S.current){let{editor:$,elemental:_}=S.current;P($,_),S.current=null}},200)},[P]),x=(0,fe.useCallback)(({editor:V})=>{if(g.current)return;let{selection:O}=V.state,{$anchor:$}=O,z=O.$head.marks().find(H=>H.type.name==="link");z||V.isActive("link")?i({mark:z}):i(null);let Q=$.depth,re=null,ne=null;for(;Q>0;){let H=$.node(Q);!ne&&H.type.name==="blockquote"&&(ne=H),!re&&(H.type.name==="paragraph"||H.type.name==="heading")&&(re=H),Q--}ne?m(ne):re&&m(re)},[i,m]),k=(0,fe.useCallback)(({editor:V,transaction:O})=>{let $=O==null?void 0:O.getMeta("showLinkForm");if($){let{selection:_}=V.state,Q=_.$head.marks().find(re=>re.type.name==="link");i({mark:Q,link:{from:$.from,to:$.to}})}},[i]),M=(0,fe.useCallback)(()=>{a.current&&clearTimeout(a.current),y.current&&clearTimeout(y.current),r==null||r(),dr("email",null)},[r]);(0,fe.useEffect)(()=>(h({action:"register",id:"email-content",fn:s(()=>{if(y.current&&(clearTimeout(y.current),y.current=void 0,S.current)){let{editor:O,elemental:$}=S.current;P(O,$),S.current=null}},"flushContentUpdate")}),()=>{h({action:"unregister",id:"email-content"})}),[P,h]);let A=(0,fe.useCallback)(V=>{var Q;if(g.current)return;let O=(Q=V.view)==null?void 0:Q.editor;if(!O||!O.isEditable)return;let $=V.target,_=O.view.posAtDOM($,0),z=O.state.doc.resolve(_).node();z.type.name==="paragraph"&&m(z)},[m]),R=(0,fe.useCallback)(()=>!g.current,[]),B=(0,fe.useMemo)(()=>[...lr({setSelectedNode:m,shouldHandleClick:R}),w].filter(V=>V!==void 0),[w,m,R]),F=e||{type:"doc",content:[{type:"paragraph"}]},L=t?{editable:!1,autofocus:!1}:{editable:!0,autofocus:!0,onCreate:N,onUpdate:T,onSelectionUpdate:x,onTransaction:k},D=(0,fe.useRef)(null);return(0,fe.useEffect)(()=>{let V=D.current;if(!(!V||t))return vr({element:V,getData:()=>({type:"editor",id:"editor-drop-zone"}),canDrop:({source:O})=>O.data.type==="sidebar"?!0:O.data.type==="editor"})},[t]),(0,yo.jsx)("div",{ref:D,"data-testid":"email-editor",children:(0,yo.jsx)(mc.EditorProvider,{content:F,extensions:B,...L,onDestroy:M,editorContainerProps:{onClick:A},immediatelyRender:!1,children:t?(0,yo.jsx)(Lr,{value:F,defaultValue:Ya}):(0,yo.jsxs)(yo.Fragment,{children:[(0,yo.jsx)(Sb,{value:F}),(0,yo.jsx)(cr,{})]})})})},"EmailEditor"),pc=Rb;var zn=require("jotai"),Hi=require("lucide-react");var ln=require("react");var fc=require("react/jsx-runtime"),Di=s(({children:e,id:t,className:r,editor:o})=>(0,fc.jsx)(Lb,{id:t,className:r,editor:o,children:e}),"SideBarSortableItemWrapper"),Lb=(0,ln.forwardRef)(({children:e,className:t,id:r,editor:o},n)=>{let i=(0,ln.useRef)(null),[a,l]=(0,ln.useState)(!1);return(0,ln.useEffect)(()=>{let c=i.current;if(!(!c||!r))return fo(wa({element:c,getInitialData:()=>({id:r,type:"sidebar",dragType:r}),onDragStart:()=>{l(!0),document.body.style.cursor="grabbing",o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{l(!1),document.body.style.cursor="",o&&o.setEditable(!0)}}))},[r,o]),(0,fc.jsx)("div",{ref:i,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":r,className:I(t,"courier-relative",a&&"courier-opacity-50 courier-cursor-grabbing"),children:(0,fc.jsx)("div",{children:e})})});var Ce=require("react/jsx-runtime"),Bb={heading:al,text:Xo,image:sl,spacer:ll,divider:Yo,button:Go,customCode:il,column:nl,blockquote:ol},Db=s(e=>({heading:(0,Ce.jsx)(Pd,{}),text:(0,Ce.jsx)(Ad,{}),image:(0,Ce.jsx)(Nd,{}),spacer:(0,Ce.jsx)(Hi.AlignVerticalSpaceAround,{className:"courier-w-4 courier-h-4"}),divider:(0,Ce.jsx)(wd,{}),button:(0,Ce.jsx)(Td,{}),customCode:(0,Ce.jsx)(kd,{}),column:(0,Ce.jsx)(Ed,{}),blockquote:(0,Ce.jsx)(Hi.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"})})[e],"getBlockIcon"),Hb=s(e=>hr(e)?`${e.type}:${e.preset}`:e,"getItemKey"),Vb=s(({preset:e})=>{let t=e.icon||Db(e.type);return(0,Ce.jsx)(et,{draggable:!0,icon:t,draggableLabel:e.label,label:e.label})},"PresetBlock"),gc=s(({items:e,brandEditor:t,label:r,editor:o})=>{var m,d;let n=(0,zn.useAtomValue)(it),i=(0,zn.useSetAtom)(mi),a=(0,zn.useAtomValue)(at),l=(0,zn.useAtomValue)(co),c=(0,zn.useAtomValue)(Wo),u=e!=null?e:l,p=s(f=>{if(hr(f)){let h=c.find(b=>b.type===f.type&&b.key===f.preset);return h?(0,Ce.jsx)(Vb,{preset:h}):(console.warn(`[SideBar] Preset not found: ${f.type}:${f.preset}`),null)}let C=Bb[f];return C?(0,Ce.jsx)(C,{draggable:!0}):null},"renderBlockItem");return(0,Ce.jsxs)("div",{className:"courier-flex courier-flex-col courier-h-full",children:[(0,Ce.jsxs)("div",{className:"courier-flex-1",children:[r&&(0,Ce.jsxs)(Ce.Fragment,{children:[(0,Ce.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:r}),(0,Ce.jsx)(ce,{className:"courier-my-4"})]}),(0,Ce.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:u.map(f=>{let C=Hb(f);return(0,Ce.jsx)(Di,{id:C,editor:o,children:(0,Ce.jsxs)("div",{className:I("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Ce.jsx)(Hi.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),p(f)]})},C)})})]}),t&&(0,Ce.jsxs)("div",{className:"courier-mt-auto courier-pt-4",children:[(0,Ce.jsx)(ce,{className:"courier-mb-4 -courier-mx-4"}),(d=(m=n==null?void 0:n.data)==null?void 0:m.tenant)!=null&&d.brand?(0,Ce.jsx)("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:(0,Ce.jsx)(Se,{variant:"link",className:"courier-underline",onClick:()=>i("brand"),disabled:!!a,children:"Edit brand"})}):(0,Ce.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,Ce.jsx)("h3",{className:"courier-text-md courier-font-medium courier-text-foreground",children:"Customize brand theme"}),(0,Ce.jsx)("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),(0,Ce.jsx)(Se,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>i("brand"),children:"Customize"})]})]})]})},"SideBar");var c5=require("jotai");var Qr=require("react/jsx-runtime"),hc=s(({element:e,editor:t})=>{var i,a;let r=(0,c5.useAtomValue)(nd);if(!e)return null;if(r!=null&&r.link||((i=r==null?void 0:r.mark)==null?void 0:i.type.name)==="link"&&((a=e.marks)!=null&&a.some(l=>l.type.name==="link")))return(0,Qr.jsx)(Fg,{editor:t,mark:r==null?void 0:r.mark,pendingLink:r==null?void 0:r.link});let o=t==null?void 0:t.isActive("blockquote"),n=s(()=>{if(!t)return;let{$anchor:l}=t.state.selection,c=l.depth;for(;c>0;){let u=l.node(c);if(u.type.name==="blockquote")return u;c--}},"getBlockquoteElement");return(0,Qr.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[e.type.name==="button"&&(0,Qr.jsx)(j1,{element:e,editor:t},e.attrs.id),e.type.name==="divider"&&(0,Qr.jsx)(gg,{element:e,editor:t},e.attrs.id),["paragraph","heading"].includes(e.type.name)&&!o&&(0,Qr.jsx)(u1,{element:e,editor:t},e.attrs.id),e.type.name==="imageBlock"&&(0,Qr.jsx)(Lg,{element:e,editor:t},e.attrs.id),e.type.name==="customCode"&&(0,Qr.jsx)(Od,{element:e,editor:t},e.attrs.id),(e.type.name==="blockquote"||e.type.name==="paragraph"&&o||e.type.name==="heading"&&o)&&(0,Qr.jsx)(g1,{element:n()||e,editor:t},e.attrs.id),e.type.name==="column"&&(0,Qr.jsx)(Hd,{element:e,editor:t},e.attrs.id)]})},"SideBarItemDetails");var am=require("react"),u5=require("jotai");var Ro=require("react/jsx-runtime"),cn=(0,am.forwardRef)(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>(0,Ro.jsx)("div",{className:I("courier-flex courier-flex-1 courier-overflow-hidden courier-root-container courier-relative",o&&"courier-editor-readonly",t&&"courier-editor-preview-mode",t==="mobile"&&"courier-editor-preview-mode-mobile",r),...n,ref:i,children:e})),un=(0,am.forwardRef)(({children:e,className:t,previewMode:r,skipExpanded:o=!1,width:n,...i},a)=>{let[l,c]=(0,u5.useAtom)(lo),u=o?!1:l,p=n||"courier-w-64";return r?null:(0,Ro.jsxs)(Ro.Fragment,{children:[u&&(0,Ro.jsx)("div",{className:"courier-absolute courier-inset-0 courier-bg-black/50 courier-z-[9] courier-transition-opacity courier-duration-300 courier-cursor-pointer",onClick:()=>c(!1),"aria-hidden":"true"}),(0,Ro.jsx)("div",{className:I("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch courier-relative",p,t),children:(0,Ro.jsx)("div",{className:I("courier-editor-sidebar courier-absolute courier-top-0 courier-bottom-0 courier-right-0 courier-p-4 courier-h-full courier-overflow-y-auto","courier-transition-all courier-duration-300 courier-ease-in-out",u?"courier-w-[80vw] courier-z-10 courier-shadow-xl courier-translate-x-0":p+" courier-translate-x-0"),...i,ref:a,children:e})})]})});var Qa=require("jotai");var ze=require("react/jsx-runtime"),lm=(0,sm.forwardRef)(({children:e,className:t,...r},o)=>(0,ze.jsx)("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),cm=(0,sm.forwardRef)(({children:e,previewMode:t,...r},o)=>(0,ze.jsx)("div",{className:I("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",t&&"courier-max-w-4xl courier-mx-auto"),...r,ref:o,children:e})),d5=s(({variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:a,colorScheme:l,...c})=>{let u=(0,Qa.useAtomValue)(te),p=(0,Qa.useAtomValue)(lo),m=(0,Qa.useSetAtom)(lo),d=s(()=>{p&&m(!1)},"handleSubjectAreaClick");return(0,ze.jsx)(lc,{value:u,variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:a,colorScheme:l,render:({subject:f,handleSubjectChange:C,selectedNode:h,setSelectedNode:b,previewMode:v,templateEditor:E,ref:g,isBrandApply:w,brandSettings:N,items:y,content:S,syncEditorItems:P,brandEditorContent:T,templateData:x,togglePreviewMode:k,hidePreviewPanelExitButton:M})=>{var A,R,B,F,L,D;return(0,ze.jsxs)(cn,{previewMode:v,children:[(0,ze.jsxs)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:[(0,ze.jsxs)("div",{className:"courier-bg-background courier-h-12 courier-flex courier-items-center courier-gap-2 courier-px-4 courier-border-b",onClick:d,children:[(0,ze.jsxs)("h4",{className:"courier-text-sm courier-h-[25px] courier-flex courier-items-end courier-pb-0.5",children:["Subject:"," "]}),(0,ze.jsx)(wi,{value:f!=null?f:"",onChange:V=>C({target:{value:V}}),onFocus:()=>b(null),className:"!courier-bg-background courier-text-sm courier-flex-1",placeholder:"Write subject...",readOnly:v!==void 0,showToolbar:!0})]}),(0,ze.jsxs)(lm,{ref:g,children:[(0,ze.jsxs)(cm,{previewMode:v,children:[w&&(0,ze.jsxs)("div",{className:I("courier-py-5 courier-px-9 courier-pb-0 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(N==null?void 0:N.headerStyle)==="border"&&"courier-pt-6"),children:[(N==null?void 0:N.headerStyle)==="border"&&(0,ze.jsx)("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)&&(0,ze.jsx)("img",{src:N.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),S&&(0,ze.jsx)(pc,{value:S,onUpdate:P,variables:e}),w&&x&&(0,ze.jsx)("div",{className:"courier-py-5 courier-px-9 courier-pt-0 courier-flex courier-flex-col",children:(0,ze.jsx)(Bi,{readOnly:!0,value:T!=null?T:(D=(L=(F=(B=(R=(A=x==null?void 0:x.data)==null?void 0:A.tenant)==null?void 0:R.brand)==null?void 0:B.settings)==null?void 0:F.email)==null?void 0:L.footer)==null?void 0:D.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})})]}),(0,ze.jsx)(dc,{previewMode:v,togglePreviewMode:k,hideExitButton:M})]})]}),(0,ze.jsx)(un,{previewMode:v,children:(0,ze.jsx)("div",{className:"courier-p-1 courier-h-full",children:h?(0,ze.jsx)(hc,{element:h,editor:E}):(0,ze.jsx)(gc,{items:y.Sidebar,brandEditor:i,label:"Blocks library",editor:E!=null?E:void 0})})})]})},...c})},"EmailLayout");var m5=require("@tiptap/react"),eo=require("jotai"),ut=require("react");var um=require("react/jsx-runtime"),es=[{type:"text",content:`
185
+ `}],!o||o.length===0)return r;let l=a(g=>{var b,M,C,S,P,k,w,T,A;if(g.type==="meta")return[];switch(g.type){case"text":if("content"in g){let N=g.text_style==="h1"?1:g.text_style==="h2"?2:null,R={};if(g.padding){let[D,F]=g.padding.replace(/px/g,"").split(" "),L=parseInt(D),W=parseInt(F);!isNaN(L)&&!isNaN(W)&&(R={paddingVertical:L,paddingHorizontal:W})}let B={};if(g.border_size||(b=g.border)!=null&&b.enabled||(M=g.border)!=null&&M.size){let D=g.border_size||((C=g.border)==null?void 0:C.size),F=g.border_color||((S=g.border)==null?void 0:S.color);B={...D&&{borderWidth:parseInt(D)},...F&&{borderColor:F}}}let H=g.content.trim()?Tf(g.content):[];return[{type:N?"heading":"paragraph",attrs:{textAlign:g.align||"left",level:N,id:`node-${(0,Fr.v4)()}`,...R,...B,...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}:{},B=g.content||"Button",H=[];dd(B,[],H),H.length===0&&H.push({type:"text",text:B||"Button"});let D=(k=g.border_radius)!=null?k:(P=g.border)==null?void 0:P.radius,F=(w=g.border)==null?void 0:w.color,L;return typeof D=="string"?L=parseInt(D):typeof D=="number"&&(L=D),[{type:"button",content:H,attrs:{label:B,link:g.href,alignment:g.align==="full"?"center":g.align||"center",style:g.style,id:`node-${(0,Fr.v4)()}`,...R,...g.background_color&&{backgroundColor:g.background_color},...g.color&&{textColor:g.color},...g.padding&&{padding:parseInt(g.padding)},...L!==void 0&&{borderRadius:L},...F&&{borderColor:F},...g.locales&&{locales:g.locales}}}]}case"quote":{let N="paragraph",R;g.text_style==="h1"?(N="heading",R=1):g.text_style==="h2"?(N="heading",R=2):g.text_style==="subtext"&&(N="heading",R=3);let B={textAlign:g.align||"left",id:`node-${(0,Fr.v4)()}`};return R!==void 0&&(B.level=R),[{type:"blockquote",attrs:{textAlign:g.align||"left",id:`node-${(0,Fr.v4)()}`,...g.border_color&&{borderColor:g.border_color},...g.border_left_width!==void 0&&{borderLeftWidth:g.border_left_width},...g.padding_horizontal!==void 0&&{paddingHorizontal:g.padding_horizontal},...g.padding_vertical!==void 0&&{paddingVertical:g.padding_vertical},...g.background_color&&{backgroundColor:g.background_color},...g.locales&&{locales:g.locales}},content:[{type:N,attrs:B,content:Tf(g.content)}]}]}case"image":{let N={};if(g.width){let H=g.width.endsWith("px"),D=parseInt(g.width.replace(/%|px/,""));if(H&&g.image_natural_width&&g.image_natural_width>0){let F=Math.round(D/g.image_natural_width*100);N.width=Math.max(1,Math.min(100,F)),N.imageNaturalWidth=g.image_natural_width}else N.width=D,g.image_natural_width&&(N.imageNaturalWidth=g.image_natural_width)}let R=g.border_size||((T=g.border)==null?void 0:T.size),B=g.border_color||((A=g.border)==null?void 0:A.color);return[{type:"imageBlock",attrs:{sourcePath:hl(g.src)?"":g.src,id:`node-${(0,Fr.v4)()}`,...g.href&&{link:g.href},...g.align&&{alignment:g.align},...g.alt_text&&{alt:g.alt_text},...N,...R&&{borderWidth:parseInt(R),...B&&{borderColor:B}},...g.locales&&{locales:g.locales}}}]}case"divider":{let N=g.border_width||g.width;return[{type:"divider",attrs:{id:`node-${(0,Fr.v4)()}`,...g.color&&{color:g.color},...N&&{size:parseInt(N)},...g.padding&&{padding:parseInt(g.padding)},variant:g.color==="transparent"?"spacer":"divider"}}]}case"html":return[{type:"customCode",attrs:{id:`node-${(0,Fr.v4)()}`,code:g.content||"<!-- Add your HTML code here -->",...g.locales&&{locales:g.locales}}}];case"group":{let N=g.elements?g.elements.length:2,R=0,B=0;if(g.padding){let V=g.padding.split(" ");R=parseInt(V[0],10)||0,B=parseInt(V[1]||V[0],10)||0}let H=0,D=0,F="transparent";g.border&&(g.border.size&&(H=parseInt(g.border.size,10)||0),g.border.radius!==void 0&&(D=g.border.radius),g.border.color&&(F=g.border.color));let L=g.background_color||"transparent",W=`node-${(0,Fr.v4)()}`,_=g.elements?g.elements.map((V,j)=>{var U;if(V.type==="text"&&"content"in V&&((U=V.content)==null?void 0:U.trim())==="Drag and drop content blocks"&&V.align==="left")return{type:"columnCell",attrs:{index:j,columnId:W,isEditorMode:!1},content:[]};let G;V.type==="group"&&V.elements?G=V.elements.flatMap(l):G=l(V);let X=G.length>0?G:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,Fr.v4)()}`},content:[]}];return{type:"columnCell",attrs:{index:j,columnId:W,isEditorMode:G.length>0},content:X}}):[{type:"columnCell",attrs:{index:0,columnId:W,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,Fr.v4)()}`},content:[]}]},{type:"columnCell",attrs:{index:1,columnId:W,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,Fr.v4)()}`},content:[]}]}];return[{type:"column",attrs:{id:W,columnsCount:Math.min(Math.max(N,1),4),paddingVertical:R,paddingHorizontal:B,backgroundColor:L,borderWidth:H,borderRadius:D,borderColor:F,...g.locales&&{locales:g.locales}},content:[{type:"columnRow",content:_}]}]}default:return[]}},"convertNode"),c=[],u=o.flatMap(l);for(let g=0;g<u.length;g++){let b=u[g],M=u[g+1];if(b.type==="button"&&(M==null?void 0:M.type)==="button"&&n==="inbox"){let C={type:"buttonRow",attrs:{id:`node-${(0,Fr.v4)()}`,button1Label:((d=b.attrs)==null?void 0:d.label)||"Button 1",button1Link:((p=b.attrs)==null?void 0:p.link)||"",button1BackgroundColor:((m=b.attrs)==null?void 0:m.backgroundColor)||"#000000",button1TextColor:((f=b.attrs)==null?void 0:f.textColor)||"#ffffff",button2Label:((v=M.attrs)==null?void 0:v.label)||"Button 2",button2Link:((h=M.attrs)==null?void 0:h.link)||"",button2BackgroundColor:((y=M.attrs)==null?void 0:y.backgroundColor)||"#ffffff",button2TextColor:((x=M.attrs)==null?void 0:x.textColor)||"#000000",padding:((E=b.attrs)==null?void 0:E.padding)||6}};c.push(C),g++}else c.push(b)}return{type:"doc",content:c}}a(tt,"convertElementalToTiptap");function Ef(e,t,r){if(!e)return;let o=/{{([^}]*)}}/g,n,i=0;for(;(n=o.exec(e))!==null;){if(n.index>i){let c=e.substring(i,n.index);r.push({type:"text",text:c,...t.length>0&&{marks:t}})}let s=n[1].trim(),l=s===""||Ot(s);r.push({type:"variable",attrs:{id:s,isInvalid:!l},...t.length>0&&{marks:t}}),i=n.index+n[0].length}if(i<e.length){let s=e.substring(i);r.push({type:"text",text:s,...t.length>0&&{marks:t}})}}a(Ef,"parseTextWithVariables");function ja(e){var l,c;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 u of t){let d=new RegExp(u.regex.source,u.regex.flags),p;for(;(p=d.exec(e))!==null;)if(u.type==="variable"){let m=p[1].trim(),f=m===""||Ot(m);r.push({start:p.index,end:p.index+p[0].length,text:p[1],type:"variable",attrs:{id:m,isInvalid:!f}})}else u.type==="link"?r.push({start:p.index,end:p.index+p[0].length,text:p[1],type:"link",attrs:{href:p[2]}}):r.push({start:p.index,end:p.index+p[0].length,text:p[1],type:u.type})}r.sort((u,d)=>u.start-d.start);let o=[],n=0;for(let u of r)u.start>=n&&(o.push(u),n=u.end);let i=[],s=0;for(let u of o){if(u.start>s){let d=e.substring(s,u.start);d&&Ef(d,[],i)}if(u.type==="variable")i.push({type:"variable",attrs:{id:(l=u.attrs)==null?void 0:l.id,isInvalid:(c=u.attrs)==null?void 0:c.isInvalid}});else if(u.type==="link"){let d=[],p=ja(u.text);d.push(...p),d.forEach(m=>{var f;m.marks=m.marks||[],m.marks.push({type:"link",attrs:{href:(f=u.attrs)==null?void 0:f.href}})}),i.push(...d)}else{let d=ja(u.text);d.forEach(p=>{p.marks=p.marks||[],p.marks.push({type:u.type})}),i.push(...d)}s=u.end}if(s<e.length){let u=e.substring(s);u&&Ef(u,[],i)}return i}a(ja,"processMarkdownFormatting");function dy(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:ja(n[2])});continue}if(o.startsWith(">")){let s=o.slice(1).trim();t.push({type:"blockquote",attrs:{textAlign:"left"},content:[{type:"paragraph",attrs:{textAlign:"left"},content:ja(s)}]});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:ja(o)})}return t}a(dy,"parseBlockContent");function md(e){return{type:"doc",content:dy(e)}}a(md,"convertMarkdownToTiptap");var my=a(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),yl=a(e=>{var o,n,i,s;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(my).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}](${(s=r.attrs)==null?void 0:s.href})`),t},"convertTextToMarkdown");function be(e){let t=a(r=>{var o,n,i,s,l,c,u,d,p,m,f,v,h,y,x,E,g,b,M,C,S,P,k,w,T,A,N,R,B,H,D,F,L,W,_,V,j,J,G,X,U,K,de,me,Me,We,Pt,Ht,ar,Vt,Yt,At,Qt,et,ut,ce,Te,ke,ie,nt,sr,lr,Ro,Lo,jn,Zn,qn,O;switch(r.type){case"paragraph":{let z="",$=r.content||[];for(let fe=0;fe<$.length;fe++)$[fe].type==="hardBreak"?z+=`
186
+ `:z+=yl($[fe]);z+=`
187
+ `;let Y={};(o=r.attrs)!=null&&o.borderWidth&&(Y.border_size=`${r.attrs.borderWidth}px`),(n=r.attrs)!=null&&n.borderColor&&(Y.border_color=r.attrs.borderColor),((i=r.attrs)==null?void 0:i.paddingVertical)!==void 0&&((s=r.attrs)==null?void 0:s.paddingHorizontal)!==void 0&&(Y.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(l=r.attrs)!=null&&l.backgroundColor&&(Y.background_color=r.attrs.backgroundColor),Y.type="text",Y.align=((c=r.attrs)==null?void 0:c.textAlign)||"left",Y.content=z;let ee=Y;return(u=r.attrs)!=null&&u.locales&&(ee.locales=r.attrs.locales),[ee]}case"heading":{let z="",$=r.content||[];for(let fe=0;fe<$.length;fe++)$[fe].type==="hardBreak"?z+=`
188
+ `:z+=yl($[fe]);z+=`
189
+ `;let Y={};(d=r.attrs)!=null&&d.borderWidth&&(Y.border_size=`${r.attrs.borderWidth}px`),(p=r.attrs)!=null&&p.borderColor&&(Y.border_color=r.attrs.borderColor),Y.text_style=((m=r.attrs)==null?void 0:m.level)===1?"h1":"h2",((f=r.attrs)==null?void 0:f.paddingVertical)!==void 0&&((v=r.attrs)==null?void 0:v.paddingHorizontal)!==void 0&&(Y.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(h=r.attrs)!=null&&h.backgroundColor&&(Y.background_color=r.attrs.backgroundColor),Y.type="text",Y.align=((y=r.attrs)==null?void 0:y.textAlign)||"left",Y.content=z;let ee=Y;return(x=r.attrs)!=null&&x.locales&&(ee.locales=r.attrs.locales),[ee]}case"blockquote":{let z="",$,Y;if(r.content)for(let fe of r.content){if(!$){if(fe.type==="heading"){let $e=(E=fe.attrs)==null?void 0:E.level;$e===1?$="h1":$e===2?$="h2":$="subtext"}Y=(g=fe.attrs)==null?void 0:g.textAlign}if(fe.content)for(let $e of fe.content)$e.type==="hardBreak"?z+=`
190
+ `:z+=yl($e);z+=`
191
+ `}z=z.trim();let ee={type:"quote",content:z};return Y&&Y!=="left"&&(ee.align=Y),(b=r.attrs)!=null&&b.borderColor&&(ee.border_color=r.attrs.borderColor),((M=r.attrs)==null?void 0:M.borderLeftWidth)!==void 0&&(ee.border_left_width=r.attrs.borderLeftWidth),((C=r.attrs)==null?void 0:C.paddingHorizontal)!==void 0&&(ee.padding_horizontal=r.attrs.paddingHorizontal),((S=r.attrs)==null?void 0:S.paddingVertical)!==void 0&&(ee.padding_vertical=r.attrs.paddingVertical),(P=r.attrs)!=null&&P.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(ee.background_color=r.attrs.backgroundColor),$&&(ee.text_style=$),(k=r.attrs)!=null&&k.locales&&(ee.locales=r.attrs.locales),[ee]}case"imageBlock":{let z={},$=(w=r.attrs)==null?void 0:w.width,Y=(T=r.attrs)==null?void 0:T.imageNaturalWidth;if($&&Y&&Y>0){let fe=Math.round($/100*Y);z.width=`${fe}px`,z.image_natural_width=Y}else $&&(z.width=`${$}%`);(A=r.attrs)!=null&&A.borderWidth&&(z.border_size=`${r.attrs.borderWidth}px`),(N=r.attrs)!=null&&N.borderColor&&(z.border_color=r.attrs.borderColor),z.type="image",z.src=((R=r.attrs)==null?void 0:R.sourcePath)||"",(B=r.attrs)!=null&&B.alignment&&(z.align=r.attrs.alignment),(H=r.attrs)!=null&&H.link&&(z.href=r.attrs.link),(D=r.attrs)!=null&&D.alt&&(z.alt_text=r.attrs.alt);let ee=z;return(F=r.attrs)!=null&&F.locales&&(ee.locales=r.attrs.locales),[ee]}case"divider":{let z={type:"divider"};return(L=r.attrs)!=null&&L.color&&(z.color=r.attrs.color),(W=r.attrs)!=null&&W.size&&(z.border_width=`${r.attrs.size}px`),(_=r.attrs)!=null&&_.padding&&(z.padding=`${r.attrs.padding}px 0px`),[z]}case"button":{let z=(j=(V=r.attrs)==null?void 0:V.label)!=null?j:"";r.content&&r.content.length>0&&(z=r.content.map(yl).join(""));let $={type:"action",content:z,href:(G=(J=r.attrs)==null?void 0:J.link)!=null?G:"#"};return(X=r.attrs)!=null&&X.style&&($.style=r.attrs.style),$.align=((U=r.attrs)==null?void 0:U.alignment)||"center",(K=r.attrs)!=null&&K.backgroundColor&&($.background_color=r.attrs.backgroundColor),(de=r.attrs)!=null&&de.padding&&($.padding=`${r.attrs.padding}px`),(me=r.attrs)!=null&&me.borderRadius&&($.border_radius=`${r.attrs.borderRadius}px`),(Me=r.attrs)!=null&&Me.locales&&($.locales=r.attrs.locales),[$]}case"buttonRow":{let z={type:"action",content:(Pt=(We=r.attrs)==null?void 0:We.button1Label)!=null?Pt:"Button 1",href:(ar=(Ht=r.attrs)==null?void 0:Ht.button1Link)!=null?ar:"#",align:"left"};(Vt=r.attrs)!=null&&Vt.button1BackgroundColor&&(z.background_color=r.attrs.button1BackgroundColor),(Yt=r.attrs)!=null&&Yt.button1TextColor&&(z.color=r.attrs.button1TextColor);let $={type:"action",content:(Qt=(At=r.attrs)==null?void 0:At.button2Label)!=null?Qt:"Button 2",href:(ut=(et=r.attrs)==null?void 0:et.button2Link)!=null?ut:"#",align:"left"};return(ce=r.attrs)!=null&&ce.button2BackgroundColor&&($.background_color=r.attrs.button2BackgroundColor),(Te=r.attrs)!=null&&Te.button2TextColor&&($.color=r.attrs.button2TextColor),[z,$]}case"customCode":{let z={type:"html",content:((ke=r.attrs)==null?void 0:ke.code)||"<!-- Add your HTML code here -->"};return(ie=r.attrs)!=null&&ie.locales&&(z.locales=r.attrs.locales),[z]}case"column":{let z=((nt=r.attrs)==null?void 0:nt.columnsCount)||2,$=[],Y=(sr=r.content)==null?void 0:sr.find(Ue=>Ue.type==="columnRow");if(Y&&Y.content){for(let Ue of Y.content)if(Ue.type==="columnCell")if(Ue.content&&Ue.content.length>0){let Jn=Ue.content.flatMap(t);Jn.length===0?$.push({type:"text",content:`Drag and drop content blocks
192
+ `,align:"left"}):Jn.length===1?$.push(Jn[0]):$.push({type:"group",elements:Jn})}else $.push({type:"text",content:`Drag and drop content blocks
193
+ `,align:"left"})}else for(let Ue=0;Ue<z;Ue++)$.push({type:"text",content:`Drag and drop content blocks
194
+ `,align:"left"});let ee={type:"group"};if((lr=r.attrs)!=null&&lr.borderWidth&&r.attrs.borderWidth>0){let Ue={};(Ro=r.attrs)!=null&&Ro.borderColor&&(Ue.color=r.attrs.borderColor),Ue.enabled=!0,Ue.size=`${r.attrs.borderWidth}px`,(Lo=r.attrs)!=null&&Lo.borderRadius&&(Ue.radius=r.attrs.borderRadius),ee.border=Ue}let fe=((jn=r.attrs)==null?void 0:jn.paddingVertical)||0,$e=((Zn=r.attrs)==null?void 0:Zn.paddingHorizontal)||0;return(fe>0||$e>0)&&(ee.padding=`${fe}px ${$e}px`),(qn=r.attrs)!=null&&qn.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(ee.background_color=r.attrs.backgroundColor),ee.elements=$,(O=r.attrs)!=null&&O.locales&&(ee.locales=r.attrs.locales),[ee]}default:return r.content?r.content.flatMap(t):[]}},"convertNode");return e!=null&&e.content?e.content.flatMap(t):[]}a(be,"convertTiptapToElemental");function pd(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!==`
195
+ `&&("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=pd(o.elements);if(n)return n}}return r||t||""}a(pd,"getTitle");function fd(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 pd(r.elements)}return""}a(fd,"getTitleForChannel");function Nt(e,t){var s;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=[],v=t.elements.find(y=>y.type==="meta");if(v)f.push(v);else{let y=(c=u.elements)==null?void 0:c.find(x=>x.type==="meta");y&&f.push(y)}let h=t.elements.filter(y=>y.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||!((s=r.elements)!=null&&s.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}a(Nt,"updateElemental");function I(...e){return(0,kf.twMerge)((0,wf.clsx)(e))}a(I,"cn");var Pf=require("@radix-ui/react-slot"),Af=require("class-variance-authority"),Mf=require("react"),Nf=require("react/jsx-runtime"),vl=(0,Af.cva)("courier-flex courier-group courier-items-center courier-justify-center courier-border courier-border-transparent courier-gap-2 courier-text-sm courier-font-semibold courier-rounded-md disabled:courier-opacity-50 courier-whitespace-nowrap courier-outline-none",{variants:{variant:{primary:"courier-text-white courier-bg-[#3B82F6] courier-border-[#3B82F6]",secondary:"courier-text-foreground courier-bg-[#F5F5F5] dark:courier-bg-neutral-700 dark:courier-text-white",tertiary:"courier-bg-neutral-50 courier-text-foreground dark:courier-bg-foreground dark:courier-text-white dark:courier-border-foreground",quaternary:"courier-bg-transparent courier-border-transparent courier-text-neutral-500 dark:courier-text-neutral-400",ghost:"hover:courier-bg-accent hover:courier-text-accent-foreground",link:"courier-text-foreground !courier-font-normal hover:courier-text-accent-foreground !courier-p-0 courier-border-none",outline:"!courier-border-border courier-text-foreground dark:courier-text-white dark:courier-border-foreground hover:courier-bg-neutral-100 dark:hover:courier-bg-neutral-800"},size:{medium:"courier-py-2 courier-px-3",small:"courier-py-1 courier-px-2",icon:"courier-w-8 courier-h-8",iconSmall:"courier-w-6 courier-h-6"},active:{true:"",false:""},disabled:{true:"",false:""}},compoundVariants:[{variant:"primary",disabled:!1,active:!1,class:"hover:courier-bg-blue-600 active:courier-bg-blue-700"},{variant:"primary",active:!0,class:"courier-bg-blue-700"},{variant:"secondary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-600 dark:active:courier-bg-neutral-800"},{variant:"secondary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"tertiary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-800 dark:active:courier-bg-neutral-700"},{variant:"tertiary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"ghost",disabled:!1,active:!1,class:"hover:courier-bg-black/5 hover:courier-text-neutral-700 active:courier-bg-black/10 active:courier-text-neutral-800 dark:hover:courier-bg-white/10 dark:hover:courier-text-neutral-300 dark:active:courier-text-neutral-200"},{variant:"ghost",active:!0,class:"courier-bg-accent courier-text-accent-foreground [&_svg]:courier-text-accent-foreground dark:courier-bg-[#3B82F6] dark:courier-text-white [&_svg]:dark:courier-text-white"}]}),Ve=(0,Mf.forwardRef)(({active:e,buttonSize:t="medium",disabled:r,variant:o="primary",className:n,asChild:i=!1,...s},l)=>(0,Nf.jsx)(i?Pf.Slot:"button",{ref:l,disabled:r,className:I(vl({variant:o,size:t,disabled:r,active:e}),n),...s}));Ve.displayName="Button";var Sf=require("react"),If=require("react/jsx-runtime"),ge=(0,Sf.forwardRef)((e,t)=>(0,If.jsx)("hr",{...e,ref:t,className:I("courier-my-1 courier-border-border dark:courier-border-neutral-600 courier-w-full",e.className)}));ge.displayName="Divider";var Ko=xe(require("react"),1),ye=xe(require("@radix-ui/react-dropdown-menu"),1),ji=require("lucide-react");var vt=require("react/jsx-runtime"),Cl=ye.Root,xl=ye.Trigger;var py=Ko.forwardRef(({className:e,inset:t,children:r,...o},n)=>(0,vt.jsxs)(ye.SubTrigger,{ref:n,className:I("courier-flex courier-cursor-default courier-gap-2 courier-select-none courier-items-center courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent data-[state=open]:courier-bg-accent [&_svg]:courier-pointer-events-none [&_svg]:courier-size-4 [&_svg]:courier-shrink-0",t&&"courier-pl-8",e),...o,children:[r,(0,vt.jsx)(ji.ChevronRight,{className:"courier-ml-auto"})]}));py.displayName=ye.SubTrigger.displayName;var fy=Ko.forwardRef(({className:e,...t},r)=>(0,vt.jsx)(ye.SubContent,{ref:r,className:I("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-lg data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...t}));fy.displayName=ye.SubContent.displayName;var Za=Ko.forwardRef(({className:e,sideOffset:t=4,portalProps:r,...o},n)=>(0,vt.jsx)(ye.Portal,{...r,children:(0,vt.jsx)(ye.Content,{ref:n,sideOffset:t,className:I("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-md","data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...o})}));Za.displayName=ye.Content.displayName;var qa=Ko.forwardRef(({className:e,inset:t,...r},o)=>(0,vt.jsx)(ye.Item,{ref:o,className:I("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-gap-2 courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50 [&>svg]:courier-size-4 [&>svg]:courier-shrink-0",t&&"courier-pl-8",e),...r}));qa.displayName=ye.Item.displayName;var gy=Ko.forwardRef(({className:e,children:t,checked:r,...o},n)=>(0,vt.jsxs)(ye.CheckboxItem,{ref:n,className:I("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),checked:r,...o,children:[(0,vt.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,vt.jsx)(ye.ItemIndicator,{children:(0,vt.jsx)(ji.Check,{className:"courier-h-4 courier-w-4"})})}),t]}));gy.displayName=ye.CheckboxItem.displayName;var hy=Ko.forwardRef(({className:e,children:t,...r},o)=>(0,vt.jsxs)(ye.RadioItem,{ref:o,className:I("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),...r,children:[(0,vt.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,vt.jsx)(ye.ItemIndicator,{children:(0,vt.jsx)(ji.Circle,{className:"courier-h-2 courier-w-2 courier-fill-current"})})}),t]}));hy.displayName=ye.RadioItem.displayName;var by=Ko.forwardRef(({className:e,inset:t,...r},o)=>(0,vt.jsx)(ye.Label,{ref:o,className:I("courier-px-2 courier-py-1.5 courier-text-sm courier-font-semibold",t&&"courier-pl-8",e),...r}));by.displayName=ye.Label.displayName;var yy=Ko.forwardRef(({className:e,...t},r)=>(0,vt.jsx)(ye.Separator,{ref:r,className:I("courier-mx-1 courier-my-1 courier-h-px courier-bg-muted",e),...t}));yy.displayName=ye.Separator.displayName;var vy=a(({className:e,...t})=>(0,vt.jsx)("span",{className:I("courier-ml-auto courier-text-xs courier-tracking-widest courier-opacity-60",e),...t}),"DropdownMenuShortcut");vy.displayName="DropdownMenuShortcut";var Rf=require("react");var Zi=require("react/jsx-runtime"),gd=class gd extends Rf.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){var o,n;console.error("ErrorBoundary caught an error:",t,r),(n=(o=this.props).onError)==null||n.call(o,t,r)}render(){return this.state.hasError?this.props.fallback||(0,Zi.jsx)(Cy,{error:this.state.error}):this.props.children}};a(gd,"ErrorBoundary");var Tl=gd,Cy=a(({error:e})=>(0,Zi.jsxs)("div",{className:"courier-p-6 courier-border courier-border-red-200 courier-bg-red-50 courier-rounded-lg courier-text-center",children:[(0,Zi.jsx)("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),(0,Zi.jsx)("p",{className:"courier-text-red-600 courier-mb-4",children:"An unexpected error occurred in the editor. Please refresh the page or contact support if the problem persists."}),!1]}),"DefaultErrorFallback");var Hf=require("@radix-ui/react-slot"),xr=xe(require("react"),1),qi=require("react-hook-form");var hd=xe(require("@radix-ui/react-label"),1),Lf=require("class-variance-authority"),Bf=xe(require("react"),1),Df=require("react/jsx-runtime"),xy=(0,Lf.cva)("courier-text-sm courier-font-medium courier-leading-none peer-disabled:courier-cursor-not-allowed peer-disabled:courier-opacity-70"),bd=Bf.forwardRef(({className:e,...t},r)=>(0,Df.jsx)(hd.Root,{ref:r,className:I(xy(),e),...t}));bd.displayName=hd.Root.displayName;var Go=require("react/jsx-runtime"),rt=qi.FormProvider,Vf=xr.createContext({}),oe=a(({...e})=>(0,Go.jsx)(Vf.Provider,{value:{name:e.name},children:(0,Go.jsx)(qi.Controller,{...e})}),"FormField"),El=a(()=>{let e=xr.useContext(Vf),t=xr.useContext(Ff),{getFieldState:r,formState:o}=(0,qi.useFormContext)(),n=r(e.name,o);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...n}},"useFormField"),Ff=xr.createContext({}),te=xr.forwardRef(({className:e,...t},r)=>{let o=xr.useId();return(0,Go.jsx)(Ff.Provider,{value:{id:o},children:(0,Go.jsx)("div",{ref:r,className:I("courier-space-y-2",e),...t})})});te.displayName="FormItem";var Vo=xr.forwardRef(({className:e,...t},r)=>{let{error:o,formItemId:n}=El();return(0,Go.jsx)(bd,{ref:r,className:I(o&&"courier-text-destructive",e),htmlFor:n,...t})});Vo.displayName="FormLabel";var re=xr.forwardRef(({...e},t)=>{let{error:r,formItemId:o,formDescriptionId:n,formMessageId:i}=El();return(0,Go.jsx)(Hf.Slot,{ref:t,id:o,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...e})});re.displayName="FormControl";var Ty=xr.forwardRef(({className:e,...t},r)=>{let{formDescriptionId:o}=El();return(0,Go.jsx)("p",{ref:r,id:o,className:I("courier-text-[0.8rem] courier-text-muted-foreground",e),...t})});Ty.displayName="FormDescription";var ne=xr.forwardRef(({className:e,children:t,...r},o)=>{let{error:n,formMessageId:i}=El(),s=n?String(n==null?void 0:n.message):t;return s?(0,Go.jsx)("p",{ref:o,id:i,className:I("courier-text-[0.8rem] courier-font-medium courier-text-destructive",e),...r,children:s}):null});ne.displayName="FormMessage";var je=xe(require("@radix-ui/react-alert-dialog"),1),Qn=xe(require("react"),1);var Of=require("react");var Or=require("react/jsx-runtime"),Wf=je.Root,Uf=je.Trigger,Ey=je.Portal,_f=Qn.forwardRef(({className:e,...t},r)=>(0,Or.jsx)("div",{className:"courier-absolute courier-inset-0 courier-z-50 courier-bg-[#0a0a0a52] data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",children:(0,Or.jsx)(je.Overlay,{asChild:!0,className:I("courier-fixed courier-inset-0 courier-z-50 courier-bg-black/80 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",e),...t,ref:r})}));_f.displayName=je.Overlay.displayName;var yd=Qn.forwardRef(({className:e,...t},r)=>{let o=(0,Of.useCallback)(()=>{var i;let n=(i=r==null?void 0:r.current)==null?void 0:i.parentElement;for(;n;){if(n.classList.contains("theme-container"))return n;n=n.parentElement}return document.body},[r]);return(0,Or.jsxs)(Ey,{container:typeof window!="undefined"?o():void 0,children:[(0,Or.jsx)(_f,{}),(0,Or.jsx)(je.Content,{ref:r,className:I("courier-fixed courier-left-[50%] courier-top-[50%] courier-z-50 courier-grid courier-w-full courier-max-w-lg courier-translate-x-[-50%] courier-translate-y-[-50%] courier-gap-4 courier-border courier-bg-background courier-p-6 courier-shadow-lg courier-duration-200 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[state=closed]:courier-slide-out-to-left-1/2 data-[state=closed]:courier-slide-out-to-top-[48%] data-[state=open]:courier-slide-in-from-left-1/2 data-[state=open]:courier-slide-in-from-top-[48%] sm:courier-rounded-lg",e),...t})]})});yd.displayName=je.Content.displayName;var vd=a(({className:e,...t})=>(0,Or.jsx)("div",{className:I("courier-flex courier-flex-col courier-space-y-2 courier-text-center sm:courier-text-left",e),...t}),"AlertDialogHeader");vd.displayName="AlertDialogHeader";var Cd=a(({className:e,...t})=>(0,Or.jsx)("div",{className:I("courier-flex courier-flex-col-reverse sm:courier-flex-row sm:courier-justify-end sm:courier-space-x-2",e),...t}),"AlertDialogFooter");Cd.displayName="AlertDialogFooter";var wy=Qn.forwardRef(({className:e,...t},r)=>(0,Or.jsx)(je.Title,{ref:r,className:I("courier-text-lg courier-font-semibold",e),...t}));wy.displayName=je.Title.displayName;var ky=Qn.forwardRef(({className:e,...t},r)=>(0,Or.jsx)(je.Description,{ref:r,className:I("courier-text-sm courier-text-muted-foreground",e),...t}));ky.displayName=je.Description.displayName;var xd=Qn.forwardRef(({className:e,...t},r)=>(0,Or.jsx)(je.Action,{ref:r,className:I(vl(),e),...t}));xd.displayName=je.Action.displayName;var Td=Qn.forwardRef(({className:e,...t},r)=>(0,Or.jsx)(je.Cancel,{ref:r,className:I(vl({variant:"outline"}),"courier-mt-2 sm:courier-mt-0",e),...t}));Td.displayName=je.Cancel.displayName;var zf=xe(require("react"),1),Ji=require("react/jsx-runtime"),Ee=zf.forwardRef(({className:e,type:t,startAdornment:r,endAdornment:o,...n},i)=>(0,Ji.jsxs)("div",{className:"courier-relative courier-flex courier-w-full courier-items-center",children:[r&&(0,Ji.jsx)("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),(0,Ji.jsx)("input",{type:t,className:I("courier-flex courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base file:courier-border-0 file:courier-bg-transparent file:courier-text-sm file:courier-font-medium file:courier-text-foreground placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm dark:courier-[color-scheme:dark]",r&&"courier-pl-8",o&&"courier-pr-8",e),ref:i,...n}),o&&(0,Ji.jsx)("div",{className:"courier-absolute courier-right-2 courier-flex courier-items-center courier-pointer-events-none",children:o})]}));Ee.displayName="Input";var yn=require("react");var ur=require("react");var $f=require("lucide-react");var Tr=require("react/jsx-runtime"),Py=a(e=>e==="transparent"||/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e),"isValidHex"),jf=a(({color:e,onChange:t,className:r,presetColors:o,defaultValue:n="transparent"})=>{let[i,s]=(0,ur.useState)(()=>Ja(e)),[l,c]=(0,ur.useState)(e),u=(0,ur.useRef)(null),d=(0,ur.useRef)(null),p=(0,ur.useRef)(null),m=(0,ur.useRef)(!1),f=e!==n,v=(0,ur.useCallback)(g=>{m.current=!0;let b=Ay(g);c(b),t(b),m.current=!1},[t]),h=a(g=>b=>{p.current=g,y(b)},"handleMouseDown"),y=(0,ur.useCallback)(g=>{if(p.current){if(p.current==="gradient"&&u.current){let b=u.current.getBoundingClientRect(),M=Math.max(0,Math.min(1,(g.clientX-b.left)/b.width)),C=Math.max(0,Math.min(1,(g.clientY-b.top)/b.height)),S={...i,s:M*100,v:(1-C)*100};s(S),v(S)}else if(p.current==="hue"&&d.current){let b=d.current.getBoundingClientRect(),M=Math.max(0,Math.min(1,(g.clientX-b.left)/b.width)),C={...i,h:M*360};s(C),v(C)}}},[i,v]),x=(0,ur.useCallback)(()=>{p.current=null},[]);(0,ur.useEffect)(()=>{if(p.current)return window.addEventListener("mousemove",y),window.addEventListener("mouseup",x),()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",x)}},[y,x]),(0,ur.useEffect)(()=>{m.current||(s(Ja(e)),c(e))},[e]);let E=a(g=>{let b=g.target.value;if(c(b),Py(b)){let M=Ja(b);s(M),v(M)}},"handleInputChange");return(0,Tr.jsxs)("div",{className:I("w-full",r),children:[(0,Tr.jsx)("div",{ref:u,className:"courier-relative courier-h-[160px] courier-w-full courier-cursor-crosshair courier-rounded-lg",style:{backgroundColor:`hsl(${i.h}, 100%, 50%)`,backgroundImage:"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)"},onMouseDown:h("gradient"),children:(0,Tr.jsx)("div",{className:"courier-absolute courier-h-3 courier-w-3 courier-translate-x-[-50%] courier-translate-y-[-50%] courier-rounded-full courier-border-2 courier-border-white",style:{left:`${i.s}%`,top:`${100-i.v}%`}})}),(0,Tr.jsx)("div",{ref:d,className:"courier-relative courier-mt-2 courier-h-3 courier-w-full courier-cursor-pointer courier-rounded",style:{background:"linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)"},onMouseDown:h("hue"),children:(0,Tr.jsx)("div",{className:"courier-absolute courier-h-full courier-w-1 courier-translate-x-[-50%] courier-rounded courier-border courier-border-input courier-bg-background",style:{left:`${i.h/360*100}%`}})}),(0,Tr.jsxs)("div",{className:"courier-mt-3 courier-relative courier-flex courier-items-center",children:[(0,Tr.jsx)(Ee,{value:l,onChange:E,placeholder:"#000000",className:"courier-flex-1"}),f&&(0,Tr.jsx)("button",{onClick:g=>{if(g.preventDefault(),n==="transparent"){t("transparent"),c("transparent"),s({h:0,s:0,v:0});return}let b=Ja(n);s(b),v(b)},className:"courier-absolute courier-right-3 courier-flex courier-cursor-pointer courier-items-center courier-justify-center courier-transition-colors",children:(0,Tr.jsx)($f.CircleX,{size:14,strokeWidth:1.25})})]}),(0,Tr.jsx)(ge,{className:"courier-my-3"}),(0,Tr.jsx)("div",{className:"courier-flex courier-flex-wrap courier-gap-1",children:o.map(g=>(0,Tr.jsx)("button",{className:I("courier-h-6 courier-w-6 courier-rounded-md courier-border courier-border-input courier-shrink-0",g==="transparent"&&Ed),style:{backgroundColor:g==="transparent"?void 0:g},onClick:b=>{if(b.preventDefault(),g==="transparent"){t("transparent"),c("transparent"),s({h:0,s:0,v:0});return}let M=Ja(g);s(M),v(M)}},g))})]})},"ColorPicker");function Ja(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),s=n-i,l=0,c=n===0?0:s/n,u=n;if(n!==i){switch(n){case t:l=(r-o)/s+(r<o?6:0);break;case r:l=(o-t)/s+2;break;case o:l=(t-r)/s+4;break}l/=6}return{h:l*360,s:c*100,v:u*100}}a(Ja,"hexToHsv");function Ay({h:e,s:t,v:r}){t/=100,r/=100,e=e%360/360;let o=a(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),s=Math.round(o(1)*255);return`#${[n,i,s].map(l=>l.toString(16).padStart(2,"0")).join("")}`}a(Ay,"hsvToHex");var Fo=xe(require("@radix-ui/react-popover"),1),Zf=xe(require("react"),1);var wd=require("react/jsx-runtime"),qf=Fo.Root,Jf=Fo.Trigger;var kd=Zf.forwardRef(({className:e,align:t="center",side:r="bottom",sideOffset:o=4,collisionPadding:n=10,avoidCollisions:i=!0,portalProps:s,...l},c)=>(0,wd.jsx)(Fo.Portal,{...s,children:(0,wd.jsx)(Fo.Content,{ref:c,side:r,align:t,sideOffset:o,collisionPadding:n,avoidCollisions:i,className:I("courier-z-50 courier-w-72 courier-rounded-md courier-border courier-bg-popover courier-p-4 courier-text-popover-foreground courier-shadow-md courier-outline-none data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...l})}));kd.displayName=Fo.Content.displayName;var Xo=require("react/jsx-runtime"),Ed="bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAwSDBWOEg4VjBaIiBmaWxsPSIjRDlEOUQ5Ii8+PHBhdGggZD0iTTE2IDhIOFYxNkgxNlY4WiIgZmlsbD0iI0Q5RDlEOSIvPjwvc3ZnPg==')]",My=["#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#000000","#525252","#a3a3a3","#ffffff","transparent"],Wt=(0,yn.forwardRef)(({className:e,value:t="",onChange:r,defaultValue:o,transparent:n=!0,presetColors:i=My,...s},l)=>{let c=t!=="transparent",u=(0,yn.useRef)(null),d=(0,yn.useMemo)(()=>n?i:i.filter(m=>m!=="transparent"),[i,n]),p=(0,yn.useCallback)(()=>{var f;let m=(f=u.current)==null?void 0:f.parentElement;for(;m;){if(m.classList.contains("theme-container"))return m;m=m.parentElement}return document.body},[]);return(0,Xo.jsxs)(qf,{children:[(0,Xo.jsx)(Jf,{asChild:!0,children:(0,Xo.jsxs)("div",{className:"courier-relative courier-flex courier-items-center",ref:u,children:[(0,Xo.jsx)("div",{className:I("courier-absolute courier-left-2 courier-flex courier-h-4 courier-w-4 courier-cursor-pointer courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-input courier-transition-colors courier-z-10",c?"":Ed),style:{backgroundColor:c?t:void 0}}),(0,Xo.jsx)(Ee,{...s,ref:l,readOnly:!0,type:"text",value:t==="transparent"?"Transparent":t,className:I("courier-relative courier-cursor-pointer courier-pl-8",e)})]})}),(0,Xo.jsx)(kd,{portalProps:{container:typeof window!="undefined"?p():void 0},className:"courier-w-[230px]",children:(0,Xo.jsx)(jf,{color:t,onChange:r,presetColors:d,defaultValue:o})})]})});Wt.displayName="InputColor";var Kf=xe(require("react"),1),Pd=xe(require("@radix-ui/react-separator"),1);var Gf=require("react/jsx-runtime"),Ad=Kf.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>(0,Gf.jsx)(Pd.Root,{ref:n,decorative:r,orientation:t,className:I("courier-shrink-0 courier-bg-border",t==="horizontal"?"courier-h-[1px] courier-w-full":"courier-h-full courier-w-[1px]",e),...o}));Ad.displayName=Pd.Root.displayName;var Xf=xe(require("react"),1),Yo=xe(require("@radix-ui/react-slider"),1);var Ki=require("react/jsx-runtime"),Md=Xf.forwardRef(({className:e,...t},r)=>(0,Ki.jsxs)(Yo.Root,{ref:r,className:I("courier-relative courier-flex courier-w-full courier-touch-none courier-select-none courier-items-center",e),...t,children:[(0,Ki.jsx)(Yo.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:(0,Ki.jsx)(Yo.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),(0,Ki.jsx)(Yo.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"})]}));Md.displayName=Yo.Root.displayName;var Yf=xe(require("react"),1),Ka=xe(require("@radix-ui/react-switch"),1);var Nd=require("react/jsx-runtime"),Gi=Yf.forwardRef(({className:e,...t},r)=>(0,Nd.jsx)(Ka.Root,{className:I("courier-peer courier-inline-flex courier-h-5 courier-w-9 courier-shrink-0 courier-cursor-pointer courier-items-center courier-rounded-full courier-border-2 courier-border-transparent courier-shadow-sm courier-transition-colors focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2 focus-visible:courier-ring-offset-background disabled:courier-cursor-not-allowed disabled:courier-opacity-50 data-[state=checked]:courier-bg-accent-foreground data-[state=unchecked]:courier-bg-input",e),...t,ref:r,children:(0,Nd.jsx)(Ka.Thumb,{className:I("courier-pointer-events-none courier-block courier-h-4 courier-w-4 courier-rounded-full courier-bg-background courier-shadow-lg courier-ring-0 courier-transition-transform data-[state=checked]:courier-translate-x-4 data-[state=unchecked]:courier-translate-x-0")})}));Gi.displayName=Ka.Root.displayName;var wl=xe(require("react"),1),so=xe(require("@radix-ui/react-tabs"),1);var Al=require("react/jsx-runtime"),kl=so.Root,Ga=wl.forwardRef(({className:e,...t},r)=>(0,Al.jsx)(so.List,{ref:r,className:I("courier-inline-flex courier-h-9 courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-border courier-bg-background courier-p-[3px] courier-text-muted-foreground",e),...t}));Ga.displayName=so.List.displayName;var Xi=wl.forwardRef(({className:e,...t},r)=>(0,Al.jsx)(so.Trigger,{ref:r,className:I("courier-inline-flex courier-items-center courier-justify-center courier-whitespace-nowrap courier-rounded-sm courier-px-3 courier-py-1 courier-text-sm courier-font-medium courier-ring-offset-background courier-transition-all focus-visible:courier-outline-none disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=active]:courier-bg-accent data-[state=active]:courier-text-accent-foreground",e),...t}));Xi.displayName=so.Trigger.displayName;var Pl=wl.forwardRef(({className:e,...t},r)=>(0,Al.jsx)(so.Content,{ref:r,className:I("courier-mt-2 courier-ring-offset-background focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2",e),...t}));Pl.displayName=so.Content.displayName;var Yi=xe(require("react"),1);var Qf=require("react/jsx-runtime"),Sd=Yi.forwardRef(({className:e,autoResize:t=!1,...r},o)=>{let n=Yi.useRef(null),i=a(s=>{n.current=s,typeof o=="function"?o(s):o&&(o.current=s)},"combinedRef");return Yi.useEffect(()=>{if(!t)return;let s=n.current;if(!s)return;let l=a(()=>{s.style.height="auto",s.style.height=`${s.scrollHeight}px`},"adjustHeight");return l(),s.addEventListener("input",l),()=>{s.removeEventListener("input",l)}},[t]),(0,Qf.jsx)("textarea",{className:I("courier-flex courier-min-h-[44px] courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base courier-placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm",t&&"courier-resize-none",e),ref:i,...r})});Sd.displayName="Textarea";var Nl=require("react");var r1=require("react");var Ml={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"},e1={...Ml},t1={...Ml,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 Id=(0,r1.createContext)(Ml);var Rd=require("react/jsx-runtime"),o1=(0,Nl.forwardRef)(({children:e,theme:t,colorScheme:r,className:o},n)=>{let i=r!=null?r:"light",s=i==="light"?e1:t1,l=s;t&&(l=typeof t=="string"?t:{...s,...t});let c=typeof t=="string"?{}:Object.entries(l).reduce((u,[d,p])=>{let m=d.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`);return{...u,[`--${m}`]:p}},{});return(0,Rd.jsx)(Id.Provider,{value:typeof l=="object"?l:{},children:(0,Rd.jsx)("div",{style:c,className:I("courier-flex courier-flex-col courier-relative",typeof t=="string"?t:"","theme-container",i==="dark"?"dark courier-dark":"",o),ref:n,children:e})})}),n1=a(()=>(0,Nl.useContext)(Id),"useTheme");var i1=xe(require("react"),1),Ld=xe(require("@radix-ui/react-toggle"),1),a1=require("class-variance-authority");var s1=require("react/jsx-runtime"),Bd=(0,a1.cva)("courier-inline-flex courier-items-center courier-justify-center courier-gap-2 courier-rounded-md courier-text-sm courier-font-medium courier-transition-colors hover:courier-bg-secondary hover:courier-text-foreground focus-visible:courier-outline-none focus-visible:courier-ring-1 focus-visible:courier-ring-ring disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=on]:courier-bg-accent data-[state=on]:courier-text-accent-foreground data-[state=on]:dark:courier-text-white [&_svg]:courier-pointer-events-none [&_svg]:courier-size-[30px] [&_svg]:courier-shrink-0",{variants:{variant:{default:"courier-bg-transparent",outline:"courier-border courier-border-input courier-bg-transparent courier-shadow-sm hover:courier-bg-accent hover:courier-text-accent-foreground"},size:{default:"courier-h-9 courier-min-w-9",sm:"courier-h-8 courier-px-1.5 courier-min-w-8",lg:"courier-h-10 courier-px-2.5 courier-min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),Ny=i1.forwardRef(({className:e,variant:t,size:r,...o},n)=>(0,s1.jsx)(Ld.Root,{ref:n,className:I(Bd({variant:t,size:r,className:e})),...o}));Ny.displayName=Ld.Root.displayName;var Qi=xe(require("@radix-ui/react-toggle-group"),1),ei=xe(require("react"),1);var Sl=require("react/jsx-runtime"),l1=ei.createContext({size:"default",variant:"default"}),Xr=ei.forwardRef(({className:e,variant:t,size:r,children:o,...n},i)=>(0,Sl.jsx)(Qi.Root,{ref:i,className:I("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:(0,Sl.jsx)(l1.Provider,{value:{variant:t,size:r},children:o})}));Xr.displayName=Qi.Root.displayName;var dr=ei.forwardRef(({className:e,children:t,variant:r,size:o,...n},i)=>{let s=ei.useContext(l1);return(0,Sl.jsx)(Qi.Item,{ref:i,className:I(Bd({variant:s.variant||r,size:s.size||o}),e),...n,children:t})});dr.displayName=Qi.Item.displayName;var Il=require("react/jsx-runtime"),Fe=a(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?(0,Il.jsx)("path",{className:I(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):(0,Il.jsx)("path",{className:I(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),Q=a(({width:e=28,height:t=28,...r})=>(0,Il.jsx)("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");var ea=require("react/jsx-runtime"),c1=a(({color:e="#000000",width:t=19,height:r=10,...o})=>(0,ea.jsxs)(Q,{...o,width:t,height:r,children:[(0,ea.jsx)("rect",{opacity:"0.6",x:"0.553621",y:"0.876863",width:"16.4923",height:"7.87692",rx:"1.6",stroke:e,strokeWidth:"0.738462"}),(0,ea.jsx)("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),(0,ea.jsx)("path",{opacity:"0.6",d:"M17.9075 3.70703C18.4513 3.70703 18.8921 4.14786 18.8921 4.69165V4.9378C18.8921 5.48159 18.4513 5.92242 17.9075 5.92242V3.70703Z",fill:e})]}),"BatteryIcon");var Dd=require("react/jsx-runtime"),Xa=a(({color:e="#DC2626",width:t=13,height:r=13,...o})=>(0,Dd.jsx)(Q,{...o,fill:"none",width:t,height:r,children:(0,Dd.jsx)("path",{d:"M4.89844 1.625C4.82812 1.625 4.78125 1.67188 4.73438 1.71875L4.28906 2.375H7.6875L7.24219 1.71875C7.21875 1.67188 7.14844 1.625 7.07812 1.625H4.89844ZM9.04688 2.375H9.35156H10.5H10.6875C10.9922 2.375 11.25 2.63281 11.25 2.9375C11.25 3.26562 10.9922 3.5 10.6875 3.5H10.4062L9.84375 11.1172C9.77344 11.9141 9.14062 12.5 8.34375 12.5H3.63281C2.83594 12.5 2.20312 11.9141 2.13281 11.1172L1.57031 3.5H1.3125C0.984375 3.5 0.75 3.26562 0.75 2.9375C0.75 2.63281 0.984375 2.375 1.3125 2.375H1.5H2.625H2.92969L3.79688 1.08594C4.03125 0.734375 4.45312 0.5 4.89844 0.5H7.07812C7.52344 0.5 7.94531 0.734375 8.17969 1.08594L9.04688 2.375ZM9.28125 3.5H2.69531L3.25781 11.0469C3.28125 11.2344 3.44531 11.375 3.63281 11.375H8.34375C8.53125 11.375 8.69531 11.2344 8.71875 11.0469L9.28125 3.5Z",fill:e})}),"BinIcon");var Hd=require("react/jsx-runtime"),Ya=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Hd.jsx)(Q,{...n,width:r,height:o,children:(0,Hd.jsx)(Fe,{active:t,colorProp:"stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",d:"M1 15V11C1 5.47715 5.47715 1 11 1H15"})}),"BorderRadiusIcon");var ta=require("react/jsx-runtime"),Qo=a(({color:e="#A3A3A3",width:t=16,height:r=16,...o})=>(0,ta.jsxs)(Q,{...o,width:t,height:r,children:[(0,ta.jsx)("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),(0,ta.jsx)("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),(0,ta.jsx)("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");var Vd=require("react/jsx-runtime"),Fd=a(({color:e,width:t=21,height:r=16,...o})=>(0,Vd.jsx)(Q,{...o,width:t,height:r,children:(0,Vd.jsx)("path",{d:"M2.5 1.5C2.21875 1.5 2 1.75 2 2V11C2 11.2812 2.21875 11.5 2.5 11.5H18.5C18.75 11.5 19 11.2812 19 11V2C19 1.75 18.75 1.5 18.5 1.5H2.5ZM0.5 2C0.5 0.90625 1.375 0 2.5 0H18.5C19.5938 0 20.5 0.90625 20.5 2V11C20.5 12.125 19.5938 13 18.5 13H2.5C1.375 13 0.5 12.125 0.5 11V2ZM4.25 14.5H16.75C17.1562 14.5 17.5 14.8438 17.5 15.25C17.5 15.6875 17.1562 16 16.75 16H4.25C3.8125 16 3.5 15.6875 3.5 15.25C3.5 14.8438 3.8125 14.5 4.25 14.5Z",fill:e})}),"DesktopIcon");var Od=require("react/jsx-runtime"),Wd=a(({color:e="#171717",width:t=12,height:r=13,...o})=>(0,Od.jsx)(Q,{...o,fill:"none",width:t,height:r,children:(0,Od.jsx)("path",{d:"M1.5 11.375H6.75C6.9375 11.375 7.125 11.2109 7.125 11V9.5H8.25V11C8.25 11.8438 7.57031 12.5 6.75 12.5H1.5C0.65625 12.5 0 11.8438 0 11V5.75C0 4.92969 0.65625 4.25 1.5 4.25H3V5.375H1.5C1.28906 5.375 1.125 5.5625 1.125 5.75V11C1.125 11.2109 1.28906 11.375 1.5 11.375ZM5.25 7.625H10.5C10.6875 7.625 10.875 7.46094 10.875 7.25V2C10.875 1.8125 10.6875 1.625 10.5 1.625H5.25C5.03906 1.625 4.875 1.8125 4.875 2V7.25C4.875 7.46094 5.03906 7.625 5.25 7.625ZM3.75 7.25V2C3.75 1.17969 4.40625 0.5 5.25 0.5H10.5C11.3203 0.5 12 1.17969 12 2V7.25C12 8.09375 11.3203 8.75 10.5 8.75H5.25C4.40625 8.75 3.75 8.09375 3.75 7.25Z",fill:e})}),"DuplicateIcon");var Ud=require("react/jsx-runtime"),_d=a(({color:e="#404040",width:t=20,height:r=15,viewBox:o="0 0 20 15",...n})=>(0,Ud.jsx)(Q,{...n,width:t,height:r,viewBox:o,children:(0,Ud.jsx)("path",{d:"M1.875 0H18.125C19.1406 0 20 0.859375 20 1.875C20 2.5 19.6875 3.04688 19.2188 3.39844L10.7422 9.76562C10.2734 10.1172 9.6875 10.1172 9.21875 9.76562L0.742188 3.39844C0.273438 3.04688 0 2.5 0 1.875C0 0.859375 0.820312 0 1.875 0ZM0 4.375L8.47656 10.7812C9.375 11.4453 10.5859 11.4453 11.4844 10.7812L20 4.375V12.5C20 13.9062 18.8672 15 17.5 15H2.5C1.09375 15 0 13.9062 0 12.5V4.375Z",fill:e})}),"EmailIcon");var zd=require("react/jsx-runtime"),Qa=a(({color:e="#737373",width:t=16,height:r=16,...o})=>(0,zd.jsx)(Q,{...o,width:t,height:r,children:(0,zd.jsx)(Fe,{d:"M10.25 1H14.25C14.6562 1 15 1.34375 15 1.75V5.75C15 6.1875 14.6562 6.5 14.25 6.5C13.8125 6.5 13.5 6.1875 13.5 5.75V3.5625L9.03125 8L13.5 12.4688V10.25C13.5 9.84375 13.8125 9.5 14.25 9.5C14.6562 9.5 15 9.84375 15 10.25V14.25C15 14.6875 14.6562 15 14.25 15H10.25C9.8125 15 9.5 14.6875 9.5 14.25C9.5 13.8438 9.8125 13.5 10.25 13.5H12.4375L8 9.0625L3.53125 13.5H5.75C6.15625 13.5 6.5 13.8438 6.5 14.25C6.5 14.6875 6.15625 15 5.75 15H1.75C1.3125 15 1 14.6875 1 14.25V10.25C1 9.84375 1.3125 9.5 1.75 9.5C2.15625 9.5 2.5 9.84375 2.5 10.25V12.4688L6.9375 8L2.5 3.5625V5.75C2.5 6.1875 2.15625 6.5 1.75 6.5C1.3125 6.5 1 6.1875 1 5.75V1.75C1 1.34375 1.3125 1 1.75 1H5.75C6.15625 1 6.5 1.34375 6.5 1.75C6.5 2.1875 6.15625 2.5 5.75 2.5H3.53125L8 6.96875L12.4375 2.5H10.25C9.8125 2.5 9.5 2.1875 9.5 1.75C9.5 1.34375 9.8125 1 10.25 1Z",fill:e})}),"ExpandIcon");var $d=require("react/jsx-runtime"),es=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,$d.jsx)(Q,{...n,width:r,height:o,children:(0,$d.jsx)(Fe,{d:"M16 8C16 12.0938 12.9062 15.4688 8.96875 15.9688V10.4688H11.125L11.5625 8H8.96875V7.15625C8.96875 5.84375 9.46875 5.34375 10.7812 5.34375C11.1875 5.34375 11.5 5.375 11.6875 5.375V3.1875C11.3438 3.0625 10.4688 2.96875 9.96875 2.96875C7.28125 2.96875 6.0625 4.25 6.0625 6.96875V8H4.40625V10.4688H6.0625V15.7812C2.5625 14.9062 0 11.75 0 8C0 3.59375 3.5625 0 8 0C12.4062 0 16 3.59375 16 8Z",active:t,fill:e})}),"FacebookIcon");var jd=require("react/jsx-runtime"),Zd=a(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,jd.jsx)(Q,{...o,width:t,height:r,children:(0,jd.jsx)(Fe,{d:"M0 2.75C0 2.34375 0.3125 2 0.75 2H13.25C13.6562 2 14 2.34375 14 2.75C14 3.1875 13.6562 3.5 13.25 3.5H0.75C0.3125 3.5 0 3.1875 0 2.75ZM2 7.75C2 7.34375 2.3125 7 2.75 7H11.25C11.6562 7 12 7.34375 12 7.75C12 8.1875 11.6562 8.5 11.25 8.5H2.75C2.3125 8.5 2 8.1875 2 7.75ZM9 12.75C9 13.1875 8.65625 13.5 8.25 13.5H5.75C5.3125 13.5 5 13.1875 5 12.75C5 12.3438 5.3125 12 5.75 12H8.25C8.65625 12 9 12.3438 9 12.75Z",fill:e})}),"HamburgerMenuIcon");var qd=require("react/jsx-runtime"),ts=a(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,qd.jsx)(Q,{...o,width:t,height:r,children:(0,qd.jsx)("path",{d:"M2 5.75C2 4.38281 3.09375 3.25 4.5 3.25H19.5C20.8672 3.25 22 4.38281 22 5.75V8.25V10.125V10.75V18.25C22 19.6562 20.8672 20.75 19.5 20.75H4.5C3.09375 20.75 2 19.6562 2 18.25V10.75V10.125V8.25V5.75ZM20.125 10.75H3.875V18.25C3.875 18.6016 4.14844 18.875 4.5 18.875H19.5C19.8125 18.875 20.125 18.6016 20.125 18.25V10.75ZM5.75 8.25C6.41406 8.25 7 7.70312 7 7C7 6.33594 6.41406 5.75 5.75 5.75C5.04688 5.75 4.5 6.33594 4.5 7C4.5 7.70312 5.04688 8.25 5.75 8.25ZM10.75 7C10.75 6.33594 10.1641 5.75 9.5 5.75C8.79688 5.75 8.25 6.33594 8.25 7C8.25 7.70312 8.79688 8.25 9.5 8.25C10.1641 8.25 10.75 7.70312 10.75 7ZM13.25 8.25C13.9141 8.25 14.5 7.70312 14.5 7C14.5 6.33594 13.9141 5.75 13.25 5.75C12.5469 5.75 12 6.33594 12 7C12 7.70312 12.5469 8.25 13.25 8.25Z",fill:e})}),"InboxIcon");var Jd=require("react/jsx-runtime"),rs=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Jd.jsx)(Q,{...n,width:r,height:o,children:(0,Jd.jsx)(Fe,{d:"M8 4.40625C9.96875 4.40625 11.5938 6.03125 11.5938 8C11.5938 10 9.96875 11.5938 8 11.5938C6 11.5938 4.40625 10 4.40625 8C4.40625 6.03125 6 4.40625 8 4.40625ZM8 10.3438C9.28125 10.3438 10.3125 9.3125 10.3125 8C10.3125 6.71875 9.28125 5.6875 8 5.6875C6.6875 5.6875 5.65625 6.71875 5.65625 8C5.65625 9.3125 6.71875 10.3438 8 10.3438ZM12.5625 4.28125C12.5625 3.8125 12.1875 3.4375 11.7188 3.4375C11.25 3.4375 10.875 3.8125 10.875 4.28125C10.875 4.75 11.25 5.125 11.7188 5.125C12.1875 5.125 12.5625 4.75 12.5625 4.28125ZM14.9375 5.125C15 6.28125 15 9.75 14.9375 10.9062C14.875 12.0312 14.625 13 13.8125 13.8438C13 14.6562 12 14.9062 10.875 14.9688C9.71875 15.0312 6.25 15.0312 5.09375 14.9688C3.96875 14.9062 3 14.6562 2.15625 13.8438C1.34375 13 1.09375 12.0312 1.03125 10.9062C0.96875 9.75 0.96875 6.28125 1.03125 5.125C1.09375 4 1.34375 3 2.15625 2.1875C3 1.375 3.96875 1.125 5.09375 1.0625C6.25 1 9.71875 1 10.875 1.0625C12 1.125 13 1.375 13.8125 2.1875C14.625 3 14.875 4 14.9375 5.125ZM13.4375 12.125C13.8125 11.2188 13.7188 9.03125 13.7188 8C13.7188 7 13.8125 4.8125 13.4375 3.875C13.1875 3.28125 12.7188 2.78125 12.125 2.5625C11.1875 2.1875 9 2.28125 8 2.28125C6.96875 2.28125 4.78125 2.1875 3.875 2.5625C3.25 2.8125 2.78125 3.28125 2.53125 3.875C2.15625 4.8125 2.25 7 2.25 8C2.25 9.03125 2.15625 11.2188 2.53125 12.125C2.78125 12.75 3.25 13.2188 3.875 13.4688C4.78125 13.8438 6.96875 13.75 8 13.75C9 13.75 11.1875 13.8438 12.125 13.4688C12.7188 13.2188 13.2188 12.75 13.4375 12.125Z",active:t,fill:e})}),"InstagramIcon");var Kd=require("react/jsx-runtime"),os=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Kd.jsx)(Q,{...n,width:r,height:o,children:(0,Kd.jsx)(Fe,{d:"M14 1C14.5312 1 15 1.46875 15 2.03125V14C15 14.5625 14.5312 15 14 15H1.96875C1.4375 15 1 14.5625 1 14V2.03125C1 1.46875 1.4375 1 1.96875 1H14ZM5.21875 13V6.34375H3.15625V13H5.21875ZM4.1875 5.40625C4.84375 5.40625 5.375 4.875 5.375 4.21875C5.375 3.5625 4.84375 3 4.1875 3C3.5 3 2.96875 3.5625 2.96875 4.21875C2.96875 4.875 3.5 5.40625 4.1875 5.40625ZM13 13V9.34375C13 7.5625 12.5938 6.15625 10.5 6.15625C9.5 6.15625 8.8125 6.71875 8.53125 7.25H8.5V6.34375H6.53125V13H8.59375V9.71875C8.59375 8.84375 8.75 8 9.84375 8C10.9062 8 10.9062 9 10.9062 9.75V13H13Z",active:t,fill:e})}),"LinkedinIcon");var Gd=require("react/jsx-runtime"),Xd=a(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 256 239",...n})=>(0,Gd.jsx)(Q,{...n,width:t,height:r,viewBox:o,children:(0,Gd.jsx)("path",{d:"M244.688 89.3027C250.936 89.3028 256 94.367 256 100.614V160.846C256 183.806 237.387 202.419 214.427 202.419H214.23C207.916 202.42 201.932 201.009 196.571 198.491C186.31 221.332 163.63 237.486 136.931 238.14C107.972 237.431 83.7409 218.49 74.9551 192.558H120.063C130.509 192.558 138.977 184.09 138.977 173.645V89.3027H244.688ZM120.082 53.5811C120.127 53.5812 120.172 53.5842 120.217 53.585C125.988 53.6645 130.676 58.2209 130.962 63.9395C130.971 64.1173 130.976 64.2966 130.977 64.4766V173.646C130.976 179.672 126.09 184.558 120.063 184.558H10.9131C4.88618 184.558 9.07128e-05 179.672 0 173.646V64.4941C0 58.4673 4.88624 53.5811 10.9131 53.5811H120.082ZM36.7686 95.125H58.4873V154.541H72.3887V95.125H94.208V83.5986H36.7686V95.125ZM139.907 0C161.279 0.000200803 178.604 17.3254 178.604 38.6973C178.604 60.0693 161.279 77.3953 139.907 77.3955C139.596 77.3955 139.286 77.3901 138.977 77.3828V64.4941C138.976 54.0493 130.509 45.5811 120.063 45.5811H101.82C101.419 43.3471 101.209 41.0467 101.209 38.6973C101.209 17.3253 118.535 0 139.907 0ZM223.256 23.8145C238.052 23.8145 250.047 35.8085 250.047 50.6045C250.047 65.4005 238.052 77.3954 223.256 77.3955C208.46 77.3955 196.465 65.4006 196.465 50.6045C196.465 35.8085 208.46 23.8145 223.256 23.8145Z",fill:e})}),"MSTeamsIcon");var Yd=require("react/jsx-runtime"),ns=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Yd.jsx)(Q,{...n,width:r,height:o,children:(0,Yd.jsx)(Fe,{d:"M5.625 2.34375C8.75 2.34375 11.2812 4.875 11.2812 8C11.2812 11.1562 8.75 13.6875 5.625 13.6875C2.5 13.6875 0 11.1562 0 8C0 4.875 2.5 2.34375 5.625 2.34375ZM14.625 2.65625C16.1875 2.65625 17.4688 5.0625 17.4688 8.03125C17.4688 10.9688 16.1875 13.375 14.625 13.375C13.0625 13.375 11.8125 10.9688 11.8125 8.03125C11.8125 5.0625 13.0625 2.65625 14.625 2.65625ZM19 3.21875C19.5312 3.21875 20 5.375 20 8C20 10.6562 19.5312 12.8125 19 12.8125C18.4375 12.8125 18 10.6562 18 8.03125C18 5.375 18.4375 3.21875 19 3.21875Z",active:t,fill:e})}),"MediumIcon");var Rl=require("react/jsx-runtime"),Qd=a(({color:e,width:t=21,height:r=16,...o})=>(0,Rl.jsx)(Q,{...o,width:t,height:r,children:(0,Rl.jsx)("g",{transform:"translate(4, 0)",children:(0,Rl.jsx)("path",{d:"M8.5 1.5V2C8.5 2.28125 8.25 2.5 8 2.5H5C4.71875 2.5 4.5 2.28125 4.5 2V1.5H3.5C2.9375 1.5 2.5 1.96875 2.5 2.5V13.5C2.5 14.0625 2.9375 14.5 3.5 14.5H9.5C10.0312 14.5 10.5 14.0625 10.5 13.5V2.5C10.5 1.96875 10.0312 1.5 9.5 1.5H8.5ZM1 2.5C1 1.125 2.09375 0 3.5 0H9.5C10.875 0 12 1.125 12 2.5V13.5C12 14.9062 10.875 16 9.5 16H3.5C2.09375 16 1 14.9062 1 13.5V2.5Z",fill:e})})}),"MobileIcon");var em=require("react/jsx-runtime"),tm=a(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,em.jsx)(Q,{...o,width:t,height:r,children:(0,em.jsx)(Fe,{d:"M13.5 8C13.5 8.5625 13.1875 9.03125 12.75 9.3125C12.2812 9.59375 11.6875 9.59375 11.25 9.3125C10.7812 9.03125 10.5 8.5625 10.5 8C10.5 7.46875 10.7812 7 11.25 6.71875C11.6875 6.4375 12.2812 6.4375 12.75 6.71875C13.1875 7 13.5 7.46875 13.5 8ZM8.5 8C8.5 8.5625 8.1875 9.03125 7.75 9.3125C7.28125 9.59375 6.6875 9.59375 6.25 9.3125C5.78125 9.03125 5.5 8.5625 5.5 8C5.5 7.46875 5.78125 7 6.25 6.71875C6.6875 6.4375 7.28125 6.4375 7.75 6.71875C8.1875 7 8.5 7.46875 8.5 8ZM2 9.5C1.4375 9.5 0.96875 9.21875 0.6875 8.75C0.40625 8.3125 0.40625 7.71875 0.6875 7.25C0.96875 6.8125 1.4375 6.5 2 6.5C2.53125 6.5 3 6.8125 3.28125 7.25C3.5625 7.71875 3.5625 8.3125 3.28125 8.75C3 9.21875 2.53125 9.5 2 9.5Z",fill:e})}),"MoreMenuIcon");var rm=require("react/jsx-runtime"),is=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,rm.jsx)(Q,{...n,width:r,height:o,children:(0,rm.jsx)(Fe,{d:"M14.25 0C14.6562 0 15 0.34375 15 0.75V15.25C15 15.6875 14.6562 16 14.25 16C13.8125 16 13.5 15.6875 13.5 15.25V0.75C13.5 0.34375 13.8125 0 14.25 0ZM9.5 11.5V4.5H6.5V11.5H9.5ZM11 4.5V11.5C11 12.3438 10.3125 13 9.5 13H6.5C5.65625 13 5 12.3438 5 11.5V4.5C5 3.6875 5.65625 3 6.5 3H9.5C10.3125 3 11 3.6875 11 4.5ZM2.5 0.75V15.25C2.5 15.6875 2.15625 16 1.75 16C1.3125 16 1 15.6875 1 15.25V0.75C1 0.34375 1.3125 0 1.75 0C2.15625 0 2.5 0.34375 2.5 0.75Z",active:t,fill:e})}),"PaddingHorizontalIcon");var om=require("react/jsx-runtime"),ti=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,om.jsx)(Q,{...n,width:r,height:o,children:(0,om.jsx)(Fe,{d:"M0 1.75C0 1.34375 0.3125 1 0.75 1H15.25C15.6562 1 16 1.34375 16 1.75C16 2.1875 15.6562 2.5 15.25 2.5H0.75C0.3125 2.5 0 2.1875 0 1.75ZM11.5 6.5H4.5V9.5H11.5V6.5ZM4.5 5H11.5C12.3125 5 13 5.6875 13 6.5V9.5C13 10.3438 12.3125 11 11.5 11H4.5C3.65625 11 3 10.3438 3 9.5V6.5C3 5.6875 3.65625 5 4.5 5ZM0.75 13.5H15.25C15.6562 13.5 16 13.8438 16 14.25C16 14.6875 15.6562 15 15.25 15H0.75C0.3125 15 0 14.6875 0 14.25C0 13.8438 0.3125 13.5 0.75 13.5Z",active:t,fill:e})}),"PaddingVerticalIcon");var as=require("react/jsx-runtime"),nm=a(({width:e=20,height:t=21,viewBox:r="0 0 20 21",...o})=>(0,as.jsxs)(Q,{...o,width:e,height:t,viewBox:r,children:[(0,as.jsx)("path",{d:"M15 4.625H2.5C2.14844 4.625 1.875 4.9375 1.875 5.25V17.75C1.875 18.1016 2.14844 18.375 2.5 18.375H15C15.3125 18.375 15.625 18.1016 15.625 17.75V5.25C15.625 4.9375 15.3125 4.625 15 4.625ZM2.5 2.75H15C16.3672 2.75 17.5 3.88281 17.5 5.25V17.75C17.5 19.1562 16.3672 20.25 15 20.25H2.5C1.09375 20.25 0 19.1562 0 17.75V5.25C0 3.88281 1.09375 2.75 2.5 2.75Z",fill:"currentColor"}),(0,as.jsx)("circle",{cx:"2",cy:"2",r:"3",transform:"matrix(-1 0 0 1 17.75 2)",fill:"currentColor",stroke:"white",strokeWidth:"2"})]}),"PushIcon");var im=require("react/jsx-runtime"),am=a(({color:e="#171717",width:t=16,height:r=13,...o})=>(0,im.jsx)(Q,{...o,fill:"none",width:t,height:r,children:(0,im.jsx)("path",{d:"M1.39062 0.640625L4.01562 2.67969L4.17969 1.97656C4.29688 1.55469 4.67188 1.25 5.09375 1.25H12.9453C13.5547 1.25 14 1.83594 13.8594 2.42188L13.6016 3.45312C13.5312 3.75781 13.2266 3.94531 12.9219 3.875C12.6172 3.80469 12.4297 3.5 12.5 3.19531L12.7109 2.375H9.78125L8.65625 6.33594L15.2656 11.5156C15.5234 11.7031 15.5703 12.0547 15.3594 12.2891C15.1719 12.5469 14.8203 12.5938 14.5859 12.3828L0.710938 1.50781C0.453125 1.32031 0.40625 0.96875 0.617188 0.734375C0.804688 0.476562 1.15625 0.429688 1.39062 0.640625ZM4.97656 3.42969L7.71875 5.58594L8.60938 2.375H5.23438L4.97656 3.42969ZM8 8.67969L7.4375 10.625H8.75C9.05469 10.625 9.3125 10.8828 9.3125 11.1875C9.3125 11.5156 9.05469 11.75 8.75 11.75H5C4.67188 11.75 4.4375 11.5156 4.4375 11.1875C4.4375 10.8828 4.67188 10.625 5 10.625H6.28906L6.3125 10.4844L7.03906 7.92969L8 8.67969Z",fill:e})}),"RemoveFormattingIcon");var sm=require("react/jsx-runtime"),lm=a(({color:e="#171717",width:t=11,height:r=12,...o})=>(0,sm.jsx)(Q,{...o,width:t,height:r,children:(0,sm.jsx)(Fe,{d:"M10.75 2.75V10.25C10.75 10.6719 10.3984 11 10 11C9.57812 11 9.25 10.6719 9.25 10.25V2.75C9.25 2.35156 9.57812 2 10 2C10.3984 2 10.75 2.35156 10.75 2.75ZM7.51562 7.03906L4.51562 10.0391C4.23438 10.3438 3.74219 10.3438 3.46094 10.0391C3.15625 9.75781 3.15625 9.26562 3.46094 8.98438L5.17188 7.25H1C0.578125 7.25 0.25 6.92188 0.25 6.5C0.25 6.10156 0.578125 5.75 1 5.75H5.17188L3.46094 4.03906C3.15625 3.75781 3.15625 3.26562 3.46094 2.98438C3.74219 2.67969 4.23438 2.67969 4.51562 2.98438L7.51562 5.98438C7.82031 6.26562 7.82031 6.75781 7.51562 7.03906Z",fill:e})}),"RightToLineIcon");var cm=require("react/jsx-runtime"),um=a(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,cm.jsx)(Q,{...o,width:t,height:r,children:(0,cm.jsx)("path",{d:"M6.80469 17.3125C7.3125 16.9219 7.97656 16.8438 8.5625 17.0391C9.57812 17.4297 10.75 17.625 12 17.625C16.8438 17.625 20.125 14.5 20.125 11.375C20.125 8.28906 16.8438 5.125 12 5.125C7.11719 5.125 3.875 8.28906 3.875 11.375C3.875 12.625 4.34375 13.8359 5.24219 14.8906C5.59375 15.2422 5.75 15.75 5.71094 16.2578C5.67188 16.9609 5.47656 17.625 5.28125 18.2109C5.94531 17.8984 6.49219 17.5469 6.80469 17.3125ZM2.82031 18.875C2.89844 18.7969 2.9375 18.6797 3.01562 18.5625C3.40625 17.9375 3.75781 17.0781 3.83594 16.1016C2.66406 14.7734 2 13.1719 2 11.375C2 6.92188 6.45312 3.25 12 3.25C17.5078 3.25 22 6.92188 22 11.375C22 15.8672 17.5078 19.5 12 19.5C10.5156 19.5 9.14844 19.2656 7.89844 18.8359C7.46875 19.1484 6.6875 19.6172 5.78906 20.0078C5.20312 20.2812 4.53906 20.5156 3.83594 20.6328C3.79688 20.6328 3.75781 20.6719 3.75781 20.6719C3.5625 20.7109 3.40625 20.7109 3.21094 20.75C3.01562 20.75 2.82031 20.7891 2.58594 20.7891C2.35156 20.7891 2.11719 20.6328 2.03906 20.3984C1.92188 20.1641 2 19.8906 2.15625 19.6953C2.3125 19.5391 2.46875 19.3828 2.58594 19.1875C2.66406 19.0703 2.74219 18.9922 2.78125 18.9141V18.875H2.82031Z",fill:e})}),"SMSIcon");var vn=require("react/jsx-runtime"),u1=a(({color:e="#000000",width:t=14,height:r=9,...o})=>(0,vn.jsx)(Q,{...o,width:t,height:r,children:(0,vn.jsxs)("g",{opacity:"0.9",children:[(0,vn.jsx)("rect",{x:"0.799805",y:"5.92188",width:"2.46154",height:"2.95385",rx:"0.246154",fill:e}),(0,vn.jsx)("rect",{x:"4.24609",y:"4.44531",width:"2.46154",height:"4.43077",rx:"0.246154",fill:e}),(0,vn.jsx)("rect",{x:"7.93823",y:"2.72266",width:"2.46154",height:"6.15385",rx:"0.246154",fill:e}),(0,vn.jsx)("rect",{x:"11.3845",y:"0.753906",width:"2.46154",height:"8.12308",rx:"0.246154",fill:e})]})}),"SignalIcon");var dm=require("react/jsx-runtime"),mm=a(({color:e="#404040",width:t=16,height:r=16,...o})=>(0,dm.jsx)(Q,{...o,width:t,height:r,children:(0,dm.jsx)("path",{d:"M3.5 10C3.5 10.8281 2.8125 11.5 2 11.5C1.16406 11.5 0.5 10.8281 0.5 10C0.5 9.19531 1.16406 8.5 2 8.5H3.5V10ZM4.25 10C4.25 9.19531 4.91406 8.5 5.75 8.5C6.5625 8.5 7.25 9.19531 7.25 10V14C7.25 14.8281 6.5625 15.5 5.75 15.5C4.91406 15.5 4.25 14.8281 4.25 14V10ZM5.75 3.5C4.91406 3.5 4.25 2.83594 4.25 2C4.25 1.1875 4.91406 0.5 5.75 0.5C6.5625 0.5 7.25 1.1875 7.25 2V3.5H5.75ZM5.75 4.25C6.5625 4.25 7.25 4.91406 7.25 5.75C7.25 6.5625 6.5625 7.25 5.75 7.25H2C1.16406 7.25 0.5 6.5625 0.5 5.75C0.5 4.91406 1.16406 4.25 2 4.25H5.75ZM12.5 5.75C12.5 4.91406 13.1641 4.25 14 4.25C14.8125 4.25 15.5 4.91406 15.5 5.75C15.5 6.5625 14.8125 7.25 14 7.25H12.5V5.75ZM11.75 5.75C11.75 6.5625 11.0859 7.25 10.25 7.25C9.41406 7.25 8.75 6.5625 8.75 5.75V2C8.75 1.1875 9.41406 0.5 10.25 0.5C11.0859 0.5 11.75 1.1875 11.75 2V5.75ZM10.25 12.5C11.0859 12.5 11.75 13.1641 11.75 14C11.75 14.8125 11.0859 15.5 10.25 15.5C9.41406 15.5 8.75 14.8125 8.75 14V12.5H10.25ZM10.25 11.75C9.41406 11.75 8.75 11.0859 8.75 10.25C8.75 9.41406 9.41406 8.75 10.25 8.75H14C14.8125 8.75 15.5 9.41406 15.5 10.25C15.5 11.0859 14.8125 11.75 14 11.75H10.25Z",fill:e})}),"SlackIcon");var pm=require("react/jsx-runtime"),ss=a(({color:e="#FFFFFF",width:t=24,height:r=24,...o})=>(0,pm.jsx)(Q,{...o,width:t,height:r,viewBox:"0 0 24 24",children:(0,pm.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.9302 18.0041C16.7152 19.4687 17.3201 20.6536 17.6716 21.4225C22.7992 18.3395 24.5289 11.7034 21.525 6.5012C18.5211 1.29895 11.9084 -0.521541 6.67543 2.3769C7.30667 3.26444 8.32896 4.86524 9.56215 6.89518C10.4351 8.33194 11.4134 9.98401 12.4328 11.7503C13.7758 14.0761 14.9841 16.2422 15.9302 18.0041ZM4.20759 16.4985C2.25528 13.1182 1.73242 9.41428 2.51159 6.43383C0.579784 9.73503 0.426001 13.9501 2.47497 17.4989C4.52394 21.0476 8.25134 23.0233 12.0769 22.9999C9.1052 22.1856 6.1599 19.8803 4.20759 16.4985ZM1.6094 17.9983C4.92231 23.738 12.2599 25.7035 17.9997 22.3906C23.738 19.0777 25.7035 11.7401 22.3906 6.00031C19.0776 0.262019 11.74 -1.70347 6.00172 1.60945C0.261966 4.92236 -1.70352 12.26 1.6094 17.9983ZM11.1249 21.6085C12.4884 22.1914 13.8534 22.4228 15.1188 22.2896C12.7711 21.2717 9.91951 18.3937 7.66989 14.4994C5.42174 10.605 4.35551 6.69599 4.6499 4.15492C3.90002 5.18306 3.41817 6.48069 3.24096 7.95408C2.94364 10.4131 3.51483 13.2999 5.07317 15.9991C6.6315 18.6998 8.84597 20.636 11.1249 21.6085ZM16.913 21.6876C16.6889 21.6993 16.4238 21.67 16.1089 21.5836C15.4513 21.402 14.6604 20.9861 13.7875 20.3197C12.0461 18.9898 10.1436 16.7827 8.53694 13.9999C6.92881 11.2157 5.9695 8.46376 5.6883 6.29176C5.62971 5.83334 5.60188 5.41008 5.60188 5.02342C5.60188 4.49324 5.65461 4.03335 5.7542 3.65109C5.89334 3.11945 6.10278 2.78845 6.33565 2.59219C7.11481 4.29259 9.11545 8.00387 11.5672 12.2497C14.0189 16.4956 16.2319 20.0853 17.3157 21.61C17.2 21.651 17.0667 21.6788 16.913 21.6876Z",fill:e})}),"UnionIcon");var fm=require("react/jsx-runtime"),ls=a(({color:e="#A3A3A3",width:t=24,height:r=24,...o})=>(0,fm.jsx)(Q,{...o,width:t,height:r,children:(0,fm.jsx)(Fe,{d:"M12 12C10.2031 12 8.5625 11.0625 7.66406 9.5C6.76562 7.97656 6.76562 6.0625 7.66406 4.5C8.5625 2.97656 10.2031 2 12 2C13.7578 2 15.3984 2.97656 16.2969 4.5C17.1953 6.0625 17.1953 7.97656 16.2969 9.5C15.3984 11.0625 13.7578 12 12 12ZM10.2031 13.875H13.7578C17.625 13.875 20.75 17 20.75 20.8672C20.75 21.4922 20.2031 22 19.5781 22H4.38281C3.75781 22 3.25 21.4922 3.25 20.8672C3.25 17 6.33594 13.875 10.2031 13.875Z",fill:e})}),"UserIcon");var gm=require("react/jsx-runtime"),d1=a(({width:e=24,height:t=20,...r})=>(0,gm.jsx)(Q,{...r,width:e,height:t,viewBox:"0 0 24 20",children:(0,gm.jsx)("path",{d:"M6 1H5C4.46957 1 3.96086 1.21071 3.58579 1.58579C3.21071 1.96086 3 2.46957 3 3V8C3 8.53043 2.78929 9.03914 2.41421 9.41421C2.03914 9.78929 1.53043 10 1 10C1.53043 10 2.03914 10.2107 2.41421 10.5858C2.78929 10.9609 3 11.4696 3 12V17C3 18.1 3.9 19 5 19H6M18 19H19C19.5304 19 20.0391 18.7893 20.4142 18.4142C20.7893 18.0391 21 17.5304 21 17V12C21 10.9 21.9 10 23 10C22.4696 10 21.9609 9.78929 21.5858 9.41421C21.2107 9.03914 21 8.53043 21 8V3C21 2.46957 20.7893 1.96086 20.4142 1.58579C20.0391 1.21071 19.5304 1 19 1H18M10 16.5C10 16.7761 9.77614 17 9.5 17C9.22386 17 9 16.7761 9 16.5C9 16.2239 9.22386 16 9.5 16C9.77614 16 10 16.2239 10 16.5ZM15 16.5C15 16.7761 14.7761 17 14.5 17C14.2239 17 14 16.7761 14 16.5C14 16.2239 14.2239 16 14.5 16C14.7761 16 15 16.2239 15 16.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"VariableIcon");var ri=require("react/jsx-runtime"),m1=a(({color:e="#000000",width:t=14,height:r=10,...o})=>(0,ri.jsx)(Q,{...o,width:t,height:r,children:(0,ri.jsxs)("g",{opacity:"0.9",children:[(0,ri.jsx)("path",{d:"M13.3282 2.87894C11.7229 1.26255 9.4985 0.261719 7.04045 0.261719C4.57494 0.261719 2.34465 1.26857 0.738281 2.89354L2.13071 4.28604C3.38071 3.01741 5.11881 2.23095 7.04045 2.23095C8.95475 2.23095 10.6867 3.01137 11.9356 4.27141L13.3282 2.87894Z",fill:e}),(0,ri.jsx)("path",{d:"M11.0654 5.14169C10.0392 4.10437 8.61484 3.46172 7.04045 3.46172C5.45859 3.46172 4.02831 4.11043 3.00102 5.15634L4.39357 6.5489C5.06436 5.85932 6.00246 5.43095 7.04045 5.43095C8.07109 5.43095 9.00307 5.85322 9.6729 6.5342L11.0654 5.14169Z",fill:e}),(0,ri.jsx)("path",{d:"M8.80258 7.40452C8.35559 6.94626 7.73119 6.66172 7.04045 6.66172C6.34225 6.66172 5.71196 6.95239 5.264 7.41931L7.0259 9.18121L8.80258 7.40452Z",fill:e})]})}),"WiFiIcon");var hm=require("react/jsx-runtime"),cs=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,hm.jsx)(Q,{...n,width:r,height:o,children:(0,hm.jsx)(Fe,{d:"M12.1562 1.5H14.3438L9.53125 7.03125L15.2188 14.5H10.7812L7.28125 9.96875L3.3125 14.5H1.09375L6.25 8.625L0.8125 1.5H5.375L8.5 5.65625L12.1562 1.5ZM11.375 13.1875H12.5938L4.71875 2.75H3.40625L11.375 13.1875Z",active:t,fill:e})}),"XIcon");var p1=require("lucide-react"),ii=require("react");var Ll=require("react/jsx-runtime"),oi=a(({className:e})=>(0,Ll.jsx)("div",{className:I("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:(0,Ll.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"courier-w-6 courier-h-6 courier-animate-spin",children:(0,Ll.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");var ni=require("react/jsx-runtime"),ra=a(({isError:e,isSaving:t,isLoading:r,renderIsSaving:o,renderIsError:n,renderSaved:i})=>{let[s,l]=(0,ii.useState)(!1),c=(0,ii.useRef)(t),u=(0,ii.useRef)(null);return(0,ii.useEffect)(()=>(r||e||t&&t!==c.current?(u.current&&(clearTimeout(u.current),u.current=null),l(!1)):c.current===!0&&t===!1&&!e&&!r&&(l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l(!1),u.current=null},5e3)),c.current=t,()=>{u.current&&clearTimeout(u.current)}),[t,e,r]),r||t===null?null:t?o?o(t):(0,ni.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,ni.jsx)(oi,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):(0,ni.jsx)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:"Error"}):s?i?i(s):(0,ni.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,ni.jsx)(p1.CircleCheck,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Saved"]}):null},"Status");var bm=require("jotai");var ai=require("react/jsx-runtime"),Cn=[{label:"Email",value:"email",icon:(0,ai.jsx)(_d,{})},{label:"SMS",value:"sms",icon:(0,ai.jsx)(um,{})},{label:"Push",value:"push",icon:(0,ai.jsx)(nm,{})},{label:"In-app",value:"inbox",icon:(0,ai.jsx)(ts,{})},{label:"Slack",value:"slack",icon:(0,ai.jsx)(mm,{})},{label:"Teams",value:"msteams",icon:(0,ai.jsx)(Xd,{})}];var xn=(0,bm.atom)("email"),oa=(0,bm.atom)("template");var B2=require("@radix-ui/react-alert-dialog"),fn=require("jotai"),qo=require("react");var Er=require("jotai");var ym={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"}},Bl=a((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 Sy={paragraph:ym,heading:ym},us=(0,Er.atom)(Sy),we=(0,Er.atom)(null),dt=(0,Er.atom)(null,(e,t,r)=>{t(we,r)}),Iy=(0,Er.atom)({ref:null,caretPosition:null}),Dl=(0,Er.atom)({ref:null,caretPosition:null}),ds=(0,Er.atom)({isFocused:!1,hasVariables:!1,showVariablePopup:!1}),f1=(0,Er.atom)(e=>(t,r=!1)=>{let o=e(us),n=e(ds),i=Bl(t,r),s=o[t],l=i;return s&&Object.keys(s).forEach(c=>{var d,p;let u=c;u!=="conditionalRules"&&((d=i[u])==null?void 0:d.state)==="enabled"&&((p=s[u])==null?void 0:p.state)==="enabled"&&(l[u]=s[u])}),n.isFocused&&n.hasVariables&&(l={...l,variable:{state:"enabled"}}),l}),g1=(0,Er.atom)(null,(e,t,{nodeName:r,config:o})=>{let n=e(us);t(us,{...n,[r]:{...n[r],...Object.fromEntries(Object.entries(o).filter(([i])=>i!=="conditionalRules").map(([i,s])=>[i,{state:!Array.isArray(s)&&(s!=null&&s.state)?s.state:"hidden"}]))}})}),Y7=(0,Er.atom)(null,(e,t,r)=>{let o=e(us),{[r]:n,...i}=o;t(us,i)}),h1=(0,Er.atom)(null,(e,t,{ref:r,caretPosition:o})=>{t(Iy,{ref:r,caretPosition:o})}),Q7=(0,Er.atom)(null,(e,t,r)=>{let o=e(ds);t(ds,{...o,showVariablePopup:r})}),vm=(0,Er.atom)(null),Hl=(0,Er.atom)(null,(e,t,r)=>{t(vm,r)});var pn=require("jotai"),Dr=require("react");var Cm=require("jotai"),lo=(0,Cm.atom)(null),Oo=(0,Cm.atom)(null);var b1=require("react"),y1=require("sonner");var Tn=require("react/jsx-runtime"),wr=(0,b1.forwardRef)(({theme:e,children:t,isLoading:r,Header:o,colorScheme:n,className:i,...s},l)=>(0,Tn.jsx)(o1,{theme:e,ref:l,colorScheme:n,className:i,children:(0,Tn.jsxs)("div",{...Object.fromEntries(Object.entries(s).filter(([c])=>c!=="variables"&&c!=="brandEditor")),className:"courier-main-layout",children:[o&&(0,Tn.jsx)("div",{className:"courier-main-header courier-flex courier-flex-row courier-h-12 courier-flex-shrink-0 courier-w-full courier-bg-primary courier-border-b courier-px-4 courier-items-center courier-gap-4 courier-self-stretch dark:courier-bg-background",children:o}),r&&(0,Tn.jsx)("div",{className:"courier-editor-loading",children:(0,Tn.jsx)(oi,{})}),(0,Tn.jsx)(y1.Toaster,{position:"top-center",expand:!0,visibleToasts:2,style:{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)"}}),t]})}));var pr=require("jotai"),Re=require("react");function v1(e){if(Array.isArray(e))return e}a(v1,"_arrayWithHoles");function C1(e,t){var r=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,n,i,s,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&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw n}}return l}}a(C1,"_iterableToArrayLimit");function ms(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}a(ms,"_arrayLikeToArray");function Vl(e,t){if(e){if(typeof e=="string")return ms(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)?ms(e,t):void 0}}a(Vl,"_unsupportedIterableToArray");function x1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
196
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}a(x1,"_nonIterableRest");function Fl(e,t){return v1(e)||C1(e,t)||Vl(e,t)||x1()}a(Fl,"_slicedToArray");var ig=xe(ps());var Wl="data-pdnd-honey-pot";function Ul(e){return e instanceof Element&&e.hasAttribute(Wl)}a(Ul,"isHoneyPotElement");function _l(e){var t=document.elementsFromPoint(e.x,e.y),r=Fl(t,2),o=r[0],n=r[1];return o?Ul(o)?n!=null?n:null:o:null}a(_l,"getElementFromPointWithoutHoneypot");function si(e){"@babel/helpers - typeof";return si=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},si(e)}a(si,"_typeof");function w1(e,t){if(si(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,t||"default");if(si(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}a(w1,"toPrimitive");function k1(e){var t=w1(e,"string");return si(t)=="symbol"?t:t+""}a(k1,"toPropertyKey");function en(e,t,r){return(t=k1(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}a(en,"_defineProperty");var gs=xe(ps());var P1=2147483647;function A1(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}a(A1,"ownKeys");function M1(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?A1(Object(r),!0).forEach(function(o){en(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):A1(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(M1,"_objectSpread");var fs=2,N1=fs/2;function Fy(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}a(Fy,"floorToClosestPixel");function Oy(e){return{x:e.x-N1,y:e.y-N1}}a(Oy,"pullBackByHalfHoneyPotSize");function Wy(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}a(Wy,"preventGoingBackwardsOffScreen");function Uy(e){return{x:Math.min(e.x,window.innerWidth-fs),y:Math.min(e.y,window.innerHeight-fs)}}a(Uy,"preventGoingForwardsOffScreen");function S1(e){var t=e.client,r=Uy(Wy(Oy(Fy(t))));return DOMRect.fromRect({x:r.x,y:r.y,width:fs,height:fs})}a(S1,"getHoneyPotRectFor");function I1(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")}}a(I1,"getRectStyles");function _y(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}a(_y,"isWithin");function zy(e){var t=e.initial,r=document.createElement("div");r.setAttribute(Wl,"true");var o=S1({client:t});Object.assign(r.style,M1(M1({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},I1({clientRect:o})),{},{pointerEvents:"auto",zIndex:P1})),document.body.appendChild(r);var n=(0,gs.bind)(window,{type:"pointermove",listener:a(function(s){var l={x:s.clientX,y:s.clientY};o=S1({client:l}),Object.assign(r.style,I1({clientRect:o}))},"listener"),options:{capture:!0}});return a(function(s){var l=s.current;if(n(),_y({client:l,clientRect:o})){r.remove();return}function c(){u(),r.remove()}a(c,"cleanup");var u=(0,gs.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")}a(zy,"mountHoneyPot");function R1(){var e=null;function t(){return e=null,(0,gs.bind)(window,{type:"pointermove",listener:a(function(n){e={x:n.clientX,y:n.clientY}},"listener"),options:{capture:!0}})}a(t,"bindEvents");function r(){var o=null;return a(function(i){var s=i.eventName,l=i.payload;if(s==="onDragStart"){var c=l.location.initial.input,u=e!=null?e:{x:c.clientX,y:c.clientY};o=zy({initial:u})}if(s==="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 a(r,"getOnPostDispatch"),{bindEvents:t,getOnPostDispatch:r}}a(R1,"makeHoneyPotFix");function L1(e){if(Array.isArray(e))return ms(e)}a(L1,"_arrayWithoutHoles");function B1(e){if(typeof Symbol!="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}a(B1,"_iterableToArray");function D1(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
197
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}a(D1,"_nonIterableSpread");function zl(e){return L1(e)||B1(e)||Vl(e)||D1()}a(zl,"_toConsumableArray");var $1=xe(ps());function Yr(e){var t=null;return a(function(){if(!t){for(var o=arguments.length,n=new Array(o),i=0;i<o;i++)n[i]=arguments[i];var s=e.apply(this,n);t={result:s}}return t.result},"wrapped")}a(Yr,"once");var H1=Yr(a(function(){return navigator.userAgent.includes("Firefox")},"isFirefox"));var hs=Yr(a(function(){var t=navigator,r=t.userAgent;return r.includes("AppleWebKit")&&!r.includes("Chrome")},"isSafari"));var V1=xe(ps());var Tm={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function F1(e){var t=e.dragLeave;return hs()?t.hasOwnProperty(Tm.isLeavingWindow):!1}a(F1,"isLeavingWindowInSafari");a(function(){if(typeof window=="undefined"||!hs())return;function t(){return{enterCount:0,isOverWindow:!1}}a(t,"getInitialState");var r=t();function o(){r=t()}a(o,"resetState"),(0,V1.bindAll)(window,[{type:"dragstart",listener:a(function(){r.enterCount=0,r.isOverWindow=!0},"listener")},{type:"drop",listener:o},{type:"dragend",listener:o},{type:"dragenter",listener:a(function(i){!r.isOverWindow&&r.enterCount===0&&(i[Tm.isEnteringWindow]=!0),r.isOverWindow=!0,r.enterCount++},"listener")},{type:"dragleave",listener:a(function(i){r.enterCount--,r.isOverWindow&&r.enterCount===0&&(i[Tm.isLeavingWindow]=!0,r.isOverWindow=!1)},"listener")}],{capture:!0})},"fixSafari")();function $y(e){return"nodeName"in e}a($y,"isNodeLike");function O1(e){return $y(e)&&e.ownerDocument!==document}a(O1,"isFromAnotherWindow");function W1(e){var t=e.dragLeave,r=t.type,o=t.relatedTarget;return r!=="dragleave"?!1:hs()?F1({dragLeave:t}):o==null?!0:H1()?O1(o):o instanceof HTMLIFrameElement}a(W1,"isLeavingWindow");function U1(e){var t=e.onDragEnd;return[{type:"pointermove",listener:function(){var r=0;return a(function(){if(r<20){r++;return}t()},"listener")}()},{type:"pointerdown",listener:t}]}a(U1,"getBindingsForBrokenDrags");function li(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}}a(li,"getInput");var jy=a(function(t){var r=[],o=null,n=a(function(){for(var s=arguments.length,l=new Array(s),c=0;c<s;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"),_1=jy;var Em=_1(function(e){return e()}),$l=function(){var e=null;function t(o){var n=requestAnimationFrame(function(){e=null,o()});e={frameId:n,fn:o}}a(t,"schedule");function r(){e&&(cancelAnimationFrame(e.frameId),e.fn(),e=null)}return a(r,"flush"),{schedule:t,flush:r}}();function z1(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}}a(i,"safeDispatch");var s={start:a(function(c){var u=c.nativeSetDragImage,d={current:r,previous:n,initial:r};i({eventName:"onGenerateDragPreview",payload:{source:t,location:d,nativeSetDragImage:u}}),$l.schedule(function(){i({eventName:"onDragStart",payload:{source:t,location:d}})})},"start"),dragUpdate:a(function(c){var u=c.current;$l.flush(),Em.cancel(),i({eventName:"onDropTargetChange",payload:{source:t,location:{initial:r,previous:n,current:u}}})},"dragUpdate"),drag:a(function(c){var u=c.current;Em(function(){$l.flush();var d={initial:r,previous:n,current:u};i({eventName:"onDrag",payload:{source:t,location:d}})})},"drag"),drop:a(function(c){var u=c.current,d=c.updatedSourcePayload;$l.flush(),Em.cancel(),i({eventName:"onDrop",payload:{source:d!=null?d:t,location:{current:u,previous:n,initial:r}}})},"drop")};return s}a(z1,"makeDispatch");var km={isActive:!1};function j1(){return!km.isActive}a(j1,"canStart");function Zy(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}a(Zy,"getNativeSetDragImage");function qy(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}a(qy,"hasHierarchyChanged");function Jy(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=e.dispatchEvent;if(!j1())return;var i=Ky({event:t,dragType:r,getDropTargetsOver:o});km.isActive=!0;var s={current:i};wm({event:t,current:i.dropTargets});var l=z1({source:r.payload,dispatchEvent:n,initial:i});function c(f){var v=qy({current:s.current.dropTargets,next:f.dropTargets});s.current=f,v&&l.dragUpdate({current:s.current})}a(c,"updateState");function u(f){var v=li(f),h=Ul(f.target)?_l({x:v.clientX,y:v.clientY}):f.target,y=o({target:h,input:v,source:r.payload,current:s.current.dropTargets});y.length&&(f.preventDefault(),wm({event:f,current:y})),c({dropTargets:y,input:v})}a(u,"onUpdateEvent");function d(){s.current.dropTargets.length&&c({dropTargets:[],input:s.current.input}),l.drop({current:s.current,updatedSourcePayload:null}),p()}a(d,"cancel");function p(){km.isActive=!1,m()}a(p,"finish");var m=(0,$1.bindAll)(window,[{type:"dragover",listener:a(function(v){u(v),l.drag({current:s.current})},"listener")},{type:"dragenter",listener:u},{type:"dragleave",listener:a(function(v){W1({dragLeave:v})&&(c({input:s.current.input,dropTargets:[]}),r.startedFrom==="external"&&d())},"listener")},{type:"drop",listener:a(function(v){if(s.current={dropTargets:s.current.dropTargets,input:li(v)},!s.current.dropTargets.length){d();return}v.preventDefault(),wm({event:v,current:s.current.dropTargets}),l.drop({current:s.current,updatedSourcePayload:r.type==="external"?r.getDropPayload(v):null}),p()},"listener")},{type:"dragend",listener:a(function(v){s.current={dropTargets:s.current.dropTargets,input:li(v)},d()},"listener")}].concat(zl(U1({onDragEnd:d}))),{capture:!0});l.start({nativeSetDragImage:Zy(t)})}a(Jy,"start");function wm(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)}a(wm,"setDropEffectOnEvent");function Ky(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=li(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}}a(Ky,"getStartLocation");var Pm={canStart:j1,start:Jy};var Am=new Map;function Gy(e){var t=e.typeKey,r=e.mount,o=Am.get(t);if(o)return o.usageCount++,o;var n={typeKey:t,unmount:r(),usageCount:1};return Am.set(t,n),n}a(Gy,"registerUsage");function Z1(e){var t=Gy(e);return a(function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),Am.delete(e.typeKey))},"unregister")}a(Z1,"register");function Wo(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return a(function(){t.forEach(function(n){return n()})},"cleanup")}a(Wo,"combine");function jl(e,t){var r=t.attribute,o=t.value;return e.setAttribute(r,o),function(){return e.removeAttribute(r)}}a(jl,"addAttribute");function q1(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}a(q1,"ownKeys");function En(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?q1(Object(r),!0).forEach(function(o){en(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):q1(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(En,"_objectSpread");function Mm(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Xy(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var o=0,n=a(function(){},"F");return{s:n,n:a(function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},"n"),e:a(function(u){throw u},"e"),f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
198
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,s=!0,l=!1;return{s:a(function(){r=r.call(e)},"s"),n:a(function(){var u=r.next();return s=u.done,u},"n"),e:a(function(u){l=!0,i=u},"e"),f:a(function(){try{s||r.return==null||r.return()}finally{if(l)throw i}},"f")}}a(Mm,"_createForOfIteratorHelper");function Xy(e,t){if(e){if(typeof e=="string")return J1(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)?J1(e,t):void 0}}a(Xy,"_unsupportedIterableToArray");function J1(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}a(J1,"_arrayLikeToArray");function Nm(e){return e.slice(0).reverse()}a(Nm,"copyReverse");function K1(e){var t=e.typeKey,r=e.defaultDropEffect,o=new WeakMap,n="data-drop-target-for-".concat(t),i="[".concat(n,"]");function s(f){return o.set(f.element,f),function(){return o.delete(f.element)}}a(s,"addToRegistry");function l(f){if(0)var v;var h=Wo(jl(f.element,{attribute:n,value:"true"}),s(f));return Yr(h)}a(l,"dropTargetForConsumers");function c(f){var v,h,y,x,E=f.source,g=f.target,b=f.input,M=f.result,C=M===void 0?[]:M;if(g==null)return C;if(!(g instanceof Element))return g instanceof Node?c({source:E,target:g.parentElement,input:b,result:C}):C;var S=g.closest(i);if(S==null)return C;var P=o.get(S);if(P==null)return C;var k={input:b,source:E,element:P.element};if(P.canDrop&&!P.canDrop(k))return c({source:E,target:P.element.parentElement,input:b,result:C});var w=(v=(h=P.getData)===null||h===void 0?void 0:h.call(P,k))!==null&&v!==void 0?v:{},T=(y=(x=P.getDropEffect)===null||x===void 0?void 0:x.call(P,k))!==null&&y!==void 0?y:r,A={data:w,element:P.element,dropEffect:T,isActiveDueToStickiness:!1};return c({source:E,target:P.element.parentElement,input:b,result:[].concat(zl(C),[A])})}a(c,"getActualDropTargets");function u(f){var v=f.eventName,h=f.payload,y=Mm(h.location.current.dropTargets),x;try{for(y.s();!(x=y.n()).done;){var E,g=x.value,b=o.get(g.element),M=En(En({},h),{},{self:g});b==null||(E=b[v])===null||E===void 0||E.call(b,M)}}catch(C){y.e(C)}finally{y.f()}}a(u,"notifyCurrent");var d={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:a(function(v){var h=v.payload,y=new Set(h.location.current.dropTargets.map(function(D){return D.element})),x=new Set,E=Mm(h.location.previous.dropTargets),g;try{for(E.s();!(g=E.n()).done;){var b,M=g.value;x.add(M.element);var C=o.get(M.element),S=y.has(M.element),P=En(En({},h),{},{self:M});if(C==null||(b=C.onDropTargetChange)===null||b===void 0||b.call(C,P),!S){var k;C==null||(k=C.onDragLeave)===null||k===void 0||k.call(C,P)}}}catch(D){E.e(D)}finally{E.f()}var w=Mm(h.location.current.dropTargets),T;try{for(w.s();!(T=w.n()).done;){var A,N,R=T.value;if(!x.has(R.element)){var B=En(En({},h),{},{self:R}),H=o.get(R.element);H==null||(A=H.onDropTargetChange)===null||A===void 0||A.call(H,B),H==null||(N=H.onDragEnter)===null||N===void 0||N.call(H,B)}}}catch(D){w.e(D)}finally{w.f()}},"onDropTargetChange")};function p(f){d[f.eventName](f)}a(p,"dispatchEvent");function m(f){var v=f.source,h=f.target,y=f.input,x=f.current,E=c({source:v,target:h,input:y});if(E.length>=x.length)return E;for(var g=Nm(x),b=Nm(E),M=[],C=0;C<g.length;C++){var S,P=g[C],k=b[C];if(k!=null){M.push(k);continue}var w=M[C-1],T=g[C-1];if((w==null?void 0:w.element)!==(T==null?void 0:T.element))break;var A=o.get(P.element);if(!A)break;var N={input:y,source:v,element:A.element};if(A.canDrop&&!A.canDrop(N)||!((S=A.getIsSticky)!==null&&S!==void 0&&S.call(A,N)))break;M.push(En(En({},P),{},{isActiveDueToStickiness:!0}))}return Nm(M)}return a(m,"getIsOver"),{dropTargetForConsumers:l,getIsOver:m,dispatchEvent:p}}a(K1,"makeDropTarget");function Yy(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Qy(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var o=0,n=a(function(){},"F");return{s:n,n:a(function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},"n"),e:a(function(u){throw u},"e"),f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
199
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,s=!0,l=!1;return{s:a(function(){r=r.call(e)},"s"),n:a(function(){var u=r.next();return s=u.done,u},"n"),e:a(function(u){l=!0,i=u},"e"),f:a(function(){try{s||r.return==null||r.return()}finally{if(l)throw i}},"f")}}a(Yy,"_createForOfIteratorHelper");function Qy(e,t){if(e){if(typeof e=="string")return G1(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)?G1(e,t):void 0}}a(Qy,"_unsupportedIterableToArray");function G1(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}a(G1,"_arrayLikeToArray");function X1(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}a(X1,"ownKeys");function e0(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?X1(Object(r),!0).forEach(function(o){en(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):X1(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(e0,"_objectSpread");function Y1(){var e=new Set,t=null;function r(i){t&&(!i.canMonitor||i.canMonitor(t.canMonitorArgs))&&t.active.add(i)}a(r,"tryAddToActive");function o(i){var s=e0({},i);e.add(s),r(s);function l(){e.delete(s),t&&t.active.delete(s)}return a(l,"cleanup"),Yr(l)}a(o,"monitorForConsumers");function n(i){var s=i.eventName,l=i.payload;if(s==="onGenerateDragPreview"){t={canMonitorArgs:{initial:l.location.initial,source:l.source},active:new Set};var c=Yy(e),u;try{for(c.s();!(u=c.n()).done;){var d=u.value;r(d)}}catch(y){c.e(y)}finally{c.f()}}if(t){for(var p=Array.from(t.active),m=0,f=p;m<f.length;m++){var v=f[m];if(t.active.has(v)){var h;(h=v[s])===null||h===void 0||h.call(v,l)}}s==="onDrop"&&(t.active.clear(),t=null)}}return a(n,"dispatchEvent"),{dispatchEvent:n,monitorForConsumers:o}}a(Y1,"makeMonitor");function Q1(e){var t=e.typeKey,r=e.mount,o=e.dispatchEventToSource,n=e.onPostDispatch,i=e.defaultDropEffect,s=Y1(),l=K1({typeKey:t,defaultDropEffect:i});function c(p){o==null||o(p),l.dispatchEvent(p),s.dispatchEvent(p),n==null||n(p)}a(c,"dispatchEvent");function u(p){var m=p.event,f=p.dragType;Pm.start({event:m,dragType:f,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}a(u,"start");function d(){function p(){var m={canStart:Pm.canStart,start:u};return r(m)}return a(p,"mountAdapter"),Z1({typeKey:t,mount:p})}return a(d,"registerUsage"),{registerUsage:d,dropTarget:l.dropTargetForConsumers,monitor:s.monitorForConsumers}}a(Q1,"makeAdapter");var eg=Yr(a(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")},"isAndroid")),tg="pdnd:android-fallback";var Sm="text/plain";var rg="text/uri-list";var og="application/vnd.pdnd";var Zl=new WeakMap;function t0(e){return Zl.set(e.element,e),a(function(){Zl.delete(e.element)},"cleanup")}a(t0,"addToRegistry");var ng=R1(),Im=Q1({typeKey:"element",defaultDropEffect:"move",mount:a(function(t){return Wo(ng.bindEvents(),(0,ig.bind)(document,{type:"dragstart",listener:a(function(o){var n,i,s,l,c,u;if(t.canStart(o)&&!o.defaultPrevented&&o.dataTransfer){var d=o.target;if(d instanceof HTMLElement){var p=Zl.get(d);if(p){var m=li(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 v=_l({x:m.clientX,y:m.clientY});if(!p.dragHandle.contains(v)){o.preventDefault();return}}var h=(i=(s=p.getInitialDataForExternal)===null||s===void 0?void 0:s.call(p,f))!==null&&i!==void 0?i:null;if(h)for(var y=0,x=Object.entries(h);y<x.length;y++){var E=Fl(x[y],2),g=E[0],b=E[1];o.dataTransfer.setData(g,b!=null?b:"")}eg()&&!o.dataTransfer.types.includes(Sm)&&!o.dataTransfer.types.includes(rg)&&o.dataTransfer.setData(Sm,tg),o.dataTransfer.setData(og,"");var M={element:p.element,dragHandle:(l=p.dragHandle)!==null&&l!==void 0?l:null,data:(c=(u=p.getInitialData)===null||u===void 0?void 0:u.call(p,f))!==null&&c!==void 0?c:{}},C={type:"element",payload:M,startedFrom:"internal"};t.start({event:o,dragType:C})}}}},"listener")}))},"mount"),dispatchEventToSource:a(function(t){var r,o,n=t.eventName,i=t.payload;(r=Zl.get(i.source.element))===null||r===void 0||(o=r[n])===null||o===void 0||o.call(r,i)},"dispatchEventToSource"),onPostDispatch:ng.getOnPostDispatch()}),Wr=Im.dropTarget,Rm=Im.monitor;function bs(e){if(0)var t;var r=Wo(Im.registerUsage(),t0(e),jl(e.element,{attribute:"draggable",value:"true"}));return Yr(r)}a(bs,"draggable");function ag(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}a(ag,"ownKeys");function sg(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ag(Object(r),!0).forEach(function(o){en(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ag(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(sg,"_objectSpread");var r0={top:a(function(t,r){return Math.abs(r.y-t.top)},"top"),right:a(function(t,r){return Math.abs(t.right-r.x)},"right"),bottom:a(function(t,r){return Math.abs(t.bottom-r.y)},"bottom"),left:a(function(t,r){return Math.abs(r.x-t.left)},"left")},lg=Symbol("closestEdge");function cg(e,t){var r,o,n=t.element,i=t.input,s=t.allowedEdges,l={x:i.clientX,y:i.clientY},c=n.getBoundingClientRect(),u=s.map(function(p){return{edge:p,value:r0[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 sg(sg({},e),{},en({},lg,d))}a(cg,"attachClosestEdge");function ys(e){var t;return(t=e[lg])!==null&&t!==void 0?t:null}a(ys,"extractClosestEdge");var Ab=require("@tiptap/core");var sa=require("@tiptap/core"),o0=/^\s*>\s$/,ug=sa.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,sa.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[(0,sa.wrappingInputRule)({find:o0,type:this.type})]}});var Mb=require("@tiptap/react");var dg=require("uuid");function St(e,t){let r=e.state.tr,o=!1;e.state.doc.descendants((n,i)=>{if(n.type.name===t&&!n.attrs.id){let s=`node-${(0,dg.v4)()}`;r.setNodeMarkup(i,void 0,{...n.attrs,id:s}),o=!0}return!1}),o&&e.view.dispatch(r)}a(St,"generateNodeIds");var Eb=require("@tiptap/react"),wb=require("jotai"),Be=require("react"),kb=require("uuid");var Rp=require("@tiptap/extension-color");var mg=require("@tiptap/core"),pg=require("@tiptap/pm/dropcursor"),Lm=mg.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[(0,pg.dropCursor)(this.options)]}});var Lp=require("@tiptap/extension-hard-break");var fg=require("@tiptap/core"),la=require("@tiptap/pm/history"),n0=fg.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>(0,la.undo)(e,t),redo:()=>({state:e,dispatch:t})=>(0,la.redo)(e,t)}},addProseMirrorPlugins(){return[(0,la.history)(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Bp=require("@tiptap/extension-placeholder"),Dp=require("@tiptap/extension-text-align"),Hp=require("@tiptap/extension-typography"),Vp=require("@tiptap/extension-underline"),Fp=require("@tiptap/starter-kit");var Xg=require("@hookform/resolvers/zod"),Yg=require("react-hook-form");var ci=require("react");var Ut=a(({editor:e,element:t,form:r,nodeType:o})=>{let n=(0,ci.useRef)(null),i=(0,ci.useRef)(null);return(0,ci.useEffect)(()=>{if(!e||!t)return;let l=a(()=>{let c=null;if(e.state.doc.descendants((u,d)=>u.attrs.id===t.attrs.id?(c=d,!1):!0),c!==null){let u=e.state.doc.nodeAt(c);(u==null?void 0:u.type.name)===o&&(n.current=u,i.current=c,Object.entries(u.attrs).forEach(([d,p])=>{r.getValues(d)!==p&&r.setValue(d,p)}))}},"updateCurrentNode");return l(),e.on("update",l),()=>{e.off("update",l)}},[e,t,r,o]),{updateNodeAttributes:(0,ci.useCallback)(l=>{if(!e||i.current===null)return;let c=e.state.doc.nodeAt(i.current);if(!c||c.type.name!==o)return;let u={...c.attrs,...l,id:c.attrs.id};JSON.stringify(c.attrs)!==JSON.stringify(u)&&e.chain().command(({tr:p,dispatch:m})=>{let f=p.doc.nodeAt(i.current);return(f==null?void 0:f.type.name)===o&&m?(p.setNodeMarkup(i.current,f.type,u),p.setMeta("addToHistory",!0),!0):!1}).run()},[e,o])}},"useNodeAttributes");var ui=require("jotai"),ca=require("react");var tn=a((e={},t="")=>Object.entries(e).reduce((r,[o,n])=>{let i=t?`${t}.${o}`:o;return n&&typeof n=="object"&&!Array.isArray(n)?[...r,...tn(n,i)]:[...r,i]},[]),"getFlattenedVariables");var i0={link:["href","content"],img:["src","href","alt_text"],image:["src","href","alt_text"],action:["href","content"],meta:["title"],list:["imgSrc","imgHref"],quote:["content"],html:[]},a0=["content","href","src","title"],gg=a((e=[])=>{let t=new Set,r=/\{\{([^}]+)\}\}/g,o=a(i=>{let s=i.matchAll(r);for(let l of s){let c=l[1].trim();c&&Ot(c)&&t.add(c)}},"extractFromString"),n=a(i=>{let s=i;s.type==="string"&&typeof s.content=="string"&&o(s.content),s.type==="text"&&typeof s.content=="string"&&o(s.content);let l=s.type,c=i0[l];c&&c.forEach(u=>{typeof s[u]=="string"&&o(s[u])}),typeof s.if=="string"&&o(s.if),typeof s.loop=="string"&&o(s.loop),s.type==="channel"&&s.raw&&typeof s.raw=="object"&&s.raw!==null&&Object.values(s.raw).forEach(u=>{typeof u=="string"&&o(u)}),s.elements&&Array.isArray(s.elements)&&s.elements.forEach(u=>n(u)),s.locales&&typeof s.locales=="object"&&s.locales!==null&&Object.values(s.locales).forEach(u=>{if(u&&typeof u=="object"){let d=u;a0.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 s0=a(e=>{let t=(0,ui.useAtomValue)(He),r=(0,ui.useAtomValue)(le),o=(0,ui.useAtomValue)(xn),n=(0,ui.useAtomValue)(Xn),i=(0,ui.useSetAtom)(Xn),s=e!=null?e:o,l=(0,ca.useMemo)(()=>{var m,f;if(!t)return[];let p=((f=(m=t.extensionManager.extensions.find(v=>v.name==="variableSuggestion"))==null?void 0:m.options)==null?void 0:f.variables)||{};return tn(p)},[t]),c=(0,ca.useMemo)(()=>{if(!r||!s)return[];let p=r.elements.find(m=>m.type==="channel"&&m.channel===s);return p?gg(p.elements||[]):[]},[r,s]),u=(0,ca.useCallback)((p,m)=>{i(f=>({...f,[p]:m}))},[i]),d=(0,ca.useCallback)(()=>{i({})},[i]);return{availableVariables:l,usedVariables:c,variableValues:n,addVariableValue:u,clearAllVariableValues:d}},"useVariables");var mi=require("jotai"),uo=require("react");var Kg=require("uuid");var ql=require("@tiptap/core"),Cg=require("@tiptap/react");var hg=require("@tiptap/react"),bg=require("jotai"),yg=require("react");var di=require("react/jsx-runtime"),l0=a(({alignment:e,backgroundColor:t,textColor:r,borderRadius:o,padding:n,fontWeight:i,fontStyle:s,children:l})=>(0,di.jsx)("div",{className:"courier-w-full node-element",children:(0,di.jsx)("div",{className:"courier-flex",children:(0,di.jsx)("div",{className:I("courier-inline-flex courier-justify-center courier-cursor-text courier-text-sm courier-leading-tight !courier-my-1",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[e]),style:{backgroundColor:t,color:r,borderRadius:`${o}px`,caretColor:r,fontWeight:i,fontStyle:s,padding:`${Number(n)+2}px ${Number(n)+10}px`},children:l})})}),"ButtonComponent"),vg=a(e=>{let t=(0,bg.useSetAtom)(dt),r=(0,yg.useCallback)(()=>{if(!e.editor.isEditable)return;let o=It(e);if(o){let n=o.attrs.id;e.editor.state.doc.descendants(i=>i.type.name==="button"&&i.attrs.id===n?(t(i),!1):!0)}},[e,t]);return(0,di.jsx)(rr,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,"data-node-type":"button",children:(0,di.jsx)(l0,{...e.node.attrs,children:(0,di.jsx)(hg.NodeViewContent,{as:"span"})})})},"ButtonComponentNode");var xg=require("uuid");var at={label:"Button",link:"",alignment:"center",backgroundColor:"#0085FF",borderRadius:0,padding:6,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1,textColor:"#ffffff",borderColor:"transparent"},Jl=ql.Node.create({name:"button",group:"block",content:"inline*",selectable:!1,isolating:!0,onCreate(){St(this.editor,this.name)},addAttributes(){return{label:{default:at.label,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},link:{default:at.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alignment:{default:at.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},backgroundColor:{default:at.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},textColor:{default:at.textColor,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.textColor})},borderRadius:{default:at.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:at.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},padding:{default:at.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.padding})},fontWeight:{default:at.fontWeight,parseHTML:e=>e.getAttribute("data-font-weight"),renderHTML:e=>({"data-font-weight":e.fontWeight})},fontStyle:{default:at.fontStyle,parseHTML:e=>e.getAttribute("data-font-style"),renderHTML:e=>({"data-font-style":e.fontStyle})},isUnderline:{default:at.isUnderline,parseHTML:e=>e.getAttribute("data-is-underline"),renderHTML:e=>({"data-is-underline":e.isUnderline})},isStrike:{default:at.isStrike,parseHTML:e=>e.getAttribute("data-is-strike"),renderHTML:e=>({"data-is-strike":e.isStrike})},id:{default:()=>`node-${(0,xg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="button"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,ql.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return(0,Cg.ReactNodeViewRenderer)(vg)},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{let{$from:t}=e.state.selection;for(let r=t.depth;r>=0;r--)if(t.node(r).type.name==="button"){let n=t.start(r),i=t.end(r);return e.commands.setTextSelection({from:n,to:i}),!0}return!1}}},addCommands(){return{setButton:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e,content:[{type:"text",text:e.label||"Button"}]}).run()}}});var Gl=require("@tiptap/core"),wg=require("@tiptap/react"),kg=require("uuid");var Tg=require("@tiptap/react"),Kl=require("jotai"),Ur=require("react");var co=require("react/jsx-runtime"),c0=a(({columnId:e,index:t,isPreviewMode:r})=>{let o=(0,Ur.useRef)(null),[n,i]=(0,Ur.useState)(!1);return(0,Ur.useEffect)(()=>{let s=o.current;if(s)return Wr({element:s,getData:()=>({type:"column-cell",columnId:e,index:t,isEmpty:!0}),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e,t]),(0,co.jsx)("div",{ref:o,"data-placeholder-cell":"true","data-column-cell":"true","data-column-id":e,"data-cell-index":t,onClick:s=>{s.stopPropagation()},className:I("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4",!r&&"courier-border",!r&&(n?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),!r&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:!r&&(0,co.jsx)("span",{className:"courier-pointer-events-none",children:"Drag and drop content blocks"})})},"PlaceholderCell"),u0=a(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderWidth:o,borderRadius:n,borderColor:i,node:s,columnsCount:l,isPreviewMode:c=!1})=>{var m;let u=!s.content||s.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=s.attrs)==null?void 0:m.id)||"";return(0,co.jsx)("div",{className:"courier-w-full node-element",style:p,children:(0,co.jsx)("div",{className:"courier-w-full courier-flex courier-gap-2 courier-p-2",style:d,children:Array.from({length:l}).map((v,h)=>(0,co.jsx)(c0,{columnId:f,index:h,isPreviewMode:c},h))})})}return(0,co.jsx)("div",{className:"courier-w-full node-element",style:p,children:(0,co.jsx)("div",{className:"courier-w-full courier-p-2",style:d,children:(0,co.jsx)(Tg.NodeViewContent,{})})})},"ColumnComponent"),Eg=a(e=>{let t=(0,Kl.useSetAtom)(dt),r=(0,Kl.useAtomValue)(Cr),[o,n]=(0,Ur.useState)(!1),[i,s]=(0,Ur.useState)(e.editor.isEditable);(0,Ur.useEffect)(()=>{let p=a(()=>{s(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",p),e.editor.on("transaction",p),e.editor.on("selectionUpdate",p),()=>{e.editor.off("update",p),e.editor.off("transaction",p),e.editor.off("selectionUpdate",p)}},[e.editor]);let l=!i&&!r,c=(0,Ur.useCallback)(p=>{var M,C;if(!e.editor.isEditable)return;let m=p.target,f=p.currentTarget,v=m===f,h=m.classList.contains("node-element"),y=m.classList.contains("courier-p-2"),x=m.classList.contains("courier-gap-2"),E=m.classList.contains("draggable-item"),g=m.hasAttribute("data-drag-handle")||m.closest("[data-drag-handle]")!==null;if(v||h||y||x||E||g||((C=(M=m.closest("[data-node-view-content]"))==null?void 0:M.parentElement)==null?void 0:C.classList.contains("node-element"))){p.stopPropagation(),g||p.preventDefault();let S=It(e);if(S){e.editor.commands.blur();let P=S.attrs.id;e.editor.state.doc.descendants(k=>k.type.name==="column"&&k.attrs.id===P?(t(k),!1):!0)}}},[e,t]),u=(0,Ur.useCallback)(p=>{let m=p.target,f=p.currentTarget;if(!(m.closest("[data-column-cell]")!==null)){n(!0);return}let h=f.getBoundingClientRect(),y=p.clientY,x=30,E=y<=h.top+x||y>=h.bottom-x;n(E)},[]),d=(0,Ur.useCallback)(()=>{n(!1)},[]);return(0,co.jsx)(rr,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element",o&&"hover-edge-zone"),onMouseDown:c,onMouseMove:u,onMouseLeave:d,editor:e.editor,getPos:e.getPos,"data-node-type":"column",children:(0,co.jsx)(u0,{...e.node.attrs,node:e.node,columnsCount:e.node.attrs.columnsCount||2,isPreviewMode:l})})},"ColumnComponentNode");var _t={columnsCount:2,paddingHorizontal:0,paddingVertical:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"transparent",cells:[]},Xl=Gl.Node.create({name:"column",group:"block",content:"columnRow?",isolating:!0,selectable:!1,onCreate(){St(this.editor,this.name)},addAttributes(){return{columnsCount:{default:_t.columnsCount,parseHTML:e=>e.getAttribute("data-columns-count"),renderHTML:e=>({"data-columns-count":e.columnsCount})},paddingHorizontal:{default:_t.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:_t.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:_t.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:_t.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:_t.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:_t.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:()=>`node-${(0,kg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})},cells:{default:[],parseHTML:e=>{let t=e.getAttribute("data-cells");return t?JSON.parse(t):[]},renderHTML:e=>({"data-cells":JSON.stringify(e.cells||[])})}}},parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Gl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"column"}),0]},addNodeView(){return(0,wg.ReactNodeViewRenderer)(Eg)},addCommands(){return{setColumn:e=>({chain:t})=>{let r=e.columnsCount||_t.columnsCount,o=`node-${Date.now()}`,n=Array.from({length:r},(i,s)=>({type:"columnCell",attrs:{index:s,columnId:o},content:[{type:"paragraph"}]}));return t().insertContent({type:this.name,attrs:{...e,id:o},content:[{type:"columnRow",content:n}]}).run()}}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"}}}});var Yl=require("@tiptap/core"),Ng=require("@tiptap/react"),Sg=require("uuid");var Pg=require("jotai"),Ag=require("react");var vs=require("react/jsx-runtime"),d0=a(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return(0,vs.jsx)("div",{className:"courier-w-full node-element",children:(0,vs.jsx)("div",{className:"courier-custom-code courier-py-1.5",dangerouslySetInnerHTML:t?{__html:e}:{__html:"&#160;"}})})},"CustomCodeComponent"),Mg=a(e=>{let t=(0,Pg.useSetAtom)(dt),r=(0,Ag.useCallback)(()=>{if(!e.editor.isEditable)return;let i=It(e);if(i){e.editor.commands.blur();let s=i.attrs.id;e.editor.state.doc.descendants(l=>l.type.name==="customCode"&&l.attrs.id===s?(t(l),!1):!0)}},[e,t]),o=e.node.attrs.code,n=!o||o.trim()===""||o==="<!-- Add your HTML code here -->";return(0,vs.jsx)(rr,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element",n&&"is-empty"),onClick:r,editor:e.editor,"data-node-type":"customCode",children:(0,vs.jsx)(d0,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var rn={code:"<!-- Add your HTML code here -->"},Ql=Yl.Node.create({name:"customCode",group:"block",atom:!0,selectable:!1,onCreate(){St(this.editor,this.name)},addAttributes(){return{code:{default:rn.code,parseHTML:e=>e.getAttribute("data-code")||"",renderHTML:e=>({"data-code":e.code})},id:{default:()=>`node-${(0,Sg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="custom-code"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Yl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"custom-code"}),["div",{innerHTML:e.code||rn.code}]]},addNodeView(){return(0,Ng.ReactNodeViewRenderer)(Mg)},addCommands(){return{setCustomCode:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e}).run()}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"}}}});var Dg=require("@tiptap/core");var wn=require("@tiptap/core"),ua=require("@tiptap/pm/state"),Ig=wn.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",(0,wn.mergeAttributes)(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{let{selection:r}=t,{$from:o,$to:n}=r,i=e();return o.parentOffset===0?i.insertContentAt({from:Math.max(o.pos-1,0),to:n.pos},{type:this.name}):(0,wn.isNodeSelection)(r)?i.insertContentAt(n.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:s,dispatch:l})=>{var c;if(l){let{$to:u}=s.selection,d=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?s.setSelection(ua.TextSelection.create(s.doc,u.pos+1)):u.nodeAfter.isBlock?s.setSelection(ua.NodeSelection.create(s.doc,u.pos)):s.setSelection(ua.TextSelection.create(s.doc,u.pos));else{let p=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();p&&(s.insert(d,p),s.setSelection(ua.TextSelection.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(0,wn.nodeInputRule)({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Hg=require("@tiptap/react"),Vg=require("uuid");var Rg=require("jotai"),Lg=require("react");var Cs=require("react/jsx-runtime"),m0=a(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>(0,Cs.jsx)("div",{className:"courier-w-full node-element courier-flex",children:(0,Cs.jsx)("hr",{style:{marginTop:`${e}px`,marginBottom:`${e}px`,backgroundColor:n==="spacer"?"transparent":t,height:`${r}px`,borderRadius:`${o}px`,border:"none",width:"100%"},"data-variant":n})}),"DividerComponent"),Bg=a(e=>{let t=(0,Rg.useSetAtom)(dt),r=(0,Lg.useCallback)(()=>{if(!e.editor.isEditable)return;let o=It(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return(0,Cs.jsx)(rr,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:(0,Cs.jsx)(m0,{...e.node.attrs})})},"DividerComponentNode");var _r={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},da={padding:24,color:"transparent",size:1,radius:0,variant:"spacer"},Bm=Ig.extend({name:"divider",atom:!0,onCreate(){St(this.editor,this.name)},addAttributes(){return{padding:{default:_r.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.margin})},size:{default:_r.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},color:{default:_r.color,parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color})},width:{default:_r.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},radius:{default:_r.radius,parseHTML:e=>e.getAttribute("data-radius"),renderHTML:e=>({"data-radius":e.radius})},variant:{default:_r.variant,parseHTML:e=>e.getAttribute("data-variant"),renderHTML:e=>({"data-variant":e.variant})},id:{default:()=>`node-${(0,Vg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})}}},parseHTML(){return[{tag:'div[data-type="divider"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Dg.mergeAttributes)(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return(0,Hg.ReactNodeViewRenderer)(Bg)},addInputRules(){return[]}});var ec=require("@tiptap/core"),Og=require("@tiptap/react");var Dm=require("jotai"),Ze=require("react");var zt=require("react/jsx-runtime"),p0=["image/png","image/jpeg","image/gif","image/webp"],f0=a(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderColor:n,isUploading:i,width:s,imageNaturalWidth:l,onFileSelect:c,editor:u})=>{let[d,p]=(0,Ze.useState)(!1),[m,f]=(0,Ze.useState)(!0),v=(0,Ze.useRef)(null),h=(0,Ze.useRef)(null);(0,Ze.useEffect)(()=>{e&&f(!0)},[e]),(0,Ze.useEffect)(()=>{if(e&&!l&&u){let k=new Image;k.onload=()=>{try{if(!u.view||!u.state)return;let w=u.view.state.selection.from;u.chain().setNodeSelection(w).updateAttributes("imageBlock",{imageNaturalWidth:k.naturalWidth}).run()}catch{}},k.src=e}},[e,l,u]);let y=(0,Ze.useCallback)(k=>{var N,R;let w=(R=(N=u==null?void 0:u.view)==null?void 0:N.dom)==null?void 0:R.closest(".ProseMirror"),T=(w==null?void 0:w.clientWidth)||1e3,A=Math.min(100,k/T*100);return Math.round(A)},[u]),x=(0,Ze.useMemo)(()=>y(l),[y,l]),E=(0,Ze.useCallback)(k=>p0.includes(k),[]),g=(0,Ze.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),k.dataTransfer.types.includes("Files")&&Array.from(k.dataTransfer.items).some(A=>E(A.type))&&(p(!0),k.dataTransfer.dropEffect="copy")},[E]),b=(0,Ze.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),p(!1)},[]),M=(0,Ze.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),k.dataTransfer.types.includes("Files")&&Array.from(k.dataTransfer.items).some(A=>E(A.type))&&p(!0)},[E]),C=(0,Ze.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),p(!1);let T=Array.from(k.dataTransfer.files).find(A=>E(A.type));T&&c&&c(T)},[c,E]),S=(0,Ze.useCallback)(k=>{var T;let w=(T=k.target.files)==null?void 0:T[0];w&&c&&c(w),k.target&&(k.target.value="")},[c]),P=(0,Ze.useCallback)(()=>{var k;(k=v.current)==null||k.click()},[]);return hl(e)?(0,zt.jsxs)("div",{className:I("courier-w-full node-element courier-empty-image courier-h-[160px] courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-justify-center courier-cursor-pointer courier-transition-colors courier-flex-1 courier-text-center courier-flex-wrap courier-content-center courier-p-4",d&&"courier-border-primary courier-bg-gray-50"),onDragOver:g,onDragEnter:M,onDragLeave:b,onDrop:C,style:{pointerEvents:"all"},children:[i?(0,zt.jsx)(oi,{className:"courier-w-8 courier-h-8"}):(0,zt.jsxs)(zt.Fragment,{children:[(0,zt.jsx)("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),(0,zt.jsx)("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:P,children:"Browse"})]}),(0,zt.jsx)("input",{ref:v,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:S})]}):(0,zt.jsx)("div",{className:"courier-w-full node-element",children:(0,zt.jsxs)("div",{className:I("courier-relative courier-p-1",(i||m)&&"courier-w-full courier-aspect-[4/3] courier-bg-gray-100"),children:[(i||m)&&(0,zt.jsx)("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:(0,zt.jsx)(oi,{className:"courier-w-8 courier-h-8"})}),(0,zt.jsx)("img",{ref:h,src:e,alt:t,className:I("courier-h-auto courier-inline-block courier-w-full",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[r],i&&"courier-opacity-50",(i||m)&&"courier-invisible"),style:{maxWidth:s===x?`${l}px`:`${s}%`,borderWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",display:"block"},loading:"lazy",decoding:"async",draggable:!1,onLoad:k=>{if(f(!1),!l&&u)try{if(!u.view||!u.state)return;setTimeout(()=>{let w=u.view.state.selection.from;u.chain().setNodeSelection(w).updateAttributes("imageBlock",{imageNaturalWidth:k.target.naturalWidth}).run()},100)}catch(w){console.warn("Editor not ready for image update:",w)}},onError:()=>f(!1)})]})})},"ImageBlockComponent"),g0=["image/png","image/jpeg","image/gif","image/webp"],Fg=a(e=>{let t=(0,Dm.useSetAtom)(dt),r=(0,Dm.useSetAtom)(ae),{uploadImage:o}=$i(),n=(0,Ze.useCallback)(l=>{var p,m,f;let c=(f=(m=(p=e.editor)==null?void 0:p.view)==null?void 0:m.dom)==null?void 0:f.closest(".ProseMirror"),u=(c==null?void 0:c.clientWidth)||1e3,d=Math.min(100,l/u*100);return Math.round(d)},[e.editor]);(0,Ze.useEffect)(()=>{var c,u;let l=It(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=kn(e.getPos);m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{width:p,imageNaturalWidth:d.naturalWidth}).run()},d.src=l.attrs.sourcePath}},[e,n]);let i=(0,Ze.useCallback)(()=>{if(!e.editor.isEditable)return;let l=It(e);l&&(e.editor.commands.blur(),t(l))},[e,t]),s=(0,Ze.useCallback)(async l=>{let c=kn(e.getPos);It(e)&&c!==null&&e.editor.chain().focus().setNodeSelection(c).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!g0.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,y)=>{d.onload=h,d.onerror=y});let m=(await o({file:l})).url,f=kn(e.getPos);if(It(e)&&f!==null){let h=new Image;h.src=m,await new Promise((x,E)=>{h.onload=x,h.onerror=()=>E(new Error("Failed to load uploaded image"))});let y=n(h.naturalWidth);e.editor.chain().focus().setNodeSelection(f).updateAttributes("imageBlock",{sourcePath:m,isUploading:!1,width:y,imageNaturalWidth:h.naturalWidth}).run()}}catch(d){console.error("Error uploading image:",d);let p="Error uploading image";if(d instanceof Error){let v=d.message;v.includes("GraphQL error")?p="Server error: Could not process image":v.includes("network")||v.includes("fetch")?p="Network error: Could not upload image":p=v}r({message:p,toastProps:{duration:6e3,description:`File: ${l.name} (${(l.size/1024/1024).toFixed(2)}MB)`}});let m=kn(e.getPos);It(e)&&m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return(0,zt.jsx)(rr,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:(0,zt.jsx)(f0,{...e.node.attrs,onFileSelect:s,editor:e.editor})})},"ImageBlockView");var Ct={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderColor:"transparent",isUploading:!1,imageNaturalWidth:0},tc=ec.Node.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){St(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:Ct.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:Ct.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:Ct.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:Ct.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:Ct.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:Ct.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:Ct.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:Ct.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:Ct.isUploading,parseHTML:e=>e.getAttribute("data-is-uploading"),renderHTML:e=>({"data-is-uploading":e.isUploading})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="image-block"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,ec.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return(0,Og.ReactNodeViewRenderer)(Fg)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...Ct,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...Ct,sourcePath:t||""}}).run(),setImageBlockAlign:e=>({commands:t})=>t.updateAttributes(this.name,{alignment:e}),setImageBlockWidth:e=>({commands:t})=>t.updateAttributes(this.name,{width:e}),uploadImage:e=>({chain:t})=>{let r=new FileReader;return r.onload=()=>{t().setImageBlock({sourcePath:r.result,isUploading:!0}).run()},r.readAsDataURL(e),!0}}}});var Uo=require("zod"),Wg=Uo.z.object({paddingVertical:Uo.z.number(),paddingHorizontal:Uo.z.number(),backgroundColor:Uo.z.string(),borderWidth:Uo.z.number(),borderColor:Uo.z.string(),textAlign:Uo.z.enum(["left","center","right","justify"]).default("left"),selected:Uo.z.boolean().default(!1),id:Uo.z.string().optional()}),ve={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderColor:"transparent",textAlign:"left",selected:!1};var rc=require("@tiptap/react");var oc=require("jotai"),_g=require("react");var on=require("react/jsx-runtime"),Ug=a(({paddingVertical:e,paddingHorizontal:t,textAlign:r,backgroundColor:o,borderWidth:n,borderColor:i,level:s,type:l})=>{let c=l==="heading"?`h${s}`:"p",u=(0,oc.useAtomValue)(Cr);return(0,on.jsx)("div",{className:"courier-w-full node-element",children:(0,on.jsx)("div",{style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderColor:i,borderStyle:n>0?"solid":"none"},children:(0,on.jsx)("div",{style:{pointerEvents:u?"none":"auto"},children:(0,on.jsx)(rc.NodeViewContent,{as:c})})})})},"TextBlockComponent"),nc=a(e=>{let t=(0,oc.useSetAtom)(dt),r=(0,_g.useCallback)(()=>{if(!e.editor.isEditable)return;let l=It(e);l&&t(l)},[e,t]),o=!e.node.content||e.node.content.size===0,n=kn(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null;return(i==null?void 0:i.parent.type.name)==="blockquote"?(0,on.jsx)(rc.NodeViewWrapper,{children:(0,on.jsx)(Ug,{...e.node.attrs,type:e.node.type.name})}):(0,on.jsx)(rr,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:(0,on.jsx)(Ug,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");var Zg=require("@hookform/resolvers/zod"),qg=require("react-hook-form");var jg=require("jotai");var xs=require("react/jsx-runtime"),mt=a(({draggable:e=!1,icon:t,draggableLabel:r,label:o})=>(0,xs.jsxs)("div",{className:"courier-flex courier-flex-row courier-items-center courier-gap-2",children:[(0,xs.jsx)("div",{className:I("courier-w-8 courier-h-8 courier-rounded-md courier-flex courier-items-center courier-justify-center",e?"courier-cursor-grab courier-bg-secondary":"courier-border courier-border-border"),children:t}),(0,xs.jsx)("span",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:e?r:o})]}),"BlockBase");var zg=require("lucide-react");var Hm=require("react/jsx-runtime"),ic=a(({draggable:e=!1})=>(0,Hm.jsx)(mt,{draggable:e,icon:(0,Hm.jsx)(zg.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),draggableLabel:"Blockquote",label:"Blockquote block"}),"BlockquoteBlock");var Ts=require("react/jsx-runtime"),Vm=a(()=>(0,Ts.jsx)("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ts.jsx)("path",{d:"M18 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V10C1.5 10.2812 1.71875 10.5 2 10.5H18C18.25 10.5 18.5 10.2812 18.5 10V2C18.5 1.75 18.25 1.5 18 1.5ZM2 0H18C19.0938 0 20 0.90625 20 2V10C20 11.125 19.0938 12 18 12H2C0.875 12 0 11.125 0 10V2C0 0.90625 0.875 0 2 0Z",fill:"currentColor"})}),"ButtonBlockIcon"),Pn=a(({draggable:e=!1})=>(0,Ts.jsx)(mt,{draggable:e,icon:(0,Ts.jsx)(Vm,{}),draggableLabel:"Button",label:"Button block"}),"ButtonBlock");var Es=require("react/jsx-runtime"),Fm=a(()=>(0,Es.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Es.jsx)("path",{d:"M14 1.5V12.5H18C18.25 12.5 18.5 12.2812 18.5 12V2C18.5 1.75 18.25 1.5 18 1.5H14ZM12.5 1.5H7.5V12.5H12.5V1.5ZM6 12.5V1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12C1.5 12.2812 1.71875 12.5 2 12.5H6ZM0 2C0 0.90625 0.875 0 2 0H18C19.0938 0 20 0.90625 20 2V12C20 13.125 19.0938 14 18 14H2C0.875 14 0 13.125 0 12V2Z",fill:"currentColor"})}),"ColumnBlockIcon"),ac=a(({draggable:e=!1})=>(0,Es.jsx)(mt,{draggable:e,icon:(0,Es.jsx)(Fm,{}),draggableLabel:"Column layout",label:"Column layout"}),"ColumnBlock");var ws=require("react/jsx-runtime"),Om=a(()=>(0,ws.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ws.jsx)("path",{d:"M6.5 3.5L3 7L6.5 10.5M13.5 3.5L17 7L13.5 10.5M11.5 1L8.5 13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"CustomCodeBlockIcon"),sc=a(({draggable:e=!1})=>(0,ws.jsx)(mt,{draggable:e,icon:(0,ws.jsx)(Om,{}),draggableLabel:"Custom code",label:"Custom code"}),"CustomCodeBlock");var ks=require("react/jsx-runtime"),Wm=a(()=>(0,ks.jsx)("svg",{width:"16",height:"2",viewBox:"0 0 16 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ks.jsx)("path",{d:"M0 1C0 0.59375 0.3125 0.25 0.75 0.25H15.25C15.6562 0.25 16 0.59375 16 1C16 1.4375 15.6562 1.75 15.25 1.75H0.75C0.3125 1.75 0 1.4375 0 1Z",fill:"currentColor"})}),"DividerBlockIcon"),An=a(({draggable:e=!1})=>(0,ks.jsx)(mt,{draggable:e,icon:(0,ks.jsx)(Wm,{}),draggableLabel:"Divider",label:"Divider block"}),"DividerBlock");var Ps=require("react/jsx-runtime"),Um=a(()=>(0,Ps.jsx)("svg",{width:"18",height:"13",viewBox:"0 0 18 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ps.jsx)("path",{d:"M1.5 1.75V6H8.5V1.75C8.5 1.34375 8.8125 1 9.25 1C9.65625 1 10 1.34375 10 1.75V6.75V12.25C10 12.6875 9.65625 13 9.25 13C8.8125 13 8.5 12.6875 8.5 12.25V7.5H1.5V12.25C1.5 12.6875 1.15625 13 0.75 13C0.3125 13 0 12.6875 0 12.25V6.75V1.75C0 1.34375 0.3125 1 0.75 1C1.15625 1 1.5 1.34375 1.5 1.75ZM15.75 1.75V11.5H17.25C17.6562 11.5 18 11.8438 18 12.25C18 12.6875 17.6562 13 17.25 13H15H12.75C12.3125 13 12 12.6875 12 12.25C12 11.8438 12.3125 11.5 12.75 11.5H14.25V3.03125L13.0938 3.65625C12.75 3.875 12.2812 3.75 12.0938 3.375C11.875 3 12 2.5625 12.375 2.34375L14.625 1.09375C14.8438 0.96875 15.125 0.96875 15.375 1.125C15.5938 1.25 15.75 1.5 15.75 1.75Z",fill:"currentColor"})}),"HeadingBlockIcon"),lc=a(({draggable:e=!1})=>(0,Ps.jsx)(mt,{draggable:e,icon:(0,Ps.jsx)(Um,{}),draggableLabel:"Heading",label:"Heading block"}),"HeadingBlock");var As=require("react/jsx-runtime"),_m=a(()=>(0,As.jsx)("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,As.jsx)("path",{d:"M14 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12V12.0312L1.625 11.8438L4.125 8.34375C4.28125 8.125 4.5 8 4.75 8C4.96875 8 5.21875 8.125 5.34375 8.3125L6.3125 9.65625L8.90625 6.3125C9.03125 6.125 9.25 6 9.5 6C9.71875 6 9.9375 6.125 10.0938 6.3125L14.3438 11.8125L14.5 12V2C14.5 1.75 14.25 1.5 14 1.5ZM2 0H14C15.0938 0 16 0.90625 16 2V12C16 13.125 15.0938 14 14 14H2C0.875 14 0 13.125 0 12V2C0 0.90625 0.875 0 2 0ZM4.5 6C3.9375 6 3.46875 5.71875 3.1875 5.25C2.90625 4.8125 2.90625 4.21875 3.1875 3.75C3.46875 3.3125 3.9375 3 4.5 3C5.03125 3 5.5 3.3125 5.78125 3.75C6.0625 4.21875 6.0625 4.8125 5.78125 5.25C5.5 5.71875 5.03125 6 4.5 6Z",fill:"currentColor"})}),"ImageBlockIcon"),cc=a(({draggable:e=!1})=>(0,As.jsx)(mt,{draggable:e,icon:(0,As.jsx)(_m,{}),draggableLabel:"Image",label:"Image block"}),"ImageBlock");var $g=require("lucide-react");var zm=require("react/jsx-runtime"),uc=a(({draggable:e=!1})=>(0,zm.jsx)(mt,{draggable:e,icon:(0,zm.jsx)($g.AlignVerticalSpaceAround,{className:"courier-w-4 courier-h-4"}),draggableLabel:"Spacer",label:"Spacer block"}),"SpacerBlock");var Ms=require("react/jsx-runtime"),$m=a(()=>(0,Ms.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ms.jsx)("path",{d:"M1.5 1.5V3C1.5 3.4375 1.15625 3.75 0.75 3.75C0.3125 3.75 0 3.4375 0 3V1.25C0 0.5625 0.53125 0 1.25 0H12.75C13.4375 0 14 0.5625 14 1.25V3C14 3.4375 13.6562 3.75 13.25 3.75C12.8125 3.75 12.5 3.4375 12.5 3V1.5H7.75V12.5H9.25C9.65625 12.5 10 12.8438 10 13.25C10 13.6875 9.65625 14 9.25 14H4.75C4.3125 14 4 13.6875 4 13.25C4 12.8438 4.3125 12.5 4.75 12.5H6.25V1.5H1.5Z",fill:"currentColor"})}),"TextBlockIcon"),Mn=a(({draggable:e=!1})=>(0,Ms.jsx)(mt,{draggable:e,icon:(0,Ms.jsx)($m,{}),draggableLabel:"Text",label:"Text block"}),"TextBlock");var kr=require("react/jsx-runtime"),or=a(({type:e})=>{let t=(0,jg.useSetAtom)(dt);return(0,kr.jsxs)("div",{className:"courier-flex courier-gap-4 courier-flex-col",children:[(0,kr.jsx)(Ve,{className:"courier-w-fit",variant:"secondary",buttonSize:"small",onClick:()=>{t(null)},children:"Close"}),e==="heading"&&(0,kr.jsx)(lc,{}),e==="text"&&(0,kr.jsx)(Mn,{}),e==="image"&&(0,kr.jsx)(cc,{}),e==="spacer"&&(0,kr.jsx)(uc,{}),e==="divider"&&(0,kr.jsx)(An,{}),e==="button"&&(0,kr.jsx)(Pn,{}),e==="blockquote"&&(0,kr.jsx)(ic,{}),e==="customCode"&&(0,kr.jsx)(sc,{}),e==="column"&&(0,kr.jsx)(ac,{}),(0,kr.jsx)(ge,{className:"courier-m-0"})]})},"FormHeader");var he=require("react/jsx-runtime"),Jg=a(({element:e,editor:t})=>{let r=(0,qg.useForm)({resolver:(0,Zg.zodResolver)(Wg),defaultValues:{...ve,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Ut({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?(0,he.jsxs)(rt,{...r,children:[(0,he.jsx)(or,{type:"text"}),(0,he.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,he.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,he.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,he.jsx)(oe,{control:r.control,name:"paddingHorizontal",render:({field:n})=>(0,he.jsxs)(te,{children:[(0,he.jsx)(re,{children:(0,he.jsx)(Ee,{startAdornment:(0,he.jsx)(is,{}),type:"number",min:0,...n})}),(0,he.jsx)(ne,{})]})}),(0,he.jsx)(oe,{control:r.control,name:"paddingVertical",render:({field:n})=>(0,he.jsxs)(te,{children:[(0,he.jsx)(re,{children:(0,he.jsx)(Ee,{startAdornment:(0,he.jsx)(ti,{}),type:"number",min:0,...n})}),(0,he.jsx)(ne,{})]})})]}),(0,he.jsx)(oe,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,he.jsxs)(te,{className:"courier-mb-4",children:[(0,he.jsx)(re,{children:(0,he.jsx)(Wt,{...n,defaultValue:ve.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,he.jsx)(ne,{})]})}),(0,he.jsx)(ge,{className:"courier-mb-4"}),(0,he.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,he.jsx)(oe,{control:r.control,name:"borderWidth",render:({field:n})=>(0,he.jsxs)(te,{className:"courier-mb-3",children:[(0,he.jsx)(re,{children:(0,he.jsx)(Ee,{startAdornment:(0,he.jsx)(Qo,{}),type:"number",min:0,...n})}),(0,he.jsx)(ne,{})]})}),(0,he.jsx)(oe,{control:r.control,name:"borderColor",render:({field:n})=>(0,he.jsxs)(te,{className:"courier-mb-4",children:[(0,he.jsx)(re,{children:(0,he.jsx)(Wt,{...n,defaultValue:ve.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,he.jsx)(ne,{})]})})]})]}):null},"TextBlockForm");var h0=a((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),dc=a((e,t,r,o,n,i)=>{let s=`node-${(0,Kg.v4)()}`,c={heading:()=>e.schema.nodes.heading.create({...ve,...o,id:s},i),paragraph:()=>e.schema.nodes.paragraph.create({...ve,...o,id:s},i),text:()=>e.schema.nodes.paragraph.create({...ve,...o,id:s},i),spacer:()=>e.schema.nodes.divider.create({...da,...o,id:s}),divider:()=>e.schema.nodes.divider.create({..._r,...o,id:s}),button:()=>e.schema.nodes.button.create({...at,...o,id:s},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...Ct,...o,id:s}),image:()=>e.schema.nodes.imageBlock.create({...Ct,...o,id:s}),customCode:()=>e.schema.nodes.customCode.create({...rn,...o,id:s}),column:()=>e.schema.nodes.column.create({..._t,...o,id:s})}[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=h0(e,s);m!==null&&e.commands.setTextSelection(m+1),e.view.focus()},50);let p=new CustomEvent("node-duplicated",{detail:{newNodeId:s}});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:s},i);u.insert(r,d),e.view.dispatch(u),n&&n(d);let p=new CustomEvent("node-duplicated",{detail:{newNodeId:s}});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 s},"createOrDuplicateNode");var b0=a(()=>{let[e,t]=(0,mi.useAtom)(Ho),[r,o]=(0,mi.useAtom)(dl),[n,i]=(0,mi.useAtom)(bn),s=(0,mi.useAtomValue)(He),l=(0,mi.useAtom)(we)[1],c=(0,uo.useCallback)(E=>{l(E)},[l]),u=(0,uo.useCallback)(E=>{t(E)},[t]),d=(0,uo.useCallback)(()=>{t(ul)},[t]),p=(0,uo.useCallback)((E,g)=>{o(b=>({...b,[E]:{...b[E],...g}}))},[o]),m=(0,uo.useCallback)(E=>r[E],[r]),f=(0,uo.useCallback)(E=>{o(g=>{let b={...g};return delete b[E],b})},[o]),v=(0,uo.useCallback)(E=>{i(g=>{let b=g.findIndex(M=>M.type===E.type&&M.key===E.key);if(b>=0){let M=[...g];return M[b]=E,M}return[...g,E]})},[i]),h=(0,uo.useCallback)((E,g)=>{i(b=>b.filter(M=>!(M.type===E&&M.key===g)))},[i]),y=(0,uo.useCallback)(E=>n.filter(g=>g.type===E),[n]),x=(0,uo.useCallback)((E,g)=>{if(!s){console.warn("[useBlockConfig] Cannot insert block: editor not available");return}let b={};E==="spacer"&&(b={...da});let M=r[E];if(M&&(b={...b,...M}),g){let k=n.find(w=>w.type===E&&w.key===g);k?b={...b,...k.attributes}:console.warn(`[useBlockConfig] Preset "${g}" not found for type "${E}"`)}let C=s.state.doc.content.size,P={heading:"heading",text:"paragraph",image:"imageBlock",spacer:"divider",divider:"divider",button:"button",customCode:"customCode",column:"column",blockquote:"blockquote"}[E];dc(s,P,C,b,c)},[s,r,n,c]);return{visibleBlocks:e,setVisibleBlocks:u,resetVisibleBlocks:d,defaultVisibleBlocks:ul,setDefaults:p,getDefaults:m,clearDefaults:f,registerPreset:v,unregisterPreset:h,presets:n,getPresetsForType:y,insertBlock:x}},"useBlockConfig");var Nn=require("zod"),Gg=Nn.z.object({paddingHorizontal:Nn.z.coerce.number().min(0),paddingVertical:Nn.z.coerce.number().min(0),backgroundColor:Nn.z.string(),borderLeftWidth:Nn.z.coerce.number().min(0),borderColor:Nn.z.string(),id:Nn.z.string().optional()});var mo=require("react/jsx-runtime"),Qg=a(({element:e,editor:t})=>{let r=(0,Yg.useForm)({resolver:(0,Xg.zodResolver)(Gg),defaultValues:{..._o,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Ut({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"blockquote"});return e?(0,mo.jsxs)(rt,{...r,children:[(0,mo.jsx)(or,{type:"blockquote"}),(0,mo.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,mo.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,mo.jsx)(oe,{control:r.control,name:"borderColor",render:({field:n})=>(0,mo.jsxs)(te,{className:"courier-mb-3",children:[(0,mo.jsx)(re,{children:(0,mo.jsx)(Wt,{...n,defaultValue:_o.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,mo.jsx)(ne,{})]})})]})]}):null},"BlockquoteForm");var Pr=require("zod"),mc=Pr.z.object({label:Pr.z.string(),link:Pr.z.string().optional(),alignment:Pr.z.enum(["left","center","right"]),backgroundColor:Pr.z.string(),borderRadius:Pr.z.number(),padding:Pr.z.number(),fontWeight:Pr.z.enum(["normal","bold"]),fontStyle:Pr.z.enum(["normal","italic"]),isUnderline:Pr.z.boolean(),isStrike:Pr.z.boolean(),textColor:Pr.z.string().optional(),borderColor:Pr.z.string().optional()});var Ch=require("@hookform/resolvers/zod"),xh=require("react-hook-form");var e5=require("@tiptap/core"),ma=e5.Node.create({name:"doc",topNode:!0,content:"block+"});var pc=require("@tiptap/core"),pa=pc.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",(0,pc.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var yh=xe(require("@tiptap/extension-placeholder"),1);var t5=require("@tiptap/core"),fc=t5.Node.create({name:"text",group:"inline"});var Oc=require("@tiptap/react"),ki=xe(require("react"),1),Us=require("react");var Ln=require("@tiptap/core"),J5=require("@tiptap/react"),K5=require("@tiptap/suggestion");var U5=require("@tiptap/react");var ot="top",xt="bottom",pt="right",st="left",gc="auto",Sn=[ot,xt,pt,st],nn="start",pi="end",r5="clippingParents",hc="viewport",fa="popper",o5="reference",jm=Sn.reduce(function(e,t){return e.concat([t+"-"+nn,t+"-"+pi])},[]),bc=[].concat(Sn,[gc]).reduce(function(e,t){return e.concat([t,t+"-"+nn,t+"-"+pi])},[]),y0="beforeRead",v0="read",C0="afterRead",x0="beforeMain",T0="main",E0="afterMain",w0="beforeWrite",k0="write",P0="afterWrite",n5=[y0,v0,C0,x0,T0,E0,w0,k0,P0];function Rt(e){return e?(e.nodeName||"").toLowerCase():null}a(Rt,"getNodeName");function qe(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}a(qe,"getWindow");function Qr(e){var t=qe(e).Element;return e instanceof t||e instanceof Element}a(Qr,"isElement");function Tt(e){var t=qe(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}a(Tt,"isHTMLElement");function ga(e){if(typeof ShadowRoot=="undefined")return!1;var t=qe(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}a(ga,"isShadowRoot");function A0(e){var t=e.state;Object.keys(t.elements).forEach(function(r){var o=t.styles[r]||{},n=t.attributes[r]||{},i=t.elements[r];!Tt(i)||!Rt(i)||(Object.assign(i.style,o),Object.keys(n).forEach(function(s){var l=n[s];l===!1?i.removeAttribute(s):i.setAttribute(s,l===!0?"":l)}))})}a(A0,"applyStyles");function M0(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow),function(){Object.keys(t.elements).forEach(function(o){var n=t.elements[o],i=t.attributes[o]||{},s=Object.keys(t.styles.hasOwnProperty(o)?t.styles[o]:r[o]),l=s.reduce(function(c,u){return c[u]="",c},{});!Tt(n)||!Rt(n)||(Object.assign(n.style,l),Object.keys(i).forEach(function(c){n.removeAttribute(c)}))})}}a(M0,"effect");var Ns={name:"applyStyles",enabled:!0,phase:"write",fn:A0,effect:M0,requires:["computeStyles"]};function Lt(e){return e.split("-")[0]}a(Lt,"getBasePlacement");var po=Math.max,fi=Math.min,an=Math.round;function ha(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}a(ha,"getUAString");function Ss(){return!/^((?!chrome|android).)*safari/i.test(ha())}a(Ss,"isLayoutViewport");function eo(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!1);var o=e.getBoundingClientRect(),n=1,i=1;t&&Tt(e)&&(n=e.offsetWidth>0&&an(o.width)/e.offsetWidth||1,i=e.offsetHeight>0&&an(o.height)/e.offsetHeight||1);var s=Qr(e)?qe(e):window,l=s.visualViewport,c=!Ss()&&r,u=(o.left+(c&&l?l.offsetLeft:0))/n,d=(o.top+(c&&l?l.offsetTop:0))/i,p=o.width/n,m=o.height/i;return{width:p,height:m,top:d,right:u+p,bottom:d+m,left:u,x:u,y:d}}a(eo,"getBoundingClientRect");function gi(e){var t=eo(e),r=e.offsetWidth,o=e.offsetHeight;return Math.abs(t.width-r)<=1&&(r=t.width),Math.abs(t.height-o)<=1&&(o=t.height),{x:e.offsetLeft,y:e.offsetTop,width:r,height:o}}a(gi,"getLayoutRect");function Is(e,t){var r=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(r&&ga(r)){var o=t;do{if(o&&e.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}a(Is,"contains");function mr(e){return qe(e).getComputedStyle(e)}a(mr,"getComputedStyle");function Zm(e){return["table","td","th"].indexOf(Rt(e))>=0}a(Zm,"isTableElement");function $t(e){return((Qr(e)?e.ownerDocument:e.document)||window.document).documentElement}a($t,"getDocumentElement");function sn(e){return Rt(e)==="html"?e:e.assignedSlot||e.parentNode||(ga(e)?e.host:null)||$t(e)}a(sn,"getParentNode");function i5(e){return!Tt(e)||mr(e).position==="fixed"?null:e.offsetParent}a(i5,"getTrueOffsetParent");function N0(e){var t=/firefox/i.test(ha()),r=/Trident/i.test(ha());if(r&&Tt(e)){var o=mr(e);if(o.position==="fixed")return null}var n=sn(e);for(ga(n)&&(n=n.host);Tt(n)&&["html","body"].indexOf(Rt(n))<0;){var i=mr(n);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||t&&i.willChange==="filter"||t&&i.filter&&i.filter!=="none")return n;n=n.parentNode}return null}a(N0,"getContainingBlock");function fo(e){for(var t=qe(e),r=i5(e);r&&Zm(r)&&mr(r).position==="static";)r=i5(r);return r&&(Rt(r)==="html"||Rt(r)==="body"&&mr(r).position==="static")?t:r||N0(e)||t}a(fo,"getOffsetParent");function hi(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}a(hi,"getMainAxisFromPlacement");function bi(e,t,r){return po(e,fi(t,r))}a(bi,"within");function a5(e,t,r){var o=bi(e,t,r);return o>r?r:o}a(a5,"withinMaxClamp");function Rs(){return{top:0,right:0,bottom:0,left:0}}a(Rs,"getFreshSideObject");function Ls(e){return Object.assign({},Rs(),e)}a(Ls,"mergePaddingObject");function Bs(e,t){return t.reduce(function(r,o){return r[o]=e,r},{})}a(Bs,"expandToHashMap");var S0=a(function(t,r){return t=typeof t=="function"?t(Object.assign({},r.rects,{placement:r.placement})):t,Ls(typeof t!="number"?t:Bs(t,Sn))},"toPaddingObject");function I0(e){var t,r=e.state,o=e.name,n=e.options,i=r.elements.arrow,s=r.modifiersData.popperOffsets,l=Lt(r.placement),c=hi(l),u=[st,pt].indexOf(l)>=0,d=u?"height":"width";if(!(!i||!s)){var p=S0(n.padding,r),m=gi(i),f=c==="y"?ot:st,v=c==="y"?xt:pt,h=r.rects.reference[d]+r.rects.reference[c]-s[c]-r.rects.popper[d],y=s[c]-r.rects.reference[c],x=fo(i),E=x?c==="y"?x.clientHeight||0:x.clientWidth||0:0,g=h/2-y/2,b=p[f],M=E-m[d]-p[v],C=E/2-m[d]/2+g,S=bi(b,C,M),P=c;r.modifiersData[o]=(t={},t[P]=S,t.centerOffset=S-C,t)}}a(I0,"arrow");function R0(e){var t=e.state,r=e.options,o=r.element,n=o===void 0?"[data-popper-arrow]":o;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||Is(t.elements.popper,n)&&(t.elements.arrow=n))}a(R0,"effect");var s5={name:"arrow",enabled:!0,phase:"main",fn:I0,effect:R0,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function to(e){return e.split("-")[1]}a(to,"getVariation");var L0={top:"auto",right:"auto",bottom:"auto",left:"auto"};function B0(e,t){var r=e.x,o=e.y,n=t.devicePixelRatio||1;return{x:an(r*n)/n||0,y:an(o*n)/n||0}}a(B0,"roundOffsetsByDPR");function l5(e){var t,r=e.popper,o=e.popperRect,n=e.placement,i=e.variation,s=e.offsets,l=e.position,c=e.gpuAcceleration,u=e.adaptive,d=e.roundOffsets,p=e.isFixed,m=s.x,f=m===void 0?0:m,v=s.y,h=v===void 0?0:v,y=typeof d=="function"?d({x:f,y:h}):{x:f,y:h};f=y.x,h=y.y;var x=s.hasOwnProperty("x"),E=s.hasOwnProperty("y"),g=st,b=ot,M=window;if(u){var C=fo(r),S="clientHeight",P="clientWidth";if(C===qe(r)&&(C=$t(r),mr(C).position!=="static"&&l==="absolute"&&(S="scrollHeight",P="scrollWidth")),C=C,n===ot||(n===st||n===pt)&&i===pi){b=xt;var k=p&&C===M&&M.visualViewport?M.visualViewport.height:C[S];h-=k-o.height,h*=c?1:-1}if(n===st||(n===ot||n===xt)&&i===pi){g=pt;var w=p&&C===M&&M.visualViewport?M.visualViewport.width:C[P];f-=w-o.width,f*=c?1:-1}}var T=Object.assign({position:l},u&&L0),A=d===!0?B0({x:f,y:h},qe(r)):{x:f,y:h};if(f=A.x,h=A.y,c){var N;return Object.assign({},T,(N={},N[b]=E?"0":"",N[g]=x?"0":"",N.transform=(M.devicePixelRatio||1)<=1?"translate("+f+"px, "+h+"px)":"translate3d("+f+"px, "+h+"px, 0)",N))}return Object.assign({},T,(t={},t[b]=E?h+"px":"",t[g]=x?f+"px":"",t.transform="",t))}a(l5,"mapToStyles");function D0(e){var t=e.state,r=e.options,o=r.gpuAcceleration,n=o===void 0?!0:o,i=r.adaptive,s=i===void 0?!0:i,l=r.roundOffsets,c=l===void 0?!0:l,u={placement:Lt(t.placement),variation:to(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,l5(Object.assign({},u,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,l5(Object.assign({},u,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}a(D0,"computeStyles");var c5={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:D0,data:{}};var yc={passive:!0};function H0(e){var t=e.state,r=e.instance,o=e.options,n=o.scroll,i=n===void 0?!0:n,s=o.resize,l=s===void 0?!0:s,c=qe(t.elements.popper),u=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&u.forEach(function(d){d.addEventListener("scroll",r.update,yc)}),l&&c.addEventListener("resize",r.update,yc),function(){i&&u.forEach(function(d){d.removeEventListener("scroll",r.update,yc)}),l&&c.removeEventListener("resize",r.update,yc)}}a(H0,"effect");var u5={name:"eventListeners",enabled:!0,phase:"write",fn:a(function(){},"fn"),effect:H0,data:{}};var V0={left:"right",right:"left",bottom:"top",top:"bottom"};function ba(e){return e.replace(/left|right|bottom|top/g,function(t){return V0[t]})}a(ba,"getOppositePlacement");var F0={start:"end",end:"start"};function vc(e){return e.replace(/start|end/g,function(t){return F0[t]})}a(vc,"getOppositeVariationPlacement");function yi(e){var t=qe(e),r=t.pageXOffset,o=t.pageYOffset;return{scrollLeft:r,scrollTop:o}}a(yi,"getWindowScroll");function vi(e){return eo($t(e)).left+yi(e).scrollLeft}a(vi,"getWindowScrollBarX");function qm(e,t){var r=qe(e),o=$t(e),n=r.visualViewport,i=o.clientWidth,s=o.clientHeight,l=0,c=0;if(n){i=n.width,s=n.height;var u=Ss();(u||!u&&t==="fixed")&&(l=n.offsetLeft,c=n.offsetTop)}return{width:i,height:s,x:l+vi(e),y:c}}a(qm,"getViewportRect");function Jm(e){var t,r=$t(e),o=yi(e),n=(t=e.ownerDocument)==null?void 0:t.body,i=po(r.scrollWidth,r.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),s=po(r.scrollHeight,r.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),l=-o.scrollLeft+vi(e),c=-o.scrollTop;return mr(n||r).direction==="rtl"&&(l+=po(r.clientWidth,n?n.clientWidth:0)-i),{width:i,height:s,x:l,y:c}}a(Jm,"getDocumentRect");function Ci(e){var t=mr(e),r=t.overflow,o=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(r+n+o)}a(Ci,"isScrollParent");function Cc(e){return["html","body","#document"].indexOf(Rt(e))>=0?e.ownerDocument.body:Tt(e)&&Ci(e)?e:Cc(sn(e))}a(Cc,"getScrollParent");function In(e,t){var r;t===void 0&&(t=[]);var o=Cc(e),n=o===((r=e.ownerDocument)==null?void 0:r.body),i=qe(o),s=n?[i].concat(i.visualViewport||[],Ci(o)?o:[]):o,l=t.concat(s);return n?l:l.concat(In(sn(s)))}a(In,"listScrollParents");function ya(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}a(ya,"rectToClientRect");function O0(e,t){var r=eo(e,!1,t==="fixed");return r.top=r.top+e.clientTop,r.left=r.left+e.clientLeft,r.bottom=r.top+e.clientHeight,r.right=r.left+e.clientWidth,r.width=e.clientWidth,r.height=e.clientHeight,r.x=r.left,r.y=r.top,r}a(O0,"getInnerBoundingClientRect");function d5(e,t,r){return t===hc?ya(qm(e,r)):Qr(t)?O0(t,r):ya(Jm($t(e)))}a(d5,"getClientRectFromMixedType");function W0(e){var t=In(sn(e)),r=["absolute","fixed"].indexOf(mr(e).position)>=0,o=r&&Tt(e)?fo(e):e;return Qr(o)?t.filter(function(n){return Qr(n)&&Is(n,o)&&Rt(n)!=="body"}):[]}a(W0,"getClippingParents");function Km(e,t,r,o){var n=t==="clippingParents"?W0(e):[].concat(t),i=[].concat(n,[r]),s=i[0],l=i.reduce(function(c,u){var d=d5(e,u,o);return c.top=po(d.top,c.top),c.right=fi(d.right,c.right),c.bottom=fi(d.bottom,c.bottom),c.left=po(d.left,c.left),c},d5(e,s,o));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}a(Km,"getClippingRect");function Ds(e){var t=e.reference,r=e.element,o=e.placement,n=o?Lt(o):null,i=o?to(o):null,s=t.x+t.width/2-r.width/2,l=t.y+t.height/2-r.height/2,c;switch(n){case ot:c={x:s,y:t.y-r.height};break;case xt:c={x:s,y:t.y+t.height};break;case pt:c={x:t.x+t.width,y:l};break;case st:c={x:t.x-r.width,y:l};break;default:c={x:t.x,y:t.y}}var u=n?hi(n):null;if(u!=null){var d=u==="y"?"height":"width";switch(i){case nn:c[u]=c[u]-(t[d]/2-r[d]/2);break;case pi:c[u]=c[u]+(t[d]/2-r[d]/2);break;default:}}return c}a(Ds,"computeOffsets");function go(e,t){t===void 0&&(t={});var r=t,o=r.placement,n=o===void 0?e.placement:o,i=r.strategy,s=i===void 0?e.strategy:i,l=r.boundary,c=l===void 0?r5:l,u=r.rootBoundary,d=u===void 0?hc:u,p=r.elementContext,m=p===void 0?fa:p,f=r.altBoundary,v=f===void 0?!1:f,h=r.padding,y=h===void 0?0:h,x=Ls(typeof y!="number"?y:Bs(y,Sn)),E=m===fa?o5:fa,g=e.rects.popper,b=e.elements[v?E:m],M=Km(Qr(b)?b:b.contextElement||$t(e.elements.popper),c,d,s),C=eo(e.elements.reference),S=Ds({reference:C,element:g,strategy:"absolute",placement:n}),P=ya(Object.assign({},g,S)),k=m===fa?P:C,w={top:M.top-k.top+x.top,bottom:k.bottom-M.bottom+x.bottom,left:M.left-k.left+x.left,right:k.right-M.right+x.right},T=e.modifiersData.offset;if(m===fa&&T){var A=T[n];Object.keys(w).forEach(function(N){var R=[pt,xt].indexOf(N)>=0?1:-1,B=[ot,xt].indexOf(N)>=0?"y":"x";w[N]+=A[B]*R})}return w}a(go,"detectOverflow");function Gm(e,t){t===void 0&&(t={});var r=t,o=r.placement,n=r.boundary,i=r.rootBoundary,s=r.padding,l=r.flipVariations,c=r.allowedAutoPlacements,u=c===void 0?bc:c,d=to(o),p=d?l?jm:jm.filter(function(v){return to(v)===d}):Sn,m=p.filter(function(v){return u.indexOf(v)>=0});m.length===0&&(m=p);var f=m.reduce(function(v,h){return v[h]=go(e,{placement:h,boundary:n,rootBoundary:i,padding:s})[Lt(h)],v},{});return Object.keys(f).sort(function(v,h){return f[v]-f[h]})}a(Gm,"computeAutoPlacement");function U0(e){if(Lt(e)===gc)return[];var t=ba(e);return[vc(e),t,vc(t)]}a(U0,"getExpandedFallbackPlacements");function _0(e){var t=e.state,r=e.options,o=e.name;if(!t.modifiersData[o]._skip){for(var n=r.mainAxis,i=n===void 0?!0:n,s=r.altAxis,l=s===void 0?!0:s,c=r.fallbackPlacements,u=r.padding,d=r.boundary,p=r.rootBoundary,m=r.altBoundary,f=r.flipVariations,v=f===void 0?!0:f,h=r.allowedAutoPlacements,y=t.options.placement,x=Lt(y),E=x===y,g=c||(E||!v?[ba(y)]:U0(y)),b=[y].concat(g).reduce(function(J,G){return J.concat(Lt(G)===gc?Gm(t,{placement:G,boundary:d,rootBoundary:p,padding:u,flipVariations:v,allowedAutoPlacements:h}):G)},[]),M=t.rects.reference,C=t.rects.popper,S=new Map,P=!0,k=b[0],w=0;w<b.length;w++){var T=b[w],A=Lt(T),N=to(T)===nn,R=[ot,xt].indexOf(A)>=0,B=R?"width":"height",H=go(t,{placement:T,boundary:d,rootBoundary:p,altBoundary:m,padding:u}),D=R?N?pt:st:N?xt:ot;M[B]>C[B]&&(D=ba(D));var F=ba(D),L=[];if(i&&L.push(H[A]<=0),l&&L.push(H[D]<=0,H[F]<=0),L.every(function(J){return J})){k=T,P=!1;break}S.set(T,L)}if(P)for(var W=v?3:1,_=a(function(G){var X=b.find(function(U){var K=S.get(U);if(K)return K.slice(0,G).every(function(de){return de})});if(X)return k=X,"break"},"_loop"),V=W;V>0;V--){var j=_(V);if(j==="break")break}t.placement!==k&&(t.modifiersData[o]._skip=!0,t.placement=k,t.reset=!0)}}a(_0,"flip");var m5={name:"flip",enabled:!0,phase:"main",fn:_0,requiresIfExists:["offset"],data:{_skip:!1}};function p5(e,t,r){return r===void 0&&(r={x:0,y:0}),{top:e.top-t.height-r.y,right:e.right-t.width+r.x,bottom:e.bottom-t.height+r.y,left:e.left-t.width-r.x}}a(p5,"getSideOffsets");function f5(e){return[ot,pt,xt,st].some(function(t){return e[t]>=0})}a(f5,"isAnySideFullyClipped");function z0(e){var t=e.state,r=e.name,o=t.rects.reference,n=t.rects.popper,i=t.modifiersData.preventOverflow,s=go(t,{elementContext:"reference"}),l=go(t,{altBoundary:!0}),c=p5(s,o),u=p5(l,n,i),d=f5(c),p=f5(u);t.modifiersData[r]={referenceClippingOffsets:c,popperEscapeOffsets:u,isReferenceHidden:d,hasPopperEscaped:p},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":p})}a(z0,"hide");var g5={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:z0};function $0(e,t,r){var o=Lt(e),n=[st,ot].indexOf(o)>=0?-1:1,i=typeof r=="function"?r(Object.assign({},t,{placement:e})):r,s=i[0],l=i[1];return s=s||0,l=(l||0)*n,[st,pt].indexOf(o)>=0?{x:l,y:s}:{x:s,y:l}}a($0,"distanceAndSkiddingToXY");function j0(e){var t=e.state,r=e.options,o=e.name,n=r.offset,i=n===void 0?[0,0]:n,s=bc.reduce(function(d,p){return d[p]=$0(p,t.rects,i),d},{}),l=s[t.placement],c=l.x,u=l.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=u),t.modifiersData[o]=s}a(j0,"offset");var h5={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:j0};function Z0(e){var t=e.state,r=e.name;t.modifiersData[r]=Ds({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}a(Z0,"popperOffsets");var b5={name:"popperOffsets",enabled:!0,phase:"read",fn:Z0,data:{}};function Xm(e){return e==="x"?"y":"x"}a(Xm,"getAltAxis");function q0(e){var t=e.state,r=e.options,o=e.name,n=r.mainAxis,i=n===void 0?!0:n,s=r.altAxis,l=s===void 0?!1:s,c=r.boundary,u=r.rootBoundary,d=r.altBoundary,p=r.padding,m=r.tether,f=m===void 0?!0:m,v=r.tetherOffset,h=v===void 0?0:v,y=go(t,{boundary:c,rootBoundary:u,padding:p,altBoundary:d}),x=Lt(t.placement),E=to(t.placement),g=!E,b=hi(x),M=Xm(b),C=t.modifiersData.popperOffsets,S=t.rects.reference,P=t.rects.popper,k=typeof h=="function"?h(Object.assign({},t.rects,{placement:t.placement})):h,w=typeof k=="number"?{mainAxis:k,altAxis:k}:Object.assign({mainAxis:0,altAxis:0},k),T=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,A={x:0,y:0};if(C){if(i){var N,R=b==="y"?ot:st,B=b==="y"?xt:pt,H=b==="y"?"height":"width",D=C[b],F=D+y[R],L=D-y[B],W=f?-P[H]/2:0,_=E===nn?S[H]:P[H],V=E===nn?-P[H]:-S[H],j=t.elements.arrow,J=f&&j?gi(j):{width:0,height:0},G=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:Rs(),X=G[R],U=G[B],K=bi(0,S[H],J[H]),de=g?S[H]/2-W-K-X-w.mainAxis:_-K-X-w.mainAxis,me=g?-S[H]/2+W+K+U+w.mainAxis:V+K+U+w.mainAxis,Me=t.elements.arrow&&fo(t.elements.arrow),We=Me?b==="y"?Me.clientTop||0:Me.clientLeft||0:0,Pt=(N=T==null?void 0:T[b])!=null?N:0,Ht=D+de-Pt-We,ar=D+me-Pt,Vt=bi(f?fi(F,Ht):F,D,f?po(L,ar):L);C[b]=Vt,A[b]=Vt-D}if(l){var Yt,At=b==="x"?ot:st,Qt=b==="x"?xt:pt,et=C[M],ut=M==="y"?"height":"width",ce=et+y[At],Te=et-y[Qt],ke=[ot,st].indexOf(x)!==-1,ie=(Yt=T==null?void 0:T[M])!=null?Yt:0,nt=ke?ce:et-S[ut]-P[ut]-ie+w.altAxis,sr=ke?et+S[ut]+P[ut]-ie-w.altAxis:Te,lr=f&&ke?a5(nt,et,sr):bi(f?nt:ce,et,f?sr:Te);C[M]=lr,A[M]=lr-et}t.modifiersData[o]=A}}a(q0,"preventOverflow");var y5={name:"preventOverflow",enabled:!0,phase:"main",fn:q0,requiresIfExists:["offset"]};function Ym(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}a(Ym,"getHTMLElementScroll");function Qm(e){return e===qe(e)||!Tt(e)?yi(e):Ym(e)}a(Qm,"getNodeScroll");function J0(e){var t=e.getBoundingClientRect(),r=an(t.width)/e.offsetWidth||1,o=an(t.height)/e.offsetHeight||1;return r!==1||o!==1}a(J0,"isElementScaled");function ep(e,t,r){r===void 0&&(r=!1);var o=Tt(t),n=Tt(t)&&J0(t),i=$t(t),s=eo(e,n,r),l={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(o||!o&&!r)&&((Rt(t)!=="body"||Ci(i))&&(l=Qm(t)),Tt(t)?(c=eo(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):i&&(c.x=vi(i))),{x:s.left+l.scrollLeft-c.x,y:s.top+l.scrollTop-c.y,width:s.width,height:s.height}}a(ep,"getCompositeRect");function K0(e){var t=new Map,r=new Set,o=[];e.forEach(function(i){t.set(i.name,i)});function n(i){r.add(i.name);var s=[].concat(i.requires||[],i.requiresIfExists||[]);s.forEach(function(l){if(!r.has(l)){var c=t.get(l);c&&n(c)}}),o.push(i)}return a(n,"sort"),e.forEach(function(i){r.has(i.name)||n(i)}),o}a(K0,"order");function tp(e){var t=K0(e);return n5.reduce(function(r,o){return r.concat(t.filter(function(n){return n.phase===o}))},[])}a(tp,"orderModifiers");function rp(e){var t;return function(){return t||(t=new Promise(function(r){Promise.resolve().then(function(){t=void 0,r(e())})})),t}}a(rp,"debounce");function op(e){var t=e.reduce(function(r,o){var n=r[o.name];return r[o.name]=n?Object.assign({},n,o,{options:Object.assign({},n.options,o.options),data:Object.assign({},n.data,o.data)}):o,r},{});return Object.keys(t).map(function(r){return t[r]})}a(op,"mergeByName");var v5={placement:"bottom",modifiers:[],strategy:"absolute"};function C5(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return!t.some(function(o){return!(o&&typeof o.getBoundingClientRect=="function")})}a(C5,"areValidElements");function x5(e){e===void 0&&(e={});var t=e,r=t.defaultModifiers,o=r===void 0?[]:r,n=t.defaultOptions,i=n===void 0?v5:n;return a(function(l,c,u){u===void 0&&(u=i);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},v5,i),modifiersData:{},elements:{reference:l,popper:c},attributes:{},styles:{}},p=[],m=!1,f={state:d,setOptions:a(function(x){var E=typeof x=="function"?x(d.options):x;h(),d.options=Object.assign({},i,d.options,E),d.scrollParents={reference:Qr(l)?In(l):l.contextElement?In(l.contextElement):[],popper:In(c)};var g=tp(op([].concat(o,d.options.modifiers)));return d.orderedModifiers=g.filter(function(b){return b.enabled}),v(),f.update()},"setOptions"),forceUpdate:a(function(){if(!m){var x=d.elements,E=x.reference,g=x.popper;if(C5(E,g)){d.rects={reference:ep(E,fo(g),d.options.strategy==="fixed"),popper:gi(g)},d.reset=!1,d.placement=d.options.placement,d.orderedModifiers.forEach(function(w){return d.modifiersData[w.name]=Object.assign({},w.data)});for(var b=0;b<d.orderedModifiers.length;b++){if(d.reset===!0){d.reset=!1,b=-1;continue}var M=d.orderedModifiers[b],C=M.fn,S=M.options,P=S===void 0?{}:S,k=M.name;typeof C=="function"&&(d=C({state:d,options:P,name:k,instance:f})||d)}}}},"forceUpdate"),update:rp(function(){return new Promise(function(y){f.forceUpdate(),y(d)})}),destroy:a(function(){h(),m=!0},"destroy")};if(!C5(l,c))return f;f.setOptions(u).then(function(y){!m&&u.onFirstUpdate&&u.onFirstUpdate(y)});function v(){d.orderedModifiers.forEach(function(y){var x=y.name,E=y.options,g=E===void 0?{}:E,b=y.effect;if(typeof b=="function"){var M=b({state:d,name:x,instance:f,options:g}),C=a(function(){},"noopFn");p.push(M||C)}})}a(v,"runModifierEffects");function h(){p.forEach(function(y){return y()}),p=[]}return a(h,"cleanupModifierEffects"),f},"createPopper")}a(x5,"popperGenerator");var G0=[u5,b5,c5,Ns,h5,m5,y5,s5,g5],np=x5({defaultModifiers:G0});var X0="tippy-box",I5="tippy-content",Y0="tippy-backdrop",R5="tippy-arrow",L5="tippy-svg-arrow",xi={passive:!0,capture:!0},B5=a(function(){return document.body},"TIPPY_DEFAULT_APPEND_TO");function ip(e,t,r){if(Array.isArray(e)){var o=e[t];return o==null?Array.isArray(r)?r[t]:r:o}return e}a(ip,"getValueAtIndexOrReturn");function dp(e,t){var r={}.toString.call(e);return r.indexOf("[object")===0&&r.indexOf(t+"]")>-1}a(dp,"isType");function D5(e,t){return typeof e=="function"?e.apply(void 0,t):e}a(D5,"invokeWithArgsOrReturn");function T5(e,t){if(t===0)return e;var r;return function(o){clearTimeout(r),r=setTimeout(function(){e(o)},t)}}a(T5,"debounce");function Q0(e){return e.split(/\s+/).filter(Boolean)}a(Q0,"splitBySpaces");function va(e){return[].concat(e)}a(va,"normalizeToArray");function E5(e,t){e.indexOf(t)===-1&&e.push(t)}a(E5,"pushIfUnique");function ev(e){return e.filter(function(t,r){return e.indexOf(t)===r})}a(ev,"unique");function tv(e){return e.split("-")[0]}a(tv,"getBasePlacement");function Tc(e){return[].slice.call(e)}a(Tc,"arrayFrom");function w5(e){return Object.keys(e).reduce(function(t,r){return e[r]!==void 0&&(t[r]=e[r]),t},{})}a(w5,"removeUndefinedProps");function Hs(){return document.createElement("div")}a(Hs,"div");function Ec(e){return["Element","Fragment"].some(function(t){return dp(e,t)})}a(Ec,"isElement");function rv(e){return dp(e,"NodeList")}a(rv,"isNodeList");function ov(e){return dp(e,"MouseEvent")}a(ov,"isMouseEvent");function nv(e){return!!(e&&e._tippy&&e._tippy.reference===e)}a(nv,"isReferenceElement");function iv(e){return Ec(e)?[e]:rv(e)?Tc(e):Array.isArray(e)?e:Tc(document.querySelectorAll(e))}a(iv,"getArrayOfElements");function ap(e,t){e.forEach(function(r){r&&(r.style.transitionDuration=t+"ms")})}a(ap,"setTransitionDuration");function k5(e,t){e.forEach(function(r){r&&r.setAttribute("data-state",t)})}a(k5,"setVisibilityState");function av(e){var t,r=va(e),o=r[0];return o!=null&&(t=o.ownerDocument)!=null&&t.body?o.ownerDocument:document}a(av,"getOwnerDocument");function sv(e,t){var r=t.clientX,o=t.clientY;return e.every(function(n){var i=n.popperRect,s=n.popperState,l=n.props,c=l.interactiveBorder,u=tv(s.placement),d=s.modifiersData.offset;if(!d)return!0;var p=u==="bottom"?d.top.y:0,m=u==="top"?d.bottom.y:0,f=u==="right"?d.left.x:0,v=u==="left"?d.right.x:0,h=i.top-o+p>c,y=o-i.bottom-m>c,x=i.left-r+f>c,E=r-i.right-v>c;return h||y||x||E})}a(sv,"isCursorOutsideInteractiveBorder");function sp(e,t,r){var o=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){e[o](n,r)})}a(sp,"updateTransitionEndListener");function P5(e,t){for(var r=t;r;){var o;if(e.contains(r))return!0;r=r.getRootNode==null||(o=r.getRootNode())==null?void 0:o.host}return!1}a(P5,"actualContains");var zo={isTouch:!1},A5=0;function lv(){zo.isTouch||(zo.isTouch=!0,window.performance&&document.addEventListener("mousemove",H5))}a(lv,"onDocumentTouchStart");function H5(){var e=performance.now();e-A5<20&&(zo.isTouch=!1,document.removeEventListener("mousemove",H5)),A5=e}a(H5,"onDocumentMouseMove");function cv(){var e=document.activeElement;if(nv(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}a(cv,"onWindowBlur");function uv(){document.addEventListener("touchstart",lv,xi),window.addEventListener("blur",cv)}a(uv,"bindGlobalEventListeners");var dv=typeof window!="undefined"&&typeof document!="undefined",mv=dv?!!window.msCrypto:!1;var pv={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},fv={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},ho=Object.assign({appendTo:B5,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:a(function(){},"onAfterUpdate"),onBeforeUpdate:a(function(){},"onBeforeUpdate"),onCreate:a(function(){},"onCreate"),onDestroy:a(function(){},"onDestroy"),onHidden:a(function(){},"onHidden"),onHide:a(function(){},"onHide"),onMount:a(function(){},"onMount"),onShow:a(function(){},"onShow"),onShown:a(function(){},"onShown"),onTrigger:a(function(){},"onTrigger"),onUntrigger:a(function(){},"onUntrigger"),onClickOutside:a(function(){},"onClickOutside"),placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},pv,fv),gv=Object.keys(ho),hv=a(function(t){var r=Object.keys(t);r.forEach(function(o){ho[o]=t[o]})},"setDefaultProps");function V5(e){var t=e.plugins||[],r=t.reduce(function(o,n){var i=n.name,s=n.defaultValue;if(i){var l;o[i]=e[i]!==void 0?e[i]:(l=ho[i])!=null?l:s}return o},{});return Object.assign({},e,r)}a(V5,"getExtendedPassedProps");function bv(e,t){var r=t?Object.keys(V5(Object.assign({},ho,{plugins:t}))):gv,o=r.reduce(function(n,i){var s=(e.getAttribute("data-tippy-"+i)||"").trim();if(!s)return n;if(i==="content")n[i]=s;else try{n[i]=JSON.parse(s)}catch{n[i]=s}return n},{});return o}a(bv,"getDataAttributeProps");function M5(e,t){var r=Object.assign({},t,{content:D5(t.content,[e])},t.ignoreAttributes?{}:bv(e,t.plugins));return r.aria=Object.assign({},ho.aria,r.aria),r.aria={expanded:r.aria.expanded==="auto"?t.interactive:r.aria.expanded,content:r.aria.content==="auto"?t.interactive?null:"describedby":r.aria.content},r}a(M5,"evaluateProps");var yv=a(function(){return"innerHTML"},"innerHTML");function cp(e,t){e[yv()]=t}a(cp,"dangerouslySetInnerHTML");function N5(e){var t=Hs();return e===!0?t.className=R5:(t.className=L5,Ec(e)?t.appendChild(e):cp(t,e)),t}a(N5,"createArrowElement");function S5(e,t){Ec(t.content)?(cp(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?cp(e,t.content):e.textContent=t.content)}a(S5,"setContent");function up(e){var t=e.firstElementChild,r=Tc(t.children);return{box:t,content:r.find(function(o){return o.classList.contains(I5)}),arrow:r.find(function(o){return o.classList.contains(R5)||o.classList.contains(L5)}),backdrop:r.find(function(o){return o.classList.contains(Y0)})}}a(up,"getChildren");function F5(e){var t=Hs(),r=Hs();r.className=X0,r.setAttribute("data-state","hidden"),r.setAttribute("tabindex","-1");var o=Hs();o.className=I5,o.setAttribute("data-state","hidden"),S5(o,e.props),t.appendChild(r),r.appendChild(o),n(e.props,e.props);function n(i,s){var l=up(t),c=l.box,u=l.content,d=l.arrow;s.theme?c.setAttribute("data-theme",s.theme):c.removeAttribute("data-theme"),typeof s.animation=="string"?c.setAttribute("data-animation",s.animation):c.removeAttribute("data-animation"),s.inertia?c.setAttribute("data-inertia",""):c.removeAttribute("data-inertia"),c.style.maxWidth=typeof s.maxWidth=="number"?s.maxWidth+"px":s.maxWidth,s.role?c.setAttribute("role",s.role):c.removeAttribute("role"),(i.content!==s.content||i.allowHTML!==s.allowHTML)&&S5(u,e.props),s.arrow?d?i.arrow!==s.arrow&&(c.removeChild(d),c.appendChild(N5(s.arrow))):c.appendChild(N5(s.arrow)):d&&c.removeChild(d)}return a(n,"onUpdate"),{popper:t,onUpdate:n}}a(F5,"render");F5.$$tippy=!0;var vv=1,xc=[],lp=[];function Cv(e,t){var r=M5(e,Object.assign({},ho,V5(w5(t)))),o,n,i,s=!1,l=!1,c=!1,u=!1,d,p,m,f=[],v=T5(Ht,r.interactiveDebounce),h,y=vv++,x=null,E=ev(r.plugins),g={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},b={id:y,reference:e,popper:Hs(),popperInstance:x,props:r,state:g,plugins:E,clearDelayTimeouts:nt,setProps:sr,setContent:lr,show:Ro,hide:Lo,hideWithInteractivity:jn,enable:ke,disable:ie,unmount:Zn,destroy:qn};if(!r.render)return b;var M=r.render(b),C=M.popper,S=M.onUpdate;C.setAttribute("data-tippy-root",""),C.id="tippy-"+b.id,b.popper=C,e._tippy=b,C._tippy=b;var P=E.map(function(O){return O.fn(b)}),k=e.hasAttribute("aria-expanded");return Me(),W(),D(),F("onCreate",[b]),r.showOnCreate&&ce(),C.addEventListener("mouseenter",function(){b.props.interactive&&b.state.isVisible&&b.clearDelayTimeouts()}),C.addEventListener("mouseleave",function(){b.props.interactive&&b.props.trigger.indexOf("mouseenter")>=0&&R().addEventListener("mousemove",v)}),b;function w(){var O=b.props.touch;return Array.isArray(O)?O:[O,0]}a(w,"getNormalizedTouchSettings");function T(){return w()[0]==="hold"}a(T,"getIsCustomTouchBehavior");function A(){var O;return!!((O=b.props.render)!=null&&O.$$tippy)}a(A,"getIsDefaultRenderFn");function N(){return h||e}a(N,"getCurrentTarget");function R(){var O=N().parentNode;return O?av(O):document}a(R,"getDocument");function B(){return up(C)}a(B,"getDefaultTemplateChildren");function H(O){return b.state.isMounted&&!b.state.isVisible||zo.isTouch||d&&d.type==="focus"?0:ip(b.props.delay,O?0:1,ho.delay)}a(H,"getDelay");function D(O){O===void 0&&(O=!1),C.style.pointerEvents=b.props.interactive&&!O?"":"none",C.style.zIndex=""+b.props.zIndex}a(D,"handleStyles");function F(O,z,$){if($===void 0&&($=!0),P.forEach(function(ee){ee[O]&&ee[O].apply(ee,z)}),$){var Y;(Y=b.props)[O].apply(Y,z)}}a(F,"invokeHook");function L(){var O=b.props.aria;if(O.content){var z="aria-"+O.content,$=C.id,Y=va(b.props.triggerTarget||e);Y.forEach(function(ee){var fe=ee.getAttribute(z);if(b.state.isVisible)ee.setAttribute(z,fe?fe+" "+$:$);else{var $e=fe&&fe.replace($,"").trim();$e?ee.setAttribute(z,$e):ee.removeAttribute(z)}})}}a(L,"handleAriaContentAttribute");function W(){if(!(k||!b.props.aria.expanded)){var O=va(b.props.triggerTarget||e);O.forEach(function(z){b.props.interactive?z.setAttribute("aria-expanded",b.state.isVisible&&z===N()?"true":"false"):z.removeAttribute("aria-expanded")})}}a(W,"handleAriaExpandedAttribute");function _(){R().removeEventListener("mousemove",v),xc=xc.filter(function(O){return O!==v})}a(_,"cleanupInteractiveMouseListeners");function V(O){if(!(zo.isTouch&&(c||O.type==="mousedown"))){var z=O.composedPath&&O.composedPath()[0]||O.target;if(!(b.props.interactive&&P5(C,z))){if(va(b.props.triggerTarget||e).some(function($){return P5($,z)})){if(zo.isTouch||b.state.isVisible&&b.props.trigger.indexOf("click")>=0)return}else F("onClickOutside",[b,O]);b.props.hideOnClick===!0&&(b.clearDelayTimeouts(),b.hide(),l=!0,setTimeout(function(){l=!1}),b.state.isMounted||X())}}}a(V,"onDocumentPress");function j(){c=!0}a(j,"onTouchMove");function J(){c=!1}a(J,"onTouchStart");function G(){var O=R();O.addEventListener("mousedown",V,!0),O.addEventListener("touchend",V,xi),O.addEventListener("touchstart",J,xi),O.addEventListener("touchmove",j,xi)}a(G,"addDocumentPress");function X(){var O=R();O.removeEventListener("mousedown",V,!0),O.removeEventListener("touchend",V,xi),O.removeEventListener("touchstart",J,xi),O.removeEventListener("touchmove",j,xi)}a(X,"removeDocumentPress");function U(O,z){de(O,function(){!b.state.isVisible&&C.parentNode&&C.parentNode.contains(C)&&z()})}a(U,"onTransitionedOut");function K(O,z){de(O,z)}a(K,"onTransitionedIn");function de(O,z){var $=B().box;function Y(ee){ee.target===$&&(sp($,"remove",Y),z())}if(a(Y,"listener"),O===0)return z();sp($,"remove",p),sp($,"add",Y),p=Y}a(de,"onTransitionEnd");function me(O,z,$){$===void 0&&($=!1);var Y=va(b.props.triggerTarget||e);Y.forEach(function(ee){ee.addEventListener(O,z,$),f.push({node:ee,eventType:O,handler:z,options:$})})}a(me,"on");function Me(){T()&&(me("touchstart",Pt,{passive:!0}),me("touchend",ar,{passive:!0})),Q0(b.props.trigger).forEach(function(O){if(O!=="manual")switch(me(O,Pt),O){case"mouseenter":me("mouseleave",ar);break;case"focus":me(mv?"focusout":"blur",Vt);break;case"focusin":me("focusout",Vt);break}})}a(Me,"addListeners");function We(){f.forEach(function(O){var z=O.node,$=O.eventType,Y=O.handler,ee=O.options;z.removeEventListener($,Y,ee)}),f=[]}a(We,"removeListeners");function Pt(O){var z,$=!1;if(!(!b.state.isEnabled||Yt(O)||l)){var Y=((z=d)==null?void 0:z.type)==="focus";d=O,h=O.currentTarget,W(),!b.state.isVisible&&ov(O)&&xc.forEach(function(ee){return ee(O)}),O.type==="click"&&(b.props.trigger.indexOf("mouseenter")<0||s)&&b.props.hideOnClick!==!1&&b.state.isVisible?$=!0:ce(O),O.type==="click"&&(s=!$),$&&!Y&&Te(O)}}a(Pt,"onTrigger");function Ht(O){var z=O.target,$=N().contains(z)||C.contains(z);if(!(O.type==="mousemove"&&$)){var Y=ut().concat(C).map(function(ee){var fe,$e=ee._tippy,Ue=(fe=$e.popperInstance)==null?void 0:fe.state;return Ue?{popperRect:ee.getBoundingClientRect(),popperState:Ue,props:r}:null}).filter(Boolean);sv(Y,O)&&(_(),Te(O))}}a(Ht,"onMouseMove");function ar(O){var z=Yt(O)||b.props.trigger.indexOf("click")>=0&&s;if(!z){if(b.props.interactive){b.hideWithInteractivity(O);return}Te(O)}}a(ar,"onMouseLeave");function Vt(O){b.props.trigger.indexOf("focusin")<0&&O.target!==N()||b.props.interactive&&O.relatedTarget&&C.contains(O.relatedTarget)||Te(O)}a(Vt,"onBlurOrFocusOut");function Yt(O){return zo.isTouch?T()!==O.type.indexOf("touch")>=0:!1}a(Yt,"isEventListenerStopped");function At(){Qt();var O=b.props,z=O.popperOptions,$=O.placement,Y=O.offset,ee=O.getReferenceClientRect,fe=O.moveTransition,$e=A()?up(C).arrow:null,Ue=ee?{getBoundingClientRect:ee,contextElement:ee.contextElement||N()}:e,Jn={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:a(function(ol){var Bi=ol.state;if(A()){var q2=B(),ed=q2.box;["placement","reference-hidden","escaped"].forEach(function(nl){nl==="placement"?ed.setAttribute("data-placement",Bi.placement):Bi.attributes.popper["data-popper-"+nl]?ed.setAttribute("data-"+nl,""):ed.removeAttribute("data-"+nl)}),Bi.attributes.popper={}}},"fn")},Kn=[{name:"offset",options:{offset:Y}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!fe}},Jn];A()&&$e&&Kn.push({name:"arrow",options:{element:$e,padding:3}}),Kn.push.apply(Kn,(z==null?void 0:z.modifiers)||[]),b.popperInstance=np(Ue,C,Object.assign({},z,{placement:$,onFirstUpdate:m,modifiers:Kn}))}a(At,"createPopperInstance");function Qt(){b.popperInstance&&(b.popperInstance.destroy(),b.popperInstance=null)}a(Qt,"destroyPopperInstance");function et(){var O=b.props.appendTo,z,$=N();b.props.interactive&&O===B5||O==="parent"?z=$.parentNode:z=D5(O,[$]),z.contains(C)||z.appendChild(C),b.state.isMounted=!0,At()}a(et,"mount");function ut(){return Tc(C.querySelectorAll("[data-tippy-root]"))}a(ut,"getNestedPopperTree");function ce(O){b.clearDelayTimeouts(),O&&F("onTrigger",[b,O]),G();var z=H(!0),$=w(),Y=$[0],ee=$[1];zo.isTouch&&Y==="hold"&&ee&&(z=ee),z?o=setTimeout(function(){b.show()},z):b.show()}a(ce,"scheduleShow");function Te(O){if(b.clearDelayTimeouts(),F("onUntrigger",[b,O]),!b.state.isVisible){X();return}if(!(b.props.trigger.indexOf("mouseenter")>=0&&b.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(O.type)>=0&&s)){var z=H(!1);z?n=setTimeout(function(){b.state.isVisible&&b.hide()},z):i=requestAnimationFrame(function(){b.hide()})}}a(Te,"scheduleHide");function ke(){b.state.isEnabled=!0}a(ke,"enable");function ie(){b.hide(),b.state.isEnabled=!1}a(ie,"disable");function nt(){clearTimeout(o),clearTimeout(n),cancelAnimationFrame(i)}a(nt,"clearDelayTimeouts");function sr(O){if(!b.state.isDestroyed){F("onBeforeUpdate",[b,O]),We();var z=b.props,$=M5(e,Object.assign({},z,w5(O),{ignoreAttributes:!0}));b.props=$,Me(),z.interactiveDebounce!==$.interactiveDebounce&&(_(),v=T5(Ht,$.interactiveDebounce)),z.triggerTarget&&!$.triggerTarget?va(z.triggerTarget).forEach(function(Y){Y.removeAttribute("aria-expanded")}):$.triggerTarget&&e.removeAttribute("aria-expanded"),W(),D(),S&&S(z,$),b.popperInstance&&(At(),ut().forEach(function(Y){requestAnimationFrame(Y._tippy.popperInstance.forceUpdate)})),F("onAfterUpdate",[b,O])}}a(sr,"setProps");function lr(O){b.setProps({content:O})}a(lr,"setContent");function Ro(){var O=b.state.isVisible,z=b.state.isDestroyed,$=!b.state.isEnabled,Y=zo.isTouch&&!b.props.touch,ee=ip(b.props.duration,0,ho.duration);if(!(O||z||$||Y)&&!N().hasAttribute("disabled")&&(F("onShow",[b],!1),b.props.onShow(b)!==!1)){if(b.state.isVisible=!0,A()&&(C.style.visibility="visible"),D(),G(),b.state.isMounted||(C.style.transition="none"),A()){var fe=B(),$e=fe.box,Ue=fe.content;ap([$e,Ue],0)}m=a(function(){var Kn;if(!(!b.state.isVisible||u)){if(u=!0,C.offsetHeight,C.style.transition=b.props.moveTransition,A()&&b.props.animation){var Qu=B(),ol=Qu.box,Bi=Qu.content;ap([ol,Bi],ee),k5([ol,Bi],"visible")}L(),W(),E5(lp,b),(Kn=b.popperInstance)==null||Kn.forceUpdate(),F("onMount",[b]),b.props.animation&&A()&&K(ee,function(){b.state.isShown=!0,F("onShown",[b])})}},"onFirstUpdate"),et()}}a(Ro,"show");function Lo(){var O=!b.state.isVisible,z=b.state.isDestroyed,$=!b.state.isEnabled,Y=ip(b.props.duration,1,ho.duration);if(!(O||z||$)&&(F("onHide",[b],!1),b.props.onHide(b)!==!1)){if(b.state.isVisible=!1,b.state.isShown=!1,u=!1,s=!1,A()&&(C.style.visibility="hidden"),_(),X(),D(!0),A()){var ee=B(),fe=ee.box,$e=ee.content;b.props.animation&&(ap([fe,$e],Y),k5([fe,$e],"hidden"))}L(),W(),b.props.animation?A()&&U(Y,b.unmount):b.unmount()}}a(Lo,"hide");function jn(O){R().addEventListener("mousemove",v),E5(xc,v),v(O)}a(jn,"hideWithInteractivity");function Zn(){b.state.isVisible&&b.hide(),b.state.isMounted&&(Qt(),ut().forEach(function(O){O._tippy.unmount()}),C.parentNode&&C.parentNode.removeChild(C),lp=lp.filter(function(O){return O!==b}),b.state.isMounted=!1,F("onHidden",[b]))}a(Zn,"unmount");function qn(){b.state.isDestroyed||(b.clearDelayTimeouts(),b.unmount(),We(),delete e._tippy,b.state.isDestroyed=!0,F("onDestroy",[b]))}a(qn,"destroy")}a(Cv,"createTippy");function Vs(e,t){t===void 0&&(t={});var r=ho.plugins.concat(t.plugins||[]);uv();var o=Object.assign({},t,{plugins:r}),n=iv(e);if(0)var i,s;var l=n.reduce(function(c,u){var d=u&&Cv(u,o);return d&&c.push(d),c},[]);return Ec(e)?l[0]:l}a(Vs,"tippy");Vs.defaultProps=ho;Vs.setDefaultProps=hv;Vs.currentInput=zo;var MS=Object.assign({},Ns,{effect:a(function(t){var r=t.state,o={popper:{position:r.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(r.elements.popper.style,o.popper),r.styles=o,r.elements.arrow&&Object.assign(r.elements.arrow.style,o.arrow)},"effect")});Vs.setDefaultProps({render:F5});var O5=Vs;var mp=require("react/jsx-runtime"),W5=a(({items:e,command:t,selected:r=0})=>e.length===0?null:(0,mp.jsx)("div",{className:"courier-bg-white dark:courier-bg-gray-800 courier-rounded-md courier-shadow-lg courier-border courier-border-border courier-max-h-60 courier-overflow-y-auto courier-z-50",children:e.map((o,n)=>(0,mp.jsx)("button",{className:I("courier-w-full courier-px-4 courier-py-2 courier-text-left courier-text-sm hover:courier-bg-gray-100 dark:hover:courier-bg-gray-700 focus:courier-bg-gray-100 dark:focus:courier-bg-gray-700 focus:courier-outline-none",n===r?"courier-bg-gray-100 dark:courier-bg-gray-700":""),onClick:()=>t(o),children:o},n))}),"VariableSuggestions");var bo={items:({query:e,editor:t})=>{var n,i;let r=((i=(n=t.extensionManager.extensions.find(s=>s.name==="variableSuggestion"))==null?void 0:n.options)==null?void 0:i.variables)||{};return tn(r).filter(s=>s.toLowerCase().includes(e.toLowerCase()))},char:"{{",allowSpaces:!1,allowedPrefixes:null,startOfLine:!1,decorationTag:"span",decorationClass:"variable-suggestion",command:({editor:e,range:t,props:r})=>{e.chain().focus().deleteRange(t).insertContent([{type:"variable",attrs:{id:r,isInvalid:!1}},{type:"text",text:" "}]).run()},render:()=>{let e=null,t=null,r=null,o=a((i,s)=>{e==null||e.updateProps({...i,selected:s})},"updateComponent"),n=a(i=>{var c,u;if(!r)return!1;let l=((c=bo.items)==null?void 0:c.call(bo,{query:(e==null?void 0:e.props).query||"",editor:(e==null?void 0:e.props).editor}))[i];return l?((u=bo.command)==null||u.call(bo,{editor:r.editor,range:r.range,props:l}),!0):!1},"selectItem");return{onStart:i=>{r=i,e=new U5.ReactRenderer(W5,{props:{...i,selected:0},editor:i.editor}),i.clientRect&&(t=O5(i.editor.options.element,{getReferenceClientRect:()=>{var s;return((s=i.clientRect)==null?void 0:s.call(i))||new DOMRect},appendTo:()=>i.editor.options.element,content:e==null?void 0:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",theme:"variable"}),e!=null&&e.element&&e.element.focus())},onUpdate(i){r=i,e==null||e.updateProps({...i,selected:e.props.selected}),i.clientRect&&(t==null||t.setProps({getReferenceClientRect:()=>{var s;return((s=i.clientRect)==null?void 0:s.call(i))||new DOMRect}}))},onKeyDown(i){var c;if(!e||!r)return!1;let s=(c=bo.items)==null?void 0:c.call(bo,{query:e.props.query||"",editor:e.props.editor}),l=e.props.selected;if(i.event.key==="ArrowUp"){let u=(l-1+s.length)%s.length;return o(r,u),!0}if(i.event.key==="ArrowDown"){let u=(l+1)%s.length;return o(r,u),!0}return i.event.key==="Enter"?(i.event.preventDefault(),n(l)):i.event.key==="Escape"?(r.editor.chain().focus().deleteRange(r.range).run(),!0):!1},onExit(){t==null||t.destroy(),e==null||e.destroy(),r=null}}}};var j5=require("@tiptap/react"),Z5=require("jotai"),Rn=require("react");var wc=require("jotai"),_e=require("react"),z5=require("react-dom"),$5=require("sonner");var Ca=require("react");var pp=require("react/jsx-runtime"),_5=a(({items:e,onSelect:t,selectedIndex:r,anchorRef:o})=>{let n=(0,Ca.useRef)(null),i=(0,Ca.useRef)(null);return(0,Ca.useEffect)(()=>{i.current&&i.current.scrollIntoView({block:"nearest"})},[r]),(0,Ca.useEffect)(()=>{if(!n.current||!o.current)return;let s=o.current,l=n.current,c=s.getBoundingClientRect();l.style.position="fixed",l.style.left=`${c.left}px`,l.style.top=`${c.bottom+4}px`},[o,e]),e.length===0?null:(0,pp.jsx)("div",{ref:n,className:"courier-bg-white dark:courier-bg-gray-800 courier-rounded-md courier-shadow-lg courier-border courier-border-border courier-max-h-60 courier-overflow-y-auto courier-z-[9999]",style:{position:"fixed",width:"max-content",minWidth:"160px",maxWidth:"280px"},children:e.map((s,l)=>(0,pp.jsx)("button",{ref:l===r?i:void 0,className:I("courier-w-full courier-px-3 courier-py-1.5 courier-text-left courier-text-sm hover:courier-bg-gray-100 dark:hover:courier-bg-gray-700 focus:courier-bg-gray-100 dark:focus:courier-bg-gray-700 focus:courier-outline-none courier-truncate",l===r?"courier-bg-gray-100 dark:courier-bg-gray-700":""),onClick:c=>{c.preventDefault(),c.stopPropagation(),t(s)},onMouseDown:c=>{c.preventDefault()},title:s,children:s},s))})},"VariableAutocomplete");var ln=require("react/jsx-runtime"),fp=50,gp=24,kc=a(({variableId:e,isInvalid:t,onUpdateAttributes:r,onDelete:o,icon:n,value:i,singleClickToEdit:s=!1,className:l,textColorOverride:c,getColors:u})=>{var F;let[d,p]=(0,_e.useState)(!1),[m,f]=(0,_e.useState)(""),[v,h]=(0,_e.useState)(0),y=(0,_e.useRef)(null),x=(0,_e.useRef)(null),E=(0,wc.useAtomValue)(Ui),g=(0,wc.useAtomValue)(ll),b=(0,wc.useAtomValue)(cl),M=(0,_e.useMemo)(()=>b||!g||Object.keys(g).length===0?[]:tn(g),[g,b]),C=(0,_e.useMemo)(()=>M.length===0?[]:m?M.filter(L=>L.toLowerCase().includes(m.toLowerCase())):M,[M,m]),S=d&&C.length>0;(0,_e.useEffect)(()=>{e===""&&!d&&(p(!0),f(""),h(0))},[e,d]),(0,_e.useEffect)(()=>{!e||d||M.length>0&&!M.includes(e)&&(t||queueMicrotask(()=>{r({id:e,isInvalid:!0})}))},[e,M,t,d,r]),(0,_e.useEffect)(()=>{if(d&&y.current){let L=y.current;L.textContent=e,L.focus(),requestAnimationFrame(()=>{if(L&&L.isConnected){let W=document.createRange();W.selectNodeContents(L),W.collapse(!1);let _=window.getSelection();_==null||_.removeAllRanges(),_==null||_.addRange(W)}})}},[d,e]);let P=(0,_e.useCallback)(()=>{var _,V;p(!1);let L=(((_=y.current)==null?void 0:_.textContent)||"").trim();if(L===""){o();return}let W=!0;if(E!=null&&E.overrideFormatValidation?E.validate&&(W=E.validate(L)):(W=Ot(L),W&&(E!=null&&E.validate)&&(W=E.validate(L))),W&&M.length>0&&(W=M.includes(L)),!W){let j=(V=E==null?void 0:E.onInvalid)!=null?V:"mark";if(E!=null&&E.invalidMessage){let J=typeof E.invalidMessage=="function"?E.invalidMessage(L):E.invalidMessage;$5.toast.error(J)}if(j==="remove"){o();return}r({id:L,isInvalid:!0});return}r({id:L,isInvalid:!1})},[o,r,E,M]),k=(0,_e.useCallback)(L=>{y.current&&(y.current.textContent=L),f(""),p(!1),r({id:L,isInvalid:!1})},[r]),w=(0,_e.useCallback)(L=>{var W,_;if(S){if(L.key==="ArrowDown"){L.preventDefault(),h(V=>(V+1)%C.length);return}if(L.key==="ArrowUp"){L.preventDefault(),h(V=>(V-1+C.length)%C.length);return}if(L.key==="Enter"){L.preventDefault();let V=C[v];V?k(V):(W=y.current)==null||W.blur();return}if(L.key==="Tab"){L.preventDefault();let V=C[v];V&&k(V);return}}else if(L.key==="Enter"){L.preventDefault(),(_=y.current)==null||_.blur();return}L.key==="Escape"&&(L.preventDefault(),y.current&&(y.current.textContent=e),p(!1),f(""),e===""&&o())},[e,o,S,C,v,k]),T=(0,_e.useCallback)(()=>{if(y.current){let L=y.current.textContent||"";if(L.length>fp){L=L.slice(0,fp),y.current.textContent=L;let W=document.createRange();W.selectNodeContents(y.current),W.collapse(!1);let _=window.getSelection();_==null||_.removeAllRanges(),_==null||_.addRange(W)}f(L),h(0)}},[]),A=(0,_e.useCallback)(L=>{L.preventDefault();let W=L.clipboardData.getData("text/plain").slice(0,fp),_=window.getSelection();if(_&&_.rangeCount>0){let V=_.getRangeAt(0);V.deleteContents();let j=document.createTextNode(W);V.insertNode(j),V.setStartAfter(j),V.setEndAfter(j),_.removeAllRanges(),_.addRange(V),T()}},[T]),N=(0,_e.useCallback)(L=>{L.stopPropagation(),d||p(!0)},[d]),R=(0,_e.useMemo)(()=>{let L=e,W=i?`="${i}"`:"",_=`${L}${W}`,V=L.length>gp;return{displayText:`${V?`${L.slice(0,gp)}\u2026`:L}${W}`,fullText:_,showTitle:V}},[e,i]);(0,_e.useEffect)(()=>{y.current&&!d&&(y.current.textContent=R.displayText)},[R.displayText,d]);let B=(0,_e.useCallback)(L=>{L.stopPropagation()},[]),H=(0,_e.useCallback)(L=>{L.stopPropagation()},[]),D=s?{onClick:N}:{onClick:H,onDoubleClick:N};return(0,ln.jsxs)(ln.Fragment,{children:[(0,ln.jsxs)("span",{ref:x,className:I("courier-variable-chip",!t&&i&&"courier-variable-chip-has-value",t&&"courier-variable-chip-invalid",l),style:{direction:"ltr"},onMouseDown:B,...D,title:R.showTitle?R.fullText:void 0,children:[(0,ln.jsx)("span",{className:"courier-flex-shrink-0 courier-flex courier-items-center courier-pt-0.5",children:n}),(0,ln.jsx)("span",{ref:y,role:"textbox",contentEditable:d,suppressContentEditableWarning:!0,onBlur:P,onKeyDown:w,onInput:T,onPaste:A,onMouseDown:B,...s?{onClick:N}:{onClick:H,onDoubleClick:N},className:I("courier-outline-none courier-min-w-[1ch]",!d&&"courier-cursor-text"),style:{...c&&{color:c},maxWidth:`${gp}ch`,overflow:"hidden",textOverflow:d?"clip":"ellipsis",whiteSpace:"nowrap",direction:"ltr",unicodeBidi:"isolate"},children:!d&&R.displayText})]}),S&&(0,z5.createPortal)((0,ln.jsx)(_5,{items:C,onSelect:k,selectedIndex:v,anchorRef:x}),((F=x.current)==null?void 0:F.closest(".theme-container"))||document.body)]})},"VariableChipBase");var Fs=require("react/jsx-runtime"),Pc=a(({color:e="#1D4ED8"})=>(0,Fs.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,Fs.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,Fs.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableIcon");var Ac=require("react/jsx-runtime"),q5=a(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=(0,Z5.useAtomValue)(Xn),i=e.attrs.id||"",s=n[i],l=e.attrs.isInvalid,[c,u]=(0,Rn.useState)(!1),d=(0,Rn.useCallback)(()=>{if(typeof r=="function")try{let h=r();if(h==null){u(!1);return}let x=t.state.doc.resolve(h).parent;u(x&&x.type.name==="button")}catch{u(!1)}else u(!1)},[t,r]);(0,Rn.useEffect)(()=>{d();let h=a(()=>{d()},"handleUpdate");return t.on("update",h),t.on("selectionUpdate",h),()=>{t.off("update",h),t.off("selectionUpdate",h)}},[t,d]);let p=(0,Rn.useCallback)(h=>{o(h)},[o]),m=(0,Rn.useCallback)(()=>{if(typeof r=="function"){let h=r();typeof h=="number"&&t.chain().focus().deleteRange({from:h,to:h+e.nodeSize}).run()}},[t,r,e.nodeSize]),v=a((h,y)=>h?"#DC2626":y?"#1E40AF":"#B45309","getIconColor")(l,!!s);return(0,Ac.jsx)(j5.NodeViewWrapper,{className:"courier-inline-block courier-max-w-full",children:(0,Ac.jsx)(kc,{variableId:i,isInvalid:l,value:s,onUpdateAttributes:p,onDelete:m,icon:(0,Ac.jsx)(Pc,{color:v}),className:I("courier-variable-node",c&&"courier-variable-in-button"),textColorOverride:c?"#000000":void 0})})},"VariableView");var hp=Ln.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:"",parseHTML:e=>e.getAttribute("data-id")||"",renderHTML:e=>({"data-id":e.id})},isInvalid:{default:!1,parseHTML:e=>e.getAttribute("data-invalid")==="true",renderHTML:e=>({"data-invalid":e.isInvalid?"true":void 0})}}},parseHTML(){return[{tag:"span[data-variable]",getAttrs:e=>{let t=e.getAttribute("data-id");return t?{id:t}:!1}}]},renderHTML({HTMLAttributes:e,node:t}){return["span",{"data-variable":!0,...e},`{{${t.attrs.id}}}`]},renderText({node:e}){return`{{${e.attrs.id}}}`},addNodeView(){return(0,J5.ReactNodeViewRenderer)(q5)}}),Ti=Ln.Extension.create({name:"variableInputRule",addInputRules(){return[new Ln.InputRule({find:/\{\{$/,handler:({range:e,chain:t})=>{t().deleteRange(e).insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()}})]}}),xv=Ln.Extension.create({name:"variableSuggestion",addOptions(){return{HTMLAttributes:{},suggestion:{char:"{{",...bo},variables:{},disableSuggestions:!1}},addProseMirrorPlugins(){return this.options.disableSuggestions?[]:[(0,K5.Suggestion)({editor:this.editor,...this.options.suggestion})]}}),Tv=Ln.Extension.create({name:"variableTypeHandler"});var G5=require("@tiptap/core"),X5=require("@tiptap/pm/state"),Mc=require("@tiptap/pm/model");var Ei=G5.Extension.create({name:"variablePaste",addProseMirrorPlugins(){return[new X5.Plugin({props:{transformPastedHTML:e=>e.replace(/\{\{([^}]+)\}\}/g,(r,o)=>{let n=o.trim();return Ot(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=[],s=0,l;for(o.lastIndex=0;(l=o.exec(e))!==null;){if(l.index>s){let u=e.substring(s,l.index);u&&i.push(n.text(u))}let c=l[1].trim();if(n.nodes.variable&&Ot(c))i.push(n.nodes.variable.create({id:c,isInvalid:!1}));else{let u=l[0];i.push(n.text(u))}s=l.index+l[0].length}if(s<e.length){let c=e.substring(s);c&&i.push(n.text(c))}if(i.length>0){let c=Mc.Fragment.from(i),u=new Mc.Slice(c,0,0),d=r.state.tr.replaceSelection(u);return r.dispatch(d),e}return e}}})]}});var Y5=require("@tiptap/core"),Nc=require("@tiptap/react"),bp=require("react");var Bn=require("react/jsx-runtime"),Ev=a(({color:e="#B45309"})=>(0,Bn.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,Bn.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,Bn.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableChipIcon"),wv=a(e=>e?"#DC2626":"#B45309","getIconColor"),kv=a(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=e.attrs.id||"",i=e.attrs.isInvalid||!1,s=(0,bp.useCallback)(c=>{o(c)},[o]),l=(0,bp.useCallback)(()=>{if(typeof r=="function"){let c=r();typeof c=="number"&&t.chain().focus().deleteRange({from:c,to:c+e.nodeSize}).run()}},[t,r,e.nodeSize]);return(0,Bn.jsx)(Nc.NodeViewWrapper,{as:"span",className:"courier-inline",children:(0,Bn.jsx)(kc,{variableId:n,isInvalid:i,onUpdateAttributes:s,onDelete:l,icon:(0,Bn.jsx)(Ev,{color:wv(i)})})})},"SimpleVariableView"),Sc=Y5.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:"",parseHTML:e=>e.getAttribute("data-id")||"",renderHTML:e=>({"data-id":e.id})},isInvalid:{default:!1,parseHTML:e=>e.getAttribute("data-invalid")==="true",renderHTML:e=>({"data-invalid":e.isInvalid?"true":void 0})}}},parseHTML(){return[{tag:"span[data-variable]",getAttrs:e=>{let t=e.getAttribute("data-id");return t?{id:t}:!1}}]},renderHTML({HTMLAttributes:e,node:t}){return["span",{"data-variable":!0,...e},`{{${t.attrs.id}}}`]},renderText({node:e}){return`{{${e.attrs.id}}}`},addNodeView(){return(0,Nc.ReactNodeViewRenderer)(kv)}});function xa(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 s=e.substring(o,n.index);s&&r.push({type:"text",text:s})}let i=n[1].trim();Ot(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}]}}a(xa,"parseStringToContent");function Ic(e){if(!e.content)return"";let t="",r=a(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}a(Ic,"contentToString");var hh=require("@tiptap/react"),bh=require("react");var Fc=require("jotai"),ft=require("lucide-react"),Nr=require("react");var Lc=require("react");var Q5=require("react"),eh=require("react/jsx-runtime"),yp=(0,Q5.forwardRef)(({children:e,className:t,withShadow:r=!0,withBorder:o=!0,...n},i)=>{let s=I("courier-bg-popover courier-rounded-lg courier-text-popover-foreground",r?"courier-shadow-sm":"",o?"courier-border courier-border-border":"",t);return(0,eh.jsx)("div",{className:s,...n,ref:i,children:e})});yp.displayName="Surface";var rh=xe(require("@tippyjs/react"),1),Rc=require("react");var jt=require("react/jsx-runtime"),th=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,Pv=a(({children:e})=>{let t="courier-inline-flex courier-items-center courier-justify-center courier-w-5 courier-h-5 courier-p-1 courier-text-[0.625rem] courier-rounded courier-font-semibold courier-leading-none courier-border courier-border-border courier-text-muted-foreground courier-border-b-2";return e==="Mod"?(0,jt.jsx)("kbd",{className:t,children:th?"\u2318":"Ctrl"}):e==="Shift"?(0,jt.jsx)("kbd",{className:t,children:"\u21E7"}):e==="Alt"?(0,jt.jsx)("kbd",{className:t,children:th?"\u2325":"Alt"}):(0,jt.jsx)("kbd",{className:t,children:e})},"ShortcutKey"),oh=a(({children:e,enabled:t=!0,title:r,shortcut:o,tippyOptions:n={}})=>{let i=n1(),s=(0,Rc.useCallback)(u=>{let d=Object.entries(i).reduce((p,[m,f])=>{let v=m.replace(/[A-Z]/g,h=>`-${h.toLowerCase()}`);return{...p,[`--${v}`]:f}},{});return(0,jt.jsxs)("span",{className:I("courier-flex courier-items-center courier-gap-2 courier-px-2.5 courier-py-1 courier-bg-popover courier-text-popover-foreground courier-border courier-border-border courier-rounded-lg courier-shadow-sm courier-z-[999]",i.colorScheme==="dark"?"dark":""),style:d,tabIndex:-1,"data-placement":u["data-placement"],"data-reference-hidden":u["data-reference-hidden"],"data-escaped":u["data-escaped"],children:[r&&(0,jt.jsx)("span",{className:"courier-text-xs courier-font-medium courier-text-muted-foreground",children:r}),o&&(0,jt.jsx)("span",{className:"courier-flex courier-items-center courier-gap-0.5",children:o.map(p=>(0,jt.jsx)(Pv,{children:p},p))})]})},[o,r,i]),[l,c]=(0,Rc.useState)(null);return t?(0,jt.jsxs)(jt.Fragment,{children:[(0,jt.jsx)("span",{ref:c,children:e}),l&&(0,jt.jsx)(rh.default,{...n,delay:500,offset:[0,8],touch:!1,zIndex:99999,appendTo:document.body,trigger:"mouseenter focus",showOnCreate:!1,render:s,animation:!1,reference:l})]}):(0,jt.jsx)(jt.Fragment,{children:e})},"Tooltip");var Os=require("react/jsx-runtime"),nh=(0,Lc.forwardRef)(({shouldShowContent:e=!0,children:t,isVertical:r=!1,className:o,...n},i)=>{let s=I("courier-text-foreground courier-inline-flex courier-h-full courier-leading-none courier-gap-0.5",r?"courier-flex-col courier-p-2":"courier-flex-row courier-p-0.5 courier-items-center",o);return e&&(0,Os.jsx)(yp,{className:s,...n,ref:i,children:t})});nh.displayName="Toolbar";var ih=(0,Lc.forwardRef)(({horizontal:e,className:t,...r},o)=>{let n=I("courier-bg-border",e?"courier-w-full courier-min-w-[1.5rem] courier-h-[1px] courier-my-1 first:courier-mt-0 last:courier-mt-0":"courier-h-full courier-min-h-[1.5rem] courier-w-[1px] courier-mx-1 first:courier-ml-0 last:courier-mr-0",t);return(0,Os.jsx)("div",{className:n,ref:o,...r})});ih.displayName="Toolbar.Divider";var ah=(0,Lc.forwardRef)(({children:e,buttonSize:t="icon",variant:r="ghost",className:o,tooltip:n,tooltipShortcut:i,onMouseDown:s,...l},c)=>{let u=I("courier-gap-1 courier-min-w-[2rem] courier-w-auto",o),p=(0,Os.jsx)(Ve,{className:u,variant:r,buttonSize:t,ref:c,onMouseDown:a(m=>{m.preventDefault(),s==null||s(m)},"handleMouseDown"),...l,children:e});return n?(0,Os.jsx)(oh,{title:n,shortcut:i,children:p}):p});ah.displayName="ToolbarButton";var Bc={Wrapper:nh,Divider:ih,Button:ah};var sh=require("lucide-react"),lh=require("react");var Ar=require("react/jsx-runtime"),Av=a(e=>e.type==="option","isOption"),ch=a(({options:e,containerRef:t})=>{let r=(0,lh.useMemo)(()=>e.find(o=>o.type==="option"&&o.isActive()),[e]);return(0,Ar.jsxs)(Cl,{children:[(0,Ar.jsx)(xl,{asChild:!0,children:(0,Ar.jsxs)(Ve,{variant:"ghost",className:"courier-flex courier-items-center courier-justify-center courier-font-normal !courier-py-[5px]",children:[(r==null?void 0:r.label)||"Normal text",(0,Ar.jsx)(sh.ChevronDown,{className:"courier-w-3 courier-h-3"})]})}),(0,Ar.jsx)(Za,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(Av(o))return(0,Ar.jsx)(qa,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?(0,Ar.jsx)(Ar.Fragment,{children:o.id==="heading1"?(0,Ar.jsx)("h1",{className:"courier-text-2xl courier-font-bold",children:o.label}):o.id==="heading2"?(0,Ar.jsx)("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading3"?(0,Ar.jsx)("h3",{className:"courier-text-lg courier-font-bold",children:o.label}):o.label}):o.label},o.id)})})]})},"ContentTypePicker");var Dc=require("jotai"),Mr=require("react"),mh=require("uuid");var uh=require("react");var dh=a((e,t,r)=>(0,uh.useMemo)(()=>{if(!(e!=null&&e.conditionalRules)||!t||!r)return null;let o=e.conditionalRules.filter(n=>n.trigger.type==="node"&&t.isActive(n.trigger.name)!==n.trigger.active?!1:n.conditions.activeItems.some(i=>i==="bold"?r.isBold:i==="italic"?r.isItalic:i==="underline"?r.isUnderline:i==="strike"?r.isStrike:!1));return{getRuleForItem:n=>o.find(i=>!i.conditions.activeItems.includes(n))}},[e,t,r]),"useConditionalRules");var Hc=a((e,t,r)=>{let o=(0,Dc.useSetAtom)(dt),n=(0,Dc.useAtomValue)(we),i=dh(t,e,r),s=(0,Mr.useCallback)(g=>{let b=-1;return e.state.doc.descendants((M,C)=>{var S;return((S=M.attrs)==null?void 0:S.id)===g?(b=C,!1):!0}),b},[e]),l=(0,Mr.useCallback)((g,b)=>{var M,C,S;if(((M=n==null?void 0:n.type)==null?void 0:M.name)==="button"&&((C=n.attrs)!=null&&C.id)){let P=n.attrs.id,k=s(P);if(k>=0){let w=e.state.tr;return w.setNodeMarkup(k,void 0,{...(S=e.state.doc.nodeAt(k))==null?void 0:S.attrs,[g]:b}),e.view.dispatch(w),setTimeout(()=>{let T=s(P);if(T>=0){let A=e.state.doc.nodeAt(T);A&&o(A)}},0),!0}}return!1},[e,n,s,o]),c=(0,Mr.useCallback)(()=>{var g,b;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"&&((b=n.attrs)!=null&&b.id)){let M=n.attrs.id,C=s(M);if(C>=0){let S=e.state.doc.nodeAt(C);if(!S)return!1;let P={...S.attrs,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},k=e.state.tr;return k.setNodeMarkup(C,void 0,P),e.view.dispatch(k),setTimeout(()=>{let w=s(M);if(w>=0){let T=e.state.doc.nodeAt(w);T&&o(T)}},0),!0}}return!1},[e,n,s,o]),u=(0,Mr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let b=n.attrs.fontWeight==="bold"?"normal":"bold";if(l("fontWeight",b))return!0}if(i&&r){let b=i.getRuleForItem("bold");if(b&&b.action.type==="toggle_off"){let M=e.chain().focus();return b.action.targets.forEach(C=>{C==="italic"&&r.isItalic&&M.toggleItalic()}),M.toggleBold().run(),!0}}return e.chain().focus().toggleBold().run()},[e,n,l,i,r]),d=(0,Mr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let b=n.attrs.fontStyle==="italic"?"normal":"italic";if(l("fontStyle",b))return!0}if(i&&r){let b=i.getRuleForItem("italic");if(b&&b.action.type==="toggle_off"){let M=e.chain().focus();return b.action.targets.forEach(C=>{C==="bold"&&r.isBold&&M.toggleBold()}),M.toggleItalic().run(),!0}}return e.chain().focus().toggleItalic().run()},[e,n,l,i,r]),p=(0,Mr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let b=!n.attrs.isStrike;if(l("isStrike",b))return!0}return e.chain().focus().toggleMark("strike").run()},[e,n,l]),m=(0,Mr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let b=!n.attrs.isUnderline;if(l("isUnderline",b))return!0}return e.chain().focus().toggleMark("underline").run()},[e,n,l]),f=(0,Mr.useCallback)(()=>e.chain().focus().setTextAlign("left").run(),[e]),v=(0,Mr.useCallback)(()=>e.chain().focus().setTextAlign("center").run(),[e]),h=(0,Mr.useCallback)(()=>e.chain().focus().setTextAlign("right").run(),[e]),y=(0,Mr.useCallback)(()=>e.chain().focus().setTextAlign("justify").run(),[e]),x=(0,Mr.useCallback)((g,b)=>e.chain().focus().setLink({href:g,target:b?"_blank":""}).run(),[e]),E=(0,Mr.useCallback)(()=>{let g=e.isActive("blockquote");if(e.chain().focus().toggleBlockquote().run()){let{selection:C}=e.state,S=C.$anchor;if(g){let P=S.node();(P.type.name==="paragraph"||P.type.name==="heading")&&o(P)}else for(let P=S.depth;P>0;P--){let k=S.node(P);if(k.type.name==="blockquote"){if(k.attrs.id)o(k);else{let w=S.before(P),T=`node-${(0,mh.v4)()}`,A=e.state.tr;A.setNodeMarkup(w,void 0,{...k.attrs,id:T}),e.view.dispatch(A);let N=e.state.doc.nodeAt(w);N&&o(N)}break}}}},[e,o]);return{onBold:u,onItalic:d,onStrike:p,onUnderline:m,onAlignLeft:f,onAlignCenter:v,onAlignRight:h,onAlignJustify:y,onLink:x,onQuote:E,resetButtonFormatting:c}},"useTextmenuCommands");var ph=require("@tiptap/react");var fh=a(e=>(0,ph.useEditorState)({editor:e,selector:t=>[{label:"Normal text",onClick:()=>{t.editor.chain().focus().setNode("paragraph").run()},id:"paragraph",disabled:()=>!t.editor.can().setParagraph(),isActive:()=>t.editor.isActive("paragraph")&&!t.editor.isActive("heading"),type:"option"},{label:"Heading 1",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:1}).run()},id:"heading1",disabled:()=>!t.editor.can().setHeading({level:1}),isActive:()=>t.editor.isActive("heading",{level:1}),type:"option"},{label:"Heading 2",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:2}).run()},id:"heading2",disabled:()=>!t.editor.can().setHeading({level:2}),isActive:()=>t.editor.isActive("heading",{level:2}),type:"option"},{label:"Heading 3",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:3}).run()},id:"heading3",disabled:()=>!t.editor.can().setHeading({level:3}),isActive:()=>t.editor.isActive("heading",{level:3}),type:"option"}]}),"useTextmenuContentTypes");var gh=require("jotai"),wi=require("react");var Vc=a(e=>{let t=(0,gh.useAtomValue)(we),[r,o]=(0,wi.useState)({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1}),n=(0,wi.useCallback)(()=>{if(e){if((t==null?void 0:t.type.name)==="button"){o({isBold:t.attrs.fontWeight==="bold",isItalic:t.attrs.fontStyle==="italic",isUnderline:t.attrs.isUnderline,isStrike:t.attrs.isStrike,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1});return}o({isBold:e.isActive("bold"),isItalic:e.isActive("italic"),isUnderline:e.isActive("underline"),isStrike:e.isActive("strike"),isAlignLeft:e.isActive({textAlign:"left"}),isAlignCenter:e.isActive({textAlign:"center"}),isAlignRight:e.isActive({textAlign:"right"}),isAlignJustify:e.isActive({textAlign:"justify"}),isQuote:e.isActive("blockquote"),isLink:e.isActive("link")})}},[e,t]);return(0,wi.useEffect)(()=>{if(e)return n(),e.on("selectionUpdate",n),e.on("transaction",n),()=>{e.off("selectionUpdate",n),e.off("transaction",n)}},[e,n]),{shouldShow:(0,wi.useCallback)(({editor:s})=>{let l=["paragraph","heading","blockquote"],{$head:c}=s.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=s.state.selection.from!==s.state.selection.to;if(s.isFocused&&m)return!0}}return!1},[]),...r}},"useTextmenuStates");var Et=require("react/jsx-runtime"),Mv=(0,Nr.memo)(Bc.Button),Nv=(0,Nr.memo)(ch),Ta=a(({editor:e,config:t})=>{var S;let r=Vc(e),o=fh(e),n=(0,Nr.useRef)(null),i=(0,Fc.useAtomValue)(Dl),s=(0,Fc.useAtomValue)(we),l=s==null?void 0:s.type.name,c=(0,Fc.useAtomValue)(f1),[u,d]=(0,Nr.useState)(()=>{let{selection:P}=e.state;return{from:P.from,to:P.to,empty:P.empty}});(0,Nr.useEffect)(()=>{let P=a(()=>{let{selection:k}=e.state;d({from:k.from,to:k.to,empty:k.empty})},"updateSelection");return e.on("selectionUpdate",P),e.on("transaction",P),()=>{e.off("selectionUpdate",P),e.off("transaction",P)}},[e]);let p=(0,Nr.useMemo)(()=>!u.empty&&u.from!==u.to,[u]),m=(0,Nr.useMemo)(()=>t||c(l||"",p),[t,c,l,p]),f=Hc(e,m,r),v=a(()=>{let{selection:P}=e.state;if(!(P.empty&&!r.isLink&&!e.can().setLink({href:""})))if(r.isLink){let k=e.state.tr.setMeta("showLinkForm",{from:P.from,to:P.to});e.view.dispatch(k)}else{let k=e.state.tr.setMeta("showLinkForm",{from:P.from,to:P.to});e.view.dispatch(k)}},"handleLinkToggle"),h=a(()=>{if(i.ref){let P=i.ref,k=P.value,w=i.caretPosition||P.selectionStart||0,T=k.substring(0,w),A=k.substring(w),N=`${T}{{${A}`,R=w+2;P.focus();let B=new Event("input",{bubbles:!0,cancelable:!0});if(Object.defineProperty(B,"target",{writable:!1,value:{...P,value:N}}),P.value=N,P.dispatchEvent(B),P.setSelectionRange(R,R),P.getBoundingClientRect()){let D=N.slice(0,R),F=document.createElement("span");F.style.font=window.getComputedStyle(P).font,F.style.whiteSpace="pre-wrap",F.textContent=D,document.body.appendChild(F);let L=F.offsetWidth;document.body.removeChild(F);let W=parseInt(window.getComputedStyle(P).lineHeight),_=D.split(`
200
+ `).length-1,V=new CustomEvent("showVariableSuggestions",{detail:{cursorPosition:{left:Math.min(L%P.offsetWidth,P.offsetWidth-200),top:_*W+30}},bubbles:!0});P.dispatchEvent(V)}return}e.chain().focus().insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()},"handleVariableClick"),y=a((P,k,w,T,A,N,R)=>{let B=m[P];return!B||Array.isArray(B)||B.state==="hidden"?null:(0,Et.jsx)(Mv,{tooltip:w,tooltipShortcut:N,onClick:T,active:A,disabled:B.state==="disabled",...R,children:k},P)},"renderButton"),x=a((P,k)=>{let w=P.filter(T=>!!T);return w.length>0?(0,Et.jsx)("div",{className:"courier-flex courier-items-center courier-gap-0.5",children:w},k):null},"renderGroup"),E=x([((S=m.contentType)==null?void 0:S.state)==="enabled"&&(0,Et.jsx)(Nv,{options:o,containerRef:n},"content-type")],"content-type-group"),g=x([y("bold",(0,Et.jsx)(ft.Bold,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",f.onBold,r.isBold,["Mod","B"]),y("italic",(0,Et.jsx)(ft.Italic,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",f.onItalic,r.isItalic,["Mod","I"]),y("underline",(0,Et.jsx)(ft.Underline,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",f.onUnderline,r.isUnderline,["Mod","U"]),y("strike",(0,Et.jsx)(ft.Strikethrough,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Strikethrough",f.onStrike,r.isStrike,["Mod","Shift","S"])],"text-style-group"),b=x([y("alignLeft",(0,Et.jsx)(ft.AlignLeft,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",f.onAlignLeft,r.isAlignLeft,["Shift","Mod","L"]),y("alignCenter",(0,Et.jsx)(ft.AlignCenter,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",f.onAlignCenter,r.isAlignCenter,["Shift","Mod","E"]),y("alignRight",(0,Et.jsx)(ft.AlignRight,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",f.onAlignRight,r.isAlignRight,["Shift","Mod","R"]),y("alignJustify",(0,Et.jsx)(ft.AlignJustify,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",f.onAlignJustify,r.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),M=x([y("quote",(0,Et.jsx)(ft.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Quote",f.onQuote,r.isQuote,["Mod","Shift","B"])],"block-style-group"),C=x([y("link",(0,Et.jsx)(ft.Link,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",v,r.isLink,["Mod","K"]),y("variable",(0,Et.jsx)(d1,{width:16}),"Variable",h,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return(0,Et.jsx)(Bc.Wrapper,{ref:n,className:"courier-border-b rounded-b-none rounded-t-sm !courier-shadow-md courier-justify-center courier-rounded-lg",children:[E,g,b,M,C].filter(Boolean).map((P,k)=>(0,Et.jsxs)(Nr.Fragment,{children:[P,k<[E,g,b,M,C].filter(Boolean).length-1&&(0,Et.jsx)(Bc.Divider,{})]},`item-${k}`))})},"TextMenu");var vp=require("react/jsx-runtime"),Sv={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"}},Ws=a(({editor:e})=>{let t=(0,bh.useCallback)(({editor:r})=>r.isFocused&&r.isEditable,[]);return e?(0,vp.jsx)(hh.BubbleMenu,{editor:e,tippyOptions:{appendTo:r=>{var o;return(o=r.closest(".theme-container"))!=null?o:document.body},getReferenceClientRect:()=>e.view.dom.getBoundingClientRect(),placement:"top",offset:[0,8],zIndex:50,popperOptions:{modifiers:[{name:"flip",enabled:!1}]}},shouldShow:t,updateDelay:100,children:(0,vp.jsx)(Ta,{editor:e,config:Sv})}):null},"VariableEditorToolbar");Ws.displayName="VariableEditorToolbar";var _s=require("react/jsx-runtime"),yo=ki.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,showToolbar:i=!1,onFocus:s,onBlur:l},c)=>{let u=ki.useRef(!1),d=ki.useRef(e),p=(0,Oc.useEditor)({immediatelyRender:!1,extensions:[ma,pa.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),fc,Sc,Ti,Ei,yh.default.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:xa(e),editable:!n,editorProps:{attributes:{class:"courier-outline-none courier-min-h-[20px]"},handleKeyDown:(f,v)=>v.key==="Enter"&&!v.shiftKey?(v.preventDefault(),!0):!1},onUpdate:({editor:f})=>{if(u.current)return;let v=Ic(f.getJSON());v!==d.current&&(d.current=v,t==null||t(v))},onFocus:()=>{s==null||s()},onBlur:()=>{l==null||l()}});(0,Us.useEffect)(()=>{if(!p||e===d.current)return;u.current=!0,d.current=e;let f=setTimeout(()=>{let v=xa(e);p.commands.setContent(v),u.current=!1},0);return()=>clearTimeout(f)},[p,e]),(0,Us.useEffect)(()=>{p&&p.setEditable(!n)},[p,n]);let m=(0,Us.useCallback)(()=>{p==null||p.commands.focus()},[p]);return ki.useImperativeHandle(c,()=>{let f=p==null?void 0:p.view.dom.parentElement;return f&&(f.focus=m),f},[p,m]),(0,_s.jsxs)("div",{ref:c,className:I("variable-textarea-placeholder variable-editor-container","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:()=>p==null?void 0:p.commands.focus(),children:[(0,_s.jsx)(Oc.EditorContent,{editor:p,className:"courier-w-full"}),i&&!n&&(0,_s.jsx)(Ws,{editor:p})]})});yo.displayName="VariableTextarea";var vh=xe(require("@tiptap/extension-placeholder"),1);var Wc=require("@tiptap/react"),Pi=xe(require("react"),1),zs=require("react");var $s=require("react/jsx-runtime"),Ea=Pi.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,readOnly:i=!1,showToolbar:s=!1,onFocus:l,onBlur:c},u)=>{let d=Pi.useRef(!1),p=Pi.useRef(e),m=(0,Wc.useEditor)({immediatelyRender:!1,extensions:[ma,pa.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),fc,Sc,Ti,Ei,vh.default.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:xa(e),editable:!n&&!i,editorProps:{attributes:{class:"courier-outline-none"},handleKeyDown:(v,h)=>h.key==="Enter"?(h.preventDefault(),!0):!1},onUpdate:({editor:v})=>{if(d.current)return;let h=Ic(v.getJSON());h!==p.current&&(p.current=h,t==null||t(h))},onFocus:()=>{l==null||l()},onBlur:()=>{c==null||c()}});(0,zs.useEffect)(()=>{if(!m||e===p.current)return;d.current=!0,p.current=e;let v=setTimeout(()=>{let h=xa(e);m.commands.setContent(h),d.current=!1},0);return()=>clearTimeout(v)},[m,e]),(0,zs.useEffect)(()=>{m&&m.setEditable(!n&&!i)},[m,n,i]);let f=(0,zs.useCallback)(()=>{m==null||m.commands.focus()},[m]);return Pi.useImperativeHandle(u,()=>{let v=m==null?void 0:m.view.dom.parentElement;return v&&(v.focus=f),v},[m,f]),(0,$s.jsxs)("div",{ref:u,className:I("variable-input-placeholder variable-editor-container","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&&(m==null?void 0:m.commands.focus()),children:[(0,$s.jsx)(Wc.EditorContent,{editor:m,className:"courier-w-full courier-flex-1"}),s&&!n&&(0,$s.jsx)(Ws,{editor:m})]})});Ea.displayName="VariableInput";var Dn=require("react/jsx-runtime"),wa=30,Uc=a(({color:e="currentColor",width:t=wa,height:r=wa,...o})=>(0,Dn.jsx)(Q,{...o,width:t,height:r,children:(0,Dn.jsx)("path",{d:"M6.375 23.9998C6.375 24.345 6.65482 24.6248 7 24.6248C7.34518 24.6248 7.625 24.345 7.625 23.9998H6.375ZM7.625 7.33317C7.625 6.98799 7.34518 6.70817 7 6.70817C6.65482 6.70817 6.375 6.98799 6.375 7.33317H7.625ZM7.625 23.9998V7.33317H6.375V23.9998H7.625ZM10.4583 16.4995V14.8328H9.20834V16.4995H10.4583ZM11.5 13.7912H21.5V12.5412H11.5V13.7912ZM22.5417 14.8328V16.4995H23.7917V14.8328H22.5417ZM21.5 17.5412H11.5V18.7912H21.5V17.5412ZM22.5417 16.4995C22.5417 16.91 22.5403 17.155 22.5167 17.3306C22.5059 17.4111 22.4932 17.4514 22.4857 17.4695C22.484 17.4737 22.4826 17.4765 22.4818 17.4781C22.481 17.4797 22.4805 17.4804 22.4805 17.4805C22.4804 17.4805 22.4805 17.4803 22.4808 17.4801C22.481 17.4798 22.481 17.4798 22.4807 17.4802L23.3645 18.364C23.6221 18.1065 23.7158 17.7934 23.7556 17.4972C23.793 17.2189 23.7917 16.8747 23.7917 16.4995H22.5417ZM21.5 18.7912C21.8752 18.7912 22.2194 18.7925 22.4977 18.7551C22.7939 18.7153 23.107 18.6216 23.3645 18.364L22.4807 17.4802C22.4803 17.4805 22.4803 17.4805 22.4806 17.4803C22.4808 17.48 22.481 17.4799 22.481 17.48C22.4809 17.48 22.4802 17.4805 22.4786 17.4813C22.477 17.4821 22.4742 17.4835 22.47 17.4852C22.4519 17.4927 22.4116 17.5054 22.3311 17.5162C22.1555 17.5398 21.9105 17.5412 21.5 17.5412V18.7912ZM21.5 13.7912C21.9105 13.7912 22.1555 13.7925 22.3311 13.8161C22.4116 13.8269 22.4519 13.8397 22.47 13.8471C22.4742 13.8489 22.477 13.8502 22.4786 13.8511C22.4802 13.8519 22.4809 13.8524 22.481 13.8524C22.481 13.8524 22.4808 13.8523 22.4806 13.8521C22.4803 13.8518 22.4803 13.8518 22.4807 13.8522L23.3645 12.9683C23.107 12.7108 22.7939 12.6171 22.4977 12.5773C22.2194 12.5398 21.8752 12.5412 21.5 12.5412V13.7912ZM23.7917 14.8328C23.7917 14.4577 23.793 14.1134 23.7556 13.8352C23.7158 13.5389 23.6221 13.2258 23.3645 12.9683L22.4807 13.8522C22.481 13.8526 22.481 13.8526 22.4808 13.8523C22.4805 13.852 22.4804 13.8518 22.4805 13.8519C22.4805 13.8519 22.481 13.8526 22.4818 13.8542C22.4826 13.8558 22.484 13.8586 22.4857 13.8628C22.4932 13.881 22.5059 13.9213 22.5167 14.0017C22.5403 14.1773 22.5417 14.4223 22.5417 14.8328H23.7917ZM10.4583 14.8328C10.4583 14.4223 10.4597 14.1773 10.4833 14.0017C10.4941 13.9213 10.5068 13.881 10.5143 13.8628C10.516 13.8586 10.5174 13.8558 10.5182 13.8542C10.5191 13.8526 10.5195 13.8519 10.5196 13.8519C10.5196 13.8518 10.5195 13.852 10.5192 13.8523C10.519 13.8526 10.519 13.8526 10.5194 13.8522L9.63548 12.9683C9.37796 13.2258 9.28425 13.5389 9.24443 13.8352C9.20702 14.1134 9.20834 14.4577 9.20834 14.8328H10.4583ZM11.5 12.5412C11.1248 12.5412 10.7806 12.5398 10.5023 12.5773C10.2061 12.6171 9.893 12.7108 9.63548 12.9683L10.5194 13.8522C10.5197 13.8518 10.5198 13.8518 10.5195 13.8521C10.5192 13.8523 10.519 13.8524 10.519 13.8524C10.5191 13.8524 10.5198 13.8519 10.5214 13.8511C10.523 13.8502 10.5258 13.8489 10.53 13.8471C10.5481 13.8397 10.5884 13.8269 10.6689 13.8161C10.8445 13.7925 11.0895 13.7912 11.5 13.7912V12.5412ZM9.20834 16.4995C9.20834 16.8747 9.20702 17.2189 9.24443 17.4972C9.28425 17.7934 9.37796 18.1065 9.63548 18.364L10.5194 17.4802C10.519 17.4798 10.519 17.4798 10.5192 17.4801C10.5195 17.4803 10.5196 17.4805 10.5196 17.4805C10.5195 17.4804 10.5191 17.4797 10.5182 17.4781C10.5174 17.4765 10.516 17.4737 10.5143 17.4695C10.5068 17.4514 10.4941 17.4111 10.4833 17.3306C10.4597 17.155 10.4583 16.91 10.4583 16.4995H9.20834ZM11.5 17.5412C11.0895 17.5412 10.8445 17.5398 10.6689 17.5162C10.5884 17.5054 10.5481 17.4927 10.53 17.4852C10.5258 17.4835 10.523 17.4821 10.5214 17.4813C10.5198 17.4805 10.5191 17.48 10.519 17.48C10.519 17.4799 10.5192 17.48 10.5195 17.4803C10.5198 17.4805 10.5197 17.4805 10.5194 17.4802L9.63548 18.364C9.893 18.6216 10.2061 18.7153 10.5023 18.7551C10.7806 18.7925 11.1248 18.7912 11.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignLeftIcon"),_c=a(({color:e="currentColor",width:t=wa,height:r=wa,...o})=>(0,Dn.jsx)(Q,{...o,width:t,height:r,children:(0,Dn.jsx)("path",{d:"M14.9583 7C14.9583 6.65482 14.6785 6.375 14.3333 6.375C13.9881 6.375 13.7083 6.65482 13.7083 7L14.9583 7ZM13.7083 23.3333C13.7083 23.6785 13.9881 23.9583 14.3333 23.9583C14.6785 23.9583 14.9583 23.6785 14.9583 23.3333L13.7083 23.3333ZM13.7083 7L13.7083 12.6665L14.9583 12.6665L14.9583 7L13.7083 7ZM20.375 14.3332L20.375 15.9998L21.625 15.9998L21.625 14.3332L20.375 14.3332ZM19.3333 17.0415L9.33333 17.0415L9.33333 18.2915L19.3333 18.2915L19.3333 17.0415ZM8.29167 15.9998L8.29167 14.3332L7.04167 14.3332L7.04167 15.9998L8.29167 15.9998ZM9.33333 13.2915L19.3333 13.2915L19.3333 12.0415L9.33333 12.0415L9.33333 13.2915ZM8.29167 14.3332C8.29167 13.9227 8.29299 13.6777 8.3166 13.5021C8.32742 13.4216 8.34016 13.3813 8.34763 13.3631C8.34936 13.3589 8.35071 13.3562 8.35155 13.3546C8.35238 13.353 8.35284 13.3523 8.35289 13.3522C8.35292 13.3521 8.35279 13.3523 8.35256 13.3526C8.35232 13.3529 8.35231 13.3529 8.35269 13.3525L7.4688 12.4686C7.21128 12.7262 7.11758 13.0393 7.07775 13.3355C7.04034 13.6138 7.04167 13.958 7.04167 14.3332L8.29167 14.3332ZM9.33333 12.0415C8.95816 12.0415 8.61391 12.0402 8.33566 12.0776C8.03943 12.1174 7.72632 12.2111 7.4688 12.4686L8.35269 13.3525C8.35307 13.3521 8.35308 13.3522 8.35279 13.3524C8.3525 13.3526 8.3523 13.3528 8.35236 13.3527C8.35243 13.3527 8.35313 13.3522 8.35472 13.3514C8.35634 13.3505 8.3591 13.3492 8.3633 13.3475C8.38145 13.34 8.42175 13.3273 8.50222 13.3164C8.67782 13.2928 8.92283 13.2915 9.33333 13.2915L9.33333 12.0415ZM9.33333 17.0415C8.92283 17.0415 8.67782 17.0402 8.50222 17.0166C8.42175 17.0057 8.38145 16.993 8.3633 16.9855C8.3591 16.9838 8.35634 16.9825 8.35472 16.9816C8.35313 16.9808 8.35243 16.9803 8.35236 16.9803C8.3523 16.9802 8.3525 16.9804 8.35279 16.9806C8.35308 16.9808 8.35307 16.9809 8.35269 16.9805L7.4688 17.8644C7.72632 18.1219 8.03943 18.2156 8.33566 18.2554C8.61391 18.2928 8.95816 18.2915 9.33333 18.2915L9.33333 17.0415ZM7.04167 15.9998C7.04167 16.375 7.04034 16.7193 7.07775 16.9975C7.11758 17.2937 7.21128 17.6068 7.4688 17.8644L8.35269 16.9805C8.3523 16.9801 8.35232 16.9801 8.35256 16.9804C8.35279 16.9807 8.35292 16.9809 8.35289 16.9808C8.35284 16.9807 8.35238 16.98 8.35155 16.9784C8.35071 16.9768 8.34936 16.9741 8.34763 16.9699C8.34016 16.9517 8.32742 16.9114 8.3166 16.8309C8.29299 16.6553 8.29167 16.4103 8.29167 15.9998L7.04167 15.9998ZM20.375 15.9998C20.375 16.4103 20.3737 16.6553 20.3501 16.8309C20.3392 16.9114 20.3265 16.9517 20.319 16.9699C20.3173 16.9741 20.316 16.9768 20.3151 16.9784C20.3143 16.98 20.3138 16.9807 20.3138 16.9808C20.3137 16.9809 20.3139 16.9807 20.3141 16.9804C20.3143 16.9801 20.3144 16.9801 20.314 16.9805L21.1979 17.8644C21.4554 17.6068 21.5491 17.2937 21.5889 16.9975C21.6263 16.7193 21.625 16.375 21.625 15.9998L20.375 15.9998ZM19.3333 18.2915C19.7085 18.2915 20.0528 18.2928 20.331 18.2554C20.6272 18.2156 20.9403 18.1219 21.1979 17.8644L20.314 16.9805C20.3136 16.9809 20.3136 16.9808 20.3139 16.9806C20.3142 16.9804 20.3144 16.9802 20.3143 16.9803C20.3142 16.9803 20.3135 16.9808 20.3119 16.9816C20.3103 16.9825 20.3076 16.9838 20.3034 16.9855C20.2852 16.993 20.2449 17.0057 20.1644 17.0166C19.9888 17.0402 19.7438 17.0415 19.3333 17.0415L19.3333 18.2915ZM21.625 14.3332C21.625 13.958 21.6263 13.6138 21.5889 13.3355C21.5491 13.0393 21.4554 12.7262 21.1979 12.4686L20.314 13.3525C20.3144 13.3529 20.3143 13.3529 20.3141 13.3526C20.3139 13.3523 20.3137 13.3521 20.3138 13.3522C20.3138 13.3523 20.3143 13.353 20.3151 13.3546C20.316 13.3562 20.3173 13.3589 20.319 13.3631C20.3265 13.3813 20.3392 13.4216 20.3501 13.5021C20.3737 13.6777 20.375 13.9227 20.375 14.3332L21.625 14.3332ZM19.3333 13.2915C19.7438 13.2915 19.9888 13.2928 20.1644 13.3164C20.2449 13.3273 20.2852 13.34 20.3034 13.3475C20.3076 13.3492 20.3103 13.3505 20.3119 13.3514C20.3135 13.3522 20.3142 13.3527 20.3143 13.3527C20.3144 13.3528 20.3142 13.3526 20.3139 13.3524C20.3136 13.3522 20.3136 13.3521 20.314 13.3525L21.1979 12.4686C20.9403 12.2111 20.6272 12.1174 20.331 12.0776C20.0528 12.0402 19.7085 12.0415 19.3333 12.0415L19.3333 13.2915ZM13.7083 17.6665L13.7083 23.3333L14.9583 23.3333L14.9583 17.6665L13.7083 17.6665Z",fill:e})}),"ButtonAlignCenterIcon"),zc=a(({color:e="currentColor",width:t=wa,height:r=wa,...o})=>(0,Dn.jsx)(Q,{...o,width:t,height:r,children:(0,Dn.jsx)("path",{d:"M23.625 23.9998C23.625 24.345 23.3452 24.6248 23 24.6248C22.6548 24.6248 22.375 24.345 22.375 23.9998H23.625ZM22.375 7.33317C22.375 6.98799 22.6548 6.70817 23 6.70817C23.3452 6.70817 23.625 6.98799 23.625 7.33317H22.375ZM22.375 23.9998V7.33317H23.625V23.9998H22.375ZM19.5417 16.4995V14.8328H20.7917V16.4995H19.5417ZM18.5 13.7912H8.49999V12.5412H18.5V13.7912ZM7.45832 14.8328V16.4995H6.20832V14.8328H7.45832ZM8.49999 17.5412H18.5V18.7912H8.49999V17.5412ZM7.45832 16.4995C7.45832 16.91 7.45965 17.155 7.48326 17.3306C7.49408 17.4111 7.50682 17.4514 7.51429 17.4695C7.51602 17.4737 7.51737 17.4765 7.51821 17.4781C7.51904 17.4797 7.5195 17.4804 7.51955 17.4805C7.51958 17.4805 7.51945 17.4803 7.51922 17.4801C7.51898 17.4798 7.51896 17.4798 7.51934 17.4802L6.63546 18.364C6.37794 18.1065 6.28424 17.7934 6.24441 17.4972C6.207 17.2189 6.20832 16.8747 6.20832 16.4995H7.45832ZM8.49999 18.7912C8.12482 18.7912 7.78057 18.7925 7.50232 18.7551C7.20608 18.7153 6.89298 18.6216 6.63546 18.364L7.51934 17.4802C7.51972 17.4805 7.51974 17.4805 7.51945 17.4803C7.51916 17.48 7.51896 17.4799 7.51902 17.48C7.51909 17.48 7.51979 17.4805 7.52138 17.4813C7.52299 17.4821 7.52576 17.4835 7.52996 17.4852C7.54811 17.4927 7.58841 17.5054 7.66888 17.5162C7.84448 17.5398 8.08948 17.5412 8.49999 17.5412V18.7912ZM8.49999 13.7912C8.08948 13.7912 7.84448 13.7925 7.66888 13.8161C7.58841 13.8269 7.54811 13.8397 7.52996 13.8471C7.52576 13.8489 7.52299 13.8502 7.52138 13.8511C7.51979 13.8519 7.51909 13.8524 7.51902 13.8524C7.51896 13.8524 7.51916 13.8523 7.51945 13.8521C7.51974 13.8518 7.51972 13.8518 7.51934 13.8522L6.63546 12.9683C6.89298 12.7108 7.20608 12.6171 7.50232 12.5773C7.78057 12.5398 8.12482 12.5412 8.49999 12.5412V13.7912ZM6.20832 14.8328C6.20832 14.4577 6.207 14.1134 6.24441 13.8352C6.28424 13.5389 6.37794 13.2258 6.63546 12.9683L7.51934 13.8522C7.51896 13.8526 7.51898 13.8526 7.51922 13.8523C7.51945 13.852 7.51958 13.8518 7.51955 13.8519C7.5195 13.8519 7.51904 13.8526 7.51821 13.8542C7.51737 13.8558 7.51602 13.8586 7.51429 13.8628C7.50682 13.881 7.49408 13.9213 7.48326 14.0017C7.45965 14.1773 7.45832 14.4223 7.45832 14.8328H6.20832ZM19.5417 14.8328C19.5417 14.4223 19.5403 14.1773 19.5167 14.0017C19.5059 13.9213 19.4932 13.881 19.4857 13.8628C19.484 13.8586 19.4826 13.8558 19.4818 13.8542C19.4809 13.8526 19.4805 13.8519 19.4804 13.8519C19.4804 13.8518 19.4805 13.852 19.4808 13.8523C19.481 13.8526 19.481 13.8526 19.4806 13.8522L20.3645 12.9683C20.622 13.2258 20.7157 13.5389 20.7556 13.8352C20.793 14.1134 20.7917 14.4577 20.7917 14.8328H19.5417ZM18.5 12.5412C18.8752 12.5412 19.2194 12.5398 19.4977 12.5773C19.7939 12.6171 20.107 12.7108 20.3645 12.9683L19.4806 13.8522C19.4803 13.8518 19.4802 13.8518 19.4805 13.8521C19.4808 13.8523 19.481 13.8524 19.481 13.8524C19.4809 13.8524 19.4802 13.8519 19.4786 13.8511C19.477 13.8502 19.4742 13.8489 19.47 13.8471C19.4519 13.8397 19.4116 13.8269 19.3311 13.8161C19.1555 13.7925 18.9105 13.7912 18.5 13.7912V12.5412ZM20.7917 16.4995C20.7917 16.8747 20.793 17.2189 20.7556 17.4972C20.7157 17.7934 20.622 18.1065 20.3645 18.364L19.4806 17.4802C19.481 17.4798 19.481 17.4798 19.4808 17.4801C19.4805 17.4803 19.4804 17.4805 19.4804 17.4805C19.4805 17.4804 19.4809 17.4797 19.4818 17.4781C19.4826 17.4765 19.484 17.4737 19.4857 17.4695C19.4932 17.4514 19.5059 17.4111 19.5167 17.3306C19.5403 17.155 19.5417 16.91 19.5417 16.4995H20.7917ZM18.5 17.5412C18.9105 17.5412 19.1555 17.5398 19.3311 17.5162C19.4116 17.5054 19.4519 17.4927 19.47 17.4852C19.4742 17.4835 19.477 17.4821 19.4786 17.4813C19.4802 17.4805 19.4809 17.48 19.481 17.48C19.481 17.4799 19.4808 17.48 19.4805 17.4803C19.4802 17.4805 19.4803 17.4805 19.4806 17.4802L20.3645 18.364C20.107 18.6216 19.7939 18.7153 19.4977 18.7551C19.2194 18.7925 18.8752 18.7912 18.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignRightIcon");var ue=require("react/jsx-runtime"),Th=a(({element:e,editor:t})=>{let r=(0,xh.useForm)({resolver:(0,Ch.zodResolver)(mc),defaultValues:{...at,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Ut({editor:t,element:e,form:r,nodeType:"button"});return e?(0,ue.jsxs)(rt,{...r,children:[(0,ue.jsx)(or,{type:"button"}),(0,ue.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,ue.jsx)(oe,{control:r.control,name:"link",render:({field:n})=>(0,ue.jsxs)(te,{children:[(0,ue.jsx)(re,{children:(0,ue.jsx)(yo,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})},showToolbar:!0})}),(0,ue.jsx)(ne,{})]})}),(0,ue.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Background"}),(0,ue.jsx)(oe,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,ue.jsxs)(te,{className:"courier-mb-4",children:[(0,ue.jsx)(re,{children:(0,ue.jsx)(Wt,{...n,defaultValue:at.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ue.jsx)(ne,{})]})}),(0,ue.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,ue.jsx)(oe,{control:r.control,name:"padding",render:({field:n})=>(0,ue.jsxs)(te,{className:"courier-mb-2",children:[(0,ue.jsx)(re,{children:(0,ue.jsx)(Ee,{type:"number",min:0,...n})}),(0,ue.jsx)(ne,{})]})}),(0,ue.jsx)(oe,{control:r.control,name:"alignment",render:({field:n})=>(0,ue.jsxs)(te,{children:[(0,ue.jsx)(re,{children:(0,ue.jsxs)(Xr,{type:"single",value:n.value,onValueChange:i=>{n.onChange(i),o({...r.getValues(),alignment:i})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,ue.jsx)(dr,{size:"sm",value:"left",className:"courier-w-full",children:(0,ue.jsx)(Uc,{className:"courier-h-4 courier-w-4"})}),(0,ue.jsx)(dr,{size:"sm",value:"center",className:"courier-w-full",children:(0,ue.jsx)(_c,{className:"courier-h-4 courier-w-4"})}),(0,ue.jsx)(dr,{size:"sm",value:"right",className:"courier-w-full",children:(0,ue.jsx)(zc,{className:"courier-h-4 courier-w-4"})})]})}),(0,ue.jsx)(ne,{})]})}),(0,ue.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,ue.jsx)(oe,{control:r.control,name:"borderRadius",render:({field:n})=>(0,ue.jsxs)(te,{children:[(0,ue.jsx)(re,{children:(0,ue.jsx)(Ee,{startAdornment:(0,ue.jsx)(Ya,{}),type:"number",min:0,...n})}),(0,ue.jsx)(ne,{})]})})]})]}):null},"ButtonForm");var jc=require("@tiptap/core"),kh=require("@tiptap/react"),Ph=require("uuid");var $c=require("jotai"),ze=require("react");var Zt=require("react/jsx-runtime"),Iv=a(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();Ot(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"),Rv=a(({parts:e})=>{let t=(0,$c.useAtomValue)(Xn);return(0,Zt.jsx)(Zt.Fragment,{children:e.map((r,o)=>{if(r.type==="text")return(0,Zt.jsx)("span",{children:r.content},o);let n=t[r.name];return(0,Zt.jsxs)("span",{className:"courier-inline-flex courier-items-center courier-gap-0.5 courier-rounded courier-border courier-px-1.5 courier-pl-1 courier-py-[1px] courier-text-sm courier-variable-node courier-font-mono courier-max-w-full courier-tracking-[0.64px] courier-variable-in-button",style:{backgroundColor:n?"#EFF6FF":"#FFFBEB",borderColor:n?"#BFDBFE":"#FDE68A",color:"#000000"},children:[(0,Zt.jsx)(Pc,{color:n?void 0:"#B45309"}),(0,Zt.jsxs)("span",{className:"courier-truncate courier-min-w-0",style:{color:"#000000"},children:[r.name,n?`="${n}"`:""]})]},o)})})},"ButtonLabelDisplay"),Eh=a(({label:e,backgroundColor:t,textColor:r,onLabelChange:o,editable:n})=>{let i=(0,ze.useRef)(null),s=(0,ze.useRef)(e),l=(0,ze.useRef)(!1),[c,u]=(0,ze.useState)(!1),d=Iv(e),m=d.some(C=>C.type==="variable")&&!c;(0,ze.useLayoutEffect)(()=>{if(!i.current||!m)return;Array.from(i.current.childNodes).filter(S=>S.nodeType===Node.TEXT_NODE).forEach(S=>S.remove())},[m,e]);let f=(0,ze.useRef)(m),v=(0,ze.useRef)(!0);(0,ze.useEffect)(()=>{if(!i.current||m){f.current=m;return}let C=f.current&&!m;f.current=m,(v.current||C||!l.current&&e!==s.current)&&(i.current.textContent=e),v.current=!1,s.current=e},[e,m]);let h=(0,ze.useCallback)(()=>{if(i.current&&!m){l.current=!0;let C=i.current.textContent||"";s.current=C,o(C),requestAnimationFrame(()=>{l.current=!1})}},[o,m]),y=(0,ze.useCallback)(C=>{var S;if(m){C.preventDefault(),C.stopPropagation();return}if(C.key==="Enter"&&(C.preventDefault(),(S=i.current)==null||S.blur()),(C.metaKey||C.ctrlKey)&&C.key==="a"&&(C.preventDefault(),C.stopPropagation(),i.current)){let P=document.createRange();P.selectNodeContents(i.current);let k=window.getSelection();k==null||k.removeAllRanges(),k==null||k.addRange(P)}},[m]),x=(0,ze.useCallback)(()=>{u(!0)},[]),E=(0,ze.useCallback)(()=>{u(!1)},[]),g=(0,ze.useCallback)(C=>{let S=i.current;if(!S)return;if(m&&n){C.stopPropagation(),setTimeout(()=>{S.focus();let w=document.createRange();w.selectNodeContents(S),w.collapse(!1);let T=window.getSelection();T==null||T.removeAllRanges(),T==null||T.addRange(w)},0);return}if(!n)return;let P=a(()=>{let w=window.getSelection();if(!w||w.rangeCount===0)return;let T=w.getRangeAt(0),A=S.contains(T.startContainer),N=S.contains(T.endContainer);if(A&&!N){let R=document.createRange();R.selectNodeContents(S),w.removeAllRanges(),w.addRange(R)}},"checkAndConstrainSelection"),k=a(w=>{let T=S.getBoundingClientRect();(w.clientX<T.left||w.clientX>T.right||w.clientY<T.top||w.clientY>T.bottom)&&P(),document.removeEventListener("mouseup",k)},"handleMouseUp");document.addEventListener("mouseup",k)},[n,m]),b=m?(0,Zt.jsx)(Rv,{parts:d}):n?null:e,M=(0,ze.useCallback)(C=>{m&&n&&C.stopPropagation()},[m,n]);return(0,Zt.jsx)("div",{ref:i,contentEditable:n&&!m,suppressContentEditableWarning:!0,tabIndex:n&&m?0:void 0,onInput:h,onKeyDown:y,onPointerDown:g,onClick:M,onFocus:x,onBlur:E,className:I("courier-inline-flex courier-justify-start courier-px-2 courier-py-1 courier-text-sm courier-rounded-sm courier-border courier-border-border courier-outline-none",n&&!m&&"courier-cursor-text"),style:{backgroundColor:t,color:r,borderColor:"transparent",borderRadius:"4px",caretColor:r,WebkitUserSelect:"text",userSelect:"text"},children:b})},"EditableButton"),Lv=a(({button1Label:e,button1Link:t,button1BackgroundColor:r,button1TextColor:o,button2Label:n,button2Link:i,button2BackgroundColor:s,button2TextColor:l,padding:c=6,onButton1LabelChange:u,onButton2LabelChange:d,editable:p=!1})=>(0,Zt.jsx)("div",{className:"node-element",children:(0,Zt.jsxs)("div",{className:"courier-flex courier-gap-1 courier-justify-start",style:{marginTop:`${c}px`,marginBottom:`${c}px`},children:[(0,Zt.jsx)(Eh,{label:e,backgroundColor:r,textColor:o,onLabelChange:u||(()=>{}),editable:p},"button1"),(0,Zt.jsx)(Eh,{label:n,backgroundColor:s,textColor:l,onLabelChange:d||(()=>{}),editable:p},"button2")]})}),"ButtonRowComponent"),wh=a(e=>{let t=(0,$c.useSetAtom)(dt),r=(0,ze.useRef)({}),o=(0,ze.useRef)({}),n=(0,ze.useCallback)(()=>{if(!e.editor.isEditable)return;let l=It(e);l&&t(l)},[e,t]),i=(0,ze.useCallback)(l=>{o.current.button1=l,r.current.button1&&clearTimeout(r.current.button1),r.current.button1=setTimeout(()=>{o.current.button1!==void 0&&e.updateAttributes({button1Label:o.current.button1})},300)},[e]),s=(0,ze.useCallback)(l=>{o.current.button2=l,r.current.button2&&clearTimeout(r.current.button2),r.current.button2=setTimeout(()=>{o.current.button2!==void 0&&e.updateAttributes({button2Label:o.current.button2})},300)},[e]);return(0,ze.useEffect)(()=>{let l=r.current;return()=>{l.button1&&clearTimeout(l.button1),l.button2&&clearTimeout(l.button2)}},[]),(0,Zt.jsx)(rr,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"buttonRow",children:(0,Zt.jsx)(Lv,{...e.node.attrs,onButton1LabelChange:i,onButton2LabelChange:s,editable:e.editor.isEditable})})},"ButtonRowComponentNode");var vo={button1Label:"Register",button1Link:"",button1BackgroundColor:"#000000",button1TextColor:"#ffffff",button2Label:"Learn more",button2Link:"",button2BackgroundColor:"#ffffff",button2TextColor:"#000000",padding:6},Zc=jc.Node.create({name:"buttonRow",group:"block",atom:!0,selectable:!1,onCreate(){St(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${(0,Ph.v4)()}`,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.id})},button1Label:{default:vo.button1Label,parseHTML:e=>e.getAttribute("data-button1-label"),renderHTML:e=>({"data-button1-label":e.button1Label})},button1Link:{default:vo.button1Link,parseHTML:e=>e.getAttribute("data-button1-link"),renderHTML:e=>({"data-button1-link":e.button1Link})},button1BackgroundColor:{default:vo.button1BackgroundColor,parseHTML:e=>e.getAttribute("data-button1-bg"),renderHTML:e=>({"data-button1-bg":e.button1BackgroundColor})},button1TextColor:{default:vo.button1TextColor,parseHTML:e=>e.getAttribute("data-button1-color"),renderHTML:e=>({"data-button1-color":e.button1TextColor})},button2Label:{default:vo.button2Label,parseHTML:e=>e.getAttribute("data-button2-label"),renderHTML:e=>({"data-button2-label":e.button2Label})},button2Link:{default:vo.button2Link,parseHTML:e=>e.getAttribute("data-button2-link"),renderHTML:e=>({"data-button2-link":e.button2Link})},button2BackgroundColor:{default:vo.button2BackgroundColor,parseHTML:e=>e.getAttribute("data-button2-bg"),renderHTML:e=>({"data-button2-bg":e.button2BackgroundColor})},button2TextColor:{default:vo.button2TextColor,parseHTML:e=>e.getAttribute("data-button2-color"),renderHTML:e=>({"data-button2-color":e.button2TextColor})},padding:{default:vo.padding,parseHTML:e=>parseInt(e.getAttribute("data-padding")||"6"),renderHTML:e=>({"data-padding":e.padding})}}},parseHTML(){return[{tag:'div[data-type="buttonRow"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,jc.mergeAttributes)(e,{"data-type":"buttonRow"})]},addNodeView(){return(0,kh.ReactNodeViewRenderer)(wh,{stopEvent:({event:e})=>!(e.type==="dragstart"||e.type==="drop")})},addCommands(){return{setButtonRow:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...vo,...e}}).run()}}});var Mh=require("@hookform/resolvers/zod"),Nh=require("react-hook-form");var zr=require("zod"),Ah=zr.z.object({columnsCount:zr.z.number().min(1).max(4).default(2),paddingHorizontal:zr.z.number().default(0),paddingVertical:zr.z.number().default(0),backgroundColor:zr.z.string().default("transparent"),borderWidth:zr.z.number().default(0),borderRadius:zr.z.number().default(0),borderColor:zr.z.string().default("transparent"),cells:zr.z.array(zr.z.object({elements:zr.z.array(zr.z.any())})).optional()});var se=require("react/jsx-runtime"),Cp=a(({element:e,editor:t})=>{let r=(0,Nh.useForm)({resolver:(0,Mh.zodResolver)(Ah),defaultValues:{..._t,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Ut({editor:t,element:e,form:r,nodeType:"column"}),n=a(i=>{if(!t||!e)return;let s=null;if(t.state.doc.descendants((f,v)=>f.attrs.id===e.attrs.id&&f.type.name==="column"?(s=v,!1):!0),s===null)return;let l=t.state.doc.nodeAt(s);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,y)=>u.nodes.columnCell.create({index:y,columnId:c,isEditorMode:!1})),v=u.nodes.columnRow.create({},f);d.replaceWith(s+1,s+l.nodeSize-1,v),d.setNodeMarkup(s,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=s+1+p.nodeSize-1;for(let y=0;y<f;y++){let x=u.nodes.columnCell.create({index:m+y,columnId:c});d.insert(h+y*x.nodeSize,x)}}else{let f=m-i,h=s+1;for(let x=0;x<m-f;x++){let E=p.child(x);h+=E.nodeSize}let y=0;for(let x=m-f;x<m;x++){let E=p.child(x);y+=E.nodeSize}d.delete(h,h+y)}d.setNodeMarkup(s,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d)}},"updateColumnCount");return e?(0,se.jsxs)(rt,{...r,children:[(0,se.jsx)(or,{type:"column",label:"Column layout"}),(0,se.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,se.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Columns count"}),(0,se.jsx)(oe,{control:r.control,name:"columnsCount",render:({field:i})=>(0,se.jsxs)(te,{className:"courier-mb-4",children:[(0,se.jsx)(re,{children:(0,se.jsx)(Xr,{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:s=>{if(s){let l=Number(s);i.onChange(l),n(l)}},children:[1,2,3,4].map(s=>(0,se.jsx)(dr,{value:s.toString(),className:"courier-w-12 courier-h-7",children:(0,se.jsx)("span",{className:"courier-text-sm courier-font-medium",children:s})},s))})}),(0,se.jsx)(ne,{})]})}),(0,se.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,se.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Frame"}),(0,se.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,se.jsx)(oe,{control:r.control,name:"paddingHorizontal",render:({field:i})=>(0,se.jsxs)(te,{children:[(0,se.jsx)(re,{children:(0,se.jsx)(Ee,{startAdornment:(0,se.jsx)(is,{}),type:"number",min:0,...i})}),(0,se.jsx)(ne,{})]})}),(0,se.jsx)(oe,{control:r.control,name:"paddingVertical",render:({field:i})=>(0,se.jsxs)(te,{children:[(0,se.jsx)(re,{children:(0,se.jsx)(Ee,{startAdornment:(0,se.jsx)(ti,{}),type:"number",min:0,...i})}),(0,se.jsx)(ne,{})]})})]}),(0,se.jsx)(oe,{control:r.control,name:"backgroundColor",render:({field:i})=>(0,se.jsxs)(te,{className:"courier-mb-4",children:[(0,se.jsx)(re,{children:(0,se.jsx)(Wt,{...i,defaultValue:_t.backgroundColor,onChange:s=>{i.onChange(s),o({...r.getValues(),[i.name]:s})}})}),(0,se.jsx)(ne,{})]})}),(0,se.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,se.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Border"}),(0,se.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,se.jsx)(oe,{control:r.control,name:"borderWidth",render:({field:i})=>(0,se.jsxs)(te,{children:[(0,se.jsx)(re,{children:(0,se.jsx)(Ee,{startAdornment:(0,se.jsx)(Qo,{}),type:"number",min:0,...i})}),(0,se.jsx)(ne,{})]})}),(0,se.jsx)(oe,{control:r.control,name:"borderRadius",render:({field:i})=>(0,se.jsxs)(te,{children:[(0,se.jsx)(re,{children:(0,se.jsx)(Ee,{startAdornment:(0,se.jsx)(Ya,{}),type:"number",min:0,...i})}),(0,se.jsx)(ne,{})]})})]}),(0,se.jsx)(oe,{control:r.control,name:"borderColor",render:({field:i})=>(0,se.jsxs)(te,{className:"courier-mb-4",children:[(0,se.jsx)(re,{children:(0,se.jsx)(Wt,{...i,defaultValue:_t.borderColor,onChange:s=>{i.onChange(s),o({...r.getValues(),[i.name]:s})}})}),(0,se.jsx)(ne,{})]})})]})]}):null},"ColumnForm");var qc=require("@tiptap/core"),Jc=qc.Node.create({name:"columnRow",group:"columnContent",content:"columnCell+",isolating:!0,parseHTML(){return[{tag:'div[data-type="column-row"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,qc.mergeAttributes)(e,{"data-type":"column-row",class:"courier-flex courier-flex-row courier-gap-2 courier-w-full",style:"display: flex; flex-direction: row; gap: 0.5rem; width: 100%;"}),0]},addCommands(){return{insertColumnRow:()=>({chain:e})=>e().insertContent({type:this.name}).run()}}});var Gc=require("@tiptap/core"),Rh=require("@tiptap/react"),Xc=require("@tiptap/pm/state");var Kc=require("@tiptap/react"),Hn=require("react");var Sh=require("jotai");var js=require("react/jsx-runtime"),Ih=a(e=>{let t=(0,Hn.useRef)(null),[r,o]=(0,Hn.useState)(!1),n=(0,Sh.useAtomValue)(Cr),i=e.node.attrs.isEditorMode===!0,[s,l]=(0,Hn.useState)(e.editor.isEditable);(0,Hn.useEffect)(()=>{let d=t.current;if(d)return Wr({element:d,getData:()=>({type:"column-cell",columnId:e.node.attrs.columnId,index:e.node.attrs.index}),onDragEnter:()=>o(!0),onDragLeave:()=>o(!1),onDrop:()=>o(!1)})},[e.node.attrs.columnId,e.node.attrs.index]),(0,Hn.useEffect)(()=>{let d=a(()=>{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=!s&&!n,u=!i&&!c;return(0,js.jsxs)(Kc.NodeViewWrapper,{ref:t,"data-column-cell":"true","data-column-id":e.node.attrs.columnId,"data-cell-index":e.node.attrs.index,className:I("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4 courier-pl-0 courier-w-full",!c&&"courier-border",!c&&(r?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),u&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:[u&&(0,js.jsx)("span",{className:"courier-pointer-events-none courier-pl-4",children:"Drag and drop content blocks"}),(0,js.jsx)(Kc.NodeViewContent,{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full"})]})},"ColumnCellComponentNode");var Yc=Gc.Node.create({name:"columnCell",group:"columnRow",content:"block*",isolating:!0,selectable:!1,addAttributes(){return{index:{default:0,parseHTML:e=>{let t=e.getAttribute("data-cell-index");return t?parseInt(t,10):0},renderHTML:e=>({"data-cell-index":e.index})},columnId:{default:null,parseHTML:e=>e.getAttribute("data-column-id"),renderHTML:e=>({"data-column-id":e.columnId})},isEditorMode:{default:!1,parseHTML:e=>e.getAttribute("data-editor-mode")==="true",renderHTML:e=>({"data-editor-mode":e.isEditorMode?"true":"false"})}}},parseHTML(){return[{tag:'div[data-type="column-cell"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Gc.mergeAttributes)(e,{"data-type":"column-cell",style:"flex: 1 1 0%; width: 0; min-height: 120px;"}),0]},addNodeView(){return(0,Rh.ReactNodeViewRenderer)(Ih)},addCommands(){return{insertColumnCell:()=>({chain:e})=>e().insertContent({type:this.name}).run()}},addProseMirrorPlugins(){return[new Xc.Plugin({key:new Xc.PluginKey("columnCellCleanup"),appendTransaction:(e,t,r)=>{if(!e.some(i=>i.docChanged))return null;let o=r.tr,n=!1;return r.doc.descendants((i,s)=>{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(s,"isEditorMode",p),n=!0),d&&p===!1&&(o.delete(s+1,s+i.nodeSize-1),n=!0)}return!0}),n?o:null}})]}});var qt=require("react");var Lh=require("react"),Bh=require("react/jsx-runtime"),xp=(0,Lh.forwardRef)(({className:e,...t},r)=>{let o=I("courier-animate-spin courier-rounded-full courier-border-2 courier-border-current courier-border-t-transparent courier-h-4 courier-w-4",e);return(0,Bh.jsx)("div",{className:o,ref:r,...t})});xp.displayName="Spinner";var Ai=require("react/jsx-runtime"),Bv=a(()=>{let[e,t]=(0,qt.useState)(!1),r=(0,qt.useRef)(null);return(0,qt.useEffect)(()=>{var i;let o=a(()=>{if(r.current){let s=r.current.closest(".dark")!==null;t(s)}},"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"),Dv=(0,qt.lazy)(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function Hv(e,t){let r=(0,qt.useRef)();return(0,qt.useCallback)((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}a(Hv,"useDebounce");var Vv=a((e,t,r)=>{if(!t||!r)return!0;let o=t.getModel();if(!o)return!0;if(r.editor.getModelMarkers({resource:o.uri}).filter(s=>s.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(y=>{var x,E;return(E=(x=y.match(/<([a-z][a-z0-9]*)/i))==null?void 0:x[1])==null?void 0:E.toLowerCase()}).filter(Boolean),f=(e.match(/<\/([a-z][a-z0-9]*)\s*>/gi)||[]).map(y=>{var x,E;return(E=(x=y.match(/<\/([a-z][a-z0-9]*)/i))==null?void 0:x[1])==null?void 0:E.toLowerCase()}).filter(Boolean),v=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],h=m.filter(y=>y&&!v.includes(y));for(let y of h){let x=m.filter(g=>g===y).length,E=f.filter(g=>g===y).length;if(x!==E)return!1}return!0}catch{return!1}},"defaultHTMLValidator"),Qc=a(({code:e,onSave:t,onValidationChange:r,validator:o=Vv})=>{let n=(0,qt.useRef)(null),i=(0,qt.useRef)(null),[s,l]=(0,qt.useState)(!0),{isDark:c,containerRef:u}=Bv(),d=(0,qt.useCallback)(()=>{if(!n.current||!i.current)return!0;let v=n.current.getModel();if(!v)return!0;let h=v.getValue(),y=o(h,n.current,i.current);return y!==s&&(l(y),r==null||r(y)),y},[s,r,o]),p=Hv(v=>{setTimeout(()=>{d()&&t(v)},150)},500);return(0,Ai.jsx)("div",{ref:u,className:"courier-h-full courier-overflow-hidden",children:(0,Ai.jsx)("div",{className:"courier-h-full courier-p-2",children:(0,Ai.jsx)(qt.Suspense,{fallback:(0,Ai.jsx)("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:(0,Ai.jsx)(xp,{})}),children:(0,Ai.jsx)(Dv,{height:"100%",defaultLanguage:"html",value:e,onChange:a(v=>{p(v||"")},"handleCodeChange"),onMount:a((v,h)=>{n.current=v,i.current=h,v.focus(),v.onDidChangeModelContent(()=>{setTimeout(d,100)}),setTimeout(d,100)},"handleEditorDidMount"),theme:c?"vs-dark":"vs-light",options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,wordWrap:"on",automaticLayout:!0,tabSize:2,insertSpaces:!0,formatOnPaste:!0,formatOnType:!0,glyphMargin:!1,folding:!1,lineDecorationsWidth:10,lineNumbersMinChars:0,fixedOverflowWidgets:!0}})})})})},"MonacoCodeEditor");var Hh=require("@hookform/resolvers/zod"),Vh=require("react-hook-form");var Tp=require("zod"),Dh=Tp.z.object({code:Tp.z.string()});var Fh=require("react"),Oh=require("jotai");var gt=require("react/jsx-runtime"),Ep=a(({element:e,editor:t})=>{let r=(0,Vh.useForm)({resolver:(0,Hh.zodResolver)(Dh),defaultValues:{...rn,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Ut({editor:t,element:e,form:r,nodeType:"customCode"}),[n,i]=(0,Oh.useAtom)(Do),s=(0,Fh.useCallback)(l=>{r.setValue("code",l),o({code:l})},[r,o]);return e?(0,gt.jsxs)(rt,{...r,children:[!n&&(0,gt.jsx)(or,{type:"customCode"}),(0,gt.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[(0,gt.jsx)(Ve,{className:"courier-w-fit",variant:"outline",buttonSize:"small",onClick:()=>i(!n),children:n?(0,gt.jsxs)(gt.Fragment,{children:[(0,gt.jsx)(lm,{className:"courier-w-3 courier-h-3"}),"Minimize"]}):(0,gt.jsxs)(gt.Fragment,{children:[(0,gt.jsx)(Qa,{className:"courier-w-3 courier-h-3"}),"Expand Editor"]})}),(0,gt.jsx)("div",{className:"courier-mb-4 courier-overflow-hidden courier-rounded-md courier-border courier-border-border",style:{minHeight:"200px",height:"300px",resize:"vertical",overflow:"auto"},children:(0,gt.jsx)("form",{onChange:()=>{o(r.getValues())},className:"courier-h-full",children:(0,gt.jsx)(oe,{control:r.control,name:"code",render:({field:l})=>(0,gt.jsxs)(te,{className:"courier-h-full",children:[(0,gt.jsx)(re,{children:(0,gt.jsx)(Qc,{code:l.value,onSave:c=>{l.onChange(c),s(c)},onCancel:()=>{}})}),(0,gt.jsx)(ne,{})]})})})})]})]}):null},"CustomCodeForm");var Mi=require("zod"),Wh=Mi.z.object({padding:Mi.z.number(),color:Mi.z.string(),size:Mi.z.number(),radius:Mi.z.number(),variant:Mi.z.enum(["divider","spacer"]).default("divider")});var Uh=require("@hookform/resolvers/zod"),_h=require("react-hook-form");var Le=require("react/jsx-runtime"),zh=a(({element:e,editor:t})=>{let r=(0,_h.useForm)({resolver:(0,Uh.zodResolver)(Wh),defaultValues:{..._r,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Ut({editor:t,element:e,form:r,nodeType:"divider"});if(!e)return null;let n=r.watch("variant");return(0,Le.jsxs)(rt,{...r,children:[(0,Le.jsx)(or,{type:n}),(0,Le.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Le.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,Le.jsx)(oe,{control:r.control,name:"padding",render:({field:i})=>(0,Le.jsxs)(te,{children:[(0,Le.jsx)(re,{children:(0,Le.jsx)(Ee,{startAdornment:(0,Le.jsx)(ti,{}),type:"number",...i,onChange:s=>{i.onChange(s),o({...r.getValues(),margin:s.target.value})}})}),(0,Le.jsx)(ne,{})]})}),n==="divider"&&(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,Le.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Line"}),(0,Le.jsx)(oe,{control:r.control,name:"size",render:({field:i})=>(0,Le.jsxs)(te,{className:"courier-mb-4",children:[(0,Le.jsx)(re,{children:(0,Le.jsx)(Ee,{startAdornment:(0,Le.jsx)(Qo,{}),type:"number",min:0,...i,onChange:s=>{i.onChange(s),o({...r.getValues(),width:s.target.value})}})}),(0,Le.jsx)(ne,{})]})}),(0,Le.jsx)(oe,{control:r.control,name:"color",render:({field:i})=>(0,Le.jsxs)(te,{className:"courier-mb-4",children:[(0,Le.jsx)(re,{children:(0,Le.jsx)(Wt,{...i,defaultValue:_r.color,onChange:s=>{i.onChange(s),o({...r.getValues(),[i.name]:s})}})}),(0,Le.jsx)(ne,{})]})})]})]})]})},"DividerForm");var wp=ma.extend({content:"(block)+"});var Zh=require("@tiptap/core"),qh=require("@tiptap/react");var $h=require("@tiptap/react"),Ni=require("react");var Zs=require("react/jsx-runtime");function Fv(){let[e,t]=(0,Ni.useState)(!1);return(0,Ni.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}a(Fv,"useMountStatus");var Ov=(0,Ni.forwardRef)(({children:e,className:t,dragOverlay:r,id:o},n)=>((0,Ni.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),(0,Zs.jsx)($h.NodeViewWrapper,{ref:n,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":o,"data-placeholder":"true",className:I("courier-flex courier-items-start courier-gap-2 courier-pl-6",t),children:e}))),Wv=a(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"),jh=a(({node:e})=>{let t=e.attrs.type,r=e.attrs.id,o=Fv();return(0,Zs.jsx)(Ov,{id:r,fadeIn:!o,children:(0,Zs.jsx)("div",{className:I("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md"),children:(0,Zs.jsx)("div",{className:"courier-text-accent-foreground",children:Wv(t)})})})},"DragPlaceholderComponent");var Jh=Zh.Node.create({name:"dragPlaceholder",group:"block",atom:!0,draggable:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},type:{default:"text",parseHTML:e=>e.getAttribute("data-type"),renderHTML:e=>({"data-type":e.type})}}},parseHTML(){return[{tag:'div[data-type="drag-placeholder"]'}]},renderHTML({HTMLAttributes:e}){return["div",{"data-type":"drag-placeholder",...e},0]},addCommands(){return{setDragPlaceholder:e=>({tr:t,dispatch:r})=>{if(r){let o=this.type.create(e);typeof e.pos=="number"?t.insert(e.pos,o):t.replaceSelectionWith(o)}return!0},removeDragPlaceholder:()=>({tr:e,state:t,dispatch:r})=>{let o=!1;return t.doc.descendants((n,i)=>n.type.name===this.name?(r&&(n!=null&&n.nodeSize)&&(e.delete(i,i+n.nodeSize),o=!0),!1):!0),o}}},addNodeView(){return(0,qh.ReactNodeViewRenderer)(jh,{as:"div",className:"drag-placeholder-wrapper"})}});var Kh=require("@tiptap/core"),eu=require("@tiptap/pm/state"),Uv=new eu.PluginKey("file-handler"),_v=Kh.Extension.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new eu.Plugin({key:Uv,props:{handleDrop:(o,n,i,s)=>{var d;if(!((d=n.dataTransfer)!=null&&d.files)||s)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,s=Array.from(i).filter(c=>e==null?void 0:e.includes(c.type));return s.length===0?!1:(n.preventDefault(),r&&r(this.editor,s),!0)}}})]}}),tu=_v;var Gh=require("@tiptap/core"),ru=require("@tiptap/pm/state");var zv=new ru.PluginKey("fixedChannelPaste"),$v=a(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,s=0;n.forEach(d=>{d.type.name==="paragraph"||d.type.name==="heading"?i++:d.type.name==="button"&&s++});let l=i===1&&s===0,c=i===2&&s===0,u=i>=2&&i+s<=4;return l||c||u},"isInFixedChannel"),jv=a(e=>{let t=[],r=a(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(`
201
+ `).trim()},"extractTextFromSlice"),ou=Gh.Extension.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new ru.Plugin({key:zv,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!$v(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=jv(o);if(!u)return!1;r.preventDefault();let d=n.tr.replaceSelectionWith(n.schema.text(u),!1);return t.dispatch(d),!0}}})]},addStorage(){return{currentChannel:null}}});var Yh=require("@tiptap/core"),Vn=require("@tiptap/pm/state");var Si=a((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"),kp=a(e=>!!e.view.dom.closest(".courier-inbox-editor"),"isInInboxChannel"),Xh=a(e=>{if(!kp(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),s=r.start(o),l=0;return i.forEach((c,u)=>{if(r.start(o-1)+u+1===s)return!1;l++}),l<=1}o--}return!1},"isInFixedInboxNode"),Ii=a(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),s=r.end(o);return{start:i,end:s,node:n}}o--}return null},"getCurrentElementBounds"),nu=a(e=>{let{selection:t}=e.state,{$from:r,$to:o}=t;if(t.empty)return!1;let n=r.depth,i=o.depth,s=null,l=null;for(;n>0;){let c=r.node(n);if(c.type.name==="paragraph"||c.type.name==="heading"){s={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!!(s&&l&&s.node!==l.node)},"isMultiElementSelection"),iu=new Vn.PluginKey("fixedChannelSelection"),au=Yh.Extension.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!Si(e,this.options.channels))return!1;let o=Ii(e);if(!o)return!1;let{start:n,end:i}=o,{selection:s}=e.state;if(s.from>=n&&s.to<=i)return!1;let l=Math.max(s.from,n),c=Math.min(s.to,i);return r&&t.setSelection(Vn.TextSelection.create(t.doc,l,c)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!Si(e,this.options.channels))return!1;let t=Ii(e);if(!t)return!1;let{start:r,end:o}=t;return e.commands.setTextSelection({from:r,to:o}),!0},Backspace:({editor:e})=>{if(!Si(e,this.options.channels))return!1;if(kp(e)){let{selection:t}=e.state;if(Ii(e)&&t.$anchor.parentOffset===0&&Xh(e))return!0}if(nu(e)){let t=Ii(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),s=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:s})}return!0}return!1},Delete:({editor:e})=>{if(!Si(e,this.options.channels))return!1;if(kp(e)){let{selection:t}=e.state,r=Ii(e);if(r){let o=r.node.textContent;if(t.$anchor.parentOffset===o.length&&Xh(e))return!0}}if(nu(e)){let t=Ii(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),s=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:s})}return!0}return!1}}},addProseMirrorPlugins(){return[new Vn.Plugin({key:iu,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!Si(o,this.options.channels))return!1;if(nu(o)){let n=Ii(o);if(n){let{start:i,end:s}=n,l=Math.max(t,i),c=Math.min(r,s),u=e.state.tr;u.setSelection(Vn.TextSelection.create(u.doc,l,c)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!Si(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 s=n.node(i);if(s.type.name==="paragraph"||s.type.name==="heading"){e.dispatch(e.state.tr.setMeta(iu,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!Si(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&nu(r)){let n=iu.getState(e.state);if(n!=null&&n.elementStart&&(n!=null&&n.elementEnd)){let{selection:i}=e.state,s=Math.max(i.from,n.elementStart),l=Math.min(i.to,n.elementEnd),c=e.state.tr;return c.setSelection(Vn.TextSelection.create(c.doc,s,l)),e.dispatch(c),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(iu)||t}}})]}});var eb=require("@tiptap/core");var ka=require("@tiptap/core"),Qh=ka.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,(0,ka.mergeAttributes)(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>(0,ka.textblockTypeInputRule)({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var tb=require("@tiptap/react");var Pp=Qh.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){St(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:ve.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):ve.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:ve.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):ve.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:ve.textAlign,parseHTML:t=>t.style.textAlign||ve.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:ve.backgroundColor,parseHTML:t=>t.style.backgroundColor||ve.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:ve.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):ve.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderColor:{default:ve.borderColor,parseHTML:t=>t.style.borderColor||ve.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,eb.mergeAttributes)(this.options.HTMLAttributes,t),0]},addNodeView(){return(0,tb.ReactNodeViewRenderer)(nc)}});var Co=require("zod"),rb=Co.z.object({sourcePath:Co.z.string(),link:Co.z.string().optional(),alt:Co.z.string().optional(),alignment:Co.z.enum(["left","center","right"]),width:Co.z.number().min(1).max(100),borderWidth:Co.z.number(),borderColor:Co.z.string(),isUploading:Co.z.boolean().optional(),imageNaturalWidth:Co.z.number()});var ob=require("@hookform/resolvers/zod"),nb=require("jotai"),ib=require("lucide-react"),Bt=require("react"),ab=require("react-hook-form");var su=require("jotai"),Js=xe(require("react"),1),Ap=require("react");var qs=require("react/jsx-runtime"),Fn=Js.forwardRef(({as:e="Input",autoResize:t,onChange:r,...o},n)=>{let i=(0,Ap.useRef)(null),s=(0,Ap.useRef)(null),l=(0,su.useSetAtom)(ds),c=(0,su.useSetAtom)(h1),u=(0,su.useSetAtom)(Dl),d=Js.useCallback(()=>{if(!s.current)return;let h={ref:s.current,caretPosition:s.current.selectionStart};c(h),u(h),l({isFocused:!0,hasVariables:!1,showVariablePopup:!1})},[l,c,u]),p=Js.useCallback(h=>{var x;((x=h.relatedTarget)==null?void 0:x.closest("[data-variable-button]"))||(c({ref:null,caretPosition:null}),l({isFocused:!1,hasVariables:!1,showVariablePopup:!1}))},[l,c]),m=a(h=>{let y=h.target,x={ref:y,caretPosition:y.selectionStart};c(x),u(x)},"handleSelect"),f=a(h=>{r&&r(h)},"handleChange");if(e==="Input"){let h={...o,ref:y=>{s.current=y,typeof n=="function"?n(y):n&&(n.current=y)},onChange:f,onFocus:d,onBlur:p,onSelect:m};return(0,qs.jsx)("div",{ref:i,className:"courier-relative",children:(0,qs.jsx)(Ee,{...h})})}let v={...o,ref:h=>{s.current=h,typeof n=="function"?n(h):n&&(n.current=h)},onChange:f,onFocus:d,onBlur:p,autoResize:t,onSelect:m};return(0,qs.jsx)("div",{ref:i,className:"courier-relative",children:(0,qs.jsx)(Sd,{...v})})});Fn.displayName="TextInput";var q=require("react/jsx-runtime"),sb=a(({element:e,editor:t})=>{var S,P;let r=(0,Bt.useRef)(null),o=(0,Bt.useRef)(null),n=(0,Bt.useRef)(null),[i,s]=(0,Bt.useState)(""),[l,c]=(0,Bt.useState)(!1),[u,d]=(0,Bt.useState)(((S=e==null?void 0:e.attrs)==null?void 0:S.imageNaturalWidth)||0),[p,m]=(0,Bt.useState)(!1),f=(0,nb.useSetAtom)(ae),{uploadImage:v}=$i(),h=(0,ab.useForm)({resolver:(0,ob.zodResolver)(rb),defaultValues:{...Ct,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:y}=Ut({editor:t,element:e,form:h,nodeType:"imageBlock"});(0,Bt.useEffect)(()=>{var w;let k=(w=e==null?void 0:e.attrs)==null?void 0:w.sourcePath;if(k&&!u){let T=new Image;T.onload=()=>{d(T.naturalWidth);let A={...h.getValues(),imageNaturalWidth:T.naturalWidth};h.setValue("imageNaturalWidth",T.naturalWidth),y(A)},T.src=k}},[(P=e==null?void 0:e.attrs)==null?void 0:P.sourcePath,u,h,y]);let x=(0,Bt.useCallback)(k=>{var R,B;let w=(B=(R=t==null?void 0:t.view)==null?void 0:R.dom)==null?void 0:B.closest(".ProseMirror"),T=(w==null?void 0:w.clientWidth)||1e3;if(k||(k=u),!k)return 0;let A=Math.min(100,k/T*100);return Math.round(A)},[t,u]),E=(0,Bt.useCallback)(k=>{var w;k.preventDefault(),(w=r.current)==null||w.click()},[]),g=(0,Bt.useCallback)((k,w)=>{let T=x(k.naturalWidth);s(`${T}%`),c(!1),h.setValue("sourcePath",w),h.setValue("imageNaturalWidth",k.naturalWidth),h.setValue("width",T);let A={...h.getValues(),sourcePath:w,width:T,imageNaturalWidth:k.naturalWidth,isUploading:!1};y(A)},[h,y,x]),b=(0,Bt.useCallback)(k=>{if(!k){h.setValue("imageNaturalWidth",0),h.setValue("width",0),y({...h.getValues(),sourcePath:"",imageNaturalWidth:0,width:0});return}let w=new Image;w.onload=()=>{let T=x(w.naturalWidth);h.setValue("imageNaturalWidth",w.naturalWidth),h.setValue("width",T);let A={...h.getValues(),sourcePath:k,width:T,imageNaturalWidth:w.naturalWidth};y(A)},w.onerror=()=>{console.debug("Image failed to load:",k)},w.src=k},[h,y,x]),M=(0,Bt.useCallback)(k=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{b(k)},500)},[b]);(0,Bt.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]);let C=h.getValues().sourcePath;return e?(0,q.jsxs)(rt,{...h,children:[(0,q.jsx)(or,{type:"image"}),(0,q.jsxs)("form",{ref:o,onChange:()=>{let k=h.getValues();y(k)},children:[(0,q.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),(0,q.jsxs)(kl,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[(0,q.jsxs)(Ga,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[(0,q.jsx)(Xi,{value:"file",className:"courier-flex-1",children:"From file"}),(0,q.jsx)(Xi,{value:"url",className:"courier-flex-1",children:"From URL"})]}),(0,q.jsx)(Pl,{value:"file",children:(0,q.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,q.jsx)(Ve,{onClick:E,className:"courier-w-full",variant:"outline",type:"button",disabled:p,children:p?(0,q.jsx)(q.Fragment,{children:"Uploading..."}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ib.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),(0,q.jsx)("input",{ref:r,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:k=>{var T;let w=(T=k.target.files)==null?void 0:T[0];if(w){m(!0),h.setValue("sourcePath",""),y({...h.getValues(),sourcePath:"",isUploading:!0});let A=new FileReader;A.onload=async()=>{try{let R=(await v({file:w})).url,B=new Image;B.onload=()=>{g(B,R),m(!1)},B.onerror=()=>{f({message:"Upload failed: Failed to load uploaded image",toastProps:{duration:6e3,description:`File: ${w.name} (${(w.size/1024/1024).toFixed(2)}MB)`}}),m(!1),y({...h.getValues(),isUploading:!1})},B.src=R}catch(N){console.error("Error uploading image:",N),f({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${w.name} (${(w.size/1024/1024).toFixed(2)}MB)`}}),m(!1),y({...h.getValues(),isUploading:!1})}},A.onerror=()=>{f({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${w.name} (${(w.size/1024/1024).toFixed(2)}MB)`}}),m(!1),y({...h.getValues(),isUploading:!1})},A.readAsDataURL(w)}}})]})}),(0,q.jsx)(Pl,{value:"url",children:(0,q.jsx)(oe,{control:h.control,name:"sourcePath",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-mb-3",children:[(0,q.jsx)(re,{children:(0,q.jsx)(Fn,{as:"Textarea",...k,autoResize:!0,className:"courier-max-h-[88px]",onChange:w=>{k.onChange(w),M(w.target.value)}})}),(0,q.jsx)(ne,{})]})})})]}),(0,q.jsx)(oe,{control:h.control,name:"link",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-mb-3",children:[(0,q.jsx)(re,{children:(0,q.jsx)(yo,{placeholder:"Link",value:k.value,onChange:w=>{k.onChange(w),y({...h.getValues(),link:w})},showToolbar:!0})}),(0,q.jsx)(ne,{})]})}),(0,q.jsx)(oe,{control:h.control,name:"alt",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-mb-4",children:[(0,q.jsx)(re,{children:(0,q.jsx)(yo,{placeholder:"Alt text...",value:k.value,onChange:w=>{k.onChange(w),y({...h.getValues(),alt:w})},showToolbar:!0})}),(0,q.jsx)(ne,{})]})}),(0,q.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,q.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Width"}),(()=>{let k=h.getValues().width,w=h.getValues().imageNaturalWidth,T=x(w),A=k===T,N=A?"original":"fill";return(0,q.jsxs)(Xr,{type:"single",value:C?N:"original",onValueChange:R=>{if(!R||R===N)return;let B=R==="fill"?100:x(w);B>0&&(h.setValue("width",B),y({...h.getValues(),width:B}))},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",disabled:!C,children:[(0,q.jsx)(dr,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),(0,q.jsx)(dr,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:A||!C,children:"Fill"})]})})(),(0,q.jsx)(oe,{control:h.control,name:"width",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-flex-1 courier-mb-3",children:[(0,q.jsx)(re,{children:(0,q.jsx)(Ee,{type:"text",inputMode:"numeric",pattern:"[0-9]*",min:1,max:100,...k,value:h.getValues().sourcePath?l?i:`${k.value}%`:"0%",className:"courier-text-2xl courier-font-normal",disabled:!h.getValues().sourcePath,onFocus:w=>{c(!0),s(w.target.value)},onChange:w=>{s(w.target.value)},onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),w.currentTarget.blur())},onBlur:w=>{c(!1);let T=parseFloat(w.target.value.replace("%",""));if(!isNaN(T)){let A=Math.min(100,Math.max(1,T));k.onChange(A),y({...h.getValues(),width:Math.round(A)})}}})}),(0,q.jsx)(ne,{})]})}),(0,q.jsx)(oe,{control:h.control,name:"width",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-flex-1 courier-mb-3",children:[(0,q.jsx)(re,{children:(0,q.jsx)(Md,{min:0,max:100,value:[C?k.value:0],disabled:!C,onValueChange:w=>{k.onChange(w[0]),y({...h.getValues(),width:w[0]})}})}),(0,q.jsx)(ne,{})]})}),(0,q.jsx)(oe,{control:h.control,name:"alignment",render:({field:k})=>(0,q.jsxs)(te,{children:[(0,q.jsx)(re,{children:(0,q.jsxs)(Xr,{disabled:!C,type:"single",value:k.value,onValueChange:w=>{k.onChange(w),y({...h.getValues(),alignment:w})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,q.jsx)(dr,{size:"sm",value:"left",className:"courier-w-full",children:(0,q.jsx)(Uc,{className:"courier-h-4 courier-w-4"})}),(0,q.jsx)(dr,{size:"sm",value:"center",className:"courier-w-full",children:(0,q.jsx)(_c,{className:"courier-h-4 courier-w-4"})}),(0,q.jsx)(dr,{size:"sm",value:"right",className:"courier-w-full",children:(0,q.jsx)(zc,{className:"courier-h-4 courier-w-4"})})]})}),(0,q.jsx)(ne,{})]})}),(0,q.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,q.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,q.jsx)(oe,{control:h.control,name:"borderWidth",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-mb-3",children:[(0,q.jsx)(re,{children:(0,q.jsx)(Ee,{startAdornment:(0,q.jsx)(Qo,{}),type:"number",disabled:!C,min:0,...k,onChange:w=>{let T=parseInt(w.target.value)||0;k.onChange(T),y({...h.getValues(),borderWidth:T})}})}),(0,q.jsx)(ne,{})]})}),(0,q.jsx)(oe,{control:h.control,name:"borderColor",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-mb-4",children:[(0,q.jsx)(re,{children:(0,q.jsx)(Wt,{...k,disabled:!C,defaultValue:Ct.borderColor,onChange:w=>{k.onChange(w),y({...h.getValues(),[k.name]:w})}})}),(0,q.jsx)(ne,{})]})})]})]}):null},"ImageBlockForm");var Ks=require("@tiptap/core"),lb=xe(require("@tiptap/extension-link"),1),Pa=require("@tiptap/pm/state"),Mp=lb.default.extend({inclusive:!0,addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),hasVariables:{default:!1},originalHref:{default:null}}},parseHTML(){return[{tag:'a[href]:not([data-type="button"]):not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:e}){if(e.hasVariables&&e.originalHref)e.href=e.originalHref,delete e.hasVariables,delete e.originalHref;else if(e.href){let t=e.href;t.includes("__VAR_")&&(e.href=t.replace(/__VAR_([^_]+)__/g,"{{$1}}"))}return["a",(0,Ks.mergeAttributes)(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new Pa.Plugin({props:{handleClick:(r,o,n)=>{if(n.button!==0)return!1;let{state:i}=r,{doc:s}=i,l=s.resolve(o),c=l.marks().find(u=>u.type.name==="link");if(c||o>0&&(c=s.resolve(o-1).marks().find(d=>d.type.name==="link")),c||o<s.content.size&&(c=s.resolve(o+1).marks().find(d=>d.type.name==="link")),c){let u=(0,Ks.getMarkRange)(l,c.type);return u?(r.dispatch(i.tr.setSelection(Pa.TextSelection.create(s,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(Pa.TextSelection.create(s,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 Pa.Plugin({appendTransaction(r,o,n){if(!r.some(l=>l.docChanged))return null;let i=n.tr,s=!1;return n.doc.descendants((l,c)=>(l.marks.forEach(u=>{if(u.type.name==="link"&&u.attrs.href){let d=u.attrs.href;if(d.includes("__VAR_")){let p=d.replace(/__VAR_([^_]+)__/g,"{{$1}}");if(p!==d){let m=(0,Ks.getMarkRange)(n.doc.resolve(c),u.type);m&&(i.removeMark(m.from,m.to,u.type),i.addMark(m.from,m.to,u.type.create({...u.attrs,href:p,hasVariables:!0,originalHref:p})),s=!0)}}}}),!0)),s?i:null}})]}});var cb=require("@hookform/resolvers/zod"),ub=require("jotai"),cu=require("react"),db=require("react-hook-form"),lu=require("zod");var xo=require("react/jsx-runtime"),Zv=lu.z.object({href:lu.z.string(),openInNewTab:lu.z.boolean().default(!1)}),mb=a(({editor:e,mark:t,pendingLink:r})=>{let o=(0,ub.useSetAtom)(Hl),n=(0,cu.useRef)(null),i=(0,db.useForm)({resolver:(0,cb.zodResolver)(Zv),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1}});(0,cu.useEffect)(()=>{i.reset({href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1})},[t,i]);let s=a(async l=>{let c=l.href.trim();if(!c){r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),e==null||e.commands.unsetLink(),o(null);return}r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),await(e==null?void 0:e.chain().focus().unsetLink().setTextSelection({from:(r==null?void 0:r.from)||0,to:(r==null?void 0:r.to)||0}).setLink({href:c,target:l.openInNewTab?"_blank":null}).run()),e==null||e.commands.setTextSelection((r==null?void 0:r.to)||0),o(null)},"updateLink");return(0,xo.jsxs)(rt,{...i,children:[(0,xo.jsx)("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),(0,xo.jsx)("div",{className:"courier-space-y-4",children:(0,xo.jsx)(oe,{control:i.control,name:"href",render:({field:l})=>(0,xo.jsxs)(te,{children:[(0,xo.jsx)(Vo,{children:"URL"}),(0,xo.jsx)(re,{children:(0,xo.jsx)(Fn,{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(s)())},onBlur:()=>{l.onBlur(),i.handleSubmit(s)()}})}),(0,xo.jsx)(ne,{})]})})})]})},"LinkForm");var mu=require("@tiptap/react"),Aa=require("prosemirror-state");var cn={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:"'"},du={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},qv=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Jv=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ht=0;ht<10;ht++)cn[48+ht]=cn[96+ht]=String(ht);var ht;for(ht=1;ht<=24;ht++)cn[ht+111]="F"+ht;var ht;for(ht=65;ht<=90;ht++)cn[ht]=String.fromCharCode(ht+32),du[ht]=String.fromCharCode(ht);var ht;for(uu in cn)du.hasOwnProperty(uu)||(du[uu]=cn[uu]);var uu;function pb(e){var t=qv&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Jv&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?du:cn)[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}a(pb,"keyName");var fb=require("prosemirror-state");var Kv=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Gv(e){let t=e.split(/-(?!$)/),r=t[t.length-1];r=="Space"&&(r=" ");let o,n,i,s;for(let l=0;l<t.length-1;l++){let c=t[l];if(/^(cmd|meta|m)$/i.test(c))s=!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))Kv?s=!0:n=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(r="Alt-"+r),n&&(r="Ctrl-"+r),s&&(r="Meta-"+r),i&&(r="Shift-"+r),r}a(Gv,"normalizeKeyName");function Xv(e){let t=Object.create(null);for(let r in e)t[Gv(r)]=e[r];return t}a(Xv,"normalize");function Np(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}a(Np,"modifiers");function gb(e){return new fb.Plugin({props:{handleKeyDown:Yv(e)}})}a(gb,"keymap");function Yv(e){let t=Xv(e);return function(r,o){let n=pb(o),i,s=t[Np(n,o)];if(s&&s(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let l=t[Np(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=cn[o.keyCode])&&i!=n){let l=t[Np(i,o)];if(l&&l(r.state,r.dispatch,r))return!0}}return!1}}a(Yv,"keydownHandler");var hb=require("uuid");var Sp=pa.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){St(this.editor,this.name)},onTransaction(){let e=this.editor.state.tr,t=!1;this.editor.state.doc.descendants((r,o)=>{if(r.type.name===this.name&&!r.attrs.id){let n=`node-${(0,hb.v4)()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:ve.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):ve.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:ve.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):ve.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:ve.textAlign,parseHTML:e=>e.style.textAlign||ve.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:ve.backgroundColor,parseHTML:e=>e.style.backgroundColor||ve.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:ve.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):ve.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:ve.borderColor,parseHTML:e=>e.style.borderColor||ve.borderColor,renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="paragraph"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,mu.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return(0,mu.ReactNodeViewRenderer)(nc)},addProseMirrorPlugins(){return[gb({"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),s=r.end(o);if(e.from!==i||e.to!==s)return t.setSelection(Aa.TextSelection.create(t.doc,i,s)),!0}return!1}}),new Aa.Plugin({key:new Aa.PluginKey("preventElementDeletion"),props:{handleKeyDown:(e,t)=>{let r=t.key==="Delete"||t.key==="Backspace"||t.keyCode===8||t.keyCode===46||t.code==="Delete"||t.code==="Backspace",o=t.metaKey||t.ctrlKey||t.altKey;if(r){let{state:n}=e,{selection:i}=n,{$anchor:s}=i,l=s.depth,c=null;for(;l>0;){let u=s.node(l);if(u.type.name==="paragraph"||u.type.name==="heading"){c=u;break}l--}if(c){let u=c.textContent,d=s.parentOffset===0,p=s.parentOffset===u.length,m=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&&m)return!1;if(o||m&&!h||!f&&d&&!h||f&&p&&!h)return t.preventDefault(),t.stopPropagation(),!0}}return!1}}})]},addKeyboardShortcuts(){let e=a((t,r=!0)=>{let{empty:o,$anchor:n,$head:i}=t.state.selection,s=n.depth,l=null;for(;s>0;){let m=n.node(s);if(m.type.name==="paragraph"||m.type.name==="heading"){l=m;break}s--}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),s=r.end(o);return t.commands.setTextSelection({from:i,to:s}),!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()}}});var bb=require("@tiptap/core"),pu=require("@tiptap/pm/state"),Qv=new pu.PluginKey("selection"),Ip=bb.Extension.create({name:"selection",addOptions(){return{HTMLAttributes:{},setSelectedNode:()=>{},shouldHandleClick:()=>!0}},addGlobalAttributes(){return[{types:["paragraph","heading","button","spacer","divider","imageBlock","blockquote","customCode","column"],attributes:{isSelected:{default:!1,parseHTML:()=>!1,renderHTML:e=>e.isSelected?{class:"selected-element"}:{}}}}]},addCommands(){return{updateSelectionState:e=>({tr:t,dispatch:r})=>{var o,n;if(r){let i=(o=e==null?void 0:e.attrs)==null?void 0:o.id,s=(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===s:s&&(m=l.type.name===s&&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 pu.Plugin({key:Qv,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),s=o.doc.resolve(i).node();return s&&["paragraph","heading"].includes(s.type.name)?(this.options.setSelectedNode(s),this.editor.commands.updateSelectionState(s),!0):!1}}})]}});var kn=a(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),It=a(e=>{let t=kn(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");var yb=require("lucide-react"),vb=require("react"),Wp=require("react/jsx-runtime"),Cb=(0,vb.forwardRef)((e,t)=>(0,Wp.jsx)("button",{...e,ref:t,"data-cypress":"draggable-handle","data-drag-handle":!0,className:I("courier-flex-shrink-0 courier-p-1 courier-w-7 courier-h-7 courier-rounded-md courier-border courier-border-border courier-flex courier-items-center courier-justify-center courier-shadow-sm courier-bg-background hover:courier-bg-card courier-cursor-grab courier-select-none courier-z-10 courier-touch-none",e.className),style:{WebkitUserSelect:"none",userSelect:"none",touchAction:"none"},children:(0,Wp.jsx)(yb.GripVertical,{strokeWidth:1,className:"courier-w-5 courier-stroke-neutral-400 courier-fill-neutral-400 courier-pointer-events-none"})}));var Tb=require("jotai");var fu=require("react/jsx-runtime"),xb={text:"Text",heading:"Heading",spacer:"Spacer",divider:"Divider",button:"Button",image:"Image",customCode:"Custom code",column:"Column layout",blockquote:"Blockquote"},eC=a(e=>e.includes(":"),"isPresetType"),tC=a(e=>{let t=e.split(":");return t.length===2?{blockType:t[0],presetKey:t[1]}:null},"parsePresetType"),gu=a(({type:e})=>{let t=(0,Tb.useAtomValue)(bn),r=a(o=>{if(!o)return"Drop here";if(eC(o)){let n=tC(o);if(n){let s=t.find(l=>l.type===n.blockType&&l.key===n.presetKey);if(s)return s.label}let i=o.split(":")[0];return xb[i]||"Drop here"}return xb[o]||"Drop here"},"getPlaceholderLabel");return(0,fu.jsx)("div",{className:"courier-flex courier-w-full courier-pointer-events-none",children:(0,fu.jsx)("div",{className:I("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50 courier-ml-10","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md courier-drag-indicator dark:courier-border-accent"),children:(0,fu.jsx)("div",{className:"courier-text-accent-foreground dark:courier-text-accent",children:r(e)})})})},"DropIndicatorPlaceholder");var lt=require("react/jsx-runtime");function rC(){let[e,t]=(0,Be.useState)(!1);return(0,Be.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}a(rC,"useMountStatus");var rr=a(({children:e,id:t,className:r,editor:o,getPos:n,...i})=>{let s=(0,Be.useRef)(null),l=(0,Be.useRef)(null),c=(0,Be.useRef)(null),[u,d]=(0,Be.useState)(!1),[p,m]=(0,Be.useState)(null),[f,v]=(0,Be.useState)(null),h=(0,Be.useRef)(null),y=(0,Be.useRef)(!1),x=(0,Be.useRef)(null),E=(0,Be.useRef)(null),g=(0,Be.useRef)(null),b=rC(),M=u&&!b,C=(0,Be.useCallback)(()=>{if(!o||!t)return null;let P=null;return o.state.doc.descendants((k,w,T)=>{var A;if(((A=k.attrs)==null?void 0:A.id)===t){let N=0;return T&&T.content.forEach((R,B,H)=>{R===k&&(N=H)}),P={node:k,pos:w,parent:T,index:N},!1}return!0}),P},[t,o]),S=(0,Be.useCallback)(()=>{if(!o)return!1;let P=C();return!P||!P.parent?!1:P.index===P.parent.childCount-1},[o,C]);return(0,Be.useEffect)(()=>{let P=s.current,k=l.current;if(!P)return;let w=Wo(bs({element:P,dragHandle:k||void 0,getInitialData:()=>{var B,H,D,F,L,W;let T=C(),A="text";if(T){let _=T.node;switch(_.type.name){case"heading":A="heading";break;case"paragraph":A="text";break;case"imageBlock":A="image";break;case"divider":A=(B=_.attrs)!=null&&B.spacer?"spacer":"divider";break;case"button":A="button";break;case"customCode":A="customCode";break;case"column":A="column";break}}let N=(T==null?void 0:T.parent)===o.state.doc,R=((H=T==null?void 0:T.parent)==null?void 0:H.type.name)==="columnCell";return{id:t,type:N?"editor":R?"column-cell-item":"nested-drag",index:(D=T==null?void 0:T.index)!=null?D:0,dragType:A,pos:T==null?void 0:T.pos,originalIndex:(F=T==null?void 0:T.index)!=null?F:0,columnId:R?(L=T==null?void 0:T.parent)==null?void 0:L.attrs.columnId:void 0,cellIndex:R?(W=T==null?void 0:T.parent)==null?void 0:W.attrs.index:void 0}},onGenerateDragPreview:()=>{let T=P.querySelectorAll("[data-no-drag-preview]"),A=[];T.forEach((N,R)=>{let B=N;A[R]=B.style.display,B.style.display="none"}),requestAnimationFrame(()=>{T.forEach((N,R)=>{let B=N;B.style.display=A[R]})})},onDragStart:()=>{d(!0),document.body.style.cursor="grabbing";let T=a(A=>{E.current=A.clientY},"handleMouseMove");document.addEventListener("mousemove",T),g.current=()=>{document.removeEventListener("mousemove",T)},o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{d(!1),document.body.style.cursor="",g.current&&(g.current(),g.current=null),o&&o.setEditable(!0)}}),Wr({element:P,getData:({input:T,element:A})=>{var W,_,V,j;let N=C(),R=(N==null?void 0:N.parent)===o.state.doc,B=((W=N==null?void 0:N.parent)==null?void 0:W.type.name)==="columnCell",H={id:t,type:R?"editor":B?"column-cell-item":"nested-drag",index:(_=N==null?void 0:N.index)!=null?_:0,pos:N==null?void 0:N.pos,nodeType:N==null?void 0:N.node.type.name,columnId:B?(V=N==null?void 0:N.parent)==null?void 0:V.attrs.columnId:void 0,cellIndex:B?(j=N==null?void 0:N.parent)==null?void 0:j.attrs.index:void 0};if(A.getAttribute("data-node-type")==="column"){let J=A.getBoundingClientRect(),G=T.clientY,X=30,U=Math.abs(G-J.top),K=Math.abs(G-J.bottom);if(U>X&&K>X)return{...H,disableDropIndicator:!0}}let F=A.closest('[data-column-cell="true"]');if(S()&&P){let J=P.getBoundingClientRect(),G=T.clientY,X=J.top+J.height/2;if(G>=X&&G>J.bottom)return{...H,[Symbol.for("closestEdge")]:"bottom"}}let L=S()?["top","bottom"]:["top"];return cg(H,{input:T,element:A,allowedEdges:L})},canDrop:({source:T})=>T.data.id!==t,onDragEnter:({self:T,source:A,location:N})=>{var _,V,j,J,G;if(T.data.disableDropIndicator){m(null);return}x.current&&(clearTimeout(x.current),x.current=null);let R=N.current.dropTargets;if(R.length>0&&R[0].element!==P){m(null),y.current=!1,h.current=null;return}let B=ys(T.data),H=B,D=S(),F=(j=(V=(_=N==null?void 0:N.current)==null?void 0:_.input)==null?void 0:V.clientY)!=null?j:E.current;F!==null&&(E.current=F);let L=A.data;v(L.dragType||null),B==="bottom"&&D&&A.data.id===t&&(H=null);let W=A.data.type==="editor"||A.data.type==="column-cell-item";if(D&&W)if(B==="top"){let X=s.current;if(X){let U=X.getBoundingClientRect(),K=(J=F!=null?F:E.current)!=null?J:U.top+U.height/2,de=U.top+U.height/2,me=U.height,Me=Math.max(10,Math.min(30,me*.3));K<de-Me?(y.current=!1,H="top"):y.current?H="bottom":H="top"}else y.current=!1,H="top"}else y.current?H="bottom":B==="bottom"&&(y.current=!0,H="bottom");else D&&!W&&(y.current=!1);if(!y.current&&(A.data.type==="editor"||A.data.type==="column-cell-item")&&typeof A.data.index=="number"){let X=A.data.index,U=C();((G=U==null?void 0:U.index)!=null?G:0)===X+1&&B==="top"&&(H=null)}H!==h.current&&(h.current=H,m(H))},onDrag:({self:T,source:A,location:N})=>{var _,V,j,J,G;if(T.data.disableDropIndicator){m(null);return}x.current&&(clearTimeout(x.current),x.current=null);let R=N.current.dropTargets;if(R.length>0&&R[0].element!==P){m(null);return}let B=(j=(V=(_=N==null?void 0:N.current)==null?void 0:_.input)==null?void 0:V.clientY)!=null?j:E.current;B!==null&&(E.current=B);let H=ys(T.data),D=H,F=S(),L=A.data;v(L.dragType||null),H==="bottom"&&F&&A.data.id===t&&(D=null);let W=A.data.type==="editor"||A.data.type==="column-cell-item";if(F&&W)if(H==="top"){let X=s.current;if(X){let U=X.getBoundingClientRect(),K=(J=B!=null?B:E.current)!=null?J:U.top+U.height/2,de=U.top+U.height/2,me=U.height,Me=Math.max(10,Math.min(30,me*.3));K<de-Me?(y.current=!1,D="top"):y.current?D="bottom":D="top"}else y.current=!1,D="top"}else y.current?D="bottom":H==="bottom"&&(y.current=!0,D="bottom");else F&&!W&&(y.current=!1);if(!y.current&&(A.data.type==="editor"||A.data.type==="column-cell-item")&&typeof A.data.index=="number"){let X=A.data.index,U=C();((G=U==null?void 0:U.index)!=null?G:0)===X+1&&H==="top"&&(D=null)}D!==h.current&&(h.current=D,m(D))},onDragLeave:()=>{if(S()&&y.current){let T=P==null?void 0:P.getBoundingClientRect(),A=E.current;if(T&&A!==null&&A>=T.bottom-10)return;x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{y.current=!1,h.current=null,m(null),v(null),x.current=null},150)}else x.current&&(clearTimeout(x.current),x.current=null),y.current=!1,h.current=null,m(null),v(null)},onDrop:()=>{x.current&&(clearTimeout(x.current),x.current=null),y.current=!1,h.current=null,m(null),v(null)}}));return()=>{x.current&&(clearTimeout(x.current),x.current=null),w()}},[t,S,o,C]),(0,lt.jsx)(oC,{ref:s,id:t,fadeIn:M,className:r,dragging:u,closestEdge:p,dragType:f,handleRef:l,contentRef:c,editor:o,...i,children:e})},"SortableItemWrapper"),oC=(0,Be.forwardRef)(({children:e,className:t,dragOverlay:r,handleRef:o,contentRef:n,closestEdge:i,dragType:s,id:l,editor:c,fadeIn:u,dragging:d,...p},m)=>{(0,Be.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let f=(0,wb.useSetAtom)(we),{resetButtonFormatting:v}=Hc(c),h=a((C,S)=>{let P=null;return C.doc.descendants((k,w)=>{var T;return P!==null?!1:((T=k.attrs)==null?void 0:T.id)===S?(P=w,!1):!0}),P},"findNodePositionById"),y=(0,Be.useCallback)(()=>{if(!c||!l)return{node:null,pos:null};let C=h(c.state,l);return C===null?{node:null,pos:null}:{node:c.state.doc.nodeAt(C),pos:C}},[c,l]),x=(0,Be.useCallback)(()=>{c.commands.blur(),f(null)},[c,f]),E=(0,Be.useCallback)(()=>{if(!(!c||!l))try{let{node:C,pos:S}=y();if(!C||S===null)return;let P=C.nodeSize,k=c.state.doc.childCount===1;f(null),c.commands.updateSelectionState(null);let w=c.state.tr;w.delete(S,S+P),w.setMeta("addToHistory",!0),c.view.dispatch(w),k&&setTimeout(()=>{let T=c.state.doc.nodeAt(0);if(T&&T.type.name==="paragraph"&&!T.attrs.id){let A=`node-${(0,kb.v4)()}`,N=c.state.tr;N.setNodeMarkup(0,void 0,{...T.attrs,id:A}),c.view.dispatch(N);let R=new CustomEvent("node-duplicated",{detail:{newNodeId:A}});document.dispatchEvent(R)}},50)}catch(C){console.error("Error deleting node:",C)}},[c,l,y,f]),g=(0,Be.useCallback)(()=>{if(!(!c||!l))try{let{node:C,pos:S}=y();if(!C||S===null)return;if(C.type.name==="button"){v();return}let P=C.type.name==="blockquote",k=C.type.name==="heading";!P&&!k&&x(),setTimeout(()=>{if(k){let T=S+1,A=S+C.nodeSize-1;c.chain().setTextSelection({from:T,to:A}).unsetAllMarks().blur().run(),f(null),c.commands.updateSelectionState(null);return}let w=c.chain();if(w.setNodeSelection(S).unsetAllMarks(),P&&C.content&&C.content.firstChild?C.content.firstChild.type.name!=="paragraph"&&w.setParagraph():C.type.name!=="paragraph"&&!P&&w.setParagraph(),w.run(),P){let T=y();T.node&&T.pos!==null&&(f(T.node),c.commands.updateSelectionState(T.node))}},100)}catch(C){console.error("Error removing formatting:",C)}},[c,l,y,x,v,f]),b=(0,Be.useCallback)(()=>{if(!(!c||!l))try{x(),setTimeout(()=>{let{node:C,pos:S}=y();if(!C||S===null)return;let P=C.type.name,k={...C.attrs};delete k.id;let w=S+(C==null?void 0:C.nodeSize);dc(c,P,w,k,T=>f(T),C.content)},100)}catch(C){console.error("Error duplicating node:",C)}},[c,l,y,x,f]),{node:M}=y();return(0,lt.jsxs)(Eb.NodeViewWrapper,{ref:m,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":l,className:I("courier-flex courier-flex-col courier-relative draggable-item",t),...p,children:[i==="top"&&(0,lt.jsx)(gu,{type:s}),(0,lt.jsxs)("div",{className:"courier-flex courier-items-center courier-justify-center courier-gap-2 courier-pl-10",children:[(0,lt.jsx)(Cb,{ref:o,className:"courier-absolute courier-left-[-8px]",tabIndex:-1,"data-no-drag-preview":!0}),(0,lt.jsx)("div",{ref:n,className:"courier-flex-1 courier-grow draggable-content-wrapper",children:e}),(0,lt.jsxs)("div",{"data-no-drag-preview":!0,className:I("courier-actions-panel courier-absolute courier-right-[-50px] courier-rounded-lg courier-border courier-border-border courier-bg-background courier-shadow-md courier-hidden courier-items-center courier-justify-center hover:courier-z-[100000]",d&&"!courier-hidden"),children:[(M==null?void 0:M.type.name)!=="imageBlock"&&(M==null?void 0:M.type.name)!=="divider"&&(M==null?void 0:M.type.name)!=="spacer"&&(M==null?void 0:M.type.name)!=="button"&&(M==null?void 0:M.type.name)!=="column"&&(M==null?void 0:M.type.name)!=="customCode"&&(0,lt.jsxs)(lt.Fragment,{children:[(0,lt.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.stopPropagation(),g()},tabIndex:-1,children:(0,lt.jsx)(am,{color:"currentColor"})}),(0,lt.jsx)(ge,{className:"!courier-my-0"})]}),(0,lt.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.stopPropagation(),b()},tabIndex:-1,children:(0,lt.jsx)(Wd,{color:"currentColor"})}),(0,lt.jsx)(ge,{className:"!courier-my-0"}),(0,lt.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#DC2626] dark:courier-text-red-500 dark:hover:courier-bg-secondary",onMouseDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.stopPropagation(),E()},tabIndex:-1,children:(0,lt.jsx)(Xa,{color:"currentColor"})})]})]}),i==="bottom"&&(0,lt.jsx)(gu,{type:s})]})});var hu=require("@tiptap/react"),bu=require("jotai"),Ma=require("react");var On=require("react/jsx-runtime"),nC=a(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderLeftWidth:o,borderColor:n})=>(0,On.jsx)("div",{className:"courier-w-full node-element",children:(0,On.jsx)("div",{style:{position:"relative",padding:`${t}px ${e}px`,backgroundColor:r,borderLeftWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",whiteSpace:"pre-wrap"},children:(0,On.jsx)(hu.NodeViewContent,{})})}),"BlockquoteComponent"),Pb=a(e=>{var l,c,u;let t=(0,bu.useSetAtom)(dt),r=(0,bu.useAtomValue)(we),o=(0,Ma.useRef)(null),n=((l=r==null?void 0:r.type)==null?void 0:l.name)==="blockquote"&&(((c=r==null?void 0:r.attrs)==null?void 0:c.id)===e.node.attrs.id||!((u=r==null?void 0:r.attrs)!=null&&u.id)&&!e.node.attrs.id&&r===e.node),i=(0,Ma.useCallback)(()=>{if(!e.editor.isEditable)return;let d=e.node;d&&(t(d),e.editor.commands.updateSelectionState(d))},[e.editor.isEditable,e.node,e.editor.commands,t]);(0,Ma.useEffect)(()=>{let d=o.current;if(!d)return;let p=a(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 s=!e.node.content||e.node.content.size===0;return(0,On.jsx)(hu.NodeViewWrapper,{children:(0,On.jsx)("div",{ref:o,children:(0,On.jsx)(rr,{id:e.node.attrs.id,className:I(n&&"selected-element",s&&"is-empty"),editor:e.editor,children:(0,On.jsx)(nC,{...e.node.attrs})})})})},"BlockquoteComponentNode");var _o={paddingHorizontal:8,paddingVertical:6,backgroundColor:"transparent",borderLeftWidth:4,borderColor:"#e0e0e0"},Op=ug.extend({content:"block+",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){St(this.editor,this.name)},addAttributes(){return{id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},paddingHorizontal:{default:_o.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:_o.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:_o.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderLeftWidth:{default:_o.borderLeftWidth,parseHTML:e=>e.getAttribute("data-border-left-width"),renderHTML:e=>({"data-border-left-width":e.borderLeftWidth})},borderColor:{default:_o.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,Ab.mergeAttributes)(e,{"data-type":"blockquote","data-id":e.id}),0]},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let{selection:t}=e.state,{empty:r}=t;if(!r)return!1;let o=e.isActive("blockquote");return!e.isActive("paragraph")||!o?!1:e.chain().command(({tr:i})=>{i.split(t.from);let s=i.selection.from,l=i.doc.resolve(s);if(l.depth>1){let c=l.blockRange();c&&i.lift(c,0)}return!0}).focus().run()}}},addNodeView(){return(0,Mb.ReactNodeViewRenderer)(Pb)}});var Nb=require("uuid"),$o=require("jotai"),Jt=require("react");var Na=a(({items:e,setItems:t,editor:r})=>{let[o]=(0,Jt.useState)(null),[n,i]=(0,Jt.useState)(null),[s,l]=(0,Jt.useState)(null),[c]=(0,Jt.useState)("outer"),u=(0,Jt.useRef)([]),d=(0,Jt.useRef)([]),p=(0,$o.useAtomValue)(He),m=(0,$o.useSetAtom)(Cr),[f,v]=(0,$o.useAtom)(le),h=(0,$o.useSetAtom)(it),y=(0,$o.useAtomValue)(xn),x=(0,$o.useAtomValue)(bn),E=(0,$o.useAtomValue)(dl),g=r||p,b=(0,Jt.useCallback)(()=>{if(!g)return;let w=g.getJSON(),T=be(w),A=Nt(f,{channel:y,elements:T});v(A),h(A)},[g,y,f,v,h]),M=(0,Jt.useCallback)(()=>{g==null||g.commands.removeDragPlaceholder(),t(w=>({...w,Editor:w.Editor.filter(T=>!T.toString().includes("_temp"))}))},[g==null?void 0:g.commands,t]),C=(0,Jt.useCallback)(w=>{try{let T=g==null?void 0:g.state.doc;if(!T||w===0)return 0;if(w>=T.childCount)return T.content.size;let A=0;for(let N=0;N<Math.min(w,T.childCount);N++){let R=T.child(N);A+=R.nodeSize}return A}catch(T){return console.error("Error calculating document position:",T),0}},[g==null?void 0:g.state.doc]),S=(0,Jt.useCallback)(w=>{let T=w.includes(":"),A=w,N=null;if(T){let F=w.split(":");A=F[0],N=F[1]}let R={};switch(A){case"text":R=ve;break;case"heading":R={};break;case"image":R=Ct;break;case"button":R=at;break;case"divider":R=_r;break;case"spacer":R=da;break;case"customCode":R=rn;break;case"column":R=_t;break;case"blockquote":R=_o;break}let B=E[A];if(B&&(R={...R,...B}),T&&N){let F=x.find(L=>L.type===A&&L.key===N);F!=null&&F.attributes&&(R={...R,...F.attributes})}let D={type:A==="text"?"paragraph":A==="image"?"imageBlock":A==="spacer"?"divider":A,attrs:{...R,id:(0,Nb.v4)()}};if(A==="button"){let F="Button";if(T&&N){let L=x.find(W=>W.type===A&&W.key===N);L!=null&&L.label&&(F=L.label)}D.content=[{type:"text",text:F}]}return D},[E,x]),P=(0,Jt.useCallback)((w,T)=>{if(!g)return;let{columnId:A,index:N,isEmpty:R}=T,B=null,H=0,D=-1;if(w.type==="sidebar"){if(!w.dragType)return;B=S(w.dragType)}else if(w.type==="editor"){if(g.state.doc.descendants((V,j)=>V.attrs.id===w.id?(D=j,B=V.toJSON(),H=V.nodeSize,!1):!0),D===-1){let V=e.Editor.findIndex(j=>j===w.id);if(V!==-1){D=C(V);let j=g.state.doc.nodeAt(D);j&&(B=j.toJSON(),H=j.nodeSize)}}if(D!==-1){let V=e.Editor.filter(j=>j!==w.id);V.length!==e.Editor.length&&t({...e,Editor:V})}}if(!B)return;let F=-1,L=null;if(g.state.doc.descendants((V,j)=>V.type.name==="column"&&V.attrs.id===A?(F=j,L=V,!1):!0),F===-1||!L)return;let W=L;D!==-1&&D<F&&(F-=H);let _=g.state.tr;if(D!==-1&&_.delete(D,D+H),R){let V=g.schema,j=Array.from({length:W.attrs.columnsCount},(G,X)=>V.nodes.columnCell.create({index:X,columnId:A,isEditorMode:!1},X===N?[V.nodeFromJSON(B)]:[])),J=V.nodes.columnRow.create({},j);_.replaceWith(F+1,F+W.nodeSize-1,J)}else{let V=F+1;W.content.forEach(j=>{if(j.type.name==="columnRow"){let J=V+1;j.content.forEach((G,X,U)=>{if(U===N){let K=J+G.nodeSize-1;_.insert(K,g.schema.nodeFromJSON(B))}J+=G.nodeSize})}V+=j.nodeSize})}g.view.dispatch(_),b()},[g,e,t,C,S,b]),k=(0,Jt.useCallback)((w,T)=>{try{if(w.type==="sidebar"&&(T.type==="editor"||T.type==="column-cell-item"||T.type==="nested-drag")){let A=w.dragType;if(!A||!g)return;let N=T.insertPos;if(N===void 0)if(T.type==="editor"){let H=T.index+1;N=C(H)}else{console.warn("Nested drop without position data");return}let R=S(A);if(g.commands.insertContentAt(N,R),g.state.doc.resolve(N).depth===0){let H=g.state.doc.resolve(N).index(0),D=[...e.Editor];H<=D.length&&(D.splice(H,0,R.attrs.id),t({...e,Editor:D}))}b();return}if((w.type==="editor"||w.type==="column-cell-item"||w.type==="nested-drag")&&(T.type==="editor"||T.type==="column-cell-item"||T.type==="nested-drag")){if(!g)return;let A=-1,N=null;if(w.pos!==void 0&&(A=w.pos,N=g.state.doc.nodeAt(A)),(A===-1||!N)&&g.state.doc.descendants((D,F)=>D.attrs.id===w.id?(A=F,N=D,!1):!0),A===-1||!N){let D=e.Editor.findIndex(F=>F===w.id);D!==-1&&(A=C(D),N=g.state.doc.nodeAt(A))}if(!N||A===-1)return;let R=T.insertPos;if(R===void 0){let D;T.index===void 0?D=g.state.doc.childCount:T.index===-1?D=0:D=T.index+1,R=C(D)}if(R===void 0||R>A&&R<A+N.nodeSize)return;if(R>A){let D=R-N.nodeSize;g.chain().deleteRange({from:A,to:A+N.nodeSize}).insertContentAt(D,N.toJSON()).run()}else g.chain().insertContentAt(R,N.toJSON()).deleteRange({from:A+N.nodeSize,to:A+N.nodeSize*2}).run();let B=e.Editor.includes(w.id);if(B){let D=e.Editor.filter(F=>F!==w.id);t({...e,Editor:D})}let H=g.state.doc.resolve(R).depth===0;b()}}catch(A){console.error("[Pragmatic DnD] Error in handleDrop:",A)}},[e,g,t,C,b,S]);return(0,Jt.useEffect)(()=>Rm({onDragStart:({source:w})=>{let T=w.data;m(!0),l(T.id),T.dragType&&i(T.dragType);let A=g==null?void 0:g.view.dom.querySelectorAll('[data-node-type="column"]');A&&(u.current=Array.from(A).map(R=>R.getBoundingClientRect()));let N=g==null?void 0:g.view.dom.querySelectorAll("[data-node-view-wrapper]");if(N){let R=new Set,B=Array.from(N).filter(H=>{let D=H,F=D.parentElement;if(F!=null&&F.hasAttribute("data-column-cell"))return!1;let L=D.getBoundingClientRect(),W=L.top+L.height/2;return R.has(Math.round(W))?!1:(R.add(Math.round(W)),!0)});d.current=B.map(H=>H.getBoundingClientRect())}},onDrop:({source:w,location:T})=>{let A=w.data,N=T.current.dropTargets[0];if(!N){M(),m(!1),l(null),i(null);return}let R=N.data;if(R.type==="column-cell"){P(A,R),m(!1),l(null),i(null),M();return}let B=R,H=ys(N.data);if(B.pos!==void 0&&H&&g){let D=g.state.doc.nodeAt(B.pos);D&&(H==="top"?B.insertPos=B.pos:H==="bottom"&&(B.insertPos=B.pos+D.nodeSize))}if(B.insertPos===void 0&&H&&B.index!==void 0){let D=H==="top"?B.index-1:B.index;B={...B,index:D}}else if(B.index===void 0&&B.insertPos===void 0){let F=T.current.input.clientY;if(d.current.length>0){let L=0,W=1/0;d.current.forEach((G,X)=>{let U=G.top+G.height/2,K=Math.abs(F-U);K<W&&(W=K,L=X)});let _=d.current[L],V=_.top+_.height/2,J=F>=V?L:L-1;B={...B,index:J,fromCoordinates:!0}}else B={...B,index:(g==null?void 0:g.state.doc.childCount)||0}}k(A,B),m(!1),l(null),i(null),M()}}),[g,m,M,l,i,k,P]),{activeId:s,activeDragType:n,dndMode:c,lastPlaceholderIndex:o,cleanupPlaceholder:M}},"usePragmaticDnd");var yu=require("react");var Sb=require("jotai");var vu=a(({setItems:e,rafId:t,editor:r})=>{let o=(0,Sb.useAtomValue)(He),n=r||o,i=(0,yu.useCallback)(s=>{t.current&&typeof cancelAnimationFrame!="undefined"&&cancelAnimationFrame(t.current);let l=setTimeout(()=>{if(typeof requestAnimationFrame!="undefined")t.current=requestAnimationFrame(()=>{try{let c=s==null?void 0:s.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 v=m.parentElement,h=!1;for(;v&&v!==c;){if(v.hasAttribute("data-column-cell")){h=!0;break}v=v.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=s==null?void 0:s.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 v=m.parentElement,h=!1;for(;v&&v!==c;){if(v.hasAttribute("data-column-cell")){h=!0;break}v=v.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(0,yu.useEffect)(()=>{if(!n||typeof n.on!="function")return;let s,l=a(()=>{n&&(s&&s(),s=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=a(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),s&&s(),t.current&&typeof cancelAnimationFrame!="undefined"&&(cancelAnimationFrame(t.current),t.current=null)}},[n,i,t]),{syncEditorItems:i}},"useSyncEditorItems");var Sa=require("react/jsx-runtime"),Gs=[{type:"text",align:"left",content:`
202
+ `,text_style:"h1"},{type:"text",align:"left",content:""},{type:"image",src:""}],iC=(0,Re.forwardRef)(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:s,colorScheme:l,hidePreviewPanelExitButton:c,...u},d)=>{let p=(0,pr.useAtomValue)(He),[m,f]=(0,pr.useAtom)(we),[v,h]=(0,pr.useAtom)(Gn),y=(0,Re.useRef)({}),[x,E]=(0,Re.useState)(c?"desktop":void 0),g=(0,pr.useAtomValue)(bt),b=(0,pr.useAtomValue)(pe),M=(0,pr.useAtomValue)(rd),C=(0,pr.useAtomValue)(Oo),S=(0,Re.useRef)(-1),P=(0,pr.useSetAtom)(g1),k=(0,Re.useRef)(!1),w=(0,Re.useRef)(!1),[T]=(0,pr.useAtom)(le),A=(0,pr.useAtomValue)(lo),N=(0,pr.useAtomValue)(Ft),R=(0,pr.useAtomValue)(Ho),[B,H]=(0,Re.useState)({Editor:[],Sidebar:R});(0,Re.useEffect)(()=>{H(U=>({...U,Sidebar:R}))},[R]);let D=(0,Re.useRef)(null);Na({items:B,setItems:H,editor:p});let{syncEditorItems:F}=vu({setItems:H,rafId:D,editor:p});(0,Re.useEffect)(()=>{N&&(w.current=!1)},[N]);let[L,W]=(0,Re.useState)(!1);(0,Re.useEffect)(()=>{if(b===!1||b===null){let U=setTimeout(()=>{W(!0)},100);return()=>clearTimeout(U)}else W(!1)},[b,L]),(0,Re.useEffect)(()=>{if(m){let U=m.type.name,K=Bl(U);P({nodeName:U,config:K})}},[m,P]);let _=(0,Re.useMemo)(()=>{var K,de,me,Me,We,Pt,Ht,ar,Vt,Yt,At,Qt,et,ut,ce,Te,ke,ie,nt,sr,lr,Ro,Lo,jn,Zn,qn,O,z,$,Y,ee,fe,$e,Ue;if(C)return C;let U=(me=(de=(K=g==null?void 0:g.data)==null?void 0:K.tenant)==null?void 0:de.brand)==null?void 0:me.settings;return{brandColor:((Me=U==null?void 0:U.colors)==null?void 0:Me.primary)||"#000000",textColor:((We=U==null?void 0:U.colors)==null?void 0:We.secondary)||"#000000",subtleColor:((Pt=U==null?void 0:U.colors)==null?void 0:Pt.tertiary)||"#666666",headerStyle:(ar=(Ht=U==null?void 0:U.email)==null?void 0:Ht.header)!=null&&ar.barColor?"border":"plain",logo:(At=(Yt=(Vt=U==null?void 0:U.email)==null?void 0:Vt.header)==null?void 0:Yt.logo)==null?void 0:At.image,link:(ut=(et=(Qt=U==null?void 0:U.email)==null?void 0:Qt.header)==null?void 0:et.logo)==null?void 0:ut.href,facebookLink:(ie=(ke=(Te=(ce=U==null?void 0:U.email)==null?void 0:ce.footer)==null?void 0:Te.social)==null?void 0:ke.facebook)==null?void 0:ie.url,linkedinLink:(Ro=(lr=(sr=(nt=U==null?void 0:U.email)==null?void 0:nt.footer)==null?void 0:sr.social)==null?void 0:lr.linkedin)==null?void 0:Ro.url,instagramLink:(qn=(Zn=(jn=(Lo=U==null?void 0:U.email)==null?void 0:Lo.footer)==null?void 0:jn.social)==null?void 0:Zn.instagram)==null?void 0:qn.url,mediumLink:(Y=($=(z=(O=U==null?void 0:U.email)==null?void 0:O.footer)==null?void 0:z.social)==null?void 0:$.medium)==null?void 0:Y.url,xLink:(Ue=($e=(fe=(ee=U==null?void 0:U.email)==null?void 0:ee.footer)==null?void 0:fe.social)==null?void 0:$e.twitter)==null?void 0:Ue.url}},[C,g]),V=M&&!!_,j=(0,Re.useCallback)(()=>{Object.values(y.current).forEach(U=>clearTimeout(U)),y.current={}},[]);(0,Re.useEffect)(()=>()=>{j()},[j]),(0,Re.useEffect)(()=>{let U=a(K=>{if(K.key==="Escape"&&(f(null),p==null||p.commands.blur(),S.current=-1),K.key==="Tab"&&p){K.preventDefault();let de=-1;m&&p.state.doc.content.forEach((We,Pt,Ht)=>{m.attrs.id===We.attrs.id&&(de=Ht)}),de===-1&&(de=0);let me=p.state.doc,Me;if(K.shiftKey?Me=(de-1+me.childCount)%me.childCount:Me=(de+1)%me.childCount,Me!==de||m===null){let We=me.child(Me);f(We),p.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",U),()=>{document.removeEventListener("keydown",U)}},[p,m,f]),(0,Re.useEffect)(()=>{if(b!==!1||N)return;let U=T!=null?T:"";if(U){let K=fd(U,"email");h(K||"")}setTimeout(()=>{if(!(!p||p.isDestroyed)&&p.state.doc.childCount===1){let K=p.state.doc.child(0);f(K)}},0)},[g,b,N,p,h,f,T]),(0,Re.useEffect)(()=>{b===!1&&g&&!w.current&&(w.current=!0,setTimeout(()=>{p&&!p.isDestroyed&&F(p)},300))},[b,g,p,F]),(0,Re.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let J=(0,Re.useCallback)(U=>{let de=U||(x===void 0?"desktop":void 0);E(de),f(null),de?p==null||p.setEditable(!1):p==null||p.setEditable(!0)},[p,x,E,f]),G=a(U=>{h(U.target.value)},"handleSubjectChange"),X=(0,Re.useMemo)(()=>{if(b!==!1||!L)return null;let U=s&&s.elements&&s.elements.length>0;U&&(w.current=!0);let K;return U&&(K=s.elements.find(me=>me.type==="channel"&&me.channel==="email")),K||(K={type:"channel",channel:"email",elements:Gs}),tt({version:"2022-01-01",elements:[K]},{channel:"email"})},[s,b,L]);return N&&(T===null||X===null)?null:(0,Sa.jsx)(wr,{theme:t,colorScheme:l,isLoading:!!b,Header:i?i({hidePublish:e,channels:r,routing:o}):(0,Sa.jsx)(ro,{hidePublish:e,channels:r,routing:o}),...u,children:(0,Sa.jsx)(Sa.Fragment,{children:n==null?void 0:n({subject:v,handleSubjectChange:G,selectedNode:m,setSelectedNode:f,previewMode:x,templateEditor:p,ref:d,isBrandApply:V,brandSettings:_,items:B,content:X,syncEditorItems:F,brandEditorContent:A,templateData:g,togglePreviewMode:J,hidePreviewPanelExitButton:c})})})}),Cu=(0,Re.memo)(iC);var xu=class xu{};a(xu,"UploadImageAPI"),xu.uploadImage=a(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 Up=xu,_p=Up;var Sr=a(e=>(e==null||e.variables,e==null||e.disableVariablesAutocomplete,[wp,Fp.StarterKit.configure({document:!1,dropcursor:!1,gapcursor:!1,heading:!1,horizontalRule:!1,paragraph:!1,blockquote:!1,hardBreak:!1,code:!1}),Ip.configure({setSelectedNode:e==null?void 0:e.setSelectedNode,shouldHandleClick:e==null?void 0:e.shouldHandleClick}),Lp.HardBreak.configure({keepMarks:!0,HTMLAttributes:{class:"my-line-break"}}),Jh,Bm,Sp,Op,Pp.configure({levels:[1,2,3,4,5,6]}),Jl,Zc,Rp.Color,Xl,Jc,Yc,Ql,Mp.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),Vp.Underline,tc.configure(),tu.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(t,r,o)=>{r.forEach(async n=>{let i=await _p.uploadImage(n);t.chain().setImageBlockAt({pos:o,src:i}).focus().run()})},onPaste:(t,r)=>{r.forEach(async o=>{let n=await _p.uploadImage(o);return t.chain().setImageBlockAt({pos:t.state.selection.anchor,src:n}).focus().run()})}}),Dp.TextAlign.extend({addKeyboardShortcuts(){return{}}}).configure({types:["paragraph","heading"]}),Hp.Typography,Bp.Placeholder.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:"",emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",showOnlyWhenEditable:!0}),Lm.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),hp,Ti,Ei,ou,au]),"ExtensionKit");var Tu=require("@tiptap/react");var zp=require("react/jsx-runtime"),Ir=a(({config:e})=>{let{editor:t}=(0,Tu.useCurrentEditor)(),r=Vc(t);return t?(0,zp.jsx)(Tu.BubbleMenu,{editor:t,tippyOptions:{appendTo:o=>{var n;return(n=o.closest(".bubble-text-menu-container"))!=null?n:o},getReferenceClientRect:()=>{var s,l,c,u;let o=(c=(l=(s=t==null?void 0:t.state)==null?void 0:s.selection)==null?void 0:l.from)!=null?c:0,n=(u=t==null?void 0:t.view)==null?void 0:u.domAtPos(o),i=(n==null?void 0:n.node.parentNode).getBoundingClientRect();return{width:i==null?void 0:i.width,height:i==null?void 0:i.height,left:(i==null?void 0:i.left)-12,right:i==null?void 0:i.right,top:i==null?void 0:i.top,bottom:i==null?void 0:i.bottom,x:i==null?void 0:i.left,y:i==null?void 0:i.top,toJSON:()=>({})}},placement:"top",offset:[0,12]},shouldShow:r.shouldShow,updateDelay:100,"data-testid":"bubble-text-menu",children:t&&(0,zp.jsx)(Ta,{editor:t,config:e})}):null},"BubbleTextMenu");var Ib=require("@tiptap/pm/state"),Ia=require("@tiptap/react"),Xs=require("jotai"),To=require("react");var Kt=require("react/jsx-runtime"),aC=a(({value:e,readOnly:t})=>{let{editor:r}=(0,Ia.useCurrentEditor)(),o=(0,Xs.useSetAtom)(Wi),n=(0,Xs.useAtomValue)(pe),i=(0,To.useRef)(!1);return(0,To.useEffect)(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(md(e!=null?e:"")))},[r,e,n,t]),(0,To.useEffect)(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),sC=a(({facebookLink:e,linkedinLink:t,instagramLink:r,mediumLink:o,xLink:n,readOnly:i=!1,value:s,onUpdate:l})=>{let c=(0,To.useRef)(!1),u=(0,Xs.useSetAtom)(we),d=Ia.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:m})=>{let{state:f,dispatch:v}=m.view;return v(f.tr.setSelection(Ib.TextSelection.create(f.doc,f.selection.$anchor.pos))),u&&u(null),!1}}}});(0,To.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=(0,To.useMemo)(()=>[...Sr({setSelectedNode:u}),d].filter(m=>m!==void 0),[d,u]);return(0,Kt.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[(0,Kt.jsxs)(Ia.EditorProvider,{content:md(s!=null?s:""),extensions:p,editable:!i,autofocus:!i,onUpdate:l,editorContainerProps:{className:I("courier-py-2 courier-flex-grow",i&&"courier-brand-editor-readonly")},immediatelyRender:!1,children:[(0,Kt.jsx)(aC,{value:s,readOnly:i}),(0,Kt.jsx)(Ir,{})]}),(0,Kt.jsxs)("div",{className:"courier-flex courier-justify-end courier-items-center courier-gap-2 courier-mt-3",children:[e&&(0,Kt.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:(0,Kt.jsx)(es,{className:"courier-w-5 courier-h-5"})}),t&&(0,Kt.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:(0,Kt.jsx)(os,{className:"courier-w-5 courier-h-5"})}),r&&(0,Kt.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:(0,Kt.jsx)(rs,{className:"courier-w-5 courier-h-5"})}),o&&(0,Kt.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:(0,Kt.jsx)(ns,{className:"courier-w-5 courier-h-5"})}),n&&(0,Kt.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:(0,Kt.jsx)(cs,{className:"courier-w-5 courier-h-5"})})]})]})},"BrandFooterComponent"),Ra=(0,To.memo)(sC);var Rr=require("react/jsx-runtime"),Rb=a(({value:e,icon:t,...r})=>(0,Rr.jsx)(dr,{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"),Eu=a(({previewMode:e,togglePreviewMode:t,hideMobileToggle:r=!1,hideExitButton:o=!1,...n})=>(0,Rr.jsxs)("div",{...n,className:I("courier-sticky courier-bottom-0 courier-mt-auto courier-self-center courier-bg-background courier-px-3 courier-py-2 courier-shadow-lg courier-border courier-border-border courier-rounded-md courier-z-10 courier-flex courier-items-center courier-gap-2",n.className),children:[e&&!r&&(0,Rr.jsxs)(Rr.Fragment,{children:[(0,Rr.jsxs)(Xr,{type:"single",value:e,onValueChange:i=>{i!==""&&t(i)},className:"courier-w-full courier-rounded-md !courier-p-0.5 courier-bg-[#3B82F6] !courier-gap-0",children:[(0,Rr.jsx)(Rb,{value:"desktop",icon:(0,Rr.jsx)(Fd,{})}),(0,Rr.jsx)(Rb,{value:"mobile",icon:(0,Rr.jsx)(Qd,{})})]}),!o&&(0,Rr.jsx)("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),!o&&(0,Rr.jsxs)(Ve,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");var jp=require("react");function lC(){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}))}a(lC,"initTestHelpers");function Lr(e,t){typeof window!="undefined"&&(lC(),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))}a(Lr,"setTestEditor");var Db=require("@tiptap/core"),Hb=require("@tiptap/pm/state"),wu=require("@tiptap/react"),ct=require("jotai"),Ce=require("react");var Lb=require("@tiptap/react"),Bb=require("react");var oo=a(({value:e,defaultValue:t})=>{let{editor:r}=(0,Lb.useCurrentEditor)();return(0,Bb.useEffect)(()=>{if(!r)return;let o=setTimeout(()=>{r.commands.setContent(e||t)},0);return()=>clearTimeout(o)},[r,e,t]),null},"ReadOnlyEditorContent");var jo=require("react/jsx-runtime"),cC=a(({value:e})=>{let{editor:t}=(0,wu.useCurrentEditor)(),[r,o]=(0,ct.useAtom)(le),n=(0,ct.useSetAtom)(it),i=(0,ct.useAtomValue)(Gn),s=(0,ct.useAtomValue)(we),l=(0,ct.useSetAtom)(He),c=(0,ct.useSetAtom)(Yn),u=(0,Ce.useRef)(!1),d=(0,Ce.useRef)(),p=(0,ct.useAtomValue)(pe),m=(0,ct.useAtomValue)(bt),f=(0,Ce.useRef)(!1),v=(0,ct.useAtomValue)(Ft);return(0,Ce.useEffect)(()=>{p&&(f.current=!1)},[p]),(0,Ce.useEffect)(()=>(c({action:"register",id:"email-subject",fn:a(()=>{var y;if(d.current&&(clearTimeout(d.current),d.current=void 0,t&&i!==null&&p===!1&&!v))try{let x=be(t.getJSON());if(!x||!Array.isArray(x))return;let E=i;if(!i&&r){let C=(y=r==null?void 0:r.elements)==null?void 0:y.find(S=>S.type==="channel"&&S.channel==="email");C&&(E=$a(C,"email"))}let g=io(r,"email",E||"",x),b={elements:g.elements,channel:"email",...g.raw&&{raw:g.raw}},M=Nt(r,b);JSON.stringify(r)!==JSON.stringify(M)&&(o(M),n(M))}catch(x){console.error("[FlushSubjectUpdate]",x)}},"flushSubjectUpdate")}),()=>{c({action:"unregister",id:"email-subject"})}),[t,i,p,v,r,o,n,c]),(0,Ce.useEffect)(()=>{!t||p!==!1||f.current||!e||(l(t),f.current=!0,t.commands.setContent(e))},[t,e,l,p]),(0,Ce.useEffect)(()=>{if(!(!(t&&i!==null)||p!==!1||v)&&!t.isFocused)return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var h;try{let y=be(t.getJSON());if(!y||!Array.isArray(y))return;let x=i;if(!i&&r){let M=(h=r==null?void 0:r.elements)==null?void 0:h.find(C=>C.type==="channel"&&C.channel==="email");M&&(x=$a(M,"email"))}let E=io(r,"email",x||"",y),g={elements:E.elements,channel:"email",...E.raw&&{raw:E.raw}},b=Nt(r,g);JSON.stringify(r)!==JSON.stringify(b)&&(o(b),n(b))}catch(y){console.error(y)}},500),()=>{d.current&&clearTimeout(d.current)}},[m,t,i,o,n,p,r,v]),(0,Ce.useEffect)(()=>()=>{t&&!t.isDestroyed&&t.setEditable(!0)},[t]),(0,Ce.useEffect)(()=>{t&&u.current&&t.commands.updateSelectionState(s)},[t,s]),(0,Ce.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]),null},"EditorContent"),uC=a(({value:e,readOnly:t=!1,onDestroy:r,onUpdate:o,subject:n,variables:i,disableVariablesAutocomplete:s=!1})=>{let l=(0,ct.useSetAtom)(Hl),c=(0,Ce.useRef)(),[u,d]=(0,ct.useAtom)(le),p=(0,ct.useAtomValue)(Gn),m=n!=null?n:p,f=(0,ct.useSetAtom)(we),v=(0,ct.useAtomValue)(He),h=(0,ct.useAtomValue)(Ft),y=(0,ct.useAtomValue)(Cr),x=(0,ct.useSetAtom)(Yn),E=(0,ct.useSetAtom)(it),g=(0,Ce.useRef)(u),b=(0,Ce.useRef)(m),M=(0,Ce.useRef)(y);(0,Ce.useEffect)(()=>{g.current=u},[u]),(0,Ce.useEffect)(()=>{b.current=m},[m]),(0,Ce.useEffect)(()=>{M.current=y},[y]),(0,Ce.useEffect)(()=>{v==null||v.setEditable(!t)},[t,v]);let C=Db.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:_})=>{let{state:V,dispatch:j}=_.view;return j(V.tr.setSelection(Hb.TextSelection.create(V.doc,V.selection.$anchor.pos))),f&&f(null),!1}}}}),S=(0,Ce.useCallback)(({editor:_})=>{o==null||o(_),Lr("email",_),f&&setTimeout(()=>{f(null)},100)},[f,o]),P=(0,Ce.useRef)(),k=(0,Ce.useRef)(null),w=(0,Ce.useCallback)((_,V)=>{var de;if(h)return;let j=g.current,J=b.current;if(!j){let me={version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:V}]};d(me),E(me);return}let G=j.elements.find(me=>me.type==="channel"&&me.channel==="email"),X={...G};X.elements=(de=X.elements)==null?void 0:de.filter(me=>me.type!=="meta");let U={type:"channel",channel:"email",elements:V};if(JSON.stringify(X)!==JSON.stringify(U)){let me=J;!J&&G&&(me=$a(G,"email"));let Me=io(j,"email",me||"",V);U.elements=Me.elements,Me.raw&&(U.raw=Me.raw);let We=Nt(j,U);d(We),E(We)}o==null||o(_),Lr("email",_)},[d,E,o,h]),T=(0,Ce.useCallback)(({editor:_})=>{let V=be(_.getJSON());k.current={editor:_,elemental:V},P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{if(k.current){let{editor:j,elemental:J}=k.current;w(j,J),k.current=null}},200)},[w]),A=(0,Ce.useCallback)(({editor:_})=>{if(M.current)return;let{selection:V}=_.state,{$anchor:j}=V,G=V.$head.marks().find(de=>de.type.name==="link");G||_.isActive("link")?l({mark:G}):l(null);let X=j.depth,U=null,K=null;for(;X>0;){let de=j.node(X);!K&&de.type.name==="blockquote"&&(K=de),!U&&(de.type.name==="paragraph"||de.type.name==="heading")&&(U=de),X--}K?f(K):U&&f(U)},[l,f]),N=(0,Ce.useCallback)(({editor:_,transaction:V})=>{let j=V==null?void 0:V.getMeta("showLinkForm");if(j){let{selection:J}=_.state,X=J.$head.marks().find(U=>U.type.name==="link");l({mark:X,link:{from:j.from,to:j.to}})}},[l]),R=(0,Ce.useCallback)(()=>{c.current&&clearTimeout(c.current),P.current&&clearTimeout(P.current),r==null||r(),Lr("email",null)},[r]);(0,Ce.useEffect)(()=>(x({action:"register",id:"email-content",fn:a(()=>{if(P.current&&(clearTimeout(P.current),P.current=void 0,k.current)){let{editor:V,elemental:j}=k.current;w(V,j),k.current=null}},"flushContentUpdate")}),()=>{x({action:"unregister",id:"email-content"})}),[w,x]);let B=(0,Ce.useCallback)(_=>{var X;if(M.current)return;let V=(X=_.view)==null?void 0:X.editor;if(!V||!V.isEditable)return;let j=_.target,J=V.view.posAtDOM(j,0),G=V.state.doc.resolve(J).node();G.type.name==="paragraph"&&f(G)},[f]),H=(0,Ce.useCallback)(()=>!M.current,[]),D=(0,Ce.useMemo)(()=>[...Sr({setSelectedNode:f,shouldHandleClick:H,variables:i,disableVariablesAutocomplete:s}),C].filter(_=>_!==void 0),[C,f,H,i,s]),F=e||{type:"doc",content:[{type:"paragraph"}]},L=t?{editable:!1,autofocus:!1}:{editable:!0,autofocus:!0,onCreate:S,onUpdate:T,onSelectionUpdate:A,onTransaction:N},W=(0,Ce.useRef)(null);return(0,Ce.useEffect)(()=>{let _=W.current;if(!(!_||t))return Wr({element:_,getData:()=>({type:"editor",id:"editor-drop-zone"}),canDrop:({source:V})=>V.data.type==="sidebar"?!0:V.data.type==="editor"})},[t]),(0,jo.jsx)("div",{ref:W,"data-testid":"email-editor",children:(0,jo.jsx)(wu.EditorProvider,{content:F,extensions:D,...L,onDestroy:R,editorContainerProps:{onClick:B},immediatelyRender:!1,children:t?(0,jo.jsx)(oo,{value:F,defaultValue:Gs}):(0,jo.jsxs)(jo.Fragment,{children:[(0,jo.jsx)(cC,{value:F}),(0,jo.jsx)(Ir,{})]})})})},"EmailEditor"),ku=uC;var Ri=require("jotai"),Ba=require("lucide-react");var Wn=require("react");var Pu=require("react/jsx-runtime"),La=a(({children:e,id:t,className:r,editor:o})=>(0,Pu.jsx)(dC,{id:t,className:r,editor:o,children:e}),"SideBarSortableItemWrapper"),dC=(0,Wn.forwardRef)(({children:e,className:t,id:r,editor:o},n)=>{let i=(0,Wn.useRef)(null),[s,l]=(0,Wn.useState)(!1);return(0,Wn.useEffect)(()=>{let c=i.current;if(!(!c||!r))return Wo(bs({element:c,getInitialData:()=>({id:r,type:"sidebar",dragType:r}),onDragStart:()=>{l(!0),document.body.style.cursor="grabbing",o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{l(!1),document.body.style.cursor="",o&&o.setEditable(!0)}}))},[r,o]),(0,Pu.jsx)("div",{ref:i,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":r,className:I(t,"courier-relative",s&&"courier-opacity-50 courier-cursor-grabbing"),children:(0,Pu.jsx)("div",{children:e})})});var Pe=require("react/jsx-runtime"),mC={heading:lc,text:Mn,image:cc,spacer:uc,divider:An,button:Pn,customCode:sc,column:ac,blockquote:ic},pC=a(e=>({heading:(0,Pe.jsx)(Um,{}),text:(0,Pe.jsx)($m,{}),image:(0,Pe.jsx)(_m,{}),spacer:(0,Pe.jsx)(Ba.AlignVerticalSpaceAround,{className:"courier-w-4 courier-h-4"}),divider:(0,Pe.jsx)(Wm,{}),button:(0,Pe.jsx)(Vm,{}),customCode:(0,Pe.jsx)(Om,{}),column:(0,Pe.jsx)(Fm,{}),blockquote:(0,Pe.jsx)(Ba.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"})})[e],"getBlockIcon"),fC=a(e=>Hr(e)?`${e.type}:${e.preset}`:e,"getItemKey"),gC=a(({preset:e})=>{let t=e.icon||pC(e.type);return(0,Pe.jsx)(mt,{draggable:!0,icon:t,draggableLabel:e.label,label:e.label})},"PresetBlock"),Au=a(({items:e,brandEditor:t,label:r,editor:o})=>{var p,m;let n=(0,Ri.useAtomValue)(bt),i=(0,Ri.useSetAtom)(oa),s=(0,Ri.useAtomValue)(yt),l=(0,Ri.useAtomValue)(Ho),c=(0,Ri.useAtomValue)(bn),u=e!=null?e:l,d=a(f=>{if(Hr(f)){let h=c.find(y=>y.type===f.type&&y.key===f.preset);return h?(0,Pe.jsx)(gC,{preset:h}):(console.warn(`[SideBar] Preset not found: ${f.type}:${f.preset}`),null)}let v=mC[f];return v?(0,Pe.jsx)(v,{draggable:!0}):null},"renderBlockItem");return(0,Pe.jsxs)("div",{className:"courier-flex courier-flex-col courier-h-full",children:[(0,Pe.jsxs)("div",{className:"courier-flex-1",children:[r&&(0,Pe.jsxs)(Pe.Fragment,{children:[(0,Pe.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:r}),(0,Pe.jsx)(ge,{className:"courier-my-4"})]}),(0,Pe.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:u.map(f=>{let v=fC(f);return(0,Pe.jsx)(La,{id:v,editor:o,children:(0,Pe.jsxs)("div",{className:I("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Pe.jsx)(Ba.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),d(f)]})},v)})})]}),t&&(0,Pe.jsxs)("div",{className:"courier-mt-auto courier-pt-4",children:[(0,Pe.jsx)(ge,{className:"courier-mb-4 -courier-mx-4"}),(m=(p=n==null?void 0:n.data)==null?void 0:p.tenant)!=null&&m.brand?(0,Pe.jsx)("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:(0,Pe.jsx)(Ve,{variant:"link",className:"courier-underline",onClick:()=>i("brand"),disabled:!!s,children:"Edit brand"})}):(0,Pe.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,Pe.jsx)("h3",{className:"courier-text-md courier-font-medium courier-text-foreground",children:"Customize brand theme"}),(0,Pe.jsx)("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),(0,Pe.jsx)(Ve,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>i("brand"),children:"Customize"})]})]})]})},"SideBar");var Vb=require("jotai");var Eo=require("react/jsx-runtime"),Mu=a(({element:e,editor:t})=>{var i,s;let r=(0,Vb.useAtomValue)(vm);if(!e)return null;if(r!=null&&r.link||((i=r==null?void 0:r.mark)==null?void 0:i.type.name)==="link"&&((s=e.marks)!=null&&s.some(l=>l.type.name==="link")))return(0,Eo.jsx)(mb,{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=a(()=>{if(!t)return;let{$anchor:l}=t.state.selection,c=l.depth;for(;c>0;){let u=l.node(c);if(u.type.name==="blockquote")return u;c--}},"getBlockquoteElement");return(0,Eo.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[e.type.name==="button"&&(0,Eo.jsx)(Th,{element:e,editor:t},e.attrs.id),e.type.name==="divider"&&(0,Eo.jsx)(zh,{element:e,editor:t},e.attrs.id),["paragraph","heading"].includes(e.type.name)&&!o&&(0,Eo.jsx)(Jg,{element:e,editor:t},e.attrs.id),e.type.name==="imageBlock"&&(0,Eo.jsx)(sb,{element:e,editor:t},e.attrs.id),e.type.name==="customCode"&&(0,Eo.jsx)(Ep,{element:e,editor:t},e.attrs.id),(e.type.name==="blockquote"||e.type.name==="paragraph"&&o||e.type.name==="heading"&&o)&&(0,Eo.jsx)(Qg,{element:n()||e,editor:t},e.attrs.id),e.type.name==="column"&&(0,Eo.jsx)(Cp,{element:e,editor:t},e.attrs.id)]})},"SideBarItemDetails");var $p=require("react"),Fb=require("jotai");var un=require("react/jsx-runtime"),Un=(0,$p.forwardRef)(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>(0,un.jsx)("div",{className:I("courier-flex courier-flex-1 courier-overflow-hidden courier-root-container courier-relative",o&&"courier-editor-readonly",t&&"courier-editor-preview-mode",t==="mobile"&&"courier-editor-preview-mode-mobile",r),...n,ref:i,children:e})),_n=(0,$p.forwardRef)(({children:e,className:t,previewMode:r,skipExpanded:o=!1,width:n,...i},s)=>{let[l,c]=(0,Fb.useAtom)(Do),u=o?!1:l,d=n||"courier-w-64";return r?null:(0,un.jsxs)(un.Fragment,{children:[u&&(0,un.jsx)("div",{className:"courier-absolute courier-inset-0 courier-bg-black/50 courier-z-[9] courier-transition-opacity courier-duration-300 courier-cursor-pointer",onClick:()=>c(!1),"aria-hidden":"true"}),(0,un.jsx)("div",{className:I("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch courier-relative",d,t),children:(0,un.jsx)("div",{className:I("courier-editor-sidebar courier-absolute courier-top-0 courier-bottom-0 courier-right-0 courier-p-4 courier-h-full courier-overflow-y-auto","courier-transition-all courier-duration-300 courier-ease-in-out",u?"courier-w-[80vw] courier-z-10 courier-shadow-xl courier-translate-x-0":d+" courier-translate-x-0"),...i,ref:s,children:e})})]})});var Ys=require("jotai");var Ye=require("react/jsx-runtime"),Zp=(0,jp.forwardRef)(({children:e,className:t,...r},o)=>(0,Ye.jsx)("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),qp=(0,jp.forwardRef)(({children:e,previewMode:t,...r},o)=>(0,Ye.jsx)("div",{className:I("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",t&&"courier-max-w-4xl courier-mx-auto"),...r,ref:o,children:e})),Ob=a(({variables:e,disableVariablesAutocomplete:t,theme:r,isLoading:o,hidePublish:n,channels:i,brandEditor:s,routing:l,colorScheme:c,...u})=>{let d=(0,Ys.useAtomValue)(le),p=(0,Ys.useAtomValue)(Do),m=(0,Ys.useSetAtom)(Do),f=a(()=>{p&&m(!1)},"handleSubjectAreaClick");return(0,Ye.jsx)(Cu,{value:d,variables:e,theme:r,isLoading:o,hidePublish:n,channels:i,brandEditor:s,routing:l,colorScheme:c,render:({subject:v,handleSubjectChange:h,selectedNode:y,setSelectedNode:x,previewMode:E,templateEditor:g,ref:b,isBrandApply:M,brandSettings:C,items:S,content:P,syncEditorItems:k,brandEditorContent:w,templateData:T,togglePreviewMode:A,hidePreviewPanelExitButton:N})=>{var R,B,H,D,F,L;return(0,Ye.jsxs)(Un,{previewMode:E,children:[(0,Ye.jsxs)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:[(0,Ye.jsxs)("div",{className:"courier-bg-background courier-h-12 courier-flex courier-items-center courier-gap-2 courier-px-4 courier-border-b",onClick:f,children:[(0,Ye.jsxs)("h4",{className:"courier-text-sm courier-h-[25px] courier-flex courier-items-end courier-pb-0.5",children:["Subject:"," "]}),(0,Ye.jsx)(Ea,{value:v!=null?v:"",onChange:W=>h({target:{value:W}}),onFocus:()=>x(null),className:"!courier-bg-background courier-text-sm courier-flex-1",placeholder:"Write subject...",readOnly:E!==void 0,showToolbar:!0})]}),(0,Ye.jsxs)(Zp,{ref:b,children:[(0,Ye.jsxs)(qp,{previewMode:E,children:[M&&(0,Ye.jsxs)("div",{className:I("courier-py-5 courier-px-9 courier-pb-0 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(C==null?void 0:C.headerStyle)==="border"&&"courier-pt-6"),children:[(C==null?void 0:C.headerStyle)==="border"&&(0,Ye.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:C==null?void 0:C.brandColor}}),(C==null?void 0:C.logo)&&(0,Ye.jsx)("img",{src:C.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),P&&(0,Ye.jsx)(ku,{value:P,onUpdate:k,variables:e,disableVariablesAutocomplete:t},`email-editor-${t?"no-autocomplete":"autocomplete"}`),M&&T&&(0,Ye.jsx)("div",{className:"courier-py-5 courier-px-9 courier-pt-0 courier-flex courier-flex-col",children:(0,Ye.jsx)(Ra,{readOnly:!0,value:w!=null?w:(L=(F=(D=(H=(B=(R=T==null?void 0:T.data)==null?void 0:R.tenant)==null?void 0:B.brand)==null?void 0:H.settings)==null?void 0:D.email)==null?void 0:F.footer)==null?void 0:L.markdown,variables:e,facebookLink:C==null?void 0:C.facebookLink,linkedinLink:C==null?void 0:C.linkedinLink,instagramLink:C==null?void 0:C.instagramLink,mediumLink:C==null?void 0:C.mediumLink,xLink:C==null?void 0:C.xLink})})]}),(0,Ye.jsx)(Eu,{previewMode:E,togglePreviewMode:A,hideExitButton:N})]})]}),(0,Ye.jsx)(_n,{previewMode:E,children:(0,Ye.jsx)("div",{className:"courier-p-1 courier-h-full",children:y?(0,Ye.jsx)(Mu,{element:y,editor:g}):(0,Ye.jsx)(Au,{items:S.Sidebar,brandEditor:s,label:"Blocks library",editor:g!=null?g:void 0})})})]})},...u})},"EmailLayout");var Wb=require("@tiptap/react"),wo=require("jotai"),wt=require("react");var Jp=require("react/jsx-runtime"),Qs=[{type:"text",content:`
203
203
  `,text_style:"h2"},{type:"text",content:`
204
- `},{type:"action",content:"Register",align:"left",href:""}],p5=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:es};else if(t.type==="channel"&&"elements"in t){let r=t.elements||[],o=r.find(d=>d.type==="meta"),n=r.filter(d=>d.type!=="meta"),i=n.filter(d=>d.type==="text"),a=n.filter(d=>d.type==="action"),c={type:"text",content:(o&&"title"in o&&o.title||"")+`
205
- `,text_style:"h2"},u=i[0],p={type:"text",content:u&&"content"in u?u.content:`
206
- `};t={...t,elements:[c,p,...a]}}return t},"getOrCreateInboxElement"),f5={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"}},g5=s(({value:e})=>{let{editor:t}=(0,m5.useCurrentEditor)(),r=(0,eo.useSetAtom)(Ie),o=(0,eo.useAtomValue)(te),n=(0,eo.useAtomValue)(se),i=(0,ut.useRef)(!1);return(0,ut.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,ut.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,ut.useEffect)(()=>{t&&(r(t),dr("inbox",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,ut.useEffect)(()=>{if(!t||!o||t.isFocused)return;let a=p5(o),l=Ze({version:"2022-01-01",elements:[a]},{channel:"inbox"}),c=de(l),u=de(t.getJSON());JSON.stringify(c)!==JSON.stringify(u)&&setTimeout(()=>{t.isFocused||t.commands.setContent(l)},1)},[t,o]),null},"InboxEditorContent"),Fb=(0,ut.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},p)=>{let m=(0,eo.useAtomValue)(se),d=(0,ut.useRef)(!0),f=(0,ut.useRef)(!1),C=(0,eo.useSetAtom)(ye),[h,b]=(0,eo.useAtom)(te),v=(0,eo.useSetAtom)(Je),E=(0,eo.useAtomValue)(xt);(0,ut.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=(0,ut.useMemo)(()=>[...lr({setSelectedNode:C})].filter(y=>y!==void 0),[C]),w=(0,ut.useCallback)(({editor:y})=>{if(!y||E)return;if(!h){let A=de(y.getJSON()),R=Wr(null,"inbox","",A),B={version:"2022-01-01",elements:[{type:"channel",channel:"inbox",elements:R.elements,...R.raw&&{raw:R.raw}}]};b(B),v(B);return}let S=y.getJSON(),P=de(S),T=Wr(h,"inbox","",P),x=ft(h,{elements:T.elements,channel:"inbox",...T.raw&&{raw:T.raw}}),k=JSON.stringify(h.elements),M=JSON.stringify(x.elements);k!==M&&setTimeout(()=>{f.current&&(b(x),v(x))},100)},[h,b,v,E]),N=(0,ut.useMemo)(()=>{let y=p5(l);return Ze({version:"2022-01-01",elements:[y]},{channel:"inbox"})},[l]);return(0,um.jsx)(rr,{theme:e,colorScheme:c,isLoading:!!(m&&d.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,um.jsx)(Rr,{hidePublish:t,channels:o,routing:n}),...u,ref:p,children:a==null?void 0:a({content:N,extensions:g,editable:!r,autofocus:!r,onUpdate:w})})}),bc=(0,ut.memo)(Fb);var h5=require("@tiptap/react");var Ct=require("react/jsx-runtime"),yc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>e?(0,Ct.jsxs)("div",{className:"courier-py-2 courier-border courier-w-[360px] courier-h-[500px] courier-rounded-3xl courier-bg-background",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,Ct.jsxs)("div",{className:"courier-my-3 courier-mx-4 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,Ct.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-3",children:[(0,Ct.jsx)(ca,{}),(0,Ct.jsx)("span",{className:"courier-text-xl courier-font-medium",children:"In-app"})]}),(0,Ct.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-4",children:[(0,Ct.jsx)(Su,{}),(0,Ct.jsx)(sa,{}),(0,Ct.jsx)(Uu,{})]})]}),(0,Ct.jsx)(h5.EditorProvider,{content:e,extensions:t,...i?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},editorContainerProps:{className:I("courier-inbox-editor")},immediatelyRender:!1,children:i?(0,Ct.jsx)(Lr,{value:e,defaultValue:es}):(0,Ct.jsxs)(Ct.Fragment,{children:[(0,Ct.jsx)(g5,{value:e}),(0,Ct.jsx)(cr,{config:f5})]})})]}):null,"InboxEditor");var b5=require("jotai"),Co=require("react");function Cc(e,t,r=500){let o=(0,b5.useSetAtom)(bn),n=(0,Co.useRef)(),i=(0,Co.useRef)(void 0),a=(0,Co.useRef)(t);(0,Co.useEffect)(()=>{a.current=t},[t]);let l=(0,Co.useCallback)(()=>{n.current&&(clearTimeout(n.current),n.current=void 0),i.current!==void 0&&(a.current(i.current),i.current=void 0)},[]);return(0,Co.useEffect)(()=>(o({action:"register",id:e,fn:l}),()=>{l(),o({action:"unregister",id:e}),n.current&&clearTimeout(n.current)}),[e,o,l]),(0,Co.useCallback)(u=>{i.current=u,n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{l()},r)},[r,l])}s(Cc,"useDebouncedFlush");var y5=require("@hookform/resolvers/zod"),Vi=require("jotai"),qt=require("react"),C5=require("react-hook-form"),dn=require("zod");var Me=require("react/jsx-runtime"),Ob=dn.z.object({enableButton:dn.z.boolean().default(!0),buttonLabel:dn.z.string().default("Try now"),buttonUrl:dn.z.string().default(""),enableSecondaryButton:dn.z.boolean().default(!1),secondaryButtonLabel:dn.z.string().default("Learn more"),secondaryButtonUrl:dn.z.string().default("")}),Ub=s(()=>{let e=(0,Vi.useAtomValue)(Ie),[t,r]=(0,Vi.useAtom)(te),o=(0,Vi.useSetAtom)(Je),n=(0,qt.useRef)(!1),i=(0,qt.useRef)(null),a=(0,qt.useRef)(t);(0,qt.useEffect)(()=>{a.current=t},[t]);let l=(0,C5.useForm)({resolver:(0,y5.zodResolver)(Ob),defaultValues:{enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""},mode:"onChange"});(0,qt.useEffect)(()=>{if(!e)return;let f=s(()=>{let{doc:C}=e.state,h=null,b=[];if(C.descendants(v=>v.type.name==="buttonRow"&&!h?(h=v.attrs,!1):(v.type.name==="button"&&b.length<2&&b.push(v.attrs),!0)),n.current=!0,h){let{button1Label:v,button1Link:E,button2Label:g,button2Link:w}=h,N=l.getValues();N.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),N.buttonLabel!==(v||"Try now")&&l.setValue("buttonLabel",v||"Try now",{shouldDirty:!1}),N.buttonUrl!==(E||"")&&l.setValue("buttonUrl",E||"",{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!==(w||"")&&l.setValue("secondaryButtonUrl",w||"",{shouldDirty:!1})}else if(b.length>0){let v=b[0],E=l.getValues();if(E.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),E.buttonLabel!==(v.label||"Try now")&&l.setValue("buttonLabel",v.label||"Try now",{shouldDirty:!1}),E.buttonUrl!==(v.link||"")&&l.setValue("buttonUrl",v.link||"",{shouldDirty:!1}),b.length>1){let g=b[1];E.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),E.secondaryButtonLabel!==(g.label||"Learn more")&&l.setValue("secondaryButtonLabel",g.label||"Learn more",{shouldDirty:!1}),E.secondaryButtonUrl!==(g.link||"")&&l.setValue("secondaryButtonUrl",g.link||"",{shouldDirty:!1})}else E.enableSecondaryButton&&l.setValue("enableSecondaryButton",!1,{shouldDirty:!1})}else l.reset({enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""});i.current=l.getValues(),setTimeout(()=>{n.current=!1},0)},"syncFromEditor");return f(),e.on("update",f),()=>{e.off("update",f)}},[e,l]),(0,qt.useEffect)(()=>{if(e||!t||n.current)return;n.current=!0;let f=t.elements.find(h=>h.type==="channel"&&h.channel==="inbox");if(!f||!f.elements){n.current=!1;return}let C=f.elements.filter(h=>h.type==="action");if(C.length>0){let h=C[0],b=C[1];l.setValue("enableButton",!0),l.setValue("buttonLabel",h.content||"Register"),l.setValue("buttonUrl",h.href||""),b?(l.setValue("enableSecondaryButton",!0),l.setValue("secondaryButtonLabel",b.content||"Learn more"),l.setValue("secondaryButtonUrl",b.href||"")):l.setValue("enableSecondaryButton",!1)}else l.setValue("enableButton",!1),l.setValue("enableSecondaryButton",!1);i.current=l.getValues(),n.current=!1},[t,l,e]);let c=(0,qt.useCallback)(f=>{let C=a.current;if(!C||n.current)return;let h=C.elements.find(y=>y.type==="channel"&&y.channel==="inbox");h||(h={type:"channel",channel:"inbox",elements:[{type:"text",content:`
204
+ `},{type:"action",content:"Register",align:"left",href:""}],Ub=a(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:Qs};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"),s=n.filter(m=>m.type==="action"),c={type:"text",content:(o&&"title"in o&&o.title||"")+`
205
+ `,text_style:"h2"},u=i[0],d={type:"text",content:u&&"content"in u?u.content:`
206
+ `};t={...t,elements:[c,d,...s]}}return t},"getOrCreateInboxElement"),_b={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"}},zb=a(({value:e})=>{let{editor:t}=(0,Wb.useCurrentEditor)(),r=(0,wo.useSetAtom)(He),o=(0,wo.useAtomValue)(le),n=(0,wo.useAtomValue)(pe),i=(0,wt.useRef)(!1);return(0,wt.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,wt.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,wt.useEffect)(()=>{t&&(r(t),Lr("inbox",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,wt.useEffect)(()=>{if(!t||!o||t.isFocused)return;let s=Ub(o),l=tt({version:"2022-01-01",elements:[s]},{channel:"inbox"}),c=be(l),u=be(t.getJSON());JSON.stringify(c)!==JSON.stringify(u)&&setTimeout(()=>{t.isFocused||t.commands.setContent(l)},1)},[t,o]),null},"InboxEditorContent"),hC=(0,wt.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...p},m)=>{let f=(0,wo.useAtomValue)(pe),v=(0,wt.useRef)(!0),h=(0,wt.useRef)(!1),y=(0,wo.useSetAtom)(we),[x,E]=(0,wo.useAtom)(le),g=(0,wo.useSetAtom)(it),b=(0,wo.useAtomValue)(Ft);(0,wt.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let M=(0,wt.useMemo)(()=>[...Sr({setSelectedNode:y,variables:u,disableVariablesAutocomplete:d})].filter(P=>P!==void 0),[y,u,d]),C=(0,wt.useCallback)(({editor:P})=>{if(!P||b)return;if(!x){let B=be(P.getJSON()),H=io(null,"inbox","",B),D={version:"2022-01-01",elements:[{type:"channel",channel:"inbox",elements:H.elements,...H.raw&&{raw:H.raw}}]};E(D),g(D);return}let k=P.getJSON(),w=be(k),T=io(x,"inbox","",w),A=Nt(x,{elements:T.elements,channel:"inbox",...T.raw&&{raw:T.raw}}),N=JSON.stringify(x.elements),R=JSON.stringify(A.elements);N!==R&&setTimeout(()=>{h.current&&(E(A),g(A))},100)},[x,E,g,b]),S=(0,wt.useMemo)(()=>{let P=Ub(l);return tt({version:"2022-01-01",elements:[P]},{channel:"inbox"})},[l]);return(0,Jp.jsx)(wr,{theme:e,colorScheme:c,isLoading:!!(f&&v.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Jp.jsx)(ro,{hidePublish:t,channels:o,routing:n}),...p,ref:m,children:s==null?void 0:s({content:S,extensions:M,editable:!r,autofocus:!r,onUpdate:C})})}),Nu=(0,wt.memo)(hC);var $b=require("@tiptap/react");var Dt=require("react/jsx-runtime"),Su=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>e?(0,Dt.jsxs)("div",{className:"courier-py-2 courier-border courier-w-[360px] courier-h-[500px] courier-rounded-3xl courier-bg-background",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,Dt.jsxs)("div",{className:"courier-my-3 courier-mx-4 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,Dt.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-3",children:[(0,Dt.jsx)(ts,{}),(0,Dt.jsx)("span",{className:"courier-text-xl courier-font-medium",children:"In-app"})]}),(0,Dt.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-4",children:[(0,Dt.jsx)(Zd,{}),(0,Dt.jsx)(Qa,{}),(0,Dt.jsx)(tm,{})]})]}),(0,Dt.jsx)($b.EditorProvider,{content:e,extensions:t,...i?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},editorContainerProps:{className:I("courier-inbox-editor")},immediatelyRender:!1,children:i?(0,Dt.jsx)(oo,{value:e,defaultValue:Qs}):(0,Dt.jsxs)(Dt.Fragment,{children:[(0,Dt.jsx)(zb,{value:e}),(0,Dt.jsx)(Ir,{config:_b})]})})]}):null,"InboxEditor");var jb=require("jotai"),Zo=require("react");function Iu(e,t,r=500){let o=(0,jb.useSetAtom)(Yn),n=(0,Zo.useRef)(),i=(0,Zo.useRef)(void 0),s=(0,Zo.useRef)(t);(0,Zo.useEffect)(()=>{s.current=t},[t]);let l=(0,Zo.useCallback)(()=>{n.current&&(clearTimeout(n.current),n.current=void 0),i.current!==void 0&&(s.current(i.current),i.current=void 0)},[]);return(0,Zo.useEffect)(()=>(o({action:"register",id:e,fn:l}),()=>{l(),o({action:"unregister",id:e}),n.current&&clearTimeout(n.current)}),[e,o,l]),(0,Zo.useCallback)(u=>{i.current=u,n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{l()},r)},[r,l])}a(Iu,"useDebouncedFlush");var Zb=require("@hookform/resolvers/zod"),Da=require("jotai"),fr=require("react"),qb=require("react-hook-form"),zn=require("zod");var De=require("react/jsx-runtime"),bC=zn.z.object({enableButton:zn.z.boolean().default(!0),buttonLabel:zn.z.string().default("Try now"),buttonUrl:zn.z.string().default(""),enableSecondaryButton:zn.z.boolean().default(!1),secondaryButtonLabel:zn.z.string().default("Learn more"),secondaryButtonUrl:zn.z.string().default("")}),yC=a(()=>{let e=(0,Da.useAtomValue)(He),[t,r]=(0,Da.useAtom)(le),o=(0,Da.useSetAtom)(it),n=(0,fr.useRef)(!1),i=(0,fr.useRef)(null),s=(0,fr.useRef)(t);(0,fr.useEffect)(()=>{s.current=t},[t]);let l=(0,qb.useForm)({resolver:(0,Zb.zodResolver)(bC),defaultValues:{enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""},mode:"onChange"});(0,fr.useEffect)(()=>{if(!e)return;let f=a(()=>{let{doc:v}=e.state,h=null,y=[];if(v.descendants(x=>x.type.name==="buttonRow"&&!h?(h=x.attrs,!1):(x.type.name==="button"&&y.length<2&&y.push(x.attrs),!0)),n.current=!0,h){let{button1Label:x,button1Link:E,button2Label:g,button2Link:b}=h,M=l.getValues();M.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),M.buttonLabel!==(x||"Try now")&&l.setValue("buttonLabel",x||"Try now",{shouldDirty:!1}),M.buttonUrl!==(E||"")&&l.setValue("buttonUrl",E||"",{shouldDirty:!1}),M.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),M.secondaryButtonLabel!==(g||"Learn more")&&l.setValue("secondaryButtonLabel",g||"Learn more",{shouldDirty:!1}),M.secondaryButtonUrl!==(b||"")&&l.setValue("secondaryButtonUrl",b||"",{shouldDirty:!1})}else if(y.length>0){let x=y[0],E=l.getValues();if(E.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),E.buttonLabel!==(x.label||"Try now")&&l.setValue("buttonLabel",x.label||"Try now",{shouldDirty:!1}),E.buttonUrl!==(x.link||"")&&l.setValue("buttonUrl",x.link||"",{shouldDirty:!1}),y.length>1){let g=y[1];E.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),E.secondaryButtonLabel!==(g.label||"Learn more")&&l.setValue("secondaryButtonLabel",g.label||"Learn more",{shouldDirty:!1}),E.secondaryButtonUrl!==(g.link||"")&&l.setValue("secondaryButtonUrl",g.link||"",{shouldDirty:!1})}else E.enableSecondaryButton&&l.setValue("enableSecondaryButton",!1,{shouldDirty:!1})}else l.reset({enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""});i.current=l.getValues(),setTimeout(()=>{n.current=!1},0)},"syncFromEditor");return f(),e.on("update",f),()=>{e.off("update",f)}},[e,l]),(0,fr.useEffect)(()=>{if(e||!t||n.current)return;n.current=!0;let f=t.elements.find(h=>h.type==="channel"&&h.channel==="inbox");if(!f||!f.elements){n.current=!1;return}let v=f.elements.filter(h=>h.type==="action");if(v.length>0){let h=v[0],y=v[1];l.setValue("enableButton",!0),l.setValue("buttonLabel",h.content||"Register"),l.setValue("buttonUrl",h.href||""),y?(l.setValue("enableSecondaryButton",!0),l.setValue("secondaryButtonLabel",y.content||"Learn more"),l.setValue("secondaryButtonUrl",y.href||"")):l.setValue("enableSecondaryButton",!1)}else l.setValue("enableButton",!1),l.setValue("enableSecondaryButton",!1);i.current=l.getValues(),n.current=!1},[t,l,e]);let c=(0,fr.useCallback)(f=>{let v=s.current;if(!v||n.current)return;let h=v.elements.find(C=>C.type==="channel"&&C.channel==="inbox");h||(h={type:"channel",channel:"inbox",elements:[{type:"text",content:`
207
207
  `,text_style:"h2"},{type:"text",content:`
208
- `}]}),h.elements||(h.elements=[]);let v=[...h.elements.filter(y=>y.type!=="action")];if(f.enableButton){let y={type:"action",content:f.buttonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.buttonUrl};v.push(y)}if(f.enableSecondaryButton){let y={type:"action",content:f.secondaryButtonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.secondaryButtonUrl};v.push(y)}let E={...h,elements:v},g=C.elements.findIndex(y=>y.type==="channel"&&y.channel==="inbox"),w=[...C.elements];g!==-1?w[g]=E:w.push(E);let N={...C,elements:w};r(N),o(N)},[r,o]),u=(0,qt.useCallback)(f=>{if(!e)return!1;let{doc:C}=e.state,h=null,b=[];C.descendants((E,g)=>E.type.name==="buttonRow"&&h===null?(h=g,!1):(E.type.name==="button"&&b.push({pos:g,attrs:E.attrs}),!0));let v=s((E,g)=>{let w=C.nodeAt(E);return w?(e.commands.command(({tr:N})=>(N.setNodeMarkup(E,w.type,g),!0)),!0):!1},"applyAttrs");if(h!==null){let E=C.nodeAt(h);if(!E)return!1;let g={...E.attrs,button1Label:f.buttonLabel,button1Link:f.buttonUrl,button2Label:f.secondaryButtonLabel,button2Link:f.secondaryButtonUrl};return v(h,g)}if(b.length>0){let[E,g]=b,w={...E.attrs,label:f.buttonLabel,link:f.buttonUrl},N=v(E.pos,w),y=!0;if(g){let S={...g.attrs,label:f.secondaryButtonLabel,link:f.secondaryButtonUrl};y=v(g.pos,S)}return N&&y}return!1},[e]),p=(0,qt.useCallback)(f=>{if(n.current)return;let C=i.current;if(i.current=f,!C||C.enableButton!==f.enableButton||C.enableSecondaryButton!==f.enableSecondaryButton){c(f);return}u(f)||c(f)},[c,u]),m=Cc("inbox-sidebar",p,500),d=(0,qt.useCallback)(()=>{let f=l.getValues();m(f)},[l,m]);return(0,Me.jsx)(qe,{...l,children:(0,Me.jsxs)("form",{onChange:d,children:[(0,Me.jsx)("div",{className:"courier-pb-4",children:(0,Me.jsx)(j,{control:l.control,name:"enableButton",render:({field:f})=>(0,Me.jsxs)(q,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between",children:[(0,Me.jsx)(uo,{className:"!courier-m-0",children:"Enable button"}),(0,Me.jsx)(J,{children:(0,Me.jsx)(ii,{checked:f.value,onCheckedChange:f.onChange,className:"!courier-m-0"})})]})})}),l.watch("enableButton")&&(0,Me.jsx)(j,{control:l.control,name:"buttonUrl",render:({field:f})=>(0,Me.jsxs)(q,{className:"courier-mb-6",children:[(0,Me.jsx)(uo,{children:"Action URL"}),(0,Me.jsx)(J,{children:(0,Me.jsx)(be,{placeholder:"https://example.com",...f})}),(0,Me.jsx)(K,{})]})}),(0,Me.jsx)(ce,{className:"courier-mb-6"}),(0,Me.jsx)(j,{control:l.control,name:"enableSecondaryButton",render:({field:f})=>(0,Me.jsxs)(q,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between courier-mb-4",children:[(0,Me.jsx)(uo,{className:"!courier-m-0",children:"Enable secondary button"}),(0,Me.jsx)(J,{children:(0,Me.jsx)(ii,{checked:f.value,onCheckedChange:f.onChange,className:"!courier-m-0"})})]})}),l.watch("enableSecondaryButton")&&(0,Me.jsx)(j,{control:l.control,name:"secondaryButtonUrl",render:({field:f})=>(0,Me.jsxs)(q,{className:"courier-mb-4",children:[(0,Me.jsx)(uo,{children:"Action URL"}),(0,Me.jsx)(J,{children:(0,Me.jsx)(be,{placeholder:"https://example.com",...f})}),(0,Me.jsx)(K,{})]})})]})})},"SideBarComponent"),vc=(0,qt.memo)(Ub);var v5=require("jotai");var Lo=require("react/jsx-runtime"),x5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i,...a})=>{let l=(0,v5.useAtomValue)(te);return(0,Lo.jsx)(bc,{value:l,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:c=>(0,Lo.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,Lo.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1 courier-py-8 courier-items-center",children:(0,Lo.jsx)(yc,{...c})}),(0,Lo.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,Lo.jsx)("div",{className:"courier-p-4 courier-h-full",children:(0,Lo.jsx)(vc,{})})})]}),...a})},"InboxLayout");var T5=require("@tiptap/react"),to=require("jotai"),dt=require("react");var dm=require("react/jsx-runtime"),E5=s(({value:e})=>{let{editor:t}=(0,T5.useCurrentEditor)(),r=(0,to.useSetAtom)(Ie),o=(0,to.useAtomValue)(te),n=(0,to.useAtomValue)(se),i=(0,dt.useRef)(!1);return(0,dt.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,dt.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,dt.useEffect)(()=>{t&&(r(t),dr("push",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,dt.useEffect)(()=>{if(!t||!o||t.isFocused)return;let a=k5(o),l=a.type==="channel"&&"elements"in a&&a.elements||$n;l=l.map(d=>d.type==="meta"&&"title"in d?{type:"text",content:d.title||`
209
- `,text_style:"h2"}:d);let u=Ze({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:l}]}),p=de(u),m=de(t.getJSON());JSON.stringify(p)!==JSON.stringify(m)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"PushEditorContent"),$n=[{type:"meta",title:""},{type:"text",content:`
210
- `}],k5=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:$n}),t},"getOrCreatePushElement"),w5={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},Wb=(0,dt.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},p)=>{let m=(0,to.useAtomValue)(se),d=(0,dt.useRef)(!0),f=(0,dt.useRef)(!1),C=(0,to.useSetAtom)(ye),[h,b]=(0,to.useAtom)(te),v=(0,to.useSetAtom)(Je),E=(0,to.useAtomValue)(xt);(0,dt.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=(0,dt.useMemo)(()=>[...lr({setSelectedNode:C})].filter(y=>y!==void 0),[C]),w=(0,dt.useCallback)(({editor:y})=>{if(E)return;if(!h){let A=de(y.getJSON()),R=A[0],B="",F=A;R&&R.type==="text"&&"text_style"in R&&R.text_style==="h2"&&"content"in R&&(B=R.content.trim(),F=A.slice(1));let D={version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:Wr(null,"push",B,F).elements}]};b(D),v(D);return}let S=de(y.getJSON()),P=S[0],T="",x=S;P&&P.type==="text"&&"text_style"in P&&P.text_style==="h2"&&"content"in P&&(T=P.content.trim(),x=S.slice(1));let k=Wr(h,"push",T,x),M=ft(h,{channel:"push",elements:k.elements});JSON.stringify(h)!==JSON.stringify(M)&&(b(M),v(M))},[h,b,v,E]),N=(0,dt.useMemo)(()=>{if(m!==!1)return null;let y=l==null?void 0:l.elements.find(T=>T.type==="channel"&&T.channel==="push");!y&&h&&(y=k5(h));let S=(y==null?void 0:y.type)==="channel"&&"elements"in y&&y.elements||$n;return S=S.map(T=>T.type==="meta"&&"title"in T?{type:"text",content:T.title||`
211
- `,text_style:"h2"}:T),Ze({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:S}]})},[l,h,m]);return(0,dm.jsx)(rr,{theme:e,colorScheme:c,isLoading:!!(m&&d.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,dm.jsx)(Rr,{hidePublish:t,channels:o,routing:n}),...u,ref:p,children:a==null?void 0:a({content:N,extensions:g,editable:!r,autofocus:!r,onUpdate:w})})}),xc=(0,dt.memo)(Wb);var P5=require("@tiptap/react");var Jt=require("react/jsx-runtime"),Tc=s(({children:e})=>(0,Jt.jsxs)("div",{className:"courier-relative",children:[(0,Jt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-6 courier-bg-border -courier-left-[2px] courier-top-[136px]"}),(0,Jt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[178px]"}),(0,Jt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[245px]"}),(0,Jt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[78px] courier-bg-border -courier-right-[2px] courier-top-[200px]"}),(0,Jt.jsxs)("div",{className:"courier-py-2 courier-border-8 courier-border-b-0 courier-w-[306px] courier-h-[500px] courier-rounded-[40px] courier-rounded-b-none courier-bg-background courier-pb-6 courier-relative",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,Jt.jsxs)("div",{className:"courier-my-6 courier-mx-11 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,Jt.jsx)("span",{className:"courier-text-xs courier-font-semibold",children:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),(0,Jt.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2",children:[(0,Jt.jsx)(wp,{}),(0,Jt.jsx)(Np,{}),(0,Jt.jsx)(kp,{})]})]}),(0,Jt.jsx)("div",{className:"courier-flex-1 courier-overflow-auto courier-h-[calc(90%-56px)] courier-mb-6",children:e})]})]}),"IPhoneFrame");var kr=require("react/jsx-runtime"),Ec=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:a=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=a?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,kr.jsxs)(Tc,{children:[(0,kr.jsxs)("div",{className:I("courier-px-4 courier-py-2 courier-text-[#A3A3A3] courier-text-center courier-my-8",i),children:[(0,kr.jsx)("p",{className:"courier-text-lg courier-font-medium",children:new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}),(0,kr.jsx)("p",{className:"courier-text-5xl courier-font-semibold courier-mt-1",children:new Date().toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})})]}),(0,kr.jsx)(P5.EditorProvider,{content:l,extensions:t,...c,editorContainerProps:{className:I("courier-push-editor")},"data-testid":"editor-provider",immediatelyRender:!1,children:a?(0,kr.jsx)(Lr,{value:l,defaultValue:$n}):(0,kr.jsxs)(kr.Fragment,{children:[(0,kr.jsx)(E5,{value:l}),(0,kr.jsx)(cr,{config:w5})]})})]})},"PushEditor");var N5=require("jotai");var kc=require("react/jsx-runtime"),M5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,...i})=>{let a=(0,N5.useAtomValue)(te);return(0,kc.jsx)(xc,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:l=>(0,kc.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,kc.jsx)(Ec,{...l})}),...i})},"PushLayout");var A5=require("@tiptap/react"),jt=require("jotai"),xe=require("react");var Fi=require("react/jsx-runtime"),ts=[{type:"text",content:`
212
- `}],I5=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:ts}),t},"getOrCreateSlackElement"),S5=s(({value:e})=>{let{editor:t}=(0,A5.useCurrentEditor)(),r=(0,jt.useSetAtom)(Ie),o=(0,jt.useAtomValue)(te),n=(0,jt.useAtomValue)(se),i=(0,jt.useAtomValue)(ye),a=(0,xe.useRef)(!1),l=(0,xe.useRef)(!1);return(0,xe.useEffect)(()=>{n&&(a.current=!1)},[n]),(0,xe.useEffect)(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),(0,xe.useEffect)(()=>{t&&(r(t),dr("slack",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,xe.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,xe.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,xe.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=I5(o),u=Ze({version:"2022-01-01",elements:[c]},{channel:"slack"}),p=de(u),m=de(t.getJSON());JSON.stringify(p)!==JSON.stringify(m)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"SlackEditorContent"),R5={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"]}}]},_b=(0,xe.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},p)=>{let m=(0,jt.useAtomValue)(se),d=(0,jt.useAtomValue)(xt),f=(0,jt.useAtomValue)(Ie),C=(0,jt.useAtomValue)(Xt),[h,b]=(0,jt.useAtom)(ye),[v,E]=(0,jt.useAtom)(te),g=(0,jt.useSetAtom)(Je),w=(0,xe.useRef)(!0),N=(0,xe.useRef)(!1),y=(0,xe.useRef)(C),S=(0,xe.useRef)(null),P=(0,jt.useAtomValue)(co),T=(0,xe.useMemo)(()=>{let L=["text","divider","button"];return P.filter(D=>{let V=hr(D)?D.type:D;return L.includes(V)})},[P]),[x,k]=(0,xe.useState)({Sidebar:T,Editor:[]});(0,xe.useEffect)(()=>{k(L=>({...L,Sidebar:T}))},[T]),Si({items:x,setItems:k});let{syncEditorItems:M}=sc({setItems:k,rafId:S});(0,xe.useEffect)(()=>(N.current=!0,()=>{N.current=!1}),[]),(0,xe.useEffect)(()=>{y.current=C},[C]),(0,xe.useEffect)(()=>{m===!1&&v&&setTimeout(()=>{f&&!f.isDestroyed&&M(f)},300)},[m,v,f,M]);let A=(0,xe.useCallback)(()=>!y.current,[]),R=(0,xe.useMemo)(()=>[...lr({setSelectedNode:b,shouldHandleClick:A})].filter(L=>L!==void 0),[b,A]),B=(0,xe.useCallback)(({editor:L})=>{if(!L||d)return;if(!v){let Q={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:de(L.getJSON())}]};E(Q),g(Q);return}let D=L.getJSON(),V=de(D),O=ft(v,{elements:V,channel:"slack"}),$=JSON.stringify(v.elements),_=JSON.stringify(O.elements);$!==_&&(E(O),g(O))},[v,E,g,d]),F=(0,xe.useMemo)(()=>{let L=I5(l);return Ze({version:"2022-01-01",elements:[L]},{channel:"slack"})},[l]);return(0,Fi.jsx)(rr,{theme:e,colorScheme:c,isLoading:!!(m&&w.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Fi.jsx)(Rr,{hidePublish:t,channels:o,routing:n}),ref:p,...u,children:(0,Fi.jsx)(Fi.Fragment,{children:a==null?void 0:a({content:F,extensions:R,editable:!r,autofocus:!r,onUpdate:B,items:x,selectedNode:h,slackEditor:f})})})}),wc=(0,xe.memo)(_b);var D5=require("@tiptap/react");var Ue=require("react/jsx-runtime"),zb=s(()=>(0,Ue.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-col courier-w-full",children:[(0,Ue.jsx)("div",{className:"courier-w-3/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),(0,Ue.jsx)("div",{className:"courier-w-full courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),(0,Ue.jsx)("div",{className:"courier-w-6/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"})]}),"TextSkeleton"),$b=s(()=>(0,Ue.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-lg",children:(0,Ue.jsx)(ha,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),L5=s(()=>(0,Ue.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row",children:[(0,Ue.jsx)($b,{}),(0,Ue.jsx)(zb,{})]}),"InteractionSkeleton"),B5=s(({children:e,className:t})=>(0,Ue.jsxs)("div",{className:I("courier-w-full courier-max-w-[800px] courier-bg-white dark:courier-bg-[#171717] courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Ue.jsx)(L5,{}),(0,Ue.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Ue.jsx)("div",{className:"courier-flex-shrink-0",children:(0,Ue.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-md courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,Ue.jsx)(ga,{color:"#FFFFFF"})})}),(0,Ue.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Ue.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mb-1",children:[(0,Ue.jsx)("span",{className:"courier-font-semibold courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1]",children:"Circle"}),(0,Ue.jsx)("span",{className:"courier-inline-flex courier-items-center courier-px-1.5 courier-py-0.5 courier-rounded courier-text-xs courier-font-medium courier-bg-gray-200 dark:courier-bg-[#2E333F] courier-text-gray-700 dark:courier-text-[#C9C8E1]",children:"APP"}),(0,Ue.jsx)("span",{className:"courier-text-xs courier-text-gray-500 dark:courier-text-[#8786A9]",children:"Now"})]}),(0,Ue.jsx)("div",{className:"courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-pr-4",children:e})]})]}),(0,Ue.jsx)(L5,{})]}),"SlackFrame");var Pc=require("react");var ro=require("react/jsx-runtime"),Nc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let a=(0,Pc.useRef)(null);return(0,Pc.useEffect)(()=>{let l=a.current;if(!(!l||i))return vr({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,ro.jsx)(B5,{children:(0,ro.jsx)("div",{ref:a,children:(0,ro.jsx)(D5.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:I("courier-slack-editor")},immediatelyRender:!1,children:i?(0,ro.jsx)(Lr,{value:e,defaultValue:ts}):(0,ro.jsxs)(ro.Fragment,{children:[(0,ro.jsx)(S5,{value:e}),(0,ro.jsx)(cr,{config:R5})]})})})}):null},"SlackEditor");var U5=require("jotai");var H5=require("lucide-react");var Ft=require("react/jsx-runtime"),Mc=s(({items:e,label:t,editor:r})=>(0,Ft.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,Ft.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,Ft.jsxs)(Ft.Fragment,{children:[(0,Ft.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),(0,Ft.jsx)(ce,{className:"courier-my-4"})]}),(0,Ft.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>{let n=hr(o)?`${o.type}:${o.preset}`:o,i=hr(o)?o.type:o;return(0,Ft.jsx)(Di,{id:n,editor:r,children:(0,Ft.jsxs)("div",{className:I("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Ft.jsx)(H5.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),i==="text"&&(0,Ft.jsx)(Xo,{draggable:!0}),i==="divider"&&(0,Ft.jsx)(Yo,{draggable:!0}),i==="button"&&(0,Ft.jsx)(Go,{draggable:!0})]})},n)})})]})}),"SlackSideBar");var V5=require("@hookform/resolvers/zod"),F5=require("react-hook-form");var oo=require("react/jsx-runtime"),O5=s(({element:e,editor:t})=>{let r=(0,F5.useForm)({resolver:(0,V5.zodResolver)(ul),defaultValues:{...je,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=kt({editor:t,element:e,form:r,nodeType:"button"});return e?(0,oo.jsxs)(qe,{...r,children:[(0,oo.jsx)(Vt,{type:"button"}),(0,oo.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,oo.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,oo.jsx)(j,{control:r.control,name:"link",render:({field:n})=>(0,oo.jsxs)(q,{children:[(0,oo.jsx)(J,{children:(0,oo.jsx)(jr,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})}})}),(0,oo.jsx)(K,{})]})})]})]}):null},"SlackButtonForm");var mm=require("react/jsx-runtime"),Ac=s(({element:e,editor:t,defaultElement:r})=>e&&e.type.name==="button"?(0,mm.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:(0,mm.jsx)(O5,{element:e,editor:t},e.attrs.id)}):r,"SlackSideBarItemDetails");var pm=require("react");var mr=require("react/jsx-runtime"),Zb=(0,pm.forwardRef)(({children:e,className:t,...r},o)=>(0,mr.jsx)("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),qb=(0,pm.forwardRef)(({children:e,...t},r)=>(0,mr.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),W5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i})=>{let a=(0,U5.useAtomValue)(te);return(0,mr.jsx)(wc,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:l=>{var c;return(0,mr.jsxs)(cn,{children:[(0,mr.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,mr.jsx)(Zb,{children:(0,mr.jsx)(qb,{children:(0,mr.jsx)(Nc,{...l})})})}),(0,mr.jsx)(un,{children:(0,mr.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,mr.jsx)(Ac,{element:l.selectedNode,editor:l.slackEditor,defaultElement:(0,mr.jsx)(Mc,{items:l.items.Sidebar,label:"Blocks library",editor:(c=l.slackEditor)!=null?c:void 0})})})})]})}})},"SlackLayout");var _5=require("@tiptap/react"),no=require("jotai"),We=require("react"),z5=require("sms-segments-calculator");var Ic=require("react/jsx-runtime"),Bo=[{type:"text",content:`
213
- `}],$5=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:Bo}),t},"getOrCreateSMSElement"),Z5=s(({value:e})=>{var c;let{editor:t}=(0,_5.useCurrentEditor)(),r=(0,no.useSetAtom)(Ie),o=(0,no.useAtomValue)(te),n=(c=t==null?void 0:t.getText())!=null?c:"",i=(0,We.useMemo)(()=>new z5.SegmentedMessage(n),[n]),a=(0,no.useAtomValue)(se),l=(0,We.useRef)(!1);return(0,We.useEffect)(()=>{a&&(l.current=!1)},[a]),(0,We.useEffect)(()=>{!t||a!==!1||l.current||!e||(l.current=!0,t.commands.setContent(e))},[t,e,a]),(0,We.useEffect)(()=>{t&&(r(t),dr("sms",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,We.useEffect)(()=>{if(!t||!o||t.isFocused)return;let u=$5(o),m={type:"channel",channel:"sms",elements:u.type==="channel"&&"elements"in u&&u.elements||Bo},d=Ze({version:"2022-01-01",elements:[m]}),f=de(d),C=de(t.getJSON());JSON.stringify(f)!==JSON.stringify(C)&&setTimeout(()=>{t.isFocused||t.commands.setContent(d)},1)},[t,o]),(0,Ic.jsx)("span",{className:"courier-self-end courier-pr-2 courier-text-xs courier-color-gray-500",children:Math.ceil(((i==null?void 0:i.messageSize)||0)/8)})},"SMSEditorContent"),q5={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"}},Jb=(0,We.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,render:i,headerRenderer:a,value:l,colorScheme:c,...u},p)=>{let m=(0,no.useAtomValue)(se),d=(0,We.useRef)(!0),f=(0,We.useRef)(!1),C=(0,no.useSetAtom)(ye),[h,b]=(0,no.useAtom)(te),v=(0,no.useSetAtom)(Je),E=(0,no.useAtomValue)(xt);(0,We.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=(0,We.useMemo)(()=>[...lr({setSelectedNode:C})].filter(T=>T!==void 0),[C]),w=(0,We.useRef)(!1),N=(0,We.useCallback)(({editor:T})=>{if(E)return;if(!h){let A=de(T.getJSON()),R=ds(A),B={version:"2022-01-01",elements:[{type:"channel",channel:"sms",elements:R.length>0?R:Bo}]};w.current=!0,b(B),v(B);return}let x=de(T.getJSON()),k=ds(x),M=ft(h,{channel:"sms",elements:k.length>0?k:Bo});JSON.stringify(h)!==JSON.stringify(M)&&(w.current=!0,b(M),v(M))},[h,b,v,E]),[y,S]=(0,We.useState)(null),P=(0,We.useCallback)(T=>{if(!T)return null;let x=T==null?void 0:T.elements.find(A=>A.type==="channel"&&A.channel==="sms");x||(x=$5(T));let M={type:"channel",channel:"sms",elements:(x==null?void 0:x.type)==="channel"&&"elements"in x&&x.elements||Bo};return Ze({version:"2022-01-01",elements:[M]})},[]);return(0,We.useEffect)(()=>{if(m!==!1)return;if(w.current){w.current=!1;return}let T=l!=null?l:h,x=P(T);x&&S(x)},[l,h,P,m]),(0,Ic.jsx)(rr,{theme:e,colorScheme:c,isLoading:!!(m&&d.current),Header:a?a({hidePublish:t,channels:o,routing:n}):(0,Ic.jsx)(Rr,{hidePublish:t,channels:o,routing:n}),...u,ref:p,children:i==null?void 0:i({content:y,extensions:g,editable:!r,autofocus:!r,onUpdate:N})})}),Sc=(0,We.memo)(Jb);var J5=require("@tiptap/react");var io=require("react/jsx-runtime"),Rc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:a=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=a?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,io.jsx)(Tc,{children:(0,io.jsx)("div",{className:I("courier-sms-editor",i),children:(0,io.jsx)(J5.EditorProvider,{content:l,extensions:t,...c,"data-testid":"editor-provider",immediatelyRender:!1,children:a?(0,io.jsx)(Lr,{value:l,defaultValue:Bo}):(0,io.jsxs)(io.Fragment,{children:[(0,io.jsx)(Z5,{value:l}),(0,io.jsx)(cr,{config:q5})]})})})})},"SMSEditor");var j5=require("jotai");var Lc=require("react/jsx-runtime"),K5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i,...a})=>{let l=(0,j5.useAtomValue)(te);return(0,Lc.jsx)(Sc,{value:l,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:c=>(0,Lc.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,Lc.jsx)(Rc,{...c})}),...a})},"SMSLayout");var G5=require("@tiptap/react"),Kt=require("jotai"),ve=require("react");var Oi=require("react/jsx-runtime"),rs=[{type:"text",content:`
214
- `}],Y5=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:rs}),t},"getOrCreateMSTeamsElement"),X5=s(({value:e})=>{let{editor:t}=(0,G5.useCurrentEditor)(),r=(0,Kt.useSetAtom)(Ie),o=(0,Kt.useAtomValue)(te),n=(0,Kt.useAtomValue)(se),i=(0,Kt.useAtomValue)(ye),a=(0,ve.useRef)(!1),l=(0,ve.useRef)(!1);return(0,ve.useEffect)(()=>{n&&(a.current=!1)},[n]),(0,ve.useEffect)(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),(0,ve.useEffect)(()=>{t&&(r(t),dr("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,ve.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,ve.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,ve.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=Y5(o),u=Ze({version:"2022-01-01",elements:[c]},{channel:"msteams"}),p=de(u),m=de(t.getJSON());JSON.stringify(p)!==JSON.stringify(m)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"MSTeamsEditorContent"),Q5={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"]}}]},jb=(0,ve.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},p)=>{let m=(0,Kt.useAtomValue)(se),d=(0,Kt.useAtomValue)(xt),f=(0,Kt.useAtomValue)(Ie),C=(0,Kt.useAtomValue)(Xt),[h,b]=(0,Kt.useAtom)(ye),[v,E]=(0,Kt.useAtom)(te),g=(0,Kt.useSetAtom)(Je),w=(0,ve.useRef)(!0),N=(0,ve.useRef)(!1),y=(0,ve.useRef)(C),S=(0,Kt.useAtomValue)(co),P=(0,ve.useMemo)(()=>{let L=["text","divider"];return S.filter(D=>{let V=hr(D)?D.type:D;return L.includes(V)})},[S]),[T,x]=(0,ve.useState)({Sidebar:P,Editor:[]});(0,ve.useEffect)(()=>{x(L=>({...L,Sidebar:P}))},[P]);let k=(0,ve.useRef)(null);Si({items:T,setItems:x});let M=(0,ve.useCallback)(L=>{k.current&&cancelAnimationFrame(k.current),setTimeout(()=>{k.current=requestAnimationFrame(()=>{try{let D=L==null?void 0:L.view.dom;if(!D){console.warn("syncEditorItems: Editor DOM element not found");return}let V=D.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),O=[];V.forEach($=>{let _=$.dataset.id;_&&O.push(_)}),x($=>({Editor:O,Sidebar:$.Sidebar}))}catch(D){console.error("Error syncing editor items:",D),x(V=>({...V}))}})},50)},[]);(0,ve.useEffect)(()=>(N.current=!0,()=>{N.current=!1}),[]),(0,ve.useEffect)(()=>{y.current=C},[C]),(0,ve.useEffect)(()=>{let L=s(()=>{f&&M(f)},"updateItems");f==null||f.on("update",L),f==null||f.on("selectionUpdate",L),f==null||f.on("create",L),f==null||f.on("transaction",L),f&&!f.isDestroyed&&L();let D=s(V=>{L()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",D),()=>{f==null||f.off("update",L),f==null||f.off("selectionUpdate",L),f==null||f.off("create",L),f==null||f.off("transaction",L),document.removeEventListener("node-duplicated",D),k.current&&cancelAnimationFrame(k.current)}},[f,M]),(0,ve.useEffect)(()=>{m===!1&&v&&setTimeout(()=>{f&&!f.isDestroyed&&M(f)},300)},[m,v,f,M]);let A=(0,ve.useCallback)(()=>!y.current,[]),R=(0,ve.useMemo)(()=>[...lr({setSelectedNode:b,shouldHandleClick:A})].filter(L=>L!==void 0),[b,A]),B=(0,ve.useCallback)(({editor:L})=>{if(!L||d)return;if(!v){let Q={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:de(L.getJSON())}]};E(Q),g(Q);return}let D=L.getJSON(),V=de(D),O=ft(v,{elements:V,channel:"msteams"}),$=JSON.stringify(v.elements),_=JSON.stringify(O.elements);$!==_&&(E(O),g(O))},[v,E,g,d]),F=(0,ve.useMemo)(()=>{let L=Y5(l);return Ze({version:"2022-01-01",elements:[L]},{channel:"msteams"})},[l]);return(0,Oi.jsx)(rr,{theme:e,colorScheme:c,isLoading:!!(m&&w.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Oi.jsx)(Rr,{hidePublish:t,channels:o,routing:n}),ref:p,...u,children:(0,Oi.jsx)(Oi.Fragment,{children:a==null?void 0:a({content:F,extensions:R,editable:!r,autofocus:!r,onUpdate:B,items:T,selectedNode:h,msteamsEditor:f})})})}),Bc=(0,ve.memo)(jb);var t2=require("@tiptap/react");var $e=require("react/jsx-runtime"),Kb=s(()=>(0,$e.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-full",children:(0,$e.jsx)(ha,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),Gb=s(()=>(0,$e.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[(0,$e.jsx)(Kb,{}),(0,$e.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[(0,$e.jsx)("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"}),(0,$e.jsx)("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),Yb=s(()=>(0,$e.jsx)("div",{className:"courier-flex courier-justify-end courier-w-full",children:(0,$e.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:(0,$e.jsx)("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),e2=s(({children:e,className:t})=>(0,$e.jsxs)("div",{className:I("courier-w-full courier-max-w-[800px] courier-bg-white dark:courier-bg-[#171717] courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,$e.jsx)(Gb,{}),(0,$e.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,$e.jsx)("div",{className:"courier-flex-shrink-0 courier-mt-6",children:(0,$e.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-full courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,$e.jsx)(ga,{color:"#FFFFFF"})})}),(0,$e.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,$e.jsx)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:(0,$e.jsx)("span",{className:"courier-text-sm courier-text-[#A3A3A3] dark:courier-text-[#8786A9]",children:"Circle"})}),(0,$e.jsx)("div",{className:"courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px] courier-px-3 courier-py-2 courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-max-w-full courier-pr-5",children:e})]})]}),(0,$e.jsx)(Yb,{})]}),"MSTeamsFrame");var Dc=require("react");var ao=require("react/jsx-runtime"),Hc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let a=(0,Dc.useRef)(null);return(0,Dc.useEffect)(()=>{let l=a.current;if(!(!l||i))return vr({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,ao.jsx)(e2,{children:(0,ao.jsx)("div",{ref:a,children:(0,ao.jsx)(t2.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:I("courier-msteams-editor")},immediatelyRender:!1,children:i?(0,ao.jsx)(Lr,{value:e,defaultValue:rs}):(0,ao.jsxs)(ao.Fragment,{children:[(0,ao.jsx)(X5,{value:e}),(0,ao.jsx)(cr,{config:Q5})]})})})}):null},"MSTeamsEditor");var o2=require("jotai");var r2=require("lucide-react");var Ot=require("react/jsx-runtime"),Vc=s(({items:e,label:t,editor:r})=>(0,Ot.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,Ot.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,Ot.jsxs)(Ot.Fragment,{children:[(0,Ot.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),(0,Ot.jsx)(ce,{className:"courier-my-4"})]}),(0,Ot.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>{let n=hr(o)?`${o.type}:${o.preset}`:o,i=hr(o)?o.type:o;return(0,Ot.jsx)(Di,{id:n,editor:r,children:(0,Ot.jsxs)("div",{className:I("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Ot.jsx)(r2.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),i==="text"&&(0,Ot.jsx)(Xo,{draggable:!0}),i==="divider"&&(0,Ot.jsx)(Yo,{draggable:!0}),i==="button"&&(0,Ot.jsx)(Go,{draggable:!0})]})},n)})})]})}),"MSTeamsSideBar");var fm=require("react");var wr=require("react/jsx-runtime"),Xb=(0,fm.forwardRef)(({children:e,className:t,...r},o)=>(0,wr.jsx)("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Qb=(0,fm.forwardRef)(({children:e,...t},r)=>(0,wr.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),n2=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i})=>{let a=(0,o2.useAtomValue)(te);return(0,wr.jsx)(Bc,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:l=>{var c;return(0,wr.jsxs)(cn,{children:[(0,wr.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,wr.jsx)(Xb,{children:(0,wr.jsx)(Qb,{children:(0,wr.jsx)(Hc,{...l})})})}),(0,wr.jsx)(un,{children:(0,wr.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,wr.jsx)(Vc,{items:l.items.Sidebar,label:"Blocks library",editor:(c=l.msteamsEditor)!=null?c:void 0})})})]})}})},"MSTeamsLayout");var i2={sms:{elements:Bo},push:{elements:$n},inbox:{elements:es},slack:{elements:ts},email:{elements:Ya},msteams:{elements:rs}},a2=s(e=>{var t;return(t=i2[e])!=null?t:i2.email},"getChannelDefaults"),e0=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"),Fc=s(({channels:e=["email"],routing:t})=>{let[r,o]=(0,pr.useState)([]),n=(0,Do.useAtomValue)(te),i=(0,Do.useSetAtom)(te),a=(0,Do.useSetAtom)(Je),[l,c]=(0,Do.useAtom)(Zo),u=(0,Do.useSetAtom)(ye),p=(0,Do.useAtomValue)(se),m=e0(t,e),d=(0,pr.useRef)(m);d.current=m,(0,pr.useEffect)(()=>{if(p||n!=null&&n.elements)return;let E=d.current.map(g=>$o.find(w=>w.value===g)).filter(g=>!!g);o(E),E.length>0&&!l&&c(E[0].value)},[n,p,c,l]),(0,pr.useEffect)(()=>{if(p||!(n!=null&&n.elements))return;let v=d.current,E=n.elements.filter(w=>w.type==="channel").map(w=>w.channel).filter(w=>v.includes(w)),g=v.filter(w=>E.includes(w)).map(w=>$o.find(N=>N.value===w)).filter(w=>!!w);o(g)},[n,p]),(0,pr.useEffect)(()=>{var g;if(p||r.length===0)return;let v=r.some(w=>w.value===l),E=(g=n==null?void 0:n.elements)==null?void 0:g.some(w=>w.type==="channel"&&w.channel===l);!v&&!E&&c(r[0].value)},[r,l,c,p,n]);let f=(0,pr.useMemo)(()=>(m==null?void 0:m.filter(v=>!r.some(E=>E.value===v)).map(v=>$o.find(E=>E.value===v)).filter(v=>!!v))||[],[r,m]),C=(0,pr.useCallback)(v=>{let E=[],g,{elements:w,raw:N}=a2(v);if(E=w,g=N,!n){let P=[];for(let k of r){let{elements:M,raw:A}=a2(k.value),R={type:"channel",channel:k.value,elements:M};A&&(R.raw=A),P.push(R)}let T={type:"channel",channel:v,elements:E};g&&(T.raw=g),P.push(T);let x={version:"2022-01-01",elements:P};i(x),a(x),c(v);return}let S=ft(n,{elements:E,channel:g?{channel:v,raw:g}:v});i(S),a(S),c(v)},[n,i,a,c,r]),h=(0,pr.useCallback)(v=>{if(!n)return;let E=n.elements.filter(N=>N.type==="channel"?N.channel!==v:!0),g={...n,elements:E};i(g),a(g),u(null);let w=r.filter(N=>N.value!==v);l===v&&w.length>0&&c(w[0].value)},[n,i,a,r,l,c,u]),b=(0,pr.useMemo)(()=>[...r,...f],[r,f]);return{enabledChannels:r,disabledChannels:f,channel:l,channelOptions:b,setChannel:c,addChannel:C,removeChannel:h}},"useChannels");var Te=require("react/jsx-runtime"),Rr=s(({hidePublish:e=!1,channels:t,routing:r})=>{let o=(0,vo.useRef)(null),n=(0,Ho.useAtomValue)(at),i=(0,Ho.useAtomValue)(se),a=(0,Ho.useAtomValue)(G),{publishTemplate:l,isTemplatePublishing:c}=Xn(),[u,p]=(0,Ho.useAtom)(jn),m=(0,Ho.useSetAtom)(lo),d=(0,Ho.useAtomValue)(lo),{enabledChannels:f,disabledChannels:C,channel:h,setChannel:b,addChannel:v,removeChannel:E}=Fc({channels:t,routing:r});(0,vo.useEffect)(()=>{n===!0&&p(null)},[n,p]);let g=(0,vo.useCallback)(()=>{d&&m(!1),l()},[l,d,m]),w=(0,vo.useCallback)(P=>{d&&m(!1),b(P)},[d,m,b]),N=(0,vo.useCallback)(P=>{d&&m(!1),v(P)},[d,m,v]),y=(0,vo.useCallback)(P=>{d&&m(!1),E(P)},[d,m,E]),S=(0,vo.useCallback)(()=>{d&&m(!1)},[d,m]);return(0,Te.jsxs)("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:S,children:[(0,Te.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[(0,Te.jsx)(Es,{value:h,onValueChange:w,className:"courier-h-full",ref:o,children:(0,Te.jsx)(na,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${$o.length}, fit-content(100%))`},children:f.map(P=>(0,Te.jsxs)(ai,{value:P.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:[P.label,P.value===h&&f.length>1&&(0,Te.jsxs)(tp,{children:[(0,Te.jsx)(rp,{asChild:!0,children:(0,Te.jsx)("div",{className:"courier-pl-2",children:(0,Te.jsx)(ia,{color:"#A3A3A3"})})}),(0,Te.jsxs)(ou,{ref:o,children:[(0,Te.jsx)(nu,{children:(0,Te.jsx)(s2.AlertDialogDescription,{children:"Are you sure you want to delete this channel?"})}),(0,Te.jsxs)(iu,{children:[(0,Te.jsx)(su,{asChild:!0,children:(0,Te.jsx)(Se,{buttonSize:"small",variant:"outline",children:"Cancel"})}),(0,Te.jsx)(au,{asChild:!0,children:(0,Te.jsx)(Se,{buttonSize:"small",variant:"primary",onClick:()=>y(P.value),children:"Delete"})})]})]})]})]},P.value))})}),C.length>0&&(0,Te.jsxs)(Te.Fragment,{children:[(0,Te.jsx)(mu,{orientation:"vertical",className:"!courier-h-5"}),(0,Te.jsxs)(ys,{children:[(0,Te.jsx)(Cs,{asChild:!0,children:(0,Te.jsx)(Se,{variant:"link",children:"+ Add channel"})}),(0,Te.jsx)(ea,{portalProps:{container:o.current},children:C.map(P=>(0,Te.jsxs)(ta,{onClick:()=>N(P.value),children:[P.icon,P.label]},P.value))})]})]})]}),(0,Te.jsxs)("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&(0,Te.jsx)(di,{isLoading:!!i,isSaving:!!n,isError:!!a}),!e&&i!==null&&(0,Te.jsx)(Se,{variant:"primary",buttonSize:"small",disabled:c===!0||n===!0||u!==null,onClick:g,children:c?"Publishing...":"Publish changes"})]})]})},"Channels");var Rt=require("react");function Ui({onSave:e,debounceMs:t=2e3,enabled:r=!0,onError:o,initialContent:n,flushBeforeSave:i}){let[a,l]=(0,Rt.useState)(!1),c=(0,Rt.useRef)(!1),u=(0,Rt.useRef)(null),p=(0,Rt.useRef)(),m=(0,Rt.useRef)(0),d=(0,Rt.useRef)();(0,Rt.useEffect)(()=>{n&&(p.current=JSON.stringify(n))},[n]);let f=(0,Rt.useCallback)(async()=>{if(c.current)return;if(i)try{i()}catch(g){console.error("[AutoSave] Error flushing updates:",g)}let E=u.current;if(u.current=null,!!E)try{let g=JSON.stringify(E);if(g===p.current)return;c.current=!0,l(!0),p.current=g,m.current=Date.now(),await e(E)}catch(g){console.error("[AutoSave] Save failed:",g),o==null||o(g)}finally{if(c.current=!1,l(!1),u.current){let g=t;d.current=setTimeout(()=>{d.current=void 0,f()},g)}}},[t,o,e,i]),C=(0,Rt.useRef)(r),h=(0,Rt.useRef)(t),b=(0,Rt.useRef)(f);return(0,Rt.useEffect)(()=>{C.current=r,h.current=t,b.current=f}),{handleAutoSave:(0,Rt.useCallback)(async E=>{if(!C.current)return;let g=JSON.stringify(E);if(u.current=E,g===p.current||c.current)return;d.current&&(clearTimeout(d.current),d.current=void 0);let w=h.current;d.current=setTimeout(()=>{d.current=void 0,b.current()},w)},[]),isSaving:a}}s(Ui,"useAutoSave");var Ye=require("jotai"),Re=require("react");var xo=require("jotai"),Lt=require("react");var Gt=require("zod"),l2=Gt.z.object({headerStyle:Gt.z.enum(["plain","border"]),isUnsubscribe:Gt.z.boolean().optional(),isPreferences:Gt.z.boolean().optional(),link:Gt.z.string().optional(),brandColor:Gt.z.string(),textColor:Gt.z.string(),subtleColor:Gt.z.string(),logo:Gt.z.string().optional(),facebookLink:Gt.z.string().optional(),linkedinLink:Gt.z.string().optional(),instagramLink:Gt.z.string().optional(),mediumLink:Gt.z.string().optional(),xLink:Gt.z.string().optional()}),Yt={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};var t0=s(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),os=s(e=>{var t,r,o,n,i,a,l,c,u,p,m,d,f,C;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 v=e.marks.map(t0).filter(Boolean);h=v.join("")+h+v.reverse().join("")}let b=(o=e.marks)==null?void 0:o.find(v=>v.type==="link");return b&&(h=`[${h}](${(n=b.attrs)==null?void 0:n.href})`),h}case"hardBreak":return`
215
- `;case"paragraph":return(((i=e.content)==null?void 0:i.map(os).join(""))||"")+`
208
+ `}]}),h.elements||(h.elements=[]);let x=[...h.elements.filter(C=>C.type!=="action")];if(f.enableButton){let C={type:"action",content:f.buttonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.buttonUrl};x.push(C)}if(f.enableSecondaryButton){let C={type:"action",content:f.secondaryButtonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.secondaryButtonUrl};x.push(C)}let E={...h,elements:x},g=v.elements.findIndex(C=>C.type==="channel"&&C.channel==="inbox"),b=[...v.elements];g!==-1?b[g]=E:b.push(E);let M={...v,elements:b};r(M),o(M)},[r,o]),u=(0,fr.useCallback)(f=>{if(!e)return!1;let{doc:v}=e.state,h=null,y=[];v.descendants((E,g)=>E.type.name==="buttonRow"&&h===null?(h=g,!1):(E.type.name==="button"&&y.push({pos:g,attrs:E.attrs}),!0));let x=a((E,g)=>{let b=v.nodeAt(E);return b?(e.commands.command(({tr:M})=>(M.setNodeMarkup(E,b.type,g),!0)),!0):!1},"applyAttrs");if(h!==null){let E=v.nodeAt(h);if(!E)return!1;let g={...E.attrs,button1Label:f.buttonLabel,button1Link:f.buttonUrl,button2Label:f.secondaryButtonLabel,button2Link:f.secondaryButtonUrl};return x(h,g)}if(y.length>0){let[E,g]=y,b={...E.attrs,label:f.buttonLabel,link:f.buttonUrl},M=x(E.pos,b),C=!0;if(g){let S={...g.attrs,label:f.secondaryButtonLabel,link:f.secondaryButtonUrl};C=x(g.pos,S)}return M&&C}return!1},[e]),d=(0,fr.useCallback)(f=>{if(n.current)return;let v=i.current;if(i.current=f,!v||v.enableButton!==f.enableButton||v.enableSecondaryButton!==f.enableSecondaryButton){c(f);return}u(f)||c(f)},[c,u]),p=Iu("inbox-sidebar",d,500),m=(0,fr.useCallback)(()=>{let f=l.getValues();p(f)},[l,p]);return(0,De.jsx)(rt,{...l,children:(0,De.jsxs)("form",{onChange:m,children:[(0,De.jsx)("div",{className:"courier-pb-4",children:(0,De.jsx)(oe,{control:l.control,name:"enableButton",render:({field:f})=>(0,De.jsxs)(te,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between",children:[(0,De.jsx)(Vo,{className:"!courier-m-0",children:"Enable button"}),(0,De.jsx)(re,{children:(0,De.jsx)(Gi,{checked:f.value,onCheckedChange:f.onChange,className:"!courier-m-0"})})]})})}),l.watch("enableButton")&&(0,De.jsx)(oe,{control:l.control,name:"buttonUrl",render:({field:f})=>(0,De.jsxs)(te,{className:"courier-mb-6",children:[(0,De.jsx)(Vo,{children:"Action URL"}),(0,De.jsx)(re,{children:(0,De.jsx)(Ee,{placeholder:"https://example.com",...f})}),(0,De.jsx)(ne,{})]})}),(0,De.jsx)(ge,{className:"courier-mb-6"}),(0,De.jsx)(oe,{control:l.control,name:"enableSecondaryButton",render:({field:f})=>(0,De.jsxs)(te,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between courier-mb-4",children:[(0,De.jsx)(Vo,{className:"!courier-m-0",children:"Enable secondary button"}),(0,De.jsx)(re,{children:(0,De.jsx)(Gi,{checked:f.value,onCheckedChange:f.onChange,className:"!courier-m-0"})})]})}),l.watch("enableSecondaryButton")&&(0,De.jsx)(oe,{control:l.control,name:"secondaryButtonUrl",render:({field:f})=>(0,De.jsxs)(te,{className:"courier-mb-4",children:[(0,De.jsx)(Vo,{children:"Action URL"}),(0,De.jsx)(re,{children:(0,De.jsx)(Ee,{placeholder:"https://example.com",...f})}),(0,De.jsx)(ne,{})]})})]})})},"SideBarComponent"),Ru=(0,fr.memo)(yC);var Jb=require("jotai");var dn=require("react/jsx-runtime"),Kb=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s,...l})=>{let c=(0,Jb.useAtomValue)(le);return(0,dn.jsx)(Nu,{value:c,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:u=>(0,dn.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,dn.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1 courier-py-8 courier-items-center",children:(0,dn.jsx)(Su,{...u},`inbox-editor-${o?"no-autocomplete":"autocomplete"}`)}),(0,dn.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,dn.jsx)("div",{className:"courier-p-4 courier-h-full",children:(0,dn.jsx)(Ru,{})})})]}),...l})},"InboxLayout");var Gb=require("@tiptap/react"),ko=require("jotai"),kt=require("react");var Kp=require("react/jsx-runtime"),Xb=a(({value:e})=>{let{editor:t}=(0,Gb.useCurrentEditor)(),r=(0,ko.useSetAtom)(He),o=(0,ko.useAtomValue)(le),n=(0,ko.useAtomValue)(pe),i=(0,kt.useRef)(!1);return(0,kt.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,kt.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,kt.useEffect)(()=>{t&&(r(t),Lr("push",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,kt.useEffect)(()=>{if(!t||!o||t.isFocused)return;let s=Yb(o),l=s.type==="channel"&&"elements"in s&&s.elements||Li;l=l.map(m=>m.type==="meta"&&"title"in m?{type:"text",content:m.title||`
209
+ `,text_style:"h2"}:m);let u=tt({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:l}]}),d=be(u),p=be(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"PushEditorContent"),Li=[{type:"meta",title:""},{type:"text",content:`
210
+ `}],Yb=a(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:Li}),t},"getOrCreatePushElement"),Qb={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"}},vC=(0,kt.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...p},m)=>{let f=(0,ko.useAtomValue)(pe),v=(0,kt.useRef)(!0),h=(0,kt.useRef)(!1),y=(0,ko.useSetAtom)(we),[x,E]=(0,ko.useAtom)(le),g=(0,ko.useSetAtom)(it),b=(0,ko.useAtomValue)(Ft);(0,kt.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let M=(0,kt.useMemo)(()=>[...Sr({setSelectedNode:y,variables:u,disableVariablesAutocomplete:d})].filter(P=>P!==void 0),[y,u,d]),C=(0,kt.useCallback)(({editor:P})=>{if(b)return;if(!x){let B=be(P.getJSON()),H=B[0],D="",F=B;H&&H.type==="text"&&"text_style"in H&&H.text_style==="h2"&&"content"in H&&(D=H.content.trim(),F=B.slice(1));let W={version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:io(null,"push",D,F).elements}]};E(W),g(W);return}let k=be(P.getJSON()),w=k[0],T="",A=k;w&&w.type==="text"&&"text_style"in w&&w.text_style==="h2"&&"content"in w&&(T=w.content.trim(),A=k.slice(1));let N=io(x,"push",T,A),R=Nt(x,{channel:"push",elements:N.elements});JSON.stringify(x)!==JSON.stringify(R)&&(E(R),g(R))},[x,E,g,b]),S=(0,kt.useMemo)(()=>{if(f!==!1)return null;let P=l==null?void 0:l.elements.find(T=>T.type==="channel"&&T.channel==="push");!P&&x&&(P=Yb(x));let k=(P==null?void 0:P.type)==="channel"&&"elements"in P&&P.elements||Li;return k=k.map(T=>T.type==="meta"&&"title"in T?{type:"text",content:T.title||`
211
+ `,text_style:"h2"}:T),tt({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:k}]})},[l,x,f]);return(0,Kp.jsx)(wr,{theme:e,colorScheme:c,isLoading:!!(f&&v.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Kp.jsx)(ro,{hidePublish:t,channels:o,routing:n}),...p,ref:m,children:s==null?void 0:s({content:S,extensions:M,editable:!r,autofocus:!r,onUpdate:C})})}),Lu=(0,kt.memo)(vC);var e2=require("@tiptap/react");var gr=require("react/jsx-runtime"),Bu=a(({children:e})=>(0,gr.jsxs)("div",{className:"courier-relative",children:[(0,gr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-6 courier-bg-border -courier-left-[2px] courier-top-[136px]"}),(0,gr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[178px]"}),(0,gr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[245px]"}),(0,gr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[78px] courier-bg-border -courier-right-[2px] courier-top-[200px]"}),(0,gr.jsxs)("div",{className:"courier-py-2 courier-border-8 courier-border-b-0 courier-w-[306px] courier-h-[500px] courier-rounded-[40px] courier-rounded-b-none courier-bg-background courier-pb-6 courier-relative",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,gr.jsxs)("div",{className:"courier-my-6 courier-mx-11 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,gr.jsx)("span",{className:"courier-text-xs courier-font-semibold",children:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),(0,gr.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2",children:[(0,gr.jsx)(u1,{}),(0,gr.jsx)(m1,{}),(0,gr.jsx)(c1,{})]})]}),(0,gr.jsx)("div",{className:"courier-flex-1 courier-overflow-auto courier-h-[calc(90%-56px)] courier-mb-6",children:e})]})]}),"IPhoneFrame");var $r=require("react/jsx-runtime"),Du=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:s=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=s?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,$r.jsxs)(Bu,{children:[(0,$r.jsxs)("div",{className:I("courier-px-4 courier-py-2 courier-text-[#A3A3A3] courier-text-center courier-my-8",i),children:[(0,$r.jsx)("p",{className:"courier-text-lg courier-font-medium",children:new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}),(0,$r.jsx)("p",{className:"courier-text-5xl courier-font-semibold courier-mt-1",children:new Date().toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})})]}),(0,$r.jsx)(e2.EditorProvider,{content:l,extensions:t,...c,editorContainerProps:{className:I("courier-push-editor")},"data-testid":"editor-provider",immediatelyRender:!1,children:s?(0,$r.jsx)(oo,{value:l,defaultValue:Li}):(0,$r.jsxs)($r.Fragment,{children:[(0,$r.jsx)(Xb,{value:l}),(0,$r.jsx)(Ir,{config:Qb})]})})]})},"PushEditor");var t2=require("jotai");var Hu=require("react/jsx-runtime"),r2=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,...s})=>{let l=(0,t2.useAtomValue)(le);return(0,Hu.jsx)(Lu,{value:l,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,render:c=>(0,Hu.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,Hu.jsx)(Du,{...c},`push-editor-${o?"no-autocomplete":"autocomplete"}`)}),...s})},"PushLayout");var o2=require("@tiptap/react"),hr=require("jotai"),Se=require("react");var Ha=require("react/jsx-runtime"),el=[{type:"text",content:`
212
+ `}],n2=a(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:el}),t},"getOrCreateSlackElement"),i2=a(({value:e})=>{let{editor:t}=(0,o2.useCurrentEditor)(),r=(0,hr.useSetAtom)(He),o=(0,hr.useAtomValue)(le),n=(0,hr.useAtomValue)(pe),i=(0,hr.useAtomValue)(we),s=(0,Se.useRef)(!1),l=(0,Se.useRef)(!1);return(0,Se.useEffect)(()=>{n&&(s.current=!1)},[n]),(0,Se.useEffect)(()=>{!t||n!==!1||s.current||!e||(s.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Se.useEffect)(()=>{t&&(r(t),Lr("slack",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Se.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Se.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,Se.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=n2(o),u=tt({version:"2022-01-01",elements:[c]},{channel:"slack"}),d=be(u),p=be(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"SlackEditorContent"),a2={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"]}}]},CC=(0,Se.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...p},m)=>{let f=(0,hr.useAtomValue)(pe),v=(0,hr.useAtomValue)(Ft),h=(0,hr.useAtomValue)(He),y=(0,hr.useAtomValue)(Cr),[x,E]=(0,hr.useAtom)(we),[g,b]=(0,hr.useAtom)(le),M=(0,hr.useSetAtom)(it),C=(0,Se.useRef)(!0),S=(0,Se.useRef)(!1),P=(0,Se.useRef)(y),k=(0,Se.useRef)(null),w=(0,hr.useAtomValue)(Ho),T=(0,Se.useMemo)(()=>{let L=["text","divider","button"];return w.filter(W=>{let _=Hr(W)?W.type:W;return L.includes(_)})},[w]),[A,N]=(0,Se.useState)({Sidebar:T,Editor:[]});(0,Se.useEffect)(()=>{N(L=>({...L,Sidebar:T}))},[T]),Na({items:A,setItems:N});let{syncEditorItems:R}=vu({setItems:N,rafId:k});(0,Se.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]),(0,Se.useEffect)(()=>{P.current=y},[y]),(0,Se.useEffect)(()=>{f===!1&&g&&setTimeout(()=>{h&&!h.isDestroyed&&R(h)},300)},[f,g,h,R]);let B=(0,Se.useCallback)(()=>!P.current,[]),H=(0,Se.useMemo)(()=>[...Sr({setSelectedNode:E,shouldHandleClick:B,variables:u,disableVariablesAutocomplete:d})].filter(L=>L!==void 0),[E,B,u,d]),D=(0,Se.useCallback)(({editor:L})=>{if(!L||v)return;if(!g){let X={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:be(L.getJSON())}]};b(X),M(X);return}let W=L.getJSON(),_=be(W),V=Nt(g,{elements:_,channel:"slack"}),j=JSON.stringify(g.elements),J=JSON.stringify(V.elements);j!==J&&(b(V),M(V))},[g,b,M,v]),F=(0,Se.useMemo)(()=>{let L=n2(l);return tt({version:"2022-01-01",elements:[L]},{channel:"slack"})},[l]);return(0,Ha.jsx)(wr,{theme:e,colorScheme:c,isLoading:!!(f&&C.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Ha.jsx)(ro,{hidePublish:t,channels:o,routing:n}),ref:m,...p,children:(0,Ha.jsx)(Ha.Fragment,{children:s==null?void 0:s({content:F,extensions:H,editable:!r,autofocus:!r,onUpdate:D,items:A,selectedNode:x,slackEditor:h})})})}),Vu=(0,Se.memo)(CC);var c2=require("@tiptap/react");var Je=require("react/jsx-runtime"),xC=a(()=>(0,Je.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-col courier-w-full",children:[(0,Je.jsx)("div",{className:"courier-w-3/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),(0,Je.jsx)("div",{className:"courier-w-full courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),(0,Je.jsx)("div",{className:"courier-w-6/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"})]}),"TextSkeleton"),TC=a(()=>(0,Je.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-lg",children:(0,Je.jsx)(ls,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),s2=a(()=>(0,Je.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row",children:[(0,Je.jsx)(TC,{}),(0,Je.jsx)(xC,{})]}),"InteractionSkeleton"),l2=a(({children:e,className:t})=>(0,Je.jsxs)("div",{className:I("courier-w-full courier-max-w-[800px] courier-bg-white dark:courier-bg-[#171717] courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Je.jsx)(s2,{}),(0,Je.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Je.jsx)("div",{className:"courier-flex-shrink-0",children:(0,Je.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-md courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,Je.jsx)(ss,{color:"#FFFFFF"})})}),(0,Je.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Je.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mb-1",children:[(0,Je.jsx)("span",{className:"courier-font-semibold courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1]",children:"Circle"}),(0,Je.jsx)("span",{className:"courier-inline-flex courier-items-center courier-px-1.5 courier-py-0.5 courier-rounded courier-text-xs courier-font-medium courier-bg-gray-200 dark:courier-bg-[#2E333F] courier-text-gray-700 dark:courier-text-[#C9C8E1]",children:"APP"}),(0,Je.jsx)("span",{className:"courier-text-xs courier-text-gray-500 dark:courier-text-[#8786A9]",children:"Now"})]}),(0,Je.jsx)("div",{className:"courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-pr-4",children:e})]})]}),(0,Je.jsx)(s2,{})]}),"SlackFrame");var Fu=require("react");var Po=require("react/jsx-runtime"),Ou=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let s=(0,Fu.useRef)(null);return(0,Fu.useEffect)(()=>{let l=s.current;if(!(!l||i))return Wr({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,Po.jsx)(l2,{children:(0,Po.jsx)("div",{ref:s,children:(0,Po.jsx)(c2.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:I("courier-slack-editor")},immediatelyRender:!1,children:i?(0,Po.jsx)(oo,{value:e,defaultValue:el}):(0,Po.jsxs)(Po.Fragment,{children:[(0,Po.jsx)(i2,{value:e}),(0,Po.jsx)(Ir,{config:a2})]})})})}):null},"SlackEditor");var f2=require("jotai");var u2=require("lucide-react");var nr=require("react/jsx-runtime"),Wu=a(({items:e,label:t,editor:r})=>(0,nr.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,nr.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,nr.jsxs)(nr.Fragment,{children:[(0,nr.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),(0,nr.jsx)(ge,{className:"courier-my-4"})]}),(0,nr.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>{let n=Hr(o)?`${o.type}:${o.preset}`:o,i=Hr(o)?o.type:o;return(0,nr.jsx)(La,{id:n,editor:r,children:(0,nr.jsxs)("div",{className:I("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,nr.jsx)(u2.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),i==="text"&&(0,nr.jsx)(Mn,{draggable:!0}),i==="divider"&&(0,nr.jsx)(An,{draggable:!0}),i==="button"&&(0,nr.jsx)(Pn,{draggable:!0})]})},n)})})]})}),"SlackSideBar");var d2=require("@hookform/resolvers/zod"),m2=require("react-hook-form");var Ao=require("react/jsx-runtime"),p2=a(({element:e,editor:t})=>{let r=(0,m2.useForm)({resolver:(0,d2.zodResolver)(mc),defaultValues:{...at,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Ut({editor:t,element:e,form:r,nodeType:"button"});return e?(0,Ao.jsxs)(rt,{...r,children:[(0,Ao.jsx)(or,{type:"button"}),(0,Ao.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Ao.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,Ao.jsx)(oe,{control:r.control,name:"link",render:({field:n})=>(0,Ao.jsxs)(te,{children:[(0,Ao.jsx)(re,{children:(0,Ao.jsx)(yo,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})}})}),(0,Ao.jsx)(ne,{})]})})]})]}):null},"SlackButtonForm");var Gp=require("react/jsx-runtime"),Uu=a(({element:e,editor:t,defaultElement:r})=>e&&e.type.name==="button"?(0,Gp.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:(0,Gp.jsx)(p2,{element:e,editor:t},e.attrs.id)}):r,"SlackSideBarItemDetails");var Xp=require("react");var Br=require("react/jsx-runtime"),EC=(0,Xp.forwardRef)(({children:e,className:t,...r},o)=>(0,Br.jsx)("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),wC=(0,Xp.forwardRef)(({children:e,...t},r)=>(0,Br.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),g2=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s})=>{let l=(0,f2.useAtomValue)(le);return(0,Br.jsx)(Vu,{value:l,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:c=>{var u;return(0,Br.jsxs)(Un,{children:[(0,Br.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Br.jsx)(EC,{children:(0,Br.jsx)(wC,{children:(0,Br.jsx)(Ou,{...c},`slack-editor-${o?"no-autocomplete":"autocomplete"}`)})})}),(0,Br.jsx)(_n,{children:(0,Br.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,Br.jsx)(Uu,{element:c.selectedNode,editor:c.slackEditor,defaultElement:(0,Br.jsx)(Wu,{items:c.items.Sidebar,label:"Blocks library",editor:(u=c.slackEditor)!=null?u:void 0})})})})]})}})},"SlackLayout");var h2=require("@tiptap/react"),Mo=require("jotai"),Ke=require("react"),b2=require("sms-segments-calculator");var _u=require("react/jsx-runtime"),mn=[{type:"text",content:`
213
+ `}],y2=a(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:mn}),t},"getOrCreateSMSElement"),v2=a(({value:e})=>{var c;let{editor:t}=(0,h2.useCurrentEditor)(),r=(0,Mo.useSetAtom)(He),o=(0,Mo.useAtomValue)(le),n=(c=t==null?void 0:t.getText())!=null?c:"",i=(0,Ke.useMemo)(()=>new b2.SegmentedMessage(n),[n]),s=(0,Mo.useAtomValue)(pe),l=(0,Ke.useRef)(!1);return(0,Ke.useEffect)(()=>{s&&(l.current=!1)},[s]),(0,Ke.useEffect)(()=>{!t||s!==!1||l.current||!e||(l.current=!0,t.commands.setContent(e))},[t,e,s]),(0,Ke.useEffect)(()=>{t&&(r(t),Lr("sms",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ke.useEffect)(()=>{if(!t||!o||t.isFocused)return;let u=y2(o),p={type:"channel",channel:"sms",elements:u.type==="channel"&&"elements"in u&&u.elements||mn},m=tt({version:"2022-01-01",elements:[p]}),f=be(m),v=be(t.getJSON());JSON.stringify(f)!==JSON.stringify(v)&&setTimeout(()=>{t.isFocused||t.commands.setContent(m)},1)},[t,o]),(0,_u.jsx)("span",{className:"courier-self-end courier-pr-2 courier-text-xs courier-color-gray-500",children:Math.ceil(((i==null?void 0:i.messageSize)||0)/8)})},"SMSEditorContent"),C2={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"}},kC=(0,Ke.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,render:i,headerRenderer:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...p},m)=>{let f=(0,Mo.useAtomValue)(pe),v=(0,Ke.useRef)(!0),h=(0,Ke.useRef)(!1),y=(0,Mo.useSetAtom)(we),[x,E]=(0,Mo.useAtom)(le),g=(0,Mo.useSetAtom)(it),b=(0,Mo.useAtomValue)(Ft);(0,Ke.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let M=(0,Ke.useMemo)(()=>[...Sr({setSelectedNode:y,variables:u,disableVariablesAutocomplete:d})].filter(T=>T!==void 0),[y,u,d]),C=(0,Ke.useRef)(!1),S=(0,Ke.useCallback)(({editor:T})=>{if(b)return;if(!x){let B=be(T.getJSON()),H=pl(B),D={version:"2022-01-01",elements:[{type:"channel",channel:"sms",elements:H.length>0?H:mn}]};C.current=!0,E(D),g(D);return}let A=be(T.getJSON()),N=pl(A),R=Nt(x,{channel:"sms",elements:N.length>0?N:mn});JSON.stringify(x)!==JSON.stringify(R)&&(C.current=!0,E(R),g(R))},[x,E,g,b]),[P,k]=(0,Ke.useState)(null),w=(0,Ke.useCallback)(T=>{if(!T)return null;let A=T==null?void 0:T.elements.find(B=>B.type==="channel"&&B.channel==="sms");A||(A=y2(T));let R={type:"channel",channel:"sms",elements:(A==null?void 0:A.type)==="channel"&&"elements"in A&&A.elements||mn};return tt({version:"2022-01-01",elements:[R]})},[]);return(0,Ke.useEffect)(()=>{if(f!==!1)return;if(C.current){C.current=!1;return}let T=l!=null?l:x,A=w(T);A&&k(A)},[l,x,w,f]),(0,_u.jsx)(wr,{theme:e,colorScheme:c,isLoading:!!(f&&v.current),Header:s?s({hidePublish:t,channels:o,routing:n}):(0,_u.jsx)(ro,{hidePublish:t,channels:o,routing:n}),...p,ref:m,children:i==null?void 0:i({content:P,extensions:M,editable:!r,autofocus:!r,onUpdate:S})})}),zu=(0,Ke.memo)(kC);var x2=require("@tiptap/react");var No=require("react/jsx-runtime"),$u=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:s=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=s?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,No.jsx)(Bu,{children:(0,No.jsx)("div",{className:I("courier-sms-editor",i),children:(0,No.jsx)(x2.EditorProvider,{content:l,extensions:t,...c,"data-testid":"editor-provider",immediatelyRender:!1,children:s?(0,No.jsx)(oo,{value:l,defaultValue:mn}):(0,No.jsxs)(No.Fragment,{children:[(0,No.jsx)(v2,{value:l}),(0,No.jsx)(Ir,{config:C2})]})})})})},"SMSEditor");var T2=require("jotai");var ju=require("react/jsx-runtime"),E2=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s,...l})=>{let c=(0,T2.useAtomValue)(le);return(0,ju.jsx)(zu,{value:c,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:u=>(0,ju.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,ju.jsx)($u,{...u},`sms-editor-${o?"no-autocomplete":"autocomplete"}`)}),...l})},"SMSLayout");var w2=require("@tiptap/react"),br=require("jotai"),Ae=require("react");var Va=require("react/jsx-runtime"),tl=[{type:"text",content:`
214
+ `}],k2=a(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:tl}),t},"getOrCreateMSTeamsElement"),P2=a(({value:e})=>{let{editor:t}=(0,w2.useCurrentEditor)(),r=(0,br.useSetAtom)(He),o=(0,br.useAtomValue)(le),n=(0,br.useAtomValue)(pe),i=(0,br.useAtomValue)(we),s=(0,Ae.useRef)(!1),l=(0,Ae.useRef)(!1);return(0,Ae.useEffect)(()=>{n&&(s.current=!1)},[n]),(0,Ae.useEffect)(()=>{!t||n!==!1||s.current||!e||(s.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Ae.useEffect)(()=>{t&&(r(t),Lr("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ae.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Ae.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,Ae.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=k2(o),u=tt({version:"2022-01-01",elements:[c]},{channel:"msteams"}),d=be(u),p=be(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"MSTeamsEditorContent"),A2={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"]}}]},PC=(0,Ae.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...p},m)=>{let f=(0,br.useAtomValue)(pe),v=(0,br.useAtomValue)(Ft),h=(0,br.useAtomValue)(He),y=(0,br.useAtomValue)(Cr),[x,E]=(0,br.useAtom)(we),[g,b]=(0,br.useAtom)(le),M=(0,br.useSetAtom)(it),C=(0,Ae.useRef)(!0),S=(0,Ae.useRef)(!1),P=(0,Ae.useRef)(y),k=(0,br.useAtomValue)(Ho),w=(0,Ae.useMemo)(()=>{let L=["text","divider"];return k.filter(W=>{let _=Hr(W)?W.type:W;return L.includes(_)})},[k]),[T,A]=(0,Ae.useState)({Sidebar:w,Editor:[]});(0,Ae.useEffect)(()=>{A(L=>({...L,Sidebar:w}))},[w]);let N=(0,Ae.useRef)(null);Na({items:T,setItems:A});let R=(0,Ae.useCallback)(L=>{N.current&&cancelAnimationFrame(N.current),setTimeout(()=>{N.current=requestAnimationFrame(()=>{try{let W=L==null?void 0:L.view.dom;if(!W){console.warn("syncEditorItems: Editor DOM element not found");return}let _=W.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),V=[];_.forEach(j=>{let J=j.dataset.id;J&&V.push(J)}),A(j=>({Editor:V,Sidebar:j.Sidebar}))}catch(W){console.error("Error syncing editor items:",W),A(_=>({..._}))}})},50)},[]);(0,Ae.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]),(0,Ae.useEffect)(()=>{P.current=y},[y]),(0,Ae.useEffect)(()=>{let L=a(()=>{h&&R(h)},"updateItems");h==null||h.on("update",L),h==null||h.on("selectionUpdate",L),h==null||h.on("create",L),h==null||h.on("transaction",L),h&&!h.isDestroyed&&L();let W=a(_=>{L()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",W),()=>{h==null||h.off("update",L),h==null||h.off("selectionUpdate",L),h==null||h.off("create",L),h==null||h.off("transaction",L),document.removeEventListener("node-duplicated",W),N.current&&cancelAnimationFrame(N.current)}},[h,R]),(0,Ae.useEffect)(()=>{f===!1&&g&&setTimeout(()=>{h&&!h.isDestroyed&&R(h)},300)},[f,g,h,R]);let B=(0,Ae.useCallback)(()=>!P.current,[]),H=(0,Ae.useMemo)(()=>[...Sr({setSelectedNode:E,shouldHandleClick:B,variables:u,disableVariablesAutocomplete:d})].filter(L=>L!==void 0),[E,B,u,d]),D=(0,Ae.useCallback)(({editor:L})=>{if(!L||v)return;if(!g){let X={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:be(L.getJSON())}]};b(X),M(X);return}let W=L.getJSON(),_=be(W),V=Nt(g,{elements:_,channel:"msteams"}),j=JSON.stringify(g.elements),J=JSON.stringify(V.elements);j!==J&&(b(V),M(V))},[g,b,M,v]),F=(0,Ae.useMemo)(()=>{let L=k2(l);return tt({version:"2022-01-01",elements:[L]},{channel:"msteams"})},[l]);return(0,Va.jsx)(wr,{theme:e,colorScheme:c,isLoading:!!(f&&C.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Va.jsx)(ro,{hidePublish:t,channels:o,routing:n}),ref:m,...p,children:(0,Va.jsx)(Va.Fragment,{children:s==null?void 0:s({content:F,extensions:H,editable:!r,autofocus:!r,onUpdate:D,items:T,selectedNode:x,msteamsEditor:h})})})}),Zu=(0,Ae.memo)(PC);var N2=require("@tiptap/react");var Qe=require("react/jsx-runtime"),AC=a(()=>(0,Qe.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-full",children:(0,Qe.jsx)(ls,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),MC=a(()=>(0,Qe.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[(0,Qe.jsx)(AC,{}),(0,Qe.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[(0,Qe.jsx)("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"}),(0,Qe.jsx)("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),NC=a(()=>(0,Qe.jsx)("div",{className:"courier-flex courier-justify-end courier-w-full",children:(0,Qe.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:(0,Qe.jsx)("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),M2=a(({children:e,className:t})=>(0,Qe.jsxs)("div",{className:I("courier-w-full courier-max-w-[800px] courier-bg-white dark:courier-bg-[#171717] courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Qe.jsx)(MC,{}),(0,Qe.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Qe.jsx)("div",{className:"courier-flex-shrink-0 courier-mt-6",children:(0,Qe.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-full courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,Qe.jsx)(ss,{color:"#FFFFFF"})})}),(0,Qe.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Qe.jsx)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:(0,Qe.jsx)("span",{className:"courier-text-sm courier-text-[#A3A3A3] dark:courier-text-[#8786A9]",children:"Circle"})}),(0,Qe.jsx)("div",{className:"courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px] courier-px-3 courier-py-2 courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-max-w-full courier-pr-5",children:e})]})]}),(0,Qe.jsx)(NC,{})]}),"MSTeamsFrame");var qu=require("react");var So=require("react/jsx-runtime"),Ju=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let s=(0,qu.useRef)(null);return(0,qu.useEffect)(()=>{let l=s.current;if(!(!l||i))return Wr({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,So.jsx)(M2,{children:(0,So.jsx)("div",{ref:s,children:(0,So.jsx)(N2.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:I("courier-msteams-editor")},immediatelyRender:!1,children:i?(0,So.jsx)(oo,{value:e,defaultValue:tl}):(0,So.jsxs)(So.Fragment,{children:[(0,So.jsx)(P2,{value:e}),(0,So.jsx)(Ir,{config:A2})]})})})}):null},"MSTeamsEditor");var I2=require("jotai");var S2=require("lucide-react");var ir=require("react/jsx-runtime"),Ku=a(({items:e,label:t,editor:r})=>(0,ir.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,ir.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,ir.jsxs)(ir.Fragment,{children:[(0,ir.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),(0,ir.jsx)(ge,{className:"courier-my-4"})]}),(0,ir.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>{let n=Hr(o)?`${o.type}:${o.preset}`:o,i=Hr(o)?o.type:o;return(0,ir.jsx)(La,{id:n,editor:r,children:(0,ir.jsxs)("div",{className:I("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,ir.jsx)(S2.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),i==="text"&&(0,ir.jsx)(Mn,{draggable:!0}),i==="divider"&&(0,ir.jsx)(An,{draggable:!0}),i==="button"&&(0,ir.jsx)(Pn,{draggable:!0})]})},n)})})]})}),"MSTeamsSideBar");var Yp=require("react");var jr=require("react/jsx-runtime"),SC=(0,Yp.forwardRef)(({children:e,className:t,...r},o)=>(0,jr.jsx)("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),IC=(0,Yp.forwardRef)(({children:e,...t},r)=>(0,jr.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),R2=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s})=>{let l=(0,I2.useAtomValue)(le);return(0,jr.jsx)(Zu,{value:l,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:c=>{var u;return(0,jr.jsxs)(Un,{children:[(0,jr.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,jr.jsx)(SC,{children:(0,jr.jsx)(IC,{children:(0,jr.jsx)(Ju,{...c},`msteams-editor-${o?"no-autocomplete":"autocomplete"}`)})})}),(0,jr.jsx)(_n,{children:(0,jr.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,jr.jsx)(Ku,{items:c.items.Sidebar,label:"Blocks library",editor:(u=c.msteamsEditor)!=null?u:void 0})})})]})}})},"MSTeamsLayout");var L2={sms:{elements:mn},push:{elements:Li},inbox:{elements:Qs},slack:{elements:el},email:{elements:Gs},msteams:{elements:tl}},Gu=a(e=>{var t;return(t=L2[e])!=null?t:L2.email},"getChannelDefaults"),RC=a((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"),Xu=a(({channels:e=["email"],routing:t})=>{let[r,o]=(0,Dr.useState)([]),n=(0,pn.useAtomValue)(le),i=(0,pn.useSetAtom)(le),s=(0,pn.useSetAtom)(it),[l,c]=(0,pn.useAtom)(xn),u=(0,pn.useSetAtom)(we),d=(0,pn.useAtomValue)(pe),p=RC(t,e),m=(0,Dr.useRef)(p);m.current=p,(0,Dr.useEffect)(()=>{if(d||n!=null&&n.elements)return;let E=m.current.map(g=>Cn.find(b=>b.value===g)).filter(g=>!!g);o(E),E.length>0&&!l&&c(E[0].value)},[n,d,c,l]),(0,Dr.useEffect)(()=>{if(d||!(n!=null&&n.elements))return;let x=m.current,E=n.elements.filter(b=>b.type==="channel").map(b=>b.channel).filter(b=>x.includes(b)),g=x.filter(b=>E.includes(b)).map(b=>Cn.find(M=>M.value===b)).filter(b=>!!b);o(g)},[n,d]),(0,Dr.useEffect)(()=>{var g;if(d||r.length===0)return;let x=r.some(b=>b.value===l),E=(g=n==null?void 0:n.elements)==null?void 0:g.some(b=>b.type==="channel"&&b.channel===l);!x&&!E&&c(r[0].value)},[r,l,c,d,n]);let f=(0,Dr.useMemo)(()=>(p==null?void 0:p.filter(x=>!r.some(E=>E.value===x)).map(x=>Cn.find(E=>E.value===x)).filter(x=>!!x))||[],[r,p]),v=(0,Dr.useCallback)(x=>{let E=[],g,{elements:b,raw:M}=Gu(x);if(E=b,g=M,!n){let P=[];for(let T of r){let{elements:A,raw:N}=Gu(T.value),R={type:"channel",channel:T.value,elements:A};N&&(R.raw=N),P.push(R)}let k={type:"channel",channel:x,elements:E};g&&(k.raw=g),P.push(k);let w={version:"2022-01-01",elements:P};i(w),s(w),c(x);return}let S=Nt(n,{elements:E,channel:g?{channel:x,raw:g}:x});i(S),s(S),c(x)},[n,i,s,c,r]),h=(0,Dr.useCallback)(x=>{if(!n)return;let E=n.elements.filter(M=>M.type==="channel"?M.channel!==x:!0),g={...n,elements:E};i(g),s(g),u(null);let b=r.filter(M=>M.value!==x);l===x&&b.length>0&&c(b[0].value)},[n,i,s,r,l,c,u]),y=(0,Dr.useMemo)(()=>[...r,...f],[r,f]);return{enabledChannels:r,disabledChannels:f,channel:l,channelOptions:y,setChannel:c,addChannel:v,removeChannel:h}},"useChannels");var Ie=require("react/jsx-runtime"),ro=a(({hidePublish:e=!1,channels:t,routing:r})=>{let o=(0,qo.useRef)(null),n=(0,fn.useAtomValue)(yt),i=(0,fn.useAtomValue)(pe),s=(0,fn.useAtomValue)(ae),{publishTemplate:l,isTemplatePublishing:c}=zi(),[u,d]=(0,fn.useAtom)(Fi),p=(0,fn.useSetAtom)(Do),m=(0,fn.useAtomValue)(Do),{enabledChannels:f,disabledChannels:v,channel:h,setChannel:y,addChannel:x,removeChannel:E}=Xu({channels:t,routing:r});(0,qo.useEffect)(()=>{n===!0&&d(null)},[n,d]);let g=(0,qo.useCallback)(()=>{m&&p(!1),l()},[l,m,p]),b=(0,qo.useCallback)(P=>{m&&p(!1),y(P)},[m,p,y]),M=(0,qo.useCallback)(P=>{m&&p(!1),x(P)},[m,p,x]),C=(0,qo.useCallback)(P=>{m&&p(!1),E(P)},[m,p,E]),S=(0,qo.useCallback)(()=>{m&&p(!1)},[m,p]);return(0,Ie.jsxs)("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:S,children:[(0,Ie.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[(0,Ie.jsx)(kl,{value:h,onValueChange:b,className:"courier-h-full",ref:o,children:(0,Ie.jsx)(Ga,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${Cn.length}, fit-content(100%))`},children:f.map(P=>(0,Ie.jsxs)(Xi,{value:P.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:[P.label,P.value===h&&f.length>1&&(0,Ie.jsxs)(Wf,{children:[(0,Ie.jsx)(Uf,{asChild:!0,children:(0,Ie.jsx)("div",{className:"courier-pl-2",children:(0,Ie.jsx)(Xa,{color:"#A3A3A3"})})}),(0,Ie.jsxs)(yd,{ref:o,children:[(0,Ie.jsx)(vd,{children:(0,Ie.jsx)(B2.AlertDialogDescription,{children:"Are you sure you want to delete this channel?"})}),(0,Ie.jsxs)(Cd,{children:[(0,Ie.jsx)(Td,{asChild:!0,children:(0,Ie.jsx)(Ve,{buttonSize:"small",variant:"outline",children:"Cancel"})}),(0,Ie.jsx)(xd,{asChild:!0,children:(0,Ie.jsx)(Ve,{buttonSize:"small",variant:"primary",onClick:()=>C(P.value),children:"Delete"})})]})]})]})]},P.value))})}),v.length>0&&(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)(Ad,{orientation:"vertical",className:"!courier-h-5"}),(0,Ie.jsxs)(Cl,{children:[(0,Ie.jsx)(xl,{asChild:!0,children:(0,Ie.jsx)(Ve,{variant:"link",children:"+ Add channel"})}),(0,Ie.jsx)(Za,{portalProps:{container:o.current},children:v.map(P=>(0,Ie.jsxs)(qa,{onClick:()=>M(P.value),children:[P.icon,P.label]},P.value))})]})]})]}),(0,Ie.jsxs)("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&(0,Ie.jsx)(ra,{isLoading:!!i,isSaving:!!n,isError:!!s}),!e&&i!==null&&(0,Ie.jsx)(Ve,{variant:"primary",buttonSize:"small",disabled:c===!0||n===!0||u!==null,onClick:g,children:c?"Publishing...":"Publish changes"})]})]})},"Channels");var Gt=require("react");function Fa({onSave:e,debounceMs:t=2e3,enabled:r=!0,onError:o,initialContent:n,flushBeforeSave:i}){let[s,l]=(0,Gt.useState)(!1),c=(0,Gt.useRef)(!1),u=(0,Gt.useRef)(null),d=(0,Gt.useRef)(),p=(0,Gt.useRef)(0),m=(0,Gt.useRef)();(0,Gt.useEffect)(()=>{n&&(d.current=JSON.stringify(n))},[n]);let f=(0,Gt.useCallback)(async()=>{if(c.current)return;if(i)try{i()}catch(g){console.error("[AutoSave] Error flushing updates:",g)}let E=u.current;if(u.current=null,!!E)try{let g=JSON.stringify(E);if(g===d.current)return;c.current=!0,l(!0),d.current=g,p.current=Date.now(),await e(E)}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]),v=(0,Gt.useRef)(r),h=(0,Gt.useRef)(t),y=(0,Gt.useRef)(f);return(0,Gt.useEffect)(()=>{v.current=r,h.current=t,y.current=f}),{handleAutoSave:(0,Gt.useCallback)(async E=>{if(!v.current)return;let g=JSON.stringify(E);if(u.current=E,g===d.current||c.current)return;m.current&&(clearTimeout(m.current),m.current=void 0);let b=h.current;m.current=setTimeout(()=>{m.current=void 0,y.current()},b)},[]),isSaving:s}}a(Fa,"useAutoSave");var Ge=require("jotai"),Ne=require("react");var Jo=require("jotai"),Xt=require("react");var yr=require("zod"),D2=yr.z.object({headerStyle:yr.z.enum(["plain","border"]),isUnsubscribe:yr.z.boolean().optional(),isPreferences:yr.z.boolean().optional(),link:yr.z.string().optional(),brandColor:yr.z.string(),textColor:yr.z.string(),subtleColor:yr.z.string(),logo:yr.z.string().optional(),facebookLink:yr.z.string().optional(),linkedinLink:yr.z.string().optional(),instagramLink:yr.z.string().optional(),mediumLink:yr.z.string().optional(),xLink:yr.z.string().optional()}),vr={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};var LC=a(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),rl=a(e=>{var t,r,o,n,i,s,l,c,u,d,p,m,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 x=e.marks.map(LC).filter(Boolean);h=x.join("")+h+x.reverse().join("")}let y=(o=e.marks)==null?void 0:o.find(x=>x.type==="link");return y&&(h=`[${h}](${(n=y.attrs)==null?void 0:n.href})`),h}case"hardBreak":return`
215
+ `;case"paragraph":return(((i=e.content)==null?void 0:i.map(rl).join(""))||"")+`
216
216
 
217
- `;case"heading":{let h=((a=e.attrs)==null?void 0:a.level)||1,b="#".repeat(h)+" ",v=((l=e.content)==null?void 0:l.map(os).join(""))||"";return b+v+`
217
+ `;case"heading":{let h=((s=e.attrs)==null?void 0:s.level)||1,y="#".repeat(h)+" ",x=((l=e.content)==null?void 0:l.map(rl).join(""))||"";return y+x+`
218
218
 
219
- `}case"blockquote":return(((c=e.content)==null?void 0:c.map(os).join(""))||"").split(`
220
- `).map(b=>`> ${b}`).join(`
219
+ `}case"blockquote":return(((c=e.content)==null?void 0:c.map(rl).join(""))||"").split(`
220
+ `).map(y=>`> ${y}`).join(`
221
221
  `)+`
222
222
 
223
- `;case"imageBlock":{let h=((u=e.attrs)==null?void 0:u.alt)||"",b=((p=e.attrs)==null?void 0:p.sourcePath)||"",v=(m=e.attrs)==null?void 0:m.link,E=`![${h}](${b})`;return v?`[${E}](${v})
223
+ `;case"imageBlock":{let h=((u=e.attrs)==null?void 0:u.alt)||"",y=((d=e.attrs)==null?void 0:d.sourcePath)||"",x=(p=e.attrs)==null?void 0:p.link,E=`![${h}](${y})`;return x?`[${E}](${x})
224
224
 
225
225
  `:E+`
226
226
 
227
227
  `}case"divider":return`---
228
228
 
229
- `;case"button":{let h=((d=e.attrs)==null?void 0:d.label)||"",b=((f=e.attrs)==null?void 0:f.link)||"#";return`[${h}](${b})
229
+ `;case"button":{let h=((m=e.attrs)==null?void 0:m.label)||"",y=((f=e.attrs)==null?void 0:f.link)||"#";return`[${h}](${y})
230
230
 
231
- `}default:return((C=e.content)==null?void 0:C.map(os).join(""))||""}},"convertNodeToMarkdown");function Oc(e){return e.content?e.content.map(os).join("").trim():""}s(Oc,"convertTiptapToMarkdown");var Br=require("jotai"),Fo=require("react");var c2=require("react"),d2=require("react/jsx-runtime"),u2=(0,c2.forwardRef)(({children:e},t)=>(0,d2.jsx)("div",{ref:t,className:"courier-z-30 courier-flex courier-w-full courier-bg-primary courier-h-12 courier-border-b rounded-b-none rounded-t-sm courier-shadow-none courier-justify-between courier-items-center courier-px-4",children:e}));var Pr=require("react");var Wi=require("react/jsx-runtime"),r0=["image/png","image/jpeg","image/gif","image/webp"],m2=s(({onFileSelect:e})=>{let[t,r]=(0,Pr.useState)(!1),o=(0,Pr.useRef)(null),n=(0,Pr.useCallback)(d=>r0.includes(d),[]),i=(0,Pr.useCallback)(d=>{d.preventDefault(),d.stopPropagation(),d.dataTransfer.types.includes("Files")&&Array.from(d.dataTransfer.items).some(h=>n(h.type))&&(r(!0),d.dataTransfer.dropEffect="copy")},[n]),a=(0,Pr.useCallback)(d=>{d.preventDefault(),d.stopPropagation(),r(!1)},[]),l=(0,Pr.useCallback)(d=>{d.preventDefault(),d.stopPropagation(),d.dataTransfer.types.includes("Files")&&Array.from(d.dataTransfer.items).some(h=>n(h.type))&&r(!0)},[n]),c=(0,Pr.useCallback)(async d=>{try{let{dataUrl:f}=await gs(d,800);e==null||e(f),o.current&&(o.current.value="")}catch(f){console.error("Error processing image:",f),o.current&&(o.current.value="")}},[e]),u=(0,Pr.useCallback)(d=>{d.preventDefault(),d.stopPropagation(),r(!1);let C=Array.from(d.dataTransfer.files).find(h=>n(h.type));C&&c(C)},[c,n]),p=(0,Pr.useCallback)(d=>{var C;let f=(C=d.target.files)==null?void 0:C[0];f&&c(f)},[c]),m=(0,Pr.useCallback)(d=>{var f;d.preventDefault(),d.stopPropagation(),(f=o.current)==null||f.click()},[]);return(0,Wi.jsxs)("div",{className:I("courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-cursor-pointer courier-transition-colors courier-py-4 courier-px-6 courier-gap-1 !courier-w-fit",t&&"courier-border-primary courier-bg-gray-50"),onDragOver:i,onDragEnter:l,onDragLeave:a,onDrop:u,style:{pointerEvents:"all"},children:[(0,Wi.jsx)("span",{className:"courier-text-sm courier-pointer-events-none",children:"Drag and drop logo, or"}),(0,Wi.jsx)("button",{className:"courier-underline courier-font-medium courier-text-sm",onClick:m,type:"button",children:"Browse"}),(0,Wi.jsx)("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:p},"logo-input")]})},"LogoUploader");var f2=require("@hookform/resolvers/zod"),_i=require("jotai"),g2=require("lucide-react"),Vo=require("react"),h2=require("react-hook-form");var U=require("react/jsx-runtime"),p2=s(({isActive:e,onClick:t,value:r})=>(0,U.jsx)("div",{className:I("courier-w-full courier-h-16 courier-rounded-md courier-border-border courier-border courier-overflow-hidden courier-bg-secondary courier-cursor-pointer",e&&"!courier-border-[#3B82F6]"),onClick:t,children:(0,U.jsx)("div",{className:"courier-h-full courier-m-2 courier-rounded-md courier-border-border courier-border courier-shadow-md courier-bg-background courier-overflow-hidden",children:r==="border"&&(0,U.jsx)("div",{className:"courier-w-full courier-bg-[#000000] courier-h-1"})})}),"HeaderStyle"),o0=s(()=>{let[e,t]=(0,_i.useAtom)(po),r=(0,_i.useSetAtom)($r),o=(0,_i.useAtomValue)(Gn),n=(0,Vo.useRef)(null),i=(0,h2.useForm)({resolver:(0,f2.zodResolver)(l2),defaultValues:{...Yt,...e},mode:"onChange"});(0,Vo.useEffect)(()=>{e&&i.reset(e)},[e,i]);let a=(0,Vo.useCallback)(()=>{t(i.getValues())},[i,t]),l=(0,Vo.useCallback)(c=>{var u;if(o){if(c){let m={type:"doc",content:[...o.getJSON().content||[],{type:"paragraph",content:[{type:"text",text:"Manage Notification Preferences",marks:[{type:"link",attrs:{href:"{{urls.preferences}}"}}]}]}]};o.chain().focus().setContent(m).run()}else{let m=((u=o.getJSON().content)==null?void 0:u.filter(d=>{var C;return d.type!=="paragraph"?!0:!((C=d.content)==null?void 0:C.some(h=>{var b;return h.type==="text"&&((b=h.marks)==null?void 0:b.some(v=>{var E;return v.type==="link"&&((E=v.attrs)==null?void 0:E.href)==="{{urls.preferences}}"}))}))}))||[];o.chain().focus().setContent({type:"doc",content:m}).run()}r(Oc(o.getJSON()))}},[o,r]);return(0,U.jsx)(qe,{...i,children:(0,U.jsx)("form",{onChange:()=>a(),children:(0,U.jsxs)("div",{className:"courier-pb-6",children:[(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Header style"}),(0,U.jsx)(j,{control:i.control,name:"headerStyle",render:({field:c})=>(0,U.jsxs)(q,{className:"courier-mb-4",children:[(0,U.jsx)(J,{children:(0,U.jsxs)("div",{className:"courier-w-full courier-flex courier-flex-row courier-gap-3",children:[(0,U.jsx)(p2,{isActive:c.value==="plain",onClick:()=>{c.onChange("plain"),t({...i.getValues(),headerStyle:"plain"})},value:"plain"}),(0,U.jsx)(p2,{isActive:c.value==="border",onClick:()=>{c.onChange("border"),t({...i.getValues(),headerStyle:"border"})},value:"border"})]})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(ce,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Logo"}),(0,U.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[i.getValues().logo?(0,U.jsx)(Se,{onClick:()=>{let c=i.getValues();c.logo="",i.reset(c),t({...c}),n.current&&(n.current.value=""),a()},className:"courier-w-full",variant:"outline",type:"button",children:"Remove logo"}):(0,U.jsxs)(Se,{onClick:c=>{c.preventDefault(),n.current&&(n.current.value="",n.current.click())},className:"courier-w-full",variant:"outline",type:"button",children:[(0,U.jsx)(g2.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-mr-2 courier-text-foreground"}),"Upload logo"]}),(0,U.jsx)("input",{ref:n,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:async c=>{var p;let u=(p=c.target.files)==null?void 0:p[0];if(u)try{let{dataUrl:m}=await gs(u,800),d=i.getValues();d.logo=m,i.reset(d),t({...d})}catch(m){console.error("Error processing image:",m)}n.current&&(n.current.value="")}})]}),(0,U.jsx)(j,{control:i.control,name:"link",render:({field:c})=>(0,U.jsxs)(q,{className:"courier-mb-3",children:[(0,U.jsx)(J,{children:(0,U.jsx)(an,{as:"Textarea",placeholder:"Link",...c,onChange:u=>{c.onChange(u),a()}})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(ce,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Brand color"}),(0,U.jsx)(j,{control:i.control,name:"brandColor",render:({field:c})=>(0,U.jsxs)(q,{className:"courier-mb-4",children:[(0,U.jsx)(J,{children:(0,U.jsx)(Et,{...c,defaultValue:c.value,onChange:u=>{c.onChange(u),a()}})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(ce,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer links"}),(0,U.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-3 courier-mb-3",children:[(0,U.jsx)(j,{control:i.control,name:"facebookLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(la,{}),placeholder:"facebook.com/username",...c,autoFocus:!0})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(j,{control:i.control,name:"linkedinLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(da,{}),placeholder:"linkedin.com/username",...c})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(j,{control:i.control,name:"instagramLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(ua,{}),placeholder:"instagram.com/username",...c})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(j,{control:i.control,name:"mediumLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(ma,{}),placeholder:"medium.com/username",...c})}),(0,U.jsx)(K,{})]})}),(0,U.jsx)(j,{control:i.control,name:"xLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(ba,{}),placeholder:"x.com/username",...c})}),(0,U.jsx)(K,{})]})})]}),(0,U.jsx)(ce,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer actions"}),(0,U.jsx)(j,{control:i.control,name:"isPreferences",render:({field:c})=>(0,U.jsxs)(q,{className:"courier-flex courier-flex-row courier-items-center courier-gap-2 courier-mb-4",children:[(0,U.jsx)(J,{children:(0,U.jsx)(ii,{checked:c.value,onCheckedChange:u=>{i.setValue("isPreferences",u),c.onChange(u),l(u);let p={...i.getValues(),isPreferences:u};t(p)}})}),(0,U.jsx)(uo,{className:"!courier-m-0",children:"Manage Preferences"}),(0,U.jsx)(K,{})]})})]})})})},"SideBarComponent"),b2=(0,Vo.memo)(o0);var De=require("react/jsx-runtime"),n0=(0,Fo.forwardRef)(({hidePublish:e=!1,templateEditor:t,variables:r},o)=>{var w,N,y,S,P,T,x,k;let n=(0,Br.useSetAtom)(mi),{publishBrand:i}=Yn(),a=(0,Br.useAtomValue)(it),l=(0,Br.useAtomValue)(_t),c=(0,Br.useAtomValue)(at),u=(0,Br.useAtomValue)(se),p=(0,Br.useAtomValue)(G),m=(0,Br.useAtomValue)(Gn),[d,f]=(0,Br.useAtom)(po),[C,h]=(0,Br.useAtom)($r),b=(0,Fo.useCallback)(()=>{i()},[i]),v=(0,Fo.useCallback)(({editor:M})=>{h(Oc(M.getJSON()))},[h]),E=(0,Fo.useCallback)(M=>{f(A=>A?{...A,logo:M}:{...Yt,logo:M})},[f]),g=(0,Fo.useCallback)(()=>{n("template")},[n]);return(0,De.jsxs)(De.Fragment,{children:[(0,De.jsx)("div",{className:"courier-z-30 courier-w-full courier-h-12",children:(0,De.jsxs)(u2,{children:[(0,De.jsx)("div",{className:"courier-text-sm courier-font-medium",children:"Brand theme"}),(0,De.jsxs)("div",{className:"courier-flex courier-gap-2 courier-items-center",children:[c!==null&&(0,De.jsx)(di,{isLoading:!!u,isSaving:!!c,isError:!!p}),t&&(0,De.jsx)(Se,{variant:"outline",buttonSize:"small",onClick:g,disabled:l===!0||c===!0,children:"Back"}),!e&&u!==null&&(0,De.jsx)(Se,{variant:"primary",buttonSize:"small",disabled:!((N=(w=a==null?void 0:a.data)==null?void 0:w.tenant)!=null&&N.brand)||l===!0||c!==!1,onClick:b,children:l?"Publishing...":"Publish changes"})]})]})}),(0,De.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,De.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,De.jsxs)("div",{className:"courier-editor-container",ref:o,children:[(0,De.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Header"}),(0,De.jsxs)("div",{className:I("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-py-5 courier-px-9 courier-mb-8 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(d==null?void 0:d.headerStyle)==="border"&&"courier-pt-6"),children:[(d==null?void 0:d.headerStyle)==="border"&&(0,De.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:d.brandColor}}),d!=null&&d.logo?(0,De.jsx)("img",{src:d.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"}):(0,De.jsx)(m2,{onFileSelect:E})]}),(0,De.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Footer"}),(0,De.jsx)("div",{className:"courier-theme-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-pt-3 courier-pb-5 courier-px-9",children:(0,De.jsx)(Bi,{value:C!=null?C:(k=(x=(T=(P=(S=(y=a==null?void 0:a.data)==null?void 0:y.tenant)==null?void 0:S.brand)==null?void 0:P.settings)==null?void 0:T.email)==null?void 0:x.footer)==null?void 0:k.markdown,variables:r,facebookLink:d==null?void 0:d.facebookLink,linkedinLink:d==null?void 0:d.linkedinLink,instagramLink:d==null?void 0:d.instagramLink,mediumLink:d==null?void 0:d.mediumLink,xLink:d==null?void 0:d.xLink,onUpdate:v})})]})}),(0,De.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,De.jsx)("div",{className:"courier-p-4 courier-h-full",children:m&&(0,De.jsx)(b2,{})})})]})]})}),y2=(0,Fo.memo)(n0);var hm=require("react/jsx-runtime"),i0=(0,Lt.forwardRef)(({hidePublish:e=!1,autoSaveDebounce:t=500,autoSave:r=!0,theme:o,colorScheme:n,...i},a)=>{let l=(0,xo.useAtomValue)(se),c=(0,Lt.useRef)(!0),u=(0,xo.useAtomValue)(pt),{getTemplate:p,saveBrand:m}=Yn(),[d,f]=(0,xo.useAtom)(it),C=(0,xo.useSetAtom)($r),h=(0,xo.useAtomValue)($r),[b,v]=(0,xo.useAtom)(po),E=(0,Lt.useRef)(!1),g=(0,xo.useSetAtom)(G);(0,Lt.useEffect)(()=>{var S,P;d&&u!==((P=(S=d==null?void 0:d.data)==null?void 0:S.tenant)==null?void 0:P.tenantId)&&(f(null),C(null),c.current=!1)},[d,u,f,C]);let w=(0,Lt.useCallback)(async S=>{await m(S)},[m]),N=(0,Lt.useCallback)(()=>{g(so("Error saving theme"))},[g]),{handleAutoSave:y}=Ui({onSave:w,enabled:l!==null&&r&&h!==null,debounceMs:t,onError:N});return(0,Lt.useEffect)(()=>{!u||l||d&&l===!1||p()},[u,p,l,d]),(0,Lt.useEffect)(()=>{h&&setTimeout(()=>{E.current=!0},500)},[h]),(0,Lt.useEffect)(()=>{if(!E.current||!b)return;let S={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}}}}};y(S)},[b,h,y]),(0,Lt.useEffect)(()=>{l||(c.current=!1)},[l]),(0,Lt.useEffect)(()=>{var S,P,T,x,k,M,A,R,B,F,L,D,V,O,$,_,z,Q,re,ne,H,X,ke,Le,nt,vt,fr,gr,le,Ve,Ae,Ut,Wt,Dr,Hr,Vr,Fr,Oo;if(!b){let ie=(T=(P=(S=d==null?void 0:d.data)==null?void 0:S.tenant)==null?void 0:P.brand)==null?void 0:T.settings,To=(A=h==null?void 0:h.split(`
232
- `))!=null?A:(M=(k=(x=ie==null?void 0:ie.email)==null?void 0:x.footer)==null?void 0:k.markdown)==null?void 0:M.split(`
233
- `),pn=To==null?void 0:To.find(fn=>fn.includes("{{urls.preferences}}"));v({brandColor:((R=ie==null?void 0:ie.colors)==null?void 0:R.primary)||Yt.brandColor,textColor:((B=ie==null?void 0:ie.colors)==null?void 0:B.secondary)||Yt.textColor,subtleColor:((F=ie==null?void 0:ie.colors)==null?void 0:F.tertiary)||Yt.subtleColor,headerStyle:(D=(L=ie==null?void 0:ie.email)==null?void 0:L.header)!=null&&D.barColor?"border":"plain",logo:(($=(O=(V=ie==null?void 0:ie.email)==null?void 0:V.header)==null?void 0:O.logo)==null?void 0:$.image)||Yt.logo,link:((Q=(z=(_=ie==null?void 0:ie.email)==null?void 0:_.header)==null?void 0:z.logo)==null?void 0:Q.href)||Yt.link,facebookLink:((X=(H=(ne=(re=ie==null?void 0:ie.email)==null?void 0:re.footer)==null?void 0:ne.social)==null?void 0:H.facebook)==null?void 0:X.url)||Yt.facebookLink,linkedinLink:((vt=(nt=(Le=(ke=ie==null?void 0:ie.email)==null?void 0:ke.footer)==null?void 0:Le.social)==null?void 0:nt.linkedin)==null?void 0:vt.url)||Yt.linkedinLink,instagramLink:((Ve=(le=(gr=(fr=ie==null?void 0:ie.email)==null?void 0:fr.footer)==null?void 0:gr.social)==null?void 0:le.instagram)==null?void 0:Ve.url)||Yt.instagramLink,mediumLink:((Dr=(Wt=(Ut=(Ae=ie==null?void 0:ie.email)==null?void 0:Ae.footer)==null?void 0:Ut.social)==null?void 0:Wt.medium)==null?void 0:Dr.url)||Yt.mediumLink,xLink:((Oo=(Fr=(Vr=(Hr=ie==null?void 0:ie.email)==null?void 0:Hr.footer)==null?void 0:Vr.social)==null?void 0:Fr.twitter)==null?void 0:Oo.url)||Yt.xLink,isPreferences:!!pn})}},[d,v,h,b]),(0,hm.jsx)(rr,{theme:o,colorScheme:n,isLoading:!!(l&&c.current),children:(0,hm.jsx)(y2,{ref:a,hidePublish:e,...i})})}),bm=(0,Lt.memo)(i0);var mn=require("react/jsx-runtime"),C2=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"),a0=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:p=is,colorScheme:m,...d})=>{let{store:f}=Jn(),C=(0,Ye.useSetAtom)(Gi),h=(0,Ye.useAtomValue)(se),b=(0,Ye.useAtomValue)(_t),v=(0,Ye.useAtomValue)(G),[E,g]=(0,Ye.useAtom)(it),w=(0,Ye.useAtomValue)(Mr),N=(0,Ye.useAtomValue)(pt),[y,S]=(0,Ye.useAtom)(gn),{getTemplate:P,saveTemplate:T,setTemplateError:x}=Xn(),k=(0,Ye.useAtomValue)(mi),M=(0,Re.useRef)(!1),[A,R]=(0,Ye.useAtom)(te),[B,F]=(0,Ye.useAtom)(xt);(0,Re.useEffect)(()=>{typeof window!="undefined"&&window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.templateEditorContent=A)},[A]);let L=(0,Ye.useSetAtom)($r),D=(0,Ye.useSetAtom)(po),[V,O]=(0,Ye.useAtom)(Zo),$=(0,Ye.useSetAtom)(se),_=C2(p,u),[z,Q]=(0,Re.useState)(_),re=(0,Re.useRef)(JSON.stringify(_));(0,Re.useEffect)(()=>{let le=C2(p,u),Ve=JSON.stringify(le);Ve!==re.current&&(Q(le),re.current=Ve,le.length&&!le.includes(V)&&O(le[0]))},[p,u,V,O]),(0,Re.useEffect)(()=>{var Ve;if(h||!(A!=null&&A.elements))return;let le=A.elements.filter(Ae=>Ae.type==="channel").map(Ae=>Ae.channel);if(!le.includes(V)){let Ae=(Ve=p==null?void 0:p.channels)==null?void 0:Ve.find(Ut=>le.includes(Ut));!Ae&&le.length>0&&(Ae=le[0]),Ae&&O(Ae)}},[A,V,O,p==null?void 0:p.channels,h]),(0,Re.useEffect)(()=>{var Ve;let le=(Ve=E==null?void 0:E.data)==null?void 0:Ve.tenant;w&&le&&!(le!=null&&le.notification)&&h===!1&&(z!=null&&z.length)&&O(z[0])},[w,E,h,z,O]);let ne=(0,Re.useRef)(null);(0,Re.useEffect)(()=>{ne.current&&(ne.current.templateId!==w||ne.current.tenantId!==N)&&w&&N&&(F(!0),M.current=!1,g(null),R(null),L(null),D(null),S(null),O((z==null?void 0:z[0])||"email"),$(null)),w&&N&&(ne.current={templateId:w,tenantId:N})},[w,N,z,F,g,R,L,D,S,O,$]);let H=(0,Re.useRef)(p);(0,Re.useEffect)(()=>{H.current=p,C(p)},[p,C]);let X=(0,Re.useCallback)(async le=>{let Ve=le==null?void 0:le._capturedTemplateId,Ae=f.get(Mr);if(Ve&&Ve!==Ae)return;let{_capturedTemplateId:Ut,...Wt}=le;await T({routing:H.current,content:Wt})},[T,f]),ke=(0,Re.useCallback)(()=>{x("Error saving template")},[x]),Le=(0,Ye.useAtomValue)(bn),nt=(0,Re.useCallback)(()=>{Mm(Le)},[Le]),{handleAutoSave:vt}=Ui({onSave:X,debounceMs:a,enabled:h===!1&&i,onError:ke,flushBeforeSave:nt});(0,Re.useEffect)(()=>{!w||!N||h||E&&h===!1||v||P({includeBrand:l})},[w,N,l,P,h,E,v]),(0,Re.useEffect)(()=>{if(!(!t||i&&h!==!1)&&JSON.stringify(de(Ze(A)))!==JSON.stringify(de(Ze(t))))if(R(t),!i)$(!1);else{let le={...t,_capturedTemplateId:w};vt(le)}},[i,t,A,R,$,vt,w,h]),(0,Re.useEffect)(()=>{var Ae,Ut,Wt,Dr,Hr,Vr,Fr;if(h!==!1)return;let le=(Wt=(Ut=(Ae=E==null?void 0:E.data)==null?void 0:Ae.tenant)==null?void 0:Ut.notification)==null?void 0:Wt.notificationId;if(E&&le&&le!==w)return;let Ve=t||((Fr=(Vr=(Hr=(Dr=E==null?void 0:E.data)==null?void 0:Dr.tenant)==null?void 0:Hr.notification)==null?void 0:Vr.data)==null?void 0:Fr.content);R(Ve),setTimeout(()=>{F(!1)},100)},[E,R,h,F,w,t]),(0,Re.useEffect)(()=>{b===!0&&(M.current=!1)},[b]),(0,Re.useEffect)(()=>{!A||h!==!1||setTimeout(()=>{M.current=!0},1e3)},[A,V,h]),(0,Re.useEffect)(()=>{M.current=!1},[V]);let fr=(0,Ye.useAtomValue)(Je),gr=(0,Ye.useAtomValue)(Nm);if((0,Re.useEffect)(()=>{let le=!!fr&&h===!1&&!B,Ve=M.current&&!!A&&h===!1&&!B;if(!le&&!Ve)return;let Ae=fr||A;if(!Ae||JSON.stringify(Ae)===gr)return;let Wt={...Ae,_capturedTemplateId:w};r&&(M.current=!1,r(A||Ae)),vt(Wt)},[A,fr,vt,h,B,w,r,gr]),l&&k==="brand")return(0,mn.jsx)(bm,{hidePublish:n,autoSave:i,templateEditor:!0,variables:o,theme:e,colorScheme:m,...c});if(k==="template"&&V==="email")return(0,mn.jsx)(d5,{variables:o,theme:e,colorScheme:m,isLoading:!!h,hidePublish:n,channels:z,brandEditor:l,routing:p,...d});if(k==="template"&&V==="sms")return(0,mn.jsx)(K5,{colorScheme:m,variables:o,theme:e,hidePublish:n,channels:z,routing:p,...d});if(k==="template"&&V==="push")return(0,mn.jsx)(M5,{variables:o,theme:e,colorScheme:m,hidePublish:n,channels:z,routing:p,...d});if(k==="template"&&V==="inbox")return(0,mn.jsx)(x5,{variables:o,theme:e,colorScheme:m,hidePublish:n,channels:z,routing:p,...d});if(k==="template"&&V==="slack")return(0,mn.jsx)(W5,{theme:e,colorScheme:m,hidePublish:n,channels:z,routing:p,variables:o,...d});if(k==="template"&&V==="msteams")return(0,mn.jsx)(n2,{theme:e,colorScheme:m,hidePublish:n,channels:z,routing:p,variables:o,...d})},"TemplateEditorComponent"),s0=(0,Re.memo)(a0);var l0=lc,c0=Sc,u0=xc,d0=bc,m0=Bc,p0=wc;
231
+ `}default:return((v=e.content)==null?void 0:v.map(rl).join(""))||""}},"convertNodeToMarkdown");function Yu(e){return e.content?e.content.map(rl).join("").trim():""}a(Yu,"convertTiptapToMarkdown");var qr=require("jotai"),Io=require("react");var H2=require("react"),F2=require("react/jsx-runtime"),V2=(0,H2.forwardRef)(({children:e},t)=>(0,F2.jsx)("div",{ref:t,className:"courier-z-30 courier-flex courier-w-full courier-bg-primary courier-h-12 courier-border-b rounded-b-none rounded-t-sm courier-shadow-none courier-justify-between courier-items-center courier-px-4",children:e}));var Zr=require("react");var Oa=require("react/jsx-runtime"),BC=["image/png","image/jpeg","image/gif","image/webp"],O2=a(({onFileSelect:e})=>{let[t,r]=(0,Zr.useState)(!1),o=(0,Zr.useRef)(null),n=(0,Zr.useCallback)(m=>BC.includes(m),[]),i=(0,Zr.useCallback)(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]),s=(0,Zr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),r(!1)},[]),l=(0,Zr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(h=>n(h.type))&&r(!0)},[n]),c=(0,Zr.useCallback)(async m=>{try{let{dataUrl:f}=await bl(m,800);e==null||e(f),o.current&&(o.current.value="")}catch(f){console.error("Error processing image:",f),o.current&&(o.current.value="")}},[e]),u=(0,Zr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),r(!1);let v=Array.from(m.dataTransfer.files).find(h=>n(h.type));v&&c(v)},[c,n]),d=(0,Zr.useCallback)(m=>{var v;let f=(v=m.target.files)==null?void 0:v[0];f&&c(f)},[c]),p=(0,Zr.useCallback)(m=>{var f;m.preventDefault(),m.stopPropagation(),(f=o.current)==null||f.click()},[]);return(0,Oa.jsxs)("div",{className:I("courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-cursor-pointer courier-transition-colors courier-py-4 courier-px-6 courier-gap-1 !courier-w-fit",t&&"courier-border-primary courier-bg-gray-50"),onDragOver:i,onDragEnter:l,onDragLeave:s,onDrop:u,style:{pointerEvents:"all"},children:[(0,Oa.jsx)("span",{className:"courier-text-sm courier-pointer-events-none",children:"Drag and drop logo, or"}),(0,Oa.jsx)("button",{className:"courier-underline courier-font-medium courier-text-sm",onClick:p,type:"button",children:"Browse"}),(0,Oa.jsx)("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:d},"logo-input")]})},"LogoUploader");var U2=require("@hookform/resolvers/zod"),Wa=require("jotai"),_2=require("lucide-react"),gn=require("react"),z2=require("react-hook-form");var Z=require("react/jsx-runtime"),W2=a(({isActive:e,onClick:t,value:r})=>(0,Z.jsx)("div",{className:I("courier-w-full courier-h-16 courier-rounded-md courier-border-border courier-border courier-overflow-hidden courier-bg-secondary courier-cursor-pointer",e&&"!courier-border-[#3B82F6]"),onClick:t,children:(0,Z.jsx)("div",{className:"courier-h-full courier-m-2 courier-rounded-md courier-border-border courier-border courier-shadow-md courier-bg-background courier-overflow-hidden",children:r==="border"&&(0,Z.jsx)("div",{className:"courier-w-full courier-bg-[#000000] courier-h-1"})})}),"HeaderStyle"),DC=a(()=>{let[e,t]=(0,Wa.useAtom)(Oo),r=(0,Wa.useSetAtom)(lo),o=(0,Wa.useAtomValue)(Wi),n=(0,gn.useRef)(null),i=(0,z2.useForm)({resolver:(0,U2.zodResolver)(D2),defaultValues:{...vr,...e},mode:"onChange"});(0,gn.useEffect)(()=>{e&&i.reset(e)},[e,i]);let s=(0,gn.useCallback)(()=>{t(i.getValues())},[i,t]),l=(0,gn.useCallback)(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 v;return m.type!=="paragraph"?!0:!((v=m.content)==null?void 0:v.some(h=>{var y;return h.type==="text"&&((y=h.marks)==null?void 0:y.some(x=>{var E;return x.type==="link"&&((E=x.attrs)==null?void 0:E.href)==="{{urls.preferences}}"}))}))}))||[];o.chain().focus().setContent({type:"doc",content:p}).run()}r(Yu(o.getJSON()))}},[o,r]);return(0,Z.jsx)(rt,{...i,children:(0,Z.jsx)("form",{onChange:()=>s(),children:(0,Z.jsxs)("div",{className:"courier-pb-6",children:[(0,Z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Header style"}),(0,Z.jsx)(oe,{control:i.control,name:"headerStyle",render:({field:c})=>(0,Z.jsxs)(te,{className:"courier-mb-4",children:[(0,Z.jsx)(re,{children:(0,Z.jsxs)("div",{className:"courier-w-full courier-flex courier-flex-row courier-gap-3",children:[(0,Z.jsx)(W2,{isActive:c.value==="plain",onClick:()=>{c.onChange("plain"),t({...i.getValues(),headerStyle:"plain"})},value:"plain"}),(0,Z.jsx)(W2,{isActive:c.value==="border",onClick:()=>{c.onChange("border"),t({...i.getValues(),headerStyle:"border"})},value:"border"})]})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(ge,{className:"courier-mb-4"}),(0,Z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Logo"}),(0,Z.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[i.getValues().logo?(0,Z.jsx)(Ve,{onClick:()=>{let c=i.getValues();c.logo="",i.reset(c),t({...c}),n.current&&(n.current.value=""),s()},className:"courier-w-full",variant:"outline",type:"button",children:"Remove logo"}):(0,Z.jsxs)(Ve,{onClick:c=>{c.preventDefault(),n.current&&(n.current.value="",n.current.click())},className:"courier-w-full",variant:"outline",type:"button",children:[(0,Z.jsx)(_2.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-mr-2 courier-text-foreground"}),"Upload logo"]}),(0,Z.jsx)("input",{ref:n,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:async c=>{var d;let u=(d=c.target.files)==null?void 0:d[0];if(u)try{let{dataUrl:p}=await bl(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="")}})]}),(0,Z.jsx)(oe,{control:i.control,name:"link",render:({field:c})=>(0,Z.jsxs)(te,{className:"courier-mb-3",children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(Fn,{as:"Textarea",placeholder:"Link",...c,onChange:u=>{c.onChange(u),s()}})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(ge,{className:"courier-mb-4"}),(0,Z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Brand color"}),(0,Z.jsx)(oe,{control:i.control,name:"brandColor",render:({field:c})=>(0,Z.jsxs)(te,{className:"courier-mb-4",children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(Wt,{...c,defaultValue:c.value,onChange:u=>{c.onChange(u),s()}})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(ge,{className:"courier-mb-4"}),(0,Z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer links"}),(0,Z.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-3 courier-mb-3",children:[(0,Z.jsx)(oe,{control:i.control,name:"facebookLink",render:({field:c})=>(0,Z.jsxs)(te,{children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(Ee,{startAdornment:(0,Z.jsx)(es,{}),placeholder:"facebook.com/username",...c,autoFocus:!0})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(oe,{control:i.control,name:"linkedinLink",render:({field:c})=>(0,Z.jsxs)(te,{children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(Ee,{startAdornment:(0,Z.jsx)(os,{}),placeholder:"linkedin.com/username",...c})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(oe,{control:i.control,name:"instagramLink",render:({field:c})=>(0,Z.jsxs)(te,{children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(Ee,{startAdornment:(0,Z.jsx)(rs,{}),placeholder:"instagram.com/username",...c})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(oe,{control:i.control,name:"mediumLink",render:({field:c})=>(0,Z.jsxs)(te,{children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(Ee,{startAdornment:(0,Z.jsx)(ns,{}),placeholder:"medium.com/username",...c})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(oe,{control:i.control,name:"xLink",render:({field:c})=>(0,Z.jsxs)(te,{children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(Ee,{startAdornment:(0,Z.jsx)(cs,{}),placeholder:"x.com/username",...c})}),(0,Z.jsx)(ne,{})]})})]}),(0,Z.jsx)(ge,{className:"courier-mb-4"}),(0,Z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer actions"}),(0,Z.jsx)(oe,{control:i.control,name:"isPreferences",render:({field:c})=>(0,Z.jsxs)(te,{className:"courier-flex courier-flex-row courier-items-center courier-gap-2 courier-mb-4",children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(Gi,{checked:c.value,onCheckedChange:u=>{i.setValue("isPreferences",u),c.onChange(u),l(u);let d={...i.getValues(),isPreferences:u};t(d)}})}),(0,Z.jsx)(Vo,{className:"!courier-m-0",children:"Manage Preferences"}),(0,Z.jsx)(ne,{})]})})]})})})},"SideBarComponent"),$2=(0,gn.memo)(DC);var Oe=require("react/jsx-runtime"),HC=(0,Io.forwardRef)(({hidePublish:e=!1,templateEditor:t,variables:r,variableValidation:o},n)=>{var C,S,P,k,w,T,A,N;let i=(0,qr.useSetAtom)(oa),{publishBrand:s}=_i(),l=(0,qr.useSetAtom)(Ui);(0,Io.useEffect)(()=>{l(o)},[o,l]);let c=(0,qr.useAtomValue)(bt),u=(0,qr.useAtomValue)(cr),d=(0,qr.useAtomValue)(yt),p=(0,qr.useAtomValue)(pe),m=(0,qr.useAtomValue)(ae),f=(0,qr.useAtomValue)(Wi),[v,h]=(0,qr.useAtom)(Oo),[y,x]=(0,qr.useAtom)(lo),E=(0,Io.useCallback)(()=>{s()},[s]),g=(0,Io.useCallback)(({editor:R})=>{x(Yu(R.getJSON()))},[x]),b=(0,Io.useCallback)(R=>{h(B=>B?{...B,logo:R}:{...vr,logo:R})},[h]),M=(0,Io.useCallback)(()=>{i("template")},[i]);return(0,Oe.jsxs)(Oe.Fragment,{children:[(0,Oe.jsx)("div",{className:"courier-z-30 courier-w-full courier-h-12",children:(0,Oe.jsxs)(V2,{children:[(0,Oe.jsx)("div",{className:"courier-text-sm courier-font-medium",children:"Brand theme"}),(0,Oe.jsxs)("div",{className:"courier-flex courier-gap-2 courier-items-center",children:[d!==null&&(0,Oe.jsx)(ra,{isLoading:!!p,isSaving:!!d,isError:!!m}),t&&(0,Oe.jsx)(Ve,{variant:"outline",buttonSize:"small",onClick:M,disabled:u===!0||d===!0,children:"Back"}),!e&&p!==null&&(0,Oe.jsx)(Ve,{variant:"primary",buttonSize:"small",disabled:!((S=(C=c==null?void 0:c.data)==null?void 0:C.tenant)!=null&&S.brand)||u===!0||d!==!1,onClick:E,children:u?"Publishing...":"Publish changes"})]})]})}),(0,Oe.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,Oe.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Oe.jsxs)("div",{className:"courier-editor-container",ref:n,children:[(0,Oe.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Header"}),(0,Oe.jsxs)("div",{className:I("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-py-5 courier-px-9 courier-mb-8 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(v==null?void 0:v.headerStyle)==="border"&&"courier-pt-6"),children:[(v==null?void 0:v.headerStyle)==="border"&&(0,Oe.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:v.brandColor}}),v!=null&&v.logo?(0,Oe.jsx)("img",{src:v.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"}):(0,Oe.jsx)(O2,{onFileSelect:b})]}),(0,Oe.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Footer"}),(0,Oe.jsx)("div",{className:"courier-theme-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-pt-3 courier-pb-5 courier-px-9",children:(0,Oe.jsx)(Ra,{value:y!=null?y:(N=(A=(T=(w=(k=(P=c==null?void 0:c.data)==null?void 0:P.tenant)==null?void 0:k.brand)==null?void 0:w.settings)==null?void 0:T.email)==null?void 0:A.footer)==null?void 0:N.markdown,variables:r,facebookLink:v==null?void 0:v.facebookLink,linkedinLink:v==null?void 0:v.linkedinLink,instagramLink:v==null?void 0:v.instagramLink,mediumLink:v==null?void 0:v.mediumLink,xLink:v==null?void 0:v.xLink,onUpdate:g})})]})}),(0,Oe.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,Oe.jsx)("div",{className:"courier-p-4 courier-h-full",children:f&&(0,Oe.jsx)($2,{})})})]})]})}),j2=(0,Io.memo)(HC);var ef=require("react/jsx-runtime"),VC=(0,Xt.forwardRef)(({hidePublish:e=!1,autoSaveDebounce:t=500,autoSave:r=!0,theme:o,colorScheme:n,...i},s)=>{let l=(0,Jo.useAtomValue)(pe),c=(0,Xt.useRef)(!0),u=(0,Jo.useAtomValue)(Mt),{getTemplate:d,saveBrand:p}=_i(),[m,f]=(0,Jo.useAtom)(bt),v=(0,Jo.useSetAtom)(lo),h=(0,Jo.useAtomValue)(lo),[y,x]=(0,Jo.useAtom)(Oo),E=(0,Xt.useRef)(!1),g=(0,Jo.useSetAtom)(ae);(0,Xt.useEffect)(()=>{var S,P;m&&u!==((P=(S=m==null?void 0:m.data)==null?void 0:S.tenant)==null?void 0:P.tenantId)&&(f(null),v(null),c.current=!1)},[m,u,f,v]);let b=(0,Xt.useCallback)(async S=>{await p(S)},[p]),M=(0,Xt.useCallback)(()=>{g(Bo("Error saving theme"))},[g]),{handleAutoSave:C}=Fa({onSave:b,enabled:l!==null&&r&&h!==null,debounceMs:t,onError:M});return(0,Xt.useEffect)(()=>{!u||l||m&&l===!1||d()},[u,d,l,m]),(0,Xt.useEffect)(()=>{h&&setTimeout(()=>{E.current=!0},500)},[h]),(0,Xt.useEffect)(()=>{if(!E.current||!y)return;let S={colors:{primary:y==null?void 0:y.brandColor,secondary:y==null?void 0:y.textColor,tertiary:y==null?void 0:y.subtleColor},email:{header:{barColor:(y==null?void 0:y.headerStyle)==="border"?y==null?void 0:y.brandColor:"",logo:{href:y==null?void 0:y.link,image:y==null?void 0:y.logo}},footer:{markdown:h!=null?h:void 0,social:{facebook:{url:y==null?void 0:y.facebookLink},instagram:{url:y==null?void 0:y.instagramLink},linkedin:{url:y==null?void 0:y.linkedinLink},medium:{url:y==null?void 0:y.mediumLink},twitter:{url:y==null?void 0:y.xLink}}}}};C(S)},[y,h,C]),(0,Xt.useEffect)(()=>{l||(c.current=!1)},[l]),(0,Xt.useEffect)(()=>{var S,P,k,w,T,A,N,R,B,H,D,F,L,W,_,V,j,J,G,X,U,K,de,me,Me,We,Pt,Ht,ar,Vt,Yt,At,Qt,et,ut,ce,Te,ke;if(!y){let ie=(k=(P=(S=m==null?void 0:m.data)==null?void 0:S.tenant)==null?void 0:P.brand)==null?void 0:k.settings,nt=(N=h==null?void 0:h.split(`
232
+ `))!=null?N:(A=(T=(w=ie==null?void 0:ie.email)==null?void 0:w.footer)==null?void 0:T.markdown)==null?void 0:A.split(`
233
+ `),sr=nt==null?void 0:nt.find(lr=>lr.includes("{{urls.preferences}}"));x({brandColor:((R=ie==null?void 0:ie.colors)==null?void 0:R.primary)||vr.brandColor,textColor:((B=ie==null?void 0:ie.colors)==null?void 0:B.secondary)||vr.textColor,subtleColor:((H=ie==null?void 0:ie.colors)==null?void 0:H.tertiary)||vr.subtleColor,headerStyle:(F=(D=ie==null?void 0:ie.email)==null?void 0:D.header)!=null&&F.barColor?"border":"plain",logo:((_=(W=(L=ie==null?void 0:ie.email)==null?void 0:L.header)==null?void 0:W.logo)==null?void 0:_.image)||vr.logo,link:((J=(j=(V=ie==null?void 0:ie.email)==null?void 0:V.header)==null?void 0:j.logo)==null?void 0:J.href)||vr.link,facebookLink:((K=(U=(X=(G=ie==null?void 0:ie.email)==null?void 0:G.footer)==null?void 0:X.social)==null?void 0:U.facebook)==null?void 0:K.url)||vr.facebookLink,linkedinLink:((We=(Me=(me=(de=ie==null?void 0:ie.email)==null?void 0:de.footer)==null?void 0:me.social)==null?void 0:Me.linkedin)==null?void 0:We.url)||vr.linkedinLink,instagramLink:((Vt=(ar=(Ht=(Pt=ie==null?void 0:ie.email)==null?void 0:Pt.footer)==null?void 0:Ht.social)==null?void 0:ar.instagram)==null?void 0:Vt.url)||vr.instagramLink,mediumLink:((et=(Qt=(At=(Yt=ie==null?void 0:ie.email)==null?void 0:Yt.footer)==null?void 0:At.social)==null?void 0:Qt.medium)==null?void 0:et.url)||vr.mediumLink,xLink:((ke=(Te=(ce=(ut=ie==null?void 0:ie.email)==null?void 0:ut.footer)==null?void 0:ce.social)==null?void 0:Te.twitter)==null?void 0:ke.url)||vr.xLink,isPreferences:!!sr})}},[m,x,h,y]),(0,ef.jsx)(wr,{theme:o,colorScheme:n,isLoading:!!(l&&c.current),children:(0,ef.jsx)(j2,{ref:s,hidePublish:e,...i})})}),tf=(0,Xt.memo)(VC);var $n=require("react/jsx-runtime"),Z2=a((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"),FC=a(({theme:e,value:t=null,onChange:r,variables:o,disableVariablesAutocomplete:n=!1,variableValidation:i,hidePublish:s=!1,autoSave:l=!0,autoSaveDebounce:c=500,brandEditor:u=!1,brandProps:d,channels:p,routing:m=il,colorScheme:f,...v})=>{let{store:h}=Vi(),y=(0,Ge.useSetAtom)(_a),x=(0,Ge.useSetAtom)(Ui),E=(0,Ge.useSetAtom)(ll),g=(0,Ge.useSetAtom)(cl),b=(0,Ge.useAtomValue)(pe),M=(0,Ge.useAtomValue)(cr),C=(0,Ge.useAtomValue)(ae),[S,P]=(0,Ge.useAtom)(bt),k=(0,Ge.useAtomValue)(Kr),w=(0,Ge.useAtomValue)(Mt),[T,A]=(0,Ge.useAtom)(Gn),{getTemplate:N,saveTemplate:R,setTemplateError:B}=zi(),H=(0,Ge.useAtomValue)(oa),D=(0,Ne.useRef)(!1),[F,L]=(0,Ge.useAtom)(le),[W,_]=(0,Ge.useAtom)(Ft);(0,Ne.useEffect)(()=>{typeof window!="undefined"&&window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.templateEditorContent=F)},[F]);let V=(0,Ge.useSetAtom)(lo),j=(0,Ge.useSetAtom)(Oo),[J,G]=(0,Ge.useAtom)(xn),X=(0,Ge.useSetAtom)(pe),U=Z2(m,p),[K,de]=(0,Ne.useState)(U),me=(0,Ne.useRef)(JSON.stringify(U)),Me=(0,Ne.useRef)(!1);(0,Ne.useEffect)(()=>{let ce=Z2(m,p),Te=JSON.stringify(ce);Te!==me.current&&(de(ce),me.current=Te,ce.length&&!ce.includes(J)&&G(ce[0]))},[m,p,J,G]),(0,Ne.useEffect)(()=>{var Te;if(b||!(F!=null&&F.elements))return;let ce=F.elements.filter(ke=>ke.type==="channel").map(ke=>ke.channel);if(!ce.includes(J)){let ke=(Te=m==null?void 0:m.channels)==null?void 0:Te.find(ie=>ce.includes(ie));!ke&&ce.length>0&&(ke=ce[0]),ke&&G(ke)}},[F,J,G,m==null?void 0:m.channels,b]),(0,Ne.useEffect)(()=>{var Te;let ce=(Te=S==null?void 0:S.data)==null?void 0:Te.tenant;k&&ce&&!(ce!=null&&ce.notification)&&b===!1&&(K!=null&&K.length)&&G(K[0])},[k,S,b,K,G]);let We=(0,Ne.useRef)(null);(0,Ne.useEffect)(()=>{We.current&&(We.current.templateId!==k||We.current.tenantId!==w)&&k&&w&&(_(!0),D.current=!1,P(null),L(null),V(null),j(null),A(null),G((K==null?void 0:K[0])||"email"),X(null)),k&&w&&(We.current={templateId:k,tenantId:w})},[k,w,K,_,P,L,V,j,A,G,X]);let Pt=(0,Ne.useRef)(m);(0,Ne.useEffect)(()=>{Pt.current=m,y(m)},[m,y]),(0,Ne.useEffect)(()=>{x(i)},[i,x]),(0,Ne.useEffect)(()=>{E(o||{})},[o,E]),(0,Ne.useEffect)(()=>{g(n)},[n,g]);let Ht=(0,Ne.useCallback)(async ce=>{let Te=ce==null?void 0:ce._capturedTemplateId,ke=h.get(Kr);if(Te&&Te!==ke)return;let{_capturedTemplateId:ie,...nt}=ce;await R({routing:Pt.current,content:nt})},[R,h]),ar=(0,Ne.useCallback)(()=>{B("Error saving template")},[B]),Vt=(0,Ge.useAtomValue)(Yn),Yt=(0,Ne.useCallback)(()=>{pf(Vt)},[Vt]),{handleAutoSave:At}=Fa({onSave:Ht,debounceMs:c,enabled:b===!1&&l,onError:ar,flushBeforeSave:Yt});(0,Ne.useEffect)(()=>{!k||!w||b||S&&b===!1||C||N({includeBrand:u})},[k,w,u,N,b,S,C]);let Qt=(0,Ne.useRef)(null);(0,Ne.useEffect)(()=>{if(!t||l&&b!==!1)return;let ce=JSON.stringify(t);if(ce!==Qt.current&&JSON.stringify(be(tt(F)))!==JSON.stringify(be(tt(t)))){if(Me.current=!0,Qt.current=ce,L(t),!l)X(!1);else{let Te={...t,_capturedTemplateId:k};At(Te)}Promise.resolve().then(()=>{Me.current=!1})}},[l,t,F,L,X,At,k,b]),(0,Ne.useEffect)(()=>{var ke,ie,nt,sr,lr,Ro,Lo;if(b!==!1)return;let ce=(nt=(ie=(ke=S==null?void 0:S.data)==null?void 0:ke.tenant)==null?void 0:ie.notification)==null?void 0:nt.notificationId;if(S&&ce&&ce!==k)return;let Te=t||((Lo=(Ro=(lr=(sr=S==null?void 0:S.data)==null?void 0:sr.tenant)==null?void 0:lr.notification)==null?void 0:Ro.data)==null?void 0:Lo.content);L(Te),setTimeout(()=>{_(!1)},100)},[S,L,b,_,k,t]),(0,Ne.useEffect)(()=>{M===!0&&(D.current=!1)},[M]),(0,Ne.useEffect)(()=>{!F||b!==!1||setTimeout(()=>{D.current=!0},1e3)},[F,J,b]),(0,Ne.useEffect)(()=>{D.current=!1},[J]);let et=(0,Ge.useAtomValue)(it),ut=(0,Ge.useAtomValue)(mf);if((0,Ne.useEffect)(()=>{let ce=!!et&&b===!1&&!W,Te=D.current&&!!F&&b===!1&&!W;if(!ce&&!Te)return;let ke=et||F;if(!ke||JSON.stringify(ke)===ut)return;let nt={...ke,_capturedTemplateId:k};r&&!Me.current&&(D.current=!1,r(F||ke)),At(nt)},[F,et,At,b,W,k,r,ut]),u&&H==="brand")return(0,$n.jsx)(tf,{hidePublish:s,autoSave:l,templateEditor:!0,variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:f,...d});if(H==="template"&&J==="email")return(0,$n.jsx)(Ob,{variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:f,isLoading:!!b,hidePublish:s,channels:K,brandEditor:u,routing:m,...v});if(H==="template"&&J==="sms")return(0,$n.jsx)(E2,{colorScheme:f,variables:o,disableVariablesAutocomplete:n,theme:e,hidePublish:s,channels:K,routing:m,...v});if(H==="template"&&J==="push")return(0,$n.jsx)(r2,{variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:f,hidePublish:s,channels:K,routing:m,...v});if(H==="template"&&J==="inbox")return(0,$n.jsx)(Kb,{variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:f,hidePublish:s,channels:K,routing:m,...v});if(H==="template"&&J==="slack")return(0,$n.jsx)(g2,{theme:e,colorScheme:f,hidePublish:s,channels:K,routing:m,variables:o,disableVariablesAutocomplete:n,...v});if(H==="template"&&J==="msteams")return(0,$n.jsx)(R2,{theme:e,colorScheme:f,hidePublish:s,channels:K,routing:m,variables:o,disableVariablesAutocomplete:n,...v})},"TemplateEditorComponent"),OC=(0,Ne.memo)(FC);var WC=Cu,UC=zu,_C=Lu,zC=Nu,$C=Zu,jC=Vu;
234
234
  //# sourceMappingURL=index.js.map