@trycourier/react-designer 0.6.0 → 0.7.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 (31) hide show
  1. package/README.md +5 -3
  2. package/dist/cjs/index.js +58 -57
  3. package/dist/cjs/index.js.map +4 -4
  4. package/dist/cjs/styles.css +496 -235
  5. package/dist/components/BrandEditor/Editor/BrandFooter/BrandFooter.d.ts +3 -1
  6. package/dist/components/TemplateEditor/Channels/Inbox/Inbox.d.ts +3 -0
  7. package/dist/components/TemplateEditor/Layout/Layout.d.ts +1 -0
  8. package/dist/components/TemplateEditor/TemplateEditor.d.ts +2 -0
  9. package/dist/components/TemplateEditor/VariableViewModeSync.d.ts +3 -0
  10. package/dist/components/TemplateEditor/index.d.ts +1 -0
  11. package/dist/components/TemplateEditor/store.d.ts +3 -0
  12. package/dist/components/extensions/Blockquote/Blockquote.d.ts +4 -0
  13. package/dist/components/extensions/Button/Button.types.d.ts +8 -4
  14. package/dist/components/extensions/ImageBlock/components/ImageBlockView.d.ts +1 -3
  15. package/dist/components/extensions/MessagingChannelPaste/MessagingChannelPaste.d.ts +11 -0
  16. package/dist/components/extensions/MessagingChannelPaste/index.d.ts +2 -0
  17. package/dist/components/extensions/Variable/Variable.d.ts +5 -0
  18. package/dist/components/ui/TextMenu/components/ContentTypePicker.d.ts +1 -1
  19. package/dist/components/ui/TextMenu/hooks/useTextmenuStates.d.ts +1 -0
  20. package/dist/components/ui/VariableEditor/VariableChipBase.d.ts +8 -0
  21. package/dist/components/ui/VariableEditor/VariableInput.d.ts +18 -0
  22. package/dist/esm/index.js +58 -57
  23. package/dist/esm/index.js.map +4 -4
  24. package/dist/esm/styles.css +496 -235
  25. package/dist/index.d.ts +2 -0
  26. package/dist/lib/constants/block-defaults.d.ts +43 -0
  27. package/dist/lib/constants/email-editor-tiptap-styles.d.ts +62 -0
  28. package/dist/lib/index.d.ts +1 -0
  29. package/dist/styles.css +496 -235
  30. package/dist/types/elemental.types.d.ts +3 -2
  31. package/package.json +1 -1
package/dist/esm/index.js CHANGED
@@ -43,7 +43,7 @@ if (typeof require !== "undefined") {
43
43
  console.warn('Unable to setup tippy imports polyfill');
44
44
  }
45
45
  }
46
- var Ey=Object.create;var Kc=Object.defineProperty;var wy=Object.getOwnPropertyDescriptor;var ky=Object.getOwnPropertyNames;var Py=Object.getPrototypeOf,My=Object.prototype.hasOwnProperty;var a=(e,t)=>Kc(e,"name",{value:t,configurable:!0});var Gc=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ny=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ky(t))!My.call(e,n)&&n!==r&&Kc(e,n,{get:()=>t[n],enumerable:!(o=wy(t,n))||o.enumerable});return e};var Ps=(e,t,r)=>(r=e!=null?Ey(Py(e)):{},Ny(t||!e||!e.__esModule?Kc(r,"default",{value:e,enumerable:!0}):r,e));var ku=Gc($s=>{"use strict";Object.defineProperty($s,"__esModule",{value:!0});$s.bind=void 0;function a2(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(a2,"bind");$s.bind=a2});var Rf=Gc(Ci=>{"use strict";var vi=Ci&&Ci.__assign||function(){return vi=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},vi.apply(this,arguments)};Object.defineProperty(Ci,"__esModule",{value:!0});Ci.bindAll=void 0;var s2=ku();function Lf(e){if(typeof e!="undefined")return typeof e=="boolean"?{capture:e}:e}a(Lf,"toOptions");function l2(e,t){if(t==null)return e;var r=vi(vi({},e),{options:vi(vi({},Lf(t)),Lf(e.options))});return r}a(l2,"getBinding");function c2(e,t,r){var o=t.map(function(n){var i=l2(n,r);return(0,s2.bind)(e,i)});return a(function(){o.forEach(function(i){return i()})},"unbindAll")}a(c2,"bindAll");Ci.bindAll=c2});var Pa=Gc(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.bindAll=xi.bind=void 0;var u2=ku();Object.defineProperty(xi,"bind",{enumerable:!0,get:function(){return u2.bind}});var d2=Rf();Object.defineProperty(xi,"bindAll",{enumerable:!0,get:function(){return d2.bindAll}})});import{Provider as Ay,useAtom as Yc,createStore as Sy}from"jotai";import{useEffect as Iy,memo as Ly,useMemo as Ry}from"react";import{atom as xr}from"jotai";var Xc={method:"single",channels:["email"]},Ot=xr("https://api.courier.com/client/q"),Wt=xr(""),wt=xr(""),Tr=xr(""),Ms=xr(Xc),dt=xr(null),he=xr(null),mt=xr(null),jt=xr(null),ue=xr(null),Fp=xr(!0);import{Fragment as Hy,jsx as Qc}from"react/jsx-runtime";var By=a(({children:e,tenantId:t,token:r,apiUrl:o})=>{let[,n]=Yc(Ot),[,i]=Yc(Wt),[,s]=Yc(wt);return Iy(()=>{i(r),s(t),o&&n(o)},[r,t,o,n,i,s]),Qc(Hy,{children:e})},"BrandProviderContext"),Dy=a(e=>{let t=Ry(()=>Sy(),[]);return Qc(Ay,{store:t,children:Qc(By,{...e})})},"BrandProviderComponent"),Vy=Ly(Dy);import{Provider as Fy,useAtom as bn,createStore as Oy,useStore as Wy}from"jotai";import{createContext as _y,memo as Uy,useContext as $y,useEffect as ru,useMemo as zy}from"react";import{toast as jy}from"sonner";import{atom as ze}from"jotai";var fn=ze(null),tu=ze(null),Ns=ze(null),de=ze(e=>e(Ns),(e,t,r)=>{if(!r){t(Ns,r);return}let o=e(tu),n=r;if(o)try{n=o(r)}catch(s){console.error("[ContentTransformer] Error applying transformer:",s),n=r}let i=e(Ns);JSON.stringify(i)!==JSON.stringify(n)&&t(Ns,n)}),si=ze(null),li=ze(null),Ae=ze(null),ci=ze(null),kt=ze(!1),_r=ze(!1),gn=ze({}),ui=ze({}),di=ze(!1),mi=ze(void 0),qt=ze(!1),As=0,pi=a(e=>{e?As++:As=Math.max(0,As-1)},"setFormUpdating"),Vo=a(()=>As>0,"getFormUpdating");var Ye=ze(null),Op=ze(null),eu=ze(new Map),hn=ze(e=>e(eu),(e,t,r)=>{let o=new Map(e(eu));r.action==="register"&&r.fn?o.set(r.id,r.fn):r.action==="unregister"&&o.delete(r.id),t(eu,o)}),Wp=a(e=>{e.forEach(t=>{try{t()}catch(r){console.error("[FlushPendingUpdates] Error flushing updates:",r)}})},"flushAllPendingUpdates"),or=a(e=>typeof e=="object"&&"preset"in e,"isPresetReference"),Ss=["heading","text","list","image","spacer","divider","button","customCode"],Ur=ze(Ss),Is=ze({}),Ho=ze([]);import{jsx as ou}from"react/jsx-runtime";var ma=a(()=>({store:Wy()}),"useTemplateStore"),_p=_y(null),Up=a(()=>$y(_p),"useUploadImage"),qy=a(({children:e,templateId:t,tenantId:r,token:o,apiUrl:n,uploadImage:i,variables:s,disableVariablesAutocomplete:l=!1})=>{let[,c]=bn(Ot),[,u]=bn(Wt),[,d]=bn(wt),[,m]=bn(Tr),[p]=bn(ue),[,g]=bn(ui),[,v]=bn(di);return ru(()=>{u(o),d(r),m(t),n&&c(n)},[o,r,t,n,c,u,d,m]),ru(()=>{s&&g(s),v(l)},[s,l,g,v]),ru(()=>{p&&jy.error(p.message,p.toastProps)},[p]),ou(_p.Provider,{value:i||null,children:e})},"TemplateProviderContext"),Zy=a(e=>{let t=zy(()=>Oy(),[]);return ou(Fy,{store:t,children:ou(qy,{...e})})},"TemplateProviderComponent"),Jy=Uy(Zy);import{useAtom as fa,useSetAtom as Vs}from"jotai";var po=a((e,t)=>({message:e,toastProps:t}),"createCustomError"),E6=a(e=>{var t;return((t=e.toastProps)==null?void 0:t.action)!==void 0},"isRetryableError"),w6=a(e=>typeof e=="string"?e:e&&typeof e=="object"&&"message"in e?String(e.message):e instanceof Error?e.message:"Unknown error","extractErrorMessage"),Ls=a(e=>typeof e=="string"?po(e):e,"convertLegacyError");import{atom as $p}from"jotai";import{toast as Ky}from"sonner";var zp=$p(null,async(e,t,r)=>{var s;let o=e(Ot),n=e(Wt),i=e(wt);if(!o){t(ue,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(mt,!0);try{let c=await(await fetch(o,{method:"POST",headers:{Authorization:`Bearer ${n}`,"x-courier-client-key":`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
46
+ var r2=Object.create;var du=Object.defineProperty;var o2=Object.getOwnPropertyDescriptor;var n2=Object.getOwnPropertyNames;var i2=Object.getPrototypeOf,a2=Object.prototype.hasOwnProperty;var a=(e,t)=>du(e,"name",{value:t,configurable:!0});var mu=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var s2=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of n2(t))!a2.call(e,n)&&n!==r&&du(e,n,{get:()=>t[n],enumerable:!(o=o2(t,n))||o.enumerable});return e};var Fs=(e,t,r)=>(r=e!=null?r2(i2(e)):{},s2(t||!e||!e.__esModule?du(r,"default",{value:e,enumerable:!0}):r,e));var Wu=mu(tl=>{"use strict";Object.defineProperty(tl,"__esModule",{value:!0});tl.bind=void 0;function O2(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(O2,"bind");tl.bind=O2});var eg=mu(Ni=>{"use strict";var Mi=Ni&&Ni.__assign||function(){return Mi=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},Mi.apply(this,arguments)};Object.defineProperty(Ni,"__esModule",{value:!0});Ni.bindAll=void 0;var _2=Wu();function Qf(e){if(typeof e!="undefined")return typeof e=="boolean"?{capture:e}:e}a(Qf,"toOptions");function W2(e,t){if(t==null)return e;var r=Mi(Mi({},e),{options:Mi(Mi({},Qf(t)),Qf(e.options))});return r}a(W2,"getBinding");function z2(e,t,r){var o=t.map(function(n){var i=W2(n,r);return(0,_2.bind)(e,i)});return a(function(){o.forEach(function(i){return i()})},"unbindAll")}a(z2,"bindAll");Ni.bindAll=z2});var Ha=mu(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.bindAll=Si.bind=void 0;var U2=Wu();Object.defineProperty(Si,"bind",{enumerable:!0,get:function(){return U2.bind}});var $2=eg();Object.defineProperty(Si,"bindAll",{enumerable:!0,get:function(){return $2.bindAll}})});import{Provider as l2,useAtom as fu,createStore as c2}from"jotai";import{useEffect as u2,memo as d2,useMemo as m2}from"react";import{atom as Ar}from"jotai";var pu={method:"single",channels:["email"]},Ut=Ar("https://api.courier.com/client/q"),$t=Ar(""),At=Ar(""),Ir=Ar(""),Os=Ar(pu),bt=Ar(null),ye=Ar(null),yt=Ar(null),Jt=Ar(null),se=Ar(null),af=Ar(!0);import{Fragment as h2,jsx as gu}from"react/jsx-runtime";var p2=a(({children:e,tenantId:t,token:r,apiUrl:o})=>{let[,n]=fu(Ut),[,i]=fu($t),[,s]=fu(At);return u2(()=>{i(r),s(t),o&&n(o)},[r,t,o,n,i,s]),gu(h2,{children:e})},"BrandProviderContext"),f2=a(e=>{let t=m2(()=>c2(),[]);return gu(l2,{store:t,children:gu(p2,{...e})})},"BrandProviderComponent"),g2=d2(f2);import{Provider as b2,useAtom as Go,createStore as y2,useStore as v2}from"jotai";import{createContext as C2,memo as x2,useContext as T2,useEffect as yu,useMemo as E2}from"react";import{toast as w2}from"sonner";import{atom as Ue}from"jotai";var Pn=Ue(null),bu=Ue(null),_s=Ue(null),le=Ue(e=>e(_s),(e,t,r)=>{if(!r){t(_s,r);return}let o=e(bu),n=r;if(o)try{n=o(r)}catch(s){console.error("[ContentTransformer] Error applying transformer:",s),n=r}let i=e(_s);JSON.stringify(i)!==JSON.stringify(n)&&t(_s,n)}),hi=Ue(null),bi=Ue(null),Le=Ue(null),yi=Ue(null),It=Ue(!1),ur=Ue(!1),Mn=Ue({}),Gt=Ue(!0),vi=Ue({}),Ci=Ue(!1),xi=Ue(void 0),Xt=Ue(!1),Ws=0,Po=a(e=>{e?Ws++:Ws=Math.max(0,Ws-1)},"setFormUpdating"),$e=a(()=>Ws>0,"getFormUpdating");var et=Ue(null),sf=Ue(null),hu=Ue(new Map),Nn=Ue(e=>e(hu),(e,t,r)=>{let o=new Map(e(hu));r.action==="register"&&r.fn?o.set(r.id,r.fn):r.action==="unregister"&&o.delete(r.id),t(hu,o)}),lf=a(e=>{e.forEach(t=>{try{t()}catch(r){console.error("[FlushPendingUpdates] Error flushing updates:",r)}})},"flushAllPendingUpdates"),dr=a(e=>typeof e=="object"&&"preset"in e,"isPresetReference"),zs=["heading","text","list","image","spacer","divider","button","customCode"],to=Ue(zs),Us=Ue({}),Jo=Ue([]);import{jsx as vu}from"react/jsx-runtime";var Ea=a(()=>({store:v2()}),"useTemplateStore"),cf=C2(null),uf=a(()=>T2(cf),"useUploadImage"),k2=a(({children:e,templateId:t,tenantId:r,token:o,apiUrl:n,uploadImage:i,variables:s,disableVariablesAutocomplete:l=!1})=>{let[,c]=Go(Ut),[,u]=Go($t),[,d]=Go(At),[,p]=Go(Ir),[m]=Go(se),[,f]=Go(vi),[,v]=Go(Ci),[,h]=Go(Gt);return yu(()=>{u(o),d(r),p(t),n&&c(n)},[o,r,t,n,c,u,d,p]),yu(()=>{h(s!==void 0),s&&f(s),v(l)},[s,l,f,v,h]),yu(()=>{m&&w2.error(m.message,m.toastProps)},[m]),vu(cf.Provider,{value:i||null,children:e})},"TemplateProviderContext"),P2=a(e=>{let t=E2(()=>y2(),[]);return vu(b2,{store:t,children:vu(k2,{...e})})},"TemplateProviderComponent"),M2=x2(P2);import{useAtom as ka,useSetAtom as Ks}from"jotai";var Mo=a((e,t)=>({message:e,toastProps:t}),"createCustomError"),B6=a(e=>{var t;return((t=e.toastProps)==null?void 0:t.action)!==void 0},"isRetryableError"),D6=a(e=>typeof e=="string"?e:e&&typeof e=="object"&&"message"in e?String(e.message):e instanceof Error?e.message:"Unknown error","extractErrorMessage"),$s=a(e=>typeof e=="string"?Mo(e):e,"convertLegacyError");import{atom as df}from"jotai";import{toast as N2}from"sonner";var mf=df(null,async(e,t,r)=>{var s;let o=e(Ut),n=e($t),i=e(At);if(!o){t(se,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(yt,!0);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 @@ var Ey=Object.create;var Kc=Object.defineProperty;var wy=Object.getOwnPropertyDe
53
53
  }
54
54
  }
55
55
  }
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(ue,{message:u.join(`
57
- `),toastProps:{duration:4e3}})}else t(ue,{message:"Error saving brand settings",toastProps:{duration:4e3}});return c}catch(l){throw t(ue,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save brand settings"}}),l}finally{t(mt,!1)}}),jp=$p(null,async(e,t)=>{let r=e(Ot),o=e(Wt),n=e(wt);if(!r){t(ue,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(jt,!0);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(se,{message:u.join(`
57
+ `),toastProps:{duration:4e3}})}else t(se,{message:"Error saving brand settings",toastProps:{duration:4e3}});return c}catch(l){throw t(se,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save brand settings"}}),l}finally{t(yt,!1)}}),pf=df(null,async(e,t)=>{let r=e(Ut),o=e($t),n=e(At);if(!r){t(se,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(Jt,!0);try{let i=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
58
58
  mutation PublishNotification($input: PublishBrandInput!) {
59
59
  tenant {
60
60
  brand {
@@ -64,7 +64,7 @@ var Ey=Object.create;var Kc=Object.defineProperty;var wy=Object.getOwnPropertyDe
64
64
  }
65
65
  }
66
66
  }
67
- `,variables:{input:{tenantId:n}}})}),s=await i.json();return i.status===200?Ky.success("Brand published"):t(ue,{message:"Error publishing brand",toastProps:{duration:4e3}}),s}catch(i){throw t(ue,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish brand"}}),i}finally{t(jt,!1)}});import{atom as Gy}from"jotai";var Rs=Gy(null,async(e,t,r)=>{var c,u,d,m,p;let o=e(Ot),n=e(Wt),i=e(wt),s=e(Tr),l=(c=r==null?void 0:r.includeBrand)!=null?c:!0;if(!o||!n||!i){let g=[];o||g.push("API URL"),n||g.push("token"),i||g.push("tenant ID"),t(ue,{message:"Missing configuration",toastProps:{description:`Missing: ${g.join(", ")}`,duration:5e3}});return}t(he,!0),t(ue,null);try{let g=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?N2.success("Brand published"):t(se,{message:"Error publishing brand",toastProps:{duration:4e3}}),s}catch(i){throw t(se,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish brand"}}),i}finally{t(Jt,!1)}});import{atom as S2}from"jotai";var qs=S2(null,async(e,t,r)=>{var c,u,d,p,m;let o=e(Ut),n=e($t),i=e(At),s=e(Ir),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(se,{message:"Missing configuration",toastProps:{description:`Missing: ${f.join(", ")}`,duration:5e3}});return}t(ye,!0),t(se,null);try{let f=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,"x-courier-client-key":`Bearer ${n}`},body:JSON.stringify({query:`
68
68
  query GetTenant($tenantId: String!, $input: GetNotificationInput!, $brandInput: GetTenantBrandInput!, $includeBrand: Boolean!) {
69
69
  tenant(tenantId: $tenantId) {
70
70
  tenantId
@@ -122,13 +122,13 @@ var Ey=Object.create;var Kc=Object.defineProperty;var wy=Object.getOwnPropertyDe
122
122
  }
123
123
  }
124
124
  }
125
- `,variables:{tenantId:i,input:{notificationId:s,version:"latest"},brandInput:{version:"latest"},includeBrand:l}})}),v=await g.json(),b=g.status,y=(u=v.data)==null?void 0:u.tenant;if(y?(t(dt,v),t(si,(d=y==null?void 0:y.notification)==null?void 0:d.publishedAt),t(li,(m=y==null?void 0:y.notification)==null?void 0:m.version)):b===401?t(ue,{message:"Authentication failed",toastProps:{duration:6e3}}):t(ue,{message:"Error fetching template data",toastProps:{duration:4e3}}),v.errors){let C=(p=v.errors)==null?void 0:p.map(x=>x.message);t(ue,{message:C.join(`
126
- `),toastProps:{duration:4e3}})}}catch{t(ue,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to fetch template data"}})}finally{t(he,!1)}});import{atom as lu}from"jotai";import{toast as Jp}from"sonner";function nu(e,t){if(!(e!=null&&e.elements))return null;let r=e.elements.find(o=>o.type==="channel"&&o.channel===t);if(!r||r.type!=="channel")return null;if("elements"in r&&r.elements){let o=r.elements.find(n=>n.type==="meta");if(o&&o.type==="meta")return o}return null}a(nu,"getExistingMetaElement");function iu(e){return!!e&&Object.keys(e).length>0}a(iu,"hasLocales");function yn(e){return"content"in e&&typeof e.content=="string"?e.content:"elements"in e&&Array.isArray(e.elements)?e.elements.map(t=>"content"in t&&typeof t.content=="string"?t.content:"").join(""):""}a(yn,"extractPlainTextFromNode");function au(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(au,"cleanInboxElements");function qp(e){return e.map(t=>{if(t.type==="text"){if("content"in t&&typeof t.content=="string")return{type:"text",content:t.content};if("elements"in t&&Array.isArray(t.elements))return{type:"text",content:yn(t)||`
127
- `}}return t})}a(qp,"cleanPushElements");function Bs(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}a(Bs,"cleanSMSElements");function su(e){return{...e,elements:e.elements.map(t=>t.type==="channel"&&t.channel==="inbox"&&t.elements?{...t,elements:au(t.elements)}:t)}}a(su,"cleanTemplateContent");function Zp(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(Zp,"getSubjectStorageFormat");function Er(e,t,r,o){let n=Zp(e,t);if(t==="push"){let i=o.find(m=>m.type==="meta"&&"title"in m),s=i&&"title"in i?i.title:r,l=o.filter(m=>m.type!=="meta"),c=qp(l),u=nu(e,t);return{elements:[{type:"meta",title:s,...iu(u==null?void 0:u.locales)&&{locales:u.locales}},...c]}}if(t==="sms")return{elements:o.length>0?o:[{type:"text",content:`
128
- `}]};if(t==="inbox"){let i=o.filter(b=>b.type==="text"),s=o.filter(b=>b.type==="action"),l=i[0],c=l&&yn(l).trim()||"",u=i[1],m={type:"text",content:(u?yn(u):`
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(hi,(d=y==null?void 0:y.notification)==null?void 0:d.publishedAt),t(bi,(p=y==null?void 0:y.notification)==null?void 0:p.version)):h===401?t(se,{message:"Authentication failed",toastProps:{duration:6e3}}):t(se,{message:"Error fetching template data",toastProps:{duration:4e3}}),v.errors){let C=(m=v.errors)==null?void 0:m.map(T=>T.message);t(se,{message:C.join(`
126
+ `),toastProps:{duration:4e3}})}}catch{t(se,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to fetch template data"}})}finally{t(ye,!1)}});import{atom as wu}from"jotai";import{toast as hf}from"sonner";function Cu(e,t){if(!(e!=null&&e.elements))return null;let r=e.elements.find(o=>o.type==="channel"&&o.channel===t);if(!r||r.type!=="channel")return null;if("elements"in r&&r.elements){let o=r.elements.find(n=>n.type==="meta");if(o&&o.type==="meta")return o}return null}a(Cu,"getExistingMetaElement");function xu(e){return!!e&&Object.keys(e).length>0}a(xu,"hasLocales");function Sn(e){return"content"in e&&typeof e.content=="string"?e.content:"elements"in e&&Array.isArray(e.elements)?e.elements.map(t=>"content"in t&&typeof t.content=="string"?t.content:"").join(""):""}a(Sn,"extractPlainTextFromNode");function Tu(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content,..."locales"in t&&t.locales&&{locales:t.locales}}: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.locales&&{locales:t.locales}}:t)}a(Tu,"cleanInboxElements");function ff(e){return e.map(t=>{if(t.type==="text"){if("content"in t&&typeof t.content=="string")return{type:"text",content:t.content,..."locales"in t&&t.locales&&{locales:t.locales}};if("elements"in t&&Array.isArray(t.elements))return{type:"text",content:Sn(t)||`
127
+ `,..."locales"in t&&t.locales&&{locales:t.locales}}}return t})}a(ff,"cleanPushElements");function js(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content,..."locales"in t&&t.locales&&{locales:t.locales}}:t)}a(js,"cleanSMSElements");function Eu(e){return{...e,elements:e.elements.map(t=>t.type==="channel"&&t.channel==="inbox"&&t.elements?{...t,elements:Tu(t.elements)}:t)}}a(Eu,"cleanTemplateContent");function gf(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(gf,"getSubjectStorageFormat");function Lr(e,t,r,o){let n=gf(e,t);if(t==="push"){let i=o.find(p=>p.type==="meta"&&"title"in p),s=i&&"title"in i?i.title:r,l=o.filter(p=>p.type!=="meta"),c=ff(l),u=Cu(e,t);return{elements:[{type:"meta",title:s,...xu(u==null?void 0:u.locales)&&{locales:u.locales}},...c]}}if(t==="sms")return{elements:o.length>0?o:[{type:"text",content:`
128
+ `}]};if(t==="inbox"){let i=o.filter(h=>h.type==="text"),s=o.filter(h=>h.type==="action"),l=i[0],c=l&&Sn(l).trim()||"",u=i[1],p={type:"text",content:(u?Sn(u):`
129
129
  `)||`
130
- `},p=au(s),g=nu(e,t);return{elements:[{type:"meta",title:c,...iu(g==null?void 0:g.locales)&&{locales:g.locales}},m,...p]}}if(n==="raw"){let i={};return t==="email"?i.subject=r:i.title=r,{elements:o,raw:i}}else{let i=nu(e,t);return{elements:[{type:"meta",title:r,...iu(i==null?void 0:i.locales)&&{locales:i.locales}},...o]}}}a(Er,"createTitleUpdate");function pa(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(pa,"extractCurrentTitle");var Ds=lu(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 b=r;o=b.routing,n=b.content}else o=r;let s=o!=null?o:e(Ms),l=e(Ot),c=e(Wt),u=e(wt),d=e(Tr),m=n||e(de);if(!m)return;let p=su(m);if(!l){t(ue,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(mt,!0);let g={content:p,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:`
130
+ `},m=Tu(s),f=Cu(e,t);return{elements:[{type:"meta",title:c,...xu(f==null?void 0:f.locales)&&{locales:f.locales}},p,...m],...c&&{raw:{title:c}}}}if(n==="raw"){let i={};return t==="email"?i.subject=r:i.title=r,{elements:o,raw:i}}else{let i=Cu(e,t);return{elements:[{type:"meta",title:r,...xu(i==null?void 0:i.locales)&&{locales:i.locales}},...o]}}}a(Lr,"createTitleUpdate");function wa(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(wa,"extractCurrentTitle");var Zs=wu(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(Os),l=e(Ut),c=e($t),u=e(At),d=e(Ir),p=n||e(le);if(!p)return;let m=Eu(p);if(!l){t(se,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(yt,!0);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 @@ var Ey=Object.create;var Kc=Object.defineProperty;var wy=Object.getOwnPropertyDe
141
141
  }
142
142
  }
143
143
  }
144
- `,variables:{input:{tenantId:u,notificationId:d,name:d,data:g}}})})).json();if(y.data)t(li,y.data.tenant.notification.save.version);else if(y.errors){let C=(v=y.errors)==null?void 0:v.map(x=>x.message);t(ue,{message:C.join(`
145
- `),toastProps:{duration:4e3}})}else t(ue,{message:"Error saving template",toastProps:{duration:4e3}});return y}catch(b){throw t(ue,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save template"}}),b}finally{t(mt,!1)}}),Kp=lu(null,async(e,t)=>{let r=e(Ot),o=e(Wt),n=e(wt),i=e(Tr),s=e(li);if(!s){t(ue,{message:"Version not defined",toastProps:{duration:5e3}});return}if(!r){t(ue,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(jt,!0);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(bi,y.data.tenant.notification.save.version);else if(y.errors){let C=(v=y.errors)==null?void 0:v.map(T=>T.message);t(se,{message:C.join(`
145
+ `),toastProps:{duration:4e3}})}else t(se,{message:"Error saving template",toastProps:{duration:4e3}});return y}catch(h){throw t(se,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save template"}}),h}finally{t(yt,!1)}}),bf=wu(null,async(e,t)=>{let r=e(Ut),o=e($t),n=e(At),i=e(Ir),s=e(bi);if(!s){t(se,{message:"Version not defined",toastProps:{duration:5e3}});return}if(!r){t(se,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(Jt,!0);try{let l=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
146
146
  mutation PublishNotification($input: PublishNotificationInput!) {
147
147
  tenant {
148
148
  notification {
@@ -154,7 +154,7 @@ var Ey=Object.create;var Kc=Object.defineProperty;var wy=Object.getOwnPropertyDe
154
154
  }
155
155
  }
156
156
  }
157
- `,variables:{input:{tenantId:n,notificationId:i,version:s}}})}),c=await l.json();return l.status===200?(Jp.success("Template published"),t(si,new Date().toISOString()),t(li,c.data.tenant.notification.publish.version)):t(ue,{message:"Error publishing template",toastProps:{duration:4e3}}),c}catch(l){throw t(ue,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish template"}}),l}finally{t(jt,!1)}}),Gp=lu(null,async(e,t,r={})=>{var g,v,b,y,C;let{content:o,name:n}=r,i=e(Ot),s=e(Wt),l=e(wt),c=e(Tr);if(!r.targetTemplateId&&!c){t(ue,{message:"No template is currently loaded",toastProps:{duration:5e3}});return}let u=r.targetTemplateId||`${c}-copy`,d=o||e(de);if(!d){t(ue,{message:"No template content to duplicate",toastProps:{duration:5e3}});return}if(!i){t(ue,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(mt,!0);let p={content:su(d)};try{let h=await(await fetch(i,{method:"POST",headers:{Authorization:`Bearer ${s}`,"x-courier-client-key":`Bearer ${s}`,"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?(hf.success("Template published"),t(hi,new Date().toISOString()),t(bi,c.data.tenant.notification.publish.version)):t(se,{message:"Error publishing template",toastProps:{duration:4e3}}),c}catch(l){throw t(se,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish template"}}),l}finally{t(Jt,!1)}}),yf=wu(null,async(e,t,r={})=>{var f,v,h,y,C;let{content:o,name:n}=r,i=e(Ut),s=e($t),l=e(At),c=e(Ir);if(!r.targetTemplateId&&!c){t(se,{message:"No template is currently loaded",toastProps:{duration:5e3}});return}let u=r.targetTemplateId||`${c}-copy`,d=o||e(le);if(!d){t(se,{message:"No template content to duplicate",toastProps:{duration:5e3}});return}if(!i){t(se,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(yt,!0);let m={content:Eu(d)};try{let E=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 @@ var Ey=Object.create;var Kc=Object.defineProperty;var wy=Object.getOwnPropertyDe
167
167
  }
168
168
  }
169
169
  }
170
- `,variables:{input:{tenantId:l,notificationId:u,name:n||u,data:p}}})})).json();if((y=(b=(v=(g=h.data)==null?void 0:g.tenant)==null?void 0:v.notification)==null?void 0:b.save)!=null&&y.success)return Jp.success("Template duplicated successfully"),{success:!0,templateId:u,version:h.data.tenant.notification.save.version};if(h.errors){let f=(C=h.errors)==null?void 0:C.map(E=>E.message);return t(ue,{message:f.join(`
171
- `),toastProps:{duration:4e3}}),{success:!1,templateId:u}}else return t(ue,{message:"Error duplicating template",toastProps:{duration:4e3}}),{success:!1,templateId:u}}catch(x){throw t(ue,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to duplicate template"}}),x}finally{t(mt,!1)}});function ga(){ma();let e=Vs(Rs),t=Vs(zp),r=Vs(Ds),o=Vs(jp),[n,i]=fa(he),[s,l]=fa(mt),[c,u]=fa(jt),[d,m]=fa(ue),[p,g]=fa(dt);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(b=>{m(b===null?null:typeof b=="string"?po(b):b)},"setTemplateError"),templateData:p,setTemplateData:g,createCustomError:po,convertLegacyError:Ls}}a(ga,"useBrandActions");import{useAtom as vn,useSetAtom as Hs}from"jotai";import{useCallback as Xy}from"react";function ha(){let e=Hs(Rs),t=Hs(Ds),r=Hs(Kp),o=Hs(Gp),[n,i]=vn(he),[s,l]=vn(mt),[c,u]=vn(jt),[d,m]=vn(ue),[p,g]=vn(dt),[v,b]=vn(de),[y,C]=vn(tu),x=Xy(h=>{m(h===null?null:typeof h=="string"?po(h):h)},[m]);return{getTemplate:e,saveTemplate:t,publishTemplate:r,duplicateTemplate:o,isTemplateLoading:n,setIsTemplateLoading:i,isTemplateSaving:s,setIsTemplateSaving:l,isTemplatePublishing:c,setIsTemplatePublishing:u,templateError:d,setTemplateError:x,templateData:p,setTemplateData:g,templateEditorContent:v,setTemplateEditorContent:b,createCustomError:po,convertLegacyError:Ls,contentTransformer:y,setContentTransformer:C}}a(ha,"useTemplateActions");import{useAtom as Yp}from"jotai";import{useCallback as Qy}from"react";var Yy=["image/png","image/jpeg","image/gif","image/webp"],Xp=a(async(e,t)=>{var c,u,d;let{apiUrl:r,token:o}=t;if(!Yy.includes(e.type))throw new Error(`Invalid file type: ${e.type}. Only PNG, JPEG, GIF, and WebP images are supported.`);let n=e.name.split(".").pop()||"",i=`image_${Date.now()}_${Math.random().toString(36).substring(2,10)}.${n}`,l=(await new Promise((m,p)=>{let g=new FileReader;g.onload=()=>{typeof g.result=="string"?m(g.result):p(new Error("Failed to read file as data URL"))},g.onerror=()=>p(g.error),g.readAsDataURL(e)})).split(",")[1];try{let p=await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({query:`
170
+ `,variables:{input:{tenantId:l,notificationId:u,name:n||u,data:m}}})})).json();if((y=(h=(v=(f=E.data)==null?void 0:f.tenant)==null?void 0:v.notification)==null?void 0:h.save)!=null&&y.success)return hf.success("Template duplicated successfully"),{success:!0,templateId:u,version:E.data.tenant.notification.save.version};if(E.errors){let b=(C=E.errors)==null?void 0:C.map(g=>g.message);return t(se,{message:b.join(`
171
+ `),toastProps:{duration:4e3}}),{success:!1,templateId:u}}else return t(se,{message:"Error duplicating template",toastProps:{duration:4e3}}),{success:!1,templateId:u}}catch(T){throw t(se,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to duplicate template"}}),T}finally{t(yt,!1)}});function Pa(){Ea();let e=Ks(qs),t=Ks(mf),r=Ks(Zs),o=Ks(pf),[n,i]=ka(ye),[s,l]=ka(yt),[c,u]=ka(Jt),[d,p]=ka(se),[m,f]=ka(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"?Mo(h):h)},"setTemplateError"),templateData:m,setTemplateData:f,createCustomError:Mo,convertLegacyError:$s}}a(Pa,"useBrandActions");import{useAtom as An,useSetAtom as Js}from"jotai";import{useCallback as A2}from"react";function Ma(){let e=Js(qs),t=Js(Zs),r=Js(bf),o=Js(yf),[n,i]=An(ye),[s,l]=An(yt),[c,u]=An(Jt),[d,p]=An(se),[m,f]=An(bt),[v,h]=An(le),[y,C]=An(bu),T=A2(E=>{p(E===null?null:typeof E=="string"?Mo(E):E)},[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:T,templateData:m,setTemplateData:f,templateEditorContent:v,setTemplateEditorContent:h,createCustomError:Mo,convertLegacyError:$s,contentTransformer:y,setContentTransformer:C}}a(Ma,"useTemplateActions");import{useAtom as Cf}from"jotai";import{useCallback as L2}from"react";var I2=["image/png","image/jpeg","image/gif","image/webp"],vf=a(async(e,t)=>{var c,u,d;let{apiUrl:r,token:o}=t;if(!I2.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,12 +178,12 @@ var Ey=Object.create;var Kc=Object.defineProperty;var wy=Object.getOwnPropertyDe
178
178
  }
179
179
  }
180
180
  }
181
- `,variables:{input:{name:i,type:e.type,data:l}}})})).json();if(p.errors)throw new Error(p.errors.map(v=>v.message).join(`
182
- `));let g=p.data;return(d=(u=(c=g==null?void 0:g.tenant)==null?void 0:c.notification)==null?void 0:u.uploadImage)==null?void 0:d.url}catch(m){throw console.error("Error uploading image:",m),m}},"uploadImage");function ba(){let[e]=Yp(Ot),[t]=Yp(Wt),r=Up();return{uploadImage:Qy(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 Xp(i,{apiUrl:e,token:t});if(!s)throw new Error("Upload failed: No URL returned from server");return{url:s}}},[e,t,r])}}a(ba,"useImageUpload");import{clsx as $T}from"clsx";import{twMerge as zT}from"tailwind-merge";import{v4 as Ue}from"uuid";function pt(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(pt,"isValidVariableName");var e2="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function Fs(e){return e?e===e2:!0}a(Fs,"isBlankImageSrc");var Os=a((e,t)=>new Promise(r=>{let o=new FileReader;o.onload=n=>{var s;let i=new Image;i.onload=()=>{var m;let l,c;i.width>i.height?(l=Math.min(t,i.width),c=Math.round(i.height/i.width*l)):(c=Math.min(t,i.height),l=Math.round(i.width/i.height*c));let u=document.createElement("canvas");u.width=l,u.height=c;let d=u.getContext("2d");if(d){d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(i,0,0,l,c);let p=.8,g=u.toDataURL(e.type||"image/jpeg",p),v=0,b=5;for(;g.length>512e3&&v<b;)v++,p-=.1,p<.3&&(p=.3),g=u.toDataURL(e.type||"image/jpeg",p);r({dataUrl:g,width:l,height:c})}else r({dataUrl:(m=n.target)==null?void 0:m.result,width:i.width,height:i.height})},i.src=(s=n.target)==null?void 0:s.result},o.readAsDataURL(e)}),"resizeImage");import{mergeAttributes as NT,Node as AT}from"@tiptap/core";import{ReactNodeViewRenderer as ST}from"@tiptap/react";import{Plugin as IT,PluginKey as LT}from"@tiptap/pm/state";import{NodeViewContent as TT}from"@tiptap/react";import{useSetAtom as ET}from"jotai";import{useCallback as wT,useEffect as kT,useState as PT}from"react";import{jsx as cu}from"react/jsx-runtime";var Le=a(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?cu("path",{className:R(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):cu("path",{className:R(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),Y=a(({width:e=28,height:t=28,...r})=>cu("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");import{jsx as uu,jsxs as t2}from"react/jsx-runtime";var Qp=a(({color:e="#000000",width:t=19,height:r=10,...o})=>t2(Y,{...o,width:t,height:r,children:[uu("rect",{opacity:"0.6",x:"0.553621",y:"0.876863",width:"16.4923",height:"7.87692",rx:"1.6",stroke:e,strokeWidth:"0.738462"}),uu("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),uu("path",{opacity:"0.6",d:"M17.9075 3.70703C18.4513 3.70703 18.8921 4.14786 18.8921 4.69165V4.9378C18.8921 5.48159 18.4513 5.92242 17.9075 5.92242V3.70703Z",fill:e})]}),"BatteryIcon");import{jsx as ef}from"react/jsx-runtime";var ya=a(({color:e="#DC2626",width:t=13,height:r=13,...o})=>ef(Y,{...o,fill:"none",width:t,height:r,children:ef("path",{d:"M4.89844 1.625C4.82812 1.625 4.78125 1.67188 4.73438 1.71875L4.28906 2.375H7.6875L7.24219 1.71875C7.21875 1.67188 7.14844 1.625 7.07812 1.625H4.89844ZM9.04688 2.375H9.35156H10.5H10.6875C10.9922 2.375 11.25 2.63281 11.25 2.9375C11.25 3.26562 10.9922 3.5 10.6875 3.5H10.4062L9.84375 11.1172C9.77344 11.9141 9.14062 12.5 8.34375 12.5H3.63281C2.83594 12.5 2.20312 11.9141 2.13281 11.1172L1.57031 3.5H1.3125C0.984375 3.5 0.75 3.26562 0.75 2.9375C0.75 2.63281 0.984375 2.375 1.3125 2.375H1.5H2.625H2.92969L3.79688 1.08594C4.03125 0.734375 4.45312 0.5 4.89844 0.5H7.07812C7.52344 0.5 7.94531 0.734375 8.17969 1.08594L9.04688 2.375ZM9.28125 3.5H2.69531L3.25781 11.0469C3.28125 11.2344 3.44531 11.375 3.63281 11.375H8.34375C8.53125 11.375 8.69531 11.2344 8.71875 11.0469L9.28125 3.5Z",fill:e})}),"BinIcon");import{jsx as tf}from"react/jsx-runtime";var va=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>tf(Y,{...n,width:r,height:o,children:tf(Le,{active:t,colorProp:"stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",d:"M1 15V11C1 5.47715 5.47715 1 11 1H15"})}),"BorderRadiusIcon");import{jsx as du,jsxs as r2}from"react/jsx-runtime";var fo=a(({color:e="#A3A3A3",width:t=16,height:r=16,...o})=>r2(Y,{...o,width:t,height:r,children:[du("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),du("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),du("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");import{jsx as rf}from"react/jsx-runtime";var mu=a(({color:e,width:t=21,height:r=16,...o})=>rf(Y,{...o,width:t,height:r,children:rf("path",{d:"M2.5 1.5C2.21875 1.5 2 1.75 2 2V11C2 11.2812 2.21875 11.5 2.5 11.5H18.5C18.75 11.5 19 11.2812 19 11V2C19 1.75 18.75 1.5 18.5 1.5H2.5ZM0.5 2C0.5 0.90625 1.375 0 2.5 0H18.5C19.5938 0 20.5 0.90625 20.5 2V11C20.5 12.125 19.5938 13 18.5 13H2.5C1.375 13 0.5 12.125 0.5 11V2ZM4.25 14.5H16.75C17.1562 14.5 17.5 14.8438 17.5 15.25C17.5 15.6875 17.1562 16 16.75 16H4.25C3.8125 16 3.5 15.6875 3.5 15.25C3.5 14.8438 3.8125 14.5 4.25 14.5Z",fill:e})}),"DesktopIcon");import{jsx as of}from"react/jsx-runtime";var pu=a(({color:e="#171717",width:t=12,height:r=13,...o})=>of(Y,{...o,fill:"none",width:t,height:r,children:of("path",{d:"M1.5 11.375H6.75C6.9375 11.375 7.125 11.2109 7.125 11V9.5H8.25V11C8.25 11.8438 7.57031 12.5 6.75 12.5H1.5C0.65625 12.5 0 11.8438 0 11V5.75C0 4.92969 0.65625 4.25 1.5 4.25H3V5.375H1.5C1.28906 5.375 1.125 5.5625 1.125 5.75V11C1.125 11.2109 1.28906 11.375 1.5 11.375ZM5.25 7.625H10.5C10.6875 7.625 10.875 7.46094 10.875 7.25V2C10.875 1.8125 10.6875 1.625 10.5 1.625H5.25C5.03906 1.625 4.875 1.8125 4.875 2V7.25C4.875 7.46094 5.03906 7.625 5.25 7.625ZM3.75 7.25V2C3.75 1.17969 4.40625 0.5 5.25 0.5H10.5C11.3203 0.5 12 1.17969 12 2V7.25C12 8.09375 11.3203 8.75 10.5 8.75H5.25C4.40625 8.75 3.75 8.09375 3.75 7.25Z",fill:e})}),"DuplicateIcon");import{jsx as nf}from"react/jsx-runtime";var fu=a(({color:e="#404040",width:t=20,height:r=15,viewBox:o="0 0 20 15",...n})=>nf(Y,{...n,width:t,height:r,viewBox:o,children:nf("path",{d:"M1.875 0H18.125C19.1406 0 20 0.859375 20 1.875C20 2.5 19.6875 3.04688 19.2188 3.39844L10.7422 9.76562C10.2734 10.1172 9.6875 10.1172 9.21875 9.76562L0.742188 3.39844C0.273438 3.04688 0 2.5 0 1.875C0 0.859375 0.820312 0 1.875 0ZM0 4.375L8.47656 10.7812C9.375 11.4453 10.5859 11.4453 11.4844 10.7812L20 4.375V12.5C20 13.9062 18.8672 15 17.5 15H2.5C1.09375 15 0 13.9062 0 12.5V4.375Z",fill:e})}),"EmailIcon");import{jsx as af}from"react/jsx-runtime";var Ca=a(({color:e="#737373",width:t=16,height:r=16,...o})=>af(Y,{...o,width:t,height:r,children:af(Le,{d:"M10.25 1H14.25C14.6562 1 15 1.34375 15 1.75V5.75C15 6.1875 14.6562 6.5 14.25 6.5C13.8125 6.5 13.5 6.1875 13.5 5.75V3.5625L9.03125 8L13.5 12.4688V10.25C13.5 9.84375 13.8125 9.5 14.25 9.5C14.6562 9.5 15 9.84375 15 10.25V14.25C15 14.6875 14.6562 15 14.25 15H10.25C9.8125 15 9.5 14.6875 9.5 14.25C9.5 13.8438 9.8125 13.5 10.25 13.5H12.4375L8 9.0625L3.53125 13.5H5.75C6.15625 13.5 6.5 13.8438 6.5 14.25C6.5 14.6875 6.15625 15 5.75 15H1.75C1.3125 15 1 14.6875 1 14.25V10.25C1 9.84375 1.3125 9.5 1.75 9.5C2.15625 9.5 2.5 9.84375 2.5 10.25V12.4688L6.9375 8L2.5 3.5625V5.75C2.5 6.1875 2.15625 6.5 1.75 6.5C1.3125 6.5 1 6.1875 1 5.75V1.75C1 1.34375 1.3125 1 1.75 1H5.75C6.15625 1 6.5 1.34375 6.5 1.75C6.5 2.1875 6.15625 2.5 5.75 2.5H3.53125L8 6.96875L12.4375 2.5H10.25C9.8125 2.5 9.5 2.1875 9.5 1.75C9.5 1.34375 9.8125 1 10.25 1Z",fill:e})}),"ExpandIcon");import{jsx as sf}from"react/jsx-runtime";var fi=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>sf(Y,{...n,width:r,height:o,children:sf(Le,{d:"M16 8C16 12.0938 12.9062 15.4688 8.96875 15.9688V10.4688H11.125L11.5625 8H8.96875V7.15625C8.96875 5.84375 9.46875 5.34375 10.7812 5.34375C11.1875 5.34375 11.5 5.375 11.6875 5.375V3.1875C11.3438 3.0625 10.4688 2.96875 9.96875 2.96875C7.28125 2.96875 6.0625 4.25 6.0625 6.96875V8H4.40625V10.4688H6.0625V15.7812C2.5625 14.9062 0 11.75 0 8C0 3.59375 3.5625 0 8 0C12.4062 0 16 3.59375 16 8Z",active:t,fill:e})}),"FacebookIcon");import{jsx as lf}from"react/jsx-runtime";var gu=a(({color:e="#737373",width:t=14,height:r=16,...o})=>lf(Y,{...o,width:t,height:r,children:lf(Le,{d:"M0 2.75C0 2.34375 0.3125 2 0.75 2H13.25C13.6562 2 14 2.34375 14 2.75C14 3.1875 13.6562 3.5 13.25 3.5H0.75C0.3125 3.5 0 3.1875 0 2.75ZM2 7.75C2 7.34375 2.3125 7 2.75 7H11.25C11.6562 7 12 7.34375 12 7.75C12 8.1875 11.6562 8.5 11.25 8.5H2.75C2.3125 8.5 2 8.1875 2 7.75ZM9 12.75C9 13.1875 8.65625 13.5 8.25 13.5H5.75C5.3125 13.5 5 13.1875 5 12.75C5 12.3438 5.3125 12 5.75 12H8.25C8.65625 12 9 12.3438 9 12.75Z",fill:e})}),"HamburgerMenuIcon");import{jsx as cf}from"react/jsx-runtime";var xa=a(({color:e="#404040",width:t=24,height:r=24,...o})=>cf(Y,{...o,width:t,height:r,children:cf("path",{d:"M2 5.75C2 4.38281 3.09375 3.25 4.5 3.25H19.5C20.8672 3.25 22 4.38281 22 5.75V8.25V10.125V10.75V18.25C22 19.6562 20.8672 20.75 19.5 20.75H4.5C3.09375 20.75 2 19.6562 2 18.25V10.75V10.125V8.25V5.75ZM20.125 10.75H3.875V18.25C3.875 18.6016 4.14844 18.875 4.5 18.875H19.5C19.8125 18.875 20.125 18.6016 20.125 18.25V10.75ZM5.75 8.25C6.41406 8.25 7 7.70312 7 7C7 6.33594 6.41406 5.75 5.75 5.75C5.04688 5.75 4.5 6.33594 4.5 7C4.5 7.70312 5.04688 8.25 5.75 8.25ZM10.75 7C10.75 6.33594 10.1641 5.75 9.5 5.75C8.79688 5.75 8.25 6.33594 8.25 7C8.25 7.70312 8.79688 8.25 9.5 8.25C10.1641 8.25 10.75 7.70312 10.75 7ZM13.25 8.25C13.9141 8.25 14.5 7.70312 14.5 7C14.5 6.33594 13.9141 5.75 13.25 5.75C12.5469 5.75 12 6.33594 12 7C12 7.70312 12.5469 8.25 13.25 8.25Z",fill:e})}),"InboxIcon");import{jsx as uf}from"react/jsx-runtime";var gi=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>uf(Y,{...n,width:r,height:o,children:uf(Le,{d:"M8 4.40625C9.96875 4.40625 11.5938 6.03125 11.5938 8C11.5938 10 9.96875 11.5938 8 11.5938C6 11.5938 4.40625 10 4.40625 8C4.40625 6.03125 6 4.40625 8 4.40625ZM8 10.3438C9.28125 10.3438 10.3125 9.3125 10.3125 8C10.3125 6.71875 9.28125 5.6875 8 5.6875C6.6875 5.6875 5.65625 6.71875 5.65625 8C5.65625 9.3125 6.71875 10.3438 8 10.3438ZM12.5625 4.28125C12.5625 3.8125 12.1875 3.4375 11.7188 3.4375C11.25 3.4375 10.875 3.8125 10.875 4.28125C10.875 4.75 11.25 5.125 11.7188 5.125C12.1875 5.125 12.5625 4.75 12.5625 4.28125ZM14.9375 5.125C15 6.28125 15 9.75 14.9375 10.9062C14.875 12.0312 14.625 13 13.8125 13.8438C13 14.6562 12 14.9062 10.875 14.9688C9.71875 15.0312 6.25 15.0312 5.09375 14.9688C3.96875 14.9062 3 14.6562 2.15625 13.8438C1.34375 13 1.09375 12.0312 1.03125 10.9062C0.96875 9.75 0.96875 6.28125 1.03125 5.125C1.09375 4 1.34375 3 2.15625 2.1875C3 1.375 3.96875 1.125 5.09375 1.0625C6.25 1 9.71875 1 10.875 1.0625C12 1.125 13 1.375 13.8125 2.1875C14.625 3 14.875 4 14.9375 5.125ZM13.4375 12.125C13.8125 11.2188 13.7188 9.03125 13.7188 8C13.7188 7 13.8125 4.8125 13.4375 3.875C13.1875 3.28125 12.7188 2.78125 12.125 2.5625C11.1875 2.1875 9 2.28125 8 2.28125C6.96875 2.28125 4.78125 2.1875 3.875 2.5625C3.25 2.8125 2.78125 3.28125 2.53125 3.875C2.15625 4.8125 2.25 7 2.25 8C2.25 9.03125 2.15625 11.2188 2.53125 12.125C2.78125 12.75 3.25 13.2188 3.875 13.4688C4.78125 13.8438 6.96875 13.75 8 13.75C9 13.75 11.1875 13.8438 12.125 13.4688C12.7188 13.2188 13.2188 12.75 13.4375 12.125Z",active:t,fill:e})}),"InstagramIcon");import{jsx as df}from"react/jsx-runtime";var hi=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>df(Y,{...n,width:r,height:o,children:df(Le,{d:"M14 1C14.5312 1 15 1.46875 15 2.03125V14C15 14.5625 14.5312 15 14 15H1.96875C1.4375 15 1 14.5625 1 14V2.03125C1 1.46875 1.4375 1 1.96875 1H14ZM5.21875 13V6.34375H3.15625V13H5.21875ZM4.1875 5.40625C4.84375 5.40625 5.375 4.875 5.375 4.21875C5.375 3.5625 4.84375 3 4.1875 3C3.5 3 2.96875 3.5625 2.96875 4.21875C2.96875 4.875 3.5 5.40625 4.1875 5.40625ZM13 13V9.34375C13 7.5625 12.5938 6.15625 10.5 6.15625C9.5 6.15625 8.8125 6.71875 8.53125 7.25H8.5V6.34375H6.53125V13H8.59375V9.71875C8.59375 8.84375 8.75 8 9.84375 8C10.9062 8 10.9062 9 10.9062 9.75V13H13Z",active:t,fill:e})}),"LinkedinIcon");import{jsx as mf}from"react/jsx-runtime";var hu=a(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 256 239",...n})=>mf(Y,{...n,width:t,height:r,viewBox:o,children:mf("path",{d:"M244.688 89.3027C250.936 89.3028 256 94.367 256 100.614V160.846C256 183.806 237.387 202.419 214.427 202.419H214.23C207.916 202.42 201.932 201.009 196.571 198.491C186.31 221.332 163.63 237.486 136.931 238.14C107.972 237.431 83.7409 218.49 74.9551 192.558H120.063C130.509 192.558 138.977 184.09 138.977 173.645V89.3027H244.688ZM120.082 53.5811C120.127 53.5812 120.172 53.5842 120.217 53.585C125.988 53.6645 130.676 58.2209 130.962 63.9395C130.971 64.1173 130.976 64.2966 130.977 64.4766V173.646C130.976 179.672 126.09 184.558 120.063 184.558H10.9131C4.88618 184.558 9.07128e-05 179.672 0 173.646V64.4941C0 58.4673 4.88624 53.5811 10.9131 53.5811H120.082ZM36.7686 95.125H58.4873V154.541H72.3887V95.125H94.208V83.5986H36.7686V95.125ZM139.907 0C161.279 0.000200803 178.604 17.3254 178.604 38.6973C178.604 60.0693 161.279 77.3953 139.907 77.3955C139.596 77.3955 139.286 77.3901 138.977 77.3828V64.4941C138.976 54.0493 130.509 45.5811 120.063 45.5811H101.82C101.419 43.3471 101.209 41.0467 101.209 38.6973C101.209 17.3253 118.535 0 139.907 0ZM223.256 23.8145C238.052 23.8145 250.047 35.8085 250.047 50.6045C250.047 65.4005 238.052 77.3954 223.256 77.3955C208.46 77.3955 196.465 65.4006 196.465 50.6045C196.465 35.8085 208.46 23.8145 223.256 23.8145Z",fill:e})}),"MSTeamsIcon");import{jsx as pf}from"react/jsx-runtime";var bi=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>pf(Y,{...n,width:r,height:o,children:pf(Le,{d:"M5.625 2.34375C8.75 2.34375 11.2812 4.875 11.2812 8C11.2812 11.1562 8.75 13.6875 5.625 13.6875C2.5 13.6875 0 11.1562 0 8C0 4.875 2.5 2.34375 5.625 2.34375ZM14.625 2.65625C16.1875 2.65625 17.4688 5.0625 17.4688 8.03125C17.4688 10.9688 16.1875 13.375 14.625 13.375C13.0625 13.375 11.8125 10.9688 11.8125 8.03125C11.8125 5.0625 13.0625 2.65625 14.625 2.65625ZM19 3.21875C19.5312 3.21875 20 5.375 20 8C20 10.6562 19.5312 12.8125 19 12.8125C18.4375 12.8125 18 10.6562 18 8.03125C18 5.375 18.4375 3.21875 19 3.21875Z",active:t,fill:e})}),"MediumIcon");import{jsx as bu}from"react/jsx-runtime";var yu=a(({color:e,width:t=21,height:r=16,...o})=>bu(Y,{...o,width:t,height:r,children:bu("g",{transform:"translate(4, 0)",children:bu("path",{d:"M8.5 1.5V2C8.5 2.28125 8.25 2.5 8 2.5H5C4.71875 2.5 4.5 2.28125 4.5 2V1.5H3.5C2.9375 1.5 2.5 1.96875 2.5 2.5V13.5C2.5 14.0625 2.9375 14.5 3.5 14.5H9.5C10.0312 14.5 10.5 14.0625 10.5 13.5V2.5C10.5 1.96875 10.0312 1.5 9.5 1.5H8.5ZM1 2.5C1 1.125 2.09375 0 3.5 0H9.5C10.875 0 12 1.125 12 2.5V13.5C12 14.9062 10.875 16 9.5 16H3.5C2.09375 16 1 14.9062 1 13.5V2.5Z",fill:e})})}),"MobileIcon");import{jsx as ff}from"react/jsx-runtime";var vu=a(({color:e="#737373",width:t=14,height:r=16,...o})=>ff(Y,{...o,width:t,height:r,children:ff(Le,{d:"M13.5 8C13.5 8.5625 13.1875 9.03125 12.75 9.3125C12.2812 9.59375 11.6875 9.59375 11.25 9.3125C10.7812 9.03125 10.5 8.5625 10.5 8C10.5 7.46875 10.7812 7 11.25 6.71875C11.6875 6.4375 12.2812 6.4375 12.75 6.71875C13.1875 7 13.5 7.46875 13.5 8ZM8.5 8C8.5 8.5625 8.1875 9.03125 7.75 9.3125C7.28125 9.59375 6.6875 9.59375 6.25 9.3125C5.78125 9.03125 5.5 8.5625 5.5 8C5.5 7.46875 5.78125 7 6.25 6.71875C6.6875 6.4375 7.28125 6.4375 7.75 6.71875C8.1875 7 8.5 7.46875 8.5 8ZM2 9.5C1.4375 9.5 0.96875 9.21875 0.6875 8.75C0.40625 8.3125 0.40625 7.71875 0.6875 7.25C0.96875 6.8125 1.4375 6.5 2 6.5C2.53125 6.5 3 6.8125 3.28125 7.25C3.5625 7.71875 3.5625 8.3125 3.28125 8.75C3 9.21875 2.53125 9.5 2 9.5Z",fill:e})}),"MoreMenuIcon");import{jsx as gf}from"react/jsx-runtime";var Cn=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>gf(Y,{...n,width:r,height:o,children:gf(Le,{d:"M14.25 0C14.6562 0 15 0.34375 15 0.75V15.25C15 15.6875 14.6562 16 14.25 16C13.8125 16 13.5 15.6875 13.5 15.25V0.75C13.5 0.34375 13.8125 0 14.25 0ZM9.5 11.5V4.5H6.5V11.5H9.5ZM11 4.5V11.5C11 12.3438 10.3125 13 9.5 13H6.5C5.65625 13 5 12.3438 5 11.5V4.5C5 3.6875 5.65625 3 6.5 3H9.5C10.3125 3 11 3.6875 11 4.5ZM2.5 0.75V15.25C2.5 15.6875 2.15625 16 1.75 16C1.3125 16 1 15.6875 1 15.25V0.75C1 0.34375 1.3125 0 1.75 0C2.15625 0 2.5 0.34375 2.5 0.75Z",active:t,fill:e})}),"PaddingHorizontalIcon");import{jsx as hf}from"react/jsx-runtime";var go=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>hf(Y,{...n,width:r,height:o,children:hf(Le,{d:"M0 1.75C0 1.34375 0.3125 1 0.75 1H15.25C15.6562 1 16 1.34375 16 1.75C16 2.1875 15.6562 2.5 15.25 2.5H0.75C0.3125 2.5 0 2.1875 0 1.75ZM11.5 6.5H4.5V9.5H11.5V6.5ZM4.5 5H11.5C12.3125 5 13 5.6875 13 6.5V9.5C13 10.3438 12.3125 11 11.5 11H4.5C3.65625 11 3 10.3438 3 9.5V6.5C3 5.6875 3.65625 5 4.5 5ZM0.75 13.5H15.25C15.6562 13.5 16 13.8438 16 14.25C16 14.6875 15.6562 15 15.25 15H0.75C0.3125 15 0 14.6875 0 14.25C0 13.8438 0.3125 13.5 0.75 13.5Z",active:t,fill:e})}),"PaddingVerticalIcon");import{jsx as bf,jsxs as o2}from"react/jsx-runtime";var Cu=a(({width:e=20,height:t=21,viewBox:r="0 0 20 21",...o})=>o2(Y,{...o,width:e,height:t,viewBox:r,children:[bf("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"}),bf("circle",{cx:"2",cy:"2",r:"3",transform:"matrix(-1 0 0 1 17.75 2)",fill:"currentColor",stroke:"white",strokeWidth:"2"})]}),"PushIcon");import{jsx as yf}from"react/jsx-runtime";var xu=a(({color:e="#171717",width:t=16,height:r=13,...o})=>yf(Y,{...o,fill:"none",width:t,height:r,children:yf("path",{d:"M1.39062 0.640625L4.01562 2.67969L4.17969 1.97656C4.29688 1.55469 4.67188 1.25 5.09375 1.25H12.9453C13.5547 1.25 14 1.83594 13.8594 2.42188L13.6016 3.45312C13.5312 3.75781 13.2266 3.94531 12.9219 3.875C12.6172 3.80469 12.4297 3.5 12.5 3.19531L12.7109 2.375H9.78125L8.65625 6.33594L15.2656 11.5156C15.5234 11.7031 15.5703 12.0547 15.3594 12.2891C15.1719 12.5469 14.8203 12.5938 14.5859 12.3828L0.710938 1.50781C0.453125 1.32031 0.40625 0.96875 0.617188 0.734375C0.804688 0.476562 1.15625 0.429688 1.39062 0.640625ZM4.97656 3.42969L7.71875 5.58594L8.60938 2.375H5.23438L4.97656 3.42969ZM8 8.67969L7.4375 10.625H8.75C9.05469 10.625 9.3125 10.8828 9.3125 11.1875C9.3125 11.5156 9.05469 11.75 8.75 11.75H5C4.67188 11.75 4.4375 11.5156 4.4375 11.1875C4.4375 10.8828 4.67188 10.625 5 10.625H6.28906L6.3125 10.4844L7.03906 7.92969L8 8.67969Z",fill:e})}),"RemoveFormattingIcon");import{jsx as vf}from"react/jsx-runtime";var Tu=a(({color:e="#171717",width:t=11,height:r=12,...o})=>vf(Y,{...o,width:t,height:r,children:vf(Le,{d:"M10.75 2.75V10.25C10.75 10.6719 10.3984 11 10 11C9.57812 11 9.25 10.6719 9.25 10.25V2.75C9.25 2.35156 9.57812 2 10 2C10.3984 2 10.75 2.35156 10.75 2.75ZM7.51562 7.03906L4.51562 10.0391C4.23438 10.3438 3.74219 10.3438 3.46094 10.0391C3.15625 9.75781 3.15625 9.26562 3.46094 8.98438L5.17188 7.25H1C0.578125 7.25 0.25 6.92188 0.25 6.5C0.25 6.10156 0.578125 5.75 1 5.75H5.17188L3.46094 4.03906C3.15625 3.75781 3.15625 3.26562 3.46094 2.98438C3.74219 2.67969 4.23438 2.67969 4.51562 2.98438L7.51562 5.98438C7.82031 6.26562 7.82031 6.75781 7.51562 7.03906Z",fill:e})}),"RightToLineIcon");import{jsx as Cf}from"react/jsx-runtime";var Eu=a(({color:e="#404040",width:t=24,height:r=24,...o})=>Cf(Y,{...o,width:t,height:r,children:Cf("path",{d:"M6.80469 17.3125C7.3125 16.9219 7.97656 16.8438 8.5625 17.0391C9.57812 17.4297 10.75 17.625 12 17.625C16.8438 17.625 20.125 14.5 20.125 11.375C20.125 8.28906 16.8438 5.125 12 5.125C7.11719 5.125 3.875 8.28906 3.875 11.375C3.875 12.625 4.34375 13.8359 5.24219 14.8906C5.59375 15.2422 5.75 15.75 5.71094 16.2578C5.67188 16.9609 5.47656 17.625 5.28125 18.2109C5.94531 17.8984 6.49219 17.5469 6.80469 17.3125ZM2.82031 18.875C2.89844 18.7969 2.9375 18.6797 3.01562 18.5625C3.40625 17.9375 3.75781 17.0781 3.83594 16.1016C2.66406 14.7734 2 13.1719 2 11.375C2 6.92188 6.45312 3.25 12 3.25C17.5078 3.25 22 6.92188 22 11.375C22 15.8672 17.5078 19.5 12 19.5C10.5156 19.5 9.14844 19.2656 7.89844 18.8359C7.46875 19.1484 6.6875 19.6172 5.78906 20.0078C5.20312 20.2812 4.53906 20.5156 3.83594 20.6328C3.79688 20.6328 3.75781 20.6719 3.75781 20.6719C3.5625 20.7109 3.40625 20.7109 3.21094 20.75C3.01562 20.75 2.82031 20.7891 2.58594 20.7891C2.35156 20.7891 2.11719 20.6328 2.03906 20.3984C1.92188 20.1641 2 19.8906 2.15625 19.6953C2.3125 19.5391 2.46875 19.3828 2.58594 19.1875C2.66406 19.0703 2.74219 18.9922 2.78125 18.9141V18.875H2.82031Z",fill:e})}),"SMSIcon");import{jsx as Ta,jsxs as n2}from"react/jsx-runtime";var xf=a(({color:e="#000000",width:t=14,height:r=9,...o})=>Ta(Y,{...o,width:t,height:r,children:n2("g",{opacity:"0.9",children:[Ta("rect",{x:"0.799805",y:"5.92188",width:"2.46154",height:"2.95385",rx:"0.246154",fill:e}),Ta("rect",{x:"4.24609",y:"4.44531",width:"2.46154",height:"4.43077",rx:"0.246154",fill:e}),Ta("rect",{x:"7.93823",y:"2.72266",width:"2.46154",height:"6.15385",rx:"0.246154",fill:e}),Ta("rect",{x:"11.3845",y:"0.753906",width:"2.46154",height:"8.12308",rx:"0.246154",fill:e})]})}),"SignalIcon");import{jsx as Tf}from"react/jsx-runtime";var wu=a(({color:e="#404040",width:t=16,height:r=16,...o})=>Tf(Y,{...o,width:t,height:r,children:Tf("path",{d:"M3.5 10C3.5 10.8281 2.8125 11.5 2 11.5C1.16406 11.5 0.5 10.8281 0.5 10C0.5 9.19531 1.16406 8.5 2 8.5H3.5V10ZM4.25 10C4.25 9.19531 4.91406 8.5 5.75 8.5C6.5625 8.5 7.25 9.19531 7.25 10V14C7.25 14.8281 6.5625 15.5 5.75 15.5C4.91406 15.5 4.25 14.8281 4.25 14V10ZM5.75 3.5C4.91406 3.5 4.25 2.83594 4.25 2C4.25 1.1875 4.91406 0.5 5.75 0.5C6.5625 0.5 7.25 1.1875 7.25 2V3.5H5.75ZM5.75 4.25C6.5625 4.25 7.25 4.91406 7.25 5.75C7.25 6.5625 6.5625 7.25 5.75 7.25H2C1.16406 7.25 0.5 6.5625 0.5 5.75C0.5 4.91406 1.16406 4.25 2 4.25H5.75ZM12.5 5.75C12.5 4.91406 13.1641 4.25 14 4.25C14.8125 4.25 15.5 4.91406 15.5 5.75C15.5 6.5625 14.8125 7.25 14 7.25H12.5V5.75ZM11.75 5.75C11.75 6.5625 11.0859 7.25 10.25 7.25C9.41406 7.25 8.75 6.5625 8.75 5.75V2C8.75 1.1875 9.41406 0.5 10.25 0.5C11.0859 0.5 11.75 1.1875 11.75 2V5.75ZM10.25 12.5C11.0859 12.5 11.75 13.1641 11.75 14C11.75 14.8125 11.0859 15.5 10.25 15.5C9.41406 15.5 8.75 14.8125 8.75 14V12.5H10.25ZM10.25 11.75C9.41406 11.75 8.75 11.0859 8.75 10.25C8.75 9.41406 9.41406 8.75 10.25 8.75H14C14.8125 8.75 15.5 9.41406 15.5 10.25C15.5 11.0859 14.8125 11.75 14 11.75H10.25Z",fill:e})}),"SlackIcon");import{jsx as Ef}from"react/jsx-runtime";var Ea=a(({color:e="#FFFFFF",width:t=24,height:r=24,...o})=>Ef(Y,{...o,width:t,height:r,viewBox:"0 0 24 24",children:Ef("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.9302 18.0041C16.7152 19.4687 17.3201 20.6536 17.6716 21.4225C22.7992 18.3395 24.5289 11.7034 21.525 6.5012C18.5211 1.29895 11.9084 -0.521541 6.67543 2.3769C7.30667 3.26444 8.32896 4.86524 9.56215 6.89518C10.4351 8.33194 11.4134 9.98401 12.4328 11.7503C13.7758 14.0761 14.9841 16.2422 15.9302 18.0041ZM4.20759 16.4985C2.25528 13.1182 1.73242 9.41428 2.51159 6.43383C0.579784 9.73503 0.426001 13.9501 2.47497 17.4989C4.52394 21.0476 8.25134 23.0233 12.0769 22.9999C9.1052 22.1856 6.1599 19.8803 4.20759 16.4985ZM1.6094 17.9983C4.92231 23.738 12.2599 25.7035 17.9997 22.3906C23.738 19.0777 25.7035 11.7401 22.3906 6.00031C19.0776 0.262019 11.74 -1.70347 6.00172 1.60945C0.261966 4.92236 -1.70352 12.26 1.6094 17.9983ZM11.1249 21.6085C12.4884 22.1914 13.8534 22.4228 15.1188 22.2896C12.7711 21.2717 9.91951 18.3937 7.66989 14.4994C5.42174 10.605 4.35551 6.69599 4.6499 4.15492C3.90002 5.18306 3.41817 6.48069 3.24096 7.95408C2.94364 10.4131 3.51483 13.2999 5.07317 15.9991C6.6315 18.6998 8.84597 20.636 11.1249 21.6085ZM16.913 21.6876C16.6889 21.6993 16.4238 21.67 16.1089 21.5836C15.4513 21.402 14.6604 20.9861 13.7875 20.3197C12.0461 18.9898 10.1436 16.7827 8.53694 13.9999C6.92881 11.2157 5.9695 8.46376 5.6883 6.29176C5.62971 5.83334 5.60188 5.41008 5.60188 5.02342C5.60188 4.49324 5.65461 4.03335 5.7542 3.65109C5.89334 3.11945 6.10278 2.78845 6.33565 2.59219C7.11481 4.29259 9.11545 8.00387 11.5672 12.2497C14.0189 16.4956 16.2319 20.0853 17.3157 21.61C17.2 21.651 17.0667 21.6788 16.913 21.6876Z",fill:e})}),"UnionIcon");import{jsx as wf}from"react/jsx-runtime";var wa=a(({color:e="#A3A3A3",width:t=24,height:r=24,...o})=>wf(Y,{...o,width:t,height:r,children:wf(Le,{d:"M12 12C10.2031 12 8.5625 11.0625 7.66406 9.5C6.76562 7.97656 6.76562 6.0625 7.66406 4.5C8.5625 2.97656 10.2031 2 12 2C13.7578 2 15.3984 2.97656 16.2969 4.5C17.1953 6.0625 17.1953 7.97656 16.2969 9.5C15.3984 11.0625 13.7578 12 12 12ZM10.2031 13.875H13.7578C17.625 13.875 20.75 17 20.75 20.8672C20.75 21.4922 20.2031 22 19.5781 22H4.38281C3.75781 22 3.25 21.4922 3.25 20.8672C3.25 17 6.33594 13.875 10.2031 13.875Z",fill:e})}),"UserIcon");import{jsx as kf}from"react/jsx-runtime";var Pf=a(({width:e=24,height:t=20,...r})=>kf(Y,{...r,width:e,height:t,viewBox:"0 0 24 20",children:kf("path",{d:"M6 1H5C4.46957 1 3.96086 1.21071 3.58579 1.58579C3.21071 1.96086 3 2.46957 3 3V8C3 8.53043 2.78929 9.03914 2.41421 9.41421C2.03914 9.78929 1.53043 10 1 10C1.53043 10 2.03914 10.2107 2.41421 10.5858C2.78929 10.9609 3 11.4696 3 12V17C3 18.1 3.9 19 5 19H6M18 19H19C19.5304 19 20.0391 18.7893 20.4142 18.4142C20.7893 18.0391 21 17.5304 21 17V12C21 10.9 21.9 10 23 10C22.4696 10 21.9609 9.78929 21.5858 9.41421C21.2107 9.03914 21 8.53043 21 8V3C21 2.46957 20.7893 1.96086 20.4142 1.58579C20.0391 1.21071 19.5304 1 19 1H18M10 16.5C10 16.7761 9.77614 17 9.5 17C9.22386 17 9 16.7761 9 16.5C9 16.2239 9.22386 16 9.5 16C9.77614 16 10 16.2239 10 16.5ZM15 16.5C15 16.7761 14.7761 17 14.5 17C14.2239 17 14 16.7761 14 16.5C14 16.2239 14.2239 16 14.5 16C14.7761 16 15 16.2239 15 16.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"VariableIcon");import{jsx as Ws,jsxs as i2}from"react/jsx-runtime";var Mf=a(({color:e="#000000",width:t=14,height:r=10,...o})=>Ws(Y,{...o,width:t,height:r,children:i2("g",{opacity:"0.9",children:[Ws("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}),Ws("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}),Ws("path",{d:"M8.80258 7.40452C8.35559 6.94626 7.73119 6.66172 7.04045 6.66172C6.34225 6.66172 5.71196 6.95239 5.264 7.41931L7.0259 9.18121L8.80258 7.40452Z",fill:e})]})}),"WiFiIcon");import{jsx as Nf}from"react/jsx-runtime";var yi=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Nf(Y,{...n,width:r,height:o,children:Nf(Le,{d:"M12.1562 1.5H14.3438L9.53125 7.03125L15.2188 14.5H10.7812L7.28125 9.96875L3.3125 14.5H1.09375L6.25 8.625L0.8125 1.5H5.375L8.5 5.65625L12.1562 1.5ZM11.375 13.1875H12.5938L4.71875 2.75H3.40625L11.375 13.1875Z",active:t,fill:e})}),"XIcon");import{NodeViewWrapper as gT}from"@tiptap/react";import{useSetAtom as hT}from"jotai";import{forwardRef as bT,useCallback as Zn,useEffect as sm,useState as bc,useRef as rn}from"react";import{v4 as yT}from"uuid";function $r(){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($r,"combine");function Af(e){if(Array.isArray(e))return e}a(Af,"_arrayWithHoles");function Sf(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(Sf,"_iterableToArrayLimit");function ka(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(ka,"_arrayLikeToArray");function _s(e,t){if(e){if(typeof e=="string")return ka(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)?ka(e,t):void 0}}a(_s,"_unsupportedIterableToArray");function If(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
183
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}a(If,"_nonIterableRest");function Us(e,t){return Af(e)||Sf(e,t)||_s(e,t)||If()}a(Us,"_slicedToArray");var gg=Ps(Pa());var zs="data-pdnd-honey-pot";function js(e){return e instanceof Element&&e.hasAttribute(zs)}a(js,"isHoneyPotElement");function qs(e){var t=document.elementsFromPoint(e.x,e.y),r=Us(t,2),o=r[0],n=r[1];return o?js(o)?n!=null?n:null:o:null}a(qs,"getElementFromPointWithoutHoneypot");function xn(e){"@babel/helpers - typeof";return xn=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},xn(e)}a(xn,"_typeof");function Bf(e,t){if(xn(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,t||"default");if(xn(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}a(Bf,"toPrimitive");function Df(e){var t=Bf(e,"string");return xn(t)=="symbol"?t:t+""}a(Df,"toPropertyKey");function ho(e,t,r){return(t=Df(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}a(ho,"_defineProperty");var Na=Ps(Pa());var Vf=2147483647;function Hf(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(Hf,"ownKeys");function Ff(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Hf(Object(r),!0).forEach(function(o){ho(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Hf(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(Ff,"_objectSpread");var Ma=2,Of=Ma/2;function m2(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}a(m2,"floorToClosestPixel");function p2(e){return{x:e.x-Of,y:e.y-Of}}a(p2,"pullBackByHalfHoneyPotSize");function f2(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}a(f2,"preventGoingBackwardsOffScreen");function g2(e){return{x:Math.min(e.x,window.innerWidth-Ma),y:Math.min(e.y,window.innerHeight-Ma)}}a(g2,"preventGoingForwardsOffScreen");function Wf(e){var t=e.client,r=g2(f2(p2(m2(t))));return DOMRect.fromRect({x:r.x,y:r.y,width:Ma,height:Ma})}a(Wf,"getHoneyPotRectFor");function _f(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(_f,"getRectStyles");function h2(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(h2,"isWithin");function b2(e){var t=e.initial,r=document.createElement("div");r.setAttribute(zs,"true");var o=Wf({client:t});Object.assign(r.style,Ff(Ff({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},_f({clientRect:o})),{},{pointerEvents:"auto",zIndex:Vf})),document.body.appendChild(r);var n=(0,Na.bind)(window,{type:"pointermove",listener:a(function(s){var l={x:s.clientX,y:s.clientY};o=Wf({client:l}),Object.assign(r.style,_f({clientRect:o}))},"listener"),options:{capture:!0}});return a(function(s){var l=s.current;if(n(),h2({client:l,clientRect:o})){r.remove();return}function c(){u(),r.remove()}a(c,"cleanup");var u=(0,Na.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(b2,"mountHoneyPot");function Uf(){var e=null;function t(){return e=null,(0,Na.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=b2({initial:u})}if(s==="onDrop"){var d,m=l.location.current.input;(d=o)===null||d===void 0||d({current:{x:m.clientX,y:m.clientY}}),o=null,e=null}},"onPostEvent")}return a(r,"getOnPostDispatch"),{bindEvents:t,getOnPostDispatch:r}}a(Uf,"makeHoneyPotFix");function $f(e){if(Array.isArray(e))return ka(e)}a($f,"_arrayWithoutHoles");function zf(e){if(typeof Symbol!="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}a(zf,"_iterableToArray");function jf(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
184
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}a(jf,"_nonIterableSpread");function Zs(e){return $f(e)||zf(e)||_s(e)||jf()}a(Zs,"_toConsumableArray");var eg=Ps(Pa());function cr(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(cr,"once");var qf=cr(a(function(){return navigator.userAgent.includes("Firefox")},"isFirefox"));var Aa=cr(a(function(){var t=navigator,r=t.userAgent;return r.includes("AppleWebKit")&&!r.includes("Chrome")},"isSafari"));var Zf=Ps(Pa());var Pu={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function Jf(e){var t=e.dragLeave;return Aa()?t.hasOwnProperty(Pu.isLeavingWindow):!1}a(Jf,"isLeavingWindowInSafari");a(function(){if(typeof window=="undefined"||!Aa())return;function t(){return{enterCount:0,isOverWindow:!1}}a(t,"getInitialState");var r=t();function o(){r=t()}a(o,"resetState"),(0,Zf.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[Pu.isEnteringWindow]=!0),r.isOverWindow=!0,r.enterCount++},"listener")},{type:"dragleave",listener:a(function(i){r.enterCount--,r.isOverWindow&&r.enterCount===0&&(i[Pu.isLeavingWindow]=!0,r.isOverWindow=!1)},"listener")}],{capture:!0})},"fixSafari")();function y2(e){return"nodeName"in e}a(y2,"isNodeLike");function Kf(e){return y2(e)&&e.ownerDocument!==document}a(Kf,"isFromAnotherWindow");function Gf(e){var t=e.dragLeave,r=t.type,o=t.relatedTarget;return r!=="dragleave"?!1:Aa()?Jf({dragLeave:t}):o==null?!0:qf()?Kf(o):o instanceof HTMLIFrameElement}a(Gf,"isLeavingWindow");function Xf(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(Xf,"getBindingsForBrokenDrags");function Tn(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(Tn,"getInput");var v2=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"),Yf=v2;var Mu=Yf(function(e){return e()}),Js=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 Qf(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}}),Js.schedule(function(){i({eventName:"onDragStart",payload:{source:t,location:d}})})},"start"),dragUpdate:a(function(c){var u=c.current;Js.flush(),Mu.cancel(),i({eventName:"onDropTargetChange",payload:{source:t,location:{initial:r,previous:n,current:u}}})},"dragUpdate"),drag:a(function(c){var u=c.current;Mu(function(){Js.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;Js.flush(),Mu.cancel(),i({eventName:"onDrop",payload:{source:d!=null?d:t,location:{current:u,previous:n,initial:r}}})},"drop")};return s}a(Qf,"makeDispatch");var Au={isActive:!1};function tg(){return!Au.isActive}a(tg,"canStart");function C2(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}a(C2,"getNativeSetDragImage");function x2(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(x2,"hasHierarchyChanged");function T2(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=e.dispatchEvent;if(!tg())return;var i=E2({event:t,dragType:r,getDropTargetsOver:o});Au.isActive=!0;var s={current:i};Nu({event:t,current:i.dropTargets});var l=Qf({source:r.payload,dispatchEvent:n,initial:i});function c(g){var v=x2({current:s.current.dropTargets,next:g.dropTargets});s.current=g,v&&l.dragUpdate({current:s.current})}a(c,"updateState");function u(g){var v=Tn(g),b=js(g.target)?qs({x:v.clientX,y:v.clientY}):g.target,y=o({target:b,input:v,source:r.payload,current:s.current.dropTargets});y.length&&(g.preventDefault(),Nu({event:g,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}),m()}a(d,"cancel");function m(){Au.isActive=!1,p()}a(m,"finish");var p=(0,eg.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){Gf({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:Tn(v)},!s.current.dropTargets.length){d();return}v.preventDefault(),Nu({event:v,current:s.current.dropTargets}),l.drop({current:s.current,updatedSourcePayload:r.type==="external"?r.getDropPayload(v):null}),m()},"listener")},{type:"dragend",listener:a(function(v){s.current={dropTargets:s.current.dropTargets,input:Tn(v)},d()},"listener")}].concat(Zs(Xf({onDragEnd:d}))),{capture:!0});l.start({nativeSetDragImage:C2(t)})}a(T2,"start");function Nu(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(Nu,"setDropEffectOnEvent");function E2(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=Tn(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(E2,"getStartLocation");var Su={canStart:tg,start:T2};var Iu=new Map;function w2(e){var t=e.typeKey,r=e.mount,o=Iu.get(t);if(o)return o.usageCount++,o;var n={typeKey:t,unmount:r(),usageCount:1};return Iu.set(t,n),n}a(w2,"registerUsage");function rg(e){var t=w2(e);return a(function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),Iu.delete(e.typeKey))},"unregister")}a(rg,"register");function Ks(e,t){var r=t.attribute,o=t.value;return e.setAttribute(r,o),function(){return e.removeAttribute(r)}}a(Ks,"addAttribute");function og(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(og,"ownKeys");function Fo(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?og(Object(r),!0).forEach(function(o){ho(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):og(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(Fo,"_objectSpread");function Lu(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=k2(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.
185
- 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(Lu,"_createForOfIteratorHelper");function k2(e,t){if(e){if(typeof e=="string")return ng(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)?ng(e,t):void 0}}a(k2,"_unsupportedIterableToArray");function ng(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(ng,"_arrayLikeToArray");function Ru(e){return e.slice(0).reverse()}a(Ru,"copyReverse");function ig(e){var t=e.typeKey,r=e.defaultDropEffect,o=new WeakMap,n="data-drop-target-for-".concat(t),i="[".concat(n,"]");function s(g){return o.set(g.element,g),function(){return o.delete(g.element)}}a(s,"addToRegistry");function l(g){if(0)var v;var b=$r(Ks(g.element,{attribute:n,value:"true"}),s(g));return cr(b)}a(l,"dropTargetForConsumers");function c(g){var v,b,y,C,x=g.source,h=g.target,f=g.input,E=g.result,T=E===void 0?[]:E;if(h==null)return T;if(!(h instanceof Element))return h instanceof Node?c({source:x,target:h.parentElement,input:f,result:T}):T;var w=h.closest(i);if(w==null)return T;var P=o.get(w);if(P==null)return T;var N={input:f,source:x,element:P.element};if(P.canDrop&&!P.canDrop(N))return c({source:x,target:P.element.parentElement,input:f,result:T});var k=(v=(b=P.getData)===null||b===void 0?void 0:b.call(P,N))!==null&&v!==void 0?v:{},S=(y=(C=P.getDropEffect)===null||C===void 0?void 0:C.call(P,N))!==null&&y!==void 0?y:r,B={data:k,element:P.element,dropEffect:S,isActiveDueToStickiness:!1};return c({source:x,target:P.element.parentElement,input:f,result:[].concat(Zs(T),[B])})}a(c,"getActualDropTargets");function u(g){var v=g.eventName,b=g.payload,y=Lu(b.location.current.dropTargets),C;try{for(y.s();!(C=y.n()).done;){var x,h=C.value,f=o.get(h.element),E=Fo(Fo({},b),{},{self:h});f==null||(x=f[v])===null||x===void 0||x.call(f,E)}}catch(T){y.e(T)}finally{y.f()}}a(u,"notifyCurrent");var d={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:a(function(v){var b=v.payload,y=new Set(b.location.current.dropTargets.map(function(_){return _.element})),C=new Set,x=Lu(b.location.previous.dropTargets),h;try{for(x.s();!(h=x.n()).done;){var f,E=h.value;C.add(E.element);var T=o.get(E.element),w=y.has(E.element),P=Fo(Fo({},b),{},{self:E});if(T==null||(f=T.onDropTargetChange)===null||f===void 0||f.call(T,P),!w){var N;T==null||(N=T.onDragLeave)===null||N===void 0||N.call(T,P)}}}catch(_){x.e(_)}finally{x.f()}var k=Lu(b.location.current.dropTargets),S;try{for(k.s();!(S=k.n()).done;){var B,M,I=S.value;if(!C.has(I.element)){var D=Fo(Fo({},b),{},{self:I}),V=o.get(I.element);V==null||(B=V.onDropTargetChange)===null||B===void 0||B.call(V,D),V==null||(M=V.onDragEnter)===null||M===void 0||M.call(V,D)}}}catch(_){k.e(_)}finally{k.f()}},"onDropTargetChange")};function m(g){d[g.eventName](g)}a(m,"dispatchEvent");function p(g){var v=g.source,b=g.target,y=g.input,C=g.current,x=c({source:v,target:b,input:y});if(x.length>=C.length)return x;for(var h=Ru(C),f=Ru(x),E=[],T=0;T<h.length;T++){var w,P=h[T],N=f[T];if(N!=null){E.push(N);continue}var k=E[T-1],S=h[T-1];if((k==null?void 0:k.element)!==(S==null?void 0:S.element))break;var B=o.get(P.element);if(!B)break;var M={input:y,source:v,element:B.element};if(B.canDrop&&!B.canDrop(M)||!((w=B.getIsSticky)!==null&&w!==void 0&&w.call(B,M)))break;E.push(Fo(Fo({},P),{},{isActiveDueToStickiness:!0}))}return Ru(E)}return a(p,"getIsOver"),{dropTargetForConsumers:l,getIsOver:p,dispatchEvent:m}}a(ig,"makeDropTarget");function P2(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=M2(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.
186
- 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(P2,"_createForOfIteratorHelper");function M2(e,t){if(e){if(typeof e=="string")return ag(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)?ag(e,t):void 0}}a(M2,"_unsupportedIterableToArray");function ag(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(ag,"_arrayLikeToArray");function sg(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(sg,"ownKeys");function N2(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?sg(Object(r),!0).forEach(function(o){ho(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sg(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(N2,"_objectSpread");function lg(){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=N2({},i);e.add(s),r(s);function l(){e.delete(s),t&&t.active.delete(s)}return a(l,"cleanup"),cr(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=P2(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 m=Array.from(t.active),p=0,g=m;p<g.length;p++){var v=g[p];if(t.active.has(v)){var b;(b=v[s])===null||b===void 0||b.call(v,l)}}s==="onDrop"&&(t.active.clear(),t=null)}}return a(n,"dispatchEvent"),{dispatchEvent:n,monitorForConsumers:o}}a(lg,"makeMonitor");function cg(e){var t=e.typeKey,r=e.mount,o=e.dispatchEventToSource,n=e.onPostDispatch,i=e.defaultDropEffect,s=lg(),l=ig({typeKey:t,defaultDropEffect:i});function c(m){o==null||o(m),l.dispatchEvent(m),s.dispatchEvent(m),n==null||n(m)}a(c,"dispatchEvent");function u(m){var p=m.event,g=m.dragType;Su.start({event:p,dragType:g,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}a(u,"start");function d(){function m(){var p={canStart:Su.canStart,start:u};return r(p)}return a(m,"mountAdapter"),rg({typeKey:t,mount:m})}return a(d,"registerUsage"),{registerUsage:d,dropTarget:l.dropTargetForConsumers,monitor:s.monitorForConsumers}}a(cg,"makeAdapter");var ug=cr(a(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")},"isAndroid")),dg="pdnd:android-fallback";var Bu="text/plain";var mg="text/uri-list";var pg="application/vnd.pdnd";var Gs=new WeakMap;function A2(e){return Gs.set(e.element,e),a(function(){Gs.delete(e.element)},"cleanup")}a(A2,"addToRegistry");var fg=Uf(),Du=cg({typeKey:"element",defaultDropEffect:"move",mount:a(function(t){return $r(fg.bindEvents(),(0,gg.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 m=Gs.get(d);if(m){var p=Tn(o),g={element:m.element,dragHandle:(n=m.dragHandle)!==null&&n!==void 0?n:null,input:p};if(m.canDrag&&!m.canDrag(g)){o.preventDefault();return}if(m.dragHandle){var v=qs({x:p.clientX,y:p.clientY});if(!m.dragHandle.contains(v)){o.preventDefault();return}}var b=(i=(s=m.getInitialDataForExternal)===null||s===void 0?void 0:s.call(m,g))!==null&&i!==void 0?i:null;if(b)for(var y=0,C=Object.entries(b);y<C.length;y++){var x=Us(C[y],2),h=x[0],f=x[1];o.dataTransfer.setData(h,f!=null?f:"")}ug()&&!o.dataTransfer.types.includes(Bu)&&!o.dataTransfer.types.includes(mg)&&o.dataTransfer.setData(Bu,dg),o.dataTransfer.setData(pg,"");var E={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,g))!==null&&c!==void 0?c:{}},T={type:"element",payload:E,startedFrom:"internal"};t.start({event:o,dragType:T})}}}},"listener")}))},"mount"),dispatchEventToSource:a(function(t){var r,o,n=t.eventName,i=t.payload;(r=Gs.get(i.source.element))===null||r===void 0||(o=r[n])===null||o===void 0||o.call(r,i)},"dispatchEventToSource"),onPostDispatch:fg.getOnPostDispatch()}),nr=Du.dropTarget,Vu=Du.monitor;function Sa(e){if(0)var t;var r=$r(Du.registerUsage(),A2(e),Ks(e.element,{attribute:"draggable",value:"true"}));return cr(r)}a(Sa,"draggable");function hg(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(hg,"ownKeys");function bg(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?hg(Object(r),!0).forEach(function(o){ho(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):hg(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(bg,"_objectSpread");var S2={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")},yg=Symbol("closestEdge");function vg(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(m){return{edge:m,value:S2[m](c,l)}}),d=(r=(o=u.sort(function(m,p){return m.value-p.value})[0])===null||o===void 0?void 0:o.edge)!==null&&r!==void 0?r:null;return bg(bg({},e),{},ho({},yg,d))}a(vg,"attachClosestEdge");function Ia(e){var t;return(t=e[yg])!==null&&t!==void 0?t:null}a(Ia,"extractClosestEdge");import{Color as cb}from"@tiptap/extension-color";import{Extension as I2}from"@tiptap/core";import{dropCursor as L2}from"@tiptap/pm/dropcursor";var Hu=I2.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[L2(this.options)]}});import{HardBreak as R2}from"@tiptap/extension-hard-break";var Xs=R2.extend({renderHTML(){return["span",{class:"hard-break-wrapper","data-hard-break":"true"},["br"],"\u200B"]},parseHTML(){return[{tag:'span[data-hard-break="true"]'},{tag:"br"}]}});import{Extension as B2}from"@tiptap/core";import{undo as D2,redo as V2,history as H2}from"@tiptap/pm/history";var F2=B2.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>D2(e,t),redo:()=>({state:e,dispatch:t})=>V2(e,t)}},addProseMirrorPlugins(){return[H2(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});import{Placeholder as ub}from"@tiptap/extension-placeholder";import{TextAlign as db}from"@tiptap/extension-text-align";import{Typography as mb}from"@tiptap/extension-typography";import{Underline as pb}from"@tiptap/extension-underline";import{StarterKit as fb}from"@tiptap/starter-kit";import{mergeAttributes as ev}from"@tiptap/core";import{Node as O2,mergeAttributes as W2,wrappingInputRule as _2}from"@tiptap/core";var U2=/^\s*>\s$/,Cg=O2.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",W2(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[_2({find:U2,type:this.type})]}});import{ReactNodeViewRenderer as tv}from"@tiptap/react";import{v4 as $2}from"uuid";function je(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-${$2()}`;r.setNodeMarkup(i,void 0,{...n.attrs,id:s}),o=!0}return!1}),o&&e.view.dispatch(r)}a(je,"generateNodeIds");import{NodeViewContent as q2,NodeViewWrapper as Z2}from"@tiptap/react";import{useSetAtom as J2,useAtomValue as K2}from"jotai";import{useCallback as G2,useEffect as X2,useRef as Y2}from"react";import{atom as ir}from"jotai";var Fu={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"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:"enabled"},variable:{state:"enabled"}},Ys=a((e,t=!1)=>{let r=["paragraph","heading","blockquote"].includes(e);if(r&&t)return{contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:e==="blockquote"?"hidden":"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{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"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:"hidden"},variable:{state:"enabled"}};switch(e){case"list":return{contentType:{state:"hidden"},bold:{state:t?"enabled":"hidden"},italic:{state:t?"enabled":"hidden"},underline:{state:t?"enabled":"hidden"},strike:{state:t?"enabled":"hidden"},alignLeft:{state:"enabled"},alignCenter:{state:"enabled"},alignRight:{state:"enabled"},alignJustify:{state:"enabled"},quote:{state:"hidden"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:t?"enabled":"hidden"},variable:{state:"enabled"}};case"button":return{bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"}};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"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"}}}},"getTextMenuConfigForNode");var z2={paragraph:Fu,heading:Fu},La=ir(z2),Ce=ir(null),Re=ir(null,(e,t,r)=>{t(Ce,r)}),j2=ir({ref:null,caretPosition:null}),Qs=ir({ref:null,caretPosition:null}),Ra=ir({isFocused:!1,hasVariables:!1,showVariablePopup:!1}),xg=ir(e=>(t,r=!1)=>{let o=e(La),n=e(Ra),i=Ys(t,r),s=o[t],l=i;return s&&Object.keys(s).forEach(c=>{var d,m;let u=c;u!=="conditionalRules"&&((d=i[u])==null?void 0:d.state)==="enabled"&&((m=s[u])==null?void 0:m.state)==="enabled"&&(l[u]=s[u])}),n.isFocused&&n.hasVariables&&(l={...l,variable:{state:"enabled"}}),l}),Tg=ir(null,(e,t,{nodeName:r,config:o})=>{let n=e(La);t(La,{...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"}]))}})}),yS=ir(null,(e,t,r)=>{let o=e(La),{[r]:n,...i}=o;t(La,i)}),Eg=ir(null,(e,t,{ref:r,caretPosition:o})=>{t(j2,{ref:r,caretPosition:o})}),vS=ir(null,(e,t,r)=>{let o=e(Ra);t(Ra,{...o,showVariablePopup:r})}),En=ir(null),Oo=ir(null,(e,t,r)=>{t(En,r)});import{jsx as wn}from"react/jsx-runtime";var Q2=a(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderLeftWidth:o,borderColor:n})=>wn("div",{className:"courier-w-full courier-my-2 node-element",children:wn("div",{style:{position:"relative",padding:`${t}px ${e}px`,backgroundColor:r,borderLeftWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",fontStyle:"italic",whiteSpace:"pre-wrap"},children:wn(q2,{})})}),"BlockquoteComponent"),wg=a(e=>{var l,c,u;let t=J2(Re),r=K2(Ce),o=Y2(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=G2(()=>{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]);X2(()=>{let d=o.current;if(!d)return;let m=a(p=>{let g=p.target;g.closest(".courier-actions-panel")||g.closest("[data-no-drag-preview]")||i()},"handleClick");return d.addEventListener("click",m,!0),()=>{d.removeEventListener("click",m,!0)}},[i]);let s=!e.node.content||e.node.content.size===0;return wn(Z2,{children:wn("div",{ref:o,children:wn(ft,{id:e.node.attrs.id,className:R(n&&"selected-element",s&&"is-empty"),editor:e.editor,children:wn(Q2,{...e.node.attrs})})})})},"BlockquoteComponentNode");var zr={paddingHorizontal:8,paddingVertical:0,backgroundColor:"transparent",borderLeftWidth:2,borderColor:"#e0e0e0"},Ou=Cg.extend({content:"block+",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){je(this.editor,this.name)},addAttributes(){return{id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},paddingHorizontal:{default:zr.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:zr.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:zr.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderLeftWidth:{default:zr.borderLeftWidth,parseHTML:e=>e.getAttribute("data-border-left-width"),renderHTML:e=>({"data-border-left-width":e.borderLeftWidth})},borderColor:{default:zr.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",ev(e,{"data-type":"blockquote","data-id":e.id}),0]},addKeyboardShortcuts(){return{"Mod-i":({editor:e})=>e.isActive("blockquote"),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 tv(wg)}});import{zodResolver as n0}from"@hookform/resolvers/zod";import{useForm as i0}from"react-hook-form";import{useCallback as rv,useEffect as ov,useRef as kg}from"react";var gt=a(({editor:e,element:t,form:r,nodeType:o})=>{let n=kg(null),i=kg(null);return ov(()=>{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,m])=>{r.getValues(d)!==m&&r.setValue(d,m)}))}},"updateCurrentNode");return l(),e.on("update",l),()=>{e.off("update",l)}},[e,t,r,o]),{updateNodeAttributes:rv(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)&&(pi(!0),e.chain().command(({tr:m,dispatch:p})=>{let g=m.doc.nodeAt(i.current);if((g==null?void 0:g.type.name)===o&&p){let v=l.listType;if(o==="list"&&v){let b=m.doc.resolve(i.current),y=[];for(let C=b.depth-1;C>=0;C--)b.node(C).type.name==="list"&&y.push(b.before(C));for(let C of y){let x=m.doc.nodeAt(C);if(x&&x.type.name==="list")try{m.setNodeMarkup(C,x.type,{...x.attrs,listType:v})}catch{}}}return m.setNodeMarkup(i.current,g.type,u),m.setMeta("addToHistory",!0),!0}return!1}).run(),requestAnimationFrame(()=>{pi(!1)}))},[e,o])}},"useNodeAttributes");import{useAtomValue as el,useSetAtom as av}from"jotai";import{useMemo as Ng,useCallback as Ag}from"react";import{atom as Pg}from"jotai";import{jsx as Ti}from"react/jsx-runtime";var kn=[{label:"Email",value:"email",icon:Ti(fu,{})},{label:"SMS",value:"sms",icon:Ti(Eu,{})},{label:"Push",value:"push",icon:Ti(Cu,{})},{label:"In-app",value:"inbox",icon:Ti(xa,{})},{label:"Slack",value:"slack",icon:Ti(wu,{})},{label:"Teams",value:"msteams",icon:Ti(hu,{})}];var Wo=Pg("email"),Ei=Pg("template");var _o=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,..._o(n,i)]:[...r,i]},[]),"getFlattenedVariables");var nv={link:["href","content"],img:["src","href","alt_text"],image:["src","href","alt_text"],action:["href","content"],meta:["title"],list:["imgSrc","imgHref"],quote:["content"],html:[]},iv=["content","href","src","title"],Mg=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&&pt(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=nv[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;iv.forEach(m=>{typeof d[m]=="string"&&o(d[m])}),d.elements&&Array.isArray(d.elements)&&d.elements.forEach(m=>{m&&n(m)}),d.raw&&typeof d.raw=="object"&&d.raw!==null&&Object.values(d.raw).forEach(m=>{typeof m=="string"&&o(m)})}})},"processNode");return e.forEach(i=>n(i)),Array.from(t).sort()},"extractVariablesFromContent");var nI=a(e=>{let t=el(Ae),r=el(de),o=el(Wo),n=el(gn),i=av(gn),s=e!=null?e:o,l=Ng(()=>{var p,g;if(!t)return[];let m=((g=(p=t.extensionManager.extensions.find(v=>v.name==="variableSuggestion"))==null?void 0:p.options)==null?void 0:g.variables)||{};return _o(m)},[t]),c=Ng(()=>{if(!r||!s)return[];let m=r.elements.find(p=>p.type==="channel"&&p.channel===s);return m?Mg(m.elements||[]):[]},[r,s]),u=Ag((m,p)=>{i(g=>({...g,[m]:p}))},[i]),d=Ag(()=>{i({})},[i]);return{availableVariables:l,usedVariables:c,variableValues:n,addVariableValue:u,clearAllVariableValues:d}},"useVariables");import{useAtom as xl,useAtomValue as o0}from"jotai";import{useCallback as Jr}from"react";import{v4 as t0}from"uuid";import{mergeAttributes as pv,Node as fv}from"@tiptap/core";import{ReactNodeViewRenderer as gv}from"@tiptap/react";import{v4 as hv}from"uuid";import{NodeViewContent as sv}from"@tiptap/react";import{useSetAtom as lv,useAtomValue as cv}from"jotai";import{useCallback as Wu,useEffect as Sg,useState as _u,useRef as uv}from"react";import{jsx as jr}from"react/jsx-runtime";var dv=a(({columnId:e,index:t,isPreviewMode:r})=>{let o=uv(null),[n,i]=_u(!1);return Sg(()=>{let s=o.current;if(s)return nr({element:s,getData:()=>({type:"column-cell",columnId:e,index:t,isEmpty:!0}),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e,t]),jr("div",{ref:o,"data-placeholder-cell":"true","data-column-cell":"true","data-column-id":e,"data-cell-index":t,onClick:s=>{s.stopPropagation()},className:R("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&&jr("span",{className:"courier-pointer-events-none",children:"Drag and drop content blocks"})})},"PlaceholderCell"),mv=a(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderWidth:o,borderRadius:n,borderColor:i,node:s,columnsCount:l,isPreviewMode:c=!1})=>{var p;let u=!s.content||s.content.size===0,d={borderWidth:`${o}px`,borderStyle:o>0?"solid":"none",borderColor:i,borderRadius:`${n}px`},m={padding:`${t}px ${e}px`,backgroundColor:r};if(u){let g=((p=s.attrs)==null?void 0:p.id)||"";return jr("div",{className:"courier-w-full node-element",style:m,children:jr("div",{className:"courier-w-full courier-flex courier-gap-2 courier-p-2",style:d,children:Array.from({length:l}).map((v,b)=>jr(dv,{columnId:g,index:b,isPreviewMode:c},b))})})}return jr("div",{className:"courier-w-full node-element",style:m,children:jr("div",{className:"courier-w-full courier-p-2",style:d,children:jr(sv,{})})})},"ColumnComponent"),Ig=a(e=>{let t=lv(Re),r=cv(qt),[o,n]=_u(!1),[i,s]=_u(e.editor.isEditable);Sg(()=>{let m=a(()=>{s(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=Wu(m=>{var E,T;if(!e.editor.isEditable)return;let p=m.target,g=m.currentTarget,v=p===g,b=p.classList.contains("node-element"),y=p.classList.contains("courier-p-2"),C=p.classList.contains("courier-gap-2"),x=p.classList.contains("draggable-item"),h=p.hasAttribute("data-drag-handle")||p.closest("[data-drag-handle]")!==null;if(v||b||y||C||x||h||((T=(E=p.closest("[data-node-view-content]"))==null?void 0:E.parentElement)==null?void 0:T.classList.contains("node-element"))){m.stopPropagation(),h||m.preventDefault();let w=ot(e);if(w){e.editor.commands.blur();let P=w.attrs.id;e.editor.state.doc.descendants(N=>N.type.name==="column"&&N.attrs.id===P?(t(N),!1):!0)}}},[e,t]),u=Wu(m=>{let p=m.target,g=m.currentTarget;if(!(p.closest("[data-column-cell]")!==null)){n(!0);return}let b=g.getBoundingClientRect(),y=m.clientY,C=30,x=y<=b.top+C||y>=b.bottom-C;n(x)},[]),d=Wu(()=>{n(!1)},[]);return jr(ft,{id:e.node.attrs.id,className:R(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:jr(mv,{...e.node.attrs,node:e.node,columnsCount:e.node.attrs.columnsCount||2,isPreviewMode:l})})},"ColumnComponentNode");var Pt={columnsCount:2,paddingHorizontal:0,paddingVertical:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"transparent",cells:[]},tl=fv.create({name:"column",group:"block",content:"columnRow?",isolating:!0,selectable:!1,onCreate(){je(this.editor,this.name)},addAttributes(){return{columnsCount:{default:Pt.columnsCount,parseHTML:e=>e.getAttribute("data-columns-count"),renderHTML:e=>({"data-columns-count":e.columnsCount})},paddingHorizontal:{default:Pt.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:Pt.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:Pt.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:Pt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:Pt.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:Pt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:()=>`node-${hv()}`,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",pv(this.options.HTMLAttributes,e,{"data-type":"column"}),0]},addNodeView(){return gv(Ig)},addCommands(){return{setColumn:e=>({chain:t})=>{let r=e.columnsCount||Pt.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"}}}});import{mergeAttributes as Cv,Node as xv}from"@tiptap/core";import{ReactNodeViewRenderer as Tv}from"@tiptap/react";import{v4 as Ev}from"uuid";import{useSetAtom as bv}from"jotai";import{useCallback as yv}from"react";import{jsx as rl}from"react/jsx-runtime";var vv=a(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return rl("div",{className:"courier-w-full node-element",children:rl("div",{className:"courier-custom-code courier-py-1.5",dangerouslySetInnerHTML:t?{__html:e}:{__html:"&#160;"}})})},"CustomCodeComponent"),Lg=a(e=>{let t=bv(Re),r=yv(()=>{if(!e.editor.isEditable)return;let i=ot(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 rl(ft,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element",n&&"is-empty"),onClick:r,editor:e.editor,"data-node-type":"customCode",children:rl(vv,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var bo={code:"<!-- Add your HTML code here -->"},ol=xv.create({name:"customCode",group:"block",atom:!0,selectable:!1,onCreate(){je(this.editor,this.name)},addAttributes(){return{code:{default:bo.code,parseHTML:e=>e.getAttribute("data-code")||"",renderHTML:e=>({"data-code":e.code})},id:{default:()=>`node-${Ev()}`,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",Cv(this.options.HTMLAttributes,e,{"data-type":"custom-code"}),["div",{innerHTML:e.code||bo.code}]]},addNodeView(){return Tv(Lg)},addCommands(){return{setCustomCode:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e}).run()}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"}}}});import{mergeAttributes as Lv}from"@tiptap/core";import{Node as wv,mergeAttributes as kv,isNodeSelection as Pv,nodeInputRule as Mv}from"@tiptap/core";import{TextSelection as Uu,NodeSelection as Nv}from"@tiptap/pm/state";var Rg=wv.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",kv(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}):Pv(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(Uu.create(s.doc,u.pos+1)):u.nodeAfter.isBlock?s.setSelection(Nv.create(s.doc,u.pos)):s.setSelection(Uu.create(s.doc,u.pos));else{let m=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();m&&(s.insert(d,m),s.setSelection(Uu.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Mv({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});import{ReactNodeViewRenderer as Rv}from"@tiptap/react";import{v4 as Bv}from"uuid";import{useSetAtom as Av}from"jotai";import{useCallback as Sv}from"react";import{jsx as nl}from"react/jsx-runtime";var Iv=a(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>nl("div",{className:"courier-w-full node-element courier-flex",children:nl("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=Av(Re),r=Sv(()=>{if(!e.editor.isEditable)return;let o=ot(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return nl(ft,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:nl(Iv,{...e.node.attrs})})},"DividerComponentNode");var ar={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},wi={padding:24,color:"transparent",size:1,radius:0,variant:"spacer"},$u=Rg.extend({name:"divider",atom:!0,onCreate(){je(this.editor,this.name)},addAttributes(){return{padding:{default:ar.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.margin})},size:{default:ar.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},color:{default:ar.color,parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color})},width:{default:ar.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},radius:{default:ar.radius,parseHTML:e=>e.getAttribute("data-radius"),renderHTML:e=>({"data-radius":e.radius})},variant:{default:ar.variant,parseHTML:e=>e.getAttribute("data-variant"),renderHTML:e=>({"data-variant":e.variant})},id:{default:()=>`node-${Bv()}`,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",Lv(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return Rv(Bg)},addInputRules(){return[]}});import{mergeAttributes as Ov,Node as Wv}from"@tiptap/core";import{ReactNodeViewRenderer as _v}from"@tiptap/react";import{useSetAtom as Dg}from"jotai";import{useCallback as Zr,useEffect as qu,useRef as Vg,useState as Hg}from"react";import{jsx as zu}from"react/jsx-runtime";var Pn=a(({className:e})=>zu("div",{className:R("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:zu("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:zu("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");import{Fragment as Fv,jsx as qr,jsxs as ju}from"react/jsx-runtime";var Dv=["image/png","image/jpeg","image/gif","image/webp"],Vv=a(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderColor:n,isUploading:i,width:s,imageNaturalWidth:l,onFileSelect:c,editor:u})=>{let[d,m]=Hg(!1),[p,g]=Hg(!0),v=Vg(null),b=Vg(null);qu(()=>{e&&g(!0)},[e]),qu(()=>{if(e&&!l&&u){let w=new Image;w.onload=()=>{try{if(!u.view||!u.state)return;let P=u.view.state.selection.from;u.chain().setNodeSelection(P).updateAttributes("imageBlock",{imageNaturalWidth:w.naturalWidth}).run()}catch{}},w.src=e}},[e,l,u]);let y=Zr(w=>Dv.includes(w),[]),C=Zr(w=>{w.preventDefault(),w.stopPropagation(),w.dataTransfer.types.includes("Files")&&Array.from(w.dataTransfer.items).some(k=>y(k.type))&&(m(!0),w.dataTransfer.dropEffect="copy")},[y]),x=Zr(w=>{w.preventDefault(),w.stopPropagation(),m(!1)},[]),h=Zr(w=>{w.preventDefault(),w.stopPropagation(),w.dataTransfer.types.includes("Files")&&Array.from(w.dataTransfer.items).some(k=>y(k.type))&&m(!0)},[y]),f=Zr(w=>{w.preventDefault(),w.stopPropagation(),m(!1);let N=Array.from(w.dataTransfer.files).find(k=>y(k.type));N&&c&&c(N)},[c,y]),E=Zr(w=>{var N;let P=(N=w.target.files)==null?void 0:N[0];P&&c&&c(P),w.target&&(w.target.value="")},[c]),T=Zr(()=>{var w;(w=v.current)==null||w.click()},[]);return Fs(e)?ju("div",{className:R("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:C,onDragEnter:h,onDragLeave:x,onDrop:f,style:{pointerEvents:"all"},children:[i?qr(Pn,{className:"courier-w-8 courier-h-8"}):ju(Fv,{children:[qr("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),qr("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:T,children:"Browse"})]}),qr("input",{ref:v,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:E})]}):qr("div",{className:"courier-w-full node-element",children:ju("div",{className:R("courier-relative courier-p-1",(i||p)&&"courier-w-full courier-aspect-[4/3] courier-bg-gray-100"),children:[(i||p)&&qr("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:qr(Pn,{className:"courier-w-8 courier-h-8"})}),qr("img",{ref:b,src:e,alt:t,className:R("courier-h-auto courier-inline-block courier-w-full",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[r],i&&"courier-opacity-50",(i||p)&&"courier-invisible"),style:{maxWidth:`${s}%`,borderWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",display:"block"},loading:"lazy",decoding:"async",draggable:!1,onLoad:w=>{if(g(!1),!l&&u)try{if(!u.view||!u.state)return;setTimeout(()=>{let P=u.view.state.selection.from;u.chain().setNodeSelection(P).updateAttributes("imageBlock",{imageNaturalWidth:w.target.naturalWidth}).run()},100)}catch(P){console.warn("Editor not ready for image update:",P)}},onError:()=>g(!1)})]})})},"ImageBlockComponent"),Hv=["image/png","image/jpeg","image/gif","image/webp"],Fg=a(e=>{let t=Dg(Re),r=Dg(ue),{uploadImage:o}=ba(),n=Zr(l=>{var m,p,g;let c=(g=(p=(m=e.editor)==null?void 0:m.view)==null?void 0:p.dom)==null?void 0:g.closest(".ProseMirror"),u=(c==null?void 0:c.clientWidth)||1e3,d=Math.min(100,l/u*100);return Math.round(d)},[e.editor]);qu(()=>{var c,u;let l=ot(e);if((c=l==null?void 0:l.attrs)!=null&&c.sourcePath&&!((u=l==null?void 0:l.attrs)!=null&&u.imageNaturalWidth)){let d=new Image;d.onload=()=>{let m=l.attrs.width||n(d.naturalWidth),p=Uo(e.getPos);p!==null&&e.editor.chain().focus().setNodeSelection(p).updateAttributes("imageBlock",{width:m,imageNaturalWidth:d.naturalWidth}).run()},d.src=l.attrs.sourcePath}},[e,n]);let i=Zr(()=>{if(!e.editor.isEditable)return;let l=ot(e);l&&(e.editor.commands.blur(),t(l))},[e,t]),s=Zr(async l=>{let c=Uo(e.getPos);ot(e)&&c!==null&&e.editor.chain().focus().setNodeSelection(c).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!Hv.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((b,y)=>{d.onload=b,d.onerror=y});let p=(await o({file:l})).url,g=Uo(e.getPos);if(ot(e)&&g!==null){let b=new Image;b.src=p,await new Promise((C,x)=>{b.onload=C,b.onerror=()=>x(new Error("Failed to load uploaded image"))});let y=n(b.naturalWidth);e.editor.chain().focus().setNodeSelection(g).updateAttributes("imageBlock",{sourcePath:p,isUploading:!1,width:y,imageNaturalWidth:b.naturalWidth}).run()}}catch(d){console.error("Error uploading image:",d);let m="Error uploading image";if(d instanceof Error){let v=d.message;v.includes("GraphQL error")?m="Server error: Could not process image":v.includes("network")||v.includes("fetch")?m="Network error: Could not upload image":m=v}r({message:m,toastProps:{duration:6e3,description:`File: ${l.name} (${(l.size/1024/1024).toFixed(2)}MB)`}});let p=Uo(e.getPos);ot(e)&&p!==null&&e.editor.chain().focus().setNodeSelection(p).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return qr(ft,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:qr(Vv,{...e.node.attrs,onFileSelect:s,editor:e.editor})})},"ImageBlockView");var st={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderColor:"transparent",isUploading:!1,imageNaturalWidth:0},il=Wv.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){je(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:st.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:st.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:st.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:st.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:st.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:st.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:st.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:st.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:st.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",Ov(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return _v(Fg)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...st,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...st,sourcePath:t||""}}).run(),setImageBlockAlign:e=>({commands:t})=>t.updateAttributes(this.name,{alignment:e}),setImageBlockWidth:e=>({commands:t})=>t.updateAttributes(this.name,{width:e}),uploadImage:e=>({chain:t})=>{let r=new FileReader;return r.onload=()=>{t().setImageBlock({sourcePath:r.result,isUploading:!0}).run()},r.readAsDataURL(e),!0}}}});import{z as yo}from"zod";var Og=yo.object({paddingVertical:yo.number(),paddingHorizontal:yo.number(),backgroundColor:yo.string(),borderWidth:yo.number(),borderColor:yo.string(),textAlign:yo.enum(["left","center","right","justify"]).default("left"),selected:yo.boolean().default(!1),id:yo.string().optional()}),xe={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderColor:"transparent",textAlign:"left",selected:!1};import{NodeViewContent as Uv,NodeViewWrapper as $v}from"@tiptap/react";import{useSetAtom as zv,useAtomValue as jv}from"jotai";import{useCallback as qv}from"react";import{jsx as $o}from"react/jsx-runtime";var Wg=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=jv(qt);return $o("div",{className:"courier-w-full node-element",children:$o("div",{style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderColor:i,borderStyle:n>0?"solid":"none"},children:$o("div",{style:{pointerEvents:u?"none":"auto"},children:$o(Uv,{as:c})})})})},"TextBlockComponent"),al=a(e=>{let t=zv(Re),r=qv(()=>{if(!e.editor.isEditable)return;let c=ot(e);c&&t(c)},[e,t]),o=!e.node.content||e.node.content.size===0,n=Uo(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null,s=(i==null?void 0:i.parent.type.name)==="blockquote",l=(i==null?void 0:i.parent.type.name)==="listItem";return s||l?$o($v,{children:$o(Wg,{...e.node.attrs,type:e.node.type.name})}):$o(ft,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:$o(Wg,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");import{zodResolver as Qv}from"@hookform/resolvers/zod";import{useForm as e0}from"react-hook-form";import{useSetAtom as Xv}from"jotai";import{jsx as _g,jsxs as Zv}from"react/jsx-runtime";var qe=a(({draggable:e=!1,icon:t,draggableLabel:r,label:o})=>Zv("div",{className:"courier-flex courier-flex-row courier-items-center courier-gap-2",children:[_g("div",{className:R("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}),_g("span",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:e?r:o})]}),"BlockBase");import{Quote as Jv}from"lucide-react";import{jsx as Ug}from"react/jsx-runtime";var sl=a(({draggable:e=!1})=>Ug(qe,{draggable:e,icon:Ug(Jv,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),draggableLabel:"Blockquote",label:"Blockquote block"}),"BlockquoteBlock");import{jsx as ll}from"react/jsx-runtime";var Zu=a(()=>ll("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:ll("path",{d:"M18 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V10C1.5 10.2812 1.71875 10.5 2 10.5H18C18.25 10.5 18.5 10.2812 18.5 10V2C18.5 1.75 18.25 1.5 18 1.5ZM2 0H18C19.0938 0 20 0.90625 20 2V10C20 11.125 19.0938 12 18 12H2C0.875 12 0 11.125 0 10V2C0 0.90625 0.875 0 2 0Z",fill:"currentColor"})}),"ButtonBlockIcon"),zo=a(({draggable:e=!1})=>ll(qe,{draggable:e,icon:ll(Zu,{}),draggableLabel:"Button",label:"Button block"}),"ButtonBlock");import{jsx as cl}from"react/jsx-runtime";var Ju=a(()=>cl("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:cl("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"),ul=a(({draggable:e=!1})=>cl(qe,{draggable:e,icon:cl(Ju,{}),draggableLabel:"Column layout",label:"Column layout"}),"ColumnBlock");import{jsx as dl}from"react/jsx-runtime";var Ku=a(()=>dl("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:dl("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"),ml=a(({draggable:e=!1})=>dl(qe,{draggable:e,icon:dl(Ku,{}),draggableLabel:"Custom code",label:"Custom code"}),"CustomCodeBlock");import{jsx as pl}from"react/jsx-runtime";var Gu=a(()=>pl("svg",{width:"16",height:"2",viewBox:"0 0 16 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:pl("path",{d:"M0 1C0 0.59375 0.3125 0.25 0.75 0.25H15.25C15.6562 0.25 16 0.59375 16 1C16 1.4375 15.6562 1.75 15.25 1.75H0.75C0.3125 1.75 0 1.4375 0 1Z",fill:"currentColor"})}),"DividerBlockIcon"),jo=a(({draggable:e=!1})=>pl(qe,{draggable:e,icon:pl(Gu,{}),draggableLabel:"Divider",label:"Divider block"}),"DividerBlock");import{jsx as fl}from"react/jsx-runtime";var Xu=a(()=>fl("svg",{width:"18",height:"13",viewBox:"0 0 18 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:fl("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"),gl=a(({draggable:e=!1})=>fl(qe,{draggable:e,icon:fl(Xu,{}),draggableLabel:"Heading",label:"Heading block"}),"HeadingBlock");import{jsx as hl}from"react/jsx-runtime";var Yu=a(()=>hl("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:hl("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"),bl=a(({draggable:e=!1})=>hl(qe,{draggable:e,icon:hl(Yu,{}),draggableLabel:"Image",label:"Image block"}),"ImageBlock");import{List as Kv}from"lucide-react";import{jsx as $g}from"react/jsx-runtime";var qo=a(({draggable:e=!1})=>$g(qe,{draggable:e,icon:$g(Kv,{strokeWidth:1.5,className:"courier-w-4 courier-h-4 courier-text-black dark:courier-text-white"}),draggableLabel:"List",label:"List block"}),"ListBlock");import{AlignVerticalSpaceAround as Gv}from"lucide-react";import{jsx as zg}from"react/jsx-runtime";var yl=a(({draggable:e=!1})=>zg(qe,{draggable:e,icon:zg(Gv,{className:"courier-w-4 courier-h-4"}),draggableLabel:"Spacer",label:"Spacer block"}),"SpacerBlock");import{jsx as vl}from"react/jsx-runtime";var Qu=a(()=>vl("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:vl("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"),Zo=a(({draggable:e=!1})=>vl(qe,{draggable:e,icon:vl(Qu,{}),draggableLabel:"Text",label:"Text block"}),"TextBlock");import{jsx as ur,jsxs as Yv}from"react/jsx-runtime";var ht=a(({type:e,hideCloseButton:t=!1})=>{let r=Xv(Re);return Yv("div",{className:"courier-flex courier-gap-4 courier-flex-col",children:[!t&&ur(Me,{className:"courier-w-fit",variant:"secondary",buttonSize:"small",onClick:()=>{r(null)},children:"Close"}),e==="heading"&&ur(gl,{}),e==="text"&&ur(Zo,{}),e==="image"&&ur(bl,{}),e==="spacer"&&ur(yl,{}),e==="divider"&&ur(jo,{}),e==="button"&&ur(zo,{}),e==="blockquote"&&ur(sl,{}),e==="customCode"&&ur(ml,{}),e==="column"&&ur(ul,{}),e==="list"&&ur(qo,{}),ur(pe,{className:"courier-m-0"})]})},"FormHeader");import{jsx as Se,jsxs as Jo}from"react/jsx-runtime";var jg=a(({element:e,editor:t,hideCloseButton:r=!1})=>{let o=e0({resolver:Qv(Og),defaultValues:{...xe,...e==null?void 0:e.attrs}}),{updateNodeAttributes:n}=gt({editor:t,element:e,form:o,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?Jo(He,{...o,children:[Se(ht,{type:"text",hideCloseButton:r}),Jo("form",{"data-sidebar-form":!0,onChange:()=>{n(o.getValues())},children:[Se("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),Jo("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[Se(te,{control:o.control,name:"paddingHorizontal",render:({field:i})=>Jo(Q,{children:[Se(ee,{children:Se(be,{startAdornment:Se(Cn,{}),type:"number",min:0,...i})}),Se(re,{})]})}),Se(te,{control:o.control,name:"paddingVertical",render:({field:i})=>Jo(Q,{children:[Se(ee,{children:Se(be,{startAdornment:Se(go,{}),type:"number",min:0,...i})}),Se(re,{})]})})]}),Se(te,{control:o.control,name:"backgroundColor",render:({field:i})=>Jo(Q,{className:"courier-mb-4",children:[Se(ee,{children:Se(bt,{...i,defaultValue:xe.backgroundColor,onChange:s=>{i.onChange(s),n({...o.getValues(),[i.name]:s})}})}),Se(re,{})]})}),Se(pe,{className:"courier-mb-4"}),Se("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),Se(te,{control:o.control,name:"borderWidth",render:({field:i})=>Jo(Q,{className:"courier-mb-3",children:[Se(ee,{children:Se(be,{startAdornment:Se(fo,{}),type:"number",min:0,...i})}),Se(re,{})]})}),Se(te,{control:o.control,name:"borderColor",render:({field:i})=>Jo(Q,{className:"courier-mb-4",children:[Se(ee,{children:Se(bt,{...i,defaultValue:xe.borderColor,onChange:s=>{i.onChange(s),n({...o.getValues(),[i.name]:s})}})}),Se(re,{})]})})]})]}):null},"TextBlockForm");var r0=a((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),Cl=a((e,t,r,o,n,i)=>{let s=`node-${t0()}`,c={heading:()=>e.schema.nodes.heading.create({...xe,...o,id:s},i),paragraph:()=>e.schema.nodes.paragraph.create({...xe,...o,id:s},i),text:()=>e.schema.nodes.paragraph.create({...xe,...o,id:s},i),spacer:()=>e.schema.nodes.divider.create({...wi,...o,id:s}),divider:()=>e.schema.nodes.divider.create({...ar,...o,id:s}),button:()=>e.schema.nodes.button.create({...Be,...o,id:s},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...st,...o,id:s}),image:()=>e.schema.nodes.imageBlock.create({...st,...o,id:s}),customCode:()=>e.schema.nodes.customCode.create({...bo,...o,id:s}),column:()=>e.schema.nodes.column.create({...Pt,...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 p=r0(e,s);p!==null&&e.commands.setTextSelection(p+1),e.view.focus()},50);let m=new CustomEvent("node-duplicated",{detail:{newNodeId:s}});document.dispatchEvent(m)}catch(u){console.error("Error creating node:",u)}else try{if(e.schema.nodes[t]){let u=e.state.tr,d=e.schema.nodes[t].create({...o,id:s},i);u.insert(r,d),e.view.dispatch(u),n&&n(d);let m=new CustomEvent("node-duplicated",{detail:{newNodeId:s}});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 s},"createOrDuplicateNode");var gB=a(()=>{let[e,t]=xl(Ur),[r,o]=xl(Is),[n,i]=xl(Ho),s=o0(Ae),l=xl(Ce)[1],c=Jr(x=>{l(x)},[l]),u=Jr(x=>{t(x)},[t]),d=Jr(()=>{t(Ss)},[t]),m=Jr((x,h)=>{o(f=>({...f,[x]:{...f[x],...h}}))},[o]),p=Jr(x=>r[x],[r]),g=Jr(x=>{o(h=>{let f={...h};return delete f[x],f})},[o]),v=Jr(x=>{i(h=>{let f=h.findIndex(E=>E.type===x.type&&E.key===x.key);if(f>=0){let E=[...h];return E[f]=x,E}return[...h,x]})},[i]),b=Jr((x,h)=>{i(f=>f.filter(E=>!(E.type===x&&E.key===h)))},[i]),y=Jr(x=>n.filter(h=>h.type===x),[n]),C=Jr((x,h)=>{if(!s){console.warn("[useBlockConfig] Cannot insert block: editor not available");return}let f={};x==="spacer"&&(f={...wi});let E=r[x];if(E&&(f={...f,...E}),h){let N=n.find(k=>k.type===x&&k.key===h);N?f={...f,...N.attributes}:console.warn(`[useBlockConfig] Preset "${h}" not found for type "${x}"`)}let T=s.state.doc.content.size,P={heading:"heading",text:"paragraph",image:"imageBlock",spacer:"divider",divider:"divider",button:"button",customCode:"customCode",column:"column",blockquote:"blockquote",list:"list"}[x];Cl(s,P,T,f,c)},[s,r,n,c]);return{visibleBlocks:e,setVisibleBlocks:u,resetVisibleBlocks:d,defaultVisibleBlocks:Ss,setDefaults:m,getDefaults:p,clearDefaults:g,registerPreset:v,unregisterPreset:b,presets:n,getPresetsForType:y,insertBlock:C}},"useBlockConfig");import{z as Mn}from"zod";var qg=Mn.object({paddingHorizontal:Mn.coerce.number().min(0),paddingVertical:Mn.coerce.number().min(0),backgroundColor:Mn.string(),borderLeftWidth:Mn.coerce.number().min(0),borderColor:Mn.string(),id:Mn.string().optional()});import{jsx as ki,jsxs as ed}from"react/jsx-runtime";var Zg=a(({element:e,editor:t,hideCloseButton:r=!1})=>{let o=i0({resolver:n0(qg),defaultValues:{...zr,...e==null?void 0:e.attrs}}),{updateNodeAttributes:n}=gt({editor:t,element:e,form:o,nodeType:(e==null?void 0:e.type.name)||"blockquote"});return e?ed(He,{...o,children:[ki(ht,{type:"blockquote",hideCloseButton:r}),ed("form",{"data-sidebar-form":!0,onChange:()=>{n(o.getValues())},children:[ki("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),ki(te,{control:o.control,name:"borderColor",render:({field:i})=>ed(Q,{className:"courier-mb-3",children:[ki(ee,{children:ki(bt,{...i,defaultValue:zr.borderColor,onChange:s=>{i.onChange(s),n({...o.getValues(),[i.name]:s})}})}),ki(re,{})]})})]})]}):null},"BlockquoteForm");import{z as sr}from"zod";var Tl=sr.object({label:sr.string(),link:sr.string().optional(),alignment:sr.enum(["left","center","right"]),backgroundColor:sr.string(),borderRadius:sr.number(),padding:sr.number(),fontWeight:sr.enum(["normal","bold"]),fontStyle:sr.enum(["normal","italic"]),isUnderline:sr.boolean(),isStrike:sr.boolean(),textColor:sr.string().optional(),borderColor:sr.string().optional()});import{zodResolver as zx}from"@hookform/resolvers/zod";import{useCallback as Th,useEffect as jx,useRef as Eh}from"react";import{useForm as qx}from"react-hook-form";import{Node as a0}from"@tiptap/core";var Pi=a0.create({name:"doc",topNode:!0,content:"block+"});import{Node as s0,mergeAttributes as l0}from"@tiptap/core";var Mi=s0.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",l0(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});import Rx from"@tiptap/extension-placeholder";import{Node as c0}from"@tiptap/core";var El=c0.create({name:"text",group:"inline"});import{EditorContent as Bx,useEditor as Dx}from"@tiptap/react";import*as On from"react";import{useCallback as Vx,useEffect as fh}from"react";import{Extension as Bd,InputRule as vC,Node as CC}from"@tiptap/core";import{ReactNodeViewRenderer as xC}from"@tiptap/react";import{Suggestion as TC}from"@tiptap/suggestion";import{Plugin as z1,PluginKey as j1,TextSelection as Ld}from"prosemirror-state";import{Decoration as EC,DecorationSet as Rd}from"prosemirror-view";import{ReactRenderer as pC}from"@tiptap/react";var Ze="top",lt="bottom",nt="right",Qe="left",wl="auto",Ko=[Ze,lt,nt,Qe],vo="start",Nn="end",Jg="clippingParents",kl="viewport",Ni="popper",Kg="reference",td=Ko.reduce(function(e,t){return e.concat([t+"-"+vo,t+"-"+Nn])},[]),Pl=[].concat(Ko,[wl]).reduce(function(e,t){return e.concat([t,t+"-"+vo,t+"-"+Nn])},[]),u0="beforeRead",d0="read",m0="afterRead",p0="beforeMain",f0="main",g0="afterMain",h0="beforeWrite",b0="write",y0="afterWrite",Gg=[u0,d0,m0,p0,f0,g0,h0,b0,y0];function yt(e){return e?(e.nodeName||"").toLowerCase():null}a(yt,"getNodeName");function Fe(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}a(Fe,"getWindow");function dr(e){var t=Fe(e).Element;return e instanceof t||e instanceof Element}a(dr,"isElement");function ct(e){var t=Fe(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}a(ct,"isHTMLElement");function Ai(e){if(typeof ShadowRoot=="undefined")return!1;var t=Fe(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}a(Ai,"isShadowRoot");function v0(e){var t=e.state;Object.keys(t.elements).forEach(function(r){var o=t.styles[r]||{},n=t.attributes[r]||{},i=t.elements[r];!ct(i)||!yt(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(v0,"applyStyles");function C0(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},{});!ct(n)||!yt(n)||(Object.assign(n.style,l),Object.keys(i).forEach(function(c){n.removeAttribute(c)}))})}}a(C0,"effect");var Ba={name:"applyStyles",enabled:!0,phase:"write",fn:v0,effect:C0,requires:["computeStyles"]};function vt(e){return e.split("-")[0]}a(vt,"getBasePlacement");var wr=Math.max,An=Math.min,Co=Math.round;function Si(){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(Si,"getUAString");function Da(){return!/^((?!chrome|android).)*safari/i.test(Si())}a(Da,"isLayoutViewport");function mr(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!1);var o=e.getBoundingClientRect(),n=1,i=1;t&&ct(e)&&(n=e.offsetWidth>0&&Co(o.width)/e.offsetWidth||1,i=e.offsetHeight>0&&Co(o.height)/e.offsetHeight||1);var s=dr(e)?Fe(e):window,l=s.visualViewport,c=!Da()&&r,u=(o.left+(c&&l?l.offsetLeft:0))/n,d=(o.top+(c&&l?l.offsetTop:0))/i,m=o.width/n,p=o.height/i;return{width:m,height:p,top:d,right:u+m,bottom:d+p,left:u,x:u,y:d}}a(mr,"getBoundingClientRect");function Sn(e){var t=mr(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(Sn,"getLayoutRect");function Va(e,t){var r=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(r&&Ai(r)){var o=t;do{if(o&&e.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}a(Va,"contains");function _t(e){return Fe(e).getComputedStyle(e)}a(_t,"getComputedStyle");function rd(e){return["table","td","th"].indexOf(yt(e))>=0}a(rd,"isTableElement");function Mt(e){return((dr(e)?e.ownerDocument:e.document)||window.document).documentElement}a(Mt,"getDocumentElement");function xo(e){return yt(e)==="html"?e:e.assignedSlot||e.parentNode||(Ai(e)?e.host:null)||Mt(e)}a(xo,"getParentNode");function Xg(e){return!ct(e)||_t(e).position==="fixed"?null:e.offsetParent}a(Xg,"getTrueOffsetParent");function x0(e){var t=/firefox/i.test(Si()),r=/Trident/i.test(Si());if(r&&ct(e)){var o=_t(e);if(o.position==="fixed")return null}var n=xo(e);for(Ai(n)&&(n=n.host);ct(n)&&["html","body"].indexOf(yt(n))<0;){var i=_t(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(x0,"getContainingBlock");function kr(e){for(var t=Fe(e),r=Xg(e);r&&rd(r)&&_t(r).position==="static";)r=Xg(r);return r&&(yt(r)==="html"||yt(r)==="body"&&_t(r).position==="static")?t:r||x0(e)||t}a(kr,"getOffsetParent");function In(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}a(In,"getMainAxisFromPlacement");function Ln(e,t,r){return wr(e,An(t,r))}a(Ln,"within");function Yg(e,t,r){var o=Ln(e,t,r);return o>r?r:o}a(Yg,"withinMaxClamp");function Ha(){return{top:0,right:0,bottom:0,left:0}}a(Ha,"getFreshSideObject");function Fa(e){return Object.assign({},Ha(),e)}a(Fa,"mergePaddingObject");function Oa(e,t){return t.reduce(function(r,o){return r[o]=e,r},{})}a(Oa,"expandToHashMap");var T0=a(function(t,r){return t=typeof t=="function"?t(Object.assign({},r.rects,{placement:r.placement})):t,Fa(typeof t!="number"?t:Oa(t,Ko))},"toPaddingObject");function E0(e){var t,r=e.state,o=e.name,n=e.options,i=r.elements.arrow,s=r.modifiersData.popperOffsets,l=vt(r.placement),c=In(l),u=[Qe,nt].indexOf(l)>=0,d=u?"height":"width";if(!(!i||!s)){var m=T0(n.padding,r),p=Sn(i),g=c==="y"?Ze:Qe,v=c==="y"?lt:nt,b=r.rects.reference[d]+r.rects.reference[c]-s[c]-r.rects.popper[d],y=s[c]-r.rects.reference[c],C=kr(i),x=C?c==="y"?C.clientHeight||0:C.clientWidth||0:0,h=b/2-y/2,f=m[g],E=x-p[d]-m[v],T=x/2-p[d]/2+h,w=Ln(f,T,E),P=c;r.modifiersData[o]=(t={},t[P]=w,t.centerOffset=w-T,t)}}a(E0,"arrow");function w0(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)||Va(t.elements.popper,n)&&(t.elements.arrow=n))}a(w0,"effect");var Qg={name:"arrow",enabled:!0,phase:"main",fn:E0,effect:w0,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function pr(e){return e.split("-")[1]}a(pr,"getVariation");var k0={top:"auto",right:"auto",bottom:"auto",left:"auto"};function P0(e,t){var r=e.x,o=e.y,n=t.devicePixelRatio||1;return{x:Co(r*n)/n||0,y:Co(o*n)/n||0}}a(P0,"roundOffsetsByDPR");function e1(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,m=e.isFixed,p=s.x,g=p===void 0?0:p,v=s.y,b=v===void 0?0:v,y=typeof d=="function"?d({x:g,y:b}):{x:g,y:b};g=y.x,b=y.y;var C=s.hasOwnProperty("x"),x=s.hasOwnProperty("y"),h=Qe,f=Ze,E=window;if(u){var T=kr(r),w="clientHeight",P="clientWidth";if(T===Fe(r)&&(T=Mt(r),_t(T).position!=="static"&&l==="absolute"&&(w="scrollHeight",P="scrollWidth")),T=T,n===Ze||(n===Qe||n===nt)&&i===Nn){f=lt;var N=m&&T===E&&E.visualViewport?E.visualViewport.height:T[w];b-=N-o.height,b*=c?1:-1}if(n===Qe||(n===Ze||n===lt)&&i===Nn){h=nt;var k=m&&T===E&&E.visualViewport?E.visualViewport.width:T[P];g-=k-o.width,g*=c?1:-1}}var S=Object.assign({position:l},u&&k0),B=d===!0?P0({x:g,y:b},Fe(r)):{x:g,y:b};if(g=B.x,b=B.y,c){var M;return Object.assign({},S,(M={},M[f]=x?"0":"",M[h]=C?"0":"",M.transform=(E.devicePixelRatio||1)<=1?"translate("+g+"px, "+b+"px)":"translate3d("+g+"px, "+b+"px, 0)",M))}return Object.assign({},S,(t={},t[f]=x?b+"px":"",t[h]=C?g+"px":"",t.transform="",t))}a(e1,"mapToStyles");function M0(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:vt(t.placement),variation:pr(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,e1(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,e1(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(M0,"computeStyles");var t1={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:M0,data:{}};var Ml={passive:!0};function N0(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=Fe(t.elements.popper),u=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&u.forEach(function(d){d.addEventListener("scroll",r.update,Ml)}),l&&c.addEventListener("resize",r.update,Ml),function(){i&&u.forEach(function(d){d.removeEventListener("scroll",r.update,Ml)}),l&&c.removeEventListener("resize",r.update,Ml)}}a(N0,"effect");var r1={name:"eventListeners",enabled:!0,phase:"write",fn:a(function(){},"fn"),effect:N0,data:{}};var A0={left:"right",right:"left",bottom:"top",top:"bottom"};function Ii(e){return e.replace(/left|right|bottom|top/g,function(t){return A0[t]})}a(Ii,"getOppositePlacement");var S0={start:"end",end:"start"};function Nl(e){return e.replace(/start|end/g,function(t){return S0[t]})}a(Nl,"getOppositeVariationPlacement");function Rn(e){var t=Fe(e),r=t.pageXOffset,o=t.pageYOffset;return{scrollLeft:r,scrollTop:o}}a(Rn,"getWindowScroll");function Bn(e){return mr(Mt(e)).left+Rn(e).scrollLeft}a(Bn,"getWindowScrollBarX");function od(e,t){var r=Fe(e),o=Mt(e),n=r.visualViewport,i=o.clientWidth,s=o.clientHeight,l=0,c=0;if(n){i=n.width,s=n.height;var u=Da();(u||!u&&t==="fixed")&&(l=n.offsetLeft,c=n.offsetTop)}return{width:i,height:s,x:l+Bn(e),y:c}}a(od,"getViewportRect");function nd(e){var t,r=Mt(e),o=Rn(e),n=(t=e.ownerDocument)==null?void 0:t.body,i=wr(r.scrollWidth,r.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),s=wr(r.scrollHeight,r.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),l=-o.scrollLeft+Bn(e),c=-o.scrollTop;return _t(n||r).direction==="rtl"&&(l+=wr(r.clientWidth,n?n.clientWidth:0)-i),{width:i,height:s,x:l,y:c}}a(nd,"getDocumentRect");function Dn(e){var t=_t(e),r=t.overflow,o=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(r+n+o)}a(Dn,"isScrollParent");function Al(e){return["html","body","#document"].indexOf(yt(e))>=0?e.ownerDocument.body:ct(e)&&Dn(e)?e:Al(xo(e))}a(Al,"getScrollParent");function Go(e,t){var r;t===void 0&&(t=[]);var o=Al(e),n=o===((r=e.ownerDocument)==null?void 0:r.body),i=Fe(o),s=n?[i].concat(i.visualViewport||[],Dn(o)?o:[]):o,l=t.concat(s);return n?l:l.concat(Go(xo(s)))}a(Go,"listScrollParents");function Li(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}a(Li,"rectToClientRect");function I0(e,t){var r=mr(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(I0,"getInnerBoundingClientRect");function o1(e,t,r){return t===kl?Li(od(e,r)):dr(t)?I0(t,r):Li(nd(Mt(e)))}a(o1,"getClientRectFromMixedType");function L0(e){var t=Go(xo(e)),r=["absolute","fixed"].indexOf(_t(e).position)>=0,o=r&&ct(e)?kr(e):e;return dr(o)?t.filter(function(n){return dr(n)&&Va(n,o)&&yt(n)!=="body"}):[]}a(L0,"getClippingParents");function id(e,t,r,o){var n=t==="clippingParents"?L0(e):[].concat(t),i=[].concat(n,[r]),s=i[0],l=i.reduce(function(c,u){var d=o1(e,u,o);return c.top=wr(d.top,c.top),c.right=An(d.right,c.right),c.bottom=An(d.bottom,c.bottom),c.left=wr(d.left,c.left),c},o1(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(id,"getClippingRect");function Wa(e){var t=e.reference,r=e.element,o=e.placement,n=o?vt(o):null,i=o?pr(o):null,s=t.x+t.width/2-r.width/2,l=t.y+t.height/2-r.height/2,c;switch(n){case Ze:c={x:s,y:t.y-r.height};break;case lt:c={x:s,y:t.y+t.height};break;case nt:c={x:t.x+t.width,y:l};break;case Qe:c={x:t.x-r.width,y:l};break;default:c={x:t.x,y:t.y}}var u=n?In(n):null;if(u!=null){var d=u==="y"?"height":"width";switch(i){case vo:c[u]=c[u]-(t[d]/2-r[d]/2);break;case Nn:c[u]=c[u]+(t[d]/2-r[d]/2);break;default:}}return c}a(Wa,"computeOffsets");function Pr(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?Jg:l,u=r.rootBoundary,d=u===void 0?kl:u,m=r.elementContext,p=m===void 0?Ni:m,g=r.altBoundary,v=g===void 0?!1:g,b=r.padding,y=b===void 0?0:b,C=Fa(typeof y!="number"?y:Oa(y,Ko)),x=p===Ni?Kg:Ni,h=e.rects.popper,f=e.elements[v?x:p],E=id(dr(f)?f:f.contextElement||Mt(e.elements.popper),c,d,s),T=mr(e.elements.reference),w=Wa({reference:T,element:h,strategy:"absolute",placement:n}),P=Li(Object.assign({},h,w)),N=p===Ni?P:T,k={top:E.top-N.top+C.top,bottom:N.bottom-E.bottom+C.bottom,left:E.left-N.left+C.left,right:N.right-E.right+C.right},S=e.modifiersData.offset;if(p===Ni&&S){var B=S[n];Object.keys(k).forEach(function(M){var I=[nt,lt].indexOf(M)>=0?1:-1,D=[Ze,lt].indexOf(M)>=0?"y":"x";k[M]+=B[D]*I})}return k}a(Pr,"detectOverflow");function ad(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?Pl:c,d=pr(o),m=d?l?td:td.filter(function(v){return pr(v)===d}):Ko,p=m.filter(function(v){return u.indexOf(v)>=0});p.length===0&&(p=m);var g=p.reduce(function(v,b){return v[b]=Pr(e,{placement:b,boundary:n,rootBoundary:i,padding:s})[vt(b)],v},{});return Object.keys(g).sort(function(v,b){return g[v]-g[b]})}a(ad,"computeAutoPlacement");function R0(e){if(vt(e)===wl)return[];var t=Ii(e);return[Nl(e),t,Nl(t)]}a(R0,"getExpandedFallbackPlacements");function B0(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,m=r.rootBoundary,p=r.altBoundary,g=r.flipVariations,v=g===void 0?!0:g,b=r.allowedAutoPlacements,y=t.options.placement,C=vt(y),x=C===y,h=c||(x||!v?[Ii(y)]:R0(y)),f=[y].concat(h).reduce(function(O,j){return O.concat(vt(j)===wl?ad(t,{placement:j,boundary:d,rootBoundary:m,padding:u,flipVariations:v,allowedAutoPlacements:b}):j)},[]),E=t.rects.reference,T=t.rects.popper,w=new Map,P=!0,N=f[0],k=0;k<f.length;k++){var S=f[k],B=vt(S),M=pr(S)===vo,I=[Ze,lt].indexOf(B)>=0,D=I?"width":"height",V=Pr(t,{placement:S,boundary:d,rootBoundary:m,altBoundary:p,padding:u}),_=I?M?nt:Qe:M?lt:Ze;E[D]>T[D]&&(_=Ii(_));var W=Ii(_),F=[];if(i&&F.push(V[B]<=0),l&&F.push(V[_]<=0,V[W]<=0),F.every(function(O){return O})){N=S,P=!1;break}w.set(S,F)}if(P)for(var L=v?3:1,$=a(function(j){var Z=f.find(function(U){var q=w.get(U);if(q)return q.slice(0,j).every(function(ne){return ne})});if(Z)return N=Z,"break"},"_loop"),A=L;A>0;A--){var H=$(A);if(H==="break")break}t.placement!==N&&(t.modifiersData[o]._skip=!0,t.placement=N,t.reset=!0)}}a(B0,"flip");var n1={name:"flip",enabled:!0,phase:"main",fn:B0,requiresIfExists:["offset"],data:{_skip:!1}};function i1(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(i1,"getSideOffsets");function a1(e){return[Ze,nt,lt,Qe].some(function(t){return e[t]>=0})}a(a1,"isAnySideFullyClipped");function D0(e){var t=e.state,r=e.name,o=t.rects.reference,n=t.rects.popper,i=t.modifiersData.preventOverflow,s=Pr(t,{elementContext:"reference"}),l=Pr(t,{altBoundary:!0}),c=i1(s,o),u=i1(l,n,i),d=a1(c),m=a1(u);t.modifiersData[r]={referenceClippingOffsets:c,popperEscapeOffsets:u,isReferenceHidden:d,hasPopperEscaped:m},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":m})}a(D0,"hide");var s1={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:D0};function V0(e,t,r){var o=vt(e),n=[Qe,Ze].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,[Qe,nt].indexOf(o)>=0?{x:l,y:s}:{x:s,y:l}}a(V0,"distanceAndSkiddingToXY");function H0(e){var t=e.state,r=e.options,o=e.name,n=r.offset,i=n===void 0?[0,0]:n,s=Pl.reduce(function(d,m){return d[m]=V0(m,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(H0,"offset");var l1={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:H0};function F0(e){var t=e.state,r=e.name;t.modifiersData[r]=Wa({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}a(F0,"popperOffsets");var c1={name:"popperOffsets",enabled:!0,phase:"read",fn:F0,data:{}};function sd(e){return e==="x"?"y":"x"}a(sd,"getAltAxis");function O0(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,m=r.padding,p=r.tether,g=p===void 0?!0:p,v=r.tetherOffset,b=v===void 0?0:v,y=Pr(t,{boundary:c,rootBoundary:u,padding:m,altBoundary:d}),C=vt(t.placement),x=pr(t.placement),h=!x,f=In(C),E=sd(f),T=t.modifiersData.popperOffsets,w=t.rects.reference,P=t.rects.popper,N=typeof b=="function"?b(Object.assign({},t.rects,{placement:t.placement})):b,k=typeof N=="number"?{mainAxis:N,altAxis:N}:Object.assign({mainAxis:0,altAxis:0},N),S=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,B={x:0,y:0};if(T){if(i){var M,I=f==="y"?Ze:Qe,D=f==="y"?lt:nt,V=f==="y"?"height":"width",_=T[f],W=_+y[I],F=_-y[D],L=g?-P[V]/2:0,$=x===vo?w[V]:P[V],A=x===vo?-P[V]:-w[V],H=t.elements.arrow,O=g&&H?Sn(H):{width:0,height:0},j=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:Ha(),Z=j[I],U=j[D],q=Ln(0,w[V],O[V]),ne=h?w[V]/2-L-q-Z-k.mainAxis:$-q-Z-k.mainAxis,X=h?-w[V]/2+L+q+U+k.mainAxis:A+q+U+k.mainAxis,le=t.elements.arrow&&kr(t.elements.arrow),ke=le?f==="y"?le.clientTop||0:le.clientLeft||0:0,we=(M=S==null?void 0:S[f])!=null?M:0,De=_+ne-we-ke,rt=_+X-we,Ve=Ln(g?An(W,De):W,_,g?wr(F,rt):F);T[f]=Ve,B[f]=Ve-_}if(l){var Je,Tt=f==="x"?Ze:Qe,ut=f==="x"?lt:nt,Ke=T[E],Ge=E==="y"?"height":"width",Et=Ke+y[Tt],me=Ke-y[ut],Pe=[Ze,Qe].indexOf(C)!==-1,K=(Je=S==null?void 0:S[E])!=null?Je:0,Xe=Pe?Et:Ke-w[Ge]-P[Ge]-K+k.altAxis,at=Pe?Ke+w[Ge]+P[Ge]-K-k.altAxis:me,Ft=g&&Pe?Yg(Xe,Ke,at):Ln(g?Xe:Et,Ke,g?at:me);T[E]=Ft,B[E]=Ft-Ke}t.modifiersData[o]=B}}a(O0,"preventOverflow");var u1={name:"preventOverflow",enabled:!0,phase:"main",fn:O0,requiresIfExists:["offset"]};function ld(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}a(ld,"getHTMLElementScroll");function cd(e){return e===Fe(e)||!ct(e)?Rn(e):ld(e)}a(cd,"getNodeScroll");function W0(e){var t=e.getBoundingClientRect(),r=Co(t.width)/e.offsetWidth||1,o=Co(t.height)/e.offsetHeight||1;return r!==1||o!==1}a(W0,"isElementScaled");function ud(e,t,r){r===void 0&&(r=!1);var o=ct(t),n=ct(t)&&W0(t),i=Mt(t),s=mr(e,n,r),l={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(o||!o&&!r)&&((yt(t)!=="body"||Dn(i))&&(l=cd(t)),ct(t)?(c=mr(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):i&&(c.x=Bn(i))),{x:s.left+l.scrollLeft-c.x,y:s.top+l.scrollTop-c.y,width:s.width,height:s.height}}a(ud,"getCompositeRect");function _0(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(_0,"order");function dd(e){var t=_0(e);return Gg.reduce(function(r,o){return r.concat(t.filter(function(n){return n.phase===o}))},[])}a(dd,"orderModifiers");function md(e){var t;return function(){return t||(t=new Promise(function(r){Promise.resolve().then(function(){t=void 0,r(e())})})),t}}a(md,"debounce");function pd(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(pd,"mergeByName");var d1={placement:"bottom",modifiers:[],strategy:"absolute"};function m1(){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(m1,"areValidElements");function p1(e){e===void 0&&(e={});var t=e,r=t.defaultModifiers,o=r===void 0?[]:r,n=t.defaultOptions,i=n===void 0?d1:n;return a(function(l,c,u){u===void 0&&(u=i);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},d1,i),modifiersData:{},elements:{reference:l,popper:c},attributes:{},styles:{}},m=[],p=!1,g={state:d,setOptions:a(function(C){var x=typeof C=="function"?C(d.options):C;b(),d.options=Object.assign({},i,d.options,x),d.scrollParents={reference:dr(l)?Go(l):l.contextElement?Go(l.contextElement):[],popper:Go(c)};var h=dd(pd([].concat(o,d.options.modifiers)));return d.orderedModifiers=h.filter(function(f){return f.enabled}),v(),g.update()},"setOptions"),forceUpdate:a(function(){if(!p){var C=d.elements,x=C.reference,h=C.popper;if(m1(x,h)){d.rects={reference:ud(x,kr(h),d.options.strategy==="fixed"),popper:Sn(h)},d.reset=!1,d.placement=d.options.placement,d.orderedModifiers.forEach(function(k){return d.modifiersData[k.name]=Object.assign({},k.data)});for(var f=0;f<d.orderedModifiers.length;f++){if(d.reset===!0){d.reset=!1,f=-1;continue}var E=d.orderedModifiers[f],T=E.fn,w=E.options,P=w===void 0?{}:w,N=E.name;typeof T=="function"&&(d=T({state:d,options:P,name:N,instance:g})||d)}}}},"forceUpdate"),update:md(function(){return new Promise(function(y){g.forceUpdate(),y(d)})}),destroy:a(function(){b(),p=!0},"destroy")};if(!m1(l,c))return g;g.setOptions(u).then(function(y){!p&&u.onFirstUpdate&&u.onFirstUpdate(y)});function v(){d.orderedModifiers.forEach(function(y){var C=y.name,x=y.options,h=x===void 0?{}:x,f=y.effect;if(typeof f=="function"){var E=f({state:d,name:C,instance:g,options:h}),T=a(function(){},"noopFn");m.push(E||T)}})}a(v,"runModifierEffects");function b(){m.forEach(function(y){return y()}),m=[]}return a(b,"cleanupModifierEffects"),g},"createPopper")}a(p1,"popperGenerator");var U0=[r1,c1,t1,Ba,l1,n1,u1,Qg,s1],fd=p1({defaultModifiers:U0});var $0="tippy-box",E1="tippy-content",z0="tippy-backdrop",w1="tippy-arrow",k1="tippy-svg-arrow",Vn={passive:!0,capture:!0},P1=a(function(){return document.body},"TIPPY_DEFAULT_APPEND_TO");function gd(e,t,r){if(Array.isArray(e)){var o=e[t];return o==null?Array.isArray(r)?r[t]:r:o}return e}a(gd,"getValueAtIndexOrReturn");function xd(e,t){var r={}.toString.call(e);return r.indexOf("[object")===0&&r.indexOf(t+"]")>-1}a(xd,"isType");function M1(e,t){return typeof e=="function"?e.apply(void 0,t):e}a(M1,"invokeWithArgsOrReturn");function f1(e,t){if(t===0)return e;var r;return function(o){clearTimeout(r),r=setTimeout(function(){e(o)},t)}}a(f1,"debounce");function j0(e){return e.split(/\s+/).filter(Boolean)}a(j0,"splitBySpaces");function Ri(e){return[].concat(e)}a(Ri,"normalizeToArray");function g1(e,t){e.indexOf(t)===-1&&e.push(t)}a(g1,"pushIfUnique");function q0(e){return e.filter(function(t,r){return e.indexOf(t)===r})}a(q0,"unique");function Z0(e){return e.split("-")[0]}a(Z0,"getBasePlacement");function Il(e){return[].slice.call(e)}a(Il,"arrayFrom");function h1(e){return Object.keys(e).reduce(function(t,r){return e[r]!==void 0&&(t[r]=e[r]),t},{})}a(h1,"removeUndefinedProps");function _a(){return document.createElement("div")}a(_a,"div");function Ll(e){return["Element","Fragment"].some(function(t){return xd(e,t)})}a(Ll,"isElement");function J0(e){return xd(e,"NodeList")}a(J0,"isNodeList");function K0(e){return xd(e,"MouseEvent")}a(K0,"isMouseEvent");function G0(e){return!!(e&&e._tippy&&e._tippy.reference===e)}a(G0,"isReferenceElement");function X0(e){return Ll(e)?[e]:J0(e)?Il(e):Array.isArray(e)?e:Il(document.querySelectorAll(e))}a(X0,"getArrayOfElements");function hd(e,t){e.forEach(function(r){r&&(r.style.transitionDuration=t+"ms")})}a(hd,"setTransitionDuration");function b1(e,t){e.forEach(function(r){r&&r.setAttribute("data-state",t)})}a(b1,"setVisibilityState");function Y0(e){var t,r=Ri(e),o=r[0];return o!=null&&(t=o.ownerDocument)!=null&&t.body?o.ownerDocument:document}a(Y0,"getOwnerDocument");function Q0(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=Z0(s.placement),d=s.modifiersData.offset;if(!d)return!0;var m=u==="bottom"?d.top.y:0,p=u==="top"?d.bottom.y:0,g=u==="right"?d.left.x:0,v=u==="left"?d.right.x:0,b=i.top-o+m>c,y=o-i.bottom-p>c,C=i.left-r+g>c,x=r-i.right-v>c;return b||y||C||x})}a(Q0,"isCursorOutsideInteractiveBorder");function bd(e,t,r){var o=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){e[o](n,r)})}a(bd,"updateTransitionEndListener");function y1(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(y1,"actualContains");var Kr={isTouch:!1},v1=0;function eC(){Kr.isTouch||(Kr.isTouch=!0,window.performance&&document.addEventListener("mousemove",N1))}a(eC,"onDocumentTouchStart");function N1(){var e=performance.now();e-v1<20&&(Kr.isTouch=!1,document.removeEventListener("mousemove",N1)),v1=e}a(N1,"onDocumentMouseMove");function tC(){var e=document.activeElement;if(G0(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}a(tC,"onWindowBlur");function rC(){document.addEventListener("touchstart",eC,Vn),window.addEventListener("blur",tC)}a(rC,"bindGlobalEventListeners");var oC=typeof window!="undefined"&&typeof document!="undefined",nC=oC?!!window.msCrypto:!1;var iC={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},aC={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Mr=Object.assign({appendTo:P1,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},iC,aC),sC=Object.keys(Mr),lC=a(function(t){var r=Object.keys(t);r.forEach(function(o){Mr[o]=t[o]})},"setDefaultProps");function A1(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=Mr[i])!=null?l:s}return o},{});return Object.assign({},e,r)}a(A1,"getExtendedPassedProps");function cC(e,t){var r=t?Object.keys(A1(Object.assign({},Mr,{plugins:t}))):sC,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(cC,"getDataAttributeProps");function C1(e,t){var r=Object.assign({},t,{content:M1(t.content,[e])},t.ignoreAttributes?{}:cC(e,t.plugins));return r.aria=Object.assign({},Mr.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(C1,"evaluateProps");var uC=a(function(){return"innerHTML"},"innerHTML");function vd(e,t){e[uC()]=t}a(vd,"dangerouslySetInnerHTML");function x1(e){var t=_a();return e===!0?t.className=w1:(t.className=k1,Ll(e)?t.appendChild(e):vd(t,e)),t}a(x1,"createArrowElement");function T1(e,t){Ll(t.content)?(vd(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?vd(e,t.content):e.textContent=t.content)}a(T1,"setContent");function Cd(e){var t=e.firstElementChild,r=Il(t.children);return{box:t,content:r.find(function(o){return o.classList.contains(E1)}),arrow:r.find(function(o){return o.classList.contains(w1)||o.classList.contains(k1)}),backdrop:r.find(function(o){return o.classList.contains(z0)})}}a(Cd,"getChildren");function S1(e){var t=_a(),r=_a();r.className=$0,r.setAttribute("data-state","hidden"),r.setAttribute("tabindex","-1");var o=_a();o.className=E1,o.setAttribute("data-state","hidden"),T1(o,e.props),t.appendChild(r),r.appendChild(o),n(e.props,e.props);function n(i,s){var l=Cd(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)&&T1(u,e.props),s.arrow?d?i.arrow!==s.arrow&&(c.removeChild(d),c.appendChild(x1(s.arrow))):c.appendChild(x1(s.arrow)):d&&c.removeChild(d)}return a(n,"onUpdate"),{popper:t,onUpdate:n}}a(S1,"render");S1.$$tippy=!0;var dC=1,Sl=[],yd=[];function mC(e,t){var r=C1(e,Object.assign({},Mr,A1(h1(t)))),o,n,i,s=!1,l=!1,c=!1,u=!1,d,m,p,g=[],v=f1(De,r.interactiveDebounce),b,y=dC++,C=null,x=q0(r.plugins),h={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},f={id:y,reference:e,popper:_a(),popperInstance:C,props:r,state:h,plugins:x,clearDelayTimeouts:Xe,setProps:at,setContent:Ft,show:Hr,hide:Fr,hideWithInteractivity:Or,enable:Pe,disable:K,unmount:dn,destroy:mn};if(!r.render)return f;var E=r.render(f),T=E.popper,w=E.onUpdate;T.setAttribute("data-tippy-root",""),T.id="tippy-"+f.id,f.popper=T,e._tippy=f,T._tippy=f;var P=x.map(function(z){return z.fn(f)}),N=e.hasAttribute("aria-expanded");return le(),L(),_(),W("onCreate",[f]),r.showOnCreate&&Et(),T.addEventListener("mouseenter",function(){f.props.interactive&&f.state.isVisible&&f.clearDelayTimeouts()}),T.addEventListener("mouseleave",function(){f.props.interactive&&f.props.trigger.indexOf("mouseenter")>=0&&I().addEventListener("mousemove",v)}),f;function k(){var z=f.props.touch;return Array.isArray(z)?z:[z,0]}a(k,"getNormalizedTouchSettings");function S(){return k()[0]==="hold"}a(S,"getIsCustomTouchBehavior");function B(){var z;return!!((z=f.props.render)!=null&&z.$$tippy)}a(B,"getIsDefaultRenderFn");function M(){return b||e}a(M,"getCurrentTarget");function I(){var z=M().parentNode;return z?Y0(z):document}a(I,"getDocument");function D(){return Cd(T)}a(D,"getDefaultTemplateChildren");function V(z){return f.state.isMounted&&!f.state.isVisible||Kr.isTouch||d&&d.type==="focus"?0:gd(f.props.delay,z?0:1,Mr.delay)}a(V,"getDelay");function _(z){z===void 0&&(z=!1),T.style.pointerEvents=f.props.interactive&&!z?"":"none",T.style.zIndex=""+f.props.zIndex}a(_,"handleStyles");function W(z,G,se){if(se===void 0&&(se=!0),P.forEach(function(J){J[z]&&J[z].apply(J,G)}),se){var Ee;(Ee=f.props)[z].apply(Ee,G)}}a(W,"invokeHook");function F(){var z=f.props.aria;if(z.content){var G="aria-"+z.content,se=T.id,Ee=Ri(f.props.triggerTarget||e);Ee.forEach(function(J){var ie=J.getAttribute(G);if(f.state.isVisible)J.setAttribute(G,ie?ie+" "+se:se);else{var ce=ie&&ie.replace(se,"").trim();ce?J.setAttribute(G,ce):J.removeAttribute(G)}})}}a(F,"handleAriaContentAttribute");function L(){if(!(N||!f.props.aria.expanded)){var z=Ri(f.props.triggerTarget||e);z.forEach(function(G){f.props.interactive?G.setAttribute("aria-expanded",f.state.isVisible&&G===M()?"true":"false"):G.removeAttribute("aria-expanded")})}}a(L,"handleAriaExpandedAttribute");function $(){I().removeEventListener("mousemove",v),Sl=Sl.filter(function(z){return z!==v})}a($,"cleanupInteractiveMouseListeners");function A(z){if(!(Kr.isTouch&&(c||z.type==="mousedown"))){var G=z.composedPath&&z.composedPath()[0]||z.target;if(!(f.props.interactive&&y1(T,G))){if(Ri(f.props.triggerTarget||e).some(function(se){return y1(se,G)})){if(Kr.isTouch||f.state.isVisible&&f.props.trigger.indexOf("click")>=0)return}else W("onClickOutside",[f,z]);f.props.hideOnClick===!0&&(f.clearDelayTimeouts(),f.hide(),l=!0,setTimeout(function(){l=!1}),f.state.isMounted||Z())}}}a(A,"onDocumentPress");function H(){c=!0}a(H,"onTouchMove");function O(){c=!1}a(O,"onTouchStart");function j(){var z=I();z.addEventListener("mousedown",A,!0),z.addEventListener("touchend",A,Vn),z.addEventListener("touchstart",O,Vn),z.addEventListener("touchmove",H,Vn)}a(j,"addDocumentPress");function Z(){var z=I();z.removeEventListener("mousedown",A,!0),z.removeEventListener("touchend",A,Vn),z.removeEventListener("touchstart",O,Vn),z.removeEventListener("touchmove",H,Vn)}a(Z,"removeDocumentPress");function U(z,G){ne(z,function(){!f.state.isVisible&&T.parentNode&&T.parentNode.contains(T)&&G()})}a(U,"onTransitionedOut");function q(z,G){ne(z,G)}a(q,"onTransitionedIn");function ne(z,G){var se=D().box;function Ee(J){J.target===se&&(bd(se,"remove",Ee),G())}if(a(Ee,"listener"),z===0)return G();bd(se,"remove",m),bd(se,"add",Ee),m=Ee}a(ne,"onTransitionEnd");function X(z,G,se){se===void 0&&(se=!1);var Ee=Ri(f.props.triggerTarget||e);Ee.forEach(function(J){J.addEventListener(z,G,se),g.push({node:J,eventType:z,handler:G,options:se})})}a(X,"on");function le(){S()&&(X("touchstart",we,{passive:!0}),X("touchend",rt,{passive:!0})),j0(f.props.trigger).forEach(function(z){if(z!=="manual")switch(X(z,we),z){case"mouseenter":X("mouseleave",rt);break;case"focus":X(nC?"focusout":"blur",Ve);break;case"focusin":X("focusout",Ve);break}})}a(le,"addListeners");function ke(){g.forEach(function(z){var G=z.node,se=z.eventType,Ee=z.handler,J=z.options;G.removeEventListener(se,Ee,J)}),g=[]}a(ke,"removeListeners");function we(z){var G,se=!1;if(!(!f.state.isEnabled||Je(z)||l)){var Ee=((G=d)==null?void 0:G.type)==="focus";d=z,b=z.currentTarget,L(),!f.state.isVisible&&K0(z)&&Sl.forEach(function(J){return J(z)}),z.type==="click"&&(f.props.trigger.indexOf("mouseenter")<0||s)&&f.props.hideOnClick!==!1&&f.state.isVisible?se=!0:Et(z),z.type==="click"&&(s=!se),se&&!Ee&&me(z)}}a(we,"onTrigger");function De(z){var G=z.target,se=M().contains(G)||T.contains(G);if(!(z.type==="mousemove"&&se)){var Ee=Ge().concat(T).map(function(J){var ie,ce=J._tippy,Ne=(ie=ce.popperInstance)==null?void 0:ie.state;return Ne?{popperRect:J.getBoundingClientRect(),popperState:Ne,props:r}:null}).filter(Boolean);Q0(Ee,z)&&($(),me(z))}}a(De,"onMouseMove");function rt(z){var G=Je(z)||f.props.trigger.indexOf("click")>=0&&s;if(!G){if(f.props.interactive){f.hideWithInteractivity(z);return}me(z)}}a(rt,"onMouseLeave");function Ve(z){f.props.trigger.indexOf("focusin")<0&&z.target!==M()||f.props.interactive&&z.relatedTarget&&T.contains(z.relatedTarget)||me(z)}a(Ve,"onBlurOrFocusOut");function Je(z){return Kr.isTouch?S()!==z.type.indexOf("touch")>=0:!1}a(Je,"isEventListenerStopped");function Tt(){ut();var z=f.props,G=z.popperOptions,se=z.placement,Ee=z.offset,J=z.getReferenceClientRect,ie=z.moveTransition,ce=B()?Cd(T).arrow:null,Ne=J?{getBoundingClientRect:J,contextElement:J.contextElement||M()}:e,Wr={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:a(function(Ie){var It=Ie.state;if(B()){var ai=D(),mo=ai.box;["placement","reference-hidden","escaped"].forEach(function(zt){zt==="placement"?mo.setAttribute("data-placement",It.placement):It.attributes.popper["data-popper-"+zt]?mo.setAttribute("data-"+zt,""):mo.removeAttribute("data-"+zt)}),It.attributes.popper={}}},"fn")},_e=[{name:"offset",options:{offset:Ee}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!ie}},Wr];B()&&ce&&_e.push({name:"arrow",options:{element:ce,padding:3}}),_e.push.apply(_e,(G==null?void 0:G.modifiers)||[]),f.popperInstance=fd(Ne,T,Object.assign({},G,{placement:se,onFirstUpdate:p,modifiers:_e}))}a(Tt,"createPopperInstance");function ut(){f.popperInstance&&(f.popperInstance.destroy(),f.popperInstance=null)}a(ut,"destroyPopperInstance");function Ke(){var z=f.props.appendTo,G,se=M();f.props.interactive&&z===P1||z==="parent"?G=se.parentNode:G=M1(z,[se]),G.contains(T)||G.appendChild(T),f.state.isMounted=!0,Tt()}a(Ke,"mount");function Ge(){return Il(T.querySelectorAll("[data-tippy-root]"))}a(Ge,"getNestedPopperTree");function Et(z){f.clearDelayTimeouts(),z&&W("onTrigger",[f,z]),j();var G=V(!0),se=k(),Ee=se[0],J=se[1];Kr.isTouch&&Ee==="hold"&&J&&(G=J),G?o=setTimeout(function(){f.show()},G):f.show()}a(Et,"scheduleShow");function me(z){if(f.clearDelayTimeouts(),W("onUntrigger",[f,z]),!f.state.isVisible){Z();return}if(!(f.props.trigger.indexOf("mouseenter")>=0&&f.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(z.type)>=0&&s)){var G=V(!1);G?n=setTimeout(function(){f.state.isVisible&&f.hide()},G):i=requestAnimationFrame(function(){f.hide()})}}a(me,"scheduleHide");function Pe(){f.state.isEnabled=!0}a(Pe,"enable");function K(){f.hide(),f.state.isEnabled=!1}a(K,"disable");function Xe(){clearTimeout(o),clearTimeout(n),cancelAnimationFrame(i)}a(Xe,"clearDelayTimeouts");function at(z){if(!f.state.isDestroyed){W("onBeforeUpdate",[f,z]),ke();var G=f.props,se=C1(e,Object.assign({},G,h1(z),{ignoreAttributes:!0}));f.props=se,le(),G.interactiveDebounce!==se.interactiveDebounce&&($(),v=f1(De,se.interactiveDebounce)),G.triggerTarget&&!se.triggerTarget?Ri(G.triggerTarget).forEach(function(Ee){Ee.removeAttribute("aria-expanded")}):se.triggerTarget&&e.removeAttribute("aria-expanded"),L(),_(),w&&w(G,se),f.popperInstance&&(Tt(),Ge().forEach(function(Ee){requestAnimationFrame(Ee._tippy.popperInstance.forceUpdate)})),W("onAfterUpdate",[f,z])}}a(at,"setProps");function Ft(z){f.setProps({content:z})}a(Ft,"setContent");function Hr(){var z=f.state.isVisible,G=f.state.isDestroyed,se=!f.state.isEnabled,Ee=Kr.isTouch&&!f.props.touch,J=gd(f.props.duration,0,Mr.duration);if(!(z||G||se||Ee)&&!M().hasAttribute("disabled")&&(W("onShow",[f],!1),f.props.onShow(f)!==!1)){if(f.state.isVisible=!0,B()&&(T.style.visibility="visible"),_(),j(),f.state.isMounted||(T.style.transition="none"),B()){var ie=D(),ce=ie.box,Ne=ie.content;hd([ce,Ne],0)}p=a(function(){var _e;if(!(!f.state.isVisible||u)){if(u=!0,T.offsetHeight,T.style.transition=f.props.moveTransition,B()&&f.props.animation){var ye=D(),Ie=ye.box,It=ye.content;hd([Ie,It],J),b1([Ie,It],"visible")}F(),L(),g1(yd,f),(_e=f.popperInstance)==null||_e.forceUpdate(),W("onMount",[f]),f.props.animation&&B()&&q(J,function(){f.state.isShown=!0,W("onShown",[f])})}},"onFirstUpdate"),Ke()}}a(Hr,"show");function Fr(){var z=!f.state.isVisible,G=f.state.isDestroyed,se=!f.state.isEnabled,Ee=gd(f.props.duration,1,Mr.duration);if(!(z||G||se)&&(W("onHide",[f],!1),f.props.onHide(f)!==!1)){if(f.state.isVisible=!1,f.state.isShown=!1,u=!1,s=!1,B()&&(T.style.visibility="hidden"),$(),Z(),_(!0),B()){var J=D(),ie=J.box,ce=J.content;f.props.animation&&(hd([ie,ce],Ee),b1([ie,ce],"hidden"))}F(),L(),f.props.animation?B()&&U(Ee,f.unmount):f.unmount()}}a(Fr,"hide");function Or(z){I().addEventListener("mousemove",v),g1(Sl,v),v(z)}a(Or,"hideWithInteractivity");function dn(){f.state.isVisible&&f.hide(),f.state.isMounted&&(ut(),Ge().forEach(function(z){z._tippy.unmount()}),T.parentNode&&T.parentNode.removeChild(T),yd=yd.filter(function(z){return z!==f}),f.state.isMounted=!1,W("onHidden",[f]))}a(dn,"unmount");function mn(){f.state.isDestroyed||(f.clearDelayTimeouts(),f.unmount(),ke(),delete e._tippy,f.state.isDestroyed=!0,W("onDestroy",[f]))}a(mn,"destroy")}a(mC,"createTippy");function Ua(e,t){t===void 0&&(t={});var r=Mr.plugins.concat(t.plugins||[]);rC();var o=Object.assign({},t,{plugins:r}),n=X0(e);if(0)var i,s;var l=n.reduce(function(c,u){var d=u&&mC(u,o);return d&&c.push(d),c},[]);return Ll(e)?l[0]:l}a(Ua,"tippy");Ua.defaultProps=Mr;Ua.setDefaultProps=lC;Ua.currentInput=Kr;var IO=Object.assign({},Ba,{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")});Ua.setDefaultProps({render:S1});var I1=Ua;import{jsx as L1}from"react/jsx-runtime";var R1=a(({items:e,command:t,selected:r=0})=>e.length===0?null:L1("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)=>L1("button",{className:R("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 Nr={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 _o(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=Nr.items)==null?void 0:c.call(Nr,{query:(e==null?void 0:e.props).query||"",editor:(e==null?void 0:e.props).editor}))[i];return l?((u=Nr.command)==null||u.call(Nr,{editor:r.editor,range:r.range,props:l}),!0):!1},"selectItem");return{onStart:i=>{r=i,e=new pC(R1,{props:{...i,selected:0},editor:i.editor}),i.clientRect&&(t=I1(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=Nr.items)==null?void 0:c.call(Nr,{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}}}};import{NodeViewWrapper as _1}from"@tiptap/react";import{useAtomValue as yC}from"jotai";import{useCallback as Sd,useEffect as Id,useState as U1}from"react";import{useAtomValue as Td}from"jotai";import{useCallback as Xo,useEffect as Rl,useMemo as Ed,useRef as F1,useState as wd}from"react";import{createPortal as fC}from"react-dom";import{toast as gC}from"sonner";import{useEffect as B1,useRef as D1}from"react";import{jsx as V1}from"react/jsx-runtime";var H1=a(({items:e,onSelect:t,selectedIndex:r,anchorRef:o})=>{let n=D1(null),i=D1(null);return B1(()=>{i.current&&i.current.scrollIntoView({block:"nearest"})},[r]),B1(()=>{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:V1("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)=>V1("button",{ref:l===r?i:void 0,className:R("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");import{Fragment as hC,jsx as Md,jsxs as O1}from"react/jsx-runtime";var kd=50,Pd=24,Bl=a(({variableId:e,isInvalid:t,onUpdateAttributes:r,onDelete:o,icon:n,value:i,singleClickToEdit:s=!1,className:l,textColorOverride:c,getColors:u,readOnly:d=!1})=>{var F;let[m,p]=wd(!1),[g,v]=wd(""),[b,y]=wd(0),C=F1(null),x=F1(null),h=Td(mi),f=Td(ui),E=Td(di),T=Ed(()=>E||!f||Object.keys(f).length===0?[]:_o(f),[f,E]),w=Ed(()=>T.length===0?[]:g?T.filter(L=>L.toLowerCase().includes(g.toLowerCase())):T,[T,g]),P=m&&w.length>0;Rl(()=>{d||e===""&&!m&&(p(!0),v(""),y(0))},[e,m,d]),Rl(()=>{!e||m||T.length>0&&!T.includes(e)&&(t||queueMicrotask(()=>{r({id:e,isInvalid:!0})}))},[e,T,t,m,r]),Rl(()=>{if(m&&C.current){let L=C.current;L.textContent=e,L.focus(),requestAnimationFrame(()=>{if(L&&L.isConnected){let $=document.createRange();$.selectNodeContents(L),$.collapse(!1);let A=window.getSelection();A==null||A.removeAllRanges(),A==null||A.addRange($)}})}},[m,e]);let N=Xo(()=>{var A,H;p(!1);let L=(((A=C.current)==null?void 0:A.textContent)||"").trim();if(L===""){o();return}let $=!0;if(h!=null&&h.overrideFormatValidation?h.validate&&($=h.validate(L)):($=pt(L),$&&(h!=null&&h.validate)&&($=h.validate(L))),$&&T.length>0&&($=T.includes(L)),!$){let O=(H=h==null?void 0:h.onInvalid)!=null?H:"mark";if(h!=null&&h.invalidMessage){let j=typeof h.invalidMessage=="function"?h.invalidMessage(L):h.invalidMessage;gC.error(j)}if(O==="remove"){o();return}r({id:L,isInvalid:!0});return}r({id:L,isInvalid:!1})},[o,r,h,T]),k=Xo(L=>{C.current&&(C.current.textContent=L),v(""),p(!1),r({id:L,isInvalid:!1})},[r]),S=Xo(L=>{var $,A;if(P){if(L.key==="ArrowDown"){L.preventDefault(),y(H=>(H+1)%w.length);return}if(L.key==="ArrowUp"){L.preventDefault(),y(H=>(H-1+w.length)%w.length);return}if(L.key==="Enter"){L.preventDefault();let H=w[b];H?k(H):($=C.current)==null||$.blur();return}if(L.key==="Tab"){L.preventDefault();let H=w[b];H&&k(H);return}}else if(L.key==="Enter"){L.preventDefault(),(A=C.current)==null||A.blur();return}L.key==="Escape"&&(L.preventDefault(),C.current&&(C.current.textContent=e),p(!1),v(""),e===""&&o())},[e,o,P,w,b,k]),B=Xo(()=>{if(C.current){let L=C.current.textContent||"";if(L.length>kd){L=L.slice(0,kd),C.current.textContent=L;let $=document.createRange();$.selectNodeContents(C.current),$.collapse(!1);let A=window.getSelection();A==null||A.removeAllRanges(),A==null||A.addRange($)}v(L),y(0)}},[]),M=Xo(L=>{L.preventDefault();let $=L.clipboardData.getData("text/plain").slice(0,kd),A=window.getSelection();if(A&&A.rangeCount>0){let H=A.getRangeAt(0);H.deleteContents();let O=document.createTextNode($);H.insertNode(O),H.setStartAfter(O),H.setEndAfter(O),A.removeAllRanges(),A.addRange(H),B()}},[B]),I=Xo(L=>{L.stopPropagation(),!d&&(m||p(!0))},[m,d]),D=Ed(()=>{let L=e,$=i?`="${i}"`:"",A=`${L}${$}`,H=L.length>Pd;return{displayText:`${H?`${L.slice(0,Pd)}\u2026`:L}${$}`,fullText:A,showTitle:H}},[e,i]);Rl(()=>{C.current&&!m&&(C.current.textContent=D.displayText)},[D.displayText,m]);let V=Xo(L=>{L.stopPropagation()},[]),_=Xo(L=>{L.stopPropagation()},[]),W=s?{onClick:I}:{onClick:_,onDoubleClick:I};return O1(hC,{children:[O1("span",{ref:x,className:R("courier-variable-chip",!t&&i&&"courier-variable-chip-has-value",t&&"courier-variable-chip-invalid",l),style:{direction:"ltr"},onMouseDown:V,...W,title:D.showTitle?D.fullText:void 0,children:[Md("span",{className:"courier-flex-shrink-0 courier-flex courier-items-center courier-pt-0.5",children:n}),Md("span",{ref:C,role:"textbox",contentEditable:m,suppressContentEditableWarning:!0,onBlur:N,onKeyDown:S,onInput:B,onPaste:M,onMouseDown:V,...s?{onClick:I}:{onClick:_,onDoubleClick:I},className:R("courier-outline-none courier-min-w-[1ch]",!m&&"courier-cursor-text"),style:{...c&&{color:c},maxWidth:`${Pd}ch`,overflow:"hidden",textOverflow:m?"clip":"ellipsis",whiteSpace:"nowrap",direction:"ltr",unicodeBidi:"isolate"},children:!m&&D.displayText})]}),P&&fC(Md(H1,{items:w,onSelect:k,selectedIndex:b,anchorRef:x}),((F=x.current)==null?void 0:F.closest(".theme-container"))||document.body)]})},"VariableChipBase");import{jsx as W1,jsxs as bC}from"react/jsx-runtime";var Dl=a(({color:e="#1D4ED8"})=>bC("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:[W1("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}),W1("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableIcon");function Bi(e,t="show-variables"){var r;return!e||!Ad(e.storage)?t:(r=e.storage.variable.variableViewMode)!=null?r:t}a(Bi,"getVariableViewMode");function Ut(e,t){if(!e)return!1;if(!Ad(e.storage)){if(typeof e.storage=="object"&&e.storage!==null){let r=e.storage;return r.variable={variableViewMode:t},!0}return!1}return e.storage.variable.variableViewMode=t,!0}a(Ut,"setVariableViewMode");function Nd(e="show-variables"){return{variableViewMode:e}}a(Nd,"initializeVariableStorage");function Ad(e){if(typeof e!="object"||e===null||!("variable"in e))return!1;let t=e;return typeof t.variable=="object"&&t.variable!==null}a(Ad,"hasVariableStorage");import{jsx as Vl}from"react/jsx-runtime";var $1=a(({node:e,editor:t,getPos:r,updateAttributes:o})=>{var C,x;let n=yC(gn),i=e.attrs.id||"",s=n[i],l=e.attrs.isInvalid,[c,u]=U1(!1),[d,m]=U1(()=>Bi(t));Id(()=>{let h=a(({transaction:f})=>{if(f.getMeta("variableViewModeChanged")){let E=Bi(t);m(E)}},"handleTransaction");return t.on("transaction",h),()=>{t.off("transaction",h)}},[t,i]),Id(()=>{let h=Bi(t);h&&m(h)},[(x=(C=t.storage)==null?void 0:C.variable)==null?void 0:x.variableViewMode]);let p=Sd(()=>{if(typeof r=="function")try{let h=r();if(h==null){u(!1);return}let E=t.state.doc.resolve(h).parent;u(E&&E.type.name==="button")}catch{u(!1)}else u(!1)},[t,r]);Id(()=>{p();let h=a(()=>{p()},"handleUpdate");return t.on("update",h),t.on("selectionUpdate",h),()=>{t.off("update",h),t.off("selectionUpdate",h)}},[t,p]);let g=Sd(h=>{o(h)},[o]),v=Sd(()=>{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]),y=a((h,f)=>h?"#DC2626":f?"#1E40AF":"#B45309","getIconColor")(l,!!s);return d==="wysiwyg"?Vl(_1,{as:"span",className:"courier-inline",contentEditable:!1,"data-variable-id":i,"data-wysiwyg":"true",children:s||""}):Vl(_1,{as:"span",className:"courier-inline courier-max-w-full",children:Vl(Bl,{variableId:i,isInvalid:l,value:s,onUpdateAttributes:g,onDelete:v,icon:Vl(Dl,{color:y}),className:R("courier-variable-node",c&&"courier-variable-in-button"),textColorOverride:c?"#000000":void 0,readOnly:!t.isEditable})})},"VariableView");var Dd=CC.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addStorage(){return Nd()},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 xC($1)},addProseMirrorPlugins(){return[new z1({key:new j1("variableCursorIndicator"),props:{decorations:e=>{let{selection:t}=e,{$from:r,empty:o}=t;if(!o)return Rd.empty;let n=r.nodeBefore,i=r.nodeAfter;if((n==null?void 0:n.type.name)==="hardBreak"&&(i==null?void 0:i.type.name)==="variable"){let s=EC.widget(r.pos,()=>{let l=document.createElement("span");return l.className="variable-cursor-indicator",l.setAttribute("data-cursor-indicator","true"),l.style.cssText=`
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 Na(){let[e]=Cf(Ut),[t]=Cf($t),r=uf();return{uploadImage:L2(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 vf(i,{apiUrl:e,token:t});if(!s)throw new Error("Upload failed: No URL returned from server");return{url:s}}},[e,t,r])}}a(Na,"useImageUpload");import{clsx as q4}from"clsx";import{twMerge as j4}from"tailwind-merge";import{v4 as qe}from"uuid";function vt(e){let t=e.trim();if(!t||t.startsWith(".")||t.endsWith(".")||t.includes("..")||t.includes(" "))return!1;let r=t.split("."),o=/^[a-zA-Z_][a-zA-Z0-9_]*$/;for(let n of r)if(!n||!o.test(n))return!1;return!0}a(vt,"isValidVariableName");var R2="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function Gs(e){return e?e===R2:!0}a(Gs,"isBlankImageSrc");var Xs=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");import{mergeAttributes as N4,Node as S4}from"@tiptap/core";import{ReactNodeViewRenderer as A4}from"@tiptap/react";import{Plugin as I4,PluginKey as L4}from"@tiptap/pm/state";import{NodeViewContent as T4}from"@tiptap/react";import{useSetAtom as E4}from"jotai";import{useCallback as w4,useEffect as k4,useState as P4}from"react";import{jsx as ku}from"react/jsx-runtime";var De=a(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?ku("path",{className:R(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):ku("path",{className:R(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),Q=a(({width:e=28,height:t=28,...r})=>ku("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");import{jsx as Pu,jsxs as B2}from"react/jsx-runtime";var xf=a(({color:e="#000000",width:t=19,height:r=10,...o})=>B2(Q,{...o,width:t,height:r,children:[Pu("rect",{opacity:"0.6",x:"0.553621",y:"0.876863",width:"16.4923",height:"7.87692",rx:"1.6",stroke:e,strokeWidth:"0.738462"}),Pu("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),Pu("path",{opacity:"0.6",d:"M17.9075 3.70703C18.4513 3.70703 18.8921 4.14786 18.8921 4.69165V4.9378C18.8921 5.48159 18.4513 5.92242 17.9075 5.92242V3.70703Z",fill:e})]}),"BatteryIcon");import{jsx as Tf}from"react/jsx-runtime";var Sa=a(({color:e="#DC2626",width:t=13,height:r=13,...o})=>Tf(Q,{...o,fill:"none",width:t,height:r,children:Tf("path",{d:"M4.89844 1.625C4.82812 1.625 4.78125 1.67188 4.73438 1.71875L4.28906 2.375H7.6875L7.24219 1.71875C7.21875 1.67188 7.14844 1.625 7.07812 1.625H4.89844ZM9.04688 2.375H9.35156H10.5H10.6875C10.9922 2.375 11.25 2.63281 11.25 2.9375C11.25 3.26562 10.9922 3.5 10.6875 3.5H10.4062L9.84375 11.1172C9.77344 11.9141 9.14062 12.5 8.34375 12.5H3.63281C2.83594 12.5 2.20312 11.9141 2.13281 11.1172L1.57031 3.5H1.3125C0.984375 3.5 0.75 3.26562 0.75 2.9375C0.75 2.63281 0.984375 2.375 1.3125 2.375H1.5H2.625H2.92969L3.79688 1.08594C4.03125 0.734375 4.45312 0.5 4.89844 0.5H7.07812C7.52344 0.5 7.94531 0.734375 8.17969 1.08594L9.04688 2.375ZM9.28125 3.5H2.69531L3.25781 11.0469C3.28125 11.2344 3.44531 11.375 3.63281 11.375H8.34375C8.53125 11.375 8.69531 11.2344 8.71875 11.0469L9.28125 3.5Z",fill:e})}),"BinIcon");import{jsx as Ef}from"react/jsx-runtime";var Aa=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Ef(Q,{...n,width:r,height:o,children:Ef(De,{active:t,colorProp:"stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",d:"M1 15V11C1 5.47715 5.47715 1 11 1H15"})}),"BorderRadiusIcon");import{jsx as Mu,jsxs as D2}from"react/jsx-runtime";var No=a(({color:e="#A3A3A3",width:t=16,height:r=16,...o})=>D2(Q,{...o,width:t,height:r,children:[Mu("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),Mu("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),Mu("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");import{jsx as wf}from"react/jsx-runtime";var Nu=a(({color:e,width:t=21,height:r=16,...o})=>wf(Q,{...o,width:t,height:r,children:wf("path",{d:"M2.5 1.5C2.21875 1.5 2 1.75 2 2V11C2 11.2812 2.21875 11.5 2.5 11.5H18.5C18.75 11.5 19 11.2812 19 11V2C19 1.75 18.75 1.5 18.5 1.5H2.5ZM0.5 2C0.5 0.90625 1.375 0 2.5 0H18.5C19.5938 0 20.5 0.90625 20.5 2V11C20.5 12.125 19.5938 13 18.5 13H2.5C1.375 13 0.5 12.125 0.5 11V2ZM4.25 14.5H16.75C17.1562 14.5 17.5 14.8438 17.5 15.25C17.5 15.6875 17.1562 16 16.75 16H4.25C3.8125 16 3.5 15.6875 3.5 15.25C3.5 14.8438 3.8125 14.5 4.25 14.5Z",fill:e})}),"DesktopIcon");import{jsx as kf}from"react/jsx-runtime";var Su=a(({color:e="#171717",width:t=12,height:r=13,...o})=>kf(Q,{...o,fill:"none",width:t,height:r,children:kf("path",{d:"M1.5 11.375H6.75C6.9375 11.375 7.125 11.2109 7.125 11V9.5H8.25V11C8.25 11.8438 7.57031 12.5 6.75 12.5H1.5C0.65625 12.5 0 11.8438 0 11V5.75C0 4.92969 0.65625 4.25 1.5 4.25H3V5.375H1.5C1.28906 5.375 1.125 5.5625 1.125 5.75V11C1.125 11.2109 1.28906 11.375 1.5 11.375ZM5.25 7.625H10.5C10.6875 7.625 10.875 7.46094 10.875 7.25V2C10.875 1.8125 10.6875 1.625 10.5 1.625H5.25C5.03906 1.625 4.875 1.8125 4.875 2V7.25C4.875 7.46094 5.03906 7.625 5.25 7.625ZM3.75 7.25V2C3.75 1.17969 4.40625 0.5 5.25 0.5H10.5C11.3203 0.5 12 1.17969 12 2V7.25C12 8.09375 11.3203 8.75 10.5 8.75H5.25C4.40625 8.75 3.75 8.09375 3.75 7.25Z",fill:e})}),"DuplicateIcon");import{jsx as Pf}from"react/jsx-runtime";var Au=a(({color:e="#404040",width:t=20,height:r=15,viewBox:o="0 0 20 15",...n})=>Pf(Q,{...n,width:t,height:r,viewBox:o,children:Pf("path",{d:"M1.875 0H18.125C19.1406 0 20 0.859375 20 1.875C20 2.5 19.6875 3.04688 19.2188 3.39844L10.7422 9.76562C10.2734 10.1172 9.6875 10.1172 9.21875 9.76562L0.742188 3.39844C0.273438 3.04688 0 2.5 0 1.875C0 0.859375 0.820312 0 1.875 0ZM0 4.375L8.47656 10.7812C9.375 11.4453 10.5859 11.4453 11.4844 10.7812L20 4.375V12.5C20 13.9062 18.8672 15 17.5 15H2.5C1.09375 15 0 13.9062 0 12.5V4.375Z",fill:e})}),"EmailIcon");import{jsx as Mf}from"react/jsx-runtime";var Ia=a(({color:e="#737373",width:t=16,height:r=16,...o})=>Mf(Q,{...o,width:t,height:r,children:Mf(De,{d:"M10.25 1H14.25C14.6562 1 15 1.34375 15 1.75V5.75C15 6.1875 14.6562 6.5 14.25 6.5C13.8125 6.5 13.5 6.1875 13.5 5.75V3.5625L9.03125 8L13.5 12.4688V10.25C13.5 9.84375 13.8125 9.5 14.25 9.5C14.6562 9.5 15 9.84375 15 10.25V14.25C15 14.6875 14.6562 15 14.25 15H10.25C9.8125 15 9.5 14.6875 9.5 14.25C9.5 13.8438 9.8125 13.5 10.25 13.5H12.4375L8 9.0625L3.53125 13.5H5.75C6.15625 13.5 6.5 13.8438 6.5 14.25C6.5 14.6875 6.15625 15 5.75 15H1.75C1.3125 15 1 14.6875 1 14.25V10.25C1 9.84375 1.3125 9.5 1.75 9.5C2.15625 9.5 2.5 9.84375 2.5 10.25V12.4688L6.9375 8L2.5 3.5625V5.75C2.5 6.1875 2.15625 6.5 1.75 6.5C1.3125 6.5 1 6.1875 1 5.75V1.75C1 1.34375 1.3125 1 1.75 1H5.75C6.15625 1 6.5 1.34375 6.5 1.75C6.5 2.1875 6.15625 2.5 5.75 2.5H3.53125L8 6.96875L12.4375 2.5H10.25C9.8125 2.5 9.5 2.1875 9.5 1.75C9.5 1.34375 9.8125 1 10.25 1Z",fill:e})}),"ExpandIcon");import{jsx as Nf}from"react/jsx-runtime";var Ti=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Nf(Q,{...n,width:r,height:o,children:Nf(De,{d:"M16 8C16 12.0938 12.9062 15.4688 8.96875 15.9688V10.4688H11.125L11.5625 8H8.96875V7.15625C8.96875 5.84375 9.46875 5.34375 10.7812 5.34375C11.1875 5.34375 11.5 5.375 11.6875 5.375V3.1875C11.3438 3.0625 10.4688 2.96875 9.96875 2.96875C7.28125 2.96875 6.0625 4.25 6.0625 6.96875V8H4.40625V10.4688H6.0625V15.7812C2.5625 14.9062 0 11.75 0 8C0 3.59375 3.5625 0 8 0C12.4062 0 16 3.59375 16 8Z",active:t,fill:e})}),"FacebookIcon");import{jsx as Sf}from"react/jsx-runtime";var Iu=a(({color:e="#737373",width:t=14,height:r=16,...o})=>Sf(Q,{...o,width:t,height:r,children:Sf(De,{d:"M0 2.75C0 2.34375 0.3125 2 0.75 2H13.25C13.6562 2 14 2.34375 14 2.75C14 3.1875 13.6562 3.5 13.25 3.5H0.75C0.3125 3.5 0 3.1875 0 2.75ZM2 7.75C2 7.34375 2.3125 7 2.75 7H11.25C11.6562 7 12 7.34375 12 7.75C12 8.1875 11.6562 8.5 11.25 8.5H2.75C2.3125 8.5 2 8.1875 2 7.75ZM9 12.75C9 13.1875 8.65625 13.5 8.25 13.5H5.75C5.3125 13.5 5 13.1875 5 12.75C5 12.3438 5.3125 12 5.75 12H8.25C8.65625 12 9 12.3438 9 12.75Z",fill:e})}),"HamburgerMenuIcon");import{jsx as Af}from"react/jsx-runtime";var La=a(({color:e="#404040",width:t=24,height:r=24,...o})=>Af(Q,{...o,width:t,height:r,children:Af("path",{d:"M2 5.75C2 4.38281 3.09375 3.25 4.5 3.25H19.5C20.8672 3.25 22 4.38281 22 5.75V8.25V10.125V10.75V18.25C22 19.6562 20.8672 20.75 19.5 20.75H4.5C3.09375 20.75 2 19.6562 2 18.25V10.75V10.125V8.25V5.75ZM20.125 10.75H3.875V18.25C3.875 18.6016 4.14844 18.875 4.5 18.875H19.5C19.8125 18.875 20.125 18.6016 20.125 18.25V10.75ZM5.75 8.25C6.41406 8.25 7 7.70312 7 7C7 6.33594 6.41406 5.75 5.75 5.75C5.04688 5.75 4.5 6.33594 4.5 7C4.5 7.70312 5.04688 8.25 5.75 8.25ZM10.75 7C10.75 6.33594 10.1641 5.75 9.5 5.75C8.79688 5.75 8.25 6.33594 8.25 7C8.25 7.70312 8.79688 8.25 9.5 8.25C10.1641 8.25 10.75 7.70312 10.75 7ZM13.25 8.25C13.9141 8.25 14.5 7.70312 14.5 7C14.5 6.33594 13.9141 5.75 13.25 5.75C12.5469 5.75 12 6.33594 12 7C12 7.70312 12.5469 8.25 13.25 8.25Z",fill:e})}),"InboxIcon");import{jsx as If}from"react/jsx-runtime";var Ei=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>If(Q,{...n,width:r,height:o,children:If(De,{d:"M8 4.40625C9.96875 4.40625 11.5938 6.03125 11.5938 8C11.5938 10 9.96875 11.5938 8 11.5938C6 11.5938 4.40625 10 4.40625 8C4.40625 6.03125 6 4.40625 8 4.40625ZM8 10.3438C9.28125 10.3438 10.3125 9.3125 10.3125 8C10.3125 6.71875 9.28125 5.6875 8 5.6875C6.6875 5.6875 5.65625 6.71875 5.65625 8C5.65625 9.3125 6.71875 10.3438 8 10.3438ZM12.5625 4.28125C12.5625 3.8125 12.1875 3.4375 11.7188 3.4375C11.25 3.4375 10.875 3.8125 10.875 4.28125C10.875 4.75 11.25 5.125 11.7188 5.125C12.1875 5.125 12.5625 4.75 12.5625 4.28125ZM14.9375 5.125C15 6.28125 15 9.75 14.9375 10.9062C14.875 12.0312 14.625 13 13.8125 13.8438C13 14.6562 12 14.9062 10.875 14.9688C9.71875 15.0312 6.25 15.0312 5.09375 14.9688C3.96875 14.9062 3 14.6562 2.15625 13.8438C1.34375 13 1.09375 12.0312 1.03125 10.9062C0.96875 9.75 0.96875 6.28125 1.03125 5.125C1.09375 4 1.34375 3 2.15625 2.1875C3 1.375 3.96875 1.125 5.09375 1.0625C6.25 1 9.71875 1 10.875 1.0625C12 1.125 13 1.375 13.8125 2.1875C14.625 3 14.875 4 14.9375 5.125ZM13.4375 12.125C13.8125 11.2188 13.7188 9.03125 13.7188 8C13.7188 7 13.8125 4.8125 13.4375 3.875C13.1875 3.28125 12.7188 2.78125 12.125 2.5625C11.1875 2.1875 9 2.28125 8 2.28125C6.96875 2.28125 4.78125 2.1875 3.875 2.5625C3.25 2.8125 2.78125 3.28125 2.53125 3.875C2.15625 4.8125 2.25 7 2.25 8C2.25 9.03125 2.15625 11.2188 2.53125 12.125C2.78125 12.75 3.25 13.2188 3.875 13.4688C4.78125 13.8438 6.96875 13.75 8 13.75C9 13.75 11.1875 13.8438 12.125 13.4688C12.7188 13.2188 13.2188 12.75 13.4375 12.125Z",active:t,fill:e})}),"InstagramIcon");import{jsx as Lf}from"react/jsx-runtime";var wi=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Lf(Q,{...n,width:r,height:o,children:Lf(De,{d:"M14 1C14.5312 1 15 1.46875 15 2.03125V14C15 14.5625 14.5312 15 14 15H1.96875C1.4375 15 1 14.5625 1 14V2.03125C1 1.46875 1.4375 1 1.96875 1H14ZM5.21875 13V6.34375H3.15625V13H5.21875ZM4.1875 5.40625C4.84375 5.40625 5.375 4.875 5.375 4.21875C5.375 3.5625 4.84375 3 4.1875 3C3.5 3 2.96875 3.5625 2.96875 4.21875C2.96875 4.875 3.5 5.40625 4.1875 5.40625ZM13 13V9.34375C13 7.5625 12.5938 6.15625 10.5 6.15625C9.5 6.15625 8.8125 6.71875 8.53125 7.25H8.5V6.34375H6.53125V13H8.59375V9.71875C8.59375 8.84375 8.75 8 9.84375 8C10.9062 8 10.9062 9 10.9062 9.75V13H13Z",active:t,fill:e})}),"LinkedinIcon");import{jsx as Rf}from"react/jsx-runtime";var Lu=a(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 256 239",...n})=>Rf(Q,{...n,width:t,height:r,viewBox:o,children:Rf("path",{d:"M244.688 89.3027C250.936 89.3028 256 94.367 256 100.614V160.846C256 183.806 237.387 202.419 214.427 202.419H214.23C207.916 202.42 201.932 201.009 196.571 198.491C186.31 221.332 163.63 237.486 136.931 238.14C107.972 237.431 83.7409 218.49 74.9551 192.558H120.063C130.509 192.558 138.977 184.09 138.977 173.645V89.3027H244.688ZM120.082 53.5811C120.127 53.5812 120.172 53.5842 120.217 53.585C125.988 53.6645 130.676 58.2209 130.962 63.9395C130.971 64.1173 130.976 64.2966 130.977 64.4766V173.646C130.976 179.672 126.09 184.558 120.063 184.558H10.9131C4.88618 184.558 9.07128e-05 179.672 0 173.646V64.4941C0 58.4673 4.88624 53.5811 10.9131 53.5811H120.082ZM36.7686 95.125H58.4873V154.541H72.3887V95.125H94.208V83.5986H36.7686V95.125ZM139.907 0C161.279 0.000200803 178.604 17.3254 178.604 38.6973C178.604 60.0693 161.279 77.3953 139.907 77.3955C139.596 77.3955 139.286 77.3901 138.977 77.3828V64.4941C138.976 54.0493 130.509 45.5811 120.063 45.5811H101.82C101.419 43.3471 101.209 41.0467 101.209 38.6973C101.209 17.3253 118.535 0 139.907 0ZM223.256 23.8145C238.052 23.8145 250.047 35.8085 250.047 50.6045C250.047 65.4005 238.052 77.3954 223.256 77.3955C208.46 77.3955 196.465 65.4006 196.465 50.6045C196.465 35.8085 208.46 23.8145 223.256 23.8145Z",fill:e})}),"MSTeamsIcon");import{jsx as Bf}from"react/jsx-runtime";var ki=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Bf(Q,{...n,width:r,height:o,children:Bf(De,{d:"M5.625 2.34375C8.75 2.34375 11.2812 4.875 11.2812 8C11.2812 11.1562 8.75 13.6875 5.625 13.6875C2.5 13.6875 0 11.1562 0 8C0 4.875 2.5 2.34375 5.625 2.34375ZM14.625 2.65625C16.1875 2.65625 17.4688 5.0625 17.4688 8.03125C17.4688 10.9688 16.1875 13.375 14.625 13.375C13.0625 13.375 11.8125 10.9688 11.8125 8.03125C11.8125 5.0625 13.0625 2.65625 14.625 2.65625ZM19 3.21875C19.5312 3.21875 20 5.375 20 8C20 10.6562 19.5312 12.8125 19 12.8125C18.4375 12.8125 18 10.6562 18 8.03125C18 5.375 18.4375 3.21875 19 3.21875Z",active:t,fill:e})}),"MediumIcon");import{jsx as Ru}from"react/jsx-runtime";var Bu=a(({color:e,width:t=21,height:r=16,...o})=>Ru(Q,{...o,width:t,height:r,children:Ru("g",{transform:"translate(4, 0)",children:Ru("path",{d:"M8.5 1.5V2C8.5 2.28125 8.25 2.5 8 2.5H5C4.71875 2.5 4.5 2.28125 4.5 2V1.5H3.5C2.9375 1.5 2.5 1.96875 2.5 2.5V13.5C2.5 14.0625 2.9375 14.5 3.5 14.5H9.5C10.0312 14.5 10.5 14.0625 10.5 13.5V2.5C10.5 1.96875 10.0312 1.5 9.5 1.5H8.5ZM1 2.5C1 1.125 2.09375 0 3.5 0H9.5C10.875 0 12 1.125 12 2.5V13.5C12 14.9062 10.875 16 9.5 16H3.5C2.09375 16 1 14.9062 1 13.5V2.5Z",fill:e})})}),"MobileIcon");import{jsx as Df}from"react/jsx-runtime";var Du=a(({color:e="#737373",width:t=14,height:r=16,...o})=>Df(Q,{...o,width:t,height:r,children:Df(De,{d:"M13.5 8C13.5 8.5625 13.1875 9.03125 12.75 9.3125C12.2812 9.59375 11.6875 9.59375 11.25 9.3125C10.7812 9.03125 10.5 8.5625 10.5 8C10.5 7.46875 10.7812 7 11.25 6.71875C11.6875 6.4375 12.2812 6.4375 12.75 6.71875C13.1875 7 13.5 7.46875 13.5 8ZM8.5 8C8.5 8.5625 8.1875 9.03125 7.75 9.3125C7.28125 9.59375 6.6875 9.59375 6.25 9.3125C5.78125 9.03125 5.5 8.5625 5.5 8C5.5 7.46875 5.78125 7 6.25 6.71875C6.6875 6.4375 7.28125 6.4375 7.75 6.71875C8.1875 7 8.5 7.46875 8.5 8ZM2 9.5C1.4375 9.5 0.96875 9.21875 0.6875 8.75C0.40625 8.3125 0.40625 7.71875 0.6875 7.25C0.96875 6.8125 1.4375 6.5 2 6.5C2.53125 6.5 3 6.8125 3.28125 7.25C3.5625 7.71875 3.5625 8.3125 3.28125 8.75C3 9.21875 2.53125 9.5 2 9.5Z",fill:e})}),"MoreMenuIcon");import{jsx as Vf}from"react/jsx-runtime";var So=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Vf(Q,{...n,width:r,height:o,children:Vf(De,{d:"M14.25 0C14.6562 0 15 0.34375 15 0.75V15.25C15 15.6875 14.6562 16 14.25 16C13.8125 16 13.5 15.6875 13.5 15.25V0.75C13.5 0.34375 13.8125 0 14.25 0ZM9.5 11.5V4.5H6.5V11.5H9.5ZM11 4.5V11.5C11 12.3438 10.3125 13 9.5 13H6.5C5.65625 13 5 12.3438 5 11.5V4.5C5 3.6875 5.65625 3 6.5 3H9.5C10.3125 3 11 3.6875 11 4.5ZM2.5 0.75V15.25C2.5 15.6875 2.15625 16 1.75 16C1.3125 16 1 15.6875 1 15.25V0.75C1 0.34375 1.3125 0 1.75 0C2.15625 0 2.5 0.34375 2.5 0.75Z",active:t,fill:e})}),"PaddingHorizontalIcon");import{jsx as Hf}from"react/jsx-runtime";var Rr=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Hf(Q,{...n,width:r,height:o,children:Hf(De,{d:"M0 1.75C0 1.34375 0.3125 1 0.75 1H15.25C15.6562 1 16 1.34375 16 1.75C16 2.1875 15.6562 2.5 15.25 2.5H0.75C0.3125 2.5 0 2.1875 0 1.75ZM11.5 6.5H4.5V9.5H11.5V6.5ZM4.5 5H11.5C12.3125 5 13 5.6875 13 6.5V9.5C13 10.3438 12.3125 11 11.5 11H4.5C3.65625 11 3 10.3438 3 9.5V6.5C3 5.6875 3.65625 5 4.5 5ZM0.75 13.5H15.25C15.6562 13.5 16 13.8438 16 14.25C16 14.6875 15.6562 15 15.25 15H0.75C0.3125 15 0 14.6875 0 14.25C0 13.8438 0.3125 13.5 0.75 13.5Z",active:t,fill:e})}),"PaddingVerticalIcon");import{jsx as Ff,jsxs as V2}from"react/jsx-runtime";var Vu=a(({width:e=20,height:t=21,viewBox:r="0 0 20 21",...o})=>V2(Q,{...o,width:e,height:t,viewBox:r,children:[Ff("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"}),Ff("circle",{cx:"2",cy:"2",r:"3",transform:"matrix(-1 0 0 1 17.75 2)",fill:"currentColor",stroke:"white",strokeWidth:"2"})]}),"PushIcon");import{jsx as Of}from"react/jsx-runtime";var Hu=a(({color:e="#171717",width:t=16,height:r=13,...o})=>Of(Q,{...o,fill:"none",width:t,height:r,children:Of("path",{d:"M1.39062 0.640625L4.01562 2.67969L4.17969 1.97656C4.29688 1.55469 4.67188 1.25 5.09375 1.25H12.9453C13.5547 1.25 14 1.83594 13.8594 2.42188L13.6016 3.45312C13.5312 3.75781 13.2266 3.94531 12.9219 3.875C12.6172 3.80469 12.4297 3.5 12.5 3.19531L12.7109 2.375H9.78125L8.65625 6.33594L15.2656 11.5156C15.5234 11.7031 15.5703 12.0547 15.3594 12.2891C15.1719 12.5469 14.8203 12.5938 14.5859 12.3828L0.710938 1.50781C0.453125 1.32031 0.40625 0.96875 0.617188 0.734375C0.804688 0.476562 1.15625 0.429688 1.39062 0.640625ZM4.97656 3.42969L7.71875 5.58594L8.60938 2.375H5.23438L4.97656 3.42969ZM8 8.67969L7.4375 10.625H8.75C9.05469 10.625 9.3125 10.8828 9.3125 11.1875C9.3125 11.5156 9.05469 11.75 8.75 11.75H5C4.67188 11.75 4.4375 11.5156 4.4375 11.1875C4.4375 10.8828 4.67188 10.625 5 10.625H6.28906L6.3125 10.4844L7.03906 7.92969L8 8.67969Z",fill:e})}),"RemoveFormattingIcon");import{jsx as _f}from"react/jsx-runtime";var Fu=a(({color:e="#171717",width:t=11,height:r=12,...o})=>_f(Q,{...o,width:t,height:r,children:_f(De,{d:"M10.75 2.75V10.25C10.75 10.6719 10.3984 11 10 11C9.57812 11 9.25 10.6719 9.25 10.25V2.75C9.25 2.35156 9.57812 2 10 2C10.3984 2 10.75 2.35156 10.75 2.75ZM7.51562 7.03906L4.51562 10.0391C4.23438 10.3438 3.74219 10.3438 3.46094 10.0391C3.15625 9.75781 3.15625 9.26562 3.46094 8.98438L5.17188 7.25H1C0.578125 7.25 0.25 6.92188 0.25 6.5C0.25 6.10156 0.578125 5.75 1 5.75H5.17188L3.46094 4.03906C3.15625 3.75781 3.15625 3.26562 3.46094 2.98438C3.74219 2.67969 4.23438 2.67969 4.51562 2.98438L7.51562 5.98438C7.82031 6.26562 7.82031 6.75781 7.51562 7.03906Z",fill:e})}),"RightToLineIcon");import{jsx as Wf}from"react/jsx-runtime";var Ou=a(({color:e="#404040",width:t=24,height:r=24,...o})=>Wf(Q,{...o,width:t,height:r,children:Wf("path",{d:"M6.80469 17.3125C7.3125 16.9219 7.97656 16.8438 8.5625 17.0391C9.57812 17.4297 10.75 17.625 12 17.625C16.8438 17.625 20.125 14.5 20.125 11.375C20.125 8.28906 16.8438 5.125 12 5.125C7.11719 5.125 3.875 8.28906 3.875 11.375C3.875 12.625 4.34375 13.8359 5.24219 14.8906C5.59375 15.2422 5.75 15.75 5.71094 16.2578C5.67188 16.9609 5.47656 17.625 5.28125 18.2109C5.94531 17.8984 6.49219 17.5469 6.80469 17.3125ZM2.82031 18.875C2.89844 18.7969 2.9375 18.6797 3.01562 18.5625C3.40625 17.9375 3.75781 17.0781 3.83594 16.1016C2.66406 14.7734 2 13.1719 2 11.375C2 6.92188 6.45312 3.25 12 3.25C17.5078 3.25 22 6.92188 22 11.375C22 15.8672 17.5078 19.5 12 19.5C10.5156 19.5 9.14844 19.2656 7.89844 18.8359C7.46875 19.1484 6.6875 19.6172 5.78906 20.0078C5.20312 20.2812 4.53906 20.5156 3.83594 20.6328C3.79688 20.6328 3.75781 20.6719 3.75781 20.6719C3.5625 20.7109 3.40625 20.7109 3.21094 20.75C3.01562 20.75 2.82031 20.7891 2.58594 20.7891C2.35156 20.7891 2.11719 20.6328 2.03906 20.3984C1.92188 20.1641 2 19.8906 2.15625 19.6953C2.3125 19.5391 2.46875 19.3828 2.58594 19.1875C2.66406 19.0703 2.74219 18.9922 2.78125 18.9141V18.875H2.82031Z",fill:e})}),"SMSIcon");import{jsx as Ra,jsxs as H2}from"react/jsx-runtime";var zf=a(({color:e="#000000",width:t=14,height:r=9,...o})=>Ra(Q,{...o,width:t,height:r,children:H2("g",{opacity:"0.9",children:[Ra("rect",{x:"0.799805",y:"5.92188",width:"2.46154",height:"2.95385",rx:"0.246154",fill:e}),Ra("rect",{x:"4.24609",y:"4.44531",width:"2.46154",height:"4.43077",rx:"0.246154",fill:e}),Ra("rect",{x:"7.93823",y:"2.72266",width:"2.46154",height:"6.15385",rx:"0.246154",fill:e}),Ra("rect",{x:"11.3845",y:"0.753906",width:"2.46154",height:"8.12308",rx:"0.246154",fill:e})]})}),"SignalIcon");import{jsx as Uf}from"react/jsx-runtime";var _u=a(({color:e="#404040",width:t=16,height:r=16,...o})=>Uf(Q,{...o,width:t,height:r,children:Uf("path",{d:"M3.5 10C3.5 10.8281 2.8125 11.5 2 11.5C1.16406 11.5 0.5 10.8281 0.5 10C0.5 9.19531 1.16406 8.5 2 8.5H3.5V10ZM4.25 10C4.25 9.19531 4.91406 8.5 5.75 8.5C6.5625 8.5 7.25 9.19531 7.25 10V14C7.25 14.8281 6.5625 15.5 5.75 15.5C4.91406 15.5 4.25 14.8281 4.25 14V10ZM5.75 3.5C4.91406 3.5 4.25 2.83594 4.25 2C4.25 1.1875 4.91406 0.5 5.75 0.5C6.5625 0.5 7.25 1.1875 7.25 2V3.5H5.75ZM5.75 4.25C6.5625 4.25 7.25 4.91406 7.25 5.75C7.25 6.5625 6.5625 7.25 5.75 7.25H2C1.16406 7.25 0.5 6.5625 0.5 5.75C0.5 4.91406 1.16406 4.25 2 4.25H5.75ZM12.5 5.75C12.5 4.91406 13.1641 4.25 14 4.25C14.8125 4.25 15.5 4.91406 15.5 5.75C15.5 6.5625 14.8125 7.25 14 7.25H12.5V5.75ZM11.75 5.75C11.75 6.5625 11.0859 7.25 10.25 7.25C9.41406 7.25 8.75 6.5625 8.75 5.75V2C8.75 1.1875 9.41406 0.5 10.25 0.5C11.0859 0.5 11.75 1.1875 11.75 2V5.75ZM10.25 12.5C11.0859 12.5 11.75 13.1641 11.75 14C11.75 14.8125 11.0859 15.5 10.25 15.5C9.41406 15.5 8.75 14.8125 8.75 14V12.5H10.25ZM10.25 11.75C9.41406 11.75 8.75 11.0859 8.75 10.25C8.75 9.41406 9.41406 8.75 10.25 8.75H14C14.8125 8.75 15.5 9.41406 15.5 10.25C15.5 11.0859 14.8125 11.75 14 11.75H10.25Z",fill:e})}),"SlackIcon");import{jsx as $f}from"react/jsx-runtime";var Ba=a(({color:e="#FFFFFF",width:t=24,height:r=24,...o})=>$f(Q,{...o,width:t,height:r,viewBox:"0 0 24 24",children:$f("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.9302 18.0041C16.7152 19.4687 17.3201 20.6536 17.6716 21.4225C22.7992 18.3395 24.5289 11.7034 21.525 6.5012C18.5211 1.29895 11.9084 -0.521541 6.67543 2.3769C7.30667 3.26444 8.32896 4.86524 9.56215 6.89518C10.4351 8.33194 11.4134 9.98401 12.4328 11.7503C13.7758 14.0761 14.9841 16.2422 15.9302 18.0041ZM4.20759 16.4985C2.25528 13.1182 1.73242 9.41428 2.51159 6.43383C0.579784 9.73503 0.426001 13.9501 2.47497 17.4989C4.52394 21.0476 8.25134 23.0233 12.0769 22.9999C9.1052 22.1856 6.1599 19.8803 4.20759 16.4985ZM1.6094 17.9983C4.92231 23.738 12.2599 25.7035 17.9997 22.3906C23.738 19.0777 25.7035 11.7401 22.3906 6.00031C19.0776 0.262019 11.74 -1.70347 6.00172 1.60945C0.261966 4.92236 -1.70352 12.26 1.6094 17.9983ZM11.1249 21.6085C12.4884 22.1914 13.8534 22.4228 15.1188 22.2896C12.7711 21.2717 9.91951 18.3937 7.66989 14.4994C5.42174 10.605 4.35551 6.69599 4.6499 4.15492C3.90002 5.18306 3.41817 6.48069 3.24096 7.95408C2.94364 10.4131 3.51483 13.2999 5.07317 15.9991C6.6315 18.6998 8.84597 20.636 11.1249 21.6085ZM16.913 21.6876C16.6889 21.6993 16.4238 21.67 16.1089 21.5836C15.4513 21.402 14.6604 20.9861 13.7875 20.3197C12.0461 18.9898 10.1436 16.7827 8.53694 13.9999C6.92881 11.2157 5.9695 8.46376 5.6883 6.29176C5.62971 5.83334 5.60188 5.41008 5.60188 5.02342C5.60188 4.49324 5.65461 4.03335 5.7542 3.65109C5.89334 3.11945 6.10278 2.78845 6.33565 2.59219C7.11481 4.29259 9.11545 8.00387 11.5672 12.2497C14.0189 16.4956 16.2319 20.0853 17.3157 21.61C17.2 21.651 17.0667 21.6788 16.913 21.6876Z",fill:e})}),"UnionIcon");import{jsx as qf}from"react/jsx-runtime";var Da=a(({color:e="#A3A3A3",width:t=24,height:r=24,...o})=>qf(Q,{...o,width:t,height:r,children:qf(De,{d:"M12 12C10.2031 12 8.5625 11.0625 7.66406 9.5C6.76562 7.97656 6.76562 6.0625 7.66406 4.5C8.5625 2.97656 10.2031 2 12 2C13.7578 2 15.3984 2.97656 16.2969 4.5C17.1953 6.0625 17.1953 7.97656 16.2969 9.5C15.3984 11.0625 13.7578 12 12 12ZM10.2031 13.875H13.7578C17.625 13.875 20.75 17 20.75 20.8672C20.75 21.4922 20.2031 22 19.5781 22H4.38281C3.75781 22 3.25 21.4922 3.25 20.8672C3.25 17 6.33594 13.875 10.2031 13.875Z",fill:e})}),"UserIcon");import{jsx as jf}from"react/jsx-runtime";var Zf=a(({width:e=24,height:t=20,...r})=>jf(Q,{...r,width:e,height:t,viewBox:"0 0 24 20",children:jf("path",{d:"M6 1H5C4.46957 1 3.96086 1.21071 3.58579 1.58579C3.21071 1.96086 3 2.46957 3 3V8C3 8.53043 2.78929 9.03914 2.41421 9.41421C2.03914 9.78929 1.53043 10 1 10C1.53043 10 2.03914 10.2107 2.41421 10.5858C2.78929 10.9609 3 11.4696 3 12V17C3 18.1 3.9 19 5 19H6M18 19H19C19.5304 19 20.0391 18.7893 20.4142 18.4142C20.7893 18.0391 21 17.5304 21 17V12C21 10.9 21.9 10 23 10C22.4696 10 21.9609 9.78929 21.5858 9.41421C21.2107 9.03914 21 8.53043 21 8V3C21 2.46957 20.7893 1.96086 20.4142 1.58579C20.0391 1.21071 19.5304 1 19 1H18M10 16.5C10 16.7761 9.77614 17 9.5 17C9.22386 17 9 16.7761 9 16.5C9 16.2239 9.22386 16 9.5 16C9.77614 16 10 16.2239 10 16.5ZM15 16.5C15 16.7761 14.7761 17 14.5 17C14.2239 17 14 16.7761 14 16.5C14 16.2239 14.2239 16 14.5 16C14.7761 16 15 16.2239 15 16.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"VariableIcon");import{jsx as Ys,jsxs as F2}from"react/jsx-runtime";var Kf=a(({color:e="#000000",width:t=14,height:r=10,...o})=>Ys(Q,{...o,width:t,height:r,children:F2("g",{opacity:"0.9",children:[Ys("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}),Ys("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}),Ys("path",{d:"M8.80258 7.40452C8.35559 6.94626 7.73119 6.66172 7.04045 6.66172C6.34225 6.66172 5.71196 6.95239 5.264 7.41931L7.0259 9.18121L8.80258 7.40452Z",fill:e})]})}),"WiFiIcon");import{jsx as Jf}from"react/jsx-runtime";var Pi=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>Jf(Q,{...n,width:r,height:o,children:Jf(De,{d:"M12.1562 1.5H14.3438L9.53125 7.03125L15.2188 14.5H10.7812L7.28125 9.96875L3.3125 14.5H1.09375L6.25 8.625L0.8125 1.5H5.375L8.5 5.65625L12.1562 1.5ZM11.375 13.1875H12.5938L4.71875 2.75H3.40625L11.375 13.1875Z",active:t,fill:e})}),"XIcon");import{NodeViewWrapper as g4}from"@tiptap/react";import{useSetAtom as h4}from"jotai";import{forwardRef as b4,useCallback as ni,useEffect as Mm,useState as Ac,useRef as gn}from"react";import{v4 as y4}from"uuid";function ro(){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(ro,"combine");function Gf(e){if(Array.isArray(e))return e}a(Gf,"_arrayWithHoles");function Xf(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(Xf,"_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}a(Va,"_arrayLikeToArray");function Qs(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}}a(Qs,"_unsupportedIterableToArray");function Yf(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
183
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}a(Yf,"_nonIterableRest");function el(e,t){return Gf(e)||Xf(e,t)||Qs(e,t)||Yf()}a(el,"_slicedToArray");var Vg=Fs(Ha());var rl="data-pdnd-honey-pot";function ol(e){return e instanceof Element&&e.hasAttribute(rl)}a(ol,"isHoneyPotElement");function nl(e){var t=document.elementsFromPoint(e.x,e.y),r=el(t,2),o=r[0],n=r[1];return o?ol(o)?n!=null?n:null:o:null}a(nl,"getElementFromPointWithoutHoneypot");function In(e){"@babel/helpers - typeof";return In=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},In(e)}a(In,"_typeof");function tg(e,t){if(In(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,t||"default");if(In(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}a(tg,"toPrimitive");function rg(e){var t=tg(e,"string");return In(t)=="symbol"?t:t+""}a(rg,"toPropertyKey");function Ao(e,t,r){return(t=rg(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}a(Ao,"_defineProperty");var Oa=Fs(Ha());var og=2147483647;function ng(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(ng,"ownKeys");function ig(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ng(Object(r),!0).forEach(function(o){Ao(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ng(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(ig,"_objectSpread");var Fa=2,ag=Fa/2;function q2(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}a(q2,"floorToClosestPixel");function j2(e){return{x:e.x-ag,y:e.y-ag}}a(j2,"pullBackByHalfHoneyPotSize");function Z2(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}a(Z2,"preventGoingBackwardsOffScreen");function K2(e){return{x:Math.min(e.x,window.innerWidth-Fa),y:Math.min(e.y,window.innerHeight-Fa)}}a(K2,"preventGoingForwardsOffScreen");function sg(e){var t=e.client,r=K2(Z2(j2(q2(t))));return DOMRect.fromRect({x:r.x,y:r.y,width:Fa,height:Fa})}a(sg,"getHoneyPotRectFor");function lg(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(lg,"getRectStyles");function J2(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(J2,"isWithin");function G2(e){var t=e.initial,r=document.createElement("div");r.setAttribute(rl,"true");var o=sg({client:t});Object.assign(r.style,ig(ig({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},lg({clientRect:o})),{},{pointerEvents:"auto",zIndex:og})),document.body.appendChild(r);var n=(0,Oa.bind)(window,{type:"pointermove",listener:a(function(s){var l={x:s.clientX,y:s.clientY};o=sg({client:l}),Object.assign(r.style,lg({clientRect:o}))},"listener"),options:{capture:!0}});return a(function(s){var l=s.current;if(n(),J2({client:l,clientRect:o})){r.remove();return}function c(){u(),r.remove()}a(c,"cleanup");var u=(0,Oa.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(G2,"mountHoneyPot");function cg(){var e=null;function t(){return e=null,(0,Oa.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=G2({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(cg,"makeHoneyPotFix");function ug(e){if(Array.isArray(e))return Va(e)}a(ug,"_arrayWithoutHoles");function dg(e){if(typeof Symbol!="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}a(dg,"_iterableToArray");function mg(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
184
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}a(mg,"_nonIterableSpread");function il(e){return ug(e)||dg(e)||Qs(e)||mg()}a(il,"_toConsumableArray");var xg=Fs(Ha());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 pg=yr(a(function(){return navigator.userAgent.includes("Firefox")},"isFirefox"));var _a=yr(a(function(){var t=navigator,r=t.userAgent;return r.includes("AppleWebKit")&&!r.includes("Chrome")},"isSafari"));var fg=Fs(Ha());var zu={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function gg(e){var t=e.dragLeave;return _a()?t.hasOwnProperty(zu.isLeavingWindow):!1}a(gg,"isLeavingWindowInSafari");a(function(){if(typeof window=="undefined"||!_a())return;function t(){return{enterCount:0,isOverWindow:!1}}a(t,"getInitialState");var r=t();function o(){r=t()}a(o,"resetState"),(0,fg.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[zu.isEnteringWindow]=!0),r.isOverWindow=!0,r.enterCount++},"listener")},{type:"dragleave",listener:a(function(i){r.enterCount--,r.isOverWindow&&r.enterCount===0&&(i[zu.isLeavingWindow]=!0,r.isOverWindow=!1)},"listener")}],{capture:!0})},"fixSafari")();function X2(e){return"nodeName"in e}a(X2,"isNodeLike");function hg(e){return X2(e)&&e.ownerDocument!==document}a(hg,"isFromAnotherWindow");function bg(e){var t=e.dragLeave,r=t.type,o=t.relatedTarget;return r!=="dragleave"?!1:_a()?gg({dragLeave:t}):o==null?!0:pg()?hg(o):o instanceof HTMLIFrameElement}a(bg,"isLeavingWindow");function yg(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(yg,"getBindingsForBrokenDrags");function Ln(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(Ln,"getInput");var Y2=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"),vg=Y2;var Uu=vg(function(e){return e()}),al=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 Cg(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}}),al.schedule(function(){i({eventName:"onDragStart",payload:{source:t,location:d}})})},"start"),dragUpdate:a(function(c){var u=c.current;al.flush(),Uu.cancel(),i({eventName:"onDropTargetChange",payload:{source:t,location:{initial:r,previous:n,current:u}}})},"dragUpdate"),drag:a(function(c){var u=c.current;Uu(function(){al.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;al.flush(),Uu.cancel(),i({eventName:"onDrop",payload:{source:d!=null?d:t,location:{current:u,previous:n,initial:r}}})},"drop")};return s}a(Cg,"makeDispatch");var qu={isActive:!1};function Tg(){return!qu.isActive}a(Tg,"canStart");function Q2(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}a(Q2,"getNativeSetDragImage");function ev(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(ev,"hasHierarchyChanged");function tv(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=e.dispatchEvent;if(!Tg())return;var i=rv({event:t,dragType:r,getDropTargetsOver:o});qu.isActive=!0;var s={current:i};$u({event:t,current:i.dropTargets});var l=Cg({source:r.payload,dispatchEvent:n,initial:i});function c(f){var v=ev({current:s.current.dropTargets,next:f.dropTargets});s.current=f,v&&l.dragUpdate({current:s.current})}a(c,"updateState");function u(f){var v=Ln(f),h=ol(f.target)?nl({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(),$u({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(){qu.isActive=!1,m()}a(p,"finish");var m=(0,xg.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){bg({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:Ln(v)},!s.current.dropTargets.length){d();return}v.preventDefault(),$u({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:Ln(v)},d()},"listener")}].concat(il(yg({onDragEnd:d}))),{capture:!0});l.start({nativeSetDragImage:Q2(t)})}a(tv,"start");function $u(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($u,"setDropEffectOnEvent");function rv(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=Ln(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(rv,"getStartLocation");var ju={canStart:Tg,start:tv};var Zu=new Map;function ov(e){var t=e.typeKey,r=e.mount,o=Zu.get(t);if(o)return o.usageCount++,o;var n={typeKey:t,unmount:r(),usageCount:1};return Zu.set(t,n),n}a(ov,"registerUsage");function Eg(e){var t=ov(e);return a(function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),Zu.delete(e.typeKey))},"unregister")}a(Eg,"register");function sl(e,t){var r=t.attribute,o=t.value;return e.setAttribute(r,o),function(){return e.removeAttribute(r)}}a(sl,"addAttribute");function wg(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(wg,"ownKeys");function Xo(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?wg(Object(r),!0).forEach(function(o){Ao(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wg(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(Xo,"_objectSpread");function Ku(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=nv(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.
185
+ 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(Ku,"_createForOfIteratorHelper");function nv(e,t){if(e){if(typeof e=="string")return kg(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)?kg(e,t):void 0}}a(nv,"_unsupportedIterableToArray");function kg(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(kg,"_arrayLikeToArray");function Ju(e){return e.slice(0).reverse()}a(Ju,"copyReverse");function Pg(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=ro(sl(f.element,{attribute:n,value:"true"}),s(f));return yr(h)}a(l,"dropTargetForConsumers");function c(f){var v,h,y,C,T=f.source,E=f.target,b=f.input,g=f.result,x=g===void 0?[]:g;if(E==null)return x;if(!(E instanceof Element))return E instanceof Node?c({source:T,target:E.parentElement,input:b,result:x}):x;var k=E.closest(i);if(k==null)return x;var P=o.get(k);if(P==null)return x;var S={input:b,source:T,element:P.element};if(P.canDrop&&!P.canDrop(S))return c({source:T,target:P.element.parentElement,input:b,result:x});var w=(v=(h=P.getData)===null||h===void 0?void 0:h.call(P,S))!==null&&v!==void 0?v:{},M=(y=(C=P.getDropEffect)===null||C===void 0?void 0:C.call(P,S))!==null&&y!==void 0?y:r,L={data:w,element:P.element,dropEffect:M,isActiveDueToStickiness:!1};return c({source:T,target:P.element.parentElement,input:b,result:[].concat(il(x),[L])})}a(c,"getActualDropTargets");function u(f){var v=f.eventName,h=f.payload,y=Ku(h.location.current.dropTargets),C;try{for(y.s();!(C=y.n()).done;){var T,E=C.value,b=o.get(E.element),g=Xo(Xo({},h),{},{self:E});b==null||(T=b[v])===null||T===void 0||T.call(b,g)}}catch(x){y.e(x)}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(W){return W.element})),C=new Set,T=Ku(h.location.previous.dropTargets),E;try{for(T.s();!(E=T.n()).done;){var b,g=E.value;C.add(g.element);var x=o.get(g.element),k=y.has(g.element),P=Xo(Xo({},h),{},{self:g});if(x==null||(b=x.onDropTargetChange)===null||b===void 0||b.call(x,P),!k){var S;x==null||(S=x.onDragLeave)===null||S===void 0||S.call(x,P)}}}catch(W){T.e(W)}finally{T.f()}var w=Ku(h.location.current.dropTargets),M;try{for(w.s();!(M=w.n()).done;){var L,N,I=M.value;if(!C.has(I.element)){var D=Xo(Xo({},h),{},{self:I}),V=o.get(I.element);V==null||(L=V.onDropTargetChange)===null||L===void 0||L.call(V,D),V==null||(N=V.onDragEnter)===null||N===void 0||N.call(V,D)}}}catch(W){w.e(W)}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,C=f.current,T=c({source:v,target:h,input:y});if(T.length>=C.length)return T;for(var E=Ju(C),b=Ju(T),g=[],x=0;x<E.length;x++){var k,P=E[x],S=b[x];if(S!=null){g.push(S);continue}var w=g[x-1],M=E[x-1];if((w==null?void 0:w.element)!==(M==null?void 0:M.element))break;var L=o.get(P.element);if(!L)break;var N={input:y,source:v,element:L.element};if(L.canDrop&&!L.canDrop(N)||!((k=L.getIsSticky)!==null&&k!==void 0&&k.call(L,N)))break;g.push(Xo(Xo({},P),{},{isActiveDueToStickiness:!0}))}return Ju(g)}return a(m,"getIsOver"),{dropTargetForConsumers:l,getIsOver:m,dispatchEvent:p}}a(Pg,"makeDropTarget");function iv(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=av(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.
186
+ 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(iv,"_createForOfIteratorHelper");function av(e,t){if(e){if(typeof e=="string")return Mg(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)?Mg(e,t):void 0}}a(av,"_unsupportedIterableToArray");function Mg(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(Mg,"_arrayLikeToArray");function Ng(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(Ng,"ownKeys");function sv(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ng(Object(r),!0).forEach(function(o){Ao(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ng(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(sv,"_objectSpread");function Sg(){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=sv({},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=iv(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(Sg,"makeMonitor");function Ag(e){var t=e.typeKey,r=e.mount,o=e.dispatchEventToSource,n=e.onPostDispatch,i=e.defaultDropEffect,s=Sg(),l=Pg({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;ju.start({event:m,dragType:f,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}a(u,"start");function d(){function p(){var m={canStart:ju.canStart,start:u};return r(m)}return a(p,"mountAdapter"),Eg({typeKey:t,mount:p})}return a(d,"registerUsage"),{registerUsage:d,dropTarget:l.dropTargetForConsumers,monitor:s.monitorForConsumers}}a(Ag,"makeAdapter");var Ig=yr(a(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")},"isAndroid")),Lg="pdnd:android-fallback";var Gu="text/plain";var Rg="text/uri-list";var Bg="application/vnd.pdnd";var ll=new WeakMap;function lv(e){return ll.set(e.element,e),a(function(){ll.delete(e.element)},"cleanup")}a(lv,"addToRegistry");var Dg=cg(),Xu=Ag({typeKey:"element",defaultDropEffect:"move",mount:a(function(t){return ro(Dg.bindEvents(),(0,Vg.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=ll.get(d);if(p){var m=Ln(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=nl({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,C=Object.entries(h);y<C.length;y++){var T=el(C[y],2),E=T[0],b=T[1];o.dataTransfer.setData(E,b!=null?b:"")}Ig()&&!o.dataTransfer.types.includes(Gu)&&!o.dataTransfer.types.includes(Rg)&&o.dataTransfer.setData(Gu,Lg),o.dataTransfer.setData(Bg,"");var g={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:{}},x={type:"element",payload:g,startedFrom:"internal"};t.start({event:o,dragType:x})}}}},"listener")}))},"mount"),dispatchEventToSource:a(function(t){var r,o,n=t.eventName,i=t.payload;(r=ll.get(i.source.element))===null||r===void 0||(o=r[n])===null||o===void 0||o.call(r,i)},"dispatchEventToSource"),onPostDispatch:Dg.getOnPostDispatch()}),mr=Xu.dropTarget,Yu=Xu.monitor;function Wa(e){if(0)var t;var r=ro(Xu.registerUsage(),lv(e),sl(e.element,{attribute:"draggable",value:"true"}));return yr(r)}a(Wa,"draggable");function Hg(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(Hg,"ownKeys");function Fg(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Hg(Object(r),!0).forEach(function(o){Ao(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Hg(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(Fg,"_objectSpread");var cv={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")},Og=Symbol("closestEdge");function _g(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:cv[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 Fg(Fg({},e),{},Ao({},Og,d))}a(_g,"attachClosestEdge");function za(e){var t;return(t=e[Og])!==null&&t!==void 0?t:null}a(za,"extractClosestEdge");import{Color as Bb}from"@tiptap/extension-color";import{Extension as uv}from"@tiptap/core";import{dropCursor as dv}from"@tiptap/pm/dropcursor";var Qu=uv.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[dv(this.options)]}});import{HardBreak as mv}from"@tiptap/extension-hard-break";var cl=mv.extend({renderHTML(){return["span",{class:"hard-break-wrapper","data-hard-break":"true"},["br"],"\u200B"]},parseHTML(){return[{tag:'span[data-hard-break="true"]'},{tag:"br"}]}});import{Extension as pv}from"@tiptap/core";import{undo as fv,redo as gv,history as hv}from"@tiptap/pm/history";var bv=pv.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>fv(e,t),redo:()=>({state:e,dispatch:t})=>gv(e,t)}},addProseMirrorPlugins(){return[hv(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});import{Placeholder as Db}from"@tiptap/extension-placeholder";import{TextAlign as Vb}from"@tiptap/extension-text-align";import{Typography as Hb}from"@tiptap/extension-typography";import{Underline as Fb}from"@tiptap/extension-underline";import{StarterKit as Ob}from"@tiptap/starter-kit";import{mergeAttributes as Rv}from"@tiptap/core";import{Node as yv,mergeAttributes as vv,wrappingInputRule as Cv}from"@tiptap/core";var xv=/^\s*>\s$/,Wg=yv.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",vv(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[Cv({find:xv,type:this.type})]}});import{Fragment as Jg,Slice as Kg}from"@tiptap/pm/model";import{Plugin as Bv,PluginKey as Dv}from"@tiptap/pm/state";import{ReactNodeViewRenderer as Vv}from"@tiptap/react";import{v4 as Gg}from"uuid";import{v4 as Tv}from"uuid";function je(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-${Tv()}`;r.setNodeMarkup(i,void 0,{...n.attrs,id:s}),o=!0}return!1}),o&&e.view.dispatch(r)}a(je,"generateNodeIds");import{NodeViewContent as kv,NodeViewWrapper as Pv}from"@tiptap/react";import{useSetAtom as Mv,useAtomValue as Nv}from"jotai";import{useCallback as Sv,useEffect as Av,useRef as Iv}from"react";import{atom as pr}from"jotai";var ed={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"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:"enabled"},variable:{state:"enabled"}},ul=a((e,t=!1)=>{let r=["paragraph","heading","blockquote"].includes(e);if(r&&t)return{contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:e==="blockquote"?"hidden":"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{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"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:"hidden"},variable:{state:"enabled"}};switch(e){case"list":return{contentType:{state:"hidden"},bold:{state:t?"enabled":"hidden"},italic:{state:t?"enabled":"hidden"},underline:{state:t?"enabled":"hidden"},strike:{state:t?"enabled":"hidden"},alignLeft:{state:"enabled"},alignCenter:{state:"enabled"},alignRight:{state:"enabled"},alignJustify:{state:"enabled"},quote:{state:"hidden"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:t?"enabled":"hidden"},variable:{state:"enabled"}};case"button":return{bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"}};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"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"}}}},"getTextMenuConfigForNode");var Ev={paragraph:ed,heading:ed},Ua=pr(Ev),Te=pr(null),Ve=pr(null,(e,t,r)=>{t(Te,r)}),wv=pr({ref:null,caretPosition:null}),dl=pr({ref:null,caretPosition:null}),$a=pr({isFocused:!1,hasVariables:!1,showVariablePopup:!1}),zg=pr(e=>(t,r=!1)=>{let o=e(Ua),n=e($a),i=ul(t,r),s=o[t],l=i;return s&&Object.keys(s).forEach(u=>{var p,m;let d=u;d!=="conditionalRules"&&((p=i[d])==null?void 0:p.state)==="enabled"&&((m=s[d])==null?void 0:m.state)==="enabled"&&(l[d]=s[d])}),n.isFocused&&n.hasVariables&&(l={...l,variable:{state:"enabled"}}),e(Gt)||(l={...l,variable:{state:"hidden"}}),l}),Ug=pr(null,(e,t,{nodeName:r,config:o})=>{let n=e(Ua);t(Ua,{...n,[r]:{...n[r],...Object.fromEntries(Object.entries(o).filter(([i])=>i!=="conditionalRules").map(([i,s])=>[i,{state:!Array.isArray(s)&&(s!=null&&s.state)?s.state:"hidden"}]))}})}),AI=pr(null,(e,t,r)=>{let o=e(Ua),{[r]:n,...i}=o;t(Ua,i)}),$g=pr(null,(e,t,{ref:r,caretPosition:o})=>{t(wv,{ref:r,caretPosition:o})}),II=pr(null,(e,t,r)=>{let o=e($a);t($a,{...o,showVariablePopup:r})}),Rn=pr(null),Yo=pr(null,(e,t,r)=>{t(Rn,r)});import{jsx as Bn}from"react/jsx-runtime";var Lv=a(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderLeftWidth:o,borderColor:n})=>Bn("div",{className:"courier-w-full courier-my-2 node-element",children:Bn("div",{style:{position:"relative",padding:`${t}px ${e}px`,backgroundColor:r,borderLeftWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",fontStyle:Br.fontStyle,color:Br.color,fontSize:Br.fontSize,lineHeight:Br.lineHeight,whiteSpace:"pre-wrap"},children:Bn(kv,{})})}),"BlockquoteComponent"),qg=a(e=>{var l,c,u;let t=Mv(Ve),r=Nv(Te),o=Iv(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=Sv(()=>{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]);Av(()=>{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 Bn(Pv,{as:"blockquote",children:Bn("div",{ref:o,children:Bn(Ct,{id:e.node.attrs.id,className:R(n&&"selected-element",s&&"is-empty"),editor:e.editor,children:Bn(Lv,{...e.node.attrs})})})})},"BlockquoteComponentNode");var jg="Helvetica, Arial, sans-serif",Vt={p:{color:"#000000",fontSize:"14px",lineHeight:"18px"},h1:{color:"#000000",fontSize:"32px",fontWeight:"600",lineHeight:"40px"},h2:{color:"#000000",fontSize:"24px",fontWeight:"600",lineHeight:"32px"},h3:{color:"#000000",fontSize:"18.72px",fontWeight:"600",lineHeight:"24px"},subtext:{color:"#8F8F8F",fontSize:"11px",lineHeight:"15px"}},Br={color:"#696969",fontSize:"14px",lineHeight:"18px",fontStyle:"italic"},Dn={h1:{fontSize:Vt.h1.fontSize,fontWeight:Vt.h1.fontWeight,lineHeight:Vt.h1.lineHeight},h2:{fontSize:Vt.h2.fontSize,fontWeight:Vt.h2.fontWeight,lineHeight:Vt.h2.lineHeight},h3:{fontSize:Vt.h3.fontSize,fontWeight:Vt.h3.fontWeight,lineHeight:Vt.h3.lineHeight},subtext:{fontSize:Vt.subtext.fontSize,fontWeight:"normal",lineHeight:Vt.subtext.lineHeight},quote:{fontSize:Br.fontSize,fontWeight:"normal",lineHeight:Br.lineHeight}};function Zg(){let e=Vt.p,t=Vt.h1,r=Vt.h2,o=Vt.h3,n=Br,i=Dn.h1,s=Dn.h2,l=Dn.h3,c=Dn.quote;return{"--email-editor-font-family":jg,"--email-editor-p-color":e.color,"--email-editor-p-font-size":e.fontSize,"--email-editor-p-line-height":e.lineHeight,"--email-editor-h1-color":t.color,"--email-editor-h1-font-size":t.fontSize,"--email-editor-h1-font-weight":t.fontWeight,"--email-editor-h1-line-height":t.lineHeight,"--email-editor-h2-color":r.color,"--email-editor-h2-font-size":r.fontSize,"--email-editor-h2-font-weight":r.fontWeight,"--email-editor-h2-line-height":r.lineHeight,"--email-editor-h3-color":o.color,"--email-editor-h3-font-size":o.fontSize,"--email-editor-h3-font-weight":o.fontWeight,"--email-editor-h3-line-height":o.lineHeight,"--email-editor-blockquote-p-color":n.color,"--email-editor-blockquote-p-font-size":c.fontSize,"--email-editor-blockquote-p-line-height":c.lineHeight,"--email-editor-blockquote-p-font-style":n.fontStyle,"--email-editor-blockquote-p-font-weight":c.fontWeight,"--email-editor-blockquote-h1-color":n.color,"--email-editor-blockquote-h1-font-size":i.fontSize,"--email-editor-blockquote-h1-font-weight":i.fontWeight,"--email-editor-blockquote-h1-line-height":i.lineHeight,"--email-editor-blockquote-h1-font-style":n.fontStyle,"--email-editor-blockquote-h2-color":n.color,"--email-editor-blockquote-h2-font-size":s.fontSize,"--email-editor-blockquote-h2-font-weight":s.fontWeight,"--email-editor-blockquote-h2-line-height":s.lineHeight,"--email-editor-blockquote-h2-font-style":n.fontStyle,"--email-editor-blockquote-h3-color":n.color,"--email-editor-blockquote-h3-font-size":l.fontSize,"--email-editor-blockquote-h3-font-weight":l.fontWeight,"--email-editor-blockquote-h3-line-height":l.lineHeight,"--email-editor-blockquote-h3-font-style":n.fontStyle}}a(Zg,"getEmailEditorTiptapCssVars");var Hv=new Dv("blockquotePaste");function td(e,t){let r=[];return e.forEach(o=>{if(o.type.name==="blockquote"){let n={...o.attrs,id:`node-${Gg()}`},i=td(o.content,t);r.push(o.type.create(n,i,o.marks))}else if(o.childCount>0){let n=td(o.content,t);r.push(o.copy(n))}else r.push(o)}),Jg.from(r)}a(td,"reassignBlockquoteIds");function Xg(e){let t=[];for(let r of e)if(r.type.name==="blockquote"){let o=[];r.content.forEach(n=>o.push(n)),t.push(...Xg(o))}else t.push(r);return t}a(Xg,"flattenBlockquotes");var vr={paddingHorizontal:20,paddingVertical:4,backgroundColor:"transparent",borderLeftWidth:2,borderColor:"#e0e0e0"},rd=Wg.extend({content:"block+",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){je(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${Gg()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},paddingHorizontal:{default:vr.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:vr.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:vr.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderLeftWidth:{default:vr.borderLeftWidth,parseHTML:e=>e.getAttribute("data-border-left-width"),renderHTML:e=>({"data-border-left-width":e.borderLeftWidth})},borderColor:{default:vr.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",Rv(e,{"data-type":"blockquote","data-id":e.id}),0]},addKeyboardShortcuts(){return{"Mod-i":({editor:e})=>e.isActive("blockquote"),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()}}},addProseMirrorPlugins(){var e,t;return[...(t=(e=this.parent)==null?void 0:e.call(this))!=null?t:[],new Bv({key:Hv,props:{transformPasted:r=>{let o=td(r.content,r.content);return new Kg(o,r.openStart,r.openEnd)},handlePaste:(r,o,n)=>{var C,T;let{state:i}=r,{$from:s}=i.selection;if(!(()=>{for(let E=s.depth;E>0;E--)if(s.node(E).type.name==="blockquote")return!0;return!1})()||!(()=>{let E=!1;return n.content.forEach(b=>{b.type.name==="blockquote"&&(E=!0)}),E})())return!1;let u=((C=n.content.firstChild)==null?void 0:C.type.name)==="blockquote",d=((T=n.content.lastChild)==null?void 0:T.type.name)==="blockquote",p=[];n.content.forEach(E=>p.push(E));let m=Xg(p),f=u?Math.max(0,n.openStart-1):n.openStart,v=d?Math.max(0,n.openEnd-1):n.openEnd,h=new Kg(Jg.from(m),f,v),y=i.tr.replaceSelection(h);return r.dispatch(y),!0}}})]},addNodeView(){return Vv(qg)}});import{zodResolver as _0}from"@hookform/resolvers/zod";import{useForm as W0}from"react-hook-form";import{useCallback as Fv,useEffect as Ov,useRef as Yg}from"react";var xt=a(({editor:e,element:t,form:r,nodeType:o})=>{let n=Yg(null),i=Yg(null);return Ov(()=>{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:Fv(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)&&(Po(!0),e.chain().command(({tr:p,dispatch:m})=>{let f=p.doc.nodeAt(i.current);if((f==null?void 0:f.type.name)===o&&m){let v=l.listType;if(o==="list"&&v){let h=p.doc.resolve(i.current),y=[];for(let C=h.depth-1;C>=0;C--)h.node(C).type.name==="list"&&y.push(h.before(C));for(let C of y){let T=p.doc.nodeAt(C);if(T&&T.type.name==="list")try{p.setNodeMarkup(C,T.type,{...T.attrs,listType:v})}catch{}}}return p.setNodeMarkup(i.current,f.type,u),p.setMeta("addToHistory",!0),!0}return!1}).run(),requestAnimationFrame(()=>{Po(!1)}))},[e,o])}},"useNodeAttributes");import{useAtomValue as ml,useSetAtom as zv}from"jotai";import{useMemo as t1,useCallback as r1}from"react";import{atom as Qg}from"jotai";import{jsx as Ai}from"react/jsx-runtime";var Vn=[{label:"Email",value:"email",icon:Ai(Au,{})},{label:"SMS",value:"sms",icon:Ai(Ou,{})},{label:"Push",value:"push",icon:Ai(Vu,{})},{label:"In-app",value:"inbox",icon:Ai(La,{})},{label:"Slack",value:"slack",icon:Ai(_u,{})},{label:"Teams",value:"msteams",icon:Ai(Lu,{})}];var oo=Qg("email"),Ii=Qg("template");var Qo=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,...Qo(n,i)]:[...r,i]},[]),"getFlattenedVariables");var _v={link:["href","content"],img:["src","href","alt_text"],image:["src","href","alt_text"],action:["href","content"],meta:["title"],list:["imgSrc","imgHref"],quote:["content"],html:[]},Wv=["content","href","src","title"],e1=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&&vt(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=_v[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;Wv.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 wL=a(e=>{let t=ml(Le),r=ml(le),o=ml(oo),n=ml(Mn),i=zv(Mn),s=e!=null?e:o,l=t1(()=>{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 Qo(p)},[t]),c=t1(()=>{if(!r||!s)return[];let p=r.elements.find(m=>m.type==="channel"&&m.channel===s);return p?e1(p.elements||[]):[]},[r,s]),u=r1((p,m)=>{i(f=>({...f,[p]:m}))},[i]),d=r1(()=>{i({})},[i]);return{availableVariables:l,usedVariables:c,variableValues:n,addVariableValue:u,clearAllVariableValues:d}},"useVariables");import{useAtom as Rl,useAtomValue as O0}from"jotai";import{useCallback as so}from"react";import{v4 as H0}from"uuid";import{mergeAttributes as Jv,Node as Gv}from"@tiptap/core";import{ReactNodeViewRenderer as Xv}from"@tiptap/react";import{v4 as Yv}from"uuid";import{NodeViewContent as Uv}from"@tiptap/react";import{useSetAtom as $v,useAtomValue as qv}from"jotai";import{useCallback as od,useEffect as o1,useState as nd,useRef as jv}from"react";import{jsx as no}from"react/jsx-runtime";var Zv=a(({columnId:e,index:t,isPreviewMode:r})=>{let o=jv(null),[n,i]=nd(!1);return o1(()=>{let s=o.current;if(s)return mr({element:s,getData:()=>({type:"column-cell",columnId:e,index:t,isEmpty:!0}),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e,t]),no("div",{ref:o,"data-placeholder-cell":"true","data-column-cell":"true","data-column-id":e,"data-cell-index":t,onClick:s=>{s.stopPropagation()},className:R("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&&no("span",{className:"courier-pointer-events-none",children:"Drag and drop content blocks"})})},"PlaceholderCell"),Kv=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 no("div",{className:"courier-w-full node-element",style:p,children:no("div",{className:"courier-w-full courier-flex courier-gap-2 courier-p-2",style:d,children:Array.from({length:l}).map((v,h)=>no(Zv,{columnId:f,index:h,isPreviewMode:c},h))})})}return no("div",{className:"courier-w-full node-element",style:p,children:no("div",{className:"courier-w-full courier-p-2",style:d,children:no(Uv,{})})})},"ColumnComponent"),n1=a(e=>{let t=$v(Ve),r=qv(Xt),[o,n]=nd(!1),[i,s]=nd(e.editor.isEditable);o1(()=>{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=od(p=>{var g,x;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"),C=m.classList.contains("courier-gap-2"),T=m.classList.contains("draggable-item"),E=m.hasAttribute("data-drag-handle")||m.closest("[data-drag-handle]")!==null;if(v||h||y||C||T||E||((x=(g=m.closest("[data-node-view-content]"))==null?void 0:g.parentElement)==null?void 0:x.classList.contains("node-element"))){p.stopPropagation(),E||p.preventDefault();let k=st(e);if(k){e.editor.commands.blur();let P=k.attrs.id;e.editor.state.doc.descendants(S=>S.type.name==="column"&&S.attrs.id===P?(t(S),!1):!0)}}},[e,t]),u=od(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,C=30,T=y<=h.top+C||y>=h.bottom-C;n(T)},[]),d=od(()=>{n(!1)},[]);return no(Ct,{id:e.node.attrs.id,className:R(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:no(Kv,{...e.node.attrs,node:e.node,columnsCount:e.node.attrs.columnsCount||2,isPreviewMode:l})})},"ColumnComponentNode");var Lt={columnsCount:2,paddingHorizontal:0,paddingVertical:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"transparent",cells:[]},pl=Gv.create({name:"column",group:"block",content:"columnRow?",isolating:!0,selectable:!1,onCreate(){je(this.editor,this.name)},addAttributes(){return{columnsCount:{default:Lt.columnsCount,parseHTML:e=>e.getAttribute("data-columns-count"),renderHTML:e=>({"data-columns-count":e.columnsCount})},paddingHorizontal:{default:Lt.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:Lt.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:Lt.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:Lt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:Lt.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:Lt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:()=>`node-${Yv()}`,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",Jv(this.options.HTMLAttributes,e,{"data-type":"column"}),0]},addNodeView(){return Xv(n1)},addCommands(){return{setColumn:e=>({chain:t})=>{let r=e.columnsCount||Lt.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"}}}});import{mergeAttributes as r0,Node as o0}from"@tiptap/core";import{ReactNodeViewRenderer as n0}from"@tiptap/react";import{v4 as i0}from"uuid";import{useSetAtom as Qv}from"jotai";import{useCallback as e0}from"react";import{jsx as fl}from"react/jsx-runtime";var t0=a(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return fl("div",{className:"courier-w-full node-element",children:fl("div",{className:"courier-custom-code courier-py-1.5",dangerouslySetInnerHTML:t?{__html:e}:{__html:"&#160;"}})})},"CustomCodeComponent"),i1=a(e=>{let t=Qv(Ve),r=e0(()=>{if(!e.editor.isEditable)return;let i=st(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 fl(Ct,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element",n&&"is-empty"),onClick:r,editor:e.editor,"data-node-type":"customCode",children:fl(t0,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var Io={code:"<!-- Add your HTML code here -->"},gl=o0.create({name:"customCode",group:"block",atom:!0,selectable:!1,onCreate(){je(this.editor,this.name)},addAttributes(){return{code:{default:Io.code,parseHTML:e=>e.getAttribute("data-code")||"",renderHTML:e=>({"data-code":e.code})},id:{default:()=>`node-${i0()}`,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",r0(this.options.HTMLAttributes,e,{"data-type":"custom-code"}),["div",{innerHTML:e.code||Io.code}]]},addNodeView(){return n0(i1)},addCommands(){return{setCustomCode:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e}).run()}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"}}}});import{mergeAttributes as f0}from"@tiptap/core";import{Node as a0,mergeAttributes as s0,isNodeSelection as l0,nodeInputRule as c0}from"@tiptap/core";import{TextSelection as id,NodeSelection as u0}from"@tiptap/pm/state";var a1=a0.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",s0(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}):l0(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(id.create(s.doc,u.pos+1)):u.nodeAfter.isBlock?s.setSelection(u0.create(s.doc,u.pos)):s.setSelection(id.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(id.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[c0({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});import{ReactNodeViewRenderer as g0}from"@tiptap/react";import{v4 as h0}from"uuid";import{useSetAtom as d0}from"jotai";import{useCallback as m0}from"react";import{jsx as hl}from"react/jsx-runtime";var p0=a(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>hl("div",{className:"courier-w-full node-element courier-flex",children:hl("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"),s1=a(e=>{let t=d0(Ve),r=m0(()=>{if(!e.editor.isEditable)return;let o=st(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return hl(Ct,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:hl(p0,{...e.node.attrs})})},"DividerComponentNode");var qt={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},en={padding:24,color:"transparent",size:1,radius:0,variant:"spacer"},ad=a1.extend({name:"divider",atom:!0,onCreate(){je(this.editor,this.name)},addAttributes(){return{padding:{default:qt.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.margin})},size:{default:qt.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},color:{default:qt.color,parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color})},width:{default:qt.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},radius:{default:qt.radius,parseHTML:e=>e.getAttribute("data-radius"),renderHTML:e=>({"data-radius":e.radius})},variant:{default:qt.variant,parseHTML:e=>e.getAttribute("data-variant"),renderHTML:e=>({"data-variant":e.variant})},id:{default:()=>`node-${h0()}`,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",f0(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return g0(s1)},addInputRules(){return[]}});import{mergeAttributes as x0,Node as T0}from"@tiptap/core";import{ReactNodeViewRenderer as E0}from"@tiptap/react";import{useSetAtom as l1}from"jotai";import{useCallback as ao,useEffect as d1,useRef as c1,useState as u1}from"react";import{jsx as sd}from"react/jsx-runtime";var Hn=a(({className:e})=>sd("div",{className:R("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:sd("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:sd("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");import{Fragment as C0,jsx as io,jsxs as ld}from"react/jsx-runtime";var b0=["image/png","image/jpeg","image/gif","image/webp"],y0=a(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderColor:n,isUploading:i,width:s,onFileSelect:l})=>{let[c,u]=u1(!1),[d,p]=u1(!0),m=c1(null),f=c1(null);d1(()=>{e&&p(!0)},[e]);let v=ao(g=>b0.includes(g),[]),h=ao(g=>{g.preventDefault(),g.stopPropagation(),g.dataTransfer.types.includes("Files")&&Array.from(g.dataTransfer.items).some(P=>v(P.type))&&(u(!0),g.dataTransfer.dropEffect="copy")},[v]),y=ao(g=>{g.preventDefault(),g.stopPropagation(),u(!1)},[]),C=ao(g=>{g.preventDefault(),g.stopPropagation(),g.dataTransfer.types.includes("Files")&&Array.from(g.dataTransfer.items).some(P=>v(P.type))&&u(!0)},[v]),T=ao(g=>{g.preventDefault(),g.stopPropagation(),u(!1);let k=Array.from(g.dataTransfer.files).find(P=>v(P.type));k&&l&&l(k)},[l,v]),E=ao(g=>{var k;let x=(k=g.target.files)==null?void 0:k[0];x&&l&&l(x),g.target&&(g.target.value="")},[l]),b=ao(()=>{var g;(g=m.current)==null||g.click()},[]);return Gs(e)?ld("div",{className:R("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",c&&"courier-border-primary courier-bg-gray-50"),onDragOver:h,onDragEnter:C,onDragLeave:y,onDrop:T,style:{pointerEvents:"all"},children:[i?io(Hn,{className:"courier-w-8 courier-h-8"}):ld(C0,{children:[io("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),io("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:b,children:"Browse"})]}),io("input",{ref:m,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:E})]}):io("div",{className:"courier-w-full node-element",children:ld("div",{className:R("courier-relative courier-p-1",(i||d)&&"courier-w-full courier-aspect-[4/3] courier-bg-gray-100"),children:[(i||d)&&io("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:io(Hn,{className:"courier-w-8 courier-h-8"})}),io("img",{ref:f,src:e,alt:t,className:R("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:`${s}%`,borderWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",display:"block"},loading:"lazy",decoding:"async",draggable:!1,onLoad:()=>{p(!1)},onError:()=>p(!1)})]})})},"ImageBlockComponent"),v0=["image/png","image/jpeg","image/gif","image/webp"],m1=a(e=>{let t=l1(Ve),r=l1(se),{uploadImage:o}=Na(),n=ao(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]);d1(()=>{var u,d;let l=st(e);if(!((u=l==null?void 0:l.attrs)!=null&&u.sourcePath)||(d=l==null?void 0:l.attrs)!=null&&d.imageNaturalWidth)return;let c=new Image;c.onload=()=>{let p=tn(e.getPos);if(p!==null)try{if(!e.editor.view||!e.editor.state)return;let m=e.editor.state.doc.nodeAt(p);if(!m||m.type.name!=="imageBlock")return;let f=m.attrs.width||n(c.naturalWidth),{tr:v}=e.editor.state;v.setNodeMarkup(p,void 0,{...m.attrs,width:f,imageNaturalWidth:c.naturalWidth}),e.editor.view.dispatch(v)}catch{}},c.src=l.attrs.sourcePath},[e,n]);let i=ao(()=>{if(!e.editor.isEditable)return;let l=st(e);l&&(e.editor.commands.blur(),t(l))},[e,t]),s=ao(async l=>{let c=tn(e.getPos);st(e)&&c!==null&&e.editor.chain().focus().setNodeSelection(c).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!v0.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=tn(e.getPos);if(st(e)&&f!==null){let h=new Image;h.src=m,await new Promise((C,T)=>{h.onload=C,h.onerror=()=>T(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=tn(e.getPos);st(e)&&m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return io(Ct,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:io(y0,{...e.node.attrs,onFileSelect:s})})},"ImageBlockView");var tt={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderColor:"transparent",isUploading:!1,imageNaturalWidth:0},bl=T0.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){je(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:tt.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:tt.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:tt.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:tt.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:tt.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:tt.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:tt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:tt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:tt.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",x0(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return E0(m1)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...tt,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...tt,sourcePath:t||""}}).run(),setImageBlockAlign:e=>({commands:t})=>t.updateAttributes(this.name,{alignment:e}),setImageBlockWidth:e=>({commands:t})=>t.updateAttributes(this.name,{width:e}),uploadImage:e=>({chain:t})=>{let r=new FileReader;return r.onload=()=>{t().setImageBlock({sourcePath:r.result,isUploading:!0}).run()},r.readAsDataURL(e),!0}}}});import{z as Lo}from"zod";var p1=Lo.object({paddingVertical:Lo.number(),paddingHorizontal:Lo.number(),backgroundColor:Lo.string(),borderWidth:Lo.number(),borderColor:Lo.string(),textAlign:Lo.enum(["left","center","right","justify"]).default("left"),selected:Lo.boolean().default(!1),id:Lo.string().optional()}),Ce={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderColor:"transparent",textAlign:"left",selected:!1};import{NodeViewContent as w0,NodeViewWrapper as k0}from"@tiptap/react";import{useSetAtom as P0,useAtomValue as M0}from"jotai";import{useCallback as N0}from"react";import{jsx as rn}from"react/jsx-runtime";var f1=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=M0(Xt);return rn("div",{className:"courier-w-full node-element",children:rn("div",{style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderColor:i,borderStyle:n>0?"solid":"none"},children:rn("div",{style:{pointerEvents:u?"none":"auto"},children:rn(w0,{as:c})})})})},"TextBlockComponent"),yl=a(e=>{let t=P0(Ve),r=N0(()=>{if(!e.editor.isEditable)return;let c=st(e);c&&t(c)},[e,t]),o=!e.node.content||e.node.content.size===0,n=tn(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null,s=(i==null?void 0:i.parent.type.name)==="blockquote",l=(i==null?void 0:i.parent.type.name)==="listItem";return s||l?rn(k0,{children:rn(f1,{...e.node.attrs,type:e.node.type.name})}):rn(Ct,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:rn(f1,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");import{zodResolver as D0}from"@hookform/resolvers/zod";import{useForm as V0}from"react-hook-form";import{useSetAtom as R0}from"jotai";import{jsx as g1,jsxs as S0}from"react/jsx-runtime";var Ze=a(({draggable:e=!1,icon:t,draggableLabel:r,label:o})=>S0("div",{className:"courier-flex courier-flex-row courier-items-center courier-gap-2",children:[g1("div",{className:R("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}),g1("span",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:e?r:o})]}),"BlockBase");import{Quote as A0}from"lucide-react";import{jsx as h1}from"react/jsx-runtime";var vl=a(({draggable:e=!1})=>h1(Ze,{draggable:e,icon:h1(A0,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),draggableLabel:"Blockquote",label:"Blockquote block"}),"BlockquoteBlock");import{jsx as Cl}from"react/jsx-runtime";var cd=a(()=>Cl("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Cl("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"),on=a(({draggable:e=!1})=>Cl(Ze,{draggable:e,icon:Cl(cd,{}),draggableLabel:"Button",label:"Button block"}),"ButtonBlock");import{jsx as xl}from"react/jsx-runtime";var ud=a(()=>xl("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:xl("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"),Tl=a(({draggable:e=!1})=>xl(Ze,{draggable:e,icon:xl(ud,{}),draggableLabel:"Column layout",label:"Column layout"}),"ColumnBlock");import{jsx as El}from"react/jsx-runtime";var dd=a(()=>El("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:El("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"),wl=a(({draggable:e=!1})=>El(Ze,{draggable:e,icon:El(dd,{}),draggableLabel:"Custom code",label:"Custom code"}),"CustomCodeBlock");import{jsx as kl}from"react/jsx-runtime";var md=a(()=>kl("svg",{width:"16",height:"2",viewBox:"0 0 16 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:kl("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"),nn=a(({draggable:e=!1})=>kl(Ze,{draggable:e,icon:kl(md,{}),draggableLabel:"Divider",label:"Divider block"}),"DividerBlock");import{jsx as Pl}from"react/jsx-runtime";var pd=a(()=>Pl("svg",{width:"18",height:"13",viewBox:"0 0 18 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Pl("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"),Ml=a(({draggable:e=!1})=>Pl(Ze,{draggable:e,icon:Pl(pd,{}),draggableLabel:"Heading",label:"Heading block"}),"HeadingBlock");import{jsx as Nl}from"react/jsx-runtime";var fd=a(()=>Nl("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Nl("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=a(({draggable:e=!1})=>Nl(Ze,{draggable:e,icon:Nl(fd,{}),draggableLabel:"Image",label:"Image block"}),"ImageBlock");import{List as I0}from"lucide-react";import{jsx as b1}from"react/jsx-runtime";var an=a(({draggable:e=!1})=>b1(Ze,{draggable:e,icon:b1(I0,{strokeWidth:1.5,className:"courier-w-4 courier-h-4 courier-text-black dark:courier-text-white"}),draggableLabel:"List",label:"List block"}),"ListBlock");import{AlignVerticalSpaceAround as L0}from"lucide-react";import{jsx as y1}from"react/jsx-runtime";var Al=a(({draggable:e=!1})=>y1(Ze,{draggable:e,icon:y1(L0,{className:"courier-w-4 courier-h-4"}),draggableLabel:"Spacer",label:"Spacer block"}),"SpacerBlock");import{jsx as Il}from"react/jsx-runtime";var gd=a(()=>Il("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Il("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"),sn=a(({draggable:e=!1})=>Il(Ze,{draggable:e,icon:Il(gd,{}),draggableLabel:"Text",label:"Text block"}),"TextBlock");import{jsx as Cr,jsxs as B0}from"react/jsx-runtime";var Tt=a(({type:e,hideCloseButton:t=!1})=>{let r=R0(Ve);return B0("div",{className:"courier-flex courier-gap-4 courier-flex-col",children:[!t&&Cr(Ae,{className:"courier-w-fit",variant:"secondary",buttonSize:"small",onClick:()=>{r(null)},children:"Close"}),e==="heading"&&Cr(Ml,{}),e==="text"&&Cr(sn,{}),e==="image"&&Cr(Sl,{}),e==="spacer"&&Cr(Al,{}),e==="divider"&&Cr(nn,{}),e==="button"&&Cr(on,{}),e==="blockquote"&&Cr(vl,{}),e==="customCode"&&Cr(wl,{}),e==="column"&&Cr(Tl,{}),e==="list"&&Cr(an,{}),Cr(pe,{className:"courier-m-0"})]})},"FormHeader");import{jsx as Be,jsxs as ln}from"react/jsx-runtime";var v1=a(({element:e,editor:t,hideCloseButton:r=!1})=>{let o=V0({resolver:D0(p1),defaultValues:{...Ce,...e==null?void 0:e.attrs}}),{updateNodeAttributes:n}=xt({editor:t,element:e,form:o,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?ln(Oe,{...o,children:[Be(Tt,{type:"text",hideCloseButton:r}),ln("form",{"data-sidebar-form":!0,onChange:()=>{n(o.getValues())},children:[Be("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),ln("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[Be(re,{control:o.control,name:"paddingHorizontal",render:({field:i})=>ln(ee,{children:[Be(te,{children:Be(ge,{startAdornment:Be(So,{}),type:"number",min:0,...i})}),Be(oe,{})]})}),Be(re,{control:o.control,name:"paddingVertical",render:({field:i})=>ln(ee,{children:[Be(te,{children:Be(ge,{startAdornment:Be(Rr,{}),type:"number",min:0,...i})}),Be(oe,{})]})})]}),Be(re,{control:o.control,name:"backgroundColor",render:({field:i})=>ln(ee,{className:"courier-mb-4",children:[Be(te,{children:Be(Et,{...i,defaultValue:Ce.backgroundColor,onChange:s=>{i.onChange(s),n({...o.getValues(),[i.name]:s})}})}),Be(oe,{})]})}),Be(pe,{className:"courier-mb-4"}),Be("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),Be(re,{control:o.control,name:"borderWidth",render:({field:i})=>ln(ee,{className:"courier-mb-3",children:[Be(te,{children:Be(ge,{startAdornment:Be(No,{}),type:"number",min:0,...i})}),Be(oe,{})]})}),Be(re,{control:o.control,name:"borderColor",render:({field:i})=>ln(ee,{className:"courier-mb-4",children:[Be(te,{children:Be(Et,{...i,defaultValue:Ce.borderColor,onChange:s=>{i.onChange(s),n({...o.getValues(),[i.name]:s})}})}),Be(oe,{})]})})]})]}):null},"TextBlockForm");var F0=a((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),Ll=a((e,t,r,o,n,i)=>{let s=`node-${H0()}`,c={heading:()=>e.schema.nodes.heading.create({...Ce,...o,id:s},i),paragraph:()=>e.schema.nodes.paragraph.create({...Ce,...o,id:s},i),text:()=>e.schema.nodes.paragraph.create({...Ce,...o,id:s},i),spacer:()=>e.schema.nodes.divider.create({...en,...o,id:s}),divider:()=>e.schema.nodes.divider.create({...qt,...o,id:s}),button:()=>e.schema.nodes.button.create({...Se,...o,id:s},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...tt,...o,id:s}),image:()=>e.schema.nodes.imageBlock.create({...tt,...o,id:s}),customCode:()=>e.schema.nodes.customCode.create({...Io,...o,id:s}),column:()=>e.schema.nodes.column.create({...Lt,...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=F0(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 DD=a(()=>{let[e,t]=Rl(to),[r,o]=Rl(Us),[n,i]=Rl(Jo),s=O0(Le),l=Rl(Te)[1],c=so(T=>{l(T)},[l]),u=so(T=>{t(T)},[t]),d=so(()=>{t(zs)},[t]),p=so((T,E)=>{o(b=>({...b,[T]:{...b[T],...E}}))},[o]),m=so(T=>r[T],[r]),f=so(T=>{o(E=>{let b={...E};return delete b[T],b})},[o]),v=so(T=>{i(E=>{let b=E.findIndex(g=>g.type===T.type&&g.key===T.key);if(b>=0){let g=[...E];return g[b]=T,g}return[...E,T]})},[i]),h=so((T,E)=>{i(b=>b.filter(g=>!(g.type===T&&g.key===E)))},[i]),y=so(T=>n.filter(E=>E.type===T),[n]),C=so((T,E)=>{if(!s){console.warn("[useBlockConfig] Cannot insert block: editor not available");return}let b={};T==="spacer"&&(b={...en});let g=r[T];if(g&&(b={...b,...g}),E){let S=n.find(w=>w.type===T&&w.key===E);S?b={...b,...S.attributes}:console.warn(`[useBlockConfig] Preset "${E}" not found for type "${T}"`)}let x=s.state.doc.content.size,P={heading:"heading",text:"paragraph",image:"imageBlock",spacer:"divider",divider:"divider",button:"button",customCode:"customCode",column:"column",blockquote:"blockquote",list:"list"}[T];Ll(s,P,x,b,c)},[s,r,n,c]);return{visibleBlocks:e,setVisibleBlocks:u,resetVisibleBlocks:d,defaultVisibleBlocks:zs,setDefaults:p,getDefaults:m,clearDefaults:f,registerPreset:v,unregisterPreset:h,presets:n,getPresetsForType:y,insertBlock:C}},"useBlockConfig");import{z as Fn}from"zod";var C1=Fn.object({paddingHorizontal:Fn.coerce.number().min(0),paddingVertical:Fn.coerce.number().min(0),backgroundColor:Fn.string(),borderLeftWidth:Fn.coerce.number().min(0),borderColor:Fn.string(),id:Fn.string().optional()});import{jsx as Li,jsxs as hd}from"react/jsx-runtime";var x1=a(({element:e,editor:t,hideCloseButton:r=!1})=>{let o=W0({resolver:_0(C1),defaultValues:{...vr,...e==null?void 0:e.attrs}}),{updateNodeAttributes:n}=xt({editor:t,element:e,form:o,nodeType:(e==null?void 0:e.type.name)||"blockquote"});return e?hd(Oe,{...o,children:[Li(Tt,{type:"blockquote",hideCloseButton:r}),hd("form",{"data-sidebar-form":!0,onChange:()=>{n(o.getValues())},children:[Li("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),Li(re,{control:o.control,name:"borderColor",render:({field:i})=>hd(ee,{className:"courier-mb-3",children:[Li(te,{children:Li(Et,{...i,defaultValue:vr.borderColor,onChange:s=>{i.onChange(s),n({...o.getValues(),[i.name]:s})}})}),Li(oe,{})]})})]})]}):null},"BlockquoteForm");import{z as Yt}from"zod";var Bl=Yt.object({label:Yt.string(),link:Yt.string().optional(),alignment:Yt.enum(["left","center","right"]),backgroundColor:Yt.string(),borderRadius:Yt.number(),paddingVertical:Yt.number(),paddingHorizontal:Yt.number(),fontWeight:Yt.enum(["normal","bold"]),fontStyle:Yt.enum(["normal","italic"]),isUnderline:Yt.boolean(),isStrike:Yt.boolean(),textColor:Yt.string().optional(),borderColor:Yt.string().optional()});import{zodResolver as W3}from"@hookform/resolvers/zod";import{useCallback as Zh,useEffect as z3,useRef as Kh}from"react";import{useForm as U3}from"react-hook-form";import{Node as z0}from"@tiptap/core";var Ri=z0.create({name:"doc",topNode:!0,content:"block+"});import{Node as U0,mergeAttributes as $0}from"@tiptap/core";var Bi=U0.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",$0(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});import P3 from"@tiptap/extension-placeholder";import{Node as q0}from"@tiptap/core";var Dl=q0.create({name:"text",group:"inline"});import{EditorContent as M3,useEditor as N3}from"@tiptap/react";import{useAtomValue as S3}from"jotai";import*as Gn from"react";import{useCallback as A3,useEffect as im}from"react";import{Extension as Xd,InputRule as ix,Node as ax}from"@tiptap/core";import{ReactNodeViewRenderer as sx}from"@tiptap/react";import{Suggestion as lx}from"@tiptap/suggestion";import{Plugin as Kd,PluginKey as Jd,TextSelection as Jl}from"prosemirror-state";import{Decoration as cx,DecorationSet as Gd}from"prosemirror-view";import{ReactRenderer as JC}from"@tiptap/react";var Ke="top",pt="bottom",lt="right",rt="left",Vl="auto",cn=[Ke,pt,lt,rt],Ro="start",On="end",T1="clippingParents",Hl="viewport",Di="popper",E1="reference",bd=cn.reduce(function(e,t){return e.concat([t+"-"+Ro,t+"-"+On])},[]),Fl=[].concat(cn,[Vl]).reduce(function(e,t){return e.concat([t,t+"-"+Ro,t+"-"+On])},[]),j0="beforeRead",Z0="read",K0="afterRead",J0="beforeMain",G0="main",X0="afterMain",Y0="beforeWrite",Q0="write",eC="afterWrite",w1=[j0,Z0,K0,J0,G0,X0,Y0,Q0,eC];function wt(e){return e?(e.nodeName||"").toLowerCase():null}a(wt,"getNodeName");function _e(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}a(_e,"getWindow");function xr(e){var t=_e(e).Element;return e instanceof t||e instanceof Element}a(xr,"isElement");function ft(e){var t=_e(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}a(ft,"isHTMLElement");function Vi(e){if(typeof ShadowRoot=="undefined")return!1;var t=_e(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}a(Vi,"isShadowRoot");function tC(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];!ft(i)||!wt(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(tC,"applyStyles");function rC(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},{});!ft(n)||!wt(n)||(Object.assign(n.style,l),Object.keys(i).forEach(function(c){n.removeAttribute(c)}))})}}a(rC,"effect");var qa={name:"applyStyles",enabled:!0,phase:"write",fn:tC,effect:rC,requires:["computeStyles"]};function kt(e){return e.split("-")[0]}a(kt,"getBasePlacement");var Dr=Math.max,_n=Math.min,Bo=Math.round;function Hi(){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(Hi,"getUAString");function ja(){return!/^((?!chrome|android).)*safari/i.test(Hi())}a(ja,"isLayoutViewport");function Tr(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!1);var o=e.getBoundingClientRect(),n=1,i=1;t&&ft(e)&&(n=e.offsetWidth>0&&Bo(o.width)/e.offsetWidth||1,i=e.offsetHeight>0&&Bo(o.height)/e.offsetHeight||1);var s=xr(e)?_e(e):window,l=s.visualViewport,c=!ja()&&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(Tr,"getBoundingClientRect");function Wn(e){var t=Tr(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(Wn,"getLayoutRect");function Za(e,t){var r=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(r&&Vi(r)){var o=t;do{if(o&&e.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}a(Za,"contains");function jt(e){return _e(e).getComputedStyle(e)}a(jt,"getComputedStyle");function yd(e){return["table","td","th"].indexOf(wt(e))>=0}a(yd,"isTableElement");function Rt(e){return((xr(e)?e.ownerDocument:e.document)||window.document).documentElement}a(Rt,"getDocumentElement");function Do(e){return wt(e)==="html"?e:e.assignedSlot||e.parentNode||(Vi(e)?e.host:null)||Rt(e)}a(Do,"getParentNode");function k1(e){return!ft(e)||jt(e).position==="fixed"?null:e.offsetParent}a(k1,"getTrueOffsetParent");function oC(e){var t=/firefox/i.test(Hi()),r=/Trident/i.test(Hi());if(r&&ft(e)){var o=jt(e);if(o.position==="fixed")return null}var n=Do(e);for(Vi(n)&&(n=n.host);ft(n)&&["html","body"].indexOf(wt(n))<0;){var i=jt(n);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||t&&i.willChange==="filter"||t&&i.filter&&i.filter!=="none")return n;n=n.parentNode}return null}a(oC,"getContainingBlock");function Vr(e){for(var t=_e(e),r=k1(e);r&&yd(r)&&jt(r).position==="static";)r=k1(r);return r&&(wt(r)==="html"||wt(r)==="body"&&jt(r).position==="static")?t:r||oC(e)||t}a(Vr,"getOffsetParent");function zn(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}a(zn,"getMainAxisFromPlacement");function Un(e,t,r){return Dr(e,_n(t,r))}a(Un,"within");function P1(e,t,r){var o=Un(e,t,r);return o>r?r:o}a(P1,"withinMaxClamp");function Ka(){return{top:0,right:0,bottom:0,left:0}}a(Ka,"getFreshSideObject");function Ja(e){return Object.assign({},Ka(),e)}a(Ja,"mergePaddingObject");function Ga(e,t){return t.reduce(function(r,o){return r[o]=e,r},{})}a(Ga,"expandToHashMap");var nC=a(function(t,r){return t=typeof t=="function"?t(Object.assign({},r.rects,{placement:r.placement})):t,Ja(typeof t!="number"?t:Ga(t,cn))},"toPaddingObject");function iC(e){var t,r=e.state,o=e.name,n=e.options,i=r.elements.arrow,s=r.modifiersData.popperOffsets,l=kt(r.placement),c=zn(l),u=[rt,lt].indexOf(l)>=0,d=u?"height":"width";if(!(!i||!s)){var p=nC(n.padding,r),m=Wn(i),f=c==="y"?Ke:rt,v=c==="y"?pt:lt,h=r.rects.reference[d]+r.rects.reference[c]-s[c]-r.rects.popper[d],y=s[c]-r.rects.reference[c],C=Vr(i),T=C?c==="y"?C.clientHeight||0:C.clientWidth||0:0,E=h/2-y/2,b=p[f],g=T-m[d]-p[v],x=T/2-m[d]/2+E,k=Un(b,x,g),P=c;r.modifiersData[o]=(t={},t[P]=k,t.centerOffset=k-x,t)}}a(iC,"arrow");function aC(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)||Za(t.elements.popper,n)&&(t.elements.arrow=n))}a(aC,"effect");var M1={name:"arrow",enabled:!0,phase:"main",fn:iC,effect:aC,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Er(e){return e.split("-")[1]}a(Er,"getVariation");var sC={top:"auto",right:"auto",bottom:"auto",left:"auto"};function lC(e,t){var r=e.x,o=e.y,n=t.devicePixelRatio||1;return{x:Bo(r*n)/n||0,y:Bo(o*n)/n||0}}a(lC,"roundOffsetsByDPR");function N1(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 C=s.hasOwnProperty("x"),T=s.hasOwnProperty("y"),E=rt,b=Ke,g=window;if(u){var x=Vr(r),k="clientHeight",P="clientWidth";if(x===_e(r)&&(x=Rt(r),jt(x).position!=="static"&&l==="absolute"&&(k="scrollHeight",P="scrollWidth")),x=x,n===Ke||(n===rt||n===lt)&&i===On){b=pt;var S=p&&x===g&&g.visualViewport?g.visualViewport.height:x[k];h-=S-o.height,h*=c?1:-1}if(n===rt||(n===Ke||n===pt)&&i===On){E=lt;var w=p&&x===g&&g.visualViewport?g.visualViewport.width:x[P];f-=w-o.width,f*=c?1:-1}}var M=Object.assign({position:l},u&&sC),L=d===!0?lC({x:f,y:h},_e(r)):{x:f,y:h};if(f=L.x,h=L.y,c){var N;return Object.assign({},M,(N={},N[b]=T?"0":"",N[E]=C?"0":"",N.transform=(g.devicePixelRatio||1)<=1?"translate("+f+"px, "+h+"px)":"translate3d("+f+"px, "+h+"px, 0)",N))}return Object.assign({},M,(t={},t[b]=T?h+"px":"",t[E]=C?f+"px":"",t.transform="",t))}a(N1,"mapToStyles");function cC(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:kt(t.placement),variation:Er(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,N1(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,N1(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(cC,"computeStyles");var S1={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:cC,data:{}};var Ol={passive:!0};function uC(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=_e(t.elements.popper),u=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&u.forEach(function(d){d.addEventListener("scroll",r.update,Ol)}),l&&c.addEventListener("resize",r.update,Ol),function(){i&&u.forEach(function(d){d.removeEventListener("scroll",r.update,Ol)}),l&&c.removeEventListener("resize",r.update,Ol)}}a(uC,"effect");var A1={name:"eventListeners",enabled:!0,phase:"write",fn:a(function(){},"fn"),effect:uC,data:{}};var dC={left:"right",right:"left",bottom:"top",top:"bottom"};function Fi(e){return e.replace(/left|right|bottom|top/g,function(t){return dC[t]})}a(Fi,"getOppositePlacement");var mC={start:"end",end:"start"};function _l(e){return e.replace(/start|end/g,function(t){return mC[t]})}a(_l,"getOppositeVariationPlacement");function $n(e){var t=_e(e),r=t.pageXOffset,o=t.pageYOffset;return{scrollLeft:r,scrollTop:o}}a($n,"getWindowScroll");function qn(e){return Tr(Rt(e)).left+$n(e).scrollLeft}a(qn,"getWindowScrollBarX");function vd(e,t){var r=_e(e),o=Rt(e),n=r.visualViewport,i=o.clientWidth,s=o.clientHeight,l=0,c=0;if(n){i=n.width,s=n.height;var u=ja();(u||!u&&t==="fixed")&&(l=n.offsetLeft,c=n.offsetTop)}return{width:i,height:s,x:l+qn(e),y:c}}a(vd,"getViewportRect");function Cd(e){var t,r=Rt(e),o=$n(e),n=(t=e.ownerDocument)==null?void 0:t.body,i=Dr(r.scrollWidth,r.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),s=Dr(r.scrollHeight,r.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),l=-o.scrollLeft+qn(e),c=-o.scrollTop;return jt(n||r).direction==="rtl"&&(l+=Dr(r.clientWidth,n?n.clientWidth:0)-i),{width:i,height:s,x:l,y:c}}a(Cd,"getDocumentRect");function jn(e){var t=jt(e),r=t.overflow,o=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(r+n+o)}a(jn,"isScrollParent");function Wl(e){return["html","body","#document"].indexOf(wt(e))>=0?e.ownerDocument.body:ft(e)&&jn(e)?e:Wl(Do(e))}a(Wl,"getScrollParent");function un(e,t){var r;t===void 0&&(t=[]);var o=Wl(e),n=o===((r=e.ownerDocument)==null?void 0:r.body),i=_e(o),s=n?[i].concat(i.visualViewport||[],jn(o)?o:[]):o,l=t.concat(s);return n?l:l.concat(un(Do(s)))}a(un,"listScrollParents");function Oi(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}a(Oi,"rectToClientRect");function pC(e,t){var r=Tr(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(pC,"getInnerBoundingClientRect");function I1(e,t,r){return t===Hl?Oi(vd(e,r)):xr(t)?pC(t,r):Oi(Cd(Rt(e)))}a(I1,"getClientRectFromMixedType");function fC(e){var t=un(Do(e)),r=["absolute","fixed"].indexOf(jt(e).position)>=0,o=r&&ft(e)?Vr(e):e;return xr(o)?t.filter(function(n){return xr(n)&&Za(n,o)&&wt(n)!=="body"}):[]}a(fC,"getClippingParents");function xd(e,t,r,o){var n=t==="clippingParents"?fC(e):[].concat(t),i=[].concat(n,[r]),s=i[0],l=i.reduce(function(c,u){var d=I1(e,u,o);return c.top=Dr(d.top,c.top),c.right=_n(d.right,c.right),c.bottom=_n(d.bottom,c.bottom),c.left=Dr(d.left,c.left),c},I1(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(xd,"getClippingRect");function Xa(e){var t=e.reference,r=e.element,o=e.placement,n=o?kt(o):null,i=o?Er(o):null,s=t.x+t.width/2-r.width/2,l=t.y+t.height/2-r.height/2,c;switch(n){case Ke:c={x:s,y:t.y-r.height};break;case pt:c={x:s,y:t.y+t.height};break;case lt:c={x:t.x+t.width,y:l};break;case rt:c={x:t.x-r.width,y:l};break;default:c={x:t.x,y:t.y}}var u=n?zn(n):null;if(u!=null){var d=u==="y"?"height":"width";switch(i){case Ro:c[u]=c[u]-(t[d]/2-r[d]/2);break;case On:c[u]=c[u]+(t[d]/2-r[d]/2);break;default:}}return c}a(Xa,"computeOffsets");function Hr(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?T1:l,u=r.rootBoundary,d=u===void 0?Hl:u,p=r.elementContext,m=p===void 0?Di:p,f=r.altBoundary,v=f===void 0?!1:f,h=r.padding,y=h===void 0?0:h,C=Ja(typeof y!="number"?y:Ga(y,cn)),T=m===Di?E1:Di,E=e.rects.popper,b=e.elements[v?T:m],g=xd(xr(b)?b:b.contextElement||Rt(e.elements.popper),c,d,s),x=Tr(e.elements.reference),k=Xa({reference:x,element:E,strategy:"absolute",placement:n}),P=Oi(Object.assign({},E,k)),S=m===Di?P:x,w={top:g.top-S.top+C.top,bottom:S.bottom-g.bottom+C.bottom,left:g.left-S.left+C.left,right:S.right-g.right+C.right},M=e.modifiersData.offset;if(m===Di&&M){var L=M[n];Object.keys(w).forEach(function(N){var I=[lt,pt].indexOf(N)>=0?1:-1,D=[Ke,pt].indexOf(N)>=0?"y":"x";w[N]+=L[D]*I})}return w}a(Hr,"detectOverflow");function Td(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?Fl:c,d=Er(o),p=d?l?bd:bd.filter(function(v){return Er(v)===d}):cn,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]=Hr(e,{placement:h,boundary:n,rootBoundary:i,padding:s})[kt(h)],v},{});return Object.keys(f).sort(function(v,h){return f[v]-f[h]})}a(Td,"computeAutoPlacement");function gC(e){if(kt(e)===Vl)return[];var t=Fi(e);return[_l(e),t,_l(t)]}a(gC,"getExpandedFallbackPlacements");function hC(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,C=kt(y),T=C===y,E=c||(T||!v?[Fi(y)]:gC(y)),b=[y].concat(E).reduce(function(A,H){return A.concat(kt(H)===Vl?Td(t,{placement:H,boundary:d,rootBoundary:p,padding:u,flipVariations:v,allowedAutoPlacements:h}):H)},[]),g=t.rects.reference,x=t.rects.popper,k=new Map,P=!0,S=b[0],w=0;w<b.length;w++){var M=b[w],L=kt(M),N=Er(M)===Ro,I=[Ke,pt].indexOf(L)>=0,D=I?"width":"height",V=Hr(t,{placement:M,boundary:d,rootBoundary:p,altBoundary:m,padding:u}),W=I?N?lt:rt:N?pt:Ke;g[D]>x[D]&&(W=Fi(W));var j=Fi(W),O=[];if(i&&O.push(V[L]<=0),l&&O.push(V[W]<=0,V[j]<=0),O.every(function(A){return A})){S=M,P=!1;break}k.set(M,O)}if(P)for(var $=v?3:1,J=a(function(H){var _=b.find(function(B){var U=k.get(B);if(U)return U.slice(0,H).every(function(Z){return Z})});if(_)return S=_,"break"},"_loop"),q=$;q>0;q--){var F=J(q);if(F==="break")break}t.placement!==S&&(t.modifiersData[o]._skip=!0,t.placement=S,t.reset=!0)}}a(hC,"flip");var L1={name:"flip",enabled:!0,phase:"main",fn:hC,requiresIfExists:["offset"],data:{_skip:!1}};function R1(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(R1,"getSideOffsets");function B1(e){return[Ke,lt,pt,rt].some(function(t){return e[t]>=0})}a(B1,"isAnySideFullyClipped");function bC(e){var t=e.state,r=e.name,o=t.rects.reference,n=t.rects.popper,i=t.modifiersData.preventOverflow,s=Hr(t,{elementContext:"reference"}),l=Hr(t,{altBoundary:!0}),c=R1(s,o),u=R1(l,n,i),d=B1(c),p=B1(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(bC,"hide");var D1={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:bC};function yC(e,t,r){var o=kt(e),n=[rt,Ke].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,[rt,lt].indexOf(o)>=0?{x:l,y:s}:{x:s,y:l}}a(yC,"distanceAndSkiddingToXY");function vC(e){var t=e.state,r=e.options,o=e.name,n=r.offset,i=n===void 0?[0,0]:n,s=Fl.reduce(function(d,p){return d[p]=yC(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(vC,"offset");var V1={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:vC};function CC(e){var t=e.state,r=e.name;t.modifiersData[r]=Xa({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}a(CC,"popperOffsets");var H1={name:"popperOffsets",enabled:!0,phase:"read",fn:CC,data:{}};function Ed(e){return e==="x"?"y":"x"}a(Ed,"getAltAxis");function xC(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=Hr(t,{boundary:c,rootBoundary:u,padding:p,altBoundary:d}),C=kt(t.placement),T=Er(t.placement),E=!T,b=zn(C),g=Ed(b),x=t.modifiersData.popperOffsets,k=t.rects.reference,P=t.rects.popper,S=typeof h=="function"?h(Object.assign({},t.rects,{placement:t.placement})):h,w=typeof S=="number"?{mainAxis:S,altAxis:S}:Object.assign({mainAxis:0,altAxis:0},S),M=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,L={x:0,y:0};if(x){if(i){var N,I=b==="y"?Ke:rt,D=b==="y"?pt:lt,V=b==="y"?"height":"width",W=x[b],j=W+y[I],O=W-y[D],$=f?-P[V]/2:0,J=T===Ro?k[V]:P[V],q=T===Ro?-P[V]:-k[V],F=t.elements.arrow,A=f&&F?Wn(F):{width:0,height:0},H=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:Ka(),_=H[I],B=H[D],U=Un(0,k[V],A[V]),Z=E?k[V]/2-$-U-_-w.mainAxis:J-U-_-w.mainAxis,K=E?-k[V]/2+$+U+B+w.mainAxis:q+U+B+w.mainAxis,G=t.elements.arrow&&Vr(t.elements.arrow),ve=G?b==="y"?G.clientTop||0:G.clientLeft||0:0,Me=(N=M==null?void 0:M[b])!=null?N:0,ke=W+Z-Me-ve,Fe=W+K-Me,Ie=Un(f?_n(j,ke):j,W,f?Dr(O,Fe):O);x[b]=Ie,L[b]=Ie-W}if(l){var Je,Ge=b==="x"?Ke:rt,St=b==="x"?pt:lt,Re=x[g],it=g==="y"?"height":"width",gt=Re+y[Ge],ut=Re-y[St],ue=[Ke,rt].indexOf(C)!==-1,Y=(Je=M==null?void 0:M[g])!=null?Je:0,Ne=ue?gt:Re-k[it]-P[it]-Y+w.altAxis,dt=ue?Re+k[it]+P[it]-Y-w.altAxis:ut,mt=f&&ue?P1(Ne,Re,dt):Un(f?Ne:gt,Re,f?dt:ut);x[g]=mt,L[g]=mt-Re}t.modifiersData[o]=L}}a(xC,"preventOverflow");var F1={name:"preventOverflow",enabled:!0,phase:"main",fn:xC,requiresIfExists:["offset"]};function wd(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}a(wd,"getHTMLElementScroll");function kd(e){return e===_e(e)||!ft(e)?$n(e):wd(e)}a(kd,"getNodeScroll");function TC(e){var t=e.getBoundingClientRect(),r=Bo(t.width)/e.offsetWidth||1,o=Bo(t.height)/e.offsetHeight||1;return r!==1||o!==1}a(TC,"isElementScaled");function Pd(e,t,r){r===void 0&&(r=!1);var o=ft(t),n=ft(t)&&TC(t),i=Rt(t),s=Tr(e,n,r),l={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(o||!o&&!r)&&((wt(t)!=="body"||jn(i))&&(l=kd(t)),ft(t)?(c=Tr(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):i&&(c.x=qn(i))),{x:s.left+l.scrollLeft-c.x,y:s.top+l.scrollTop-c.y,width:s.width,height:s.height}}a(Pd,"getCompositeRect");function EC(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(EC,"order");function Md(e){var t=EC(e);return w1.reduce(function(r,o){return r.concat(t.filter(function(n){return n.phase===o}))},[])}a(Md,"orderModifiers");function Nd(e){var t;return function(){return t||(t=new Promise(function(r){Promise.resolve().then(function(){t=void 0,r(e())})})),t}}a(Nd,"debounce");function Sd(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(Sd,"mergeByName");var O1={placement:"bottom",modifiers:[],strategy:"absolute"};function _1(){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(_1,"areValidElements");function W1(e){e===void 0&&(e={});var t=e,r=t.defaultModifiers,o=r===void 0?[]:r,n=t.defaultOptions,i=n===void 0?O1:n;return a(function(l,c,u){u===void 0&&(u=i);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},O1,i),modifiersData:{},elements:{reference:l,popper:c},attributes:{},styles:{}},p=[],m=!1,f={state:d,setOptions:a(function(C){var T=typeof C=="function"?C(d.options):C;h(),d.options=Object.assign({},i,d.options,T),d.scrollParents={reference:xr(l)?un(l):l.contextElement?un(l.contextElement):[],popper:un(c)};var E=Md(Sd([].concat(o,d.options.modifiers)));return d.orderedModifiers=E.filter(function(b){return b.enabled}),v(),f.update()},"setOptions"),forceUpdate:a(function(){if(!m){var C=d.elements,T=C.reference,E=C.popper;if(_1(T,E)){d.rects={reference:Pd(T,Vr(E),d.options.strategy==="fixed"),popper:Wn(E)},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 g=d.orderedModifiers[b],x=g.fn,k=g.options,P=k===void 0?{}:k,S=g.name;typeof x=="function"&&(d=x({state:d,options:P,name:S,instance:f})||d)}}}},"forceUpdate"),update:Nd(function(){return new Promise(function(y){f.forceUpdate(),y(d)})}),destroy:a(function(){h(),m=!0},"destroy")};if(!_1(l,c))return f;f.setOptions(u).then(function(y){!m&&u.onFirstUpdate&&u.onFirstUpdate(y)});function v(){d.orderedModifiers.forEach(function(y){var C=y.name,T=y.options,E=T===void 0?{}:T,b=y.effect;if(typeof b=="function"){var g=b({state:d,name:C,instance:f,options:E}),x=a(function(){},"noopFn");p.push(g||x)}})}a(v,"runModifierEffects");function h(){p.forEach(function(y){return y()}),p=[]}return a(h,"cleanupModifierEffects"),f},"createPopper")}a(W1,"popperGenerator");var wC=[A1,H1,S1,qa,V1,L1,F1,M1,D1],Ad=W1({defaultModifiers:wC});var kC="tippy-box",X1="tippy-content",PC="tippy-backdrop",Y1="tippy-arrow",Q1="tippy-svg-arrow",Zn={passive:!0,capture:!0},eh=a(function(){return document.body},"TIPPY_DEFAULT_APPEND_TO");function Id(e,t,r){if(Array.isArray(e)){var o=e[t];return o==null?Array.isArray(r)?r[t]:r:o}return e}a(Id,"getValueAtIndexOrReturn");function Hd(e,t){var r={}.toString.call(e);return r.indexOf("[object")===0&&r.indexOf(t+"]")>-1}a(Hd,"isType");function th(e,t){return typeof e=="function"?e.apply(void 0,t):e}a(th,"invokeWithArgsOrReturn");function z1(e,t){if(t===0)return e;var r;return function(o){clearTimeout(r),r=setTimeout(function(){e(o)},t)}}a(z1,"debounce");function MC(e){return e.split(/\s+/).filter(Boolean)}a(MC,"splitBySpaces");function _i(e){return[].concat(e)}a(_i,"normalizeToArray");function U1(e,t){e.indexOf(t)===-1&&e.push(t)}a(U1,"pushIfUnique");function NC(e){return e.filter(function(t,r){return e.indexOf(t)===r})}a(NC,"unique");function SC(e){return e.split("-")[0]}a(SC,"getBasePlacement");function Ul(e){return[].slice.call(e)}a(Ul,"arrayFrom");function $1(e){return Object.keys(e).reduce(function(t,r){return e[r]!==void 0&&(t[r]=e[r]),t},{})}a($1,"removeUndefinedProps");function Ya(){return document.createElement("div")}a(Ya,"div");function $l(e){return["Element","Fragment"].some(function(t){return Hd(e,t)})}a($l,"isElement");function AC(e){return Hd(e,"NodeList")}a(AC,"isNodeList");function IC(e){return Hd(e,"MouseEvent")}a(IC,"isMouseEvent");function LC(e){return!!(e&&e._tippy&&e._tippy.reference===e)}a(LC,"isReferenceElement");function RC(e){return $l(e)?[e]:AC(e)?Ul(e):Array.isArray(e)?e:Ul(document.querySelectorAll(e))}a(RC,"getArrayOfElements");function Ld(e,t){e.forEach(function(r){r&&(r.style.transitionDuration=t+"ms")})}a(Ld,"setTransitionDuration");function q1(e,t){e.forEach(function(r){r&&r.setAttribute("data-state",t)})}a(q1,"setVisibilityState");function BC(e){var t,r=_i(e),o=r[0];return o!=null&&(t=o.ownerDocument)!=null&&t.body?o.ownerDocument:document}a(BC,"getOwnerDocument");function DC(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=SC(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,C=i.left-r+f>c,T=r-i.right-v>c;return h||y||C||T})}a(DC,"isCursorOutsideInteractiveBorder");function Rd(e,t,r){var o=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){e[o](n,r)})}a(Rd,"updateTransitionEndListener");function j1(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(j1,"actualContains");var lo={isTouch:!1},Z1=0;function VC(){lo.isTouch||(lo.isTouch=!0,window.performance&&document.addEventListener("mousemove",rh))}a(VC,"onDocumentTouchStart");function rh(){var e=performance.now();e-Z1<20&&(lo.isTouch=!1,document.removeEventListener("mousemove",rh)),Z1=e}a(rh,"onDocumentMouseMove");function HC(){var e=document.activeElement;if(LC(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}a(HC,"onWindowBlur");function FC(){document.addEventListener("touchstart",VC,Zn),window.addEventListener("blur",HC)}a(FC,"bindGlobalEventListeners");var OC=typeof window!="undefined"&&typeof document!="undefined",_C=OC?!!window.msCrypto:!1;var WC={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},zC={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Fr=Object.assign({appendTo:eh,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},WC,zC),UC=Object.keys(Fr),$C=a(function(t){var r=Object.keys(t);r.forEach(function(o){Fr[o]=t[o]})},"setDefaultProps");function oh(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=Fr[i])!=null?l:s}return o},{});return Object.assign({},e,r)}a(oh,"getExtendedPassedProps");function qC(e,t){var r=t?Object.keys(oh(Object.assign({},Fr,{plugins:t}))):UC,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(qC,"getDataAttributeProps");function K1(e,t){var r=Object.assign({},t,{content:th(t.content,[e])},t.ignoreAttributes?{}:qC(e,t.plugins));return r.aria=Object.assign({},Fr.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(K1,"evaluateProps");var jC=a(function(){return"innerHTML"},"innerHTML");function Dd(e,t){e[jC()]=t}a(Dd,"dangerouslySetInnerHTML");function J1(e){var t=Ya();return e===!0?t.className=Y1:(t.className=Q1,$l(e)?t.appendChild(e):Dd(t,e)),t}a(J1,"createArrowElement");function G1(e,t){$l(t.content)?(Dd(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?Dd(e,t.content):e.textContent=t.content)}a(G1,"setContent");function Vd(e){var t=e.firstElementChild,r=Ul(t.children);return{box:t,content:r.find(function(o){return o.classList.contains(X1)}),arrow:r.find(function(o){return o.classList.contains(Y1)||o.classList.contains(Q1)}),backdrop:r.find(function(o){return o.classList.contains(PC)})}}a(Vd,"getChildren");function nh(e){var t=Ya(),r=Ya();r.className=kC,r.setAttribute("data-state","hidden"),r.setAttribute("tabindex","-1");var o=Ya();o.className=X1,o.setAttribute("data-state","hidden"),G1(o,e.props),t.appendChild(r),r.appendChild(o),n(e.props,e.props);function n(i,s){var l=Vd(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)&&G1(u,e.props),s.arrow?d?i.arrow!==s.arrow&&(c.removeChild(d),c.appendChild(J1(s.arrow))):c.appendChild(J1(s.arrow)):d&&c.removeChild(d)}return a(n,"onUpdate"),{popper:t,onUpdate:n}}a(nh,"render");nh.$$tippy=!0;var ZC=1,zl=[],Bd=[];function KC(e,t){var r=K1(e,Object.assign({},Fr,oh($1(t)))),o,n,i,s=!1,l=!1,c=!1,u=!1,d,p,m,f=[],v=z1(ke,r.interactiveDebounce),h,y=ZC++,C=null,T=NC(r.plugins),E={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},b={id:y,reference:e,popper:Ya(),popperInstance:C,props:r,state:E,plugins:T,clearDelayTimeouts:Ne,setProps:dt,setContent:mt,show:Gr,hide:Xr,hideWithInteractivity:Yr,enable:ue,disable:Y,unmount:Qr,destroy:wn};if(!r.render)return b;var g=r.render(b),x=g.popper,k=g.onUpdate;x.setAttribute("data-tippy-root",""),x.id="tippy-"+b.id,b.popper=x,e._tippy=b,x._tippy=b;var P=T.map(function(z){return z.fn(b)}),S=e.hasAttribute("aria-expanded");return G(),$(),W(),j("onCreate",[b]),r.showOnCreate&&gt(),x.addEventListener("mouseenter",function(){b.props.interactive&&b.state.isVisible&&b.clearDelayTimeouts()}),x.addEventListener("mouseleave",function(){b.props.interactive&&b.props.trigger.indexOf("mouseenter")>=0&&I().addEventListener("mousemove",v)}),b;function w(){var z=b.props.touch;return Array.isArray(z)?z:[z,0]}a(w,"getNormalizedTouchSettings");function M(){return w()[0]==="hold"}a(M,"getIsCustomTouchBehavior");function L(){var z;return!!((z=b.props.render)!=null&&z.$$tippy)}a(L,"getIsDefaultRenderFn");function N(){return h||e}a(N,"getCurrentTarget");function I(){var z=N().parentNode;return z?BC(z):document}a(I,"getDocument");function D(){return Vd(x)}a(D,"getDefaultTemplateChildren");function V(z){return b.state.isMounted&&!b.state.isVisible||lo.isTouch||d&&d.type==="focus"?0:Id(b.props.delay,z?0:1,Fr.delay)}a(V,"getDelay");function W(z){z===void 0&&(z=!1),x.style.pointerEvents=b.props.interactive&&!z?"":"none",x.style.zIndex=""+b.props.zIndex}a(W,"handleStyles");function j(z,X,ae){if(ae===void 0&&(ae=!0),P.forEach(function(be){be[z]&&be[z].apply(be,X)}),ae){var we;(we=b.props)[z].apply(we,X)}}a(j,"invokeHook");function O(){var z=b.props.aria;if(z.content){var X="aria-"+z.content,ae=x.id,we=_i(b.props.triggerTarget||e);we.forEach(function(be){var Xe=be.getAttribute(X);if(b.state.isVisible)be.setAttribute(X,Xe?Xe+" "+ae:ae);else{var ht=Xe&&Xe.replace(ae,"").trim();ht?be.setAttribute(X,ht):be.removeAttribute(X)}})}}a(O,"handleAriaContentAttribute");function $(){if(!(S||!b.props.aria.expanded)){var z=_i(b.props.triggerTarget||e);z.forEach(function(X){b.props.interactive?X.setAttribute("aria-expanded",b.state.isVisible&&X===N()?"true":"false"):X.removeAttribute("aria-expanded")})}}a($,"handleAriaExpandedAttribute");function J(){I().removeEventListener("mousemove",v),zl=zl.filter(function(z){return z!==v})}a(J,"cleanupInteractiveMouseListeners");function q(z){if(!(lo.isTouch&&(c||z.type==="mousedown"))){var X=z.composedPath&&z.composedPath()[0]||z.target;if(!(b.props.interactive&&j1(x,X))){if(_i(b.props.triggerTarget||e).some(function(ae){return j1(ae,X)})){if(lo.isTouch||b.state.isVisible&&b.props.trigger.indexOf("click")>=0)return}else j("onClickOutside",[b,z]);b.props.hideOnClick===!0&&(b.clearDelayTimeouts(),b.hide(),l=!0,setTimeout(function(){l=!1}),b.state.isMounted||_())}}}a(q,"onDocumentPress");function F(){c=!0}a(F,"onTouchMove");function A(){c=!1}a(A,"onTouchStart");function H(){var z=I();z.addEventListener("mousedown",q,!0),z.addEventListener("touchend",q,Zn),z.addEventListener("touchstart",A,Zn),z.addEventListener("touchmove",F,Zn)}a(H,"addDocumentPress");function _(){var z=I();z.removeEventListener("mousedown",q,!0),z.removeEventListener("touchend",q,Zn),z.removeEventListener("touchstart",A,Zn),z.removeEventListener("touchmove",F,Zn)}a(_,"removeDocumentPress");function B(z,X){Z(z,function(){!b.state.isVisible&&x.parentNode&&x.parentNode.contains(x)&&X()})}a(B,"onTransitionedOut");function U(z,X){Z(z,X)}a(U,"onTransitionedIn");function Z(z,X){var ae=D().box;function we(be){be.target===ae&&(Rd(ae,"remove",we),X())}if(a(we,"listener"),z===0)return X();Rd(ae,"remove",p),Rd(ae,"add",we),p=we}a(Z,"onTransitionEnd");function K(z,X,ae){ae===void 0&&(ae=!1);var we=_i(b.props.triggerTarget||e);we.forEach(function(be){be.addEventListener(z,X,ae),f.push({node:be,eventType:z,handler:X,options:ae})})}a(K,"on");function G(){M()&&(K("touchstart",Me,{passive:!0}),K("touchend",Fe,{passive:!0})),MC(b.props.trigger).forEach(function(z){if(z!=="manual")switch(K(z,Me),z){case"mouseenter":K("mouseleave",Fe);break;case"focus":K(_C?"focusout":"blur",Ie);break;case"focusin":K("focusout",Ie);break}})}a(G,"addListeners");function ve(){f.forEach(function(z){var X=z.node,ae=z.eventType,we=z.handler,be=z.options;X.removeEventListener(ae,we,be)}),f=[]}a(ve,"removeListeners");function Me(z){var X,ae=!1;if(!(!b.state.isEnabled||Je(z)||l)){var we=((X=d)==null?void 0:X.type)==="focus";d=z,h=z.currentTarget,$(),!b.state.isVisible&&IC(z)&&zl.forEach(function(be){return be(z)}),z.type==="click"&&(b.props.trigger.indexOf("mouseenter")<0||s)&&b.props.hideOnClick!==!1&&b.state.isVisible?ae=!0:gt(z),z.type==="click"&&(s=!ae),ae&&!we&&ut(z)}}a(Me,"onTrigger");function ke(z){var X=z.target,ae=N().contains(X)||x.contains(X);if(!(z.type==="mousemove"&&ae)){var we=it().concat(x).map(function(be){var Xe,ht=be._tippy,br=(Xe=ht.popperInstance)==null?void 0:Xe.state;return br?{popperRect:be.getBoundingClientRect(),popperState:br,props:r}:null}).filter(Boolean);DC(we,z)&&(J(),ut(z))}}a(ke,"onMouseMove");function Fe(z){var X=Je(z)||b.props.trigger.indexOf("click")>=0&&s;if(!X){if(b.props.interactive){b.hideWithInteractivity(z);return}ut(z)}}a(Fe,"onMouseLeave");function Ie(z){b.props.trigger.indexOf("focusin")<0&&z.target!==N()||b.props.interactive&&z.relatedTarget&&x.contains(z.relatedTarget)||ut(z)}a(Ie,"onBlurOrFocusOut");function Je(z){return lo.isTouch?M()!==z.type.indexOf("touch")>=0:!1}a(Je,"isEventListenerStopped");function Ge(){St();var z=b.props,X=z.popperOptions,ae=z.placement,we=z.offset,be=z.getReferenceClientRect,Xe=z.moveTransition,ht=L()?Vd(x).arrow:null,br=be?{getBoundingClientRect:be,contextElement:be.contextElement||N()}:e,Ca={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:a(function(me){var fe=me.state;if(L()){var Ye=D(),Sr=Ye.box;["placement","reference-hidden","escaped"].forEach(function(at){at==="placement"?Sr.setAttribute("data-placement",fe.placement):fe.attributes.popper["data-popper-"+at]?Sr.setAttribute("data-"+at,""):Sr.removeAttribute("data-"+at)}),fe.attributes.popper={}}},"fn")},eo=[{name:"offset",options:{offset:we}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!Xe}},Ca];L()&&ht&&eo.push({name:"arrow",options:{element:ht,padding:3}}),eo.push.apply(eo,(X==null?void 0:X.modifiers)||[]),b.popperInstance=Ad(br,x,Object.assign({},X,{placement:ae,onFirstUpdate:m,modifiers:eo}))}a(Ge,"createPopperInstance");function St(){b.popperInstance&&(b.popperInstance.destroy(),b.popperInstance=null)}a(St,"destroyPopperInstance");function Re(){var z=b.props.appendTo,X,ae=N();b.props.interactive&&z===eh||z==="parent"?X=ae.parentNode:X=th(z,[ae]),X.contains(x)||X.appendChild(x),b.state.isMounted=!0,Ge()}a(Re,"mount");function it(){return Ul(x.querySelectorAll("[data-tippy-root]"))}a(it,"getNestedPopperTree");function gt(z){b.clearDelayTimeouts(),z&&j("onTrigger",[b,z]),H();var X=V(!0),ae=w(),we=ae[0],be=ae[1];lo.isTouch&&we==="hold"&&be&&(X=be),X?o=setTimeout(function(){b.show()},X):b.show()}a(gt,"scheduleShow");function ut(z){if(b.clearDelayTimeouts(),j("onUntrigger",[b,z]),!b.state.isVisible){_();return}if(!(b.props.trigger.indexOf("mouseenter")>=0&&b.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(z.type)>=0&&s)){var X=V(!1);X?n=setTimeout(function(){b.state.isVisible&&b.hide()},X):i=requestAnimationFrame(function(){b.hide()})}}a(ut,"scheduleHide");function ue(){b.state.isEnabled=!0}a(ue,"enable");function Y(){b.hide(),b.state.isEnabled=!1}a(Y,"disable");function Ne(){clearTimeout(o),clearTimeout(n),cancelAnimationFrame(i)}a(Ne,"clearDelayTimeouts");function dt(z){if(!b.state.isDestroyed){j("onBeforeUpdate",[b,z]),ve();var X=b.props,ae=K1(e,Object.assign({},X,$1(z),{ignoreAttributes:!0}));b.props=ae,G(),X.interactiveDebounce!==ae.interactiveDebounce&&(J(),v=z1(ke,ae.interactiveDebounce)),X.triggerTarget&&!ae.triggerTarget?_i(X.triggerTarget).forEach(function(we){we.removeAttribute("aria-expanded")}):ae.triggerTarget&&e.removeAttribute("aria-expanded"),$(),W(),k&&k(X,ae),b.popperInstance&&(Ge(),it().forEach(function(we){requestAnimationFrame(we._tippy.popperInstance.forceUpdate)})),j("onAfterUpdate",[b,z])}}a(dt,"setProps");function mt(z){b.setProps({content:z})}a(mt,"setContent");function Gr(){var z=b.state.isVisible,X=b.state.isDestroyed,ae=!b.state.isEnabled,we=lo.isTouch&&!b.props.touch,be=Id(b.props.duration,0,Fr.duration);if(!(z||X||ae||we)&&!N().hasAttribute("disabled")&&(j("onShow",[b],!1),b.props.onShow(b)!==!1)){if(b.state.isVisible=!0,L()&&(x.style.visibility="visible"),W(),H(),b.state.isMounted||(x.style.transition="none"),L()){var Xe=D(),ht=Xe.box,br=Xe.content;Ld([ht,br],0)}m=a(function(){var eo;if(!(!b.state.isVisible||u)){if(u=!0,x.offsetHeight,x.style.transition=b.props.moveTransition,L()&&b.props.animation){var de=D(),me=de.box,fe=de.content;Ld([me,fe],be),q1([me,fe],"visible")}O(),$(),U1(Bd,b),(eo=b.popperInstance)==null||eo.forceUpdate(),j("onMount",[b]),b.props.animation&&L()&&U(be,function(){b.state.isShown=!0,j("onShown",[b])})}},"onFirstUpdate"),Re()}}a(Gr,"show");function Xr(){var z=!b.state.isVisible,X=b.state.isDestroyed,ae=!b.state.isEnabled,we=Id(b.props.duration,1,Fr.duration);if(!(z||X||ae)&&(j("onHide",[b],!1),b.props.onHide(b)!==!1)){if(b.state.isVisible=!1,b.state.isShown=!1,u=!1,s=!1,L()&&(x.style.visibility="hidden"),J(),_(),W(!0),L()){var be=D(),Xe=be.box,ht=be.content;b.props.animation&&(Ld([Xe,ht],we),q1([Xe,ht],"hidden"))}O(),$(),b.props.animation?L()&&B(we,b.unmount):b.unmount()}}a(Xr,"hide");function Yr(z){I().addEventListener("mousemove",v),U1(zl,v),v(z)}a(Yr,"hideWithInteractivity");function Qr(){b.state.isVisible&&b.hide(),b.state.isMounted&&(St(),it().forEach(function(z){z._tippy.unmount()}),x.parentNode&&x.parentNode.removeChild(x),Bd=Bd.filter(function(z){return z!==b}),b.state.isMounted=!1,j("onHidden",[b]))}a(Qr,"unmount");function wn(){b.state.isDestroyed||(b.clearDelayTimeouts(),b.unmount(),ve(),delete e._tippy,b.state.isDestroyed=!0,j("onDestroy",[b]))}a(wn,"destroy")}a(KC,"createTippy");function Qa(e,t){t===void 0&&(t={});var r=Fr.plugins.concat(t.plugins||[]);FC();var o=Object.assign({},t,{plugins:r}),n=RC(e);if(0)var i,s;var l=n.reduce(function(c,u){var d=u&&KC(u,o);return d&&c.push(d),c},[]);return $l(e)?l[0]:l}a(Qa,"tippy");Qa.defaultProps=Fr;Qa.setDefaultProps=$C;Qa.currentInput=lo;var X_=Object.assign({},qa,{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")});Qa.setDefaultProps({render:nh});var ih=Qa;import{jsx as ah}from"react/jsx-runtime";var sh=a(({items:e,command:t,selected:r=0})=>e.length===0?null:ah("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)=>ah("button",{className:R("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":""),onMouseDown:i=>{i.preventDefault(),i.stopPropagation()},onClick:()=>t(o),children:o},n))}),"VariableSuggestions");var Or={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 Qo(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=Or.items)==null?void 0:c.call(Or,{query:(e==null?void 0:e.props).query||"",editor:(e==null?void 0:e.props).editor}))[i];return l?((u=Or.command)==null||u.call(Or,{editor:r.editor,range:r.range,props:l}),!0):!1},"selectItem");return{onStart:i=>{r=i,e=new JC(sh,{props:{...i,selected:0},editor:i.editor}),i.clientRect&&(t=ih(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"}))},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=Or.items)==null?void 0:c.call(Or,{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}}}};import{NodeViewWrapper as gh}from"@tiptap/react";import{useAtomValue as ex}from"jotai";import{NodeSelection as tx,TextSelection as rx}from"prosemirror-state";import{useCallback as zi,useEffect as jd,useMemo as ox,useState as Zd}from"react";import{useAtomValue as Fd}from"jotai";import{useCallback as dn,useEffect as ql,useMemo as Od,useRef as mh,useState as _d}from"react";import{createPortal as GC}from"react-dom";import{toast as XC}from"sonner";import{useEffect as lh,useRef as ch}from"react";import{jsx as uh}from"react/jsx-runtime";var dh=a(({items:e,onSelect:t,selectedIndex:r,anchorRef:o})=>{let n=ch(null),i=ch(null);return lh(()=>{i.current&&i.current.scrollIntoView({block:"nearest"})},[r]),lh(()=>{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:uh("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)=>uh("button",{ref:l===r?i:void 0,className:R("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");import{Fragment as YC,jsx as Ud,jsxs as ph}from"react/jsx-runtime";var Wd=50,zd=24,jl=a(({variableId:e,isInvalid:t,onUpdateAttributes:r,onDelete:o,icon:n,value:i,singleClickToEdit:s=!1,className:l,textColorOverride:c,getColors:u,readOnly:d=!1,formattingStyle:p,isSelected:m=!1,onSelect:f,onCommit:v})=>{var F;let[h,y]=_d(!1),[C,T]=_d(""),[E,b]=_d(0),g=mh(null),x=mh(null),k=Fd(xi),P=Fd(vi),S=Fd(Ci),w=Od(()=>S||!P||Object.keys(P).length===0?[]:Qo(P),[P,S]),M=Od(()=>w.length===0?[]:C?w.filter(A=>A.toLowerCase().includes(C.toLowerCase())):w,[w,C]),L=h&&M.length>0;ql(()=>{d||e===""&&!h&&(y(!0),T(""),b(0))},[e,h,d]),ql(()=>{!e||h||w.length>0&&!w.includes(e)&&(t||queueMicrotask(()=>{r({id:e,isInvalid:!0})}))},[e,w,t,h,r]),ql(()=>{if(h&&g.current){let A=g.current;A.textContent=e,A.focus(),requestAnimationFrame(()=>{if(A&&A.isConnected){let H=document.createRange();H.selectNodeContents(A),H.collapse(!1);let _=window.getSelection();_==null||_.removeAllRanges(),_==null||_.addRange(H)}})}},[h,e]);let N=dn(()=>{var _,B;y(!1);let A=(((_=g.current)==null?void 0:_.textContent)||"").trim();if(A===""){o();return}let H=!0;if(k!=null&&k.overrideFormatValidation?k.validate&&(H=k.validate(A)):(H=vt(A),H&&(k!=null&&k.validate)&&(H=k.validate(A))),H&&w.length>0&&(H=w.includes(A)),!H){let U=(B=k==null?void 0:k.onInvalid)!=null?B:"mark";if(k!=null&&k.invalidMessage){let Z=typeof k.invalidMessage=="function"?k.invalidMessage(A):k.invalidMessage;XC.error(Z)}if(U==="remove"){o();return}r({id:A,isInvalid:!0});return}r({id:A,isInvalid:!1}),v==null||v()},[o,r,k,w,v]),I=dn(A=>{g.current&&(g.current.textContent=A),T(""),y(!1),r({id:A,isInvalid:!1}),v==null||v()},[r,v]),D=dn(A=>{var H,_,B;if(A.metaKey||A.ctrlKey){let U=A.key.toLowerCase();if(!new Set(["a","c","v","x","z"]).has(U)){A.stopPropagation(),A.preventDefault();return}}if(L){if(A.key==="ArrowDown"){A.preventDefault(),b(U=>(U+1)%M.length);return}if(A.key==="ArrowUp"){A.preventDefault(),b(U=>(U-1+M.length)%M.length);return}if(A.key==="Enter"){A.preventDefault();let U=M[E];U?I(U):(H=g.current)==null||H.blur();return}if(A.key==="Tab"){A.preventDefault();let U=M[E];U&&I(U);return}}else if(A.key==="Enter"){A.preventDefault(),(_=g.current)==null||_.blur();return}if(A.key==="Backspace"&&(((B=g.current)==null?void 0:B.textContent)||"")===""){A.preventDefault(),y(!1),o();return}A.key==="Escape"&&(A.preventDefault(),g.current&&(g.current.textContent=e),y(!1),T(""),e===""&&o())},[e,o,L,M,E,I]),V=dn(()=>{if(g.current){let A=g.current.textContent||"";if(A.length>Wd){A=A.slice(0,Wd),g.current.textContent=A;let H=document.createRange();H.selectNodeContents(g.current),H.collapse(!1);let _=window.getSelection();_==null||_.removeAllRanges(),_==null||_.addRange(H)}T(A),b(0)}},[]),W=dn(A=>{A.preventDefault();let H=A.clipboardData.getData("text/plain").slice(0,Wd),_=window.getSelection();if(_&&_.rangeCount>0){let B=_.getRangeAt(0);B.deleteContents();let U=document.createTextNode(H);B.insertNode(U),B.setStartAfter(U),B.setEndAfter(U),_.removeAllRanges(),_.addRange(B),V()}},[V]),j=dn(A=>{A.stopPropagation(),!d&&(h||y(!0))},[h,d]),O=Od(()=>{let A=e,H=i?`="${i}"`:"",_=`${A}${H}`,B=A.length>zd;return{displayText:`${B?`${A.slice(0,zd)}\u2026`:A}${H}`,fullText:_,showTitle:B}},[e,i]);ql(()=>{g.current&&!h&&(g.current.textContent=O.displayText)},[O.displayText,h]);let $=dn(A=>{A.stopPropagation(),!h&&f&&f()},[h,f]),J=dn(A=>{A.stopPropagation()},[]),q=s?{onClick:j}:{onClick:J,onDoubleClick:j};return ph(YC,{children:[ph("span",{ref:x,className:R("courier-variable-chip",!t&&i&&"courier-variable-chip-has-value",t&&"courier-variable-chip-invalid",m&&"courier-variable-chip-selected",l),style:{direction:"ltr"},onMouseDown:$,...q,title:O.showTitle?O.fullText:void 0,children:[Ud("span",{className:"courier-flex-shrink-0 courier-flex courier-items-center courier-pt-0.5",children:n}),Ud("span",{ref:g,role:"textbox",contentEditable:h,suppressContentEditableWarning:!0,onBlur:N,onKeyDown:D,onInput:V,onPaste:W,onMouseDown:$,...s?{onClick:j}:{onClick:J,onDoubleClick:j},className:R("courier-outline-none courier-min-w-[1ch]",!h&&"courier-cursor-text"),style:{...c&&{color:c},...p,...(p==null?void 0:p.fontStyle)==="italic"&&{paddingRight:"0.15em"},maxWidth:`var(--courier-variable-chip-max-width, ${zd}ch)`,overflow:"hidden",textOverflow:h?"clip":"ellipsis",whiteSpace:"nowrap",direction:"ltr",unicodeBidi:"isolate"},children:!h&&O.displayText})]}),L&&GC(Ud(dh,{items:M,onSelect:I,selectedIndex:E,anchorRef:x}),((F=x.current)==null?void 0:F.closest(".theme-container"))||document.body)]})},"VariableChipBase");import{jsx as fh,jsxs as QC}from"react/jsx-runtime";var Zl=a(({color:e="#1D4ED8"})=>QC("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:[fh("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}),fh("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableIcon");function Wi(e,t="show-variables"){var r;return!e||!qd(e.storage)?t:(r=e.storage.variable.variableViewMode)!=null?r:t}a(Wi,"getVariableViewMode");function Zt(e,t){if(!e)return!1;if(!qd(e.storage)){if(typeof e.storage=="object"&&e.storage!==null){let r=e.storage;return r.variable={variableViewMode:t},!0}return!1}return e.storage.variable.variableViewMode=t,!0}a(Zt,"setVariableViewMode");function $d(e="show-variables"){return{variableViewMode:e}}a($d,"initializeVariableStorage");function qd(e){if(typeof e!="object"||e===null||!("variable"in e))return!1;let t=e;return typeof t.variable=="object"&&t.variable!==null}a(qd,"hasVariableStorage");import{jsx as Kl}from"react/jsx-runtime";function nx(e){if(!e||e.length===0)return{};let t={},r=[];for(let o of e)switch(o.type.name){case"bold":t.fontWeight="bold";break;case"italic":t.fontStyle="italic";break;case"underline":r.push("underline");break;case"strike":r.push("line-through");break}return r.length>0&&(t.textDecoration=r.join(" ")),t}a(nx,"getFormattingStyleFromMarks");var hh=a(({node:e,editor:t,getPos:r,updateAttributes:o})=>{var k,P;let n=ex(Mn),i=e.attrs.id||"",s=n[i],l=e.attrs.isInvalid,[c,u]=Zd(!1),[d,p]=Zd(!1),m=ox(()=>nx(e.marks),[e]),[f,v]=Zd(()=>Wi(t));jd(()=>{let S=a(({transaction:w})=>{if(w.getMeta("variableViewModeChanged")){let M=Wi(t);v(M)}},"handleTransaction");return t.on("transaction",S),()=>{t.off("transaction",S)}},[t,i]),jd(()=>{let S=Wi(t);S&&v(S)},[(P=(k=t.storage)==null?void 0:k.variable)==null?void 0:P.variableViewMode]);let h=zi(()=>{if(typeof r=="function")try{let S=r();if(S==null){u(!1);return}let M=t.state.doc.resolve(S).parent;u(M&&M.type.name==="button")}catch{u(!1)}else u(!1)},[t,r]),y=zi(()=>{if(typeof r=="function")try{let S=r();if(typeof S!="number"){p(!1);return}let{from:w,to:M,empty:L}=t.state.selection;p(!L&&w<S+e.nodeSize&&M>S)}catch{p(!1)}},[t,r,e.nodeSize]);jd(()=>{h(),y();let S=a(()=>{h(),y()},"handleUpdate");return t.on("update",S),t.on("selectionUpdate",S),()=>{t.off("update",S),t.off("selectionUpdate",S)}},[t,h,y]);let C=zi(S=>{o(S)},[o]),T=zi(()=>{if(typeof r=="function"){let S=r();typeof S=="number"&&t.chain().focus().deleteRange({from:S,to:S+e.nodeSize}).run()}},[t,r,e.nodeSize]),E=zi(()=>{if(typeof r=="function"){let S=r();typeof S=="number"&&t.chain().focus().command(({tr:w})=>(w.setSelection(tx.create(w.doc,S)),!0)).run()}},[t,r]),b=zi(()=>{if(typeof r=="function"){let S=r();if(typeof S=="number"){let w=S+e.nodeSize;requestAnimationFrame(()=>{if(!(t.isDestroyed||!t.state||!t.view))try{let{tr:M}=t.state;M.setSelection(rx.create(M.doc,w)),t.view.dispatch(M),t.view.focus()}catch{}})}}},[t,r,e.nodeSize]),x=a((S,w)=>S?"#DC2626":w?"#1E40AF":"#B45309","getIconColor")(l,!!s);return f==="wysiwyg"?Kl(gh,{as:"span",className:"courier-inline",contentEditable:!1,"data-variable-id":i,"data-wysiwyg":"true",style:m,children:s||""}):Kl(gh,{as:"span",className:"courier-inline courier-max-w-full",children:Kl(jl,{variableId:i,isInvalid:l,value:s,onUpdateAttributes:C,onDelete:T,icon:Kl(Zl,{color:x}),className:R("courier-variable-node",c&&"courier-variable-in-button"),textColorOverride:c?"#000000":void 0,readOnly:!t.isEditable,formattingStyle:m,isSelected:d,onSelect:E,onCommit:b})})},"VariableView");var Yd=ax.create({name:"variable",group:"inline",inline:!0,selectable:!0,atom:!0,addStorage(){return $d()},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 sx(hh)},addProseMirrorPlugins(){return[new Kd({key:new Jd("variableClickGuard"),props:{handleClickOn(e,t,r,o,n){if(r.type.name!=="variable")return!1;let i=e.nodeDOM(o);if(i instanceof HTMLElement&&i.contains(n.target))return!0;let s=o+r.nodeSize;if(i instanceof HTMLElement){let c=i.getBoundingClientRect();n.clientX<c.left+c.width/2&&(s=o)}let l=e.state.tr.setSelection(Jl.create(e.state.doc,s));return e.dispatch(l),!0}}}),new Kd({key:new Jd("variableCursorIndicator"),props:{decorations:e=>{let{selection:t}=e,{$from:r,empty:o}=t;if(!o)return Gd.empty;let n=r.nodeBefore,i=r.nodeAfter;if((n==null?void 0:n.type.name)==="hardBreak"&&(i==null?void 0:i.type.name)==="variable"){let s=cx.widget(r.pos,()=>{let l=document.createElement("span");return l.className="variable-cursor-indicator",l.setAttribute("data-cursor-indicator","true"),l.style.cssText=`
187
187
  display: inline-block;
188
188
  width: 1px;
189
189
  height: 1.2em;
@@ -191,54 +191,55 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
191
191
  animation: cursor-blink 1s step-end infinite;
192
192
  vertical-align: text-bottom;
193
193
  margin-right: -1px;
194
- `,l},{side:0});return Rd.create(e.doc,[s])}return Rd.empty}}}),new z1({key:new j1("variableCursorFix"),props:{handleKeyDown:(e,t)=>{var l,c;if(t.key!=="ArrowLeft"&&t.key!=="ArrowRight")return!1;let{state:r}=e,{selection:o}=r,{$from:n}=o;if(!o.empty)return!1;let i=n.nodeBefore,s=n.nodeAfter;if(t.key==="ArrowLeft"){if((i==null?void 0:i.type.name)==="hardBreak"&&(s==null?void 0:s.type.name)==="variable"){let u=n.pos-i.nodeSize,d=r.tr.setSelection(Ld.create(r.doc,u));return e.dispatch(d),!0}if((i==null?void 0:i.type.name)==="variable"){let d=n.pos-i.nodeSize;if(d>n.start()&&((l=r.doc.resolve(d).nodeBefore)==null?void 0:l.type.name)==="hardBreak"){let p=r.tr.setSelection(Ld.create(r.doc,d));return e.dispatch(p),!0}}}if(t.key==="ArrowRight"&&(i==null?void 0:i.type.name)==="variable"&&(s==null?void 0:s.type.name)==="hardBreak"){let u=n.pos+s.nodeSize;if(u<=n.end()&&((c=r.doc.resolve(u).nodeAfter)==null?void 0:c.type.name)==="variable"){let m=r.tr.setSelection(Ld.create(r.doc,u));return e.dispatch(m),!0}}return!1}}})]}}),Hn=Bd.create({name:"variableInputRule",addInputRules(){return[new vC({find:/\{\{$/,handler:({range:e,chain:t})=>{t().deleteRange(e).insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()}})]}}),wC=Bd.create({name:"variableSuggestion",addOptions(){return{HTMLAttributes:{},suggestion:{char:"{{",...Nr},variables:{},disableSuggestions:!1}},addProseMirrorPlugins(){return this.options.disableSuggestions?[]:[TC({editor:this.editor,...this.options.suggestion})]}}),kC=Bd.create({name:"variableTypeHandler"});import{Extension as PC}from"@tiptap/core";import{Plugin as MC}from"@tiptap/pm/state";import{Slice as NC,Fragment as AC}from"@tiptap/pm/model";var Fn=PC.create({name:"variablePaste",addProseMirrorPlugins(){return[new MC({props:{transformPastedHTML:e=>e.replace(/\{\{([^}]+)\}\}/g,(r,o)=>{let n=o.trim();return pt(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&&pt(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=AC.from(i),u=new NC(c,0,0),d=r.state.tr.replaceSelection(u);return r.dispatch(d),e}return e}}})]}});import{Node as SC}from"@tiptap/core";import{NodeViewWrapper as IC,ReactNodeViewRenderer as LC}from"@tiptap/react";import{useCallback as q1}from"react";import{jsx as $a,jsxs as HC}from"react/jsx-runtime";var RC=a(({color:e="#B45309"})=>HC("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:[$a("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}),$a("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableChipIcon"),BC=a(e=>e?"#DC2626":"#B45309","getIconColor"),DC=a(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=e.attrs.id||"",i=e.attrs.isInvalid||!1,s=q1(c=>{o(c)},[o]),l=q1(()=>{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 $a(IC,{as:"span",className:"courier-inline",children:$a(Bl,{variableId:n,isInvalid:i,onUpdateAttributes:s,onDelete:l,icon:$a(RC,{color:BC(i)}),readOnly:!t.isEditable})})},"SimpleVariableView"),Hl=SC.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 LC(DC)}}),VC="\u200B";function Di(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();pt(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 r.length>0&&r[r.length-1].type==="variable"&&r.push({type:"text",text:VC}),{type:"doc",content:[{type:"paragraph",content:r.length>0?r:void 0}]}}a(Di,"parseStringToContent");function Fl(e){if(!e.content)return"";let t="",r=a(o=>{var n;o.type==="text"&&o.text?t+=o.text.replace(/\u200B/g,""):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(Fl,"contentToString");import{BubbleMenu as Sx}from"@tiptap/react";import{useCallback as Ix}from"react";import{useAtomValue as Wd}from"jotai";import{AlignCenter as px,AlignJustify as fx,AlignLeft as gx,AlignRight as hx,Bold as bx,Italic as yx,Link as vx,Quote as Cx,Strikethrough as xx,Underline as Tx}from"lucide-react";import{Fragment as Ex,memo as mh,useMemo as dh,useRef as wx,useState as kx,useEffect as Px}from"react";import{forwardRef as Fd}from"react";import{forwardRef as FC}from"react";import{jsx as OC}from"react/jsx-runtime";var Vd=FC(({children:e,className:t,withShadow:r=!0,withBorder:o=!0,...n},i)=>{let s=R("courier-bg-popover courier-rounded-lg courier-text-popover-foreground",r?"courier-shadow-sm":"",o?"courier-border courier-border-border":"",t);return OC("div",{className:s,...n,ref:i,children:e})});Vd.displayName="Surface";import $C from"@tippyjs/react";import{useCallback as zC,useState as jC}from"react";import{forwardRef as _C,useContext as UC}from"react";import{createContext as WC}from"react";var Ol={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"},Z1={...Ol},J1={...Ol,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 Hd=WC(Ol);import{jsx as K1}from"react/jsx-runtime";var G1=_C(({children:e,theme:t,colorScheme:r,className:o},n)=>{let i=r!=null?r:"light",s=i==="light"?Z1:J1,l=s;t&&(l=typeof t=="string"?t:{...s,...t});let c=typeof t=="string"?{}:Object.entries(l).reduce((u,[d,m])=>{let p=d.replace(/[A-Z]/g,g=>`-${g.toLowerCase()}`);return{...u,[`--${p}`]:m}},{});return K1(Hd.Provider,{value:typeof l=="object"?l:{},children:K1("div",{style:c,className:R("courier-flex courier-flex-col courier-relative",typeof t=="string"?t:"","theme-container",i==="dark"?"dark courier-dark":"",o),ref:n,children:e})})}),X1=a(()=>UC(Hd),"useTheme");import{Fragment as eh,jsx as Gr,jsxs as Q1}from"react/jsx-runtime";var Y1=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,qC=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"?Gr("kbd",{className:t,children:Y1?"\u2318":"Ctrl"}):e==="Shift"?Gr("kbd",{className:t,children:"\u21E7"}):e==="Alt"?Gr("kbd",{className:t,children:Y1?"\u2325":"Alt"}):Gr("kbd",{className:t,children:e})},"ShortcutKey"),th=a(({children:e,enabled:t=!0,title:r,shortcut:o,tippyOptions:n={}})=>{let i=X1(),s=zC(u=>{let d=Object.entries(i).reduce((m,[p,g])=>{let v=p.replace(/[A-Z]/g,b=>`-${b.toLowerCase()}`);return{...m,[`--${v}`]:g}},{});return Q1("span",{className:R("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&&Gr("span",{className:"courier-text-xs courier-font-medium courier-text-muted-foreground",children:r}),o&&Gr("span",{className:"courier-flex courier-items-center courier-gap-0.5",children:o.map(m=>Gr(qC,{children:m},m))})]})},[o,r,i]),[l,c]=jC(null);return t?Q1(eh,{children:[Gr("span",{ref:c,children:e}),l&&Gr($C,{...n,delay:500,offset:[0,8],touch:!1,zIndex:99999,appendTo:document.body,trigger:"mouseenter focus",showOnCreate:!1,render:s,animation:!1,reference:l})]}):Gr(eh,{children:e})},"Tooltip");import{jsx as Wl}from"react/jsx-runtime";var rh=Fd(({shouldShowContent:e=!0,children:t,isVertical:r=!1,className:o,...n},i)=>{let s=R("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&&Wl(Vd,{className:s,...n,ref:i,children:t})});rh.displayName="Toolbar";var oh=Fd(({horizontal:e,className:t,...r},o)=>{let n=R("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 Wl("div",{className:n,ref:o,...r})});oh.displayName="Toolbar.Divider";var nh=Fd(({children:e,buttonSize:t="icon",variant:r="ghost",className:o,tooltip:n,tooltipShortcut:i,onMouseDown:s,...l},c)=>{let u=R("courier-gap-1 courier-min-w-[2rem] courier-w-auto",o),m=Wl(Me,{className:u,variant:r,buttonSize:t,ref:c,onMouseDown:a(p=>{p.preventDefault(),s==null||s(p)},"handleMouseDown"),...l,children:e});return n?Wl(th,{title:n,shortcut:i,children:m}):m});nh.displayName="ToolbarButton";var _l={Wrapper:rh,Divider:oh,Button:nh};import*as To from"react";import*as Te from"@radix-ui/react-dropdown-menu";import{Check as ZC,ChevronRight as JC,Circle as KC}from"lucide-react";import{jsx as Zt,jsxs as Od}from"react/jsx-runtime";var Ul=Te.Root,$l=Te.Trigger;var GC=To.forwardRef(({className:e,inset:t,children:r,...o},n)=>Od(Te.SubTrigger,{ref:n,className:R("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,Zt(JC,{className:"courier-ml-auto"})]}));GC.displayName=Te.SubTrigger.displayName;var XC=To.forwardRef(({className:e,...t},r)=>Zt(Te.SubContent,{ref:r,className:R("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}));XC.displayName=Te.SubContent.displayName;var za=To.forwardRef(({className:e,sideOffset:t=4,portalProps:r,...o},n)=>Zt(Te.Portal,{...r,children:Zt(Te.Content,{ref:n,sideOffset:t,className:R("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=Te.Content.displayName;var ja=To.forwardRef(({className:e,inset:t,...r},o)=>Zt(Te.Item,{ref:o,className:R("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}));ja.displayName=Te.Item.displayName;var YC=To.forwardRef(({className:e,children:t,checked:r,...o},n)=>Od(Te.CheckboxItem,{ref:n,className:R("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:[Zt("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:Zt(Te.ItemIndicator,{children:Zt(ZC,{className:"courier-h-4 courier-w-4"})})}),t]}));YC.displayName=Te.CheckboxItem.displayName;var QC=To.forwardRef(({className:e,children:t,...r},o)=>Od(Te.RadioItem,{ref:o,className:R("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:[Zt("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:Zt(Te.ItemIndicator,{children:Zt(KC,{className:"courier-h-2 courier-w-2 courier-fill-current"})})}),t]}));QC.displayName=Te.RadioItem.displayName;var ex=To.forwardRef(({className:e,inset:t,...r},o)=>Zt(Te.Label,{ref:o,className:R("courier-px-2 courier-py-1.5 courier-text-sm courier-font-semibold",t&&"courier-pl-8",e),...r}));ex.displayName=Te.Label.displayName;var tx=To.forwardRef(({className:e,...t},r)=>Zt(Te.Separator,{ref:r,className:R("courier-mx-1 courier-my-1 courier-h-px courier-bg-muted",e),...t}));tx.displayName=Te.Separator.displayName;var rx=a(({className:e,...t})=>Zt("span",{className:R("courier-ml-auto courier-text-xs courier-tracking-widest courier-opacity-60",e),...t}),"DropdownMenuShortcut");rx.displayName="DropdownMenuShortcut";import{ChevronDown as ox}from"lucide-react";import{useMemo as nx}from"react";import{Fragment as ax,jsx as Yo,jsxs as ih}from"react/jsx-runtime";var ix=a(e=>e.type==="option","isOption"),ah=a(({options:e,containerRef:t})=>{let r=nx(()=>e.find(o=>o.type==="option"&&o.isActive()),[e]);return ih(Ul,{children:[Yo($l,{asChild:!0,children:ih(Me,{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",Yo(ox,{className:"courier-w-3 courier-h-3"})]})}),Yo(za,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(ix(o))return Yo(ja,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?Yo(ax,{children:o.id==="heading1"?Yo("h1",{className:"courier-text-2xl courier-font-bold",children:o.label}):o.id==="heading2"?Yo("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading3"?Yo("h3",{className:"courier-text-lg courier-font-bold",children:o.label}):o.label}):o.label},o.id)})})]})},"ContentTypePicker");import{useSetAtom as lx}from"jotai";import{useCallback as fr}from"react";import{v4 as zl}from"uuid";import{useMemo as sx}from"react";var sh=a((e,t,r)=>sx(()=>{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 lh=a((e,t,r)=>{let o=lx(Re),n=sh(t,e,r),i=fr(()=>{if(n&&r){let C=n.getRuleForItem("bold");if(C&&C.action.type==="toggle_off"){let x=e.chain().focus();return C.action.targets.forEach(h=>{h==="italic"&&r.isItalic&&x.toggleItalic()}),x.toggleBold().run(),!0}}return e.chain().focus().toggleBold().run()},[e,n,r]),s=fr(()=>{if(n&&r){let C=n.getRuleForItem("italic");if(C&&C.action.type==="toggle_off"){let x=e.chain().focus();return C.action.targets.forEach(h=>{h==="bold"&&r.isBold&&x.toggleBold()}),x.toggleItalic().run(),!0}}return e.chain().focus().toggleItalic().run()},[e,n,r]),l=fr(()=>e.chain().focus().toggleMark("strike").run(),[e]),c=fr(()=>e.chain().focus().toggleMark("underline").run(),[e]),u=fr(()=>e.chain().focus().setTextAlign("left").run(),[e]),d=fr(()=>e.chain().focus().setTextAlign("center").run(),[e]),m=fr(()=>e.chain().focus().setTextAlign("right").run(),[e]),p=fr(()=>e.chain().focus().setTextAlign("justify").run(),[e]),g=fr((C,x)=>e.chain().focus().setLink({href:C,target:x?"_blank":""}).run(),[e]),v=fr(()=>{if(e.isActive("list")){let{$from:f}=e.state.selection,E=-1,T=-1;for(let V=f.depth;V>=0;V--)if(f.node(V).type.name==="list"&&E===-1&&(E=V),f.node(V).type.name==="blockquote"){T=V;break}if(E===-1)return;let w=f.node(E),P=f.before(E),N=f.after(E),k=[],S=!1,B=1;w.forEach((V,_,W)=>{W>0&&k.push(e.state.schema.nodes.hardBreak.create()),V.forEach(F=>{F.type.name==="heading"?(S=!0,B=F.attrs.level||1,F.content.forEach(L=>{k.push(L)})):F.type.name==="paragraph"&&F.content.forEach(L=>{k.push(L)})})});let M;if(S?M=e.state.schema.nodes.heading.create({id:`node-${zl()}`,level:B},k.length>0?k:void 0):M=e.state.schema.nodes.paragraph.create({id:`node-${zl()}`},k.length>0?k:void 0),T!==-1){let V=e.state.tr.replaceWith(P,N,M);e.view.dispatch(V),setTimeout(()=>{let{selection:_}=e.state,W=_.$anchor;for(let F=W.depth;F>0;F--){let L=W.node(F);if(L.type.name==="blockquote"){o(L);break}}},0);return}let I=e.state.schema.nodes.blockquote.create({id:`node-${zl()}`},M),D=e.state.tr.replaceWith(P,N,I);e.view.dispatch(D),setTimeout(()=>{let{selection:V}=e.state,_=V.$anchor;for(let W=_.depth;W>0;W--){let F=_.node(W);if(F.type.name==="blockquote"){o(F);break}}},0);return}let C=e.isActive("blockquote");if(e.chain().focus().toggleBlockquote().run()){let{selection:f}=e.state,E=f.$anchor;if(C){let T=E.node();(T.type.name==="paragraph"||T.type.name==="heading")&&o(T)}else for(let T=E.depth;T>0;T--){let w=E.node(T);if(w.type.name==="blockquote"){if(w.attrs.id)o(w);else{let P=E.before(T),N=`node-${zl()}`,k=e.state.tr;k.setNodeMarkup(P,void 0,{...w.attrs,id:N}),e.view.dispatch(k);let S=e.state.doc.nodeAt(P);S&&o(S)}break}}}},[e,o]),b=fr(()=>{let C=e.isActive("list",{listType:"ordered"}),x=e.isActive("list",{listType:"unordered"}),h=e.state.selection.from;C||x&&(e.view.focus(),e.commands.setTextSelection(h),e.commands.updateAttributes("list",{listType:"ordered"})&&setTimeout(()=>{e.commands.setTextSelection(h);let{selection:E}=e.state,T=E.$anchor;for(let w=T.depth;w>0;w--){let P=T.node(w);if(P.type.name==="list"){o(P);break}}},0))},[e,o]),y=fr(()=>{let C=e.isActive("list",{listType:"unordered"}),x=e.isActive("list",{listType:"ordered"}),h=e.state.selection.from;C||x&&(e.view.focus(),e.commands.setTextSelection(h),e.commands.updateAttributes("list",{listType:"unordered"})&&setTimeout(()=>{e.commands.setTextSelection(h);let{selection:E}=e.state,T=E.$anchor;for(let w=T.depth;w>0;w--){let P=T.node(w);if(P.type.name==="list"){o(P);break}}},0))},[e,o]);return{onBold:i,onItalic:s,onStrike:l,onUnderline:c,onAlignLeft:u,onAlignCenter:d,onAlignRight:m,onAlignJustify:p,onLink:g,onQuote:v,onOrderedList:b,onUnorderedList:y}},"useTextmenuCommands");import{useEditorState as cx}from"@tiptap/react";var ch=a(e=>cx({editor:e,selector:t=>[{label:"Normal text",onClick:()=>{t.editor.chain().focus().setNode("paragraph").run()},id:"paragraph",disabled:()=>!t.editor.can().setParagraph(),isActive:()=>t.editor.isActive("paragraph")&&!t.editor.isActive("heading"),type:"option"},{label:"Heading 1",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:1}).run()},id:"heading1",disabled:()=>!t.editor.can().setHeading({level:1}),isActive:()=>t.editor.isActive("heading",{level:1}),type:"option"},{label:"Heading 2",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:2}).run()},id:"heading2",disabled:()=>!t.editor.can().setHeading({level:2}),isActive:()=>t.editor.isActive("heading",{level:2}),type:"option"},{label:"Heading 3",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:3}).run()},id:"heading3",disabled:()=>!t.editor.can().setHeading({level:3}),isActive:()=>t.editor.isActive("heading",{level:3}),type:"option"}]}),"useTextmenuContentTypes");import{useAtomValue as ux}from"jotai";import{useCallback as uh,useEffect as dx,useState as mx}from"react";var jl=a(e=>{let t=ux(Ce),[r,o]=mx({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isOrderedList:!1,isUnorderedList:!1,isLink:!1}),n=uh(()=>{if(!e)return;if((t==null?void 0:t.type.name)==="button"){o({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isOrderedList:!1,isUnorderedList:!1,isLink:!1});return}let s=null,{$from:l}=e.state.selection;for(let c=l.depth;c>=0;c--){let u=l.node(c);if(u.type.name==="list"){s=u.attrs.listType;break}}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"),isOrderedList:s==="ordered",isUnorderedList:s==="unordered",isLink:e.isActive("link")})},[e,t]);return dx(()=>{if(e)return n(),e.on("selectionUpdate",n),e.on("transaction",n),()=>{e.off("selectionUpdate",n),e.off("transaction",n)}},[e,n]),{shouldShow:uh(({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 m=c.node(d);if(m.type.name==="blockquote"){if(m.attrs.isSelected)return!0;let p=s.state.selection.from!==s.state.selection.to;if(s.isFocused&&p)return!0}if(m.type.name==="list"){if(m.attrs.isSelected)return!0;let p=s.state.selection.from!==s.state.selection.to;if(s.isFocused&&p)return!0}}return!1},[]),...r}},"useTextmenuStates");import{jsx as Lt,jsxs as Ax}from"react/jsx-runtime";var Mx=mh(_l.Button),Nx=mh(ah),qa=a(({editor:e,config:t})=>{var w;let r=jl(e),o=ch(e),n=wx(null),i=Wd(Qs),s=Wd(Ce),l=s==null?void 0:s.type.name,c=Wd(xg),[u,d]=kx(()=>{let{selection:P}=e.state;return{from:P.from,to:P.to,empty:P.empty}});Px(()=>{let P=a(()=>{let{selection:N}=e.state;d({from:N.from,to:N.to,empty:N.empty})},"updateSelection");return e.on("selectionUpdate",P),e.on("transaction",P),()=>{e.off("selectionUpdate",P),e.off("transaction",P)}},[e]);let m=dh(()=>!u.empty&&u.from!==u.to,[u]),p=dh(()=>t||c(l||"",m),[t,c,l,m]),g=lh(e,p,r),v=a(()=>{let{selection:P}=e.state;if(!(P.empty&&!r.isLink&&!e.can().setLink({href:""})))if(r.isLink){let N=e.state.tr.setMeta("showLinkForm",{from:P.from,to:P.to});e.view.dispatch(N)}else{let N=e.state.tr.setMeta("showLinkForm",{from:P.from,to:P.to});e.view.dispatch(N)}},"handleLinkToggle"),b=a(()=>{if(i.ref){let P=i.ref,N=P.value,k=i.caretPosition||P.selectionStart||0,S=N.substring(0,k),B=N.substring(k),M=`${S}{{${B}`,I=k+2;P.focus();let D=new Event("input",{bubbles:!0,cancelable:!0});if(Object.defineProperty(D,"target",{writable:!1,value:{...P,value:M}}),P.value=M,P.dispatchEvent(D),P.setSelectionRange(I,I),P.getBoundingClientRect()){let _=M.slice(0,I),W=document.createElement("span");W.style.font=window.getComputedStyle(P).font,W.style.whiteSpace="pre-wrap",W.textContent=_,document.body.appendChild(W);let F=W.offsetWidth;document.body.removeChild(W);let L=parseInt(window.getComputedStyle(P).lineHeight),$=_.split(`
195
- `).length-1,A=new CustomEvent("showVariableSuggestions",{detail:{cursorPosition:{left:Math.min(F%P.offsetWidth,P.offsetWidth-200),top:$*L+30}},bubbles:!0});P.dispatchEvent(A)}return}e.chain().focus().insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()},"handleVariableClick"),y=a((P,N,k,S,B,M,I)=>{let D=p[P];return!D||Array.isArray(D)||D.state==="hidden"?null:Lt(Mx,{tooltip:k,tooltipShortcut:M,onClick:S,active:B,disabled:D.state==="disabled",...I,children:N},P)},"renderButton"),C=a((P,N)=>{let k=P.filter(S=>!!S);return k.length>0?Lt("div",{className:"courier-flex courier-items-center courier-gap-0.5",children:k},N):null},"renderGroup"),x=C([((w=p.contentType)==null?void 0:w.state)==="enabled"&&Lt(Nx,{options:o,containerRef:n},"content-type")],"content-type-group"),h=C([y("bold",Lt(bx,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",g.onBold,r.isBold,["Mod","B"]),y("italic",Lt(yx,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",g.onItalic,r.isItalic,["Mod","I"]),y("underline",Lt(Tx,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",g.onUnderline,r.isUnderline,["Mod","U"]),y("strike",Lt(xx,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Strikethrough",g.onStrike,r.isStrike,["Mod","Shift","S"])],"text-style-group"),f=C([y("alignLeft",Lt(gx,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",g.onAlignLeft,r.isAlignLeft,["Shift","Mod","L"]),y("alignCenter",Lt(px,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",g.onAlignCenter,r.isAlignCenter,["Shift","Mod","E"]),y("alignRight",Lt(hx,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",g.onAlignRight,r.isAlignRight,["Shift","Mod","R"]),y("alignJustify",Lt(fx,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",g.onAlignJustify,r.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),E=r.isOrderedList||r.isUnorderedList?null:C([y("quote",Lt(Cx,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Quote",g.onQuote,r.isQuote,["Mod","Shift","B"])],"block-style-group"),T=C([y("link",Lt(vx,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",v,r.isLink,["Mod","K"]),y("variable",Lt(Pf,{width:16}),"Variable",b,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return Lt(_l.Wrapper,{ref:n,className:"courier-border-b rounded-b-none rounded-t-sm !courier-shadow-md courier-justify-center courier-rounded-lg",children:[x,h,f,E,T].filter(Boolean).map((P,N)=>Ax(Ex,{children:[P,N<[x,h,f,E,T].filter(Boolean).length-1&&Lt(_l.Divider,{})]},`item-${N}`))})},"TextMenu");import{jsx as ph}from"react/jsx-runtime";var Lx={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"}},Za=a(({editor:e})=>{let t=Ix(({editor:r})=>r.isFocused&&r.isEditable,[]);return e?ph(Sx,{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:ph(qa,{editor:e,config:Lx})}):null},"VariableEditorToolbar");Za.displayName="VariableEditorToolbar";import{jsx as gh,jsxs as Hx}from"react/jsx-runtime";var Xr=On.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,showToolbar:i=!1,onFocus:s,onBlur:l},c)=>{let u=On.useRef(!1),d=On.useRef(e),m=Dx({immediatelyRender:!1,extensions:[Pi,Mi.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),El,Hl,Hn,Fn,Rx.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:Di(e),editable:!n,editorProps:{attributes:{class:"courier-outline-none courier-min-h-[20px]"},handleKeyDown:(g,v)=>v.key==="Enter"&&!v.shiftKey?(v.preventDefault(),!0):!1},onUpdate:({editor:g})=>{if(u.current)return;let v=Fl(g.getJSON());v!==d.current&&(d.current=v,t==null||t(v))},onFocus:()=>{s==null||s()},onBlur:()=>{l==null||l()}});fh(()=>{if(!m||e===d.current)return;u.current=!0,d.current=e;let g=setTimeout(()=>{let v=Di(e);m.commands.setContent(v),u.current=!1},0);return()=>clearTimeout(g)},[m,e]),fh(()=>{m&&m.setEditable(!n)},[m,n]);let p=Vx(()=>{m==null||m.commands.focus()},[m]);return On.useImperativeHandle(c,()=>{let g=m==null?void 0:m.view.dom.parentElement;return g&&(g.focus=p),g},[m,p]),Hx("div",{ref:c,className:R("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:[gh(Bx,{editor:m,className:"courier-w-full"}),i&&!n&&gh(Za,{editor:m})]})});Xr.displayName="VariableTextarea";import Fx from"@tiptap/extension-placeholder";import{EditorContent as Ox,useEditor as Wx}from"@tiptap/react";import*as Wn from"react";import{useCallback as _x,useEffect as hh}from"react";import{jsx as bh,jsxs as Ux}from"react/jsx-runtime";var Ja=Wn.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=Wn.useRef(!1),m=Wn.useRef(e),p=Wx({immediatelyRender:!1,extensions:[Pi,Mi.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal courier-flex !courier-whitespace-nowrap courier-flex-nowrap courier-items-center"}}),El,Hl,Hn,Fn,Fx.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:Di(e),editable:!n&&!i,editorProps:{attributes:{class:"courier-outline-none"},handleKeyDown:(v,b)=>b.key==="Enter"?(b.preventDefault(),!0):!1},onUpdate:({editor:v})=>{if(d.current)return;let b=Fl(v.getJSON());b!==m.current&&(m.current=b,t==null||t(b))},onFocus:()=>{l==null||l()},onBlur:()=>{c==null||c()}});hh(()=>{if(!p||e===m.current)return;d.current=!0,m.current=e;let v=setTimeout(()=>{let b=Di(e);p.commands.setContent(b),d.current=!1},0);return()=>clearTimeout(v)},[p,e]),hh(()=>{p&&p.setEditable(!n&&!i)},[p,n,i]);let g=_x(()=>{p==null||p.commands.focus()},[p]);return Wn.useImperativeHandle(u,()=>{let v=p==null?void 0:p.view.dom.parentElement;return v&&(v.focus=g),v},[p,g]),Ux("div",{ref:u,className:R("variable-input-placeholder variable-editor-container variable-input-no-scrollbar","courier-flex courier-items-center courier-w-full courier-rounded-md courier-border-none courier-bg-transparent courier-text-foreground courier-py-1","courier-overflow-x-auto courier-overflow-y-clip","[&_.tiptap]:courier-whitespace-nowrap [&_.tiptap]:courier-flex-nowrap","[&_.tiptap]:courier-inline-flex [&_.tiptap]:courier-items-center","[&_.ProseMirror]:courier-inline-flex [&_.ProseMirror]:courier-items-center [&_.ProseMirror]:courier-flex-nowrap",(n||i)&&"courier-cursor-default",n&&"courier-opacity-50","[&_.tiptap]:courier-outline-none [&_.tiptap]:courier-border-none",o),style:{scrollbarWidth:"none",msOverflowStyle:"none"},onClick:()=>!i&&!n&&(p==null?void 0:p.commands.focus()),children:[bh(Ox,{editor:p,className:"courier-flex-1 courier-min-w-0"}),s&&!n&&bh(Za,{editor:p})]})});Ja.displayName="VariableInput";import{jsx as Hi,jsxs as t$}from"react/jsx-runtime";var Vi=30,ql=a(({color:e="currentColor",width:t=Vi,height:r=Vi,...o})=>Hi(Y,{...o,width:t,height:r,children:Hi("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"),Zl=a(({color:e="currentColor",width:t=Vi,height:r=Vi,...o})=>Hi(Y,{...o,width:t,height:r,children:Hi("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"),Jl=a(({color:e="currentColor",width:t=Vi,height:r=Vi,...o})=>Hi(Y,{...o,width:t,height:r,children:Hi("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");function yh(e,t){let r=null;return e.descendants((o,n)=>o.type.name==="button"&&o.attrs.id===t?(r={pos:n,node:o},!1):!0),r}a(yh,"findButtonNodeById");function vh(e,t){let r=e.nodeAt(t);return(r==null?void 0:r.type.name)==="button"?{pos:t,node:r}:null}a(vh,"findButtonNodeAtPosition");function $x(e){let t="";return e.content.forEach(r=>{var o;r.isText?t+=r.text:r.type.name==="variable"&&(t+=((o=r.attrs)==null?void 0:o.fallback)||"")}),t}a($x,"extractButtonTextContent");function Ch(e){let t=e.tr,r=!1;return e.doc.descendants((o,n)=>{if(o.type.name==="button"){let i=$x(o);i!==o.attrs.label&&(t.setNodeMarkup(n,void 0,{...o.attrs,label:i}),r=!0)}}),r?t:null}a(Ch,"syncButtonContentToLabelAttr");function xh(e,t,r){let o=e.doc.nodeAt(t);if(!o||o.type.name!=="button")return!1;e.setNodeMarkup(t,o.type,{...o.attrs,label:r});let n=t+1,i=t+1+o.content.size;return e.replaceWith(n,i,e.doc.type.schema.text(r)),e.setMeta("addToHistory",!0),!0}a(xh,"updateButtonLabelAndContent");import{jsx as fe,jsxs as Eo}from"react/jsx-runtime";var Kl=a(({element:e,editor:t,hideCloseButton:r=!1})=>{let o=qx({resolver:zx(Tl),defaultValues:{...Be,...e==null?void 0:e.attrs}}),{updateNodeAttributes:n}=gt({editor:t,element:e,form:o,nodeType:"button"}),i=Eh((e==null?void 0:e.attrs.id)||null),s=Eh(null);jx(()=>{e!=null&&e.attrs.id&&t&&(i.current=e.attrs.id,t.state.doc.descendants((u,d)=>u.attrs.id===e.attrs.id&&u.type.name==="button"?(s.current=d,!1):!0))},[e==null?void 0:e.attrs.id,t]);let l=Th(()=>{if(!t)return null;if(i.current){let u=yh(t.state.doc,i.current);if(u)return s.current=u.pos,u}if(s.current!==null){let u=vh(t.state.doc,s.current);if(u)return i.current=u.node.attrs.id,u}return null},[t]),c=Th(u=>{if(!t)return;let d=l();if(!d)return;let{pos:m}=d;pi(!0),t.chain().command(({tr:p,dispatch:g})=>g?xh(p,m,u):!1).run(),setTimeout(()=>{pi(!1)},50)},[t,l]);return e?Eo(He,{...o,children:[fe(ht,{type:"button",hideCloseButton:r}),Eo("form",{"data-sidebar-form":!0,onChange:()=>{n(o.getValues())},children:[fe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Label"}),fe(te,{control:o.control,name:"label",render:({field:u})=>Eo(Q,{className:"courier-mb-4",children:[fe(ee,{children:fe(be,{placeholder:"Enter button text",value:u.value,onChange:d=>{let m=typeof d=="string"?d:d.target.value;u.onChange(m),c(m)}})}),fe(re,{})]})}),fe(pe,{className:"courier-mt-6 courier-mb-4"}),fe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),fe(te,{control:o.control,name:"link",render:({field:u})=>Eo(Q,{children:[fe(ee,{children:fe(Xr,{value:u.value,onChange:d=>{u.onChange(d),n({...o.getValues(),link:d})},showToolbar:!0})}),fe(re,{})]})}),fe(pe,{className:"courier-mt-6 courier-mb-4"}),fe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Background"}),fe(te,{control:o.control,name:"backgroundColor",render:({field:u})=>Eo(Q,{className:"courier-mb-4",children:[fe(ee,{children:fe(bt,{...u,defaultValue:Be.backgroundColor,onChange:d=>{u.onChange(d),n({...o.getValues(),[u.name]:d})}})}),fe(re,{})]})}),fe(pe,{className:"courier-mt-6 courier-mb-4"}),fe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),fe(te,{control:o.control,name:"padding",render:({field:u})=>Eo(Q,{className:"courier-mb-2",children:[fe(ee,{children:fe(be,{type:"number",min:0,...u})}),fe(re,{})]})}),fe(te,{control:o.control,name:"alignment",render:({field:u})=>Eo(Q,{children:[fe(ee,{children:Eo(Ar,{type:"single",value:u.value,onValueChange:d=>{u.onChange(d),n({...o.getValues(),alignment:d})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[fe(Rt,{size:"sm",value:"left",className:"courier-w-full",children:fe(ql,{className:"courier-h-4 courier-w-4"})}),fe(Rt,{size:"sm",value:"center",className:"courier-w-full",children:fe(Zl,{className:"courier-h-4 courier-w-4"})}),fe(Rt,{size:"sm",value:"right",className:"courier-w-full",children:fe(Jl,{className:"courier-h-4 courier-w-4"})})]})}),fe(re,{})]})}),fe(pe,{className:"courier-mt-6 courier-mb-4"}),fe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),fe(te,{control:o.control,name:"borderRadius",render:({field:u})=>Eo(Q,{children:[fe(ee,{children:fe(be,{startAdornment:fe(va,{}),type:"number",min:0,...u})}),fe(re,{})]})})]})]}):null},"ButtonForm");import{mergeAttributes as t3,Node as r3}from"@tiptap/core";import{ReactNodeViewRenderer as o3}from"@tiptap/react";import{v4 as n3}from"uuid";import{useAtomValue as Zx,useSetAtom as Jx}from"jotai";import{useCallback as wo,useRef as _n,useEffect as kh,useLayoutEffect as Kx,useState as Gx}from"react";import{Fragment as e3,jsx as Yr,jsxs as _d}from"react/jsx-runtime";var Xx=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();pt(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"),Yx=a(({parts:e})=>{let t=Zx(gn);return Yr(e3,{children:e.map((r,o)=>{if(r.type==="text")return Yr("span",{children:r.content},o);let n=t[r.name];return _d("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:[Yr(Dl,{color:n?void 0:"#B45309"}),_d("span",{className:"courier-truncate courier-min-w-0",style:{color:"#000000"},children:[r.name,n?`="${n}"`:""]})]},o)})})},"ButtonLabelDisplay"),wh=a(({label:e,backgroundColor:t,textColor:r,onLabelChange:o,editable:n})=>{let i=_n(null),s=_n(e),l=_n(!1),[c,u]=Gx(!1),d=Xx(e),p=d.some(T=>T.type==="variable")&&!c;Kx(()=>{if(!i.current||!p)return;Array.from(i.current.childNodes).filter(w=>w.nodeType===Node.TEXT_NODE).forEach(w=>w.remove())},[p,e]);let g=_n(p),v=_n(!0);kh(()=>{if(!i.current||p){g.current=p;return}let T=g.current&&!p;g.current=p,(v.current||T||!l.current&&e!==s.current)&&(i.current.textContent=e),v.current=!1,s.current=e},[e,p]);let b=wo(()=>{if(i.current&&!p){l.current=!0;let T=i.current.textContent||"";s.current=T,o(T),requestAnimationFrame(()=>{l.current=!1})}},[o,p]),y=wo(T=>{var w;if(p){T.preventDefault(),T.stopPropagation();return}if(T.key==="Enter"&&(T.preventDefault(),(w=i.current)==null||w.blur()),(T.metaKey||T.ctrlKey)&&T.key==="a"&&(T.preventDefault(),T.stopPropagation(),i.current)){let P=document.createRange();P.selectNodeContents(i.current);let N=window.getSelection();N==null||N.removeAllRanges(),N==null||N.addRange(P)}},[p]),C=wo(()=>{u(!0)},[]),x=wo(()=>{u(!1)},[]),h=wo(T=>{let w=i.current;if(!w)return;if(p&&n){T.stopPropagation(),setTimeout(()=>{w.focus();let k=document.createRange();k.selectNodeContents(w),k.collapse(!1);let S=window.getSelection();S==null||S.removeAllRanges(),S==null||S.addRange(k)},0);return}if(!n)return;let P=a(()=>{let k=window.getSelection();if(!k||k.rangeCount===0)return;let S=k.getRangeAt(0),B=w.contains(S.startContainer),M=w.contains(S.endContainer);if(B&&!M){let I=document.createRange();I.selectNodeContents(w),k.removeAllRanges(),k.addRange(I)}},"checkAndConstrainSelection"),N=a(k=>{let S=w.getBoundingClientRect();(k.clientX<S.left||k.clientX>S.right||k.clientY<S.top||k.clientY>S.bottom)&&P(),document.removeEventListener("mouseup",N)},"handleMouseUp");document.addEventListener("mouseup",N)},[n,p]),f=p?Yr(Yx,{parts:d}):n?null:e,E=wo(T=>{p&&n&&T.stopPropagation()},[p,n]);return Yr("div",{ref:i,contentEditable:n&&!p,suppressContentEditableWarning:!0,tabIndex:n&&p?0:void 0,onInput:b,onKeyDown:y,onPointerDown:h,onClick:E,onFocus:C,onBlur:x,className:R("courier-inline-flex courier-justify-start courier-px-2 courier-py-1 courier-text-sm courier-rounded-sm courier-border courier-border-border courier-outline-none",n&&!p&&"courier-cursor-text"),style:{backgroundColor:t,color:r,borderColor:"transparent",borderRadius:"4px",caretColor:r,WebkitUserSelect:"text",userSelect:"text"},children:f})},"EditableButton"),Qx=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:m=!1})=>Yr("div",{className:"node-element",children:_d("div",{className:"courier-flex courier-gap-1 courier-justify-start",style:{marginTop:`${c}px`,marginBottom:`${c}px`},children:[Yr(wh,{label:e,backgroundColor:r,textColor:o,onLabelChange:u||(()=>{}),editable:m},"button1"),Yr(wh,{label:n,backgroundColor:s,textColor:l,onLabelChange:d||(()=>{}),editable:m},"button2")]})}),"ButtonRowComponent"),Ph=a(e=>{let t=Jx(Re),r=_n({}),o=_n({}),n=wo(()=>{if(!e.editor.isEditable)return;let l=ot(e);l&&t(l)},[e,t]),i=wo(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=wo(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 kh(()=>{let l=r.current;return()=>{l.button1&&clearTimeout(l.button1),l.button2&&clearTimeout(l.button2)}},[]),Yr(ft,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"buttonRow",children:Yr(Qx,{...e.node.attrs,onButton1LabelChange:i,onButton2LabelChange:s,editable:e.editor.isEditable})})},"ButtonRowComponentNode");var Sr={button1Label:"Register",button1Link:"",button1BackgroundColor:"#000000",button1TextColor:"#ffffff",button2Label:"Learn more",button2Link:"",button2BackgroundColor:"#ffffff",button2TextColor:"#000000",padding:6},Xl=r3.create({name:"buttonRow",group:"block",atom:!0,selectable:!1,onCreate(){je(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${n3()}`,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.id})},button1Label:{default:Sr.button1Label,parseHTML:e=>e.getAttribute("data-button1-label"),renderHTML:e=>({"data-button1-label":e.button1Label})},button1Link:{default:Sr.button1Link,parseHTML:e=>e.getAttribute("data-button1-link"),renderHTML:e=>({"data-button1-link":e.button1Link})},button1BackgroundColor:{default:Sr.button1BackgroundColor,parseHTML:e=>e.getAttribute("data-button1-bg"),renderHTML:e=>({"data-button1-bg":e.button1BackgroundColor})},button1TextColor:{default:Sr.button1TextColor,parseHTML:e=>e.getAttribute("data-button1-color"),renderHTML:e=>({"data-button1-color":e.button1TextColor})},button2Label:{default:Sr.button2Label,parseHTML:e=>e.getAttribute("data-button2-label"),renderHTML:e=>({"data-button2-label":e.button2Label})},button2Link:{default:Sr.button2Link,parseHTML:e=>e.getAttribute("data-button2-link"),renderHTML:e=>({"data-button2-link":e.button2Link})},button2BackgroundColor:{default:Sr.button2BackgroundColor,parseHTML:e=>e.getAttribute("data-button2-bg"),renderHTML:e=>({"data-button2-bg":e.button2BackgroundColor})},button2TextColor:{default:Sr.button2TextColor,parseHTML:e=>e.getAttribute("data-button2-color"),renderHTML:e=>({"data-button2-color":e.button2TextColor})},padding:{default:Sr.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",t3(e,{"data-type":"buttonRow"})]},addNodeView(){return o3(Ph,{stopEvent:({event:e})=>!(e.type==="dragstart"||e.type==="drop")})},addCommands(){return{setButtonRow:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...Sr,...e}}).run()}}});import{zodResolver as i3}from"@hookform/resolvers/zod";import{useForm as a3}from"react-hook-form";import{z as gr}from"zod";var Mh=gr.object({columnsCount:gr.number().min(1).max(4).default(2),paddingHorizontal:gr.number().default(0),paddingVertical:gr.number().default(0),backgroundColor:gr.string().default("transparent"),borderWidth:gr.number().default(0),borderRadius:gr.number().default(0),borderColor:gr.string().default("transparent"),cells:gr.array(gr.object({elements:gr.array(gr.any())})).optional()});import{jsx as ge,jsxs as Ir}from"react/jsx-runtime";var Ud=a(({element:e,editor:t,hideCloseButton:r=!1})=>{let o=a3({resolver:i3(Mh),defaultValues:{...Pt,...e==null?void 0:e.attrs}}),{updateNodeAttributes:n}=gt({editor:t,element:e,form:o,nodeType:"column"}),i=a(s=>{if(!t||!e)return;let l=null;if(t.state.doc.descendants((v,b)=>v.attrs.id===e.attrs.id&&v.type.name==="column"?(l=b,!1):!0),l===null)return;let c=t.state.doc.nodeAt(l);if(!c)return;let u=e.attrs.id,d=t.schema,m=t.state.tr,p=c.firstChild;if(!p||p.type.name!=="columnRow"){let v=Array.from({length:s},(y,C)=>d.nodes.columnCell.create({index:C,columnId:u,isEditorMode:!1})),b=d.nodes.columnRow.create({},v);m.replaceWith(l+1,l+c.nodeSize-1,b),m.setNodeMarkup(l,void 0,{...c.attrs,columnsCount:s}),m.setMeta("addToHistory",!0),t.view.dispatch(m);return}let g=p.childCount;if(s!==g){if(s>g){let v=s-g,y=l+1+p.nodeSize-1;for(let C=0;C<v;C++){let x=d.nodes.columnCell.create({index:g+C,columnId:u});m.insert(y+C*x.nodeSize,x)}}else{let v=g-s,y=l+1;for(let x=0;x<g-v;x++){let h=p.child(x);y+=h.nodeSize}let C=0;for(let x=g-v;x<g;x++){let h=p.child(x);C+=h.nodeSize}m.delete(y,y+C)}m.setNodeMarkup(l,void 0,{...c.attrs,columnsCount:s}),m.setMeta("addToHistory",!0),t.view.dispatch(m)}},"updateColumnCount");return e?Ir(He,{...o,children:[ge(ht,{type:"column",label:"Column layout",hideCloseButton:r}),Ir("form",{"data-sidebar-form":!0,onChange:()=>{n(o.getValues())},children:[ge("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Columns count"}),ge(te,{control:o.control,name:"columnsCount",render:({field:s})=>Ir(Q,{className:"courier-mb-4",children:[ge(ee,{children:ge(Ar,{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:s.value.toString(),onValueChange:l=>{if(l){let c=Number(l);s.onChange(c),i(c)}},children:[1,2,3,4].map(l=>ge(Rt,{value:l.toString(),className:"courier-w-12 courier-h-7",children:ge("span",{className:"courier-text-sm courier-font-medium",children:l})},l))})}),ge(re,{})]})}),ge(pe,{className:"courier-mt-6 courier-mb-4"}),ge("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Frame"}),Ir("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[ge(te,{control:o.control,name:"paddingHorizontal",render:({field:s})=>Ir(Q,{children:[ge(ee,{children:ge(be,{startAdornment:ge(Cn,{}),type:"number",min:0,...s})}),ge(re,{})]})}),ge(te,{control:o.control,name:"paddingVertical",render:({field:s})=>Ir(Q,{children:[ge(ee,{children:ge(be,{startAdornment:ge(go,{}),type:"number",min:0,...s})}),ge(re,{})]})})]}),ge(te,{control:o.control,name:"backgroundColor",render:({field:s})=>Ir(Q,{className:"courier-mb-4",children:[ge(ee,{children:ge(bt,{...s,defaultValue:Pt.backgroundColor,onChange:l=>{s.onChange(l),n({...o.getValues(),[s.name]:l})}})}),ge(re,{})]})}),ge(pe,{className:"courier-mt-6 courier-mb-4"}),ge("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Border"}),Ir("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[ge(te,{control:o.control,name:"borderWidth",render:({field:s})=>Ir(Q,{children:[ge(ee,{children:ge(be,{startAdornment:ge(fo,{}),type:"number",min:0,...s})}),ge(re,{})]})}),ge(te,{control:o.control,name:"borderRadius",render:({field:s})=>Ir(Q,{children:[ge(ee,{children:ge(be,{startAdornment:ge(va,{}),type:"number",min:0,...s})}),ge(re,{})]})})]}),ge(te,{control:o.control,name:"borderColor",render:({field:s})=>Ir(Q,{className:"courier-mb-4",children:[ge(ee,{children:ge(bt,{...s,defaultValue:Pt.borderColor,onChange:l=>{s.onChange(l),n({...o.getValues(),[s.name]:l})}})}),ge(re,{})]})})]})]}):null},"ColumnForm");import{mergeAttributes as s3,Node as l3}from"@tiptap/core";var Yl=l3.create({name:"columnRow",group:"columnContent",content:"columnCell+",isolating:!0,parseHTML(){return[{tag:'div[data-type="column-row"]'}]},renderHTML({HTMLAttributes:e}){return["div",s3(e,{"data-type":"column-row",class:"courier-flex courier-flex-row courier-gap-2 courier-w-full",style:"display: flex; flex-direction: row; gap: 0.5rem; width: 100%;"}),0]},addCommands(){return{insertColumnRow:()=>({chain:e})=>e().insertContent({type:this.name}).run()}}});import{mergeAttributes as f3,Node as g3}from"@tiptap/core";import{ReactNodeViewRenderer as h3}from"@tiptap/react";import{Plugin as b3,PluginKey as y3}from"@tiptap/pm/state";import{NodeViewWrapper as c3,NodeViewContent as u3}from"@tiptap/react";import{useEffect as Nh,useRef as d3,useState as Ah}from"react";import{useAtomValue as m3}from"jotai";import{jsx as Sh,jsxs as p3}from"react/jsx-runtime";var Ih=a(e=>{let t=d3(null),[r,o]=Ah(!1),n=m3(qt),i=e.node.attrs.isEditorMode===!0,[s,l]=Ah(e.editor.isEditable);Nh(()=>{let d=t.current;if(d)return nr({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]),Nh(()=>{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 p3(c3,{ref:t,"data-column-cell":"true","data-column-id":e.node.attrs.columnId,"data-cell-index":e.node.attrs.index,className:R("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&&Sh("span",{className:"courier-pointer-events-none courier-pl-4",children:"Drag and drop content blocks"}),Sh(u3,{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full"})]})},"ColumnCellComponentNode");var Ql=g3.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",f3(e,{"data-type":"column-cell",style:"flex: 1 1 0%; width: 0; min-height: 120px;"}),0]},addNodeView(){return h3(Ih)},addCommands(){return{insertColumnCell:()=>({chain:e})=>e().insertContent({type:this.name}).run()}},addProseMirrorPlugins(){return[new b3({key:new y3("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,m=i.attrs.isEditorMode;u?m=!1:u||(m=!0),m!==i.attrs.isEditorMode&&(o.setNodeAttribute(s,"isEditorMode",m),n=!0),d&&m===!1&&(o.delete(s+1,s+i.nodeSize-1),n=!0)}return!0}),n?o:null}})]}});import{useRef as ec,useCallback as Lh,useState as Rh,lazy as x3,Suspense as T3,useEffect as E3}from"react";import{forwardRef as v3}from"react";import{jsx as C3}from"react/jsx-runtime";var $d=v3(({className:e,...t},r)=>{let o=R("courier-animate-spin courier-rounded-full courier-border-2 courier-border-current courier-border-t-transparent courier-h-4 courier-w-4",e);return C3("div",{className:o,ref:r,...t})});$d.displayName="Spinner";import{jsx as Fi}from"react/jsx-runtime";var w3=a(()=>{let[e,t]=Rh(!1),r=ec(null);return E3(()=>{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"),k3=x3(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function P3(e,t){let r=ec();return Lh((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}a(P3,"useDebounce");var M3=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 p=(e.match(/<([a-z][a-z0-9]*)\b[^>]*(?<!\/\/)>/gi)||[]).map(y=>{var C,x;return(x=(C=y.match(/<([a-z][a-z0-9]*)/i))==null?void 0:C[1])==null?void 0:x.toLowerCase()}).filter(Boolean),g=(e.match(/<\/([a-z][a-z0-9]*)\s*>/gi)||[]).map(y=>{var C,x;return(x=(C=y.match(/<\/([a-z][a-z0-9]*)/i))==null?void 0:C[1])==null?void 0:x.toLowerCase()}).filter(Boolean),v=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],b=p.filter(y=>y&&!v.includes(y));for(let y of b){let C=p.filter(h=>h===y).length,x=g.filter(h=>h===y).length;if(C!==x)return!1}return!0}catch{return!1}},"defaultHTMLValidator"),zd=a(({code:e,onSave:t,onValidationChange:r,validator:o=M3})=>{let n=ec(null),i=ec(null),[s,l]=Rh(!0),{isDark:c,containerRef:u}=w3(),d=Lh(()=>{if(!n.current||!i.current)return!0;let v=n.current.getModel();if(!v)return!0;let b=v.getValue(),y=o(b,n.current,i.current);return y!==s&&(l(y),r==null||r(y)),y},[s,r,o]),m=P3(v=>{setTimeout(()=>{d()&&t(v)},150)},500);return Fi("div",{ref:u,className:"courier-h-full courier-overflow-hidden",children:Fi("div",{className:"courier-h-full courier-p-2",children:Fi(T3,{fallback:Fi("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:Fi($d,{})}),children:Fi(k3,{height:"100%",defaultLanguage:"html",value:e,onChange:a(v=>{m(v||"")},"handleCodeChange"),onMount:a((v,b)=>{n.current=v,i.current=b,v.focus(),v.onDidChangeModelContent(()=>{setTimeout(d,100)}),setTimeout(d,100)},"handleEditorDidMount"),theme:c?"vs-dark":"vs-light",options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,wordWrap:"on",automaticLayout:!0,tabSize:2,insertSpaces:!0,formatOnPaste:!0,formatOnType:!0,glyphMargin:!1,folding:!1,lineDecorationsWidth:10,lineNumbersMinChars:0,fixedOverflowWidgets:!0}})})})})},"MonacoCodeEditor");import{zodResolver as N3}from"@hookform/resolvers/zod";import{useForm as A3}from"react-hook-form";import{z as Bh}from"zod";var Dh=Bh.object({code:Bh.string()});import{useCallback as S3}from"react";import{useAtom as I3}from"jotai";import{Fragment as Vh,jsx as Qr,jsxs as Ka}from"react/jsx-runtime";var jd=a(({element:e,editor:t,hideCloseButton:r=!1})=>{let o=A3({resolver:N3(Dh),defaultValues:{...bo,...e==null?void 0:e.attrs}}),{updateNodeAttributes:n}=gt({editor:t,element:e,form:o,nodeType:"customCode"}),[i,s]=I3(_r),l=S3(c=>{o.setValue("code",c),n({code:c})},[o,n]);return e?Ka(He,{...o,children:[!i&&Qr(ht,{type:"customCode",hideCloseButton:r}),Ka("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[Qr(Me,{className:"courier-w-fit",variant:"outline",buttonSize:"small",onClick:()=>s(!i),children:i?Ka(Vh,{children:[Qr(Tu,{className:"courier-w-3 courier-h-3"}),"Minimize"]}):Ka(Vh,{children:[Qr(Ca,{className:"courier-w-3 courier-h-3"}),"Expand Editor"]})}),Qr("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:Qr("form",{"data-sidebar-form":!0,onChange:()=>{n(o.getValues())},className:"courier-h-full",children:Qr(te,{control:o.control,name:"code",render:({field:c})=>Ka(Q,{className:"courier-h-full",children:[Qr(ee,{children:Qr(zd,{code:c.value,onSave:u=>{c.onChange(u),l(u)},onCancel:()=>{}})}),Qr(re,{})]})})})})]})]}):null},"CustomCodeForm");import{z as Oi}from"zod";var Hh=Oi.object({padding:Oi.number(),color:Oi.string(),size:Oi.number(),radius:Oi.number(),variant:Oi.enum(["divider","spacer"]).default("divider")});import{zodResolver as L3}from"@hookform/resolvers/zod";import{useForm as R3}from"react-hook-form";import{Fragment as B3,jsx as Ct,jsxs as Wi}from"react/jsx-runtime";var Fh=a(({element:e,editor:t,hideCloseButton:r=!1})=>{let o=R3({resolver:L3(Hh),defaultValues:{...ar,...e==null?void 0:e.attrs}}),{updateNodeAttributes:n}=gt({editor:t,element:e,form:o,nodeType:"divider"});if(!e)return null;let i=o.watch("variant");return Wi(He,{...o,children:[Ct(ht,{type:i,hideCloseButton:r}),Wi("form",{"data-sidebar-form":!0,onChange:()=>{n(o.getValues())},children:[Ct("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),Ct(te,{control:o.control,name:"padding",render:({field:s})=>Wi(Q,{children:[Ct(ee,{children:Ct(be,{startAdornment:Ct(go,{}),type:"number",...s,onChange:l=>{s.onChange(l),n({...o.getValues(),margin:l.target.value})}})}),Ct(re,{})]})}),i==="divider"&&Wi(B3,{children:[Ct(pe,{className:"courier-mt-6 courier-mb-4"}),Ct("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Line"}),Ct(te,{control:o.control,name:"size",render:({field:s})=>Wi(Q,{className:"courier-mb-4",children:[Ct(ee,{children:Ct(be,{startAdornment:Ct(fo,{}),type:"number",min:0,...s,onChange:l=>{s.onChange(l),n({...o.getValues(),width:l.target.value})}})}),Ct(re,{})]})}),Ct(te,{control:o.control,name:"color",render:({field:s})=>Wi(Q,{className:"courier-mb-4",children:[Ct(ee,{children:Ct(bt,{...s,defaultValue:ar.color,onChange:l=>{s.onChange(l),n({...o.getValues(),[s.name]:l})}})}),Ct(re,{})]})})]})]})]})},"DividerForm");var qd=Pi.extend({content:"(block)+"});import{Node as _3}from"@tiptap/core";import{ReactNodeViewRenderer as U3}from"@tiptap/react";import{NodeViewWrapper as D3}from"@tiptap/react";import{forwardRef as V3,useEffect as Oh,useState as H3}from"react";import{jsx as tc}from"react/jsx-runtime";function F3(){let[e,t]=H3(!1);return Oh(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}a(F3,"useMountStatus");var O3=V3(({children:e,className:t,dragOverlay:r,id:o},n)=>(Oh(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),tc(D3,{ref:n,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":o,"data-placeholder":"true",className:R("courier-flex courier-items-start courier-gap-2 courier-pl-6",t),children:e}))),W3=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"list":return"List";case"customCode":return"Custom code";case"column":return"Column layout";default:return e}},"getPlaceholderLabel"),Wh=a(({node:e})=>{let t=e.attrs.type,r=e.attrs.id,o=F3();return tc(O3,{id:r,fadeIn:!o,children:tc("div",{className:R("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:tc("div",{className:"courier-text-accent-foreground",children:W3(t)})})})},"DragPlaceholderComponent");var _h=_3.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 U3(Wh,{as:"div",className:"drag-placeholder-wrapper"})}});import{Extension as $3}from"@tiptap/core";import{Plugin as z3,PluginKey as j3}from"@tiptap/pm/state";var q3=new j3("file-handler"),Z3=$3.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new z3({key:q3,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(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,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)}}})]}}),rc=Z3;import{Extension as J3}from"@tiptap/core";import{Plugin as K3,PluginKey as G3}from"@tiptap/pm/state";var X3=new G3("fixedChannelPaste"),Y3=a(e=>{let t=e.view.dom.closest(".courier-slack-editor"),r=e.view.dom.closest(".courier-msteams-editor"),o=e.view.dom.closest(".courier-email-editor");if(t||r||o)return!1;let n=e.view.dom.closest(".courier-push-editor"),i=e.view.dom.closest(".courier-sms-editor"),s=e.view.dom.closest(".courier-inbox-editor");if(n||i||s)return!0;let l=e.state.doc,c=0,u=0;l.forEach(g=>{g.type.name==="paragraph"||g.type.name==="heading"?c++:g.type.name==="button"&&u++});let d=c===1&&u===0,m=c===2&&u===0,p=c>=2&&c+u<=4;return d||m||p},"isInFixedChannel"),Q3=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(`
196
- `).trim()},"extractTextFromSlice"),oc=J3.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new K3({key:X3,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!Y3(e))return!1;let l=i.$from.node();if(!(l.type.name==="paragraph"||l.type.name==="heading"))return!1;let u=o.content.childCount>1;if(r.preventDefault(),u){let v=Q3(o);if(!v)return!1;let b=n.tr.replaceSelectionWith(n.schema.text(v),!1);return t.dispatch(b),!0}let d=i.from,m=n.tr.replaceSelection(o),p=d+o.size,g=new Set;return m.doc.nodesBetween(d,p,v=>{v.marks.forEach(b=>{g.add(b.type.name)})}),g.forEach(v=>{let b=n.schema.marks[v];b&&(m=m.removeMark(d,p,b))}),t.dispatch(m),!0}}})]},addStorage(){return{currentChannel:null}}});import{Extension as e8}from"@tiptap/core";import{Plugin as t8,PluginKey as r8,TextSelection as Zd}from"@tiptap/pm/state";var Un=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"),Jd=a(e=>!!e.view.dom.closest(".courier-inbox-editor"),"isInInboxChannel"),Uh=a(e=>{if(!Jd(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"),$n=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"),nc=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"),ic=new r8("fixedChannelSelection"),ac=e8.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!Un(e,this.options.channels))return!1;let o=$n(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(Zd.create(t.doc,l,c)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!Un(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(!Un(e,this.options.channels))return!1;if(Jd(e)){let{selection:t}=e.state;if($n(e)&&t.$anchor.parentOffset===0&&Uh(e))return!0}if(nc(e)){let t=$n(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(!Un(e,this.options.channels))return!1;if(Jd(e)){let{selection:t}=e.state,r=$n(e);if(r){let o=r.node.textContent;if(t.$anchor.parentOffset===o.length&&Uh(e))return!0}}if(nc(e)){let t=$n(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 t8({key:ic,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!Un(o,this.options.channels))return!1;if(nc(o)){let n=$n(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(Zd.create(u.doc,l,c)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!Un(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(ic,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!Un(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&nc(r)){let n=ic.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(Zd.create(c.doc,s,l)),e.dispatch(c),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(ic)||t}}})]}});import{mergeAttributes as a8}from"@tiptap/core";import{Node as o8,mergeAttributes as n8,textblockTypeInputRule as i8}from"@tiptap/core";var $h=o8.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]}`,n8(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=>i8({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});import{ReactNodeViewRenderer as s8}from"@tiptap/react";var Kd=$h.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){je(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:xe.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):xe.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:xe.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):xe.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:xe.textAlign,parseHTML:t=>t.style.textAlign||xe.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:xe.backgroundColor,parseHTML:t=>t.style.backgroundColor||xe.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:xe.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):xe.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderColor:{default:xe.borderColor,parseHTML:t=>t.style.borderColor||xe.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]}`,a8(this.options.HTMLAttributes,t),0]},addNodeView(){return s8(al)}});import{z as eo}from"zod";var zh=eo.object({sourcePath:eo.string(),link:eo.string().optional(),alt:eo.string().optional(),alignment:eo.enum(["left","center","right"]),width:eo.number().min(1).max(100),borderWidth:eo.number(),borderColor:eo.string(),isUploading:eo.boolean().optional(),imageNaturalWidth:eo.number()});import{zodResolver as l8}from"@hookform/resolvers/zod";import{useSetAtom as c8}from"jotai";import{ArrowUp as u8}from"lucide-react";import{useCallback as Xa,useEffect as qh,useRef as Yd,useState as lc}from"react";import{useForm as d8}from"react-hook-form";import{useSetAtom as Gd}from"jotai";import*as Ga from"react";import{useRef as jh}from"react";import{jsx as sc}from"react/jsx-runtime";var Qo=Ga.forwardRef(({as:e="Input",autoResize:t,onChange:r,...o},n)=>{let i=jh(null),s=jh(null),l=Gd(Ra),c=Gd(Eg),u=Gd(Qs),d=Ga.useCallback(()=>{if(!s.current)return;let b={ref:s.current,caretPosition:s.current.selectionStart};c(b),u(b),l({isFocused:!0,hasVariables:!1,showVariablePopup:!1})},[l,c,u]),m=Ga.useCallback(b=>{var C;((C=b.relatedTarget)==null?void 0:C.closest("[data-variable-button]"))||(c({ref:null,caretPosition:null}),l({isFocused:!1,hasVariables:!1,showVariablePopup:!1}))},[l,c]),p=a(b=>{let y=b.target,C={ref:y,caretPosition:y.selectionStart};c(C),u(C)},"handleSelect"),g=a(b=>{r&&r(b)},"handleChange");if(e==="Input"){let b={...o,ref:y=>{s.current=y,typeof n=="function"?n(y):n&&(n.current=y)},onChange:g,onFocus:d,onBlur:m,onSelect:p};return sc("div",{ref:i,className:"courier-relative",children:sc(be,{...b})})}let v={...o,ref:b=>{s.current=b,typeof n=="function"?n(b):n&&(n.current=b)},onChange:g,onFocus:d,onBlur:m,autoResize:t,onSelect:p};return sc("div",{ref:i,className:"courier-relative",children:sc(Xd,{...v})})});Qo.displayName="TextInput";import{Fragment as Zh,jsx as ae,jsxs as Bt}from"react/jsx-runtime";var Jh=a(({element:e,editor:t,hideCloseButton:r=!1})=>{var P,N;let o=Yd(null),n=Yd(null),i=Yd(null),[s,l]=lc(""),[c,u]=lc(!1),[d,m]=lc(((P=e==null?void 0:e.attrs)==null?void 0:P.imageNaturalWidth)||0),[p,g]=lc(!1),v=c8(ue),{uploadImage:b}=ba(),y=d8({resolver:l8(zh),defaultValues:{...st,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:C}=gt({editor:t,element:e,form:y,nodeType:"imageBlock"});qh(()=>{var S;let k=(S=e==null?void 0:e.attrs)==null?void 0:S.sourcePath;if(k&&!d){let B=new Image;B.onload=()=>{m(B.naturalWidth);let M={...y.getValues(),imageNaturalWidth:B.naturalWidth};y.setValue("imageNaturalWidth",B.naturalWidth),C(M)},B.src=k}},[(N=e==null?void 0:e.attrs)==null?void 0:N.sourcePath,d,y,C]);let x=Xa(k=>{var D,V;let S=(V=(D=t==null?void 0:t.view)==null?void 0:D.dom)==null?void 0:V.closest(".ProseMirror"),B=(S==null?void 0:S.clientWidth)||1e3;if(k||(k=d),!k)return 0;let M=Math.min(100,k/B*100);return Math.round(M)},[t,d]),h=Xa(k=>{var S;k.preventDefault(),(S=o.current)==null||S.click()},[]),f=Xa((k,S)=>{let B=x(k.naturalWidth);l(`${B}%`),u(!1),y.setValue("sourcePath",S),y.setValue("imageNaturalWidth",k.naturalWidth),y.setValue("width",B);let M={...y.getValues(),sourcePath:S,width:B,imageNaturalWidth:k.naturalWidth,isUploading:!1};C(M)},[y,C,x]),E=Xa(k=>{if(!k){y.setValue("imageNaturalWidth",0),y.setValue("width",0),C({...y.getValues(),sourcePath:"",imageNaturalWidth:0,width:0});return}let S=new Image;S.onload=()=>{let B=x(S.naturalWidth);y.setValue("imageNaturalWidth",S.naturalWidth),y.setValue("width",B);let M={...y.getValues(),sourcePath:k,width:B,imageNaturalWidth:S.naturalWidth};C(M)},S.onerror=()=>{console.debug("Image failed to load:",k)},S.src=k},[y,C,x]),T=Xa(k=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{E(k)},500)},[E]);qh(()=>()=>{i.current&&clearTimeout(i.current)},[]);let w=y.getValues().sourcePath;return e?Bt(He,{...y,children:[ae(ht,{type:"image",hideCloseButton:r}),Bt("form",{ref:n,"data-sidebar-form":!0,onChange:()=>{let k=y.getValues();C(k)},children:[ae("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),Bt(_i,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[Bt(zn,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[ae(ko,{value:"file",className:"courier-flex-1",children:"From file"}),ae(ko,{value:"url",className:"courier-flex-1",children:"From URL"})]}),ae(cc,{value:"file",children:Bt("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[ae(Me,{onClick:h,className:"courier-w-full",variant:"outline",type:"button",disabled:p,children:p?ae(Zh,{children:"Uploading..."}):Bt(Zh,{children:[ae(u8,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),ae("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:k=>{var B;let S=(B=k.target.files)==null?void 0:B[0];if(S){g(!0),y.setValue("sourcePath",""),C({...y.getValues(),sourcePath:"",isUploading:!0});let M=new FileReader;M.onload=async()=>{try{let D=(await b({file:S})).url,V=new Image;V.onload=()=>{f(V,D),g(!1)},V.onerror=()=>{v({message:"Upload failed: Failed to load uploaded image",toastProps:{duration:6e3,description:`File: ${S.name} (${(S.size/1024/1024).toFixed(2)}MB)`}}),g(!1),C({...y.getValues(),isUploading:!1})},V.src=D}catch(I){console.error("Error uploading image:",I),v({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${S.name} (${(S.size/1024/1024).toFixed(2)}MB)`}}),g(!1),C({...y.getValues(),isUploading:!1})}},M.onerror=()=>{v({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${S.name} (${(S.size/1024/1024).toFixed(2)}MB)`}}),g(!1),C({...y.getValues(),isUploading:!1})},M.readAsDataURL(S)}}})]})}),ae(cc,{value:"url",children:ae(te,{control:y.control,name:"sourcePath",render:({field:k})=>Bt(Q,{className:"courier-mb-3",children:[ae(ee,{children:ae(Qo,{as:"Textarea",...k,autoResize:!0,className:"courier-max-h-[88px]",onChange:S=>{k.onChange(S),T(S.target.value)}})}),ae(re,{})]})})})]}),ae(te,{control:y.control,name:"link",render:({field:k})=>Bt(Q,{className:"courier-mb-3",children:[ae(ee,{children:ae(Xr,{placeholder:"Link",value:k.value,onChange:S=>{k.onChange(S),C({...y.getValues(),link:S})},showToolbar:!0})}),ae(re,{})]})}),ae(te,{control:y.control,name:"alt",render:({field:k})=>Bt(Q,{className:"courier-mb-4",children:[ae(ee,{children:ae(Xr,{placeholder:"Alt text...",value:k.value,onChange:S=>{k.onChange(S),C({...y.getValues(),alt:S})},showToolbar:!0})}),ae(re,{})]})}),ae(pe,{className:"courier-mt-6 courier-mb-4"}),ae("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Width"}),(()=>{let k=y.getValues().width,S=y.getValues().imageNaturalWidth,B=x(S),M=k===B,I=M?"original":"fill";return Bt(Ar,{type:"single",value:w?I:"original",onValueChange:D=>{if(!D||D===I)return;let V=D==="fill"?100:x(S);V>0&&(y.setValue("width",V),C({...y.getValues(),width:V}))},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",disabled:!w,children:[ae(Rt,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),ae(Rt,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:M||!w,children:"Fill"})]})})(),ae(te,{control:y.control,name:"width",render:({field:k})=>Bt(Q,{className:"courier-flex-1 courier-mb-3",children:[ae(ee,{children:ae(be,{type:"text",inputMode:"numeric",pattern:"[0-9]*",min:1,max:100,...k,value:y.getValues().sourcePath?c?s:`${k.value}%`:"0%",className:"courier-text-2xl courier-font-normal",disabled:!y.getValues().sourcePath,onFocus:S=>{u(!0),l(S.target.value)},onChange:S=>{l(S.target.value)},onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),S.currentTarget.blur())},onBlur:S=>{u(!1);let B=parseFloat(S.target.value.replace("%",""));if(!isNaN(B)){let M=Math.min(100,Math.max(1,B));k.onChange(M),C({...y.getValues(),width:Math.round(M)})}}})}),ae(re,{})]})}),ae(te,{control:y.control,name:"width",render:({field:k})=>Bt(Q,{className:"courier-flex-1 courier-mb-3",children:[ae(ee,{children:ae(Qd,{min:0,max:100,value:[w?k.value:0],disabled:!w,onValueChange:S=>{k.onChange(S[0]),C({...y.getValues(),width:S[0]})}})}),ae(re,{})]})}),ae(te,{control:y.control,name:"alignment",render:({field:k})=>Bt(Q,{children:[ae(ee,{children:Bt(Ar,{disabled:!w,type:"single",value:k.value,onValueChange:S=>{k.onChange(S),C({...y.getValues(),alignment:S})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[ae(Rt,{size:"sm",value:"left",className:"courier-w-full",children:ae(ql,{className:"courier-h-4 courier-w-4"})}),ae(Rt,{size:"sm",value:"center",className:"courier-w-full",children:ae(Zl,{className:"courier-h-4 courier-w-4"})}),ae(Rt,{size:"sm",value:"right",className:"courier-w-full",children:ae(Jl,{className:"courier-h-4 courier-w-4"})})]})}),ae(re,{})]})}),ae(pe,{className:"courier-mt-6 courier-mb-4"}),ae("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),ae(te,{control:y.control,name:"borderWidth",render:({field:k})=>Bt(Q,{className:"courier-mb-3",children:[ae(ee,{children:ae(be,{startAdornment:ae(fo,{}),type:"number",disabled:!w,min:0,...k,onChange:S=>{let B=parseInt(S.target.value)||0;k.onChange(B),C({...y.getValues(),borderWidth:B})}})}),ae(re,{})]})}),ae(te,{control:y.control,name:"borderColor",render:({field:k})=>Bt(Q,{className:"courier-mb-4",children:[ae(ee,{children:ae(bt,{...k,disabled:!w,defaultValue:st.borderColor,onChange:S=>{k.onChange(S),C({...y.getValues(),[k.name]:S})}})}),ae(re,{})]})})]})]}):null},"ImageBlockForm");import{getMarkRange as Kh,mergeAttributes as m8}from"@tiptap/core";import p8 from"@tiptap/extension-link";import{Plugin as Gh,TextSelection as Xh}from"@tiptap/pm/state";var em=p8.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",m8(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new Gh({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=Kh(l,c.type);return u?(r.dispatch(i.tr.setSelection(Xh.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(Xh.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 Gh({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 m=d.replace(/__VAR_([^_]+)__/g,"{{$1}}");if(m!==d){let p=Kh(n.doc.resolve(c),u.type);p&&(i.removeMark(p.from,p.to,u.type),i.addMark(p.from,p.to,u.type.create({...u.attrs,href:m,hasVariables:!0,originalHref:m})),s=!0)}}}}),!0)),s?i:null}})]}});import{zodResolver as f8}from"@hookform/resolvers/zod";import{useSetAtom as g8}from"jotai";import{ExternalLink as h8}from"lucide-react";import{useRef as b8,useEffect as y8}from"react";import{useForm as v8}from"react-hook-form";import{z as tm}from"zod";import{jsx as en,jsxs as Ya}from"react/jsx-runtime";var C8=tm.object({href:tm.string(),openInNewTab:tm.boolean().default(!1)}),Ui=a(({editor:e,mark:t,pendingLink:r})=>{let o=g8(Oo),n=b8(null),i=v8({resolver:f8(C8),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1},mode:"onChange"});y8(()=>{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 d=>{let m=d.href.trim();if(!m){r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),e==null||e.commands.unsetLink(),o(null);return}r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),await(e==null?void 0:e.chain().focus().unsetLink().setTextSelection({from:(r==null?void 0:r.from)||0,to:(r==null?void 0:r.to)||0}).setLink({href:m,target:d.openInNewTab?"_blank":null}).run()),e==null||e.commands.setTextSelection((r==null?void 0:r.to)||0),o(null)},"updateLink"),l=a(()=>{let d=i.getValues().href.trim();d&&window.open(d,"_blank","noopener,noreferrer")},"handleOpenLink"),c=a(()=>{i.handleSubmit(s)()},"handleSave"),{isDirty:u}=i.formState;return Ya(He,{...i,children:[en("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),Ya("div",{className:"courier-space-y-4",children:[en(te,{control:i.control,name:"href",render:({field:d})=>Ya(Q,{children:[en(to,{children:"URL"}),en(ee,{children:en(Qo,{as:"Textarea",autoResize:!0,...d,ref:m=>{typeof d.ref=="function"&&d.ref(m),n.current=m},onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),m.stopPropagation(),i.handleSubmit(s)())},onBlur:()=>{d.onBlur(),i.handleSubmit(s)()}})}),en(re,{})]})}),Ya("div",{className:"courier-flex courier-gap-2",children:[Ya(Me,{type:"button",variant:"outline",onClick:l,disabled:!i.getValues().href.trim(),className:"courier-flex-1",children:[en(h8,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2"}),"Open link"]}),en(Me,{type:"button",variant:"primary",onClick:c,disabled:!u,className:"courier-flex-1",children:"Save"})]})]})]})},"LinkForm");import{mergeAttributes as P8,Node as M8}from"@tiptap/core";import{Plugin as N8,PluginKey as A8,TextSelection as S8}from"@tiptap/pm/state";import{ReactNodeViewRenderer as I8}from"@tiptap/react";import{v4 as L8}from"uuid";import{z as Qa}from"zod";var Yh=Qa.object({id:Qa.string().optional(),listType:Qa.enum(["ordered","unordered"]),paddingVertical:Qa.coerce.number().min(0),paddingHorizontal:Qa.coerce.number().min(0)}),Po={listType:"unordered",paddingVertical:6,paddingHorizontal:0};import{NodeViewContent as Qh,NodeViewWrapper as x8}from"@tiptap/react";import{useSetAtom as T8,useAtomValue as E8}from"jotai";import{useCallback as w8,useMemo as k8}from"react";import{jsx as jn}from"react/jsx-runtime";var eb=a(e=>{var b,y;let{editor:t,node:r,getPos:o}=e,n=T8(Re),i=E8(Ce),{listType:s,id:l,paddingVertical:c,paddingHorizontal:u}=r.attrs,d=k8(()=>{let C=o();if(typeof C!="number")return!1;let x=t.state.doc.resolve(C);for(let h=x.depth;h>=0;h--)if(x.node(h).type.name==="blockquote")return!0;return!1},[t.state.doc,o]),m=((b=i==null?void 0:i.type)==null?void 0:b.name)==="list"&&(((y=i==null?void 0:i.attrs)==null?void 0:y.id)===l||i===e.node),p=w8(()=>{if(!e.editor.isEditable||d)return;let C=ot(e);C&&n(C)},[e,n,d]),g=s==="ordered"?"ol":"ul",v={...c&&{paddingTop:`${c}px`,paddingBottom:`${c}px`},...u&&{paddingLeft:`${20+Number(u)}px`,paddingRight:`${u}px`}};return d?jn(x8,{className:"node-list",children:jn(g,{className:R("courier-list-wrapper",s==="ordered"?"courier-list-decimal":"courier-list-disc","courier-m-0 courier-py-1 courier-pl-6"),style:v,"data-type":"list","data-list-type":s,"data-id":l,"data-node-id":l,children:jn(Qh,{})})}):jn(ft,{id:l,className:R(m&&"selected-element"),onClick:p,editor:e.editor,children:jn("div",{className:"node-element",children:jn(g,{className:R("courier-list-wrapper",s==="ordered"?"courier-list-decimal":"courier-list-disc","courier-m-0 courier-py-1 courier-pl-6"),style:v,"data-type":"list","data-list-type":s,"data-id":l,"data-node-id":l,children:jn(Qh,{})})})})},"ListComponentNode");var uc=M8.create({name:"list",group:"block",content:"listItem+",defining:!0,addOptions(){return{HTMLAttributes:{}}},onCreate(){je(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${L8()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},listType:{default:Po.listType,parseHTML:e=>e.tagName.toLowerCase()==="ol"?"ordered":e.tagName.toLowerCase()==="ul"?"unordered":e.getAttribute("data-list-type")||"unordered",renderHTML:e=>({"data-list-type":e.listType})},paddingVertical:{default:Po.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:Po.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})}}},parseHTML(){return[{tag:"ul",attrs:{listType:"unordered"}},{tag:"ol",attrs:{listType:"ordered"}},{tag:'div[data-type="list"]'}]},renderHTML({HTMLAttributes:e,node:t}){return[t.attrs.listType==="ordered"?"ol":"ul",P8(this.options.HTMLAttributes,e,{"data-type":"list"}),0]},addNodeView(){return I8(eb)},addKeyboardShortcuts(){return{Tab:({editor:t})=>{if(!t.isActive("listItem"))return!1;let{$from:r}=t.state.selection,o=0,n=null;for(let i=r.depth;i>=0;i--)r.node(i).type.name==="list"&&(o++,n===null&&(n=r.node(i).attrs.listType||"unordered"));return o>=5||t.commands.sinkListItem("listItem"),!0},"Shift-Tab":({editor:t})=>t.isActive("listItem")?(t.commands.liftListItem("listItem"),!0):!1,Enter:({editor:t})=>{let{$from:r,empty:o}=t.state.selection,n=-1,i=-1,s=0;for(let d=r.depth;d>=0;d--){let m=r.node(d);m.type.name==="listItem"&&n===-1&&(n=d),m.type.name==="list"&&(i===-1&&(i=d),s++)}if(n===-1||i===-1)return!1;let l=r.node(n),c=r.node(i),u=l.textContent.length===0;if(o&&u){if(s>1)return t.commands.liftListItem("listItem");if(c.childCount===1)return!0;let p=r.index(i),g=r.before(n),v=r.after(n);return p===c.childCount-1||t.chain().focus().deleteRange({from:g,to:v}).run(),!0}return t.commands.splitListItem("listItem")},Backspace:({editor:t})=>{let{$from:r,empty:o}=t.state.selection;if(!o||r.parentOffset!==0)return!1;let n=-1,i=-1,s=0;for(let b=r.depth;b>=0;b--){let y=r.node(b);y.type.name==="listItem"&&n===-1&&(n=b),y.type.name==="list"&&(i===-1&&(i=b),s++)}if(n===-1||i===-1)return!1;let l=r.node(n),c=r.node(i),u=l.textContent.length===0,d=r.index(i),m=s>1;if(!u){if(d===0)return!0;let{state:b,view:y}=t,C=b.tr,x=r.before(n),h=r.after(n),f=l.firstChild;if(!f)return!1;let E=x-2;if(E<0)return!1;let T=b.doc.resolve(E),w=-1;for(let M=T.depth;M>=0;M--)if(T.node(M).type.name==="listItem"){w=M;break}if(w===-1)return!1;let N=T.node(w).firstChild;if(!N)return!1;let S=T.before(w)+1+N.nodeSize-1,B=f.content;return C.delete(x,h),C.insert(S,B),C.setSelection(S8.near(C.doc.resolve(S))),y.dispatch(C),!0}if(c.childCount===1)return m?t.commands.liftListItem("listItem"):!0;let g=r.before(n),v=r.after(n);if(d>0){let b=g-2;if(b<0)return!1;let y=t.state.doc.resolve(b),C=-1;for(let T=y.depth;T>=0;T--)if(y.node(T).type.name==="listItem"){C=T;break}if(C===-1)return!1;let h=y.node(C).firstChild;if(!h)return!1;let E=y.before(C)+1+h.nodeSize-1;t.chain().focus().deleteRange({from:g,to:v}).setTextSelection(E).run()}else t.chain().focus().deleteRange({from:g,to:v}).run();return!0}}},addCommands(){return{setList:(e={})=>({chain:t})=>{let r=e.listType||"unordered";return t().insertContent({type:this.name,attrs:{listType:r,...e},content:[{type:"listItem",content:[{type:"paragraph",content:[]}]}]}).run()},toggleOrderedList:()=>({commands:e,editor:t})=>t.isActive("list",{listType:"ordered"})?!0:t.isActive("list",{listType:"unordered"})?e.updateAttributes("list",{listType:"ordered"}):!1,toggleUnorderedList:()=>({commands:e,editor:t})=>t.isActive("list",{listType:"unordered"})?!0:t.isActive("list",{listType:"ordered"})?e.updateAttributes("list",{listType:"unordered"}):!1}},addProseMirrorPlugins(){return[new N8({key:new A8("nestedListUnordered"),appendTransaction:(e,t,r)=>{if(!e.some(i=>i.docChanged))return null;let{tr:o}=r,n=!1;return r.doc.descendants((i,s,l)=>{if(i.type.name==="list"&&(l==null?void 0:l.type.name)==="listItem"&&i.attrs.listType!=="unordered")try{o.setNodeMarkup(s,void 0,{...i.attrs,listType:"unordered"}),n=!0}catch{}return!0}),n?o:null}})]}});import{zodResolver as R8}from"@hookform/resolvers/zod";import{useForm as B8}from"react-hook-form";import{Fragment as D8,jsx as et,jsxs as tn}from"react/jsx-runtime";var qn=a(({element:e,editor:t,hideCloseButton:r=!1,minimalMode:o=!1})=>{let n=B8({resolver:R8(Yh),defaultValues:{...Po,...e==null?void 0:e.attrs}}),{updateNodeAttributes:i}=gt({editor:t,element:e,form:n,nodeType:(e==null?void 0:e.type.name)||"list"});return e?tn(He,{...n,children:[et(ht,{type:"list",hideCloseButton:r}),tn("form",{"data-sidebar-form":!0,onChange:()=>{i(n.getValues())},children:[et("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Type"}),et(te,{control:n.control,name:"listType",render:({field:s})=>tn(Q,{className:o?"":"courier-mb-4",children:[et(ee,{children:et("div",{onPointerDown:l=>l.stopPropagation(),onClick:l=>l.stopPropagation(),children:et(_i,{value:s.value,onValueChange:l=>{l&&(s.onChange(l),i({...n.getValues(),listType:l}))},children:tn(zn,{className:"courier-w-full",children:[et(ko,{value:"unordered",className:"courier-flex-1",children:"Unordered"}),et(ko,{value:"ordered",className:"courier-flex-1",children:"Ordered"})]})})})}),et(re,{})]})}),!o&&tn(D8,{children:[et(pe,{className:"courier-mb-4"}),et("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Padding"}),tn("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-4",children:[et(te,{control:n.control,name:"paddingHorizontal",render:({field:s})=>tn(Q,{children:[et(ee,{children:et(be,{startAdornment:et(Cn,{}),type:"number",min:0,...s})}),et(re,{})]})}),et(te,{control:n.control,name:"paddingVertical",render:({field:s})=>tn(Q,{children:[et(ee,{children:et(be,{startAdornment:et(go,{}),type:"number",min:0,...s})}),et(re,{})]})})]})]})]})]}):null},"ListForm");import{mergeAttributes as z8,Node as j8}from"@tiptap/core";import{findWrapping as V8,ReplaceAroundStep as dc,canSplit as tb,liftTarget as H8,canJoin as F8}from"prosemirror-transform";import{NodeRange as rm,Fragment as Nt,Slice as es}from"prosemirror-model";import{Selection as O8}from"prosemirror-state";function rb(e,t=null){return function(r,o){let{$from:n,$to:i}=r.selection,s=n.blockRange(i);if(!s)return!1;let l=o?r.tr:null;return W8(l,s,e,t)?(o&&o(l.scrollIntoView()),!0):!1}}a(rb,"wrapInList");function W8(e,t,r,o=null){let n=!1,i=t,s=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(r)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let c=s.resolve(t.start-2);i=new rm(c,c,t.depth),t.endIndex<t.parent.childCount&&(t=new rm(t.$from,s.resolve(t.$to.end(t.depth)),t.depth)),n=!0}let l=V8(i,r,o,t);return l?(e&&_8(e,t,l,n,r),!0):!1}a(W8,"wrapRangeInList");function _8(e,t,r,o,n){let i=Nt.empty;for(let d=r.length-1;d>=0;d--)i=Nt.from(r[d].type.create(r[d].attrs,i));e.step(new dc(t.start-(o?2:0),t.end,t.start,t.end,new es(i,0,0),r.length,!0));let s=0;for(let d=0;d<r.length;d++)r[d].type==n&&(s=d+1);let l=r.length-s,c=t.start+r.length-(o?2:0),u=t.parent;for(let d=t.startIndex,m=t.endIndex,p=!0;d<m;d++,p=!1)!p&&tb(e.doc,c,l)&&(e.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return e}a(_8,"doWrapInList");function ob(e,t){return function(r,o){let{$from:n,$to:i,node:s}=r.selection;if(s&&s.isBlock||n.depth<2||!n.sameParent(i))return!1;let l=n.node(-1);if(l.type!=e)return!1;if(n.parent.content.size==0&&n.node(-1).childCount==n.indexAfter(-1)){if(n.depth==3||n.node(-3).type!=e||n.index(-2)!=n.node(-2).childCount-1)return!1;if(o){let m=Nt.empty,p=n.index(-1)?1:n.index(-2)?2:3;for(let C=n.depth-p;C>=n.depth-3;C--)m=Nt.from(n.node(C).copy(m));let g=n.indexAfter(-1)<n.node(-2).childCount?1:n.indexAfter(-2)<n.node(-3).childCount?2:3;m=m.append(Nt.from(e.createAndFill()));let v=n.before(n.depth-(p-1)),b=r.tr.replace(v,n.after(-g),new es(m,4-p,0)),y=-1;b.doc.nodesBetween(v,b.doc.content.size,(C,x)=>{if(y>-1)return!1;C.isTextblock&&C.content.size==0&&(y=x+1)}),y>-1&&b.setSelection(O8.near(b.doc.resolve(y))),o(b.scrollIntoView())}return!0}let c=i.pos==n.end()?l.contentMatchAt(0).defaultType:null,u=r.tr.delete(n.pos,i.pos),d=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return tb(u.doc,n.pos,2,d)?(o&&o(u.split(n.pos,2,d).scrollIntoView()),!0):!1}}a(ob,"splitListItem");function nb(e){return function(t,r){let{$from:o,$to:n}=t.selection,i=o.blockRange(n,s=>s.childCount>0&&s.firstChild.type==e);return i?r?o.node(i.depth-1).type==e?U8(t,r,e,i):$8(t,r,i):!0:!1}}a(nb,"liftListItem");function U8(e,t,r,o){let n=e.tr,i=o.end,s=o.$to.end(o.depth);i<s&&(n.step(new dc(i-1,s,i,s,new es(Nt.from(r.create(null,o.parent.copy())),1,0),1,!0)),o=new rm(n.doc.resolve(o.$from.pos),n.doc.resolve(s),o.depth));let l=H8(o);if(l==null)return!1;n.lift(o,l);let c=n.doc.resolve(n.mapping.map(i,-1)-1);return F8(n.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&n.join(c.pos),t(n.scrollIntoView()),!0}a(U8,"liftToOuterList");function $8(e,t,r){let o=e.tr,n=r.parent;for(let g=r.end,v=r.endIndex-1,b=r.startIndex;v>b;v--)g-=n.child(v).nodeSize,o.delete(g-1,g+1);let i=o.doc.resolve(r.start),s=i.nodeAfter;if(o.mapping.map(r.end)!=r.start+i.nodeAfter.nodeSize)return!1;let l=r.startIndex==0,c=r.endIndex==n.childCount,u=i.node(-1),d=i.index(-1);if(!u.canReplace(d+(l?0:1),d+1,s.content.append(c?Nt.empty:Nt.from(n))))return!1;let m=i.pos,p=m+s.nodeSize;return o.step(new dc(m-(l?1:0),p+(c?1:0),m+1,p-1,new es((l?Nt.empty:Nt.from(n.copy(Nt.empty))).append(c?Nt.empty:Nt.from(n.copy(Nt.empty))),l?0:1,c?0:1),l?0:1)),t(o.scrollIntoView()),!0}a($8,"liftOutOfList");function ib(e){return function(t,r){let{$from:o,$to:n}=t.selection,i=o.blockRange(n,u=>u.childCount>0&&u.firstChild.type==e);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,c=l.child(s-1);if(c.type!=e)return!1;if(r){let u=c.lastChild&&c.lastChild.type==l.type,d=Nt.from(u?e.create():null),m=new es(Nt.from(e.create(null,Nt.from(l.type.create(null,d)))),u?3:1,0),p=i.start,g=i.end;r(t.tr.step(new dc(p-(u?3:1),g,p,g,m,1,!0)).scrollIntoView())}return!0}}a(ib,"sinkListItem");import{v4 as q8}from"uuid";var ab={backgroundColor:"transparent"},mc=j8.create({name:"listItem",content:"(paragraph | heading) block*",defining:!0,addOptions(){return{HTMLAttributes:{}}},onCreate(){je(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${q8()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},backgroundColor:{default:ab.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})}}},parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",z8(this.options.HTMLAttributes,e),0]},addCommands(){return{splitListItem:e=>({state:t,dispatch:r})=>{let o=typeof e=="string"?t.schema.nodes[e]:e;return o?ob(o)(t,r):!1},liftListItem:e=>({state:t,dispatch:r})=>{let o=typeof e=="string"?t.schema.nodes[e]:e;return o?nb(o)(t,r):!1},sinkListItem:e=>({state:t,dispatch:r})=>{let o=typeof e=="string"?t.schema.nodes[e]:e;return o?ib(o)(t,r):!1},wrapInList:(e,t)=>({state:r,dispatch:o})=>{let n=typeof e=="string"?r.schema.nodes[e]:e;return n?rb(n,t)(r,o):!1}}},addKeyboardShortcuts(){return{"Shift-Enter":()=>this.editor.chain().setHardBreak().run()}}});import{mergeAttributes as eT,ReactNodeViewRenderer as tT}from"@tiptap/react";import{TextSelection as rT,Plugin as oT,PluginKey as nT}from"prosemirror-state";var Mo={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:"'"},fc={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Z8=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),J8=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(it=0;it<10;it++)Mo[48+it]=Mo[96+it]=String(it);var it;for(it=1;it<=24;it++)Mo[it+111]="F"+it;var it;for(it=65;it<=90;it++)Mo[it]=String.fromCharCode(it+32),fc[it]=String.fromCharCode(it);var it;for(pc in Mo)fc.hasOwnProperty(pc)||(fc[pc]=Mo[pc]);var pc;function sb(e){var t=Z8&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||J8&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?fc:Mo)[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(sb,"keyName");import{Plugin as K8}from"prosemirror-state";var G8=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function X8(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))G8?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(X8,"normalizeKeyName");function Y8(e){let t=Object.create(null);for(let r in e)t[X8(r)]=e[r];return t}a(Y8,"normalize");function om(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(om,"modifiers");function lb(e){return new K8({props:{handleKeyDown:Q8(e)}})}a(lb,"keymap");function Q8(e){let t=Y8(e);return function(r,o){let n=sb(o),i,s=t[om(n,o)];if(s&&s(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let l=t[om(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=Mo[o.keyCode])&&i!=n){let l=t[om(i,o)];if(l&&l(r.state,r.dispatch,r))return!0}}return!1}}a(Q8,"keydownHandler");import{v4 as iT}from"uuid";var nm=Mi.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){je(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-${iT()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:xe.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):xe.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:xe.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):xe.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:xe.textAlign,parseHTML:e=>e.style.textAlign||xe.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:xe.backgroundColor,parseHTML:e=>e.style.backgroundColor||xe.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:xe.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):xe.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:xe.borderColor,parseHTML:e=>e.style.borderColor||xe.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",eT(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return tT(al)},addProseMirrorPlugins(){return[lb({"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(rT.create(t.doc,i,s)),!0}return!1}}),new oT({key:new nT("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;for(let u=s.depth;u>=0;u--)if(s.node(u).type.name==="listItem")return!1;let 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,m=s.parentOffset===u.length,p=u.length===0,g=t.key==="Delete"||t.keyCode===46||t.code==="Delete",v=g?i.$from.nodeAfter:i.$from.nodeBefore,b=v!=null;if(b&&p)return!1;if(o||p&&!b||!g&&d&&!b||g&&m&&!b)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;for(let p=n.depth;p>=0;p--)if(n.node(p).type.name==="listItem")return!1;let s=n.depth,l=null;for(;s>0;){let p=n.node(s);if(p.type.name==="paragraph"||p.type.name==="heading"){l=p;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,m=d!=null;return m&&u?!1:c&&!m||u&&!m?!0:o?!1:(t.commands.command(({tr:p,dispatch:g})=>g?(p.insertText("",t.state.selection.from,t.state.selection.to),!0):!1),!0)},"handleDeletion");return{Enter:({editor:t})=>{if(t.view.dom.querySelector(".variable-suggestion")||t.view.state.selection.$from.node().type.spec.code)return!1;let{$from:o}=t.state.selection;for(let l=o.depth;l>=0;l--)if(o.node(l).type.name==="listItem")return!1;let{state:n,dispatch:i}=t.view,{tr:s}=n;return s.replaceSelectionWith(n.schema.nodes.hardBreak.create()).scrollIntoView(),i(s),!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:({editor:t})=>!t.isActive("listItem"),"Shift-Tab":({editor:t})=>!t.isActive("listItem")}},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setTextAlign:t=>({chain:r})=>r().updateAttributes(this.name,{textAlign:t}).run()}}});import{Extension as aT}from"@tiptap/core";import{Plugin as sT,PluginKey as lT}from"@tiptap/pm/state";var cT=new lT("selection"),im=aT.create({name:"selection",addOptions(){return{HTMLAttributes:{},setSelectedNode:()=>{},shouldHandleClick:()=>!0}},addGlobalAttributes(){return[{types:["paragraph","heading","button","spacer","divider","imageBlock","blockquote","customCode","column","list"],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){t.setMeta("addToHistory",!1);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,m;if(l.type.name!=="text"&&((u=l.type.spec.attrs)==null?void 0:u.isSelected)!==void 0){let p=!1;i?p=((d=l.attrs)==null?void 0:d.id)===i&&l.type.name===s:s&&(p=l.type.name===s&&l.content.size===((m=e==null?void 0:e.content)==null?void 0:m.size));try{p?t.setNodeAttribute(c,"isSelected",!0):t.setNodeAttribute(c,"isSelected",!1)}catch{}}return!0})}return!0}}},addProseMirrorPlugins(){return[new sT({key:cT,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(".node-list")||n.closest('[data-cypress="draggable-handle"]')||n.closest('button[class*="courier-cursor-grab"]'))return!1;try{let c=window.getSelection();if(c&&c.rangeCount>0){let d=c.getRangeAt(0).startContainer.parentElement;if(d&&(["P","H1","H2","H3"].includes(d.tagName)||["P","H1","H2","H3"].some(m=>d.closest(m)))){let m=e.posAtDOM(d,0);if(m<0||m>o.doc.content.size)return!1;let p=o.doc.resolve(m),g=p.node();if(g&&["paragraph","heading"].includes(g.type.name)){let v=g;for(let b=p.depth;b>=0;b--){let y=p.node(b);if(y.type.name==="list"){v=y;break}}return this.options.setSelectedNode(v),this.editor.commands.updateSelectionState(v),!0}}}}catch{return!1}let i=e.posAtDOM(n,0),s=o.doc.resolve(i),l=s.node();if(i<0||i>o.doc.content.size)return!1;if(l&&["paragraph","heading"].includes(l.type.name))try{let c=l;for(let u=s.depth;u>=0;u--){let d=s.node(u);if(d.type.name==="list"){c=d;break}}return this.options.setSelectedNode(c),this.editor.commands.updateSelectionState(c),!0}catch{return!1}return!1}}})]}});var Uo=a(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),ot=a(e=>{let t=Uo(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");import{GripVertical as uT}from"lucide-react";import{forwardRef as dT}from"react";import{jsx as gb}from"react/jsx-runtime";var hb=dT((e,t)=>gb("button",{...e,ref:t,"data-cypress":"draggable-handle","data-drag-handle":!0,className:R("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:gb(uT,{strokeWidth:1,className:"courier-w-5 courier-stroke-neutral-400 courier-fill-neutral-400 courier-pointer-events-none"})}));import{useAtomValue as mT}from"jotai";import{jsx as am}from"react/jsx-runtime";var bb={text:"Text",heading:"Heading",spacer:"Spacer",divider:"Divider",button:"Button",image:"Image",list:"List",customCode:"Custom code",column:"Column layout",blockquote:"Blockquote"},pT=a(e=>e.includes(":"),"isPresetType"),fT=a(e=>{let t=e.split(":");return t.length===2?{blockType:t[0],presetKey:t[1]}:null},"parsePresetType"),gc=a(({type:e})=>{let t=mT(Ho),r=a(o=>{if(!o)return"Drop here";if(pT(o)){let n=fT(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 bb[i]||"Drop here"}return bb[o]||"Drop here"},"getPlaceholderLabel");return am("div",{className:"courier-flex courier-w-full courier-pointer-events-none",children:am("div",{className:R("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:am("div",{className:"courier-text-accent-foreground dark:courier-text-accent",children:r(e)})})})},"DropIndicatorPlaceholder");import{Fragment as xT,jsx as lr,jsxs as hc}from"react/jsx-runtime";function vT(){let[e,t]=bc(!1);return sm(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}a(vT,"useMountStatus");var ft=a(({children:e,id:t,className:r,editor:o,getPos:n,disableDropTarget:i=!1,...s})=>{let l=rn(null),c=rn(null),u=rn(null),[d,m]=bc(!1),[p,g]=bc(null),[v,b]=bc(null),y=rn(null),C=rn(!1),x=rn(null),h=rn(null),f=rn(null),E=vT(),T=d&&!E,w=Zn(()=>{if(!o||!t)return null;let N=null;return o.state.doc.descendants((k,S,B)=>{var M;if(((M=k.attrs)==null?void 0:M.id)===t){let I=0;return B&&B.content.forEach((D,V,_)=>{D===k&&(I=_)}),N={node:k,pos:S,parent:B,index:I},!1}return!0}),N},[t,o]),P=Zn(()=>{if(!o)return!1;let N=w();return!N||!N.parent?!1:N.index===N.parent.childCount-1},[o,w]);return sm(()=>{let N=l.current,k=c.current;if(!N)return;let S=N.getRootNode()instanceof ShadowRoot,B=$r(Sa({element:N,dragHandle:S?void 0:k||void 0,getInitialData:()=>{var _,W,F,L,$,A;let M=w(),I="text";if(M){let H=M.node;switch(H.type.name){case"heading":I="heading";break;case"paragraph":I="text";break;case"imageBlock":I="image";break;case"divider":I=(_=H.attrs)!=null&&_.spacer?"spacer":"divider";break;case"button":I="button";break;case"customCode":I="customCode";break;case"column":I="column";break;case"list":I="list";break}}let D=(M==null?void 0:M.parent)===o.state.doc,V=((W=M==null?void 0:M.parent)==null?void 0:W.type.name)==="columnCell";return{id:t,type:D?"editor":V?"column-cell-item":"nested-drag",index:(F=M==null?void 0:M.index)!=null?F:0,dragType:I,pos:M==null?void 0:M.pos,originalIndex:(L=M==null?void 0:M.index)!=null?L:0,columnId:V?($=M==null?void 0:M.parent)==null?void 0:$.attrs.columnId:void 0,cellIndex:V?(A=M==null?void 0:M.parent)==null?void 0:A.attrs.index:void 0}},onGenerateDragPreview:()=>{let M=N.querySelectorAll("[data-no-drag-preview]"),I=[];M.forEach((D,V)=>{let _=D;I[V]=_.style.display,_.style.display="none"}),requestAnimationFrame(()=>{M.forEach((D,V)=>{let _=D;_.style.display=I[V]})})},onDragStart:()=>{m(!0),document.body.style.cursor="grabbing";let M=a(I=>{h.current=I.clientY},"handleMouseMove");document.addEventListener("mousemove",M),f.current=()=>{document.removeEventListener("mousemove",M)},o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{m(!1),document.body.style.cursor="",f.current&&(f.current(),f.current=null),o&&o.setEditable(!0)}}),nr({element:N,getData:({input:M,element:I})=>{var A,H,O,j;let D=w(),V=(D==null?void 0:D.parent)===o.state.doc,_=((A=D==null?void 0:D.parent)==null?void 0:A.type.name)==="columnCell",W={id:t,type:V?"editor":_?"column-cell-item":"nested-drag",index:(H=D==null?void 0:D.index)!=null?H:0,pos:D==null?void 0:D.pos,nodeType:D==null?void 0:D.node.type.name,columnId:_?(O=D==null?void 0:D.parent)==null?void 0:O.attrs.columnId:void 0,cellIndex:_?(j=D==null?void 0:D.parent)==null?void 0:j.attrs.index:void 0};if(I.getAttribute("data-node-type")==="column"){let Z=I.getBoundingClientRect(),U=M.clientY,q=30,ne=Math.abs(U-Z.top),X=Math.abs(U-Z.bottom);if(ne>q&&X>q)return{...W,disableDropIndicator:!0}}let L=I.closest('[data-column-cell="true"]');if(P()&&N){let Z=N.getBoundingClientRect(),U=M.clientY,q=Z.top+Z.height/2;if(U>=q&&U>Z.bottom)return{...W,[Symbol.for("closestEdge")]:"bottom"}}let $=P()?["top","bottom"]:["top"];return vg(W,{input:M,element:I,allowedEdges:$})},canDrop:({source:M})=>!(i||M.data.id===t),onDragEnter:({self:M,source:I,location:D})=>{var O,j,Z,U,q;if(M.data.disableDropIndicator){g(null);return}if((N==null?void 0:N.closest('[data-type="list"]'))!==null){g(null);return}x.current&&(clearTimeout(x.current),x.current=null);let _=D.current.dropTargets;if(_.length>0&&_[0].element!==N){g(null),C.current=!1,y.current=null;return}let W=Ia(M.data),F=W,L=P(),$=(Z=(j=(O=D==null?void 0:D.current)==null?void 0:O.input)==null?void 0:j.clientY)!=null?Z:h.current;$!==null&&(h.current=$);let A=I.data;b(A.dragType||null),W==="bottom"&&L&&I.data.id===t&&(F=null);let H=I.data.type==="editor"||I.data.type==="column-cell-item";if(L&&H)if(W==="top"){let ne=l.current;if(ne){let X=ne.getBoundingClientRect(),le=(U=$!=null?$:h.current)!=null?U:X.top+X.height/2,ke=X.top+X.height/2,we=X.height,De=Math.max(10,Math.min(30,we*.3));le<ke-De?(C.current=!1,F="top"):C.current?F="bottom":F="top"}else C.current=!1,F="top"}else C.current?F="bottom":W==="bottom"&&(C.current=!0,F="bottom");else L&&!H&&(C.current=!1);if(!C.current&&(I.data.type==="editor"||I.data.type==="column-cell-item")&&typeof I.data.index=="number"){let ne=I.data.index,X=w();((q=X==null?void 0:X.index)!=null?q:0)===ne+1&&W==="top"&&(F=null)}F!==y.current&&(y.current=F,g(F))},onDrag:({self:M,source:I,location:D})=>{var O,j,Z,U,q;if(M.data.disableDropIndicator){g(null);return}if((N==null?void 0:N.closest('[data-type="list"]'))!==null){g(null);return}x.current&&(clearTimeout(x.current),x.current=null);let _=D.current.dropTargets;if(_.length>0&&_[0].element!==N){g(null);return}let W=(Z=(j=(O=D==null?void 0:D.current)==null?void 0:O.input)==null?void 0:j.clientY)!=null?Z:h.current;W!==null&&(h.current=W);let F=Ia(M.data),L=F,$=P(),A=I.data;b(A.dragType||null),F==="bottom"&&$&&I.data.id===t&&(L=null);let H=I.data.type==="editor"||I.data.type==="column-cell-item";if($&&H)if(F==="top"){let ne=l.current;if(ne){let X=ne.getBoundingClientRect(),le=(U=W!=null?W:h.current)!=null?U:X.top+X.height/2,ke=X.top+X.height/2,we=X.height,De=Math.max(10,Math.min(30,we*.3));le<ke-De?(C.current=!1,L="top"):C.current?L="bottom":L="top"}else C.current=!1,L="top"}else C.current?L="bottom":F==="bottom"&&(C.current=!0,L="bottom");else $&&!H&&(C.current=!1);if(!C.current&&(I.data.type==="editor"||I.data.type==="column-cell-item")&&typeof I.data.index=="number"){let ne=I.data.index,X=w();((q=X==null?void 0:X.index)!=null?q:0)===ne+1&&F==="top"&&(L=null)}L!==y.current&&(y.current=L,g(L))},onDragLeave:()=>{if(P()&&C.current){let M=N==null?void 0:N.getBoundingClientRect(),I=h.current;if(M&&I!==null&&I>=M.bottom-10)return;x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{C.current=!1,y.current=null,g(null),b(null),x.current=null},150)}else x.current&&(clearTimeout(x.current),x.current=null),C.current=!1,y.current=null,g(null),b(null)},onDrop:()=>{x.current&&(clearTimeout(x.current),x.current=null),C.current=!1,y.current=null,g(null),b(null)}}));return()=>{x.current&&(clearTimeout(x.current),x.current=null),B()}},[t,P,o,w,i]),lr(CT,{ref:l,id:t,fadeIn:T,className:r,dragging:d,closestEdge:p,dragType:v,handleRef:c,contentRef:u,editor:o,...s,children:e})},"SortableItemWrapper"),CT=bT(({children:e,className:t,dragOverlay:r,handleRef:o,contentRef:n,closestEdge:i,dragType:s,id:l,editor:c,fadeIn:u,dragging:d,...m},p)=>{sm(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let g=hT(Ce),v=a((E,T)=>{let w=null;return E.doc.descendants((P,N)=>{var k;return w!==null?!1:((k=P.attrs)==null?void 0:k.id)===T?(w=N,!1):!0}),w},"findNodePositionById"),b=Zn(()=>{if(!c||!l)return{node:null,pos:null};let E=v(c.state,l);return E===null?{node:null,pos:null}:{node:c.state.doc.nodeAt(E),pos:E}},[c,l]),y=Zn(()=>{c.commands.blur(),g(null)},[c,g]),C=Zn(()=>{if(!(!c||!l))try{let{node:E,pos:T}=b();if(!E||T===null)return;let w=E.nodeSize,P=c.state.doc.childCount===1;g(null),c.commands.updateSelectionState(null);let N=c.state.tr;N.delete(T,T+w),N.setMeta("addToHistory",!0),c.view.dispatch(N),P&&setTimeout(()=>{let k=c.state.doc.nodeAt(0);if(k&&k.type.name==="paragraph"&&!k.attrs.id){let S=`node-${yT()}`,B=c.state.tr;B.setNodeMarkup(0,void 0,{...k.attrs,id:S}),c.view.dispatch(B);let M=new CustomEvent("node-duplicated",{detail:{newNodeId:S}});document.dispatchEvent(M)}},50)}catch(E){console.error("Error deleting node:",E)}},[c,l,b,g]),x=Zn(()=>{if(!(!c||!l))try{let{node:E,pos:T}=b();if(!E||T===null||E.type.name==="button")return;let w=E.type.name==="blockquote",P=E.type.name==="heading";!w&&!P&&y(),setTimeout(()=>{if(P){let k=T+1,S=T+E.nodeSize-1;c.chain().setTextSelection({from:k,to:S}).unsetAllMarks().blur().run(),g(null),c.commands.updateSelectionState(null);return}let N=c.chain();if(N.setNodeSelection(T).unsetAllMarks(),w&&E.content&&E.content.firstChild?E.content.firstChild.type.name!=="paragraph"&&N.setParagraph():E.type.name!=="paragraph"&&!w&&N.setParagraph(),N.run(),w){let k=b();k.node&&k.pos!==null&&(g(k.node),c.commands.updateSelectionState(k.node))}},100)}catch(E){console.error("Error removing formatting:",E)}},[c,l,b,y,g]),h=Zn(()=>{if(!(!c||!l))try{y(),setTimeout(()=>{let{node:E,pos:T}=b();if(!E||T===null)return;let w=E.type.name,P={...E.attrs};delete P.id;let N=T+(E==null?void 0:E.nodeSize);Cl(c,w,N,P,k=>g(k),E.content)},100)}catch(E){console.error("Error duplicating node:",E)}},[c,l,b,y,g]),{node:f}=b();return hc(gT,{ref:p,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":l,className:R("courier-flex courier-flex-col courier-relative draggable-item",t),...m,children:[i==="top"&&lr(gc,{type:s}),hc("div",{className:"courier-flex courier-items-center courier-justify-center courier-gap-2 courier-pl-10",children:[lr(hb,{ref:o,className:"courier-absolute courier-left-[-8px]",tabIndex:-1,"data-no-drag-preview":!0}),lr("div",{ref:n,className:"courier-flex-1 courier-grow draggable-content-wrapper",children:e}),hc("div",{"data-no-drag-preview":!0,className:R("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:[(f==null?void 0:f.type.name)!=="imageBlock"&&(f==null?void 0:f.type.name)!=="divider"&&(f==null?void 0:f.type.name)!=="spacer"&&(f==null?void 0:f.type.name)!=="button"&&(f==null?void 0:f.type.name)!=="column"&&(f==null?void 0:f.type.name)!=="customCode"&&hc(xT,{children:[lr("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:E=>{E.preventDefault(),E.stopPropagation()},onClick:E=>{E.stopPropagation(),x()},tabIndex:-1,children:lr(xu,{color:"currentColor"})}),lr(pe,{className:"!courier-my-0"})]}),lr("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:E=>{E.preventDefault(),E.stopPropagation()},onClick:E=>{E.stopPropagation(),h()},tabIndex:-1,children:lr(pu,{color:"currentColor"})}),lr(pe,{className:"!courier-my-0"}),lr("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#DC2626] dark:courier-text-red-500 dark:hover:courier-bg-secondary",onMouseDown:E=>{E.preventDefault(),E.stopPropagation()},onClick:E=>{E.stopPropagation(),C()},tabIndex:-1,children:lr(ya,{color:"currentColor"})})]})]}),i==="bottom"&&lr(gc,{type:s})]})});import{jsx as ro}from"react/jsx-runtime";var MT=a(({alignment:e,backgroundColor:t,textColor:r,borderRadius:o,padding:n,children:i,isPreviewMode:s,link:l})=>{let c={backgroundColor:t,color:r,borderRadius:`${o}px`,caretColor:r,padding:`${Number(n)+2}px ${Number(n)+10}px`},u=ro("div",{className:R("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:c,children:i});return s&&l?ro("div",{className:"courier-w-full node-element",children:ro("div",{className:"courier-flex",children:ro("a",{href:l,className:R("button-link-wrapper courier-no-underline",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[e]),target:"_blank",rel:"noopener noreferrer",children:ro("div",{className:"courier-inline-flex courier-justify-center courier-text-sm courier-leading-tight !courier-my-1",style:c,children:i})})})}):ro("div",{className:"courier-w-full node-element",children:ro("div",{className:"courier-flex",children:u})})},"ButtonComponent"),yb=a(e=>{let t=ET(Re),[r,o]=PT(e.editor.isEditable);kT(()=>{let l=a(()=>{let c=e.editor.isEditable;o(u=>u!==c?c:u)},"updateEditable");return e.editor.on("transaction",l),e.editor.on("update",l),l(),()=>{e.editor.off("transaction",l),e.editor.off("update",l)}},[e.editor,e.node.attrs.link]);let n=wT(()=>{if(!r)return;let l=ot(e);if(l){let c=l.attrs.id;e.editor.state.doc.descendants(u=>u.type.name==="button"&&u.attrs.id===c?(t(u),!1):!0)}},[e,t,r]),i=!r,s=e.node.attrs.link;return ro(ft,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"button",children:ro(MT,{...e.node.attrs,isPreviewMode:i,link:s,children:ro(TT,{as:"span"})})})},"ButtonComponentNode");import{v4 as RT}from"uuid";var Be={label:"Enter text",link:"",alignment:"center",backgroundColor:"#0085FF",borderRadius:0,padding:6,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1,textColor:"#ffffff",borderColor:"transparent"},Gl=AT.create({name:"button",group:"block",content:"text*",marks:"",selectable:!1,isolating:!0,onCreate(){je(this.editor,this.name)},addAttributes(){return{label:{default:Be.label,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},link:{default:Be.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alignment:{default:Be.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},backgroundColor:{default:Be.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},textColor:{default:Be.textColor,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.textColor})},borderRadius:{default:Be.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:Be.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},padding:{default:Be.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.padding})},fontWeight:{default:Be.fontWeight,parseHTML:e=>e.getAttribute("data-font-weight"),renderHTML:e=>({"data-font-weight":e.fontWeight})},fontStyle:{default:Be.fontStyle,parseHTML:e=>e.getAttribute("data-font-style"),renderHTML:e=>({"data-font-style":e.fontStyle})},isUnderline:{default:Be.isUnderline,parseHTML:e=>e.getAttribute("data-is-underline"),renderHTML:e=>({"data-is-underline":e.isUnderline})},isStrike:{default:Be.isStrike,parseHTML:e=>e.getAttribute("data-is-strike"),renderHTML:e=>({"data-is-strike":e.isStrike})},id:{default:()=>`node-${RT()}`,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",NT(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return ST(yb)},addKeyboardShortcuts(){let e=a(t=>{let{$from:r}=t.state.selection;for(let o=r.depth;o>=0;o--)if(r.node(o).type.name==="button")return!0;return!1},"isInsideButton");return{"Mod-a":({editor:t})=>{let{$from:r}=t.state.selection;for(let o=r.depth;o>=0;o--)if(r.node(o).type.name==="button"){let i=r.start(o),s=r.end(o);return t.commands.setTextSelection({from:i,to:s}),!0}return!1},"Mod-b":({editor:t})=>e(t),"Mod-i":({editor:t})=>e(t),"Mod-u":({editor:t})=>e(t),"Mod-Shift-s":({editor:t})=>e(t)}},addCommands(){return{setButton:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e,content:[{type:"text",text:e.label||Be.label}]}).run()}},addProseMirrorPlugins(){return[new IT({key:new LT("syncButtonContentToLabel"),appendTransaction:(e,t,r)=>e.some(n=>n.docChanged)?Ch(r):null})]}});var vb=a(e=>e==="full"?"justify":e||"left","elementalAlignToTiptap");function BT(e){let t=[];for(let r of e)r.type==="string"?DT(r,t):r.type==="link"&&VT(r,t);return t}a(BT,"convertElementsArrayToTiptapNodes");function Cb(e){let t=[];return e.bold&&t.push({type:"bold"}),e.italic&&t.push({type:"italic"}),e.strikethrough&&t.push({type:"strike"}),e.underline&&t.push({type:"underline"}),e.color&&t.push({type:"textColor",attrs:{color:e.color}}),t}a(Cb,"buildMarksFromFlags");function DT(e,t){let r="content"in e?e.content:"";if(!r)return;let o=Cb(e),n=r.split(`
197
- `);for(let i=0;i<n.length;i++){let s=n[i];s&&xb(s,o,t),i<n.length-1&&t.push({type:"hardBreak"})}}a(DT,"convertStringElementToTiptapNodes");function VT(e,t){if(e.type!=="link")return;let r=e.content||"";if(!r)return;let o=Cb(e);o.push({type:"link",attrs:{href:e.href}}),xb(r,o,t)}a(VT,"convertLinkElementToTiptapNodes");function xb(e,t,r){if(!e)return;let o=/\{\{([^}]*)\}\}/g,n,i=0;for(o.lastIndex=0;(n=o.exec(e))!==null;){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=s===""||pt(s),c=t.some(u=>u.type==="link");r.push({type:"variable",attrs:{id:s,isInvalid:!l,...c&&{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(xb,"parseTextSegmentWithVariables");function ts(e){let t=[],r=e.replace(/\n$/,"").split(`
198
- `);for(let o=0;o<r.length;o++)HT(r[o],t),o<r.length-1&&t.push({type:"hardBreak"});return t}a(ts,"parseMDContent");function HT(e,t){lm(e,t)}a(HT,"parseTextLine");function lm(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 m=new RegExp(d.regex.source,d.regex.flags),p;for(;(p=m.exec(e))!==null;)if(d.type==="variable"){let g=p[1].trim(),v=g===""||pt(g);o.push({start:p.index,end:p.index+p[0].length,text:p[1],type:"variable",attrs:{id:g,isInvalid:!v}})}else d.type==="link"?o.push({start:p.index,end:p.index+p[0].length,text:p[1],type:"link",attrs:{href:p[2]}}):o.push({start:p.index,end:p.index+p[0].length,text:p[1],type:d.type})}o.sort((d,m)=>d.start-m.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 m=e.substring(l,d.start);m&&cm(m,[],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 m=[];lm(d.text,m),m.forEach(p=>{var g;p.marks=p.marks||[],p.marks.push({type:"link",attrs:{href:(g=d.attrs)==null?void 0:g.href}})}),s.push(...m)}else{let m=[];lm(d.text,m),m.forEach(p=>{p.marks=p.marks||[],p.marks.push({type:d.type})}),s.push(...m)}l=d.end}if(l<e.length){let d=e.substring(l);d&&cm(d,[],s)}t.push(...s)}a(lm,"processMarkdownFormatting");function cm(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===""||pt(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(cm,"parseTextWithVariables");function $e(e,t){var d,m,p,g,v,b,y,C,x;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 h of e.elements)if(h.type==="channel"){let f=h;if(n){if(f.channel===n){i=f;break}}else{i=f;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(h=>h.type==="meta"&&"title"in h?{type:"text",content:h.title||`
199
- `,text_style:"h2"}:h))):o=[{type:"text",content:`
200
- `}],!o||o.length===0)return r;let l=a(h=>{var f,E,T,w,P,N,k,S,B,M,I,D,V,_;if(h.type==="meta")return[];switch(h.type){case"text":if("content"in h){let W=h.text_style==="h1"?1:h.text_style==="h2"?2:null,F={};if(h.padding){let[A,H]=h.padding.replace(/px/g,"").split(" "),O=parseInt(A),j=parseInt(H);!isNaN(O)&&!isNaN(j)&&(F={paddingVertical:O,paddingHorizontal:j})}let L={};if(h.border_size||(f=h.border)!=null&&f.enabled||(E=h.border)!=null&&E.size){let A=h.border_size||((T=h.border)==null?void 0:T.size),H=h.border_color||((w=h.border)==null?void 0:w.color);L={...A&&{borderWidth:parseInt(A)},...H&&{borderColor:H}}}let $=h.content.trim()?ts(h.content):[];return[{type:W?"heading":"paragraph",attrs:{textAlign:vb(h.align),level:W,id:`node-${Ue()}`,...F,...L,...h.background_color&&{backgroundColor:h.background_color},...h.locales&&{locales:h.locales}},content:$}]}else if("elements"in h){let W=h.text_style==="h1"?1:h.text_style==="h2"?2:null,F={};if(h.padding){let[A,H]=h.padding.replace(/px/g,"").split(" "),O=parseInt(A),j=parseInt(H);!isNaN(O)&&!isNaN(j)&&(F={paddingVertical:O,paddingHorizontal:j})}let L={};if(h.border_size||(P=h.border)!=null&&P.enabled||(N=h.border)!=null&&N.size){let A=h.border_size||((k=h.border)==null?void 0:k.size),H=h.border_color||((S=h.border)==null?void 0:S.color);L={...A&&{borderWidth:parseInt(A)},...H&&{borderColor:H}}}let $=BT(h.elements);return[{type:W?"heading":"paragraph",attrs:{textAlign:vb(h.align),level:W,id:`node-${Ue()}`,...F,...L,...h.background_color&&{backgroundColor:h.background_color},...h.locales&&{locales:h.locales}},content:$}]}return[];case"action":{let F=n==="inbox"?{backgroundColor:"#000000",textColor:"#ffffff",borderColor:"transparent",borderWidth:1,borderRadius:4}:{},L=h.content||Be.label,$=[];cm(L,[],$),$.length===0&&$.push({type:"text",text:L||Be.label});let A=(M=h.border_radius)!=null?M:(B=h.border)==null?void 0:B.radius,H=(I=h.border)==null?void 0:I.color,O;return typeof A=="string"?O=parseInt(A):typeof A=="number"&&(O=A),[{type:"button",content:$,attrs:{label:L,link:h.href,alignment:h.align==="full"?"center":h.align||"center",style:h.style,id:`node-${Ue()}`,...F,...h.background_color&&{backgroundColor:h.background_color},...h.color&&{textColor:h.color},...h.padding&&{padding:(()=>{let j=h.padding.replace(/px/g,"").trim().split(/\s+/),Z=parseInt(j[0])||0;return Math.max(0,j.length>1?Z-2:Z)})()},...O!==void 0&&{borderRadius:O},...H&&{borderColor:H},...h.locales&&{locales:h.locales}}}]}case"quote":{let W=a(A=>{let H=A.split(`
201
- `).filter(q=>q.trim());if(H.length===0)return{isList:!1,isOrdered:!1};let O=/^•\s+/,j=/^\d+\.\s+/,Z=H.every(q=>O.test(q)),U=H.every(q=>j.test(q));return{isList:Z||U,isOrdered:U}},"isListContent"),F=a((A,H)=>{let O=A.split(`
202
- `).filter(Z=>Z.trim()),j=[];for(let Z of O){let U=Z.replace(/^(•|\d+\.)\s+/,"");j.push({type:"listItem",attrs:{id:`node-${Ue()}`},content:[{type:"paragraph",attrs:{id:`node-${Ue()}`},content:ts(U)}]})}return[{type:"list",attrs:{id:`node-${Ue()}`,listType:H?"ordered":"unordered"},content:j}]},"parseListContent"),L=W(h.content),$;if(L.isList)$=F(h.content,L.isOrdered);else{let A="paragraph",H;h.text_style==="h1"?(A="heading",H=1):h.text_style==="h2"?(A="heading",H=2):h.text_style==="subtext"&&(A="heading",H=3);let O={textAlign:h.align||"left",id:`node-${Ue()}`};H!==void 0&&(O.level=H),$=[{type:A,attrs:O,content:ts(h.content)}]}return[{type:"blockquote",attrs:{textAlign:h.align||"left",id:`node-${Ue()}`,...h.border_color&&{borderColor:h.border_color},...h.border_left_width!==void 0&&{borderLeftWidth:h.border_left_width},...h.padding_horizontal!==void 0&&{paddingHorizontal:h.padding_horizontal},...h.padding_vertical!==void 0&&{paddingVertical:h.padding_vertical},...h.background_color&&{backgroundColor:h.background_color},...h.locales&&{locales:h.locales}},content:$}]}case"image":{let W={};if(h.width){let $=h.width.endsWith("px"),A=h.width.endsWith("%"),H=parseInt(h.width.replace(/%|px/,""));if($)if(h.image_natural_width&&h.image_natural_width>0){let O=Math.round(H/h.image_natural_width*100);W.width=Math.max(1,Math.min(100,O)),W.imageNaturalWidth=h.image_natural_width}else W.width=100;else W.width=Math.max(1,Math.min(100,H))}let F=h.border_size||((D=h.border)==null?void 0:D.size),L=h.border_color||((V=h.border)==null?void 0:V.color);return[{type:"imageBlock",attrs:{sourcePath:Fs(h.src)?"":h.src,id:`node-${Ue()}`,...h.href&&{link:h.href},...h.align&&{alignment:h.align},...h.alt_text&&{alt:h.alt_text},...W,...F&&{borderWidth:parseInt(F),...L&&{borderColor:L}},...h.locales&&{locales:h.locales}}}]}case"divider":{let W=h.border_width||h.width;return[{type:"divider",attrs:{id:`node-${Ue()}`,...h.color&&{color:h.color},...W&&{size:parseInt(W)},...h.padding&&{padding:parseInt(h.padding)},variant:h.color==="transparent"?"spacer":"divider"}}]}case"html":return[{type:"customCode",attrs:{id:`node-${Ue()}`,code:h.content||"<!-- Add your HTML code here -->",...h.locales&&{locales:h.locales}}}];case"group":{let W=h.elements?h.elements.length:2,F=0,L=0;if(h.padding){let U=h.padding.split(" ");F=parseInt(U[0],10)||0,L=parseInt(U[1]||U[0],10)||0}let $=0,A=0,H="transparent";h.border&&(h.border.size&&($=parseInt(h.border.size,10)||0),h.border.radius!==void 0&&(A=h.border.radius),h.border.color&&(H=h.border.color));let O=h.background_color||"transparent",j=`node-${Ue()}`,Z=h.elements?h.elements.map((U,q)=>{var ke;if(U.type==="text"&&"content"in U&&((ke=U.content)==null?void 0:ke.trim())==="Drag and drop content blocks"&&U.align==="left")return{type:"columnCell",attrs:{index:q,columnId:j,isEditorMode:!1},content:[]};let X;U.type==="group"&&U.elements?X=U.elements.flatMap(l):X=l(U);let le=X.length>0?X:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${Ue()}`},content:[]}];return{type:"columnCell",attrs:{index:q,columnId:j,isEditorMode:X.length>0},content:le}}):[{type:"columnCell",attrs:{index:0,columnId:j,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${Ue()}`},content:[]}]},{type:"columnCell",attrs:{index:1,columnId:j,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${Ue()}`},content:[]}]}];return[{type:"column",attrs:{id:j,columnsCount:Math.min(Math.max(W,1),4),paddingVertical:F,paddingHorizontal:L,backgroundColor:O,borderWidth:$,borderRadius:A,borderColor:H,...h.locales&&{locales:h.locales}},content:[{type:"columnRow",content:Z}]}]}case"list":{let W=((_=h.elements)==null?void 0:_.map($=>{let A=[];return $.elements&&Array.isArray($.elements)?A=$.elements.flatMap(H=>{let O=H;return O.type==="string"||O.type==="text"?[{type:"paragraph",attrs:{textAlign:"left",id:`node-${Ue()}`},content:O.content?ts(O.content):[]}]:O.type==="list"?l(O):[]}):"content"in $&&typeof $.content=="string"&&(A=[{type:"paragraph",attrs:{textAlign:"left",id:`node-${Ue()}`},content:ts($.content)}]),A.length===0&&(A=[{type:"paragraph",attrs:{textAlign:"left",id:`node-${Ue()}`},content:[]}]),{type:"listItem",attrs:{id:`node-${Ue()}`},content:A}}))||[],F=0,L=0;if(h.padding){let $=h.padding.split(/\s+/).map(A=>parseInt(A,10)||0);$.length===1?(F=$[0],L=$[0]):$.length>=2&&(F=$[0],L=$[1])}return[{type:"list",attrs:{id:`node-${Ue()}`,listType:h.list_type||"unordered",...F>0&&{paddingVertical:F},...L>0&&{paddingHorizontal:L}},content:W.length>0?W:[{type:"listItem",attrs:{id:`node-${Ue()}`},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${Ue()}`},content:[]}]}]}]}default:return[]}},"convertNode"),c=[],u=o.flatMap(l);for(let h=0;h<u.length;h++){let f=u[h],E=u[h+1];if(f.type==="button"&&(E==null?void 0:E.type)==="button"&&n==="inbox"){let T={type:"buttonRow",attrs:{id:`node-${Ue()}`,button1Label:((d=f.attrs)==null?void 0:d.label)||"Button 1",button1Link:((m=f.attrs)==null?void 0:m.link)||"",button1BackgroundColor:((p=f.attrs)==null?void 0:p.backgroundColor)||"#000000",button1TextColor:((g=f.attrs)==null?void 0:g.textColor)||"#ffffff",button2Label:((v=E.attrs)==null?void 0:v.label)||"Button 2",button2Link:((b=E.attrs)==null?void 0:b.link)||"",button2BackgroundColor:((y=E.attrs)==null?void 0:y.backgroundColor)||"#ffffff",button2TextColor:((C=E.attrs)==null?void 0:C.textColor)||"#000000",padding:((x=f.attrs)==null?void 0:x.padding)||6}};c.push(T),h++}else c.push(f)}return{type:"doc",content:c}}a($e,"convertElementalToTiptap");function Tb(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===""||pt(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(Tb,"parseTextWithVariables");function rs(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),m;for(;(m=d.exec(e))!==null;)if(u.type==="variable"){let p=m[1].trim(),g=p===""||pt(p);r.push({start:m.index,end:m.index+m[0].length,text:m[1],type:"variable",attrs:{id:p,isInvalid:!g}})}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,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&&Tb(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=[],m=rs(u.text);d.push(...m),d.forEach(p=>{var g;p.marks=p.marks||[],p.marks.push({type:"link",attrs:{href:(g=u.attrs)==null?void 0:g.href}})}),i.push(...d)}else{let d=rs(u.text);d.forEach(m=>{m.marks=m.marks||[],m.marks.push({type:u.type})}),i.push(...d)}s=u.end}if(s<e.length){let u=e.substring(s);u&&Tb(u,[],i)}return i}a(rs,"processMarkdownFormatting");function FT(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:rs(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:rs(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:rs(o)})}return t}a(FT,"parseBlockContent");function um(e){return{type:"doc",content:FT(e)}}a(um,"convertMarkdownToTiptap");var OT=a(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),Eb=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(OT).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"),kb=a(e=>{var r;let t={};if(!e)return t;for(let o of e)switch(o.type){case"bold":t.bold=!0;break;case"italic":t.italic=!0;break;case"strike":t.strikethrough=!0;break;case"underline":t.underline=!0;break;case"textColor":(r=o.attrs)!=null&&r.color&&(t.color=o.attrs.color);break}return t},"getFormattingFlags"),WT=a((e,t)=>{var r,o,n,i,s,l,c,u,d,m;return((r=e.bold)!=null?r:void 0)===((o=t.bold)!=null?o:void 0)&&((n=e.italic)!=null?n:void 0)===((i=t.italic)!=null?i:void 0)&&((s=e.strikethrough)!=null?s:void 0)===((l=t.strikethrough)!=null?l:void 0)&&((c=e.underline)!=null?c:void 0)===((u=t.underline)!=null?u:void 0)&&((d=e.color)!=null?d:void 0)===((m=t.color)!=null?m:void 0)},"sameFlags"),_T=a((e,t)=>{if(!t)return;let r=kb(t);r.bold&&(e.bold=!0),r.italic&&(e.italic=!0),r.strikethrough&&(e.strikethrough=!0),r.underline&&(e.underline=!0),r.color&&(e.color=r.color)},"applyFormattingFlags"),dm=a(e=>{var n,i,s;let t=[],r=null,o=a(()=>{r&&(t.push(r),r=null)},"flush");for(let l of e){if(l.type==="hardBreak"){r?r.content+=`
194
+ `,l},{side:0});return Gd.create(e.doc,[s])}return Gd.empty}}}),new Kd({key:new Jd("variableCursorFix"),props:{handleKeyDown:(e,t)=>{var l,c;if(t.key!=="ArrowLeft"&&t.key!=="ArrowRight")return!1;let{state:r}=e,{selection:o}=r,{$from:n}=o;if(!o.empty)return!1;let i=n.nodeBefore,s=n.nodeAfter;if(t.key==="ArrowLeft"){if((i==null?void 0:i.type.name)==="hardBreak"&&(s==null?void 0:s.type.name)==="variable"){if(!i)return!1;let u=n.pos-i.nodeSize,d=r.tr.setSelection(Jl.create(r.doc,u));return e.dispatch(d),!0}if((i==null?void 0:i.type.name)==="variable"){if(!i)return!1;let d=n.pos-i.nodeSize;if(d>n.start()&&((l=r.doc.resolve(d).nodeBefore)==null?void 0:l.type.name)==="hardBreak"){let m=r.tr.setSelection(Jl.create(r.doc,d));return e.dispatch(m),!0}}}if(t.key==="ArrowRight"&&(i==null?void 0:i.type.name)==="variable"&&(s==null?void 0:s.type.name)==="hardBreak"){if(!s)return!1;let u=n.pos+s.nodeSize;if(u<=n.end()&&((c=r.doc.resolve(u).nodeAfter)==null?void 0:c.type.name)==="variable"){let p=r.tr.setSelection(Jl.create(r.doc,u));return e.dispatch(p),!0}}return!1}}})]}}),Kn=Xd.create({name:"variableInputRule",addStorage(){return{disabled:!1}},addInputRules(){let e=this.storage;return[new ix({find:/\{\{$/,handler:({range:t,chain:r})=>{e.disabled||r().deleteRange(t).insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()}})]}}),ux=Xd.create({name:"variableSuggestion",addOptions(){return{HTMLAttributes:{},suggestion:{char:"{{",...Or},variables:{},disableSuggestions:!1}},addProseMirrorPlugins(){return this.options.disableSuggestions?[]:[lx({editor:this.editor,...this.options.suggestion})]}}),dx=Xd.create({name:"variableTypeHandler"});import{Extension as mx}from"@tiptap/core";import{Plugin as px}from"@tiptap/pm/state";import{Slice as fx,Fragment as gx}from"@tiptap/pm/model";var hx=/\{\{([^}]+)\}\}/g,Qd=/\{\{[^}]+\}\}/;function bh(e){return e.replace(hx,(t,r)=>{let o=r.trim();return vt(o)?`<span data-variable="true" data-id="${o}"></span>`:t})}a(bh,"replaceVariablePatternsInHtml");function bx(e,t,r){let o=/\{\{([^}]+)\}\}/g,n=[],i=0,s;for(;(s=o.exec(e))!==null;){s.index>i&&n.push(t.text(e.substring(i,s.index),r));let l=s[1].trim();t.nodes.variable&&vt(l)?n.push(t.nodes.variable.create({id:l,isInvalid:!1})):n.push(t.text(s[0],r)),i=s.index+s[0].length}return i<e.length&&n.push(t.text(e.substring(i),r)),n}a(bx,"splitTextWithVariables");function yh(e,t){let r=[],o=!1;return e.forEach(n=>{if(n.isText&&Qd.test(n.text||"")){let i=bx(n.text||"",t,n.marks);r.push(...i),o=!0}else if(n.content&&n.content.size>0){let i=yh(n.content,t);i!==n.content?(r.push(n.copy(i)),o=!0):r.push(n)}else r.push(n)}),o?gx.from(r):e}a(yh,"transformFragment");var Jn=mx.create({name:"variablePaste",addProseMirrorPlugins(){return[new px({props:{transformPastedHTML:e=>{let t=bh(e);if(t!==e)return t;let r=document.createElement("div");r.innerHTML=e;let o=r.textContent||"";if(!Qd.test(o))return e;let n=e.replace(/<\/?span[^>]*>/gi,"");return bh(n)},handlePaste:(e,t,r)=>{let o=!1;if(r.content.descendants(l=>{if(l.isText&&Qd.test(l.text||""))return o=!0,!1}),!o)return!1;let n=yh(r.content,e.state.schema),i=new fx(n,r.openStart,r.openEnd),s=e.state.tr.replaceSelection(i);return e.dispatch(s),!0}}})]}});import{Node as yx}from"@tiptap/core";import{NodeViewWrapper as vx,ReactNodeViewRenderer as Cx}from"@tiptap/react";import{useCallback as vh}from"react";import{jsx as es,jsxs as kx}from"react/jsx-runtime";var xx=a(({color:e="#B45309"})=>kx("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:[es("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}),es("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableChipIcon"),Tx=a(e=>e?"#DC2626":"#B45309","getIconColor"),Ex=a(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=e.attrs.id||"",i=e.attrs.isInvalid||!1,s=vh(c=>{o(c)},[o]),l=vh(()=>{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 es(vx,{as:"span",className:"courier-inline",children:es(jl,{variableId:n,isInvalid:i,onUpdateAttributes:s,onDelete:l,icon:es(xx,{color:Tx(i)}),readOnly:!t.isEditable})})},"SimpleVariableView"),Gl=yx.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 Cx(Ex)}}),wx="\u200B";function Ui(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();vt(i)?r.push({type:"variable",attrs:{id:i,isInvalid:!1}}):r.push({type:"text",text:n[0]}),o=n.index+n[0].length}if(o<e.length){let i=e.substring(o);i&&r.push({type:"text",text:i})}return r.length>0&&r[r.length-1].type==="variable"&&r.push({type:"text",text:wx}),{type:"doc",content:[{type:"paragraph",content:r.length>0?r:void 0}]}}a(Ui,"parseStringToContent");function Xl(e){if(!e.content)return"";let t="",r=a(o=>{var n;o.type==="text"&&o.text?t+=o.text.replace(/\u200B/g,""):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(Xl,"contentToString");import{BubbleMenu as T3}from"@tiptap/react";import{useAtomValue as E3}from"jotai";import{useCallback as w3}from"react";import{useAtomValue as nm}from"jotai";import{AlignCenter as i3,AlignJustify as a3,AlignLeft as s3,AlignRight as l3,Bold as c3,Italic as u3,Link as d3,Quote as m3,Strikethrough as p3,Underline as f3}from"lucide-react";import{Fragment as g3,memo as Oh,useMemo as Fh,useRef as h3,useState as b3,useEffect as y3}from"react";import{forwardRef as rm}from"react";import{forwardRef as Px}from"react";import{jsx as Mx}from"react/jsx-runtime";var em=Px(({children:e,className:t,withShadow:r=!0,withBorder:o=!0,...n},i)=>{let s=R("courier-bg-popover courier-rounded-lg courier-text-popover-foreground",r?"courier-shadow-sm":"",o?"courier-border courier-border-border":"",t);return Mx("div",{className:s,...n,ref:i,children:e})});em.displayName="Surface";import Ix from"@tippyjs/react";import{useCallback as Lx,useState as Rx}from"react";import{forwardRef as Sx,useContext as Ax}from"react";import{createContext as Nx}from"react";var Yl={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"},Ch={...Yl},xh={...Yl,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 tm=Nx(Yl);import{jsx as Th}from"react/jsx-runtime";var Eh=Sx(({children:e,theme:t,colorScheme:r,className:o},n)=>{let i=r!=null?r:"light",s=i==="light"?Ch:xh,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 Th(tm.Provider,{value:typeof l=="object"?l:{},children:Th("div",{style:c,className:R("courier-flex courier-flex-col courier-relative",typeof t=="string"?t:"","theme-container",i==="dark"?"dark courier-dark":"",o),ref:n,children:e})})}),wh=a(()=>Ax(tm),"useTheme");import{Fragment as Mh,jsx as co,jsxs as Ph}from"react/jsx-runtime";var kh=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,Bx=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"?co("kbd",{className:t,children:kh?"\u2318":"Ctrl"}):e==="Shift"?co("kbd",{className:t,children:"\u21E7"}):e==="Alt"?co("kbd",{className:t,children:kh?"\u2325":"Alt"}):co("kbd",{className:t,children:e})},"ShortcutKey"),Nh=a(({children:e,enabled:t=!0,title:r,shortcut:o,tippyOptions:n={}})=>{let i=wh(),s=Lx(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 Ph("span",{className:R("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&&co("span",{className:"courier-text-xs courier-font-medium courier-text-muted-foreground",children:r}),o&&co("span",{className:"courier-flex courier-items-center courier-gap-0.5",children:o.map(p=>co(Bx,{children:p},p))})]})},[o,r,i]),[l,c]=Rx(null);return t?Ph(Mh,{children:[co("span",{ref:c,children:e}),l&&co(Ix,{...n,delay:500,offset:[0,8],touch:!1,zIndex:99999,appendTo:document.body,trigger:"mouseenter focus",showOnCreate:!1,render:s,animation:!1,reference:l})]}):co(Mh,{children:e})},"Tooltip");import{jsx as Ql}from"react/jsx-runtime";var Sh=rm(({shouldShowContent:e=!0,children:t,isVertical:r=!1,className:o,...n},i)=>{let s=R("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&&Ql(em,{className:s,...n,ref:i,children:t})});Sh.displayName="Toolbar";var Ah=rm(({horizontal:e,className:t,...r},o)=>{let n=R("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 Ql("div",{className:n,ref:o,...r})});Ah.displayName="Toolbar.Divider";var Ih=rm(({children:e,buttonSize:t="icon",variant:r="ghost",className:o,tooltip:n,tooltipShortcut:i,onMouseDown:s,...l},c)=>{let u=R("courier-gap-1 courier-min-w-[2rem] courier-w-auto",o),p=Ql(Ae,{className:u,variant:r,buttonSize:t,ref:c,onMouseDown:a(m=>{m.preventDefault(),s==null||s(m)},"handleMouseDown"),...l,children:e});return n?Ql(Nh,{title:n,shortcut:i,children:p}):p});Ih.displayName="ToolbarButton";var ec={Wrapper:Sh,Divider:Ah,Button:Ih};import*as Vo from"react";import*as Ee from"@radix-ui/react-dropdown-menu";import{Check as Dx,ChevronRight as Vx,Circle as Hx}from"lucide-react";import{jsx as Qt,jsxs as om}from"react/jsx-runtime";var tc=Ee.Root,rc=Ee.Trigger;var Fx=Vo.forwardRef(({className:e,inset:t,children:r,...o},n)=>om(Ee.SubTrigger,{ref:n,className:R("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,Qt(Vx,{className:"courier-ml-auto"})]}));Fx.displayName=Ee.SubTrigger.displayName;var Ox=Vo.forwardRef(({className:e,...t},r)=>Qt(Ee.SubContent,{ref:r,className:R("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}));Ox.displayName=Ee.SubContent.displayName;var ts=Vo.forwardRef(({className:e,sideOffset:t=4,portalProps:r,...o},n)=>Qt(Ee.Portal,{...r,children:Qt(Ee.Content,{ref:n,sideOffset:t,className:R("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})}));ts.displayName=Ee.Content.displayName;var rs=Vo.forwardRef(({className:e,inset:t,...r},o)=>Qt(Ee.Item,{ref:o,className:R("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}));rs.displayName=Ee.Item.displayName;var _x=Vo.forwardRef(({className:e,children:t,checked:r,...o},n)=>om(Ee.CheckboxItem,{ref:n,className:R("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:[Qt("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:Qt(Ee.ItemIndicator,{children:Qt(Dx,{className:"courier-h-4 courier-w-4"})})}),t]}));_x.displayName=Ee.CheckboxItem.displayName;var Wx=Vo.forwardRef(({className:e,children:t,...r},o)=>om(Ee.RadioItem,{ref:o,className:R("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:[Qt("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:Qt(Ee.ItemIndicator,{children:Qt(Hx,{className:"courier-h-2 courier-w-2 courier-fill-current"})})}),t]}));Wx.displayName=Ee.RadioItem.displayName;var zx=Vo.forwardRef(({className:e,inset:t,...r},o)=>Qt(Ee.Label,{ref:o,className:R("courier-px-2 courier-py-1.5 courier-text-sm courier-font-semibold",t&&"courier-pl-8",e),...r}));zx.displayName=Ee.Label.displayName;var Ux=Vo.forwardRef(({className:e,...t},r)=>Qt(Ee.Separator,{ref:r,className:R("courier-mx-1 courier-my-1 courier-h-px courier-bg-muted",e),...t}));Ux.displayName=Ee.Separator.displayName;var $x=a(({className:e,...t})=>Qt("span",{className:R("courier-ml-auto courier-text-xs courier-tracking-widest courier-opacity-60",e),...t}),"DropdownMenuShortcut");$x.displayName="DropdownMenuShortcut";import{ChevronDown as qx}from"lucide-react";import{useMemo as jx}from"react";import{Fragment as Kx,jsx as Ho,jsxs as Lh}from"react/jsx-runtime";var Zx=a(e=>e.type==="option","isOption"),Rh=a(({options:e,containerRef:t})=>{let r=jx(()=>e.find(o=>o.type==="option"&&o.isActive()),[e]);return e.length===0?null:Lh(tc,{children:[Ho(rc,{asChild:!0,children:Lh(Ae,{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",Ho(qx,{className:"courier-w-3 courier-h-3"})]})}),Ho(ts,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(Zx(o))return Ho(rs,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?Ho(Kx,{children:o.id==="heading"?Ho("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading1"?Ho("h1",{className:"courier-text-2xl courier-font-bold",children:o.label}):o.id==="heading2"?Ho("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading3"?Ho("h3",{className:"courier-text-lg courier-font-bold",children:o.label}):o.label}):o.label},o.id)})})]})},"ContentTypePicker");import{useSetAtom as Gx}from"jotai";import{useCallback as wr}from"react";import{v4 as oc}from"uuid";import{useMemo as Jx}from"react";var Bh=a((e,t,r)=>Jx(()=>{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 Dh=a((e,t,r)=>{let o=Gx(Ve),n=Bh(t,e,r),i=wr(()=>{if(n&&r){let C=n.getRuleForItem("bold");if(C&&C.action.type==="toggle_off"){let T=e.chain().focus();return C.action.targets.forEach(E=>{E==="italic"&&r.isItalic&&T.toggleItalic()}),T.toggleBold().run(),!0}}return e.chain().focus().toggleBold().run()},[e,n,r]),s=wr(()=>{if(n&&r){let C=n.getRuleForItem("italic");if(C&&C.action.type==="toggle_off"){let T=e.chain().focus();return C.action.targets.forEach(E=>{E==="bold"&&r.isBold&&T.toggleBold()}),T.toggleItalic().run(),!0}}return e.chain().focus().toggleItalic().run()},[e,n,r]),l=wr(()=>e.chain().focus().toggleMark("strike").run(),[e]),c=wr(()=>e.chain().focus().toggleMark("underline").run(),[e]),u=wr(()=>e.chain().focus().setTextAlign("left").run(),[e]),d=wr(()=>e.chain().focus().setTextAlign("center").run(),[e]),p=wr(()=>e.chain().focus().setTextAlign("right").run(),[e]),m=wr(()=>e.chain().focus().setTextAlign("justify").run(),[e]),f=wr((C,T)=>e.chain().focus().setLink({href:C,target:T?"_blank":""}).run(),[e]),v=wr(()=>{if(e.isActive("list")){let{$from:b}=e.state.selection,g=-1,x=-1;for(let V=b.depth;V>=0;V--)if(b.node(V).type.name==="list"&&g===-1&&(g=V),b.node(V).type.name==="blockquote"){x=V;break}if(g===-1)return;let k=b.node(g),P=b.before(g),S=b.after(g),w=[],M=!1,L=1;k.forEach((V,W,j)=>{j>0&&w.push(e.state.schema.nodes.hardBreak.create()),V.forEach(O=>{O.type.name==="heading"?(M=!0,L=O.attrs.level||1,O.content.forEach($=>{w.push($)})):O.type.name==="paragraph"&&O.content.forEach($=>{w.push($)})})});let N;if(M?N=e.state.schema.nodes.heading.create({id:`node-${oc()}`,level:L},w.length>0?w:void 0):N=e.state.schema.nodes.paragraph.create({id:`node-${oc()}`},w.length>0?w:void 0),x!==-1){let V=e.state.tr.replaceWith(P,S,N);e.view.dispatch(V),setTimeout(()=>{let{selection:W}=e.state,j=W.$anchor;for(let O=j.depth;O>0;O--){let $=j.node(O);if($.type.name==="blockquote"){o($);break}}},0);return}let I=e.state.schema.nodes.blockquote.create({id:`node-${oc()}`},N),D=e.state.tr.replaceWith(P,S,I);e.view.dispatch(D),setTimeout(()=>{let{selection:V}=e.state,W=V.$anchor;for(let j=W.depth;j>0;j--){let O=W.node(j);if(O.type.name==="blockquote"){o(O);break}}},0);return}let C=e.isActive("blockquote");if(e.chain().focus().toggleBlockquote().run()){let{selection:b}=e.state,g=b.$anchor;if(C){let x=g.node();(x.type.name==="paragraph"||x.type.name==="heading")&&o(x)}else for(let x=g.depth;x>0;x--){let k=g.node(x);if(k.type.name==="blockquote"){if(k.attrs.id)o(k);else{let P=g.before(x),S=`node-${oc()}`,w=e.state.tr;w.setNodeMarkup(P,void 0,{...k.attrs,id:S}),e.view.dispatch(w);let M=e.state.doc.nodeAt(P);M&&o(M)}break}}}},[e,o]),h=wr(()=>{let C=e.isActive("list",{listType:"ordered"}),T=e.isActive("list",{listType:"unordered"}),E=e.state.selection.from;C||T&&(e.view.focus(),e.commands.setTextSelection(E),e.commands.updateAttributes("list",{listType:"ordered"})&&setTimeout(()=>{e.commands.setTextSelection(E);let{selection:g}=e.state,x=g.$anchor;for(let k=x.depth;k>0;k--){let P=x.node(k);if(P.type.name==="list"){o(P);break}}},0))},[e,o]),y=wr(()=>{let C=e.isActive("list",{listType:"unordered"}),T=e.isActive("list",{listType:"ordered"}),E=e.state.selection.from;C||T&&(e.view.focus(),e.commands.setTextSelection(E),e.commands.updateAttributes("list",{listType:"unordered"})&&setTimeout(()=>{e.commands.setTextSelection(E);let{selection:g}=e.state,x=g.$anchor;for(let k=x.depth;k>0;k--){let P=x.node(k);if(P.type.name==="list"){o(P);break}}},0))},[e,o]);return{onBold:i,onItalic:s,onStrike:l,onUnderline:c,onAlignLeft:u,onAlignCenter:d,onAlignRight:p,onAlignJustify:m,onLink:f,onQuote:v,onOrderedList:h,onUnorderedList:y}},"useTextmenuCommands");import{useEditorState as Xx}from"@tiptap/react";import{useAtomValue as Yx}from"jotai";var Qx=["slack"],e3=["msteams"],Vh=a(e=>{let t=Yx(oo),r=Qx.includes(t),o=e3.includes(t);return Xx({editor:e,selector:n=>{if(o)return[];let i={label:"Normal text",onClick:()=>{n.editor.chain().focus().setNode("paragraph").run()},id:"paragraph",disabled:()=>!n.editor.can().setParagraph(),isActive:()=>n.editor.isActive("paragraph")&&!n.editor.isActive("heading"),type:"option"};return r?[i,{label:"Heading",onClick:()=>{n.editor.chain().focus().setNode("heading",{level:1}).run()},id:"heading",disabled:()=>!n.editor.can().setHeading({level:1}),isActive:()=>n.editor.isActive("heading",{level:1})||n.editor.isActive("heading",{level:2})||n.editor.isActive("heading",{level:3}),type:"option"}]:[i,{label:"Heading 1",onClick:()=>{n.editor.chain().focus().setNode("heading",{level:1}).run()},id:"heading1",disabled:()=>!n.editor.can().setHeading({level:1}),isActive:()=>n.editor.isActive("heading",{level:1}),type:"option"},{label:"Heading 2",onClick:()=>{n.editor.chain().focus().setNode("heading",{level:2}).run()},id:"heading2",disabled:()=>!n.editor.can().setHeading({level:2}),isActive:()=>n.editor.isActive("heading",{level:2}),type:"option"},{label:"Heading 3",onClick:()=>{n.editor.chain().focus().setNode("heading",{level:3}).run()},id:"heading3",disabled:()=>!n.editor.can().setHeading({level:3}),isActive:()=>n.editor.isActive("heading",{level:3}),type:"option"}]}})},"useTextmenuContentTypes");import{useAtomValue as t3}from"jotai";import{useCallback as Hh,useEffect as r3,useState as o3}from"react";import{NodeSelection as n3}from"prosemirror-state";var nc=a(e=>{let t=t3(Te),[r,o]=o3({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isOrderedList:!1,isUnorderedList:!1,isLink:!1,isHeading:!1}),n=Hh(()=>{if(!e)return;if((t==null?void 0:t.type.name)==="button"){o({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isOrderedList:!1,isUnorderedList:!1,isLink:!1,isHeading:!1});return}let s=null,{$from:l}=e.state.selection;for(let c=l.depth;c>=0;c--){let u=l.node(c);if(u.type.name==="list"){s=u.attrs.listType;break}}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"),isOrderedList:s==="ordered",isUnorderedList:s==="unordered",isLink:e.isActive("link"),isHeading:e.isActive("heading")})},[e,t]);return r3(()=>{if(e)return n(),e.on("selectionUpdate",n),e.on("transaction",n),()=>{e.off("selectionUpdate",n),e.off("transaction",n)}},[e,n]),{shouldShow:Hh(({editor:s})=>{let{selection:l}=s.state;if(l instanceof n3&&l.node.type.name==="variable")return!0;let c=["paragraph","heading","blockquote"],{$head:u}=l,d=u.node();if(c.includes(d.type.name)&&d.attrs.isSelected)return!0;for(let p=1;p<=u.depth;p++){let m=u.node(p);if(m.type.name==="blockquote"){if(m.attrs.isSelected)return!0;let f=s.state.selection.from!==s.state.selection.to;if(s.isFocused&&f)return!0}if(m.type.name==="list"){if(m.attrs.isSelected)return!0;let f=s.state.selection.from!==s.state.selection.to;if(s.isFocused&&f)return!0}}return!1},[]),...r}},"useTextmenuStates");import{jsx as Ht,jsxs as x3}from"react/jsx-runtime";var v3=Oh(ec.Button),C3=Oh(Rh),os=a(({editor:e,config:t})=>{var S;let r=nc(e),o=Vh(e),n=h3(null),i=nm(dl),s=nm(Te),l=s==null?void 0:s.type.name,c=nm(zg),[u,d]=b3(()=>{let{selection:w}=e.state;return{from:w.from,to:w.to,empty:w.empty}});y3(()=>{let w=a(()=>{let{selection:M}=e.state;d({from:M.from,to:M.to,empty:M.empty})},"updateSelection");return e.on("selectionUpdate",w),e.on("transaction",w),()=>{e.off("selectionUpdate",w),e.off("transaction",w)}},[e]);let p=Fh(()=>!u.empty&&u.from!==u.to,[u]),m=Fh(()=>t||c(l||"",p),[t,c,l,p]),f=Dh(e,m,r),v=a(()=>{let{selection:w}=e.state;if(!(w.empty&&!r.isLink&&!e.can().setLink({href:""})))if(r.isLink){let M=e.state.tr.setMeta("showLinkForm",{from:w.from,to:w.to});e.view.dispatch(M)}else{let M=e.state.tr.setMeta("showLinkForm",{from:w.from,to:w.to});e.view.dispatch(M)}},"handleLinkToggle"),h=a(()=>{if(i.ref){let w=i.ref,M=w.value,L=i.caretPosition||w.selectionStart||0,N=M.substring(0,L),I=M.substring(L),D=`${N}{{${I}`,V=L+2;w.focus();let W=new Event("input",{bubbles:!0,cancelable:!0});if(Object.defineProperty(W,"target",{writable:!1,value:{...w,value:D}}),w.value=D,w.dispatchEvent(W),w.setSelectionRange(V,V),w.getBoundingClientRect()){let O=D.slice(0,V),$=document.createElement("span");$.style.font=window.getComputedStyle(w).font,$.style.whiteSpace="pre-wrap",$.textContent=O,document.body.appendChild($);let J=$.offsetWidth;document.body.removeChild($);let q=parseInt(window.getComputedStyle(w).lineHeight),F=O.split(`
195
+ `).length-1,A=new CustomEvent("showVariableSuggestions",{detail:{cursorPosition:{left:Math.min(J%w.offsetWidth,w.offsetWidth-200),top:F*q+30}},bubbles:!0});w.dispatchEvent(A)}return}e.chain().focus().insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()},"handleVariableClick"),y=a((w,M,L,N,I,D,V)=>{let W=m[w];return!W||Array.isArray(W)||W.state==="hidden"?null:Ht(v3,{tooltip:L,tooltipShortcut:D,onClick:N,active:I,disabled:W.state==="disabled",...V,children:M},w)},"renderButton"),C=a((w,M)=>{let L=w.filter(N=>!!N);return L.length>0?Ht("div",{className:"courier-flex courier-items-center courier-gap-0.5",children:L},M):null},"renderGroup"),T=C([((S=m.contentType)==null?void 0:S.state)==="enabled"&&o.length>0&&Ht(C3,{options:o,containerRef:n},"content-type")],"content-type-group"),E=m.bold,b=r.isHeading&&(E==null?void 0:E.state)==="enabled"?{state:"hidden"}:E,g=C([(b==null?void 0:b.state)!=="hidden"&&y("bold",Ht(c3,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",f.onBold,r.isBold,["Mod","B"]),y("italic",Ht(u3,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",f.onItalic,r.isItalic,["Mod","I"]),y("underline",Ht(f3,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",f.onUnderline,r.isUnderline,["Mod","U"]),y("strike",Ht(p3,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Strikethrough",f.onStrike,r.isStrike,["Mod","Shift","S"])],"text-style-group"),x=C([y("alignLeft",Ht(s3,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",f.onAlignLeft,r.isAlignLeft,["Shift","Mod","L"]),y("alignCenter",Ht(i3,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",f.onAlignCenter,r.isAlignCenter,["Shift","Mod","E"]),y("alignRight",Ht(l3,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",f.onAlignRight,r.isAlignRight,["Shift","Mod","R"]),y("alignJustify",Ht(a3,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",f.onAlignJustify,r.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),k=r.isOrderedList||r.isUnorderedList?null:C([y("quote",Ht(m3,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Quote",f.onQuote,r.isQuote,["Mod","Shift","B"])],"block-style-group"),P=C([y("link",Ht(d3,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",v,r.isLink,["Mod","K"]),y("variable",Ht(Zf,{width:16}),"Variable",h,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return Ht(ec.Wrapper,{ref:n,className:"courier-border-b rounded-b-none rounded-t-sm !courier-shadow-md courier-justify-center courier-rounded-lg",children:[T,g,x,k,P].filter(Boolean).map((w,M)=>x3(g3,{children:[w,M<[T,g,x,k,P].filter(Boolean).length-1&&Ht(ec.Divider,{})]},`item-${M}`))})},"TextMenu");import{jsx as _h}from"react/jsx-runtime";var k3={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"}},ns=a(({editor:e})=>{let t=E3(Gt),r=w3(({editor:o})=>o.isFocused&&o.isEditable&&t,[t]);return e?_h(T3,{editor:e,tippyOptions:{appendTo:o=>{var n;return(n=o.closest(".theme-container"))!=null?n:document.body},getReferenceClientRect:()=>e.view.dom.getBoundingClientRect(),placement:"top",offset:[0,8],zIndex:50,popperOptions:{modifiers:[{name:"flip",enabled:!1}]}},shouldShow:r,updateDelay:100,children:_h(os,{editor:e,config:k3})}):null},"VariableEditorToolbar");ns.displayName="VariableEditorToolbar";import{jsx as Wh,jsxs as I3}from"react/jsx-runtime";var uo=Gn.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,showToolbar:i=!1,onFocus:s,onBlur:l},c)=>{let u=Gn.useRef(!1),d=Gn.useRef(e),p=S3(Gt),m=N3({immediatelyRender:!1,extensions:[Ri,Bi.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),Dl,Gl,Kn,Jn,P3.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:Ui(e),editable:!n,editorProps:{attributes:{class:"courier-outline-none courier-min-h-[20px]"},handleKeyDown:(v,h)=>h.key==="Enter"&&!h.shiftKey?(h.preventDefault(),!0):!1},onUpdate:({editor:v})=>{if(u.current)return;let h=Xl(v.getJSON());h!==d.current&&(d.current=h,t==null||t(h))},onFocus:()=>{s==null||s()},onBlur:()=>{l==null||l()}});im(()=>{if(!m||e===d.current)return;u.current=!0,d.current=e;let v=setTimeout(()=>{let h=Ui(e);m.commands.setContent(h),u.current=!1},0);return()=>clearTimeout(v)},[m,e]),im(()=>{m&&m.setEditable(!n)},[m,n]),im(()=>{var v;(v=m==null?void 0:m.storage)!=null&&v.variableInputRule&&(m.storage.variableInputRule.disabled=!p)},[m,p]);let f=A3(()=>{m==null||m.commands.focus()},[m]);return Gn.useImperativeHandle(c,()=>{let v=m==null?void 0:m.view.dom.parentElement;return v&&(v.focus=f),v},[m,f]),I3("div",{ref:c,className:R("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:[Wh(M3,{editor:m,className:"courier-w-full"}),i&&!n&&Wh(ns,{editor:m})]})});uo.displayName="VariableTextarea";import L3 from"@tiptap/extension-placeholder";import{EditorContent as R3,useEditor as B3}from"@tiptap/react";import{TextSelection as D3}from"@tiptap/pm/state";import{useAtomValue as V3}from"jotai";import*as Xn from"react";import{useCallback as H3,useEffect as am}from"react";import{jsx as zh,jsxs as O3}from"react/jsx-runtime";function F3(e,t,r,o,n){let i=1+r;return e===0?t>=i?{targetPos:i,bias:-1}:{targetPos:1,bias:1}:n!==null&&o>n?{targetPos:i,bias:-1}:null}a(F3,"resolveEmptySpaceClick");var is=Xn.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=Xn.useRef(!1),p=Xn.useRef(e),m=V3(Gt),f=B3({immediatelyRender:!1,extensions:[Ri,Bi.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal !courier-whitespace-nowrap"}}),Dl,Gl,Kn,Jn,L3.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:Ui(e),editable:!n&&!i,editorProps:{attributes:{class:"courier-outline-none"},handleKeyDown:(h,y)=>y.key==="Enter"?(y.preventDefault(),!0):!1,handleClick:(h,y,C)=>{let{state:T}=h,{doc:E}=T,b=E.resolve(y),g=E.firstChild;if(!g)return!1;let x=1+g.content.size,k=null;try{k=h.coordsAtPos(x).right}catch{}let P=F3(b.depth,y,g.content.size,C.clientX,k);if(P){let S=E.resolve(P.targetPos),w=D3.near(S,P.bias);return h.dispatch(T.tr.setSelection(w)),h.focus(),!0}return!1}},onUpdate:({editor:h})=>{if(d.current)return;let y=Xl(h.getJSON());y!==p.current&&(p.current=y,t==null||t(y))},onFocus:()=>{l==null||l()},onBlur:()=>{c==null||c()}});am(()=>{if(!f||e===p.current)return;d.current=!0,p.current=e;let h=setTimeout(()=>{let y=Ui(e);f.commands.setContent(y),d.current=!1},0);return()=>clearTimeout(h)},[f,e]),am(()=>{f&&f.setEditable(!n&&!i)},[f,n,i]),am(()=>{var h;(h=f==null?void 0:f.storage)!=null&&h.variableInputRule&&(f.storage.variableInputRule.disabled=!m)},[f,m]);let v=H3(()=>{f==null||f.commands.focus()},[f]);return Xn.useImperativeHandle(u,()=>{let h=f==null?void 0:f.view.dom.parentElement;return h&&(h.focus=v),h},[f,v]),O3("div",{ref:u,className:R("variable-input-placeholder variable-editor-container variable-input-no-scrollbar","courier-flex courier-items-center courier-w-full courier-rounded-md courier-border-none courier-bg-transparent courier-text-foreground courier-py-1","courier-overflow-x-auto courier-overflow-y-clip","[&_.tiptap]:courier-whitespace-nowrap [&_.tiptap]:courier-flex-nowrap","[&_.tiptap]:courier-inline-flex [&_.tiptap]:courier-items-center","[&_.ProseMirror]:courier-inline-flex [&_.ProseMirror]:courier-items-center [&_.ProseMirror]:courier-flex-nowrap",(n||i)&&"courier-cursor-default",n&&"courier-opacity-50","[&_.tiptap]:courier-outline-none [&_.tiptap]:courier-border-none",o),style:{scrollbarWidth:"none",msOverflowStyle:"none"},onClick:h=>{var C,T;if(i||n)return;((T=(C=f==null?void 0:f.view)==null?void 0:C.dom)==null?void 0:T.contains(h.target))||f==null||f.commands.focus()},children:[zh(R3,{editor:f,className:"courier-flex-1 courier-min-w-0"}),s&&!n&&zh(ns,{editor:f})]})});is.displayName="VariableInput";import{jsx as qi,jsxs as B$}from"react/jsx-runtime";var $i=30,ic=a(({color:e="currentColor",width:t=$i,height:r=$i,...o})=>qi(Q,{...o,width:t,height:r,children:qi("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"),ac=a(({color:e="currentColor",width:t=$i,height:r=$i,...o})=>qi(Q,{...o,width:t,height:r,children:qi("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"),sc=a(({color:e="currentColor",width:t=$i,height:r=$i,...o})=>qi(Q,{...o,width:t,height:r,children:qi("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");function Uh(e,t){let r=null;return e.descendants((o,n)=>o.type.name==="button"&&o.attrs.id===t?(r={pos:n,node:o},!1):!0),r}a(Uh,"findButtonNodeById");function $h(e,t){let r=e.nodeAt(t);return(r==null?void 0:r.type.name)==="button"?{pos:t,node:r}:null}a($h,"findButtonNodeAtPosition");function _3(e){let t="";return e.content.forEach(r=>{var o;r.isText?t+=r.text:r.type.name==="variable"&&(t+=((o=r.attrs)==null?void 0:o.fallback)||"")}),t}a(_3,"extractButtonTextContent");function qh(e){let t=e.tr,r=!1;return e.doc.descendants((o,n)=>{if(o.type.name==="button"){let i=_3(o);i!==o.attrs.label&&(t.setNodeMarkup(n,void 0,{...o.attrs,label:i}),r=!0)}}),r?t:null}a(qh,"syncButtonContentToLabelAttr");function jh(e,t,r){let o=e.doc.nodeAt(t);if(!o||o.type.name!=="button")return!1;e.setNodeMarkup(t,o.type,{...o.attrs,label:r});let n=t+1,i=t+1+o.content.size;return e.replaceWith(n,i,e.doc.type.schema.text(r)),e.setMeta("addToHistory",!0),!0}a(jh,"updateButtonLabelAndContent");import{jsx as ce,jsxs as _r}from"react/jsx-runtime";var lc=a(({element:e,editor:t,hideCloseButton:r=!1})=>{let o=U3({resolver:W3(Bl),defaultValues:{...Se,...e==null?void 0:e.attrs}}),{updateNodeAttributes:n}=xt({editor:t,element:e,form:o,nodeType:"button"}),i=Kh((e==null?void 0:e.attrs.id)||null),s=Kh(null);z3(()=>{e!=null&&e.attrs.id&&t&&(i.current=e.attrs.id,t.state.doc.descendants((u,d)=>u.attrs.id===e.attrs.id&&u.type.name==="button"?(s.current=d,!1):!0))},[e==null?void 0:e.attrs.id,t]);let l=Zh(()=>{if(!t)return null;if(i.current){let u=Uh(t.state.doc,i.current);if(u)return s.current=u.pos,u}if(s.current!==null){let u=$h(t.state.doc,s.current);if(u)return i.current=u.node.attrs.id,u}return null},[t]),c=Zh(u=>{if(!t)return;let d=l();if(!d)return;let{pos:p}=d;Po(!0),t.chain().command(({tr:m,dispatch:f})=>f?jh(m,p,u):!1).run(),setTimeout(()=>{Po(!1)},50)},[t,l]);return e?_r(Oe,{...o,children:[ce(Tt,{type:"button",hideCloseButton:r}),_r("form",{"data-sidebar-form":!0,onChange:()=>{n(o.getValues())},children:[ce("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Label"}),ce(re,{control:o.control,name:"label",render:({field:u})=>_r(ee,{className:"courier-mb-4",children:[ce(te,{children:ce(ge,{placeholder:"Enter button text",value:u.value,onChange:d=>{let p=typeof d=="string"?d:d.target.value;u.onChange(p),c(p)}})}),ce(oe,{})]})}),ce(pe,{className:"courier-mt-6 courier-mb-4"}),ce("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),ce(re,{control:o.control,name:"link",render:({field:u})=>_r(ee,{children:[ce(te,{children:ce(uo,{value:u.value,onChange:d=>{u.onChange(d),n({...o.getValues(),link:d})},showToolbar:!0})}),ce(oe,{})]})}),ce(pe,{className:"courier-mt-6 courier-mb-4"}),ce("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Background"}),ce(re,{control:o.control,name:"backgroundColor",render:({field:u})=>_r(ee,{className:"courier-mb-4",children:[ce(te,{children:ce(Et,{...u,defaultValue:Se.backgroundColor,onChange:d=>{u.onChange(d),n({...o.getValues(),[u.name]:d})}})}),ce(oe,{})]})}),ce(pe,{className:"courier-mt-6 courier-mb-4"}),ce("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),_r("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-2",children:[ce(re,{control:o.control,name:"paddingHorizontal",render:({field:u})=>_r(ee,{children:[ce(te,{children:ce(ge,{startAdornment:ce(So,{}),type:"number",min:0,...u})}),ce(oe,{})]})}),ce(re,{control:o.control,name:"paddingVertical",render:({field:u})=>_r(ee,{children:[ce(te,{children:ce(ge,{startAdornment:ce(Rr,{}),type:"number",min:0,...u})}),ce(oe,{})]})})]}),ce(re,{control:o.control,name:"alignment",render:({field:u})=>_r(ee,{children:[ce(te,{children:_r(Wr,{type:"single",value:u.value,onValueChange:d=>{u.onChange(d),n({...o.getValues(),alignment:d})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[ce(Ft,{size:"sm",value:"left",className:"courier-w-full",children:ce(ic,{className:"courier-h-4 courier-w-4"})}),ce(Ft,{size:"sm",value:"center",className:"courier-w-full",children:ce(ac,{className:"courier-h-4 courier-w-4"})}),ce(Ft,{size:"sm",value:"right",className:"courier-w-full",children:ce(sc,{className:"courier-h-4 courier-w-4"})})]})}),ce(oe,{})]})}),ce(pe,{className:"courier-mt-6 courier-mb-4"}),ce("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),ce(re,{control:o.control,name:"borderRadius",render:({field:u})=>_r(ee,{children:[ce(te,{children:ce(ge,{startAdornment:ce(Aa,{}),type:"number",min:0,...u})}),ce(oe,{})]})})]})]}):null},"ButtonForm");import{mergeAttributes as Y3,Node as Q3}from"@tiptap/core";import{ReactNodeViewRenderer as eT}from"@tiptap/react";import{v4 as tT}from"uuid";import{useAtomValue as $3,useSetAtom as q3}from"jotai";import{useCallback as Fo,useRef as Yn,useEffect as Gh,useLayoutEffect as j3,useState as Z3}from"react";import{Fragment as X3,jsx as mo,jsxs as sm}from"react/jsx-runtime";var K3=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();vt(i)?t.push({type:"variable",name:i}):t.push({type:"text",content:n[0]}),o=n.index+n[0].length}return o<e.length&&t.push({type:"text",content:e.substring(o)}),t},"parseLabel"),J3=a(({parts:e})=>{let t=$3(Mn);return mo(X3,{children:e.map((r,o)=>{if(r.type==="text")return mo("span",{children:r.content},o);let n=t[r.name];return sm("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:[mo(Zl,{color:n?void 0:"#B45309"}),sm("span",{className:"courier-truncate courier-min-w-0",style:{color:"#000000"},children:[r.name,n?`="${n}"`:""]})]},o)})})},"ButtonLabelDisplay"),Jh=a(({label:e,backgroundColor:t,textColor:r,onLabelChange:o,editable:n})=>{let i=Yn(null),s=Yn(e),l=Yn(!1),[c,u]=Z3(!1),d=K3(e),m=d.some(x=>x.type==="variable")&&!c;j3(()=>{if(!i.current||!m)return;Array.from(i.current.childNodes).filter(k=>k.nodeType===Node.TEXT_NODE).forEach(k=>k.remove())},[m,e]);let f=Yn(m),v=Yn(!0);Gh(()=>{if(!i.current||m){f.current=m;return}let x=f.current&&!m;f.current=m,(v.current||x||!l.current&&e!==s.current)&&(i.current.textContent=e),v.current=!1,s.current=e},[e,m]);let h=Fo(()=>{if(i.current&&!m){l.current=!0;let x=i.current.textContent||"";s.current=x,o(x),requestAnimationFrame(()=>{l.current=!1})}},[o,m]),y=Fo(x=>{var k;if(m){x.preventDefault(),x.stopPropagation();return}if(x.key==="Enter"&&(x.preventDefault(),(k=i.current)==null||k.blur()),(x.metaKey||x.ctrlKey)&&x.key==="a"&&(x.preventDefault(),x.stopPropagation(),i.current)){let P=document.createRange();P.selectNodeContents(i.current);let S=window.getSelection();S==null||S.removeAllRanges(),S==null||S.addRange(P)}},[m]),C=Fo(()=>{u(!0)},[]),T=Fo(()=>{u(!1)},[]),E=Fo(x=>{let k=i.current;if(!k)return;if(m&&n){x.stopPropagation(),setTimeout(()=>{k.focus();let w=document.createRange();w.selectNodeContents(k),w.collapse(!1);let M=window.getSelection();M==null||M.removeAllRanges(),M==null||M.addRange(w)},0);return}if(!n)return;let P=a(()=>{let w=window.getSelection();if(!w||w.rangeCount===0)return;let M=w.getRangeAt(0),L=k.contains(M.startContainer),N=k.contains(M.endContainer);if(L&&!N){let I=document.createRange();I.selectNodeContents(k),w.removeAllRanges(),w.addRange(I)}},"checkAndConstrainSelection"),S=a(w=>{let M=k.getBoundingClientRect();(w.clientX<M.left||w.clientX>M.right||w.clientY<M.top||w.clientY>M.bottom)&&P(),document.removeEventListener("mouseup",S)},"handleMouseUp");document.addEventListener("mouseup",S)},[n,m]),b=m?mo(J3,{parts:d}):n?null:e,g=Fo(x=>{m&&n&&x.stopPropagation()},[m,n]);return mo("div",{ref:i,contentEditable:n&&!m,suppressContentEditableWarning:!0,tabIndex:n&&m?0:void 0,onInput:h,onKeyDown:y,onPointerDown:E,onClick:g,onFocus:C,onBlur:T,className:R("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"),G3=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})=>mo("div",{className:"node-element",children:sm("div",{className:"courier-flex courier-gap-1 courier-justify-start",style:{marginTop:`${c}px`,marginBottom:`${c}px`},children:[mo(Jh,{label:e,backgroundColor:r,textColor:o,onLabelChange:u||(()=>{}),editable:p},"button1"),mo(Jh,{label:n,backgroundColor:s,textColor:l,onLabelChange:d||(()=>{}),editable:p},"button2")]})}),"ButtonRowComponent"),Xh=a(e=>{let t=q3(Ve),r=Yn({}),o=Yn({}),n=Fo(()=>{if(!e.editor.isEditable)return;let l=st(e);l&&t(l)},[e,t]),i=Fo(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=Fo(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 Gh(()=>{let l=r.current;return()=>{l.button1&&clearTimeout(l.button1),l.button2&&clearTimeout(l.button2)}},[]),mo(Ct,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"buttonRow",children:mo(G3,{...e.node.attrs,onButton1LabelChange:i,onButton2LabelChange:s,editable:e.editor.isEditable})})},"ButtonRowComponentNode");var zr={button1Label:"Register",button1Link:"",button1BackgroundColor:"#000000",button1TextColor:"#ffffff",button2Label:"Learn more",button2Link:"",button2BackgroundColor:"#ffffff",button2TextColor:"#000000",padding:6},uc=Q3.create({name:"buttonRow",group:"block",atom:!0,selectable:!1,onCreate(){je(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${tT()}`,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.id})},button1Label:{default:zr.button1Label,parseHTML:e=>e.getAttribute("data-button1-label"),renderHTML:e=>({"data-button1-label":e.button1Label})},button1Link:{default:zr.button1Link,parseHTML:e=>e.getAttribute("data-button1-link"),renderHTML:e=>({"data-button1-link":e.button1Link})},button1BackgroundColor:{default:zr.button1BackgroundColor,parseHTML:e=>e.getAttribute("data-button1-bg"),renderHTML:e=>({"data-button1-bg":e.button1BackgroundColor})},button1TextColor:{default:zr.button1TextColor,parseHTML:e=>e.getAttribute("data-button1-color"),renderHTML:e=>({"data-button1-color":e.button1TextColor})},button2Label:{default:zr.button2Label,parseHTML:e=>e.getAttribute("data-button2-label"),renderHTML:e=>({"data-button2-label":e.button2Label})},button2Link:{default:zr.button2Link,parseHTML:e=>e.getAttribute("data-button2-link"),renderHTML:e=>({"data-button2-link":e.button2Link})},button2BackgroundColor:{default:zr.button2BackgroundColor,parseHTML:e=>e.getAttribute("data-button2-bg"),renderHTML:e=>({"data-button2-bg":e.button2BackgroundColor})},button2TextColor:{default:zr.button2TextColor,parseHTML:e=>e.getAttribute("data-button2-color"),renderHTML:e=>({"data-button2-color":e.button2TextColor})},padding:{default:zr.padding,parseHTML:e=>parseInt(e.getAttribute("data-padding")||"6"),renderHTML:e=>({"data-padding":e.padding})}}},parseHTML(){return[{tag:'div[data-type="buttonRow"]'}]},renderHTML({HTMLAttributes:e}){return["div",Y3(e,{"data-type":"buttonRow"})]},addNodeView(){return eT(Xh,{stopEvent:({event:e})=>!(e.type==="dragstart"||e.type==="drop")})},addCommands(){return{setButtonRow:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...zr,...e}}).run()}}});import{zodResolver as rT}from"@hookform/resolvers/zod";import{useForm as oT}from"react-hook-form";import{z as kr}from"zod";var Yh=kr.object({columnsCount:kr.number().min(1).max(4).default(2),paddingHorizontal:kr.number().default(0),paddingVertical:kr.number().default(0),backgroundColor:kr.string().default("transparent"),borderWidth:kr.number().default(0),borderRadius:kr.number().default(0),borderColor:kr.string().default("transparent"),cells:kr.array(kr.object({elements:kr.array(kr.any())})).optional()});import{jsx as he,jsxs as Ur}from"react/jsx-runtime";var lm=a(({element:e,editor:t,hideCloseButton:r=!1})=>{let o=oT({resolver:rT(Yh),defaultValues:{...Lt,...e==null?void 0:e.attrs}}),{updateNodeAttributes:n}=xt({editor:t,element:e,form:o,nodeType:"column"}),i=a(s=>{if(!t||!e)return;let l=null;if(t.state.doc.descendants((v,h)=>v.attrs.id===e.attrs.id&&v.type.name==="column"?(l=h,!1):!0),l===null)return;let c=t.state.doc.nodeAt(l);if(!c)return;let u=e.attrs.id,d=t.schema,p=t.state.tr,m=c.firstChild;if(!m||m.type.name!=="columnRow"){let v=Array.from({length:s},(y,C)=>d.nodes.columnCell.create({index:C,columnId:u,isEditorMode:!1})),h=d.nodes.columnRow.create({},v);p.replaceWith(l+1,l+c.nodeSize-1,h),p.setNodeMarkup(l,void 0,{...c.attrs,columnsCount:s}),p.setMeta("addToHistory",!0),t.view.dispatch(p);return}let f=m.childCount;if(s!==f){if(s>f){let v=s-f,y=l+1+m.nodeSize-1;for(let C=0;C<v;C++){let T=d.nodes.columnCell.create({index:f+C,columnId:u});p.insert(y+C*T.nodeSize,T)}}else{let v=f-s,y=l+1;for(let T=0;T<f-v;T++){let E=m.child(T);y+=E.nodeSize}let C=0;for(let T=f-v;T<f;T++){let E=m.child(T);C+=E.nodeSize}p.delete(y,y+C)}p.setNodeMarkup(l,void 0,{...c.attrs,columnsCount:s}),p.setMeta("addToHistory",!0),t.view.dispatch(p)}},"updateColumnCount");return e?Ur(Oe,{...o,children:[he(Tt,{type:"column",label:"Column layout",hideCloseButton:r}),Ur("form",{"data-sidebar-form":!0,onChange:()=>{n(o.getValues())},children:[he("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Columns count"}),he(re,{control:o.control,name:"columnsCount",render:({field:s})=>Ur(ee,{className:"courier-mb-4",children:[he(te,{children:he(Wr,{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:s.value.toString(),onValueChange:l=>{if(l){let c=Number(l);s.onChange(c),i(c)}},children:[1,2,3,4].map(l=>he(Ft,{value:l.toString(),className:"courier-w-12 courier-h-7",children:he("span",{className:"courier-text-sm courier-font-medium",children:l})},l))})}),he(oe,{})]})}),he(pe,{className:"courier-mt-6 courier-mb-4"}),he("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Frame"}),Ur("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[he(re,{control:o.control,name:"paddingHorizontal",render:({field:s})=>Ur(ee,{children:[he(te,{children:he(ge,{startAdornment:he(So,{}),type:"number",min:0,...s})}),he(oe,{})]})}),he(re,{control:o.control,name:"paddingVertical",render:({field:s})=>Ur(ee,{children:[he(te,{children:he(ge,{startAdornment:he(Rr,{}),type:"number",min:0,...s})}),he(oe,{})]})})]}),he(re,{control:o.control,name:"backgroundColor",render:({field:s})=>Ur(ee,{className:"courier-mb-4",children:[he(te,{children:he(Et,{...s,defaultValue:Lt.backgroundColor,onChange:l=>{s.onChange(l),n({...o.getValues(),[s.name]:l})}})}),he(oe,{})]})}),he(pe,{className:"courier-mt-6 courier-mb-4"}),he("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Border"}),Ur("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[he(re,{control:o.control,name:"borderWidth",render:({field:s})=>Ur(ee,{children:[he(te,{children:he(ge,{startAdornment:he(No,{}),type:"number",min:0,...s})}),he(oe,{})]})}),he(re,{control:o.control,name:"borderRadius",render:({field:s})=>Ur(ee,{children:[he(te,{children:he(ge,{startAdornment:he(Aa,{}),type:"number",min:0,...s})}),he(oe,{})]})})]}),he(re,{control:o.control,name:"borderColor",render:({field:s})=>Ur(ee,{className:"courier-mb-4",children:[he(te,{children:he(Et,{...s,defaultValue:Lt.borderColor,onChange:l=>{s.onChange(l),n({...o.getValues(),[s.name]:l})}})}),he(oe,{})]})})]})]}):null},"ColumnForm");import{mergeAttributes as nT,Node as iT}from"@tiptap/core";var dc=iT.create({name:"columnRow",group:"columnContent",content:"columnCell+",isolating:!0,parseHTML(){return[{tag:'div[data-type="column-row"]'}]},renderHTML({HTMLAttributes:e}){return["div",nT(e,{"data-type":"column-row",class:"courier-flex courier-flex-row courier-gap-2 courier-w-full",style:"display: flex; flex-direction: row; gap: 0.5rem; width: 100%;"}),0]},addCommands(){return{insertColumnRow:()=>({chain:e})=>e().insertContent({type:this.name}).run()}}});import{mergeAttributes as dT,Node as mT}from"@tiptap/core";import{ReactNodeViewRenderer as pT}from"@tiptap/react";import{Plugin as fT,PluginKey as gT}from"@tiptap/pm/state";import{NodeViewWrapper as aT,NodeViewContent as sT}from"@tiptap/react";import{useEffect as Qh,useRef as lT,useState as eb}from"react";import{useAtomValue as cT}from"jotai";import{jsx as tb,jsxs as uT}from"react/jsx-runtime";var rb=a(e=>{let t=lT(null),[r,o]=eb(!1),n=cT(Xt),i=e.node.attrs.isEditorMode===!0,[s,l]=eb(e.editor.isEditable);Qh(()=>{let d=t.current;if(d)return mr({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]),Qh(()=>{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 uT(aT,{ref:t,"data-column-cell":"true","data-column-id":e.node.attrs.columnId,"data-cell-index":e.node.attrs.index,className:R("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&&tb("span",{className:"courier-pointer-events-none courier-pl-4",children:"Drag and drop content blocks"}),tb(sT,{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full"})]})},"ColumnCellComponentNode");var mc=mT.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",dT(e,{"data-type":"column-cell",style:"flex: 1 1 0%; width: 0; min-height: 120px;"}),0]},addNodeView(){return pT(rb)},addCommands(){return{insertColumnCell:()=>({chain:e})=>e().insertContent({type:this.name}).run()}},addProseMirrorPlugins(){return[new fT({key:new gT("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}})]}});import{useRef as pc,useCallback as ob,useState as nb,lazy as yT,Suspense as vT,useEffect as CT}from"react";import{forwardRef as hT}from"react";import{jsx as bT}from"react/jsx-runtime";var cm=hT(({className:e,...t},r)=>{let o=R("courier-animate-spin courier-rounded-full courier-border-2 courier-border-current courier-border-t-transparent courier-h-4 courier-w-4",e);return bT("div",{className:o,ref:r,...t})});cm.displayName="Spinner";import{jsx as ji}from"react/jsx-runtime";var xT=a(()=>{let[e,t]=nb(!1),r=pc(null);return CT(()=>{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"),TT=yT(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function ET(e,t){let r=pc();return ob((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}a(ET,"useDebounce");var wT=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 C,T;return(T=(C=y.match(/<([a-z][a-z0-9]*)/i))==null?void 0:C[1])==null?void 0:T.toLowerCase()}).filter(Boolean),f=(e.match(/<\/([a-z][a-z0-9]*)\s*>/gi)||[]).map(y=>{var C,T;return(T=(C=y.match(/<\/([a-z][a-z0-9]*)/i))==null?void 0:C[1])==null?void 0:T.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 C=m.filter(E=>E===y).length,T=f.filter(E=>E===y).length;if(C!==T)return!1}return!0}catch{return!1}},"defaultHTMLValidator"),um=a(({code:e,onSave:t,onValidationChange:r,validator:o=wT})=>{let n=pc(null),i=pc(null),[s,l]=nb(!0),{isDark:c,containerRef:u}=xT(),d=ob(()=>{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=ET(v=>{setTimeout(()=>{d()&&t(v)},150)},500);return ji("div",{ref:u,className:"courier-h-full courier-overflow-hidden",children:ji("div",{className:"courier-h-full courier-p-2",children:ji(vT,{fallback:ji("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:ji(cm,{})}),children:ji(TT,{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");import{zodResolver as kT}from"@hookform/resolvers/zod";import{useForm as PT}from"react-hook-form";import{z as ib}from"zod";var ab=ib.object({code:ib.string()});import{useCallback as MT}from"react";import{useAtom as NT}from"jotai";import{Fragment as sb,jsx as $r,jsxs as as}from"react/jsx-runtime";var dm=a(({element:e,editor:t,hideCloseButton:r=!1})=>{let o=PT({resolver:kT(ab),defaultValues:{...Io,...e==null?void 0:e.attrs}}),{updateNodeAttributes:n}=xt({editor:t,element:e,form:o,nodeType:"customCode"}),[i,s]=NT(ur),l=MT(c=>{o.setValue("code",c),n({code:c})},[o,n]);return e?$r(Oe,{...o,children:as("div",{className:i?"courier-flex courier-flex-col courier-h-full":void 0,children:[!i&&$r(Tt,{type:"customCode",hideCloseButton:r}),as("div",{className:`courier-flex courier-flex-col courier-gap-4 ${i?"courier-flex-1 courier-min-h-0":""}`,children:[$r(Ae,{className:"courier-w-fit courier-flex-shrink-0",variant:"outline",buttonSize:"small",onClick:()=>s(!i),children:i?as(sb,{children:[$r(Fu,{className:"courier-w-3 courier-h-3"}),"Minimize"]}):as(sb,{children:[$r(Ia,{className:"courier-w-3 courier-h-3"}),"Expand Editor"]})}),$r("div",{className:`courier-overflow-hidden courier-rounded-md courier-border courier-border-border ${i?"courier-flex-1 courier-min-h-0":"courier-mb-4"}`,style:i?{minHeight:"200px"}:{minHeight:"200px",height:"300px",resize:"vertical",overflow:"auto"},children:$r("form",{"data-sidebar-form":!0,onChange:()=>{n(o.getValues())},className:"courier-h-full",children:$r(re,{control:o.control,name:"code",render:({field:c})=>as(ee,{className:"courier-h-full",children:[$r(te,{children:$r(um,{code:c.value,onSave:u=>{c.onChange(u),l(u)},onCancel:()=>{}})}),$r(oe,{})]})})})})]})]})}):null},"CustomCodeForm");import{z as Zi}from"zod";var lb=Zi.object({padding:Zi.number(),color:Zi.string(),size:Zi.number(),radius:Zi.number(),variant:Zi.enum(["divider","spacer"]).default("divider")});import{zodResolver as ST}from"@hookform/resolvers/zod";import{useForm as AT}from"react-hook-form";import{Fragment as IT,jsx as Pt,jsxs as Ki}from"react/jsx-runtime";var cb=a(({element:e,editor:t,hideCloseButton:r=!1})=>{let o=AT({resolver:ST(lb),defaultValues:{...qt,...e==null?void 0:e.attrs}}),{updateNodeAttributes:n}=xt({editor:t,element:e,form:o,nodeType:"divider"});if(!e)return null;let i=o.watch("variant");return Ki(Oe,{...o,children:[Pt(Tt,{type:i,hideCloseButton:r}),Ki("form",{"data-sidebar-form":!0,onChange:()=>{n(o.getValues())},children:[Pt("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),Pt(re,{control:o.control,name:"padding",render:({field:s})=>Ki(ee,{children:[Pt(te,{children:Pt(ge,{startAdornment:Pt(Rr,{}),type:"number",...s,onChange:l=>{s.onChange(l),n({...o.getValues(),margin:l.target.value})}})}),Pt(oe,{})]})}),i==="divider"&&Ki(IT,{children:[Pt(pe,{className:"courier-mt-6 courier-mb-4"}),Pt("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Line"}),Pt(re,{control:o.control,name:"size",render:({field:s})=>Ki(ee,{className:"courier-mb-4",children:[Pt(te,{children:Pt(ge,{startAdornment:Pt(No,{}),type:"number",min:0,...s,onChange:l=>{s.onChange(l),n({...o.getValues(),width:l.target.value})}})}),Pt(oe,{})]})}),Pt(re,{control:o.control,name:"color",render:({field:s})=>Ki(ee,{className:"courier-mb-4",children:[Pt(te,{children:Pt(Et,{...s,defaultValue:qt.color,onChange:l=>{s.onChange(l),n({...o.getValues(),[s.name]:l})}})}),Pt(oe,{})]})})]})]})]})},"DividerForm");var mm=Ri.extend({content:"(block)+"});import{Node as FT}from"@tiptap/core";import{ReactNodeViewRenderer as OT}from"@tiptap/react";import{NodeViewWrapper as LT}from"@tiptap/react";import{forwardRef as RT,useEffect as ub,useState as BT}from"react";import{jsx as fc}from"react/jsx-runtime";function DT(){let[e,t]=BT(!1);return ub(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}a(DT,"useMountStatus");var VT=RT(({children:e,className:t,dragOverlay:r,id:o},n)=>(ub(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),fc(LT,{ref:n,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":o,"data-placeholder":"true",className:R("courier-flex courier-items-start courier-gap-2 courier-pl-6",t),children:e}))),HT=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"list":return"List";case"customCode":return"Custom code";case"column":return"Column layout";default:return e}},"getPlaceholderLabel"),db=a(({node:e})=>{let t=e.attrs.type,r=e.attrs.id,o=DT();return fc(VT,{id:r,fadeIn:!o,children:fc("div",{className:R("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:fc("div",{className:"courier-text-accent-foreground",children:HT(t)})})})},"DragPlaceholderComponent");var mb=FT.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 OT(db,{as:"div",className:"drag-placeholder-wrapper"})}});import{Extension as _T}from"@tiptap/core";import{Plugin as WT,PluginKey as zT}from"@tiptap/pm/state";var UT=new zT("file-handler"),$T=_T.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new WT({key:UT,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)}}})]}}),gc=$T;import{Extension as qT}from"@tiptap/core";import{Plugin as jT,PluginKey as ZT}from"@tiptap/pm/state";import{Slice as KT,Fragment as JT}from"@tiptap/pm/model";var GT=new ZT("fixedChannelPaste"),XT=a(e=>{let t=e.view.dom.closest(".courier-slack-editor"),r=e.view.dom.closest(".courier-msteams-editor"),o=e.view.dom.closest(".courier-email-editor");if(t||r||o)return!1;let n=e.view.dom.closest(".courier-push-editor"),i=e.view.dom.closest(".courier-sms-editor"),s=e.view.dom.closest(".courier-inbox-editor");if(n||i||s)return!0;let l=e.state.doc,c=0,u=0;l.forEach(f=>{f.type.name==="paragraph"||f.type.name==="heading"?c++:f.type.name==="button"&&u++});let d=c===1&&u===0,p=c===2&&u===0,m=c>=2&&c+u<=4;return d||p||m},"isInFixedChannel"),YT=a((e,t)=>{let r=[],o=!0,n=a(s=>{let l=!1;return s.content.forEach(c=>{var u;(c.type.name==="variable"||c.isText&&((u=c.text)!=null&&u.trim()))&&(l=!0)}),l},"hasInlineContent"),i=a(s=>{if(s.type.name==="paragraph"||s.type.name==="heading"){if(!n(s))return;o||r.push(t.text(`
196
+ `)),o=!1,s.content.forEach(l=>{if(l.type.name==="variable")r.push(l.type.create(l.attrs));else if(l.isText){let c=l.text||"";c&&r.push(t.text(c))}else l.type.name==="hardBreak"&&r.push(t.text(`
197
+ `))})}else s.content&&s.content.forEach(l=>i(l))},"processNode");return e.content.forEach(s=>i(s)),JT.from(r)},"extractInlineContentFromSlice"),hc=qT.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new jT({key:GT,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!XT(e))return!1;let l=i.$from.node();if(!(l.type.name==="paragraph"||l.type.name==="heading"))return!1;let u=o.content.childCount>1;if(r.preventDefault(),u){let v=YT(o,n.schema);if(v.childCount===0)return!1;let h=n.tr.replaceSelection(new KT(v,0,0));return t.dispatch(h),!0}let d=i.from,p=n.tr.replaceSelection(o),m=d+o.size,f=new Set;return p.doc.nodesBetween(d,m,v=>{v.marks.forEach(h=>{f.add(h.type.name)})}),f.forEach(v=>{let h=n.schema.marks[v];h&&(p=p.removeMark(d,m,h))}),t.dispatch(p),!0}}})]},addStorage(){return{currentChannel:null}}});import{Extension as QT}from"@tiptap/core";import{Plugin as e8,PluginKey as t8,TextSelection as pm}from"@tiptap/pm/state";var Qn=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"),fm=a(e=>!!e.view.dom.closest(".courier-inbox-editor"),"isInInboxChannel"),pb=a(e=>{if(!fm(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"),ei=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"),bc=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"),yc=new t8("fixedChannelSelection"),vc=QT.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!Qn(e,this.options.channels))return!1;let o=ei(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(pm.create(t.doc,l,c)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!Qn(e,this.options.channels))return!1;let t=ei(e);if(!t)return!1;let{start:r,end:o}=t;return e.commands.setTextSelection({from:r,to:o}),!0},Backspace:({editor:e})=>{if(!Qn(e,this.options.channels))return!1;if(fm(e)){let{selection:t}=e.state;if(ei(e)&&t.$anchor.parentOffset===0&&pb(e))return!0}if(bc(e)){let t=ei(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(!Qn(e,this.options.channels))return!1;if(fm(e)){let{selection:t}=e.state,r=ei(e);if(r){let o=r.node.textContent;if(t.$anchor.parentOffset===o.length&&pb(e))return!0}}if(bc(e)){let t=ei(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 e8({key:yc,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!Qn(o,this.options.channels))return!1;if(bc(o)){let n=ei(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(pm.create(u.doc,l,c)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!Qn(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(yc,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!Qn(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&bc(r)){let n=yc.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(pm.create(c.doc,s,l)),e.dispatch(c),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(yc)||t}}})]}});import{mergeAttributes as i8}from"@tiptap/core";import{Node as r8,mergeAttributes as o8,textblockTypeInputRule as n8}from"@tiptap/core";var fb=r8.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]}`,o8(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=>n8({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});import{ReactNodeViewRenderer as a8}from"@tiptap/react";var gm=fb.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){je(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:Ce.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):Ce.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:Ce.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):Ce.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:Ce.textAlign,parseHTML:t=>t.style.textAlign||Ce.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:Ce.backgroundColor,parseHTML:t=>t.style.backgroundColor||Ce.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:Ce.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):Ce.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderColor:{default:Ce.borderColor,parseHTML:t=>t.style.borderColor||Ce.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]}`,i8(this.options.HTMLAttributes,t),0]},addNodeView(){return a8(yl)}});import{z as po}from"zod";var gb=po.object({sourcePath:po.string(),link:po.string().optional(),alt:po.string().optional(),alignment:po.enum(["left","center","right"]),width:po.number().min(1).max(100),borderWidth:po.number(),borderColor:po.string(),isUploading:po.boolean().optional(),imageNaturalWidth:po.number()});import{zodResolver as s8}from"@hookform/resolvers/zod";import{useSetAtom as l8}from"jotai";import{ArrowUp as c8}from"lucide-react";import{useCallback as ls,useEffect as bb,useRef as ym,useState as xc}from"react";import{useForm as u8}from"react-hook-form";import{useSetAtom as hm}from"jotai";import*as ss from"react";import{useRef as hb}from"react";import{jsx as Cc}from"react/jsx-runtime";var mn=ss.forwardRef(({as:e="Input",autoResize:t,onChange:r,...o},n)=>{let i=hb(null),s=hb(null),l=hm($a),c=hm($g),u=hm(dl),d=ss.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=ss.useCallback(h=>{var C;((C=h.relatedTarget)==null?void 0:C.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,C={ref:y,caretPosition:y.selectionStart};c(C),u(C)},"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 Cc("div",{ref:i,className:"courier-relative",children:Cc(ge,{...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 Cc("div",{ref:i,className:"courier-relative",children:Cc(bm,{...v})})});mn.displayName="TextInput";import{Fragment as yb,jsx as ie,jsxs as Ot}from"react/jsx-runtime";var vb=a(({element:e,editor:t,hideCloseButton:r=!1})=>{var P,S;let o=ym(null),n=ym(null),i=ym(null),[s,l]=xc(""),[c,u]=xc(!1),[d,p]=xc(((P=e==null?void 0:e.attrs)==null?void 0:P.imageNaturalWidth)||0),[m,f]=xc(!1),v=l8(se),{uploadImage:h}=Na(),y=u8({resolver:s8(gb),defaultValues:{...tt,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:C}=xt({editor:t,element:e,form:y,nodeType:"imageBlock"});bb(()=>{var M;let w=(M=e==null?void 0:e.attrs)==null?void 0:M.sourcePath;if(w&&!d){let L=new Image;L.onload=()=>{p(L.naturalWidth);let N={...y.getValues(),imageNaturalWidth:L.naturalWidth};y.setValue("imageNaturalWidth",L.naturalWidth),C(N)},L.src=w}},[(S=e==null?void 0:e.attrs)==null?void 0:S.sourcePath,d,y,C]);let T=ls(w=>{var D,V;let M=(V=(D=t==null?void 0:t.view)==null?void 0:D.dom)==null?void 0:V.closest(".ProseMirror"),L=(M==null?void 0:M.clientWidth)||1e3;if(w||(w=d),!w)return 0;let N=Math.min(100,w/L*100);return Math.round(N)},[t,d]),E=ls(w=>{var M;w.preventDefault(),(M=o.current)==null||M.click()},[]),b=ls((w,M)=>{let L=T(w.naturalWidth);l(`${L}%`),u(!1),y.setValue("sourcePath",M),y.setValue("imageNaturalWidth",w.naturalWidth),y.setValue("width",L);let N={...y.getValues(),sourcePath:M,width:L,imageNaturalWidth:w.naturalWidth,isUploading:!1};C(N)},[y,C,T]),g=ls(w=>{if(!w){y.setValue("imageNaturalWidth",0),y.setValue("width",0),C({...y.getValues(),sourcePath:"",imageNaturalWidth:0,width:0});return}let M=new Image;M.onload=()=>{let L=T(M.naturalWidth);y.setValue("imageNaturalWidth",M.naturalWidth),y.setValue("width",L);let N={...y.getValues(),sourcePath:w,width:L,imageNaturalWidth:M.naturalWidth};C(N)},M.onerror=()=>{console.debug("Image failed to load:",w)},M.src=w},[y,C,T]),x=ls(w=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{g(w)},500)},[g]);bb(()=>()=>{i.current&&clearTimeout(i.current)},[]);let k=y.getValues().sourcePath;return e?Ot(Oe,{...y,children:[ie(Tt,{type:"image",hideCloseButton:r}),Ot("form",{ref:n,"data-sidebar-form":!0,onChange:()=>{let w=y.getValues();C(w)},children:[ie("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),Ot(Ji,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[Ot(ti,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[ie(Oo,{value:"file",className:"courier-flex-1",children:"From file"}),ie(Oo,{value:"url",className:"courier-flex-1",children:"From URL"})]}),ie(Tc,{value:"file",children:Ot("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[ie(Ae,{onClick:E,className:"courier-w-full",variant:"outline",type:"button",disabled:m,children:m?ie(yb,{children:"Uploading..."}):Ot(yb,{children:[ie(c8,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),ie("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:w=>{var L;let M=(L=w.target.files)==null?void 0:L[0];if(M){f(!0),y.setValue("sourcePath",""),C({...y.getValues(),sourcePath:"",isUploading:!0});let N=new FileReader;N.onload=async()=>{try{let D=(await h({file:M})).url,V=new Image;V.onload=()=>{b(V,D),f(!1)},V.onerror=()=>{v({message:"Upload failed: Failed to load uploaded image",toastProps:{duration:6e3,description:`File: ${M.name} (${(M.size/1024/1024).toFixed(2)}MB)`}}),f(!1),C({...y.getValues(),isUploading:!1})},V.src=D}catch(I){console.error("Error uploading image:",I),v({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${M.name} (${(M.size/1024/1024).toFixed(2)}MB)`}}),f(!1),C({...y.getValues(),isUploading:!1})}},N.onerror=()=>{v({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${M.name} (${(M.size/1024/1024).toFixed(2)}MB)`}}),f(!1),C({...y.getValues(),isUploading:!1})},N.readAsDataURL(M)}}})]})}),ie(Tc,{value:"url",children:ie(re,{control:y.control,name:"sourcePath",render:({field:w})=>Ot(ee,{className:"courier-mb-3",children:[ie(te,{children:ie(mn,{as:"Textarea",...w,autoResize:!0,className:"courier-max-h-[88px]",onChange:M=>{w.onChange(M),x(M.target.value)}})}),ie(oe,{})]})})})]}),ie(re,{control:y.control,name:"link",render:({field:w})=>Ot(ee,{className:"courier-mb-3",children:[ie(te,{children:ie(uo,{placeholder:"Link",value:w.value,onChange:M=>{w.onChange(M),C({...y.getValues(),link:M})},showToolbar:!0})}),ie(oe,{})]})}),ie(re,{control:y.control,name:"alt",render:({field:w})=>Ot(ee,{className:"courier-mb-4",children:[ie(te,{children:ie(uo,{placeholder:"Alt text...",value:w.value,onChange:M=>{w.onChange(M),C({...y.getValues(),alt:M})},showToolbar:!0})}),ie(oe,{})]})}),ie(pe,{className:"courier-mt-6 courier-mb-4"}),ie("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Width"}),(()=>{let w=y.getValues().width,M=y.getValues().imageNaturalWidth,L=T(M),N=w===L,I=N?"original":"fill";return Ot(Wr,{type:"single",value:k?I:"original",onValueChange:D=>{if(!D||D===I)return;let V=D==="fill"?100:T(M);V>0&&(y.setValue("width",V),C({...y.getValues(),width:V}))},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",disabled:!k,children:[ie(Ft,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),ie(Ft,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:N||!k,children:"Fill"})]})})(),ie(re,{control:y.control,name:"width",render:({field:w})=>Ot(ee,{className:"courier-flex-1 courier-mb-3",children:[ie(te,{children:ie(ge,{type:"text",inputMode:"numeric",pattern:"[0-9]*",min:1,max:100,...w,value:y.getValues().sourcePath?c?s:`${w.value}%`:"0%",className:"courier-text-2xl courier-font-normal",disabled:!y.getValues().sourcePath,onFocus:M=>{u(!0),l(M.target.value)},onChange:M=>{l(M.target.value)},onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),M.currentTarget.blur())},onBlur:M=>{u(!1);let L=parseFloat(M.target.value.replace("%",""));if(!isNaN(L)){let N=Math.min(100,Math.max(1,L));w.onChange(N),C({...y.getValues(),width:Math.round(N)})}}})}),ie(oe,{})]})}),ie(re,{control:y.control,name:"width",render:({field:w})=>Ot(ee,{className:"courier-flex-1 courier-mb-3",children:[ie(te,{children:ie(vm,{min:0,max:100,value:[k?w.value:0],disabled:!k,onValueChange:M=>{w.onChange(M[0]),C({...y.getValues(),width:M[0]})}})}),ie(oe,{})]})}),ie(re,{control:y.control,name:"alignment",render:({field:w})=>Ot(ee,{children:[ie(te,{children:Ot(Wr,{disabled:!k,type:"single",value:w.value,onValueChange:M=>{w.onChange(M),C({...y.getValues(),alignment:M})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[ie(Ft,{size:"sm",value:"left",className:"courier-w-full",children:ie(ic,{className:"courier-h-4 courier-w-4"})}),ie(Ft,{size:"sm",value:"center",className:"courier-w-full",children:ie(ac,{className:"courier-h-4 courier-w-4"})}),ie(Ft,{size:"sm",value:"right",className:"courier-w-full",children:ie(sc,{className:"courier-h-4 courier-w-4"})})]})}),ie(oe,{})]})}),ie(pe,{className:"courier-mt-6 courier-mb-4"}),ie("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),ie(re,{control:y.control,name:"borderWidth",render:({field:w})=>Ot(ee,{className:"courier-mb-3",children:[ie(te,{children:ie(ge,{startAdornment:ie(No,{}),type:"number",disabled:!k,min:0,...w,onChange:M=>{let L=parseInt(M.target.value)||0;w.onChange(L),C({...y.getValues(),borderWidth:L})}})}),ie(oe,{})]})}),ie(re,{control:y.control,name:"borderColor",render:({field:w})=>Ot(ee,{className:"courier-mb-4",children:[ie(te,{children:ie(Et,{...w,disabled:!k,defaultValue:tt.borderColor,onChange:M=>{w.onChange(M),C({...y.getValues(),[w.name]:M})}})}),ie(oe,{})]})})]})]}):null},"ImageBlockForm");import{getMarkRange as Cb,mergeAttributes as d8}from"@tiptap/core";import m8 from"@tiptap/extension-link";import{Plugin as xb,TextSelection as Tb}from"@tiptap/pm/state";var Cm=m8.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",d8(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new xb({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=Cb(l,c.type);return u?(r.dispatch(i.tr.setSelection(Tb.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(Tb.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 xb({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=Cb(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}})]}});import{zodResolver as p8}from"@hookform/resolvers/zod";import{useSetAtom as f8}from"jotai";import{ExternalLink as g8}from"lucide-react";import{useRef as h8,useEffect as b8}from"react";import{useForm as y8}from"react-hook-form";import{z as xm}from"zod";import{jsx as pn,jsxs as cs}from"react/jsx-runtime";var v8=xm.object({href:xm.string(),openInNewTab:xm.boolean().default(!1)}),Gi=a(({editor:e,mark:t,pendingLink:r})=>{let o=f8(Yo),n=h8(null),i=y8({resolver:p8(v8),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1},mode:"onChange"});b8(()=>{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 d=>{let p=d.href.trim();if(!p){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:p,target:d.openInNewTab?"_blank":null}).run()),e==null||e.commands.setTextSelection((r==null?void 0:r.to)||0),o(null)},"updateLink"),l=a(()=>{let d=i.getValues().href.trim();d&&window.open(d,"_blank","noopener,noreferrer")},"handleOpenLink"),c=a(()=>{i.handleSubmit(s)()},"handleSave"),{isDirty:u}=i.formState;return cs(Oe,{...i,children:[pn("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),cs("div",{className:"courier-space-y-4",children:[pn(re,{control:i.control,name:"href",render:({field:d})=>cs(ee,{children:[pn(fo,{children:"URL"}),pn(te,{children:pn(mn,{as:"Textarea",autoResize:!0,...d,ref:p=>{typeof d.ref=="function"&&d.ref(p),n.current=p},onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),p.stopPropagation(),i.handleSubmit(s)())},onBlur:()=>{d.onBlur(),i.handleSubmit(s)()}})}),pn(oe,{})]})}),cs("div",{className:"courier-flex courier-gap-2",children:[cs(Ae,{type:"button",variant:"outline",onClick:l,disabled:!i.getValues().href.trim(),className:"courier-flex-1",children:[pn(g8,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2"}),"Open link"]}),pn(Ae,{type:"button",variant:"primary",onClick:c,disabled:!u,className:"courier-flex-1",children:"Save"})]})]})]})},"LinkForm");import{mergeAttributes as k8,Node as P8}from"@tiptap/core";import{Plugin as M8,PluginKey as N8,TextSelection as S8}from"@tiptap/pm/state";import{ReactNodeViewRenderer as A8}from"@tiptap/react";import{v4 as I8}from"uuid";import{z as us}from"zod";var Eb=us.object({id:us.string().optional(),listType:us.enum(["ordered","unordered"]),paddingVertical:us.coerce.number().min(0),paddingHorizontal:us.coerce.number().min(0)}),qr={listType:"unordered",paddingVertical:6,paddingHorizontal:0};import{NodeViewContent as wb,NodeViewWrapper as C8}from"@tiptap/react";import{useSetAtom as x8,useAtomValue as T8}from"jotai";import{useCallback as E8,useMemo as w8}from"react";import{jsx as ri}from"react/jsx-runtime";var kb=a(e=>{var h,y;let{editor:t,node:r,getPos:o}=e,n=x8(Ve),i=T8(Te),{listType:s,id:l,paddingVertical:c,paddingHorizontal:u}=r.attrs,d=w8(()=>{let C=o();if(typeof C!="number")return!1;let T=t.state.doc.resolve(C);for(let E=T.depth;E>=0;E--)if(T.node(E).type.name==="blockquote")return!0;return!1},[t.state.doc,o]),p=((h=i==null?void 0:i.type)==null?void 0:h.name)==="list"&&(((y=i==null?void 0:i.attrs)==null?void 0:y.id)===l||i===e.node),m=E8(()=>{if(!e.editor.isEditable||d)return;let C=st(e);C&&n(C)},[e,n,d]),f=s==="ordered"?"ol":"ul",v={...c&&{paddingTop:`${c}px`,paddingBottom:`${c}px`},...u&&{paddingLeft:`${20+Number(u)}px`,paddingRight:`${u}px`}};return d?ri(C8,{className:"node-list",children:ri(f,{className:R("courier-list-wrapper",s==="ordered"?"courier-list-decimal":"courier-list-disc","courier-m-0 courier-py-1 courier-pl-6"),style:v,"data-type":"list","data-list-type":s,"data-id":l,"data-node-id":l,children:ri(wb,{})})}):ri(Ct,{id:l,className:R(p&&"selected-element"),onClick:m,editor:e.editor,children:ri("div",{className:"node-element",children:ri(f,{className:R("courier-list-wrapper",s==="ordered"?"courier-list-decimal":"courier-list-disc","courier-m-0 courier-py-1 courier-pl-6"),style:v,"data-type":"list","data-list-type":s,"data-id":l,"data-node-id":l,children:ri(wb,{})})})})},"ListComponentNode");var Ec=P8.create({name:"list",group:"block",content:"listItem+",defining:!0,addOptions(){return{HTMLAttributes:{}}},onCreate(){je(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${I8()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},listType:{default:qr.listType,parseHTML:e=>e.tagName.toLowerCase()==="ol"?"ordered":e.tagName.toLowerCase()==="ul"?"unordered":e.getAttribute("data-list-type")||"unordered",renderHTML:e=>({"data-list-type":e.listType})},paddingVertical:{default:qr.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:qr.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})}}},parseHTML(){return[{tag:"ul",attrs:{listType:"unordered"}},{tag:"ol",attrs:{listType:"ordered"}},{tag:'div[data-type="list"]'}]},renderHTML({HTMLAttributes:e,node:t}){return[t.attrs.listType==="ordered"?"ol":"ul",k8(this.options.HTMLAttributes,e,{"data-type":"list"}),0]},addNodeView(){return A8(kb)},addKeyboardShortcuts(){return{Tab:({editor:t})=>{if(!t.isActive("listItem"))return!1;let{$from:r}=t.state.selection,o=0,n=null;for(let i=r.depth;i>=0;i--)r.node(i).type.name==="list"&&(o++,n===null&&(n=r.node(i).attrs.listType||"unordered"));return o>=5||t.commands.sinkListItem("listItem"),!0},"Shift-Tab":({editor:t})=>t.isActive("listItem")?(t.commands.liftListItem("listItem"),!0):!1,Enter:({editor:t})=>{let{$from:r,empty:o}=t.state.selection,n=-1,i=-1,s=0;for(let p=r.depth;p>=0;p--){let m=r.node(p);m.type.name==="listItem"&&n===-1&&(n=p),m.type.name==="list"&&(i===-1&&(i=p),s++)}if(n===-1||i===-1)return!1;let l=r.node(n),c=r.node(i),u=l.firstChild,d=!u||u.content.size===0;if(o&&d){if(s>1)return t.commands.liftListItem("listItem");if(c.childCount===1)return!0;let f=r.index(i),v=r.before(n),h=r.after(n);return f===c.childCount-1||t.chain().focus().deleteRange({from:v,to:h}).run(),!0}return t.commands.splitListItem("listItem")},Backspace:({editor:t})=>{let{$from:r,empty:o}=t.state.selection;if(!o||r.parentOffset!==0)return!1;let n=-1,i=-1,s=0;for(let y=r.depth;y>=0;y--){let C=r.node(y);C.type.name==="listItem"&&n===-1&&(n=y),C.type.name==="list"&&(i===-1&&(i=y),s++)}if(n===-1||i===-1)return!1;let l=r.node(n),c=r.node(i),u=l.firstChild,d=!u||u.content.size===0,p=r.index(i),m=s>1;if(!d){if(p===0)return!0;let{state:y,view:C}=t,T=y.tr,E=r.before(n),b=r.after(n),g=l.firstChild;if(!g)return!1;let x=E-2;if(x<0)return!1;let k=y.doc.resolve(x),P=-1;for(let I=k.depth;I>=0;I--)if(k.node(I).type.name==="listItem"){P=I;break}if(P===-1)return!1;let w=k.node(P).firstChild;if(!w)return!1;let L=k.before(P)+1+w.nodeSize-1,N=g.content;return T.delete(E,b),T.insert(L,N),T.setSelection(S8.near(T.doc.resolve(L))),C.dispatch(T),!0}if(c.childCount===1)return m?t.commands.liftListItem("listItem"):!0;let v=r.before(n),h=r.after(n);if(p>0){let y=v-2;if(y<0)return!1;let C=t.state.doc.resolve(y),T=-1;for(let k=C.depth;k>=0;k--)if(C.node(k).type.name==="listItem"){T=k;break}if(T===-1)return!1;let b=C.node(T).firstChild;if(!b)return!1;let x=C.before(T)+1+b.nodeSize-1;t.chain().focus().deleteRange({from:v,to:h}).setTextSelection(x).run()}else t.chain().focus().deleteRange({from:v,to:h}).run();return!0}}},addCommands(){return{setList:(e={})=>({chain:t})=>{let r=e.listType||"unordered";return t().insertContent({type:this.name,attrs:{listType:r,...e},content:[{type:"listItem",content:[{type:"paragraph",content:[]}]}]}).run()},toggleOrderedList:()=>({commands:e,editor:t})=>t.isActive("list",{listType:"ordered"})?!0:t.isActive("list",{listType:"unordered"})?e.updateAttributes("list",{listType:"ordered"}):!1,toggleUnorderedList:()=>({commands:e,editor:t})=>t.isActive("list",{listType:"unordered"})?!0:t.isActive("list",{listType:"ordered"})?e.updateAttributes("list",{listType:"unordered"}):!1}},addProseMirrorPlugins(){return[new M8({key:new N8("nestedListUnordered"),appendTransaction:(e,t,r)=>{if(!e.some(i=>i.docChanged))return null;let{tr:o}=r,n=!1;return r.doc.descendants((i,s,l)=>{if(i.type.name==="list"&&(l==null?void 0:l.type.name)==="listItem"&&i.attrs.listType!=="unordered")try{o.setNodeMarkup(s,void 0,{...i.attrs,listType:"unordered"}),n=!0}catch{}return!0}),n?o:null}})]}});import{zodResolver as L8}from"@hookform/resolvers/zod";import{useForm as R8}from"react-hook-form";import{Fragment as B8,jsx as ot,jsxs as fn}from"react/jsx-runtime";var oi=a(({element:e,editor:t,hideCloseButton:r=!1,minimalMode:o=!1})=>{let n=R8({resolver:L8(Eb),defaultValues:{...qr,...e==null?void 0:e.attrs}}),{updateNodeAttributes:i}=xt({editor:t,element:e,form:n,nodeType:(e==null?void 0:e.type.name)||"list"});return e?fn(Oe,{...n,children:[ot(Tt,{type:"list",hideCloseButton:r}),fn("form",{"data-sidebar-form":!0,onChange:()=>{i(n.getValues())},children:[ot("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Type"}),ot(re,{control:n.control,name:"listType",render:({field:s})=>fn(ee,{className:o?"":"courier-mb-4",children:[ot(te,{children:ot("div",{onPointerDown:l=>l.stopPropagation(),onClick:l=>l.stopPropagation(),children:ot(Ji,{value:s.value,onValueChange:l=>{l&&(s.onChange(l),i({...n.getValues(),listType:l}))},children:fn(ti,{className:"courier-w-full",children:[ot(Oo,{value:"unordered",className:"courier-flex-1",children:"Unordered"}),ot(Oo,{value:"ordered",className:"courier-flex-1",children:"Ordered"})]})})})}),ot(oe,{})]})}),!o&&fn(B8,{children:[ot(pe,{className:"courier-mb-4"}),ot("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Padding"}),fn("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-4",children:[ot(re,{control:n.control,name:"paddingHorizontal",render:({field:s})=>fn(ee,{children:[ot(te,{children:ot(ge,{startAdornment:ot(So,{}),type:"number",min:0,...s})}),ot(oe,{})]})}),ot(re,{control:n.control,name:"paddingVertical",render:({field:s})=>fn(ee,{children:[ot(te,{children:ot(ge,{startAdornment:ot(Rr,{}),type:"number",min:0,...s})}),ot(oe,{})]})})]})]})]})]}):null},"ListForm");import{mergeAttributes as U8,Node as $8}from"@tiptap/core";import{findWrapping as D8,ReplaceAroundStep as wc,canSplit as Pb,liftTarget as V8,canJoin as H8}from"prosemirror-transform";import{NodeRange as Tm,Fragment as Bt,Slice as ds}from"prosemirror-model";import{Selection as F8}from"prosemirror-state";function Mb(e,t=null){return function(r,o){let{$from:n,$to:i}=r.selection,s=n.blockRange(i);if(!s)return!1;let l=o?r.tr:null;return O8(l,s,e,t)?(o&&o(l.scrollIntoView()),!0):!1}}a(Mb,"wrapInList");function O8(e,t,r,o=null){let n=!1,i=t,s=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(r)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let c=s.resolve(t.start-2);i=new Tm(c,c,t.depth),t.endIndex<t.parent.childCount&&(t=new Tm(t.$from,s.resolve(t.$to.end(t.depth)),t.depth)),n=!0}let l=D8(i,r,o,t);return l?(e&&_8(e,t,l,n,r),!0):!1}a(O8,"wrapRangeInList");function _8(e,t,r,o,n){let i=Bt.empty;for(let d=r.length-1;d>=0;d--)i=Bt.from(r[d].type.create(r[d].attrs,i));e.step(new wc(t.start-(o?2:0),t.end,t.start,t.end,new ds(i,0,0),r.length,!0));let s=0;for(let d=0;d<r.length;d++)r[d].type==n&&(s=d+1);let l=r.length-s,c=t.start+r.length-(o?2:0),u=t.parent;for(let d=t.startIndex,p=t.endIndex,m=!0;d<p;d++,m=!1)!m&&Pb(e.doc,c,l)&&(e.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return e}a(_8,"doWrapInList");function Nb(e,t){return function(r,o){let{$from:n,$to:i,node:s}=r.selection;if(s&&s.isBlock||n.depth<2||!n.sameParent(i))return!1;let l=n.node(-1);if(l.type!=e)return!1;if(n.parent.content.size==0&&n.node(-1).childCount==n.indexAfter(-1)){if(n.depth==3||n.node(-3).type!=e||n.index(-2)!=n.node(-2).childCount-1)return!1;if(o){let p=Bt.empty,m=n.index(-1)?1:n.index(-2)?2:3;for(let C=n.depth-m;C>=n.depth-3;C--)p=Bt.from(n.node(C).copy(p));let f=n.indexAfter(-1)<n.node(-2).childCount?1:n.indexAfter(-2)<n.node(-3).childCount?2:3;p=p.append(Bt.from(e.createAndFill()));let v=n.before(n.depth-(m-1)),h=r.tr.replace(v,n.after(-f),new ds(p,4-m,0)),y=-1;h.doc.nodesBetween(v,h.doc.content.size,(C,T)=>{if(y>-1)return!1;C.isTextblock&&C.content.size==0&&(y=T+1)}),y>-1&&h.setSelection(F8.near(h.doc.resolve(y))),o(h.scrollIntoView())}return!0}let c=i.pos==n.end()?l.contentMatchAt(0).defaultType:null,u=r.tr.delete(n.pos,i.pos),d=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return Pb(u.doc,n.pos,2,d)?(o&&o(u.split(n.pos,2,d).scrollIntoView()),!0):!1}}a(Nb,"splitListItem");function Sb(e){return function(t,r){let{$from:o,$to:n}=t.selection,i=o.blockRange(n,s=>s.childCount>0&&s.firstChild.type==e);return i?r?o.node(i.depth-1).type==e?W8(t,r,e,i):z8(t,r,i):!0:!1}}a(Sb,"liftListItem");function W8(e,t,r,o){let n=e.tr,i=o.end,s=o.$to.end(o.depth);i<s&&(n.step(new wc(i-1,s,i,s,new ds(Bt.from(r.create(null,o.parent.copy())),1,0),1,!0)),o=new Tm(n.doc.resolve(o.$from.pos),n.doc.resolve(s),o.depth));let l=V8(o);if(l==null)return!1;n.lift(o,l);let c=n.doc.resolve(n.mapping.map(i,-1)-1);return H8(n.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&n.join(c.pos),t(n.scrollIntoView()),!0}a(W8,"liftToOuterList");function z8(e,t,r){let o=e.tr,n=r.parent;for(let f=r.end,v=r.endIndex-1,h=r.startIndex;v>h;v--)f-=n.child(v).nodeSize,o.delete(f-1,f+1);let i=o.doc.resolve(r.start),s=i.nodeAfter;if(o.mapping.map(r.end)!=r.start+i.nodeAfter.nodeSize)return!1;let l=r.startIndex==0,c=r.endIndex==n.childCount,u=i.node(-1),d=i.index(-1);if(!u.canReplace(d+(l?0:1),d+1,s.content.append(c?Bt.empty:Bt.from(n))))return!1;let p=i.pos,m=p+s.nodeSize;return o.step(new wc(p-(l?1:0),m+(c?1:0),p+1,m-1,new ds((l?Bt.empty:Bt.from(n.copy(Bt.empty))).append(c?Bt.empty:Bt.from(n.copy(Bt.empty))),l?0:1,c?0:1),l?0:1)),t(o.scrollIntoView()),!0}a(z8,"liftOutOfList");function Ab(e){return function(t,r){let{$from:o,$to:n}=t.selection,i=o.blockRange(n,u=>u.childCount>0&&u.firstChild.type==e);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,c=l.child(s-1);if(c.type!=e)return!1;if(r){let u=c.lastChild&&c.lastChild.type==l.type,d=Bt.from(u?e.create():null),p=new ds(Bt.from(e.create(null,Bt.from(l.type.create(null,d)))),u?3:1,0),m=i.start,f=i.end;r(t.tr.step(new wc(m-(u?3:1),f,m,f,p,1,!0)).scrollIntoView())}return!0}}a(Ab,"sinkListItem");import{v4 as q8}from"uuid";var Ib={backgroundColor:"transparent"},kc=$8.create({name:"listItem",content:"(paragraph | heading) block*",defining:!0,addOptions(){return{HTMLAttributes:{}}},onCreate(){je(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${q8()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},backgroundColor:{default:Ib.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})}}},parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",U8(this.options.HTMLAttributes,e),0]},addCommands(){return{splitListItem:e=>({state:t,dispatch:r})=>{let o=typeof e=="string"?t.schema.nodes[e]:e;return o?Nb(o)(t,r):!1},liftListItem:e=>({state:t,dispatch:r})=>{let o=typeof e=="string"?t.schema.nodes[e]:e;return o?Sb(o)(t,r):!1},sinkListItem:e=>({state:t,dispatch:r})=>{let o=typeof e=="string"?t.schema.nodes[e]:e;return o?Ab(o)(t,r):!1},wrapInList:(e,t)=>({state:r,dispatch:o})=>{let n=typeof e=="string"?r.schema.nodes[e]:e;return n?Mb(n,t)(r,o):!1}}},addKeyboardShortcuts(){return{"Shift-Enter":()=>this.editor.chain().setHardBreak().run()}}});import{mergeAttributes as Q8,ReactNodeViewRenderer as e4}from"@tiptap/react";import{TextSelection as t4,NodeSelection as r4,Plugin as o4,PluginKey as n4}from"prosemirror-state";var _o={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:"'"},Mc={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},j8=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Z8=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ct=0;ct<10;ct++)_o[48+ct]=_o[96+ct]=String(ct);var ct;for(ct=1;ct<=24;ct++)_o[ct+111]="F"+ct;var ct;for(ct=65;ct<=90;ct++)_o[ct]=String.fromCharCode(ct+32),Mc[ct]=String.fromCharCode(ct);var ct;for(Pc in _o)Mc.hasOwnProperty(Pc)||(Mc[Pc]=_o[Pc]);var Pc;function Lb(e){var t=j8&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Z8&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?Mc:_o)[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(Lb,"keyName");import{Plugin as K8}from"prosemirror-state";var J8=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function G8(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))J8?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(G8,"normalizeKeyName");function X8(e){let t=Object.create(null);for(let r in e)t[G8(r)]=e[r];return t}a(X8,"normalize");function Em(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(Em,"modifiers");function Rb(e){return new K8({props:{handleKeyDown:Y8(e)}})}a(Rb,"keymap");function Y8(e){let t=X8(e);return function(r,o){let n=Lb(o),i,s=t[Em(n,o)];if(s&&s(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let l=t[Em(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=_o[o.keyCode])&&i!=n){let l=t[Em(i,o)];if(l&&l(r.state,r.dispatch,r))return!0}}return!1}}a(Y8,"keydownHandler");import{v4 as i4}from"uuid";var wm=Bi.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){je(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-${i4()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:Ce.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):Ce.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:Ce.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):Ce.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:Ce.textAlign,parseHTML:e=>e.style.textAlign||Ce.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:Ce.backgroundColor,parseHTML:e=>e.style.backgroundColor||Ce.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:Ce.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):Ce.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:Ce.borderColor,parseHTML:e=>e.style.borderColor||Ce.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",Q8(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return e4(yl)},addProseMirrorPlugins(){return[Rb({"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(t4.create(t.doc,i,s)),!0}return!1}}),new o4({key:new n4("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;for(let u=s.depth;u>=0;u--)if(s.node(u).type.name==="listItem")return!1;let 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)=>{if(t.state.selection instanceof r4)return!1;let{empty:o,$anchor:n,$head:i}=t.state.selection;for(let m=n.depth;m>=0;m--)if(n.node(m).type.name==="listItem")return!1;let 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;if(o&&p&&d.type.spec.atom){let m=r?n.pos-d.nodeSize:n.pos;return t.chain().deleteRange({from:m,to:m+d.nodeSize}).run(),!0}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{$from:o}=t.state.selection;for(let l=o.depth;l>=0;l--)if(o.node(l).type.name==="listItem")return!1;let{state:n,dispatch:i}=t.view,{tr:s}=n;return s.replaceSelectionWith(n.schema.nodes.hardBreak.create()).scrollIntoView(),i(s),!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:({editor:t})=>!t.isActive("listItem"),"Shift-Tab":({editor:t})=>!t.isActive("listItem")}},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setTextAlign:t=>({chain:r})=>r().updateAttributes(this.name,{textAlign:t}).run()}}});import{Extension as a4}from"@tiptap/core";import{Plugin as s4,PluginKey as l4}from"@tiptap/pm/state";var c4=new l4("selection"),km=a4.create({name:"selection",addOptions(){return{HTMLAttributes:{},setSelectedNode:()=>{},shouldHandleClick:()=>!0}},addGlobalAttributes(){return[{types:["paragraph","heading","button","spacer","divider","imageBlock","blockquote","customCode","column","list"],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){t.setMeta("addToHistory",!1);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));try{m?t.setNodeAttribute(c,"isSelected",!0):t.setNodeAttribute(c,"isSelected",!1)}catch{}}return!0})}return!0}}},addProseMirrorPlugins(){return[new s4({key:c4,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(".node-list")||n.closest('[data-cypress="draggable-handle"]')||n.closest('button[class*="courier-cursor-grab"]'))return!1;try{let c=window.getSelection();if(c&&c.rangeCount>0){let d=c.getRangeAt(0).startContainer.parentElement;if(d&&(["P","H1","H2","H3"].includes(d.tagName)||["P","H1","H2","H3"].some(p=>d.closest(p)))){let p=e.posAtDOM(d,0);if(p<0||p>o.doc.content.size)return!1;let m=o.doc.resolve(p),f=m.node();if(f&&["paragraph","heading"].includes(f.type.name)){let v=f;for(let h=m.depth;h>=0;h--){let y=m.node(h);if(y.type.name==="list"){v=y;break}}return this.options.setSelectedNode(v),this.editor.commands.updateSelectionState(v),!0}}}}catch{return!1}let i=e.posAtDOM(n,0),s=o.doc.resolve(i),l=s.node();if(i<0||i>o.doc.content.size)return!1;if(l&&["paragraph","heading"].includes(l.type.name))try{let c=l;for(let u=s.depth;u>=0;u--){let d=s.node(u);if(d.type.name==="list"){c=d;break}}return this.options.setSelectedNode(c),this.editor.commands.updateSelectionState(c),!0}catch{return!1}return!1}}})]}});var tn=a(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),st=a(e=>{let t=tn(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");import{GripVertical as u4}from"lucide-react";import{forwardRef as d4}from"react";import{jsx as _b}from"react/jsx-runtime";var Wb=d4((e,t)=>_b("button",{...e,ref:t,"data-cypress":"draggable-handle","data-drag-handle":!0,className:R("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:_b(u4,{strokeWidth:1,className:"courier-w-5 courier-stroke-neutral-400 courier-fill-neutral-400 courier-pointer-events-none"})}));import{useAtomValue as m4}from"jotai";import{jsx as Pm}from"react/jsx-runtime";var zb={text:"Text",heading:"Heading",spacer:"Spacer",divider:"Divider",button:"Button",image:"Image",list:"List",customCode:"Custom code",column:"Column layout",blockquote:"Blockquote"},p4=a(e=>e.includes(":"),"isPresetType"),f4=a(e=>{let t=e.split(":");return t.length===2?{blockType:t[0],presetKey:t[1]}:null},"parsePresetType"),Nc=a(({type:e})=>{let t=m4(Jo),r=a(o=>{if(!o)return"Drop here";if(p4(o)){let n=f4(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 zb[i]||"Drop here"}return zb[o]||"Drop here"},"getPlaceholderLabel");return Pm("div",{className:"courier-flex courier-w-full courier-pointer-events-none",children:Pm("div",{className:R("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:Pm("div",{className:"courier-text-accent-foreground dark:courier-text-accent",children:r(e)})})})},"DropIndicatorPlaceholder");import{Fragment as x4,jsx as fr,jsxs as Sc}from"react/jsx-runtime";function v4(){let[e,t]=Ac(!1);return Mm(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}a(v4,"useMountStatus");var Ct=a(({children:e,id:t,className:r,editor:o,getPos:n,disableDropTarget:i=!1,...s})=>{let l=gn(null),c=gn(null),u=gn(null),[d,p]=Ac(!1),[m,f]=Ac(null),[v,h]=Ac(null),y=gn(null),C=gn(!1),T=gn(null),E=gn(null),b=gn(null),g=v4(),x=d&&!g,k=ni(()=>{if(!o||!t)return null;let S=null;return o.state.doc.descendants((w,M,L)=>{var N;if(((N=w.attrs)==null?void 0:N.id)===t){let I=0;return L&&L.content.forEach((D,V,W)=>{D===w&&(I=W)}),S={node:w,pos:M,parent:L,index:I},!1}return!0}),S},[t,o]),P=ni(()=>{if(!o)return!1;let S=k();return!S||!S.parent?!1:S.index===S.parent.childCount-1},[o,k]);return Mm(()=>{let S=l.current,w=c.current;if(!S)return;let M=S.getRootNode()instanceof ShadowRoot,L=ro(Wa({element:S,dragHandle:M?void 0:w||void 0,getInitialData:()=>{var W,j,O,$,J,q;let N=k(),I="text";if(N){let F=N.node;switch(F.type.name){case"heading":I="heading";break;case"paragraph":I="text";break;case"imageBlock":I="image";break;case"divider":I=(W=F.attrs)!=null&&W.spacer?"spacer":"divider";break;case"button":I="button";break;case"customCode":I="customCode";break;case"column":I="column";break;case"list":I="list";break}}let D=(N==null?void 0:N.parent)===o.state.doc,V=((j=N==null?void 0:N.parent)==null?void 0:j.type.name)==="columnCell";return{id:t,type:D?"editor":V?"column-cell-item":"nested-drag",index:(O=N==null?void 0:N.index)!=null?O:0,dragType:I,pos:N==null?void 0:N.pos,originalIndex:($=N==null?void 0:N.index)!=null?$:0,columnId:V?(J=N==null?void 0:N.parent)==null?void 0:J.attrs.columnId:void 0,cellIndex:V?(q=N==null?void 0:N.parent)==null?void 0:q.attrs.index:void 0}},onGenerateDragPreview:()=>{let N=S.querySelectorAll("[data-no-drag-preview]"),I=[];N.forEach((D,V)=>{let W=D;I[V]=W.style.display,W.style.display="none"}),requestAnimationFrame(()=>{N.forEach((D,V)=>{let W=D;W.style.display=I[V]})})},onDragStart:()=>{p(!0),document.body.style.cursor="grabbing";let N=a(I=>{E.current=I.clientY},"handleMouseMove");document.addEventListener("mousemove",N),b.current=()=>{document.removeEventListener("mousemove",N)},o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{p(!1),document.body.style.cursor="",b.current&&(b.current(),b.current=null),o&&o.setEditable(!0)}}),mr({element:S,getData:({input:N,element:I})=>{var q,F,A,H;let D=k(),V=(D==null?void 0:D.parent)===o.state.doc,W=((q=D==null?void 0:D.parent)==null?void 0:q.type.name)==="columnCell",j={id:t,type:V?"editor":W?"column-cell-item":"nested-drag",index:(F=D==null?void 0:D.index)!=null?F:0,pos:D==null?void 0:D.pos,nodeType:D==null?void 0:D.node.type.name,columnId:W?(A=D==null?void 0:D.parent)==null?void 0:A.attrs.columnId:void 0,cellIndex:W?(H=D==null?void 0:D.parent)==null?void 0:H.attrs.index:void 0};if(I.getAttribute("data-node-type")==="column"){let _=I.getBoundingClientRect(),B=N.clientY,U=30,Z=Math.abs(B-_.top),K=Math.abs(B-_.bottom);if(Z>U&&K>U)return{...j,disableDropIndicator:!0}}let $=I.closest('[data-column-cell="true"]');if(P()&&S){let _=S.getBoundingClientRect(),B=N.clientY,U=_.top+_.height/2;if(B>=U&&B>_.bottom)return{...j,[Symbol.for("closestEdge")]:"bottom"}}let J=P()?["top","bottom"]:["top"];return _g(j,{input:N,element:I,allowedEdges:J})},canDrop:({source:N})=>!(i||N.data.id===t),onDragEnter:({self:N,source:I,location:D})=>{var A,H,_,B,U;if(N.data.disableDropIndicator){f(null);return}if((S==null?void 0:S.closest('[data-type="list"]'))!==null){f(null);return}T.current&&(clearTimeout(T.current),T.current=null);let W=D.current.dropTargets;if(W.length>0&&W[0].element!==S){f(null),C.current=!1,y.current=null;return}let j=za(N.data),O=j,$=P(),J=(_=(H=(A=D==null?void 0:D.current)==null?void 0:A.input)==null?void 0:H.clientY)!=null?_:E.current;J!==null&&(E.current=J);let q=I.data;h(q.dragType||null),j==="bottom"&&$&&I.data.id===t&&(O=null);let F=I.data.type==="editor"||I.data.type==="column-cell-item";if($&&F)if(j==="top"){let Z=l.current;if(Z){let K=Z.getBoundingClientRect(),G=(B=J!=null?J:E.current)!=null?B:K.top+K.height/2,ve=K.top+K.height/2,Me=K.height,ke=Math.max(10,Math.min(30,Me*.3));G<ve-ke?(C.current=!1,O="top"):C.current?O="bottom":O="top"}else C.current=!1,O="top"}else C.current?O="bottom":j==="bottom"&&(C.current=!0,O="bottom");else $&&!F&&(C.current=!1);if(!C.current&&(I.data.type==="editor"||I.data.type==="column-cell-item")&&typeof I.data.index=="number"){let Z=I.data.index,K=k();((U=K==null?void 0:K.index)!=null?U:0)===Z+1&&j==="top"&&(O=null)}O!==y.current&&(y.current=O,f(O))},onDrag:({self:N,source:I,location:D})=>{var A,H,_,B,U;if(N.data.disableDropIndicator){f(null);return}if((S==null?void 0:S.closest('[data-type="list"]'))!==null){f(null);return}T.current&&(clearTimeout(T.current),T.current=null);let W=D.current.dropTargets;if(W.length>0&&W[0].element!==S){f(null);return}let j=(_=(H=(A=D==null?void 0:D.current)==null?void 0:A.input)==null?void 0:H.clientY)!=null?_:E.current;j!==null&&(E.current=j);let O=za(N.data),$=O,J=P(),q=I.data;h(q.dragType||null),O==="bottom"&&J&&I.data.id===t&&($=null);let F=I.data.type==="editor"||I.data.type==="column-cell-item";if(J&&F)if(O==="top"){let Z=l.current;if(Z){let K=Z.getBoundingClientRect(),G=(B=j!=null?j:E.current)!=null?B:K.top+K.height/2,ve=K.top+K.height/2,Me=K.height,ke=Math.max(10,Math.min(30,Me*.3));G<ve-ke?(C.current=!1,$="top"):C.current?$="bottom":$="top"}else C.current=!1,$="top"}else C.current?$="bottom":O==="bottom"&&(C.current=!0,$="bottom");else J&&!F&&(C.current=!1);if(!C.current&&(I.data.type==="editor"||I.data.type==="column-cell-item")&&typeof I.data.index=="number"){let Z=I.data.index,K=k();((U=K==null?void 0:K.index)!=null?U:0)===Z+1&&O==="top"&&($=null)}$!==y.current&&(y.current=$,f($))},onDragLeave:()=>{if(P()&&C.current){let N=S==null?void 0:S.getBoundingClientRect(),I=E.current;if(N&&I!==null&&I>=N.bottom-10)return;T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{C.current=!1,y.current=null,f(null),h(null),T.current=null},150)}else T.current&&(clearTimeout(T.current),T.current=null),C.current=!1,y.current=null,f(null),h(null)},onDrop:()=>{T.current&&(clearTimeout(T.current),T.current=null),C.current=!1,y.current=null,f(null),h(null)}}));return()=>{T.current&&(clearTimeout(T.current),T.current=null),L()}},[t,P,o,k,i]),fr(C4,{ref:l,id:t,fadeIn:x,className:r,dragging:d,closestEdge:m,dragType:v,handleRef:c,contentRef:u,editor:o,...s,children:e})},"SortableItemWrapper"),C4=b4(({children:e,className:t,dragOverlay:r,handleRef:o,contentRef:n,closestEdge:i,dragType:s,id:l,editor:c,fadeIn:u,dragging:d,...p},m)=>{Mm(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let f=h4(Te),v=a((g,x)=>{let k=null;return g.doc.descendants((P,S)=>{var w;return k!==null?!1:((w=P.attrs)==null?void 0:w.id)===x?(k=S,!1):!0}),k},"findNodePositionById"),h=ni(()=>{if(!c||!l)return{node:null,pos:null};let g=v(c.state,l);return g===null?{node:null,pos:null}:{node:c.state.doc.nodeAt(g),pos:g}},[c,l]),y=ni(()=>{c.commands.blur(),f(null)},[c,f]),C=ni(()=>{if(!(!c||!l))try{let{node:g,pos:x}=h();if(!g||x===null)return;let k=g==null?void 0:g.nodeSize;if(k==null)return;let P=c.state.doc.childCount===1;f(null),c.commands.updateSelectionState(null);let S=c.state.tr;S.delete(x,x+k),S.setMeta("addToHistory",!0),c.view.dispatch(S),P&&setTimeout(()=>{let w=c.state.doc.nodeAt(0);if(w&&w.type.name==="paragraph"&&!w.attrs.id){let M=`node-${y4()}`,L=c.state.tr;L.setNodeMarkup(0,void 0,{...w.attrs,id:M}),c.view.dispatch(L);let N=new CustomEvent("node-duplicated",{detail:{newNodeId:M}});document.dispatchEvent(N)}},50)}catch(g){console.error("Error deleting node:",g)}},[c,l,h,f]),T=ni(()=>{if(!(!c||!l))try{let{node:g,pos:x}=h();if(!g||x===null||g.type.name==="button")return;let k=g.type.name==="blockquote",P=g.type.name==="heading";!k&&!P&&y(),setTimeout(()=>{if(P){let w=x+1,M=g==null?void 0:g.nodeSize;if(M==null)return;let L=x+M-1;c.chain().setTextSelection({from:w,to:L}).unsetAllMarks().blur().run(),f(null),c.commands.updateSelectionState(null);return}let S=c.chain();if(S.setNodeSelection(x).unsetAllMarks(),k&&g.content&&g.content.firstChild?g.content.firstChild.type.name!=="paragraph"&&S.setParagraph():g.type.name!=="paragraph"&&!k&&S.setParagraph(),S.run(),k){let w=h();w.node&&w.pos!==null&&(f(w.node),c.commands.updateSelectionState(w.node))}},100)}catch(g){console.error("Error removing formatting:",g)}},[c,l,h,y,f]),E=ni(()=>{if(!(!c||!l))try{y(),setTimeout(()=>{let{node:g,pos:x}=h();if(!g||x===null)return;let k=g.type.name,P={...g.attrs};delete P.id;let S=g==null?void 0:g.nodeSize;if(S==null)return;let w=x+S;Ll(c,k,w,P,M=>f(M),g.content)},100)}catch(g){console.error("Error duplicating node:",g)}},[c,l,h,y,f]),{node:b}=h();return Sc(g4,{ref:m,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":l,className:R("courier-flex courier-flex-col courier-relative draggable-item",t),...p,children:[i==="top"&&fr(Nc,{type:s}),Sc("div",{className:"courier-flex courier-items-center courier-justify-center courier-gap-2 courier-pl-10",children:[fr(Wb,{ref:o,className:"courier-absolute courier-left-[-8px]",tabIndex:-1,"data-no-drag-preview":!0}),fr("div",{ref:n,className:"courier-flex-1 courier-grow draggable-content-wrapper",children:e}),Sc("div",{"data-no-drag-preview":!0,className:R("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:[(b==null?void 0:b.type.name)!=="imageBlock"&&(b==null?void 0:b.type.name)!=="divider"&&(b==null?void 0:b.type.name)!=="spacer"&&(b==null?void 0:b.type.name)!=="button"&&(b==null?void 0:b.type.name)!=="column"&&(b==null?void 0:b.type.name)!=="customCode"&&Sc(x4,{children:[fr("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:g=>{g.preventDefault(),g.stopPropagation()},onClick:g=>{g.stopPropagation(),T()},tabIndex:-1,children:fr(Hu,{color:"currentColor"})}),fr(pe,{className:"!courier-my-0"})]}),fr("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:g=>{g.preventDefault(),g.stopPropagation()},onClick:g=>{g.stopPropagation(),E()},tabIndex:-1,children:fr(Su,{color:"currentColor"})}),fr(pe,{className:"!courier-my-0"}),fr("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:g=>{g.preventDefault(),g.stopPropagation()},onClick:g=>{g.stopPropagation(),C()},tabIndex:-1,children:fr(Sa,{color:"currentColor"})})]})]}),i==="bottom"&&fr(Nc,{type:s})]})});import{jsx as go}from"react/jsx-runtime";var M4=a(({alignment:e,backgroundColor:t,textColor:r,borderRadius:o,paddingVertical:n,paddingHorizontal:i,children:s,isPreviewMode:l,link:c})=>{let u={backgroundColor:t,color:r,borderRadius:`${o}px`,caretColor:r,padding:`${Number(n)}px ${Number(i)}px`},d=go("div",{className:R("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:u,children:s});return l&&c?go("div",{className:"courier-w-full node-element",children:go("div",{className:"courier-flex",children:go("a",{href:c,className:R("button-link-wrapper courier-no-underline",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[e]),target:"_blank",rel:"noopener noreferrer",children:go("div",{className:"courier-inline-flex courier-justify-center courier-text-sm courier-leading-tight !courier-my-1",style:u,children:s})})})}):go("div",{className:"courier-w-full node-element",children:go("div",{className:"courier-flex",children:d})})},"ButtonComponent"),Ub=a(e=>{let t=E4(Ve),[r,o]=P4(e.editor.isEditable);k4(()=>{let l=a(()=>{let c=e.editor.isEditable;o(u=>u!==c?c:u)},"updateEditable");return e.editor.on("transaction",l),e.editor.on("update",l),l(),()=>{e.editor.off("transaction",l),e.editor.off("update",l)}},[e.editor,e.node.attrs.link]);let n=w4(()=>{if(!r)return;let l=st(e);if(l){let c=l.attrs.id;e.editor.state.doc.descendants(u=>u.type.name==="button"&&u.attrs.id===c?(t(u),!1):!0)}},[e,t,r]),i=!r,s=e.node.attrs.link;return go(Ct,{id:e.node.attrs.id,className:R(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"button",children:go(M4,{...e.node.attrs,isPreviewMode:i,link:s,children:go(T4,{as:"span"})})})},"ButtonComponentNode");import{v4 as R4}from"uuid";var $b="__COURIER_VAR_OPEN__",qb="__COURIER_VAR_CLOSE__",B4=a(e=>e==null?void 0:e.replace(/\{\{/g,$b).replace(/\}\}/g,qb),"encodeVars"),D4=a(e=>e==null?void 0:e.replace(new RegExp($b,"g"),"{{").replace(new RegExp(qb,"g"),"}}"),"decodeVars"),Se={label:"Enter text",link:"",alignment:"center",backgroundColor:"#0085FF",borderRadius:0,paddingVertical:8,paddingHorizontal:16,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1,textColor:"#ffffff",borderColor:"transparent"},cc=S4.create({name:"button",group:"block",content:"text*",marks:"",selectable:!1,isolating:!0,onCreate(){je(this.editor,this.name)},addAttributes(){return{label:{default:Se.label,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},link:{default:Se.link,parseHTML:e=>D4(e.getAttribute("data-link")),renderHTML:e=>({"data-link":B4(e.link)})},alignment:{default:Se.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},backgroundColor:{default:Se.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},textColor:{default:Se.textColor,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.textColor})},borderRadius:{default:Se.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:Se.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},paddingVertical:{default:Se.paddingVertical,parseHTML:e=>{let t=e.getAttribute("data-padding-vertical");if(t!=null)return Number(t);let r=e.getAttribute("data-padding");return r!=null?Number(r)+2:Se.paddingVertical},renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:Se.paddingHorizontal,parseHTML:e=>{let t=e.getAttribute("data-padding-horizontal");if(t!=null)return Number(t);let r=e.getAttribute("data-padding");return r!=null?Number(r)+10:Se.paddingHorizontal},renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},fontWeight:{default:Se.fontWeight,parseHTML:e=>e.getAttribute("data-font-weight"),renderHTML:e=>({"data-font-weight":e.fontWeight})},fontStyle:{default:Se.fontStyle,parseHTML:e=>e.getAttribute("data-font-style"),renderHTML:e=>({"data-font-style":e.fontStyle})},isUnderline:{default:Se.isUnderline,parseHTML:e=>e.getAttribute("data-is-underline"),renderHTML:e=>({"data-is-underline":e.isUnderline})},isStrike:{default:Se.isStrike,parseHTML:e=>e.getAttribute("data-is-strike"),renderHTML:e=>({"data-is-strike":e.isStrike})},id:{default:()=>`node-${R4()}`,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",N4(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return A4(Ub)},addKeyboardShortcuts(){let e=a(t=>{let{$from:r}=t.state.selection;for(let o=r.depth;o>=0;o--)if(r.node(o).type.name==="button")return!0;return!1},"isInsideButton");return{"Mod-a":({editor:t})=>{let{$from:r}=t.state.selection;for(let o=r.depth;o>=0;o--)if(r.node(o).type.name==="button"){let i=r.start(o),s=r.end(o);return t.commands.setTextSelection({from:i,to:s}),!0}return!1},"Mod-b":({editor:t})=>e(t),"Mod-i":({editor:t})=>e(t),"Mod-u":({editor:t})=>e(t),"Mod-Shift-s":({editor:t})=>e(t)}},addCommands(){return{setButton:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e,content:[{type:"text",text:e.label||Se.label}]}).run()}},addProseMirrorPlugins(){return[new I4({key:new L4("syncButtonContentToLabel"),appendTransaction:(e,t,r)=>e.some(n=>n.docChanged)?qh(r):null})]}});var jb={h1:1,h2:2,h3:3,subtext:3},Zb=a(e=>e==="full"?"justify":e||"left","elementalAlignToTiptap");function Kb(e){let t=[];for(let r of e)r.type==="string"?V4(r,t):r.type==="link"&&H4(r,t);return t}a(Kb,"convertElementsArrayToTiptapNodes");function Jb(e){let t=[];return e.bold&&t.push({type:"bold"}),e.italic&&t.push({type:"italic"}),e.strikethrough&&t.push({type:"strike"}),e.underline&&t.push({type:"underline"}),e.color&&t.push({type:"textColor",attrs:{color:e.color}}),t}a(Jb,"buildMarksFromFlags");function V4(e,t){let r="content"in e?e.content:"";if(!r)return;let o=Jb(e),n=r.split(`
198
+ `);for(let i=0;i<n.length;i++){let s=n[i];s&&Gb(s,o,t),i<n.length-1&&t.push({type:"hardBreak"})}}a(V4,"convertStringElementToTiptapNodes");function H4(e,t){if(e.type!=="link")return;let r=e.content||"";if(!r)return;let o=Jb(e);o.push({type:"link",attrs:{href:e.href}}),Gb(r,o,t)}a(H4,"convertLinkElementToTiptapNodes");function Gb(e,t,r){if(!e)return;let o=/\{\{([^}]*)\}\}/g,n,i=0;for(o.lastIndex=0;(n=o.exec(e))!==null;){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=s===""||vt(s),c=t.some(u=>u.type==="link");r.push({type:"variable",attrs:{id:s,isInvalid:!l,...c&&{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(Gb,"parseTextSegmentWithVariables");function Xi(e){let t=[],r=e.replace(/\n$/,"").split(`
199
+ `);for(let o=0;o<r.length;o++)F4(r[o],t),o<r.length-1&&t.push({type:"hardBreak"});return t}a(Xi,"parseMDContent");function F4(e,t){Nm(e,t)}a(F4,"parseTextLine");function Nm(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===""||vt(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&&Sm(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=[];Nm(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=[];Nm(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&&Sm(d,[],s)}t.push(...s)}a(Nm,"processMarkdownFormatting");function Sm(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===""||vt(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(Sm,"parseTextWithVariables");function He(e,t){var d,p,m,f,v,h,y,C,T,E,b;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 x=g;if(n){if(x.channel===n){i=x;break}}else{i=x;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||`
200
+ `,text_style:"h2"}:g))):o=[{type:"text",content:`
201
+ `}],!o||o.length===0)return r;let l=a(g=>{var x,k,P,S,w,M,L,N,I,D,V,W,j,O,$,J;if(g.type==="meta")return[];switch(g.type){case"text":if("content"in g){let q=g.text_style&&(x=jb[g.text_style])!=null?x:null,F={};if(g.padding){let[_,B]=g.padding.replace(/px/g,"").split(" "),U=parseInt(_),Z=parseInt(B);!isNaN(U)&&!isNaN(Z)&&(F={paddingVertical:U,paddingHorizontal:Z})}let A={};if(g.border_size||(k=g.border)!=null&&k.enabled||(P=g.border)!=null&&P.size){let _=g.border_size||((S=g.border)==null?void 0:S.size),B=g.border_color||((w=g.border)==null?void 0:w.color);A={..._&&{borderWidth:parseInt(_)},...B&&{borderColor:B}}}let H=g.content.trim()?Xi(g.content):[];return[{type:q?"heading":"paragraph",attrs:{textAlign:Zb(g.align),level:q,id:`node-${qe()}`,...F,...A,...g.background_color&&{backgroundColor:g.background_color},...g.locales&&{locales:g.locales}},content:H}]}else if("elements"in g){let q=g.text_style&&(M=jb[g.text_style])!=null?M:null,F={};if(g.padding){let[_,B]=g.padding.replace(/px/g,"").split(" "),U=parseInt(_),Z=parseInt(B);!isNaN(U)&&!isNaN(Z)&&(F={paddingVertical:U,paddingHorizontal:Z})}let A={};if(g.border_size||(L=g.border)!=null&&L.enabled||(N=g.border)!=null&&N.size){let _=g.border_size||((I=g.border)==null?void 0:I.size),B=g.border_color||((D=g.border)==null?void 0:D.color);A={..._&&{borderWidth:parseInt(_)},...B&&{borderColor:B}}}let H=Kb(g.elements);return[{type:q?"heading":"paragraph",attrs:{textAlign:Zb(g.align),level:q,id:`node-${qe()}`,...F,...A,...g.background_color&&{backgroundColor:g.background_color},...g.locales&&{locales:g.locales}},content:H}]}return[];case"action":{let F=n==="inbox"?{backgroundColor:"#000000",textColor:"#ffffff",borderColor:"transparent",borderWidth:1,borderRadius:4}:{},A=g.content||Se.label,H=[];Sm(A,[],H),H.length===0&&H.push({type:"text",text:A||Se.label});let _=(W=g.border_radius)!=null?W:(V=g.border)==null?void 0:V.radius,B=(j=g.border)==null?void 0:j.color,U;return typeof _=="string"?U=parseInt(_):typeof _=="number"&&(U=_),[{type:"button",content:H,attrs:{label:A,link:g.href,alignment:g.align==="full"?"center":g.align||"center",style:g.style,id:`node-${qe()}`,...F,...g.background_color&&{backgroundColor:g.background_color},...g.color&&{textColor:g.color},...g.padding&&(()=>{let Z=g.padding.replace(/px/g,"").trim().split(/\s+/),K=parseInt(Z[0])||0,G=Z.length>1?parseInt(Z[1])||0:K;return{paddingVertical:Math.max(0,K),paddingHorizontal:Math.max(0,G)}})(),...U!==void 0&&{borderRadius:U},...B&&{borderColor:B},...g.locales&&{locales:g.locales}}}]}case"quote":{let q=a(_=>{let B=_.split(`
202
+ `).filter(ve=>ve.trim());if(B.length===0)return{isList:!1,isOrdered:!1};let U=/^•\s+/,Z=/^\d+\.\s+/,K=B.every(ve=>U.test(ve)),G=B.every(ve=>Z.test(ve));return{isList:K||G,isOrdered:G}},"isListContent"),F=a((_,B)=>{let U=_.split(`
203
+ `).filter(K=>K.trim()),Z=[];for(let K of U){let G=K.replace(/^(•|\d+\.)\s+/,"");Z.push({type:"listItem",attrs:{id:`node-${qe()}`},content:[{type:"paragraph",attrs:{id:`node-${qe()}`},content:Xi(G)}]})}return[{type:"list",attrs:{id:`node-${qe()}`,listType:B?"ordered":"unordered"},content:Z}]},"parseListContent"),A=q(g.content),H;if(A.isList)H=F(g.content,A.isOrdered);else{let _="paragraph",B;g.text_style==="h1"?(_="heading",B=1):g.text_style==="h2"?(_="heading",B=2):(g.text_style==="h3"||g.text_style==="subtext")&&(_="heading",B=3);let U={textAlign:g.align||"left",id:`node-${qe()}`};B!==void 0&&(U.level=B),H=[{type:_,attrs:U,content:Xi(g.content)}]}return[{type:"blockquote",attrs:{textAlign:g.align||"left",id:`node-${qe()}`,...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:H}]}case"image":{let q={};if(g.width){let H=g.width.endsWith("px"),_=g.width.endsWith("%"),B=parseInt(g.width.replace(/%|px/,""));if(H)if(g.image_natural_width&&g.image_natural_width>0){let U=Math.round(B/g.image_natural_width*100);q.width=Math.max(1,Math.min(100,U)),q.imageNaturalWidth=g.image_natural_width}else q.width=100;else q.width=Math.max(1,Math.min(100,B))}let F=g.border_size||((O=g.border)==null?void 0:O.size),A=g.border_color||(($=g.border)==null?void 0:$.color);return[{type:"imageBlock",attrs:{sourcePath:Gs(g.src)?"":g.src,id:`node-${qe()}`,...g.href&&{link:g.href},...g.align&&{alignment:g.align},...g.alt_text&&{alt:g.alt_text},...q,...F&&{borderWidth:parseInt(F),...A&&{borderColor:A}},...g.locales&&{locales:g.locales}}}]}case"divider":{let q=g.border_width||g.width;return[{type:"divider",attrs:{id:`node-${qe()}`,...g.color&&{color:g.color},...q&&{size:parseInt(q)},...g.padding&&{padding:parseInt(g.padding)},variant:g.color==="transparent"?"spacer":"divider"}}]}case"html":return[{type:"customCode",attrs:{id:`node-${qe()}`,code:g.content||"<!-- Add your HTML code here -->",...g.locales&&{locales:g.locales}}}];case"group":{let q=g.elements?g.elements.length:2,F=0,A=0;if(g.padding){let G=g.padding.split(" ");F=parseInt(G[0],10)||0,A=parseInt(G[1]||G[0],10)||0}let H=0,_=0,B="transparent";g.border&&(g.border.size&&(H=parseInt(g.border.size,10)||0),g.border.radius!==void 0&&(_=g.border.radius),g.border.color&&(B=g.border.color));let U=g.background_color||"transparent",Z=`node-${qe()}`,K=g.elements?g.elements.map((G,ve)=>{var Ie;if(G.type==="text"&&"content"in G&&((Ie=G.content)==null?void 0:Ie.trim())==="Drag and drop content blocks"&&G.align==="left")return{type:"columnCell",attrs:{index:ve,columnId:Z,isEditorMode:!1},content:[]};let ke;G.type==="group"&&G.elements?ke=G.elements.flatMap(l):ke=l(G);let Fe=ke.length>0?ke:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${qe()}`},content:[]}];return{type:"columnCell",attrs:{index:ve,columnId:Z,isEditorMode:ke.length>0},content:Fe}}):[{type:"columnCell",attrs:{index:0,columnId:Z,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${qe()}`},content:[]}]},{type:"columnCell",attrs:{index:1,columnId:Z,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${qe()}`},content:[]}]}];return[{type:"column",attrs:{id:Z,columnsCount:Math.min(Math.max(q,1),4),paddingVertical:F,paddingHorizontal:A,backgroundColor:U,borderWidth:H,borderRadius:_,borderColor:B,...g.locales&&{locales:g.locales}},content:[{type:"columnRow",content:K}]}]}case"list":{let q=((J=g.elements)==null?void 0:J.map(H=>{let _=[];if(H.elements&&Array.isArray(H.elements)){let B=[],U=a(()=>{B.length>0&&(_.push({type:"paragraph",attrs:{textAlign:"left",id:`node-${qe()}`},content:Kb(B)}),B=[])},"flushInline");for(let Z of H.elements){let K=Z;K.type==="string"||K.type==="text"||K.type==="link"||K.type==="img"?B.push(K):K.type==="list"&&(U(),_.push(...l(K)))}U()}else"content"in H&&typeof H.content=="string"&&(_=[{type:"paragraph",attrs:{textAlign:"left",id:`node-${qe()}`},content:Xi(H.content)}]);return _.length===0&&(_=[{type:"paragraph",attrs:{textAlign:"left",id:`node-${qe()}`},content:[]}]),{type:"listItem",attrs:{id:`node-${qe()}`},content:_}}))||[],F=0,A=0;if(g.padding){let H=g.padding.split(/\s+/).map(_=>parseInt(_,10)||0);H.length===1?(F=H[0],A=H[0]):H.length>=2&&(F=H[0],A=H[1])}return[{type:"list",attrs:{id:`node-${qe()}`,listType:g.list_type||"unordered",...F>0&&{paddingVertical:F},...A>0&&{paddingHorizontal:A}},content:q.length>0?q:[{type:"listItem",attrs:{id:`node-${qe()}`},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${qe()}`},content:[]}]}]}]}default:return[]}},"convertNode"),c=[],u=o.flatMap(l);for(let g=0;g<u.length;g++){let x=u[g],k=u[g+1];if(x.type==="button"&&(k==null?void 0:k.type)==="button"&&n==="inbox"){let P={type:"buttonRow",attrs:{id:`node-${qe()}`,button1Label:((d=x.attrs)==null?void 0:d.label)||"Button 1",button1Link:((p=x.attrs)==null?void 0:p.link)||"",button1BackgroundColor:((m=x.attrs)==null?void 0:m.backgroundColor)||"#000000",button1TextColor:((f=x.attrs)==null?void 0:f.textColor)||"#ffffff",...(v=x.attrs)!=null&&v.locales?{button1Locales:x.attrs.locales}:{},button2Label:((h=k.attrs)==null?void 0:h.label)||"Button 2",button2Link:((y=k.attrs)==null?void 0:y.link)||"",button2BackgroundColor:((C=k.attrs)==null?void 0:C.backgroundColor)||"#ffffff",button2TextColor:((T=k.attrs)==null?void 0:T.textColor)||"#000000",...(E=k.attrs)!=null&&E.locales?{button2Locales:k.attrs.locales}:{},padding:((b=x.attrs)==null?void 0:b.paddingVertical)||8}};c.push(P),g++}else c.push(x)}return{type:"doc",content:c}}a(He,"convertElementalToTiptap");function Xb(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===""||vt(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(Xb,"parseTextWithVariables");function ms(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===""||vt(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&&Xb(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=ms(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=ms(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&&Xb(u,[],i)}return i}a(ms,"processMarkdownFormatting");function O4(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:ms(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:ms(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:ms(o)})}return t}a(O4,"parseBlockContent");function Am(e){return{type:"doc",content:O4(e)}}a(Am,"convertMarkdownToTiptap");var _4={1:"h1",2:"h2",3:"h3"},W4=a(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),Yb=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(W4).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"),Im=a(e=>{var r;let t={};if(!e)return t;for(let o of e)switch(o.type){case"bold":t.bold=!0;break;case"italic":t.italic=!0;break;case"strike":t.strikethrough=!0;break;case"underline":t.underline=!0;break;case"textColor":(r=o.attrs)!=null&&r.color&&(t.color=o.attrs.color);break}return t},"getFormattingFlags"),z4=a((e,t)=>{var r,o,n,i,s,l,c,u,d,p;return((r=e.bold)!=null?r:void 0)===((o=t.bold)!=null?o:void 0)&&((n=e.italic)!=null?n:void 0)===((i=t.italic)!=null?i:void 0)&&((s=e.strikethrough)!=null?s:void 0)===((l=t.strikethrough)!=null?l:void 0)&&((c=e.underline)!=null?c:void 0)===((u=t.underline)!=null?u:void 0)&&((d=e.color)!=null?d:void 0)===((p=t.color)!=null?p:void 0)},"sameFlags"),U4=a((e,t)=>{if(!t)return;let r=Im(t);r.bold&&(e.bold=!0),r.italic&&(e.italic=!0),r.strikethrough&&(e.strikethrough=!0),r.underline&&(e.underline=!0),r.color&&(e.color=r.color)},"applyFormattingFlags"),Ic=a(e=>{var n,i,s;let t=[],r=null,o=a(()=>{r&&(t.push(r),r=null)},"flush");for(let l of e){if(l.type==="hardBreak"){r?r.content+=`
203
204
  `:r={type:"string",content:`
204
- `};continue}if(l.type==="variable"){o(),t.push({type:"string",content:`{{${(n=l.attrs)==null?void 0:n.id}}}`});continue}let c=(i=l.marks)==null?void 0:i.find(d=>d.type==="link");if(c){o();let d={type:"link",content:l.text||"",href:((s=c.attrs)==null?void 0:s.href)||""};_T(d,l.marks),t.push(d);continue}let u=kb(l.marks);r&&WT(r,u)?r.content+=l.text||"":(o(),r={type:"string",content:l.text||"",...u})}return o(),t},"convertTiptapNodesToElements"),wb=a(e=>e==="justify"?"full":e||"left","tiptapAlignToElemental");function ve(e){let t=a(r=>{var o,n,i,s,l,c,u,d,m,p,g,v,b,y,C,x,h,f,E,T,w,P,N,k,S,B,M,I,D,V,_,W,F,L,$,A,H,O,j,Z,U,q,ne,X,le,ke,we,De,rt,Ve,Je,Tt,ut,Ke,Ge,Et,me,Pe,K,Xe,at,Ft,Hr,Fr,Or,dn,mn,z,G,se,Ee;switch(r.type){case"paragraph":{let J=r.content||[],ie=dm(J),ce={};(o=r.attrs)!=null&&o.borderWidth&&(ce.border_size=`${r.attrs.borderWidth}px`),(n=r.attrs)!=null&&n.borderColor&&(ce.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&&(ce.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(l=r.attrs)!=null&&l.backgroundColor&&(ce.background_color=r.attrs.backgroundColor),ce.type="text",ce.align=wb((c=r.attrs)==null?void 0:c.textAlign),ce.elements=ie;let Ne=ce;return(u=r.attrs)!=null&&u.locales&&(Ne.locales=r.attrs.locales),[Ne]}case"heading":{let J=r.content||[],ie=dm(J),ce={};(d=r.attrs)!=null&&d.borderWidth&&(ce.border_size=`${r.attrs.borderWidth}px`),(m=r.attrs)!=null&&m.borderColor&&(ce.border_color=r.attrs.borderColor),ce.text_style=((p=r.attrs)==null?void 0:p.level)===1?"h1":"h2",((g=r.attrs)==null?void 0:g.paddingVertical)!==void 0&&((v=r.attrs)==null?void 0:v.paddingHorizontal)!==void 0&&(ce.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(b=r.attrs)!=null&&b.backgroundColor&&(ce.background_color=r.attrs.backgroundColor),ce.type="text",ce.align=wb((y=r.attrs)==null?void 0:y.textAlign),ce.elements=ie;let Ne=ce;return(C=r.attrs)!=null&&C.locales&&(Ne.locales=r.attrs.locales),[Ne]}case"blockquote":{let J="",ie,ce,Ne=a(ye=>{let Ie="";if(ye.content)for(let It of ye.content)It.type==="hardBreak"?Ie+=`
205
- `:Ie+=Eb(It);return Ie},"convertTextBlock"),Wr=a(ye=>{var mo;let Ie="",It=((mo=ye.attrs)==null?void 0:mo.listType)==="ordered",ai=1;if(ye.content){for(let zt of ye.content)if(zt.type==="listItem"&&zt.content){let pn=It?`${ai}. `:"\u2022 ";for(let da of zt.content)(da.type==="paragraph"||da.type==="heading")&&(Ie+=pn+Ne(da)+`
206
- `);ai++}}return Ie},"convertListToText");if(r.content)for(let ye of r.content){if(!ie){if(ye.type==="heading"){let Ie=(x=ye.attrs)==null?void 0:x.level;Ie===1?ie="h1":Ie===2?ie="h2":ie="subtext"}ce=(h=ye.attrs)==null?void 0:h.textAlign}ye.type==="list"?J+=Wr(ye):(ye.type==="paragraph"||ye.type==="heading")&&(J+=Ne(ye)+`
207
- `)}J=J.trim();let _e={type:"quote",content:J};return ce&&ce!=="left"&&(_e.align=ce),(f=r.attrs)!=null&&f.borderColor&&(_e.border_color=r.attrs.borderColor),((E=r.attrs)==null?void 0:E.borderLeftWidth)!==void 0&&(_e.border_left_width=r.attrs.borderLeftWidth),((T=r.attrs)==null?void 0:T.paddingHorizontal)!==void 0&&(_e.padding_horizontal=r.attrs.paddingHorizontal),((w=r.attrs)==null?void 0:w.paddingVertical)!==void 0&&(_e.padding_vertical=r.attrs.paddingVertical),(P=r.attrs)!=null&&P.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(_e.background_color=r.attrs.backgroundColor),ie&&(_e.text_style=ie),(N=r.attrs)!=null&&N.locales&&(_e.locales=r.attrs.locales),[_e]}case"imageBlock":{let J={},ie=(k=r.attrs)==null?void 0:k.width;ie&&(J.width=`${ie}%`),(S=r.attrs)!=null&&S.borderWidth&&(J.border_size=`${r.attrs.borderWidth}px`),(B=r.attrs)!=null&&B.borderColor&&(J.border_color=r.attrs.borderColor),J.type="image",J.src=((M=r.attrs)==null?void 0:M.sourcePath)||"",(I=r.attrs)!=null&&I.alignment&&(J.align=r.attrs.alignment),(D=r.attrs)!=null&&D.link&&(J.href=r.attrs.link),(V=r.attrs)!=null&&V.alt&&(J.alt_text=r.attrs.alt);let ce=J;return(_=r.attrs)!=null&&_.locales&&(ce.locales=r.attrs.locales),[ce]}case"divider":{let J={type:"divider"};return(W=r.attrs)!=null&&W.color&&(J.color=r.attrs.color),(F=r.attrs)!=null&&F.size&&(J.border_width=`${r.attrs.size}px`),(L=r.attrs)!=null&&L.padding&&(J.padding=`${r.attrs.padding}px 0px`),[J]}case"button":{let J=(A=($=r.attrs)==null?void 0:$.label)!=null?A:"";r.content&&r.content.length>0&&(J=r.content.map(Eb).join(""));let ie={type:"action",content:J,href:(O=(H=r.attrs)==null?void 0:H.link)!=null?O:"#"};if((j=r.attrs)!=null&&j.style&&(ie.style=r.attrs.style),ie.align=((Z=r.attrs)==null?void 0:Z.alignment)||"center",(U=r.attrs)!=null&&U.backgroundColor&&(ie.background_color=r.attrs.backgroundColor),((q=r.attrs)==null?void 0:q.padding)!==void 0){let ce=Number(r.attrs.padding);ie.padding=`${ce+2}px ${ce+10}px`}return((ne=r.attrs)==null?void 0:ne.borderRadius)!==void 0&&(ie.border_radius=`${r.attrs.borderRadius}px`),(X=r.attrs)!=null&&X.locales&&(ie.locales=r.attrs.locales),[ie]}case"buttonRow":{let J={type:"action",content:(ke=(le=r.attrs)==null?void 0:le.button1Label)!=null?ke:"Button 1",href:(De=(we=r.attrs)==null?void 0:we.button1Link)!=null?De:"#",align:"left"};(rt=r.attrs)!=null&&rt.button1BackgroundColor&&(J.background_color=r.attrs.button1BackgroundColor),(Ve=r.attrs)!=null&&Ve.button1TextColor&&(J.color=r.attrs.button1TextColor);let ie={type:"action",content:(Tt=(Je=r.attrs)==null?void 0:Je.button2Label)!=null?Tt:"Button 2",href:(Ke=(ut=r.attrs)==null?void 0:ut.button2Link)!=null?Ke:"#",align:"left"};return(Ge=r.attrs)!=null&&Ge.button2BackgroundColor&&(ie.background_color=r.attrs.button2BackgroundColor),(Et=r.attrs)!=null&&Et.button2TextColor&&(ie.color=r.attrs.button2TextColor),[J,ie]}case"customCode":{let J={type:"html",content:((me=r.attrs)==null?void 0:me.code)||"<!-- Add your HTML code here -->"};return(Pe=r.attrs)!=null&&Pe.locales&&(J.locales=r.attrs.locales),[J]}case"column":{let J=((K=r.attrs)==null?void 0:K.columnsCount)||2,ie=[],ce=(Xe=r.content)==null?void 0:Xe.find(ye=>ye.type==="columnRow");if(ce&&ce.content){for(let ye of ce.content)if(ye.type==="columnCell")if(ye.content&&ye.content.length>0){let Ie=ye.content.flatMap(t);Ie.length===0?ie.push({type:"text",content:`Drag and drop content blocks
208
- `,align:"left"}):Ie.length===1?ie.push(Ie[0]):ie.push({type:"group",elements:Ie})}else ie.push({type:"text",content:`Drag and drop content blocks
209
- `,align:"left"})}else for(let ye=0;ye<J;ye++)ie.push({type:"text",content:`Drag and drop content blocks
210
- `,align:"left"});let Ne={type:"group"};if((at=r.attrs)!=null&&at.borderWidth&&r.attrs.borderWidth>0){let ye={};(Ft=r.attrs)!=null&&Ft.borderColor&&(ye.color=r.attrs.borderColor),ye.enabled=!0,ye.size=`${r.attrs.borderWidth}px`,(Hr=r.attrs)!=null&&Hr.borderRadius&&(ye.radius=r.attrs.borderRadius),Ne.border=ye}let Wr=((Fr=r.attrs)==null?void 0:Fr.paddingVertical)||0,_e=((Or=r.attrs)==null?void 0:Or.paddingHorizontal)||0;return(Wr>0||_e>0)&&(Ne.padding=`${Wr}px ${_e}px`),(dn=r.attrs)!=null&&dn.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(Ne.background_color=r.attrs.backgroundColor),Ne.elements=ie,(mn=r.attrs)!=null&&mn.locales&&(Ne.locales=r.attrs.locales),[Ne]}case"list":{let J=((z=r.attrs)==null?void 0:z.listType)||"unordered",ie=[];if(r.content){for(let Ie of r.content)if(Ie.type==="listItem"){let It=[];if(Ie.content){for(let zt of Ie.content)if(zt.type==="paragraph"||zt.type==="heading"){let pn=zt.content||[],da=dm(pn);for(let Ty of da)It.push(Ty)}else if(zt.type==="list"){let pn=t(zt);pn.length>0&&pn[0].type==="list"&&It.push(pn[0])}}let ai={type:"string",content:""},mo={type:"list-item",elements:It.length>0?It:[ai]};(G=Ie.attrs)!=null&&G.backgroundColor&&Ie.attrs.backgroundColor!=="transparent"&&(mo.background_color=Ie.attrs.backgroundColor),ie.push(mo)}}let Ne={type:"list-item",elements:[{type:"string",content:""}]},Wr={type:"list",list_type:J,elements:ie.length>0?ie:[Ne]},_e=((se=r.attrs)==null?void 0:se.paddingVertical)||0,ye=((Ee=r.attrs)==null?void 0:Ee.paddingHorizontal)||0;return(_e>0||ye>0)&&(Wr.padding=`${_e}px ${ye}px`),[Wr]}default:return r.content?r.content.flatMap(t):[]}},"convertNode");return e!=null&&e.content?e.content.flatMap(t):[]}a(ve,"convertTiptapToElemental");function mm(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!==`
211
- `&&("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=mm(o.elements);if(n)return n}}return r||t||""}a(mm,"getTitle");function pm(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 mm(r.elements)}return""}a(pm,"getTitleForChannel");function xt(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 m={};if(t.channel&&typeof t.channel=="object")for(let g in t.channel)g!=="type"&&g!=="elements"&&g!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,g)&&(m[g]=t.channel[g]);let p={type:"channel",channel:u.channel,...Object.fromEntries(Object.entries(u).filter(([g])=>!["type","channel","elements"].includes(g))),...m};if(t.elements!==void 0){let g=[],v=t.elements.find(y=>y.type==="meta");if(v)g.push(v);else{let y=(c=u.elements)==null?void 0:c.find(C=>C.type==="meta");y&&g.push(y)}let b=t.elements.filter(y=>y.type!=="meta");g.push(...b),p.elements=g}o.elements.push(p),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=[],m=t.elements.find(g=>g.type==="meta");m&&d.push(m);let p=t.elements.filter(g=>g.type!=="meta");d.push(...p),u.elements=d}o.elements.push(u)}return o}a(xt,"updateElemental");var UT=a(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),os=a(e=>{var t,r,o,n,i,s,l,c,u,d,m,p,g,v;switch(e.type){case"variable":return`{{${(t=e.attrs)==null?void 0:t.id}}}`;case"text":{let b=e.text||"";if((r=e.marks)!=null&&r.length){let C=e.marks.map(UT).filter(Boolean);b=C.join("")+b+C.reverse().join("")}let y=(o=e.marks)==null?void 0:o.find(C=>C.type==="link");return y&&(b=`[${b}](${(n=y.attrs)==null?void 0:n.href})`),b}case"hardBreak":return`
212
- `;case"paragraph":return(((i=e.content)==null?void 0:i.map(os).join(""))||"")+`
205
+ `};continue}if(l.type==="variable"){o();let d=Im(l.marks);t.push({type:"string",content:`{{${(n=l.attrs)==null?void 0:n.id}}}`,...d});continue}let c=(i=l.marks)==null?void 0:i.find(d=>d.type==="link");if(c){o();let d={type:"link",content:l.text||"",href:((s=c.attrs)==null?void 0:s.href)||""};U4(d,l.marks),t.push(d);continue}let u=Im(l.marks);r&&z4(r,u)?r.content+=l.text||"":(o(),r={type:"string",content:l.text||"",...u})}return o(),t},"convertTiptapNodesToElements"),Qb=a(e=>{let t={};for(let[r,o]of Object.entries(e))if(o.elements)t[r]={elements:o.elements};else if(o.content){let n=Xi(o.content);t[r]={elements:Ic(n)}}return t},"convertLocaleMarkdownToElements"),e5=a(e=>e==="justify"?"full":e||"left","tiptapAlignToElemental");function xe(e){let t=a(r=>{var o,n,i,s,l,c,u,d,p,m,f,v,h,y,C,T,E,b,g,x,k,P,S,w,M,L,N,I,D,V,W,j,O,$,J,q,F,A,H,_,B,U,Z,K,G,ve,Me,ke,Fe,Ie,Je,Ge,St,Re,it,gt,ut,ue,Y,Ne,dt,mt,Gr,Xr,Yr,Qr,wn,z,X,ae,we,be,Xe,ht,br,Ca,eo;switch(r.type){case"paragraph":{let de=r.content||[],me=Ic(de),fe={};(o=r.attrs)!=null&&o.borderWidth&&(fe.border_size=`${r.attrs.borderWidth}px`),(n=r.attrs)!=null&&n.borderColor&&(fe.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&&(fe.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(l=r.attrs)!=null&&l.backgroundColor&&(fe.background_color=r.attrs.backgroundColor),fe.type="text",fe.align=e5((c=r.attrs)==null?void 0:c.textAlign),fe.elements=me;let Ye=fe;return(u=r.attrs)!=null&&u.locales&&(Ye.locales=Qb(r.attrs.locales)),[Ye]}case"heading":{let de=r.content||[],me=Ic(de),fe={};(d=r.attrs)!=null&&d.borderWidth&&(fe.border_size=`${r.attrs.borderWidth}px`),(p=r.attrs)!=null&&p.borderColor&&(fe.border_color=r.attrs.borderColor),fe.text_style=(f=_4[(m=r.attrs)==null?void 0:m.level])!=null?f:"subtext",((v=r.attrs)==null?void 0:v.paddingVertical)!==void 0&&((h=r.attrs)==null?void 0:h.paddingHorizontal)!==void 0&&(fe.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(y=r.attrs)!=null&&y.backgroundColor&&(fe.background_color=r.attrs.backgroundColor),fe.type="text",fe.align=e5((C=r.attrs)==null?void 0:C.textAlign),fe.elements=me;let Ye=fe;return(T=r.attrs)!=null&&T.locales&&(Ye.locales=Qb(r.attrs.locales)),[Ye]}case"blockquote":{let de="",me,fe,Ye=a(Pe=>{let Qe="";if(Pe.content)for(let wo of Pe.content)wo.type==="hardBreak"?Qe+=`
206
+ `:Qe+=Yb(wo);return Qe},"convertTextBlock"),Sr=a(Pe=>{var xa;let Qe="",wo=((xa=Pe.attrs)==null?void 0:xa.listType)==="ordered",Hs=1;if(Pe.content){for(let ko of Pe.content)if(ko.type==="listItem"&&ko.content){let kn=wo?`${Hs}. `:"\u2022 ";for(let Ta of ko.content)(Ta.type==="paragraph"||Ta.type==="heading")&&(Qe+=kn+Ye(Ta)+`
207
+ `);Hs++}}return Qe},"convertListToText");if(r.content)for(let Pe of r.content){if(!me){if(Pe.type==="heading"){let Qe=(E=Pe.attrs)==null?void 0:E.level;Qe===1?me="h1":Qe===2?me="h2":me="h3"}fe=(b=Pe.attrs)==null?void 0:b.textAlign}Pe.type==="list"?de+=Sr(Pe):(Pe.type==="paragraph"||Pe.type==="heading")&&(de+=Ye(Pe)+`
208
+ `)}de=de.trim();let at={type:"quote",content:de};return fe&&fe!=="left"&&(at.align=fe),(g=r.attrs)!=null&&g.borderColor&&(at.border_color=r.attrs.borderColor),((x=r.attrs)==null?void 0:x.borderLeftWidth)!==void 0&&(at.border_left_width=r.attrs.borderLeftWidth),((k=r.attrs)==null?void 0:k.paddingHorizontal)!==void 0&&(at.padding_horizontal=r.attrs.paddingHorizontal),((P=r.attrs)==null?void 0:P.paddingVertical)!==void 0&&(at.padding_vertical=r.attrs.paddingVertical),(S=r.attrs)!=null&&S.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(at.background_color=r.attrs.backgroundColor),me&&(at.text_style=me),(w=r.attrs)!=null&&w.locales&&(at.locales=r.attrs.locales),[at]}case"imageBlock":{let de={},me=(M=r.attrs)==null?void 0:M.width;me&&(de.width=`${me}%`),(L=r.attrs)!=null&&L.borderWidth&&(de.border_size=`${r.attrs.borderWidth}px`),(N=r.attrs)!=null&&N.borderColor&&(de.border_color=r.attrs.borderColor),de.type="image",de.src=((I=r.attrs)==null?void 0:I.sourcePath)||"",(D=r.attrs)!=null&&D.alignment&&(de.align=r.attrs.alignment),(V=r.attrs)!=null&&V.link&&(de.href=r.attrs.link),(W=r.attrs)!=null&&W.alt&&(de.alt_text=r.attrs.alt);let fe=de;return(j=r.attrs)!=null&&j.locales&&(fe.locales=r.attrs.locales),[fe]}case"divider":{let de={type:"divider"};return(O=r.attrs)!=null&&O.color&&(de.color=r.attrs.color),($=r.attrs)!=null&&$.size&&(de.border_width=`${r.attrs.size}px`),(J=r.attrs)!=null&&J.padding&&(de.padding=`${r.attrs.padding}px 0px`),[de]}case"button":{let de=(F=(q=r.attrs)==null?void 0:q.label)!=null?F:"";r.content&&r.content.length>0&&(de=r.content.map(Yb).join(""));let me={type:"action",content:de,href:(H=(A=r.attrs)==null?void 0:A.link)!=null?H:"#"};if((_=r.attrs)!=null&&_.style&&(me.style=r.attrs.style),me.align=((B=r.attrs)==null?void 0:B.alignment)||"center",(U=r.attrs)!=null&&U.backgroundColor&&(me.background_color=r.attrs.backgroundColor),((Z=r.attrs)==null?void 0:Z.paddingVertical)!==void 0||((K=r.attrs)==null?void 0:K.paddingHorizontal)!==void 0){let fe=Number((G=r.attrs.paddingVertical)!=null?G:8),Ye=Number((ve=r.attrs.paddingHorizontal)!=null?ve:16);me.padding=`${fe}px ${Ye}px`}return((Me=r.attrs)==null?void 0:Me.borderRadius)!==void 0&&(me.border_radius=`${r.attrs.borderRadius}px`),(ke=r.attrs)!=null&&ke.locales&&(me.locales=r.attrs.locales),[me]}case"buttonRow":{let de={type:"action",content:(Ie=(Fe=r.attrs)==null?void 0:Fe.button1Label)!=null?Ie:"Button 1",href:(Ge=(Je=r.attrs)==null?void 0:Je.button1Link)!=null?Ge:"#",align:"left"};(St=r.attrs)!=null&&St.button1BackgroundColor&&(de.background_color=r.attrs.button1BackgroundColor),(Re=r.attrs)!=null&&Re.button1TextColor&&(de.color=r.attrs.button1TextColor),(it=r.attrs)!=null&&it.button1Locales&&(de.locales=r.attrs.button1Locales);let me={type:"action",content:(ut=(gt=r.attrs)==null?void 0:gt.button2Label)!=null?ut:"Button 2",href:(Y=(ue=r.attrs)==null?void 0:ue.button2Link)!=null?Y:"#",align:"left"};return(Ne=r.attrs)!=null&&Ne.button2BackgroundColor&&(me.background_color=r.attrs.button2BackgroundColor),(dt=r.attrs)!=null&&dt.button2TextColor&&(me.color=r.attrs.button2TextColor),(mt=r.attrs)!=null&&mt.button2Locales&&(me.locales=r.attrs.button2Locales),[de,me]}case"customCode":{let de={type:"html",content:((Gr=r.attrs)==null?void 0:Gr.code)||"<!-- Add your HTML code here -->"};return(Xr=r.attrs)!=null&&Xr.locales&&(de.locales=r.attrs.locales),[de]}case"column":{let de=((Yr=r.attrs)==null?void 0:Yr.columnsCount)||2,me=[],fe=(Qr=r.content)==null?void 0:Qr.find(Pe=>Pe.type==="columnRow");if(fe&&fe.content){for(let Pe of fe.content)if(Pe.type==="columnCell")if(Pe.content&&Pe.content.length>0){let Qe=Pe.content.flatMap(t);Qe.length===0?me.push({type:"text",content:`Drag and drop content blocks
209
+ `,align:"left"}):Qe.length===1?me.push(Qe[0]):me.push({type:"group",elements:Qe})}else me.push({type:"text",content:`Drag and drop content blocks
210
+ `,align:"left"})}else for(let Pe=0;Pe<de;Pe++)me.push({type:"text",content:`Drag and drop content blocks
211
+ `,align:"left"});let Ye={type:"group"};if((wn=r.attrs)!=null&&wn.borderWidth&&r.attrs.borderWidth>0){let Pe={};(z=r.attrs)!=null&&z.borderColor&&(Pe.color=r.attrs.borderColor),Pe.enabled=!0,Pe.size=`${r.attrs.borderWidth}px`,(X=r.attrs)!=null&&X.borderRadius&&(Pe.radius=r.attrs.borderRadius),Ye.border=Pe}let Sr=((ae=r.attrs)==null?void 0:ae.paddingVertical)||0,at=((we=r.attrs)==null?void 0:we.paddingHorizontal)||0;return(Sr>0||at>0)&&(Ye.padding=`${Sr}px ${at}px`),(be=r.attrs)!=null&&be.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(Ye.background_color=r.attrs.backgroundColor),Ye.elements=me,(Xe=r.attrs)!=null&&Xe.locales&&(Ye.locales=r.attrs.locales),[Ye]}case"list":{let de=((ht=r.attrs)==null?void 0:ht.listType)||"unordered",me=[];if(r.content){for(let Qe of r.content)if(Qe.type==="listItem"){let wo=[];if(Qe.content){for(let ko of Qe.content)if(ko.type==="paragraph"||ko.type==="heading"){let kn=ko.content||[],Ta=Ic(kn);for(let t2 of Ta)wo.push(t2)}else if(ko.type==="list"){let kn=t(ko);kn.length>0&&kn[0].type==="list"&&wo.push(kn[0])}}let Hs={type:"string",content:""},xa={type:"list-item",elements:wo.length>0?wo:[Hs]};(br=Qe.attrs)!=null&&br.backgroundColor&&Qe.attrs.backgroundColor!=="transparent"&&(xa.background_color=Qe.attrs.backgroundColor),me.push(xa)}}let Ye={type:"list-item",elements:[{type:"string",content:""}]},Sr={type:"list",list_type:de,elements:me.length>0?me:[Ye]},at=((Ca=r.attrs)==null?void 0:Ca.paddingVertical)||0,Pe=((eo=r.attrs)==null?void 0:eo.paddingHorizontal)||0;return(at>0||Pe>0)&&(Sr.padding=`${at}px ${Pe}px`),[Sr]}default:return r.content?r.content.flatMap(t):[]}},"convertNode");return e!=null&&e.content?e.content.flatMap(t):[]}a(xe,"convertTiptapToElemental");function Lm(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!==`
212
+ `&&("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=Lm(o.elements);if(n)return n}}return r||t||""}a(Lm,"getTitle");function Rm(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 Lm(r.elements)}return""}a(Rm,"getTitleForChannel");function Mt(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(C=>C.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(Mt,"updateElemental");var $4=a(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),ps=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 C=e.marks.map($4).filter(Boolean);h=C.join("")+h+C.reverse().join("")}let y=(o=e.marks)==null?void 0:o.find(C=>C.type==="link");return y&&(h=`[${h}](${(n=y.attrs)==null?void 0:n.href})`),h}case"hardBreak":return`
213
+ `;case"paragraph":return(((i=e.content)==null?void 0:i.map(ps).join(""))||"")+`
213
214
 
214
- `;case"heading":{let b=((s=e.attrs)==null?void 0:s.level)||1,y="#".repeat(b)+" ",C=((l=e.content)==null?void 0:l.map(os).join(""))||"";return y+C+`
215
+ `;case"heading":{let h=((s=e.attrs)==null?void 0:s.level)||1,y="#".repeat(h)+" ",C=((l=e.content)==null?void 0:l.map(ps).join(""))||"";return y+C+`
215
216
 
216
- `}case"blockquote":return(((c=e.content)==null?void 0:c.map(os).join(""))||"").split(`
217
+ `}case"blockquote":return(((c=e.content)==null?void 0:c.map(ps).join(""))||"").split(`
217
218
  `).map(y=>`> ${y}`).join(`
218
219
  `)+`
219
220
 
220
- `;case"imageBlock":{let b=((u=e.attrs)==null?void 0:u.alt)||"",y=((d=e.attrs)==null?void 0:d.sourcePath)||"",C=(m=e.attrs)==null?void 0:m.link,x=`![${b}](${y})`;return C?`[${x}](${C})
221
+ `;case"imageBlock":{let h=((u=e.attrs)==null?void 0:u.alt)||"",y=((d=e.attrs)==null?void 0:d.sourcePath)||"",C=(p=e.attrs)==null?void 0:p.link,T=`![${h}](${y})`;return C?`[${T}](${C})
221
222
 
222
- `:x+`
223
+ `:T+`
223
224
 
224
225
  `}case"divider":return`---
225
226
 
226
- `;case"button":{let b=((p=e.attrs)==null?void 0:p.label)||"",y=((g=e.attrs)==null?void 0:g.link)||"#";return`[${b}](${y})
227
+ `;case"button":{let h=((m=e.attrs)==null?void 0:m.label)||"",y=((f=e.attrs)==null?void 0:f.link)||"#";return`[${h}](${y})
227
228
 
228
- `}default:return((v=e.content)==null?void 0:v.map(os).join(""))||""}},"convertNodeToMarkdown");function yc(e){return e.content?e.content.map(os).join("").trim():""}a(yc,"convertTiptapToMarkdown");function R(...e){return zT($T(e))}a(R,"cn");import{Slot as jT}from"@radix-ui/react-slot";import{cva as qT}from"class-variance-authority";import{forwardRef as ZT}from"react";import{jsx as JT}from"react/jsx-runtime";var vc=qT("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"}]}),Me=ZT(({active:e,buttonSize:t="medium",disabled:r,variant:o="primary",className:n,asChild:i=!1,...s},l)=>JT(i?jT:"button",{ref:l,disabled:r,className:R(vc({variant:o,size:t,disabled:r,active:e}),n),...s}));Me.displayName="Button";import{forwardRef as KT}from"react";import{jsx as GT}from"react/jsx-runtime";var pe=KT((e,t)=>GT("hr",{...e,ref:t,className:R("courier-my-1 courier-border-border dark:courier-border-neutral-600 courier-w-full",e.className)}));pe.displayName="Divider";import{Component as XT}from"react";import{jsx as gm,jsxs as QT}from"react/jsx-runtime";var hm=class hm extends XT{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||gm(YT,{error:this.state.error}):this.props.children}};a(hm,"ErrorBoundary");var fm=hm,YT=a(({error:e})=>QT("div",{className:"courier-p-6 courier-border courier-border-red-200 courier-bg-red-50 courier-rounded-lg courier-text-center",children:[gm("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),gm("p",{className:"courier-text-red-600 courier-mb-4",children:"An unexpected error occurred in the editor. Please refresh the page or contact support if the problem persists."}),!1]}),"DefaultErrorFallback");import{Slot as o4}from"@radix-ui/react-slot";import*as Jt from"react";import{Controller as n4,FormProvider as i4,useFormContext as a4}from"react-hook-form";import*as bm from"@radix-ui/react-label";import{cva as e4}from"class-variance-authority";import*as Pb from"react";import{jsx as r4}from"react/jsx-runtime";var t4=e4("courier-text-sm courier-font-medium courier-leading-none peer-disabled:courier-cursor-not-allowed peer-disabled:courier-opacity-70"),ym=Pb.forwardRef(({className:e,...t},r)=>r4(bm.Root,{ref:r,className:R(t4(),e),...t}));ym.displayName=bm.Root.displayName;import{jsx as on}from"react/jsx-runtime";var He=i4,Mb=Jt.createContext({}),te=a(({...e})=>on(Mb.Provider,{value:{name:e.name},children:on(n4,{...e})}),"FormField"),Cc=a(()=>{let e=Jt.useContext(Mb),t=Jt.useContext(Nb),{getFieldState:r,formState:o}=a4(),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"),Nb=Jt.createContext({}),Q=Jt.forwardRef(({className:e,...t},r)=>{let o=Jt.useId();return on(Nb.Provider,{value:{id:o},children:on("div",{ref:r,className:R("courier-space-y-2",e),...t})})});Q.displayName="FormItem";var to=Jt.forwardRef(({className:e,...t},r)=>{let{error:o,formItemId:n}=Cc();return on(ym,{ref:r,className:R(o&&"courier-text-destructive",e),htmlFor:n,...t})});to.displayName="FormLabel";var ee=Jt.forwardRef(({...e},t)=>{let{error:r,formItemId:o,formDescriptionId:n,formMessageId:i}=Cc();return on(o4,{ref:t,id:o,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...e})});ee.displayName="FormControl";var s4=Jt.forwardRef(({className:e,...t},r)=>{let{formDescriptionId:o}=Cc();return on("p",{ref:r,id:o,className:R("courier-text-[0.8rem] courier-text-muted-foreground",e),...t})});s4.displayName="FormDescription";var re=Jt.forwardRef(({className:e,children:t,...r},o)=>{let{error:n,formMessageId:i}=Cc(),s=n?String(n==null?void 0:n.message):t;return s?on("p",{ref:o,id:i,className:R("courier-text-[0.8rem] courier-font-medium courier-text-destructive",e),...r,children:s}):null});re.displayName="FormMessage";import*as Oe from"@radix-ui/react-alert-dialog";import*as Jn from"react";import{useCallback as l4}from"react";import{jsx as oo,jsxs as m4}from"react/jsx-runtime";var Ab=Oe.Root,Sb=Oe.Trigger,c4=Oe.Portal,Ib=Jn.forwardRef(({className:e,...t},r)=>oo("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:oo(Oe.Overlay,{asChild:!0,className:R("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})}));Ib.displayName=Oe.Overlay.displayName;var vm=Jn.forwardRef(({className:e,...t},r)=>{let o=l4(()=>{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 m4(c4,{container:typeof window!="undefined"?o():void 0,children:[oo(Ib,{}),oo(Oe.Content,{ref:r,className:R("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})]})});vm.displayName=Oe.Content.displayName;var Cm=a(({className:e,...t})=>oo("div",{className:R("courier-flex courier-flex-col courier-space-y-2 courier-text-center sm:courier-text-left",e),...t}),"AlertDialogHeader");Cm.displayName="AlertDialogHeader";var xm=a(({className:e,...t})=>oo("div",{className:R("courier-flex courier-flex-col-reverse sm:courier-flex-row sm:courier-justify-end sm:courier-space-x-2",e),...t}),"AlertDialogFooter");xm.displayName="AlertDialogFooter";var u4=Jn.forwardRef(({className:e,...t},r)=>oo(Oe.Title,{ref:r,className:R("courier-text-lg courier-font-semibold",e),...t}));u4.displayName=Oe.Title.displayName;var d4=Jn.forwardRef(({className:e,...t},r)=>oo(Oe.Description,{ref:r,className:R("courier-text-sm courier-text-muted-foreground",e),...t}));d4.displayName=Oe.Description.displayName;var Tm=Jn.forwardRef(({className:e,...t},r)=>oo(Oe.Action,{ref:r,className:R(vc(),e),...t}));Tm.displayName=Oe.Action.displayName;var Em=Jn.forwardRef(({className:e,...t},r)=>oo(Oe.Cancel,{ref:r,className:R(vc({variant:"outline"}),"courier-mt-2 sm:courier-mt-0",e),...t}));Em.displayName=Oe.Cancel.displayName;import*as Lb from"react";import{jsx as wm,jsxs as p4}from"react/jsx-runtime";var be=Lb.forwardRef(({className:e,type:t,startAdornment:r,endAdornment:o,...n},i)=>p4("div",{className:"courier-relative courier-flex courier-w-full courier-items-center",children:[r&&wm("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),wm("input",{type:t,className:R("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&&wm("div",{className:"courier-absolute courier-right-2 courier-flex courier-items-center courier-pointer-events-none",children:o})]}));be.displayName="Input";import{forwardRef as b4,useRef as y4,useMemo as v4,useCallback as C4}from"react";import{useCallback as km,useEffect as Rb,useRef as xc,useState as Bb}from"react";import{CircleX as f4}from"lucide-react";import{jsx as no,jsxs as Db}from"react/jsx-runtime";var g4=a(e=>e==="transparent"||/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e),"isValidHex"),Vb=a(({color:e,onChange:t,className:r,presetColors:o,defaultValue:n="transparent"})=>{let[i,s]=Bb(()=>ns(e)),[l,c]=Bb(e),u=xc(null),d=xc(null),m=xc(null),p=xc(!1),g=e!==n,v=km(h=>{p.current=!0;let f=h4(h);c(f),t(f),p.current=!1},[t]),b=a(h=>f=>{m.current=h,y(f)},"handleMouseDown"),y=km(h=>{if(m.current){if(m.current==="gradient"&&u.current){let f=u.current.getBoundingClientRect(),E=Math.max(0,Math.min(1,(h.clientX-f.left)/f.width)),T=Math.max(0,Math.min(1,(h.clientY-f.top)/f.height)),w={...i,s:E*100,v:(1-T)*100};s(w),v(w)}else if(m.current==="hue"&&d.current){let f=d.current.getBoundingClientRect(),E=Math.max(0,Math.min(1,(h.clientX-f.left)/f.width)),T={...i,h:E*360};s(T),v(T)}}},[i,v]),C=km(()=>{m.current=null},[]);Rb(()=>{if(m.current)return window.addEventListener("mousemove",y),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",C)}},[y,C]),Rb(()=>{p.current||(s(ns(e)),c(e))},[e]);let x=a(h=>{let f=h.target.value;if(c(f),g4(f)){let E=ns(f);s(E),v(E)}},"handleInputChange");return Db("div",{className:R("w-full",r),children:[no("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:b("gradient"),children:no("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}%`}})}),no("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:b("hue"),children:no("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}%`}})}),Db("div",{className:"courier-mt-3 courier-relative courier-flex courier-items-center",children:[no(be,{value:l,onChange:x,placeholder:"#000000",className:"courier-flex-1"}),g&&no("button",{onClick:h=>{if(h.preventDefault(),n==="transparent"){t("transparent"),c("transparent"),s({h:0,s:0,v:0});return}let f=ns(n);s(f),v(f)},className:"courier-absolute courier-right-3 courier-flex courier-cursor-pointer courier-items-center courier-justify-center courier-transition-colors",children:no(f4,{size:14,strokeWidth:1.25})})]}),no(pe,{className:"courier-my-3"}),no("div",{className:"courier-flex courier-flex-wrap courier-gap-1",children:o.map(h=>no("button",{className:R("courier-h-6 courier-w-6 courier-rounded-md courier-border courier-border-input courier-shrink-0",h==="transparent"&&Pm),style:{backgroundColor:h==="transparent"?void 0:h},onClick:f=>{if(f.preventDefault(),h==="transparent"){t("transparent"),c("transparent"),s({h:0,s:0,v:0});return}let E=ns(h);s(E),v(E)}},h))})]})},"ColorPicker");function ns(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(ns,"hexToHsv");function h4({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(h4,"hsvToHex");import*as io from"@radix-ui/react-popover";import*as Fb from"react";import{jsx as Hb}from"react/jsx-runtime";var Ob=io.Root,Wb=io.Trigger;var Mm=Fb.forwardRef(({className:e,align:t="center",side:r="bottom",sideOffset:o=4,collisionPadding:n=10,avoidCollisions:i=!0,portalProps:s,...l},c)=>Hb(io.Portal,{...s,children:Hb(io.Content,{ref:c,side:r,align:t,sideOffset:o,collisionPadding:n,avoidCollisions:i,className:R("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})}));Mm.displayName=io.Content.displayName;import{jsx as is,jsxs as _b}from"react/jsx-runtime";var Pm="bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAwSDBWOEg4VjBaIiBmaWxsPSIjRDlEOUQ5Ii8+PHBhdGggZD0iTTE2IDhIOFYxNkgxNlY4WiIgZmlsbD0iI0Q5RDlEOSIvPjwvc3ZnPg==')]",x4=["#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#000000","#525252","#a3a3a3","#ffffff","transparent"],bt=b4(({className:e,value:t="",onChange:r,defaultValue:o,transparent:n=!0,presetColors:i=x4,...s},l)=>{let c=t!=="transparent",u=y4(null),d=v4(()=>n?i:i.filter(p=>p!=="transparent"),[i,n]),m=C4(()=>{var g;let p=(g=u.current)==null?void 0:g.parentElement;for(;p;){if(p.classList.contains("theme-container"))return p;p=p.parentElement}return document.body},[]);return _b(Ob,{children:[is(Wb,{asChild:!0,children:_b("div",{className:"courier-relative courier-flex courier-items-center",ref:u,children:[is("div",{className:R("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?"":Pm),style:{backgroundColor:c?t:void 0}}),is(be,{...s,ref:l,readOnly:!0,type:"text",value:t==="transparent"?"Transparent":t,className:R("courier-relative courier-cursor-pointer courier-pl-8",e)})]})}),is(Mm,{portalProps:{container:typeof window!="undefined"?m():void 0},className:"courier-w-[230px]",children:is(Vb,{color:t,onChange:r,presetColors:d,defaultValue:o})})]})});bt.displayName="InputColor";import*as Ub from"react";import*as Nm from"@radix-ui/react-separator";import{jsx as T4}from"react/jsx-runtime";var Am=Ub.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>T4(Nm.Root,{ref:n,decorative:r,orientation:t,className:R("courier-shrink-0 courier-bg-border",t==="horizontal"?"courier-h-[1px] courier-w-full":"courier-h-full courier-w-[1px]",e),...o}));Am.displayName=Nm.Root.displayName;import*as $b from"react";import*as No from"@radix-ui/react-slider";import{jsx as Sm,jsxs as E4}from"react/jsx-runtime";var Qd=$b.forwardRef(({className:e,...t},r)=>E4(No.Root,{ref:r,className:R("courier-relative courier-flex courier-w-full courier-touch-none courier-select-none courier-items-center",e),...t,children:[Sm(No.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:Sm(No.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),Sm(No.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"})]}));Qd.displayName=No.Root.displayName;import*as jb from"react";import*as as from"@radix-ui/react-switch";import{jsx as zb}from"react/jsx-runtime";var $i=jb.forwardRef(({className:e,...t},r)=>zb(as.Root,{className:R("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:zb(as.Thumb,{className:R("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")})}));$i.displayName=as.Root.displayName;import*as Tc from"react";import*as Lr from"@radix-ui/react-tabs";import{jsx as Im}from"react/jsx-runtime";var _i=Lr.Root,zn=Tc.forwardRef(({className:e,...t},r)=>Im(Lr.List,{ref:r,className:R("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}));zn.displayName=Lr.List.displayName;var ko=Tc.forwardRef(({className:e,...t},r)=>Im(Lr.Trigger,{ref:r,className:R("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}));ko.displayName=Lr.Trigger.displayName;var cc=Tc.forwardRef(({className:e,...t},r)=>Im(Lr.Content,{ref:r,className:R("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}));cc.displayName=Lr.Content.displayName;import*as zi from"react";import{jsx as w4}from"react/jsx-runtime";var Xd=zi.forwardRef(({className:e,autoResize:t=!1,...r},o)=>{let n=zi.useRef(null),i=a(s=>{n.current=s,typeof o=="function"?o(s):o&&(o.current=s)},"combinedRef");return zi.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]),w4("textarea",{className:R("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})});Xd.displayName="Textarea";import*as qb from"react";import*as Lm from"@radix-ui/react-toggle";import{cva as k4}from"class-variance-authority";import{jsx as P4}from"react/jsx-runtime";var Rm=k4("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"}}),Zb=qb.forwardRef(({className:e,variant:t,size:r,...o},n)=>P4(Lm.Root,{ref:n,className:R(Rm({variant:t,size:r,className:e})),...o}));Zb.displayName=Lm.Root.displayName;import*as ji from"@radix-ui/react-toggle-group";import*as Kn from"react";import{jsx as Bm}from"react/jsx-runtime";var Jb=Kn.createContext({size:"default",variant:"default"}),Ar=Kn.forwardRef(({className:e,variant:t,size:r,children:o,...n},i)=>Bm(ji.Root,{ref:i,className:R("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:Bm(Jb.Provider,{value:{variant:t,size:r},children:o})}));Ar.displayName=ji.Root.displayName;var Rt=Kn.forwardRef(({className:e,children:t,variant:r,size:o,...n},i)=>{let s=Kn.useContext(Jb);return Bm(ji.Item,{ref:i,className:R(Rm({variant:s.variant||r,size:s.size||o}),e),...n,children:t})});Rt.displayName=ji.Item.displayName;import{CircleCheck as M4}from"lucide-react";import{useEffect as N4,useState as A4,useRef as Kb}from"react";import{jsx as Dm,jsxs as Gb}from"react/jsx-runtime";var ss=a(({isError:e,isSaving:t,isLoading:r,renderIsSaving:o,renderIsError:n,renderSaved:i})=>{let[s,l]=A4(!1),c=Kb(t),u=Kb(null);return N4(()=>(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):Gb("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[Dm(Pn,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):Dm("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):Gb("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[Dm(M4,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Saved"]}):null},"Status");import{AlertDialogDescription as xw}from"@radix-ui/react-alert-dialog";import{useAtom as Tw,useAtomValue as Zc,useSetAtom as Ew}from"jotai";import{useCallback as Es,useEffect as ww,useRef as kw}from"react";import{useAtom as bw,useAtomValue as ty,useSetAtom as Ap}from"jotai";import{useCallback as ry,useEffect as Sp,useMemo as oy,useRef as yw,useState as vw}from"react";import{atom as Xb}from"jotai";var Rr=Xb(null),ao=Xb(null);import{forwardRef as S4}from"react";import{Toaster as I4}from"sonner";import{jsx as ls,jsxs as L4}from"react/jsx-runtime";var Kt=S4(({theme:e,children:t,isLoading:r,Header:o,colorScheme:n,className:i,...s},l)=>ls(G1,{theme:e,ref:l,colorScheme:n,className:i,children:L4("div",{...Object.fromEntries(Object.entries(s).filter(([c])=>c!=="variables"&&c!=="brandEditor")),className:"courier-main-layout",children:[o&&ls("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&&ls("div",{className:"courier-editor-loading",children:ls(Pn,{})}),ls(I4,{position:"top-center",expand:!0,visibleToasts:2,style:{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)"}}),t]})}));import{useAtom as Fm,useAtomValue as nn,useSetAtom as F4}from"jotai";import{forwardRef as O4,memo as W4,useCallback as Qb,useEffect as Ao,useMemo as e5,useRef as cs,useState as Om}from"react";import{v4 as Vm}from"uuid";import{useAtomValue as Ec,useSetAtom as Hm,useAtom as R4}from"jotai";import{useCallback as Gn,useRef as Yb,useState as wc,useEffect as B4}from"react";var qi=a(({items:e,setItems:t,editor:r})=>{let[o]=wc(null),[n,i]=wc(null),[s,l]=wc(null),[c]=wc("outer"),u=Yb([]),d=Yb([]),m=Ec(Ae),p=Hm(qt),[g,v]=R4(de),b=Hm(Ye),y=Ec(Wo),C=Ec(Ho),x=Ec(Is),h=Hm(Ce),f=r||m,E=Gn(()=>{if(!f)return;let B=f.getJSON(),M=ve(B),I=xt(g,{channel:y,elements:M});v(I),b(I)},[f,y,g,v,b]),T=Gn(()=>{f==null||f.commands.removeDragPlaceholder(),t(B=>({...B,Editor:B.Editor.filter(M=>!M.toString().includes("_temp"))}))},[f==null?void 0:f.commands,t]),w=Gn(B=>{try{let M=f==null?void 0:f.state.doc;if(!M||B===0)return 0;if(B>=M.childCount)return M.content.size;let I=0;for(let D=0;D<Math.min(B,M.childCount);D++){let V=M.child(D);I+=V.nodeSize}return I}catch(M){return console.error("Error calculating document position:",M),0}},[f==null?void 0:f.state.doc]),P=Gn(B=>{let M=B.includes(":"),I=B,D=null;if(M){let L=B.split(":");I=L[0],D=L[1]}let V={};switch(I){case"text":V=xe;break;case"heading":V={};break;case"image":V=st;break;case"button":V=Be;break;case"divider":V=ar;break;case"spacer":V=wi;break;case"customCode":V=bo;break;case"column":V=Pt;break;case"blockquote":V=zr;break;case"list":V=Po;break}let _=x[I];if(_&&(V={...V,..._}),M&&D){let L=C.find($=>$.type===I&&$.key===D);L!=null&&L.attributes&&(V={...V,...L.attributes})}let F={type:I==="text"?"paragraph":I==="image"?"imageBlock":I==="spacer"?"divider":I,attrs:{...V,id:Vm()}};if(I==="button"){let L=Be.label;if(M&&D){let $=C.find(A=>A.type===I&&A.key===D);$!=null&&$.label&&(L=$.label)}F.content=[{type:"text",text:L}]}return I==="list"&&(F.content=[{type:"listItem",attrs:{id:Vm()},content:[{type:"paragraph",attrs:{id:Vm()},content:[]}]}]),F},[x,C]),N=Gn((B,M)=>{if(!f)return;let{columnId:I,index:D,isEmpty:V}=M,_=null,W=0,F=-1;if(B.type==="sidebar"){if(!B.dragType)return;_=P(B.dragType)}else if(B.type==="editor"){if(f.state.doc.descendants((O,j)=>O.attrs.id===B.id?(F=j,_=O.toJSON(),W=O.nodeSize,!1):!0),F===-1){let O=e.Editor.findIndex(j=>j===B.id);if(O!==-1){F=w(O);let j=f.state.doc.nodeAt(F);j&&(_=j.toJSON(),W=j.nodeSize)}}if(F!==-1){let O=e.Editor.filter(j=>j!==B.id);O.length!==e.Editor.length&&t({...e,Editor:O})}}if(!_)return;let L=-1,$=null;if(f.state.doc.descendants((O,j)=>O.type.name==="column"&&O.attrs.id===I?(L=j,$=O,!1):!0),L===-1||!$)return;let A=$;F!==-1&&F<L&&(L-=W);let H=f.state.tr;if(F!==-1&&H.delete(F,F+W),V){let O=f.schema,j=Array.from({length:A.attrs.columnsCount},(U,q)=>O.nodes.columnCell.create({index:q,columnId:I,isEditorMode:!1},q===D?[O.nodeFromJSON(_)]:[])),Z=O.nodes.columnRow.create({},j);H.replaceWith(L+1,L+A.nodeSize-1,Z)}else{let O=L+1;A.content.forEach(j=>{if(j.type.name==="columnRow"){let Z=O+1;j.content.forEach((U,q,ne)=>{if(ne===D){let X=Z+U.nodeSize-1;H.insert(X,f.schema.nodeFromJSON(_))}Z+=U.nodeSize})}O+=j.nodeSize})}if(f.view.dispatch(H),B.type==="sidebar"&&_&&"attrs"in _&&_.attrs){let O=_.attrs.id,j=null;f.state.doc.descendants(U=>U.attrs.id===O?(j=U,!1):!0);let Z=j;Z&&h(Z)}E()},[f,e,t,w,P,E,h]),k=Gn(B=>{if(!f)return B;let M=f.state.doc.resolve(B);for(let I=M.depth;I>=0;I--){let D=M.node(I);if(D.type.name==="list")return M.before(I)+D.nodeSize}return B},[f]),S=Gn((B,M)=>{try{if(B.type==="sidebar"&&(M.type==="editor"||M.type==="column-cell-item"||M.type==="nested-drag")){let I=B.dragType;if(!I||!f)return;let D=M.insertPos;if(D===void 0)if(M.type==="editor"){let $=M.index+1;D=w($)}else{console.warn("Nested drop without position data");return}D=k(D);let V=P(I);f.commands.insertContentAt(D,V);let _=V.type;if(f.state.doc.resolve(D).depth===0){let $=f.state.doc.resolve(D).index(0),A=[...e.Editor];$<=A.length&&(A.splice($,0,V.attrs.id),t({...e,Editor:A}))}E();let F=f,L=D;setTimeout(()=>{if(!F||F.isDestroyed)return;let $=F.state.doc.nodeAt(L);$&&$.type.name===_&&(h($),(_==="paragraph"||_==="heading")&&(F.commands.setTextSelection(L+1),F.view.focus()))},100);return}if((B.type==="editor"||B.type==="column-cell-item"||B.type==="nested-drag")&&(M.type==="editor"||M.type==="column-cell-item"||M.type==="nested-drag")){if(!f)return;let I=-1,D=null;if(B.pos!==void 0&&(I=B.pos,D=f.state.doc.nodeAt(I)),(I===-1||!D)&&f.state.doc.descendants((F,L)=>F.attrs.id===B.id?(I=L,D=F,!1):!0),I===-1||!D){let F=e.Editor.findIndex(L=>L===B.id);F!==-1&&(I=w(F),D=f.state.doc.nodeAt(I))}if(!D||I===-1)return;let V=M.insertPos;if(V===void 0){let F;M.index===void 0?F=f.state.doc.childCount:M.index===-1?F=0:F=M.index+1,V=w(F)}if(V===void 0||(V=k(V),V>I&&V<I+D.nodeSize))return;if(V>I){let F=V-D.nodeSize;f.chain().deleteRange({from:I,to:I+D.nodeSize}).insertContentAt(F,D.toJSON()).run()}else f.chain().insertContentAt(V,D.toJSON()).deleteRange({from:I+D.nodeSize,to:I+D.nodeSize*2}).run();let _=e.Editor.includes(B.id);if(_){let F=e.Editor.filter(L=>L!==B.id);t({...e,Editor:F})}let W=f.state.doc.resolve(V).depth===0;E()}}catch(I){console.error("[Pragmatic DnD] Error in handleDrop:",I)}},[e,f,t,w,E,P,k,h]);return B4(()=>Vu({onDragStart:({source:B})=>{let M=B.data;p(!0),l(M.id),M.dragType&&i(M.dragType);let I=f==null?void 0:f.view.dom.querySelectorAll('[data-node-type="column"]');I&&(u.current=Array.from(I).map(V=>V.getBoundingClientRect()));let D=f==null?void 0:f.view.dom.querySelectorAll("[data-node-view-wrapper]");if(D){let V=new Set,_=Array.from(D).filter(W=>{let F=W,L=F.parentElement;if(L!=null&&L.hasAttribute("data-column-cell"))return!1;let $=F.getBoundingClientRect(),A=$.top+$.height/2;return V.has(Math.round(A))?!1:(V.add(Math.round(A)),!0)});d.current=_.map(W=>W.getBoundingClientRect())}},onDrop:({source:B,location:M})=>{let I=B.data,D=M.current.dropTargets[0];if(!D){T(),p(!1),l(null),i(null);return}let V=D.data;if(V.type==="column-cell"){N(I,V),p(!1),l(null),i(null),T();return}let _=V,W=Ia(D.data);if(_.pos!==void 0&&W&&f){let F=f.state.doc.nodeAt(_.pos);F&&(W==="top"?_.insertPos=_.pos:W==="bottom"&&(_.insertPos=_.pos+F.nodeSize))}if(_.insertPos===void 0&&W&&_.index!==void 0){let F=W==="top"?_.index-1:_.index;_={..._,index:F}}else if(_.index===void 0&&_.insertPos===void 0){let L=M.current.input.clientY;if(d.current.length>0){let $=0,A=1/0;d.current.forEach((U,q)=>{let ne=U.top+U.height/2,X=Math.abs(L-ne);X<A&&(A=X,$=q)});let H=d.current[$],O=H.top+H.height/2,Z=L>=O?$:$-1;_={..._,index:Z,fromCoordinates:!0}}else _={..._,index:(f==null?void 0:f.state.doc.childCount)||0}}S(I,_),p(!1),l(null),i(null),T()}}),[f,p,T,l,i,S,N]),{activeId:s,activeDragType:n,dndMode:c,lastPlaceholderIndex:o,cleanupPlaceholder:T}},"usePragmaticDnd");import{useCallback as D4,useEffect as V4}from"react";import{useAtomValue as H4}from"jotai";var kc=a(({setItems:e,rafId:t,editor:r})=>{let o=H4(Ae),n=r||o,i=D4(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(m=>{let p=m,g=p.dataset.id;if(g){let v=p.parentElement,b=!1;for(;v&&v!==c;){if(v.hasAttribute("data-column-cell")){b=!0;break}v=v.parentElement}b||d.push(g)}}),e(m=>({Editor:d,Sidebar:m.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(m=>{let p=m,g=p.dataset.id;if(g){let v=p.parentElement,b=!1;for(;v&&v!==c;){if(v.hasAttribute("data-column-cell")){b=!0;break}v=v.parentElement}b||d.push(g)}}),e(m=>({Editor:d,Sidebar:m.Sidebar}))}catch(c){console.error("Error syncing editor items:",c)}},50);return()=>clearTimeout(l)},[e,t]);return V4(()=>{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");import{Fragment as U4,jsx as Wm}from"react/jsx-runtime";var us=[{type:"text",align:"left",content:`
229
- `,text_style:"h1"},{type:"text",align:"left",content:""},{type:"image",src:""}],_4=O4(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:s,colorScheme:l,hidePreviewPanelExitButton:c,...u},d)=>{let m=nn(Ae),[p,g]=Fm(Ce),[v,b]=Fm(fn),y=cs({}),[C,x]=Om(c?"desktop":void 0),h=nn(dt),f=nn(he),E=nn(Fp),T=nn(ao),w=cs(-1),P=F4(Tg),N=cs(!1),k=cs(!1),[S]=Fm(de),B=nn(Rr),M=nn(kt),I=nn(Ur),[D,V]=Om({Editor:[],Sidebar:I});Ao(()=>{V(U=>({...U,Sidebar:I}))},[I]);let _=cs(null);qi({items:D,setItems:V,editor:m});let{syncEditorItems:W}=kc({setItems:V,rafId:_,editor:m});Ao(()=>{M&&(k.current=!1)},[M]);let[F,L]=Om(!1);Ao(()=>{if(f===!1||f===null){let U=setTimeout(()=>{L(!0)},100);return()=>clearTimeout(U)}else L(!1)},[f,F]),Ao(()=>{if(p){let U=p.type.name,q=Ys(U);P({nodeName:U,config:q})}},[p,P]);let $=e5(()=>{var q,ne,X,le,ke,we,De,rt,Ve,Je,Tt,ut,Ke,Ge,Et,me,Pe,K,Xe,at,Ft,Hr,Fr,Or,dn,mn,z,G,se,Ee,J,ie,ce,Ne;if(T)return T;let U=(X=(ne=(q=h==null?void 0:h.data)==null?void 0:q.tenant)==null?void 0:ne.brand)==null?void 0:X.settings;return{brandColor:((le=U==null?void 0:U.colors)==null?void 0:le.primary)||"#000000",textColor:((ke=U==null?void 0:U.colors)==null?void 0:ke.secondary)||"#000000",subtleColor:((we=U==null?void 0:U.colors)==null?void 0:we.tertiary)||"#666666",headerStyle:(rt=(De=U==null?void 0:U.email)==null?void 0:De.header)!=null&&rt.barColor?"border":"plain",logo:(Tt=(Je=(Ve=U==null?void 0:U.email)==null?void 0:Ve.header)==null?void 0:Je.logo)==null?void 0:Tt.image,link:(Ge=(Ke=(ut=U==null?void 0:U.email)==null?void 0:ut.header)==null?void 0:Ke.logo)==null?void 0:Ge.href,facebookLink:(K=(Pe=(me=(Et=U==null?void 0:U.email)==null?void 0:Et.footer)==null?void 0:me.social)==null?void 0:Pe.facebook)==null?void 0:K.url,linkedinLink:(Hr=(Ft=(at=(Xe=U==null?void 0:U.email)==null?void 0:Xe.footer)==null?void 0:at.social)==null?void 0:Ft.linkedin)==null?void 0:Hr.url,instagramLink:(mn=(dn=(Or=(Fr=U==null?void 0:U.email)==null?void 0:Fr.footer)==null?void 0:Or.social)==null?void 0:dn.instagram)==null?void 0:mn.url,mediumLink:(Ee=(se=(G=(z=U==null?void 0:U.email)==null?void 0:z.footer)==null?void 0:G.social)==null?void 0:se.medium)==null?void 0:Ee.url,xLink:(Ne=(ce=(ie=(J=U==null?void 0:U.email)==null?void 0:J.footer)==null?void 0:ie.social)==null?void 0:ce.twitter)==null?void 0:Ne.url}},[T,h]),A=E&&!!$,H=Qb(()=>{Object.values(y.current).forEach(U=>clearTimeout(U)),y.current={}},[]);Ao(()=>()=>{H()},[H]),Ao(()=>{let U=a(q=>{if(q.key==="Escape"&&(g(null),m==null||m.commands.blur(),w.current=-1),q.key==="Tab"&&m){let ne=document.activeElement;if(ne instanceof HTMLInputElement||ne instanceof HTMLTextAreaElement||ne instanceof HTMLSelectElement||(ne==null?void 0:ne.closest("[data-sidebar-form]"))!==null)return;let{$from:le}=m.state.selection,ke=m.isActive("list")||m.isActive("listItem");if(!ke)for(let Ve=le.depth;Ve>=0;Ve--){let Je=le.node(Ve).type.name;if(Je==="list"||Je==="listItem"){ke=!0;break}}if(ke)return;q.preventDefault();let we=-1;p&&m.state.doc.content.forEach((Ve,Je,Tt)=>{p.attrs.id===Ve.attrs.id&&(we=Tt)}),we===-1&&(we=0);let De=m.state.doc,rt;if(q.shiftKey?rt=(we-1+De.childCount)%De.childCount:rt=(we+1)%De.childCount,rt!==we||p===null){let Ve=De.child(rt);g(Ve),m.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",U),()=>{document.removeEventListener("keydown",U)}},[m,p,g]),Ao(()=>{if(f!==!1||M)return;let U=S!=null?S:"";if(U){let q=pm(U,"email");b(q||"")}setTimeout(()=>{if(!(!m||m.isDestroyed)&&m.state.doc.childCount===1){let q=m.state.doc.child(0);g(q)}},0)},[h,f,M,m,b,g,S]),Ao(()=>{f===!1&&h&&!k.current&&(k.current=!0,setTimeout(()=>{m&&!m.isDestroyed&&W(m)},300))},[f,h,m,W]),Ao(()=>(N.current=!0,()=>{N.current=!1}),[]);let O=Qb(U=>{let ne=U||(C===void 0?"desktop":void 0);x(ne),g(null),ne?m==null||m.setEditable(!1):m==null||m.setEditable(!0)},[m,C,x,g]),j=a(U=>{b(U.target.value)},"handleSubjectChange"),Z=e5(()=>{if(f!==!1||!F)return null;let U=s&&s.elements&&s.elements.length>0;U&&(k.current=!0);let q;return U&&(q=s.elements.find(X=>X.type==="channel"&&X.channel==="email")),q||(q={type:"channel",channel:"email",elements:us}),$e({version:"2022-01-01",elements:[q]},{channel:"email"})},[s,f,F]);return M&&(S===null||Z===null)?null:Wm(Kt,{theme:t,colorScheme:l,isLoading:!!f,Header:i?i({hidePublish:e,channels:r,routing:o}):Wm(hr,{hidePublish:e,channels:r,routing:o}),...u,children:Wm(U4,{children:n==null?void 0:n({subject:v,handleSubjectChange:j,selectedNode:p,setSelectedNode:g,previewMode:C,templateEditor:m,ref:d,isBrandApply:A,brandSettings:$,items:D,content:Z,syncEditorItems:W,brandEditorContent:B,templateData:h,togglePreviewMode:O,hidePreviewPanelExitButton:c})})})}),Pc=W4(_4);var Mc=class Mc{};a(Mc,"UploadImageAPI"),Mc.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 _m=Mc,Um=_m;var Gt=a(e=>{var r;e==null||e.variables,e==null||e.disableVariablesAutocomplete;let t=(e==null?void 0:e.textMarks)==="plain-text"?{bold:"disabled",italic:"disabled",underline:"disabled",strike:"disabled"}:(r=e==null?void 0:e.textMarks)!=null?r:{};return[qd,fb.configure({document:!1,dropcursor:!1,gapcursor:!1,heading:!1,horizontalRule:!1,paragraph:!1,blockquote:!1,hardBreak:!1,code:!1,bulletList:!1,orderedList:!1,listItem:!1,bold:t.bold==="disabled"?!1:void 0,italic:t.italic==="disabled"?!1:void 0,strike:t.strike==="disabled"?!1:void 0,history:{newGroupDelay:100}}),im.configure({setSelectedNode:e==null?void 0:e.setSelectedNode,shouldHandleClick:e==null?void 0:e.shouldHandleClick}),Xs.configure({keepMarks:!0,HTMLAttributes:{class:"my-line-break"}}),_h,$u,nm,Ou,mc,uc,Kd.configure({levels:[1,2,3,4,5,6]}),Gl,Xl,cb,tl,Yl,Ql,ol,em.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),...t.underline==="disabled"?[]:[pb],il.configure(),rc.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(o,n,i)=>{n.forEach(async s=>{let l=await Um.uploadImage(s);o.chain().setImageBlockAt({pos:i,src:l}).focus().run()})},onPaste:(o,n)=>{n.forEach(async i=>{let s=await Um.uploadImage(i);return o.chain().setImageBlockAt({pos:o.state.selection.anchor,src:s}).focus().run()})}}),db.extend({addKeyboardShortcuts(){return{}}}).configure({types:["paragraph","heading"]}),mb,ub.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:"",emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",showOnlyWhenEditable:!0}),Hu.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),Dd,Hn,Fn,oc,ac]},"ExtensionKit");import{BubbleMenu as $4,useCurrentEditor as z4}from"@tiptap/react";import{jsx as t5}from"react/jsx-runtime";var Xt=a(({config:e})=>{let{editor:t}=z4(),r=jl(t);return t?t5($4,{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&&t5(qa,{editor:t,config:e})}):null},"BubbleTextMenu");import{TextSelection as j4}from"@tiptap/pm/state";import{EditorProvider as q4,Extension as Z4,useCurrentEditor as J4}from"@tiptap/react";import{useAtomValue as K4,useSetAtom as r5}from"jotai";import{memo as G4,useEffect as zm,useMemo as X4,useRef as o5}from"react";import{jsx as br,jsxs as $m}from"react/jsx-runtime";var Y4=a(({value:e,readOnly:t})=>{let{editor:r}=J4(),o=r5(ci),n=K4(he),i=o5(!1);return zm(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(um(e!=null?e:"")))},[r,e,n,t]),zm(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),Q4=a(({facebookLink:e,linkedinLink:t,instagramLink:r,mediumLink:o,xLink:n,readOnly:i=!1,value:s,onUpdate:l})=>{let c=o5(!1),u=r5(Ce),d=Z4.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:p})=>{let{state:g,dispatch:v}=p.view;return v(g.tr.setSelection(j4.create(g.doc,g.selection.$anchor.pos))),u&&u(null),!1}}}});zm(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=X4(()=>[...Gt({setSelectedNode:u}),d].filter(p=>p!==void 0),[d,u]);return $m("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[$m(q4,{content:um(s!=null?s:""),extensions:m,editable:!i,autofocus:!i,onUpdate:l,editorContainerProps:{className:R("courier-py-2 courier-flex-grow courier-brand-editor",i&&"courier-brand-editor-readonly")},immediatelyRender:!1,children:[br(Y4,{value:s,readOnly:i}),br(Xt,{})]}),$m("div",{className:"courier-flex courier-justify-end courier-items-center courier-gap-2 courier-mt-3",children:[e&&br("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:br(fi,{className:"courier-w-5 courier-h-5"})}),t&&br("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:br(hi,{className:"courier-w-5 courier-h-5"})}),r&&br("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:br(gi,{className:"courier-w-5 courier-h-5"})}),o&&br("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:br(bi,{className:"courier-w-5 courier-h-5"})}),n&&br("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:br(yi,{className:"courier-w-5 courier-h-5"})})]})]})},"BrandFooterComponent"),ds=G4(Q4);import{Fragment as e7,jsx as Zi,jsxs as Nc}from"react/jsx-runtime";var n5=a(({value:e,icon:t,...r})=>Zi(Rt,{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"),jm=a(({previewMode:e,togglePreviewMode:t,hideMobileToggle:r=!1,hideExitButton:o=!1,...n})=>Nc("div",{...n,className:R("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&&Nc(e7,{children:[Nc(Ar,{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:[Zi(n5,{value:"desktop",icon:Zi(mu,{})}),Zi(n5,{value:"mobile",icon:Zi(yu,{})})]}),!o&&Zi("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),!o&&Nc(Me,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");import{forwardRef as c5}from"react";function t7(){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(t7,"initTestHelpers");function Yt(e,t){typeof window!="undefined"&&(t7(),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(Yt,"setTestEditor");import{Extension as s7}from"@tiptap/core";import{TextSelection as l7}from"@tiptap/pm/state";import{EditorProvider as c7,useCurrentEditor as u7}from"@tiptap/react";import{useAtom as a5,useAtomValue as So,useSetAtom as Xn}from"jotai";import{useCallback as an,useEffect as Qt,useMemo as d7,useRef as so}from"react";import{useCurrentEditor as r7}from"@tiptap/react";import{useEffect as o7}from"react";var yr=a(({value:e,defaultValue:t})=>{let{editor:r}=r7();return o7(()=>{if(!r)return;let o=setTimeout(()=>{r.commands.setContent(e||t)},0);return()=>clearTimeout(o)},[r,e,t]),null},"ReadOnlyEditorContent");import{useCurrentEditor as n7}from"@tiptap/react";import{useEffect as i7,useRef as a7}from"react";var vr=a(({variableViewMode:e})=>{let{editor:t}=n7(),r=a7(null);return i7(()=>{if(t&&r.current!==e){if(Ut(t,e)){let n=t.state.tr.setMeta("variableViewModeChanged",!0);t.view.dispatch(n)}r.current=e}},[t,e]),null},"VariableViewModeSync");import{Fragment as f7,jsx as ms,jsxs as i5}from"react/jsx-runtime";var qm=!1,Sc=!1,Ac=null,m7=a(({value:e})=>{let{editor:t}=u7(),[r,o]=a5(de),n=Xn(Ye),i=So(fn),s=So(Ce),l=Xn(Ae),c=Xn(hn),u=so(!1),d=so(),m=So(he),p=So(dt),g=so(!1),v=So(kt);return Qt(()=>{m&&(g.current=!1)},[m]),Qt(()=>(c({action:"register",id:"email-subject",fn:a(()=>{var y;if(d.current&&(clearTimeout(d.current),d.current=void 0,t&&m===!1&&!v))try{let C=ve(t.getJSON());if(!C||!Array.isArray(C))return;let x=i;if(i===null&&r){let T=(y=r==null?void 0:r.elements)==null?void 0:y.find(w=>w.type==="channel"&&w.channel==="email");T&&(x=pa(T,"email"))}let h=Er(r,"email",x||"",C),f={elements:h.elements,channel:"email",...h.raw&&{raw:h.raw}},E=xt(r,f);JSON.stringify(r)!==JSON.stringify(E)&&(o(E),n(E))}catch(C){console.error("[FlushSubjectUpdate]",C)}},"flushSubjectUpdate")}),()=>{c({action:"unregister",id:"email-subject"})}),[t,i,m,v,r,o,n,c]),Qt(()=>{!t||m!==!1||g.current||!e||(l(t),g.current=!0,t.commands.setContent(e))},[t,e,l,m]),Qt(()=>{var T;if(!t||!r||t.isFocused||Vo()||Sc)return;let b=document.activeElement;if((b==null?void 0:b.closest("[data-sidebar-form]"))!==null)return;let C=(T=r.elements)==null?void 0:T.find(w=>w.type==="channel"&&w.channel==="email");if(!C)return;let x=C.type==="channel"&&"elements"in C&&C.elements||[],h=$e({version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:x}]}),f=ve(h),E=ve(t.getJSON());JSON.stringify(f)!==JSON.stringify(E)&&setTimeout(()=>{let w=document.activeElement,P=(w==null?void 0:w.closest("[data-sidebar-form]"))!==null;!t.isFocused&&!Vo()&&!Sc&&!P&&(qm=!0,t.commands.setContent(h),setTimeout(()=>{qm=!1},50))},1)},[t,r]),Qt(()=>{if(!(!t||m!==!1||v)&&!t.isFocused)return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var b;try{let y=ve(t.getJSON());if(!y||!Array.isArray(y))return;let C=i;if(i===null&&r){let E=(b=r==null?void 0:r.elements)==null?void 0:b.find(T=>T.type==="channel"&&T.channel==="email");E&&(C=pa(E,"email"))}let x=Er(r,"email",C||"",y),h={elements:x.elements,channel:"email",...x.raw&&{raw:x.raw}},f=xt(r,h);JSON.stringify(r)!==JSON.stringify(f)&&(o(f),n(f))}catch(y){console.error(y)}},500),()=>{d.current&&clearTimeout(d.current)}},[p,t,i,o,n,m,r,v]),Qt(()=>()=>{t&&!t.isDestroyed&&t.setEditable(!0)},[t]),Qt(()=>{t&&u.current&&t.commands.updateSelectionState(s)},[t,s]),Qt(()=>(u.current=!0,()=>{u.current=!1}),[]),null},"EditorContent"),p7=a(({value:e,readOnly:t=!1,onDestroy:r,onUpdate:o,subject:n,variables:i,disableVariablesAutocomplete:s=!1,variableViewMode:l="show-variables"})=>{let c=Xn(Oo),u=so(),[d,m]=a5(de),p=So(fn),g=n!=null?n:p,v=Xn(Ce),b=So(Ae),y=So(kt),C=So(qt),x=Xn(hn),h=Xn(Ye),f=so(d),E=so(g),T=so(C);Qt(()=>{f.current=d},[d]),Qt(()=>{E.current=g},[g]),Qt(()=>{T.current=C},[C]),Qt(()=>{b==null||b.setEditable(!t)},[t,b]);let w=s7.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:A})=>{let{state:H,dispatch:O}=A.view;return O(H.tr.setSelection(l7.create(H.doc,H.selection.$anchor.pos))),v&&v(null),!1}}}}),P=an(({editor:A})=>{Ut(A,l),o==null||o(A),Yt("email",A),v&&setTimeout(()=>{v(null)},100)},[v,o,l]),N=so(),k=so(null),S=an((A,H)=>{var X;if(y)return;let O=f.current,j=E.current;if(!O){let le={version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:H}]};m(le),h(le);return}let Z=O.elements.find(le=>le.type==="channel"&&le.channel==="email"),U={...Z};U.elements=(X=U.elements)==null?void 0:X.filter(le=>le.type!=="meta");let q={type:"channel",channel:"email",elements:H};if(JSON.stringify(U)!==JSON.stringify(q)){let le=j;!j&&Z&&(le=pa(Z,"email"));let ke=Er(O,"email",le||"",H);q.elements=ke.elements,ke.raw&&(q.raw=ke.raw);let we=xt(O,q);Sc=!0,m(we),h(we),Ac&&clearTimeout(Ac),Ac=setTimeout(()=>{Sc=!1,Ac=null},300)}o==null||o(A),Yt("email",A)},[m,h,o,y]),B=an(({editor:A})=>{let H=ve(A.getJSON());k.current={editor:A,elemental:H},N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{if(k.current){let{editor:O,elemental:j}=k.current;S(O,j),k.current=null}},200)},[S]),M=an(({editor:A})=>{if(T.current||qm||Vo())return;let{selection:H}=A.state,{$anchor:O}=H,Z=H.$head.marks().find(le=>le.type.name==="link");Z||A.isActive("link")?c({mark:Z}):c(null);let U=O.depth,q=null,ne=null,X=null;for(;U>0;){let le=O.node(U);!ne&&le.type.name==="blockquote"&&(ne=le),!X&&le.type.name==="list"&&(X=le),!q&&(le.type.name==="paragraph"||le.type.name==="heading")&&(q=le),U--}X?v(X):ne?v(ne):q&&v(q)},[c,v]),I=an(({editor:A,transaction:H})=>{let O=H==null?void 0:H.getMeta("showLinkForm");if(O){let{selection:j}=A.state,U=j.$head.marks().find(q=>q.type.name==="link");c({mark:U,link:{from:O.from,to:O.to}})}},[c]),D=an(()=>{u.current&&clearTimeout(u.current),N.current&&clearTimeout(N.current),r==null||r(),Yt("email",null)},[r]);Qt(()=>(x({action:"register",id:"email-content",fn:a(()=>{if(N.current&&(clearTimeout(N.current),N.current=void 0,k.current)){let{editor:H,elemental:O}=k.current;S(H,O),k.current=null}},"flushContentUpdate")}),()=>{x({action:"unregister",id:"email-content"})}),[S,x]);let V=an(A=>{var U;if(T.current)return;let H=(U=A.view)==null?void 0:U.editor;if(!H||!H.isEditable)return;let O=A.target,j=H.view.posAtDOM(O,0),Z=H.state.doc.resolve(j).node();Z.type.name==="paragraph"&&v(Z)},[v]),_=an(()=>!T.current,[]),W=d7(()=>[...Gt({setSelectedNode:v,shouldHandleClick:_,variables:i,disableVariablesAutocomplete:s}),w].filter(A=>A!==void 0),[w,v,_,i,s]),F=e||{type:"doc",content:[{type:"paragraph"}]},L=t?{editable:!1,autofocus:!1}:{editable:!0,autofocus:!0,onCreate:P,onUpdate:B,onSelectionUpdate:M,onTransaction:I},$=so(null);return Qt(()=>{let A=$.current;if(!(!A||t))return nr({element:A,getData:()=>({type:"editor",id:"editor-drop-zone"}),canDrop:({source:H})=>H.data.type==="sidebar"?!0:H.data.type==="editor"})},[t]),ms("div",{ref:$,"data-testid":"email-editor",children:i5(c7,{content:F,extensions:W,...L,onDestroy:D,editorContainerProps:{onClick:V},immediatelyRender:!1,children:[ms(vr,{variableViewMode:l}),t?ms(yr,{value:F,defaultValue:us}):i5(f7,{children:[ms(m7,{value:F}),ms(Xt,{})]})]})})},"EmailEditor"),Zm=p7;import{useAtomValue as Ic,useSetAtom as C7}from"jotai";import{AlignVerticalSpaceAround as x7,GripVertical as T7,List as E7,Quote as w7}from"lucide-react";import{forwardRef as g7,useEffect as h7,useRef as b7,useState as y7}from"react";import{jsx as Jm}from"react/jsx-runtime";var Ji=a(({children:e,id:t,className:r,editor:o})=>Jm(v7,{id:t,className:r,editor:o,children:e}),"SideBarSortableItemWrapper"),v7=g7(({children:e,className:t,id:r,editor:o},n)=>{let i=b7(null),[s,l]=y7(!1);return h7(()=>{let c=i.current;if(!(!c||!r))return $r(Sa({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]),Jm("div",{ref:i,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":r,className:R(t,"courier-relative",s&&"courier-opacity-50 courier-cursor-grabbing"),children:Jm("div",{children:e})})});import{Fragment as A7,jsx as We,jsxs as Ki}from"react/jsx-runtime";var k7={heading:gl,text:Zo,image:bl,spacer:yl,divider:jo,button:zo,customCode:ml,column:ul,blockquote:sl,list:qo},P7=a(e=>({heading:We(Xu,{}),text:We(Qu,{}),image:We(Yu,{}),spacer:We(x7,{className:"courier-w-4 courier-h-4"}),divider:We(Gu,{}),button:We(Zu,{}),customCode:We(Ku,{}),column:We(Ju,{}),blockquote:We(w7,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),list:We(E7,{strokeWidth:1.5,className:"courier-w-4 courier-h-4 courier-text-black dark:courier-text-white"})})[e],"getBlockIcon"),M7=a(e=>or(e)?`${e.type}:${e.preset}`:e,"getItemKey"),N7=a(({preset:e})=>{let t=e.icon||P7(e.type);return We(qe,{draggable:!0,icon:t,draggableLabel:e.label,label:e.label})},"PresetBlock"),Km=a(({items:e,brandEditor:t,label:r,editor:o})=>{var m,p;let n=Ic(dt),i=C7(Ei),s=Ic(mt),l=Ic(Ur),c=Ic(Ho),u=e!=null?e:l,d=a(g=>{if(or(g)){let b=c.find(y=>y.type===g.type&&y.key===g.preset);return b?We(N7,{preset:b}):(console.warn(`[SideBar] Preset not found: ${g.type}:${g.preset}`),null)}let v=k7[g];return v?We(v,{draggable:!0}):null},"renderBlockItem");return Ki("div",{className:"courier-flex courier-flex-col courier-h-full",children:[Ki("div",{className:"courier-flex-1",children:[r&&Ki(A7,{children:[We("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:r}),We(pe,{className:"courier-my-4"})]}),We("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:u.map(g=>{let v=M7(g);return We(Ji,{id:v,editor:o,children:Ki("div",{className:R("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:[We(T7,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),d(g)]})},v)})})]}),t&&Ki("div",{className:"courier-mt-auto courier-pt-4",children:[We(pe,{className:"courier-mb-4 -courier-mx-4"}),(p=(m=n==null?void 0:n.data)==null?void 0:m.tenant)!=null&&p.brand?We("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:We(Me,{variant:"link",className:"courier-underline",onClick:()=>i("brand"),disabled:!!s,children:"Edit brand"})}):Ki("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[We("h3",{className:"courier-text-md courier-font-medium courier-text-foreground",children:"Customize brand theme"}),We("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),We(Me,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>i("brand"),children:"Customize"})]})]})]})},"SideBar");import{useAtomValue as S7}from"jotai";import{jsx as Io,jsxs as I7}from"react/jsx-runtime";var Gm=a(({element:e,editor:t,hideCloseButton:r=!1})=>{var s,l;let o=S7(En);if(!e)return null;if(o!=null&&o.link||((s=o==null?void 0:o.mark)==null?void 0:s.type.name)==="link"&&((l=e.marks)!=null&&l.some(c=>c.type.name==="link")))return Io(Ui,{editor:t,mark:o==null?void 0:o.mark,pendingLink:o==null?void 0:o.link});let n=t==null?void 0:t.isActive("blockquote"),i=a(()=>{if(!t)return;let{$anchor:c}=t.state.selection,u=c.depth;for(;u>0;){let d=c.node(u);if(d.type.name==="blockquote")return d;u--}},"getBlockquoteElement");return I7("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[e.type.name==="button"&&Io(Kl,{element:e,editor:t,hideCloseButton:r},"button-form"),e.type.name==="divider"&&Io(Fh,{element:e,editor:t,hideCloseButton:r},e.attrs.id),["paragraph","heading"].includes(e.type.name)&&!n&&Io(jg,{element:e,editor:t,hideCloseButton:r},e.attrs.id),e.type.name==="list"&&!n&&Io(qn,{element:e,editor:t,hideCloseButton:r},e.attrs.id),e.type.name==="imageBlock"&&Io(Jh,{element:e,editor:t,hideCloseButton:r},e.attrs.id),e.type.name==="customCode"&&Io(jd,{element:e,editor:t,hideCloseButton:r},e.attrs.id),(e.type.name==="blockquote"||e.type.name==="paragraph"&&n||e.type.name==="heading"&&n||e.type.name==="list"&&n)&&Io(Zg,{element:i()||e,editor:t,hideCloseButton:r},e.attrs.id),e.type.name==="column"&&Io(Ud,{element:e,editor:t,hideCloseButton:r},e.attrs.id)]})},"SideBarItemDetails");import{forwardRef as s5}from"react";import{useAtom as L7}from"jotai";import{Fragment as R7,jsx as Lc,jsxs as B7}from"react/jsx-runtime";var Yn=s5(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>Lc("div",{className:R("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})),Qn=s5(({children:e,className:t,previewMode:r,skipExpanded:o=!1,width:n,...i},s)=>{let[l,c]=L7(_r),u=o?!1:l,d=n||"courier-w-64";return r?null:B7(R7,{children:[u&&Lc("div",{className:"courier-absolute courier-inset-0 courier-bg-black/50 courier-z-[40] courier-transition-opacity courier-duration-300 courier-cursor-pointer",onClick:()=>c(!1),"aria-hidden":"true"}),Lc("div",{className:R("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch",!u&&"courier-relative",d,t),children:Lc("div",{className:R("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-[85%] courier-z-[50] courier-shadow-xl courier-bg-background":d),...i,ref:s,children:e})})]})});import{useAtomValue as l5,useSetAtom as D7}from"jotai";import{jsx as er,jsxs as ei}from"react/jsx-runtime";var u5=c5(({children:e,className:t,...r},o)=>er("div",{className:R("courier-editor-container courier-relative",t),...r,ref:o,children:e})),d5=c5(({children:e,previewMode:t,...r},o)=>er("div",{className:R("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})),m5=a(({variables:e,disableVariablesAutocomplete:t,theme:r,isLoading:o,hidePublish:n,channels:i,brandEditor:s,routing:l,colorScheme:c,...u})=>{let d=l5(de),m=l5(_r),p=D7(_r),g=a(()=>{m&&p(!1)},"handleSubjectAreaClick");return er(Pc,{value:d,variables:e,theme:r,isLoading:o,hidePublish:n,channels:i,brandEditor:s,routing:l,colorScheme:c,render:({subject:v,handleSubjectChange:b,selectedNode:y,setSelectedNode:C,previewMode:x,templateEditor:h,ref:f,isBrandApply:E,brandSettings:T,items:w,content:P,syncEditorItems:N,brandEditorContent:k,templateData:S,togglePreviewMode:B,hidePreviewPanelExitButton:M})=>{var I,D,V,_,W,F;return ei(Yn,{previewMode:x,children:[ei("div",{className:"courier-flex courier-flex-col courier-flex-1 courier-min-w-0 courier-overflow-hidden",children:[ei("div",{className:"courier-bg-background courier-h-12 courier-flex courier-items-center courier-gap-2 courier-px-4 courier-border-b courier-min-w-0",onClick:g,children:[ei("h4",{className:"courier-text-sm courier-h-[25px] courier-flex courier-items-end courier-pb-0.5 courier-shrink-0",children:["Subject:"," "]}),er(Ja,{value:v!=null?v:"",onChange:L=>b({target:{value:L}}),onFocus:()=>C(null),className:"!courier-bg-background courier-text-sm courier-flex-1 courier-min-w-0",placeholder:"Write subject...","data-testid":"email-subject-input",readOnly:x!==void 0,showToolbar:!0})]}),ei(u5,{ref:f,children:[ei(d5,{previewMode:x,children:[E&&ei("div",{className:R("courier-py-5 courier-px-9 courier-pb-0 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(T==null?void 0:T.headerStyle)==="border"&&"courier-pt-6"),children:[(T==null?void 0:T.headerStyle)==="border"&&er("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:T==null?void 0:T.brandColor}}),(T==null?void 0:T.logo)&&er("img",{src:T.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),P&&er(Zm,{value:P,onUpdate:N,variables:e,disableVariablesAutocomplete:t},`email-editor-${t?"no-autocomplete":"autocomplete"}`),E&&S&&er("div",{className:"courier-py-5 courier-px-9 courier-pt-0 courier-flex courier-flex-col",children:er(ds,{readOnly:!0,value:k!=null?k:(F=(W=(_=(V=(D=(I=S==null?void 0:S.data)==null?void 0:I.tenant)==null?void 0:D.brand)==null?void 0:V.settings)==null?void 0:_.email)==null?void 0:W.footer)==null?void 0:F.markdown,variables:e,facebookLink:T==null?void 0:T.facebookLink,linkedinLink:T==null?void 0:T.linkedinLink,instagramLink:T==null?void 0:T.instagramLink,mediumLink:T==null?void 0:T.mediumLink,xLink:T==null?void 0:T.xLink})})]}),er(jm,{previewMode:x,togglePreviewMode:B,hideExitButton:M})]})]}),er(Qn,{previewMode:x,children:er("div",{className:"courier-p-1 courier-h-full",children:y?er(Gm,{element:y,editor:h}):er(Km,{items:w.Sidebar,brandEditor:s,label:"Blocks library",editor:h!=null?h:void 0})})})]})},...u})},"EmailLayout");import{useCurrentEditor as V7}from"@tiptap/react";import{useAtom as H7,useAtomValue as Rc,useSetAtom as Xm}from"jotai";import{forwardRef as F7,memo as O7,useCallback as W7,useEffect as ps,useMemo as p5,useRef as Ym}from"react";import{jsx as f5}from"react/jsx-runtime";var fs=[{type:"text",content:`
229
+ `}default:return((v=e.content)==null?void 0:v.map(ps).join(""))||""}},"convertNodeToMarkdown");function Lc(e){return e.content?e.content.map(ps).join("").trim():""}a(Lc,"convertTiptapToMarkdown");function R(...e){return j4(q4(e))}a(R,"cn");var Z4={blockquote:vr,button:Se,divider:qt,spacer:en,image:tt,text:Ce,list:qr,quoteTextStyle:Br,quoteTextStyleVariants:Dn};import{Slot as K4}from"@radix-ui/react-slot";import{cva as J4}from"class-variance-authority";import{forwardRef as G4}from"react";import{jsx as X4}from"react/jsx-runtime";var Rc=J4("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"}]}),Ae=G4(({active:e,buttonSize:t="medium",disabled:r,variant:o="primary",className:n,asChild:i=!1,...s},l)=>X4(i?K4:"button",{ref:l,disabled:r,className:R(Rc({variant:o,size:t,disabled:r,active:e}),n),...s}));Ae.displayName="Button";import{forwardRef as Y4}from"react";import{jsx as Q4}from"react/jsx-runtime";var pe=Y4((e,t)=>Q4("hr",{...e,ref:t,className:R("courier-my-1 courier-border-border dark:courier-border-neutral-600 courier-w-full",e.className)}));pe.displayName="Divider";import{Component as e7}from"react";import{jsx as Dm,jsxs as r7}from"react/jsx-runtime";var Vm=class Vm extends e7{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||Dm(t7,{error:this.state.error}):this.props.children}};a(Vm,"ErrorBoundary");var Bm=Vm,t7=a(({error:e})=>r7("div",{className:"courier-p-6 courier-border courier-border-red-200 courier-bg-red-50 courier-rounded-lg courier-text-center",children:[Dm("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),Dm("p",{className:"courier-text-red-600 courier-mb-4",children:"An unexpected error occurred in the editor. Please refresh the page or contact support if the problem persists."}),!1]}),"DefaultErrorFallback");import{Slot as a7}from"@radix-ui/react-slot";import*as er from"react";import{Controller as s7,FormProvider as l7,useFormContext as c7}from"react-hook-form";import*as Hm from"@radix-ui/react-label";import{cva as o7}from"class-variance-authority";import*as t5 from"react";import{jsx as i7}from"react/jsx-runtime";var n7=o7("courier-text-sm courier-font-medium courier-leading-none peer-disabled:courier-cursor-not-allowed peer-disabled:courier-opacity-70"),Fm=t5.forwardRef(({className:e,...t},r)=>i7(Hm.Root,{ref:r,className:R(n7(),e),...t}));Fm.displayName=Hm.Root.displayName;import{jsx as hn}from"react/jsx-runtime";var Oe=l7,r5=er.createContext({}),re=a(({...e})=>hn(r5.Provider,{value:{name:e.name},children:hn(s7,{...e})}),"FormField"),Bc=a(()=>{let e=er.useContext(r5),t=er.useContext(o5),{getFieldState:r,formState:o}=c7(),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"),o5=er.createContext({}),ee=er.forwardRef(({className:e,...t},r)=>{let o=er.useId();return hn(o5.Provider,{value:{id:o},children:hn("div",{ref:r,className:R("courier-space-y-2",e),...t})})});ee.displayName="FormItem";var fo=er.forwardRef(({className:e,...t},r)=>{let{error:o,formItemId:n}=Bc();return hn(Fm,{ref:r,className:R(o&&"courier-text-destructive",e),htmlFor:n,...t})});fo.displayName="FormLabel";var te=er.forwardRef(({...e},t)=>{let{error:r,formItemId:o,formDescriptionId:n,formMessageId:i}=Bc();return hn(a7,{ref:t,id:o,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...e})});te.displayName="FormControl";var u7=er.forwardRef(({className:e,...t},r)=>{let{formDescriptionId:o}=Bc();return hn("p",{ref:r,id:o,className:R("courier-text-[0.8rem] courier-text-muted-foreground",e),...t})});u7.displayName="FormDescription";var oe=er.forwardRef(({className:e,children:t,...r},o)=>{let{error:n,formMessageId:i}=Bc(),s=n?String(n==null?void 0:n.message):t;return s?hn("p",{ref:o,id:i,className:R("courier-text-[0.8rem] courier-font-medium courier-text-destructive",e),...r,children:s}):null});oe.displayName="FormMessage";import*as We from"@radix-ui/react-alert-dialog";import*as ii from"react";import{useCallback as d7}from"react";import{jsx as ho,jsxs as g7}from"react/jsx-runtime";var n5=We.Root,i5=We.Trigger,m7=We.Portal,a5=ii.forwardRef(({className:e,...t},r)=>ho("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:ho(We.Overlay,{asChild:!0,className:R("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})}));a5.displayName=We.Overlay.displayName;var Om=ii.forwardRef(({className:e,...t},r)=>{let o=d7(()=>{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 g7(m7,{container:typeof window!="undefined"?o():void 0,children:[ho(a5,{}),ho(We.Content,{ref:r,className:R("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})]})});Om.displayName=We.Content.displayName;var _m=a(({className:e,...t})=>ho("div",{className:R("courier-flex courier-flex-col courier-space-y-2 courier-text-center sm:courier-text-left",e),...t}),"AlertDialogHeader");_m.displayName="AlertDialogHeader";var Wm=a(({className:e,...t})=>ho("div",{className:R("courier-flex courier-flex-col-reverse sm:courier-flex-row sm:courier-justify-end sm:courier-space-x-2",e),...t}),"AlertDialogFooter");Wm.displayName="AlertDialogFooter";var p7=ii.forwardRef(({className:e,...t},r)=>ho(We.Title,{ref:r,className:R("courier-text-lg courier-font-semibold",e),...t}));p7.displayName=We.Title.displayName;var f7=ii.forwardRef(({className:e,...t},r)=>ho(We.Description,{ref:r,className:R("courier-text-sm courier-text-muted-foreground",e),...t}));f7.displayName=We.Description.displayName;var zm=ii.forwardRef(({className:e,...t},r)=>ho(We.Action,{ref:r,className:R(Rc(),e),...t}));zm.displayName=We.Action.displayName;var Um=ii.forwardRef(({className:e,...t},r)=>ho(We.Cancel,{ref:r,className:R(Rc({variant:"outline"}),"courier-mt-2 sm:courier-mt-0",e),...t}));Um.displayName=We.Cancel.displayName;import*as s5 from"react";import{jsx as $m,jsxs as h7}from"react/jsx-runtime";var ge=s5.forwardRef(({className:e,type:t,startAdornment:r,endAdornment:o,...n},i)=>h7("div",{className:"courier-relative courier-flex courier-w-full courier-items-center",children:[r&&$m("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),$m("input",{type:t,className:R("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&&$m("div",{className:"courier-absolute courier-right-2 courier-flex courier-items-center courier-pointer-events-none",children:o})]}));ge.displayName="Input";import{forwardRef as C7,useRef as x7,useMemo as T7,useCallback as E7}from"react";import{useCallback as qm,useEffect as l5,useRef as Dc,useState as c5}from"react";import{CircleX as b7}from"lucide-react";import{jsx as bo,jsxs as u5}from"react/jsx-runtime";var y7=a(e=>e==="transparent"||/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e),"isValidHex"),d5=a(({color:e,onChange:t,className:r,presetColors:o,defaultValue:n="transparent"})=>{let[i,s]=c5(()=>fs(e)),[l,c]=c5(e),u=Dc(null),d=Dc(null),p=Dc(null),m=Dc(!1),f=e!==n,v=qm(E=>{m.current=!0;let b=v7(E);c(b),t(b),m.current=!1},[t]),h=a(E=>b=>{p.current=E,y(b)},"handleMouseDown"),y=qm(E=>{if(p.current){if(p.current==="gradient"&&u.current){let b=u.current.getBoundingClientRect(),g=Math.max(0,Math.min(1,(E.clientX-b.left)/b.width)),x=Math.max(0,Math.min(1,(E.clientY-b.top)/b.height)),k={...i,s:g*100,v:(1-x)*100};s(k),v(k)}else if(p.current==="hue"&&d.current){let b=d.current.getBoundingClientRect(),g=Math.max(0,Math.min(1,(E.clientX-b.left)/b.width)),x={...i,h:g*360};s(x),v(x)}}},[i,v]),C=qm(()=>{p.current=null},[]);l5(()=>{if(p.current)return window.addEventListener("mousemove",y),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",C)}},[y,C]),l5(()=>{m.current||(s(fs(e)),c(e))},[e]);let T=a(E=>{let b=E.target.value;if(c(b),y7(b)){let g=fs(b);s(g),v(g)}},"handleInputChange");return u5("div",{className:R("w-full",r),children:[bo("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:bo("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}%`}})}),bo("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:bo("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}%`}})}),u5("div",{className:"courier-mt-3 courier-relative courier-flex courier-items-center",children:[bo(ge,{value:l,onChange:T,placeholder:"#000000",className:"courier-flex-1"}),f&&bo("button",{onClick:E=>{if(E.preventDefault(),n==="transparent"){t("transparent"),c("transparent"),s({h:0,s:0,v:0});return}let b=fs(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:bo(b7,{size:14,strokeWidth:1.25})})]}),bo(pe,{className:"courier-my-3"}),bo("div",{className:"courier-flex courier-flex-wrap courier-gap-1",children:o.map(E=>bo("button",{className:R("courier-h-6 courier-w-6 courier-rounded-md courier-border courier-border-input courier-shrink-0",E==="transparent"&&jm),style:{backgroundColor:E==="transparent"?void 0:E},onClick:b=>{if(b.preventDefault(),E==="transparent"){t("transparent"),c("transparent"),s({h:0,s:0,v:0});return}let g=fs(E);s(g),v(g)}},E))})]})},"ColorPicker");function fs(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(fs,"hexToHsv");function v7({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(v7,"hsvToHex");import*as yo from"@radix-ui/react-popover";import*as p5 from"react";import{jsx as m5}from"react/jsx-runtime";var f5=yo.Root,g5=yo.Trigger;var Zm=p5.forwardRef(({className:e,align:t="center",side:r="bottom",sideOffset:o=4,collisionPadding:n=10,avoidCollisions:i=!0,portalProps:s,...l},c)=>m5(yo.Portal,{...s,children:m5(yo.Content,{ref:c,side:r,align:t,sideOffset:o,collisionPadding:n,avoidCollisions:i,className:R("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})}));Zm.displayName=yo.Content.displayName;import{jsx as gs,jsxs as h5}from"react/jsx-runtime";var jm="bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAwSDBWOEg4VjBaIiBmaWxsPSIjRDlEOUQ5Ii8+PHBhdGggZD0iTTE2IDhIOFYxNkgxNlY4WiIgZmlsbD0iI0Q5RDlEOSIvPjwvc3ZnPg==')]",w7=["#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#000000","#525252","#a3a3a3","#ffffff","transparent"],Et=C7(({className:e,value:t="",onChange:r,defaultValue:o,transparent:n=!0,presetColors:i=w7,...s},l)=>{let c=t!=="transparent",u=x7(null),d=T7(()=>n?i:i.filter(m=>m!=="transparent"),[i,n]),p=E7(()=>{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 h5(f5,{children:[gs(g5,{asChild:!0,children:h5("div",{className:"courier-relative courier-flex courier-items-center",ref:u,children:[gs("div",{className:R("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?"":jm),style:{backgroundColor:c?t:void 0}}),gs(ge,{...s,ref:l,readOnly:!0,type:"text",value:t==="transparent"?"Transparent":t,className:R("courier-relative courier-cursor-pointer courier-pl-8",e)})]})}),gs(Zm,{portalProps:{container:typeof window!="undefined"?p():void 0},className:"courier-w-[230px]",children:gs(d5,{color:t,onChange:r,presetColors:d,defaultValue:o})})]})});Et.displayName="InputColor";import*as b5 from"react";import*as Km from"@radix-ui/react-separator";import{jsx as k7}from"react/jsx-runtime";var Jm=b5.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>k7(Km.Root,{ref:n,decorative:r,orientation:t,className:R("courier-shrink-0 courier-bg-border",t==="horizontal"?"courier-h-[1px] courier-w-full":"courier-h-full courier-w-[1px]",e),...o}));Jm.displayName=Km.Root.displayName;import*as y5 from"react";import*as Wo from"@radix-ui/react-slider";import{jsx as Gm,jsxs as P7}from"react/jsx-runtime";var vm=y5.forwardRef(({className:e,...t},r)=>P7(Wo.Root,{ref:r,className:R("courier-relative courier-flex courier-w-full courier-touch-none courier-select-none courier-items-center",e),...t,children:[Gm(Wo.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:Gm(Wo.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),Gm(Wo.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"})]}));vm.displayName=Wo.Root.displayName;import*as C5 from"react";import*as hs from"@radix-ui/react-switch";import{jsx as v5}from"react/jsx-runtime";var Yi=C5.forwardRef(({className:e,...t},r)=>v5(hs.Root,{className:R("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:v5(hs.Thumb,{className:R("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")})}));Yi.displayName=hs.Root.displayName;import*as Vc from"react";import*as jr from"@radix-ui/react-tabs";import{jsx as Xm}from"react/jsx-runtime";var Ji=jr.Root,ti=Vc.forwardRef(({className:e,...t},r)=>Xm(jr.List,{ref:r,className:R("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}));ti.displayName=jr.List.displayName;var Oo=Vc.forwardRef(({className:e,...t},r)=>Xm(jr.Trigger,{ref:r,className:R("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}));Oo.displayName=jr.Trigger.displayName;var Tc=Vc.forwardRef(({className:e,...t},r)=>Xm(jr.Content,{ref:r,className:R("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}));Tc.displayName=jr.Content.displayName;import*as Qi from"react";import{jsx as M7}from"react/jsx-runtime";var bm=Qi.forwardRef(({className:e,autoResize:t=!1,...r},o)=>{let n=Qi.useRef(null),i=a(s=>{n.current=s,typeof o=="function"?o(s):o&&(o.current=s)},"combinedRef");return Qi.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]),M7("textarea",{className:R("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})});bm.displayName="Textarea";import*as x5 from"react";import*as Ym from"@radix-ui/react-toggle";import{cva as N7}from"class-variance-authority";import{jsx as S7}from"react/jsx-runtime";var Qm=N7("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"}}),T5=x5.forwardRef(({className:e,variant:t,size:r,...o},n)=>S7(Ym.Root,{ref:n,className:R(Qm({variant:t,size:r,className:e})),...o}));T5.displayName=Ym.Root.displayName;import*as ea from"@radix-ui/react-toggle-group";import*as ai from"react";import{jsx as ep}from"react/jsx-runtime";var E5=ai.createContext({size:"default",variant:"default"}),Wr=ai.forwardRef(({className:e,variant:t,size:r,children:o,...n},i)=>ep(ea.Root,{ref:i,className:R("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:ep(E5.Provider,{value:{variant:t,size:r},children:o})}));Wr.displayName=ea.Root.displayName;var Ft=ai.forwardRef(({className:e,children:t,variant:r,size:o,...n},i)=>{let s=ai.useContext(E5);return ep(ea.Item,{ref:i,className:R(Qm({variant:s.variant||r,size:s.size||o}),e),...n,children:t})});Ft.displayName=ea.Item.displayName;import{CircleCheck as A7}from"lucide-react";import{useEffect as I7,useState as L7,useRef as w5}from"react";import{jsx as tp,jsxs as k5}from"react/jsx-runtime";var bs=a(({isError:e,isSaving:t,isLoading:r,renderIsSaving:o,renderIsError:n,renderSaved:i})=>{let[s,l]=L7(!1),c=w5(t),u=w5(null);return I7(()=>(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):k5("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[tp(Hn,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):tp("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):k5("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[tp(A7,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Saved"]}):null},"Status");import{AlertDialogDescription as Lk}from"@radix-ui/react-alert-dialog";import{useAtom as Rk,useAtomValue as cu,useSetAtom as Bk}from"jotai";import{useCallback as Bs,useEffect as Dk,useRef as Vk}from"react";import{useAtom as Nk,useAtomValue as Dy,useSetAtom as lu}from"jotai";import{useCallback as Gp,useEffect as Xp,useMemo as Vy,useRef as Sk,useState as Ak}from"react";import{atom as P5}from"jotai";var Zr=P5(null),vo=P5(null);import{forwardRef as R7}from"react";import{Toaster as B7}from"sonner";import{jsx as ys,jsxs as D7}from"react/jsx-runtime";var tr=R7(({theme:e,children:t,isLoading:r,Header:o,colorScheme:n,className:i,...s},l)=>ys(Eh,{theme:e,ref:l,colorScheme:n,className:i,children:D7("div",{...Object.fromEntries(Object.entries(s).filter(([c])=>c!=="variables"&&c!=="brandEditor")),className:"courier-main-layout",children:[o&&ys("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&&ys("div",{className:"courier-editor-loading",children:ys(Hn,{})}),ys(B7,{position:"top-center",expand:!0,visibleToasts:2,style:{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)"}}),t]})}));import{useAtom as np,useAtomValue as bn,useSetAtom as W7}from"jotai";import{forwardRef as z7,memo as U7,useCallback as N5,useEffect as zo,useMemo as S5,useRef as vs,useState as ip}from"react";import{v4 as rp}from"uuid";import{useAtomValue as Hc,useSetAtom as op,useAtom as V7}from"jotai";import{useCallback as si,useRef as M5,useState as Fc,useEffect as H7}from"react";var ta=a(({items:e,setItems:t,editor:r})=>{let[o]=Fc(null),[n,i]=Fc(null),[s,l]=Fc(null),[c]=Fc("outer"),u=M5([]),d=M5([]),p=Hc(Le),m=op(Xt),[f,v]=V7(le),h=op(et),y=Hc(oo),C=Hc(Jo),T=Hc(Us),E=op(Te),b=r||p,g=si(()=>{if(!b)return;let L=b.getJSON(),N=xe(L),I=Mt(f,{channel:y,elements:N});v(I),h(I)},[b,y,f,v,h]),x=si(()=>{b==null||b.commands.removeDragPlaceholder(),t(L=>({...L,Editor:L.Editor.filter(N=>!N.toString().includes("_temp"))}))},[b==null?void 0:b.commands,t]),k=si(L=>{try{let N=b==null?void 0:b.state.doc;if(!N||L===0)return 0;if(L>=N.childCount)return N.content.size;let I=0;for(let D=0;D<Math.min(L,N.childCount);D++){let V=N.child(D);I+=V.nodeSize}return I}catch(N){return console.error("Error calculating document position:",N),0}},[b==null?void 0:b.state.doc]),P=si(L=>{let N=L.includes(":"),I=L,D=null;if(N){let $=L.split(":");I=$[0],D=$[1]}let V={};switch(I){case"text":V=Ce;break;case"heading":V={};break;case"image":V=tt;break;case"button":V=Se;break;case"divider":V=qt;break;case"spacer":V=en;break;case"customCode":V=Io;break;case"column":V=Lt;break;case"blockquote":V=vr;break;case"list":V=qr;break}let W=T[I];if(W&&(V={...V,...W}),N&&D){let $=C.find(J=>J.type===I&&J.key===D);$!=null&&$.attributes&&(V={...V,...$.attributes})}let O={type:I==="text"?"paragraph":I==="image"?"imageBlock":I==="spacer"?"divider":I,attrs:{...V,id:rp()}};if(I==="button"){let $=Se.label;if(N&&D){let J=C.find(q=>q.type===I&&q.key===D);J!=null&&J.label&&($=J.label)}O.content=[{type:"text",text:$}]}return I==="list"&&(O.content=[{type:"listItem",attrs:{id:rp()},content:[{type:"paragraph",attrs:{id:rp()},content:[]}]}]),O},[T,C]),S=si((L,N)=>{if(!b)return;let{columnId:I,index:D,isEmpty:V}=N,W=null,j=0,O=-1;if(L.type==="sidebar"){if(!L.dragType)return;W=P(L.dragType)}else if(L.type==="editor"){if(b.state.doc.descendants((A,H)=>A.attrs.id===L.id?(O=H,W=A.toJSON(),j=A.nodeSize,!1):!0),O===-1){let A=e.Editor.findIndex(H=>H===L.id);if(A!==-1){O=k(A);let H=b.state.doc.nodeAt(O);H&&(W=H.toJSON(),j=H.nodeSize)}}if(O!==-1){let A=e.Editor.filter(H=>H!==L.id);A.length!==e.Editor.length&&t({...e,Editor:A})}}if(!W)return;let $=-1,J=null;if(b.state.doc.descendants((A,H)=>A.type.name==="column"&&A.attrs.id===I?($=H,J=A,!1):!0),$===-1||!J)return;let q=J;O!==-1&&O<$&&($-=j);let F=b.state.tr;if(O!==-1&&F.delete(O,O+j),V){let A=b.schema,H=Array.from({length:q.attrs.columnsCount},(B,U)=>A.nodes.columnCell.create({index:U,columnId:I,isEditorMode:!1},U===D?[A.nodeFromJSON(W)]:[])),_=A.nodes.columnRow.create({},H);F.replaceWith($+1,$+q.nodeSize-1,_)}else{let A=$+1;q.content.forEach(H=>{if(H.type.name==="columnRow"){let _=A+1;H.content.forEach((B,U,Z)=>{if(Z===D){let K=_+B.nodeSize-1;F.insert(K,b.schema.nodeFromJSON(W))}_+=B.nodeSize})}A+=H.nodeSize})}if(b.view.dispatch(F),L.type==="sidebar"&&W&&"attrs"in W&&W.attrs){let A=W.attrs.id,H=null;b.state.doc.descendants(B=>B.attrs.id===A?(H=B,!1):!0);let _=H;_&&E(_)}g()},[b,e,t,k,P,g,E]),w=si(L=>{if(!b)return L;let N=b.state.doc.resolve(L);for(let I=N.depth;I>=0;I--){let D=N.node(I);if(D.type.name==="list")return N.before(I)+D.nodeSize}return L},[b]),M=si((L,N)=>{try{if(L.type==="sidebar"&&(N.type==="editor"||N.type==="column-cell-item"||N.type==="nested-drag")){let I=L.dragType;if(!I||!b)return;let D=N.insertPos;if(D===void 0)if(N.type==="editor"){let J=N.index+1;D=k(J)}else{console.warn("Nested drop without position data");return}D=w(D);let V=P(I);b.commands.insertContentAt(D,V);let W=V.type;if(b.state.doc.resolve(D).depth===0){let J=b.state.doc.resolve(D).index(0),q=[...e.Editor];J<=q.length&&(q.splice(J,0,V.attrs.id),t({...e,Editor:q}))}g();let O=b,$=D;setTimeout(()=>{if(!O||O.isDestroyed)return;let J=O.state.doc.nodeAt($);J&&J.type.name===W&&(E(J),(W==="paragraph"||W==="heading")&&(O.commands.setTextSelection($+1),O.view.focus()))},100);return}if((L.type==="editor"||L.type==="column-cell-item"||L.type==="nested-drag")&&(N.type==="editor"||N.type==="column-cell-item"||N.type==="nested-drag")){if(!b)return;let I=-1,D=null;if(L.pos!==void 0&&(I=L.pos,D=b.state.doc.nodeAt(I)),(I===-1||!D)&&b.state.doc.descendants((O,$)=>O.attrs.id===L.id?(I=$,D=O,!1):!0),I===-1||!D){let O=e.Editor.findIndex($=>$===L.id);O!==-1&&(I=k(O),D=b.state.doc.nodeAt(I))}if(!D||I===-1)return;let V=N.insertPos;if(V===void 0){let O;N.index===void 0?O=b.state.doc.childCount:N.index===-1?O=0:O=N.index+1,V=k(O)}if(V===void 0||(V=w(V),V>I&&V<I+D.nodeSize))return;if(V>I){let O=V-D.nodeSize;b.chain().deleteRange({from:I,to:I+D.nodeSize}).insertContentAt(O,D.toJSON()).run()}else b.chain().insertContentAt(V,D.toJSON()).deleteRange({from:I+D.nodeSize,to:I+D.nodeSize*2}).run();let W=e.Editor.includes(L.id);if(W){let O=e.Editor.filter($=>$!==L.id);t({...e,Editor:O})}let j=b.state.doc.resolve(V).depth===0;g()}}catch(I){console.error("[Pragmatic DnD] Error in handleDrop:",I)}},[e,b,t,k,g,P,w,E]);return H7(()=>Yu({onDragStart:({source:L})=>{let N=L.data;m(!0),l(N.id),N.dragType&&i(N.dragType);let I=b==null?void 0:b.view.dom.querySelectorAll('[data-node-type="column"]');I&&(u.current=Array.from(I).map(V=>V.getBoundingClientRect()));let D=b==null?void 0:b.view.dom.querySelectorAll("[data-node-view-wrapper]");if(D){let V=new Set,W=Array.from(D).filter(j=>{let O=j,$=O.parentElement;if($!=null&&$.hasAttribute("data-column-cell"))return!1;let J=O.getBoundingClientRect(),q=J.top+J.height/2;return V.has(Math.round(q))?!1:(V.add(Math.round(q)),!0)});d.current=W.map(j=>j.getBoundingClientRect())}},onDrop:({source:L,location:N})=>{let I=L.data,D=N.current.dropTargets[0];if(!D){x(),m(!1),l(null),i(null);return}let V=D.data;if(V.type==="column-cell"){S(I,V),m(!1),l(null),i(null),x();return}let W=V,j=za(D.data);if(W.pos!==void 0&&j&&b){let O=b.state.doc.nodeAt(W.pos);O&&(j==="top"?W.insertPos=W.pos:j==="bottom"&&(W.insertPos=W.pos+O.nodeSize))}if(W.insertPos===void 0&&j&&W.index!==void 0){let O=j==="top"?W.index-1:W.index;W={...W,index:O}}else if(W.index===void 0&&W.insertPos===void 0){let $=N.current.input.clientY;if(d.current.length>0){let J=0,q=1/0;d.current.forEach((B,U)=>{let Z=B.top+B.height/2,K=Math.abs($-Z);K<q&&(q=K,J=U)});let F=d.current[J],A=F.top+F.height/2,_=$>=A?J:J-1;W={...W,index:_,fromCoordinates:!0}}else W={...W,index:(b==null?void 0:b.state.doc.childCount)||0}}M(I,W),m(!1),l(null),i(null),x()}}),[b,m,x,l,i,M,S]),{activeId:s,activeDragType:n,dndMode:c,lastPlaceholderIndex:o,cleanupPlaceholder:x}},"usePragmaticDnd");import{useCallback as F7,useEffect as O7}from"react";import{useAtomValue as _7}from"jotai";var Oc=a(({setItems:e,rafId:t,editor:r})=>{let o=_7(Le),n=r||o,i=F7(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 O7(()=>{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");import{Fragment as q7,jsx as ap}from"react/jsx-runtime";var Cs=[{type:"text",align:"left",content:`
230
+ `,text_style:"h1"},{type:"text",align:"left",content:""},{type:"image",src:""}],$7=z7(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:s,colorScheme:l,hidePreviewPanelExitButton:c,...u},d)=>{let p=bn(Le),[m,f]=np(Te),[v,h]=np(Pn),y=vs({}),[C,T]=ip(c?"desktop":void 0),E=bn(bt),b=bn(ye),g=bn(af),x=bn(vo),k=vs(-1),P=W7(Ug),S=vs(!1),w=vs(!1),[M]=np(le),L=bn(Zr),N=bn(It),I=bn(to),[D,V]=ip({Editor:[],Sidebar:I});zo(()=>{V(B=>({...B,Sidebar:I}))},[I]);let W=vs(null);ta({items:D,setItems:V,editor:p});let{syncEditorItems:j}=Oc({setItems:V,rafId:W,editor:p});zo(()=>{N&&(w.current=!1)},[N]);let[O,$]=ip(!1);zo(()=>{if(b===!1||b===null){let B=setTimeout(()=>{$(!0)},100);return()=>clearTimeout(B)}else $(!1)},[b,O]),zo(()=>{if(m){let B=m.type.name,U=ul(B);P({nodeName:B,config:U})}},[m,P]);let J=S5(()=>{var U,Z,K,G,ve,Me,ke,Fe,Ie,Je,Ge,St,Re,it,gt,ut,ue,Y,Ne,dt,mt,Gr,Xr,Yr,Qr,wn,z,X,ae,we,be,Xe,ht,br;if(x)return x;let B=(K=(Z=(U=E==null?void 0:E.data)==null?void 0:U.tenant)==null?void 0:Z.brand)==null?void 0:K.settings;return{brandColor:((G=B==null?void 0:B.colors)==null?void 0:G.primary)||"#000000",textColor:((ve=B==null?void 0:B.colors)==null?void 0:ve.secondary)||"#000000",subtleColor:((Me=B==null?void 0:B.colors)==null?void 0:Me.tertiary)||"#666666",headerStyle:(Fe=(ke=B==null?void 0:B.email)==null?void 0:ke.header)!=null&&Fe.barColor?"border":"plain",logo:(Ge=(Je=(Ie=B==null?void 0:B.email)==null?void 0:Ie.header)==null?void 0:Je.logo)==null?void 0:Ge.image,link:(it=(Re=(St=B==null?void 0:B.email)==null?void 0:St.header)==null?void 0:Re.logo)==null?void 0:it.href,facebookLink:(Y=(ue=(ut=(gt=B==null?void 0:B.email)==null?void 0:gt.footer)==null?void 0:ut.social)==null?void 0:ue.facebook)==null?void 0:Y.url,linkedinLink:(Gr=(mt=(dt=(Ne=B==null?void 0:B.email)==null?void 0:Ne.footer)==null?void 0:dt.social)==null?void 0:mt.linkedin)==null?void 0:Gr.url,instagramLink:(wn=(Qr=(Yr=(Xr=B==null?void 0:B.email)==null?void 0:Xr.footer)==null?void 0:Yr.social)==null?void 0:Qr.instagram)==null?void 0:wn.url,mediumLink:(we=(ae=(X=(z=B==null?void 0:B.email)==null?void 0:z.footer)==null?void 0:X.social)==null?void 0:ae.medium)==null?void 0:we.url,xLink:(br=(ht=(Xe=(be=B==null?void 0:B.email)==null?void 0:be.footer)==null?void 0:Xe.social)==null?void 0:ht.twitter)==null?void 0:br.url}},[x,E]),q=g&&!!J,F=N5(()=>{Object.values(y.current).forEach(B=>clearTimeout(B)),y.current={}},[]);zo(()=>()=>{F()},[F]),zo(()=>{let B=a(U=>{if(U.key==="Escape"&&(f(null),p==null||p.commands.blur(),k.current=-1),U.key==="Tab"&&p){let Z=document.activeElement;if(Z instanceof HTMLInputElement||Z instanceof HTMLTextAreaElement||Z instanceof HTMLSelectElement||(Z==null?void 0:Z.closest("[data-sidebar-form]"))!==null)return;let{$from:G}=p.state.selection,ve=p.isActive("list")||p.isActive("listItem");if(!ve)for(let Ie=G.depth;Ie>=0;Ie--){let Je=G.node(Ie).type.name;if(Je==="list"||Je==="listItem"){ve=!0;break}}if(ve)return;U.preventDefault();let Me=-1;m&&p.state.doc.content.forEach((Ie,Je,Ge)=>{m.attrs.id===Ie.attrs.id&&(Me=Ge)}),Me===-1&&(Me=0);let ke=p.state.doc,Fe;if(U.shiftKey?Fe=(Me-1+ke.childCount)%ke.childCount:Fe=(Me+1)%ke.childCount,Fe!==Me||m===null){let Ie=ke.child(Fe);if(f(Ie),["paragraph","heading"].includes(Ie.type.name)){let Ge=0;for(let Re=0;Re<Fe;Re++)Ge+=ke.child(Re).nodeSize;let St=Ge+Ie.nodeSize-1;p.chain().setTextSelection(St).focus().run()}else p.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",B),()=>{document.removeEventListener("keydown",B)}},[p,m,f]),zo(()=>{if(b!==!1||N)return;let B=M!=null?M:"";if(B){let U=Rm(B,"email");h(U||"")}setTimeout(()=>{if(!(!p||p.isDestroyed)&&p.state.doc.childCount===1){let U=p.state.doc.child(0);f(U)}},0)},[E,b,N,p,h,f,M]),zo(()=>{b===!1&&E&&!w.current&&(w.current=!0,setTimeout(()=>{p&&!p.isDestroyed&&j(p)},300))},[b,E,p,j]),zo(()=>(S.current=!0,()=>{S.current=!1}),[]);let A=N5(B=>{let Z=B||(C===void 0?"desktop":void 0);T(Z),f(null),Z?p==null||p.setEditable(!1):p==null||p.setEditable(!0)},[p,C,T,f]),H=a(B=>{h(B.target.value)},"handleSubjectChange"),_=S5(()=>{if(b!==!1||!O)return null;let B=s&&s.elements&&s.elements.length>0;B&&(w.current=!0);let U;return B&&(U=s.elements.find(K=>K.type==="channel"&&K.channel==="email")),U||(U={type:"channel",channel:"email",elements:Cs}),He({version:"2022-01-01",elements:[U]},{channel:"email"})},[s,b,O]);return N&&(M===null||_===null)?null:ap(tr,{theme:t,colorScheme:l,isLoading:!!b,Header:i?i({hidePublish:e,channels:r,routing:o}):ap(Pr,{hidePublish:e,channels:r,routing:o}),...u,children:ap(q7,{children:n==null?void 0:n({subject:v,handleSubjectChange:H,selectedNode:m,setSelectedNode:f,previewMode:C,templateEditor:p,ref:d,isBrandApply:q,brandSettings:J,items:D,content:_,syncEditorItems:j,brandEditorContent:L,templateData:E,togglePreviewMode:A,hidePreviewPanelExitButton:c})})})}),_c=U7($7);var Wc=class Wc{};a(Wc,"UploadImageAPI"),Wc.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 sp=Wc,lp=sp;var rr=a(e=>{var r;e==null||e.variables,e==null||e.disableVariablesAutocomplete;let t=(e==null?void 0:e.textMarks)==="plain-text"?{bold:"disabled",italic:"disabled",underline:"disabled",strike:"disabled"}:(r=e==null?void 0:e.textMarks)!=null?r:{};return[mm,Ob.configure({document:!1,dropcursor:!1,gapcursor:!1,heading:!1,horizontalRule:!1,paragraph:!1,blockquote:!1,hardBreak:!1,code:!1,bulletList:!1,orderedList:!1,listItem:!1,bold:t.bold==="disabled"?!1:void 0,italic:t.italic==="disabled"?!1:void 0,strike:t.strike==="disabled"?!1:void 0,history:{newGroupDelay:100}}),km.configure({setSelectedNode:e==null?void 0:e.setSelectedNode,shouldHandleClick:e==null?void 0:e.shouldHandleClick}),cl.configure({keepMarks:!0,HTMLAttributes:{class:"my-line-break"}}),mb,ad,wm,rd,kc,Ec,gm.configure({levels:[1,2,3,4,5,6]}),cc,uc,Bb,pl,dc,mc,gl,Cm.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),...t.underline==="disabled"?[]:[Fb],bl.configure(),gc.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(o,n,i)=>{n.forEach(async s=>{let l=await lp.uploadImage(s);o.chain().setImageBlockAt({pos:i,src:l}).focus().run()})},onPaste:(o,n)=>{n.forEach(async i=>{let s=await lp.uploadImage(i);return o.chain().setImageBlockAt({pos:o.state.selection.anchor,src:s}).focus().run()})}}),Vb.extend({addKeyboardShortcuts(){return{}}}).configure({types:["paragraph","heading"]}),Hb,Db.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:"",emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",showOnlyWhenEditable:!0}),Qu.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),Yd,Kn,Jn,hc,vc]},"ExtensionKit");import{BubbleMenu as j7,useCurrentEditor as Z7}from"@tiptap/react";import{jsx as A5}from"react/jsx-runtime";var or=a(({config:e})=>{let{editor:t}=Z7(),r=nc(t);return t?A5(j7,{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&&A5(os,{editor:t,config:e})}):null},"BubbleTextMenu");import{useCurrentEditor as K7}from"@tiptap/react";import{useAtomValue as J7}from"jotai";import{useEffect as I5,useRef as G7}from"react";var nr=a(({variableViewMode:e})=>{let{editor:t}=K7(),r=G7(null),o=J7(Gt);return I5(()=>{if(t&&r.current!==e){if(Zt(t,e)){let i=t.state.tr.setMeta("variableViewModeChanged",!0);t.view.dispatch(i)}r.current=e}},[t,e]),I5(()=>{var n;(n=t==null?void 0:t.storage)!=null&&n.variableInputRule&&(t.storage.variableInputRule.disabled=!o)},[t,o]),null},"VariableViewModeSync");import{TextSelection as X7}from"@tiptap/pm/state";import{EditorProvider as Y7,Extension as Q7,useCurrentEditor as eE}from"@tiptap/react";import{useAtomValue as tE,useSetAtom as L5}from"jotai";import{memo as rE,useEffect as up,useMemo as oE,useRef as R5}from"react";import{jsx as gr,jsxs as cp}from"react/jsx-runtime";var nE=a(({value:e,readOnly:t})=>{let{editor:r}=eE(),o=L5(yi),n=tE(ye),i=R5(!1);return up(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(Am(e!=null?e:"")))},[r,e,n,t]),up(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),iE=a(({facebookLink:e,linkedinLink:t,instagramLink:r,mediumLink:o,xLink:n,readOnly:i=!1,value:s,variableViewMode:l="show-variables",onUpdate:c})=>{let u=R5(!1),d=L5(Te),p=Q7.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:f})=>{let{state:v,dispatch:h}=f.view;return h(v.tr.setSelection(X7.create(v.doc,v.selection.$anchor.pos))),d&&d(null),!1}}}});up(()=>(u.current=!0,()=>{u.current=!1}),[]);let m=oE(()=>[...rr({setSelectedNode:d}),p].filter(f=>f!==void 0),[p,d]);return cp("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[cp(Y7,{content:Am(s!=null?s:""),extensions:m,editable:!i,autofocus:!i,onUpdate:c,editorContainerProps:{className:R("courier-py-2 courier-flex-grow courier-brand-editor",i&&"courier-brand-editor-readonly")},immediatelyRender:!1,children:[gr(nr,{variableViewMode:l}),gr(nE,{value:s,readOnly:i}),gr(or,{})]}),cp("div",{className:"courier-flex courier-justify-end courier-items-center courier-gap-2 courier-mt-3",children:[e&&gr("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:gr(Ti,{className:"courier-w-5 courier-h-5"})}),t&&gr("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:gr(wi,{className:"courier-w-5 courier-h-5"})}),r&&gr("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:gr(Ei,{className:"courier-w-5 courier-h-5"})}),o&&gr("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:gr(ki,{className:"courier-w-5 courier-h-5"})}),n&&gr("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:gr(Pi,{className:"courier-w-5 courier-h-5"})})]})]})},"BrandFooterComponent"),xs=rE(iE);import{Fragment as aE,jsx as ra,jsxs as zc}from"react/jsx-runtime";var B5=a(({value:e,icon:t,...r})=>ra(Ft,{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"),dp=a(({previewMode:e,togglePreviewMode:t,hideMobileToggle:r=!1,hideExitButton:o=!1,...n})=>zc("div",{...n,className:R("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&&zc(aE,{children:[zc(Wr,{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:[ra(B5,{value:"desktop",icon:ra(Nu,{})}),ra(B5,{value:"mobile",icon:ra(Bu,{})})]}),!o&&ra("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),!o&&zc(Ae,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");import{forwardRef as _5}from"react";function sE(){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(sE,"initTestHelpers");function ir(e,t){typeof window!="undefined"&&(sE(),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(ir,"setTestEditor");import{Extension as uE}from"@tiptap/core";import{TextSelection as dE}from"@tiptap/pm/state";import{EditorProvider as mE,useCurrentEditor as pE}from"@tiptap/react";import{useAtom as V5,useAtomValue as Uo,useSetAtom as li}from"jotai";import{useCallback as yn,useEffect as ar,useMemo as fE,useRef as Co}from"react";import{useCurrentEditor as lE}from"@tiptap/react";import{useEffect as cE}from"react";var Mr=a(({value:e,defaultValue:t})=>{let{editor:r}=lE();return cE(()=>{if(!r)return;let o=setTimeout(()=>{r.commands.setContent(e||t)},0);return()=>clearTimeout(o)},[r,e,t]),null},"ReadOnlyEditorContent");import{Fragment as bE,jsx as Ts,jsxs as D5}from"react/jsx-runtime";var mp=!1,$c=!1,Uc=null,gE=a(({value:e})=>{let{editor:t}=pE(),[r,o]=V5(le),n=li(et),i=Uo(Pn),s=Uo(Te),l=li(Le),c=li(Nn),u=Co(!1),d=Co(),p=Uo(ye),m=Uo(bt),f=Co(!1),v=Uo(It);return ar(()=>{p&&(f.current=!1)},[p]),ar(()=>(c({action:"register",id:"email-subject",fn:a(()=>{var y;if(d.current&&(clearTimeout(d.current),d.current=void 0,t&&p===!1&&!v))try{let C=xe(t.getJSON());if(!C||!Array.isArray(C))return;let T=i;if(i===null&&r){let x=(y=r==null?void 0:r.elements)==null?void 0:y.find(k=>k.type==="channel"&&k.channel==="email");x&&(T=wa(x,"email"))}let E=Lr(r,"email",T||"",C),b={elements:E.elements,channel:"email",...E.raw&&{raw:E.raw}},g=Mt(r,b);JSON.stringify(r)!==JSON.stringify(g)&&(o(g),n(g))}catch(C){console.error("[FlushSubjectUpdate]",C)}},"flushSubjectUpdate")}),()=>{c({action:"unregister",id:"email-subject"})}),[t,i,p,v,r,o,n,c]),ar(()=>{!t||p!==!1||f.current||!e||(l(t),f.current=!0,t.commands.setContent(e))},[t,e,l,p]),ar(()=>{var x;if(!t||!r||t.isFocused||$e()||$c)return;let h=document.activeElement;if((h==null?void 0:h.closest("[data-sidebar-form]"))!==null)return;let C=(x=r.elements)==null?void 0:x.find(k=>k.type==="channel"&&k.channel==="email");if(!C)return;let T=C.type==="channel"&&"elements"in C&&C.elements||[],E=He({version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:T}]}),b=xe(E),g=xe(t.getJSON());JSON.stringify(b)!==JSON.stringify(g)&&setTimeout(()=>{let k=document.activeElement,P=(k==null?void 0:k.closest("[data-sidebar-form]"))!==null;!t.isFocused&&!$e()&&!$c&&!P&&(mp=!0,t.commands.setContent(E),setTimeout(()=>{mp=!1},50))},1)},[t,r]),ar(()=>{if(!(!t||p!==!1||v)&&!t.isFocused)return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var h;try{let y=xe(t.getJSON());if(!y||!Array.isArray(y))return;let C=i;if(i===null&&r){let g=(h=r==null?void 0:r.elements)==null?void 0:h.find(x=>x.type==="channel"&&x.channel==="email");g&&(C=wa(g,"email"))}let T=Lr(r,"email",C||"",y),E={elements:T.elements,channel:"email",...T.raw&&{raw:T.raw}},b=Mt(r,E);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]),ar(()=>()=>{t&&!t.isDestroyed&&t.setEditable(!0)},[t]),ar(()=>{t&&u.current&&t.commands.updateSelectionState(s)},[t,s]),ar(()=>(u.current=!0,()=>{u.current=!1}),[]),null},"EditorContent"),hE=a(({value:e,readOnly:t=!1,onDestroy:r,onUpdate:o,subject:n,variables:i,disableVariablesAutocomplete:s=!1,variableViewMode:l="show-variables"})=>{let c=li(Yo),u=Co(),[d,p]=V5(le),m=Uo(Pn),f=n!=null?n:m,v=li(Te),h=Uo(Le),y=Uo(It),C=Uo(Xt),T=li(Nn),E=li(et),b=Co(d),g=Co(f),x=Co(C);ar(()=>{b.current=d},[d]),ar(()=>{g.current=f},[f]),ar(()=>{x.current=C},[C]),ar(()=>{h==null||h.setEditable(!t)},[t,h]);let k=uE.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:q})=>{let{state:F,dispatch:A}=q.view;return A(F.tr.setSelection(dE.create(F.doc,F.selection.$anchor.pos))),v&&v(null),!1}}}}),P=yn(({editor:q})=>{Zt(q,l),o==null||o(q),ir("email",q),v&&setTimeout(()=>{v(null)},100)},[v,o,l]),S=Co(),w=Co(null),M=yn((q,F)=>{var K;if(y)return;let A=b.current,H=g.current;if(!A){let G={version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:F}]};p(G),E(G);return}let _=A.elements.find(G=>G.type==="channel"&&G.channel==="email"),B={..._};B.elements=(K=B.elements)==null?void 0:K.filter(G=>G.type!=="meta");let U={type:"channel",channel:"email",elements:F};if(JSON.stringify(B)!==JSON.stringify(U)){let G=H;!H&&_&&(G=wa(_,"email"));let ve=Lr(A,"email",G||"",F);U.elements=ve.elements,ve.raw&&(U.raw=ve.raw);let Me=Mt(A,U);$c=!0,p(Me),E(Me),Uc&&clearTimeout(Uc),Uc=setTimeout(()=>{$c=!1,Uc=null},300)}o==null||o(q),ir("email",q)},[p,E,o,y]),L=yn(({editor:q})=>{let F=xe(q.getJSON());w.current={editor:q,elemental:F},S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{if(w.current){let{editor:A,elemental:H}=w.current;M(A,H),w.current=null}},200)},[M]),N=yn(({editor:q})=>{if(x.current||mp||$e())return;let{selection:F}=q.state,{$anchor:A}=F,_=F.$head.marks().find(G=>G.type.name==="link");_||q.isActive("link")?c({mark:_}):c(null);let B=A.depth,U=null,Z=null,K=null;for(;B>0;){let G=A.node(B);!Z&&G.type.name==="blockquote"&&(Z=G),!K&&G.type.name==="list"&&(K=G),!U&&(G.type.name==="paragraph"||G.type.name==="heading")&&(U=G),B--}K?v(K):Z?v(Z):U&&v(U)},[c,v]),I=yn(({editor:q,transaction:F})=>{let A=F==null?void 0:F.getMeta("showLinkForm");if(A){let{selection:H}=q.state,B=H.$head.marks().find(U=>U.type.name==="link");c({mark:B,link:{from:A.from,to:A.to}})}},[c]),D=yn(()=>{u.current&&clearTimeout(u.current),S.current&&clearTimeout(S.current),r==null||r(),ir("email",null)},[r]);ar(()=>(T({action:"register",id:"email-content",fn:a(()=>{if(S.current&&(clearTimeout(S.current),S.current=void 0,w.current)){let{editor:F,elemental:A}=w.current;M(F,A),w.current=null}},"flushContentUpdate")}),()=>{T({action:"unregister",id:"email-content"})}),[M,T]);let V=yn(q=>{var B;if(x.current)return;let F=(B=q.view)==null?void 0:B.editor;if(!F||!F.isEditable)return;let A=q.target,H=F.view.posAtDOM(A,0),_=F.state.doc.resolve(H).node();_.type.name==="paragraph"&&v(_)},[v]),W=yn(()=>!x.current,[]),j=fE(()=>[...rr({setSelectedNode:v,shouldHandleClick:W,variables:i,disableVariablesAutocomplete:s}),k].filter(q=>q!==void 0),[k,v,W,i,s]),O=e||{type:"doc",content:[{type:"paragraph"}]},$=t?{editable:!1,autofocus:!1}:{editable:!0,autofocus:!0,onCreate:P,onUpdate:L,onSelectionUpdate:N,onTransaction:I},J=Co(null);return ar(()=>{let q=J.current;if(!(!q||t))return mr({element:q,getData:()=>({type:"editor",id:"editor-drop-zone"}),canDrop:({source:F})=>F.data.type==="sidebar"?!0:F.data.type==="editor"})},[t]),Ts("div",{ref:J,"data-testid":"email-editor",children:D5(mE,{content:O,extensions:j,...$,onDestroy:D,editorContainerProps:{onClick:V},immediatelyRender:!1,children:[Ts(nr,{variableViewMode:l}),t?Ts(Mr,{value:O,defaultValue:Cs}):D5(bE,{children:[Ts(gE,{value:O}),Ts(or,{})]})]})})},"EmailEditor"),pp=hE;import{useAtomValue as qc,useSetAtom as EE}from"jotai";import{AlignVerticalSpaceAround as wE,GripVertical as kE,List as PE,Quote as ME}from"lucide-react";import{forwardRef as yE,useEffect as vE,useRef as CE,useState as xE}from"react";import{jsx as fp}from"react/jsx-runtime";var oa=a(({children:e,id:t,className:r,editor:o})=>fp(TE,{id:t,className:r,editor:o,children:e}),"SideBarSortableItemWrapper"),TE=yE(({children:e,className:t,id:r,editor:o},n)=>{let i=CE(null),[s,l]=xE(!1);return vE(()=>{let c=i.current;if(!(!c||!r))return ro(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]),fp("div",{ref:i,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":r,className:R(t,"courier-relative",s&&"courier-opacity-50 courier-cursor-grabbing"),children:fp("div",{children:e})})});import{Fragment as LE,jsx as ze,jsxs as na}from"react/jsx-runtime";var NE={heading:Ml,text:sn,image:Sl,spacer:Al,divider:nn,button:on,customCode:wl,column:Tl,blockquote:vl,list:an},SE=a(e=>({heading:ze(pd,{}),text:ze(gd,{}),image:ze(fd,{}),spacer:ze(wE,{className:"courier-w-4 courier-h-4"}),divider:ze(md,{}),button:ze(cd,{}),customCode:ze(dd,{}),column:ze(ud,{}),blockquote:ze(ME,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),list:ze(PE,{strokeWidth:1.5,className:"courier-w-4 courier-h-4 courier-text-black dark:courier-text-white"})})[e],"getBlockIcon"),AE=a(e=>dr(e)?`${e.type}:${e.preset}`:e,"getItemKey"),IE=a(({preset:e})=>{let t=e.icon||SE(e.type);return ze(Ze,{draggable:!0,icon:t,draggableLabel:e.label,label:e.label})},"PresetBlock"),gp=a(({items:e,brandEditor:t,label:r,editor:o})=>{var p,m;let n=qc(bt),i=EE(Ii),s=qc(yt),l=qc(to),c=qc(Jo),u=e!=null?e:l,d=a(f=>{if(dr(f)){let h=c.find(y=>y.type===f.type&&y.key===f.preset);return h?ze(IE,{preset:h}):(console.warn(`[SideBar] Preset not found: ${f.type}:${f.preset}`),null)}let v=NE[f];return v?ze(v,{draggable:!0}):null},"renderBlockItem");return na("div",{className:"courier-flex courier-flex-col courier-h-full",children:[na("div",{className:"courier-flex-1",children:[r&&na(LE,{children:[ze("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:r}),ze(pe,{className:"courier-my-4"})]}),ze("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:u.map(f=>{let v=AE(f);return ze(oa,{id:v,editor:o,children:na("div",{className:R("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:[ze(kE,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),d(f)]})},v)})})]}),t&&na("div",{className:"courier-mt-auto courier-pt-4",children:[ze(pe,{className:"courier-mb-4 -courier-mx-4"}),(m=(p=n==null?void 0:n.data)==null?void 0:p.tenant)!=null&&m.brand?ze("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:ze(Ae,{variant:"link",className:"courier-underline",onClick:()=>i("brand"),disabled:!!s,children:"Edit brand"})}):na("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[ze("h3",{className:"courier-text-md courier-font-medium courier-text-foreground",children:"Customize brand theme"}),ze("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),ze(Ae,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>i("brand"),children:"Customize"})]})]})]})},"SideBar");import{useAtomValue as H5}from"jotai";import{jsx as $o,jsxs as RE}from"react/jsx-runtime";var hp=a(({element:e,editor:t,hideCloseButton:r=!1})=>{var l,c;let o=H5(Rn),n=H5(ur);if(!e)return null;if(o!=null&&o.link||((l=o==null?void 0:o.mark)==null?void 0:l.type.name)==="link"&&((c=e.marks)!=null&&c.some(u=>u.type.name==="link")))return $o(Gi,{editor:t,mark:o==null?void 0:o.mark,pendingLink:o==null?void 0:o.link});let i=t==null?void 0:t.isActive("blockquote"),s=a(()=>{if(!t)return;let{$anchor:u}=t.state.selection,d=u.depth;for(;d>0;){let p=u.node(d);if(p.type.name==="blockquote")return p;d--}},"getBlockquoteElement");return RE("div",{className:`courier-flex courier-flex-col courier-gap-4 ${n?"courier-h-full":""}`,children:[e.type.name==="button"&&$o(lc,{element:e,editor:t,hideCloseButton:r},"button-form"),e.type.name==="divider"&&$o(cb,{element:e,editor:t,hideCloseButton:r},e.attrs.id),["paragraph","heading"].includes(e.type.name)&&!i&&$o(v1,{element:e,editor:t,hideCloseButton:r},e.attrs.id),e.type.name==="list"&&!i&&$o(oi,{element:e,editor:t,hideCloseButton:r},e.attrs.id),e.type.name==="imageBlock"&&$o(vb,{element:e,editor:t,hideCloseButton:r},e.attrs.id),e.type.name==="customCode"&&$o(dm,{element:e,editor:t,hideCloseButton:r},e.attrs.id),(e.type.name==="blockquote"||e.type.name==="paragraph"&&i||e.type.name==="heading"&&i||e.type.name==="list"&&i)&&$o(x1,{element:s()||e,editor:t,hideCloseButton:r},e.attrs.id),e.type.name==="column"&&$o(lm,{element:e,editor:t,hideCloseButton:r},e.attrs.id)]})},"SideBarItemDetails");import{forwardRef as F5,useEffect as BE}from"react";import{useAtom as DE}from"jotai";import{Fragment as VE,jsx as jc,jsxs as HE}from"react/jsx-runtime";var ci=F5(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>jc("div",{className:R("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})),ui=F5(({children:e,className:t,previewMode:r,skipExpanded:o=!1,collapsed:n=!1,width:i,...s},l)=>{let[c,u]=DE(ur);BE(()=>{n&&c&&u(!1)},[n,c,u]);let d=o||n?!1:c,p=i||"courier-w-64";return r?null:HE(VE,{children:[d&&jc("div",{className:"courier-absolute courier-inset-0 courier-bg-black/50 courier-z-[40] courier-transition-opacity courier-duration-300 courier-cursor-pointer",onClick:()=>u(!1),"aria-hidden":"true"}),jc("div",{className:R("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch",!d&&"courier-relative",p,t),children:jc("div",{className:R("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",d?"courier-w-[85%] courier-z-[50] courier-shadow-xl courier-bg-background courier-flex courier-flex-col":p),...s,ref:l,children:e})})]})});import{useAtomValue as O5,useSetAtom as FE}from"jotai";import{jsx as sr,jsxs as di}from"react/jsx-runtime";var W5=_5(({children:e,className:t,style:r,...o},n)=>sr("div",{className:R("courier-editor-container courier-email-editor courier-relative",t),style:{...Zg(),...r},...o,ref:n,children:e})),z5=_5(({children:e,previewMode:t,...r},o)=>sr("div",{className:R("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})),U5=a(({variables:e,disableVariablesAutocomplete:t,theme:r,isLoading:o,hidePublish:n,channels:i,brandEditor:s,routing:l,colorScheme:c,...u})=>{let d=O5(le),p=O5(ur),m=FE(ur),f=a(()=>{p&&m(!1)},"handleSubjectAreaClick");return sr(_c,{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:C,previewMode:T,templateEditor:E,ref:b,isBrandApply:g,brandSettings:x,items:k,content:P,syncEditorItems:S,brandEditorContent:w,templateData:M,togglePreviewMode:L,hidePreviewPanelExitButton:N})=>{var I,D,V,W,j,O;return di(ci,{previewMode:T,children:[di("div",{className:"courier-flex courier-flex-col courier-flex-1 courier-min-w-0 courier-overflow-hidden",children:[di("div",{className:"courier-bg-background courier-h-12 courier-flex courier-items-center courier-gap-2 courier-px-4 courier-border-b courier-min-w-0",onClick:f,children:[di("h4",{className:"courier-text-sm courier-h-[25px] courier-flex courier-items-end courier-pb-[3px] courier-shrink-0",children:["Subject:"," "]}),sr(is,{value:v!=null?v:"",onChange:$=>h({target:{value:$}}),onFocus:()=>C(null),className:"!courier-bg-background courier-text-sm courier-flex-1 courier-min-w-0",placeholder:"Write subject...","data-testid":"email-subject-input",readOnly:T!==void 0,showToolbar:!0})]}),di(W5,{ref:b,children:[di(z5,{previewMode:T,children:[g&&di("div",{className:R("courier-py-5 courier-px-9 courier-pb-0 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(x==null?void 0:x.headerStyle)==="border"&&"courier-pt-6"),children:[(x==null?void 0:x.headerStyle)==="border"&&sr("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:x==null?void 0:x.brandColor}}),(x==null?void 0:x.logo)&&sr("img",{src:x.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),P&&sr(pp,{value:P,onUpdate:S,variables:e,disableVariablesAutocomplete:t},`email-editor-${t?"no-autocomplete":"autocomplete"}`),g&&M&&sr("div",{className:"courier-py-5 courier-px-9 courier-pt-0 courier-flex courier-flex-col",children:sr(xs,{readOnly:!0,value:w!=null?w:(O=(j=(W=(V=(D=(I=M==null?void 0:M.data)==null?void 0:I.tenant)==null?void 0:D.brand)==null?void 0:V.settings)==null?void 0:W.email)==null?void 0:j.footer)==null?void 0:O.markdown,variables:e,facebookLink:x==null?void 0:x.facebookLink,linkedinLink:x==null?void 0:x.linkedinLink,instagramLink:x==null?void 0:x.instagramLink,mediumLink:x==null?void 0:x.mediumLink,xLink:x==null?void 0:x.xLink})})]}),sr(dp,{previewMode:T,togglePreviewMode:L,hideExitButton:N})]})]}),sr(ui,{previewMode:T,children:sr("div",{className:"courier-p-1 courier-h-full",children:y?sr(hp,{element:y,editor:E}):sr(gp,{items:k.Sidebar,brandEditor:s,label:"Blocks library",editor:E!=null?E:void 0})})})]})},...u})},"EmailLayout");import{useCurrentEditor as OE}from"@tiptap/react";import{useAtom as _E,useAtomValue as Zc,useSetAtom as bp}from"jotai";import{forwardRef as WE,memo as zE,useCallback as UE,useEffect as Es,useMemo as $5,useRef as yp}from"react";import{jsx as q5}from"react/jsx-runtime";var ws=[{type:"text",content:`
230
231
  `,text_style:"h2"},{type:"text",content:`
231
- `},{type:"action",content:"Register",align:"left",href:""}],g5=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:fs};else if(t.type==="channel"&&"elements"in t){let r=t.elements||[],o=r.find(p=>p.type==="meta"),n=r.filter(p=>p.type!=="meta"),i=n.filter(p=>p.type==="text"),s=n.filter(p=>p.type==="action"),c={type:"text",content:(o&&"title"in o&&o.title||"")+`
232
+ `},{type:"action",content:"Register",align:"left",href:""}],Kc=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:ws};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||"")+`
232
233
  `,text_style:"h2"},u=i[0],d={type:"text",content:u&&"content"in u?u.content:`
233
- `};t={...t,elements:[c,d,...s]}}return t},"getOrCreateInboxElement"),h5={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"}},b5=a(({value:e})=>{let{editor:t}=V7(),r=Xm(Ae),o=Rc(de),n=Rc(he),i=Ym(!1);return ps(()=>{n&&(i.current=!1)},[n]),ps(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),ps(()=>{t&&(r(t),Yt("inbox",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),ps(()=>{if(!t||!o||t.isFocused)return;let s=g5(o),l=$e({version:"2022-01-01",elements:[s]},{channel:"inbox"}),c=ve(l),u=ve(t.getJSON());JSON.stringify(c)!==JSON.stringify(u)&&setTimeout(()=>{t.isFocused||t.commands.setContent(l)},1)},[t,o]),null},"InboxEditorContent"),_7=F7(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...m},p)=>{let g=Rc(he),v=Ym(!0),b=Ym(!1),y=Xm(Ce),[C,x]=H7(de),h=Xm(Ye),f=Rc(kt);ps(()=>(b.current=!0,()=>{b.current=!1}),[]);let E=p5(()=>[...Gt({setSelectedNode:y,variables:u,disableVariablesAutocomplete:d,textMarks:"plain-text"})].filter(P=>P!==void 0),[y,u,d]),T=W7(({editor:P})=>{if(!P||f)return;if(!C){let M=ve(P.getJSON()),I=Er(null,"inbox","",M),D={version:"2022-01-01",elements:[{type:"channel",channel:"inbox",elements:I.elements,...I.raw&&{raw:I.raw}}]};x(D),h(D);return}let N=P.getJSON(),k=ve(N),S=Er(C,"inbox","",k),B=xt(C,{elements:S.elements,channel:"inbox",...S.raw&&{raw:S.raw}});JSON.stringify(C)!==JSON.stringify(B)&&(x(B),h(B))},[C,x,h,f]),w=p5(()=>{if(g!==!1)return null;let P=l!=null?l:C,N=g5(P);return $e({version:"2022-01-01",elements:[N]},{channel:"inbox"})},[g]);return f5(Kt,{theme:e,colorScheme:c,isLoading:!!(g&&v.current),Header:i?i({hidePublish:t,channels:o,routing:n}):f5(hr,{hidePublish:t,channels:o,routing:n}),...m,ref:p,children:s==null?void 0:s({content:w,extensions:E,editable:!r,autofocus:!1,onUpdate:T})})}),Bc=O7(_7);import{EditorProvider as U7}from"@tiptap/react";import{useCallback as $7}from"react";import{Fragment as z7,jsx as Lo,jsxs as Gi}from"react/jsx-runtime";var Qm=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1,variableViewMode:s="show-variables"})=>{let l=$7(({editor:u})=>{Ut(u,s)},[s]);return e?Gi("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:[Gi("div",{className:"courier-my-3 courier-mx-4 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[Gi("div",{className:"courier-flex courier-items-center courier-gap-3",children:[Lo(xa,{}),Lo("span",{className:"courier-text-xl courier-font-medium",children:"In-app"})]}),Gi("div",{className:"courier-flex courier-items-center courier-gap-4",children:[Lo(gu,{}),Lo(Ca,{}),Lo(vu,{})]})]}),Gi(U7,{content:e,extensions:t,...i?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},onCreate:l,editorContainerProps:{className:R("courier-inbox-editor")},immediatelyRender:!1,children:[Lo(vr,{variableViewMode:s}),i?Lo(yr,{value:e,defaultValue:fs}):Gi(z7,{children:[Lo(b5,{value:e}),Lo(Xt,{config:h5})]})]})]}):null},"InboxEditor");import{useSetAtom as j7}from"jotai";import{useCallback as y5,useEffect as v5,useRef as ep}from"react";function tp(e,t,r=500){let o=j7(hn),n=ep(),i=ep(void 0),s=ep(t);v5(()=>{s.current=t},[t]);let l=y5(()=>{n.current&&(clearTimeout(n.current),n.current=void 0),i.current!==void 0&&(s.current(i.current),i.current=void 0)},[]);return v5(()=>(o({action:"register",id:e,fn:l}),()=>{l(),o({action:"unregister",id:e}),n.current&&clearTimeout(n.current)}),[e,o,l]),y5(u=>{i.current=u,n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{l()},r)},[r,l])}a(tp,"useDebouncedFlush");import{zodResolver as q7}from"@hookform/resolvers/zod";import{useAtom as Z7,useAtomValue as J7,useSetAtom as K7}from"jotai";import{memo as G7,useCallback as Dc,useEffect as rp,useRef as op}from"react";import{useForm as X7}from"react-hook-form";import{z as ti}from"zod";import{jsx as tt,jsxs as gs}from"react/jsx-runtime";var Y7=ti.object({enableButton:ti.boolean().default(!0),buttonLabel:ti.string().default("Try now"),buttonUrl:ti.string().default(""),enableSecondaryButton:ti.boolean().default(!1),secondaryButtonLabel:ti.string().default("Learn more"),secondaryButtonUrl:ti.string().default("")}),Q7=a(()=>{let e=J7(Ae),[t,r]=Z7(de),o=K7(Ye),n=op(!1),i=op(null),s=op(t);rp(()=>{s.current=t},[t]);let l=X7({resolver:q7(Y7),defaultValues:{enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""},mode:"onChange"});rp(()=>{if(!e)return;let g=a(()=>{let{doc:v}=e.state,b=null,y=[];if(v.descendants(C=>C.type.name==="buttonRow"&&!b?(b=C.attrs,!1):(C.type.name==="button"&&y.length<2&&y.push(C.attrs),!0)),n.current=!0,b){let{button1Label:C,button1Link:x,button2Label:h,button2Link:f}=b,E=l.getValues();E.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),E.buttonLabel!==(C||"Try now")&&l.setValue("buttonLabel",C||"Try now",{shouldDirty:!1}),E.buttonUrl!==(x||"")&&l.setValue("buttonUrl",x||"",{shouldDirty:!1}),E.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),E.secondaryButtonLabel!==(h||"Learn more")&&l.setValue("secondaryButtonLabel",h||"Learn more",{shouldDirty:!1}),E.secondaryButtonUrl!==(f||"")&&l.setValue("secondaryButtonUrl",f||"",{shouldDirty:!1})}else if(y.length>0){let C=y[0],x=l.getValues();if(x.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),x.buttonLabel!==(C.label||"Try now")&&l.setValue("buttonLabel",C.label||"Try now",{shouldDirty:!1}),x.buttonUrl!==(C.link||"")&&l.setValue("buttonUrl",C.link||"",{shouldDirty:!1}),y.length>1){let h=y[1];x.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),x.secondaryButtonLabel!==(h.label||"Learn more")&&l.setValue("secondaryButtonLabel",h.label||"Learn more",{shouldDirty:!1}),x.secondaryButtonUrl!==(h.link||"")&&l.setValue("secondaryButtonUrl",h.link||"",{shouldDirty:!1})}else x.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 g(),e.on("update",g),()=>{e.off("update",g)}},[e,l]),rp(()=>{if(e||!t||n.current)return;n.current=!0;let g=t.elements.find(b=>b.type==="channel"&&b.channel==="inbox");if(!g||!g.elements){n.current=!1;return}let v=g.elements.filter(b=>b.type==="action");if(v.length>0){let b=v[0],y=v[1];l.setValue("enableButton",!0),l.setValue("buttonLabel",b.content||"Register"),l.setValue("buttonUrl",b.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=Dc(g=>{let v=s.current;if(!v||n.current)return;let b=v.elements.find(T=>T.type==="channel"&&T.channel==="inbox");b||(b={type:"channel",channel:"inbox",elements:[{type:"text",content:`
234
+ `};t={...t,elements:[c,d,...s]}}return t},"getOrCreateInboxElement"),j5={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"}},Z5=a(({value:e})=>{let{editor:t}=OE(),r=bp(Le),o=Zc(le),n=Zc(ye),i=yp(!1);return Es(()=>{n&&(i.current=!1)},[n]),Es(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),Es(()=>{t&&(r(t),ir("inbox",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),Es(()=>{if(!t||!o||t.isFocused||$e())return;let s=document.activeElement;if(s!=null&&s.closest("[data-sidebar-form]"))return;let l=Kc(o),c=He({version:"2022-01-01",elements:[l]},{channel:"inbox"}),u=xe(c),d=xe(t.getJSON());JSON.stringify(u)!==JSON.stringify(d)&&setTimeout(()=>{let p=document.activeElement,m=(p==null?void 0:p.closest("[data-sidebar-form]"))!==null;!t.isFocused&&!$e()&&!m&&t.commands.setContent(c)},1)},[t,o]),null},"InboxEditorContent"),$E=WE(({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=Zc(ye),v=yp(!0),h=yp(!1),y=bp(Te),[C,T]=_E(le),E=bp(et),b=Zc(It);Es(()=>(h.current=!0,()=>{h.current=!1}),[]);let g=$5(()=>[...rr({setSelectedNode:y,variables:u,disableVariablesAutocomplete:d,textMarks:"plain-text"})].filter(P=>P!==void 0),[y,u,d]),x=UE(({editor:P})=>{if(!P||b)return;if(!C){let N=xe(P.getJSON()),I=Lr(null,"inbox","",N),D={version:"2022-01-01",elements:[{type:"channel",channel:"inbox",elements:I.elements,...I.raw&&{raw:I.raw}}]};T(D),E(D);return}let S=P.getJSON(),w=xe(S),M=Lr(C,"inbox","",w),L=Mt(C,{elements:M.elements,channel:{channel:"inbox",...M.raw&&{raw:M.raw}}});JSON.stringify(C)!==JSON.stringify(L)&&(T(L),E(L))},[C,T,E,b]),k=$5(()=>{if(f!==!1)return null;let P=l!=null?l:C,S=Kc(P);return He({version:"2022-01-01",elements:[S]},{channel:"inbox"})},[f]);return q5(tr,{theme:e,colorScheme:c,isLoading:!!(f&&v.current),Header:i?i({hidePublish:t,channels:o,routing:n}):q5(Pr,{hidePublish:t,channels:o,routing:n}),...p,ref:m,children:s==null?void 0:s({content:k,extensions:g,editable:!r,autofocus:!1,onUpdate:x})})}),Jc=zE($E);import{EditorProvider as qE}from"@tiptap/react";import{useCallback as jE}from"react";import{Fragment as ZE,jsx as qo,jsxs as ia}from"react/jsx-runtime";var vp=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1,variableViewMode:s="show-variables"})=>{let l=jE(({editor:u})=>{Zt(u,s)},[s]);return e?ia("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:[ia("div",{className:"courier-my-3 courier-mx-4 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[ia("div",{className:"courier-flex courier-items-center courier-gap-3",children:[qo(La,{}),qo("span",{className:"courier-text-xl courier-font-medium",children:"In-app"})]}),ia("div",{className:"courier-flex courier-items-center courier-gap-4",children:[qo(Iu,{}),qo(Ia,{}),qo(Du,{})]})]}),ia(qE,{content:e,extensions:t,...i?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},onCreate:l,editorContainerProps:{className:R("courier-inbox-editor")},immediatelyRender:!1,children:[qo(nr,{variableViewMode:s}),i?qo(Mr,{value:e,defaultValue:ws}):ia(ZE,{children:[qo(Z5,{value:e}),qo(or,{config:j5})]})]})]}):null},"InboxEditor");import{useSetAtom as KE}from"jotai";import{useCallback as K5,useEffect as J5,useRef as Cp}from"react";function xp(e,t,r=500){let o=KE(Nn),n=Cp(),i=Cp(void 0),s=Cp(t);J5(()=>{s.current=t},[t]);let l=K5(()=>{n.current&&(clearTimeout(n.current),n.current=void 0),i.current!==void 0&&(s.current(i.current),i.current=void 0)},[]);return J5(()=>(o({action:"register",id:e,fn:l}),()=>{l(),o({action:"unregister",id:e}),n.current&&clearTimeout(n.current)}),[e,o,l]),K5(u=>{i.current=u,n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{l()},r)},[r,l])}a(xp,"useDebouncedFlush");import{zodResolver as JE}from"@hookform/resolvers/zod";import{useAtom as GE,useAtomValue as XE,useSetAtom as YE}from"jotai";import{memo as QE,useCallback as Tp,useEffect as Gc,useRef as Ep}from"react";import{useForm as ew}from"react-hook-form";import{z as mi}from"zod";import{jsx as nt,jsxs as ks}from"react/jsx-runtime";var tw=mi.object({enableButton:mi.boolean().default(!0),buttonLabel:mi.string().default("Try now"),buttonUrl:mi.string().default(""),enableSecondaryButton:mi.boolean().default(!1),secondaryButtonLabel:mi.string().default("Learn more"),secondaryButtonUrl:mi.string().default("")}),rw=a(()=>{let e=XE(Le),[t,r]=GE(le),o=YE(et),n=Ep(!1),i=Ep(null),s=Ep(t);Gc(()=>{s.current=t},[t]);let l=ew({resolver:JE(tw),defaultValues:{enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""},mode:"onChange"});Gc(()=>{if(!e)return;let m=a(()=>{let{doc:f}=e.state,v=null,h=[];if(f.descendants(y=>y.type.name==="buttonRow"&&!v?(v=y.attrs,!1):(y.type.name==="button"&&h.length<2&&h.push(y.attrs),!0)),n.current=!0,v){let{button1Label:y,button1Link:C,button2Label:T,button2Link:E}=v,b=l.getValues();b.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),b.buttonLabel!==(y||"Try now")&&l.setValue("buttonLabel",y||"Try now",{shouldDirty:!1}),b.buttonUrl!==(C||"")&&l.setValue("buttonUrl",C||"",{shouldDirty:!1}),b.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),b.secondaryButtonLabel!==(T||"Learn more")&&l.setValue("secondaryButtonLabel",T||"Learn more",{shouldDirty:!1}),b.secondaryButtonUrl!==(E||"")&&l.setValue("secondaryButtonUrl",E||"",{shouldDirty:!1})}else if(h.length>0){let y=h[0],C=l.getValues();if(C.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),C.buttonLabel!==(y.label||"Try now")&&l.setValue("buttonLabel",y.label||"Try now",{shouldDirty:!1}),C.buttonUrl!==(y.link||"")&&l.setValue("buttonUrl",y.link||"",{shouldDirty:!1}),h.length>1){let T=h[1];C.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),C.secondaryButtonLabel!==(T.label||"Learn more")&&l.setValue("secondaryButtonLabel",T.label||"Learn more",{shouldDirty:!1}),C.secondaryButtonUrl!==(T.link||"")&&l.setValue("secondaryButtonUrl",T.link||"",{shouldDirty:!1})}else C.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 m(),e.on("update",m),()=>{e.off("update",m)}},[e,l]),Gc(()=>{if(e||!t||n.current)return;n.current=!0;let m=t.elements.find(v=>v.type==="channel"&&v.channel==="inbox");if(!m||!m.elements){n.current=!1;return}let f=m.elements.filter(v=>v.type==="action");if(f.length>0){let v=f[0],h=f[1];l.setValue("enableButton",!0),l.setValue("buttonLabel",v.content||"Register"),l.setValue("buttonUrl",v.href||""),h?(l.setValue("enableSecondaryButton",!0),l.setValue("secondaryButtonLabel",h.content||"Learn more"),l.setValue("secondaryButtonUrl",h.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=Tp(m=>{let f=s.current;if(!f||n.current)return;let v=f.elements.find(g=>g.type==="channel"&&g.channel==="inbox");v||(v={type:"channel",channel:"inbox",elements:[{type:"text",content:`
234
235
  `,text_style:"h2"},{type:"text",content:`
235
- `}]}),b.elements||(b.elements=[]);let C=[...b.elements.filter(T=>T.type!=="action")];if(g.enableButton){let T={type:"action",content:g.buttonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:g.buttonUrl};C.push(T)}if(g.enableSecondaryButton){let T={type:"action",content:g.secondaryButtonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:g.secondaryButtonUrl};C.push(T)}let x={...b,elements:C},h=v.elements.findIndex(T=>T.type==="channel"&&T.channel==="inbox"),f=[...v.elements];h!==-1?f[h]=x:f.push(x);let E={...v,elements:f};r(E),o(E)},[r,o]),u=Dc(g=>{if(!e)return!1;let{doc:v}=e.state,b=null,y=[];v.descendants((x,h)=>x.type.name==="buttonRow"&&b===null?(b=h,!1):(x.type.name==="button"&&y.push({pos:h,attrs:x.attrs}),!0));let C=a((x,h)=>{let f=v.nodeAt(x);return f?(e.commands.command(({tr:E})=>(E.setNodeMarkup(x,f.type,h),!0)),!0):!1},"applyAttrs");if(b!==null){let x=v.nodeAt(b);if(!x)return!1;let h={...x.attrs,button1Label:g.buttonLabel,button1Link:g.buttonUrl,button2Label:g.secondaryButtonLabel,button2Link:g.secondaryButtonUrl};return C(b,h)}if(y.length>0){let[x,h]=y,f={...x.attrs,label:g.buttonLabel,link:g.buttonUrl},E=C(x.pos,f),T=!0;if(h){let w={...h.attrs,label:g.secondaryButtonLabel,link:g.secondaryButtonUrl};T=C(h.pos,w)}return E&&T}return!1},[e]),d=Dc(g=>{if(n.current)return;let v=i.current;if(i.current=g,!v||v.enableButton!==g.enableButton||v.enableSecondaryButton!==g.enableSecondaryButton){c(g);return}u(g)||c(g)},[c,u]),m=tp("inbox-sidebar",d,500),p=Dc(()=>{let g=l.getValues();m(g)},[l,m]);return tt(He,{...l,children:gs("form",{onChange:p,children:[tt("div",{className:"courier-pb-4",children:tt(te,{control:l.control,name:"enableButton",render:({field:g})=>gs(Q,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between",children:[tt(to,{className:"!courier-m-0",children:"Enable button"}),tt(ee,{children:tt($i,{checked:g.value,onCheckedChange:g.onChange,className:"!courier-m-0"})})]})})}),l.watch("enableButton")&&tt(te,{control:l.control,name:"buttonUrl",render:({field:g})=>gs(Q,{className:"courier-mb-6",children:[tt(to,{children:"Action URL"}),tt(ee,{children:tt(be,{placeholder:"https://example.com",...g})}),tt(re,{})]})}),tt(pe,{className:"courier-mb-6"}),tt(te,{control:l.control,name:"enableSecondaryButton",render:({field:g})=>gs(Q,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between courier-mb-4",children:[tt(to,{className:"!courier-m-0",children:"Enable secondary button"}),tt(ee,{children:tt($i,{checked:g.value,onCheckedChange:g.onChange,className:"!courier-m-0"})})]})}),l.watch("enableSecondaryButton")&&tt(te,{control:l.control,name:"secondaryButtonUrl",render:({field:g})=>gs(Q,{className:"courier-mb-4",children:[tt(to,{children:"Action URL"}),tt(ee,{children:tt(be,{placeholder:"https://example.com",...g})}),tt(re,{})]})})]})})},"SideBarComponent"),np=G7(Q7);import{useAtomValue as eE}from"jotai";import{jsx as Xi,jsxs as tE}from"react/jsx-runtime";var C5=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s,...l})=>{let c=eE(de);return Xi(Bc,{value:c,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:u=>tE("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[Xi("div",{className:"courier-flex courier-flex-col courier-flex-1 courier-py-8 courier-items-center",children:Xi(Qm,{...u},`inbox-editor-${o?"no-autocomplete":"autocomplete"}`)}),Xi("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:Xi("div",{className:"courier-p-4 courier-h-full",children:Xi(np,{})})})]}),...l})},"InboxLayout");import{useCurrentEditor as rE}from"@tiptap/react";import{useAtom as oE,useAtomValue as Vc,useSetAtom as ip}from"jotai";import{forwardRef as nE,memo as iE,useCallback as aE,useEffect as hs,useMemo as x5,useRef as ap}from"react";import{jsx as T5}from"react/jsx-runtime";var E5=a(({value:e})=>{let{editor:t}=rE(),r=ip(Ae),o=Vc(de),n=Vc(he),i=ap(!1);return hs(()=>{n&&(i.current=!1)},[n]),hs(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),hs(()=>{t&&(r(t),Yt("push",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),hs(()=>{if(!t||!o||t.isFocused)return;let s=w5(o),l=s.type==="channel"&&"elements"in s&&s.elements||ri;l=l.map(p=>p.type==="meta"&&"title"in p?{type:"text",content:p.title||`
236
- `,text_style:"h2"}:p);let u=$e({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:l}]}),d=ve(u),m=ve(t.getJSON());JSON.stringify(d)!==JSON.stringify(m)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"PushEditorContent"),ri=[{type:"meta",title:""},{type:"text",content:`
237
- `}],w5=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:ri}),t},"getOrCreatePushElement"),k5={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"}},sE=nE(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...m},p)=>{let g=Vc(he),v=ap(!0),b=ap(!1),y=ip(Ce),[C,x]=oE(de),h=ip(Ye),f=Vc(kt);hs(()=>(b.current=!0,()=>{b.current=!1}),[]);let E=x5(()=>[...Gt({setSelectedNode:y,variables:u,disableVariablesAutocomplete:d,textMarks:"plain-text"})].filter(P=>P!==void 0),[y,u,d]),T=aE(({editor:P})=>{if(f)return;if(!C){let D=ve(P.getJSON()),V=D[0],_="",W=D;V&&V.type==="text"&&"text_style"in V&&V.text_style==="h2"&&(_=yn(V).trim(),W=D.slice(1));let L={version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:Er(null,"push",_,W).elements}]};x(L),h(L);return}let N=ve(P.getJSON()),k=N[0],S="",B=N;k&&k.type==="text"&&"text_style"in k&&k.text_style==="h2"&&(S=yn(k).trim(),B=N.slice(1));let M=Er(C,"push",S,B),I=xt(C,{channel:"push",elements:M.elements});JSON.stringify(C)!==JSON.stringify(I)&&(x(I),h(I))},[C,x,h,f]),w=x5(()=>{var B;if(g!==!1)return null;let P=l!=null?l:C,N=(B=P==null?void 0:P.elements)==null?void 0:B.find(M=>M.type==="channel"&&M.channel==="push");N||(N=w5(P));let k=(N==null?void 0:N.type)==="channel"&&"elements"in N&&N.elements||ri;return k=k.map(M=>M.type==="meta"&&"title"in M?{type:"text",content:M.title||`
238
- `,text_style:"h2"}:M),$e({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:k}]})},[g]);return T5(Kt,{theme:e,colorScheme:c,isLoading:!!(g&&v.current),Header:i?i({hidePublish:t,channels:o,routing:n}):T5(hr,{hidePublish:t,channels:o,routing:n}),...m,ref:p,children:s==null?void 0:s({content:w,extensions:E,editable:!r,autofocus:!r,onUpdate:T})})}),Hc=iE(sE);import{EditorProvider as lE}from"@tiptap/react";import{useCallback as cE}from"react";import{jsx as Ro,jsxs as Fc}from"react/jsx-runtime";var Oc=a(({children:e})=>Fc("div",{className:"courier-relative",children:[Ro("div",{className:"courier-absolute courier-w-0.5 courier-h-6 courier-bg-border -courier-left-[2px] courier-top-[136px]"}),Ro("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[178px]"}),Ro("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[245px]"}),Ro("div",{className:"courier-absolute courier-w-0.5 courier-h-[78px] courier-bg-border -courier-right-[2px] courier-top-[200px]"}),Fc("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:[Fc("div",{className:"courier-my-6 courier-mx-11 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[Ro("span",{className:"courier-text-xs courier-font-semibold",children:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),Fc("div",{className:"courier-flex courier-items-center courier-gap-2",children:[Ro(xf,{}),Ro(Mf,{}),Ro(Qp,{})]})]}),Ro("div",{className:"courier-flex-1 courier-overflow-auto courier-h-[calc(90%-56px)] courier-mb-6",children:e})]})]}),"IPhoneFrame");import{Fragment as uE,jsx as Yi,jsxs as Wc}from"react/jsx-runtime";var sp=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:s=!1,variableViewMode:l="show-variables"})=>{let c=e||{type:"doc",content:[{type:"paragraph"}]},u=s?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},d=cE(({editor:m})=>{Ut(m,l)},[l]);return Wc(Oc,{children:[Wc("div",{className:R("courier-px-4 courier-py-2 courier-text-[#A3A3A3] courier-text-center courier-my-8",i),children:[Yi("p",{className:"courier-text-lg courier-font-medium",children:new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}),Yi("p",{className:"courier-text-5xl courier-font-semibold courier-mt-1",children:new Date().toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})})]}),Wc(lE,{content:c,extensions:t,...u,onCreate:d,editorContainerProps:{className:R("courier-push-editor")},"data-testid":"editor-provider",immediatelyRender:!1,children:[Yi(vr,{variableViewMode:l}),s?Yi(yr,{value:c,defaultValue:ri}):Wc(uE,{children:[Yi(E5,{value:c}),Yi(Xt,{config:k5})]})]})]})},"PushEditor");import{useAtomValue as dE}from"jotai";import{jsx as lp}from"react/jsx-runtime";var P5=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,...s})=>{let l=dE(de);return lp(Hc,{value:l,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,render:c=>lp("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:lp(sp,{...c},`push-editor-${o?"no-autocomplete":"autocomplete"}`)}),...s})},"PushLayout");import{useCurrentEditor as mE}from"@tiptap/react";import{useAtom as M5,useAtomValue as sn,useSetAtom as S5}from"jotai";import{forwardRef as pE,memo as fE,useCallback as N5,useEffect as Br,useMemo as _c,useRef as ea,useState as A5}from"react";import{Fragment as CE,jsx as cp}from"react/jsx-runtime";var bs=[{type:"text",content:`
239
- `}],I5=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:bs}),t},"getOrCreateSlackElement"),L5=a(({value:e})=>{let{editor:t}=mE(),r=S5(Ae),o=sn(de),n=sn(he),i=sn(Ce),s=ea(!1),l=ea(!1);return Br(()=>{n&&(s.current=!1)},[n]),Br(()=>{!t||n!==!1||s.current||!e||(s.current=!0,t.commands.setContent(e))},[t,e,n]),Br(()=>{t&&(r(t),Yt("slack",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),Br(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),Br(()=>(l.current=!0,()=>{l.current=!1}),[]),Br(()=>{if(!t||!o||t.isFocused)return;let c=I5(o),u=$e({version:"2022-01-01",elements:[c]},{channel:"slack"}),d=ve(u),m=ve(t.getJSON());JSON.stringify(d)!==JSON.stringify(m)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"SlackEditorContent"),gE={alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"}},hE=[{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"]}}],Qi={conditionalRules:hE,...gE},bE={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"},...Qi},yE=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"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"enabled"},variable:{state:"enabled"},...Qi};if(r&&!t)return{contentType:{state:"enabled"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},quote:{state:"enabled"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:"hidden"},variable:{state:"enabled"},...Qi};switch(e){case"list":return{contentType:{state:"hidden"},bold:{state:t?"enabled":"hidden"},italic:{state:t?"enabled":"hidden"},underline:{state:t?"enabled":"hidden"},strike:{state:t?"enabled":"hidden"},quote:{state:"hidden"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:t?"enabled":"hidden"},variable:{state:"enabled"},...Qi};case"button":return{bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},...Qi};default:return{contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"},...Qi}}},"getTextMenuConfigForSlackNode"),vE=pE(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...m},p)=>{let g=sn(he),v=sn(kt),b=sn(Ae),y=sn(qt),[C,x]=M5(Ce),[h,f]=M5(de),E=S5(Ye),T=ea(!0),w=ea(!1),P=ea(y),N=ea(null),k=sn(Ur),[S,B]=A5(!1);Br(()=>{if(!b)return;let A=a(()=>{var H;try{let O=(H=b.state)==null?void 0:H.selection;if(O){let{from:j,to:Z}=O;B(j!==Z)}}catch{}},"updateSelection");return b.on("selectionUpdate",A),b.on("transaction",A),A(),()=>{b.off("selectionUpdate",A),b.off("transaction",A)}},[b]);let M=_c(()=>C?yE(C.type.name,S):bE,[C,S]),I=_c(()=>{let A=["text","divider","button","list"];return k.filter(H=>{let O=or(H)?H.type:H;return A.includes(O)})},[k]),[D,V]=A5({Sidebar:I,Editor:[]});Br(()=>{V(A=>({...A,Sidebar:I}))},[I]),qi({items:D,setItems:V});let{syncEditorItems:_}=kc({setItems:V,rafId:N});Br(()=>(w.current=!0,()=>{w.current=!1}),[]),Br(()=>{P.current=y},[y]),Br(()=>{g===!1&&h&&setTimeout(()=>{b&&!b.isDestroyed&&_(b)},300)},[g,h,b,_]);let W=N5(()=>!P.current,[]),F=_c(()=>[...Gt({setSelectedNode:x,shouldHandleClick:W,variables:u,disableVariablesAutocomplete:d})].filter(A=>A!==void 0),[x,W,u,d]),L=N5(({editor:A})=>{if(!A||v)return;if(!h){let ne={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:ve(A.getJSON())}]};f(ne),E(ne);return}let H=A.getJSON(),O=ve(H),j=xt(h,{elements:O,channel:"slack"}),Z=JSON.stringify(h.elements),U=JSON.stringify(j.elements);Z!==U&&(f(j),E(j))},[h,f,E,v]),$=_c(()=>{let A=I5(l);return $e({version:"2022-01-01",elements:[A]},{channel:"slack"})},[l]);return cp(Kt,{theme:e,colorScheme:c,isLoading:!!(g&&T.current),Header:i?i({hidePublish:t,channels:o,routing:n}):cp(hr,{hidePublish:t,channels:o,routing:n}),ref:p,...m,children:cp(CE,{children:s==null?void 0:s({content:$,extensions:F,editable:!r,autofocus:!r,onUpdate:L,items:D,selectedNode:C,slackEditor:b,textMenuConfig:M})})})}),Uc=fE(vE);import{EditorProvider as EE}from"@tiptap/react";import{jsx as Dt,jsxs as ta}from"react/jsx-runtime";var xE=a(()=>ta("div",{className:"courier-flex courier-gap-2 courier-flex-col courier-w-full",children:[Dt("div",{className:"courier-w-3/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),Dt("div",{className:"courier-w-full courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),Dt("div",{className:"courier-w-6/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"})]}),"TextSkeleton"),TE=a(()=>Dt("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-lg",children:Dt(wa,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),R5=a(()=>ta("div",{className:"courier-flex courier-gap-2 courier-flex-row",children:[Dt(TE,{}),Dt(xE,{})]}),"InteractionSkeleton"),B5=a(({children:e,className:t})=>ta("div",{className:R("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:[Dt(R5,{}),ta("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[Dt("div",{className:"courier-flex-shrink-0",children:Dt("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:Dt(Ea,{color:"#FFFFFF"})})}),ta("div",{className:"courier-flex-1 courier-min-w-0",children:[ta("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mb-1",children:[Dt("span",{className:"courier-font-semibold courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1]",children:"Circle"}),Dt("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"}),Dt("span",{className:"courier-text-xs courier-text-gray-500 dark:courier-text-[#8786A9]",children:"Now"})]}),Dt("div",{className:"courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-pr-4",children:e})]})]}),Dt(R5,{})]}),"SlackFrame");import{useRef as wE,useEffect as kE,useCallback as up}from"react";import{useSetAtom as D5}from"jotai";import{Fragment as PE,jsx as ra,jsxs as V5}from"react/jsx-runtime";var dp=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1,variableViewMode:s="show-variables",textMenuConfig:l})=>{let c=wE(null),u=D5(Re),d=D5(Oo),m=up(({editor:v})=>{Ut(v,s)},[s]),p=up(({editor:v})=>{if(Vo())return;let{selection:b}=v.state,{$anchor:y}=b,x=b.$head.marks().find(w=>w.type.name==="link");x||v.isActive("link")?d({mark:x}):d(null);let h=y.depth,f=null,E=null,T=null;for(;h>0;){let w=y.node(h);!E&&w.type.name==="blockquote"&&(E=w),!T&&w.type.name==="list"&&(T=w),!f&&(w.type.name==="paragraph"||w.type.name==="heading")&&(f=w),h--}T?u(T):E?u(E):f&&u(f)},[d,u]),g=up(({editor:v,transaction:b})=>{let y=b==null?void 0:b.getMeta("showLinkForm");if(y){let{selection:C}=v.state,h=C.$head.marks().find(f=>f.type.name==="link");d({mark:h,link:{from:y.from,to:y.to}})}},[d]);return kE(()=>{let v=c.current;if(!(!v||i))return nr({element:v,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?ra(B5,{children:ra("div",{ref:c,children:V5(EE,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,onCreate:m,onSelectionUpdate:p,onTransaction:g,editorContainerProps:{className:R("courier-slack-editor")},immediatelyRender:!1,children:[ra(vr,{variableViewMode:s}),i?ra(yr,{value:e,defaultValue:bs}):V5(PE,{children:[ra(L5,{value:e}),ra(Xt,{config:l})]})]})})}):null},"SlackEditor");import{useAtomValue as LE}from"jotai";import{GripVertical as ME}from"lucide-react";import{Fragment as NE,jsx as lo,jsxs as mp}from"react/jsx-runtime";var pp=a(({items:e,label:t,editor:r})=>lo("div",{className:"courier-flex courier-flex-col courier-h-full",children:mp("div",{className:"courier-flex-1",children:[t&&mp(NE,{children:[lo("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),lo(pe,{className:"courier-my-4"})]}),lo("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>{let n=or(o)?`${o.type}:${o.preset}`:o,i=or(o)?o.type:o;return lo(Ji,{id:n,editor:r,children:mp("div",{className:R("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:[lo(ME,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),i==="text"&&lo(Zo,{draggable:!0}),i==="divider"&&lo(jo,{draggable:!0}),i==="button"&&lo(zo,{draggable:!0}),i==="list"&&lo(qo,{draggable:!0})]})},n)})})]})}),"SlackSideBar");import{zodResolver as AE}from"@hookform/resolvers/zod";import{useForm as SE}from"react-hook-form";import{jsx as oa,jsxs as fp}from"react/jsx-runtime";var H5=a(({element:e,editor:t})=>{let r=SE({resolver:AE(Tl),defaultValues:{...Be,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=gt({editor:t,element:e,form:r,nodeType:"button"});return e?fp(He,{...r,children:[oa(ht,{type:"button"}),fp("form",{onChange:()=>{o(r.getValues())},children:[oa("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),oa(te,{control:r.control,name:"link",render:({field:n})=>fp(Q,{children:[oa(ee,{children:oa(Xr,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})}})}),oa(re,{})]})})]})]}):null},"SlackButtonForm");import{useAtomValue as IE}from"jotai";import{jsx as ys}from"react/jsx-runtime";var gp=a(({element:e,editor:t,defaultElement:r})=>{var n,i;let o=IE(En);return e?o!=null&&o.link||((n=o==null?void 0:o.mark)==null?void 0:n.type.name)==="link"&&((i=e.marks)!=null&&i.some(s=>s.type.name==="link"))?ys(Ui,{editor:t,mark:o==null?void 0:o.mark,pendingLink:o==null?void 0:o.link}):e.type.name==="button"?ys("div",{className:"courier-flex courier-flex-col courier-gap-4",children:ys(H5,{element:e,editor:t},e.attrs.id)}):e.type.name==="list"?ys("div",{className:"courier-flex courier-flex-col courier-gap-4",children:ys(qn,{element:e,editor:t,minimalMode:!0},e.attrs.id)}):r:r},"SlackSideBarItemDetails");import{forwardRef as F5}from"react";import{jsx as Dr,jsxs as DE}from"react/jsx-runtime";var RE=F5(({children:e,className:t,...r},o)=>Dr("div",{className:R("courier-editor-container courier-relative",t),...r,ref:o,children:e})),BE=F5(({children:e,...t},r)=>Dr("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),O5=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s})=>{let l=LE(de);return Dr(Uc,{value:l,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:c=>{var u;return DE(Yn,{children:[Dr("div",{className:"courier-flex courier-flex-col courier-flex-1",children:Dr(RE,{children:Dr(BE,{children:Dr(dp,{...c},`slack-editor-${o?"no-autocomplete":"autocomplete"}`)})})}),Dr(Qn,{children:Dr("div",{className:"courier-p-1 courier-h-full",children:Dr(gp,{element:c.selectedNode,editor:c.slackEditor,defaultElement:Dr(pp,{items:c.items.Sidebar,label:"Blocks library",editor:(u=c.slackEditor)!=null?u:void 0})})})})]})}})},"SlackLayout");import{useCurrentEditor as VE}from"@tiptap/react";import{useAtom as HE,useAtomValue as $c,useSetAtom as hp}from"jotai";import{forwardRef as FE,memo as OE,useCallback as WE,useEffect as vs,useMemo as bp,useRef as yp}from"react";import{SegmentedMessage as _E}from"sms-segments-calculator";import{jsx as vp}from"react/jsx-runtime";var Bo=[{type:"text",content:`
240
- `}],W5=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:Bo}),t},"getOrCreateSMSElement"),_5=a(({value:e})=>{var c;let{editor:t}=VE(),r=hp(Ae),o=$c(de),n=(c=t==null?void 0:t.getText())!=null?c:"",i=bp(()=>new _E(n),[n]),s=$c(he),l=yp(!1);return vs(()=>{s&&(l.current=!1)},[s]),vs(()=>{!t||s!==!1||l.current||!e||(l.current=!0,t.commands.setContent(e))},[t,e,s]),vs(()=>{t&&(r(t),Yt("sms",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),vs(()=>{if(!t||!o||t.isFocused)return;let u=W5(o),m={type:"channel",channel:"sms",elements:u.type==="channel"&&"elements"in u&&u.elements||Bo},p=$e({version:"2022-01-01",elements:[m]}),g=ve(p),v=ve(t.getJSON());JSON.stringify(g)!==JSON.stringify(v)&&setTimeout(()=>{t.isFocused||t.commands.setContent(p)},1)},[t,o]),vp("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"),U5={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"}},UE=FE(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,render:i,headerRenderer:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...m},p)=>{let g=$c(he),v=yp(!0),b=yp(!1),y=hp(Ce),[C,x]=HE(de),h=hp(Ye),f=$c(kt);vs(()=>(b.current=!0,()=>{b.current=!1}),[]);let E=bp(()=>[...Gt({setSelectedNode:y,variables:u,disableVariablesAutocomplete:d,textMarks:"plain-text"})].filter(P=>P!==void 0),[y,u,d]),T=WE(({editor:P})=>{if(f)return;if(!C){let B=ve(P.getJSON()),M=Bs(B),I={version:"2022-01-01",elements:[{type:"channel",channel:"sms",elements:M.length>0?M:Bo}]};x(I),h(I);return}let N=ve(P.getJSON()),k=Bs(N),S=xt(C,{channel:"sms",elements:k.length>0?k:Bo});JSON.stringify(C)!==JSON.stringify(S)&&(x(S),h(S))},[C,x,h,f]),w=bp(()=>{var B;if(g!==!1)return null;let P=l!=null?l:C,N=(B=P==null?void 0:P.elements)==null?void 0:B.find(M=>M.type==="channel"&&M.channel==="sms");N||(N=W5(P));let S={type:"channel",channel:"sms",elements:(N==null?void 0:N.type)==="channel"&&"elements"in N&&N.elements||Bo};return $e({version:"2022-01-01",elements:[S]})},[g]);return vp(Kt,{theme:e,colorScheme:c,isLoading:!!(g&&v.current),Header:s?s({hidePublish:t,channels:o,routing:n}):vp(hr,{hidePublish:t,channels:o,routing:n}),...m,ref:p,children:i==null?void 0:i({content:w,extensions:E,editable:!r,autofocus:!r,onUpdate:T})})}),zc=OE(UE);import{EditorProvider as $E}from"@tiptap/react";import{useCallback as zE}from"react";import{Fragment as jE,jsx as na,jsxs as $5}from"react/jsx-runtime";var Cp=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:s=!1,variableViewMode:l="show-variables"})=>{let c=e||{type:"doc",content:[{type:"paragraph"}]},u=s?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},d=zE(({editor:m})=>{Ut(m,l)},[l]);return na(Oc,{children:na("div",{className:R("courier-sms-editor",i),children:$5($E,{content:c,extensions:t,...u,onCreate:d,"data-testid":"editor-provider",immediatelyRender:!1,children:[na(vr,{variableViewMode:l}),s?na(yr,{value:c,defaultValue:Bo}):$5(jE,{children:[na(_5,{value:c}),na(Xt,{config:U5})]})]})})})},"SMSEditor");import{useAtomValue as qE}from"jotai";import{jsx as xp}from"react/jsx-runtime";var z5=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s,...l})=>{let c=qE(de);return xp(zc,{value:c,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:u=>xp("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:xp(Cp,{...u},`sms-editor-${o?"no-autocomplete":"autocomplete"}`)}),...l})},"SMSLayout");import{useCurrentEditor as ZE}from"@tiptap/react";import{useAtom as j5,useAtomValue as ln,useSetAtom as Z5}from"jotai";import{forwardRef as JE,memo as KE,useCallback as Tp,useEffect as Cr,useMemo as jc,useRef as aa,useState as q5}from"react";import{Fragment as rw,jsx as Ep}from"react/jsx-runtime";var Cs=[{type:"text",content:`
241
- `}],J5=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:Cs}),t},"getOrCreateMSTeamsElement"),K5=a(({value:e})=>{let{editor:t}=ZE(),r=Z5(Ae),o=ln(de),n=ln(he),i=ln(Ce),s=aa(!1),l=aa(!1);return Cr(()=>{n&&(s.current=!1)},[n]),Cr(()=>{!t||n!==!1||s.current||!e||(s.current=!0,t.commands.setContent(e))},[t,e,n]),Cr(()=>{t&&(r(t),Yt("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),Cr(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),Cr(()=>(l.current=!0,()=>{l.current=!1}),[]),Cr(()=>{if(!t||!o||t.isFocused)return;let c=J5(o),u=$e({version:"2022-01-01",elements:[c]},{channel:"msteams"}),d=ve(u),m=ve(t.getJSON());JSON.stringify(d)!==JSON.stringify(m)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"MSTeamsEditorContent"),GE={alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"}},XE={underline:{state:"hidden"},strike:{state:"hidden"}},YE=[{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"]}}],ia={conditionalRules:YE,...XE,...GE},QE={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"},...ia},ew=a((e,t=!1)=>{let r=["paragraph","heading","blockquote"].includes(e);if(r&&t)return{contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:"enabled"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"enabled"},variable:{state:"enabled"},...ia};if(r&&!t)return{contentType:{state:"enabled"},bold:{state:"hidden"},italic:{state:"hidden"},quote:{state:"enabled"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:"hidden"},variable:{state:"enabled"},...ia};switch(e){case"list":return{contentType:{state:"hidden"},bold:{state:t?"enabled":"hidden"},italic:{state:t?"enabled":"hidden"},quote:{state:"hidden"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:t?"enabled":"hidden"},variable:{state:"enabled"},...ia};case"button":return{bold:{state:"enabled"},italic:{state:"enabled"},...ia};default:return{contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"},...ia}}},"getTextMenuConfigForMSTeamsNode"),tw=JE(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...m},p)=>{let g=ln(he),v=ln(kt),b=ln(Ae),y=ln(qt),[C,x]=j5(Ce),[h,f]=j5(de),E=Z5(Ye),T=aa(!0),w=aa(!1),P=aa(y),N=ln(Ur),[k,S]=q5(!1);Cr(()=>{if(!b)return;let A=a(()=>{var H;try{let O=(H=b.state)==null?void 0:H.selection;if(O){let{from:j,to:Z}=O;S(j!==Z)}}catch{}},"updateSelection");return b.on("selectionUpdate",A),b.on("transaction",A),A(),()=>{b.off("selectionUpdate",A),b.off("transaction",A)}},[b]);let B=jc(()=>C?ew(C.type.name,k):QE,[C,k]),M=jc(()=>{let A=["text","divider","list"];return N.filter(H=>{let O=or(H)?H.type:H;return A.includes(O)})},[N]),[I,D]=q5({Sidebar:M,Editor:[]});Cr(()=>{D(A=>({...A,Sidebar:M}))},[M]);let V=aa(null);qi({items:I,setItems:D});let _=Tp(A=>{V.current&&cancelAnimationFrame(V.current),setTimeout(()=>{V.current=requestAnimationFrame(()=>{try{let H=A==null?void 0:A.view.dom;if(!H){console.warn("syncEditorItems: Editor DOM element not found");return}let O=H.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),j=[];O.forEach(Z=>{let U=Z.dataset.id;U&&j.push(U)}),D(Z=>({Editor:j,Sidebar:Z.Sidebar}))}catch(H){console.error("Error syncing editor items:",H),D(O=>({...O}))}})},50)},[]);Cr(()=>(w.current=!0,()=>{w.current=!1}),[]),Cr(()=>{P.current=y},[y]),Cr(()=>{let A=a(()=>{b&&_(b)},"updateItems");b==null||b.on("update",A),b==null||b.on("selectionUpdate",A),b==null||b.on("create",A),b==null||b.on("transaction",A),b&&!b.isDestroyed&&A();let H=a(O=>{A()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",H),()=>{b==null||b.off("update",A),b==null||b.off("selectionUpdate",A),b==null||b.off("create",A),b==null||b.off("transaction",A),document.removeEventListener("node-duplicated",H),V.current&&cancelAnimationFrame(V.current)}},[b,_]),Cr(()=>{g===!1&&h&&setTimeout(()=>{b&&!b.isDestroyed&&_(b)},300)},[g,h,b,_]);let W=Tp(()=>!P.current,[]),F=jc(()=>[...Gt({setSelectedNode:x,shouldHandleClick:W,variables:u,disableVariablesAutocomplete:d,textMarks:{underline:"disabled",strike:"disabled"}})].filter(A=>A!==void 0),[x,W,u,d]),L=Tp(({editor:A})=>{if(!A||v)return;if(!h){let ne={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:ve(A.getJSON())}]};f(ne),E(ne);return}let H=A.getJSON(),O=ve(H),j=xt(h,{elements:O,channel:"msteams"}),Z=JSON.stringify(h.elements),U=JSON.stringify(j.elements);Z!==U&&(f(j),E(j))},[h,f,E,v]),$=jc(()=>{let A=J5(l);return $e({version:"2022-01-01",elements:[A]},{channel:"msteams"})},[l]);return Ep(Kt,{theme:e,colorScheme:c,isLoading:!!(g&&T.current),Header:i?i({hidePublish:t,channels:o,routing:n}):Ep(hr,{hidePublish:t,channels:o,routing:n}),ref:p,...m,children:Ep(rw,{children:s==null?void 0:s({content:$,extensions:F,editable:!r,autofocus:!r,onUpdate:L,items:I,selectedNode:C,msteamsEditor:b,textMenuConfig:B})})})}),qc=KE(tw);import{EditorProvider as aw}from"@tiptap/react";import{jsx as Vt,jsxs as xs}from"react/jsx-runtime";var ow=a(()=>Vt("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-full",children:Vt(wa,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),nw=a(()=>xs("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[Vt(ow,{}),xs("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[Vt("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"}),Vt("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),iw=a(()=>Vt("div",{className:"courier-flex courier-justify-end courier-w-full",children:Vt("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:Vt("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),G5=a(({children:e,className:t})=>xs("div",{className:R("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:[Vt(nw,{}),xs("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[Vt("div",{className:"courier-flex-shrink-0 courier-mt-6",children:Vt("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:Vt(Ea,{color:"#FFFFFF"})})}),xs("div",{className:"courier-flex-1 courier-min-w-0",children:[Vt("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:Vt("span",{className:"courier-text-sm courier-text-[#A3A3A3] dark:courier-text-[#8786A9]",children:"Circle"})}),Vt("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})]})]}),Vt(iw,{})]}),"MSTeamsFrame");import{useRef as sw,useEffect as lw,useCallback as wp}from"react";import{useSetAtom as X5}from"jotai";import{Fragment as cw,jsx as sa,jsxs as Y5}from"react/jsx-runtime";var kp=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1,variableViewMode:s="show-variables",textMenuConfig:l})=>{let c=sw(null),u=X5(Re),d=X5(Oo),m=wp(({editor:v})=>{Ut(v,s)},[s]),p=wp(({editor:v})=>{if(Vo())return;let{selection:b}=v.state,{$anchor:y}=b,x=b.$head.marks().find(w=>w.type.name==="link");x||v.isActive("link")?d({mark:x}):d(null);let h=y.depth,f=null,E=null,T=null;for(;h>0;){let w=y.node(h);!E&&w.type.name==="blockquote"&&(E=w),!T&&w.type.name==="list"&&(T=w),!f&&(w.type.name==="paragraph"||w.type.name==="heading")&&(f=w),h--}T?u(T):E?u(E):f&&u(f)},[d,u]),g=wp(({editor:v,transaction:b})=>{let y=b==null?void 0:b.getMeta("showLinkForm");if(y){let{selection:C}=v.state,h=C.$head.marks().find(f=>f.type.name==="link");d({mark:h,link:{from:y.from,to:y.to}})}},[d]);return lw(()=>{let v=c.current;if(!(!v||i))return nr({element:v,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?sa(G5,{children:sa("div",{ref:c,children:Y5(aw,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,onCreate:m,onSelectionUpdate:p,onTransaction:g,editorContainerProps:{className:R("courier-msteams-editor")},immediatelyRender:!1,children:[sa(vr,{variableViewMode:s}),i?sa(yr,{value:e,defaultValue:Cs}):Y5(cw,{children:[sa(K5,{value:e}),sa(Xt,{config:l})]})]})})}):null},"MSTeamsEditor");import{useAtomValue as pw}from"jotai";import{GripVertical as uw}from"lucide-react";import{Fragment as dw,jsx as co,jsxs as Pp}from"react/jsx-runtime";var Mp=a(({items:e,label:t,editor:r})=>co("div",{className:"courier-flex courier-flex-col courier-h-full",children:Pp("div",{className:"courier-flex-1",children:[t&&Pp(dw,{children:[co("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),co(pe,{className:"courier-my-4"})]}),co("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>{let n=or(o)?`${o.type}:${o.preset}`:o,i=or(o)?o.type:o;return co(Ji,{id:n,editor:r,children:Pp("div",{className:R("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:[co(uw,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),i==="text"&&co(Zo,{draggable:!0}),i==="divider"&&co(jo,{draggable:!0}),i==="button"&&co(zo,{draggable:!0}),i==="list"&&co(qo,{draggable:!0})]})},n)})})]})}),"MSTeamsSideBar");import{useAtomValue as mw}from"jotai";import{jsx as Ts}from"react/jsx-runtime";var Np=a(({element:e,editor:t,defaultElement:r})=>{var n,i;let o=mw(En);return e?o!=null&&o.link||((n=o==null?void 0:o.mark)==null?void 0:n.type.name)==="link"&&((i=e.marks)!=null&&i.some(s=>s.type.name==="link"))?Ts(Ui,{editor:t,mark:o==null?void 0:o.mark,pendingLink:o==null?void 0:o.link}):e.type.name==="button"?Ts("div",{className:"courier-flex courier-flex-col courier-gap-4",children:Ts(Kl,{element:e,editor:t},e.attrs.id)}):e.type.name==="list"?Ts("div",{className:"courier-flex courier-flex-col courier-gap-4",children:Ts(qn,{element:e,editor:t,minimalMode:!0},e.attrs.id)}):r:r},"MSTeamsSideBarItemDetails");import{forwardRef as Q5}from"react";import{jsx as Vr,jsxs as hw}from"react/jsx-runtime";var fw=Q5(({children:e,className:t,...r},o)=>Vr("div",{className:R("courier-editor-container courier-relative",t),...r,ref:o,children:e})),gw=Q5(({children:e,...t},r)=>Vr("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),ey=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s})=>{let l=pw(de);return Vr(qc,{value:l,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:c=>{var u;return hw(Yn,{children:[Vr("div",{className:"courier-flex courier-flex-col courier-flex-1",children:Vr(fw,{children:Vr(gw,{children:Vr(kp,{...c},`msteams-editor-${o?"no-autocomplete":"autocomplete"}`)})})}),Vr(Qn,{children:Vr("div",{className:"courier-p-1 courier-h-full",children:Vr(Np,{element:c.selectedNode,editor:c.msteamsEditor,defaultElement:Vr(Mp,{items:c.items.Sidebar,label:"Blocks library",editor:(u=c.msteamsEditor)!=null?u:void 0})})})})]})}})},"MSTeamsLayout");var ny={sms:{elements:Bo},push:{elements:ri},inbox:{elements:fs},slack:{elements:bs},email:{elements:us},msteams:{elements:Cs}},Ip=a(e=>{var t;return(t=ny[e])!=null?t:ny.email},"getChannelDefaults"),Cw=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"),Lp=a(({channels:e=["email"],routing:t})=>{let[r,o]=vw([]),n=ty(de),i=Ap(de),s=Ap(Ye),[l,c]=bw(Wo),u=Ap(Ce),d=ty(he),m=Cw(t,e),p=yw(m);p.current=m,Sp(()=>{if(d||n!=null&&n.elements)return;let x=p.current.map(h=>kn.find(f=>f.value===h)).filter(h=>!!h);o(x),x.length>0&&!l&&c(x[0].value)},[n,d,c,l]),Sp(()=>{if(d||!(n!=null&&n.elements))return;let C=p.current,x=n.elements.filter(f=>f.type==="channel").map(f=>f.channel).filter(f=>C.includes(f)),h=C.filter(f=>x.includes(f)).map(f=>kn.find(E=>E.value===f)).filter(f=>!!f);o(h)},[n,d]),Sp(()=>{var h;if(d||r.length===0)return;let C=r.some(f=>f.value===l),x=(h=n==null?void 0:n.elements)==null?void 0:h.some(f=>f.type==="channel"&&f.channel===l);!C&&!x&&c(r[0].value)},[r,l,c,d,n]);let g=oy(()=>(m==null?void 0:m.filter(C=>!r.some(x=>x.value===C)).map(C=>kn.find(x=>x.value===C)).filter(C=>!!C))||[],[r,m]),v=ry(C=>{let x=[],h,{elements:f,raw:E}=Ip(C);if(x=f,h=E,!n){let P=[];for(let S of r){let{elements:B,raw:M}=Ip(S.value),I={type:"channel",channel:S.value,elements:B};M&&(I.raw=M),P.push(I)}let N={type:"channel",channel:C,elements:x};h&&(N.raw=h),P.push(N);let k={version:"2022-01-01",elements:P};i(k),s(k),c(C);return}let w=xt(n,{elements:x,channel:h?{channel:C,raw:h}:C});i(w),s(w),c(C)},[n,i,s,c,r]),b=ry(C=>{if(!n)return;let x=n.elements.filter(E=>E.type==="channel"?E.channel!==C:!0),h={...n,elements:x};i(h),s(h),u(null);let f=r.filter(E=>E.value!==C);l===C&&f.length>0&&c(f[0].value)},[n,i,s,r,l,c,u]),y=oy(()=>[...r,...g],[r,g]);return{enabledChannels:r,disabledChannels:g,channel:l,channelOptions:y,setChannel:c,addChannel:v,removeChannel:b}},"useChannels");import{Fragment as Pw,jsx as At,jsxs as uo}from"react/jsx-runtime";var hr=a(({hidePublish:e=!1,channels:t,routing:r})=>{let o=kw(null),n=Zc(mt),i=Zc(he),s=Zc(ue),{publishTemplate:l,isTemplatePublishing:c}=ha(),[u,d]=Tw(si),m=Ew(_r),p=Zc(_r),{enabledChannels:g,disabledChannels:v,channel:b,setChannel:y,addChannel:C,removeChannel:x}=Lp({channels:t,routing:r});ww(()=>{n===!0&&d(null)},[n,d]);let h=Es(()=>{p&&m(!1),l()},[l,p,m]),f=Es(P=>{p&&m(!1),y(P)},[p,m,y]),E=Es(P=>{p&&m(!1),C(P)},[p,m,C]),T=Es(P=>{p&&m(!1),x(P)},[p,m,x]),w=Es(()=>{p&&m(!1)},[p,m]);return uo("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:w,children:[uo("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[At(_i,{value:b,onValueChange:f,className:"courier-h-full",ref:o,children:At(zn,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${kn.length}, fit-content(100%))`},children:g.map(P=>uo(ko,{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===b&&g.length>1&&uo(Ab,{children:[At(Sb,{asChild:!0,children:At("div",{className:"courier-pl-2",children:At(ya,{color:"#A3A3A3"})})}),uo(vm,{ref:o,children:[At(Cm,{children:At(xw,{children:"Are you sure you want to delete this channel?"})}),uo(xm,{children:[At(Em,{asChild:!0,children:At(Me,{buttonSize:"small",variant:"outline",children:"Cancel"})}),At(Tm,{asChild:!0,children:At(Me,{buttonSize:"small",variant:"primary",onClick:()=>T(P.value),children:"Delete"})})]})]})]})]},P.value))})}),v.length>0&&uo(Pw,{children:[At(Am,{orientation:"vertical",className:"!courier-h-5"}),uo(Ul,{children:[At($l,{asChild:!0,children:At(Me,{variant:"link",children:"+ Add channel"})}),At(za,{portalProps:{container:o.current},children:v.map(P=>uo(ja,{onClick:()=>E(P.value),children:[P.icon,P.label]},P.value))})]})]})]}),uo("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&At(ss,{isLoading:!!i,isSaving:!!n,isError:!!s}),!e&&i!==null&&At(Me,{variant:"primary",buttonSize:"small",disabled:c===!0||n===!0||u!==null,onClick:h,children:c?"Publishing...":"Publish changes"})]})]})},"Channels");import{useCallback as Rp,useEffect as iy,useRef as cn,useState as Mw}from"react";function ws({onSave:e,debounceMs:t=2e3,enabled:r=!0,onError:o,initialContent:n,flushBeforeSave:i}){let[s,l]=Mw(!1),c=cn(!1),u=cn(null),d=cn(),m=cn(0),p=cn();iy(()=>{n&&(d.current=JSON.stringify(n))},[n]);let g=Rp(async()=>{if(c.current)return;if(i)try{i()}catch(f){console.error("[AutoSave] Error flushing updates:",f)}let h=u.current;if(u.current=null,!!h)try{let f=JSON.stringify(h);if(f===d.current)return;c.current=!0,l(!0),d.current=f,m.current=Date.now(),await e(h)}catch(f){console.error("[AutoSave] Save failed:",f),o==null||o(f)}finally{if(c.current=!1,l(!1),u.current){let f=t;p.current=setTimeout(()=>{p.current=void 0,g()},f)}}},[t,o,e,i]),v=cn(r),b=cn(t),y=cn(g);iy(()=>{v.current=r,b.current=t,y.current=g});let C=Rp(async h=>{if(!v.current)return;let f=JSON.stringify(h);if(u.current=h,f===d.current||c.current)return;p.current&&(clearTimeout(p.current),p.current=void 0);let E=b.current;p.current=setTimeout(()=>{p.current=void 0,y.current()},E)},[]),x=Rp(async()=>{p.current&&(clearTimeout(p.current),p.current=void 0),await y.current()},[]);return{handleAutoSave:C,flush:x,isSaving:s}}a(ws,"useAutoSave");import{useAtom as ks,useAtomValue as Do,useSetAtom as oi}from"jotai";import{memo as Yw,useCallback as Hp,useEffect as St,useRef as ni,useState as Qw}from"react";import{useAtom as gy,useAtomValue as Vp,useSetAtom as hy}from"jotai";import{forwardRef as Kw,memo as Gw,useCallback as by,useEffect as ua,useRef as yy}from"react";import{z as tr}from"zod";var ay=tr.object({headerStyle:tr.enum(["plain","border"]),isUnsubscribe:tr.boolean().optional(),isPreferences:tr.boolean().optional(),link:tr.string().optional(),brandColor:tr.string(),textColor:tr.string(),subtleColor:tr.string(),logo:tr.string().optional(),facebookLink:tr.string().optional(),linkedinLink:tr.string().optional(),instagramLink:tr.string().optional(),mediumLink:tr.string().optional(),xLink:tr.string().optional()}),$t={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};import{useAtom as my,useAtomValue as la,useSetAtom as py}from"jotai";import{forwardRef as zw,memo as jw,useCallback as Jc,useEffect as qw}from"react";import{forwardRef as Nw}from"react";import{jsx as Aw}from"react/jsx-runtime";var sy=Nw(({children:e},t)=>Aw("div",{ref:t,className:"courier-z-30 courier-flex courier-w-full courier-bg-primary courier-h-12 courier-border-b rounded-b-none rounded-t-sm courier-shadow-none courier-justify-between courier-items-center courier-px-4",children:e}));import{useCallback as un,useRef as Sw,useState as Iw}from"react";import{jsx as Bp,jsxs as Rw}from"react/jsx-runtime";var Lw=["image/png","image/jpeg","image/gif","image/webp"],ly=a(({onFileSelect:e})=>{let[t,r]=Iw(!1),o=Sw(null),n=un(p=>Lw.includes(p),[]),i=un(p=>{p.preventDefault(),p.stopPropagation(),p.dataTransfer.types.includes("Files")&&Array.from(p.dataTransfer.items).some(b=>n(b.type))&&(r(!0),p.dataTransfer.dropEffect="copy")},[n]),s=un(p=>{p.preventDefault(),p.stopPropagation(),r(!1)},[]),l=un(p=>{p.preventDefault(),p.stopPropagation(),p.dataTransfer.types.includes("Files")&&Array.from(p.dataTransfer.items).some(b=>n(b.type))&&r(!0)},[n]),c=un(async p=>{try{let{dataUrl:g}=await Os(p,800);e==null||e(g),o.current&&(o.current.value="")}catch(g){console.error("Error processing image:",g),o.current&&(o.current.value="")}},[e]),u=un(p=>{p.preventDefault(),p.stopPropagation(),r(!1);let v=Array.from(p.dataTransfer.files).find(b=>n(b.type));v&&c(v)},[c,n]),d=un(p=>{var v;let g=(v=p.target.files)==null?void 0:v[0];g&&c(g)},[c]),m=un(p=>{var g;p.preventDefault(),p.stopPropagation(),(g=o.current)==null||g.click()},[]);return Rw("div",{className:R("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:[Bp("span",{className:"courier-text-sm courier-pointer-events-none",children:"Drag and drop logo, or"}),Bp("button",{className:"courier-underline courier-font-medium courier-text-sm",onClick:m,type:"button",children:"Browse"}),Bp("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:d},"logo-input")]})},"LogoUploader");import{zodResolver as Bw}from"@hookform/resolvers/zod";import{useAtom as Dw,useAtomValue as Vw,useSetAtom as Hw}from"jotai";import{ArrowUp as Fw}from"lucide-react";import{memo as Ow,useCallback as cy,useEffect as Ww,useRef as _w}from"react";import{useForm as Uw}from"react-hook-form";import{jsx as oe,jsxs as rr}from"react/jsx-runtime";var uy=a(({isActive:e,onClick:t,value:r})=>oe("div",{className:R("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:oe("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"&&oe("div",{className:"courier-w-full courier-bg-[#000000] courier-h-1"})})}),"HeaderStyle"),$w=a(()=>{let[e,t]=Dw(ao),r=Hw(Rr),o=Vw(ci),n=_w(null),i=Uw({resolver:Bw(ay),defaultValues:{...$t,...e},mode:"onChange"});Ww(()=>{e&&i.reset(e)},[e,i]);let s=cy(()=>{t(i.getValues())},[i,t]),l=cy(c=>{var u;if(o){if(c){let m={type:"doc",content:[...o.getJSON().content||[],{type:"paragraph",content:[{type:"text",text:"Manage Notification Preferences",marks:[{type:"link",attrs:{href:"{{urls.preferences}}"}}]}]}]};o.chain().focus().setContent(m).run()}else{let m=((u=o.getJSON().content)==null?void 0:u.filter(p=>{var v;return p.type!=="paragraph"?!0:!((v=p.content)==null?void 0:v.some(b=>{var y;return b.type==="text"&&((y=b.marks)==null?void 0:y.some(C=>{var x;return C.type==="link"&&((x=C.attrs)==null?void 0:x.href)==="{{urls.preferences}}"}))}))}))||[];o.chain().focus().setContent({type:"doc",content:m}).run()}r(yc(o.getJSON()))}},[o,r]);return oe(He,{...i,children:oe("form",{onChange:()=>s(),children:rr("div",{className:"courier-pb-6",children:[oe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Header style"}),oe(te,{control:i.control,name:"headerStyle",render:({field:c})=>rr(Q,{className:"courier-mb-4",children:[oe(ee,{children:rr("div",{className:"courier-w-full courier-flex courier-flex-row courier-gap-3",children:[oe(uy,{isActive:c.value==="plain",onClick:()=>{c.onChange("plain"),t({...i.getValues(),headerStyle:"plain"})},value:"plain"}),oe(uy,{isActive:c.value==="border",onClick:()=>{c.onChange("border"),t({...i.getValues(),headerStyle:"border"})},value:"border"})]})}),oe(re,{})]})}),oe(pe,{className:"courier-mb-4"}),oe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Logo"}),rr("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[i.getValues().logo?oe(Me,{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"}):rr(Me,{onClick:c=>{c.preventDefault(),n.current&&(n.current.value="",n.current.click())},className:"courier-w-full",variant:"outline",type:"button",children:[oe(Fw,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-mr-2 courier-text-foreground"}),"Upload logo"]}),oe("input",{ref:n,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:async c=>{var d;let u=(d=c.target.files)==null?void 0:d[0];if(u)try{let{dataUrl:m}=await Os(u,800),p=i.getValues();p.logo=m,i.reset(p),t({...p})}catch(m){console.error("Error processing image:",m)}n.current&&(n.current.value="")}})]}),oe(te,{control:i.control,name:"link",render:({field:c})=>rr(Q,{className:"courier-mb-3",children:[oe(ee,{children:oe(Qo,{as:"Textarea",placeholder:"Link",...c,onChange:u=>{c.onChange(u),s()}})}),oe(re,{})]})}),oe(pe,{className:"courier-mb-4"}),oe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Brand color"}),oe(te,{control:i.control,name:"brandColor",render:({field:c})=>rr(Q,{className:"courier-mb-4",children:[oe(ee,{children:oe(bt,{...c,defaultValue:c.value,onChange:u=>{c.onChange(u),s()}})}),oe(re,{})]})}),oe(pe,{className:"courier-mb-4"}),oe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer links"}),rr("div",{className:"courier-flex courier-flex-col courier-gap-3 courier-mb-3",children:[oe(te,{control:i.control,name:"facebookLink",render:({field:c})=>rr(Q,{children:[oe(ee,{children:oe(be,{startAdornment:oe(fi,{}),placeholder:"facebook.com/username",...c,autoFocus:!0})}),oe(re,{})]})}),oe(te,{control:i.control,name:"linkedinLink",render:({field:c})=>rr(Q,{children:[oe(ee,{children:oe(be,{startAdornment:oe(hi,{}),placeholder:"linkedin.com/username",...c})}),oe(re,{})]})}),oe(te,{control:i.control,name:"instagramLink",render:({field:c})=>rr(Q,{children:[oe(ee,{children:oe(be,{startAdornment:oe(gi,{}),placeholder:"instagram.com/username",...c})}),oe(re,{})]})}),oe(te,{control:i.control,name:"mediumLink",render:({field:c})=>rr(Q,{children:[oe(ee,{children:oe(be,{startAdornment:oe(bi,{}),placeholder:"medium.com/username",...c})}),oe(re,{})]})}),oe(te,{control:i.control,name:"xLink",render:({field:c})=>rr(Q,{children:[oe(ee,{children:oe(be,{startAdornment:oe(yi,{}),placeholder:"x.com/username",...c})}),oe(re,{})]})})]}),oe(pe,{className:"courier-mb-4"}),oe("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer actions"}),oe(te,{control:i.control,name:"isPreferences",render:({field:c})=>rr(Q,{className:"courier-flex courier-flex-row courier-items-center courier-gap-2 courier-mb-4",children:[oe(ee,{children:oe($i,{checked:c.value,onCheckedChange:u=>{i.setValue("isPreferences",u),c.onChange(u),l(u);let d={...i.getValues(),isPreferences:u};t(d)}})}),oe(to,{className:"!courier-m-0",children:"Manage Preferences"}),oe(re,{})]})})]})})})},"SideBarComponent"),dy=Ow($w);import{Fragment as Jw,jsx as Ht,jsxs as ca}from"react/jsx-runtime";var Zw=zw(({hidePublish:e=!1,templateEditor:t,variables:r,variableValidation:o},n)=>{var T,w,P,N,k,S,B,M;let i=py(Ei),{publishBrand:s}=ga(),l=py(mi);qw(()=>{l(o)},[o,l]);let c=la(dt),u=la(jt),d=la(mt),m=la(he),p=la(ue),g=la(ci),[v,b]=my(ao),[y,C]=my(Rr),x=Jc(()=>{s()},[s]),h=Jc(({editor:I})=>{C(yc(I.getJSON()))},[C]),f=Jc(I=>{b(D=>D?{...D,logo:I}:{...$t,logo:I})},[b]),E=Jc(()=>{i("template")},[i]);return ca(Jw,{children:[Ht("div",{className:"courier-z-30 courier-w-full courier-h-12",children:ca(sy,{children:[Ht("div",{className:"courier-text-sm courier-font-medium",children:"Brand theme"}),ca("div",{className:"courier-flex courier-gap-2 courier-items-center",children:[d!==null&&Ht(ss,{isLoading:!!m,isSaving:!!d,isError:!!p}),t&&Ht(Me,{variant:"outline",buttonSize:"small",onClick:E,disabled:u===!0||d===!0,children:"Back"}),!e&&m!==null&&Ht(Me,{variant:"primary",buttonSize:"small",disabled:!((w=(T=c==null?void 0:c.data)==null?void 0:T.tenant)!=null&&w.brand)||u===!0||d!==!1,onClick:x,children:u?"Publishing...":"Publish changes"})]})]})}),ca("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[Ht("div",{className:"courier-flex courier-flex-col courier-flex-1",children:ca("div",{className:"courier-editor-container",ref:n,children:[Ht("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Header"}),ca("div",{className:R("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"&&Ht("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:v.brandColor}}),v!=null&&v.logo?Ht("img",{src:v.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"}):Ht(ly,{onFileSelect:f})]}),Ht("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Footer"}),Ht("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:Ht(ds,{value:y!=null?y:(M=(B=(S=(k=(N=(P=c==null?void 0:c.data)==null?void 0:P.tenant)==null?void 0:N.brand)==null?void 0:k.settings)==null?void 0:S.email)==null?void 0:B.footer)==null?void 0:M.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:h})})]})}),Ht("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:Ht("div",{className:"courier-p-4 courier-h-full",children:g&&Ht(dy,{})})})]})]})}),fy=jw(Zw);import{jsx as vy}from"react/jsx-runtime";var Xw=Kw(({hidePublish:e=!1,autoSaveDebounce:t=500,autoSave:r=!0,theme:o,colorScheme:n,...i},s)=>{let l=Vp(he),c=yy(!0),u=Vp(wt),{getTemplate:d,saveBrand:m}=ga(),[p,g]=gy(dt),v=hy(Rr),b=Vp(Rr),[y,C]=gy(ao),x=yy(!1),h=hy(ue);ua(()=>{var w,P;p&&u!==((P=(w=p==null?void 0:p.data)==null?void 0:w.tenant)==null?void 0:P.tenantId)&&(g(null),v(null),c.current=!1)},[p,u,g,v]);let f=by(async w=>{await m(w)},[m]),E=by(()=>{h(po("Error saving theme"))},[h]),{handleAutoSave:T}=ws({onSave:f,enabled:l!==null&&r&&b!==null,debounceMs:t,onError:E});return ua(()=>{!u||l||p&&l===!1||d()},[u,d,l,p]),ua(()=>{b&&setTimeout(()=>{x.current=!0},500)},[b]),ua(()=>{if(!x.current||!y)return;let w={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:b!=null?b: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}}}}};T(w)},[y,b,T]),ua(()=>{l||(c.current=!1)},[l]),ua(()=>{var w,P,N,k,S,B,M,I,D,V,_,W,F,L,$,A,H,O,j,Z,U,q,ne,X,le,ke,we,De,rt,Ve,Je,Tt,ut,Ke,Ge,Et,me,Pe;if(!y){let K=(N=(P=(w=p==null?void 0:p.data)==null?void 0:w.tenant)==null?void 0:P.brand)==null?void 0:N.settings,Xe=(M=b==null?void 0:b.split(`
242
- `))!=null?M:(B=(S=(k=K==null?void 0:K.email)==null?void 0:k.footer)==null?void 0:S.markdown)==null?void 0:B.split(`
243
- `),at=Xe==null?void 0:Xe.find(Ft=>Ft.includes("{{urls.preferences}}"));C({brandColor:((I=K==null?void 0:K.colors)==null?void 0:I.primary)||$t.brandColor,textColor:((D=K==null?void 0:K.colors)==null?void 0:D.secondary)||$t.textColor,subtleColor:((V=K==null?void 0:K.colors)==null?void 0:V.tertiary)||$t.subtleColor,headerStyle:(W=(_=K==null?void 0:K.email)==null?void 0:_.header)!=null&&W.barColor?"border":"plain",logo:(($=(L=(F=K==null?void 0:K.email)==null?void 0:F.header)==null?void 0:L.logo)==null?void 0:$.image)||$t.logo,link:((O=(H=(A=K==null?void 0:K.email)==null?void 0:A.header)==null?void 0:H.logo)==null?void 0:O.href)||$t.link,facebookLink:((q=(U=(Z=(j=K==null?void 0:K.email)==null?void 0:j.footer)==null?void 0:Z.social)==null?void 0:U.facebook)==null?void 0:q.url)||$t.facebookLink,linkedinLink:((ke=(le=(X=(ne=K==null?void 0:K.email)==null?void 0:ne.footer)==null?void 0:X.social)==null?void 0:le.linkedin)==null?void 0:ke.url)||$t.linkedinLink,instagramLink:((Ve=(rt=(De=(we=K==null?void 0:K.email)==null?void 0:we.footer)==null?void 0:De.social)==null?void 0:rt.instagram)==null?void 0:Ve.url)||$t.instagramLink,mediumLink:((Ke=(ut=(Tt=(Je=K==null?void 0:K.email)==null?void 0:Je.footer)==null?void 0:Tt.social)==null?void 0:ut.medium)==null?void 0:Ke.url)||$t.mediumLink,xLink:((Pe=(me=(Et=(Ge=K==null?void 0:K.email)==null?void 0:Ge.footer)==null?void 0:Et.social)==null?void 0:me.twitter)==null?void 0:Pe.url)||$t.xLink,isPreferences:!!at})}},[p,C,b,y]),vy(Kt,{theme:o,colorScheme:n,isLoading:!!(l&&c.current),children:vy(fy,{ref:s,hidePublish:e,...i})})}),Cy=Gw(Xw);import{jsx as ii}from"react/jsx-runtime";var xy=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"),e6=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:m,routing:p=Xc,colorScheme:g,...v})=>{let{store:b}=ma(),y=oi(Ms),C=oi(mi),x=oi(ui),h=oi(di),f=Do(he),E=Do(jt),T=Do(ue),[w,P]=ks(dt),N=Do(Tr),k=Do(wt),[S,B]=ks(fn),{getTemplate:M,saveTemplate:I,setTemplateError:D}=ha(),V=Do(Ei),_=ni(!1),[W,F]=ks(de),[L,$]=ks(kt);St(()=>{typeof window!="undefined"&&window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.templateEditorContent=W)},[W]);let A=oi(Rr),H=oi(ao),[O,j]=ks(Wo);St(()=>{typeof window!="undefined"&&window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.setTemplateEditorContent=F,window.__COURIER_CREATE_TEST__.getTemplateEditorContent=()=>W,window.__COURIER_CREATE_TEST__.setChannel=j,window.__COURIER_CREATE_TEST__.getChannel=()=>O)},[F,W,j,O]);let Z=oi(he),U=xy(p,m),[q,ne]=Qw(U),X=ni(JSON.stringify(U)),le=ni(!1),ke=ni(null);St(()=>{let me=xy(p,m),Pe=JSON.stringify(me);Pe!==X.current&&(ne(me),X.current=Pe,me.length&&!me.includes(O)&&j(me[0]))},[p,m,O,j]),St(()=>{var Pe;if(f||!(W!=null&&W.elements))return;let me=W.elements.filter(K=>K.type==="channel").map(K=>K.channel);if(!me.includes(O)){let K=(Pe=p==null?void 0:p.channels)==null?void 0:Pe.find(Xe=>me.includes(Xe));!K&&me.length>0&&(K=me[0]),K&&j(K)}},[W,O,j,p==null?void 0:p.channels,f]),St(()=>{var Pe;let me=(Pe=w==null?void 0:w.data)==null?void 0:Pe.tenant;N&&me&&!(me!=null&&me.notification)&&f===!1&&(q!=null&&q.length)&&j(q[0])},[N,w,f,q,j]);let we=ni(null);St(()=>{we.current&&(we.current.templateId!==N||we.current.tenantId!==k)&&N&&k&&($(!0),_.current=!1,ke.current=null,P(null),F(null),A(null),H(null),B(null),j((q==null?void 0:q[0])||"email"),Z(null)),N&&k&&(we.current={templateId:N,tenantId:k})},[N,k,q,$,P,F,A,H,B,j,Z]);let De=ni(p);St(()=>{De.current=p,y(p)},[p,y]),St(()=>{C(i)},[i,C]),St(()=>{x(o||{})},[o,x]),St(()=>{h(n)},[n,h]);let rt=Hp(async me=>{let Pe=me==null?void 0:me._capturedTemplateId,K=b.get(Tr);if(Pe&&Pe!==K)return;let{_capturedTemplateId:Xe,...at}=me;await I({routing:De.current,content:at})},[I,b]),Ve=Hp(()=>{D("Error saving template")},[D]),Je=Do(hn),Tt=Hp(()=>{Wp(Je)},[Je]),{handleAutoSave:ut}=ws({onSave:rt,debounceMs:c,enabled:f===!1&&l,onError:Ve,flushBeforeSave:Tt});St(()=>{!N||!k||f||w&&f===!1||T||M({includeBrand:u})},[N,k,u,M,f,w,T]);let Ke=ni(null);St(()=>{if(!t||l&&f!==!1)return;let me=JSON.stringify(t);if(me!==Ke.current&&JSON.stringify(ve($e(W)))!==JSON.stringify(ve($e(t)))){if(le.current=!0,Ke.current=me,F(t),!l)Z(!1);else{let Pe={...t,_capturedTemplateId:N};ut(Pe)}Promise.resolve().then(()=>{le.current=!1})}},[l,t,W,F,Z,ut,N,f]),St(()=>{var K,Xe,at,Ft,Hr,Fr,Or;if(f!==!1)return;let me=(at=(Xe=(K=w==null?void 0:w.data)==null?void 0:K.tenant)==null?void 0:Xe.notification)==null?void 0:at.notificationId;if(w&&me&&me!==N||ke.current===w)return;let Pe=t||((Or=(Fr=(Hr=(Ft=w==null?void 0:w.data)==null?void 0:Ft.tenant)==null?void 0:Hr.notification)==null?void 0:Fr.data)==null?void 0:Or.content);F(Pe),ke.current=w,setTimeout(()=>{$(!1)},100)},[w,F,f,$,N,t]),St(()=>{E===!0&&(_.current=!1)},[E]),St(()=>{!W||f!==!1||setTimeout(()=>{_.current=!0},1e3)},[W,O,f]),St(()=>{_.current=!1},[O]);let Ge=Do(Ye),Et=Do(Op);if(St(()=>{let me=!!Ge&&f===!1&&!L,Pe=_.current&&!!W&&f===!1&&!L;if(!me&&!Pe)return;let K=Ge||W;if(!K||JSON.stringify(K)===Et)return;let at={...K,_capturedTemplateId:N};r&&!le.current&&(_.current=!1,r(W||K)),ut(at)},[W,Ge,ut,f,L,N,r,Et]),u&&V==="brand")return ii(Cy,{hidePublish:s,autoSave:l,templateEditor:!0,variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:g,...d});if(V==="template"&&O==="email")return ii(m5,{variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:g,isLoading:!!f,hidePublish:s,channels:q,brandEditor:u,routing:p,...v});if(V==="template"&&O==="sms")return ii(z5,{colorScheme:g,variables:o,disableVariablesAutocomplete:n,theme:e,hidePublish:s,channels:q,routing:p,...v});if(V==="template"&&O==="push")return ii(P5,{variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:g,hidePublish:s,channels:q,routing:p,...v});if(V==="template"&&O==="inbox")return ii(C5,{variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:g,hidePublish:s,channels:q,routing:p,...v});if(V==="template"&&O==="slack")return ii(O5,{theme:e,colorScheme:g,hidePublish:s,channels:q,routing:p,variables:o,disableVariablesAutocomplete:n,...v});if(V==="template"&&O==="msteams")return ii(ey,{theme:e,colorScheme:g,hidePublish:s,channels:q,routing:p,variables:o,disableVariablesAutocomplete:n,...v})},"TemplateEditorComponent"),Zse=Yw(e6);var Yse=Pc,Qse=zc,ele=Hc,tle=Bc,rle=qc,ole=Uc;var t6=new Set(["dragstart","drag","dragend","dragenter","dragleave","dragover","drop","mousedown","mouseup","mousemove","click","pointerdown","pointerup","pointermove","pointercancel"]);function r6(e){let t=Object.getOwnPropertyDescriptor(Event.prototype,"target");if(!t)return console.warn("[ShadowDomDndFix] Could not get Event.prototype.target descriptor"),()=>{};let r={...t,get:function(){var s,l;if(!t6.has(this.type))return(s=t.get)==null?void 0:s.call(this);let o=(l=t.get)==null?void 0:l.call(this),i=this.composedPath()[0];return i&&i!==o&&e.contains(i)?i:o}};return Object.defineProperty(Event.prototype,"target",r),()=>{t&&Object.defineProperty(Event.prototype,"target",t)}}a(r6,"applyShadowDomDndFix");export{Cy as BrandEditor,ds as BrandFooter,Vy as BrandProvider,kn as CHANNELS,Yn as ChannelRootContainer,Xc as DEFAULT_ROUTING,pe as Divider,Qn as EditorSidebar,Yse as EmailChannel,Zm as EmailEditor,u5 as EmailEditorContainer,d5 as EmailEditorMain,Km as EmailSideBar,Gm as EmailSideBarItemDetails,fm as ErrorBoundary,fi as FacebookIcon,tle as InboxChannel,Qm as InboxEditor,np as InboxSideBar,be as Input,bt as InputColor,gi as InstagramIcon,hi as LinkedinIcon,rle as MSTeamsChannel,kp as MSTeamsEditor,Mp as MSTeamsSideBar,Np as MSTeamsSideBarItemDetails,bi as MediumIcon,zd as MonacoCodeEditor,jm as PreviewPanel,ele as PushChannel,sp as PushEditor,Qse as SMSChannel,Cp as SMSEditor,ole as SlackChannel,dp as SlackEditor,pp as SlackSideBar,gp as SlackSideBarItemDetails,Zse as TemplateEditor,Jy as TemplateProvider,ss as TemplateStatus,qa as TextMenu,Zb as Toggle,Ar as ToggleGroup,Rt as ToggleGroupItem,Ja as VariableInput,Xr as VariableTextarea,yi as XIcon,Ot as apiUrlAtom,r6 as applyShadowDomDndFix,Fp as brandApplyAtom,R as cn,$e as convertElementalToTiptap,Ls as convertLegacyError,ve as convertTiptapToElemental,po as createCustomError,w6 as extractErrorMessage,Ip as getChannelDefaults,_o as getFlattenedVariables,E6 as isRetryableError,he as isTemplateLoadingAtom,jt as isTemplatePublishingAtom,mt as isTemplateSavingAtom,Ms as routingAtom,dt as templateDataAtom,ue as templateErrorAtom,Tr as templateIdAtom,wt as tenantIdAtom,Wt as tokenAtom,ws as useAutoSave,gB as useBlockConfig,ga as useBrandActions,Lp as useChannels,tp as useDebouncedFlush,ba as useImageUpload,gt as useNodeAttributes,ha as useTemplateActions,ma as useTemplateStore,nI as useVariables};
236
+ `}]}),v.elements||(v.elements=[]);let y=[...v.elements.filter(g=>g.type!=="action")];if(m.enableButton){let g={type:"action",content:m.buttonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:m.buttonUrl};y.push(g)}if(m.enableSecondaryButton){let g={type:"action",content:m.secondaryButtonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:m.secondaryButtonUrl};y.push(g)}let C={...v,elements:y},T=f.elements.findIndex(g=>g.type==="channel"&&g.channel==="inbox"),E=[...f.elements];T!==-1?E[T]=C:E.push(C);let b={...f,elements:E};if(r(b),o(b),e){let g=Kc(b),x=He({version:"2022-01-01",elements:[g]},{channel:"inbox"});e.commands.setContent(x)}},[e,r,o]),u=Tp(m=>{if(!e)return!1;let{doc:f}=e.state,v=null,h=[];f.descendants((C,T)=>C.type.name==="buttonRow"&&v===null?(v=T,!1):(C.type.name==="button"&&h.push({pos:T,attrs:C.attrs}),!0));let y=a((C,T)=>{let E=f.nodeAt(C);return E?(e.commands.command(({tr:b})=>(b.setNodeMarkup(C,E.type,T),!0)),!0):!1},"applyAttrs");if(v!==null){let C=f.nodeAt(v);if(!C)return!1;let T={...C.attrs,button1Label:m.buttonLabel,button1Link:m.buttonUrl,button2Label:m.secondaryButtonLabel,button2Link:m.secondaryButtonUrl};return y(v,T)}if(h.length>0){let[C,T]=h,E={...C.attrs,label:m.buttonLabel,link:m.buttonUrl},b=y(C.pos,E),g=!0;if(T){let x={...T.attrs,label:m.secondaryButtonLabel,link:m.secondaryButtonUrl};g=y(T.pos,x)}return b&&g}return!1},[e]),d=Tp(m=>{if(n.current)return;let f=i.current;if(i.current=m,!f||f.enableButton!==m.enableButton||f.enableSecondaryButton!==m.enableSecondaryButton){c(m);return}u(m)||c(m)},[c,u]),p=xp("inbox-sidebar",d,500);return Gc(()=>{let m=l.watch((f,{name:v})=>{if(n.current)return;let h=l.getValues();v==="enableButton"||v==="enableSecondaryButton"?(d(h),p(h)):v&&p(h)});return()=>m.unsubscribe()},[l,p,d]),nt(Oe,{...l,children:ks("form",{"data-sidebar-form":!0,children:[nt("div",{className:"courier-pb-4",children:nt(re,{control:l.control,name:"enableButton",render:({field:m})=>ks(ee,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between",children:[nt(fo,{className:"!courier-m-0",children:"Enable button"}),nt(te,{children:nt(Yi,{checked:m.value,onCheckedChange:m.onChange,className:"!courier-m-0"})})]})})}),l.watch("enableButton")&&nt(re,{control:l.control,name:"buttonUrl",render:({field:m})=>ks(ee,{className:"courier-mb-6",children:[nt(fo,{children:"Action URL"}),nt(te,{children:nt(ge,{placeholder:"https://example.com",...m})}),nt(oe,{})]})}),nt(pe,{className:"courier-mb-6"}),nt(re,{control:l.control,name:"enableSecondaryButton",render:({field:m})=>ks(ee,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between courier-mb-4",children:[nt(fo,{className:"!courier-m-0",children:"Enable secondary button"}),nt(te,{children:nt(Yi,{checked:m.value,onCheckedChange:m.onChange,className:"!courier-m-0"})})]})}),l.watch("enableSecondaryButton")&&nt(re,{control:l.control,name:"secondaryButtonUrl",render:({field:m})=>ks(ee,{className:"courier-mb-4",children:[nt(fo,{children:"Action URL"}),nt(te,{children:nt(ge,{placeholder:"https://example.com",...m})}),nt(oe,{})]})})]})})},"SideBarComponent"),wp=QE(rw);import{useAtomValue as ow}from"jotai";import{jsx as aa,jsxs as nw}from"react/jsx-runtime";var G5=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s,...l})=>{let c=ow(le);return aa(Jc,{value:c,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:u=>nw("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[aa("div",{className:"courier-flex courier-flex-col courier-flex-1 courier-py-8 courier-items-center",children:aa(vp,{...u},`inbox-editor-${o?"no-autocomplete":"autocomplete"}`)}),aa("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:aa("div",{className:"courier-p-4 courier-h-full",children:aa(wp,{})})})]}),...l})},"InboxLayout");import{useCurrentEditor as iw}from"@tiptap/react";import{useAtom as aw,useAtomValue as Xc,useSetAtom as kp}from"jotai";import{forwardRef as sw,memo as lw,useCallback as cw,useEffect as Ps,useMemo as X5,useRef as Pp}from"react";import{jsx as Y5}from"react/jsx-runtime";var Q5=a(({value:e})=>{let{editor:t}=iw(),r=kp(Le),o=Xc(le),n=Xc(ye),i=Pp(!1);return Ps(()=>{n&&(i.current=!1)},[n]),Ps(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),Ps(()=>{t&&(r(t),ir("push",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),Ps(()=>{if(!t||!o||t.isFocused||$e())return;let s=document.activeElement;if(s!=null&&s.closest("[data-sidebar-form]"))return;let l=ey(o),c=l.type==="channel"&&"elements"in l&&l.elements||pi;c=c.map(f=>f.type==="meta"&&"title"in f?{type:"text",content:f.title||`
237
+ `,text_style:"h2"}:f);let d=He({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:c}]}),p=xe(d),m=xe(t.getJSON());JSON.stringify(p)!==JSON.stringify(m)&&setTimeout(()=>{let f=document.activeElement,v=(f==null?void 0:f.closest("[data-sidebar-form]"))!==null;!t.isFocused&&!$e()&&!v&&t.commands.setContent(d)},1)},[t,o]),null},"PushEditorContent"),pi=[{type:"meta",title:""},{type:"text",content:`
238
+ `}],ey=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:pi}),t},"getOrCreatePushElement"),ty={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"}},uw=sw(({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=Xc(ye),v=Pp(!0),h=Pp(!1),y=kp(Te),[C,T]=aw(le),E=kp(et),b=Xc(It);Ps(()=>(h.current=!0,()=>{h.current=!1}),[]);let g=X5(()=>[...rr({setSelectedNode:y,variables:u,disableVariablesAutocomplete:d,textMarks:"plain-text"})].filter(P=>P!==void 0),[y,u,d]),x=cw(({editor:P})=>{if(b)return;if(!C){let D=xe(P.getJSON()),V=D[0],W="",j=D;V&&V.type==="text"&&"text_style"in V&&V.text_style==="h2"&&(W=Sn(V).trim(),j=D.slice(1));let $={version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:Lr(null,"push",W,j).elements}]};T($),E($);return}let S=xe(P.getJSON()),w=S[0],M="",L=S;w&&w.type==="text"&&"text_style"in w&&w.text_style==="h2"&&(M=Sn(w).trim(),L=S.slice(1));let N=Lr(C,"push",M,L),I=Mt(C,{channel:"push",elements:N.elements});JSON.stringify(C)!==JSON.stringify(I)&&(T(I),E(I))},[C,T,E,b]),k=X5(()=>{var L;if(f!==!1)return null;let P=l!=null?l:C,S=(L=P==null?void 0:P.elements)==null?void 0:L.find(N=>N.type==="channel"&&N.channel==="push");S||(S=ey(P));let w=(S==null?void 0:S.type)==="channel"&&"elements"in S&&S.elements||pi;return w=w.map(N=>N.type==="meta"&&"title"in N?{type:"text",content:N.title||`
239
+ `,text_style:"h2"}:N),He({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:w}]})},[f]);return Y5(tr,{theme:e,colorScheme:c,isLoading:!!(f&&v.current),Header:i?i({hidePublish:t,channels:o,routing:n}):Y5(Pr,{hidePublish:t,channels:o,routing:n}),...p,ref:m,children:s==null?void 0:s({content:k,extensions:g,editable:!r,autofocus:!r,onUpdate:x})})}),Yc=lw(uw);import{EditorProvider as dw}from"@tiptap/react";import{useCallback as mw}from"react";import{jsx as jo,jsxs as Qc}from"react/jsx-runtime";var eu=a(({children:e})=>Qc("div",{className:"courier-relative",children:[jo("div",{className:"courier-absolute courier-w-0.5 courier-h-6 courier-bg-border -courier-left-[2px] courier-top-[136px]"}),jo("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[178px]"}),jo("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[245px]"}),jo("div",{className:"courier-absolute courier-w-0.5 courier-h-[78px] courier-bg-border -courier-right-[2px] courier-top-[200px]"}),Qc("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:[Qc("div",{className:"courier-my-6 courier-mx-11 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[jo("span",{className:"courier-text-xs courier-font-semibold",children:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),Qc("div",{className:"courier-flex courier-items-center courier-gap-2",children:[jo(zf,{}),jo(Kf,{}),jo(xf,{})]})]}),jo("div",{className:"courier-flex-1 courier-overflow-auto courier-h-[calc(90%-56px)] courier-mb-6",children:e})]})]}),"IPhoneFrame");import{Fragment as pw,jsx as sa,jsxs as tu}from"react/jsx-runtime";var Mp=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:s=!1,variableViewMode:l="show-variables"})=>{let c=e||{type:"doc",content:[{type:"paragraph"}]},u=s?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},d=mw(({editor:p})=>{Zt(p,l)},[l]);return tu(eu,{children:[tu("div",{className:R("courier-px-4 courier-py-2 courier-text-[#A3A3A3] courier-text-center courier-my-8",i),children:[sa("p",{className:"courier-text-lg courier-font-medium",children:new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}),sa("p",{className:"courier-text-5xl courier-font-semibold courier-mt-1",children:new Date().toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})})]}),tu(dw,{content:c,extensions:t,...u,onCreate:d,editorContainerProps:{className:R("courier-push-editor")},"data-testid":"editor-provider",immediatelyRender:!1,children:[sa(nr,{variableViewMode:l}),s?sa(Mr,{value:c,defaultValue:pi}):tu(pw,{children:[sa(Q5,{value:c}),sa(or,{config:ty})]})]})]})},"PushEditor");import{useAtomValue as fw}from"jotai";import{jsx as Np}from"react/jsx-runtime";var ry=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,...s})=>{let l=fw(le);return Np(Yc,{value:l,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,render:c=>Np("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:Np(Mp,{...c},`push-editor-${o?"no-autocomplete":"autocomplete"}`)}),...s})},"PushLayout");import{Extension as gw}from"@tiptap/core";import{Fragment as oy,Slice as hw}from"@tiptap/pm/model";import{Plugin as bw,PluginKey as yw}from"@tiptap/pm/state";var Sp={textAlign:"left",backgroundColor:"transparent",borderWidth:0,borderColor:"transparent",paddingHorizontal:0},vw=new yw("messagingChannelPaste");function Cw(e,t){var n;let r=new DOMParser().parseFromString(e,"text/html");r.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach(i=>{let s=r.createElement(t.headingBehavior==="strip"?"p":"div");for(t.headingBehavior!=="strip"&&s.setAttribute("data-type","heading");i.firstChild;)s.appendChild(i.firstChild);i.replaceWith(s)});let o={button:'[data-type="button"]'};if((n=t.blockedNodeTypes)!=null&&n.length){let i=t.blockedNodeTypes.map(s=>o[s]).filter(Boolean).join(", ");i&&r.querySelectorAll(i).forEach(s=>s.remove())}return r.querySelectorAll("p, div, blockquote").forEach(i=>{i instanceof HTMLElement&&(i.style.textAlign="",i.style.backgroundColor="",i.style.borderWidth="",i.style.borderColor="",i.style.borderStyle="")}),r.body.innerHTML}a(Cw,"transformHTML");function ny(e,t){var n;if((n=t.blockedNodeTypes)!=null&&n.includes(e.type.name))return null;let r=[];e.content.forEach(i=>{let s=ny(i,t);s&&r.push(s)});let o=oy.from(r);if(e.type.name==="heading")if(t.headingBehavior==="strip"){let i=e.type.schema.nodes.paragraph;if(i){let s={...e.attrs,...Sp};return i.create(s,o,e.marks)}}else{let i={...e.attrs,...Sp,level:t.headingBehavior.level};return e.type.create(i,o,e.marks)}if(e.type.name==="paragraph"){let i={...e.attrs,...Sp};return e.type.create(i,o,e.marks)}return e.type.name==="blockquote"?e.type.create(e.attrs,o,e.marks):e.childCount>0?e.copy(o):e}a(ny,"normalizeNode");var Ms=gw.create({name:"messagingChannelPaste",addOptions(){return{headingBehavior:{level:1},blockedNodeTypes:[]}},addProseMirrorPlugins(){let e=this.options;return[new bw({key:vw,props:{transformPastedHTML(t){return Cw(t,e)},transformPasted(t){let r=[];return t.content.forEach(o=>{let n=ny(o,e);n&&r.push(n)}),new hw(oy.from(r),t.openStart,t.openEnd)}}})]}});import{Extension as xw}from"@tiptap/core";import{TextSelection as Tw}from"@tiptap/pm/state";import{useCurrentEditor as Ew}from"@tiptap/react";import{useAtom as iy,useAtomValue as vn,useSetAtom as ly}from"jotai";import{forwardRef as ww,memo as kw,useCallback as ay,useEffect as Nr,useMemo as ru,useRef as ca,useState as sy}from"react";import{Fragment as Iw,jsx as Ap}from"react/jsx-runtime";var Ns=[{type:"text",content:`
240
+ `}],cy=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:Ns}),t},"getOrCreateSlackElement"),uy=a(({value:e})=>{let{editor:t}=Ew(),r=ly(Le),o=vn(le),n=vn(ye),i=vn(Te),s=ca(!1),l=ca(!1);return Nr(()=>{n&&(s.current=!1)},[n]),Nr(()=>{!t||n!==!1||s.current||!e||(s.current=!0,t.commands.setContent(e))},[t,e,n]),Nr(()=>{t&&(r(t),ir("slack",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),Nr(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),Nr(()=>(l.current=!0,()=>{l.current=!1}),[]),Nr(()=>{if(!t||!o||t.isFocused||$e())return;let c=document.activeElement;if(c!=null&&c.closest("[data-sidebar-form]"))return;let u=cy(o),d=He({version:"2022-01-01",elements:[u]},{channel:"slack"}),p=xe(d),m=xe(t.getJSON());JSON.stringify(p)!==JSON.stringify(m)&&setTimeout(()=>{let f=document.activeElement,v=(f==null?void 0:f.closest("[data-sidebar-form]"))!==null;!t.isFocused&&!$e()&&!v&&t.commands.setContent(d)},1)},[t,o]),null},"SlackEditorContent"),Pw={alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"}},Mw=[{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"]}}],la={conditionalRules:Mw,...Pw},Nw={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"},...la},Sw=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:"hidden"},strike:{state:"enabled"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"enabled"},variable:{state:"enabled"},...la};if(r&&!t)return{contentType:{state:"enabled"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},quote:{state:"enabled"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:"hidden"},variable:{state:"enabled"},...la};switch(e){case"list":return{contentType:{state:"hidden"},bold:{state:t?"enabled":"hidden"},italic:{state:t?"enabled":"hidden"},underline:{state:"hidden"},strike:{state:t?"enabled":"hidden"},quote:{state:"hidden"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:t?"enabled":"hidden"},variable:{state:"enabled"},...la};case"button":return{bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"hidden"},strike:{state:"enabled"},...la};default:return{contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"},...la}}},"getTextMenuConfigForSlackNode"),Aw=ww(({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=vn(ye),v=vn(It),h=vn(Le),y=vn(Xt),[C,T]=iy(Te),[E,b]=iy(le),g=ly(et),x=ca(!0),k=ca(!1),P=ca(y),S=ca(null),w=vn(to),[M,L]=sy(!1);Nr(()=>{if(!h)return;let F=a(()=>{var A;try{let H=(A=h.state)==null?void 0:A.selection;if(H){let{from:_,to:B}=H;L(_!==B)}}catch{}},"updateSelection");return h.on("selectionUpdate",F),h.on("transaction",F),F(),()=>{h.off("selectionUpdate",F),h.off("transaction",F)}},[h]),Nr(()=>{let F=a(A=>{A.key==="Escape"&&(T(null),h==null||h.commands.blur())},"handleKeyDown");return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[T,h]);let N=ru(()=>C?Sw(C.type.name,M):Nw,[C,M]),I=ru(()=>{let F=["text","divider","button","list"];return w.filter(A=>{let H=dr(A)?A.type:A;return F.includes(H)})},[w]),[D,V]=sy({Sidebar:I,Editor:[]});Nr(()=>{V(F=>({...F,Sidebar:I}))},[I]),ta({items:D,setItems:V});let{syncEditorItems:W}=Oc({setItems:V,rafId:S});Nr(()=>(k.current=!0,()=>{k.current=!1}),[]),Nr(()=>{P.current=y},[y]),Nr(()=>{f===!1&&E&&setTimeout(()=>{h&&!h.isDestroyed&&W(h)},300)},[f,E,h,W]);let j=ay(()=>!P.current,[]),O=xw.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:F})=>{let{state:A,dispatch:H}=F.view;return H(A.tr.setSelection(Tw.create(A.doc,A.selection.$anchor.pos))),T(null),!1}}}}),$=ru(()=>[...rr({setSelectedNode:T,shouldHandleClick:j,variables:u,disableVariablesAutocomplete:d,textMarks:{underline:"disabled"}}),Ms.configure({headingBehavior:{level:1}}),O].filter(F=>F!==void 0),[O,T,j,u,d]),J=ay(({editor:F})=>{if(!F||v)return;if(!E){let K={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:xe(F.getJSON())}]};b(K),g(K);return}let A=F.getJSON(),H=xe(A),_=Mt(E,{elements:H,channel:"slack"}),B=JSON.stringify(E.elements),U=JSON.stringify(_.elements);B!==U&&(b(_),g(_))},[E,b,g,v]),q=ru(()=>{let F=cy(l);return He({version:"2022-01-01",elements:[F]},{channel:"slack"})},[l]);return Ap(tr,{theme:e,colorScheme:c,isLoading:!!(f&&x.current),Header:i?i({hidePublish:t,channels:o,routing:n}):Ap(Pr,{hidePublish:t,channels:o,routing:n}),ref:m,...p,children:Ap(Iw,{children:s==null?void 0:s({content:q,extensions:$,editable:!r,autofocus:!r,onUpdate:J,items:D,selectedNode:C,slackEditor:h,textMenuConfig:N})})})}),ou=kw(Aw);import{EditorProvider as Bw}from"@tiptap/react";import{jsx as _t,jsxs as ua}from"react/jsx-runtime";var Lw=a(()=>ua("div",{className:"courier-flex courier-gap-2 courier-flex-col courier-w-full",children:[_t("div",{className:"courier-w-3/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),_t("div",{className:"courier-w-full courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),_t("div",{className:"courier-w-6/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"})]}),"TextSkeleton"),Rw=a(()=>_t("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-lg",children:_t(Da,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),dy=a(()=>ua("div",{className:"courier-flex courier-gap-2 courier-flex-row",children:[_t(Rw,{}),_t(Lw,{})]}),"InteractionSkeleton"),my=a(({children:e,className:t})=>ua("div",{className:R("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:[_t(dy,{}),ua("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[_t("div",{className:"courier-flex-shrink-0",children:_t("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:_t(Ba,{color:"#FFFFFF"})})}),ua("div",{className:"courier-flex-1 courier-min-w-0",children:[ua("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mb-1",children:[_t("span",{className:"courier-font-semibold courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1]",children:"Circle"}),_t("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"}),_t("span",{className:"courier-text-xs courier-text-gray-500 dark:courier-text-[#8786A9]",children:"Now"})]}),_t("div",{className:"courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-pr-4",children:e})]})]}),_t(dy,{})]}),"SlackFrame");import{useRef as py,useEffect as Dw,useCallback as Ip}from"react";import{useSetAtom as fy}from"jotai";import{Fragment as Vw,jsx as da,jsxs as gy}from"react/jsx-runtime";var Lp=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1,variableViewMode:s="show-variables",textMenuConfig:l})=>{let c=py(null),u=py(!0),d=fy(Ve),p=fy(Yo),m=Ip(({editor:h})=>{Zt(h,s),setTimeout(()=>{u.current=!1},100)},[s]),f=Ip(({editor:h})=>{if(u.current||$e())return;let{selection:y}=h.state,{$anchor:C}=y,E=y.$head.marks().find(P=>P.type.name==="link");E||h.isActive("link")?p({mark:E}):p(null);let b=C.depth,g=null,x=null,k=null;for(;b>0;){let P=C.node(b);!x&&P.type.name==="blockquote"&&(x=P),!k&&P.type.name==="list"&&(k=P),!g&&(P.type.name==="paragraph"||P.type.name==="heading")&&(g=P),b--}k?d(k):x?d(x):g&&d(g)},[p,d]),v=Ip(({editor:h,transaction:y})=>{let C=y==null?void 0:y.getMeta("showLinkForm");if(C){let{selection:T}=h.state,b=T.$head.marks().find(g=>g.type.name==="link");p({mark:b,link:{from:C.from,to:C.to}})}},[p]);return Dw(()=>{let h=c.current;if(!(!h||i))return mr({element:h,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?da(my,{children:da("div",{ref:c,children:gy(Bw,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,onCreate:m,onSelectionUpdate:f,onTransaction:v,editorContainerProps:{className:R("courier-slack-editor")},immediatelyRender:!1,children:[da(nr,{variableViewMode:s}),i?da(Mr,{value:e,defaultValue:Ns}):gy(Vw,{children:[da(uy,{value:e}),da(or,{config:l})]})]})})}):null},"SlackEditor");import{useAtomValue as zw}from"jotai";import{GripVertical as Hw}from"lucide-react";import{Fragment as Fw,jsx as xo,jsxs as Rp}from"react/jsx-runtime";var Bp=a(({items:e,label:t,editor:r})=>xo("div",{className:"courier-flex courier-flex-col courier-h-full",children:Rp("div",{className:"courier-flex-1",children:[t&&Rp(Fw,{children:[xo("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),xo(pe,{className:"courier-my-4"})]}),xo("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>{let n=dr(o)?`${o.type}:${o.preset}`:o,i=dr(o)?o.type:o;return xo(oa,{id:n,editor:r,children:Rp("div",{className:R("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:[xo(Hw,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),i==="text"&&xo(sn,{draggable:!0}),i==="divider"&&xo(nn,{draggable:!0}),i==="button"&&xo(on,{draggable:!0}),i==="list"&&xo(an,{draggable:!0})]})},n)})})]})}),"SlackSideBar");import{zodResolver as Ow}from"@hookform/resolvers/zod";import{useForm as _w}from"react-hook-form";import{jsx as ma,jsxs as Dp}from"react/jsx-runtime";var hy=a(({element:e,editor:t})=>{let r=_w({resolver:Ow(Bl),defaultValues:{...Se,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=xt({editor:t,element:e,form:r,nodeType:"button"});return e?Dp(Oe,{...r,children:[ma(Tt,{type:"button"}),Dp("form",{"data-sidebar-form":!0,onChange:()=>{o(r.getValues())},children:[ma("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),ma(re,{control:r.control,name:"link",render:({field:n})=>Dp(ee,{children:[ma(te,{children:ma(uo,{value:n.value,onChange:i=>{Po(!0),n.onChange(i),o({...r.getValues(),link:i}),setTimeout(()=>{Po(!1)},50)}})}),ma(oe,{})]})})]})]}):null},"SlackButtonForm");import{useAtomValue as Ww}from"jotai";import{jsx as Ss}from"react/jsx-runtime";var Vp=a(({element:e,editor:t,defaultElement:r})=>{var n,i;let o=Ww(Rn);return e?o!=null&&o.link||((n=o==null?void 0:o.mark)==null?void 0:n.type.name)==="link"&&((i=e.marks)!=null&&i.some(s=>s.type.name==="link"))?Ss(Gi,{editor:t,mark:o==null?void 0:o.mark,pendingLink:o==null?void 0:o.link}):e.type.name==="button"?Ss("div",{className:"courier-flex courier-flex-col courier-gap-4",children:Ss(hy,{element:e,editor:t},e.attrs.id)}):e.type.name==="list"?Ss("div",{className:"courier-flex courier-flex-col courier-gap-4",children:Ss(oi,{element:e,editor:t,minimalMode:!0},e.attrs.id)}):r:r},"SlackSideBarItemDetails");import{forwardRef as by}from"react";import{jsx as Kr,jsxs as qw}from"react/jsx-runtime";var Uw=by(({children:e,className:t,...r},o)=>Kr("div",{className:R("courier-editor-container courier-relative",t),...r,ref:o,children:e})),$w=by(({children:e,...t},r)=>Kr("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),yy=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s})=>{let l=zw(le);return Kr(ou,{value:l,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:c=>{var u;return qw(ci,{children:[Kr("div",{className:"courier-flex courier-flex-col courier-flex-1",children:Kr(Uw,{children:Kr($w,{children:Kr(Lp,{...c},`slack-editor-${o?"no-autocomplete":"autocomplete"}`)})})}),Kr(ui,{children:Kr("div",{className:"courier-p-1 courier-h-full",children:Kr(Vp,{element:c.selectedNode,editor:c.slackEditor,defaultElement:Kr(Bp,{items:c.items.Sidebar,label:"Blocks library",editor:(u=c.slackEditor)!=null?u:void 0})})})})]})}})},"SlackLayout");import{useCurrentEditor as jw}from"@tiptap/react";import{useAtom as Zw,useAtomValue as nu,useSetAtom as Hp}from"jotai";import{forwardRef as Kw,memo as Jw,useCallback as Gw,useEffect as As,useMemo as Fp,useRef as Op}from"react";import{SegmentedMessage as Xw}from"sms-segments-calculator";import{jsx as _p}from"react/jsx-runtime";var Zo=[{type:"text",content:`
241
+ `}],vy=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:Zo}),t},"getOrCreateSMSElement"),Cy=a(({value:e})=>{var c;let{editor:t}=jw(),r=Hp(Le),o=nu(le),n=(c=t==null?void 0:t.getText())!=null?c:"",i=Fp(()=>new Xw(n),[n]),s=nu(ye),l=Op(!1);return As(()=>{s&&(l.current=!1)},[s]),As(()=>{!t||s!==!1||l.current||!e||(l.current=!0,t.commands.setContent(e))},[t,e,s]),As(()=>{t&&(r(t),ir("sms",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),As(()=>{if(!t||!o||t.isFocused||$e())return;let u=document.activeElement;if(u!=null&&u.closest("[data-sidebar-form]"))return;let d=vy(o),m={type:"channel",channel:"sms",elements:d.type==="channel"&&"elements"in d&&d.elements||Zo},f=He({version:"2022-01-01",elements:[m]}),v=xe(f),h=xe(t.getJSON());JSON.stringify(v)!==JSON.stringify(h)&&setTimeout(()=>{let y=document.activeElement,C=(y==null?void 0:y.closest("[data-sidebar-form]"))!==null;!t.isFocused&&!$e()&&!C&&t.commands.setContent(f)},1)},[t,o]),_p("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"),xy={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"}},Yw=Kw(({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=nu(ye),v=Op(!0),h=Op(!1),y=Hp(Te),[C,T]=Zw(le),E=Hp(et),b=nu(It);As(()=>(h.current=!0,()=>{h.current=!1}),[]);let g=Fp(()=>[...rr({setSelectedNode:y,variables:u,disableVariablesAutocomplete:d,textMarks:"plain-text"})].filter(P=>P!==void 0),[y,u,d]),x=Gw(({editor:P})=>{if(b)return;if(!C){let L=xe(P.getJSON()),N=js(L),I={version:"2022-01-01",elements:[{type:"channel",channel:"sms",elements:N.length>0?N:Zo}]};T(I),E(I);return}let S=xe(P.getJSON()),w=js(S),M=Mt(C,{channel:"sms",elements:w.length>0?w:Zo});JSON.stringify(C)!==JSON.stringify(M)&&(T(M),E(M))},[C,T,E,b]),k=Fp(()=>{var L;if(f!==!1)return null;let P=l!=null?l:C,S=(L=P==null?void 0:P.elements)==null?void 0:L.find(N=>N.type==="channel"&&N.channel==="sms");S||(S=vy(P));let M={type:"channel",channel:"sms",elements:(S==null?void 0:S.type)==="channel"&&"elements"in S&&S.elements||Zo};return He({version:"2022-01-01",elements:[M]})},[f]);return _p(tr,{theme:e,colorScheme:c,isLoading:!!(f&&v.current),Header:s?s({hidePublish:t,channels:o,routing:n}):_p(Pr,{hidePublish:t,channels:o,routing:n}),...p,ref:m,children:i==null?void 0:i({content:k,extensions:g,editable:!r,autofocus:!r,onUpdate:x})})}),iu=Jw(Yw);import{EditorProvider as Qw}from"@tiptap/react";import{useCallback as ek}from"react";import{Fragment as tk,jsx as pa,jsxs as Ty}from"react/jsx-runtime";var Wp=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:s=!1,variableViewMode:l="show-variables"})=>{let c=e||{type:"doc",content:[{type:"paragraph"}]},u=s?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},d=ek(({editor:p})=>{Zt(p,l)},[l]);return pa(eu,{children:pa("div",{className:R("courier-sms-editor",i),children:Ty(Qw,{content:c,extensions:t,...u,onCreate:d,"data-testid":"editor-provider",immediatelyRender:!1,children:[pa(nr,{variableViewMode:l}),s?pa(Mr,{value:c,defaultValue:Zo}):Ty(tk,{children:[pa(Cy,{value:c}),pa(or,{config:xy})]})]})})})},"SMSEditor");import{useAtomValue as rk}from"jotai";import{jsx as zp}from"react/jsx-runtime";var Ey=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s,...l})=>{let c=rk(le);return zp(iu,{value:c,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:u=>zp("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:zp(Wp,{...u},`sms-editor-${o?"no-autocomplete":"autocomplete"}`)}),...l})},"SMSLayout");import{Extension as ok}from"@tiptap/core";import{TextSelection as nk}from"@tiptap/pm/state";import{useCurrentEditor as ik}from"@tiptap/react";import{useAtom as wy,useAtomValue as Cn,useSetAtom as Py}from"jotai";import{forwardRef as ak,memo as sk,useCallback as Up,useEffect as hr,useMemo as au,useRef as ga,useState as ky}from"react";import{Fragment as fk,jsx as $p}from"react/jsx-runtime";var Is=[{type:"text",content:`
242
+ `}],My=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:Is}),t},"getOrCreateMSTeamsElement"),Ny=a(({value:e})=>{let{editor:t}=ik(),r=Py(Le),o=Cn(le),n=Cn(ye),i=Cn(Te),s=ga(!1),l=ga(!1);return hr(()=>{n&&(s.current=!1)},[n]),hr(()=>{!t||n!==!1||s.current||!e||(s.current=!0,t.commands.setContent(e))},[t,e,n]),hr(()=>{t&&(r(t),ir("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),hr(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),hr(()=>(l.current=!0,()=>{l.current=!1}),[]),hr(()=>{if(!t||!o||t.isFocused||$e())return;let c=document.activeElement;if(c!=null&&c.closest("[data-sidebar-form]"))return;let u=My(o),d=He({version:"2022-01-01",elements:[u]},{channel:"msteams"}),p=xe(d),m=xe(t.getJSON());JSON.stringify(p)!==JSON.stringify(m)&&setTimeout(()=>{let f=document.activeElement,v=(f==null?void 0:f.closest("[data-sidebar-form]"))!==null;!t.isFocused&&!$e()&&!v&&t.commands.setContent(d)},1)},[t,o]),null},"MSTeamsEditorContent"),lk={alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"}},ck={underline:{state:"hidden"},strike:{state:"hidden"}},uk=[{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"]}}],fa={conditionalRules:uk,...ck,...lk},dk={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"},...fa},mk=a((e,t=!1)=>{let r=["paragraph","heading","blockquote"].includes(e);if(r&&t)return{contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:"enabled"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"enabled"},variable:{state:"enabled"},...fa};if(r&&!t)return{contentType:{state:"enabled"},bold:{state:"hidden"},italic:{state:"hidden"},quote:{state:"enabled"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:"hidden"},variable:{state:"enabled"},...fa};switch(e){case"list":return{contentType:{state:"hidden"},bold:{state:t?"enabled":"hidden"},italic:{state:t?"enabled":"hidden"},quote:{state:"hidden"},orderedList:{state:"enabled"},unorderedList:{state:"enabled"},link:{state:t?"enabled":"hidden"},variable:{state:"enabled"},...fa};case"button":return{bold:{state:"enabled"},italic:{state:"enabled"},...fa};default:return{contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},quote:{state:"hidden"},orderedList:{state:"hidden"},unorderedList:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"},...fa}}},"getTextMenuConfigForMSTeamsNode"),pk=ak(({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=Cn(ye),v=Cn(It),h=Cn(Le),y=Cn(Xt),[C,T]=wy(Te),[E,b]=wy(le),g=Py(et),x=ga(!0),k=ga(!1),P=ga(y),S=Cn(to),[w,M]=ky(!1);hr(()=>{if(!h)return;let F=a(()=>{var A;try{let H=(A=h.state)==null?void 0:A.selection;if(H){let{from:_,to:B}=H;M(_!==B)}}catch{}},"updateSelection");return h.on("selectionUpdate",F),h.on("transaction",F),F(),()=>{h.off("selectionUpdate",F),h.off("transaction",F)}},[h]),hr(()=>{let F=a(A=>{A.key==="Escape"&&(T(null),h==null||h.commands.blur())},"handleKeyDown");return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[T,h]);let L=au(()=>C?mk(C.type.name,w):dk,[C,w]),N=au(()=>{let F=["text","divider","list"];return S.filter(A=>{let H=dr(A)?A.type:A;return F.includes(H)})},[S]),[I,D]=ky({Sidebar:N,Editor:[]});hr(()=>{D(F=>({...F,Sidebar:N}))},[N]);let V=ga(null);ta({items:I,setItems:D});let W=Up(F=>{V.current&&cancelAnimationFrame(V.current),setTimeout(()=>{V.current=requestAnimationFrame(()=>{try{let A=F==null?void 0:F.view.dom;if(!A){console.warn("syncEditorItems: Editor DOM element not found");return}let H=A.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),_=[];H.forEach(B=>{let U=B.dataset.id;U&&_.push(U)}),D(B=>({Editor:_,Sidebar:B.Sidebar}))}catch(A){console.error("Error syncing editor items:",A),D(H=>({...H}))}})},50)},[]);hr(()=>(k.current=!0,()=>{k.current=!1}),[]),hr(()=>{P.current=y},[y]),hr(()=>{let F=a(()=>{h&&W(h)},"updateItems");h==null||h.on("update",F),h==null||h.on("selectionUpdate",F),h==null||h.on("create",F),h==null||h.on("transaction",F),h&&!h.isDestroyed&&F();let A=a(H=>{F()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",A),()=>{h==null||h.off("update",F),h==null||h.off("selectionUpdate",F),h==null||h.off("create",F),h==null||h.off("transaction",F),document.removeEventListener("node-duplicated",A),V.current&&cancelAnimationFrame(V.current)}},[h,W]),hr(()=>{f===!1&&E&&setTimeout(()=>{h&&!h.isDestroyed&&W(h)},300)},[f,E,h,W]);let j=Up(()=>!P.current,[]),O=ok.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:F})=>{let{state:A,dispatch:H}=F.view;return H(A.tr.setSelection(nk.create(A.doc,A.selection.$anchor.pos))),T(null),!1}}}}),$=au(()=>[...rr({setSelectedNode:T,shouldHandleClick:j,variables:u,disableVariablesAutocomplete:d,textMarks:{underline:"disabled",strike:"disabled"}}),Ms.configure({headingBehavior:"strip",blockedNodeTypes:["button"]}),O].filter(F=>F!==void 0),[O,T,j,u,d]),J=Up(({editor:F})=>{if(!F||v)return;if(!E){let K={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:xe(F.getJSON())}]};b(K),g(K);return}let A=F.getJSON(),H=xe(A),_=Mt(E,{elements:H,channel:"msteams"}),B=JSON.stringify(E.elements),U=JSON.stringify(_.elements);B!==U&&(b(_),g(_))},[E,b,g,v]),q=au(()=>{let F=My(l);return He({version:"2022-01-01",elements:[F]},{channel:"msteams"})},[l]);return $p(tr,{theme:e,colorScheme:c,isLoading:!!(f&&x.current),Header:i?i({hidePublish:t,channels:o,routing:n}):$p(Pr,{hidePublish:t,channels:o,routing:n}),ref:m,...p,children:$p(fk,{children:s==null?void 0:s({content:q,extensions:$,editable:!r,autofocus:!r,onUpdate:J,items:I,selectedNode:C,msteamsEditor:h,textMenuConfig:L})})})}),su=sk(pk);import{EditorProvider as yk}from"@tiptap/react";import{jsx as Wt,jsxs as Ls}from"react/jsx-runtime";var gk=a(()=>Wt("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-full",children:Wt(Da,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),hk=a(()=>Ls("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[Wt(gk,{}),Ls("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[Wt("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"}),Wt("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),bk=a(()=>Wt("div",{className:"courier-flex courier-justify-end courier-w-full",children:Wt("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:Wt("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),Sy=a(({children:e,className:t})=>Ls("div",{className:R("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:[Wt(hk,{}),Ls("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[Wt("div",{className:"courier-flex-shrink-0 courier-mt-6",children:Wt("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:Wt(Ba,{color:"#FFFFFF"})})}),Ls("div",{className:"courier-flex-1 courier-min-w-0",children:[Wt("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:Wt("span",{className:"courier-text-sm courier-text-[#A3A3A3] dark:courier-text-[#8786A9]",children:"Circle"})}),Wt("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})]})]}),Wt(bk,{})]}),"MSTeamsFrame");import{useRef as Ay,useEffect as vk,useCallback as qp}from"react";import{useSetAtom as Iy}from"jotai";import{Fragment as Ck,jsx as ha,jsxs as Ly}from"react/jsx-runtime";var jp=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1,variableViewMode:s="show-variables",textMenuConfig:l})=>{let c=Ay(null),u=Ay(!0),d=Iy(Ve),p=Iy(Yo),m=qp(({editor:h})=>{Zt(h,s),setTimeout(()=>{u.current=!1},100)},[s]),f=qp(({editor:h})=>{if(u.current||$e())return;let{selection:y}=h.state,{$anchor:C}=y,E=y.$head.marks().find(P=>P.type.name==="link");E||h.isActive("link")?p({mark:E}):p(null);let b=C.depth,g=null,x=null,k=null;for(;b>0;){let P=C.node(b);!x&&P.type.name==="blockquote"&&(x=P),!k&&P.type.name==="list"&&(k=P),!g&&(P.type.name==="paragraph"||P.type.name==="heading")&&(g=P),b--}k?d(k):x?d(x):g&&d(g)},[p,d]),v=qp(({editor:h,transaction:y})=>{let C=y==null?void 0:y.getMeta("showLinkForm");if(C){let{selection:T}=h.state,b=T.$head.marks().find(g=>g.type.name==="link");p({mark:b,link:{from:C.from,to:C.to}})}},[p]);return vk(()=>{let h=c.current;if(!(!h||i))return mr({element:h,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?ha(Sy,{children:ha("div",{ref:c,children:Ly(yk,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,onCreate:m,onSelectionUpdate:f,onTransaction:v,editorContainerProps:{className:R("courier-msteams-editor")},immediatelyRender:!1,children:[ha(nr,{variableViewMode:s}),i?ha(Mr,{value:e,defaultValue:Is}):Ly(Ck,{children:[ha(Ny,{value:e}),ha(or,{config:l})]})]})})}):null},"MSTeamsEditor");import{useAtomValue as wk}from"jotai";import{GripVertical as xk}from"lucide-react";import{Fragment as Tk,jsx as To,jsxs as Zp}from"react/jsx-runtime";var Kp=a(({items:e,label:t,editor:r})=>To("div",{className:"courier-flex courier-flex-col courier-h-full",children:Zp("div",{className:"courier-flex-1",children:[t&&Zp(Tk,{children:[To("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),To(pe,{className:"courier-my-4"})]}),To("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>{let n=dr(o)?`${o.type}:${o.preset}`:o,i=dr(o)?o.type:o;return To(oa,{id:n,editor:r,children:Zp("div",{className:R("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:[To(xk,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),i==="text"&&To(sn,{draggable:!0}),i==="divider"&&To(nn,{draggable:!0}),i==="button"&&To(on,{draggable:!0}),i==="list"&&To(an,{draggable:!0})]})},n)})})]})}),"MSTeamsSideBar");import{useAtomValue as Ek}from"jotai";import{jsx as Rs}from"react/jsx-runtime";var Jp=a(({element:e,editor:t,defaultElement:r})=>{var n,i;let o=Ek(Rn);return e?o!=null&&o.link||((n=o==null?void 0:o.mark)==null?void 0:n.type.name)==="link"&&((i=e.marks)!=null&&i.some(s=>s.type.name==="link"))?Rs(Gi,{editor:t,mark:o==null?void 0:o.mark,pendingLink:o==null?void 0:o.link}):e.type.name==="button"?Rs("div",{className:"courier-flex courier-flex-col courier-gap-4",children:Rs(lc,{element:e,editor:t},e.attrs.id)}):e.type.name==="list"?Rs("div",{className:"courier-flex courier-flex-col courier-gap-4",children:Rs(oi,{element:e,editor:t,minimalMode:!0},e.attrs.id)}):r:r},"MSTeamsSideBarItemDetails");import{forwardRef as Ry}from"react";import{jsx as Jr,jsxs as Mk}from"react/jsx-runtime";var kk=Ry(({children:e,className:t,...r},o)=>Jr("div",{className:R("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Pk=Ry(({children:e,...t},r)=>Jr("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),By=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s})=>{let l=wk(le);return Jr(su,{value:l,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:c=>{var u;return Mk(ci,{children:[Jr("div",{className:"courier-flex courier-flex-col courier-flex-1",children:Jr(kk,{children:Jr(Pk,{children:Jr(jp,{...c},`msteams-editor-${o?"no-autocomplete":"autocomplete"}`)})})}),Jr(ui,{children:Jr("div",{className:"courier-p-1 courier-h-full",children:Jr(Jp,{element:c.selectedNode,editor:c.msteamsEditor,defaultElement:Jr(Kp,{items:c.items.Sidebar,label:"Blocks library",editor:(u=c.msteamsEditor)!=null?u:void 0})})})})]})}})},"MSTeamsLayout");var Hy={sms:{elements:Zo},push:{elements:pi},inbox:{elements:ws},slack:{elements:Ns},email:{elements:Cs},msteams:{elements:Is}},Yp=a(e=>{var t;return(t=Hy[e])!=null?t:Hy.email},"getChannelDefaults"),Ik=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"),Qp=a(({channels:e=["email"],routing:t})=>{let[r,o]=Ak([]),n=Dy(le),i=lu(le),s=lu(et),[l,c]=Nk(oo),u=lu(Te),d=lu(Le),p=Dy(ye),m=Gp(E=>{E!==l&&(u(null),d(null)),c(E)},[c,u,d,l]),f=Ik(t,e),v=Sk(f);v.current=f,Xp(()=>{if(p||n!=null&&n.elements)return;let b=v.current.map(g=>Vn.find(x=>x.value===g)).filter(g=>!!g);o(b),b.length>0&&!l&&m(b[0].value)},[n,p,m,l]),Xp(()=>{if(p||!(n!=null&&n.elements))return;let E=v.current,b=n.elements.filter(x=>x.type==="channel").map(x=>x.channel).filter(x=>E.includes(x)),g=E.filter(x=>b.includes(x)).map(x=>Vn.find(k=>k.value===x)).filter(x=>!!x);o(g)},[n,p]),Xp(()=>{var g;if(p||r.length===0)return;let E=r.some(x=>x.value===l),b=(g=n==null?void 0:n.elements)==null?void 0:g.some(x=>x.type==="channel"&&x.channel===l);!E&&!b&&m(r[0].value)},[r,l,m,p,n]);let h=Vy(()=>(f==null?void 0:f.filter(E=>!r.some(b=>b.value===E)).map(E=>Vn.find(b=>b.value===E)).filter(E=>!!E))||[],[r,f]),y=Gp(E=>{let b=[],g,{elements:x,raw:k}=Yp(E);if(b=x,g=k,!n){let w=[];for(let N of r){let{elements:I,raw:D}=Yp(N.value),V={type:"channel",channel:N.value,elements:I};D&&(V.raw=D),w.push(V)}let M={type:"channel",channel:E,elements:b};g&&(M.raw=g),w.push(M);let L={version:"2022-01-01",elements:w};i(L),s(L),m(E);return}let S=Mt(n,{elements:b,channel:g?{channel:E,raw:g}:E});i(S),s(S),m(E)},[n,i,s,m,r]),C=Gp(E=>{if(!n)return;let b=n.elements.filter(k=>k.type==="channel"?k.channel!==E:!0),g={...n,elements:b};i(g),s(g),u(null);let x=r.filter(k=>k.value!==E);l===E&&x.length>0&&m(x[0].value)},[n,i,s,r,l,m,u]),T=Vy(()=>[...r,...h],[r,h]);return{enabledChannels:r,disabledChannels:h,channel:l,channelOptions:T,setChannel:m,addChannel:y,removeChannel:C}},"useChannels");import{Fragment as Hk,jsx as Dt,jsxs as Eo}from"react/jsx-runtime";var Pr=a(({hidePublish:e=!1,channels:t,routing:r})=>{let o=Vk(null),n=cu(yt),i=cu(ye),s=cu(se),{publishTemplate:l,isTemplatePublishing:c}=Ma(),[u,d]=Rk(hi),p=Bk(ur),m=cu(ur),{enabledChannels:f,disabledChannels:v,channel:h,setChannel:y,addChannel:C,removeChannel:T}=Qp({channels:t,routing:r});Dk(()=>{n===!0&&d(null)},[n,d]);let E=Bs(()=>{m&&p(!1),l()},[l,m,p]),b=Bs(P=>{m&&p(!1),y(P)},[m,p,y]),g=Bs(P=>{m&&p(!1),C(P)},[m,p,C]),x=Bs(P=>{m&&p(!1),T(P)},[m,p,T]),k=Bs(()=>{m&&p(!1)},[m,p]);return Eo("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:k,children:[Eo("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[Dt(Ji,{value:h,onValueChange:b,className:"courier-h-full",ref:o,children:Dt(ti,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${Vn.length}, fit-content(100%))`},children:f.map(P=>Eo(Oo,{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&&Eo(n5,{children:[Dt(i5,{asChild:!0,children:Dt("div",{className:"courier-pl-2",children:Dt(Sa,{color:"#A3A3A3"})})}),Eo(Om,{ref:o,children:[Dt(_m,{children:Dt(Lk,{children:"Are you sure you want to delete this channel?"})}),Eo(Wm,{children:[Dt(Um,{asChild:!0,children:Dt(Ae,{buttonSize:"small",variant:"outline",children:"Cancel"})}),Dt(zm,{asChild:!0,children:Dt(Ae,{buttonSize:"small",variant:"primary",onClick:()=>x(P.value),children:"Delete"})})]})]})]})]},P.value))})}),v.length>0&&Eo(Hk,{children:[Dt(Jm,{orientation:"vertical",className:"!courier-h-5"}),Eo(tc,{children:[Dt(rc,{asChild:!0,children:Dt(Ae,{variant:"link",children:"+ Add channel"})}),Dt(ts,{portalProps:{container:o.current},children:v.map(P=>Eo(rs,{onClick:()=>g(P.value),children:[P.icon,P.label]},P.value))})]})]})]}),Eo("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&Dt(bs,{isLoading:!!i,isSaving:!!n,isError:!!s}),!e&&i!==null&&Dt(Ae,{variant:"primary",buttonSize:"small",disabled:c===!0||n===!0||u!==null,onClick:E,children:c?"Publishing...":"Publish changes"})]})]})},"Channels");import{useCallback as ef,useEffect as Fy,useRef as xn,useState as Fk}from"react";function Ds({onSave:e,debounceMs:t=2e3,enabled:r=!0,onError:o,initialContent:n,flushBeforeSave:i}){let[s,l]=Fk(!1),c=xn(!1),u=xn(null),d=xn(),p=xn(0),m=xn();Fy(()=>{n&&(d.current=JSON.stringify(n))},[n]);let f=ef(async()=>{if(c.current)return;if(i)try{i()}catch(b){console.error("[AutoSave] Error flushing updates:",b)}let E=u.current;if(u.current=null,!!E)try{let b=JSON.stringify(E);if(b===d.current)return;c.current=!0,l(!0),d.current=b,p.current=Date.now(),await e(E)}catch(b){console.error("[AutoSave] Save failed:",b),o==null||o(b)}finally{if(c.current=!1,l(!1),u.current){let b=t;m.current=setTimeout(()=>{m.current=void 0,f()},b)}}},[t,o,e,i]),v=xn(r),h=xn(t),y=xn(f);Fy(()=>{v.current=r,h.current=t,y.current=f});let C=ef(async E=>{if(!v.current)return;let b=JSON.stringify(E);if(u.current=E,b===d.current||c.current)return;m.current&&(clearTimeout(m.current),m.current=void 0);let g=h.current;m.current=setTimeout(()=>{m.current=void 0,y.current()},g)},[]),T=ef(async()=>{m.current&&(clearTimeout(m.current),m.current=void 0),await y.current()},[]);return{handleAutoSave:C,flush:T,isSaving:s}}a(Ds,"useAutoSave");import{useAtom as Vs,useAtomValue as Ko,useSetAtom as En}from"jotai";import{memo as c6,useCallback as nf,useEffect as Nt,useRef as fi,useState as u6}from"react";import{useAtom as Ky,useAtomValue as of,useSetAtom as Jy}from"jotai";import{forwardRef as a6,memo as s6,useCallback as Gy,useEffect as va,useRef as Xy}from"react";import{z as lr}from"zod";var Oy=lr.object({headerStyle:lr.enum(["plain","border"]),isUnsubscribe:lr.boolean().optional(),isPreferences:lr.boolean().optional(),link:lr.string().optional(),brandColor:lr.string(),textColor:lr.string(),subtleColor:lr.string(),logo:lr.string().optional(),facebookLink:lr.string().optional(),linkedinLink:lr.string().optional(),instagramLink:lr.string().optional(),mediumLink:lr.string().optional(),xLink:lr.string().optional()}),Kt={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};import{useAtom as qy,useAtomValue as ba,useSetAtom as jy}from"jotai";import{forwardRef as t6,memo as r6,useCallback as uu,useEffect as o6}from"react";import{forwardRef as Ok}from"react";import{jsx as _k}from"react/jsx-runtime";var _y=Ok(({children:e},t)=>_k("div",{ref:t,className:"courier-z-30 courier-flex courier-w-full courier-bg-primary courier-h-12 courier-border-b rounded-b-none rounded-t-sm courier-shadow-none courier-justify-between courier-items-center courier-px-4",children:e}));import{useCallback as Tn,useRef as Wk,useState as zk}from"react";import{jsx as tf,jsxs as $k}from"react/jsx-runtime";var Uk=["image/png","image/jpeg","image/gif","image/webp"],Wy=a(({onFileSelect:e})=>{let[t,r]=zk(!1),o=Wk(null),n=Tn(m=>Uk.includes(m),[]),i=Tn(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=Tn(m=>{m.preventDefault(),m.stopPropagation(),r(!1)},[]),l=Tn(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(h=>n(h.type))&&r(!0)},[n]),c=Tn(async m=>{try{let{dataUrl:f}=await Xs(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=Tn(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=Tn(m=>{var v;let f=(v=m.target.files)==null?void 0:v[0];f&&c(f)},[c]),p=Tn(m=>{var f;m.preventDefault(),m.stopPropagation(),(f=o.current)==null||f.click()},[]);return $k("div",{className:R("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:[tf("span",{className:"courier-text-sm courier-pointer-events-none",children:"Drag and drop logo, or"}),tf("button",{className:"courier-underline courier-font-medium courier-text-sm",onClick:p,type:"button",children:"Browse"}),tf("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:d},"logo-input")]})},"LogoUploader");import{zodResolver as qk}from"@hookform/resolvers/zod";import{useAtom as jk,useAtomValue as Zk,useSetAtom as Kk}from"jotai";import{ArrowUp as Jk}from"lucide-react";import{memo as Gk,useCallback as zy,useEffect as Xk,useRef as Yk}from"react";import{useForm as Qk}from"react-hook-form";import{jsx as ne,jsxs as cr}from"react/jsx-runtime";var Uy=a(({isActive:e,onClick:t,value:r})=>ne("div",{className:R("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:ne("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"&&ne("div",{className:"courier-w-full courier-bg-[#000000] courier-h-1"})})}),"HeaderStyle"),e6=a(()=>{let[e,t]=jk(vo),r=Kk(Zr),o=Zk(yi),n=Yk(null),i=Qk({resolver:qk(Oy),defaultValues:{...Kt,...e},mode:"onChange"});Xk(()=>{e&&i.reset(e)},[e,i]);let s=zy(()=>{t(i.getValues())},[i,t]),l=zy(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(C=>{var T;return C.type==="link"&&((T=C.attrs)==null?void 0:T.href)==="{{urls.preferences}}"}))}))}))||[];o.chain().focus().setContent({type:"doc",content:p}).run()}r(Lc(o.getJSON()))}},[o,r]);return ne(Oe,{...i,children:ne("form",{onChange:()=>s(),children:cr("div",{className:"courier-pb-6",children:[ne("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Header style"}),ne(re,{control:i.control,name:"headerStyle",render:({field:c})=>cr(ee,{className:"courier-mb-4",children:[ne(te,{children:cr("div",{className:"courier-w-full courier-flex courier-flex-row courier-gap-3",children:[ne(Uy,{isActive:c.value==="plain",onClick:()=>{c.onChange("plain"),t({...i.getValues(),headerStyle:"plain"})},value:"plain"}),ne(Uy,{isActive:c.value==="border",onClick:()=>{c.onChange("border"),t({...i.getValues(),headerStyle:"border"})},value:"border"})]})}),ne(oe,{})]})}),ne(pe,{className:"courier-mb-4"}),ne("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Logo"}),cr("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[i.getValues().logo?ne(Ae,{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"}):cr(Ae,{onClick:c=>{c.preventDefault(),n.current&&(n.current.value="",n.current.click())},className:"courier-w-full",variant:"outline",type:"button",children:[ne(Jk,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-mr-2 courier-text-foreground"}),"Upload logo"]}),ne("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 Xs(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="")}})]}),ne(re,{control:i.control,name:"link",render:({field:c})=>cr(ee,{className:"courier-mb-3",children:[ne(te,{children:ne(mn,{as:"Textarea",placeholder:"Link",...c,onChange:u=>{c.onChange(u),s()}})}),ne(oe,{})]})}),ne(pe,{className:"courier-mb-4"}),ne("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Brand color"}),ne(re,{control:i.control,name:"brandColor",render:({field:c})=>cr(ee,{className:"courier-mb-4",children:[ne(te,{children:ne(Et,{...c,defaultValue:c.value,onChange:u=>{c.onChange(u),s()}})}),ne(oe,{})]})}),ne(pe,{className:"courier-mb-4"}),ne("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer links"}),cr("div",{className:"courier-flex courier-flex-col courier-gap-3 courier-mb-3",children:[ne(re,{control:i.control,name:"facebookLink",render:({field:c})=>cr(ee,{children:[ne(te,{children:ne(ge,{startAdornment:ne(Ti,{}),placeholder:"facebook.com/username",...c,autoFocus:!0})}),ne(oe,{})]})}),ne(re,{control:i.control,name:"linkedinLink",render:({field:c})=>cr(ee,{children:[ne(te,{children:ne(ge,{startAdornment:ne(wi,{}),placeholder:"linkedin.com/username",...c})}),ne(oe,{})]})}),ne(re,{control:i.control,name:"instagramLink",render:({field:c})=>cr(ee,{children:[ne(te,{children:ne(ge,{startAdornment:ne(Ei,{}),placeholder:"instagram.com/username",...c})}),ne(oe,{})]})}),ne(re,{control:i.control,name:"mediumLink",render:({field:c})=>cr(ee,{children:[ne(te,{children:ne(ge,{startAdornment:ne(ki,{}),placeholder:"medium.com/username",...c})}),ne(oe,{})]})}),ne(re,{control:i.control,name:"xLink",render:({field:c})=>cr(ee,{children:[ne(te,{children:ne(ge,{startAdornment:ne(Pi,{}),placeholder:"x.com/username",...c})}),ne(oe,{})]})})]}),ne(pe,{className:"courier-mb-4"}),ne("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer actions"}),ne(re,{control:i.control,name:"isPreferences",render:({field:c})=>cr(ee,{className:"courier-flex courier-flex-row courier-items-center courier-gap-2 courier-mb-4",children:[ne(te,{children:ne(Yi,{checked:c.value,onCheckedChange:u=>{i.setValue("isPreferences",u),c.onChange(u),l(u);let d={...i.getValues(),isPreferences:u};t(d)}})}),ne(fo,{className:"!courier-m-0",children:"Manage Preferences"}),ne(oe,{})]})})]})})})},"SideBarComponent"),$y=Gk(e6);import{Fragment as i6,jsx as zt,jsxs as ya}from"react/jsx-runtime";var n6=t6(({hidePublish:e=!1,templateEditor:t,variables:r,variableValidation:o},n)=>{var x,k,P,S,w,M,L,N;let i=jy(Ii),{publishBrand:s}=Pa(),l=jy(xi);o6(()=>{l(o)},[o,l]);let c=ba(bt),u=ba(Jt),d=ba(yt),p=ba(ye),m=ba(se),f=ba(yi),[v,h]=qy(vo),[y,C]=qy(Zr),T=uu(()=>{s()},[s]),E=uu(({editor:I})=>{C(Lc(I.getJSON()))},[C]),b=uu(I=>{h(D=>D?{...D,logo:I}:{...Kt,logo:I})},[h]),g=uu(()=>{i("template")},[i]);return ya(i6,{children:[zt("div",{className:"courier-z-30 courier-w-full courier-h-12",children:ya(_y,{children:[zt("div",{className:"courier-text-sm courier-font-medium",children:"Brand theme"}),ya("div",{className:"courier-flex courier-gap-2 courier-items-center",children:[d!==null&&zt(bs,{isLoading:!!p,isSaving:!!d,isError:!!m}),t&&zt(Ae,{variant:"outline",buttonSize:"small",onClick:g,disabled:u===!0||d===!0,children:"Back"}),!e&&p!==null&&zt(Ae,{variant:"primary",buttonSize:"small",disabled:!((k=(x=c==null?void 0:c.data)==null?void 0:x.tenant)!=null&&k.brand)||u===!0||d!==!1,onClick:T,children:u?"Publishing...":"Publish changes"})]})]})}),ya("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[zt("div",{className:"courier-flex courier-flex-col courier-flex-1",children:ya("div",{className:"courier-editor-container",ref:n,children:[zt("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Header"}),ya("div",{className:R("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"&&zt("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:v.brandColor}}),v!=null&&v.logo?zt("img",{src:v.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"}):zt(Wy,{onFileSelect:b})]}),zt("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Footer"}),zt("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:zt(xs,{value:y!=null?y:(N=(L=(M=(w=(S=(P=c==null?void 0:c.data)==null?void 0:P.tenant)==null?void 0:S.brand)==null?void 0:w.settings)==null?void 0:M.email)==null?void 0:L.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:E})})]})}),zt("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:zt("div",{className:"courier-p-4 courier-h-full",children:f&&zt($y,{})})})]})]})}),Zy=r6(n6);import{jsx as Yy}from"react/jsx-runtime";var l6=a6(({hidePublish:e=!1,autoSaveDebounce:t=500,autoSave:r=!0,theme:o,colorScheme:n,...i},s)=>{let l=of(ye),c=Xy(!0),u=of(At),{getTemplate:d,saveBrand:p}=Pa(),[m,f]=Ky(bt),v=Jy(Zr),h=of(Zr),[y,C]=Ky(vo),T=Xy(!1),E=Jy(se);va(()=>{var k,P;m&&u!==((P=(k=m==null?void 0:m.data)==null?void 0:k.tenant)==null?void 0:P.tenantId)&&(f(null),v(null),c.current=!1)},[m,u,f,v]);let b=Gy(async k=>{await p(k)},[p]),g=Gy(()=>{E(Mo("Error saving theme"))},[E]),{handleAutoSave:x}=Ds({onSave:b,enabled:l!==null&&r&&h!==null,debounceMs:t,onError:g});return va(()=>{!u||l||m&&l===!1||d()},[u,d,l,m]),va(()=>{h&&setTimeout(()=>{T.current=!0},500)},[h]),va(()=>{if(!T.current||!y)return;let k={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}}}}};x(k)},[y,h,x]),va(()=>{l||(c.current=!1)},[l]),va(()=>{var k,P,S,w,M,L,N,I,D,V,W,j,O,$,J,q,F,A,H,_,B,U,Z,K,G,ve,Me,ke,Fe,Ie,Je,Ge,St,Re,it,gt,ut,ue;if(!y){let Y=(S=(P=(k=m==null?void 0:m.data)==null?void 0:k.tenant)==null?void 0:P.brand)==null?void 0:S.settings,Ne=(N=h==null?void 0:h.split(`
243
+ `))!=null?N:(L=(M=(w=Y==null?void 0:Y.email)==null?void 0:w.footer)==null?void 0:M.markdown)==null?void 0:L.split(`
244
+ `),dt=Ne==null?void 0:Ne.find(mt=>mt.includes("{{urls.preferences}}"));C({brandColor:((I=Y==null?void 0:Y.colors)==null?void 0:I.primary)||Kt.brandColor,textColor:((D=Y==null?void 0:Y.colors)==null?void 0:D.secondary)||Kt.textColor,subtleColor:((V=Y==null?void 0:Y.colors)==null?void 0:V.tertiary)||Kt.subtleColor,headerStyle:(j=(W=Y==null?void 0:Y.email)==null?void 0:W.header)!=null&&j.barColor?"border":"plain",logo:((J=($=(O=Y==null?void 0:Y.email)==null?void 0:O.header)==null?void 0:$.logo)==null?void 0:J.image)||Kt.logo,link:((A=(F=(q=Y==null?void 0:Y.email)==null?void 0:q.header)==null?void 0:F.logo)==null?void 0:A.href)||Kt.link,facebookLink:((U=(B=(_=(H=Y==null?void 0:Y.email)==null?void 0:H.footer)==null?void 0:_.social)==null?void 0:B.facebook)==null?void 0:U.url)||Kt.facebookLink,linkedinLink:((ve=(G=(K=(Z=Y==null?void 0:Y.email)==null?void 0:Z.footer)==null?void 0:K.social)==null?void 0:G.linkedin)==null?void 0:ve.url)||Kt.linkedinLink,instagramLink:((Ie=(Fe=(ke=(Me=Y==null?void 0:Y.email)==null?void 0:Me.footer)==null?void 0:ke.social)==null?void 0:Fe.instagram)==null?void 0:Ie.url)||Kt.instagramLink,mediumLink:((Re=(St=(Ge=(Je=Y==null?void 0:Y.email)==null?void 0:Je.footer)==null?void 0:Ge.social)==null?void 0:St.medium)==null?void 0:Re.url)||Kt.mediumLink,xLink:((ue=(ut=(gt=(it=Y==null?void 0:Y.email)==null?void 0:it.footer)==null?void 0:gt.social)==null?void 0:ut.twitter)==null?void 0:ue.url)||Kt.xLink,isPreferences:!!dt})}},[m,C,h,y]),Yy(tr,{theme:o,colorScheme:n,isLoading:!!(l&&c.current),children:Yy(Zy,{ref:s,hidePublish:e,...i})})}),Qy=s6(l6);import{jsx as gi}from"react/jsx-runtime";var e2=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"),d6=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=pu,colorScheme:f,...v})=>{let{store:h}=Ea(),y=En(Os),C=En(xi),T=En(vi),E=En(Ci),b=En(Gt),g=Ko(ye),x=Ko(Jt),k=Ko(se),[P,S]=Vs(bt),w=Ko(Ir),M=Ko(At),[L,N]=Vs(Pn),{getTemplate:I,saveTemplate:D,setTemplateError:V}=Ma(),W=Ko(Ii),j=fi(!1),[O,$]=Vs(le),[J,q]=Vs(It);Nt(()=>{typeof window!="undefined"&&window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.templateEditorContent=O)},[O]);let F=En(Zr),A=En(vo),[H,_]=Vs(oo);Nt(()=>{typeof window!="undefined"&&window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.setTemplateEditorContent=$,window.__COURIER_CREATE_TEST__.getTemplateEditorContent=()=>O,window.__COURIER_CREATE_TEST__.setChannel=_,window.__COURIER_CREATE_TEST__.getChannel=()=>H)},[$,O,_,H]);let B=En(ye),U=e2(m,p),[Z,K]=u6(U),G=fi(JSON.stringify(U)),ve=fi(!1),Me=fi(null);Nt(()=>{let ue=e2(m,p),Y=JSON.stringify(ue);Y!==G.current&&(K(ue),G.current=Y,ue.length&&!ue.includes(H)&&_(ue[0]))},[m,p,H,_]),Nt(()=>{var Y;if(g||!(O!=null&&O.elements))return;let ue=O.elements.filter(Ne=>Ne.type==="channel").map(Ne=>Ne.channel);if(!ue.includes(H)){let Ne=(Y=m==null?void 0:m.channels)==null?void 0:Y.find(dt=>ue.includes(dt));!Ne&&ue.length>0&&(Ne=ue[0]),Ne&&_(Ne)}},[O,H,_,m==null?void 0:m.channels,g]),Nt(()=>{var Y;let ue=(Y=P==null?void 0:P.data)==null?void 0:Y.tenant;w&&ue&&!(ue!=null&&ue.notification)&&g===!1&&(Z!=null&&Z.length)&&_(Z[0])},[w,P,g,Z,_]);let ke=fi(null);Nt(()=>{ke.current&&(ke.current.templateId!==w||ke.current.tenantId!==M)&&w&&M&&(q(!0),j.current=!1,Me.current=null,S(null),$(null),F(null),A(null),N(null),_((Z==null?void 0:Z[0])||"email"),B(null)),w&&M&&(ke.current={templateId:w,tenantId:M})},[w,M,Z,q,S,$,F,A,N,_,B]);let Fe=fi(m);Nt(()=>{Fe.current=m,y(m)},[m,y]),Nt(()=>{C(i)},[i,C]),Nt(()=>{b(o!==void 0)},[o,b]),Nt(()=>{T(o||{})},[o,T]),Nt(()=>{E(n)},[n,E]);let Ie=nf(async ue=>{let Y=ue==null?void 0:ue._capturedTemplateId,Ne=h.get(Ir);if(Y&&Y!==Ne)return;let{_capturedTemplateId:dt,...mt}=ue;await D({routing:Fe.current,content:mt})},[D,h]),Je=nf(()=>{V("Error saving template")},[V]),Ge=Ko(Nn),St=nf(()=>{lf(Ge)},[Ge]),{handleAutoSave:Re}=Ds({onSave:Ie,debounceMs:c,enabled:g===!1&&l,onError:Je,flushBeforeSave:St});Nt(()=>{!w||!M||g||P&&g===!1||k||I({includeBrand:u})},[w,M,u,I,g,P,k]);let it=fi(null);Nt(()=>{if(!t||l&&g!==!1)return;let ue=JSON.stringify(t);if(ue!==it.current&&JSON.stringify(xe(He(O)))!==JSON.stringify(xe(He(t)))){if(ve.current=!0,it.current=ue,$(t),!l)B(!1);else{let Y={...t,_capturedTemplateId:w};Re(Y)}Promise.resolve().then(()=>{ve.current=!1})}},[l,t,O,$,B,Re,w,g]),Nt(()=>{var Ne,dt,mt,Gr,Xr,Yr,Qr;if(g!==!1)return;let ue=(mt=(dt=(Ne=P==null?void 0:P.data)==null?void 0:Ne.tenant)==null?void 0:dt.notification)==null?void 0:mt.notificationId;if(P&&ue&&ue!==w||Me.current===P)return;let Y=t||((Qr=(Yr=(Xr=(Gr=P==null?void 0:P.data)==null?void 0:Gr.tenant)==null?void 0:Xr.notification)==null?void 0:Yr.data)==null?void 0:Qr.content);$(Y),Me.current=P,setTimeout(()=>{q(!1)},100)},[P,$,g,q,w,t]),Nt(()=>{x===!0&&(j.current=!1)},[x]),Nt(()=>{!O||g!==!1||setTimeout(()=>{j.current=!0},1e3)},[O,H,g]),Nt(()=>{j.current=!1},[H]);let gt=Ko(et),ut=Ko(sf);if(Nt(()=>{let ue=!!gt&&g===!1&&!J,Y=j.current&&!!O&&g===!1&&!J;if(!ue&&!Y)return;let Ne=gt||O;if(!Ne||JSON.stringify(Ne)===ut)return;let mt={...Ne,_capturedTemplateId:w};r&&!ve.current&&(j.current=!1,r(O||Ne)),Re(mt)},[O,gt,Re,g,J,w,r,ut]),u&&W==="brand")return gi(Qy,{hidePublish:s,autoSave:l,templateEditor:!0,variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:f,...d});if(W==="template"&&H==="email")return gi(U5,{variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:f,isLoading:!!g,hidePublish:s,channels:Z,brandEditor:u,routing:m,...v});if(W==="template"&&H==="sms")return gi(Ey,{colorScheme:f,variables:o,disableVariablesAutocomplete:n,theme:e,hidePublish:s,channels:Z,routing:m,...v});if(W==="template"&&H==="push")return gi(ry,{variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:f,hidePublish:s,channels:Z,routing:m,...v});if(W==="template"&&H==="inbox")return gi(G5,{variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:f,hidePublish:s,channels:Z,routing:m,...v});if(W==="template"&&H==="slack")return gi(yy,{theme:e,colorScheme:f,hidePublish:s,channels:Z,routing:m,variables:o,disableVariablesAutocomplete:n,...v});if(W==="template"&&H==="msteams")return gi(By,{theme:e,colorScheme:f,hidePublish:s,channels:Z,routing:m,variables:o,disableVariablesAutocomplete:n,...v})},"TemplateEditorComponent"),rue=c6(d6);var sue=_c,lue=iu,cue=Yc,uue=Jc,due=su,mue=ou;var m6=new Set(["dragstart","drag","dragend","dragenter","dragleave","dragover","drop","mousedown","mouseup","mousemove","click","pointerdown","pointerup","pointermove","pointercancel"]);function p6(e){let t=Object.getOwnPropertyDescriptor(Event.prototype,"target");if(!t)return console.warn("[ShadowDomDndFix] Could not get Event.prototype.target descriptor"),()=>{};let r={...t,get:function(){var s,l;if(!m6.has(this.type))return(s=t.get)==null?void 0:s.call(this);let o=(l=t.get)==null?void 0:l.call(this),i=this.composedPath()[0];return i&&i!==o&&e.contains(i)?i:o}};return Object.defineProperty(Event.prototype,"target",r),()=>{t&&Object.defineProperty(Event.prototype,"target",t)}}a(p6,"applyShadowDomDndFix");export{Qy as BrandEditor,xs as BrandFooter,g2 as BrandProvider,Vn as CHANNELS,ci as ChannelRootContainer,pu as DEFAULT_ROUTING,pe as Divider,jg as EMAIL_EDITOR_FONT_FAMILY,Vt as EMAIL_EDITOR_TEXT_STYLES,ui as EditorSidebar,sue as EmailChannel,pp as EmailEditor,W5 as EmailEditorContainer,z5 as EmailEditorMain,gp as EmailSideBar,hp as EmailSideBarItemDetails,Bm as ErrorBoundary,Ti as FacebookIcon,uue as InboxChannel,vp as InboxEditor,wp as InboxSideBar,ge as Input,Et as InputColor,Ei as InstagramIcon,wi as LinkedinIcon,due as MSTeamsChannel,jp as MSTeamsEditor,Kp as MSTeamsSideBar,Jp as MSTeamsSideBarItemDetails,ki as MediumIcon,um as MonacoCodeEditor,dp as PreviewPanel,cue as PushChannel,Mp as PushEditor,lue as SMSChannel,Wp as SMSEditor,mue as SlackChannel,Lp as SlackEditor,Bp as SlackSideBar,Vp as SlackSideBarItemDetails,rue as TemplateEditor,M2 as TemplateProvider,bs as TemplateStatus,os as TextMenu,T5 as Toggle,Wr as ToggleGroup,Ft as ToggleGroupItem,is as VariableInput,uo as VariableTextarea,Pi as XIcon,Ut as apiUrlAtom,p6 as applyShadowDomDndFix,Z4 as blockDefaults,af as brandApplyAtom,R as cn,He as convertElementalToTiptap,$s as convertLegacyError,xe as convertTiptapToElemental,Mo as createCustomError,D6 as extractErrorMessage,Yp as getChannelDefaults,Qo as getFlattenedVariables,B6 as isRetryableError,ur as isSidebarExpandedAtom,ye as isTemplateLoadingAtom,Jt as isTemplatePublishingAtom,yt as isTemplateSavingAtom,Os as routingAtom,bt as templateDataAtom,se as templateErrorAtom,Ir as templateIdAtom,At as tenantIdAtom,$t as tokenAtom,Ds as useAutoSave,DD as useBlockConfig,Pa as useBrandActions,Qp as useChannels,xp as useDebouncedFlush,Na as useImageUpload,xt as useNodeAttributes,Ma as useTemplateActions,Ea as useTemplateStore,wL as useVariables};
244
245
  //# sourceMappingURL=index.js.map