1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[28935],{9521:(e,t,a)=>{function n(e){return"string"==typeof e&&e.trim().toLowerCase().endsWith("@inbox.upgraded")}a.d(t,{G_:()=>n,Jd:()=>l});let l=[{value:"email",label:"Email",hint:"Real sendable addresses (not @inbox.upgraded)"},{value:"linkedin",label:"LinkedIn",hint:"Has a LinkedIn profile URL"}]},19768:(e,t,a)=>{a.d(t,{C_:()=>x,DC:()=>y,EU:()=>b,X4:()=>v,fB:()=>d,qh:()=>f,ud:()=>c,vz:()=>p,yv:()=>u,zG:()=>w});let n={announcement:"Announcement",education:"Educational",roundup:"Roundup",promotion:"Promotion",story:"Story"};function l(e){var t,a;return null!=(a=null==(t=e.trim().split("\n").find(e=>e.trim()))?void 0:t.trim())?a:""}function r(e,t){return e.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\*\*|__|\*|_/g,"").replace(/\s+/g," ").trim().slice(0,t)}function o(e){var t,a;for(let n of null!=(t=e.sections)?t:[])if("hero"===n.type&&(null==(a=n.headline)?void 0:a.trim()))return n.headline.trim();return null}function i(e){var t,a,i,s,c,d,u,p,m;let h=o(e.data),g=l(e.brief),f=n[e.goal],b=function(e){var t,a,n,l;for(let o of null!=(t=e.sections)?t:[]){if("hero"===o.type&&(null==(a=o.subtext)?void 0:a.trim()))return o.subtext.trim().slice(0,140);if("text"===o.type&&(null==(n=o.markdown)?void 0:n.trim()))return r(o.markdown,140);if("feature"===o.type&&(null==(l=o.body)?void 0:l.trim()))return r(o.body,140)}return""}(e.data),x=(null==(t=e.data.subject)?void 0:t.trim())||h||(g?g.slice(0,120):"")||"".concat(f," update"),y=(null==(a=e.data.subject)?void 0:a.trim())||h||"",v=(null==(i=e.data.preheader)?void 0:i.trim())||b||(g?g.slice(0,140):"");return!v&&g&&y&&!g.startsWith(y.slice(0,24))&&(v=g.slice(0,140)),{subject:x,preheader:v,senderName:(null==(c=e.data.footer)||null==(s=c.senderName)?void 0:s.trim())||(null==(d=e.defaultSenderName)?void 0:d.trim())||"",mailingAddress:(null==(p=e.data.footer)||null==(u=p.mailingAddress)?void 0:u.trim())||(null==(m=e.defaultMailingAddress)?void 0:m.trim())||""}}function s(e,t){return"string"==typeof e&&e.length>0?e:t}function c(e,t){var a;let n=i({data:e,...t}),l=null!=(a=e.footer)?a:{senderName:"",mailingAddress:""};return{...e,preheader:s(e.preheader,n.preheader),footer:{...l,senderName:s(l.senderName,n.senderName),mailingAddress:s(l.mailingAddress,n.mailingAddress)}}}function d(e,t){let a=i({data:e,...t});return{...c(e,t),subject:s(e.subject,a.subject)}}function u(e){var t,a,n,l;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return!!((null==(t=e.subject)?void 0:t.trim())||(null==(a=e.customHtml)?void 0:a.trim())||(null!=(l=null==(n=e.sections)?void 0:n.length)?l:0)>0||r.trim())}function p(e){var t,a;let r=null==(t=e.data.subject)?void 0:t.trim(),i=null==(a=e.data.preheader)?void 0:a.trim(),s=o(e.data),c=l(e.brief),d=n[e.goal],u=r||s||(c?c.slice(0,72):"")||"".concat(d," newsletter"),p=i||(c?c.slice(0,140):"")||"A ".concat(d.toLowerCase()," starting point."),m=y(r||s||c||"".concat(d,"-newsletter"));return m||(m=y("".concat(d,"-template"))),m||(m="template-".concat(Date.now())),{id:m,name:u,blurb:p}}let m="upgraded.newsletter.adminTemplates";function h(){try{let e=localStorage.getItem(m);if(!e)return[];let t=JSON.parse(e);if(!Array.isArray(t))return[];return t.filter(g)}catch(e){return[]}}function g(e){return!!e&&"object"==typeof e&&"string"==typeof e.id&&"string"==typeof e.name&&"string"==typeof e.blurb&&"string"==typeof e.brief&&"string"==typeof e.goal&&null!=e.data&&"object"==typeof e.data}function f(){return h()}function b(e,t){let a=y(e.id)||"template-".concat(Date.now()),n=h();!(null==t?void 0:t.replaceId)&&n.some(e=>e.id===a)&&(a="".concat(a,"-").concat(Date.now().toString(36)));let l={...e,id:a},r=n.filter(e=>e.id!==a&&e.id!==(null==t?void 0:t.replaceId));try{localStorage.setItem(m,JSON.stringify([...r,l]))}catch(e){throw Error("Could not save the template in this browser (storage full or blocked).")}return l}function x(e){let t=y(e);localStorage.setItem(m,JSON.stringify(h().filter(e=>e.id!==t)))}function y(e){return e.trim().toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"")}function v(e){var t;return{id:y(e.id),name:e.name.trim(),blurb:e.blurb.trim(),brief:e.brief.trim(),goal:e.goal,data:{...t=structuredClone(e.data),footer:{...t.footer,senderName:"",mailingAddress:""}}}}async function w(e){try{return await navigator.clipboard.writeText(JSON.stringify(e,null,2)),!0}catch(e){return!1}}},28935:(e,t,a)=>{a.r(t),a.d(t,{NewsletterTile:()=>b,NewslettersTab:()=>x});var n=a(95155),l=a(12115),r=a(57218),o=a(9554),i=a(18720),s=a(38521),c=a(19768),d=a(42991),u=a(99259),p=a(92959),m=a(67816);function h(e){let{data:t,height:a=176,className:r=""}=e,o=(0,l.useRef)(null),[i,s]=(0,l.useState)(0),[c,d]=(0,l.useState)(!1),u=(0,l.useMemo)(()=>{try{return(0,m.fK)(t,{unsubscribeUrl:m.xc,preview:!0}).html}catch(e){return""}},[t]);return(0,l.useEffect)(()=>{let e=o.current;if(!e)return;let t=new ResizeObserver(e=>{let[t]=e,a=t.contentRect.width;a>0&&s(a/624)});t.observe(e);let a=new IntersectionObserver(e=>e.some(e=>e.isIntersecting)&&d(!0),{rootMargin:"600px"});return a.observe(e),()=>{t.disconnect(),a.disconnect()}},[]),(0,n.jsxs)("div",{ref:o,className:"relative overflow-hidden bg-white ".concat(r),style:{height:a},"aria-hidden":"true",children:[c&&i>0&&u&&(0,n.jsx)("iframe",{title:"",tabIndex:-1,srcDoc:u,sandbox:"",scrolling:"no",className:"pointer-events-none absolute left-0 top-0 border-0",style:{width:624,height:Math.ceil(a/i)+40,transform:"scale(".concat(i,")"),transformOrigin:"top left"}}),(0,n.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-b from-transparent to-white"})]})}var g=a(87754);let f=[{id:"all",label:"All"},{id:"draft",label:"Drafts"},{id:"scheduled",label:"Scheduled"},{id:"published",label:"Sent"}];function b(e){var t;let{row:a,isDark:l,onOpen:r,templateBlurb:o}=e,i=null==(t=a.platform_specific_content)?void 0:t.newsletter,s=function(e,t){var a;let n={draft:t?"bg-white/10 text-gray-300":"bg-gray-900/[0.06] text-gray-600",scheduled:t?"bg-blue-500/15 text-blue-300":"bg-blue-50 text-blue-700",publishing:t?"bg-amber-500/15 text-amber-300":"bg-amber-50 text-amber-700",published:t?"bg-emerald-500/15 text-emerald-300":"bg-emerald-50 text-emerald-700",failed:t?"bg-red-500/15 text-red-300":"bg-red-50 text-red-700"};return{cls:null!=(a=n[e])?a:n.draft,label:"published"===e?"Sent":e}}(a.status,l);return(0,n.jsxs)("button",{type:"button",onClick:r,className:"group flex h-full w-full min-w-0 cursor-pointer flex-col overflow-hidden rounded-xl border text-left transition-all hover:-translate-y-0.5 hover:shadow-lg ".concat(l?"border-white/10 bg-white/[0.02]":"border-gray-200 bg-white"),children:[i?(0,n.jsx)(h,{data:i,height:176}):(0,n.jsx)("div",{className:"h-44 ".concat(l?"bg-white/5":"bg-gray-100")}),(0,n.jsxs)("div",{className:"border-t px-3 py-2.5 ".concat(l?"border-white/10":"border-gray-100"),children:[(0,n.jsx)("div",{className:"truncate text-sm font-medium ".concat(l?"text-gray-100":"text-gray-900"),children:(null==i?void 0:i.subject)||a.title}),o?(0,n.jsx)("div",{className:"mt-1 line-clamp-2 text-[11px] ".concat("text-gray-500"),children:o}):(0,n.jsxs)("div",{className:"mt-1.5 flex items-center gap-2",children:[(0,n.jsx)("span",{className:"rounded-full px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide ".concat(s.cls),children:s.label}),(0,n.jsx)("span",{className:"text-[11px] ".concat(l?"text-gray-500":"text-gray-400"),children:new Date(a.updated_at).toLocaleDateString()})]})]})]})}function x(e){var t;let{isDark:a,defaultSenderName:m="",defaultMailingAddress:h="",userEmail:x=null,userName:y=null,openNewsletterId:v=null,onNewsletterOpened:w}=e,k=function(){let[e,t]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{t("dark"===localStorage.getItem("app-theme")||document.documentElement.classList.contains("dark"));let e=e=>{let a=e.detail;t((null==a?void 0:a.theme)==="dark")};return window.addEventListener("themeChanged",e),()=>window.removeEventListener("themeChanged",e)},[]),e}(),j=null!=a?a:k,N=(0,p.Z)(x),[S,C]=(0,l.useState)("all"),[D,A]=(0,l.useState)(!1),[F,T]=(0,l.useState)(null),[U,Z]=(0,l.useState)(null),[E,L]=(0,l.useState)(!1),[R,B]=(0,l.useState)({id:"",name:"",blurb:""}),[z,H]=(0,l.useState)([]),[I,_]=(0,l.useState)(()=>(0,u.H)({senderName:m,mailingAddress:h}));(0,l.useEffect)(()=>{let e=!1;return fetch("/api/newsletter-drafts/footer-defaults",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&_(e=>{var a,n;return(0,u.H)({senderName:(null==(a=t.senderName)?void 0:a.trim())||m,mailingAddress:(null==(n=t.mailingAddress)?void 0:n.trim())||h},e)})}).catch(()=>{}),()=>{e=!0}},[m,h]);let M=(0,l.useCallback)(()=>{H((0,c.qh)())},[]);(0,l.useEffect)(()=>{M()},[M]);let{items:O,loading:q,error:P,create:V,update:W,remove:$}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"all",[t,a]=(0,l.useState)([]),[n,r]=(0,l.useState)(!0),[o,i]=(0,l.useState)(null),s=(0,l.useCallback)(async()=>{i(null);try{let t="all"===e?"":"?status=".concat(e),n=await fetch("/api/newsletter-drafts".concat(t),{cache:"no-store"});if(!n.ok)throw Error((await n.json().catch(()=>({}))).error||"Failed to load");let l=await n.json();a(Array.isArray(l.newsletters)?l.newsletters:[])}catch(e){i(e instanceof Error?e.message:"Failed to load newsletters")}finally{r(!1)}},[e]);(0,l.useEffect)(()=>{r(!0),s()},[s]);let c=(0,l.useCallback)(async e=>{var t;let a=await fetch("/api/newsletter-drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await a.json().catch(()=>({}));if(!a.ok)throw Error(n.error||"Failed to save newsletter");return await s(),null!=(t=n.newsletter)?t:null},[s]),d=(0,l.useCallback)(async(e,t)=>{var a;let n=await fetch("/api/newsletter-drafts/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await n.json().catch(()=>({}));if(!n.ok)throw Error(l.error||"Failed to update newsletter");return await s(),null!=(a=l.newsletter)?a:null},[s]),u=(0,l.useCallback)(async e=>{a(t=>t.filter(t=>t.id!==e));let t=await fetch("/api/newsletter-drafts/".concat(e),{method:"DELETE"});if(!t.ok)throw await s(),Error((await t.json().catch(()=>({}))).error||"Failed to delete newsletter")},[s]);return{items:t,loading:n,error:o,refresh:s,create:c,update:d,remove:u}}
1(S),Y=(0,l.useRef)(w);Y.current=w,(0,l.useEffect)(()=>{if(!v)return;let e=!1,t=t=>{var a;e||(t&&(T(t),Z(null),L(!1),A(!0)),null==(a=Y.current)||a.call(Y))},a=O.find(e=>e.id===v);return a?(t(a),()=>{e=!0}):(fetch("/api/newsletter-drafts/".concat(v),{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>{var a;return t(null!=(a=null==e?void 0:e.newsletter)?a:null)}).catch(()=>t(null)),()=>{e=!0})},[v,O]);let G=j?"text-gray-400":"text-gray-500",J=(0,l.useMemo)(()=>{let e=new Set(z.map(e=>e.id));return[...s.u.filter(t=>!e.has(t.id)),...z]},[z]),K=(0,l.useMemo)(()=>new Set(z.map(e=>e.id)),[z]),X=(0,l.useMemo)(()=>J.map(e=>({template:e,row:{id:"template:".concat(e.id),title:e.data.subject||e.name,content:null,status:"draft",scheduled_at:"",published_at:null,created_at:"",updated_at:"",platform_specific_content:{kind:"newsletter",newsletter:e.data}}})),[J]),Q=(0,l.useMemo)(()=>async(e,t)=>t?W(t,e):V(e),[V,W]);return(0,n.jsxs)("div",{className:"px-4 py-4 md:px-6",children:[(0,n.jsxs)("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[f.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>C(e.id),className:"cursor-pointer rounded-full border px-3 py-1.5 text-sm transition-colors ".concat(S===e.id?j?"border-white/25 bg-white/10 text-white":"border-gray-300 bg-gray-900/[0.06] text-gray-900":j?"border-white/10 text-gray-400 hover:bg-white/5":"border-gray-200 text-gray-600 hover:bg-gray-50"),children:e.label},e.id)),(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsxs)("button",{type:"button",onClick:()=>{T(null),Z(null),L(!1),A(!0)},className:"flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium transition-colors ".concat(j?"bg-white text-gray-900 hover:bg-gray-200":"bg-gray-900 text-white hover:bg-gray-700"),children:[(0,n.jsx)(r.A,{className:"h-4 w-4"}),"New newsletter"]})]}),P&&(0,n.jsx)("div",{className:"mb-4 rounded-lg px-3 py-2 text-sm ".concat(j?"bg-red-500/10 text-red-300":"bg-red-50 text-red-600"),children:P}),q?(0,n.jsx)("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-4",children:Array.from({length:8}).map((e,t)=>(0,n.jsx)("div",{className:"h-64 animate-pulse rounded-xl ".concat(j?"bg-white/5":"bg-gray-100")},t))}):0===O.length?"all"===S?null:(0,n.jsxs)("p",{className:"px-1 py-2 text-sm ".concat(G),children:["No ",null==(t=f.find(e=>e.id===S))?void 0:t.label.toLowerCase()," newsletters."]}):(0,n.jsx)("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-4",children:O.map(e=>(0,n.jsx)(b,{row:e,isDark:j,onOpen:()=>{T(e),Z(null),L(!1),A(!0)}},e.id))}),(0,n.jsxs)("div",{className:"mt-10",children:[(0,n.jsx)("h3",{className:"text-sm font-semibold ".concat(j?"text-gray-200":"text-gray-900"),children:"Start from a template"}),(0,n.jsxs)("p",{className:"mt-0.5 text-xs ".concat(G),children:["Fully written and styled. Pick one, then rewrite it with your own brief.",N&&(0,n.jsxs)("span",{className:"block mt-1",children:["Admins can add templates to this gallery or copy JSON for"," ",(0,n.jsx)("code",{className:"text-[10px]",children:"templates.ts"}),"."]})]}),(0,n.jsxs)("div",{className:"mt-4 grid grid-cols-2 items-stretch gap-4 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6",children:[N&&(0,n.jsxs)("button",{type:"button",onClick:()=>{T(null),L(!0),B({id:"",name:"",blurb:""}),Z({data:(0,d.E)({footer:{senderName:m,mailingAddress:h}}),brief:"",goal:"education"}),A(!0)},className:"flex h-full min-h-[252px] w-full min-w-0 cursor-pointer flex-col items-center justify-center gap-2 rounded-xl border border-dashed px-3 py-6 text-center transition-colors hover:-translate-y-0.5 hover:shadow-md ".concat(j?"border-white/20 bg-white/[0.02] text-gray-300 hover:border-white/35 hover:bg-white/[0.04]":"border-gray-300 bg-gray-50/80 text-gray-600 hover:border-gray-400 hover:bg-white"),children:[(0,n.jsx)(r.A,{className:"h-8 w-8 shrink-0 opacity-70"}),(0,n.jsx)("span",{className:"text-sm font-semibold",children:"New template"}),(0,n.jsx)("span",{className:"max-w-[12rem] text-[11px] leading-snug ".concat(G),children:"Design in the composer, save to gallery"})]}),X.map(e=>{let{template:t,row:a}=e,l=K.has(t.id);return(0,n.jsxs)("div",{className:"group/tile relative flex min-w-0",children:[(0,n.jsx)(b,{row:a,isDark:j,templateBlurb:l?"".concat(t.blurb," \xb7 Team template"):t.blurb,onOpen:()=>
1N&&l?void(T(null),L(!0),B({id:t.id,name:t.name,blurb:t.blurb}),Z({data:structuredClone(t.data),brief:t.brief,goal:t.goal}),A(!0)):void(T(null),L(!1),Z({data:structuredClone(t.data),brief:t.brief,goal:t.goal}),A(!0))}),N&&l&&(0,n.jsx)("button",{type:"button",title:"Remove template",onClick:e=>{var a;e.stopPropagation(),a=t.id,window.confirm("Remove this template from your gallery?")&&((0,c.C_)(a),M(),i.o.success("Template removed"))},className:"absolute right-2 top-2 z-10 cursor-pointer rounded-md p-1.5 opacity-0 shadow-sm transition-opacity group-hover/tile:opacity-100 ".concat(j?"bg-[#15161a] text-red-300 hover:bg-red-500/20":"bg-white text-red-600 hover:bg-red-50"),children:(0,n.jsx)(o.A,{className:"h-4 w-4"})})]},t.id)})]})]}),(0,n.jsx)(g.t,{open:D,onClose:()=>{A(!1),L(!1)},existing:F,seed:U,isDark:j,onSave:Q,onDelete:$,defaultSenderName:I.senderName,defaultMailingAddress:I.mailingAddress,userEmail:x,userName:y,templateAuthoring:E&&N,initialTemplateMeta:R,onSaveAdminTemplate:N?(e,t)=>{(0,c.EU)(e,{replaceId:t}),M()}:void 0})]})}},38521:(e,t,a)=>{a.d(t,{u:()=>i});let n={logoUrl:"https://www.getupgraded.ai/Upgraded-Logo-Light.png",logoAlt:"Upgraded",logoWidth:132,linkUrl:"https://www.getupgraded.ai"},l="-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif",r="Georgia, 'Times New Roman', serif";function o(e,t,a,r,o){var i,s;return{subject:r,preheader:o,palette:e,typography:{headlineFont:null!=(i=t.headlineFont)?i:l,bodyFont:null!=(s=t.bodyFont)?s:l,headlineSize:"32px",bodySize:"16px"},sections:a,brand:n,footer:{senderName:"",mailingAddress:"",social:[{label:"LinkedIn",url:"https://www.linkedin.com/company/getupgraded"},{label:"Website",url:"https://www.getupgraded.ai"}]}}}let i=[{id:"editorial-deadline",name:"Deadline roundup",blurb:"Time-sensitive list with one clear action. Editorial serif.",goal:"roundup",brief:"Round up the grant and tax-credit programs closing in the next 30 days, with amounts and who qualifies.",data:o({primary:"#16181d",secondary:"#f6f4f0",accent:"#b3261e",textLight:"#ffffff",textDark:"#16181d",background:"#fbfaf8",primaryText:"#16181d"},{headlineFont:r},[{type:"hero",headline:"Four programs close this month",subtext:"Two of them you can still start today. One takes 20 minutes."},{type:"text",markdown:"Deadlines move quietly. Here's what's actually closing before the end of the month, and what each is worth."},{type:"text",markdown:"- **SR&ED** â filed with your T2, worth 35% of eligible R&D spend\n- **IRAP advisory** â up to $50,000, reopened this quarter\n- **BC Launch Online** â cap raised to $7,500\n- **CDAP** â 0% financing up to $100,000"},{type:"divider"},{type:"text",markdown:"Most teams assume they don't qualify, then find out the work they already did counts. It takes a few minutes to check."},{type:"cta",label:"Check what you qualify for",url:"https://www.getupgraded.ai/grants-finder"}],"Four programs close this month","Two you can still start today â one takes 20 minutes")},{id:"product-launch",name:"Product announcement",blurb:"Single idea, big statement, one button. Deep navy.",goal:"announcement",brief:"Announce a new product or major feature, what it replaces, and how to start using it.",data:o({primary:"#062841",secondary:"#eef2f6",accent:"#062841",textLight:"#ffffff",textDark:"#101418",background:"#ffffff",primaryText:"#101418"},{},[{type:"hero",headline:"Your inbox now writes back",subtext:"AI drafts every reply in your voice. You approve or edit. Nothing sends itself."},{type:"text",markdown:"We built this because the slowest part of sales isn't finding people â it's the forty minutes a day spent writing near-identical replies."},{type:"stat",value:"38 min",label:"saved per day, median"},{type:"text",markdown:"It reads the thread, your past replies and the deal context, then drafts. Every draft waits for you."},{type:"cta",label:"Try it on your inbox",url:"https://www.getupgraded.ai/ai-inbox"}],"Your inbox now writes back","AI drafts every reply in your voice â you stay in control")},{id:"monthly-recap",name:"Monthly recap",blurb:"What shipped, what changed. Warm sand, quiet and scannable.",goal:"education",brief:"Recap what we shipped this month and what it means for customers.",data:o({primary:"#2b2a26",secondary:"#efe9de",accent:"#8a5a2b",textLight:"#ffffff",textDark:"#2b2a26",background:"#f8f5ef",primaryText:"#2b2a26"},{headlineFont:r},[{type:"hero",headline:"What we shipped in September"},{type:"text",markdown:"A quieter month than usual, mostly spent on things you asked for twice."},{type:"text",markdown:"**Newsletters.** Write, preview and send from the same calendar as your social posts.\n\n**Faster scorecard sync.** Pipeline refreshes in seconds
1instead of minutes.\n\n**Connection health.** Broken integrations now tell you before a workflow fails."},{type:"divider"},{type:"text",markdown:"Next month we're on attribution â which campaign actually produced the meeting. Reply if you want to test it early."}],"What we shipped in September","Newsletters, faster sync, and connections that warn you first")},{id:"customer-story",name:"Customer story",blurb:"One result, told plainly, with the number up front. Forest green.",goal:"story",brief:"Tell one customer story: their problem, what changed, and the measurable outcome.",data:o({primary:"#14352a",secondary:"#e8efe9",accent:"#14352a",textLight:"#ffffff",textDark:"#13201a",background:"#ffffff",primaryText:"#13201a"},{},[{type:"hero",headline:"How a five-person team booked 31 meetings in six weeks"},{type:"stat",value:"31",label:"meetings booked in six weeks"},{type:"text",markdown:"They weren't short on leads. They were short on follow-up â 400 conversations sitting in an inbox nobody had time to reopen."},{type:"text",markdown:"We turned the backlog into a sequence, let AI draft the first touch, and put every draft in front of a human before it went out."},{type:"divider"},{type:"text",markdown:'*"It found deals we had already given up on."* â Head of Growth'},{type:"cta",label:"Read the full story",url:"https://www.getupgraded.ai/case-studies"}],"How a five-person team booked 31 meetings in six weeks","They were not short on leads â they were short on follow-up")},{id:"event-invite",name:"Event invite",blurb:"Date, what you get, one button. High-contrast blue.",goal:"announcement",brief:"Invite people to a live session: the date, who it is for, and what they will leave with.",data:o({primary:"#101418",secondary:"#eaf0fb",accent:"#12459e",textLight:"#ffffff",textDark:"#101418",background:"#ffffff",primaryText:"#101418"},{},[{type:"hero",headline:"Earnings Strategy Session",subtext:"Forty-five minutes on what your company can actually claim this year."},{type:"text",markdown:"It's not a demo. We look at your numbers, map the programs you qualify for, and tell you what the realistic total is."},{type:"text",markdown:"**Who it's for:** Canadian companies with at least one technical employee and some R&D spend.\n\n**What you leave with:** a written list of programs, amounts and deadlines."},{type:"cta",label:"Book a session",url:"https://www.getupgraded.ai/earnings-strategy-estimate"},{type:"text",markdown:"Can't make it? Reply and we'll send the written version instead."}],"Forty-five minutes on what you can actually claim","Not a demo â a written list of programs, amounts and deadlines")},{id:"offer",name:"Offer",blurb:"One offer, the terms, the deadline. Monochrome with a single accent.",goal:"promotion",brief:"Present one offer clearly: what it is, what it costs, what the catch is, when it ends.",data:o({primary:"#0a0a0a",secondary:"#f2f2f2",accent:"#c2410c",textLight:"#ffffff",textDark:"#0a0a0a",background:"#ffffff",primaryText:"#0a0a0a"},{},[{type:"hero",headline:"$0 down, 0% for twelve months",subtext:"Fund your subscription out of grants instead of cash flow."},{type:"stat",value:"0%",label:"for the first twelve months"},{type:"text",markdown:"Our financing partners cover the year up front. You pay it back as the grant money lands â which, for most teams, is before the first payment is due."},{type:"text",markdown:"**The catch, honestly:** you need to be a Canadian company and pass a standard credit check. That is it."},{type:"cta",label:"See if you qualify",url:"https://www.getupgraded.ai/financing-partners"}],"$0 down, 0% for twelve months","Fund your subscription out of grants instead of cash flow")}];i.push({id:"catalog-editorial",name:"Catalog editorial",blurb:"Category nav, a point of view, then product. Warm retail grey.",goal:"education",brief:"Write an editorial-led retail email: a design idea worth reading, with category navigation above it and products below.",data:o({primary:"#2d2d2d",secondary:"#e9e6e2",accent:"#8a4b2a",textLight:"#ffffff",textDark:"#2d2d2d",background:"#f4f2ef",primaryText:"#2d2d2d",cardBackgroun
1d:"#e9e6e2"},{headlineFont:r},[{type:"columns",variant:"plain",cells:[{heading:"New"},{heading:"Lighting"},{heading:"Bedding"},{heading:"Decor"}]},{type:"divider"},{type:"hero",headline:"The art of intentional layering",subtext:"Three principles for a bedroom that feels collected, comfortable and distinctly yours."},{type:"feature",heading:"Start with the foundation",body:"Everything else is a response to what the bed is made of. Choose the quilt first and let the rest answer to it â colour, weight, how it wrinkles."},{type:"feature",heading:"Layer for depth, not volume",body:"Three textures beat six patterns. A linen sheet, a channeled cotton quilt and one wool throw will read richer than a pile of cushions ever does."},{type:"feature",heading:"Objects with purpose",body:"A lamp you actually read by. A tray that catches what your pockets hold. Rooms feel collected when the objects in them are used."},{type:"divider"},{type:"columns",cells:[{heading:"Channeled Cotton Quilt",body:"From $148"},{heading:"Linnea Rug",body:"From $395"},{heading:"Grid Stitch Pillow",body:"From $68"}]},{type:"cta",label:"Shop bedding",url:"https://www.getupgraded.ai"}],"The art of intentional layering","Three principles for a bedroom that feels collected and distinctly yours")},{id:"event-recap",name:"Event recap",blurb:"Big serif statement, benefit tiles, a founder quote. Dusk gradient.",goal:"announcement",brief:"Recap a live event: the headline claim, the four things we announced, and a quote from the founder.",data:o({primary:"#32302f",secondary:"#eeece7",accent:"#7d5a86",textLight:"#ffffff",textDark:"#32302f",background:"#fcfcfc",primaryText:"#32302f",cardBackground:"#eeece7"},{headlineFont:r},[{type:"hero",headline:"Old-school banking is over",subtext:"A recap of our live event, and everything we announced on the day."},{type:"text",markdown:"We're building a better alternative to your bank. Here's what landed, and what it means if you're still paying for the privilege of holding your own money."},{type:"columns",cells:[{heading:"Pay $0 everyday fees",body:"No FX, ATM or transfer fees. No monthly fee either."},{heading:"Up to 2.75% interest",body:"The highest chequing rate in the country."}]},{type:"columns",cells:[{heading:"Auto-invest your pay",body:"Route part of every deposit into any account, on your schedule."},{heading:"Better protection",body:"Up to $1 million of eligible funds covered."}]},{type:"quote",text:"Our goal isn't to build a new bank. The country doesn't need another bank. It's to change how banking is done.",attribution:"Co-founder & Chief Executive Officer"},{type:"cta",label:"Watch the full session",url:"https://www.getupgraded.ai"}],"Old-school banking is over","A recap of the live event â and everything we announced")},{id:"promo-code",name:"Promo code",blurb:"Date, code, terms. Nothing else. High-contrast product launch.",goal:"promotion",brief:"Announce a pre-order date and give the reader an exclusive discount code with the terms stated plainly.",data:o({primary:"#101010",secondary:"#f1efef",accent:"#1a5fd0",textLight:"#ffffff",textDark:"#101010",background:"#ffffff",primaryText:"#101010",cardBackground:"#f4f3f6"},{},[{type:"hero",headline:"Pre-order opens August 12",subtext:"Your exclusive offer code is below. It is good for two weeks."},{type:"code",label:"Save this code",value:"UPGRADED-250-AUG",caption:"Valid 12â27 August. One use per customer. Terms apply."},{type:"text",markdown:"Add any eligible device to your cart and enter the code at checkout for **$250 off**. It stacks with trade-in credit, and it does not expire quietly â we will remind you once."},{type:"divider"},{type:"columns",cells:[{heading:"Warranty included",body:"Eligible repairs, replacements and refunds covered."},{heading:"Free shipping",body:"On every order, no minimum."}]},{type:"cta",label:"Mark your calendar",url:"https://www.getupgraded.ai"}],"Pre-order opens August 12","Your exclusive $250 code is inside â good for two weeks")},{id:"product-changelog",name:"Product changelog",blurb:"Feature blocks, a more-updates list, one CTA. Clean SaaS blue.",goal:"education",brief:"Write a monthly product update: the two or three features worth a paragraph, then a short list of everything else.",data:o({primary:"#111822",secondary:"#eef1f7",accent:"#2f5bd7",textLight:"#ffffff",textDark:"#111822",background:"#ffffff",primaryText:"#111822",cardBackgroun
1d:"#eef1f7"},{headlineFont:"'Helvetica Neue', Helvetica, Arial, sans-serif"},[{type:"hero",headline:"What's new this month",subtext:"Item-level sharing, a new data source, and three workflow integrations."},{type:"text",markdown:"We've been busy. Here's what shipped \uD83D\uDC47"},{type:"feature",heading:"Item-level sharing",body:"Share individual apps, databases and workflows with the right people. Connected items surface too, so sharing an app extends permissions to everything linked to it.",linkLabel:"See how it works",linkUrl:"https://www.getupgraded.ai"},{type:"feature",heading:"Zoho CRM as a data source",body:"Connect your account and build customer portals, client dashboards and internal tools directly on top of your CRM data.",linkLabel:"Connect Zoho",linkUrl:"https://www.getupgraded.ai/apps"},{type:"feature",heading:"New workflow integrations",body:"Bring **SharePoint** in to manage files and pages automatically. Trigger a workflow the moment a **Typeform** is submitted. Connect **QuickBooks** to create invoices, customers and bills without leaving the builder."},{type:"divider"},{type:"text",markdown:"**Everything else**\n\n- AI can now build apps from your Supabase data\n- New Stripe actions\n- Trello, Tally and Documint integrations"},{type:"cta",label:"Open the app",url:"https://www.getupgraded.ai"}],"New this month: item-level sharing + Zoho CRM","Plus SharePoint, Typeform and QuickBooks integrations")}),i.push({id:"claims-and-footnotes",name:"Offer with fine print",blurb:"Bold financial claims, each tied to a numbered footnote. Apple-style.",goal:"promotion",brief:"Make a specific financial claim about what a customer can expect to receive, and qualify every number in footnotes.",data:o({primary:"#111111",secondary:"#f2f2f2",accent:"#0070c9",textLight:"#ffffff",textDark:"#1d1d1f",background:"#ffffff",primaryText:"#1d1d1f",cardBackground:"#f2f2f2"},{},[{type:"hero",headline:"There's funded R&D. And then there's unfunded R&D.",subtext:"See what you qualify for with no cost and no commitment.^1"},{type:"cta",label:"Check eligibility",url:"https://www.getupgraded.ai/grants-finder"},{type:"text",markdown:"If you are building software in Canada and not claiming SR&ED, you are funding your own R&D out of revenue. Most teams we speak to assume they do not qualify, then discover the work they already shipped counts. Eligible claims return up to **35% of qualifying spend**,^2 and the money arrives as a refund rather than a loan."},{type:"divider"},{type:"feature",heading:"No cost to find out",body:"Eligibility takes minutes to check and does not obligate you to file. You see the estimated range before anyone talks to you.^1",linkLabel:"How eligibility works",linkUrl:"https://www.getupgraded.ai/guides/sred-and-irap"},{type:"feature",heading:"Stack it with financing",body:"Grant timelines are slow. Our financing partners advance against an approved claim at **0% for twelve months**,^3 so the cash arrives when you need it rather than when the government sends it.",linkLabel:"See financing terms",linkUrl:"https://www.getupgraded.ai/financing-partners"},{type:"stat",value:"$41,000",label:"median first-year claim^4"},{type:"text",markdown:"We handle the technical narrative, the costing and the filing. You review it before anything is submitted."},{type:"cta",label:"Start a claim",url:"https://www.getupgraded.ai/grants-finder"},{type:"footnotes",items:[{marker:"1",text:"Eligibility review is provided at no charge and creates no obligation to file. A completed claim is subject to a separate engagement agreement."},{marker:"2",text:"Combined federal and provincial rates vary by province, corporate structure and expenditure type. 35% reflects the enhanced federal ITC rate available to qualifying Canadian-controlled private corporations on the first $3M of eligible expenditures."},{marker:"3",text:"Financing is offered by third-party partners, not by Upgraded, and is subject to credit approval. Rates and terms are set by the partner and may change."},{marker:"4",text:"Median of first-year claims filed through Upgraded. Individual results vary substantially with headcount, eligible spend and province. Past results do not predict future claims."}]}],"There's funded R&D. And then there's unfunded R&D.","Check what you qual
1ify for â no cost, no commitment")})},38731:(e,t,a)=>{a.d(t,{MP:()=>m,O:()=>c,gf:()=>d,hF:()=>l});var n=a(76766);let l=[{key:"first_name",label:"First name",token:"{{first_name}}"},{key:"last_name",label:"Last name",token:"{{last_name}}"},{key:"full_name",label:"Full name",token:"{{full_name}}"},{key:"company",label:"Company",token:"{{company}}"},{key:"title",label:"Title",token:"{{title}}"},{key:"email",label:"Email",token:"{{email}}"}],r=["first_name","last_name","full_name","company","title","email","company_domain","phone"],o=/\{\{\s*([A-Za-z][A-Za-z0-9_]{0,40})\s*(?:\|\s*([^}]*?))?\s*\}\}/g,i=/^[A-Za-z][A-Za-z0-9_]{0,40}$/;function s(e){return"string"==typeof e?e.trim():"number"==typeof e&&Number.isFinite(e)?String(e):""}function c(e){var t;let a={};for(let[n,l]of Object.entries(null!=(t=e.extracted_fields)?t:{})){if(!i.test(n)||r.includes(n))continue;let e=s(l);e&&(a[n]=e)}let n=s(e.first_name),l=s(e.last_name),o=[n,l].filter(Boolean).join(" ");return a.first_name=n,a.last_name=l,a.full_name=o,a.company=s(e.company),a.company_domain=s(e.company_domain),a.title=s(e.title),a.email=s(e.email),a.phone=s(e.phone),a}function d(e){var t,a,n;let l=s(e.email),r=s(e.fullName),o=null!=(a=null==(t=l.split("@")[0])?void 0:t.replace(/[._]+/g," ").trim())?a:"",i=(r||o).split(/\s+/).filter(Boolean);return c({email:l,first_name:null!=(n=i[0])?n:"",last_name:i.slice(1).join(" ")})}function u(e,t,a){var l,r;let i=null!=(l=null==a?void 0:a.htmlEscape)&&l,s=null!=(r=null==a?void 0:a.unresolved)?r:"blank";return e.replace(o,(e,a,l)=>{var r;if(!Object.prototype.hasOwnProperty.call(t,a))return"keep"===s?e:(null!=l?l:"").trim();let o=(null!=(r=t[a])?r:"").trim()||(null!=l?l:"").trim();return i?(0,n.ZD)(o):o})}function p(e,t){return null==e?e:t(e)}function m(e,t,a){var n,l,r,o;let i=null!=(l=null==a?void 0:a.unresolved)?l:"blank",s=e=>u(e,t,{unresolved:i});return{...e,subject:s(e.subject),preheader:s(e.preheader),sections:(null!=(r=e.sections)?r:[]).map(e=>(function(e,t){var a,n;switch(e.type){case"hero":return{...e,headline:t(e.headline),subtext:p(e.subtext,t),imageAlt:p(e.imageAlt,t)};case"text":return{...e,markdown:t(e.markdown)};case"image":return{...e,url:t(e.url),alt:t(e.alt),caption:p(e.caption,t),linkUrl:p(e.linkUrl,t)};case"cta":return{...e,label:t(e.label),url:t(e.url)};case"stat":return{...e,value:t(e.value),label:t(e.label)};case"feature":return{...e,heading:t(e.heading),body:p(e.body,t),imageAlt:p(e.imageAlt,t),linkLabel:p(e.linkLabel,t),linkUrl:p(e.linkUrl,t)};case"columns":return{...e,cells:(null!=(a=e.cells)?a:[]).map(e=>({...e,heading:p(e.heading,t),body:p(e.body,t),imageAlt:p(e.imageAlt,t),linkUrl:p(e.linkUrl,t)}))};case"quote":return{...e,text:t(e.text),attribution:p(e.attribution,t)};case"code":return{...e,value:t(e.value),label:p(e.label,t),caption:p(e.caption,t)};case"footnotes":return{...e,items:(null!=(n=e.items)?n:[]).map(e=>({...e,marker:p(e.marker,t),text:t(e.text)}))};default:return e}})(e,s)),brand:e.brand?{...e.brand,logoAlt:p(e.brand.logoAlt,s),linkUrl:p(e.brand.linkUrl,s)}:e.brand,footer:{...e.footer,senderName:s(e.footer.senderName),mailingAddress:s(e.footer.mailingAddress),replyToEmail:null!=(o=p(e.footer.replyToEmail,s))?o:e.footer.replyToEmail,social:null==(n=e.footer.social)?void 0:n.map(e=>({label:s(e.label),url:s(e.url)}))},customHtml:e.customHtml?u(e.customHtml,t,{unresolved:i,htmlEscape:!0}):e.customHtml}}},42991:(e,t,a)=>{a.d(t,{E:()=>l});let n="-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif";function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{subject:"",preheader:"",palette:{primary:"#111111",secondary:"#f2f2f2",accent:"#111111",textLight:"#ffffff",textDark:"#111111",background:"#ffffff",primaryText:"#111111",cardBackground:"#f4f4f5"},typography:{headlineFont:n,bodyFont:n,headlineSize:"32px",bodySize:"16px"},sections:[],customHtml:null,footer:{senderName:"",mailingAddress:""},...e}}},53866:(e,t,a)=>{a.d(t,{A:()=>l});var n=a(12115);let l=n.forwardRef(function(e,t){let{title:a,titleId:l,...r}=e;return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":l},r),a?n.createElement("title",{id:l},a):null,n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.7
15"}))})},67816:(e,t,a)=>{a.d(t,{fK:()=>i,xc:()=>l});var n=a(76766);let l="#preview-unsubscribe",r="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif";function o(e){var t,a;switch(e.type){case"hero":return[(0,n.im)(e.headline),(0,n.im)(null!=(t=e.subtext)?t:"")].filter(Boolean).join("\n\n");case"text":return(0,n.im)(e.markdown);case"image":return e.caption?"[image: ".concat(e.alt,"] ").concat(e.caption):"[image: ".concat(e.alt,"]");case"cta":return"".concat(e.label,": ").concat(e.url);case"stat":return"".concat(e.value," â ").concat((0,n.im)(e.label));case"feature":return[(0,n.im)(e.heading),e.body?(0,n.im)(e.body):"",e.linkLabel&&e.linkUrl?"".concat(e.linkLabel,": ").concat(e.linkUrl):""].filter(Boolean).join("\n");case"columns":return e.cells.slice(0,4).map(e=>[e.heading,e.body?(0,n.im)(e.body):""].filter(Boolean).join(" â ")).filter(Boolean).map(e=>"- ".concat(e)).join("\n");case"quote":return'"'.concat(e.text,'"').concat(e.attribution?"\nâ ".concat(e.attribution):"");case"code":return[e.label,e.value,e.caption].filter(Boolean).join("\n");case"footnotes":return(null!=(a=e.items)?a:[]).map((e,t)=>{var a;return"".concat(null!=(a=e.marker)?a:t+1,". ").concat((0,n.im)(e.text))}).join("\n");case"divider":return"---";default:return""}}function i(e,t){var a,l,i,s,c,d,u,p,m,h,g,f,b,x,y,v;let w=(null==(a=e.palette)?void 0:a.background)||"#ffffff",k=(null==(l=e.palette)?void 0:l.primaryText)||(null==(i=e.palette)?void 0:i.textDark)||"#111111",j=(null==(s=e.palette)?void 0:s.accent)||"#1a1a1a",N=(null==(c=e.typography)?void 0:c.headlineFont)||r,S=(null==(d=e.typography)?void 0:d.bodyFont)||r,C=(null==(u=e.typography)?void 0:u.bodySize)||"16px",D={bg:w,text:k,accent:j,panel:(null==(p=e.palette)?void 0:p.cardBackground)||(null==(m=e.palette)?void 0:m.secondary)||"#f1f1ef",headlineFont:N,bodyFont:S,bodySize:C},A=null==(g=e.brand)||null==(h=g.logoUrl)?void 0:h.trim(),F=A&&(0,n.YS)(A)?(()=>{var t,a,l,r;let o=Math.min(Math.max((null==(t=e.brand)?void 0:t.logoWidth)||140,24),600),i=(0,n.ZD)((null==(a=e.brand)?void 0:a.logoAlt)||e.footer.senderName||""),s='<img src="'.concat((0,n.ZD)(A),'" alt="').concat(i,'" width="').concat(o,'" style="display:block;width:').concat(o,'px;max-width:100%;height:auto;border:0;outline:none;text-decoration:none;" />'),c=null==(r=e.brand)||null==(l=r.linkUrl)?void 0:l.trim(),d=c&&(0,n.FY)(c)?'<a href="'.concat((0,n.ZD)(c),'" target="_blank" rel="noopener noreferrer">').concat(s,"</a>"):s;return'<tr><td align="center" style="padding:28px 32px 4px 32px;">'.concat(d,"</td></tr>")})():"",T=!!(null==(f=e.customHtml)?void 0:f.trim()),U=T?'<tr><td style="padding:0;">'.concat(e.customHtml,"</td></tr>"):(null!=(x=e.sections)?x:[]).map(e=>(function(e,t){var a,l,r,o;let i=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0 32px";return'<tr><td style="padding:'.concat(t,';">').concat(e,"</td></tr>")};switch(e.type){case"hero":{let l=e.imageUrl&&(0,n.YS)(e.imageUrl)?'<img src="'.concat((0,n.ZD)(e.imageUrl),'" alt="').concat((0,n.ZD)(null!=(a=e.imageAlt)?a:""),'" width="').concat(600,'" style="display:block;width:100%;max-width:').concat(600,'px;height:auto;border:0;" />'):"",r=e.subtext?'<p style="margin:12px 0 0 0;color:'.concat((0,n.ZD)(t.text),";font-family:").concat((0,n.ZD)(t.bodyFont),';font-size:17px;line-height:1.55;opacity:0.85;">').concat((0,n.ZS)(e.subtext,t.accent),"</p>"):"";return(l?'<tr><td style="padding:0;">'.concat(l,"</td></tr>"):"")+i('<h1 style="margin:0;color:'.concat((0,n.ZD)(t.text),";font-family:").concat((0,n.ZD)(t.headlineFont),';font-size:32px;line-height:1.2;font-weight:700;">').concat((0,n.ZD)(e.headline),"</h1>").concat(r),"32px 32px 8px 32px")}case"text":return i((0,n.ni)(e.markdown,{textColor:t.text,linkColor:t.accent,bodyFont:t.bodyFont,bodySize:t.bodySize}),"12px 32px");case"image":{if(!(0,n.YS)(e.url))return"";let a=!0===e.fullBleed,l='<img src="'.concat((0,n.ZD)(e.url),'" alt="').concat((0,n.ZD)(e.alt),'" width="').concat(a?600:536,'" style="display:block;width:100%;height:auto;border:0;').concat(a?"":"border-radius:6px;",'" />'),r=e.linkUrl&&(0,n.FY)(e.linkUrl)?'<a href="'.concat((0,n.ZD)(e.linkUrl),'" target="_blank" rel="noopener noreferrer">').concat(l,"</a>"):l,o=e.caption?'<p style="margin:8px 0 0 0;color:'.concat((0,n.ZD)(t.text),";font-family:").concat((0,n.ZD)(t.bodyFont),';font-size:13px;line-height:1.5;opacity:0.7;">').concat((0,n.ZD)(e.caption),"</p>"):"";if(a)return'<tr><td style="padding:0;">'.concat(r,"</td></tr>")+(o?i(o,"8px 32px 0 32px"):"");return i("".concat(r).concat(o),"12px 32px")}case"cta":if(!(0,n.FY)(e.url))return"";return i('<table role="presentation" cellpadding="0" cellspacing="0" border="0" style="margin:8px 0;">\n <tr><td align="center" bgcolor="'.concat((0,n.ZD)(t.accent),'" style="border-radius:6px;">\n <a href="').concat((0,n.ZD)(e.url),'" target="_blank" rel="noopener noreferrer"\n style="display:inline-block;padding:14px 28px;font-family:').concat((0,n.ZD)(t.bodyFont),';font-size:16px;font-weight:600;color:#ffffff;text-decoration:none;border-radius:6px;">').concat((0,n.ZD)(e.label),"</a>\n </td></tr>\n </table>"),"12px 32px");case"stat":return i('<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%">\n <tr><td align="center" style="padding:20px 0;">\n <div style="color:'.concat((0,n.ZD)(t.accent),";font-family:").concat((0,n.ZD)(t.headlineFont),';font-size:44px;line-height:1;font-weight:700;">').concat((0,n.ZD)(e.value),'</div>\n <div style="margin-top:8px;color:').concat((0,n.ZD)(t.text),";font-family:").concat((0,n.ZD)(t.bodyFont),';font-size:14px;letter-spacing:0.04em;text-transform:uppercase;opacity:0.7;">').concat((0,n.ZS)(e.label,t.accent),"</div>\n </td></tr>\n </table>"),"4px 32px");case"feature":{let a=e.body?(0,n.ni)(e.body,{textColor:t.text,linkColor:t.accent,bodyFont:t.bodyFont,bodySize:t.bodySize}):"",o=e.linkLabel&&e.linkUrl&&(0,n.FY)(e.linkUrl)?'<a href="'.concat((0,n.ZD)(e.linkUrl),'" style="color:').concat((0,n.ZD)(t.accent),";font-family:").concat((0,n.ZD)(t.bodyFont),';font-size:15px;font-weight:600;text-decoration:underline;" target="_blank" rel="noopener noreferrer">').concat((0,n.ZD)(e.linkLabel),"</a>"):"",s='<h2 style="margin:0 0 8px 0;color:'.concat((0,n.ZD)(t.text),";font-family:").concat((0,n.ZD)(t.headlineFont),';font-size:21px;line-height:1.25;font-weight:700;">').concat((0,n.ZD)(e.heading),"</h2>");if(e.compact){let t=e.imageUrl&&(0,n.YS)(e.imageUrl)?'<img src="'.concat((0,n.ZD)(e.imageUrl),'" alt="').concat((0,n.ZD)(null!=(l=e.imageAlt)?l:""),'" width="44" style="display:block;width:44px;height:auto;border:0;" />'):"";return i('<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%">\n <tr>\n '.concat(t?'<td width="64" valign="top" style="padding-right:20px;">'.concat(t,"</td>"):"",'\n <td valign="top">').concat(s).concat(a).concat(o,"</td>\n </tr>\n </table>"),"14px 32px")}let c=e.imageUrl&&(0,n.YS)(e.imageUrl)?'<img src="'.concat((0,n.ZD)(e.imageUrl),'" alt="').concat((0,n.ZD)(null!=(r=e.imageAlt)?r:""),'" width="').concat(536,'" style="display:block;width:100%;height:auto;border:0;border-radius:10px;margin-bottom:18px;" />'):"";return i("".concat(c).concat(s).concat(a).concat(o),"16px 32px")}case"columns":{let a=e.cells.slice(0,4);if(0===a.length)return"";let l=(100/a.length).toFixed(4),r="plain"!==e.variant,o=a.map(e=>{var a;let o=e.imageUrl&&(0,n.YS)(e.imageUrl)?'<img src="'.concat((0,n.ZD)(e.imageUrl),'" alt="').concat((0,n.ZD)(null!=(a=e.imageAlt)?a:""),'" width="240" style="display:block;width:100%;height:auto;border:0;border-radius:8px;margin-bottom:10px;" />'):"",i=e.heading?'<div style="color:'.concat((0,n.ZD)(t.text),";font-family:").concat((0,n.ZD)(t.headlineFont),';font-size:16px;line-height:1.3;font-weight:700;margin-bottom:6px;">').concat((0,n.ZD)(e.heading),"</div>"):"",s=e.body?'<div style="color:'.concat((0,n.ZD)(t.text),";font-family:").concat((0,n.ZD)(t.bodyFont),';font-size:14px;line-height:1.5;opacity:0.8;">').concat((0,n.ZS)(e.body,t.accent),"</div>
1"):"",c="".concat(o).concat(i).concat(s),d=e.linkUrl&&(0,n.FY)(e.linkUrl)?'<a href="'.concat((0,n.ZD)(e.linkUrl),'" style="text-decoration:none;color:inherit;" target="_blank" rel="noopener noreferrer">').concat(c,"</a>"):c;return'<td class="nl-col" width="'.concat(l,'%" valign="top" style="width:').concat(l,"%;padding:").concat(r?"18px":"0 8px",";").concat(r?"background-color:".concat((0,n.ZD)(t.panel),";border-radius:12px;"):"",'">').concat(d,"</td>")}).join(r?'<td class="nl-gap" width="12"> </td>':"");return i('<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="table-layout:fixed;"><tr>'.concat(o,"</tr></table>"),"12px 32px")}case"quote":{let a=e.attribution?'<div style="margin-top:14px;color:'.concat((0,n.ZD)(t.text),";font-family:").concat((0,n.ZD)(t.bodyFont),';font-size:14px;opacity:0.65;">').concat((0,n.ZD)(e.attribution),"</div>"):"";return i('<div style="border-top:1px solid '.concat((0,n.ZD)(t.text),"20;border-bottom:1px solid ").concat((0,n.ZD)(t.text),'20;padding:26px 0;">\n <div style="color:').concat((0,n.ZD)(t.text),";font-family:").concat((0,n.ZD)(t.headlineFont),';font-size:23px;line-height:1.35;font-weight:400;">“').concat((0,n.ZD)(e.text),"”</div>\n ").concat(a,"\n </div>"),"16px 32px")}case"code":{let a=e.label?'<div style="color:'.concat((0,n.ZD)(t.text),";font-family:").concat((0,n.ZD)(t.bodyFont),';font-size:13px;opacity:0.7;margin-bottom:10px;">').concat((0,n.ZD)(e.label),"</div>"):"",l=e.caption?'<div style="color:'.concat((0,n.ZD)(t.text),";font-family:").concat((0,n.ZD)(t.bodyFont),';font-size:12px;opacity:0.6;margin-top:10px;">').concat((0,n.ZD)(e.caption),"</div>"):"";return i('<div style="background-color:'.concat((0,n.ZD)(t.panel),';border-radius:12px;padding:22px;text-align:center;">\n ').concat(a,'\n <div style="color:').concat((0,n.ZD)(t.accent),";font-family:Consolas,'Courier New',monospace;font-size:19px;font-weight:700;letter-spacing:0.09em;word-break:break-all;\">").concat((0,n.ZD)(e.value),"</div>\n ").concat(l,"\n </div>"),"14px 32px")}case"footnotes":{if(!(null==(o=e.items)?void 0:o.length))return"";let a=e.items.map((e,a)=>{var l;return'<tr>\n <td valign="top" width="18" style="padding:0 6px 10px 0;color:'.concat((0,n.ZD)(t.text),";font-family:").concat((0,n.ZD)(t.bodyFont),';font-size:10px;line-height:1.5;opacity:0.55;">').concat((0,n.ZD)(null!=(l=e.marker)?l:String(a+1)),'</td>\n <td valign="top" style="padding:0 0 10px 0;color:').concat((0,n.ZD)(t.text),";font-family:").concat((0,n.ZD)(t.bodyFont),';font-size:11px;line-height:1.55;opacity:0.55;">').concat((0,n.ZS)(e.text,t.accent),"</td>\n </tr>")}).join("");return i('<div style="height:1px;line-height:1px;font-size:0;background-color:'.concat((0,n.ZD)(t.text),';opacity:0.12;margin-bottom:18px;"> </div>\n <table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%">').concat(a,"</table>"),"10px 32px")}case"divider":return i('<div style="height:1px;line-height:1px;font-size:0;background-color:'.concat((0,n.ZD)(t.text),';opacity:0.12;"> </div>'),"20px 32px");default:return""}})(e,D)).join(""),Z=e=>T?'<div style="max-width:'.concat(600,'px;margin:0 auto;">').concat(e,"</div>"):e,E="color:".concat((0,n.ZD)(k),";font-family:").concat((0,n.ZD)(S),";font-size:12px;line-height:1.6;opacity:0.6;"),L=t.preview?'<span style="text-decoration:underline;">Unsubscribe</span> <span style="opacity:0.7;">(inactive in preview)</span>':'<a href="'.concat((0,n.ZD)(t.unsubscribeUrl),'" style="color:').concat((0,n.ZD)(k),';text-decoration:underline;">Unsubscribe</a>'),R=(null!=(y=e.footer.social)?y:[]).filter(e=>{var t,a;return(null==e||null==(t=e.label)?void 0:t.trim())&&(null==e||null==(a=e.url)?void 0:a.trim())&&(0,n.FY)(e.url)}),B=R.length?'<tr><td align="center" style="padding:12px 32px 0 32px;'.concat(E,'">').concat(R.map(e=>'<a href="'.concat((0,n.ZD)(e.url),'" target="_blank" rel="noopener noreferrer" style="color:').concat((0,n.ZD)(k),';text-decoration:underline;">').concat((0,n.ZD)(e.label),"</a>")).join('<span style="opacity:0.5;"> · </span>'),"</td></tr>"):"",z=t.webViewUrl&&(0,n.FY)(t.webViewUrl)?'<tr><td align="center" style="padding:0 32px 12px 32px;"><a href="'.concat((0,n.ZD)(t.webViewUrl),'" style="').concat(E,'text-decoration:underline;">View in browser</a></td></tr>'):"",H='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" lang="en">\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n<meta name="viewport" content="width=device-width, initial-scale=1" />\n<meta name="color-scheme" content="light" />\n<meta name="supported-color-schemes" content="light" />\n<title>'.concat((0,n.ZD)(e.subject),'</title>\n\x3c!--[if mso]><style type="text/css">body,table,td,a{font-family:Arial,Helvetica,sans-serif !important;}</style><![endif]--\x3e\n<style type="text/css">\n/* Column stacking. This is the ONE place a <style> block is load-bearing:\n side-by-side cells are unreadable below ~480px and there is no inline\n equivalent. Outlook ignores this and keeps the desktop columns, which is\n the correct fallback since Outlook is not a phone. */\n@media only screen and (max-width:480px){\n .nl-col{display:block !important;width:100% !important;padding-left:0 !important;padding-right:0 !important;margin-bottom:12px !important;}\n .nl-gap{display:none !important;}\n}\n</style>\n</head>\n<body style="margin:0;padding:0;background-color:#f4f4f5;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;">\n\x3c!-- Preheader: the grey line clients show next to the subject. The trailing\n entities stop the first line of body copy bleeding into that preview. --\x3e\n<div style="display:none;font-size:1px;color:#f4f4f5;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden;">').concat((0,n.ZD)(e.preheader),'͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ </div>\n<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="background-color:#f4f4f5;">\n <tr>\n <td align="center" style="padding:').concat(T?"0":"24px 12px",';">\n <table role="presentation" cellpadding="0" cellspacing="0" border="0"').concat(T?"":' width="'.concat(600,'"'),' style="').concat(T?"width:100%;":"width:100%;max-width:".concat(600,"px;"),"background-color:").concat((0,n.ZD)(w),";").concat(T?"":"border-radius:8px;overflow:hidden;",'">\n ').concat(F,"\n ").concat(U,'\n <tr><td style="padding:8px 32px 0 32px;">').concat(Z('<div style="height:1px;line-height:1px;font-size:0;background-color:'.concat((0,n.ZD)(k),';opacity:0.12;"> </div>')),"</td></tr>\n ").concat(B,"\n ").concat(z,'\n <tr>\n <td align="center" style="padding:16px 32px 28px 32px;').concat(E,'">\n ').concat(Z("<div>".concat((0,n.ZD)(e.footer.senderName),"</div>\n <div>").concat((0,n.ZD)(e.footer.mailingAddress),'</div>\n <div style="margin-top:8px;">').concat(L,"</div>")),"\n </td>\n </tr>\n </table>\n </td>\n </tr>\n</table>\n</body>\n</html>"),I=[(0,n.im)(e.preheader),"",...(null==(b=e.customHtml)?void 0:b.trim())?[(0,n.io)(e.customHtml)]:(null!=(v=e.sections)?v:[]).map(o).filter(
1Boolean),"",...R.map(e=>"".concat(e.label,": ").concat(e.url)),"---",e.footer.senderName,e.footer.mailingAddress,t.preview?"Unsubscribe: (inactive in preview)":"Unsubscribe: ".concat(t.unsubscribeUrl)];return{subject:e.subject,html:H,text:I.join("\n").replace(/\n{3,}/g,"\n\n").trim()}}},72948:(e,t,a)=>{a.d(t,{W:()=>p,k:()=>u});var n=a(95155),l=a(12115),r=a(18720),o=a(67816),i=a(38731),s=a(9521);let c=[{id:"desktop",label:"Desktop"},{id:"mobile",label:"Mobile"},{id:"code",label:"Code"},{id:"text",label:"Text"}],d={desktop:640,mobile:375};function u(e){var t,a;let{data:u,isDark:p=!1,height:m=620,className:h="",editableHtml:g=null,onHtmlChange:f,selfProfile:b=null,onSampleChange:x}=e,[y,v]=(0,l.useState)("desktop"),[w,k]=(0,l.useState)(null),[j,N]=(0,l.useState)(""),[S,C]=(0,l.useState)([]),[D,A]=(0,l.useState)(!1),[F,T]=(0,l.useState)(null),[U,Z]=(0,l.useState)(!1),E=null!==b,L=(0,l.useMemo)(()=>(0,i.gf)({email:null==b?void 0:b.email,fullName:null==b?void 0:b.fullName}),[null==b?void 0:b.email,null==b?void 0:b.fullName]),R=F?[F.first_name,F.last_name].filter(Boolean).join(" ")||F.email||"Lead":"you",B=(0,l.useMemo)(()=>F?(0,i.O)(F):L,[F,L]);(0,l.useEffect)(()=>{var e;E&&(null==x||x({context:B,label:R,leadId:null!=(e=null==F?void 0:F.id)?e:null}))},[E,x,B,R,null==F?void 0:F.id]),(0,l.useEffect)(()=>{if(!E)return;let e=j.trim();if(e.length<2)return void C([]);let t=window.setTimeout(()=>{let t=new URLSearchParams({search:e.replace(/,/g," "),limit:"6"});fetch("/api/scorecard/leads?".concat(t.toString()),{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>{C(Array.isArray(null==e?void 0:e.leads)?e.leads:[]),A(!0)}).catch(()=>C([]))},250);return()=>window.clearTimeout(t)},[E,j]);let z=(null==F||null==(t=F.email)?void 0:t.trim())||"",H=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(z)&&!(0,s.G_)(z),I=F?H?z:"":(null==b||null==(a=b.email)?void 0:a.trim())||"",_=async()=>{if(I&&!U){Z(!0);try{var e;let t=await fetch("/api/newsletters/send-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletter:u,leadId:null!=(e=null==F?void 0:F.id)?e:null})}),a=await t.json().catch(()=>null);if(!t.ok)return void r.o.error((null==a?void 0:a.error)||"Failed to send test email");r.o.success("Test sent to ".concat((null==a?void 0:a.sentTo)||I))}catch(e){r.o.error("Failed to send test email")}finally{Z(!1)}}},M=(0,l.useMemo)(()=>E?(0,i.MP)(u,B):u,[E,u,B]),O=(0,l.useMemo)(()=>(0,o.fK)(M,{unsubscribeUrl:o.xc,preview:!0}),[M]),q=(0,l.useMemo)(()=>(0,o.fK)(u,{unsubscribeUrl:o.xc,preview:!0}),[u]),P=f?null!==g?g:q.html:O.html,V=async e=>{try{await navigator.clipboard.writeText("code"===e?P:O.text),k(e),setTimeout(()=>k(null),1500)}catch(e){}},W=p?"border-white/10":"border-gray-200",$=p?"text-gray-400":"text-gray-500",Y=p?"bg-black/40 text-gray-200":"bg-gray-50 text-gray-800";return(0,n.jsxs)("div",{className:"flex flex-col ".concat(h),children:[E&&(0,n.jsxs)("div",{className:"flex items-center gap-2 border-b ".concat(W," px-3 py-2"),children:[(0,n.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,n.jsx)("input",{value:j,onChange:e=>{N(e.target.value),A(!0)},onFocus:()=>S.length>0&&A(!0),placeholder:F?"Previewing as ".concat(R):"Preview as a leadâ¦",className:"w-full rounded-lg border px-3 py-1.5 text-xs outline-none ".concat(p?"border-white/15 bg-white/[0.04] text-gray-100 placeholder:text-gray-500":"border-gray-200 bg-white text-gray-900 placeholder:text-gray-400")}),D&&S.length>0&&(0,n.jsx)("div",{className:"absolute left-0 right-0 top-full z-20 mt-1 max-h-56 overflow-auto rounded-lg border py-1 shadow-lg ".concat(p?"border-white/10 bg-[#1c1d22]":"border-gray-200 bg-white"),children:S.map(e=>{let t=[e.first_name,e.last_name].filter(Boolean).join(" ")||e.email||"Lead";return(0,n.jsxs)("button",{type:"button",onClick:()=>{T(e),N(""),A(!1)},className:"flex w-full cursor-pointer flex-col px-3 py-1.5 text-left ".concat(p?"hover:bg-white/10":"hover:bg-gray-50"),children:[(0,n.jsx)("span",{className:"text-xs ".concat(p?"text-gray-100":"text-gray-900"),children:t}),(0,n.jsx)("span",{className:"text-[10px] ".concat($),children:[e.email,e.company].filter(
1Boolean).join(" \xb7 ")})]},e.id)})})]}),F&&(0,n.jsx)("button",{type:"button",onClick:()=>{T(null),N(""),A(!1)},className:"shrink-0 cursor-pointer text-[11px] underline ".concat($),children:"As you"}),((null==b?void 0:b.email)||F)&&(0,n.jsx)("button",{type:"button",onClick:()=>void _(),disabled:U||!I,title:I?"Send this preview to ".concat(I):"This lead has no email address",className:"shrink-0 cursor-pointer rounded-lg px-3 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50 ".concat(p?"bg-white text-gray-900 hover:bg-gray-200":"bg-gray-900 text-white hover:bg-gray-700"),children:U?"Sendingâ¦":"Send test"})]}),E&&(0,n.jsxs)("p",{className:"px-3 py-1.5 text-[10px] leading-relaxed ".concat($),children:["Variables fill as ",R,".",I?" Send test delivers this preview to ".concat(I,"."):F?" This lead has no email address.":""]}),(0,n.jsxs)("div",{className:"flex items-center gap-1 border-b ".concat(W," px-1"),children:[c.map(e=>{let t=y===e.id;return(0,n.jsxs)("button",{type:"button",onClick:()=>v(e.id),"aria-current":t?"true":void 0,className:"relative cursor-pointer rounded-t-lg px-3 py-2 text-sm transition-colors ".concat(t?p?"text-white font-medium":"text-gray-900 font-medium":"".concat($," hover:").concat(p?"text-gray-200":"text-gray-900")),children:[e.label,t&&(0,n.jsx)("span",{"aria-hidden":!0,className:"absolute inset-x-2 -bottom-px h-[2px] rounded-full ".concat(p?"bg-white/80":"bg-gray-900/80")})]},e.id)}),("code"===y||"text"===y)&&(0,n.jsx)("button",{type:"button",onClick:()=>V(y),className:"ml-auto mr-1 cursor-pointer rounded-md px-2.5 py-1 text-xs transition-colors ".concat(p?"text-gray-400 hover:bg-white/10 hover:text-white":"text-gray-500 hover:bg-gray-100 hover:text-gray-900"),children:w===y?"Copied":"Copy"})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-auto ".concat("desktop"===y||"mobile"===y?p?"bg-black/20":"bg-gray-100":p?"bg-[#111112]":"bg-white"),style:{height:m},children:[("desktop"===y||"mobile"===y)&&(0,n.jsx)("div",{className:"flex justify-center py-4",children:(0,n.jsx)("iframe",{title:"Newsletter preview (".concat(y,")"),srcDoc:O.html,sandbox:"",width:d[y],style:{width:d[y],height:m-32,border:"none",borderRadius:8,background:"#f4f4f5",boxShadow:"0 1px 3px rgba(0,0,0,0.12)"}},y)}),"code"===y&&(f?(0,n.jsx)("textarea",{value:P,onChange:e=>f(e.target.value),spellCheck:!1,placeholder:'<table role="presentation" width="600">\n <tr><td>â¦</td></tr>\n</table>',className:"m-0 h-full w-full resize-none border-0 p-4 font-mono text-[11px] leading-relaxed outline-none ".concat(Y)}):(0,n.jsx)("pre",{className:"m-0 h-full overflow-auto p-4 text-[11px] leading-relaxed ".concat(Y),children:(0,n.jsx)("code",{children:P})})),"text"===y&&(0,n.jsxs)("div",{className:"p-4",children:[(0,n.jsx)("p",{className:"mb-3 text-xs ".concat($),children:"The text/plain alternative. Clients that block HTML fall back to this, and a message without it is a spam signal."}),(0,n.jsx)("pre",{className:"m-0 overflow-auto whitespace-pre-wrap rounded-lg p-4 text-xs leading-relaxed ".concat(Y),children:O.text})]})]})]})}function p(e){let{subject:t,preheader:a,senderName:l,isDark:r=!1}=e;return(0,n.jsxs)("div",{className:"rounded-xl border px-4 py-3 ".concat(r?"border-white/10 bg-white/[0.03]":"border-gray-200 bg-white"),children:[(0,n.jsx)("div",{className:"text-sm font-semibold ".concat(r?"text-gray-100":"text-gray-900"),children:l||"Sender"}),(0,n.jsx)("div",{className:"truncate text-sm ".concat(r?"text-gray-200":"text-gray-800"),children:t||(0,n.jsx)("span",{className:"opacity-50",children:"No subject"})}),(0,n.jsx)("div",{className:"truncate text-xs ".concat("text-gray-500"),children:a||(0,n.jsx)("span",{className:"opacity-60",children:"No preview text"})})]})}},76766:(e,t,a)=>{function n(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function l(e){try{let t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol||"mailto:"===t.protocol}catch(e){return!1}}function r(e){try{let t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch(e){return!1}}function o(e,t){if(!e)return"";let a=[],r=e=>"XNLLINK".concat(e,"XNLLINK"),o=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(e,o,i)=>{if(!l(i))return o;let s=a.length;return a.push('<a href="'.concat(n(i),'" style="color:').concat(n(t),';text-decoration:underline;" target="_blank" rel="noopener noreferrer">').concat(n(o),"</a>")),r(s)});o=o.replace(/(^|[\s(])(https?:\/\/[^\s<>"']+[^\s<>"'.,;
1:!?)\]])/g,(e,l,o)=>{let i=a.length;return a.push('<a href="'.concat(n(o),'" style="color:').concat(n(t),';text-decoration:underline;" target="_blank" rel="noopener noreferrer">').concat(n(o),"</a>")),"".concat(l).concat(r(i))});let i="[^\\s*](?:[^*]*[^\\s*])?";return(o=(o=(o=(o=n(o)).replace(RegExp("\\*\\*(".concat(i,")\\*\\*"),"g"),"<strong>$1</strong>")).replace(RegExp("(^|[^*])\\*(".concat(i,")\\*"),"g"),"$1<em>$2</em>")).replace(/\^(\d{1,2})\b/g,'<sup style="font-size:0.65em;line-height:0;vertical-align:super;">$1</sup>')).replace(/XNLLINK(\d+)XNLLINK/g,(e,t)=>{var n;return null!=(n=a[Number(t)])?n:""})}function i(e,t){if(!(null==e?void 0:e.trim()))return"";let a="margin:0 0 16px 0;color:".concat(n(t.textColor),";font-family:").concat(n(t.bodyFont),";font-size:").concat(n(t.bodySize),";line-height:1.6;");return e.trim().split(/\n\s*\n/).map(e=>{let n=e.split("\n").map(e=>e.trim()).filter(Boolean);if(0===n.length)return"";let l=n.every(e=>/^[-*]\s+/.test(e)),r=n.every(e=>/^\d+[.)]\s+/.test(e));if(l||r){let e=l?"ul":"ol",r=n.map(e=>e.replace(l?/^[-*]\s+/:/^\d+[.)]\s+/,"")).map(e=>'<li style="margin:0 0 8px 0;">'.concat(o(e,t.linkColor),"</li>")).join("");return"<".concat(e,' style="').concat(a,'padding-left:22px;">').concat(r,"</").concat(e,">")}let i=n.map(e=>o(e,t.linkColor)).join("<br>");return'<p style="'.concat(a,'">').concat(i,"</p>")}).filter(Boolean).join("")}function s(e){return(null==e?void 0:e.trim())?e.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<!--[\s\S]*?-->/g,"").replace(/<br\s*\/?>/gi,"\n").replace(/<\/(p|div|tr|h[1-6]|li|table|blockquote)>/gi,"\n").replace(/<[^>]*>/g,"").replace(/ /gi," ").replace(/</gi,"<").replace(/>/gi,">").replace(/"/gi,'"').replace(/�*39;/g,"'").replace(/&/gi,"&").replace(/[ \t]+/g," ").replace(/ *\n */g,"\n").replace(/\n{3,}/g,"\n\n").trim():""}function c(e){return e?e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,"$1 ($2)").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/(^|[^*])\*([^*]+)\*/g,"$1$2").replace(/^[-*]\s+/gm,"- ").replace(/\^(\d{1,2})\b/g," ($1)").trim():""}a.d(t,{FY:()=>l,YS:()=>r,ZD:()=>n,ZS:()=>o,im:()=>c,io:()=>s,ni:()=>i})},87754:(e,t,a)=>{a.d(t,{t:()=>I});var n=a(95155),l=a(12115),r=a(47650),o=a(18720),i=a(42991),s=a(19768),c=a(72948),d=a(38731);let u=(0,l.createContext)(null);function p(e){let{children:t}=e,a=(0,l.useRef)(null),r=(0,l.useRef)({register:e=>{a.current=e},insert:e=>!!a.current&&(a.current(e),!0)});return(0,n.jsx)(u.Provider,{value:r.current,children:t})}function m(e,t){let a=(0,l.useRef)(null),n=(0,l.useRef)(e),r=(0,l.useRef)(t),o=(0,l.useRef)({start:0,end:0});n.current=e,r.current=t;let i=(0,l.useContext)(u),s=()=>{var e,t;let l=a.current;l&&(o.current={start:null!=(e=l.selectionStart)?e:n.current.length,end:null!=(t=l.selectionEnd)?t:n.current.length})},c=(0,l.useCallback)(()=>{null==i||i.register(e=>{var t,l,i;let s=a.current,c=null!=(t=n.current)?t:"",d=null!=(l=null==s?void 0:s.selectionStart)?l:o.current.start,u=null!=(i=null==s?void 0:s.selectionEnd)?i:o.current.end,p="".concat(c.slice(0,d)).concat(e).concat(c.slice(u));r.current(p);let m=d+e.length;o.current={start:m,end:m},requestAnimationFrame(()=>{let e=a.current;e&&(e.focus(),e.setSelectionRange(m,m))})})},[i]);return{ref:a,onFocus:c,onBlur:s,onSelect:s}}function h(e){let{value:t,onChange:a,disabled:l,placeholder:r,className:o,multiline:i,rows:s,spellCheck:c}=e,d=m(t,a);return i?(0,n.jsx)("textarea",{ref:d.ref,value:t,disabled:l,rows:s,placeholder:r,spellCheck:c,onFocus:d.onFocus,onBlur:d.onBlur,onSelect:d.onSelect,onChange:e=>a(e.target.value),className:o}):(0,n.jsx)("input",{ref:d.ref,value:t,disabled:l,placeholder:r,onFocus:d.onFocus,onBlur:d.onBlur,onSelect:d.onSelect,onChange:e=>a(e.target.value),className:o})}function g(e){let{isDark:t=!1,disabled:a=!1}=e,r=(0,l.useContext)(u),[o,i]=(0,l.useState)(!1),[s,c]=(0,l.useState)(null);return(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("button",{type:"button",disabled:a,onMouseDown:e=>e.preventDefault(),onClick:()=>i(e=>!e),className:"cursor-pointer rounded-md px-2 py-1 text-[11px] font-medium disabled:cursor-not-allowed disabled:opacity-40 ".concat(t?"text-gray-300 hover:bg-white/10":"text-gray-600 hover:bg-gray-100"),children:"Insert variable"}),o&&!a&&(0,n.jsxs)("div",{className:"absolute right-0 z-30 mt-1 w-52 rounded-lg border py-1 shadow-lg ".concat(t?"border-white/10 bg-[#1c1d22]":"border-gray-200 bg-white"),children:[d.hF.map(e=>(0,n.jsxs)("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:()=>(e=>{var t;let a=null!=(t=null==r?void 0:r.insert(e))&&t;i(!1),a?c(null):c("Click into a text field first, then insert.")})(e.token),className:"flex w-full cursor-pointer items-center justify-between px-3 py-1.5 text-left text-xs ".concat(t?"text-gray-200 hover:bg-white/10":"text-gray-800 hover:bg-gray-50"),children:[(0,n.jsx)("span",{children:e.label}),(0,n.jsx)("span",{className:"font-mono text-[10px] ".concat(t?"text-gray-500":"text-gray-400"),children:e.token})]},e.key)),(0,n.jsxs)("p",{className:"px-3 py-2 text-[10px] leading-relaxed ".concat("text-gray-500"),children:["Add a fallback with a pipe: ","{{first_name|there}}",". Custom lead fields work the same way, for example ","{{interest}}","."]})]}),s&&(0,n.jsx)("p",{className:"mt-1 text-[10px] ".concat(t?"text-amber-300/90":"text-amber-700"),children:s})]})}var f=a(9554),b=a(96059),x=a(49537),y=a(53866),v=a(57218);let w={hero:"Hero",text:"Text",image:"Image",cta:"Button",stat:"Stat",feature:"Feature",columns:"Columns",quote:"Quote",code:"Code",footnotes:"Footnotes",divider:"Divider"},k=["text","hero","cta","feature","image","columns","stat","quote","code","divider","footnotes"],j=(0,l.createContext)(null);function N(){let e=(0,l.useContext)(j);if(!e)throw Error("Field used outside NewsletterSectionEditor");return e}function S(e){let{label:t,value:a,onValue:l,placeholder:r,mono:o}=e,{disabled:i,muted:s,inputClass:c}=N(),d=null!=a?a:"",u=m(d,l);return(0,n.jsxs)("label",{className:"block",children:[(0,n.jsx)("span",{className:"mb-1 block text-[11px] font-medium ".concat(s),children:t}),(0,n.jsx)("input",{ref:u.ref,value:d,disabled:i,placeholder:r,onFocus:u.onFocus,onBlur:u.onBlur,onSelect:u.onSelect,onChange:e=>l(e.target.value),className:"".concat(c).concat(o?" font-mono tracking-wide":"")})]})}function C(e){let{label:t,value:a,onValue:l,placeholder:r,rows:o=4}=e,{disabled:i,muted:s,inputClass:c}=N(),d=null!=a?a:"",u=m(d,l);return(0,n.jsxs)("label",{className:"block",children:[(0,n.jsx)("span",{className:"mb-1 block text-[11px] font-medium ".concat(s),children:t}),(0,n.jsx)("textarea",{ref:u.ref,value:d,disabled:i,rows:o,placeholder:r,onFocus:u.onFocus,onBlur:u.onBlur,onSelect:u.onSelect,onChange:e=>l(e.target.value),className:"".concat(c," resize-y leading-relaxed")})]})}function D(e){let{label:t,hint:a,checked:l,onValue:r}=e,{disabled:o,muted:i}=N();return(0,n.jsxs)("label",{className:"flex cursor-pointer items-start gap-2",children:[(0,n.jsx)("input",{type:"checkbox",checked:l,disabled:o,onChange:e=>r(e.target.checked),className:"mt-0.5 cursor-pointer"}),(0,n.jsxs)("span",{className:"text-[12px] leading-snug",children:[t,a&&(0,n.jsx)("span",{className:"block text-[11px] ".concat(i),children:a})]})]})}function A(e){let{title:t,onRemove:a,canRemove:l,children:r}=e,{disabled:o,muted:i,border:s,iconBtn:c}=N();return(0,n.jsxs)("div",{className:"rounded-lg border p-2.5 ".concat(s),children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-[11px] font-medium uppercase tracking-wide ".concat(i),children:t}),(0,n.jsx)("button",{type:"button","aria-label":"Remove ".concat(t.toLowerCase()),disabled:o||!l,onClick:a,className:c,children:(0,n.jsx)(f.A,{className:"h-3.5 w-3.5"})})]}),(0,n.jsx)("div",{className:"space-y-2",children:r})]})}function F(e){let{onClick:t,disabled:a,children:l}=e,r=N();return(0,n.jsx)("button",{type:"button",disabled:r.disabled||a,onClick:t,className:"w-full cursor-pointer rounded-lg border border-dashed px-2 py-1.5 text-[12px] transition-colors disabled:cursor-not-allowed disabled:opacity-40 ".concat(r.border," ").concat(r.muted," ").concat(r.isDark?"hover:bg-white/5":"hover:bg-gray-50"),children:l})}function T(e){let{section:t,onReplace:a}=e,{disabled:l,muted:r,inputClass:o}=N(),i=e=>a({...t,...e});switch(t.type){case"hero":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(C,{label:"Headline",value:t.headline,rows:2,onValue:e=>i({headline:e})}),(0,n.jsx)(C,{label:"Subtext",value:t.subtext,rows:2,placeholder:"Optional supporting line",onValue:e=>i({subtext:e})}),(0,n.jsx)(S,{label:"Image URL",value:t.imageUrl,placeholder:"https://â¦",onValue:e=>i({imageUrl:e})}),t.imageUrl?(0,n.jsx)(S,{label:"Image alt text",value:t.imageAlt,onValue:e=>i({imageAlt:e})}):null]});case"text":return(0,n.jsx)(C,{label:"Body â **bold**, *italic*, [links](url), - lists, ^1 markers",value:t.markdown,rows:7,onValue:e=>i({markdown:e})});case"image":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(S,{label:"Image URL",value:t.url,placeholder:"https://â¦",onValue:e=>i({url:e})}
1),(0,n.jsx)(S,{label:"Alt text â most inboxes block images by default",value:t.alt,onValue:e=>i({alt:e})}),(0,n.jsx)(S,{label:"Caption",value:t.caption,onValue:e=>i({caption:e})}),(0,n.jsx)(S,{label:"Links to",value:t.linkUrl,placeholder:"https://â¦",onValue:e=>i({linkUrl:e})}),(0,n.jsx)(D,{label:"Full bleed",hint:"Edge to edge, no side margin",checked:!!t.fullBleed,onValue:e=>i({fullBleed:e})})]});case"cta":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(S,{label:"Button label",value:t.label,onValue:e=>i({label:e})}),(0,n.jsx)(S,{label:"Destination",value:t.url,placeholder:"https://â¦",onValue:e=>i({url:e})})]});case"stat":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(S,{label:"Value",value:t.value,placeholder:"$41,000",onValue:e=>i({value:e})}),(0,n.jsx)(S,{label:"Label",value:t.label,placeholder:"median first-year claim",onValue:e=>i({label:e})})]});case"feature":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(S,{label:"Heading",value:t.heading,onValue:e=>i({heading:e})}),(0,n.jsx)(C,{label:"Body",value:t.body,rows:4,onValue:e=>i({body:e})}),(0,n.jsx)(S,{label:"Image URL",value:t.imageUrl,placeholder:"https://â¦",onValue:e=>i({imageUrl:e})}),t.imageUrl?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(S,{label:"Image alt text",value:t.imageAlt,onValue:e=>i({imageAlt:e})}),(0,n.jsx)(D,{label:"Compact",hint:"Icon beside the heading instead of a full-width image",checked:!!t.compact,onValue:e=>i({compact:e})})]}):null,(0,n.jsx)(S,{label:"Link label",value:t.linkLabel,placeholder:"See how it works",onValue:e=>i({linkLabel:e})}),(0,n.jsx)(S,{label:"Link URL",value:t.linkUrl,placeholder:"https://â¦",onValue:e=>i({linkUrl:e})})]});case"columns":{var s;let e=t.cells,c=(n,l)=>a({...t,cells:e.map((e,t)=>t===n?{...e,...l}:e)});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"block",children:[(0,n.jsx)("span",{className:"mb-1 block text-[11px] font-medium ".concat(r),children:"Style"}),(0,n.jsxs)("select",{value:null!=(s=t.variant)?s:"card",disabled:l,onChange:e=>i({variant:e.target.value}),className:"".concat(o," cursor-pointer"),children:[(0,n.jsx)("option",{value:"card",children:"Tinted cards"}),(0,n.jsx)("option",{value:"plain",children:"Plain"})]})]}),e.map((l,r)=>(0,n.jsxs)(A,{title:"Column ".concat(r+1),canRemove:e.length>1,onRemove:()=>a({...t,cells:e.filter((e,t)=>t!==r)}),children:[(0,n.jsx)(S,{label:"Heading",value:l.heading,onValue:e=>c(r,{heading:e})}),(0,n.jsx)(C,{label:"Body",value:l.body,rows:2,onValue:e=>c(r,{body:e})}),(0,n.jsx)(S,{label:"Image URL",value:l.imageUrl,placeholder:"https://â¦",onValue:e=>c(r,{imageUrl:e})}),l.imageUrl?(0,n.jsx)(S,{label:"Image alt text",value:l.imageAlt,onValue:e=>c(r,{imageAlt:e})}):null,(0,n.jsx)(S,{label:"Links to",value:l.linkUrl,placeholder:"https://â¦",onValue:e=>c(r,{linkUrl:e})})]},r)),(0,n.jsx)(F,{disabled:e.length>=4,onClick:()=>a({...t,cells:[...e,{heading:"",body:""}]}),children:e.length>=4?"Maximum of four columns":"Add column"})]})}case"quote":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(C,{label:"Quote",value:t.text,rows:4,onValue:e=>i({text:e})}),(0,n.jsx)(S,{label:"Attribution",value:t.attribution,placeholder:"Head of Growth",onValue:e=>i({attribution:e})})]});case"code":return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(S,{label:"Label",value:t.label,placeholder:"Save this code",onValue:e=>i({label:e})}),(0,n.jsx)(S,{label:"Code",value:t.value,mono:!0,onValue:e=>i({value:e})}),(0,n.jsx)(S,{label:"Caption",value:t.caption,placeholder:"Valid until 27 August. Terms apply.",onValue:e=>i({caption:e})})]});case"footnotes":{let e=t.items,l=(n,l)=>a({...t,items:e.map((e,t)=>t===n?{...e,...l}:e)});return(0,n.jsxs)(n.Fragment,{children:[e.map((r,o)=>(0,n.jsxs)(A,{title:"Note ".concat(o+1),canRemove:e.length>1,onRemove:()=>a({...t,items:e.filter((e,t)=>t!==o)}),children:[(0,n.jsx)(S,{label:"Marker â matches ^1 in the copy above",value:r.marker,onValue:e=>l(o,{marker:e})}),(0,n.jsx)(C,{label:"Text",value:r.text,rows:3,onValue:e=>l(o,{text:e})})]},o)),(0,n.jsx)(F,{onClick:()=>a({...t,items:[...e,{marker:String(e.length+1),text:""}]}),children:"Add note"})]})}case"divider":return(0,n.jsx)("p",{className:"text-[12px] ".concat(r),children:"A horizontal rule. Nothing to configure."});default:throw Error("Unhandled section: ".concat(JSON.stringify(t)))}}function U(e){let{sections:t,onChange:a,disabled:r=!1,isDark:o=!1}=e,[i,s]=(0,l.useState)(null),[c,d]=(0,l.useState)("text"),u=(0,l.useMemo)(()=>{let e=o?"text-gray-400":"text-gray-500",t=o?"border-white/10":"border-gray-200",a=o?"bg-white/[0.04] border-white/15 text-gray-100 placeholder:text-gray-500":"bg-white border-gray-200 text-gray-900 placeholder:text-gray-400";return{disabled:r,isDark:o,muted:e,border:t,inputClass:"w-full rounded-lg border px-2.5 py-1.5 text-[13px] outline-none focus:border-gray-400 disabled:opacity-60 ".concat(a),iconBtn:"cursor-pointer rounded p-1 transition-colors disabled:cursor-not-allowed disabled:opacity-30 ".concat(o?"text-gray-400 hover:bg-white/10":"text-gray-500 hover:bg-gray-100")}},[r,o]),p=(e,n)=>{let l=e+n;if(l<0||l>=t.length)return;let r=t.slice();[r[e],r[l]]=[r[l],r[e]],a(r),i===e?s(l):i===l&&s(e)};return(0,n.jsx)(j.Provider,{value:u,children:(0,n.jsxs)("div",{className:"space-y-2",children:[0===t.length&&(0,n.jsx)("p",{className:"rounded-lg border border-dashed px-3 py-4 text-center text-[12px] ".concat(u.border," ").concat(u.muted),children:"No sections yet. Add one below, or generate from your brief."}),t.map((e,l)=>{let c=i===l,d=function(e){switch(e.type){case"hero":return e.headline;case"text":return e.markdown.replace(/\s+/g," ").trim();case"image":return e.alt||e.url;case"cta":return e.label;
1case"stat":return[e.value,e.label].filter(Boolean).join(" â ");case"feature":return e.heading;case"columns":return e.cells.map(e=>e.heading||"â").join(" \xb7 ");case"quote":return e.text;case"code":return e.value;case"footnotes":return"".concat(e.items.length," note").concat(1===e.items.length?"":"s");case"divider":return"";default:throw Error("Unhandled section: ".concat(JSON.stringify(e)))}}(e);return(0,n.jsxs)("div",{className:"overflow-hidden rounded-lg border ".concat(u.border),children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 ".concat(o?"bg-white/[0.03]":"bg-gray-50"),children:[(0,n.jsxs)("button",{type:"button",onClick:()=>s(c?null:l),"aria-expanded":c,className:"flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 text-left",children:[c?(0,n.jsx)(b.A,{className:"h-3.5 w-3.5 shrink-0 ".concat(u.muted)}):(0,n.jsx)(x.A,{className:"h-3.5 w-3.5 shrink-0 ".concat(u.muted)}),(0,n.jsx)("span",{className:"shrink-0 text-[11px] font-semibold uppercase tracking-wide",children:w[e.type]}),d&&(0,n.jsx)("span",{className:"truncate text-[11px] ".concat(u.muted),children:d})]}),(0,n.jsx)("button",{type:"button","aria-label":"Move up",disabled:r||0===l,onClick:()=>p(l,-1),className:u.iconBtn,children:(0,n.jsx)(b.A,{className:"h-3.5 w-3.5 rotate-180"})}),(0,n.jsx)("button",{type:"button","aria-label":"Move down",disabled:r||l===t.length-1,onClick:()=>p(l,1),className:u.iconBtn,children:(0,n.jsx)(b.A,{className:"h-3.5 w-3.5"})}),(0,n.jsx)("button",{type:"button","aria-label":"Duplicate section",disabled:r,onClick:()=>(e=>{let n=t.slice();n.splice(e+1,0,structuredClone(t[e])),a(n),s(e+1)})(l),className:u.iconBtn,children:(0,n.jsx)(y.A,{className:"h-3.5 w-3.5"})}),(0,n.jsx)("button",{type:"button","aria-label":"Delete section",disabled:r,onClick:()=>{a(t.filter((e,t)=>t!==l)),i===l?s(null):null!==i&&i>l&&s(i-1)},className:"cursor-pointer rounded p-1 transition-colors disabled:cursor-not-allowed disabled:opacity-30 ".concat(o?"text-red-400 hover:bg-red-500/10":"text-red-500 hover:bg-red-50"),children:(0,n.jsx)(f.A,{className:"h-3.5 w-3.5"})})]}),c&&(0,n.jsx)("div",{className:"space-y-2.5 p-2.5",children:(0,n.jsx)(T,{section:e,onReplace:e=>((e,n)=>{let l=t.slice();l[e]=n,a(l)})(l,e)})})]},l)}),!r&&(0,n.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,n.jsx)("select",{value:c,onChange:e=>d(e.target.value),"aria-label":"Section type to add",className:"".concat(u.inputClass," flex-1 cursor-pointer"),children:k.map(e=>(0,n.jsx)("option",{value:e,children:w[e]},e))}),(0,n.jsxs)("button",{type:"button",onClick:()=>{a([...t,function(e){switch(e){case"hero":return{type:"hero",headline:"Headline",subtext:""};case"text":return{type:"text",markdown:""};case"image":return{type:"image",url:"",alt:""};case"cta":return{type:"cta",label:"Learn more",url:""};case"stat":return{type:"stat",value:"",label:""};case"feature":return{type:"feature",heading:"Feature",body:""};case"columns":return{type:"columns",variant:"card",cells:[{heading:"",body:""},{heading:"",body:""}]};case"quote":return{type:"quote",text:"",attribution:""};case"code":return{type:"code",value:"",label:"",caption:""};case"footnotes":return{type:"footnotes",items:[{marker:"1",text:""}]};case"divider":return{type:"divider"};default:throw Error("Unhandled section type: ".concat(String(e)))}}(c)]),s(t.length)},className:"flex shrink-0 cursor-pointer items-center gap-1 rounded-lg border px-2.5 py-1.5 text-[12px] font-medium transition-colors ".concat(u.border," ").concat(o?"hover:bg-white/5":"hover:bg-gray-50"),children:[(0,n.jsx)(v.A,{className:"h-3.5 w-3.5"}),"Add"]})]})]})})}let Z=[{label:"System sans",stack:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif"},{label:"Helvetica",stack:"'Helvetica Neue', Helvetica, Arial, sans-serif"},{label:"Georgia (serif)",stack:"Georgia, 'Times New Roman', serif"},{label:"Times (serif)",stack:"'Times New Roman', Times, serif"},{label:"Courier (mono)",stack:"'Courier New', Courier, monospace"}],E=["14px","15px","16px","17px","18px"];function L(e){var t,a,l,r,o;let{palette:i,typography:s,brand:c,social:d,onPalette:u,onTypography:p,onBrand:m,onSocial:h,disabled:g=!1,isDark:b=!1}=e,x=b?"text-gray-400":"text-gray-500",y=b?"border-white/10":"border-gray-200",w="w-full rounded-lg border px-2.5 py-1.5 text-[13px] outline-none focus:border-gray-400 disabled:opacity-60 ".concat(b?"bg-white/[0.04] border-white/15 text-gray-100 placeholder:text-gray-500":"bg-white border-gray-200 text-gray-900 placeholder:text-gray-400"),k=[{key:"background",label:"Backgroun
1d",hint:"Keep it light â most clients ignore dark-mode CSS",value:i.background||"#ffffff"},{key:"primaryText",label:"Body text",hint:"",value:i.primaryText||i.textDark||"#111111"},{key:"accent",label:"Accent",hint:"Buttons and links. Needs to carry white type.",value:i.accent||"#1a1a1a"},{key:"cardBackground",label:"Card surface",hint:"Tinted columns, code blocks, quotes",value:i.cardBackground||i.secondary||"#f1f1ef"}],j="mb-1 block text-[11px] font-medium ".concat(x);return(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"space-y-2 border-b pb-3 ".concat(y),children:[(0,n.jsx)("label",{className:j,children:"Logo URL"}),(0,n.jsx)("input",{value:null!=(a=null==c?void 0:c.logoUrl)?a:"",disabled:g,placeholder:"https://â¦/logo.png",onChange:e=>m({logoUrl:e.target.value}),className:w}),(null==c||null==(t=c.logoUrl)?void 0:t.trim())?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,n.jsxs)("label",{className:"block",children:[(0,n.jsx)("span",{className:j,children:"Width (px)"}),(0,n.jsx)("input",{type:"number",min:24,max:600,value:null!=(l=null==c?void 0:c.logoWidth)?l:140,disabled:g,onChange:e=>m({logoWidth:Number(e.target.value)||140}),className:w})]}),(0,n.jsxs)("label",{className:"block",children:[(0,n.jsx)("span",{className:j,children:"Alt text"}),(0,n.jsx)("input",{value:null!=(r=null==c?void 0:c.logoAlt)?r:"",disabled:g,placeholder:"Your company",onChange:e=>m({logoAlt:e.target.value}),className:w})]})]}),(0,n.jsxs)("label",{className:"block",children:[(0,n.jsx)("span",{className:j,children:"Logo links to"}),(0,n.jsx)("input",{value:null!=(o=null==c?void 0:c.linkUrl)?o:"",disabled:g,placeholder:"https://â¦",onChange:e=>m({linkUrl:e.target.value}),className:w})]})]}):null]}),k.map(e=>{var t;return(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"mb-1 block text-[11px] font-medium ".concat(x),children:e.label}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{type:"color","aria-label":"".concat(e.label," colour picker"),value:(t=e.value,/^#[0-9a-f]{6}$/i.test(t.trim()))?e.value:"#ffffff",disabled:g,onChange:t=>u({[e.key]:t.target.value}),className:"h-8 w-10 shrink-0 cursor-pointer rounded border bg-transparent p-0.5 disabled:opacity-60 ".concat(y)}),(0,n.jsx)("input",{value:e.value,disabled:g,onChange:t=>u({[e.key]:t.target.value}),className:"".concat(w," font-mono")})]}),e.hint&&(0,n.jsx)("p",{className:"mt-1 text-[11px] ".concat(x),children:e.hint})]},e.key)}),(0,n.jsxs)("div",{className:"space-y-3 border-t pt-3 ".concat(y),children:[(0,n.jsxs)("label",{className:"block",children:[(0,n.jsx)("span",{className:"mb-1 block text-[11px] font-medium ".concat(x),children:"Headline font"}),(0,n.jsxs)("select",{value:s.headlineFont,disabled:g,onChange:e=>p({headlineFont:e.target.value}),className:"".concat(w," cursor-pointer"),children:[!Z.some(e=>e.stack===s.headlineFont)&&(0,n.jsx)("option",{value:s.headlineFont,children:"Custom"}),Z.map(e=>(0,n.jsx)("option",{value:e.stack,children:e.label},e.label))]})]}),(0,n.jsxs)("label",{className:"block",children:[(0,n.jsx)("span",{className:"mb-1 block text-[11px] font-medium ".concat(x),children:"Body font"}),(0,n.jsxs)("select",{value:s.bodyFont,disabled:g,onChange:e=>p({bodyFont:e.target.value}),className:"".concat(w," cursor-pointer"),children:[!Z.some(e=>e.stack===s.bodyFont)&&(0,n.jsx)("option",{value:s.bodyFont,children:"Custom"}),Z.map(e=>(0,n.jsx)("option",{value:e.stack,children:e.label},e.label))]})]}),(0,n.jsxs)("label",{className:"block",children:[(0,n.jsx)("span",{className:"mb-1 block text-[11px] font-medium ".concat(x),children:"Body size"}),(0,n.jsxs)("select",{value:s.bodySize,disabled:g,onChange:e=>p({bodySize:e.target.value}),className:"".concat(w," cursor-pointer"),children:[!E.includes(s.bodySize)&&(0,n.jsx)("option",{value:s.bodySize,children:s.bodySize}),E.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]})]})]}),(0,n.jsxs)("div",{className:"space-y-2 border-t pt-3 ".concat(y),children:[(0,n.jsx)("label",{className:j,children:"Footer links"}),d.map((e,t)=>(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{value:e.label,disabled:g,placeholder:"LinkedIn",onChange:e=>h(d.map((a,n)=>n===t?{...a,label:e.target.value}:a)),className:"".concat(w," w-24 shrink-0")}),(0,n.jsx)("input",{value:e.url,disabled:g,placeholder:"https://â¦",onChange:e=>h(d.map((a,n)=>n===t?{...a,url:e.target.value}:a)),className:w}),(0,n.jsx)("button",{type:"button","aria-label":"Remove footer link ".concat(t+1),disabled:g,onClick:()=>h(d.filter((e,a)=>a!==t)),className:"shrink-0 cursor-pointer rounded p-1 transition-colors disabled:opacity-40 ".concat(b?"text-gray-400 hover:bg-white/10":"text-gray-500 hover:bg-gray-100"),children:(0,n.jsx)(f.A,{className:"h-3.5 w-3.5"})})]},t)),(0,n.jsxs)("button",{type:"button",disabled:g,onClick:()=>h([...d,{label:"",url:""}]),className:"flex cursor-pointer items-center gap-1 rounded-lg border border-dashed px-2 py-1.5 text-[12px] transition-colors disabled:opacity-40 ".concat(y," ").concat(x," ").concat(b?"hover:bg-white/5":"hover:bg-gray-50"),children:[(0,n.jsx)(v.A,{className:"h-3.5 w-3.5"}),"Add link"]}),(0,n.jsx)("p",{className:"text-[11px] leading-relaxed ".concat(x),children:"Rendered as text, not icons â images are blocked by default in most inboxes, so an icon-only row shows up as a line of empty boxes."})]}),(0,n.jsx)("p",{className:"text-[11px] leading-relaxed ".concat(x),children:"Email clients only render fonts installed on the readerâs machine, so each option is a stack that falls back gracefully. Web fonts are not used."})]})}var R=a(99259),B=a(82108);let z=[{id:"setup",label:"Setup"},{id:"content",label:"Content"},{id:"style",label:"Style"}],H=[{id:"announcement",label:"Announcement"},{id:"education",label:"Educational"}
1,{id:"roundup",label:"Roundup"},{id:"promotion",label:"Promotion"},{id:"story",label:"Story"}];function I(e){var t,a,u,m,f,b;let{open:x,onClose:y,existing:v,seed:w,isDark:k=!1,onSave:j,onDelete:N,defaultSenderName:S="",defaultMailingAddress:C="",userEmail:D=null,userName:A=null,templateAuthoring:F=!1,initialTemplateMeta:T,onSaveAdminTemplate:Z}=e,[E,I]=(0,l.useState)(!1),[_,M]=(0,l.useState)(""),[O,q]=(0,l.useState)("education"),[P,V]=(0,l.useState)(null),[W,$]=(0,l.useState)(!1),[Y,G]=(0,l.useState)(!1),[J,K]=(0,l.useState)(!1),[X,Q]=(0,l.useState)("setup"),[ee,et]=(0,l.useState)(""),[ea,en]=(0,l.useState)(""),[el,er]=(0,l.useState)(""),[eo,ei]=(0,l.useState)(()=>(0,R.H)({senderName:S,mailingAddress:C})),[es,ec]=(0,l.useState)(null),[ed,eu]=(0,l.useState)(null),[ep,em]=(0,l.useState)([]),[eh,eg]=(0,l.useState)(""),ef=(0,l.useRef)(null),eb=(0,l.useRef)(!1),ex=(0,l.useRef)(!1),ey=(0,l.useRef)(async()=>!0),ev=(0,l.useMemo)(()=>(0,d.gf)({email:D,fullName:A}),[D,A]),[ew,ek]=(0,l.useState)(null),ej=(0,l.useCallback)(e=>{ek(t=>(null==t?void 0:t.leadId)===e.leadId&&t.label===e.label?t:e)},[]),eN=(0,l.useMemo)(()=>{var e;return P?(0,d.MP)(P,null!=(e=null==ew?void 0:ew.context)?e:ev):null},[P,ew,ev]);(0,l.useEffect)(()=>I(!0),[]),(0,l.useEffect)(()=>{ei(e=>(0,R.H)({senderName:S,mailingAddress:C},e))},[S,C]),(0,l.useEffect)(()=>{if(!x||F)return;let e=!1;return fetch("/api/newsletter-drafts/footer-defaults",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&ei(e=>{var a,n;return(0,R.H)({senderName:(null==(a=t.senderName)?void 0:a.trim())||"",mailingAddress:(null==(n=t.mailingAddress)?void 0:n.trim())||""},e)})}).catch(()=>{}),()=>{e=!0}},[x,F]);let eS=(null==v?void 0:v.status)==="published"||(null==v?void 0:v.status)==="publishing",eC=(null==P?void 0:P.customHtml)!=null;(0,l.useEffect)(()=>{var e,t,a,n,l,r,o,i,s;if(!x)return;let c=null==v?void 0:v.platform_specific_content;if(null==c?void 0:c.newsletter){let l=null!=(a=null==(e=c.inputs)?void 0:e.userDescription)?a:"",r=null!=(n=null==(t=c.inputs)?void 0:t.goal)?n:"education";M(l),q(r),V(c.newsletter),Q("content")}else if(w){let e=structuredClone(w.data);M(w.brief),q(w.goal),V(e),Q("content")}else V(null),M(""),q("education"),Q("setup");et(null!=(l=null==T?void 0:T.id)?l:""),en(null!=(r=null==T?void 0:T.name)?r:""),er(null!=(o=null==T?void 0:T.blurb)?o:""),K(!1),ef.current=null!=(i=null==v?void 0:v.id)?i:null,ec(null!=(s=null==v?void 0:v.id)?s:null);let d=null==c?void 0:c.audience;eg(d&&"leads_filter"===d.kind&&d.savedFilterId?d.savedFilterId:""),eu(v?(0,B.RV)(v.scheduled_at,v.status):null)},[x,v,w,T]),(0,l.useEffect)(()=>{if(!x||F)return;let e=!1;return fetch("/api/scorecard/saved-filters",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(t=>{!e&&(null==t?void 0:t.filters)&&em(t.filters.map(e=>({id:e.id,label:e.label,filters:e.filters})))}).catch(()=>{}),()=>{e=!0}},[x,F]),(0,l.useEffect)(()=>{if(!x||!F||!P)return;let e=(0,s.vz)({data:P,brief:_,goal:O});et(t=>t.trim()?t:e.id),en(t=>t.trim()?t:e.name),er(t=>t.trim()?t:e.blurb)},[x,F,P,_,O]),(0,l.useEffect)(()=>{x&&P&&!eS&&!F&&V(e=>{if(!e)return e;let t=(0,s.ud)(e,{brief:_,goal:O,defaultSenderName:eo.senderName,defaultMailingAddress:eo.mailingAddress});return t.preheader===e.preheader&&t.footer.senderName===e.footer.senderName&&t.footer.mailingAddress===e.footer.mailingAddress?e:t})},[x,P,_,O,eo.senderName,eo.mailingAddress,eS,F]),(0,l.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&ey.current({close:!0,silent:!0})};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x]);let eD=(0,l.useMemo)(()=>({userDescription:_,goal:O}),[_,O]),eA=async function(e){var t,a,n,l,r,i,c,d,u,p,m,h,g,f,b;let x=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},w=null!=(n=x.status)?n:"draft",k=null!=(l=x.close)&&l,N=null!=(r=x.silent)&&r;if(F||eS||!e||"draft"===w&&!(0,s.yv)(e,_))return k&&y(),!0;if(eb.current)return k&&(ex.current=!0),!1;let S=eo;if(!(null==(a=e.footer)||null==(t=a.mailingAddress)?void 0:t.trim())&&!S.mailingAddress.trim())try{let e=await fetch("/api/newsletter-drafts/footer-defaults",{cache:"no-store"});if(e.ok){let t=await e.json();S=(0,R.H)({senderName:(null==(i=t.senderName)?void 0:i.trim())||"",mailingAddress:(null==(c=t.mailingAddress)?void 0:c.trim())||""},S),ei(e=>(0,R.H)(S,e))}}catch(e){}let C=(0,s.fB)(e,{brief:_,goal:O,defaultSenderName:S.senderName,defaultMailingAddress:S.mailingAddress});if("scheduled"===w){if(!eh)return o.o.error("Choose a saved lead segment in Setup."),Q("setup"),!1;if(!ed)return o.o.error("Pick a date and time for this send."),!1;if(!(null==(d=C.subject)?void 0:d.trim()))return o.o.error("Subject is required â add one in Setup or write a hero headline."),!1;if(!(null==(u=C.footer.senderName)?void 0:u.trim()))return o.o.error("From name is required â add it in Setup, or add your company to the Knowledge Base."),!1;if(!(null==(p=C.footer.mailingAddress)?void 0:p.trim()))return o.o.error("Mailing address is required â add it in Setup (CASL). Put your office address in the Knowledge Base to auto-fill next time."),
1!1}let D=!!(null!=(m=ef.current)?m:null==v?void 0:v.id);eb.current=!0,G(!0);try{V(C),((null==(h=C.footer.senderName)?void 0:h.trim())||(null==(g=C.footer.mailingAddress)?void 0:g.trim()))&&(0,R.rc)({senderName:C.footer.senderName,mailingAddress:C.footer.mailingAddress});let e=ep.find(e=>e.id===eh),t=e?{kind:"leads_filter",savedFilterId:e.id,filterState:e.filters,includeUnknownConsent:!1}:void 0,a=await j({newsletter:C,inputs:eD,...N&&D?{}:{status:w,scheduledAt:null!=(f=null==ed?void 0:ed.date.toISOString())?f:new Date().toISOString(),...t?{audience:t}:{}}},null!=(b=ef.current)?b:null==v?void 0:v.id),n=a&&"object"==typeof a&&"id"in a?String(a.id):null;return n&&(ef.current=n,ec(n)),k?(N||o.o.success("scheduled"===w&&ed?"Scheduled for ".concat((0,B.xH)(ed.date)):D?"Newsletter updated":"Saved to drafts"),y()):N||o.o.success(D?"Newsletter updated":"Newsletter saved"),!0}catch(e){return ex.current=!1,o.o.error(e instanceof Error?e.message:"Failed to save"),!1}finally{eb.current=!1,G(!1),ex.current&&(ex.current=!1,y())}};ey.current=e=>eA(P,e);let eF=async e=>{if(!W){$(!0);try{var t,a,n,l;let r=await fetch("/api/generate-newsletter",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userDescription:_,goal:O,...e&&P?{currentNewsletter:P,refinementInstruction:e}:{}})}),o=await r.json().catch(()=>({}));if(!r.ok)throw Error(o.error||"Generation failed");let i=o.newsletter,c=(0,s.ud)({...i,customHtml:null,brand:null!=(a=null!=(t=null==P?void 0:P.brand)?t:i.brand)?a:null,footer:{...i.footer,social:null!=(l=null!=(n=null==P?void 0:P.footer.social)?n:i.footer.social)?l:null,senderName:(null==P?void 0:P.footer.senderName)||i.footer.senderName||"",mailingAddress:(null==P?void 0:P.footer.mailingAddress)||""}},{brief:_,goal:O,defaultSenderName:eo.senderName,defaultMailingAddress:eo.mailingAddress});V(c),F||eA(c,{silent:!0})}catch(e){o.o.error(e instanceof Error?e.message:"Generation failed")}finally{$(!1)}}},eT=e=>{V((0,s.ud)((0,i.E)({customHtml:e?"":null}),{brief:_,goal:O,defaultSenderName:eo.senderName,defaultMailingAddress:eo.mailingAddress})),Q("content")},eU=async()=>{if(!P)return;let e=(0,s.vz)({data:P,brief:_,goal:O}),t=(0,s.X4)({id:(0,s.DC)(ee)||e.id,name:ea.trim()||e.name,blurb:el.trim()||e.blurb,brief:_,goal:O,data:P}),a=await (0,s.zG)(t);o.o[a?"success":"error"](a?"Template JSON copied":"Could not copy â check clipboard permissions")},eZ=async e=>{P&&await eA(P,{status:e,close:!0,silent:!1})},eE=async()=>{var e;let t=null!=(e=ef.current)?e:null==v?void 0:v.id;if(t&&N)try{await N(t),o.o.success("Newsletter deleted"),y()}catch(e){o.o.error(e instanceof Error?e.message:"Failed to delete")}};if(!E||!x)return null;let eL=k?"bg-[#15161a] text-gray-100":"bg-white text-gray-900",eR=k?"border-white/10":"border-gray-200",eB=k?"bg-white/[0.04] border-white/15 text-gray-100 placeholder:text-gray-500":"bg-white border-gray-200 text-gray-900 placeholder:text-gray-400",ez=k?"text-gray-400":"text-gray-500";return(0,r.createPortal)((0,n.jsx)("div",{className:"fixed inset-0 z-[9995] flex items-center justify-center bg-black/50 p-4",onClick:()=>void eA(P,{close:!0,silent:!0}),role:"dialog","aria-modal":"true","aria-label":v?"Edit newsletter":"New newsletter",children:(0,n.jsx)(p,{children:(0,n.jsxs)("div",{className:"flex h-full max-h-[90vh] w-full max-w-6xl overflow-hidden rounded-2xl shadow-2xl ".concat(eL),onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex w-[400px] shrink-0 flex-col border-r ".concat(eR),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between border-b ".concat(eR," px-4 py-3"),children:[(0,n.jsx)("h2",{className:"text-sm font-semibold",children:F?(null==T?void 0:T.id)?"Edit template":"New template":v?"Edit newsletter":"New newsletter"}),eS&&(0,n.jsx)("span",{className:"text-[11px] uppercase tracking-wide ".concat(ez),children:"Sent â read only"})]}),P&&(0,n.jsx)("div",{className:"flex shrink-0 gap-1 border-b ".concat(eR," px-3 py-2"),children:z.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>Q(e.id),"aria-current":X===e.id,className:"flex-1 cursor-pointer rounded-md px-2 py-1.5 text-xs font-medium transition-colors ".concat(X===e.id?k?"bg-white/10 text-white":"bg-gray-900/[0.07] text-gray-900":k?"text-gray-400 hover:bg-white/5":"text-gray-500 hover:bg-gray-50"),children:e.label},e.id))}),(0,n.jsxs)("div",{className:"flex-1 space-y-4 overflow-y-auto p-4",children:[(!P||"setup"===X)&&(0,n.jsxs)(n.Fragment,{children:[F&&(0,n.jsxs)("div",{className:"space-y-3 rounded-lg border p-3 ".concat(eR),children:[(0,n.jsx)("p",{className:"text-[11px] leading-relaxed ".concat(ez),children:"Gallery metadata auto-fills from subject, preview text, and your brief. Edit any field before saving."}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"mb-1.5 block text-xs font-medium ".concat(ez),children:"Template ID"}),(0,n.jsx)("input",{value:ee,onChange:e=>et(e.target.value),placeholder:"product-launch",className:"w-full rounded-lg border px-3 py-2 text-sm outline-none focus:border-gray-400 ".concat(eB)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"mb-1.5 block text-xs font-medium ".concat(ez),children:"Display name"}),(0,n.jsx)("input",{value:ea,onChange:e=>en(e.target.value),placeholder:"Product launch",className:"w-full rounded-lg border px-3 py-2 text-sm outline-none focus:border-gray-400 ".concat(eB)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"mb-1.5 block text-xs font-medium ".concat(ez),children:"Tile blurb"}),(0,n.jsx)("input",{value:el,onChange:e=>er(e.target.value),placeholder:"One line for the gallery under the thumbnail.",className:"w-full rounded-lg border px-3 py-2 text-sm outline-none focus:border-gray-400 ".concat(eB)})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"mb-1.5 block text-xs font-medium ".concat(ez),children:"What is it about?"}
1),(0,n.jsx)("textarea",{value:_,onChange:e=>M(e.target.value),disabled:eS,rows:5,placeholder:"Three grant programs closing this month, and what SR&ED actually pays outâ¦",className:"w-full resize-none rounded-lg border px-3 py-2 text-sm outline-none focus:border-gray-400 disabled:opacity-60 ".concat(eB)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"mb-1.5 block text-xs font-medium ".concat(ez),children:"Goal"}),(0,n.jsx)("div",{className:"flex flex-wrap gap-1.5",children:H.map(e=>(0,n.jsx)("button",{type:"button",disabled:eS,onClick:()=>q(e.id),className:"cursor-pointer rounded-full border px-2.5 py-1 text-xs transition-colors disabled:opacity-60 ".concat(O===e.id?k?"border-white/30 bg-white/10 text-white":"border-gray-300 bg-gray-900/[0.06] text-gray-900":k?"border-white/10 text-gray-400 hover:bg-white/5":"border-gray-200 text-gray-600 hover:bg-gray-50"),children:e.label},e.id))})]}),!eS&&(0,n.jsx)("button",{type:"button",onClick:()=>eF(),disabled:W||!_.trim(),className:"w-full cursor-pointer rounded-lg px-3 py-2.5 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-40 ".concat(k?"bg-white text-gray-900 hover:bg-gray-200":"bg-gray-900 text-white hover:bg-gray-700"),children:W?"Writingâ¦":P?"Regenerate":"Generate newsletter"}),!P&&!eS&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("div",{className:"h-px flex-1 ".concat(k?"bg-white/10":"bg-gray-200")}),(0,n.jsx)("span",{className:"text-[11px] uppercase tracking-wide ".concat(ez),children:"or"}),(0,n.jsx)("div",{className:"h-px flex-1 ".concat(k?"bg-white/10":"bg-gray-200")})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,n.jsx)("button",{type:"button",onClick:()=>eT(!1),className:"cursor-pointer rounded-lg border px-3 py-2 text-sm transition-colors ".concat(eR," ").concat(k?"hover:bg-white/5":"hover:bg-gray-50"),children:"Write it myself"}),(0,n.jsx)("button",{type:"button",onClick:()=>eT(!0),className:"cursor-pointer rounded-lg border px-3 py-2 text-sm transition-colors ".concat(eR," ").concat(k?"hover:bg-white/5":"hover:bg-gray-50"),children:"Paste HTML"})]})]}),P&&(0,n.jsxs)("div",{className:"space-y-3 border-t pt-4 ".concat(eR),children:[!eS&&!F&&(0,n.jsx)("p",{className:"text-[11px] leading-relaxed ".concat(ez),children:"Subject, preview text, and footer fields auto-fill from your content and account settings. Edit anything before you save."}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"mb-1.5 block text-xs font-medium ".concat(ez),children:"Subject"}),(0,n.jsx)(h,{value:P.subject,disabled:eS,onChange:e=>V({...P,subject:e}),placeholder:"Hi {{first_name|there}}",className:"w-full rounded-lg border px-3 py-2 text-sm outline-none focus:border-gray-400 disabled:opacity-60 ".concat(eB)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"mb-1.5 block text-xs font-medium ".concat(ez),children:"Preview text"}),(0,n.jsx)(h,{value:P.preheader,disabled:eS,onChange:e=>V({...P,preheader:e}),className:"w-full rounded-lg border px-3 py-2 text-sm outline-none focus:border-gray-400 disabled:opacity-60 ".concat(eB)})]}),!eS&&!F&&(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"mb-1.5 block text-xs font-medium ".concat(ez),children:"Lead segment"}),(0,n.jsxs)("select",{value:eh,onChange:e=>eg(e.target.value),className:"w-full rounded-lg border px-3 py-2 text-sm outline-none focus:border-gray-400 ".concat(eB),children:[(0,n.jsx)("option",{value:"",children:"Choose a saved filterâ¦"}),ep.map(e=>(0,n.jsx)("option",{value:e.id,children:e.label},e.id))]}),(0,n.jsx)("p",{className:"mt-1.5 text-[11px] leading-relaxed ".concat(ez),children:"The same saved filters as the lead list. Scheduling copies that filter, so later edits to the view do not change a send that is already queued. Leads with unknown consent are left out."})]}),!eS&&(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,n.jsxs)("p",{className:"text-[11px] leading-relaxed ".concat(ez),children:["Use ","{{first_name|there}}"," and the preview fills it from you or a lead."]}),(0,n.jsx)(g,{isDark:k})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("label",{className:"mb-1.5 block text-xs font-medium ".concat(ez),children:["From name ",(0,n.jsx)("span",{className:"opacity-70",children:"(required in every email)"})]}),(0,n.jsx)("input",{value:P.footer.senderName,disabled:eS,onChange:e=>V({...P,footer:{...P.footer,senderName:e.target.value}}),placeholder:"Upgraded Inc.",className:"w-full rounded-lg border px-3 py-2 text-sm outline-none focus:border-gray-400 disabled:opacity-60 ".concat(eB)})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("label",{className:"mb-1.5 block text-xs font-medium ".concat(ez),children:["Mailing address ",(0,n.jsx)("span",{className:"opacity-70",children:"(required in every email)"})]}),(0,n.jsx)("input",{value:P.footer.mailingAddress,disabled:eS,onChange:e=>V({...P,footer:{...P.footer,mailingAddress:e.target.value}}),placeholder:"1055 W Georgia St, Vancouver, BC",className:"w-full rounded-lg border px-3 py-2 text-sm outline-none focus:border-gray-400 disabled:opacity-60 ".concat(eB)})]}),(0,n.jsx)(c.W,{subject:null!=(t=null==eN?void 0:eN.subject)?t:P.subject,preheader:null!=(a=null==eN?void 0:eN.preheader)?a:P.preheader,senderName:null!=(u=null==eN?void 0:eN.footer.senderName)?u:P.footer.senderName,isDark:k}
1),(null==ew?void 0:ew.leadId)&&(0,n.jsxs)("p",{className:"text-[10px] ".concat(ez),children:["Inbox line previewed as ",ew.label,"."]})]})]}),P&&"content"===X&&(eC?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("label",{className:"text-xs font-medium ".concat(ez),children:"Email HTML"}),(0,n.jsx)("button",{type:"button",disabled:eS,onClick:()=>{var e;(null==(e=P.customHtml)||!e.trim()||window.confirm("Discard the pasted HTML and switch to blocks?"))&&V({...P,customHtml:null})},className:"cursor-pointer text-[11px] underline disabled:opacity-40 ".concat(ez),children:"Switch to blocks"})]}),(0,n.jsx)("div",{className:"flex justify-end",children:!eS&&(0,n.jsx)(g,{isDark:k})}),(0,n.jsx)(h,{multiline:!0,rows:24,spellCheck:!1,value:null!=(m=P.customHtml)?m:"",disabled:eS,onChange:e=>V({...P,customHtml:e}),placeholder:'<table role="presentation" width="600">\n <tr><td>â¦</td></tr>\n</table>',className:"w-full resize-y rounded-lg border px-3 py-2 font-mono text-[11px] leading-relaxed outline-none focus:border-gray-400 disabled:opacity-60 ".concat(eB)}),(0,n.jsxs)("p",{className:"text-[11px] leading-relaxed ".concat(ez),children:["Paste a full email or a fragment â the surrounding"," ",(0,n.jsx)("code",{children:"<html>"})," and ",(0,n.jsx)("code",{children:"<head>"})," are unwrapped for you, and head styles are kept so media queries still work. Scripts, forms and unsafe links are stripped when you save. Your footer, mailing address and unsubscribe link are still added below whatever you paste."]})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[!eS&&(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)(g,{isDark:k})}),(0,n.jsx)(U,{sections:P.sections,disabled:eS,isDark:k,onChange:e=>V({...P,sections:e})}),!eS&&(0,n.jsx)("button",{type:"button",onClick:()=>V({...P,customHtml:""}),className:"cursor-pointer text-[11px] underline ".concat(ez),children:"Paste HTML instead"})]})),P&&"style"===X&&(0,n.jsx)(L,{palette:P.palette,typography:P.typography,brand:P.brand,social:null!=(f=P.footer.social)?f:[],disabled:eS,isDark:k,onPalette:e=>V({...P,palette:{...P.palette,...e}}),onTypography:e=>V({...P,typography:{...P.typography,...e}}),onBrand:e=>V({...P,brand:{...P.brand,...e}}),onSocial:e=>V({...P,footer:{...P.footer,social:e}})})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 border-t ".concat(eR," p-3"),children:[(v||es)&&N&&!eS&&(0,n.jsx)("button",{type:"button",onClick:()=>J?eE():K(!0),onBlur:()=>K(!1),className:"cursor-pointer rounded-lg px-3 py-2 text-sm transition-colors ".concat(J?"bg-red-600 text-white hover:bg-red-700":k?"text-red-400 hover:bg-red-500/10":"text-red-600 hover:bg-red-50"),children:J?"Confirm delete":"Delete"}),(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsx)("button",{type:"button",onClick:()=>void eA(P,{close:!0,silent:!0}),className:"cursor-pointer rounded-lg px-3 py-2 text-sm ".concat(ez," hover:").concat(k?"bg-white/5":"bg-gray-100"),children:"Close"}),F&&Z&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",onClick:()=>void eU(),disabled:!P,className:"cursor-pointer rounded-lg px-3 py-2 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-40 ".concat(ez," hover:").concat(k?"bg-white/5":"bg-gray-100"),children:"Copy JSON"}),(0,n.jsx)("button",{type:"button",onClick:()=>{if(!P||!Z)return;if(!(0,s.yv)(P,_))return void o.o.error("Add sections, HTML, or at least a subject before saving the template.");let e=(0,s.vz)({data:P,brief:_,goal:O}),t=(0,s.DC)(ee)||e.id,a=ea.trim()||e.name,n=el.trim()||e.blurb,l=(0,s.X4)({id:t,name:a,blurb:n,brief:_,goal:O,data:P});try{Z(l,(null==T?void 0:T.id)||void 0),o.o.success("Template saved to your gallery"),y()}catch(e){o.o.error(e instanceof Error?e.message:"Failed to save template")}},disabled:!P,className:"cursor-pointer rounded-lg px-3 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-40 ".concat(k?"bg-emerald-400 text-gray-900 hover:bg-emerald-300":"bg-emerald-600 text-white hover:bg-emerald-700"),children:"Save to gallery"})]}),!eS&&!F&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(B.re,{value:ed,onChange:eu,placement:"up"}),(0,n.jsx)("button",{type:"button",onClick:()=>{var e;return eZ(null!=(e=null==ed?void 0:ed.mode)?e:"draft")},disabled:!P||Y,className:"cursor-pointer rounded-lg px-3 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-40 ".concat(k?"bg-white text-gray-900 hover:bg-gray-200":"bg-gray-900 text-white hover:bg-gray-700"),children:Y?"Savingâ¦":ed?"".concat("scheduled"===ed.mode?"Schedule":"Save"," for ").concat((0,B.xH)(ed.date)):"Save draft"})]})]})]}),(0,n.jsx)("div",{className:"flex min-w-0 flex-1 flex-col",children:P?(0,n.jsx)(c.k,{data:P,isDark:k,height:9999,className:"h-full",selfProfile:{email:D,fullName:A},onSampleChange:ej,editableHtml:eC&&!eS?null!=(b=P.customHtml)?b:"":null,onHtmlChange:eS?void 0:e=>V({...P,customHtml:e})}):(0,n.jsx)("div",{className:"flex h-full items-center justify-center px-8 text-center text-sm ".concat(ez),children:W?"Writing your newsletterâ¦":"Describe what the newsletter is about, then generate. The preview appears here."})})]})})}),document.body)}},99259:(e,t,a)=>{a.d(t,{H:()=>r,rc:()=>l});let n="upgraded.newsletter.savedFooter.v1";function l(e){try{localStorage.setItem(n,JSON.stringify({senderName:e.senderName.trim(),mailingAddress:e.mailingAddress.trim()}))}catch(e){}}function r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){try{let e=localStorage.getItem(n);if(!e)return{senderName:"",mailingAddress:""};let t=JSON.parse(e);return{senderName:"string"==typeof t.senderName?t.senderName.trim():"",mailingAddress:"string"==typeof t.mailingAddress?t.mailingAddress.trim():""}}catch(e){return{senderName:"",mailingAddress:""}}}();return{senderName:e.senderName.trim()||t.senderName,mailingAddress:e.mailingAddress.trim()||t.mailingAddress}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.