PageSourceSearch

https://www.tang.ai/assets/my-searches-CWOvCvxt.js

js tang.ai collected 2026-10-05 13:55:36 UTC 35,025 bytes, 24 lines download raw bytes

vendor: 8,148 bytes, lines 1-2
1import{g as Be,r as N,j as s,ai as H,ar as Fe,a7 as le,M as ke,ac as Ce,ah as _e,bC as Pe,bD as De,bE as Ue,aR as We,U as ze,ak as Oe}from"./react-vendor-BLA2qDP6.js";import{u as $e,a as qe,k as He,b as X}from"./index-D5COCHS2.js";import{S as Ve}from"./static-header-L5BaZ-i6.js";import"./ui-vendor-BA32w1ww.js";import"./maplibre-vendor-BGpB8rPO.js";var Ne={};(function o(l,b,j,I){var L=!!(l.Worker&&l.Blob&&l.Promise&&l.OffscreenCanvas&&l.OffscreenCanvasRenderingContext2D&&l.HTMLCanvasElement&&l.HTMLCanvasElement.prototype.transferControlToOffscreen&&l.URL&&l.URL.createObjectURL),B=typeof Path2D=="function"&&typeof DOMMatrix=="function",P=function(){if(!l.OffscreenCanvas)return!1;try{var t=new OffscreenCanvas(1,1),e=t.getContext("2d");e.fillRect(0,0,1,1);var c=t.transferToImageBitmap();e.createPattern(c,"no-repeat")}catch{return!1}return!0}();function z(){}function V(t){var e=b.exports.Promise,c=e!==void 0?e:l.Promise;return typeof c=="function"?new c(t):(t(z,z),null)}var Y=function(t,e){return{transform:function(c){if(t)return c;if(e.has(c))return e.get(c);var d=new OffscreenCanvas(c.width,c.height),m=d.getContext("2d");return m.drawImage(c,0,0),e.set(c,d),d},clear:function(){e.clear()}}}(P,new Map),U=function(){var t=Math.floor(16.666666666666668),e,c,d={},m=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(e=function(h){var f=Math.random();return d[f]=requestAnimationFrame(function u(x){m===x||m+t-1<x?(m=x,delete d[f],h()):d[f]=requestAnimationFrame(u)}),f},c=function(h){d[h]&&cancelAnimationFrame(d[h])}):(e=function(h){return setTimeout(h,t)},c=function(h){return clearTimeout(h)}),{frame:e,cancel:c}}(),ce=function(){var t,e,c={};function d(m){function h(f,u){m.postMessage({options:f||{},callback:u})}m.init=function(u){var x=u.transferControlToOffscreen();m.postMessage({canvas:x},[x])},m.fire=function(u,x,w){if(e)return h(u,null),e;var S=Math.random().toString(36).slice(2);return e=V(function(a){function r(i){i.data.callback===S&&(delete c[S],m.removeEventListener("message",r),e=null,Y.clear(),w(),a())}m.addEventListener("message",r),h(u,S),c[S]=r.bind(null,{data:{callback:S}})}),e},m.reset=function(){m.postMessage({reset:!0});for(var u in c)c[u](),delete c[u]}}return function(){if(t)return t;if(!j&&L){var m=["var CONFETTI, SIZE = {}, module = {};","("+o.toString()+")(this, module, true, SIZE);","onmessage = function(msg) {","  if (msg.data.options) {","    CONFETTI(msg.data.options).then(function () {","      if (msg.data.callback) {","        postMessage({ callback: msg.data.callback });","      }","    });","  } else if (msg.data.reset) {","    CONFETTI && CONFETTI.reset();","  } else if (msg.data.resize) {","    SIZE.width = msg.data.resize.width;","    SIZE.height = msg.data.resize.height;","  } else if (msg.data.canvas) {","    SIZE.width = msg.data.canvas.width;","    SIZE.height = msg.data.canvas.height;","    CONFETTI = module.exports.create(msg.data.canvas);","  }","}"].join(`
2`);try{t=new Worker(URL.createObjectURL(new Blob([m])))}catch(h){return typeof console<"u"&&typeof console.warn=="function"&&console.warn("🎊 Could not load worker",h),null}d(t)}return t}}(),J={particleCount:50,angle:90,spread:45,startVelocity:45,decay:.9,gravity:1,drift:0,ticks:200,x:.5,y:.5,shapes:["square","circle"],zIndex:100,colors:["#26ccff","#a25afd","#ff5e7e","#88ff5a","#fcff42","#ffa62d","#ff36ff"],disableForReducedMotion:!1,scalar:1};function ee(t,e){return e?e(t):t}function _(t){return t!=null}function M(t,e,c){return ee(t&&_(t[e])?t[e]:J[e],c)}function te(t){return t<0?0:Math.floor(t)}function se(t,e){return Math.floor(Math.random()*(e-t))+t}function Z(t){return parseInt(t,16)}function ae(t){return t.map(re)}function re(t){var e=String(t).replace(/[^0-9a-f]/gi,"");return e.length<6&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),{r:Z(e.substring(0,2)),g:Z(e.substring(2,4)),b:Z(e.substring(4,6))}}function O(t){var e=M(t,"origin",Object);return e.x=M(e,"x",Number),e.y=M(e,"y",Number),e}function de(t){t.width=document.documentElement.clientWidth,t.height=document.documentElement.clientHeight}function ne(t){var e=t.getBoundingClientRect();t.width=e.width,t.height=e.height}function W(t){var e=document.createElement("canvas");return e.style.position="fixed",e.style.top="0px",e.style.left="0px",e.style.pointerEvents="none",e.style.zIndex=t,e}function ue(t,e,c,d,m,h,f,u,x){t.save(),t.translate(e,c),t.rotate(h),t.scale(d,m),t.arc(0,0,1,f,u,x),t.restore()}function ie(t){var e=t.angle*(Math.PI/180),c=t.spread*(Math.PI/180);return{x:t.x,y:t.y,wobble:Math.random()*10,wobbleSpeed:Math.min(.11,Math.random()*.1+.05),velocity:t.startVelocity*.5+Math.random()*t.startVelocity,angle2D:-e+(.5*c-Math.random()*c),tiltAngle:(Math.random()*(.75-.25)+.25)*Math.PI,color:t.color,shape:t.shape,tick:0,totalTicks:t.ticks,decay:t.decay,drift:t.drift,random:Math.random()+2,tiltSin:0,tiltCos:0,wobbleX:0,wobbleY:0,gravity:t.gravity*3,ovalScalar:.6,scalar:t.scalar,flat:t.flat}}function me(t,e){e.x+=Math.cos(e.angle2D)*e.velocity+e.drift,e.y+=Math.sin(e.angle2D)*e.velocity+e.gravity,e.velocity*=e.decay,e.flat?(e.wobble=0,e.wobbleX=e.x+10*e.scalar,e.wobbleY=e.y+10*e.scalar,e.tiltSin=0,e.tiltCos=0,e.random=1):(e.wobble+=e.wobbleSpeed,e.wobbleX=e.x+10*e.scalar*Math.cos(e.wobble),e.wobbleY=e.y+10*e.scalar*Math.sin(e.wobble),e.tiltAngle+=.1,e.tiltSin=Math.sin(e.tiltAngle),e.tiltCos=Math.cos(e.tiltAngle),e.random=Math.random()+2);var c=e.tick++/e.totalTicks,d=e.x+e.random*e.tiltCos,m=e.y+e.random*e.tiltSin,h=e.wobbleX+e.random*e.tiltCos,f=e.wobbleY+e.random*e.tiltSin;if(t.fillStyle="rgba("+e.color.r+", "+e.color.g+", "+e.color.b+", "+(1-c)+")",t.beginPath(),B&&e.shape.type==="path"&&typeof e.shape.path=="string"&&Array.isArray(e.shape.matrix))t.fill(Q(e.shape.path,e.shape.matrix,e.x,e.y,Math.abs(h-d)*.1,Math.abs(f-m)*.1,Math.PI/10*e.wobble));else if(e.shape.type==="bitmap"){var u=Math.PI/10*e.wobble,x=Math.abs(h-d)*.1,w=Math.abs(f-m)*.1,S=e.shape.bitmap.width*e.scalar,a=e.shape.bitmap.height*e.scalar,r=new DOMMatrix([Math.cos(u)*x,Math.sin(u)*x,-Math.sin(u)*w,Math.cos(u)*w,e.x,e.y]);r.multiplySelf(new DOMMatrix(e.shape.matrix));var i=t.createPattern(Y.transform(e.shape.bitmap),"no-repeat");i.setTransform(r),t.globalAlpha=1-c,t.fillStyle=i,t.fillRect(e.x-S/2,e.y-a/2,S,a),t.globalAlpha=1}else if(e.shape==="circle")t.ellipse?t.ellipse(e.x,e.y,Math.abs(h-d)*e.ovalScalar,Math.abs(f-m)*e.ovalScalar,Math.PI/10*e.wobble,0,2*Math.PI):ue(t,e.x,e.y,Math.abs(h-d)*e.ovalScalar,Math.abs(f-m)*e.ovalScalar,Math.PI/10*e.wobble,0,2*Math.PI);else if(e.shape==="star")for(var n=Math.PI/2*3,y=4*e.scalar,g=8*e.scalar,p=e.x,k=e.y,E=5,C=Math.PI/E;E--;)p=e.x+Math.cos(n)*g,k=e.y+Math.sin(n)*g,t.lineTo(p,k),n+=C,p=e.x+Math.cos(n)*y,k=e.y+Math.sin(n)*y,t.lineTo(p,k),n+=C;else t.moveTo(Math.floor(e.x),Math.floor(e.y)),t.lineTo(Math.floor(e.wobbleX),Math.floor(m)),t.lineTo(Math.floor(h),Math.floor(f)),t.lineTo(Math.floor(d),Math.floor(e.wobbleY));return t.closePath(),t.fill(),e.tick<e.totalTicks}function $(t,e,c,d,m){var h=e.slice(),f=t.getContext("2d"),u,x,w=V(function(S){function a(){u=x=null,f.clearRect(0,0,d.width,d.height),Y.clear(),m(),S()}function r(){j&&!(d.width===I.width&&d.height===I.height)&&(d.width=t.width=I.width,d.height=t.height=I.height),!d.width&&!d.height&&(c(t),d.width=t.width,d.height=t.height),f.clearRect(0,0,d.width,d.height),h=h.filter(function(i){return me(f,i)}),h.length?u=U.frame(r):a()}u=U.frame(r),x=a});return{addFettis:function(S){return h=h.concat(S),w},canvas:t,promise:w,reset:function(){u&&U.cancel(u),x&&x()}}}function K(t,e){var c=!t,d=!!M(e||{},"resize"),m=!1,h=M(e,"disableForReducedMotion",Boolean),f=L&&!!M(e||{},"useWorker"),u=f?ce():null,x=c?de:ne,w=t&&u?!!t.__confetti_initialized:!1,S=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion)").matches,a;function r(n,y,g){for(var p=M(n,"particleCount",te),k=M(n,"angle",Number),E=M(n,"spread",Number),C=M(n,"startVelocity",Number),T=M(n,"decay",Number),fe=M(n,"gravity",Number),v=M(n,"drift",Number),A=M(n,"colors",ae),R=M(n,"ticks",Number),je=M(n,"shapes"),Le=M(n,"scalar"),Ee=!!M(n,"flat"),Se=O(n),Me=p,xe=[],Te=t.width*Se.x,Ae=t.height*Se.y;Me--;
2)xe.push(ie({x:Te,y:Ae,angle:k,spread:E,startVelocity:C,color:A[Me%A.length],shape:je[se(0,je.length)],ticks:R,decay:T,gravity:fe,drift:v,scalar:Le,flat:Ee}));return a?a.addFettis(xe):(a=$(t,xe,x,y,g),a.promise)}function i(n){var y=h||M(n,"disableForReducedMotion",Boolean),g=M(n,"zIndex",Number);if(y&&S)return V(function(C){C()});c&&a?t=a.canvas:c&&!t&&(t=W(g),document.body.appendChild(t)),d&&!w&&x(t);var p={width:t.width,height:t.height};u&&!w&&u.init(t),w=!0,u&&(t.__confetti_initialized=!0);function k(){if(u){var C={getBoundingClientRect:function(){if(!c)return t.getBoundingClientRect()}};x(C),u.postMessage({resize:{width:C.width,height:C.height}});return}p.width=p.height=null}function E(){a=null,d&&(m=!1,l.removeEventListener("resize",k)),c&&t&&(document.body.contains(t)&&document.body.removeChild(t),t=null,w=!1)}return d&&!m&&(m=!0,l.addEventListener("resize",k,!1)),u?u.fire(n,p,E):r(n,p,E)}return i.reset=function(){u&&u.reset(),a&&a.reset()},i}var G;function q(){return G||(G=K(null,{useWorker:!0,resize:!0})),G}function Q(t,e,c,d,m,h,f){var u=new Path2D(t),x=new Path2D;x.addPath(u,new DOMMatrix(e));var w=new Path2D;return w.addPath(x,new DOMMatrix([Math.cos(f)*m,Math.sin(f)*m,-Math.sin(f)*h,Math.cos(f)*h,c,d])),w}function D(t){if(!B)throw new Error("path confetti are not supported in this browser");var e,c;typeof t=="string"?e=t:(e=t.path,c=t.matrix);var d=new Path2D(e),m=document.createElement("canvas"),h=m.getContext("2d");if(!c){for(var f=1e3,u=f,x=f,w=0,S=0,a,r,i=0;i<f;i+=2)for(var n=0;n<f;n+=2)h.isPointInPath(d,i,n,"nonzero")&&(u=Math.min(u,i),x=Math.min(x,n),w=Math.max(w,i),S=Math.max(S,n));a=w-u,r=S-x;var y=10,g=Math.min(y/a,y/r);c=[g,0,0,g,-Math.round(a/2+u)*g,-Math.round(r/2+x)*g]}return{type:"path",path:e,matrix:c}}function he(t){var e,c=1,d="#000000",m='"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif';typeof t=="string"?e=t:(e=t.text,c="scalar"in t?t.scalar:c,m="fontFamily"in t?t.fontFamily:m,d="color"in t?t.color:d);var h=10*c,f=""+h+"px "+m,u=new OffscreenCanvas(h,h),x=u.getContext("2d");x.font=f;var w=x.measureText(e),S=Math.ceil(w.actualBoundingBoxRight+w.actualBoundingBoxLeft),a=Math.ceil(w.actualBoundingBoxAscent+w.actualBoundingBoxDescent),r=2,i=w.actualBoundingBoxLeft+r,n=w.actualBoundingBoxAscent+r;S+=r+r,a+=r+r,u=new OffscreenCanvas(S,a),x=u.getContext("2d"),x.font=f,x.fillStyle=d,x.fillText(e,i,n);var y=1/c;return{type:"bitmap",bitmap:u.transferToImageBitmap(),matrix:[y,0,0,y,-S*y/2,-a*y/2]}}b.exports=function(){return q().apply(this,arguments)},b.exports.reset=function(){q().reset()},b.exports.create=K,b.exports.shapeFromPath=D,b.exports.shapeFromText=he})(function(){return typeof window<"u"?window:typeof self<"u"?self:this||{}}(),Ne,!1);const pe=Ne.exports;Ne.exports.create;function oe(){const o=localStorage.getItem("auth_token");return o?{Authorization:`Bearer ${o}`}:{}}function F(o){const l=Number(o||0);return Number.isFinite(l)?l.toLocaleString():"0"}function Ze(o){const l=new Date(o).getTime();if(!Number.isFinite(l))return"unknown";const b=Date.now()-l,j=Math.floor(b/6e4),I=Math.floor(b/36e5),L=Math.floor(b/864e5);return j<1?"just now":j<60?`${j}m ago`:I<24?`${I}h ago`:L<30?`${L}d ago`:new Date(o).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Ge(o){const l=new Date(o).getTime();return Number.isFinite(l)?new Date(o).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}):"Unknown time"}function ye(o){const l=String(o.searchRunId||"").trim();if(l)return l;try{const b=new URL(String(o.href||""),window.location.origin);return String(b.searchParams.get("run")||b.searchParams.get("search_run_id")||"").trim()}catch{return""}}function Ye(o){return o.length===0?null:o.find(l=>l.isPrimary===!0)||[...o].sort((l,b)=>new Date(l.createdAt).getTime()-new Date(b.createdAt).getTime())[0]||o[0]}function Je(o){const l=String(o||"").trim();if(!/^[a-f0-9]{24}$/i.test(l))return encodeURIComponent(l);const b=l.match(/.{2}/g).map(j=>String.fromCharCode(Number.parseInt(j,16))).join("");return btoa(b).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Re(o,l={}){const b=Array.isArray(o)?o:[o],j=Ye(b),I=b.map(P=>
2P.mapsJobId).filter(Boolean);if(I.length)return`/company?${new URLSearchParams({maps_job:I.join(","),email_source:"business",search_scope:"maps_job"})}`;if(l.aggregateBatch&&(j!=null&&j._id))return`/s/${Je(j._id)}`;const L=new URLSearchParams,B=j?ye(j):"";return B&&L.set("run",B),L.set("email_source","business"),L.set("search_scope",l.aggregateBatch?"batch":"run"),`/company?${L.toString()}`}const be=["dentists","med spa","body shop","salon","HVAC"];function ve(o){var l,b,j,I;return o.locationLabel||[((b=(l=o.runDetail)==null?void 0:l.normalizedLocation)==null?void 0:b.city)||o.city,((I=(j=o.runDetail)==null?void 0:j.normalizedLocation)==null?void 0:I.state)||o.state].filter(Boolean).join(", ")||"Unknown location"}function ge(o){const l=String(o||"").trim();return l?/^[A-Z]{2}$/.test(l)?l:l.toLowerCase().replace(/\b([a-z])/g,b=>b.toUpperCase()):""}function Ke(o){return we(o.metrics||{})}function Qe(o){var L,B,P,z;const l=String(((B=(L=o.runDetail)==null?void 0:L.normalizedLocation)==null?void 0:B.city)||o.city||"").trim(),b=String(((z=(P=o.runDetail)==null?void 0:P.normalizedLocation)==null?void 0:z.state)||o.state||"").trim();return l||b?[ge(l),ge(b)].filter(Boolean).join(", "):ve(o).split(",").map(V=>ge(V)).filter(Boolean).slice(0,2).join(", ")||"Unknown city"}function Xe(o){var l;return((l=o.runDetail)==null?void 0:l.normalizedQuery)||o.query||"Unnamed search"}function we(o){return Math.max(Number((o==null?void 0:o.businessResults)||0),Number((o==null?void 0:o.completedWebsites)||0))}function et(){return s.jsx("style",{children:`
3        @keyframes tangMySearchesFadeUp {
4          from { opacity: 0; transform: translateY(8px); }
5          to { opacity: 1; transform: translateY(0); }
6        }
7        @keyframes tangMySearchesShimmer {
8          from { background-position: -600px 0; }
9          to { background-position: 600px 0; }
10        }
11        .tang-my-searches-card {
12          box-shadow: 0 1px 3px rgba(0,0,0,0.04);
13          transition: box-shadow 0.15s ease, transform 0.15s ease;
14        }
15        .tang-my-searches-card:hover {
16          box-shadow: 0 4px 20px rgba(0,0,0,0.08);
17          transform: translateY(-1px);
18        }
19        .tang-my-searches-skeleton {
20          background: linear-gradient(90deg, #e8e8e7 25%, #f0f0ef 50%, #e8e8e7 75%);
21          background-size: 600px 100%;
22          animation: tangMySearchesShimmer 1.4s ease infinite;
23        }
24      `})}function tt({searches:o,summary:l}){const b=[{label:"Searches",value:F(o.length),className:"text-[#0f172a]"},{label:"Businesses",value:F(l.businessResults),className:"text-[#2563eb]"},{label:"Emails",value:F(l.emailAddresses),className:"text-[#059669]"}];return s.jsxs("aside",{className:"hidden h-full w-[220px] shrink-0 flex-col border-r border-[#e8eaed] bg-white md:flex",children:[s.jsx("div",{className:"border-b border-[#f1f5f9] px-[22px] pb-5 pt-7",children:s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-[9px] bg-[#0f172a] text-white",children:s.jsx(le,{className:"h-[15px] w-[15px]"})}),s.jsx("span",{className:"text-[15px] font-bold tracking-normal text-[#0f172a]",children:"Tang"})]})}),s.jsxs("nav",{className:"border-b border-[#f1f5f9] px-3 py-4",children:[s.jsx(H,{href:"/my-searches",className:"mb-0.5 flex rounded-[9px] bg-[#f1f5f9] px-3 py-2 text-[13px] font-semibold text-[#0f172a]",children:"My Searches"}),s.jsx(H,{href:"/in",className:"mb-0.5 flex rounded-[9px] px-3 py-2 text-[13px] font-medium text-[#64748b] transition-colors hover:bg-[#f8fafc] hover:text-[#0f172a]",children:"New Search"}),s.jsx(H,{href:"/pricing",className:"mb-0.5 flex rounded-[9px] px-3 py-2 text-[13px] font-medium text-[#64748b] transition-colors hover:bg-[#f8fafc] hover:text-[#0f172a]",children:"Settings"})]}),s.jsxs("div",{className:"flex-1 px-[22px] py-5",children:[s.jsx("div",{className:"mb-3.5 text-[10px] font-bold uppercase tracking-[0.1em] text-[#475569]",children:"Summary"}),b.map(j=>s.jsxs("div",{className:"flex items-baseline justify-between border-b border-[#f8fafc] py-2.5",children:[s.jsx("span",{className:"text-xs font-medium text-[#475569]",children:j.label}),s.jsx("span",{className:`text-lg font-bold ${j.className}`,children:j.value})]},j.label))]}),s.jsx("div",{className:"border-t border-[#f1f5f9] p-4",children:s.jsxs(H,{href:"/in",className:"flex w-full items-center justify-center gap-2 rounded-[11px] bg-[#0f172a] py-[11px] text-[13px] font-semibold text-white transition-colors hover:bg-[#1e293b]",children:[s.jsx(Pe,{className:"h-3.5 w-3.5"}),"New search"]})})]})}const Ie="payment_celebrated";function ot(){const[,o]=Be(),{isAuthenticated:l,isLoading:b}=$e(),{setCredits:j,setPaidAccess:I}=qe(),[L,B]=N.useState(!1),[P,z]=N.useState([]),[V,Y]=N.useState(!0),[U,ce]=N.useState(""),[J,ee]=N.useState(""),[_,M]=N.useState([]),[te,se]=N.useState(!1),[Z,ae]=N.useState(null),[re,O]=N.useState(""),[de,ne]=N.useState(!1),[W,ue]=N.useState(""),[ie,me]=N.useState(0),[$,K]=N.useState(!1),[G,q]=N.useState([]),[Q,D]=N.useState(!1),[he,t]=N.useState(!1),[e,c]=N.useState(null),d=N.useRef(0),m=N.useRef(null),h=N.useRef(null);N.useEffect(()=>{!b&&!l&&o("/signup")},[l,b,o]),N.useEffect(()=>
24{if(new URLSearchParams(window.location.search).get("payment")!=="success")return;if(localStorage.getItem(Ie)){window.history.replaceState({},"",window.location.pathname);return}window.history.replaceState({},"",window.location.pathname),localStorage.setItem(Ie,"1"),B(!0);const r=He(),i=r?{Authorization:`Bearer ${r}`}:{};X("/api/credits",{headers:i}).then(g=>g.ok?g.json():null).then(g=>{(g==null?void 0:g.credits)!=null&&j(g.credits),typeof(g==null?void 0:g.paidAccess)=="boolean"&&I(g.paidAccess)}).catch(()=>{});const n=()=>{pe({particleCount:80,spread:70,origin:{y:.4},zIndex:9999}),pe({particleCount:60,spread:100,origin:{x:.1,y:.5},angle:60,zIndex:9999}),pe({particleCount:60,spread:100,origin:{x:.9,y:.5},angle:120,zIndex:9999})};n();const y=setTimeout(n,600);return()=>clearTimeout(y)},[]),N.useEffect(()=>{l&&X("/api/my-searches",{headers:oe()}).then(a=>a.ok?a.json():{searches:[]}).then(a=>z(a.searches??[])).catch(()=>{}).finally(()=>Y(!1))},[l]),N.useEffect(()=>{if(String(U||"").length>0)return;const a=be[ie]||be[0],r=window.setTimeout(()=>{if(!$&&W===a){K(!0);return}if($&&W===""){K(!1),me(i=>(i+1)%be.length);return}ue($?a.slice(0,Math.max(0,W.length-1)):a.slice(0,W.length+1))},!$&&W===a?1100:$?55:95);return()=>{window.clearTimeout(r)}},[ie,W,$,U]),N.useEffect(()=>{const a=String(J||"").trim();if(a.length<2){q([]),D(!1),t(!1);return}const r=d.current+1;d.current=r,t(!0);const i=window.setTimeout(async()=>{try{const n=await X(`/api/maps-areas?q=${encodeURIComponent(a)}`,{headers:oe()});if(!n.ok)throw new Error("City autocomplete request failed");const y=await n.json();if(d.current!==r)return;const g=(Array.isArray(y==null?void 0:y.areas)?y.areas:[]).map(p=>({key:`${p.kind}:${p.name}:${p.state}`,primaryText:String(p.label||""),secondaryText:`${p.kind} · ${p.zip_count} ZIPs`,name:String(p.name||""),kind:p.kind,city:String(p.name||""),state:String(p.state||""),country:"United States"})).filter(p=>p.name&&p.state&&["city","county"].includes(p.kind));q(g),D(g.length>0)}catch(n){if(d.current!==r)return;console.error("Failed to fetch my-searches city suggestions:",n),q([]),D(!1)}finally{d.current===r&&t(!1)}},180);return()=>{window.clearTimeout(i)}},[J]),N.useEffect(()=>{if(!Q){c(null);return}const a=()=>{var n;const i=(n=m.current)==null?void 0:n.getBoundingClientRect();i&&c({top:i.bottom+8,left:i.left,width:i.width})};a();const r=i=>{var y,g;const n=i.target;(y=m.current)!=null&&y.contains(n)||(g=h.current)!=null&&g.contains(n)||D(!1)};return window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),document.addEventListener("mousedown",r),()=>{window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a),document.removeEventListener("mousedown",r)}},[Q]);const f=N.useMemo(()=>P.reduce((a,r)=>{const i=r.metrics||{};return a.totalLeads+=Number(i.totalLeads||0),a.businessResults+=we(i),a.emailAddresses+=Number(i.emailAddressesDiscovered||0),a},{totalLeads:0,businessResults:0,emailAddresses:0}),[P]),u=N.useMemo(()=>{const a=[],r=new Map;for(const i of P)if(i.batchId){const n=r.get(i.batchId);n!==void 0?a[n].searches.push(i):(r.set(i.batchId,a.length),a.push({id:i.batchId,batchId:i.batchId,searches:[i]}))}else a.push({id:i._id,batchId:null,searches:[i]});return a},[P]),x=async()=>{const a=U.trim();if(!a){O("Enter a business name or category.");return}if(_.length===0){O("Select at least one city or county.");return}O(""),se(!0);try{const r=_.length>1,i=r?crypto.randomUUID():void 0,n=r?_.map(k=>[k.city,k.state].filter(Boolean).join(", ")):void 0,y=_.map((k,E)=>X("/api/search-runs",{method:"POST",headers:{"Content-Type":"application/json",...oe()},body:JSON.stringify({keyword:a,kind:k.kind,name:k.name,state:k.state,country:"United States",force_place_refresh:!1,...i?{batch_id:i,batch_cities:n,is_primary:E===0}:{}})}).then(async C=>{const T=await C.json().catch(()=>({}));if(!C.ok)throw new Error(String((T==null?void 0:T.detail)||(T==null?void 0:T.error)||"Failed to start run."));return T})),g=await Promise.all(y),p=new URLSearchParams;p.set("email_source","business"),p.set("maps_job",g.map(k=>k.maps_job_id||k.job_id).join(",")),p.set("search_scope","maps_job"),r&&p.set("batch_cities",_.map(k=>
24k.city).join(",")),o(`/company?${p.toString()}`)}catch(r){O(r instanceof Error?r.message:"Failed to start prospecting run.")}finally{se(!1)}},w=async a=>{if(!Z){ae(a);try{const r=u.find(p=>p.id===a),i=((r==null?void 0:r.searches)||[]).map(p=>ye(p)).filter(Boolean),n=new URLSearchParams;n.set("refresh","1"),i.length>0&&n.set("refresh_run_id",i.join(","));const y=await X(`/api/my-searches?${n.toString()}`,{headers:oe()}),g=y.ok?await y.json():{searches:[]};z(g.searches??[])}catch{}finally{ae(null)}}};if(b||!l)return null;const S=a=>{q([]),D(!1),t(!1),ee(""),O(""),M(r=>r.some(i=>i.key===a.key)?r:[...r,a])};return s.jsxs("div",{className:"flex h-screen overflow-hidden bg-[#f0f0ef] pt-[60px]",style:{fontFamily:'"Space Grotesk", sans-serif'},children:[s.jsx(Ve,{}),s.jsx(et,{}),s.jsx(tt,{searches:P,summary:f}),s.jsxs("main",{className:"flex-1 overflow-y-auto bg-[#f0f0ef]",children:[L&&s.jsxs("div",{className:"relative flex items-center justify-between gap-4 bg-gradient-to-r from-emerald-500 to-teal-500 px-6 py-4 text-white shadow-md",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-2xl",children:"🎉"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-bold leading-tight",children:"You're all set! 1,000 credits added."}),s.jsx("p",{className:"text-sm opacity-90",children:"Your account has been upgraded — happy prospecting!"})]})]}),s.jsx("button",{onClick:()=>B(!1),className:"shrink-0 rounded-full p-1 opacity-70 transition-opacity hover:opacity-100","aria-label":"Dismiss",children:"✕"})]}),s.jsxs("div",{className:"mx-auto w-full px-4 py-8 sm:w-4/5 sm:px-8 sm:pb-[60px] sm:pt-10",children:[s.jsxs(H,{href:"/in",className:"mb-6 inline-flex items-center gap-1.5 text-[13px] font-medium text-[#475569] transition-colors hover:text-[#334155]",children:[s.jsx(Fe,{className:"h-[13px] w-[13px]"}),"Back to search"]}),s.jsxs("header",{className:"mb-8",children:[s.jsx("h1",{className:"text-[28px] font-bold leading-[1.1] tracking-[-0.03em] text-[#0f172a]",children:"My Searches"}),s.jsxs("section",{className:"mt-6",children:[s.jsx("div",{className:"mb-2.5 text-[10px] font-bold uppercase tracking-[0.12em] text-[#475569]",children:"Start a new prospecting run"}),s.jsxs("div",{className:"overflow-hidden rounded-xl border border-[#e2e8f0] bg-white shadow-[0_1px_4px_rgba(0,0,0,0.05)]",children:[s.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center lg:divide-x lg:divide-[#e2e8f0]",children:[s.jsxs("div",{className:"flex min-h-[46px] min-w-0 flex-[2] items-center gap-2 border-b border-[#e2e8f0] px-4 lg:border-b-0",children:[s.jsx(le,{className:"h-[15px] w-[15px] shrink-0 text-[#475569]"}),s.jsxs("div",{className:"relative min-w-0 flex-1",children:[U||de?null:s.jsxs("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center text-sm text-[#475569]",children:[s.jsx("span",{children:"Search "}),s.jsx("span",{children:W}),s.jsx("span",{className:"ml-0.5 inline-block h-[1em] w-px animate-pulse bg-[#475569]"})]}),s.jsx("input",{value:U,onChange:a=>ce(a.target.value),onFocus:()=>ne(!0),onBlur:()=>ne(!1),placeholder:"",className:"w-full bg-transparent py-3.5 text-sm text-[#0f172a] outline-none"})]})]}),s.jsx("div",{className:"hidden min-h-[46px] shrink-0 items-center px-3 text-[13px] text-[#475569] lg:flex",children:"in"}),s.jsxs("div",{ref:m,className:"flex min-h-[46px] min-w-0 flex-[1.5] items-center gap-2 border-b border-[#e2e8f0] px-4 lg:border-b-0",children:[s.jsx(ke,{className:"h-3.5 w-3.5 shrink-0 text-[#475569]"}),s.jsx("input",{value:J,onChange:a=>{ee(a.target.value),O(""),a.target.value.trim().length>=2?D(!0):(q([]),D(!1))},onFocus:()=>{G.length>0&&D(!0)},placeholder:_.length===0?"City or county":"Add another area…",autoComplete:"off",className:"w-full bg-transparent py-3.5 text-sm text-[#0f172a] outline-none placeholder:text-[#475569]"})]}),s.jsxs("button",{type:"button",onClick:x,disabled:te,className:"inline-flex min-h-[46px] shrink-0 items-center justify-center gap-2 bg-[#2563eb] px-[22px] py-[13px] text-sm font-semibold text-white transition-colors hover:bg-[#1d4ed8] disabled:cursor-wait disabled:opacity-70",children:[te?s.jsx(Ce,{className:"h-[15p
24x] w-[15px] animate-spin"}):s.jsx(le,{className:"h-[15px] w-[15px]"}),"Get Leads"]})]}),_.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2 border-t border-[#e2e8f0] px-4 py-2.5",children:_.map(a=>s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-[#bfdbfe] bg-[#eff6ff] px-2.5 py-0.5 text-[12px] font-medium text-[#1d4ed8]",children:[a.city,", ",a.state,s.jsx("button",{type:"button",onClick:()=>M(r=>r.filter(i=>i.key!==a.key)),className:"ml-0.5 text-[#93c5fd] hover:text-[#1d4ed8]","aria-label":`Remove ${a.city}`,children:"×"})]},a.key))})]}),re?s.jsx("p",{className:"mt-3 text-[13px] font-medium text-[#dc2626]",children:re}):null]}),s.jsx("p",{className:"mt-1.5 max-w-[716px] text-left text-[13px] font-normal leading-[1.6] tracking-normal text-[#475569]",children:"Review previous lead runs, reopen result tables, and see how many leads, emails, and source websites each search produced."})]}),Q&&e&&_e.createPortal(s.jsx("div",{ref:h,style:{position:"fixed",top:e.top,left:e.left,width:e.width,zIndex:9999},className:"overflow-hidden rounded-xl border border-slate-200 bg-white shadow-[0_18px_50px_rgba(15,23,42,0.12)]",children:he?s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 text-sm text-slate-500",children:[s.jsx(Ce,{className:"h-4 w-4 animate-spin"}),s.jsx("span",{children:"Looking up U.S. cities and counties..."})]}):G.length>0?G.map(a=>s.jsxs("button",{type:"button",className:"flex w-full items-start justify-between gap-3 border-b border-slate-100 px-4 py-3 text-left last:border-b-0 hover:bg-slate-50",onPointerDown:r=>{r.preventDefault(),r.stopPropagation(),S(a)},onMouseDown:r=>{r.preventDefault(),r.stopPropagation()},onClick:()=>S(a),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-semibold text-slate-900",children:a.primaryText}),s.jsx("p",{className:"truncate text-xs text-slate-500",children:a.secondaryText})]}),s.jsx("span",{className:"shrink-0 text-[11px] font-semibold uppercase tracking-[0.08em] text-slate-400",children:"US"})]},a.key)):null}),document.body),V?s.jsx("div",{className:"flex flex-col gap-3.5",children:[160,200,180].map(a=>s.jsx("div",{className:"tang-my-searches-skeleton rounded-2xl",style:{height:a}},a))}):P.length===0?s.jsxs("div",{className:"rounded-2xl border border-[#e8eaed] bg-white px-10 py-20 text-center",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-[52px] w-[52px] items-center justify-center rounded-[14px] bg-[#f1f5f9]",children:s.jsx(le,{className:"h-[22px] w-[22px] text-[#475569]"})}),s.jsx("h2",{className:"mb-2 text-[17px] font-bold text-[#0f172a]",children:"No searches yet"}),s.jsx("p",{className:"mx-auto mb-6 max-w-[360px] text-[13px] leading-[1.6] text-[#475569]",children:"Start a lead search and Tang will save the run here with timing, lead, email, and source-site metrics."}),s.jsxs(H,{href:"/in",className:"inline-flex items-center gap-2 rounded-full bg-[#0f172a] px-[22px] py-2.5 text-[13px] font-semibold text-white transition-colors hover:bg-[#1e293b]",children:[s.jsx(Pe,{className:"h-3.5 w-3.5"}),"Start your first search"]})]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[u.map((a,r)=>{const i=a.searches.length>1,n=a.searches[0],y=Xe(n),k=a.searches.map(v=>{var A;return String(((A=v.runDetail)==null?void 0:A.status)||"").trim().toLowerCase()}).some(v=>v&&v!=="complete"&&v!=="completed"&&v!=="failed"&&v!=="error"),E=a.searches.reduce((v,A)=>{const R=A.metrics||{};return{totalLeads:Number(v.totalLeads||0)+Number(R.totalLeads||0),businessResults:Number(v.businessResults||0)+Number(R.businessResults||0),emailAddressesDiscovered:Number(v.emailAddressesDiscovered||0)+Number(R.emailAddressesDiscovered||0),staffEmailLeads:Number(v.staffEmailLeads||0)+Number(R.staffEmailLeads||0),businessEmailLeads:Number(v.businessEmailLeads||0)+Number(R.businessEmailLeads||0),discoveredWebsites:Number(v.discoveredWebsites||0)+Number(R.discoveredWebsites||0),completedWebsites:Number(v.completedWebsites||0)+Number(R.completedWebsites||0),failedWebsites:Number(v.failedWebsites||0)+Number(R.failedWebsites||0),cancelledWebsites:Number(v.cancelledWebsites||0)+Number(R.cancelledWebsites||0),reusedWebsites:Number(v.reusedWebsites||0)+Number(R.reusedWebsites||0),inProgressWebsites:Number(v.inProgressWebsites||0)+Number(R.inProgressWebsites||0),queuedWebsites:Number(v.queuedWebsites||0)+Number(R.queuedWebsites||0)}},{}),C=we(E),T=ye(n).slice(0,10),fe=a.searches.map(v=>({search:v,label:Qe(v),count:Ke(v)})).sort((v,A)=>v.label.localeCompare(A.label));return s.jsx("article",{className:"tang-my-searches-card flex overflow-hidden rounded-2xl border border-[#e8eaed] bg-white",style:{animation:"tangMySearchesFadeUp 0.25s ease both",animationDelay:`${r*60}ms`},children:s.jsxs("div",{className:"min-w-0 flex-1 px-5 py-[18px]",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"mb-2.5 flex flex-wrap items-center gap-[7px]",children:[s.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-[#475569]",children:[s.jsx(De,{className:"h-[11px] w-[11px]"}),Ze(n.createdAt)]}),!i&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-[#475569]",children:[s.jsx(ke,{className:"h-[11px] w-[11px]"}),ve(n)]})]}),s.jsxs("h2",{className:"text-[17px] font-bold leading-[1.3] tracking-[-0.02em] text-[#0f172a]",children:[s.jsx("span",{className:"capitalize",children:y}),i?null:` in ${ve(n)}`]}),i&&s.jsxs("div",{className:"mt-2.5 rounded-xl border border-[#e2e8f0] bg-[#f8fafc] p-2.5",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[s.jsxs("span",{className:"text-[11px] font-bold uppercase tracking-[0.08em] text-[#475569]",children:[F(a.searches.length)," areas"]}),s.jsxs("span",{className:"text-[12px] font-semibold text-[#0f172a]",children:[F(C)," businesses"]})]}),s.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2 xl:grid-cols-4",children:fe.map(({search:v,label:A,count:R})=>s.jsxs(H,{href:Re(v),className:"group flex min-w-0 items-center justify-between gap-2 rounded-lg border border-[#e2e8f0] bg-white px-2.5 py-2 text-[12px] transition-colors hover:border-[#bfdbfe] hover:bg-[#eff6ff]",title:`Open ${A} results`,children:[s.jsx("span",{className:"min-w-0 truncate font-semibold text-[#1e293b] group-hover:text-[#1d4ed8]",children:A}),s.jsxs("span",{className:"shrink-0 rounded-full bg-[#eef2ff] px-2 py-0.5 text-[11px] font-bold text-[#1d4ed8]",children:[F(R)," result",R===1?"":"s"]})]},v._id))})]}),!i&&s.jsxs("div",{className:"mt-2 text-[13px] font-semibold text-[#0f172a]",children:[F(C)," businesses found."]}),s.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3.5 gap-y-1 text-xs text-[#475569]",children:[s.jsxs("span",{children:["Ran ",Ge(n.createdAt)]}),T?s.jsxs("span",{className:"text-[#475569]",style:{fontFamily:'"Geist Mono", monospace'},children:["run ",T,"..."]}):null]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[k&&s.jsx("button",{type:"button",onClick:()=>w(a.id),disabled:Z===a.id,title:"Refresh status",className:"inline-flex items-center gap-1 rounded-lg border border-[#e2e8f0] bg-white px-2.5 py-1.5 text-xs font-medium text-[#475569] transition-colors hover:bg-[#f8fafc] hover:text-[#0f172a] disabled:cursor-wait disabled:opacity-60",children:s.jsx(Ue,{className:`h-3 w-3 ${Z===a.id?"animate-spin":""}`})}),s.jsxs(H,{href:Re(a.searches,{aggregateBatch:i}),className:"inline-flex shrink-0 items-center gap-2 rounded-xl bg-[#0f172a] px-5 py-3 text-sm font-bold text-white shadow-sm transition-colors hover:bg-[#1e293b]",title:i?"View all batch business results":"View business results",children:["Open",s.jsx(We,{className:"h-4 w-4"})]})]})]}),s.jsxs("div",{className:"mt-3.5 grid gap-2 sm:grid-cols-2",children:[s.jsxs("div",{className:"rounded-[10px] border border-[#f1f5f9] bg-[#f8fafc] px-[13px] py-2.5",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10px] font-bold uppercase tracking-[0.08em] text-[#334155] opacity-80",children:[s.jsx(ze,{className:"h-[11px] w-[11px]"}),"Businesses"]}),s.jsx("div",{className:"mt-[3px] text-[19px] font-bold text-[#0f172a]",children:F(C)})]}),s.jsxs("div",{className:"rounded-[10px] border border-[#f1f5f9] bg-[#f8fafc] px-[13px] py-2.5",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10px] font-bold uppercase tracking-[0.08em] text-[#334155] opacity-80",children:[s.jsx(Oe,{className:"h-[11px] w-[11px]"}),"Emails"]}
24),s.jsx("div",{className:"mt-[3px] text-[19px] font-bold text-[#0f172a]",children:F(E.emailAddressesDiscovered)}),s.jsxs("div",{className:"mt-px text-[11px] text-[#475569]",children:[F(E.staffEmailLeads)," staff · ",F(E.businessEmailLeads)," biz"]})]})]})]})},a.id)}),s.jsxs("p",{className:"mt-2 text-center text-xs text-[#475569]",children:["Showing ",P.length," search",P.length!==1?"es":""]})]})]})]})]})}export{ot 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.