PageSourceSearch

https://crewops.lovable.app/assets/CustomerFinder-Bo6j9GKX.js

js crewops.lovable.app collected 2026-10-03 03:23:33 UTC 34,525 bytes, 17 lines download raw bytes

vendor: 5,037 bytes, lines 1-6
1import{c as ht,cL as pt,cd as gt,r as n,cg as bt,j as e,cl as G,cs as Q,cf as yt,ci as re,cu as jt,ct as vt,d2 as qe,b1 as wt,u as Nt,an as B,K as W,aq as St,aK as X,M as _t,U as le,aX as Be,a7 as ce,m as $e,aj as Ve,B as Z,a6 as de,Q as me,bF as Se,a$ as ue,b5 as Ct,P as kt}from"./index-B01jGDSO.js";import{u as Rt}from"./useOrgQuery-JRPR4imB.js";import{H as He}from"./house-BstGMZ7_.js";import{F as Ke}from"./filter-BEpKhFH_.js";import{S as Oe}from"./square-check-big-B16EHvBu.js";import{S as Ue}from"./square-CyisdnPT.js";import{S as Pt}from"./save-DXWhUztY.js";import{A as Mt}from"./arrow-right-D4XSCGwT.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Et=ht("Satellite",[["path",{d:"M13 7 9 3 5 7l4 4",key:"vyckw6"}],["path",{d:"m17 11 4 4-4 4-4-4",key:"rchckc"}],["path",{d:"m8 12 4 4 6-6-4-4Z",key:"1sshf7"}],["path",{d:"m16 8 3-3",key:"x428zp"}],["path",{d:"M9 21a6 6 0 0 0-6-6",key:"1iajcf"}]]);var We=["PageUp","PageDown"],Xe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Ze={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},J="Slider",[Ce,zt,Dt]=pt(J),[Ge,ns]=gt(J,[Dt]),[It,xe]=Ge(J),Qe=n.forwardRef((r,a)=>{const{name:i,min:l=0,max:o=100,step:x=1,orientation:c="horizontal",disabled:u=!1,minStepsBetweenThumbs:f=0,defaultValue:C=[l],value:w,onValueChange:m=()=>{},onValueCommit:g=()=>{},inverted:k=!1,form:M,...y}=r,N=n.useRef(new Set),p=n.useRef(0),j=c==="horizontal"?Ft:Lt,[v=[],I]=bt({prop:w,defaultProp:C,onChange:S=>{var z;(z=[...N.current][p.current])==null||z.focus(),m(S)}}),ee=n.useRef(v);function $(S){const L=Vt(v,S);K(S,L)}function fe(S){K(S,p.current)}function O(){const S=ee.current[p.current];v[p.current]!==S&&g(v)}function K(S,L,{commit:z}={commit:!1}){const te=Ut(x),V=Yt(Math.round((S-l)/x)*x+l,te),H=qe(V,[l,o]);I((b=[])=>{const T=Bt(b,H,L);if(Ot(T,f*x)){p.current=T.indexOf(H);const U=String(T)!==String(b);return U&&z&&g(T),U?T:b}else return b})}return e.jsx(It,{scope:r.__scopeSlider,name:i,disabled:u,min:l,max:o,valueIndexToChangeRef:p,thumbs:N.current,values:v,orientation:c,form:M,children:e.jsx(Ce.Provider,{scope:r.__scopeSlider,children:e.jsx(Ce.Slot,{scope:r.__scopeSlider,children:e.jsx(j,{"aria-disabled":u,"data-disabled":u?"":void 0,...y,ref:a,onPointerDown:G(y.onPointerDown,()=>{u||(ee.current=v)}),min:l,max:o,inverted:k,onSlideStart:u?void 0:$,onSlideMove:u?void 0:fe,onSlideEnd:u?void 0:O,onHomeKeyDown:()=>!u&&K(l,0,{commit:!0}),onEndKeyDown:()=>!u&&K(o,v.length-1,{commit:!0}),onStepKeyDown:({event:S,direction:L})=>{if(!u){const V=We.includes(S.key)||S.shiftKey&&Xe.includes(S.key)?10:1,H=p.current,b=v[H],T=x*V*L;K(b+T,H,{commit:!0})}}})})})})});Qe.displayName=J;var[Je,et]=Ge(J,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Ft=n.forwardRef((r,a)=>{const{min:i,max:l,dir:o,inverted:x,onSlideStart:c,onSlideMove:u,onSlideEnd:f,onStepKeyDown:C,...w}=r,[m,g]=n.useState(null),k=Q(a,j=>g(j)),M=n.useRef(void 0),y=yt(o),N=y==="ltr",p=N&&!x||!N&&x;function F(j){const v=M.current||m.getBoundingClientRect(),I=[0,v.width],$=Pe(I,p?[i,l]:[l,i]);return M.current=v,$(j-v.left)}return e.jsx(Je,{scope:r.__scopeSlider,startEdge:p?"left":"right",endEdge:p?"right":"left",direction:p?1:-1,size:"width",children:e.jsx(tt,{dir:y,"data-orientation":"horizontal",...w,ref:k,style:{...w.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:j=>{const v=F(j.clientX);c==null||c(v)},onSlideMove:j=>{const v=F(j.clientX);u==null||u(v)},onSlideEnd:()=>{M.current=void 0,f==null||f()},onStepKeyDown:j=>{const I=Ze[p?"from-left":"from-right"].includes(j.key);C==null||C({event:j,direction:I?-1:1})}})})}),Lt=n.forwardRef((r,a)=>{const{min:i,max:l,inverted:o,onSlideStart:x,onSlideMove:c,onSlideEnd:u,onStepKeyDown:f,...C}=r,w=n.useRef(null),m=Q(a,w),g=n.useRef(void 0),k=!o;function M(y){const N=g.current||w.current.getBoundingClientRect(),p=[0,N.height],j=Pe(p,k?[l,i]:[i,l]);return g.current=N,j(y-N.top)}return e.jsx(Je,{scope:r.__scopeSlider,startEdge:k?"bottom":"top",endEdge:k?"top":"bottom",size:"height",direction:k?1:-1,children:e.jsx(tt,{"data-orientation":"vertical",...C,ref:m,style:{...C.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:y=>{const N=M(y.clientY);x==null||x(N)},onSlideMove:y=>{const N=M(y.clientY);c==null||c(N)},onSlideEnd:()=>{g.current=void 0,u==null||u()},onStepKeyDown:y=>{const p=Ze[k?"from-bottom":"from-top"].includes(y.key);f==null||f({event:y,direction:p?-1:1})}})})}),tt=n.forwardRef((r,a)=>{const{__scopeSlider:i,onSlideStart:l,onSlideMove:o,onSlideEnd:x,onHomeKeyDown:c,onEndKeyDown:u,onStepKeyDown:f,...C}=r,w=xe(J,i);return e.jsx(re.span,{...C,ref:a,onKeyDown:G(r.onKeyDown,m=>{m.key==="Home"?(c(m),m.preventDefault()):m.key==="End"?(u(m),m.preventDefault()):We.concat(Xe).includes(m.key)&&
6(f(m),m.preventDefault())}),onPointerDown:G(r.onPointerDown,m=>{const g=m.target;g.setPointerCapture(m.pointerId),m.preventDefault(),w.thumbs.has(g)?g.focus():l(m)}),onPointerMove:G(r.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&o(m)}),onPointerUp:G(r.onPointerUp,m=>{const g=m.target;g.hasPointerCapture(m.pointerId)&&(g.releasePointerCapture(m.pointerId),x(m))})})}),st="SliderTrack",rt=n.forwardRef((r,a)=>{const{__scopeSlider:i,...l}=r,o=xe(st,i);return e.jsx(re.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...l,ref:a})});rt.displayName=st;var ke="SliderRange",nt=n.forwardRef((r,a)=>{const{__scopeSlider:i,...l}=r,o=xe(ke,i),x=et(ke,i),c=n.useRef(null),u=Q(a,c),f=o.values.length,C=o.values.map(g=>it(g,o.min,o.max)),w=f>1?Math.min(...C):0,m=100-Math.max(...C);return e.jsx(re.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...l,ref:u,style:{...r.style,[x.startEdge]:w+"%",[x.endEdge]:m+"%"}})});nt.displayName=ke;var Re="SliderThumb",at=n.forwardRef((r,a)=>{const i=zt(r.__scopeSlider),[l,o]=n.useState(null),x=Q(a,u=>o(u)),c=n.useMemo(()=>l?i().findIndex(u=>u.ref.current===l):-1,[i,l]);return e.jsx(Tt,{...r,ref:x,index:c})}),Tt=n.forwardRef((r,a)=>{const{__scopeSlider:i,index:l,name:o,...x}=r,c=xe(Re,i),u=et(Re,i),[f,C]=n.useState(null),w=Q(a,F=>C(F)),m=f?c.form||!!f.closest("form"):!0,g=jt(f),k=c.values[l],M=k===void 0?0:it(k,c.min,c.max),y=$t(l,c.values.length),N=g==null?void 0:g[u.size],p=N?Ht(N,M,u.direction):0;return n.useEffect(()=>{if(f)return c.thumbs.add(f),()=>{c.thumbs.delete(f)}},[f,c.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[u.startEdge]:`calc(${M}% + ${p}px)`},children:[e.jsx(Ce.ItemSlot,{scope:r.__scopeSlider,children:e.jsx(re.span,{role:"slider","aria-label":r["aria-label"]||y,"aria-valuemin":c.min,"aria-valuenow":k,"aria-valuemax":c.max,"aria-orientation":c.orientation,"data-orientation":c.orientation,"data-disabled":c.disabled?"":void 0,tabIndex:c.disabled?void 0:0,...x,ref:w,style:k===void 0?{display:"none"}:r.style,onFocus:G(r.onFocus,()=>{c.valueIndexToChangeRef.current=l})})}),m&&e.jsx(ot,{name:o??(c.name?c.name+(c.values.length>1?"[]":""):void 0),form:c.form,value:k},l)]})});at.displayName=Re;var At="RadioBubbleInput",ot=n.forwardRef(({__scopeSlider:r,value:a,...i},l)=>{const o=n.useRef(null),x=Q(o,l),c=vt(a);return n.useEffect(()=>{const u=o.current;if(!u)return;const f=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(f,"value").set;if(c!==a&&w){const m=new Event("input",{bubbles:!0});w.call(u,a),u.dispatchEvent(m)}},[c,a]),e.jsx(re.input,{style:{display:"none"},...i,ref:x,defaultValue:a})});ot.displayName=At;function Bt(r=[],a,i){const l=[...r];return l[i]=a,l.sort((o,x)=>o-x)}function it(r,a,i){const x=100/(i-a)*(r-a);return qe(x,[0,100])}function $t(r,a){return a>2?`Value ${r+1} of ${a}`:a===2?["Minimum","Maximum"][r]:void 0}function Vt(r,a){if(r.length===1)return 0;const i=r.map(o=>Math.abs(o-a)),l=Math.min(...i);return i.indexOf(l)}function Ht(r,a,i){const l=r/2,x=Pe([0,50],[0,l]);return(l-x(a)*i)*i}function Kt(r){return r.slice(0,-1).map((a,i)=>r[i+1]-a)}function Ot(r,a){if(a>0){const i=Kt(r);return Math.min(...i)>=a}return!0}function Pe(r,a){return i=>{if(r[0]===r[1]||a[0]===a[1])return a[0];const l=(a[1]-a[0])/(r[1]-r[0]);return a[0]+l*(i-r[0])}}function Ut(r){return(String(r).split(".")[1]||"").length}function Yt(r,a){const i=Math.pow(10,a);return Math.round(r*i)/i}var lt=Qe,qt=rt,Wt=nt,Xt=at;const ct=n.forwardRef(({className:r,...a},i)=>e.jsxs(lt,{ref:i,className:wt("relative flex w-full touch-none select-none items-center",r),...a,children:[e.jsx(qt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(Wt,{className:"absolute h-full bg-primary"})}),e.jsx(Xt,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));ct.displayName=lt.displayName;
6const _e=1.25,Ye=[{label:"Household",filters:["Estimated Home Value","Homeowner or Renter"]},{label:"Personal Details",filters:["Income"]},{label:"Other",filters:["Property Type"]}];function as(){const{orgId:r}=Rt(),a=Nt(),[i,l]=n.useState(""),[o,x]=n.useState(25),[c,u]=n.useState(200),[f,C]=n.useState("all"),[w,m]=n.useState(!1),g=n.useRef(null),[k,M]=n.useState(!1),[y,N]=n.useState([]),[p,F]=n.useState([]),[j,v]=n.useState(null),[I,ee]=n.useState(),[$,fe]=n.useState(),[O,K]=n.useState(),[S,L]=n.useState(),[z,te]=n.useState(),[V,H]=n.useState(!1),[b,T]=n.useState(null),U=n.useRef(null),se=n.useRef(null),he=n.useRef(null),pe=n.useRef(null),Me=n.useRef(null),ge=n.useRef(null),be=n.useRef([]),ye=n.useRef(null),Y=n.useRef(null),je=n.useRef(null),[R,Ee]=n.useState([]),[q,ze]=n.useState(!1),[De,dt]=n.useState(!1),[A,ne]=n.useState(new Set),[ae,mt]=n.useState(null);n.useState(!1);const[Ie,Fe]=n.useState(!1),oe="AIzaSyABy3q72y6P0uoLMriQCI0ur8cVioA_Uns",ie=()=>{var t;return(t=window.google)==null?void 0:t.maps},Le=n.useCallback(()=>{var t,s;be.current.forEach(d=>d.setMap(null)),be.current=[],ye.current&&((s=(t=ye.current).clearMarkers)==null||s.call(t),ye.current=null),Y.current&&Y.current.close()},[]),Te=n.useCallback(t=>{const s=ie(),d=se.current;!s||!d||(Y.current||(Y.current=new s.InfoWindow),t.forEach((h,D)=>{if(!b)return;const E=new s.Marker({map:d,position:{lat:b.lat+(Math.random()-.5)*o*.02,lng:b.lng+(Math.random()-.5)*o*.02},title:`${h.first_name||""} ${h.last_name||""}`.trim()||h.address,icon:{url:`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(`
7            <svg xmlns="http://www.w3.org/2000/svg" width="28" height="40" viewBox="0 0 28 40">
8              <path d="M14 0C6.268 0 0 6.268 0 14c0 10.5 14 26 14 26s14-15.5 14-26C28 6.268 21.732 0 14 0z" fill="#f97316" stroke="#c2410c" stroke-width="2"/>
9              <circle cx="14" cy="14" r="6" fill="white"/>
10            </svg>
11          `)}`,scaledSize:new s.Size(28,40),anchor:new s.Point(14,40)}});E.addListener("click",()=>{const P=[h.first_name,h.last_name].filter(Boolean).join(" ")||"Current Resident",_=[h.address,h.city,h.state,h.zip].filter(Boolean).join(", ");Y.current.setContent(`
12          <div style="padding:10px;max-width:260px;font-family:system-ui,sans-serif;">
13            <strong style="font-size:14px;display:block;margin-bottom:4px;">${P}</strong>
14            <p style="margin:0;font-size:12px;color:#555;">${_}</p>
15            ${h.phone?`<p style="margin:4px 0 0;font-size:12px;color:#555;">📞 ${h.phone}</p>`:""}
16          </div>
17        `),Y.current.open(d,E)}),be.current.push(E)}))},[b,o]),ve=n.useCallback(async()=>{if(!b){B.error("Please select an address first");return}if(!r){B.error("No organization context");return}ze(!0),dt(!0),Le();try{const t={};I&&(t.home_value_min=I),$&&(t.home_value_max=$),O&&(t.income_min=O),S&&(t.income_max=S),z&&(t.property_type=z);const{data:s,error:d}=await W.functions.invoke("melissa-lead-search",{body:{lat:b.lat,lng:b.lng,radius_miles:o,lead_type:f,max_results:c,filters:t,organization_id:r}});if(d)throw d;if(!(s!=null&&s.ok))throw new Error((s==null?void 0:s.error)||"Search failed");const h=s.results||[];Ee(h),mt(s.search_id),ne(new Set),Te(h),h.length>0?B.success(`Found ${h.length} leads`):B.info("No leads found in this area. Try expanding the radius.")}catch(t){console.error("Search error:",t),B.error(t.message||"Search failed. Please try again.")}finally{ze(!1)}},[b,r,o,f,c,I,$,O,S,z,Le,Te]),ut=n.useCallback(async t=>{if(!r)return;const s=R[t];if(!(!s||s._saved))try{const{error:d}=await W.from("customer_finder_leads").insert({organization_id:r,search_id:ae,first_name:s.first_name,last_name:s.last_name,address:s.address,city:s.city,state:s.state,zip:s.zip,phone:s.phone,email:s.email,property_type:s.property_type,home_value_est:s.home_value_est,income_range:s.income_range,is_business:s.is_business,melissa_address_key:s.melissa_address_key,status:"new"});if(d)throw d;Ee(h=>h.map((D,E)=>E===t?{...D,_saved:!0}:D)),B.success("Lead saved to My Leads List")}catch(d){B.error(d.message||"Failed to save lead")}},[r,ae,R]),xt=n.useCallback(async()=>
17{if(!(!r||A.size===0)){Fe(!0);try{const{data:{user:t}}=await W.auth.getUser(),s=R.filter((P,_)=>A.has(_)),d=s.filter(P=>!P._saved);if(d.length>0){const P=d.map(_=>({organization_id:r,search_id:ae,first_name:_.first_name,last_name:_.last_name,address:_.address,city:_.city,state:_.state,zip:_.zip,phone:_.phone,email:_.email,property_type:_.property_type,home_value_est:_.home_value_est,income_range:_.income_range,is_business:_.is_business,melissa_address_key:_.melissa_address_key,status:"new"}));await W.from("customer_finder_leads").insert(P)}const{data:h,error:D}=await W.from("postcard_campaigns").insert({name:`Customer Finder — ${new Date().toLocaleDateString()}`,status:"DRAFT",tenant_id:r,created_by_user_id:(t==null?void 0:t.id)??null,quantity:s.length,amount_cents:Math.round(s.length*_e*100),source:"customer_finder",return_name:"",return_address1:"",return_city:"",return_state:"",return_zip:""}).select("id").single();if(D)throw D;const E=s.map(P=>({campaign_id:h.id,tenant_id:r,full_name:[P.first_name,P.last_name].filter(Boolean).join(" ")||"Current Resident",address1:P.address,city:P.city,state:P.state,zip:P.zip,normalized_address_key:`${P.address.toLowerCase().replace(/\s+/g,"")}_${P.zip}`}));await W.from("postcard_campaign_recipients").insert(E),B.success(`Campaign created with ${s.length} recipients`),a(`/marketing/postcards/new?campaign=${h.id}&step=2`)}catch(t){B.error(t.message||"Failed to create campaign")}finally{Fe(!1)}}},[r,ae,R,A,a]);n.useEffect(()=>{var h;const t=window;if(t.__gmapsLoadedKey===oe&&((h=t.google)!=null&&h.maps)){H(!0);return}const s=document.getElementById("google-maps-script");s&&(s.remove(),delete t.google,delete t.__gmapsLoadedKey),t.__gmapsLoadedKey=oe;const d=document.createElement("script");d.id="google-maps-script",d.src=`https://maps.googleapis.com/maps/api/js?key=${oe}&libraries=places,marker&v=weekly`,d.async=!0,d.defer=!0,d.onload=()=>H(!0),document.head.appendChild(d)},[oe]),n.useEffect(()=>{if(!V||!U.current||se.current)return;const t=ie();t&&(se.current=new t.Map(U.current,{center:{lat:44.9372,lng:-91.3929},zoom:14,mapTypeId:"roadmap",zoomControl:!0,mapTypeControl:!0,streetViewControl:!0,fullscreenControl:!0,gestureHandling:"greedy",styles:[{featureType:"poi",elementType:"labels",stylers:[{visibility:"off"}]}]}))},[V]),n.useEffect(()=>{if(!V||!ge.current||Me.current)return;const t=ie();if(!(t!=null&&t.places))return;const s=new t.places.Autocomplete(ge.current,{componentRestrictions:{country:"us"},fields:["geometry","formatted_address"]});s.addListener("place_changed",()=>{var h;const d=s.getPlace();if((h=d==null?void 0:d.geometry)!=null&&h.location){const D=d.geometry.location.lat(),E=d.geometry.location.lng();T({lat:D,lng:E,address:d.formatted_address||""}),l(d.formatted_address||"")}}),Me.current=s},[V]),n.useEffect(()=>{if(!se.current||!b)return;const t=ie();if(!t)return;const s=se.current;he.current&&he.current.setMap(null),pe.current&&pe.current.setMap(null),s.setCenter(b),s.setZoom(o<=2?15:o<=5?14:o<=15?12:o<=50?10:8),pe.current=new t.Marker({map:s,position:b,title:b.address,icon:{url:`data:image/svg+xml;charset=UTF-8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="32" height="44" viewBox="0 0 28 40"><path d="M14 0C6.268 0 0 6.268 0 14c0 10.5 14 26 14 26s14-15.5 14-26C28 6.268 21.732 0 14 0z" fill="#dc2626" stroke="#991b1b" stroke-width="2"/><circle cx="14" cy="14" r="6" fill="white"/></svg>')}`,scaledSize:new t.Size(32,44),anchor:new t.Point(16,44)},zIndex:9999}),he.current=new t.Circle({map:s,center:b,radius:o*1609.34,fillColor:"#ef4444",fillOpacity:.12,strokeColor:"#f97316",strokeOpacity:.6,strokeWeight:2})},[b,o]),n.useEffect(()=>{const t=s=>{je.current&&!je.current.contains(s.target)&&M(!1),g.current&&!g.current.contains(s.target)&&m(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const Ae=t=>{N(s=>s.includes(t)?s.filter(d=>d!==t):[...s,t])},we=t=>{F(s=>s.includes(t)?s.filter(d=>d!==t):[...s,t]),v(t)},ft=()=>De?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-3 border-b bg-orange-500/10 flex items-center justify-between",children:[e.jsxs("h3",{className:"text-sm font-bold flex items-center gap-2",children:[e.jsx(le,{className:"h-4 w-4 text-orange-600"}),R.length," Lead",R.length!==1?"s":""," Found"]}),R.length>0&&e.jsx("button",{onClick:()=>{A.size===R.length?ne(new Set):ne(new Set(R.map((t,s)=>s)))},className:"text-xs text-primary hover:underline",children:A.size===R.length?"Deselect All":"Select All"})]}),e.jsxs("div",{className:"p-4 border-b bg-muted/30 space-y-2.5",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Leads found"}),e.jsx("span",{className:"font-semibold",children:R.length})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Postcards to send"}),e.jsx("span",{className:"font-semibold",children:A.size})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Price per card"}),e.jsxs("span",{className:"font-semibold",children:["$",_e.toFixed(2)]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Powered by Melissa Data + Lob"}),e.jsx(ue,{}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"font-bold",children:"Total Price"}),e.jsxs("span",{className:"font-bold text-lg text-orange-600",children:["$",(A.size*_e).toFixed(2)]})]}),e.jsx(Z,{className:"w-full h-11 mt-1 text-base font-bold bg-orange-500 hover:bg-orange-600 text-white",disabled:A.size===0||Ie,onClick:xt,children:Ie?e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"h-5 w-5 mr-2 animate-spin"})," Creating Campaign..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Mt,{className:"h-5 w-5 mr-2"})," Continue"]})})]}),e.jsx(Se,{className:"flex-1",children:R.length===0&&!q?e.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm p-6 text-center",children:e.jsxs("div",{children:[e.jsx(X,{className:"h-10 w-10 mx-auto mb-3 opacity-20"}),e.jsx("p",{className:"font-medium",children:"No results found"}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:"Try a different address or increase the search radius"})]})}):e.jsx("div",{className:"p-2 space-y-1.5",children:R.map((t,s)=>
17{const d=A.has(s),h=[t.first_name,t.last_name].filter(Boolean).join(" ")||"Current Resident",D=[t.city,t.state].filter(Boolean).join(", "),E=D?`${D} ${t.zip||""}`.trim():t.zip||"";return e.jsx("div",{className:`w-full text-left rounded-lg border bg-card p-2.5 hover:border-orange-400/60 hover:shadow-sm transition-all group cursor-pointer ${d?"border-orange-400 bg-orange-500/5":""}`,children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 mt-0.5",children:[e.jsx(Ct,{checked:d,onCheckedChange:P=>{ne(_=>{const Ne=new Set(_);return P?Ne.add(s):Ne.delete(s),Ne})},className:"data-[state=checked]:bg-orange-500 data-[state=checked]:border-orange-500"}),e.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:s+1})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold truncate group-hover:text-orange-600 transition-colors",children:h}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5 truncate",children:t.address}),E&&e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:E}),t.phone&&e.jsxs("p",{className:"text-[11px] text-muted-foreground flex items-center gap-1 mt-0.5",children:[e.jsx(kt,{className:"h-3 w-3 shrink-0"})," ",t.phone]})]})]})},s)})})})]}):j?e.jsx(Se,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsx("h3",{className:"text-base font-bold",children:j}),e.jsx(ue,{}),j==="Estimated Home Value"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Min Home Value ($)"}),e.jsx("input",{type:"number",placeholder:"0",value:I||"",onChange:t=>ee(t.target.value?Number(t.target.value):void 0),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Max Home Value ($)"}),e.jsx("input",{type:"number",placeholder:"No max",value:$||"",onChange:t=>fe(t.target.value?Number(t.target.value):void 0),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm"})]})]}),j==="Income"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Min Income ($)"}),e.jsx("input",{type:"number",placeholder:"0",value:O||"",onChange:t=>K(t.target.value?Number(t.target.value):void 0),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Max Income ($)"}),e.jsx("input",{type:"number",placeholder:"No max",value:S||"",onChange:t=>L(t.target.value?Number(t.target.value):void 0),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm"})]})]}),j==="Property Type"&&e.jsxs("div",{className:"space-y-3",children:[["Single Family","Multi-Family","Condo","Townhouse","Mobile Home","Commercial"].map(t=>e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer hover:text-primary transition-colors",children:[e.jsx("input",{type:"radio",name:"propertyType",checked:z===t,onChange:()=>te(t),className:"rounded border-input"}),t]},t)),e.jsx("button",{onClick:()=>te(void 0),className:"text-xs text-muted-foreground hover:underline",children:"Clear"})]}),j==="Homeowner or Renter"&&e.jsx("div",{className:"space-y-3",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Use the Lead Type dropdown in the toolbar to filter residential vs commercial."})}),e.jsx(ue,{}),e.jsxs(Z,{size:"sm",className:"w-full",onClick:()=>v(null),children:[e.jsx(X,{className:"h-4 w-4 mr-2"})," Done"]})]})}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-muted-foreground text-sm p-6 text-center gap-4",children:[e.jsxs("div",{children:[e.jsx(X,{className:"h-10 w-10 mx-auto mb-3 opacity-20"}),e.jsx("p",{className:"font-medium",children:"Search for leads"}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:"Enter an address and click Search Leads to find potential customers"})]}),e.jsx(Z,{onClick:ve,disabled:!b||q,className:"w-full h-11 text-base font-semibold bg-orange-500 hover:bg-orange-600 text-white",children:q?e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"h-5 w-5 mr-2 animate-spin"})," Searching..."]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-5 w-5 mr-2"})," Search Leads"]})})]});return e.jsx(St,{children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Customer Finder 360"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Be one step ahead of your competition. Narrow your target audience and connect with your new potential customers."})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 items-end",children:[e.jsxs("div",{className:"flex-1 min-w-0 sm:min-w-[300px]",children:[e.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 flex items-center gap-1",children:[e.jsx(Et,{className:"h-3 w-3"})," Search Address"]}),e.jsxs("div",{className:"relative",children:[e.jsx(X,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground z-10"}),e.jsx("input",{ref:ge,type:"text",placeholder:"Start typing an address...",value:i,onChange:t=>l(t.target.value),onKeyDown:t=>{t.key==="Enter"&&b&&ve()},className:"flex h-10 w-full rounded-md border border-input bg-background px-9 py-2 text-sm r
17ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),e.jsx(_t,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"})]})]}),e.jsxs("div",{className:"w-44",children:[e.jsxs("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:["Radius: ",o," mi"]}),e.jsx(ct,{value:[o],onValueChange:([t])=>x(t),min:1,max:100,step:1,className:"mt-2"})]}),e.jsxs("div",{className:"relative",ref:g,children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Lead Type"}),e.jsxs("button",{onClick:()=>m(!w),className:"flex h-10 items-center gap-2 rounded-md border border-input bg-background px-4 py-2 text-sm hover:bg-muted/50 transition-colors min-w-[160px] justify-between",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[f==="all"?e.jsx(le,{className:"h-4 w-4 text-muted-foreground"}):f==="residential"?e.jsx(He,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Be,{className:"h-4 w-4 text-muted-foreground"}),f==="all"?"All Leads":f==="residential"?"Residential":"Commercial"]}),e.jsx(ce,{className:"h-4 w-4 text-muted-foreground"})]}),w&&e.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-popover border rounded-md shadow-lg w-full py-1",children:[{value:"all",label:"All Leads",icon:le},{value:"residential",label:"Residential",icon:He},{value:"commercial",label:"Commercial",icon:Be}].map(t=>e.jsxs("button",{onClick:()=>{C(t.value),m(!1)},className:`w-full text-left px-3 py-2 text-sm flex items-center gap-2 hover:bg-muted/50 ${f===t.value?"bg-primary/10 text-primary font-medium":""}`,children:[e.jsx(t.icon,{className:"h-4 w-4"})," ",t.label]},t.value))})]}),e.jsxs("div",{className:"relative",ref:je,children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Filters"}),e.jsxs("button",{onClick:()=>M(!k),className:"flex h-10 items-center gap-2 rounded-md border border-input bg-background px-4 py-2 text-sm hover:bg-muted/50 transition-colors min-w-[160px] justify-between",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4 text-muted-foreground"})," Filters",p.length>0&&e.jsx($e,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:p.length})]}),e.jsx(ce,{className:"h-4 w-4 text-muted-foreground"})]}),k&&e.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-popover border rounded-md shadow-lg w-[280px] py-1 max-h-[400px] overflow-y-auto",children:Ye.map(t=>e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>Ae(t.label),className:"w-full text-left px-3 py-2 text-sm font-semibold flex items-center justify-between hover:bg-muted/50",children:[t.label,y.includes(t.label)?e.jsx(ce,{className:"h-3.5 w-3.5 text-muted-foreground"}):e.jsx(Ve,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),y.includes(t.label)&&e.jsx("div",{className:"pl-3 pb-1",children:t.filters.map(s=>e.jsxs("button",{onClick:()=>{we(s),M(!1)},className:`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-muted/50 ${p.includes(s)?"text-primary":"text-muted-foreground"}`,children:[p.includes(s)?e.jsx(Oe,{className:"h-3.5 w-3.5 text-primary shrink-0"}):e.jsx(Ue,{className:"h-3.5 w-3.5 shrink-0"}),s]},s))})]},t.label))})]}),e.jsxs("div",{className:"w-28",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"How many leads?"}),e.jsx("input",{type:"number",min:1,max:500,value:c,onChange:t=>u(Math.max(1,Math.min(500,Number(t.target.value)||200))),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
17ing-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring text-center"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block invisible",children:"Search"}),e.jsx(Z,{onClick:ve,disabled:!b||q,className:"h-10",children:q?e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"h-4 w-4 mr-2 animate-spin"})," Searching..."]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-4 w-4 mr-2"})," Search Leads"]})})]})]}),p.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[p.map(t=>e.jsxs($e,{variant:"secondary",className:"cursor-pointer hover:bg-destructive/20 transition-colors",onClick:()=>we(t),children:[t," ✕"]},t)),e.jsx(Z,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:()=>{F([]),v(null)},children:"Clear all"})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[260px_1fr_320px]",style:{height:"calc(100vh - 340px)"},children:[e.jsxs(me,{className:"flex flex-col overflow-hidden",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4 text-muted-foreground"})," Filter Categories"]})}),e.jsx(Se,{className:"flex-1",children:e.jsx("div",{className:"py-1",children:Ye.map(t=>e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>Ae(t.label),className:"w-full text-left px-4 py-2.5 text-sm font-semibold flex items-center justify-between hover:bg-muted/50",children:[e.jsx("span",{children:t.label}),y.includes(t.label)?e.jsx(ce,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Ve,{className:"h-4 w-4 text-muted-foreground"})]}),y.includes(t.label)&&e.jsx("div",{className:"pb-1",children:t.filters.map(s=>e.jsxs("button",{onClick:()=>{we(s)},className:`w-full text-left px-6 py-2 text-sm flex items-center gap-2 hover:bg-muted/50 ${p.includes(s)?"text-primary font-medium":"text-foreground"}`,children:[p.includes(s)?e.jsx(Oe,{className:"h-4 w-4 text-primary shrink-0"}):e.jsx(Ue,{className:"h-4 w-4 text-muted-foreground shrink-0"}),s]},s))}),e.jsx(ue,{})]},t.label))})})]}),e.jsxs(me,{className:"overflow-hidden relative p-0",children:[e.jsx("div",{ref:U,style:{width:"100%",height:"100%",display:"block"}}),q&&e.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:e.jsxs("div",{className:"flex items-center gap-3 bg-background rounded-lg border shadow-lg px-5 py-3",children:[e.jsx(de,{className:"h-5 w-5 animate-spin text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Searching nearby leads..."})]})})]}),e.jsx(me,{className:"flex flex-col overflow-hidden",children:ft()})]}),De&&R.length>0&&e.jsxs(me,{className:"overflow-hidden",children:[e.jsx("div",{className:"p-4 border-b flex items-center justify-between",children:e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(le,{className:"h-4 w-4 text-muted-foreground"}),R.length," lead",R.length!==1?"s":""," found",b&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["within ",o," mi of ",b.address]})]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground w-8",children:"#"}),e.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"First Name"}),e.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Last Name"}),e.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Address"}),e.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"City"}),e.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground w-12",children:"State"}),e.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground w-16",children:"Zip"}),e.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Phone"}),e.jsx("th",{className:"text-right px-3 py-2 font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y",children:R.map((t,s)=>e.jsxs("tr",{className:"hover:bg-muted/30 transition-colors",children:[e.jsx("td",{className:"px-3 py-2 text-muted-foreground text-xs",children:s+1}),e.jsx("td",{className:"px-3 py-2 font-medium",children:t.first_name||"—"}),e.jsx("td",{className:"px-3 py-2 font-medium",children:t.last_name||"—"}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:t.address||"—"}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:t.city||"—"}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:t.state||"—"}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:t.zip||"—"}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:t.phone||"—"}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx(Z,{variant:t._saved?"secondary":"ghost",size:"sm",className:"h-7 text-xs",disabled:t._saved,onClick:d=>{d.stopPropagation(),ut(s)},children:t._saved?e.jsx(e.Fragment,{children:"✓ Saved"}):e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"h-3 w-3 mr-1"})," Save"]})})})]},s))})]})})]})]})})}export{as as default};

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.