PageSourceSearch

https://www.mygovtools.org/_next/static/chunks/7622.704cc5fab442ea66.js

js mygovtools.org collected 2026-09-25 07:29:39 UTC 70,210 bytes, 72 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7622,9625],{7810:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(78340).A)("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},9921:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(78340).A)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},15283:(e,s,t)=>{t.d(s,{Fc:()=>c,TN:()=>o});var a=t(95155),r=t(12115),l=t(18460),i=t(40980);let n=(0,l.F)("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),c=r.forwardRef(({className:e,variant:s,...t},r)=>(0,a.jsx)("div",{ref:r,role:"alert",className:(0,i.cn)(n({variant:s}),e),...t}));c.displayName="Alert",r.forwardRef(({className:e,...s},t)=>(0,a.jsx)("h5",{ref:t,className:(0,i.cn)("mb-1 font-medium leading-none tracking-tight",e),...s})).displayName="AlertTitle";let o=r.forwardRef(({className:e,...s},t)=>(0,a.jsx)("div",{ref:t,className:(0,i.cn)("text-sm [&_p]:leading-relaxed",e),...s}));o.displayName="AlertDescription"},17017:(e,s,t)=>{t.d(s,{i:()=>x});var a=t(95155),r=t(12115),l=t(89239),i=t(60529),n=t(15283),c=t(6296),o=t(48368),d=t(19625),m=t(41484);function x({onHtmlProcessed:e,defaultUrl:s="",showPreview:t=!1,jurisdiction:x,applyTemplate:h=!1}){let[g,u]=(0,r.useState)(s),[p,b]=(0,r.useState)(!1),[y,f]=(0,r.useState)(""),[j,v]=(0,r.useState)(""),N=(0,r.useCallback)(async()=>{if(!g)return void alert("Please enter a Google Doc URL");b(!0),f("");try{let s=g.match(/\/document\/d\/([a-zA-Z0-9_-]+)/);if(!s)throw Error("Invalid Google Doc URL format");let t=s[1],a=`https://docs.google.com/document/d/${t}/export?format=html`,r=await fetch(a);if(!r.ok)throw Error(`Failed to fetch HTML: ${r.status} ${r.statusText}`);let l=await r.text();if(!l||""===l.trim())throw Error("Received empty HTML content");let i=l;if(h&&x)try{i=await (0,m.jb)(l,x)}catch(e){}v(i),e&&e(i)}catch(s){let e=s instanceof Error?s.message:"Unknown error";f(`Failed to process HTML: ${e}`)}finally{b(!1)}},[g,e,h,x]);return(0,r.useEffect)(()=>{s&&!t&&g&&N()},[s,t]),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"googleDocUrl",className:"block text-sm font-medium mb-2",children:"Google Doc URL"}),(0,a.jsx)(i.p,{id:"googleDocUrl",type:"url",value:g,onChange:e=>u(e.target.value),placeholder:"https://docs.google.com/document/d/...",required:!0,className:"w-full"}),(0,a.jsx)("p",{className:"text-xs text-slate-500 mt-1",children:"Make sure the Google Doc is publicly accessible (Anyone with the link can view)"})]}),(0,a.jsx)(l.$,{type:"button",onClick:N,disabled:!(0,d.t)(g)||p,className:"w-full",children:p?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Processing..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.A,{className:"mr-2 h-4 w-4"}),"Process Google Doc HTML"]})})]}),y&&(0,a.jsx)(n.Fc,{variant:"destructive",children:(0,a.jsx)(n.TN,{children:y})}),t&&j&&(0,a.jsxs)("div",{className:"mt-6",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-3",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Newsletter Preview"}),(0,a.jsx)(l.$,{type:"button",onClick:()=>v(""),variant:"ghost",size:"sm",className:"text-gray-500 hover:text-gray-700",children:"✕ Close"})]}),(0,a.jsx)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3 mb-4",children:(0,a.jsx)("p",{className:"text-sm text-blue-800",children:"\uD83D\uDD0D Raw HTML exported directly from Google Docs with mobile-friendly padding"})}),(0,a.jsx)("div",{className:"prose prose-sm max-w-none border rounded-lg p-6 bg-white",dangerouslySetInnerHTML:{__html:j}})]})]})}},18460:(e,s,t)=>{t.d(s,{F:()=>i});var a=t(29722);let r=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,l=a.$,i=(e,s)=>t=>{var a;if((null==s?void 0:s.variants)==null)return l(e,null==t?void 0:t.class,null==t?void 0:t.className);let{variants:i,defaultVariants:n}=s,c=Object.keys(i).map(e=>{let s=null==t?void 0:t[e],a=null==n?void 0:n[e];if(null===s)return null;let l=r(s)||r(a);return i[e][l]}),o=t&&Object.entries(t).reduce((e,s)=>
1{let[t,a]=s;return void 0===a||(e[t]=a),e},{});return l(e,c,null==s||null==(a=s.compoundVariants)?void 0:a.reduce((e,s)=>{let{class:t,className:a,...r}=s;return Object.entries(r).every(e=>{let[s,t]=e;return Array.isArray(t)?t.includes({...n,...o}[s]):({...n,...o})[s]===t})?[...e,t,a]:e},[]),null==t?void 0:t.class,null==t?void 0:t.className)}},19625:(e,s,t)=>{function a(e){let s=e;return(s=s.replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>")).replace(/\*(.*?)\*/g,"<em>$1</em>")}function r(e){return e.includes("docs.google.com/document")||e.includes("drive.google.com/file")}t.d(s,{convertMarkdownToHtml:()=>a,t:()=>r})},22536:(e,s,t)=>{t.d(s,{gJ:()=>r,jI:()=>a});let a=["new","contacted","interested","demo","closed-won","closed-lost"],r={new:"New",contacted:"Contacted",interested:"Interested",demo:"Demoed","closed-won":"Closed (rep)","closed-lost":"Not now"}},33210:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(78340).A)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},41484:(e,s,t)=>{function a(e){let s=e.headerImages.map(e=>`<img src="${e.src}" alt="${e.alt}" style="width: 100%; height: auto; display: block; max-width: 640px; margin: 0 auto;" />`).join("\n");return`
2    <!-- Newsletter Header - Injected by MyGovTools -->
3    <div class="newsletter-header" style="margin: 0; padding: 0;">
4      ${s}
5    </div>
6    <!-- Spacing after header -->
7    <div style="height: 2rem;"></div>
8  `}function r(e){let s=`
9    <!-- Newsletter Signature - Injected by MyGovTools -->
10    <div class="newsletter-signature" style="margin-top: 40px; padding: 40px 20px; text-align: center; background-color: #f8f9fa;">
11      <img src="${e.signature.profileImage}" alt="Profile" style="width: 100px; height: 100px; border-radius: 50%; object-fit: cover; margin: 0 auto 20px auto; display: block;" />
12      <div style="font-style: italic; font-size: 18px; line-height: 1.5; margin: 20px 0 30px 0; color: #333;">
13        ${e.signature.message}
14      </div>
15      <div style="font-size: 16px; color: #333; margin: 0;">
16        ${e.signature.text.replace(/\n/g,"<br>")}
17      </div>
18  `;return e.signature.socialImage&&(s+=`
19      <img src="${e.signature.socialImage}" alt="Social Media Links" style="width: 100%; max-width: 400px; height: auto; margin: 20px auto; display: block;" />
20    `),s+=`
21    </div>
22  `}function l(e){let s=`https://mygovtools.org/newsletters/${e}?utm_source=newsletter-footer`;return`
23    <!-- Newsletter Subscribe CTA - Injected by MyGovTools -->
24    <div class="newsletter-subscribe" style="padding: 28px 20px; text-align: center; background-color: #ffffff; border-top: 1px solid #e9ecef;">
25      <p style="font-size: 16px; font-weight: bold; color: #333; margin: 0 0 6px 0;">Get these updates in your inbox</p>
26      <p style="font-size: 13px; color: #666; margin: 0 0 16px 0;">Forwarded by a friend, or reading online? Subscribe and never miss an update.</p>
27      <a href="${s}" style="display: inline-block; background-color: #1e90ff; color: white; padding: 12px 25px; text-decoration: none; border-radius: 5px; font-weight: bold;" target="_blank">Subscribe to my newsletter</a>
28    </div>
29  `}function i(){return`
30    <!-- Newsletter Footer - Injected by MyGovTools -->
31    <div class="newsletter-footer" style="padding: 24px 20px; text-align: center; background-color: #f8f9fa; border-top: 2px solid #e9ecef;">
32      <a href="https://mygovtools.org/newsletters" style="display: inline-block; border: 2px solid #1e90ff; color: #1e90ff; padding: 10px 20px; text-decoration: none; border-radius: 5px; font-weight: bold; font-size: 14px;" target="_blank">Powered by MyGovTools Newsletters</a>
33      <p style="font-size: 12px; color: #666; margin: 10px 0 0 0;">Modern Government Communication Platform</p>
34    </div>
35  `}async function n(e,s,t){try{let c={};t&&(c.Authorization=`Bearer ${t}`);let o=await fetch(`/api/newsletter-template-config?jurisdiction=${encodeURIComponent(s)}`,{headers:c});if(o.ok){let t=await o.json();if(t.config){var n;let c,o,d,m,x;return n=t.config,c=a(n),o=r(n),d=s?l(s):"",m=i(),x=`
36    <style type="text/css">
37      /* Fix excessive top padding from Google Docs on desktop */
38      body {
39        padding-top: 0 !important;
40      }
41      .doc-content {
42        padding-top: 0 !important;
43      }
44      
45      /* Mobile-responsive padding fixes */
46      @media only screen and (max-width: 600px) {
47        body {
48          padding: 5px !important;
49        }
50        .doc-content {
51          padding: 5px !important;
52        }
53        /* Reduce excessive padding from Google Docs on mobile */
54        * {
55          max-width: 100% !important;
56        }
57      }
58    </style>
59  `,e.replace(/<\/head>/i,`${x}
60</head>`).replace(/<body([^>]*)>/i,`<body$1>
61${c}`).replace(/<\/body>/i,`${o}
62${d}
63${m}
64</body>`)}}}catch(e){}return e}t.d(s,{JI:()=>a,KZ:()=>r,Mp:()=>l,Zb:()=>i,jb:()=>n})},42442:(e,s,t)=>{t.d(s,{DX:()=>n,Dc:()=>o,TL:()=>i});var a=t(12115),r=t(47527),l=t(95155);function i(e){var s;let t,i=(s=e,(t=a.forwardRef((e,s)=>{let{children:t,...l}=e;if(a.isValidElement(t)){var i;let e,n,c=(i=t,(n=(e=Object.getOwnPropertyDescriptor(i.props,"ref")?.get)&&"isReactWarning"in e&&e.
64isReactWarning)?i.ref:(n=(e=Object.getOwnPropertyDescriptor(i,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.props.ref:i.props.ref||i.ref),o=function(e,s){let t={...s};for(let a in s){let r=e[a],l=s[a];/^on[A-Z]/.test(a)?r&&l?t[a]=(...e)=>{l(...e),r(...e)}:r&&(t[a]=r):"style"===a?t[a]={...r,...l}:"className"===a&&(t[a]=[r,l].filter(Boolean).join(" "))}return{...e,...t}}(l,t.props);return t.type!==a.Fragment&&(o.ref=s?(0,r.t)(s,c):c),a.cloneElement(t,o)}return a.Children.count(t)>1?a.Children.only(null):null})).displayName=`${s}.SlotClone`,t),n=a.forwardRef((e,s)=>{let{children:t,...r}=e,n=a.Children.toArray(t),c=n.find(d);if(c){let e=c.props.children,t=n.map(s=>s!==c?s:a.Children.count(e)>1?a.Children.only(null):a.isValidElement(e)?e.props.children:null);return(0,l.jsx)(i,{...r,ref:s,children:a.isValidElement(e)?a.cloneElement(e,void 0,t):null})}return(0,l.jsx)(i,{...r,ref:s,children:t})});return n.displayName=`${e}.Slot`,n}var n=i("Slot"),c=Symbol("radix.slottable");function o(e){let s=({children:e})=>(0,l.jsx)(l.Fragment,{children:e});return s.displayName=`${e}.Slottable`,s.__radixId=c,s}function d(e){return a.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===c}},47527:(e,s,t)=>{t.d(s,{s:()=>i,t:()=>l});var a=t(12115);function r(e,s){if("function"==typeof e)return e(s);null!=e&&(e.current=s)}function l(...e){return s=>{let t=!1,a=e.map(e=>{let a=r(e,s);return t||"function"!=typeof a||(t=!0),a});if(t)return()=>{for(let s=0;s<a.length;s++){let t=a[s];"function"==typeof t?t():r(e[s],null)}}}}function i(...e){return a.useCallback(l(...e),e)}},48368:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(78340).A)("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},50049:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(78340).A)("building-2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]])},51914:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(78340).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},52484:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(78340).A)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},56204:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(78340).A)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},60529:(e,s,t)=>{t.d(s,{p:()=>i});var a=t(95155),r=t(12115),l=t(40980);let i=r.forwardRef(({className:e,type:s,...t},r)=>(0,a.jsx)("input",{type:s,className:(0,l.cn)("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...t}));i.displayName="Input"},66088:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(78340).A)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},67622:(e,s,t)=>{t.r(s),t.d(s,{default:()=>S});var a=t(95155),r=t(12115),l=t(81477),i=t(89239),n=t(60529),c=t(6296),o=t(56204),d=t(92289),m=t(7810),x=t(9921),h=t(66088),g=t(50049),u=t(33210),p=t(51914),b=t(52484),y=t(98500),f=t.n(y),j=t(22536),v=t(9528),N=t(73321),w=t(17017);function k({icon:e,title:s,subtitle:t,gradientFrom:r,gradientTo:l}){return(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,a.jsx)("div",{className:`p-2 bg-gradient-to-br from-${r} to-${l} rounded-lg`,children:(0,a.jsx)(e,{className:"w-6 h-6 text-white"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-2xl font-medium text-gray-700",children:s}),(0,a.jsx)("p",{className:"text-sm text-gray-500",children:t})]})]})}function C({message:e="Loading...",size:s="md",className:t=""}){return(0,a.jsxs)("div",{className:`flex items-center justify-center py-8 ${t}`,children:[(0,a.jsx)(c.A,{className:`${{sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"}[s]} animate-spin text-gray-400`}),e&&(0,a.jsx)("span",{className:"ml-2 text-gray-600",children:e})]})}function S({}){let e,{user:s}=(0,v.A)(),t=(0,N.useSearchParams)(),y=t.get("filter"),S=t.get("search"),[A,T]=(0,r.useState)(""),[$,E]=(0,r.useState)("MyGovTools Team"),[M,F]=(0,r.useState)("[email protected]"),[D,L]=(0,r.useState)("[email protected]"),[z,B]=(0,r.useState)("Save Hours with MyGovTools Newsletter Manager for Electeds, Now Available!"),[I,R]=(0,r.useState)("Save Hours with MyGovTools Newsletter Manager for Electeds, Now Available!"),[P,O]=(0,r.useState)(!0),[H,J]=(0,r.useState)(s?.email||""),[G,U]=(0,r.useState)("broadcast"),[_,q]=(0,r.useState)(!1),[Z,V]=(0,r.useState)(!1),[W,Y]=(0,r.useState)(!1),[K,X]=(0,r.useState)(""),[Q,ee]=(0,r.useState)(!1),[es,et]=(0,r.useState)(null),[ea,er]=(0,r.useState)(!1),[el,ei]=(0,r.useState)(null),[en]=(0,r.useState)(50),[ec]=(0,r.useState)(3e4),[eo,ed]=(0,r.useState)(null),[em,ex]=(0,r.useState)("idle"),[eh,eg]=(0,r.useState)({sent:0,total:0,currentBatch:0,totalBatches:0}),[eu,ep]=(0,r.useState)(!1),[eb,ey]=(0,r.useState)(!1),[ef,ej]=(0,r.useState)(null),[ev,eN]=(0,r.useState)(null),[ew,ek]=(0,r.useState)(!1),[eC,eS]=(0,r.useState)(!1),[eA,eT]=(0,r.useState)(!1),[e$,eE]=(0,r.useState)(""),[eM,eF]=(0,r.useState)([]),[eD,eL]=(0,r.useState)(!1),[ez,eB]=(0,r.useState)([]),[eI,eR]=(0,r.useState)(!1),[eP,eO]=(0,r.useState)(!1),[eH,eJ]=(0,r.useState)(!0),[eG,eU]=(0,r.useState)(!1),[e_,eq]=(0,r.useState)(!1),[eZ,eV]=(0,r.useState)(!1),[eW,eY]=(0,r.useState)(!1),[eK,eX]=(0,r.useState)([]),[eQ,e0]=(0,r.useState)(!0),[e1,e2]=(0,r.useState)(""),[e4,e5]=(0,r.useState)(!1),[e3,e6]=(0,r.useState)(""),[e8,e7]=(0,r.useState)(!1),[e9,se]=(0,r.useState)([]),[ss,st]=(0,r.useState)(!0),[sa,sr]=(0,r.useState)(!1),[sl,si]=(0,r.useState)(!1),[sn,sc]=(0,r.useState)([]),[so,sd]=(0,r.useState)(!0),[sm,sx]=(0,r.useState)(!1),[sh,sg]=(0,r.useState)(!1),[su,sp]=(0,r.useState)([]),[sb,sy]=(0,r.useState)(!1),[sf,sj]=(0,r.useState)(!1),[sv,sN]=(0,r.useState)(!1),[sw,sk]=(0,r.useState)([]),[sC,sS]=(0,r.useState)(!0),[sA,sT]=(0,r.useState)(!1),[s$,sE]=(0,r.useState)(!1),[sM,sF]=(0,r.useState)(!1),[sD,sL]=(0,r.useState)(!1),sz=(0,r.useMemo)(()=>["new","contacted","interested","demo"],[]),sB=(0,r.useMemo)(()=>sw.filter(e=>sz.includes(e.stage)&&e.email),[sw,sz]),sI=(0,r.useMemo)(()=>sw.filter(e=>"closed-won"===e.stage&&e.email),[sw]),sR=(0,r.useMemo)(()=>sw.filter(e=>"closed-won"===e.stage),[sw]),sP=(0,r.useCallback)(e=>(e||"").toLowerCase().replace(/[^a-z]/g,""),[]),sO=(0,r.useCallback)(e=>(e||"").toLowerCase().replace(/[^a-z]/g,""),[]),sH=(0,r.useMemo)(()=>{let e=new Set,s=[];
64return sR.forEach(t=>{let a=sP(t.city);a&&!e.has(a)&&(e.add(a),s.push(t.city))}),s.sort()},[sR,sP]),sJ=(0,r.useMemo)(()=>new Set(sH.map(sP)),[sH,sP]),sG=(0,r.useMemo)(()=>{let e=new Set(["gmail.com","yahoo.com","hotmail.com","outlook.com","aol.com","me.com","mac.com","icloud.com","protonmail.com","msn.com"]),s=new Set;return sI.forEach(t=>{let a=t.email.toLowerCase().trim().split("@")[1]||"";a&&!e.has(a)&&s.add(a)}),s},[sI]),sU=(0,r.useCallback)((e,s)=>{let t=sP(s);if(t&&sJ.has(t))return!0;let a=e.toLowerCase().trim().split("@")[1]||"";return sG.has(a)},[sJ,sG,sP]),s_=(0,r.useMemo)(()=>{let e=new Set;return sw.forEach(s=>{if(!sz.includes(s.stage))return;let t=sO(s.name),a=sP(s.city);t&&a&&e.add(`${t}|${a}`)}),e},[sw,sz,sO,sP]),[sq,sZ]=(0,r.useState)([]),[sV,sW]=(0,r.useState)(!1),[sY,sK]=(0,r.useState)(!1),sX=["[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]"],sQ=(0,r.useCallback)(e=>{let s=e.toLowerCase().trim();return sX.some(e=>e.toLowerCase()===s)},[]);(0,r.useEffect)(()=>{s?.email&&!H&&J(s.email)},[s,H]),(0,r.useEffect)(()=>{(async()=>{if(s){eL(!0);try{let e=await s.getIdToken(),t=new URLSearchParams;y&&t.set("filter",y),S&&t.set("search",S);let a=t.toString()?`?${t.toString()}
64`:"",r=await fetch(`/api/email-controls${a}`,{headers:{Authorization:`Bearer ${e}`}});if(!r.ok)throw Error("Failed to fetch email controls");let l=await r.json();l.success&&Array.isArray(l.emails)&&eF(l.emails)}catch(e){}finally{eL(!1)}}})()},[s,y,S]),(0,r.useEffect)(()=>{(async()=>{if(s){eR(!0);try{let e=await s.getIdToken(),t=await fetch("/api/mayor-emails",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error("Failed to fetch mayor emails");let a=await t.json();a.success&&Array.isArray(a.emails)&&eB(a.emails)}catch(e){}finally{eR(!1)}}})()},[s]),(0,r.useEffect)(()=>{(async()=>{if(s){ek(!0);try{let e=await s.getIdToken(),t=await fetch("/api/user-email-config",{method:"GET",headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error("Failed to fetch email configuration");let a=await t.json();a.success&&a.config&&(E(a.config.fromName||"MyGovTools Team"),F(a.config.fromEmail||"[email protected]"),L(a.config.replyToEmail||"[email protected]"),B(a.config.defaultSubjectTemplate||"Save Hours with MyGovTools Newsletter Manager for Electeds, Now Available!"),R(a.config.defaultPreviewTextTemplate||"Save Hours with MyGovTools Newsletter Manager for Electeds, Now Available!"))}catch(e){}finally{ek(!1)}}})()},[s]);let s0=(0,r.useCallback)(e=>{T(e.replace(/<img[^>]*alt="&#(\d+);"[^>]*>/g,(e,s)=>String.fromCodePoint(parseInt(s,10))))},[]),s1=(0,r.useCallback)(async()=>{if(s){eS(!0),eT(!1),eE("");try{let e=await s.getIdToken(),t=await fetch("/api/user-email-config",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({fromName:$,fromEmail:M,replyToEmail:D,defaultSubjectTemplate:z,defaultPreviewTextTemplate:I})});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to save email configuration")}eT(!0),setTimeout(()=>{eT(!1)},3e3)}catch(e){eE(e instanceof Error?e.message:"Failed to save configuration")}finally{eS(!1)}}},[s,$,M,D,z,I]),s2=(0,r.useCallback)((e,s,t)=>{let a=e.toLowerCase().trim();if(eQ&&eK.some(e=>e.toLowerCase().trim()===a)||sM&&sI.some(e=>e.email.toLowerCase().trim()===a))return!0;if(sD){if(sB.some(e=>e.email.toLowerCase().trim()===a))return!0;let e=sO(t),r=sP(s);if(e&&r&&s_.has(`${e}|${r}`))return!0}return!!(eZ&&sU(e,s)||eW&&sQ(e))},[eQ,eK,sM,sI,sD,sB,s_,sO,sP,eZ,sU,eW,sQ]),s4=(0,r.useCallback)(()=>{let e=new Set,s=[],t=(t,a,r)=>{let l=t.toLowerCase().trim();e.has(l)||s2(t,a,r)||(e.add(l),s.push(t))};return eP&&eM.forEach(e=>t(e.email,e.district)),eH&&ez.forEach(e=>t(e.email,e.city,e.name)),ss&&e9.forEach(e=>t(e.email,e.city,e.name)),so&&sn.forEach(e=>t(e.email,e.city,e.name)),sb&&su.forEach(e=>t(e.email,e.city,e.name)),sC&&sB.forEach(e=>t(e.email,e.city,e.name)),s},[eP,eH,eM,ez,ss,e9,so,sn,sb,su,sC,sB,s2]);(0,r.useEffect)(()=>{(async()=>{if(s){sr(!0);try{let e=await s.getIdToken(),t=await fetch("/api/crm-contacts?source=ca-2026-primary",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)return;let a=await t.json();a.success&&Array.isArray(a.contacts)&&se(a.contacts)}catch(e){}finally{sr(!1)}}})()},[s]),(0,r.useEffect)(()=>{(async()=>{if(s){sx(!0);try{let e=await s.getIdToken(),t=await fetch("/api/crm-contacts?source=us-mayors",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)return;let a=await t.json();if(a.success&&Array.isArray(a.contacts)){let e=[...a.contacts].sort((e,s)=>(e.state||"").localeCompare(s.state||"",void 0,{sensitivity:"base"})||(e.city||"").localeCompare(s.city||"",void 0,{sensitivity:"base"}));sc(e)}}catch(e){}finally{sx(!1)}}})()},[s]),(0,r.useEffect)(()=>{(async()=>{if(s){sj(!0);try{let e=await s.getIdToken(),t=await fetch("/api/crm-contacts?source=or-councilmembers",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)return;let a=await t.json();if(a.success&&Array.isArray(a.contacts)){let e=[...a.contacts].sort((e,s)=>(e.city||"").localeCompare(s.city||"",void 0,{sensitivity:"base"})||(e.name||"").localeCompare(s.name||"",void 0,{sensitivity:"base"}));sp(e)}}catch(e){}finally{sj(!1)}}})()},[s]),(0,r.useEffect)(()=>{(async()=>{if(s){sT(!0);try{let e=await s.getIdToken(),t=await fetch("/api/crm-contacts?view=leads",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)return;let a=await t.json();a.success&&Array.isArray(a.leads)&&sk(a.leads)}catch(e){}finally{sT(!1)}}})()},[s]);let s5=(0,r.useCallback)(()=>{let e=[];eP&&e.push("Email Controls"),eH&&e.push("Scraped Mayor Emails"),ss&&e.push("Candidates (CA 2026)"),so&&e.push("US City Mayors"),sb&&e.push("OR Councilmembers"),sC&&e.push("Leads (pipeline)");let s=[];return sM&&sI.length>0&&s.push(`excluding ${sI.length} closed-won clients`),sD&&sB.length>0&&s.push(`excluding ${sB.length} open leads`),eZ&&sH.length>0&&s.push(`excluding ${sH.length} client cities`),eW&&s.push(`excluding ${sX.length} specific emails`),eQ&&eK.length>0&&s.push(`excluding ${eK.length} saved`),{label:e.join(" + ")+(s.length?` \xb7 ${s.join(", ")}`:""),sources:e,filters:s,counts:{emailControls:eP?eM.length:0,mayorEmails:eH?ez.length:0,candidates:ss?e9.length:0,usMayors:so?sn.length:0,orCouncil:sb?su.length:0,leads:sC?sB.length:0}}},[eP,eH,ss,so,sb,sC,eZ,sH,eW,sM,sI,sD,eQ,eK,eM,ez,e9,sn,su,sB,sX.length]),s3=(0,r.useCallback)(async()=>
64{if(s){sW(!0);try{let e=await s.getIdToken(),t=await fetch("/api/crm-email-jobs/list?limit=50",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)return;let a=await t.json();a.success&&Array.isArray(a.jobs)&&sZ(a.jobs)}catch(e){}finally{sW(!1)}}},[s]);(0,r.useEffect)(()=>{(async()=>{if(s)try{let e=await s.getIdToken(),t=await fetch("/api/crm-excluded-emails",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)return;let a=await t.json();a.success&&Array.isArray(a.emails)&&eX(a.emails)}catch(e){}})()},[s]);let s6=(0,r.useCallback)(async e=>{if(!s)return!1;e5(!0),e6("");try{let t=await s.getIdToken(),a=await fetch("/api/crm-excluded-emails",{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({emails:e})});if(!a.ok){let e=await a.json();throw Error(e.error||"Failed to save exclusion list")}let r=await a.json();return eX(Array.isArray(r.emails)?r.emails:e),!0}catch(e){return e6(e instanceof Error?e.message:"Failed to save exclusion list"),!1}finally{e5(!1)}},[s]),s8=(0,r.useCallback)(async()=>{let e=e1.trim().toLowerCase();if(e6(""),e){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))return void e6("Please enter a valid email address");if(eK.some(s=>s.toLowerCase()===e)){e6("That email is already in the list"),e2("");return}await s6([...eK,e])&&e2("")}},[e1,eK,s6]),s7=(0,r.useCallback)(async e=>{await s6(eK.filter(s=>s.toLowerCase()!==e.toLowerCase()))},[eK,s6]),s9=(0,r.useCallback)(()=>{if(!s||!A||!H)return;let e=H.split(",").map(e=>e.trim()).filter(e=>e),t=e.length,a=Math.min(50,t),r=Math.ceil(t/a),l={fromName:$,fromEmail:M,replyToEmail:D,subject:`[TEST] ${z}`,previewText:I,htmlContent:A,recipientEmails:e,batchSize:a,batchDelay:0,bccToAdmin:null,messageStream:G,isTest:!0,totalRecipients:t,totalBatches:r};et(l),ee(!0)},[s,A,H,$,M,D,z,I,G]),te=(0,r.useCallback)(async()=>{if(!s||!A)return;let e=s4();if(0===e.length)return void alert("No recipients selected");let t={fromName:$,fromEmail:M,replyToEmail:D,subject:z,previewText:I,htmlContent:A,recipientEmails:e,batchSize:en,batchDelay:ec,bccToAdmin:null,messageStream:G,isTest:!1,audience:s5(),totalRecipients:e.length,totalBatches:Math.ceil(e.length/en)};ej(t),ey(!0)},[s,A,s4,$,M,D,z,I,en,ec,P,G,s5]),ts=(0,r.useCallback)(async()=>{if(s&&ef){V(!0),X("");try{let e=await s.getIdToken(),t=await fetch("/api/crm-email-jobs/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(ef)});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to create email job")}let a=await t.json(),r=a.jobId;ed(r),ex("pending"),eg({sent:0,total:a.totalRecipients,currentBatch:0,totalBatches:a.totalBatches}),ey(!1),ej(null),alert(`Job created: ${r}
65
66To start sending, open Firestore (emailJobsCRM/${r}) and do BOTH:
67  1. Change "status" from 'pending' to 'processing'
68  2. Set "lastProcessedAt" to a new value (use the timestamp "now", or any value)
69
70Step 2 is required to kick off the first batch — without it the job stays at "processing, 0 sent". After that it sends all batches automatically.`),tt(r)}catch(e){X(e instanceof Error?e.message:"Failed to create job")}finally{V(!1)}}},[s,ef,en]),tt=(0,r.useCallback)(e=>{ev&&clearInterval(ev),ep(!0);let t=setInterval(async()=>{if(s)try{let a=await s.getIdToken(),r=await fetch(`/api/crm-email-jobs/${e}/status`,{headers:{Authorization:`Bearer ${a}`}});if(!r.ok)return;let l=await r.json();ex(l.status),eg({sent:l.sentCount,total:l.totalRecipients,currentBatch:l.currentBatch,totalBatches:l.totalBatches}),("completed"===l.status||"cancelled"===l.status||"failed"===l.status)&&(clearInterval(t),eN(null),ep(!1),"completed"===l.status&&Y(!0))}catch(e){}},2e3);eN(t)},[s,ev]),ta=(0,r.useCallback)(async()=>{if(s&&es){q(!0),X("");try{let e=await s.getIdToken(),t=await fetch("/api/crm-email-jobs/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(es)});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to create test email job")}let a=(await t.json()).jobId;ed(a),ex("processing"),eg({sent:0,total:1,currentBatch:0,totalBatches:1}),ee(!1),et(null),alert(`Test job created: ${a}
71
72Test email is being sent automatically...`),tt(a)}catch(e){X(e instanceof Error?e.message:"Failed to create test job")}finally{q(!1)}}},[s,es,tt]),tr=(0,r.useCallback)(async()=>{if(s&&eo&&confirm("Are you sure you want to cancel this job?"))try{let e=await s.getIdToken(),t=await fetch(`/api/crm-email-jobs/${eo}/cancel`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to cancel job")}alert("Job cancelled successfully")}catch(e){alert(e instanceof Error?e.message:"Failed to cancel job")}},[s,eo]);return(0,r.useEffect)(()=>()=>{ev&&clearInterval(ev)},[ev]),(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)(l.Zp,{className:"bg-white rounded-lg shadow-sm p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,a.jsx)("div",{className:"p-2 bg-gradient-to-br from-orange-500 to-amber-500 rounded-lg",children:(0,a.jsx)(d.A,{className:"w-6 h-6 text-white"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-2xl font-medium text-gray-700",children:"Email Configuration"}),(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Configure sender details and email settings"})]})]}),ew?(0,a.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,a.jsx)(c.A,{className:"h-8 w-8 animate-spin text-orange-500"}),(0,a.jsx)("span",{className:"ml-3 text-gray-600",children:"Loading your email configuration..."})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"From Name"}),(0,a.jsx)(n.p,{value:$,onChange:e=>E(e.target.value),placeholder:"MyGovTools Team",className:"w-full"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"From Email"}),(0,a.jsx)(n.p,{type:"email",value:M,onChange:e=>F(e.target.value),placeholder:"[email protected]",className:"w-full"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Reply-To Email"}),(0,a.jsx)(n.p,{type:"email",value:D,onChange:e=>L(e.target.value),placeholder:"[email protected]",className:"w-full"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Subject Line"}),(0,a.jsx)(n.p,{value:z,onChange:e=>B(e.target.value),placeholder:"Your newsletter subject",className:"w-full"})]}),(0,a.jsxs)("div",{className:"md:col-span-2",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Preview Text"}
72),(0,a.jsx)(n.p,{value:I,onChange:e=>R(e.target.value),placeholder:"Text shown in email inbox preview",className:"w-full"})]}),(0,a.jsxs)("div",{className:"md:col-span-2",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Test Email Address"}),(0,a.jsx)(n.p,{type:"email",value:H,onChange:e=>J(e.target.value),placeholder:"[email protected]",className:"w-full"}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Email address to receive test emails"})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between pt-4 border-t border-gray-200",children:[(0,a.jsxs)("div",{className:"flex-1",children:[eA&&(0,a.jsx)("p",{className:"text-sm text-green-600 font-medium",children:"✓ Configuration saved successfully!"}),e$&&(0,a.jsx)("p",{className:"text-sm text-red-600",children:e$})]}),(0,a.jsx)(i.$,{onClick:s1,disabled:eC||!$||!M||!D,className:"bg-gradient-to-r from-orange-600 to-amber-600 hover:from-orange-700 hover:to-amber-700 text-white",children:eC?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):(0,a.jsx)(a.Fragment,{children:"Save as Default"})})]})]})]}),(0,a.jsx)(l.Zp,{className:"bg-white rounded-lg shadow-sm p-6",children:(0,a.jsx)(w.i,{onHtmlProcessed:s0,defaultUrl:"https://docs.google.com/document/d/1QAp_-eWwywDGS6maSV1m7mpUlvmAJH87DnA1EsSU7iY/edit?tab=t.0",showPreview:!0})}),(0,a.jsxs)(l.Zp,{className:"bg-white rounded-lg shadow-sm p-6",children:[(0,a.jsx)(k,{icon:m.A,title:"Recipients",subtitle:"Select which recipient sets to include",gradientFrom:"green-500",gradientTo:"teal-500"}),(0,a.jsxs)("div",{className:"p-3 bg-gradient-to-r from-green-50 to-teal-50 border border-green-200 rounded-lg mb-3",children:[(0,a.jsxs)("p",{className:"text-2xl font-bold text-green-600",children:[s4().length," Total Recipients Selected"]}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:(e=[],eP&&e.push(`Email Controls (${eM.length})`),eH&&e.push(`Scraped Mayor Emails (${ez.length})`),ss&&e.push(`Candidates (${e9.length})`),so&&e.push(`US City Mayors (${sn.length})`),sb&&e.push(`OR Councilmembers (${su.length})`),sC&&e.push(`Leads (${sB.length})`),e.length?`${e.join(" + ")}, deduplicated, minus exclusions below`:"No recipient sets selected")})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:`border rounded-lg px-3 py-2 ${eP?"border-green-300 bg-green-50/50":"border-gray-200 bg-gray-50"}`,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{type:"checkbox",id:"useEmailControls",checked:eP,onChange:e=>eO(e.target.checked),className:"w-5 h-5 text-green-600 rounded focus:ring-green-500"}),(0,a.jsx)("label",{htmlFor:"useEmailControls",className:"cursor-pointer",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)(m.A,{className:"w-4 h-4 text-green-600"}),(0,a.jsx)("span",{className:"font-semibold text-gray-800",children:"Email Controls"}),(0,a.jsxs)("span",{className:"text-sm text-gray-500",children:["(",eD?"...":eM.length," emails)"]}),(0,a.jsxs)("span",{className:"text-xs text-gray-400",children:["\xb7 From Email Controls database","gov"===y&&" (.gov only)",S&&` (contains: ${S})`]})]})})]}),eM.length>0&&(0,a.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>eU(!eG),className:"text-green-700 hover:text-green-900 hover:bg-green-100",children:eG?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.A,{className:"mr-1 h-4 w-4"})," Hide"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.A,{className:"mr-1 h-4 w-4"})," Show"]})})]}),eD&&(0,a.jsx)(C,{message:"Loading email controls..."}),eG&&eM.length>0&&(0,a.jsx)("div",{className:"mt-2 max-h-40 overflow-y-auto border border-gray-200 rounded-lg p-2 bg-white",children:(0,a.jsx)("ul",{className:"space-y-1",children:eM.map((e,s)=>(0,a.jsxs)("li",{className:"text-sm text-gray-600",children:[e.email," ",(0,a.jsxs)("span",{className:"text-gray-400",children:["(",e.district,")"]})]},s))})})]}),(0,a.jsxs)("div",{className:`border rounded-lg px-3 py-2 ${eH?"border-indigo-300 bg-indigo-50/50":"border-gray-200 bg-gray-50"}`,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{type:"checkbox",id:"useMayorEmails",checked:eH,onChange:e=>eJ(e.target.checked),className:"w-5 h-5 text-indigo-600 rounded focus:ring-indigo-500"}),(0,a.jsx)("label",{htmlFor:"useMayorEmails",className:"cursor-pointer",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)(g.A,{className:"w-4 h-4 text-indigo-600"}),(0,a.jsx)("span",{className:"font-semibold text-gray-800",children:"Scraped Mayor Emails"}),(0,a.jsxs)("span",{className:"text-sm text-gray-500",children:["(",eI?"...":ez.length," emails)"]}),(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"\xb7 From Representants collection (scraped mayor documents)"})]})})]}),ez.length>0&&(0,a.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>eq(!e_),className:"text-indigo-700 hover:text-indigo-900 hover:bg-indigo-100",children:e_?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.A,{className:"mr-1 h-4 w-4"})," Hide"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.A,{className:"mr-1 h-4 w-4"})," Show"]})})]}),eI&&(0,a.jsx)(C,{message:"Loading mayor emails..."}),e_&&ez.length>0&&(0,a.jsx)("div",{className:"mt-2 max-h-40 overflow-y-auto border border-gray-200 rounded-lg p-2 bg-white",children:(0,a.jsx)("ul",{className:"space-y-1",children:ez.map((e,s)=>{let t=s2(e.email,e.city,e.name);return(0,a.jsxs)("li",{className:`text-sm ${t?"text-gray-400 line-through":"text-gray-600"}`,children:[e.email,e.name&&(0,a.jsxs)("span",{className:t?"text-gray-300":"text-gray-400",children:[" — ",e.name]}),e.city&&(0,a.jsxs)("span",{className:t?"text-red-300":"text-indigo-400",children:[" (",e.city,")"]}),t&&(0,a.jsx)("span",{className:"ml-2 text-xs bg-red-100 text-red-600 px-1.5 py-0.5 rounded no-underline inline-block",style:{textDecoration:"none"},children:"excluded"})]},s)})})})]}),(0,a.jsxs)("div",{className:`border rounded-lg px-3 py-2 ${ss?"border-purple-300 bg-purple-50/50":"border-gray-200 bg-gray-50"}`,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{type:"checkbox",id:"useCandidates",checked:ss,onChange:e=>st(e.target.checked),className:"w-5 h-5 text-purple-600 rounded focus:ring-purple-500"}),(0,a.jsx)("label",{htmlFor:"useCandidates",className:"cursor-pointer",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)(g.A,{className:"w-4 h-4 text-purple-600"}),(0,a.jsx)("span",{className:"font-semibold text-gray-800",children:"Candidates (CA 2026)"}),(0,a.jsxs)("span",{className:"text-sm text-gray-500",children:["(",sa?"...":e9.length," emails)"]}),(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"\xb7 CA 2026 primary candidate outreach list"})]})})]}),e9.length>0&&(0,a.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>si(!sl),className:"text-purple-700 hover:text-purple-900 hover:bg-purple-100 shrink-0",children:sl?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.A,{className:"mr-1 h-4 w-4"})," Hide"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.A,{className:"mr-1 h-4 w-4"})," Show"]})})]}
72),sa&&(0,a.jsx)(C,{message:"Loading candidates..."}),sl&&e9.length>0&&(0,a.jsx)("div",{className:"mt-2 max-h-40 overflow-y-auto border border-gray-200 rounded-lg p-2 bg-white",children:(0,a.jsx)("ul",{className:"space-y-1",children:e9.map((e,s)=>(0,a.jsxs)("li",{className:"text-sm text-gray-600",children:[e.email,e.name&&(0,a.jsxs)("span",{className:"text-gray-400",children:[" — ",e.name]}),e.office&&(0,a.jsxs)("span",{className:"text-purple-400",children:[" (",e.office,")"]})]},s))})})]}),(0,a.jsxs)("div",{className:`border rounded-lg px-3 py-2 ${so?"border-teal-300 bg-teal-50/50":"border-gray-200 bg-gray-50"}`,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{type:"checkbox",id:"useUsMayors",checked:so,onChange:e=>sd(e.target.checked),className:"w-5 h-5 text-teal-600 rounded focus:ring-teal-500"}),(0,a.jsx)("label",{htmlFor:"useUsMayors",className:"cursor-pointer",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)(g.A,{className:"w-4 h-4 text-teal-600"}),(0,a.jsx)("span",{className:"font-semibold text-gray-800",children:"US City Mayors"}),(0,a.jsxs)("span",{className:"text-sm text-gray-500",children:["(",sm?"...":sn.length," emails)"]}),(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"\xb7 Sitting mayors of large cities nationwide"})]})})]}),sn.length>0&&(0,a.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>sg(!sh),className:"text-teal-700 hover:text-teal-900 hover:bg-teal-100 shrink-0",children:sh?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.A,{className:"mr-1 h-4 w-4"})," Hide"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.A,{className:"mr-1 h-4 w-4"})," Show"]})})]}),sm&&(0,a.jsx)(C,{message:"Loading US mayors..."}),sh&&sn.length>0&&(0,a.jsx)("div",{className:"mt-2 max-h-40 overflow-y-auto border border-gray-200 rounded-lg p-2 bg-white",children:(0,a.jsx)("ul",{className:"space-y-1",children:sn.map((e,s)=>(0,a.jsxs)("li",{className:"text-sm text-gray-600",children:[e.email,e.name&&(0,a.jsxs)("span",{className:"text-gray-400",children:[" — ",e.name]}),(e.city||e.state)&&(0,a.jsxs)("span",{className:"text-teal-400",children:[" (",[e.city,e.state].filter(Boolean).join(", "),")"]})]},s))})})]}),(0,a.jsxs)("div",{className:`border rounded-lg px-3 py-2 ${sb?"border-cyan-300 bg-cyan-50/50":"border-gray-200 bg-gray-50"}`,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{type:"checkbox",id:"useOrCouncil",checked:sb,onChange:e=>sy(e.target.checked),className:"w-5 h-5 text-cyan-600 rounded focus:ring-cyan-500"}),(0,a.jsx)("label",{htmlFor:"useOrCouncil",className:"cursor-pointer",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)(g.A,{className:"w-4 h-4 text-cyan-600"}),(0,a.jsx)("span",{className:"font-semibold text-gray-800",children:"OR Councilmembers"}),(0,a.jsxs)("span",{className:"text-sm text-gray-500",children:["(",sf?"...":su.length," emails)"]}),(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"\xb7 Councilmembers & mayors of all Oregon cities (individual emails only)"})]})})]}),su.length>0&&(0,a.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>sN(!sv),className:"text-cyan-700 hover:text-cyan-900 hover:bg-cyan-100 shrink-0",children:sv?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.A,{className:"mr-1 h-4 w-4"})," Hide"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.A,{className:"mr-1 h-4 w-4"})," Show"]})})]}),sf&&(0,a.jsx)(C,{message:"Loading Oregon councilmembers..."}),sv&&su.length>0&&(0,a.jsx)("div",{className:"mt-2 max-h-40 overflow-y-auto border border-gray-200 rounded-lg p-2 bg-white",children:(0,a.jsx)("ul",{className:"space-y-1",children:su.map((e,s)=>(0,a.jsxs)("li",{className:"text-sm text-gray-600",children:[e.email,e.name&&(0,a.jsxs)("span",{className:"text-gray-400",children:[" — ",e.name]}),(e.city||e.office)&&(0,a.jsxs)("span",{className:"text-cyan-500",children:[" (",[e.office,e.city].filter(
72Boolean).join(", "),")"]})]},s))})})]}),(0,a.jsxs)("div",{className:`border rounded-lg px-3 py-2 ${sC?"border-emerald-300 bg-emerald-50/50":"border-gray-200 bg-gray-50"}`,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{type:"checkbox",id:"useLeads",checked:sC,onChange:e=>sS(e.target.checked),className:"w-5 h-5 text-emerald-600 rounded focus:ring-emerald-500"}),(0,a.jsx)("label",{htmlFor:"useLeads",className:"cursor-pointer",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)(m.A,{className:"w-4 h-4 text-emerald-600"}),(0,a.jsx)("span",{className:"font-semibold text-gray-800",children:"Leads (pipeline)"}),(0,a.jsxs)("span",{className:"text-sm text-gray-500",children:["(",sA?"...":sB.length," emails)"]}),(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"\xb7 Open-stage leads from the Leads page (new, contacted, interested, demoed)"})]})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,a.jsx)(f(),{href:"/settings/leads",className:"text-xs text-emerald-700 underline hover:text-emerald-900 whitespace-nowrap",children:"Manage ↗"}),sw.length>0&&(0,a.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>sE(!s$),className:"text-emerald-700 hover:text-emerald-900 hover:bg-emerald-100",children:s$?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.A,{className:"mr-1 h-4 w-4"})," Hide"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.A,{className:"mr-1 h-4 w-4"})," Show"]})})]})]}),sA&&(0,a.jsx)(C,{message:"Loading leads..."}),s$&&sw.length>0&&(0,a.jsx)("div",{className:"mt-2 max-h-40 overflow-y-auto border border-gray-200 rounded-lg p-2 bg-white",children:(0,a.jsx)("ul",{className:"space-y-1",children:sw.map((e,s)=>{let t=sz.includes(e.stage),r=t&&!!e.email&&sC&&!s2(e.email,e.city,e.name),l="closed-won"===e.stage&&sM,i=t&&!!e.email&&sD;return(0,a.jsxs)("li",{className:"text-sm text-gray-600 flex flex-wrap items-center gap-x-2",children:[(0,a.jsx)("span",{children:e.email||(0,a.jsx)("span",{className:"italic text-gray-400",children:"no email"})}),e.name&&(0,a.jsxs)("span",{className:"text-gray-400",children:["— ",e.name]}),(0,a.jsx)("span",{className:"text-emerald-500 text-xs",children:j.gJ[e.stage]||e.stage}),r&&(0,a.jsx)("span",{className:"text-xs font-medium text-emerald-700 bg-emerald-100 rounded px-1.5",children:"included"}),l&&(0,a.jsx)("span",{className:"text-xs font-medium text-red-700 bg-red-100 rounded px-1.5",children:"excluded everywhere (client)"}),i&&(0,a.jsx)("span",{className:"text-xs font-medium text-red-700 bg-red-100 rounded px-1.5",children:"excluded everywhere (open lead)"}),!r&&!l&&!i&&(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"not included"})]},s)})})})]}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 border-b border-red-200 pb-2 mb-1",children:[(0,a.jsx)(u.A,{className:"w-4 h-4 text-red-600"}),(0,a.jsx)("h3",{className:"font-semibold text-gray-800",children:"Exclusions"}),(0,a.jsx)("span",{className:"text-xs text-gray-500",children:"\xb7 Applied to ALL selected lists above, after deduplication"})]})}),(0,a.jsx)("div",{className:`border rounded-lg px-3 py-2 ${sM?"border-red-300 bg-red-50/50":"border-gray-200 bg-gray-50"}`,children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{type:"checkbox",id:"excludeClosedWon",checked:sM,onChange:e=>sF(e.target.checked),className:"w-5 h-5 text-red-600 rounded focus:ring-red-500"}),(0,a.jsx)("label",{htmlFor:"excludeClosedWon",className:"cursor-pointer",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"font-semibold text-gray-800",children:"Client emails"}),(0,a.jsxs)("span",{className:"text-sm text-gray-500",children:["(",sI.length," emails)"]}),(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"\xb7 Every closed-won lead's address — auto-updates when a lead is marked closed-won"})]})})]})}),(0,a.jsx)("div",{className:`border rounded-lg px-3 py-2 ${sD?"border-red-300 bg-red-50/50":"border-gray-200 bg-gray-50"}`,children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{type:"checkbox",id:"excludeOpenLeads",checked:sD,onChange:e=>sL(e.target.checked),className:"w-5 h-5 text-red-600 rounded focus:ring-red-500"}),(0,a.jsx)("label",{htmlFor:"excludeOpenLeads",className:"cursor-pointer",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"font-semibold text-gray-800",children:"Leads (pipeline)"}),(0,a.jsxs)("span",{className:"text-sm text-gray-500",children:["(",sB.length," emails)"]}),(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"\xb7 Open-stage leads from the Leads page — matched by email OR name+city, removed from every list, overriding the include toggle above"})]})})]})}),(0,a.jsx)("div",{className:`border rounded-lg px-3 py-2 ${eZ?"border-red-300 bg-red-50/50":"border-gray-200 bg-gray-50"}`,children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{type:"checkbox",id:"excludeClientCities",checked:eZ,onChange:e=>eV(e.target.checked),className:"w-5 h-5 text-red-600 rounded focus:ring-red-500"}),(0,a.jsx)("label",{htmlFor:"excludeClientCities",className:"cursor-pointer",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"font-semibold text-gray-800",children:"Client cities"}),(0,a.jsxs)("span",{className:"text-sm text-gray-500",children:["(",sH.length," cities)"]}),(0,a.jsxs)("span",{className:"text-xs text-gray-400",children:["\xb7 Everyone in a closed-won client's city: ",sH.join(", ")||"none yet"]})]})})]})}),(0,a.jsx)("div",{className:`border rounded-lg px-3 py-2 ${eW?"border-red-300 bg-red-50/50":"border-gray-200 bg-gray-50"}`,children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{type:"checkbox",id:"excludeIndividualEmails",checked:eW,onChange:e=>eY(e.target.checked),className:"w-5 h-5 text-red-600 rounded focus:ring-red-500"}),(0,a.jsx)("label",{htmlFor:"excludeIndividualEmails",className:"cursor-pointer",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"font-semibold text-gray-800",children:"Specific email addresses (legacy list)"}),(0,a.jsxs)("span",{className:"text-sm text-gray-500",children:["(",sX.length," emails)"]}),(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"\xb7 Hardcoded one-off exclusions from various cities"})]})})]})}),(0,a.jsxs)("div",{className:`border rounded-lg px-3 py-2 ${eQ?"border-red-300 bg-red-50/50":"border-gray-200 bg-gray-50"}`,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{type:"checkbox",id:"use
72SavedExclusions",checked:eQ,onChange:e=>e0(e.target.checked),className:"w-5 h-5 text-red-600 rounded focus:ring-red-500"}),(0,a.jsx)("label",{htmlFor:"useSavedExclusions",className:"cursor-pointer",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)(u.A,{className:"w-4 h-4 text-red-600"}),(0,a.jsx)("span",{className:"font-semibold text-gray-800",children:"Saved excluded emails"}),(0,a.jsxs)("span",{className:"text-sm text-gray-500",children:["(",eK.length," saved)"]}),(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"\xb7 Your editable one-off skip list, add/remove below"})]})})]}),eK.length>0&&(0,a.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>e7(!e8),className:"text-red-700 hover:text-red-900 hover:bg-red-100 shrink-0",children:e8?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.A,{className:"mr-1 h-4 w-4"})," Hide"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.A,{className:"mr-1 h-4 w-4"})," Show"]})})]}),(0,a.jsxs)("div",{className:"mt-3 flex flex-col sm:flex-row gap-2",children:[(0,a.jsx)(n.p,{type:"email",value:e1,onChange:e=>e2(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),s8())},placeholder:"[email protected]",className:"flex-1"}),(0,a.jsx)(i.$,{onClick:s8,disabled:e4||!e1.trim(),className:"bg-red-600 hover:bg-red-700 text-white whitespace-nowrap",children:e4?(0,a.jsx)(c.A,{className:"h-4 w-4 animate-spin"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p.A,{className:"mr-1 h-4 w-4"})," Add to exclude list"]})})]}),e3&&(0,a.jsx)("p",{className:"text-xs text-red-600 mt-1",children:e3}),e8&&eK.length>0&&(0,a.jsx)("div",{className:"mt-2 max-h-40 overflow-y-auto border border-gray-200 rounded-lg p-2 bg-white",children:(0,a.jsx)("ul",{className:"space-y-1",children:eK.map((e,s)=>(0,a.jsxs)("li",{className:"text-sm text-gray-600 flex items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"truncate",children:e}),(0,a.jsx)("button",{onClick:()=>s7(e),disabled:e4,className:"text-xs text-red-500 hover:text-red-700 shrink-0 disabled:opacity-50",children:"Remove"})]},s))})})]})]})]}),A&&(0,a.jsxs)(l.Zp,{className:"bg-white rounded-lg shadow-sm p-6",children:[(0,a.jsx)(k,{icon:o.A,title:"Send Newsletter",subtitle:"Test or send to all recipients",gradientFrom:"purple-500",gradientTo:"pink-500"}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("div",{className:"bg-teal-50 border border-teal-200 rounded-lg p-3",children:(0,a.jsx)("p",{className:"text-sm text-teal-800",children:"✅ Using Direct HTML Export (raw from Google Docs)"})}),(0,a.jsxs)("div",{className:"border border-gray-200 rounded-lg p-4",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-3",children:"Message Stream"}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"flex items-center gap-3 cursor-pointer",children:[(0,a.jsx)("input",{type:"radio",name:"messageStream",value:"broadcast",checked:"broadcast"===G,onChange:e=>U(e.target.value),className:"w-4 h-4 text-blue-600"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-sm font-medium text-gray-900",children:"Broadcast/Marketing"}),(0,a.jsx)("p",{className:"text-xs text-gray-500",children:"For newsletters and marketing emails"})]})]}),(0,a.jsxs)("label",{className:"flex items-center gap-3 cursor-pointer",children:[(0,a.jsx)("input",{type:"radio",name:"messageStream",value:"outbound",checked:"outbound"===G,onChange:e=>U(e.target.value),className:"w-4 h-4 text-blue-600"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-sm font-medium text-gray-900",children:"Outbound/Transactional"}),(0,a.jsx)("p",{className:"text-xs text-gray-500",children:"For transactional emails"})]})]})]})]}),eo&&"idle"!==em&&(0,a.jsxs)("div",{className:"p-4 bg-cyan-50 border border-cyan-300 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-sm font-semibold text-cyan-900",children:["Job Status: ",em.toUpperCase()]}),(0,a.jsxs)("p",{className:"text-xs text-cyan-700",children:["Job ID: ",eo]}),"processing"===em&&(0,a.jsxs)("p",{className:"text-xs text-cyan-700 mt-1",children:["Batch ",eh.currentBatch," of ",eh.totalBatches," • ",eh.sent," of ",eh.total," emails sent"]})]}),("pending"===em||"processing"===em)&&(0,a.jsx)(i.$,{onClick:tr,variant:"outline",className:"bg-red-500 hover:bg-red-600 text-white border-red-600",children:"\uD83D\uDED1 CANCEL JOB"})]}),"processing"===em&&eh.total>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"w-full bg-cyan-200 rounded-full h-3 overflow-hidden",children:(0,a.jsx)("div",{className:"bg-gradient-to-r from-cyan-500 to-blue-500 h-3 transition-all duration-500",style:{width:`${eh.sent/eh.total*100}%`}})}),(0,a.jsxs)("p",{className:"text-xs text-cyan-600 mt-2",children:["⏱️ Sending in batches of ",en," with ",ec/1e3,"s delay"]})]}),"pending"===em&&(0,a.jsx)("div",{className:"mt-2 p-2 bg-yellow-50 border border-yellow-200 rounded",children:(0,a.jsx)("p",{className:"text-xs text-yellow-800",children:"⚠️ Job created but not started. In Firestore, set status to 'processing' AND change lastProcessedAt to a new value (e.g. timestamp 'now') to begin sending. Both are required."})}),"completed"===em&&(0,a.jsx)("div",{className:"mt-2 p-2 bg-green-50 border border-green-200 rounded",children:(0,a.jsxs)("p",{className:"text-xs text-green-800",children:["✅ Job completed! Sent ",eh.sent," of ",eh.total," emails."]})}),"cancelled"===em&&(0,a.jsx)("div",{className:"mt-2 p-2 bg-orange-50 border border-orange-200 rounded",children:(0,a.jsxs)("p",{className:"text-xs text-orange-800",children:["⚠️ Job cancelled. Sent ",eh.sent," of ",eh.total," emails before cancellation."]})}),"failed"===em&&(0,a.jsx)("div",{className:"mt-2 p-2 bg-red-50 border border-red-200 rounded",children:(0,a.jsx)("p",{className:"text-xs text-red-800",children:"❌ Job failed. Check Firestore for error details."})})]}),K&&(0,a.jsx)("div",{className:"p-3 bg-red-50 border border-red-200 rounded-md",children:(0,a.jsx)("p",{className:"text-sm text-red-600",children:K})}),W&&(0,a.jsx)("div",{className:"p-3 bg-green-50 border border-green-200 rounded-md",children:(0,a.jsx)("p",{className:"text-sm text-green-600",children:"Newsletter sent successfully!"})}),Q||eb?Q&&es?(0,a.jsxs)("div",{className:"border rounded-lg p-4 border-blue-200 bg-blue-50",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold text-blue-900",children:"Test Email Job Preview"}),(0,a.jsx)("button",{onClick:()=>{ee(!1),et(null)},className:"text-sm font-medium text-blue-600 hover:text-blue-800",children:"✕ Close"})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"p-3 bg-white border border-blue-200 rounded",children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-blue-900 mb-2",children:"\uD83D\uDCE7 Email Configuration"}),(0,a.jsxs)("div",{className:"text-xs text-gray-700 space-y-1",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"From:"})," ",es.fromName," <",es.fromEmail,">"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Reply-To:"})," ",es.replyToEmail]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Subject:"})," ",es.subject]}),es.previewText&&(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Preview:"})," ",es.previewText]}),es.bccToAdmin&&(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"BCC:"})," ",es.bccToAdmin]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Message Stream:"})," ","broadcast"===es.messageStream?"Broadcast/Marketing":"Outbound/Transactional"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Test Recipient:"})," ",es.recipientEmails[0]]})]})]}),(0,a.jsxs)("div",{className:"p-3 bg-white border border-blue-200 rounded",children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-blue-900 mb-2",children:"\uD83D\uDD12 Email Headers (Postmark)"}),(0,a.jsxs)("div",{className:"text-xs text-gray-700 space-y-1",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"MessageStream:"})," ",es.messageStream]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Tag:"})," platform-newsletter-test"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"TrackOpens:"})," false (test mode)"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"TrackLinks:"})," None (test mode)"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"List-Unsubscribe:"})," Personalized (if subscriber exists)"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"List-Unsubscribe-Post:"})," One-Click"]})]})]}),(0,a.jsxs)("div",{className:"p-3 bg-white border border-blue-200 rounded",children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-blue-900 mb-2",children:"\uD83D\uDCC4 Request Payload"}),(0,a.jsx)("pre",{className:"text-xs bg-gray-50 p-2 rounded border border-gray-200 overflow-x-auto max-h-48 overflow-y-auto",children:JSON.stringify(es,null,2)})]}),(0,a.jsxs)("div",{className:"p-3 bg-yellow-50 border border-yellow-300 rounded",children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-yellow-900 mb-2",children:"⚠️ Important"}),(0,a.jsxs)("ul",{className:"text-xs text-yellow-800 space-y-1 list-disc list-inside",children:[(0,a.jsx)("li",{children:"Test job will be created with status 'pen
72ding'"}),(0,a.jsx)("li",{children:"You must manually change status to 'processing' in Firestore to send"}),(0,a.jsxs)("li",{children:["Test email will be sent to: ",es.recipientEmails[0]]}),(0,a.jsx)("li",{children:"Subject will be prefixed with [TEST]"})]})]}),(0,a.jsxs)("div",{className:"flex gap-3",children:[(0,a.jsx)(i.$,{onClick:()=>{ee(!1),et(null)},variant:"outline",className:"flex-1",children:"Cancel"}),(0,a.jsx)(i.$,{onClick:ta,disabled:!es||_,className:"flex-1 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700",children:_?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.A,{className:"mr-2 h-4 w-4 animate-spin"})," Creating Test Job..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(b.A,{className:"mr-2 h-4 w-4"})," ✓ Create Test Job and Send"]})})]})]})]}):eb&&ef?(0,a.jsxs)("div",{className:"border rounded-lg p-4 border-cyan-200 bg-cyan-50",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold text-cyan-900",children:"Email Job Preview"}),(0,a.jsx)("button",{onClick:()=>{ey(!1),ej(null)},className:"text-sm font-medium text-cyan-600 hover:text-cyan-800",children:"✕ Close"})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"p-3 bg-white border border-cyan-200 rounded",children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-cyan-900 mb-2",children:"\uD83D\uDCE7 Email Configuration"}),(0,a.jsxs)("div",{className:"text-xs text-gray-700 space-y-1",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"From:"})," ",ef.fromName," <",ef.fromEmail,">"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Reply-To:"})," ",ef.replyToEmail]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Subject:"})," ",ef.subject]}),ef.previewText&&(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Preview:"})," ",ef.previewText]}),ef.bccToAdmin&&(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"BCC:"})," ",ef.bccToAdmin]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Message Stream:"})," ","broadcast"===ef.messageStream?"Broadcast/Marketing":"Outbound/Transactional"]})]})]}),(0,a.jsxs)("div",{className:"p-3 bg-white border border-cyan-200 rounded",children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-cyan-900 mb-2",children:"\uD83D\uDCCA Batch Configuration"}),(0,a.jsxs)("div",{className:"text-xs text-gray-700 space-y-1",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Total Recipients:"})," ",ef.totalRecipients]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Batch Size:"})," ",ef.batchSize," emails per batch"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Batch Delay:"})," ",ef.batchDelay/1e3," seconds"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Total Batches:"})," ",ef.totalBatches]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Estimated Time:"})," ~",Math.ceil(ef.totalBatches*ef.batchDelay/6e4)," minutes"]})]})]}),(0,a.jsxs)("div",{className:"p-3 bg-white border border-cyan-200 rounded",children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-cyan-900 mb-2",children:"\uD83D\uDD12 Email Headers (Postmark)"}),(0,a.jsxs)("div",{className:"text-xs text-gray-700 space-y-1",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"MessageStream:"})," broadcast"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Tag:"})," platform-newsletter"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"TrackOpens:"})," true"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"TrackLinks:"})," HtmlAndText"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"List-Unsubscribe:"})," Personalized per recipient"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"List-Unsubscribe-Post:"})," One-Click"]})]})]}),(0,a.jsxs)("div",{className:"p-3 bg-white border border-cyan-200 rounded",children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-cyan-900 mb-2",children:"\uD83D\uDCC4 Request Payload"}),(0,a.jsx)("pre",{className:"text-xs bg-gray-50 p-2 rounded border border-gray-200 overflow-x-auto max-h-48 overflow-y-auto",children:JSON.stringify(ef,null,2)})]}),(0,a.jsxs)("div",{className:"p-3 bg-yellow-50 border border-yellow-300 rounded",children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-yellow-900 mb-2",children:"⚠️ Important"}),(0,a.jsxs)("ul",{className:"text-xs text-yellow-800 space-y-1 list-disc list-inside",children:[(0,a.jsx)("li",{children:"Job will be created with status 'pen
72ding'"}),(0,a.jsxs)("li",{children:["To start: in Firestore set status to 'processing' ",(0,a.jsx)("strong",{children:"and"})," set lastProcessedAt to a new value (e.g. timestamp 'now') — both required"]}),(0,a.jsx)("li",{children:"You can cancel the job at any time by changing status to 'cancelled'"}),(0,a.jsx)("li",{children:"Progress will be tracked in real-time in the emailJobsCRM collection"})]})]}),(0,a.jsxs)("div",{className:"flex gap-3",children:[(0,a.jsx)(i.$,{onClick:()=>{ey(!1),ej(null)},variant:"outline",className:"flex-1",children:"Cancel"}),(0,a.jsx)(i.$,{onClick:ts,disabled:Z,className:"flex-1 bg-gradient-to-r from-cyan-600 to-blue-600 hover:from-cyan-700 hover:to-blue-700",children:Z?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.A,{className:"mr-2 h-4 w-4 animate-spin"})," Creating Job..."]}):(0,a.jsx)(a.Fragment,{children:"✓ Create Job"})})]})]})]}):null:(0,a.jsxs)("div",{className:"flex gap-4",children:[(0,a.jsxs)(i.$,{onClick:s9,disabled:!z||!s||!H,variant:"outline",className:"flex-1",children:[(0,a.jsx)(d.A,{className:"mr-2 h-4 w-4"}),"Preview Test Job & Headers"]}),(0,a.jsxs)(i.$,{onClick:te,disabled:!z||0===s4().length||Z,className:"flex-1 bg-gradient-to-r from-cyan-600 to-blue-600 hover:from-cyan-700 hover:to-blue-700",children:[(0,a.jsx)(o.A,{className:"mr-2 h-4 w-4"}),"Preview Bulk Job & Headers (",s4().length," recipients)"]})]})]})]}),(0,a.jsxs)(l.Zp,{className:"bg-white rounded-lg shadow-sm p-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"p-2 bg-gradient-to-br from-slate-500 to-gray-600 rounded-lg",children:(0,a.jsx)(d.A,{className:"w-6 h-6 text-white"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-2xl font-medium text-gray-700",children:"Send History"}),(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Past campaigns — what was sent, to which list, and when"})]})]}),(0,a.jsx)(i.$,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{let e=!sY;sK(e),e&&0===sq.length&&s3()},children:sY?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.A,{className:"mr-1 h-4 w-4"})," Hide"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.A,{className:"mr-1 h-4 w-4"})," Show"]})})]}),sY&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"flex justify-end mb-3",children:(0,a.jsx)(i.$,{variant:"ghost",size:"sm",onClick:s3,disabled:sV,className:"text-gray-600",children:sV?(0,a.jsx)(c.A,{className:"h-4 w-4 animate-spin"}):"Refresh"})}),sV&&0===sq.length?(0,a.jsx)(C,{message:"Loading send history..."}):0===sq.length?(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"No sends yet."}):(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-sm",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"text-left text-xs text-gray-500 border-b",children:[(0,a.jsx)("th",{className:"py-2 pr-3 font-medium",children:"Date"}),(0,a.jsx)("th",{className:"py-2 pr-3 font-medium",children:"Subject"}),(0,a.jsx)("th",{className:"py-2 pr-3 font-medium",children:"Sent to (list / filters)"}),(0,a.jsx)("th",{className:"py-2 pr-3 font-medium",children:"Recipients"}),(0,a.jsx)("th",{className:"py-2 pr-3 font-medium",children:"Status"})]})}),(0,a.jsx)("tbody",{children:sq.map((e,s)=>(0,a.jsxs)("tr",{className:"border-b last:border-0 align-top",children:[(0,a.jsx)("td",{className:"py-2 pr-3 whitespace-nowrap text-gray-600",children:e.createdAt?new Date(e.createdAt).toLocaleDateString():"—"}),(0,a.jsxs)("td",{className:"py-2 pr-3 text-gray-800",children:[e.isTest&&(0,a.jsx)("span",{className:"text-xs bg-blue-100 text-blue-700 px-1.5 py-0.5 rounded mr-1",children:"TEST"}),e.subject||"—"]}),(0,a.jsx)("td",{className:"py-2 pr-3 text-gray-600",children:e.audienceLabel||(0,a.jsx)("span",{className:"text-gray-400 italic",children:"not recorded"})}),(0,a.jsxs)("td",{className:"py-2 pr-3 whitespace-nowrap text-gray-600",children:[e.sentCount,"/",e.totalRecipients,e.failedCount>0&&(0,a.jsxs)("span",{className:"text-red-500",children:[" (",e.failedCount," failed)"]})]}),(0,a.jsx)("td",{className:"py-2 pr-3",children:(0,a.jsx)("span",{className:`text-xs px-2 py-0.5 rounded ${"completed"===e.status?"bg-green-100 text-green-700":"processing"===e.status?"bg-cyan-100 text-cyan-700":"failed"===e.status?"bg-red-100 text-red-700":"cancelled"===e.status?"bg-orange-100 text-orange-700":"bg-gray-100 text-gray-600"}`,children:e.status})})]},s))})]})})]})]})]})}},89239:(e,s,t)=>{t.d(s,{$:()=>o});var a=t(95155),r=t(12115),l=t(42442),i=t(18460),n=t(40980);let c=(0,i.F)("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),o=r.forwardRef(({className:e,variant:s,size:t,asChild:r=!1,...i},o)=>{let d=r?l.DX:"button";return(0,a.jsx)(d,{className:(0,n.cn)(c({variant:s,size:t,className:e})),ref:o,...i})});o.displayName="Button"},92289:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(78340).A)("mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]])}}]);

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.