1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3284],{49835:(e,t,s)=>{"use strict";s.d(t,{A:()=>n});var r=s(37876),a=s(14232);function n({value:e,onChange:t,onSelect:s,className:n,placeholder:i}){let[l,o]=(0,a.useState)([]),[d,c]=(0,a.useState)(!1),[h]=(0,a.useState)(()=>Math.random().toString(36).slice(2)+Date.now().toString(36)),x=(0,a.useRef)(),m=(0,a.useRef)();async function u(e){c(!1),o([]),t(e.description.split(",")[0]);try{let r=await fetch(`/api/places/address?placeId=${encodeURIComponent(e.placeId)}&token=${h}`),a=await r.json();a.detail&&(t(a.detail.line1||e.description.split(",")[0]),s?.(a.detail))}catch{}}return(0,a.useEffect)(()=>{let e=e=>{m.current&&!m.current.contains(e.target)&&c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,r.jsxs)("div",{className:"relative",ref:m,children:[(0,r.jsx)("input",{value:e,onChange:e=>{t(e.target.value),function(e){if(clearTimeout(x.current),!e||e.trim().length<3){o([]),c(!1);return}x.current=setTimeout(async()=>{try{let t=await fetch(`/api/places/address?q=${encodeURIComponent(e)}&token=${h}`),s=(await t.json()).predictions||[];o(s),c(s.length>0)}catch{o([]),c(!1)}},250)}(e.target.value)},onFocus:()=>l.length&&c(!0),onKeyDown:e=>{"Enter"===e.key&&e.preventDefault()},placeholder:i,autoComplete:"off",className:n}),d&&(0,r.jsx)("div",{className:"absolute z-50 left-0 right-0 mt-1 bg-white border border-gray-200 rounded-2xl shadow-lg overflow-hidden",children:l.map((e,t)=>(0,r.jsxs)("button",{type:"button",onClick:()=>u(e),className:"flex items-start gap-2 w-full text-left px-4 py-2.5 text-sm text-brand-navy hover:bg-orange-50 border-b border-gray-50 last:border-0",children:[(0,r.jsxs)("svg",{width:"15",height:"15",className:"text-gray-400 mt-0.5 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{d:"M21 10c0 7-9 12-9 12s-9-5-9-12a9 9 0 0 1 18 0z"}),(0,r.jsx)("circle",{cx:"12",cy:"10",r:"3"})]}),(0,r.jsx)("span",{children:e.description})]},e.placeId||t))})]})}},56747:(e,t,s)=>{"use strict";function r(e){let t=String(e||"").replace(/\D/g,"");return(11===t.length&&t.startsWith("1")&&(t=t.slice(1)),(t=t.slice(0,10)).length<4)?t:t.length<7?`(${t.slice(0,3)}) ${t.slice(3)}`:`(${t.slice(0,3)}) ${t.slice(3,6)}-${t.slice(6)}`}function a(e){let t=String(e||"").replace(/\D/g,"");return(11===t.length&&t.startsWith("1")&&(t=t.slice(1)),10!==t.length)?null:`+1${t}`}s.d(t,{qH:()=>r,yk:()=>a}),s(65364)},72552:()=>{},72784:(e,t,s)=>{"use strict";var r=s(65364);s(72552);var a=s(14232),n=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(a),i=void 0!==r&&r.env&&!0,l=function(e){return"[object String]"===Object.prototype.toString.call(e)},o=function(){function e(e){var t=void 0===e?{}:e,s=t.name,r=void 0===s?"stylesheet":s,a=t.optimizeForSpeed,n=void 0===a?i:a;d(l(r),"`name` must be a string"),this._name=r,this._deletedRulePlaceholder="#"+r+"-deleted-rule____{}",d("boolean"==typeof n,"`optimizeForSpeed` must be a boolean"),this._optimizeForSpeed=n,this._serverSheet=void 0,this._tags=[],this._injected=!1,this._rulesCount=0;var o=document.querySelector('meta[property="csp-nonce"]');this._nonce=o?o.getAttribute("content"):null}var t,s=e.prototype;return s.setOptimizeForSpeed=function(e){d("boolean"==typeof e,"`setOptimizeForSpeed` accepts a boolean"),d(0===this._rulesCount,"optimizeForSpeed cannot be when rules have already been inserted"),this.flush(),this._optimizeForSpeed=e,this.inject()},s.isOptimizeForSpeed=function(){return this._optimizeForSpeed},s.inject=function(){var e=this;if(d(!this._injected,"sheet already injected"),this._injected=!0,this._optimizeForSpeed){this._tags[0]=this.makeStyleTag(this._name),this._optimizeForSpeed="insertRule"in this.getSheet(),this._optimizeForSpeed||(i||console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode."),this.flush(),this._injected=!0);return}this._serverSheet={cssRules:[],insertRule:function(t,s){return"number"==typeof s?e._serverSheet.cssRules[s]={cssText:t}:e._serverSheet.cssRules.push({cssText:t}),s},deleteRule:function(t){e._serverSheet.cssRules[t]=null}}},s.getSheetForTag=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}
1,s.getSheet=function(){return this.getSheetForTag(this._tags[this._tags.length-1])},s.insertRule=function(e,t){if(d(l(e),"`insertRule` accepts only strings"),this._optimizeForSpeed){var s=this.getSheet();"number"!=typeof t&&(t=s.cssRules.length);try{s.insertRule(e,t)}catch(t){return i||console.warn("StyleSheet: illegal rule: \n\n"+e+"\n\nSee https://stackoverflow.com/q/20007992 for more info"),-1}}else{var r=this._tags[t];this._tags.push(this.makeStyleTag(this._name,e,r))}return this._rulesCount++},s.replaceRule=function(e,t){if(this._optimizeForSpeed){var s=this.getSheet();if(t.trim()||(t=this._deletedRulePlaceholder),!s.cssRules[e])return e;s.deleteRule(e);try{s.insertRule(t,e)}catch(r){i||console.warn("StyleSheet: illegal rule: \n\n"+t+"\n\nSee https://stackoverflow.com/q/20007992 for more info"),s.insertRule(this._deletedRulePlaceholder,e)}}else{var r=this._tags[e];d(r,"old rule at index `"+e+"` not found"),r.textContent=t}return e},s.deleteRule=function(e){if(this._optimizeForSpeed)this.replaceRule(e,"");else{var t=this._tags[e];d(t,"rule at index `"+e+"` not found"),t.parentNode.removeChild(t),this._tags[e]=null}},s.flush=function(){this._injected=!1,this._rulesCount=0,this._tags.forEac
1h(function(e){return e&&e.parentNode.removeChild(e)}),this._tags=[]},s.cssRules=function(){var e=this;return this._tags.reduce(function(t,s){return s?t=t.concat(Array.prototype.map.call(e.getSheetForTag(s).cssRules,function(t){return t.cssText===e._deletedRulePlaceholder?null:t})):t.push(null),t},[])},s.makeStyleTag=function(e,t,s){t&&d(l(t),"makeStyleTag accepts only strings as second parameter");var r=document.createElement("style");this._nonce&&r.setAttribute("nonce",this._nonce),r.type="text/css",r.setAttribute("data-"+e,""),t&&r.appendChild(document.createTextNode(t));var a=document.head||document.getElementsByTagName("head")[0];return s?a.insertBefore(r,s):a.appendChild(r),r},t=[{key:"length",get:function(){return this._rulesCount}}],function(e,t){for(var s=0;s<t.length;s++){var r=t[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,t),e}();function d(e,t){if(!e)throw Error("StyleSheet: "+t+".")}var c=function(e){for(var t=5381,s=e.length;s;)t=33*t^e.charCodeAt(--s);return t>>>0},h={};function x(e,t){if(!t)return"jsx-"+e;var s=String(t),r=e+s;return h[r]||(h[r]="jsx-"+c(e+"-"+s)),h[r]}function m(e,t){var s=e+t;return h[s]||(h[s]=t.replace(/__jsx-style-dynamic-selector/g,e)),h[s]}var u=function(){function e(e){var t=void 0===e?{}:e,s=t.styleSheet,r=void 0===s?null:s,a=t.optimizeForSpeed,n=void 0!==a&&a;this._sheet=r||new o({name:"styled-jsx",optimizeForSpeed:n}),this._sheet.inject(),r&&"boolean"==typeof n&&(this._sheet.setOptimizeForSpeed(n),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),this._fromServer=void 0,this._indices={},this._instancesCounts={}}var t=e.prototype;return t.add=function(e){var t=this;void 0===this._optimizeForSpeed&&(this._optimizeForSpeed=Array.isArray(e.children),this._sheet.setOptimizeForSpeed(this._optimizeForSpeed),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),this._fromServer||(this._fromServer=this.selectFromServer(),this._instancesCounts=Object.keys(this._fromServer).reduce(function(e,t){return e[t]=0,e},{}));var s=this.getIdAndRules(e),r=s.styleId,a=s.rules;if(r in this._instancesCounts){this._instancesCounts[r]+=1;return}var n=a.map(function(e){return t._sheet.insertRule(e)}).filter(function(e){return -1!==e});this._indices[r]=n,this._instancesCounts[r]=1},t.remove=function(e){var t=this,s=this.getIdAndRules(e).styleId;if(function(e,t){if(!e)throw Error("StyleSheetRegistry: "+t+".")}(s in this._instancesCounts,"styleId: `"+s+"` not found"),this._instancesCounts[s]-=1,this._instancesCounts[s]<1){var r=this._fromServer&&this._fromServer[s];r?(r.parentNode.removeChild(r),delete this._fromServer[s]):(this._indices[s].forEach(function(e){return t._sheet.deleteRule(e)}),delete this._indices[s]),delete this._instancesCounts[s]}},t.update=function(e,t){this.add(t),this.remove(e)},t.flush=function(){this._sheet.flush(),this._sheet.inject(),this._fromServer=void 0,this._indices={},this._instancesCounts={}},t.cssRules=function(){var e=this,t=this._fromServer?Object.keys(this._fromServer).map(function(t){return[t,e._fromServer[t]]}):[],s=this._sheet.cssRules();return t.concat(Object.keys(this._indices).map(function(t){return[t,e._indices[t].map(function(e){return s[e].cssText}).join(e._optimizeForSpeed?"":"\n")]}).filter(function(e){return!!e[1]}))},t.styles=function(e){var t,s;return t=this.cssRules(),void 0===(s=e)&&(s={}),t.map(function(e){var t=e[0],r=e[1];return n.default.createElement("style",{id:"__"+t,key:"__"+t,nonce:s.nonce?s.nonce:void 0,dangerouslySetInnerHTML:{__html:r}})})},t.getIdAndRules=function(e){var t=e.children,s=e.dynamic,r=e.id;if(s){var a=x(r,s);return{styleId:a,rules:Array.isArray(t)?t.map(function(e){return m(a,e)}):[m(a,t)]}}return{styleId:x(r),rules:Array.isArray(t)?t:[t]}},t.selectFromServer=function(){return Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]')).reduce(function(e,t){return e[t.id.slice(2)]=t,e},{})},e}(),p=a.createContext(null);p.displayName="StyleSheetContext";var g=n.default.useInsertionEffect||n.default.useLayoutEffect,f=new u;function y(e){var t=f||a.useContext(p);return t&&g(function(){return t.add(e),function(){t.remove(e)}},[e.id,String(e.dynamic)]),null}y.dynamic=function(e){return e.map(function(e){return x(e[0],e[1])}).join(" ")},t.style=y},74888:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboard/contacts",function(){return s(97103)}])},75961:(e,t,s)=>{"use strict";e.exports=s(72784).style},97103:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>$});var r=s(37876),a=s(14232),n=s(89099),i=s(90030),l=s(49835),o=s(56747);let d=e=>String(e).replace(/<br\s*\/?>/gi," ").replace(/<[^>]+>/g,"").replace(/ /gi," ").replace(/&/gi,"&").replace(/</gi,"<").replace(/>/gi,">").replace(/"/gi,'"').replace(/'/gi,"'").replace(/\s+/g," ").trim();function c(e){if(/<\s*(table|tr|td)\b/i.test(String(e||"").slice(0,4e3)))return{rows:function(e){let t=String(e||""),s=[];for(let e of t.matchAll(/<tr[^>]*>([\s\S]*?)<\/tr>/gi)){let t=[...e[1].matchAll(/<t[dh][^>]*>([\s\S]*?)<\/t[dh]>/gi)].map(e=>d(e[1]));t.length&&s.push(t)}return s.filter(e=>e.some(e=>""!==e))}(e),format:"html"};let t=function(e){let t=String(e||"").split(/\r?\n/).find(e=>e.trim())||"",s=[[",",0],[";",0],[" ",0],["|",0]].map(([e])=>{let s=0,r=!1;for(let a of t)'"'===a?r=!r:a===e&&!r&&s++;return[e,s]});return s.sort((e,t)=>
1t[1]-e[1]),s[0][1]>0?s[0][0]:","}(e);return{rows:function(e,t=","){let s=[],r=[],a="",n=!1,i=String(e||"").replace(/^/,"");for(let e=0;e<i.length;e++){let l=i[e];if(n){'"'===l?'"'===i[e+1]?(a+='"',e++):n=!1:a+=l;continue}if('"'===l){n=!0;continue}if(l===t){r.push(a),a="";continue}if("\r"!==l){if("\n"===l){r.push(a),s.push(r),r=[],a="";continue}a+=l}}return(a.length||r.length)&&(r.push(a),s.push(r)),s.map(e=>e.map(e=>e.trim())).filter(e=>e.some(e=>""!==e))}(e,t),format:","===t?"csv":`delimited:${t}`}}let h=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,x=e=>h.test(String(e||"").trim());function m(e){let t=String(e||"").replace(/\D/g,"");return!!(10===t.length||11===t.length&&t.startsWith("1"))}let u=e=>/^\d{5}(-\d{4})?$/.test(String(e||"").trim()),p=e=>/^[A-Z]{2}$/.test(String(e||"").trim()),g=e=>/^-?\$?\d+(\.\d{1,2})?$/.test(String(e||"").trim()),f=e=>/\b(19|20)\d{2}\b/.test(String(e||""))&&/[a-z]{3}|[/-]/i.test(String(e||"")),y=e=>{let t=String(e||"").trim();return!!t&&t.length<60&&/^[\p{L}][\p{L}'.\- ]*$/u.test(t)&&!p(t)},b={email:["email","emailaddress","email1","primaryemail","buyeremail","contactemail","mail","eaddress"],phone:["phone","phonenumber","mobile","mobilenumber","cell","cellphone","telephone","tel","contactnumber","homephone"],firstName:["firstname","fname","givenname","first"],lastName:["lastname","lname","surname","familyname","last"],fullName:["name","fullname","customername","buyername","attendee","attendeename","contactname","billingname","purchasername"],address:["address","address1","streetaddress","street","mailingaddress","addressline1"],city:["city","town"],state:["state","province","region"],zip:["zip","zipcode","postalcode","postcode"],company:["company","organisation","organization","employer","business"]};function w(e=[]){let t={},s=new Set;return e.forEach((e,r)=>{let a=String(e||"").toLowerCase().replace(/[^a-z0-9]/g,"");if(a){for(let[e,n]of Object.entries(b))if(n.includes(a)){null==t[e]&&(t[e]=r,s.add(r));return}}}),t}function j(e=[]){let t=e[0];return!!t&&!(t.filter(e=>x(e)||m(e)||u(e)).length>0)&&(Object.keys(w(t)).length>0||t.filter(e=>/^[\p{L} _/-]{2,30}$/u.test(String(e||"").trim())).length>=Math.ceil(t.length/2))}let v=e=>String(e||"").trim().replace(/\s+/g," ");function k(e){let t=v(e).split(" ").filter(Boolean);return t.length?1===t.length?{firstName:t[0],lastName:null}:{firstName:t[0],lastName:t.slice(1).join(" ")}:{firstName:null,lastName:null}}function N({sub:e,onClose:t,onSave:s}){let[n,i]=(0,a.useState)({email:e.email||"",firstName:e.first_name||"",lastName:e.last_name||"",phone:e.phone||"",address:e.address||"",status:e.status||"active",volunteer:!!e.volunteer,vendor:!!e.vendor}),[l,d]=(0,a.useState)(!1),[c,h]=(0,a.useState)("");function x(e){i(t=>({...t,[e.target.name]:e.target.value}))}async function m(t){t.preventDefault(),d(!0);try{h("");let t=await fetch(`/api/admin/subscribers?id=${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),r=await t.json();if(r.error)return void h(r.error);s(r.subscriber)}catch{h("Could not save â the connection dropped.")}finally{d(!1)}}let u="w-full border border-gray-200 dark:border-white/10 rounded-xl px-4 py-3 text-sm focus:outline-hidden focus:ring-2 focus:ring-[#F26644]/20 focus:border-[#F26644] transition-all dark:text-white dark:placeholder-white/30",p="block text-xs font-semibold text-gray-500 dark:text-white/60 uppercase tracking-wide mb-1.5";return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.5)"},children:(0,r.jsxs)("div",{className:"bg-white dark:bg-white/4 roun
1ded-3xl shadow-2xl w-full max-w-md max-h-[90vh] overflow-y-auto",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-7 py-5 border-b border-gray-100 dark:border-white/10",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"font-bold text-gray-900 dark:text-white",children:"Edit contact"}),(0,r.jsx)("p",{className:"text-gray-400 dark:text-white/40 text-xs mt-0.5",children:e.email})]}),(0,r.jsx)("button",{onClick:t,className:"w-8 h-8 rounded-full bg-gray-100 dark:bg-white/6 hover:bg-gray-200 dark:hover:bg-white/6 flex items-center justify-center text-gray-500 dark:text-white/60 transition-colors text-lg leading-none",children:"\xd7"})]}),(0,r.jsxs)("form",{onSubmit:m,className:"px-7 py-6 space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:p,children:"Email"}),(0,r.jsx)("input",{type:"email",name:"email",value:n.email,onChange:x,required:!0,className:u})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:p,children:"First name"}),(0,r.jsx)("input",{type:"text",name:"firstName",value:n.firstName,onChange:x,placeholder:"Optional",className:u})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:p,children:"Last name"}),(0,r.jsx)("input",{type:"text",name:"lastName",value:n.lastName,onChange:x,placeholder:"Optional",className:u})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:p,children:"Phone"}),(0,r.jsx)("input",{type:"tel",name:"phone",value:n.phone,onChange:e=>i(t=>({...t,phone:(0,o.qH)(e.target.value)})),placeholder:"(201) 555-0100",className:u})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:p,children:"Mailing address"}),(0,r.jsx)("textarea",{name:"address",value:n.address,onChange:x,placeholder:"Optional",rows:2,className:u})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:p,children:"Status"}),(0,r.jsxs)("select",{name:"status",value:n.status,onChange:x,className:u,children:[(0,r.jsx)("option",{value:"active",children:"Active"}),(0,r.jsx)("option",{value:"unsubscribed",children:"Unsubscribed"})]})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2.5 cursor-pointer select-none",children:[(0,r.jsx)("input",{type:"checkbox",checked:n.volunteer,onChange:e=>i(t=>({...t,volunteer:e.target.checked})),className:"w-4 h-4 rounded-sm border-gray-300 dark:border-white/10 text-[#0F2044] focus:ring-[#F26644]/30"}),(0,r.jsx)("span",{className:"text-sm text-gray-700 dark:text-white/60 font-medium",children:"Volunteer"})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2.5 cursor-pointer select-none",children:[(0,r.jsx)("input",{type:"checkbox",checked:n.vendor,onChange:e=>i(t=>({...t,vendor:e.target.checked})),className:"w-4 h-4 rounded-sm border-gray-300 dark:border-white/10 text-[#0F2044] focus:ring-[#F26644]/30"}),(0,r.jsxs)("span",{className:"text-sm text-gray-700 dark:text-white/60 font-medium",children:["Vendor ",(0,r.jsx)("span",{className:"text-gray-400 dark:text-white/40 font-normal",children:"(paid customer â excluded from main list)"})]})]}),c&&(0,r.jsx)("p",{className:"text-red-500 text-xs",children:c}),(0,r.jsxs)("div",{className:"flex gap-3 pt-1",children:[(0,r.jsx)("button",{type:"button",onClick:t,className:"flex-1 border border-gray-200 dark:border-white/10 text-gray-600 dark:text-white/60 text-sm font-semibold py-3 rounded-2xl hover:bg-gray-50 dark:hover:bg-white/6 transition-all",children:"Cancel"}),(0,r.jsx)("button",{type:"submit",disabled:l,className:"flex-1 text-white text-sm font-bold py-3 rounded-2xl shadow-md hover:opacity-90 transition-all disabled:opacity-50",style:{background:"linear-gradient(135deg,#F26644,#FF9933)"},children:l?"Savingâ¦":"Save changes"})]})]})]})})}function S({children:e,color:t}){let s={green:"bg-green-100 text-green-700",purple:"bg-purple-100 text-purple-700",gray:"bg-gray-100 text-gray-500",blue:"bg-orange-100 text-orange-700"};return(0,r.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-semibold ${s[t]??s.gray}`,children:e})}function C({onClose:e,onImport:t}){let[s,n]=(0,a.useState)([]),[i,l]=(0,a.useState)(null),[o,d]=(0,a.useState)(!1),[h,b]=(0,a.useState)(null),[N,S]=(0,a.useState)(""),[C,_]=(0,a.useState)(!1),[F,R]=(0,a.useState)(!1),[$,z]=(0,a.useState)(""),M=(0,a.useRef)(""),E=(0,a.useRef)();function O(e,t=null){let{contacts:s,report:r}=function(e,{mapping:t=null}={}){let{rows:s,format:r}=c(e);if(!s.length)return{contacts:[],report:{format:r,rows:0,reason:"no rows found"}};
1let a=j(s)?s[0]:null,n=a?s.slice(1):s,i=t||(a?w(a):{}),l=t?"given":a?"header":"values";t||null!=i.email||null!=i.phone||(i={...function(e=[],{sampleSize:t=40}={}){let s=e.slice(0,t);if(!s.length)return{};let r=Math.max(...s.map(e=>e.length)),a={},n={email:[-1,0],phone:[-1,0],zip:[-1,0],state:[-1,0],fullName:[-1,0],address:[-1,0]};for(let e=0;e<r;e++){let t=s.map(t=>t[e]).filter(e=>""!==String(e||"").trim());if(!t.length)continue;let r=e=>t.filter(e).length/t.length;for(let[t,s]of Object.entries({email:r(x),phone:r(m),zip:r(u),state:r(p),fullName:r(y)-r(g)-r(f),address:r(e=>/^\d+\s+\p{L}/u.test(String(e))&&String(e).length>8)}))s>=.66&&s>n[t][1]&&(n[t]=[e,s])}for(let[e,[t]]of Object.entries(n))t>=0&&(a[e]=t);return a}(n),...i},l=a?"values (header not recognised)":"values (no header row)");let o=function(e=[]){let t=new Map,s=e=>e.email?`e:${e.email}`:`p:${e.phone}`;for(let r of e){let e=s(r),a=t.get(e);if(!a){t.set(e,{...r});continue}for(let e of["email","phone","firstName","lastName","address","company"])!a[e]&&r[e]&&(a[e]=r[e])}return[...t.values()]}(n.map(e=>(function(e=[],t={}){let s=s=>null==t[s]?"":v(e[t[s]]),r=s("email").toLowerCase(),a=function e(t){let s=String(t||"").replace(/\D/g,"");return 10===s.length?`(${s.slice(0,3)}) ${s.slice(3,6)}-${s.slice(6)}`:11===s.length&&s.startsWith("1")?e(s.slice(1)):null}(s("phone"));if(!x(r)&&!a)return null;let n=s("firstName")||null,i=s("lastName")||null;if(n&&!i&&n.includes(" ")){let e=k(n);n=e.firstName,i=e.lastName}if(!n&&s("fullName")){let e=k(s("fullName"));n=e.firstName,i=e.lastName}let l=[s("address"),s("city"),[s("state"),s("zip")].filter(Boolean).join(" ")].map(e=>e.trim()).filter(Boolean).join(", ")||null;return{email:x(r)?r:null,phone:a,firstName:n||null,lastName:i||null,address:l,company:s("company")||null}})(e,i)).filter(Boolean));return{contacts:o,report:{format:r,rows:n.length,header:a||null,hasHeader:!!a,mapping:i,strategy:l,mapped:Object.keys(i),found:o.length,withEmail:o.filter(e=>e.email).length,withPhone:o.filter(e=>e.phone).length,duplicatesMerged:n.length-o.length,needsHelp:null==i.email&&null==i.phone}}}(e,t?{mapping:t}:{});n(s),l(r),S(s.length?"":"No contacts found in that file.")}async function T(){if(M.current){_(!0);try{let{rows:e}=c(M.current),t=j(e)?e[0]:[],s=t.length?e.slice(1):e,r=await fetch("/api/admin/import-map",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({header:t,shapes:function(e=[],{sampleSize:t=20}={}){let s=e.slice(0,t);if(!s.length)return[];let r=Math.max(...s.map(e=>e.length)),a=[];for(let e=0;e<r;e++){let t=s.map(t=>t[e]).filter(e=>""!==String(e||"").trim());if(!t.length){a.push("always empty");continue}let r=t.length,n=[],i=e=>Math.round(t.filter(e).length/r*100);for(let[e,t]of[["email addresses",x],["phone numbers",m],["5-digit postcodes",u],["2-letter state codes",p],["names",y],["money amounts",e=>/^-?\$?\d+(\.\d{1,2})?$/.test(String(e).trim())],["dates",e=>/\b(19|20)\d{2}\b/.test(String(e))],["whole numbers",e=>/^\d+$/.test(String(e).trim())]]){let s=i(t);s>=50&&n.push(`${s}% ${e}`)}let l=t.map(e=>String(e).length);n.push(`length ${Math.min(...l)}â${Math.max(...l)}`),a.push(n.join(", "))}return a}(s)})}),a=await r.json();a.mapping&&Object.keys(a.mapping).length?O(M.current,a.mapping):S(a.note||a.error||"Could not work out the columns.")}catch{S("Could not work out the columns.")}finally{_(!1)}}}async function A(){if(!s.length)return;d(!0),S("");let e=await fetch("/api/admin/import-csv",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rows:s.map(e=>({email:e.email,first_name:e.firstName,last_name:e.lastName,phone:e.phone,address:e.address})),source:"csv-import",sendWelcome:F})}),r=await e.json();d(!1),r.error?S(r.error):(b(r),t())}return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.5)"},children:(0,r.jsxs)("div",{className:"bg-white dark:bg-white/4 roun
1ded-3xl shadow-2xl w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-7 py-5 border-b border-gray-100 dark:border-white/10",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"font-bold text-gray-900 dark:text-white",children:"Import Contacts"}),(0,r.jsx)("p",{className:"text-gray-400 dark:text-white/40 text-xs mt-0.5",children:"Upload a CSV with email, name, and phone columns"})]}),(0,r.jsx)("button",{onClick:e,className:"w-8 h-8 rounded-full bg-gray-100 dark:bg-white/6 hover:bg-gray-200 dark:hover:bg-white/6 flex items-center justify-center text-gray-500 dark:text-white/60 transition-colors",children:"\xd7"})]}),(0,r.jsx)("div",{className:"px-7 py-6 space-y-5",children:h?(0,r.jsxs)("div",{className:"text-center py-4",children:[(0,r.jsx)("div",{className:"w-14 h-14 rounded-2xl bg-green-100 flex items-center justify-center mx-auto mb-4",children:(0,r.jsx)("svg",{width:"24",height:"24",className:"text-green-600",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})})}),(0,r.jsxs)("p",{className:"font-bold text-gray-900 dark:text-white text-lg",children:[h.imported," contacts imported"]}),h.welcomed>0&&(0,r.jsxs)("p",{className:"text-gray-400 dark:text-white/40 text-sm mt-1",children:[h.welcomed," welcome email",1===h.welcomed?"":"s"," sent"]}),!h.sendWelcome&&(0,r.jsx)("p",{className:"text-gray-400 dark:text-white/40 text-sm mt-1",children:"No welcome emails were sent"}),h.optedOut>0&&(0,r.jsxs)("p",{className:"text-gray-400 dark:text-white/40 text-sm mt-1",children:[h.optedOut," left opted-out and untouched"]}),h.noEmail>0&&(0,r.jsxs)("p",{className:"text-gray-400 dark:text-white/40 text-sm mt-1",children:[h.noEmail," had no email address and could not be saved"]}),h.skipped>h.noEmail&&(0,r.jsxs)("p",{className:"text-gray-400 dark:text-white/40 text-sm mt-1",children:[h.skipped-h.noEmail," other rows skipped"]}),(0,r.jsx)("button",{onClick:e,className:"mt-5 bg-[#0F2044] text-white text-sm font-bold px-6 py-2.5 rounded-2xl hover:bg-[#0F2044] transition-all",children:"Done"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{onClick:()=>E.current.click(),className:"border-2 border-dashed border-gray-200 dark:border-white/10 rounded-2xl p-8 text-center cursor-pointer hover:border-[#F26644] hover:bg-gray-50 dark:hover:bg-white/6 transition-all",children:[(0,r.jsxs)("svg",{width:"32",height:"32",className:"text-gray-300 dark:text-white/40 mx-auto mb-3",fill:"none",stroke:"currentColor",strokeWidth:"1.5",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"17 8 12 3 7 8"}),(0,r.jsx)("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),(0,r.jsx)("p",{className:"text-gray-500 dark:text-white/60 text-sm font-medium",children:$||"Click to upload a file"}),(0,r.jsx)("p",{className:"text-gray-400 dark:text-white/40 text-xs mt-1",children:"CSV, TSV, or a .xls export from a ticketing system"}),(0,r.jsx)("input",{ref:E,type:"file",accept:".csv,.tsv,.txt,.xls,.html,text/csv,text/plain,text/html",className:"hidden",onChange:function(e){let t=e.target.files[0];if(!t)return;z(t.name);let s=new FileReader;s.onload=e=>{M.current=e.target.result,O(e.target.result)},s.readAsText(t)}})]}),i&&(0,r.jsxs)("div",{className:"bg-gray-50 dark:bg-white/4 roun
1ded-xl px-4 py-3 text-xs space-y-1.5",children:[(0,r.jsxs)("p",{className:"text-gray-700 dark:text-white/70",children:[(0,r.jsxs)("span",{className:"font-semibold text-gray-900 dark:text-white",children:[i.found," contacts"]})," ","from ",i.rows," rows",i.duplicatesMerged>0&&(0,r.jsxs)(r.Fragment,{children:[" \xb7 ",i.duplicatesMerged," duplicate",1===i.duplicatesMerged?"":"s"," merged"]})]}),(0,r.jsxs)("p",{className:"text-gray-500 dark:text-white/50",children:[i.withEmail," with an email \xb7 ",i.withPhone," with a phone",i.withEmail<i.found&&(0,r.jsxs)("span",{className:"text-orange-600",children:[" \xb7 ",i.found-i.withEmail," have no email and cannot be saved"]})]}),(0,r.jsxs)("p",{className:"text-gray-400 dark:text-white/40",children:["Read as ",i.format,i.hasHeader?" with a header row":" with no header row"," \xb7 columns found by ",i.strategy]}),i.mapped?.length>0&&(0,r.jsxs)("p",{className:"text-gray-400 dark:text-white/40",children:["Using: ",i.mapped.join(", ")]})]}),i?.needsHelp&&(0,r.jsxs)("div",{className:"bg-orange-50 dark:bg-orange-400/10 rounded-xl px-4 py-3 text-xs text-orange-700 space-y-2",children:[(0,r.jsxs)("p",{children:[(0,r.jsx)("span",{className:"font-semibold",children:"These columns arenât recognised."})," No email or phone column was found."]}),(0,r.jsx)("button",{onClick:T,disabled:C,className:"bg-[#0F2044] text-white font-bold px-4 py-2 rounded-xl disabled:opacity-50",children:C?"Working it outâ¦":"Work out the columns for me"}),(0,r.jsx)("p",{className:"text-orange-500",children:"Only the column names and a description of each column are sent â never anyoneâs details."})]}),i?.found>0&&(0,r.jsxs)("label",{className:"flex items-start gap-2.5 text-xs text-gray-600 dark:text-white/60 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:F,onChange:e=>R(e.target.checked),className:"mt-0.5"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"font-semibold text-gray-900 dark:text-white",children:"Send a welcome email to new contacts"}),(0,r.jsxs)("span",{className:"block text-gray-400 dark:text-white/40 mt-0.5",children:["Leave this off for older lists. ",i.found," emails at once to people who havenât heard from you in a while is how a sending domain gets marked as spam."]})]})]}),(0,r.jsx)("p",{className:"text-[11px] text-gray-400 dark:text-white/35 leading-relaxed",children:"Anyone who previously unsubscribed stays unsubscribed â importing them again will not put them back on the list."}),s.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"text-xs font-semibold text-gray-500 dark:text-white/60 uppercase tracking-wide mb-2",children:["Preview â ",s.length," contact",1!==s.length?"s":""," ready"]}),(0,r.jsx)("div",{className:"overflow-auto rounded-xl border border-gray-100 dark:border-white/10",children:(0,r.jsxs)("table",{className:"w-full text-xs",children:[(0,r.jsx)("thead",{className:"bg-gray-50 dark:bg-white/6",children:(0,r.jsx)("tr",{children:["email","name","phone"].map(e=>(0,r.jsx)("th",{className:"px-3 py-2 text-left text-gray-500 dark:text-white/60 font-semibold",children:e},e))})}),(0,r.jsx)("tbody",{children:s.slice(0,5).map((e,t)=>(0,r.jsxs)("tr",{className:"border-t border-gray-50 dark:border-white/10",children:[(0,r.jsx)("td",{className:"px-3 py-2 text-gray-700 dark:text-white/60",children:e.email||"â"}),(0,r.jsx)("td",{className:"px-3 py-2 text-gray-500 dark:text-white/60",children:[e.firstName,e.lastName].filter(Boolean).join(" ")||"â"}),(0,r.jsx)("td",{className:"px-3 py-2 text-gray-500 dark:text-white/60",children:e.phone||"â"})]},t))})]})}),s.length>5&&(0,r.jsxs)("p",{className:"text-gray-400 dark:text-white/40 text-xs mt-1",children:["+",s.length-5," more rows"]})]}),N&&(0,r.jsx)("p",{className:"text-red-500 text-xs",children:N}),s.length>0&&(0,r.jsx)("button",{onClick:A,disabled:o,className:"w-full text-white font-bold text-sm py-3.5 rounded-2xl transition-all disabled:opacity-60",style:{background:"linear-gradient(135deg, #F26644, #FF9933)"},children:o?"Importingâ¦":`Import ${s.length} contacts`})]})})]})})}function _({onClose:e,onAdd:t}){let[s,n]=(0,a.useState)({email:"",firstName:"",lastName:"",phone:"",address:"",volunteer:!1}),[i,d]=(0,a.useState)(!1),[c,h]=(0,a.useState)("");function x(e){n(t=>({...t,[e.target.name]:e.target.value}))}async function m(r){r.preventDefault(),d(!0),h("");try{(await fetch("/api/subscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:s.email,firstName:s.firstName,lastName:s.lastName,phone:s.phone,address:s.address,volunteer:s.volunteer,source:"manual"})})).ok?(t(),e()):h("Could not add contact. Check the email address.")}catch{h("The connection dropped â the contact may or may not have been added. Check the list before retrying.")}finally{d(!1)}}let u="w-full border border-gray-200 dark:border-white/10 rounded-xl px-4 py-3 text-sm focus:outline-hidden focu
1s:ring-2 focus:ring-[#F26644]/20 focus:border-[#F26644] transition-all dark:text-white dark:placeholder-white/30",p="block text-xs font-semibold text-gray-500 dark:text-white/60 uppercase tracking-wide mb-1.5";return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.5)"},children:(0,r.jsxs)("div",{className:"bg-white dark:bg-white/4 rounded-3xl shadow-2xl w-full max-w-md max-h-[90vh] overflow-y-auto",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-7 py-5 border-b border-gray-100 dark:border-white/10",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"font-bold text-gray-900 dark:text-white",children:"Add contact"}),(0,r.jsx)("p",{className:"text-gray-400 dark:text-white/40 text-xs mt-0.5",children:"They will receive a confirmation email"})]}),(0,r.jsx)("button",{onClick:e,className:"w-8 h-8 rounded-full bg-gray-100 dark:bg-white/6 hover:bg-gray-200 dark:hover:bg-white/6 flex items-center justify-center text-gray-500 dark:text-white/60 transition-colors text-lg leading-none",children:"\xd7"})]}),(0,r.jsxs)("form",{onSubmit:m,className:"px-7 py-6 space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:p,children:["Email ",(0,r.jsx)("span",{className:"text-red-400",children:"*"})]}),(0,r.jsx)("input",{type:"email",name:"email",value:s.email,onChange:x,required:!0,autoFocus:!0,className:u,placeholder:"[email protected]"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:p,children:"First name"}),(0,r.jsx)("input",{type:"text",name:"firstName",value:s.firstName,onChange:x,placeholder:"Jane",className:u})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:p,children:"Last name"}),(0,r.jsx)("input",{type:"text",name:"lastName",value:s.lastName,onChange:x,placeholder:"Doe",className:u})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:p,children:"Phone"}),(0,r.jsx)("input",{type:"tel",name:"phone",value:s.phone,onChange:e=>n(t=>({...t,phone:(0,o.qH)(e.target.value)})),placeholder:"(201) 555-0100",className:u})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:p,children:"Address"}),(0,r.jsx)(l.A,{value:s.address,onChange:e=>n(t=>({...t,address:e})),onSelect:e=>n(t=>({...t,address:[e.line1,e.city,e.state,e.zip].filter(Boolean).join(", ")})),placeholder:"Start typing an addressâ¦",className:u})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2.5 cursor-pointer select-none",children:[(0,r.jsx)("input",{type:"checkbox",checked:s.volunteer,onChange:e=>n(t=>({...t,volunteer:e.target.checked})),className:"w-4 h-4 rounded-sm border-gray-300 dark:border-white/10 text-[#0F2044] focus:ring-[#F26644]/30"}),(0,r.jsx)("span",{className:"text-sm text-gray-700 dark:text-white/60 font-medium",children:"Add as volunteer"})]}),c&&(0,r.jsx)("p",{className:"text-red-500 text-xs",children:c}),(0,r.jsxs)("div",{className:"flex gap-3 pt-1",children:[(0,r.jsx)("button",{type:"button",onClick:e,className:"flex-1 border border-gray-200 dark:border-white/10 text-gray-600 dark:text-white/60 text-sm font-semibold py-3 rounded-2xl hover:bg-gray-50 dark:hover:bg-white/6 transition-all",children:"Cancel"}),(0,r.jsx)("button",{type:"submit",disabled:i,className:"flex-1 text-white text-sm font-bold py-3 rounded-2xl shadow-md hover:opacity-90 transition-all disabled:opacity-50",style:{background:"linear-gradient(135deg,#F26644,#FF9933)"},children:i?"Addingâ¦":"Add contact"})]})]})]})})}function F({onClose:e,onRemoved:t}){let[s,n]=(0,a.useState)(!0),[i,l]=(0,a.useState)([]),[o,d]=(0,a.useState)(()=>new Set),[c,h]=(0,a.useState)(!1),[x,m]=(0,a.useState)("");async function u(){if(0!==o.size){h(!0),m("");try{let e=await fetch("/api/admin/spam-signups",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[...o]})}),s=await e.json().catch(()=>({}));if(!e.ok||s.error)throw Error(s.error||`Request failed (${e.status})`);t(s.removed||0)}catch(e){m(e.message||"Could not remove the selected addresses."),h(!1)}}}return(0,a.useEffect)(()=>{fetch("/api/admin/spam-signups").then(e=>e.json()).then(e=>{let t=e.flagged??[];l(t),d(new Set(t.map(e=>e.id))),n(!1)}).catch(()=>{m("Could not load suspected sign-ups."),n(!1)})},[]),(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.5)"},children:(0,r.jsxs)("div",{className:"bg-white dark:bg-white/4 roun
1ded-3xl shadow-2xl w-full max-w-2xl overflow-hidden flex flex-col max-h-[85vh]",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-7 py-5 border-b border-gray-100 dark:border-white/10",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"font-bold text-gray-900 dark:text-white",children:"Review suspected spam sign-ups"}),(0,r.jsx)("p",{className:"text-gray-400 dark:text-white/40 text-xs mt-0.5",children:"Disposable domains and random-looking addresses. Uncheck any real ones before removing."})]}),(0,r.jsx)("button",{onClick:e,className:"w-8 h-8 rounded-full bg-gray-100 dark:bg-white/6 hover:bg-gray-200 dark:hover:bg-white/6 flex items-center justify-center text-gray-500 dark:text-white/60 transition-colors text-lg leading-none",children:"\xd7"})]}),(0,r.jsxs)("div",{className:"px-7 py-5 overflow-y-auto",children:[s?(0,r.jsxs)("div",{className:"flex items-center justify-center py-16 text-gray-300 dark:text-white/40",children:[(0,r.jsxs)("svg",{className:"animate-spin mr-2",width:"20",height:"20",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Scanningâ¦"]}):0===i.length?(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)("p",{className:"text-gray-500 dark:text-white/60 text-sm font-medium",children:"No suspicious sign-ups found"}),(0,r.jsx)("p",{className:"text-gray-400 dark:text-white/40 text-xs mt-1",children:"Your active list looks clean."})]}):(0,r.jsx)("div",{className:"space-y-1.5",children:i.map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-gray-50 dark:hover:bg-white/6 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:o.has(e.id),onChange:()=>{var t;return t=e.id,void d(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"w-4 h-4 rounded-sm border-gray-300 dark:border-white/10 text-[#0F2044] focus:ring-[#F26644]/30"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"text-sm text-gray-900 dark:text-white font-medium truncate",children:e.email}),(e.first_name||e.last_name)&&(0,r.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 truncate",children:[e.first_name,e.last_name].filter(Boolean).join(" ")})]}),(0,r.jsx)(S,{color:"high"===e.confidence?"purple":"gray",children:e.reason})]},e.id))}),x&&(0,r.jsx)("p",{className:"text-red-500 text-xs mt-3",children:x})]}),!s&&i.length>0&&(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-7 py-4 border-t border-gray-100 dark:border-white/10",children:[(0,r.jsxs)("span",{className:"text-xs text-gray-500 dark:text-white/60 font-medium",children:[o.size," of ",i.length," selected"]}),(0,r.jsxs)("div",{className:"flex gap-3",children:[(0,r.jsx)("button",{type:"button",onClick:e,className:"border border-gray-200 dark:border-white/10 text-gray-600 dark:text-white/60 text-sm font-semibold px-5 py-2.5 rounded-2xl hover:bg-gray-50 dark:hover:bg-white/6 transition-all",children:"Cancel"}),(0,r.jsx)("button",{type:"button",onClick:u,disabled:c||0===o.size,className:"text-white text-sm font-bold px-5 py-2.5 rounded-2xl shadow-md hover:opacity-90 transition-all disabled:opacity-50",style:{background:"linear-gradient(135deg,#dc2626,#b91c1c)"},children:c?"Removingâ¦":`Remove ${o.size} selected`})]})]})]})})}function R({onClose:e,onMerged:t}){let[s,n]=(0,a.useState)(null),[i,l]=(0,a.useState)(null);async function o(e,s){l(s);let r=e.contacts[0].id;for(let t of e.contacts.slice(1))await fetch("/api/admin/subscribers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"merge",primaryId:r,secondaryId:t.id})}).catch(()=>{});l(null),n(e=>e.filter((e,t)=>t!==s)),t()}return(0,a.useEffect)(()=>{fetch("/api/admin/subscribers?view=duplicates").then(e=>e.json()).then(e=>n(e.groups||[])).catch(()=>n([]))},[]),(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.5)"},onClick:e,children:(0,r.jsxs)("div",{className:"bg-white dark:bg-white/4 roun
1ded-3xl shadow-2xl w-full max-w-lg max-h-[85vh] overflow-y-auto",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-7 py-5 border-b border-gray-100 dark:border-white/10 sticky top-0 bg-white dark:bg-white/4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"font-bold text-gray-900 dark:text-white",children:"Find duplicates"}),(0,r.jsx)("p",{className:"text-gray-400 dark:text-white/40 text-xs mt-0.5",children:"Same phone or name across different emails. The first is kept; the rest merge into it."})]}),(0,r.jsx)("button",{onClick:e,className:"w-8 h-8 rounded-full bg-gray-100 dark:bg-white/6 flex items-center justify-center text-gray-500 dark:text-white/60 text-lg leading-none",children:"\xd7"})]}),(0,r.jsx)("div",{className:"px-7 py-5",children:null===s?(0,r.jsxs)("div",{className:"flex items-center justify-center py-12 text-gray-300 dark:text-white/40",children:[(0,r.jsxs)("svg",{className:"animate-spin mr-2",width:"20",height:"20",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Scanningâ¦"]}):0===s.length?(0,r.jsx)("p",{className:"text-gray-400 dark:text-white/40 text-sm text-center py-10",children:"No likely duplicates found."}):(0,r.jsx)("div",{className:"space-y-3",children:s.map((e,t)=>(0,r.jsxs)("div",{className:"border border-gray-100 dark:border-white/10 rounded-2xl p-4",children:[(0,r.jsx)("span",{className:"text-[11px] font-bold text-[#F26644] bg-orange-50 rounded-full px-2 py-0.5",children:e.reason}),(0,r.jsx)("div",{className:"mt-2 space-y-1",children:e.contacts.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,r.jsx)("span",{className:`text-[10px] font-bold rounded-sm px-1.5 py-0.5 ${0===t?"bg-green-100 text-green-700":"bg-gray-100 text-gray-500"}`,children:0===t?"KEEP":"MERGE"}),(0,r.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[(0,r.jsx)("span",{className:"font-semibold text-gray-900 dark:text-white",children:e.name})," ",(0,r.jsx)("span",{className:"text-gray-400 dark:text-white/40",children:e.email}),e.phone?(0,r.jsxs)("span",{className:"text-gray-400 dark:text-white/40 font-mono",children:[" \xb7 ",e.phone]}
1):""]})]},e.id))}),(0,r.jsx)("button",{onClick:()=>o(e,t),disabled:i===t,className:"mt-3 text-white text-xs font-bold px-4 py-2 rounded-xl disabled:opacity-50",style:{background:"linear-gradient(135deg,#F26644,#FF9933)"},children:i===t?"Mergingâ¦":`Merge ${e.contacts.length-1} into ${e.contacts[0].name}`})]},t))})})]})})}function $(){let e=(0,n.useRouter)(),{isAdmin:t,isVolunteer:s,isParticipant:l}=(0,i.It)(),o=s||l,[d,c]=(0,a.useState)([]),[h,x]=(0,a.useState)(!0),[m,u]=(0,a.useState)(""),[p,g]=(0,a.useState)("active"),[f,y]=(0,a.useState)(!1),[b,w]=(0,a.useState)(null),[j,v]=(0,a.useState)(null),[k,$]=(0,a.useState)(!1),[z,M]=(0,a.useState)(null),[E,O]=(0,a.useState)(""),[T,A]=(0,a.useState)(!1),[B,L]=(0,a.useState)(""),[P,W]=(0,a.useState)(!1),[I,q]=(0,a.useState)(!1),[D,H]=(0,a.useState)(!1),U=(0,a.useRef)(null),[V,J]=(0,a.useState)({key:"created_at",dir:"desc"}),K=(0,a.useMemo)(()=>{let{key:e,dir:t}=V,s="asc"===t?1:-1,r=t=>"created_at"===e?new Date(t.created_at||0).getTime():"name"===e?([t.first_name,t.last_name].filter(Boolean).join(" ")||t.email||"").toLowerCase():String(t[e]||"").toLowerCase();return[...d].sort((e,t)=>{let a=r(e),n=r(t);return a<n?-s:a>n?s:0})},[d,V]);(0,a.useEffect)(()=>{if(!D)return;let e=e=>{U.current&&!U.current.contains(e.target)&&H(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[D]);let X=(0,a.useRef)(0),G=(0,a.useCallback)(()=>{x(!0);let e="volunteers"===p,t="vendors"===p,s=new URLSearchParams({status:e||t?"active":p,search:m});e&&s.set("volunteer","true"),t&&s.set("vendor","true");let r=++X.current;fetch(`/api/admin/subscribers?${s}`).then(e=>e.json()).then(e=>{r===X.current&&(c(e.subscribers??[]),x(!1))}).catch(()=>{r===X.current&&x(!1)})},[p,m]);(0,a.useEffect)(()=>{G()},[G]);let Y=(0,a.useRef)(!1);async function Z(){if(!z)return;let e=z.id;w(e),O("");try{let t=await fetch(`/api/admin/subscribers?id=${e}`,{method:"DELETE"}),s=await t.json().catch(()=>({}));if(!t.ok||s.error)throw Error(s.error||`Request failed (${t.status})`);M(null),G()}catch(e){O(e.message||"Could not remove contact. Please try again.")}finally{w(null)}}async function Q(){A(!0),L("");try{let e=await fetch("/api/admin/prune-bounced",{method:"POST"}),t=await e.json().catch(()=>({}));if(!e.ok||t.error)throw Error(t.error||`Request failed (${e.status})`);L(t.removed>0?`Removed ${t.removed} undeliverable ${1===t.removed?"address":"addresses"}`:"No undeliverable addresses to remove â list is clean"),G()}catch(e){L(e.message||"Could not clean bounced addresses. Please try again.")}finally{A(!1)}}async function ee(){A(!0),L("");try{let e=await fetch("/api/admin/normalize-names",{method:"POST"}),t=await e.json().catch(()=>({}));if(!e.ok||t.error)throw Error(t.error||`Request failed (${e.status})`);let s=(t.subscribers||0)+(t.members||0);L(s>0?`Normalized ${t.subscribers||0} contact name${1===t.subscribers?"":"s"}${t.blanked?` \xb7 blanked ${t.blanked} placeholder${1===t.blanked?"":"s"}`:""}`:"All names already tidy â nothing to change"),G()}catch(e){L(e.message||"Could not normalize names. Please try again.")}finally{A(!1)}}async function et(){A(!0),L("Pushing contacts to the email platformâ¦");let e=0,t=0,s=0;try{for(;;){let r=new URLSearchParams({afterId:String(e),limit:"100"}),a=await fetch(`/api/admin/sync-resend?${r.toString()}`,{method:"POST"}),n=await a.json().catch(()=>({error:`Request failed (${a.status})`}));if(n.error)throw Error(n.error);if(t+=n.synced||0,s+=n.skipped||0,n.total,L(`Syncing to email platform⦠${t.toLocaleString()} done`),!n.hasMore)break;e=n.nextCursor||e}L(`â Synced ${t.toLocaleString()} to the email platform${s?` \xb7 ${s} skipped`:""}`)}catch(e){L(e.message||"Could not sync to the email platform. Please try again.")}finally{A(!1)}}(0,a.useEffect)(()=>{e.isReady&&!Y.current&&(Y.current=!0,"1"===e.query.import&&y(!0),"volunteers"===e.query.filter&&g("volunteers"),"vendors"===e.query.filter&&g("vendors"))},[e.isReady,e.query]);let es=d.filter(e=>e.phone),er=d.filter(e=>e.volunteer),ea=d.filter(e=>e.vendor);return(0,r.jsxs)(i.Ay,{title:"Contacts",children:[f&&(0,r.jsx)(C,{onClose:()=>{y(!1),e.replace("/dashboard/contacts",void 0,{shallow:!0})},onImport:G}),k&&(0,r.jsx)(_,{onClose:()=>$(!1),onAdd:G}),P&&(0,r.jsx)(F,{onClose:()=>W(!1),onRemoved:e=>{W(!1),L(e>0?`Removed ${e} spam sign-up${1===e?"":"s"}`:"No addresses removed"),G()}}),I&&(0,r.jsx)(R,{onClose:()=>q(!1),onMerged:()=>{L("Duplicates merged"),G()}}),j&&(0,r.jsx)(N,{sub:j,onClose:()=>v(null),onSave:e=>{c(t=>t.map(t=>
1t.id===e.id?{...t,...e}:t)),v(null)}}),z&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.5)"},children:(0,r.jsx)("div",{className:"bg-white dark:bg-white/4 rounded-3xl shadow-2xl w-full max-w-sm max-h-[90vh] overflow-y-auto",children:(0,r.jsxs)("div",{className:"px-7 py-6",children:[(0,r.jsx)("div",{className:"w-12 h-12 rounded-2xl bg-red-100 flex items-center justify-center mb-4",children:(0,r.jsxs)("svg",{width:"22",height:"22",className:"text-red-600",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,r.jsx)("path",{d:"M10 11v6"}),(0,r.jsx)("path",{d:"M14 11v6"})]})}),(0,r.jsx)("h2",{className:"font-bold text-gray-900 dark:text-white text-lg",children:"Unsubscribe contact?"}),(0,r.jsxs)("p",{className:"text-gray-500 dark:text-white/60 text-sm mt-1",children:[(0,r.jsx)("span",{className:"font-medium text-gray-700 dark:text-white/60",children:z.email})," will be marked as unsubscribed and removed from the active list."]}),E&&(0,r.jsx)("p",{className:"text-red-500 text-xs mt-3",children:E}),(0,r.jsxs)("div",{className:"flex gap-3 pt-5",children:[(0,r.jsx)("button",{type:"button",onClick:()=>M(null),disabled:!!b,className:"flex-1 border border-gray-200 dark:border-white/10 text-gray-600 dark:text-white/60 text-sm font-semibold py-3 rounded-2xl hover:bg-gray-50 dark:hover:bg-white/6 transition-all disabled:opacity-50",children:"Cancel"}),(0,r.jsx)("button",{type:"button",onClick:Z,disabled:!!b,className:"flex-1 text-white text-sm font-bold py-3 rounded-2xl shadow-md hover:opacity-90 transition-all disabled:opacity-50",style:{background:"linear-gradient(135deg,#dc2626,#b91c1c)"},children:b?"Removingâ¦":"Unsubscribe"})]})]})})}),s||l?(0,r.jsxs)("div",{className:"max-w-md mx-auto mt-8 bg-white dark:bg-white/4 roun
1ded-3xl border border-gray-100 dark:border-white/10 shadow-xs p-8 text-center",children:[(0,r.jsx)("div",{className:"w-14 h-14 rounded-2xl bg-orange-50 flex items-center justify-center mx-auto mb-4",children:(0,r.jsxs)("svg",{width:"26",height:"26",className:"text-[#F26644]",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),(0,r.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,r.jsx)("line",{x1:"19",y1:"8",x2:"19",y2:"14"}),(0,r.jsx)("line",{x1:"22",y1:"11",x2:"16",y2:"11"})]})}),(0,r.jsx)("h2",{className:"font-bold text-gray-900 dark:text-white text-lg",children:"Add a contact"}),(0,r.jsx)("p",{className:"text-gray-500 dark:text-white/60 text-sm mt-1.5",children:"Save a new contact to the community list. The full contact list isnât available on your account."}),(0,r.jsxs)("button",{onClick:()=>$(!0),className:"mt-5 inline-flex items-center gap-2 text-white text-sm font-bold px-5 py-3 rounded-2xl shadow-md hover:opacity-90 transition-all",style:{background:"linear-gradient(135deg,#F26644,#FF9933)"},children:[(0,r.jsxs)("svg",{width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",children:[(0,r.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,r.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add contact"]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-5",children:[(0,r.jsxs)("div",{className:"w-full sm:flex-1 sm:min-w-0 relative",children:[(0,r.jsxs)("svg",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-gray-400 dark:text-white/40",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),(0,r.jsx)("input",{type:"text",placeholder:"Search by email, name, or phoneâ¦",value:m,onChange:e=>u(e.target.value),className:"w-full bg-white dark:bg-white/4 border border-gray-200 dark:border-white/10 rounded-xl pl-9 pr-4 py-2.5 text-sm focus:outline-hidden focus:ring-2 focus:ring-[#F26644]/20 focus:border-[#F26644] transition-all shadow-xs dark:text-white dark:placeholder-white/30"})]}),(0,r.jsx)("div",{className:"flex items-center bg-white dark:bg-white/4 border border-gray-200 dark:border-white/10 rounded-xl shadow-xs overflow-hidden",children:["active","volunteers","vendors","all"].map(e=>(0,r.jsx)("button",{onClick:()=>g(e),className:`px-4 py-2.5 text-xs font-semibold capitalize transition-all ${p===e?"bg-[#0F2044] text-white":"text-gray-500 dark:text-white/60 hover:text-gray-800"}`,children:e},e))}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("button",{onClick:()=>$(!0),disabled:!t&&!o,className:"flex items-center gap-1.5 text-white text-xs font-bold px-3 py-2.5 rounded-xl shadow-xs transition-all hover:opacity-90 disabled:opacity-50",style:{background:"linear-gradient(135deg,#F26644,#FF9933)"},children:[(0,r.jsxs)("svg",{width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",children:[(0,r.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,r.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Add"})]}),!o&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{onClick:function(){let e=["id","email","first_name","last_name","phone","address","source","status","interests","created_at"],t=d.map(t=>e.map(e=>`"${(t[e]??"").toString().replace(/"/g,'""')}"`).join(",")),s=new Blob([[e.join(","),...t].join("\n")],{type:"text/csv"}),r=URL.createObjectURL(s),a=document.createElement("a");a.href=r,a.download=`contacts-${new Date().toISOString().slice(0,10)}.csv`,a.click(),URL.revokeObjectURL(r)},disabled:!d.length,className:"flex items-center gap-1.5 border border-gray-200 dark:border-white/10 bg-white dark:bg-white/4 text-gray-600 dark:text-white/60 text-xs font-semibold px-3 py-2.5 rounded-xl hover:bg-gray-50 dark:hover:bg-white/6 transition-all shadow-xs disabled:opacity-50",children:[(0,r.jsxs)("svg",{width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,r.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Export"})]}),(0,r.jsxs)("button",{onClick:()=>y(!0),disabled:!t,className:"flex items-center gap-1.5 text-white text-xs font-bold px-3 py-2.5 rounded-xl shadow-xs transition-all hover:opacity-90 disabled:opacity-50",style:{background:"linear-gradient(135deg, #7c3aed, #a855f7)"},children:[(0,r.jsxs)("svg",{width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"17 8 12 3 7 8"}),(0,r.jsx)("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Import"})]}),(0,r.jsxs)("div",{className:"relative",ref:U,children:[(0,r.jsxs)("button",{onClick:()=>H(e=>!e),disabled:!t,"aria-haspopup":"menu","aria-expanded":D,className:"flex items-center gap-1.5 border border-gray-200 dark:border-white/10 bg-white dark:bg-white/4 text-gray-600 dark:text-white/60 text-xs font-semibold px-3 py-2.5 rounded-xl hover:bg-gray-50 dark:hover:bg-white/6 transition-all shadow-xs disabled:opacity-50",children:[(0,r.jsxs)("svg",{width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{d:"M3 6h18"}),(0,r.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,r.jsx)("path",{d:"M10 11v6"}),(0,r.jsx)("path",{d:"M14 11v6"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Clean up"}),(0,r.jsx)("svg",{width:"11",height:"11",className:`transition-transform ${D?"rotate-180":""}`,fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",children:(0,r.jsx)("polyline",{points:"6 9 12 15 18 9"})})]}),D&&(0,r.jsxs)("div",{role:"menu",className:"absolute right-0 z-30 mt-1.5 w-
156 bg-white dark:bg-white/4 border border-gray-100 dark:border-white/10 rounded-2xl shadow-lg overflow-hidden py-1",children:[(0,r.jsxs)("button",{role:"menuitem",onClick:()=>{H(!1),W(!0)},className:"w-full flex items-start gap-2.5 px-4 py-2.5 text-left hover:bg-gray-50 dark:hover:bg-white/6 transition-colors",children:[(0,r.jsxs)("svg",{width:"15",height:"15",className:"mt-0.5 text-gray-400 dark:text-white/40 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),(0,r.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,r.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block text-xs font-bold text-gray-800 dark:text-white",children:"Find spam"}),(0,r.jsx)("span",{className:"block text-[11px] text-gray-400 dark:text-white/40",children:"Disposable / random-looking sign-ups"})]})]}),(0,r.jsxs)("button",{role:"menuitem",onClick:()=>{H(!1),q(!0)},className:"w-full flex items-start gap-2.5 px-4 py-2.5 text-left hover:bg-gray-50 dark:hover:bg-white/6 transition-colors",children:[(0,r.jsxs)("svg",{width:"15",height:"15",className:"mt-0.5 text-gray-400 dark:text-white/40 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{d:"M18 6 6 18M8 6h10a2 2 0 0 1 2 2v10"}),(0,r.jsx)("circle",{cx:"6",cy:"6",r:"3"})]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block text-xs font-bold text-gray-800 dark:text-white",children:"Find duplicates"}),(0,r.jsx)("span",{className:"block text-[11px] text-gray-400 dark:text-white/40",children:"Merge same phone or name"})]})]}),(0,r.jsxs)("button",{role:"menuitem",onClick:()=>{H(!1),ee()},disabled:T,className:"w-full flex items-start gap-2.5 px-4 py-2.5 text-left hover:bg-gray-50 dark:hover:bg-white/6 transition-colors disabled:opacity-50",children:[(0,r.jsxs)("svg",{width:"15",height:"15",className:"mt-0.5 text-gray-400 dark:text-white/40 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),(0,r.jsx)("path",{d:"M9 20h6"}),(0,r.jsx)("path",{d:"M12 4v16"})]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block text-xs font-bold text-gray-800 dark:text-white",children:"Normalize names"}),(0,r.jsx)("span",{className:"block text-[11px] text-gray-400 dark:text-white/40",children:"Fix ALL-CAPS \xb7 blank âNot Providedâ"})]})]}),(0,r.jsxs)("button",{role:"menuitem",onClick:()=>{H(!1),et()},disabled:T,className:"w-full flex items-start gap-2.5 px-4 py-2.5 text-left hover:bg-gray-50 dark:hover:bg-white/6 transition-colors disabled:opacity-50",children:[(0,r.jsxs)("svg",{width:"15",height:"15",className:"mt-0.5 text-gray-400 dark:text-white/40 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2.2",viewBox:"0 0 24 24",children:[(0,r.jsx)("polyline",{points:"23 4 23 10 17 10"}),(0,r.jsx)("polyline",{points:"1 20 1 14 7 14"}),(0,r.jsx)("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block text-xs font-bold text-gray-800 dark:text-white",children:"Sync to email platform"}),(0,r.jsx)("span",{className:"block text-[11px] text-gray-400 dark:text-white/40",children:"Push contacts & names to Resend"})]})]}),(0,r.jsxs)("button",{role:"menuitem",onClick:()=>{H(!1),Q()},disabled:T,className:"w-full flex items-start gap-2.5 px-4 py-2.5 text-left hover:bg-gray-50 dark:hover:bg-white/6 transition-colors disabled:opacity-50",children:[(0,r.jsxs)("svg",{width:"15",height:"15",className:"mt-0.5 text-gray-400 dark:text-white/40 shrink-0",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{d:"M3 6h18"}),(0,r.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,r.jsx)("path",{d:"M10 11v6"}),(0,r.jsx)("path",{d:"M14 11v6"})]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block text-xs font-bold text-gray-800 dark:text-white",children:T?"Cleaningâ¦":"Clean undeliverable"}),(0,r.jsx)("span",{className:"block text-[11px] text-gray-400 dark:text-white/40",children:"Remove bounced / spam / failed"})]})]})]})]})]})]})]}),B&&(0,r.jsx)("div",{className:"mb-4 text-xs font-medium text-gray-600 bg-amber-50 border border-amber-100 dar
1k:bg-amber-400/10 dark:border-amber-400/20 dark:text-white/70 rounded-xl px-4 py-2.5",children:B}),!h&&(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 mb-4 text-xs",children:[(0,r.jsxs)("span",{className:"bg-[#0F2044]/10 text-[#0F2044] font-semibold px-3 py-1 rounded-full",children:[d.length," shown"]}),es.length>0&&(0,r.jsxs)("span",{className:"bg-purple-100 text-purple-700 font-semibold px-3 py-1 rounded-full",children:[es.length," with phone numbers"]}),er.length>0&&(0,r.jsxs)("span",{className:"bg-amber-100 text-amber-700 font-semibold px-3 py-1 rounded-full",children:[er.length," volunteer",1===er.length?"":"s"]}),ea.length>0&&(0,r.jsxs)("span",{className:"bg-teal-100 text-teal-700 font-semibold px-3 py-1 rounded-full",children:[ea.length," vendor",1===ea.length?"":"s"]})]}),(0,r.jsx)("div",{className:"bg-white dark:bg-white/4 rounded-2xl border border-gray-100 dark:border-white/10 shadow-xs overflow-hidden overflow-x-auto",children:h?(0,r.jsxs)("div",{className:"flex items-center justify-center py-20 text-gray-300 dark:text-white/40",children:[(0,r.jsxs)("svg",{className:"animate-spin mr-2",width:"20",height:"20",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loadingâ¦"]}):0===d.length?(0,r.jsxs)("div",{className:"text-center py-16",children:[(0,r.jsx)("div",{className:"w-14 h-14 rounded-2xl bg-gray-100 dark:bg-white/6 flex items-center justify-center mx-auto mb-4",children:(0,r.jsxs)("svg",{width:"24",height:"24",className:"text-gray-300 dark:text-white/40",fill:"none",stroke:"currentColor",strokeWidth:"1.5",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,r.jsx)("circle",{cx:"9",cy:"7",r:"4"})]})}),(0,r.jsx)("p",{className:"text-gray-400 dark:text-white/40 text-sm font-medium",children:"No contacts yet"}),(0,r.jsx)("p",{className:"text-gray-300 dark:text-white/40 text-xs mt-1",children:"Import a CSV or wait for sign-ups from your site"})]}):(0,r.jsxs)("table",{className:"w-full min-w-176",children:[(0,r.jsx)("thead",{children:(0,r.jsx)("tr",{className:"border-b border-gray-100 dark:border-white/10",children:[["Name & Email","name"],["Phone","phone"],["Source","source"],["Joined","created_at"],["",null]].map(([e,t])=>(0,r.jsx)("th",{className:"text-left px-5 py-3.5 text-xs font-semibold text-gray-400 dark:text-white/40 uppercase tracking-wide",children:t?(0,r.jsxs)("button",{onClick:()=>{J(e=>e.key===t?{key:t,dir:"asc"===e.dir?"desc":"asc"}:{key:t,dir:"created_at"===t?"desc":"asc"})},className:"inline-flex items-center gap-1 uppercase tracking-wide hover:text-gray-700 transition-colors",children:[e,(0,r.jsx)("span",{className:`text-[9px] leading-none ${V.key===t?"text-[#F26644]":"text-gray-300 dark:text-white/40"}`,children:V.key===t&&"asc"===V.dir?"â²":"â¼"})]}):e},e||"actions"))})}),(0,r.jsx)("tbody",{children:K.map((t,s)=>(0,r.jsxs)("tr",{className:`border-b border-gray-50 dark:border-white/10 hover:bg-gray-50/60 dark:hover:bg-white/6 transition-colors ${s===K.length-1?"border-0":""}`,children:[(0,r.jsx)("td",{className:"px-5 py-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer group",onClick:()=>e.push(`/dashboard/contact/${t.id}`),title:"View CRM profile",children:[(0,r.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-bold shrink-0",style:{background:`hsl(${37*t.email.charCodeAt(0)%360}, 60%, 45%)`},children:(t.first_name?.[0]??t.last_name?.[0]??t.email[0]).toUpperCase()}),(0,r.jsxs)("div",{className:"group-hover:underline decoration-gray-300",children:[(t.first_name||t.last_name)&&(0,r.jsx)("p",{className:"text-gray-900 dark:text-white text-sm font-medium",children:[t.first_name,t.last_name].filter(Boolean).join(" ")}),(0,r.jsx)("p",{className:`text-sm ${t.first_name||t.last_name?"text-gray-400 dark:text-white/40":"text-gray-900 dark:text-white font-medium"}`,children:t.email}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1 mt-1",children:[t.volunteer&&(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 bg-amber-100 text-amber-700 text-[11px] font-semibold px-2 py-0.5 rounded-full",children:[(0,r.jsx)("svg",{width:"10",height:"10",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}),"Volunteer"]}),t.vendor&&(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 bg-teal-100 text-teal-700 text-[11px] font-semibold px-2 py-0.5 rounded-full",children:[(0,r.jsxs)("svg",{width:"10",height:"10",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,r.jsx)("path",{d:"M3 3h18v4H3z"}),(0,r.jsx)("path",{d:"M5 7v13h14V7"})]}),"Vendor"]})]}),t.interests&&(0,r.jsxs)("p",{className:"text-[11px] text-gray-400 dark:text-white/40 mt-1",children:[(0,r.jsx)("span",{className:"font-semibold text-gray-500 dark:text-white/60",children:"Helps with:"})," ",t.interests]})]})]})}),(0,r.jsx)("td",{className:"px-5 py-4",children:t.phone?(0,r.jsx)("span",{className:"text-sm text-gray-700 dark:text-white/60 font-mono",children:t.phone}):(0,r.jsx)("span",{className:"text-gray-300 dark:text-white/40 text-sm",children:"â"})}),(0,r.jsx)("td",{className:"px-5 py-4",children:(0,r.jsx)(S,{color:"csv-import"===t.source?"blue":"event"===t.source?"purple":"green",children:t.source})}),(0,r.jsx)("td",{className:"px-5 py-4 text-gray-400 dark:text-white/40 text-sm",children:new Date(t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),(0,r.jsx)("td",{className:"px-5 py-4",children:(0,r.jsxs)("button",{onClick:()=>e.push(`/dashboard/contact/${t.id}`),className:"inline-flex items-center gap-1.5 text-xs font-bold text-white rounded-lg px-3 py-2 transition-all hover:opacity-90 whitespace-nowrap",style:{background:"linear-gradient(135deg,#F26644,#FF9933)"},title:"View CRM profile â edit, unsubscribe, text, call, and full history",children:["View profile",(0,r.jsx)("svg",{width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",children:(0,r.jsx)("polyline",{points:"9 18 15 12 9 6"})})]})})]},t.id))})]})})]})]})}}},e=>{e.O(0,[8230,6475,30,636,6593,8792],()=>e(e.s=74888)),_N_E=e.O()}]);
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.