1import{a as n,j as t}from"./vendor-react-5BUW_FQY.js";import{u as M}from"./vendor-clerk-DfvZ0u2Z.js";import{u as O}from"./vendor-router-B8lZ4E-e.js";const N=["[email protected]","[email protected]"],U="https://api.kairobot.ai",x={"Kairo Pro":"#3b82f6","What AI Services":"#10b981","Outbound AI":"#f59e0b","Grammar Pro":"#ec4899","Creator Bundle":"#14b8a6","Services Hub":"#8b5cf6"},K={active:{bg:"rgba(16,185,129,0.15)",text:"#34d399"},cancelled:{bg:"rgba(239,68,68,0.15)",text:"#f87171"},pending:{bg:"rgba(245,158,11,0.15)",text:"#fbbf24"},paused:{bg:"rgba(107,114,128,0.15)",text:"#9ca3af"}};function H({label:a,color:o}){return t.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:99,fontSize:11,fontWeight:600,background:`${o}22`,color:o,border:`1px solid ${o}44`},children:a})}function q({status:a}){const o=K[a.toLowerCase()]??{bg:"rgba(107,114,128,0.15)",text:"#9ca3af"};return t.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:99,fontSize:11,fontWeight:600,background:o.bg,color:o.text},children:a})}function Q(){const{user:a,isLoaded:o}=M(),[,f]=O(),[l,A]=n.useState([]),[y,j]=n.useState(!0),[g,S]=n.useState(null),[c,k]=n.useState("all"),[p,z]=n.useState(""),[d,L]=n.useState("created_at"),[h,v]=n.useState("desc"),[w,R]=n.useState(null),W=a?.primaryEmailAddress?.emailAddress??"",u=N.includes(W),b=n.useCallback(async(e=!1)=>{if(u){e||j(!0),S(null);try{const s=await(await fetch(`${U}/api/founder/crm`,{credentials:"include"})).json();if(s.error)throw new Error(s.error);A(s.subscribers??[]),R(new Date)}catch(r){S(r.message)}finally{j(!1)}}},[u]);n.useEffect(()=>{if(!o)return;if(!u){f("/");return}b();const e=setInterval(()=>b(!0),3e4);return()=>clearInterval(e)},[o,u,f,b]);const _=n.useMemo(()=>Array.from(new Set(l.map(e=>e.product))),[l]),m=n.useMemo(()=>{let e=l;if(c!=="all"&&(e=e.filter(r=>r.product===c)),p.trim()){const r=p.toLowerCase();e=e.filter(s=>s.email.toLowerCase().includes(r)||(s.name??"").toLowerCase().includes(r)||(s.business_name??"").toLowerCase().includes(r)||(s.phone??"").includes(r))}return[...e].sort((r,s)=>{const D=r[d]??"",F=s[d]??"",C=String(D).localeCompare(String(F),void 0,{numeric:!0});return h==="asc"?C:-C})},[l,c,p,d,h]);function E(e){d===e?v(r=>r==="asc"?"desc":"asc"):(L(e),v("asc"))}function I(e){const r=parseFloat(e);return isNaN(r)?e:"$"+r.toFixed(0)}function $(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}const B={padding:"10px 14px",textAlign:"left",fontSize:11,fontWeight:700,letterSpacing:"0.06em",color:"#6b7280",textTransform:"uppercase",background:"#0f172a",borderBottom:"1px solid rgba(255,255,255,0.08)",whiteSpace:"nowrap",cursor:"pointer",userSelect:"none"},i={padding:"12px 14px",fontSize:13,color:"#e2e8f0",borderBottom:"1px solid rgba(255,255,255,0.05)",verticalAlign:"middle"},T=l.filter(e=>e.status==="active").length,P=l.filter(e=>e.status==="active").reduce((e,r)=>e+(parseFloat(r.monthly_amount)||0),0);return!o||!u?null:t.jsxs("div",{style:{minHeight:"100vh",background:"#060b14",color:"#e2e8f0",fontFamily:"system-ui, -apple-system, sans-serif"},children:[t.jsxs("div",{style:{background:"#0f172a",borderBottom:"1px solid rgba(255,255,255,0.08)",padding:"20px 28px",display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:12},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[t.jsx("button",{onClick:()=>f("/"),style:{background:"none",border:"none",color:"#6b7280",cursor:"pointer",fontSize:18,padding:4},title:"Back",children:"â"}),t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:700,fontSize:18,color:"#f1f5f9"},children:"Subscriber CRM"}),t.jsxs("div",{style:{fontSize:12,color:"#475569",marginTop:2,display:"flex",alignItems:"center",gap:8},children:["All subscribers & listings across every product",w&&t.jsxs("span",{style:{color:"#22c55e",fontSize:11,display:"flex",alignItems:"center",gap:4},children:[t.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#22c55e",display:"inline-block"}}),"Live · ",w.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})]})]})]})]}),t.jsxs("div",{style:{display:"flex",gap:20},children:[t.jsxs("div",{style:{textAlign:"center"},children:[t.jsx("div",{style:{fontSize:22,fontWeight:700,color:"#34d399"},children:T}),t.jsx("div",{style:{fontSize:11,color:"#6b7280"},children:"Active"})]}),t.jsxs("div",{style:{textAlign:"center"},children:[t.jsxs("div",{style:{fontSize:22,fontWeight:700,color:"#60a5fa"},children:["$",P.toFixed(0)]}),t.jsx("div",{style:{fontSize:11,color:"#6b7280"},children:"MRR"})]}),t.jsxs("div",{style:{textAlign:"center"},children:[t.jsx("div",{style:{fontSize:22,fontWeight:700,color:"#f1f5f9"},children:l.length}),t.jsx("div",{style:{fontSize:11,color:"#6b7280"},children:"Total"})]})]})]}),t.jsxs("div",{style:{padding:"16px 28px",display:"flex",gap:10,flexWrap:"wrap",alignItems:"center"},children:[t.jsx("input",{placeholder:"Search name, email, business, phoneâ¦",value:p,onChange:e=>z(e.target.value),style:{background:"#1e293b",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 14px",color:"#e2e8f0",fontSize:13,width:260,outline:"none"}}),t.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:["all",..._].map(e=>t.jsx("button",{onClick:()=>k(e),style:{padding:"6px 14px",borderRadius:99,fontSize:12,fontWeight:600,border:"1px solid",cursor:"pointer",borderColor:c===e?x[e]??"#3b82f6":"rgba(255,255,255,0.1)",background:c===e?`${x[e]??"#3b82f6"}22`:"transparent",color:c===e?x[e]??"#3b82f6":"#9ca3af"},children:e==="all"?"All Products":e},e))})]}),t.jsxs("div",{style:{padding:"0 28px 40px",overflowX:"auto"},children:[y&&t.jsx("div",{style:{textAlign:"center",padding:"60px 0",color:"#6b7280"},children:"Loading subscribersâ¦"}),g&&t.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:"#f87171"},children:g}),!y&&!g&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{fontSize:12,color:"#475569",marginBottom:10},children:[m.length," of ",l.length," subscriber",l.length!==1?"s":""]}),t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",minWidth:700},children:[t.jsx("thead",{children:t.jsx("tr",{children:[["name","Name"],["email","Email"],["business_name","Business"],["phone","Phone"],["product","Product"],["plan","Plan"],["monthly_amount","$/mo"],["status","Status"],["created_at","Joined"]].map(([e,r])=>t.jsxs("th",{style:B,onClick:()=>
1E(e),children:[r," ",d===e?h==="asc"?"â":"â":""]},e))})}),t.jsxs("tbody",{children:[m.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:9,style:{...i,textAlign:"center",color:"#475569",padding:"40px 0"},children:"No subscribers match your filters"})}),m.map((e,r)=>t.jsxs("tr",{style:{background:r%2===0?"transparent":"rgba(255,255,255,0.015)",transition:"background 0.15s"},onMouseEnter:s=>s.currentTarget.style.background="rgba(255,255,255,0.04)",onMouseLeave:s=>s.currentTarget.style.background=r%2===0?"transparent":"rgba(255,255,255,0.015)",children:[t.jsx("td",{style:i,children:e.name||t.jsx("span",{style:{color:"#475569"},children:"â"})}),t.jsx("td",{style:{...i,color:"#93c5fd"},children:t.jsx("a",{href:`mailto:${e.email}`,style:{color:"inherit",textDecoration:"none"},children:e.email})}),t.jsx("td",{style:i,children:e.business_name||t.jsx("span",{style:{color:"#475569"},children:"â"})}),t.jsx("td",{style:i,children:e.phone||t.jsx("span",{style:{color:"#475569"},children:"â"})}),t.jsx("td",{style:i,children:t.jsx(H,{label:e.product,color:x[e.product]??"#6b7280"})}),t.jsx("td",{style:{...i,textTransform:"capitalize"},children:e.plan}),t.jsxs("td",{style:{...i,color:"#34d399",fontWeight:600},children:[I(e.monthly_amount),"/mo"]}),t.jsx("td",{style:i,children:t.jsx(q,{status:e.status})}),t.jsx("td",{style:{...i,color:"#6b7280",whiteSpace:"nowrap"},children:$(e.created_at)})]},`${e.product}-${e.id}`))]})]})]})]})]})}export{Q 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.