1import{u as H,r as f,m as P,W as L,j as e,H as k,X as T,Z as K,Y as $,I as A,_ as G,P as U,B as _,F as C,$ as z,a0 as Y,a1 as Z}from"./index-DUiXJ36l.js";const D=[{v:"",label:"All"},{v:"buy",label:"Buy"},{v:"rent",label:"Rent"},{v:"commercial",label:"Commercial"},{v:"pg",label:"PG"}],I=[{v:"newest",label:"Newest"},{v:"price_asc",label:"Price: Low â High"},{v:"price_desc",label:"Price: High â Low"},{v:"most_viewed",label:"Most viewed"}];function Q({ownerId:a,profile:n,stats:r,search:t}){const p=H(),u=t.page??1,[h,w]=f.useState(t.bhk??""),[g,S]=f.useState(t.minPrice?.toString()??""),[b,M]=f.useState(t.maxPrice?.toString()??""),{data:x,isLoading:B}=P({queryKey:["owner-portfolio",a,t],queryFn:()=>L({data:{ownerId:a,category:t.category,city:t.city,propertyType:t.propertyType,bhk:t.bhk,minPrice:t.minPrice,maxPrice:t.maxPrice,furnishing:t.furnishing,possession:t.possession,sort:t.sort??"newest",page:u,pageSize:24,status:t.status??"live"}})});function d(s){p({to:"/u/$id",params:{id:a},search:i=>{const l={...i,...s};return"page"in s||(l.page=void 0),l.sort==="newest"&&(l.sort=void 0),Object.keys(l).forEach(o=>{(l[o]===""||l[o]===void 0||l[o]===!1)&&delete l[o]}),l}})}f.useEffect(()=>{const s=setTimeout(()=>{const i=h||void 0,l=g?Number(g):void 0,o=b?Number(b):void 0;i===(t.bhk??void 0)&&l===(t.minPrice??void 0)&&o===(t.maxPrice??void 0)||d({bhk:i,minPrice:l,maxPrice:o})},350);return()=>clearTimeout(s)},[h,g,b]);function q(){w(""),S(""),M(""),p({to:"/u/$id",params:{id:a},search:{}})}const y=n.full_name??"Member",F=(y.match(/\b\w/g)??[]).slice(0,2).join("").toUpperCase()||"?",m=x?.facets,v=x?.total??0,j=Math.max(1,Math.ceil(v/24)),R=m?.byStatus??{live:0,sold:0,rented:0},E=t.status??"live",N=!!(t.category||t.city||t.propertyType||t.bhk||t.minPrice||t.maxPrice||t.furnishing||t.possession);return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(k,{}),e.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-8 sm:px-6",children:[e.jsxs("section",{className:"flex flex-wrap items-start gap-6 rounded-2xl border border-border bg-card p-6",children:[n.avatar_url?e.jsx("img",{src:n.avatar_url,alt:y,className:"size-20 rounded-full object-cover"}):e.jsx("div",{className:"flex size-20 items-center justify-center rounded-full bg-primary/15 text-2xl font-bold text-primary",children:F}),e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h1",{className:"text-2xl font-bold",children:y}),n.verified_at&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/15 px-2 py-0.5 text-xs font-semibold text-emerald-700 dark:text-emerald-400",children:[e.jsx(T,{className:"size-3"})," Verified seller"]}),n.is_phone_verified&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-primary/15 px-2 py-0.5 text-xs font-semibold text-primary",children:[e.jsx(T,{className:"size-3"})," Phone verified"]}),r?.responds_quickly&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/15 px-2 py-0.5 text-xs font-semibold text-emerald-700 dark:text-emerald-400",children:[e.jsx(K,{className:"size-3"})," Responds quickly"]})]}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Member since ",$(n.created_at)]}),n.bio&&e.jsx("p",{className:"mt-3 text-sm text-foreground/90 whitespace-pre-line",children:n.bio}),e.jsxs("dl",{className:"mt-4 grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e.jsx(c,{label:"Active",value:r?.total_live??v}),e.jsx(c,{label:"Sold",value:r?.total_sold??0}),e.jsx(c,{label:"Enquiries handled",value:r?.total_enquiries_handled??0}),e.jsx(c,{label:"Response (30d)",value:r?.response_rate_30d==null?"â":`${Math.round((r.response_rate_30d??0)*100)}%`})]}),r?.seller_stats?e.jsxs("dl",{className:"mt-3 grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e.jsx(c,{label:"Median reply time",value:r.seller_stats.median_reply_minutes==null?"â":r.seller_stats.median_reply_minutes<60?`${r.seller_stats.median_reply_minutes} min`:`${Math.round(r.seller_stats.median_reply_minutes/60)} h`}),e.jsx(c,{label:"Enquiries answered",value:`${r.seller_stats.enquiries_answered}/${r.seller_stats.enquiries_received}`}),e.jsx(c,{label:"Listings removed",value:r.seller_stats.listings_removed}),e.jsx(c,{label:"Awaiting confirmation",value:r.seller_stats.listings_stale})]}):null,r?.seller_stats?e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Reply and outcome figures come from this seller's enquiry record, last calculated"," ",$(r.seller_stats.computed_at),"."]}):null]})]}),e.jsxs("section",{className:"mt-8",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("h2",{className:"text-lg font-bold",children:["Portfolio",e.jsxs("span",{className:"ml-2 text-sm font-normal text-muted-foreground",children:[v," ",v===1?"listing":"listings"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("label",{htmlFor:"sort",className:"text-muted-foreground",children:"Sort"}),e.jsx("select",{id:"sort",value:t.sort??"newest",onChange:s=>d({sort:s.target.value}),className:"h-9 rounded-md border border-border bg-background px-2 text-sm",children:I.map(s=>e.jsx("option",{value:s.v,children:s.label},s.v))})]})]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:D.map(s=>{const i=(t.category??"")===s.v,l=s.v?m?.byCategory?.[s.v]??0:Object.values(m?.byCategory??{}).reduce((o,O)=>o+O,0);return e.jsxs("button",{type:"button",onClick:()=>d({category:s.v||void 0}),className:`inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-semibold transition ${i?"border-primary bg-primary text-primary-foreground":"border-border bg-background text-foreground hover:border-primary"}`,children:[s.label,m?e.jsxs("span",{className:"opacity-70",children:["· ",l]}):null]},s.label)})}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-xs",children:["live","sold","rented"].map(s=>{const i={live:"Active",sold:"Sold",rented:"Rented"},l=E===s,o=R[s]??0;return s!=="live"&&o===0&&!l?null:e.jsxs("button",{type:"button",onClick:()=>d({status:s==="live"?void 0:s}),className:`rounded-md border px-2.5 py-1 transition ${l?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:border-primary hover:text-primary"}`,children:[i[s]," ",e.jsxs("span",{className:"opacity-70",children:["· ",o]})]},s)})}),m?.topCities&&m.topCities.length>1?e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>d({city:void 0}),className:`rounded-full border px-3 py-1 text-xs transition ${t.city?"border-border hover:border-primary":"border-primary bg-primary/10 text-primary"}`,children:"All cities"}),m.topCities.map(s=>{const i=t.city===s.slug;return e.jsxs("button",{type:"button",onClick:()=>d({city:i?void 0:s.slug}),className:`rounded-full border px-3 py-1 text-xs transition ${i?"border-primary bg-primary/10 text-primary":"border-border hover:border-primary"}`,children:[s.name," ",e.jsxs("span",{className:"opacity-70",children:["· ",s.count]})]},s.slug)})]}):null,e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2 sm:grid-cols-5",children:[e.jsxs("select",{value:h,onChange:s=>w(s.target.value),className:"h-9 rounded-md border border-border bg-background px-2 text-sm",children:[e.jsx("option",{value:"",children:"Any BHK"}),["1","2","3","4","5+"].map(s=>e.jsxs("option",{value:s,children:[s," BHK"]},s))]}),e.jsx(A,{type:"number",inputMode:"numeric",placeholder:"Min price",value:g,onChange:s=>S(s.target.value),className:"h-9"}),e.jsx(A,{type:"number",inputMode:"numeric",placeholder:"Max price",value:b,onChange:s=>M(s.target.value),className:"h-9"}),e.jsxs("select",{value:t.furnishing??"",onChange:s=>d({furnishing:s.target.value||void 0}),className:"h-9 rounded-md border border-border bg-background px-2 text-sm",children:[e.jsx("option",{value:"",children:"Any furnishing"}
1),e.jsx("option",{value:"unfurnished",children:"Unfurnished"}),e.jsx("option",{value:"semi_furnished",children:"Semi-furnished"}),e.jsx("option",{value:"fully_furnished",children:"Fully furnished"})]})]}),N?e.jsx("div",{className:"mt-3",children:e.jsx("button",{type:"button",onClick:q,className:"text-xs font-semibold text-primary underline",children:"Clear all filters"})}):null,B?e.jsx("div",{className:"mt-6 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:Array.from({length:6}).map((s,i)=>e.jsx(G,{},i))}):x&&x.items.length>0?e.jsx("div",{className:"mt-6 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:x.items.map(s=>e.jsx(U,{p:s},s.id))}):e.jsxs("div",{className:"mt-6 rounded-2xl border border-dashed border-border bg-card/50 p-10 text-center",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:N?"No listings match these filters.":"This member has no active listings yet."}),N?e.jsx(_,{variant:"outline",size:"sm",className:"mt-3",onClick:q,children:"Clear filters"}):null]}),j>1?e.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",disabled:u<=1,onClick:()=>d({page:u-1}),children:"Previous"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",u," of ",j]}),e.jsx(_,{variant:"outline",size:"sm",disabled:u>=j,onClick:()=>d({page:u+1}),children:"Next"})]}):null]})]}),e.jsx(C,{})]})}function c({label:a,value:n}){return e.jsxs("div",{className:"rounded-lg border border-border bg-background px-3 py-2",children:[e.jsx("div",{className:"text-lg font-bold text-foreground",children:n}),e.jsx("div",{className:"text-xs text-muted-foreground",children:a})]})}function W(){const{id:a}=z.useParams(),n=z.useSearch(),{data:r,isLoading:t}=P({queryKey:["public-profile",a],queryFn:()=>Y({data:{id:a}})}),p=P({queryKey:["public-profile-stats",a],queryFn:()=>Z({data:{id:a}}),staleTime:300*1e3});return t?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(k,{}),e.jsx("main",{className:"mx-auto max-w-5xl px-4 py-12 sm:px-6",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"})}),e.jsx(C,{})]}):r?.profile?e.jsx(Q,{ownerId:a,profile:r.profile,stats:p.data,search:n}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(k,{}),e.jsxs("main",{className:"mx-auto max-w-5xl px-4 py-12 sm:px-6",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Profile not found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"This user no longer exists."})]}),e.jsx(C,{})]})}export{W as component};
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.