PageSourceSearch

https://governance.center/_next/static/chunks/24203-6636099f99785220.js

js governance.center collected 2026-10-08 13:11:00 UTC 65,733 bytes, 1 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="81dca000-7141-45d5-961a-7ed698db6ac3",e._sentryDebugIdIdentifier="sentry-dbid-81dca000-7141-45d5-961a-7ed698db6ac3")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[24203],{24203:function(e,t,s){s.r(t),s.d(t,{CsvImportDialog:function(){return es}});var n=s(85067),a=s(41434),l=s(54649),r=s(97313),i=s(81407),o=s(69962),d=s(11331),c=s(34019),m=s(51755),u=s(77324),h=s(48894),p=s(57420),x=s(58414),f=s(5479),g=s(72960),b=s(84236),w=s(42935),v=s(35634),j=s(50043),N=s(98508),y=s(11973),_=s(47979),C=s(92096),k=s(31442),T=s(67600);let S=/[\u00A0\u1680\u2000-\u200D\u2028\u2029\u202F\u205F\u3000\uFEFF]/g;function F(e){return e.replace(S," ").replace(/\s+/g," ").trim()}let M=new Set(["de","del","della","dei","der","den","di","da","das","dos","du","van","von","la","le","el","al","bin","ibn","of","and","y"]),$={jr:"Jr",sr:"Sr",esq:"Esq"},I=/^(i{1,3}|iv|vi{0,3}|ix|xi{0,2})$/i;function Z(e){let t=e.split(/(\s+)/),s=!1;return t.map(e=>{if(/^\s+$/.test(e)||!e)return e;let t=e.replace(/[.,]+$/,""),n=e.slice(t.length),a=t.toLowerCase(),l=!s;return(s=!0,$[a])?$[a]+n:I.test(t)&&t.length<=4||1===t.length?t.toUpperCase()+n:!l&&M.has(a)?a+n:t.split(/([-–—'’])/).map((e,t,s)=>{if(/^[-–—'’]$/.test(e)||!e)return e;let n=s[t-1];if(("'"===n||"’"===n)&&(s[t-2]?.length??0)>2)return e.toLowerCase();let a=e.toLowerCase(),l=a.charAt(0).toUpperCase()+a.slice(1);return/^mc[a-z]{2,}$/.test(a)?"Mc"+a.charAt(2).toUpperCase()+a.slice(3):l}).join("")+n}).join("")}function L(e){return(e.match(/[A-Za-z]/g)??[]).length}let z=new Set(["jr","sr","ii","iii","iv","v","md","phd","esq","dds","trustee","trust"]);function A(e){let t=e.split(",");if(2!==t.length)return null;let s=t[0].trim(),n=t[1].trim();if(!s||!n||/\d/.test(e)||2>L(s)||2>L(n))return null;let a=n.split(/\s+/);return a.length>4||a.every(e=>z.has(e.replace(/[.]/g,"").toLowerCase()))?null:`${n} ${s}`}let E=/^(grand\s+)?(sub)?totals?\b|^sum\b|^count\b|^page\s+\d/i;function R(e,t,s){e.length<3&&t!==s&&e.push({before:t,after:s})}function O(e){let{headers:t,rows:s,nameColumns:n}=e,a=[],l=0,r=[];for(let e of s)for(let s of t){let t=e[s]??"";if(!t)continue;let n=F(t);n!==t&&(l++,R(r,`"${t}"`,`"${n}"`))}l>0&&a.push({id:"whitespace",kind:"whitespace",count:l,label:`Cleaned up spacing in ${l.toLocaleString()} ${1===l?"cell":"cells"}`,detail:"Stray spaces and invisible characters that stop an address matching later.",examples:r,optional:!1});let i=s.map(e=>{let s={};for(let n of t)s[n]=F(e[n]??"");return s}),o=[];for(let e=0;e<i.length;e++){let s=function(e,t){if(function(e){for(let t of Object.values(e)){let e=(t??"").trim();if(e&&(/[^\s@]+@[^\s@]+\.[^\s@]+/.test(e)||(e.match(/\d/g)??[]).length>=10))return!0}return!1}(e))return null;let s=t.filter(t=>(e[t]??"").trim().length>0);if(0===s.length)return null;let n=(e[s[0]]??"").trim(),a=n.length>48?`${n.slice(0,48)}…`:n;if(s.length<=Math.max(2,Math.floor(t.length/2))){for(let t of s)if(E.test((e[t]??"").trim()))return{reason:"total",label:a}}return t.length>=2&&s.length>=2&&s.filter(t=>(e[t]??"").trim().toLowerCase()===t.trim().toLowerCase()).length/s.length>=.6?{reason:"repeated-header",label:a}:t.length>=3&&1===s.length&&n.length<=60?{reason:"section",label:a}:null}(i[e],t);s&&o.push({index:e,reason:s.reason,label:s.label})}if(o.length>0){let e=new Set(o.map(e=>e.reason));a.push({id:"junk",kind:"junk",count:o.length,label:`Left out ${o.length} ${1===o.length?"row":"rows"} that ${1===o.length?"is not a person":"are not people"}`,detail:e.has("repeated-header")?"Headings, totals and a repeated header row. No row with an email address or a phone number is ever left out.":e.has("total")?"Section headings and totals. No row with an email address or a phone number is ever left out.":"Section headings. No row with an email address or a phone number is ever left out.",examples:o.slice(0,3).map(e=>({before:e.label,after:"not imported"})),optional:!0})}let d=new Set(o.map(e=>e.index)),c=i.map((e,t)=>t).filter(e=>!d.has(e));for(let{column:e,whole:s}of n){if(!t.includes(e))continue;let n=c.filter(t=>(i[t][e]??"").length>0);if(n.length<2)continue;let l=new Map;if(s){for(let t of n){let s=A(i[t][e]);null!==s&&l.set(t,s)}if(l.size>=2&&l.size/n.length>=.6){let t=[];for(let[s,n]of l)R(t,i[s][e],n);a.push({id:`order:${e}`,kind:"order",column:e,count:l.size,label:`Put ${l.size.toLocaleStr
1ing()} ${1===l.size?"name":"names"} in first-name-first order`,detail:`${e} is written "Last, First". Ballot emails read better addressed the other way round.`,examples:t,optional:!0,rowIndexes:[...l.keys()]})}else l.clear()}let r=n.filter(t=>L(l.get(t)??i[t][e])>=2),o=r.filter(t=>{var s;return!(2>L(s=l.get(t)??i[t][e]))&&(s===s.toUpperCase()||s===s.toLowerCase())});if(r.length>=2&&o.length>=2&&o.length/r.length>=.6){let t=[],s=0;for(let n of o){let a=l.get(n)??i[n][e];a===a.toUpperCase()&&s++,R(t,a,Z(a))}t.length>0&&a.push({id:`case:${e}`,kind:"case",column:e,count:o.length,label:`Fixed the capitalization of ${o.length.toLocaleString()} ${1===o.length?"name":"names"}`,detail:`${e} is ${s>=o.length/2?"in capitals":"in lower case"} throughout. Voters see this name on their ballot.`,examples:t,optional:!0,rowIndexes:o})}}return{fixes:a,junkRows:o}}function B(e){let{headers:t,rows:s,plan:n,off:a}=e,l=new Map(n.fixes.filter(e=>!e.optional||!a.has(e.id)).map(e=>[e.id,e]));if(0===l.size)return s;let r=l.has("junk")?new Set(n.junkRows.map(e=>e.index)):new Set,i=new Map;for(let e of l.values())e.rowIndexes&&i.set(e.id,new Set(e.rowIndexes));let o=[];for(let e=0;e<s.length;e++){if(r.has(e))continue;let n=s[e],a={};for(let s of t){let t=n[s]??"";t&&l.has("whitespace")&&(t=F(t)),t&&i.get(`order:${s}`)?.has(e)&&(t=A(t)??t),t&&i.get(`case:${s}`)?.has(e)&&(t=Z(t)),a[s]=t}o.push(a)}return o}var P=s(28458),W=s(15533),U=s(3690);let V=U.Ry({summary:U.Z_().trim().min(1).max(400),columns:U.IX(U.Ry({header:U.Z_().max(200),role:U.Km(["email","mobile","other_phone","first_name","last_name","full_name","co_owner_first_name","co_owner_last_name","co_owner_full_name","street_number","address_line1","address_line2","city","state","postal_code","unit","weight","channel","dob","organization","bookkeeping","flag","empty","keep","unknown"]),note:U.Z_().trim().max(120).optional()})).max(120)});function D(e,t){let s=(e??"").replace(/\s+/g," ").replace(/—/g,",").trim();return s?s.slice(0,100):t}let H={organization:{reason:"organization",note:"the association, not the member"},bookkeeping:{reason:"bookkeeping",note:"the management company's bookkeeping"},flag:{reason:"flag",note:"a yes/no flag"},empty:{reason:"empty",note:"empty in every row"},dob:{reason:"identity",note:"read for date-of-birth matching when that check is on"},other_phone:{reason:"landline",note:"a second number that is not texted"}},G=new Set(["sparse","constant","empty"]),q={[T.bS.first]:"Member first name",[T.bS.last]:"Member last name",[T.bS.coFirst]:"Co-owner first name",[T.bS.coLast]:"Co-owner last name"},Q=new Set(Object.values(T.bS)),K=new Set;function X(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"").replace(/^(\d)/,"f_$1")}function Y(e){let{mapping:t,existingFields:s,newFields:l,updateMapping:r,updateNewField:d,compact:f,isWeightField:g}=e,[b,w]=(0,a.useState)(!1),v="ignore"===t.mappedTo&&!!t.setAside,j=!v&&("suggested"===t.confidence||"unmatched"===t.confidence),N=!f||b,y=(0,T.Fi)(t.csvColumn)&&"ignore"!==t.mappedTo,_=(0,T.QG)(t.csvColumn)&&"ignore"!==t.mappedTo,k=t.isNewField&&l[t.csvColumn]?.type==="number"&&"__weight__"===t.mappedTo,S=g||y||k,F=_&&!S,M="displayName"===t.mappedTo?"Display Name":"phone"===t.mappedTo?"Phone":"ignore"===t.mappedTo?t.setAside?`Not imported: ${t.setAside.note}`:"Ignored":"__weight__"===t.mappedTo?"Voting Weight":"__channel__"===t.mappedTo?"Notify By (Email / Text)":"__address__"===t.mappedTo?"Mailing address":q[t.mappedTo]?q[t.mappedTo]:"__new__"===t.mappedTo?t.hint?`+ New field? ${t.hint}`:"+ New field":s.find(e=>e.name===t.mappedTo)?.label||t.mappedTo;return(0,n.jsxs)("div",{className:(0,C.cn)("rounded-lg px-3 py-2.5 -mx-3 transition-colors",S&&"bg-violet-50/70 border border-violet-200/80",F&&"bg-blue-50/70 border border-blue-200/80",j&&!S&&!F&&"bg-amber-50/70 border border-amber-200/80",!S&&!F&&!j&&"border border-transparent",f&&!b&&"hover:bg-neutral-50 cursor-pointer"),onClick:f&&!b?()=>w(!0):void 0,children:[(0,n.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[S?(0,n.jsx)(c.Z,{className:"h-3.5 w-3.5 text-violet-500 shrink-0"}):F?(0,n.jsx)(m.Z,{className:"h-3.5 w-3.5 text-blue-500 shrink-0"}):j?(0,n.jsx)(u.Z,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}):v?(0,n.jsx)(h.Z,{className:"h-3.5 w-3.5 text-neutral-300 shrink-0"}):(0,n.jsx)(p.Z,{className:"h-3.5 w-3.5 text-assurance-500 shrink-0"}),(0,n.jsx)("span",{className:(0,C.cn)("text-sm font-medium w-36 truncate shrink-0",v&&"text-neutral-500"),
1children:t.csvColumn.trim()||(0,n.jsx)("span",{className:"text-neutral-400 italic",children:"(unnamed column)"})}),S&&(0,n.jsx)(i.C,{variant:"outline",className:"text-[10px] py-0 border-violet-300 bg-violet-100 text-violet-700 shrink-0",children:g?"Weight Field":"Vote Weight"}),F&&(0,n.jsx)(i.C,{variant:"outline",className:"text-[10px] py-0 border-blue-300 bg-blue-100 text-blue-700 shrink-0",children:"Group / Unit"}),(0,n.jsx)("span",{className:"text-neutral-300 shrink-0",children:"→"}),N?(0,n.jsxs)("select",{value:"__weight__"===t.mappedTo?"__weight__":t.isNewField?"__new__":t.mappedTo,onChange:e=>r(t.csvColumn,e.target.value),className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-neutral-200 rounded-md focus:border-neutral-900 focus:outline-none transition-colors bg-white",children:[(0,n.jsx)("option",{value:"ignore",children:"Ignore this column"}),(0,n.jsx)("option",{value:"displayName",children:"Display Name"}),(0,n.jsx)("option",{value:T.bS.first,children:"Member first name"}),(0,n.jsx)("option",{value:T.bS.last,children:"Member last name"}),(0,n.jsx)("option",{value:T.bS.coFirst,children:"Co-owner first name"}),(0,n.jsx)("option",{value:T.bS.coLast,children:"Co-owner last name"}),(0,n.jsx)("option",{value:"phone",children:"Phone"}),(0,n.jsx)("option",{value:"__channel__",children:"Notify By (Email / Text)"}),(0,n.jsx)("option",{value:"__address__",children:"Mailing address"}),s.length>0&&(0,n.jsx)("optgroup",{label:"Existing Fields",children:s.map(e=>(0,n.jsxs)("option",{value:e.name,children:[e.label," (",e.type,")"]},e.id))}),(0,n.jsx)("option",{value:"__new__",children:"+ Create new field"})]}):(0,n.jsx)("span",{className:"flex-1 text-sm text-neutral-500",children:M}),f&&b&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),w(!1)},className:"text-neutral-400 hover:text-neutral-600 shrink-0",children:(0,n.jsx)(x.Z,{className:"h-3 w-3"})})]}),t.isNewField&&l[t.csvColumn]&&N&&(0,n.jsxs)("div",{className:"sm:ml-[calc(8rem+2.75rem)] ml-5 flex items-center gap-2 mt-1.5 p-2 rounded-md bg-neutral-50/80 animate-in fade-in slide-in-from-top-1",children:[(0,n.jsx)(o.I,{placeholder:"Field label",value:l[t.csvColumn].label,onChange:e=>{d(t.csvColumn,{label:e.target.value,name:X(e.target.value)})},className:"h-8 text-sm flex-1"}),k||y?(0,n.jsxs)("span",{className:"h-8 px-3 text-sm border border-violet-200 rounded-md bg-violet-50 text-violet-700 font-medium flex items-center gap-1",children:[(0,n.jsx)(c.Z,{className:"h-3 w-3"}),"Number"]}):(0,n.jsxs)("select",{value:l[t.csvColumn].type,onChange:e=>d(t.csvColumn,{type:e.target.value}),className:"h-8 px-2 text-sm border border-neutral-200 rounded-md focus:border-neutral-900 focus:outline-none bg-white",children:[(0,n.jsx)("option",{value:"text",children:"Text"}),(0,n.jsx)("option",{value:"number",children:"Number"}),(0,n.jsx)("option",{value:"boolean",children:"Boolean"}),(0,n.jsx)("option",{value:"date",children:"Date"}),(0,n.jsx)("option",{value:"select",children:"Select"})]})]})]})}function J(e){let{children:t}=e;return(0,n.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-assurance-700",children:t})}function ee(e){let{fix:t,off:s,onToggle:l}=e,[r,i]=(0,a.useState)(!1);return(0,n.jsxs)("div",{className:"text-sm","data-testid":`cleanup-fix-${t.id}`,children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[s?(0,n.jsx)(h.Z,{className:"mt-1 h-3.5 w-3.5 shrink-0 text-neutral-300"}):(0,n.jsx)(p.Z,{className:"mt-1 h-3.5 w-3.5 shrink-0 text-assurance-600"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("p",{className:(0,C.cn)("leading-snug",s?"text-neutral-400":"text-neutral-900"),children:t.label}),(0,n.jsx)("p",{className:"text-xs leading-snug text-neutral-500",children:s?"Not applied. The file is imported exactly as it was written.":t.detail})]}),(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-3 text-xs",children:[t.examples.length>0&&(0,n.jsx)("button",{type:"button",onClick:()=>i(e=>!e),className:"text-neutral-500 underline underline-offset-2 hover:text-neutral-900",children:r?"Hide":"Show"}),t.optional&&(0,n.jsx)("button",{type:"button",onClick:l,"data-testid":`cleanup-toggle-${t.id}`,className:"font-medium text-neutral-900 underline underline-offset-2 hover:text-assurance-700",children:s?"Apply":"Undo"})]})]}),r&&(0,n.jsxs)("ul",{className:"ml-5 mt-1.5 space-y-1 pl-0.5","data-testid":`cleanup-examples-${t.id}`,children:[t.examples.map((e,t)=>(0,n.jsxs)("li",{className:"flex flex-wrap items-baseline gap-1.5 font-mono text-[11px]",children:[(0,n.jsx)("span",{className:"text-neutral-500",children:e.before}),(0,n.jsx)("span",{className:"text-neutral-400","aria-label":"becomes",children:"→"}),(0,n.jsx)("span",{className:s?"text-neutral-400 line-through":"text-neutral-900",children:e.after})]},t)),t.count>t.examples.length&&(0,n.jsxs)("li",{className:"text-[11px] text-neutral-400",children:["and ",(t.count-t.examples.length).toLocaleStr
1ing()," more"]})]})]})}let et=["#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6"];function es(e){let{sheets:t,activeSheetIndex:s}=e.parseResult,[l,r]=(0,a.useState)(s??0),i=t?.[l],o=i?{...e.parseResult,headers:i.headers,rows:i.rows,totalRows:i.totalRows}:e.parseResult;return(0,n.jsx)(en,{...e,parseResult:o,sheetPicker:t&&t.length>1?{sheets:t,index:l,onChange:r}:void 0},l)}function en(e){let{open:t,onOpenChange:s,parseResult:h,fileName:S,existingFields:F,activeWeightFieldIds:M=[],existingTags:$=[],onCreateTag:I,smsEnabled:Z=!1,unpaidRosterCount:L=null,allowOfflineChannels:z=!0,identityChecks:A,readWithModel:E=!0,rosterToken:R,offerUnitVoting:U=!1,onConfirm:q,context:es="voters",sheetPicker:en}=e,{headers:ea,rows:el}=h,er=null!=L&&L+h.totalRows<=W.bs,[ei,eo]=(0,a.useState)(!1),[ed,ec]=(0,a.useState)(null),[em,eu]=(0,a.useState)(new Set),[eh,ep]=(0,a.useState)(!1),[ex,ef]=(0,a.useState)(""),[eg,eb]=(0,a.useState)("#6B7280"),[ew,ev]=(0,a.useState)(!1),[ej]=(0,a.useState)(()=>{let e=O({headers:ea,rows:el,nameColumns:[]}),t=B({headers:ea,rows:el,plan:e,off:K}),s=(0,T.gG)(ea,F,t),n=(0,T.vN)(s),a=s.find(e=>"displayName"===e.mappedTo)?.csvColumn??null,l=O({headers:ea,rows:el,nameColumns:[...a?[{column:a,whole:!0}]:[],...[n.primary.first,n.primary.last,n.coOwner.first,n.coOwner.last].filter(e=>!!e).map(e=>({column:e,whole:!1}))]}),r={};for(let e of s)if(e.isNewField){let t=(0,T.Fi)(e.csvColumn);r[e.csvColumn]={label:e.csvColumn,name:X(e.csvColumn),type:e.newFieldType||"text",isWeightField:t||void 0}}return{plan:l,initialMappings:s,initialNewFields:r,emailColumn:(0,T.g4)(ea,t.slice(0,20))||""}}),[eN,ey]=(0,a.useState)(ej.emailColumn),[e_,eC]=(0,a.useState)(K),ek=(0,a.useMemo)(()=>B({headers:ea,rows:el,plan:ej.plan,off:e_}),[ea,el,ej.plan,e_]),[eT,eS]=(0,a.useState)(ej.initialMappings),[eF,eM]=(0,a.useState)(ej.initialNewFields),[e$,eI]=(0,a.useState)(!1),[eZ,eL]=(0,a.useState)(!1),[ez,eA]=(0,a.useState)(!1),[eE,eR]=(0,a.useState)(!1),[eO,eB]=(0,a.useState)({status:"idle",summary:null,changed:0}),eP=(0,a.useRef)(!1),eW=(0,a.useRef)(eN);eW.current=eN,(0,a.useEffect)(()=>{if(!E||0===ea.length||0===ek.length)return;let e=!1,t=new AbortController,s=setTimeout(()=>t.abort(),15e3);return eB({status:"pending",summary:null,changed:0}),(async()=>{try{let s=function(e,t,s){let n=new Map(s.map(e=>[e.csvColumn,e])),a=e.slice(0,120).map(e=>{var s;let a=(0,T.XI)(e,t),l=t.map(t=>(t[e]??"").trim()).filter(Boolean),r=new Map;for(let e of l){let t=e.trim().replace(/[0-9]/g,"9").replace(/[A-Z]+/g,"A").replace(/[a-z]+/g,"a").replace(/[^\x20-\x7E]/g,"?").slice(0,24);r.set(t,(r.get(t)??0)+1)}let i=[...r.entries()].sort((e,t)=>t[1]-e[1]).slice(0,3).map(e=>{let[t,s]=e;return`${t} x${s}`}),o=t.length>=5&&a.filled>=3&&a.distinct<=6&&2*a.distinct<=a.filled&&!a.phone&&!a.email&&!a.money&&l.every(e=>!(e.includes("@")||(e.match(/\d/g)??[]).length>=7||/^\d+\s+\S/.test(e)||e.length>40))?[...new Set(l)].slice(0,8).map(e=>e.slice(0,40)):void 0;return{header:e.slice(0,200),filled:a.filled,distinct:a.distinct,shapes:i,...o?{values:o}:{},current:(s=n.get(e))?s.setAside?`set aside: ${s.setAside.reason}`:"__new__"===s.mappedTo?"confirmed"===s.confidence?"new field":"unmatched":s.mappedTo:"unmatched"}});return{rows:t.length,columns:a}}(ea,ek,ej.initialMappings),n=await fetch("/api/roster/classify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profile:s,...R?{token:R}:{}}),signal:t.signal}),a=n.ok?await n.json().catch(()=>null):null;if(e)return;let l=a?.engine==="ai"?V.safeParse(a.reading):null;if(!l?.success){eB({status:"off",summary:null,changed:0});return}let r=l.data.summary.replace(/\s+/g," ").replace(/\s*—\s*/g,". ").trim().slice(0,300);if(eP.current){eB({status:"done",summary:r,changed:0});return}let i=function(e){let{headers:t,rows:s,reading:n}=e,a=e.mappings.map(e=>({...e})),l=[],r=e.emailColumn,i=new Map(t.map(e=>[e.trim().toLowerCase(),e])),o=e=>a.some(t=>t.mappedTo===e&&"ignore"!==t.mappedTo),d=e=>"confirmed"===e.confidence&&"ignore"!==e.mappedTo,c=e=>!d(e)&&(!e.setAside||G.has(e.setAside.reason));for(let e of n.columns){let t=i.get(e.header.trim().toLowerCase());if(void 0===t||t===r)continue;let n=a.findIndex(e=>e.csvColumn===t);if(n<0)continue;let d=a[n],m=(0,T.XI)(t,s);if("email"===e.role){!r&&m.email&&(r=t,a[n]={csvColumn:t,mappedTo:"email",confidence:"confirmed",role:"email"},l.push(`${t}: email column`));continue}if(!c(d)||0===m.filled&&"empty"!==e.role)continue;let u=(s,r)=>{a[n]={csvColumn:t,mappedTo:d.mappedTo,...s,role:e.role},l.push(`${t}: ${r}`)},h=(e,t)=>u({mappedTo:e,confidence:"confirmed",isNewField:!1,fieldId:void 0,setAside:void 0},t);
1switch(e.role){case"mobile":!o("phone")&&m.phone&&h("phone","the mobile number");break;case"first_name":o(T.bS.first)||m.phone||m.email||h(T.bS.first,"first name");break;case"last_name":o(T.bS.last)||m.phone||m.email||h(T.bS.last,"last name");break;case"co_owner_first_name":o(T.bS.coFirst)||m.phone||m.email||h(T.bS.coFirst,"co-owner's first name");break;case"co_owner_last_name":o(T.bS.coLast)||m.phone||m.email||h(T.bS.coLast,"co-owner's last name");break;case"full_name":o("displayName")||o(T.bS.first)||m.phone||m.email||m.numeric||h("displayName","the member name");break;case"co_owner_full_name":break;case"street_number":case"address_line1":case"address_line2":case"city":case"state":case"postal_code":m.boolean||m.email||m.phone||h("__address__",`part of the mailing address (${e.role.replace(/_/g," ")})`);break;case"channel":{let e=s.filter(e=>null!==(0,P.MD)(e[t])).length;!o("__channel__")&&m.filled>0&&e/m.filled>=.5&&h("__channel__","how each voter is notified");break}case"keep":case"unit":case"weight":!d.setAside&&e.note&&(a[n]={...d,role:e.role,hint:D(e.note,"")},l.push(`${t}: noted`));break;case"organization":case"bookkeeping":case"flag":case"empty":case"dob":case"other_phone":{let t=H[e.role];if(d.setAside)break;u({mappedTo:"ignore",confidence:"unmatched",isNewField:!1,fieldId:void 0,setAside:{reason:t.reason,note:D(e.note,t.note)}},`set aside (${t.reason})`)}}}return{mappings:a,emailColumn:r,changes:l}}({mappings:ej.initialMappings,reading:l.data,headers:ea,rows:ek,emailColumn:eW.current||null});i.changes.length>0&&(eS(i.mappings),eM(e=>{let t={...e};for(let e of i.mappings)e.isNewField&&!t[e.csvColumn]&&(t[e.csvColumn]={label:e.csvColumn,name:X(e.csvColumn),type:e.newFieldType||"text"});return t}),i.emailColumn&&!eW.current&&ey(i.emailColumn)),eB({status:"done",summary:r,changed:i.changes.length})}catch{e||eB({status:"off",summary:null,changed:0})}finally{clearTimeout(s)}})(),()=>{e=!0,t.abort(),clearTimeout(s)}},[E,R,ea,ek,ej]);let eU=(0,a.useMemo)(()=>(0,T.hf)(ek,eN),[ek,eN]),eV=(0,a.useMemo)(()=>eT.find(e=>e.csvColumn!==eN&&T.QG(e.csvColumn)&&"ignore"!==e.mappedTo)?.csvColumn??null,[eT,eN]),eD=(0,a.useMemo)(()=>eT.find(e=>e.csvColumn!==eN&&T.Fi(e.csvColumn)&&"ignore"!==e.mappedTo)?.csvColumn??null,[eT,eN]),eH=(0,a.useMemo)(()=>eN?(0,T.I7)(ek,eN,eV).filter(e=>e.units.length>1):[],[ek,eN,eV]),[eG,eq]=(0,a.useState)("merge"),eQ=(0,a.useMemo)(()=>eN&&eV&&"merge"===eG&&0!==eH.length?(0,T.Hc)(ek,eN,eV,eD??void 0):null,[ek,eN,eV,eD,eG,eH.length]),eK=eQ?.mergedRows??ek,eX=(0,a.useMemo)(()=>eQ?(0,T.hf)(eQ.mergedRows,eN):eU,[eQ,eN,eU]),eY=U&&"contacts"!==es&&!!eV,[eJ,e0]=(0,a.useState)(!0),[e1,e2]=(0,a.useState)("per_unit"),e5=(0,a.useMemo)(()=>{if(!eV||!eN)return 0;let e=new Set,t=0;for(let s of eK){let n=(0,T.OM)(s[eN])[0];!(!n||e.has(n))&&(e.add(n),new Set((s[eV]||"").split(/[;,]/).map(e=>e.trim().toUpperCase()).filter(Boolean)).size>1&&t++)}return t},[eV,eN,eK]),[e3,e4]=(0,a.useState)(!1),e7=(0,a.useMemo)(()=>ek.slice(0,5),[ek]),e8=(0,a.useMemo)(()=>ea.filter(e=>{if(e===eN)return!0;let t=eT.find(t=>t.csvColumn===e);return!!t&&"ignore"!==t.mappedTo&&!("__new__"===t.mappedTo&&"confirmed"!==t.confidence)}),[ea,eT,eN]),e6=eE||0===e8.length?ea:e8,e9=(0,a.useMemo)(()=>eT.filter(e=>e.csvColumn!==eN),[eT,eN]),te=(0,a.useMemo)(()=>e9.filter(e=>"ignore"!==e.mappedTo&&"displayName"!==e.mappedTo&&"phone"!==e.mappedTo&&!T._q.has(e.mappedTo)&&"confirmed"===e.confidence).length,[e9]),{recognizedMappings:tt,suggestedMappings:ts,needsLookMappings:tn,setAsideMappings:ta}=(0,a.useMemo)(()=>{let e=e9.filter(e=>"confirmed"===e.confidence&&"ignore"!==e.mappedTo);return{recognizedMappings:e,suggestedMappings:e9.filter(e=>"suggested"===e.confidence),needsLookMappings:e9.filter(e=>"unmatched"===e.confidence&&!e.setAside),setAsideMappings:e9.filter(e=>"ignore"===e.mappedTo&&!!e.setAside)}},[e9]),tl=ts.length+tn.length,tr=(0,a.useMemo)(()=>(function(e,t){let s=e=>t.find(t=>t.role===e&&"__address__"===t.mappedTo)?.csvColumn??null;return{...e,streetNumber:e.streetNumber??s("street_number"),addressLine1:e.addressLine1??s("address_line1"),addressLine2:e.addressLine2??s("address_line2"),addressCity:e.addressCity??s("city"),addressState:e.addressState??s("state"),addressPostalCode:e.addressPostalCode??s("postal_code")}})((0,T.uR)(ea,ek),eT),[ea,ek,eT]),ti=(0,a.useMemo)(()=>(0,T.vN)(eT),[eT]),to=(0,a.useMemo)(()=>(0,T.ep)({headers:ea,rows:ek,mappings:eT,emailColumn:eN||null,identity:tr}),[ea,ek,eT,eN,tr]),td=(0,a.useMemo)(()=>new Set(M),[M]),tc=(0,a.useCallback)(e=>{if(0===td.size)return!1;if(e.fieldId&&td.has(e.fieldId))return!0;let t=F.find(t=>t.name===e.mappedTo);return!!t&&td.has(t.id)},[td,F]),tm=(0,a.useMemo)(()=>{let e=new Set;for(let t of eT)(tc(t)||(0,T.Fi)(t.csvColumn)||"__weight__"===t.mappedTo)&&e.add(t.csvColumn);return e},[eT,tc]),tu=(0,a.useMemo)(()=>{let e=new Set;for(let t of eT)(0,T.QG)(t.csvColumn)&&"ignore"!==t.mappedTo&&e.add(t.csvColumn);return e},[eT]),th=(0,a.useMemo)(()=>{let e=eT.find(e=>"__channel__"===e.mappedTo),t=eT.find(e=>"phone"===e.mappedTo);if(!e)return{mapped:!1,sms:0,email:0,noPhone:0,unrecognized:0,offline:0};let s=0,n=0,a=0,l=0,r=0;for(let i of ek){if(0===(0,T.OM)(i[eN]).length){(t?(0,P.vI)(i[t.csvColumn]):null)&&s++;continue}let o=(0,P.MD)(i[e.csvColumn]),d=(i[e.csvColumn]||"").trim();if(!o){d&&l++,n++;continue}if("email"===o){n++;continue}if("mail"===o||"in_person"===o||"code"===o){r++;continue}(t?(0,P.vI)(i[t.csvColumn]):null)?s++:(a++,n++)}return{mapped:!0,sms:s,email:n,noPhone:a,unrecognized:l,offline:r}},[eT,ek,eN]),tp=(0,a.useMemo)(()=>{let e=eT.find(e=>"phone"===e.mappedTo),t=ek.filter(e=>0===(0,T.OM)(e[eN]).length);if(!e)return{count:0,couldBe:t.length,phoneMapped:!1};let s=new Set;for(let n of t){let t=(0,P.vI)(n[e.csvColumn]);t&&s.add(t)}return{count:s.size,couldBe:0,phoneMapped:!0}},[eT,ek,eN]),tx=(0,a.useMemo)(()=>{let e=(0,T.a2)(ek,{emailColumn:eN,phoneColumn:eT.find(e=>"phone"===e.mappedTo)?.csvColumn??null,channelColumn:eT.find(e=>"__channel__"===e.mappedTo)?.csvColumn??null}),t=eT.find(e=>"displayName"===e.mappedTo)?.csvColumn??null,s=0;for(let n of e){let e=ek[n-1];e&&(0,T.vw)(e,ea,tr)&&(0,T.U9)(e,ea,t,ti.primary)&&s++}return{count:e.size,rowNumbers:e,complete:s,incomplete:e.size-s}},[eT,ek,eN,ea,tr,ti]),tf=(0,a.useMemo)(()=>{let e=eT.find(e=>"phone"===e.mappedTo);return eU.invalidRows.filter(t=>{if(tx.rowNumbers.has(t.row))return!1;if(!e)return!0;let s=ek[t.row-1];return!s||!(0,P.vI)(s[e.csvColumn])})},[eU.invalidRows,eT,ek,tx]),tg=eU.totalValid+tp.count+(z?tx.complete:0),tb=(0,a.useMemo)(()=>
1{if(!eV)return[];let e=new Map;for(let t of ek){let s=t[eN]?.trim().toLowerCase();if(s)for(let n of(t[eV]||"").split(/[;,]/).map(e=>e.trim().toUpperCase()).filter(Boolean))e.has(n)||e.set(n,new Set),e.get(n).add(s)}return[...e.entries()].filter(e=>{let[,t]=e;return t.size>1}).map(e=>{let[t,s]=e;return{unit:t,count:s.size}})},[eV,eN,ek]),tw=(0,a.useCallback)((e,t)=>{eP.current=!0,eS(s=>s.map(s=>{if(s.csvColumn!==e)return s;let n={...s,setAside:void 0,role:void 0,hint:void 0};if("__weight__"===t)return{...n,mappedTo:"__weight__",isNewField:!0,fieldId:void 0,confidence:"confirmed"};if("__new__"===t)return{...n,mappedTo:"__new__",isNewField:!0,fieldId:void 0,confidence:"confirmed"};if("ignore"===t)return{...n,mappedTo:"ignore",fieldId:void 0,isNewField:!1,confidence:"unmatched",setAside:{reason:"bookkeeping",note:"left out by you"}};if("displayName"===t||"phone"===t||T._q.has(t))return{...n,mappedTo:t,fieldId:void 0,isNewField:!1,confidence:"confirmed"};let a=F.find(e=>e.name===t);return{...n,mappedTo:t,fieldId:a?.id,isNewField:!1,confidence:"confirmed"}})),"__weight__"===t?eM(t=>({...t,[e]:{label:e,name:X(e),type:"number",isWeightField:!0}})):"__new__"!==t?eM(t=>{let s={...t};return delete s[e],s}):eM(t=>({...t,[e]:{label:e,name:X(e),type:"text"}}))},[F]),tv=(0,a.useCallback)((e,t)=>{eP.current=!0,eM(s=>({...s,[e]:{...s[e],...t}}))},[]),tj=(0,a.useCallback)(()=>{eS(e=>e.map(e=>"suggested"===e.confidence?{...e,confidence:"confirmed"}:e))},[]),tN=(0,a.useCallback)(()=>{eS(e=>e.map(e=>"unmatched"===e.confidence&&e.isNewField?{...e,confidence:"confirmed"}:e))},[]),ty=(0,a.useCallback)(e=>{eu(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),t_=(0,a.useCallback)(async()=>{if(ex.trim()&&I){ev(!0);try{let e=await I(ex.trim(),eg);e&&(eu(t=>new Set(t).add(e.id)),ef(""),ep(!1))}finally{ev(!1)}}},[ex,eg,I]),tC=async()=>{ec(null);let e=new Set(em);if(eh&&ex.trim()&&I){let t=await I(ex.trim(),eg);t&&(e=new Set(e).add(t.id))}let t=eT.map(e=>{if(e.csvColumn===eN)return{...e,mappedTo:"email"};if("suggested"===e.confidence||"unmatched"===e.confidence)return{...e,mappedTo:"ignore",isNewField:!1};if((e.isNewField||"__weight__"===e.mappedTo)&&eF[e.csvColumn]){let t=eF[e.csvColumn];return t.name?{...e,mappedTo:t.name,newFieldType:t.type,isNewField:!0,isWeightField:t.isWeightField||e.isWeightField||!1}:{...e,mappedTo:"ignore",isNewField:!1}}return e}),s=eX.validEmails.map(e=>{let s;let n=eK.find(t=>(0,T.OM)(t[eN])[0]===e),a={};if(n)for(let e of t){if("email"===e.mappedTo||"ignore"===e.mappedTo||"__new__"===e.mappedTo||"__address__"===e.mappedTo||Q.has(e.mappedTo))continue;let t=n[e.csvColumn]?.trim();if(t){if("displayName"===e.mappedTo||"phone"===e.mappedTo)a[e.mappedTo]=t;else if("__channel__"===e.mappedTo){let e=(0,P.MD)(t);e&&(a.channel=e)}else{let s=e.isNewField&&eF[e.csvColumn]?eF[e.csvColumn].type:F.find(t=>t.name===e.mappedTo)?.type;if("number"===s){let s=Number(t.replace(/[,%\s]/g,""));a[e.mappedTo]=isNaN(s)?t:s}else"boolean"===s?a[e.mappedTo]=["true","1","yes"].includes(t.toLowerCase()):a[e.mappedTo]=t}}}if(n&&A&&(A.verifyName||A.verifyDob||A.verifyAddress)){if(s={},A.verifyName){let e=ti.primary.first??tr.firstName,t=ti.primary.last??tr.lastName;e&&(s.firstName=n[e]?.trim()||void 0),t&&(s.lastName=n[t]?.trim()||void 0)}if(A.verifyDob&&tr.dob){let e=n[tr.dob]?.trim();e&&(s.dob=(0,T.S8)(e)||void 0)}A.verifyAddress&&(tr.addressLine1&&(s.addressLine1=n[tr.addressLine1]?.trim()||void 0),tr.addressCity&&(s.addressCity=n[tr.addressCity]?.trim()||void 0),tr.addressState&&(s.addressState=n[tr.addressState]?.trim()||void 0),tr.addressPostalCode&&(s.addressPostalCode=n[tr.addressPostalCode]?.trim()||void 0)),0===Object.keys(s).length&&(s=void 0)}return{email:e,metadata:a,identityData:s}}),n=new Set(t.filter(e=>e.isNewField&&"ignore"!==e.mappedTo).map(e=>e.csvColumn)),a=Object.entries(eF).filter(e=>{let[t,s]=e;return s.label&&s.name&&n.has(t)}).map(e=>{let[,t]=e;return t}),l=[],r=t.find(e=>"phone"===e.mappedTo);if(r){let e=new Set;for(let t of eK){if((0,T.OM)(t[eN]).length>0)continue;let s=(0,P.vI)(t[r.csvColumn]);!s||e.has(s)||(e.add(s),l.push(s))}}let i=[],o=[],d=[],c=[],m=eT.find(e=>"displayName"===e.mappedTo)?.csvColumn??null,u=t.find(e=>e.csvColumn!==eN&&T.QG(e.csvColumn)&&"ignore"!==e.mappedTo)?.csvColumn??null,h=t.find(e=>"ignore"!==e.mappedTo&&e.csvColumn!==eN&&(e.isWeightField||tc(e)||T.Fi(e.csvColumn)))?.csvColumn,p=t.find(e=>"__channel__"===e.mappedTo)?.csvColumn,x=[],f=new Set;
1for(let e of eK){let t=(0,T.OM)(e[eN]),s=t[0]??null,n=r?(0,P.vI)(e[r.csvColumn]):null,a=(0,T.U9)(e,ea,m,ti.primary);if(a&&(s||n)&&d.push(s?{email:s,name:a}:{phone:n,name:a}),s&&u&&!f.has(s)){let t=(e[u]??"").trim();t&&t.length<=100&&(x.push({email:s,units:t}),f.add(s))}if(eZ&&s&&t.length>1){let n=(0,T.IH)(e,ea,ti.coOwner)||a;c.push({email:s,alternates:t.slice(1),...n?{name:n}:{}})}let l=(0,T.vw)(e,ea,tr);if(l){if(s)i.push({email:s,address:l});else if(n)i.push({phone:n,address:l});else if(z){let t=u?(e[u]??"").trim():"",s=h?e[h]?.trim():"",n=s?Number(s.replace(/[,%\s]/g,"")):void 0;if(void 0!==n&&(!Number.isFinite(n)||n<0||n>1e6)){ec("A postal voter has an invalid voting weight. Use a number from 0 to 1,000,000, or leave the cell blank. Correct the spreadsheet and upload it again.");return}let r=p?(0,P.MD)(e[p]):null;a&&o.push({name:a,address:l,...t?{units:t}:{},...void 0!==n?{weight:n}:{},..."in_person"===r?{channel:r}:{}})}}}let g=eY?t.find(e=>e.csvColumn===eV):void 0,b=!g||"ignore"===g.mappedTo||g.mappedTo.startsWith("__")||"email"===g.mappedTo||"displayName"===g.mappedTo||"phone"===g.mappedTo||Q.has(g.mappedTo)?null:g.mappedTo,w=g&&b&&eJ?{fieldName:b,...!g.isNewField&&g.fieldId?{fieldId:g.fieldId}:{},multiUnitMode:e5>0?e1:"combined"}:null;eo(!0);try{await q({emails:eX.validEmails,contacts:s,mappings:t,newFields:a,tagIds:Array.from(e),phoneOnly:l,mailingAddresses:i,postalOnly:o,displayNames:d,coOwnerBallots:c,units:x,...eY?{unitVoting:w}:{},...en?{sheetName:en.sheets[en.index]?.name}:{}})}catch(e){ec(e instanceof Error?e.message:"Could not import your voters. Please try again.")}finally{eo(!1)}};return(0,n.jsx)(l.Vq,{open:t,onOpenChange:s,children:(0,n.jsxs)(l.cZ,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[(0,n.jsxs)(l.fK,{children:[(0,n.jsxs)(l.$N,{className:"flex items-center gap-2",children:[(0,n.jsx)(f.Z,{className:"h-5 w-5"}),"Import ","contacts"===es?"Contacts":"Voters"," from a spreadsheet"]}),(0,n.jsxs)(l.Be,{children:[S,en?` \xb7 ${en.sheets[en.index]?.name??""}`:"",":"," ",h.totalRows.toLocaleString()," rows"]})]}),ed&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-error-dark",children:ed}),(0,n.jsxs)("div",{className:"space-y-6 overflow-hidden",children:[en&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(d._,{htmlFor:"csv-sheet-select",children:"Sheet"}),(0,n.jsx)("select",{id:"csv-sheet-select","data-testid":"sheet-select",value:en.index,onChange:e=>en.onChange(Number(e.target.value)),className:"w-full px-3 py-2 text-sm border-2 border-neutral-200 rounded focus:border-neutral-900 focus:outline-none transition-colors bg-white",children:en.sheets.map((e,t)=>(0,n.jsxs)("option",{value:t,children:[e.name," — ",e.totalRows.toLocaleString()," ",1===e.totalRows?"row":"rows"]},`${e.name}-${t}`))}),(0,n.jsxs)("p",{className:"text-xs text-neutral-500",children:["This workbook has ",en.sheets.length," tabs. Everything below reads"," ",(0,n.jsx)("strong",{children:en.sheets[en.index]?.name})," — nothing on the other tabs is imported."]})]}),(0,n.jsxs)("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50/60 p-4 space-y-3","data-testid":"import-summary",children:["pending"===eO.status&&(0,n.jsxs)("p",{className:"flex items-center gap-1.5 text-xs text-neutral-500",children:[(0,n.jsx)(g.Z,{className:"h-3 w-3 animate-spin"})," Reading the file…"]}),eO.summary&&(0,n.jsxs)("p",{className:"flex items-start gap-2 text-sm text-neutral-800","data-testid":"ai-summary",children:[(0,n.jsx)(b.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-assurance-600"}),(0,n.jsx)("span",{children:eO.summary})]}),(0,n.jsx)(J,{children:"What we read"}),(0,n.jsxs)("p",{className:"text-sm text-neutral-900",children:[(0,n.jsxs)("strong",{children:[to.rows.toLocaleString()," ",to.households?1===to.rows?"property":"properties":1===to.rows?"row":"rows"]}),to.households&&(0,n.jsxs)("span",{className:"text-neutral-600",children:[" ","\xb7 a row is a property with its owners, and a property holds one ballot"]})]}),(0,n.jsxs)("dl",{className:"text-sm space-y-2",children:[(0,n.jsxs)("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-3",children:[(0,n.jsx)("dt",{className:"w-32 shrink-0 text-neutral-500",children:"Email"}),(0,n.jsxs)("dd",{className:"flex flex-1 flex-wrap items-center gap-2 min-w-0",children:[(0,n.jsxs)("select",{"aria-label":"Email column",value:eN,onChange:e=>{eP.current=!0,ey(e.target.value)},className:"max-w-full px-2 py-1 text-sm border border-neutral-200 rounded focus:border-neutral-900 focus:outline-none transition-colors bg-white",children:[(0,n.jsx)("option",{value:"",children:"This file has no email column"}),ea.map(e=>(0,n.jsx)("option",{value:e,children:e.trim()||"(unnamed column)"},e))]}),eN&&(0,n.jsxs)("span",{className:"text-neutral-600",children:[to.email.withEmail.toLocaleStr
1ing()," ",1===to.email.withEmail?"row has":"rows have"," one",to.email.secondOwner>0&&(0,n.jsxs)(n.Fragment,{children:[", ",to.email.secondOwner.toLocaleString()," list a second owner"]})]})]})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-1 sm:flex-row sm:gap-3",children:[(0,n.jsx)("dt",{className:"w-32 shrink-0 text-neutral-500",children:"Name"}),(0,n.jsxs)("dd",{className:"flex-1 min-w-0 text-neutral-800",children:[to.name.whole?(0,n.jsxs)(n.Fragment,{children:["from ",(0,n.jsx)("strong",{children:to.name.whole})]}):to.name.first||to.name.last?(0,n.jsxs)(n.Fragment,{children:["from ",(0,n.jsx)("strong",{children:[to.name.first,to.name.last].filter(Boolean).join(" + ")})]}):(0,n.jsx)("span",{className:"text-amber-700",children:"no name column found; voters are addressed by email"}),(to.name.coFirst||to.name.coLast)&&(0,n.jsxs)("span",{className:"text-neutral-600",children:[" ","\xb7 co-owner from"," ",(0,n.jsx)("strong",{className:"text-neutral-800",children:[to.name.coFirst,to.name.coLast].filter(Boolean).join(" + ")})]})]})]}),to.mobile.column&&(0,n.jsxs)("div",{className:"flex flex-col gap-1 sm:flex-row sm:gap-3",children:[(0,n.jsx)("dt",{className:"w-32 shrink-0 text-neutral-500",children:"Mobile"}),(0,n.jsxs)("dd",{className:"flex-1 min-w-0 text-neutral-800",children:["from ",(0,n.jsx)("strong",{children:to.mobile.column}),(0,n.jsxs)("span",{className:"text-neutral-600",children:[" ","\xb7 ",to.mobile.withMobile.toLocaleString()," ",1===to.mobile.withMobile?"row has":"rows have"," one",to.mobile.textOnly>0&&(0,n.jsxs)(n.Fragment,{children:[", ",to.mobile.textOnly.toLocaleString()," with no email ",1===to.mobile.textOnly?"is":"are"," texted"]}),0===to.mobile.textOnly&&!to.channel&&(0,n.jsx)(n.Fragment,{children:"; everyone is emailed, and any voter can be switched to text after import"}),to.mobile.others.length>0&&(0,n.jsxs)(n.Fragment,{children:[" \xb7 ",to.mobile.others.join(", ")," ",1===to.mobile.others.length?"is":"are"," not texted"]})]})]})]}),to.address.columns.length>0&&(0,n.jsxs)("div",{className:"flex flex-col gap-1 sm:flex-row sm:gap-3",children:[(0,n.jsx)("dt",{className:"w-32 shrink-0 text-neutral-500",children:"Mailing address"}),(0,n.jsxs)("dd",{className:"flex-1 min-w-0 text-neutral-800",children:["from ",(0,n.jsx)("strong",{children:to.address.columns.join(", ")}),(0,n.jsxs)("span",{className:"text-neutral-600",children:[" ","\xb7 ",to.address.complete.toLocaleString()," of ",to.rows.toLocaleString()," complete"]})]})]}),to.weight&&(0,n.jsxs)("div",{className:"flex flex-col gap-1 sm:flex-row sm:gap-3",children:[(0,n.jsx)("dt",{className:"w-32 shrink-0 text-neutral-500",children:"Voting weight"}),(0,n.jsxs)("dd",{className:"flex-1 min-w-0 text-neutral-800",children:["from ",(0,n.jsx)("strong",{children:to.weight})]})]}),to.unit&&(0,n.jsxs)("div",{className:"flex flex-col gap-1 sm:flex-row sm:gap-3",children:[(0,n.jsx)("dt",{className:"w-32 shrink-0 text-neutral-500",children:"Unit"}),(0,n.jsxs)("dd",{className:"flex-1 min-w-0 text-neutral-800",children:["from ",(0,n.jsx)("strong",{children:to.unit})]})]}),to.channel&&(0,n.jsxs)("div",{className:"flex flex-col gap-1 sm:flex-row sm:gap-3",children:[(0,n.jsx)("dt",{className:"w-32 shrink-0 text-neutral-500",children:"Notify by"}),(0,n.jsxs)("dd",{className:"flex-1 min-w-0 text-neutral-800",children:["from ",(0,n.jsx)("strong",{children:to.channel})]})]})]}),ej.plan.fixes.length>0&&(0,n.jsxs)("div",{className:"space-y-2.5 border-t border-neutral-200 pt-3","data-testid":"cleanup-panel",children:[(0,n.jsx)(J,{children:"What we fixed"}),ej.plan.fixes.map(e=>(0,n.jsx)(ee,{fix:e,off:e_.has(e.id),onToggle:()=>eC(t=>{let s=new Set(t);return s.has(e.id)?s.delete(e.id):s.add(e.id),s})},e.id))]}),(ta.length>0||tl>0)&&(0,n.jsxs)("p",{className:"text-xs text-neutral-600 border-t border-neutral-200 pt-3","data-testid":"set-aside-line",children:[ta.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("strong",{children:[ta.length," ",1===ta.length?"column":"columns"," set aside"]})," ","(",ta.slice(0,8).map(e=>e.csvColumn.trim()||"unnamed").join(", "),ta.length>8&&` and ${ta.length-8} more`,"): bookkeeping and blanks. Nothing about who can vote depends on them."," "]}),tl>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("strong",{children:[tl," ",1===tl?"column":"columns"]})," we could not place"," ",1===tl?"is":"are"," left out unless you keep ",1===tl?"it":"them","."," "]}),(0,n.jsx)("button",{type:"button",onClick:()=>eA(e=>!e),className:"font-medium text-neutral-900 underline underline-offset-2 hover:text-assurance-700",children:ez?"Hide columns":"Review columns"})]}),"done"===eO.status&&(0,n.jsx)("p",{className:"text-[11px] text-neutral-400",children:"Column names and value patterns were checked by an AI model. The names, emails, phone numbers and addresses themselves were read and tidied in your browser, and never sent anywhere."})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)(d._,{children:"Preview (first 5 rows)"}),ea.length>e6.length||eE?(0,n.jsx)("button",{type:"button",onClick:()=>eR(e=>!e),className:"text-xs text-neutral-500 underline underline-offset-2 hover:text-neutral-900",children:eE?`Show the ${e6.length===ea.length?e8.length:e6.length} in use`:`Show all ${ea.length} columns`}):null]}),(0,n.jsx)("div",{className:"overflow-x-auto rounded-lg border border-neutral-200",children:(0,n.jsxs)("table",{className:"min-w-full text-sm",children:[(0,n.jsx)("thead",{children:(0,n.jsx)("tr",{className:"border-b bg-neutral-50",children:e6.map(e=>{let t=tm.has(e),s=tu.has(e);return(0,n.jsxs)("th",{className:(0,C.cn)("px-3 py-2 text-left font-medium whitespace-nowrap",e===eN&&"text-assurance-700 bg-assurance-50",t&&"text-violet-700 bg-violet-50",s&&!t&&"text-blue-700 bg-blue-50"),children:[e.trim()||(0,n.jsx)("span",{className:"italic text-neutral-400",children:"(unnamed)"}),e===eN&&(0,n.jsx)(i.C,{variant:"outline",className:"ml-1.5 text-[10px] py-0",children:"email"}),t&&(0,n.jsx)(i.C,{variant:"outline",className:"ml-1.5 text-[10px] py-0 border-violet-300 text-violet-600",children:"weight"}),s&&!t&&(0,n.jsx)(i.C,{variant:"outline",className:"ml-1.5 text-[10px] py-0 border-blue-300 text-blue-600",children:"group"})]},e)})})}),(0,n.jsx)("tbody",{children:e7.map((e,t)=>(0,n.jsx)("tr",{className:"border-b last:border-0",children:e6.map(t=>(0,n.jsx)("td",{className:(0,C.cn)("px-3 py-1.5 whitespace-nowrap",t===eN&&"bg-assurance-50/50",tm.has(t)&&"bg-violet-50/50",tu.has(t)&&!tm.has(t)&&"bg-blue-50/50"),children:e[t]||""},t))},t))})]})})]}),tm.size>0&&tu.size>0?(0,n.jsxs)("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 p-3 text-sm text-neutral-700 flex items-start gap-2",children:[(0,n.jsx)(c.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-violet-500"}),(0,n.jsxs)("span",{children:["We detected a ",(0,n.jsx)("strong",{className:"text-violet-700",children:"vote weight"})," column and a ",(0,n.jsx)("strong",{className:"text-blue-700",children:"group/unit"})," column. Both are saved on each contact."," ",eY?"One vote per unit is chosen below; to count each vote by its weight, choose this column under Weighted voting in Voting Rules or the election’s settings.":"Weighted voting and one vote per unit are turned on in the election’s Voting Rules."]})]}):M.length>0&&eT.some(tc)?(0,n.jsxs)("div",{className:"rounded-lg border border-violet-200 bg-vi
1olet-50 p-3 text-sm text-violet-800 flex items-start gap-2",children:[(0,n.jsx)(w.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-violet-500"}),(0,n.jsxs)("span",{children:["Fields marked ",(0,n.jsx)("strong",{children:"Weight Field"})," are used to calculate voting weights in active votes. Ensure the correct column maps to this field so weights stay accurate."]})]}):tm.size>0?(0,n.jsxs)("div",{className:"rounded-lg border border-violet-200 bg-violet-50 p-3 text-sm text-violet-800 flex items-start gap-2",children:[(0,n.jsx)(c.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-violet-500"}),(0,n.jsxs)("span",{children:["A column was detected as a ",(0,n.jsx)("strong",{children:"vote weight"})," field. It will be saved as a number field you can select for weighted voting."]})]}):tu.size>0&&!eY?(0,n.jsxs)("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 flex items-start gap-2",children:[(0,n.jsx)(m.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-blue-500"}),(0,n.jsxs)("span",{children:["A column was detected as a ",(0,n.jsx)("strong",{children:"unit"})," identifier. You can use it for per-unit voting (one vote per unit) in Voting Rules."]})]}):null,eH.length>0&&(0,n.jsxs)("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 space-y-2","data-testid":"multi-unit-owners",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(m.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-blue-500"}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("p",{className:"font-medium",children:1===eH.length?"1 owner is listed on more than one row, with a different unit on each":`${eH.length} owners are listed on more than one row, with a different unit on each`}),(0,n.jsx)("p",{className:"text-blue-700",children:"That is how an export writes someone who owns several units. Each of them is imported as one voter. Say what to keep:"})]})]}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer rounded-md bg-white/70 p-2",children:[(0,n.jsx)("input",{type:"radio",name:"repeated-owner-policy",checked:"merge"===eG,onChange:()=>eq("merge"),className:"mt-0.5 h-4 w-4 shrink-0 accent-blue-600","data-testid":"repeated-owner-merge"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:"All their units on one voter"})," (recommended). The roster shows every unit they own, and how they vote them, one combined ballot or one ballot per unit,"," ",eY?"is chosen under Voting by unit below.":"is set in the election’s Voting Rules."]})]}),(0,n.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer rounded-md bg-white/70 p-2",children:[(0,n.jsx)("input",{type:"radio",name:"repeated-owner-policy",checked:"first"===eG,onChange:()=>eq("first"),className:"mt-0.5 h-4 w-4 shrink-0 accent-blue-600","data-testid":"repeated-owner-first"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:"First row only."})," Their other units are left out of this election."]})]})]}),(0,n.jsxs)("ul",{className:"space-y-0.5 pt-0.5 text-xs text-blue-700","data-testid":"multi-unit-owner-list",children:[eH.slice(0,12).map(e=>(0,n.jsxs)("li",{className:"flex flex-wrap items-baseline gap-x-2",children:[(0,n.jsx)("span",{className:"font-mono",children:e.email}),(0,n.jsxs)("span",{children:[e.rows," rows \xb7"," ","merge"===eG?`units ${e.units.join(", ")}`:`unit ${e.units[0]} kept, ${e.units.slice(1).join(", ")} left out`]})]},e.email)),eH.length>12&&(0,n.jsxs)("li",{children:["+",eH.length-12," more"]})]})]}),eY&&(0,n.jsxs)("div",{className:"rounded-card border border-neutral-300 bg-neutral-50 p-3 text-body-sm text-neutral-800 space-y-2","data-testid":"unit-voting-choice",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(m.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-neutral-500","aria-hidden":"true"}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("p",{className:"font-medium text-neutral-900",children:"Voting by unit"}),(0,n.jsxs)("p",{className:"text-neutral-600",children:["The ",eV," column names each voter’s unit. Say how the units vote:"]})]})]}),(0,n.jsxs)("div",{className:"space-y-1.5",role:"radiogroup","aria-label":"Voting by unit",children:[(0,n.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer rounded-card border border-neutral-200 bg-white p-2",children:[(0,n.jsx)("input",{type:"radio",name:"unit-voting",checked:eJ,onChange:()=>e0(!0),className:"mt-0.5 h-4 w-4 shrink-0 accent-neutral-900","data-testid":"unit-voting-on"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:"One vote per unit"})," (recommended). Co-owners of a unit share its vote: the first to vote casts it, and the others are told it has already been cast and by whom."]})]}),(0,n.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer rounded-card border border-neutral-200 bg-white p-2",children:[(0,n.jsx)("input",{type:"radio",name:"unit-voting",checked:!eJ,onChange:()=>e0(!1),className:"mt-0.5 h-4 w-4 shrink-0 accent-neutral-900","data-testid":"unit-voting-off"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:"One vote per person."})," Everyone on the list votes, co-owners included, and the units are kept for reference."]})]})]}),tb.length>0&&(0,n.jsxs)("div",{className:"space-y-1","data-testid":"shared-units",children:[(0,n.jsxs)("p",{className:"text-neutral-700",children:[1===tb.length?"1 unit has":`${tb.length} units have`," more than one owner on the list."," ",eJ?"Each counts once, for whichever owner votes first.":"Every owner’s ballot counts."]}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-1",children:[tb.slice(0,12).map(e=>(0,n.jsxs)(i.C,{variant:"outline",className:"border-neutral-300 bg-white text-neutral-700 text-caption py-0",children:["Unit ",e.unit," \xb7 ",e.count]},e.unit)),tb.length>12&&(0,n.jsxs)("span",{className:"text-caption text-neutral-500",children:["+",tb.length-12," more"]})]})]}),eJ&&e5>0&&(0,n.jsxs)("fieldset",{className:"space-y-1.5","data-testid":"unit-multi-mode",children:[(0,n.jsx)("legend",{className:"pb-1 font-medium text-neutral-900",children:1===e5?"1 voter owns more than one unit. How do they vote?":`${e5} voters own more than one unit. How do they vote?`}),k.Qw.map(e=>(0,n.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer rounded-card border border-neutral-200 bg-white p-2",children:[(0,n.jsx)("input",{type:"radio",name:"unit-multi-mode",checked:e1===e.value,onChange:()=>e2(e.value),className:"mt-0.5 h-4 w-4 shrink-0 accent-neutral-900","data-testid":`unit-multi-mode-${e.value}`}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:e.label}),"per_unit"===e.value?" (recommended)":"",". ",e.help]})]},e.value))]})]}),tb.length>0&&!eY&&(0,n.jsx)("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800",children:(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(m.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-amber-500"}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsxs)("p",{className:"font-medium",children:[tb.length," ",1===tb.length?"unit is":"units are"," shared by co-owners"]}),(0,n.jsx)("p",{className:"text-amber-700",children:"These units are listed for more than one person. With One vote per unit on in the election’s Voting Rules, each unit counts once, for whichever owner votes first; without it, every owner’s ballot counts."}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-1 pt-0.5",children:[tb.slice(0,12).map(e=>(0,n.jsxs)(i.C,{variant:"outline",className:"border-amber-300 bg-amber-100 text-amber-700 text-[10px] py-0",children:["Unit ",e.unit," \xb7 ",e.count]},e.unit)),tb.length>12&&(0,n.jsxs)("span",{className:"text-xs text-amber-600",children:["+",tb.length-12," more"]})]})]})]})}),tp.count>0&&(0,n.jsxs)("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 space-y-1.5",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(v.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-blue-500"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:tp.count})," ",1===tp.count?"row has":"rows have"," a mobile number and no email address. ",1===tp.count?"That voter":"Those voters"," will be added",er?" as text voters":(0,n.jsxs)(n.Fragment,{children:[" and will get their ballot ",(0,n.jsx)("strong",{children:"by text"})]}),"."]})]}),er?(0,n.jsxs)("p",{className:"ml-6 text-xs text-muted-foreground",children:["Texts come with paid elections, and at ",W.bs," voters or fewer this one is free. Unless your plan covers texts, nobody is texted: when you publish, you can hand ",1===tp.count?"this voter a link":"these voters their links"," ","yourself instead, or give them an email address in the file."]}):!Z&&(0,n.jsx)("p",{className:"ml-6 text-xs text-blue-700",children:"SMS verification will be switched on for this election so they can be reached. Text is the only way. You confirm texting consent before it goes on."})]}),tx.count>0&&z&&(0,n.jsxs)("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 flex items-start gap-2",children:[(0,n.jsx)(j.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-blue-500"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:tx.complete})," ",1===tx.complete?"row is a paper voter":"rows are paper voters"," ","with no email or mobile. ",1===tx.complete?"It":"They"," will be added and reached ",(0,n.jsx)("strong",{children:"by mail"})," at the address in the file.",tx.incomplete>0&&(0,n.jsxs)(n.Fragment,{children:[" ",(0,n.jsx)("strong",{children:tx.incomplete})," more"," ",1===tx.incomplete?"has":"have"," no name or an incomplete address (street, city, state and ZIP) and will be skipped."]})]})]}),eU.multiEmailRows.length>0&&(0,n.jsxs)("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(m.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-blue-500"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:eU.multiEmailRows.length})," ",1===eU.multiEmailRows.length?"row lists":"rows list"," more than one email address, which is how an export writes a property with co-owners. Only the first address is invited unless you say otherwise."]})]}),(0,n.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer rounded-md bg-white/70 p-2",children:[(0,n.jsx)("input",{type:"checkbox",checked:eZ,onChange:e=>eL(e.target.checked),className:"mt-0.5 h-4 w-4 shrink-0 accent-blue-600"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:"Send every address a ballot, first to vote counts."})," Each co-owner gets their own link, the property still holds one vote, and whichever of them votes first casts it. The others are told it has already been cast and by whom."]})]})]}),tx.count>0&&!z&&(0,n.jsxs)("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800 flex items-start gap-2",children:[(0,n.jsx)(j.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-amber-500"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:tx.count})," ",1===tx.count?"row is a paper voter":"rows are paper voters"," ","with no email address and no mobile number."," ",1===tx.count?"It":"They"," will"," ",(0,n.jsx)("strong",{children:"not"})," be added here — nothing is wrong with the file, this is just the wrong door. Add ",1===tx.count?"it":"them"," from the election’s ",(0,n.jsx)("strong",{children:"Voters"})," tab once it exists, where a mailing address makes a voter who is reached by mail."]})]}),tp.couldBe>0&&(0,n.jsxs)("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800 flex items-start gap-2",children:[(0,n.jsx)(N.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-amber-500"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:tp.couldBe})," ",1===tp.couldBe?"row has":"rows have"," no email address. If those members have mobile numbers in this file, map that column to"," ",(0,n.jsx)("strong",{children:"Phone"})," above and they will be added as text-only voters instead of being skipped."]})]}),th.mapped&&(0,n.jsxs)("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 space-y-1.5",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(v.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-blue-500"}),(0,n.jsxs)("span",{children:["A ",(0,n.jsx)("strong",{children:"Notify By"})," column was found. After import,"," ",(0,n.jsx)("strong",{children:th.sms})," ",1===th.sms?"voter":"voters"," will be texted and ",(0,n.jsx)("strong",{children:th.email})," emailed. You can change any of them individually before publishing."]})]}),th.noPhone>0&&(0,n.jsxs)("p",{className:"ml-6 text-blue-700 text-xs",children:[th.noPhone," asked for text but"," ",eT.some(e=>"phone"===e.mappedTo)?"have no usable number in the phone column":"no column is mapped to Phone",", so they will be emailed. ",!eT.some(e=>"phone"===e.mappedTo)&&'Map a column to "Phone" above to text them.']}),th.offline>0&&z&&(0,n.jsxs)("p",{className:"ml-6 text-blue-700 text-xs","data-testid":"channel-preview-offline",children:[th.offline," ",1===th.offline?"voter votes":"voters vote"," on paper or with a printed code (“mail”, “in person”, “code”) — nothing is emailed or texted to them."]}),th.offline>0&&!z&&(0,n.jsxs)("p",{className:"ml-6 text-amber-700 text-xs font-medium","data-testid":"channel-preview-offline-wizard",children:[th.offline," ",1===th.offline?"row is":"rows are"," marked paper or printed-code (“mail”, “in person”, “code”). They’ll be added as email voters for now — set up paper ballots and reassign them on the election page after you create the vote, before sending any invites."]}),th.unrecognized>0&&(0,n.jsxs)("p",{className:"ml-6 text-blue-700 text-xs",children:[th.unrecognized," ",1===th.unrecognized?"row has":"rows have"," a value we could not read (we understand “email”, “text”, “sms”, “mail”, “in person”, “code”, “yes”, “no”). Those voters default to email."]}),er&&th.sms>0?(0,n.jsx)("p",{className:"ml-6 text-xs text-blue-700",children:"Texts come with paid elections, and this one is free. Unless your plan covers texts, voters set to text are not texted: when you publish, you can hand them their links yourself instead."}):!Z&&th.sms>0&&(0,n.jsx)("p",{className:"ml-6 text-xs text-blue-700",children:"SMS verification is off for this election. It is switched on when you add these voters — you confirm texting consent first — so they are texted, not emailed."})]}),Z&&!eT.some(e=>"phone"===e.mappedTo)&&(0,n.jsxs)("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800 flex items-start gap-2",children:[(0,n.jsx)(N.Z,{className:"h-4 w-4 shrink-0 mt-0.5 text-amber-500"}),(0,n.jsxs)("span",{children:["SMS verification is enabled but no column is mapped to ",(0,n.jsx)("strong",{children:"Phone"}),". Map a column to “Phone” above to text any of these voters — without one, everyone is contacted by email."]})]}),e9.length>0&&(ez||tl>0)&&(0,n.jsxs)("div",{className:"space-y-5","data-testid":"column-review",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)(d._,{children:"Columns"}),0===tl&&(0,n.jsx)("button",{type:"button",onClick:()=>eA(!1),className:"text-xs text-neutral-500 underline underline-offset-2 hover:text-neutral-900",children:"Hide"})]}),tt.length>0&&(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("p",{className:"text-xs font-mono uppercase tracking-wider text-neutral-400 border-l-2 border-neutral-200 pl-2",children:["In use (",tt.length,")"]}),tt.map(e=>(0,n.jsx)(Y,{mapping:e,existingFields:F,newFields:eF,updateMapping:tw,updateNewField:tv,isWeightField:tc(e),weightFieldIdSet:td,compact:!(0,T.Fi)(e.csvColumn)&&!tc(e)},e.csvColumn))]}),ts.length>0&&(0,n.jsxs)("div",{className:"space-y-1.5 pt-4 border-t border-neutral-100",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("p",{className:"text-xs font-mono uppercase tracking-wider text-amber-600 border-l-2 border-amber-300 pl-2",children:["Verify matches (",ts.length,")"]}),(0,n.jsx)("button",{onClick:tj,className:"text
1-xs text-amber-700 hover:text-amber-900 underline underline-offset-2 font-medium",children:"Confirm all suggestions"})]}),ts.map(e=>(0,n.jsx)(Y,{mapping:e,existingFields:F,newFields:eF,updateMapping:tw,updateNewField:tv,isWeightField:tc(e),weightFieldIdSet:td},e.csvColumn))]}),tn.length>0&&(0,n.jsxs)("div",{className:"space-y-1.5 pt-4 border-t border-neutral-100",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("p",{className:"text-xs font-mono uppercase tracking-wider text-amber-600 border-l-2 border-amber-300 pl-2",children:["Could not place (",tn.length,")"]}),(0,n.jsx)("button",{onClick:tN,className:"text-xs text-amber-700 hover:text-amber-900 underline underline-offset-2 font-medium",children:"Confirm all new fields"})]}),(0,n.jsx)("p",{className:"text-xs text-neutral-500 pl-2",children:"Left out unless you keep them. Nothing about who can vote depends on them."}),tn.map(e=>(0,n.jsx)(Y,{mapping:e,existingFields:F,newFields:eF,updateMapping:tw,updateNewField:tv,isWeightField:tc(e),weightFieldIdSet:td},e.csvColumn))]}),ta.length>0&&(0,n.jsxs)("div",{className:"space-y-1.5 pt-4 border-t border-neutral-100",children:[(0,n.jsxs)("p",{className:"text-xs font-mono uppercase tracking-wider text-neutral-400 border-l-2 border-neutral-200 pl-2",children:["Set aside (",ta.length,")"]}),ta.map(e=>(0,n.jsx)(Y,{mapping:e,existingFields:F,newFields:eF,updateMapping:tw,updateNewField:tv,isWeightField:!1,weightFieldIdSet:td,compact:!0},e.csvColumn))]})]}),($.length>0||I)&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)(d._,{className:"flex items-center gap-1.5",children:[(0,n.jsx)(m.Z,{className:"h-3.5 w-3.5 text-neutral-400"}),"Add to group"]}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[$.map(e=>{let t=em.has(e.id);return(0,n.jsxs)("button",{onClick:()=>ty(e.id),className:(0,C.cn)("inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium transition-colors border",t?"bg-neutral-900 text-white border-neutral-900":"bg-white text-neutral-700 border-neutral-200 hover:border-neutral-400"),children:[(0,n.jsx)("span",{className:"h-2 w-2 rounded-full flex-shrink-0",style:{backgroundColor:t?"white":e.color}}),e.name]},e.id)}),I&&!eh&&(0,n.jsxs)("button",{onClick:()=>ep(!0),className:"inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium text-neutral-500 border border-dashed border-neutral-300 hover:border-neutral-400 hover:text-neutral-700 transition-colors",children:[(0,n.jsx)(y.Z,{className:"h-3 w-3"}),"New group"]})]}),eh&&I&&(0,n.jsxs)("div",{className:"flex items-center gap-2 animate-in fade-in slide-in-from-top-1",children:[(0,n.jsx)(o.I,{placeholder:"Group name...",value:ex,onChange:e=>ef(e.target.value),onKeyDown:e=>"Enter"===e.key&&t_(),className:"h-8 text-sm flex-1",autoFocus:!0}),(0,n.jsx)("div",{className:"flex gap-0.5",children:et.map(e=>(0,n.jsx)("button",{onClick:()=>eb(e),className:(0,C.cn)("h-5 w-5 rounded-full border-2 transition-colors",eg===e?"border-neutral-900":"border-transparent"),style:{backgroundColor:e}},e))}),(0,n.jsx)(r.z,{size:"sm",onClick:t_,disabled:!ex.trim()||ew,className:"h-8 text-xs",children:ew?(0,n.jsx)(g.Z,{className:"h-3 w-3 animate-spin"}):"Add"}),(0,n.jsx)("button",{onClick:()=>{ep(!1),ef("")},className:"text-neutral-400 hover:text-neutral-600",children:(0,n.jsx)(x.Z,{className:"h-3.5 w-3.5"})})]})]}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,n.jsxs)(i.C,{variant:"outline",className:"border-assurance-200 bg-assurance-50 text-assurance-700",children:[(0,n.jsx)(p.Z,{className:"h-3 w-3 mr-1"}),eU.totalValid," valid emails"]}),tx.count>0&&(0,n.jsxs)(i.C,{variant:"outline",className:"border-amber-200 bg-amber-50 text-amber-700",children:[(0,n.jsx)(j.Z,{className:"h-3 w-3 mr-1"}),tx.count," on paper"]}),tp.count>0&&(0,n.jsxs)(i.C,{variant:"outline",className:"border-blue-200 bg-blue-50 text-blue-700",children:[(0,n.jsx)(v.Z,{className:"h-3 w-3 mr-1"}),tp.count," by text"]}),tf.length>0&&(0,n.jsx)("button",{onClick:()=>eI(!e$),className:"inline-flex",children:(0,n.jsxs)(i.C,{variant:"outline",className:"border-red-200 bg-red-50 text-red-700 cursor-pointer hover:bg-red-100",children:[(0,n.jsx)(u.Z,{className:"h-3 w-3 mr-1"}),tf.length," invalid",e$?(0,n.jsx)(x.Z,{className:"h-3 w-3 ml-1"}):(0,n.jsx)(_.Z,{className:"h-3 w-3 ml-1"})]})}),eX.duplicates.length>0&&(0,n.jsx)("button",{type:"button",onClick:()=>e4(!e3),className:"inline-flex","data-testid":"repeated-emails-badge",children:(0,n.jsxs)(i.C,{variant:"outline",className:"border-yellow-200 bg-yellow-50 text-yellow-700 cursor-pointer hover:bg-yellow-100",children:[eX.duplicates.length," ",1===eX.duplicates.length?"email repeats":"emails repeat",", first row kept",e3?(0,n.jsx)(x.Z,{className:"h-3 w-3 ml-1"}):(0,n.jsx)(_.Z,{className:"h-3 w-3 ml-1"})]})}),te>0&&(0,n.jsxs)(i.C,{variant:"outline",className:"border-blue-200 bg-blue-50 text-blue-700",children:[(0,n.jsx)(y.Z,{className:"h-3 w-3 mr-1"}),te," data ",1===te?"field":"fields"," mapped"]})]}),e3&&eX.duplicates.length>0&&(0,n.jsxs)("div",{className:"rounded-lg border border-yellow-200 bg-yellow-50 p-3 text-sm space-y-1 max-h-32 overflow-y-auto animate-in fade-in slide-in-from-top-1","data-testid":"repeated-emails-list",children:[(0,n.jsxs)("p",{className:"text-yellow-800",children:["One voter per email. The
1se addresses appear more than once in the file",eV?" with the same unit or none":"","; the first row is the one imported."]}),[...new Set(eX.duplicates)].slice(0,20).map(e=>(0,n.jsx)("div",{className:"font-mono text-yellow-700",children:e},e)),new Set(eX.duplicates).size>20&&(0,n.jsxs)("div",{className:"text-yellow-700",children:["+",new Set(eX.duplicates).size-20," more"]})]}),e$&&tf.length>0&&(0,n.jsxs)("div",{className:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm space-y-1 max-h-32 overflow-y-auto animate-in fade-in slide-in-from-top-1",children:[tf.slice(0,20).map(e=>(0,n.jsxs)("div",{className:"text-red-700",children:["Row ",e.row,": ",(0,n.jsx)("span",{className:"font-mono",children:e.value})]},e.row)),tf.length>20&&(0,n.jsxs)("div",{className:"text-red-500",children:["...and ",tf.length-20," more"]})]}),h.errors.length>0&&(0,n.jsx)("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800",children:h.errors.map((e,t)=>(0,n.jsx)("div",{children:e},t))})]}),(0,n.jsxs)(l.cN,{className:"sticky bottom-0 -mx-6 -mb-6 mt-2 flex-col gap-2 border-t border-neutral-200 bg-background px-6 py-4 sm:flex-col sm:gap-2 sm:space-x-0",children:[tl>0&&(0,n.jsxs)("p",{className:"text-xs text-neutral-600 sm:text-right",role:"status",children:[1===tl?"1 column we could not place is":`${tl} columns we could not place are`," not being imported. Nothing about who can vote depends on"," ",1===tl?"it":"them","; keep"," ",1===tl?"it":"any of them"," as a contact field above if you want."]}),(0,n.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[(0,n.jsx)(r.z,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),(0,n.jsx)(r.z,{onClick:tC,disabled:0===tg||ei,children:ei?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(g.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):(0,n.jsxs)(n.Fragment,{children:["Import ",tg," ","contacts"===es?"contacts":"voters"]})})]})]})]})})}}}]);

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.