PageSourceSearch

https://snestico.ai/assets/js/DashboardPage-BNcQ9yFq.js

js snestico.ai collected 2026-10-05 15:07:23 UTC 162,682 bytes, 1 lines download raw bytes

1import{r as l,j as e,S as de,a as Je,N as He,Z as Ss,M as zs}from"./vendor-BOadm9Gy.js";import{P as Gs}from"./ProtectedRoute-CrAct2uw.js";import{m as Ys,G as Ws,g as Js,a as Ks}from"./gender-CZchakj1.js";import{C as ks,P as ds,a as Qs}from"./ChatInterface-BMpc1rrz.js";import{V as Cs,n as Zs,I as Xs,D as De}from"./VerificationRequestModal-DE1hDmfA.js";import{l as j,c as he,d as ze,e as et,f as st,h as As,m as be,C as se,i as te,B as U,j as me,k as xe,n as ve,r as Le,D as es,o as ss,p as ts,q as as,s as rs,g as we,A as ae,u as ge,t as tt,v as at,w as rt,x as Ke,y as Oe,z as it,E as nt,P as lt,F as ot,G as ct,a as Ve,H as dt,I as mt,J as xt,K as ht,L as ut,M as ms,N as gt,O as ft}from"./index-DcN63-UG.js";import{u as pt,C as yt,a as bt,f as jt,H as vt}from"./ListingCompare-DH6gieHv.js";import{u as L}from"./vendor-toast-D6B0hGGw.js";import{S as ne}from"./SectionHero-DiEC8UrR.js";import{u as wt,m as Nt,f as xs,p as St,s as kt,a as Ct,b as At}from"./leasing-CdBr7fTh.js";import{b as Qe,m as qe,a1 as Pt,M as le,a2 as ie,a3 as Rt,a4 as Ps,a5 as Se,a6 as Et,a7 as Tt,a8 as Ae,l as is,a9 as Rs,aa as Es,ab as fe,ac as Ft,ad as ke,H as pe,ae as $t,af as Lt,ag as Ee,ah as Ts,U as oe,f as ns,v as ye,X as ls,n as Fs,i as _e,ai as Ze,C as $s,aj as Mt,ak as Ls,h as os,R as Ms,B as Dt,al as It,L as Ds,am as Bt,an as Ut,ao as Ot,e as Is,ap as Pe,Z as Bs,aq as Vt,ar as Ht,as as qt,S as _t,W as Us,at as zt,au as Gt,av as hs,A as Yt,V as Wt,E as Jt,aw as Kt,y as Qt,ax as Zt,ay as Xt,o as ea}from"./vendor-icons-kUGsRs8M.js";import{A as Te,a as Fe,b as $e}from"./avatar-Cn6RInez.js";import{n as sa,o as ta,p as aa,q as ra}from"./vendor-ui-CeWyqG0w.js";import{I as ce}from"./input-Bkp3DRxb.js";import{L as B,T as Os}from"./textarea-Du0P8z2Y.js";import{S as K,a as Q,b as Z,c as X,d as S}from"./select-CPZ2CXll.js";import{A as ia,a as na,b as la,c as oa,d as ca,e as da,f as ma,g as xa,C as Ie}
1from"./alert-dialog-CmfuT_sx.js";import{L as ha}from"./LocationAutocomplete-B1B46CfE.js";import{B as Ne}from"./badge-7z_Rspf7.js";import{S as ua}from"./separator-BG1XqNk9.js";import{S as ga,P as fa}from"./SavedSearches-Do81aa9J.js";import{R as Vs,m as pa,c as ya,a as ba,b as us}from"./RoommateCard-Cn--Sh_J.js";import{T as ja,a as va,b as gs,c as fs}from"./tabs-DEAXSYV8.js";import{r as wa,s as Na}from"./messageSuggestions-DhDNsipD.js";import{P as ps}from"./progress-BRAw2phP.js";import{S as Sa}from"./SquareCard-doccMRae.js";import{u as Hs,c as ka,m as Xe,l as je,P as Ge,p as ys}from"./billing-DUvobp70.js";import{P as Ca}from"./PhoneSetup-NTARMWNS.js";import{u as Aa}from"./snesty-CUiRl0A6.js";import{u as Pa}from"./linkedItem-D-HWBT5B.js";import{R as Ra}from"./Resources-3tF_MP3x.js";import{C as Ea}from"./CollapsibleSidebar-CFZk25t2.js";import{P as Ta}from"./PageWithSplitScreenChat-FH3zsyYX.js";import{A as Fa,a as $a}from"./alert-BLmRd9L2.js";import{A as La}from"./vendor-motion-DwikGbVM.js";import{N as Ma}from"./NestSearchMark-CqXMNjtM.js";import{C as bs}from"./ScamSafetyNotice-CVSGlzEi.js";import{S as Da}from"./SEO-BlctqH_J.js";import{u as Ia,P as js}from"./useShowGuestPreview-Esp5n2H_.js";import"./SignInGate-C8h4QWAT.js";import"./confirmation-dialog-CMFVQjnw.js";import"./videoCallInvite-CJW20aQp.js";import"./calls-D_YBXu01.js";import"./SuggestedMessages-CWV_yBFJ.js";import"./ReportButton-CtaQmsdm.js";import"./adminFeaturesApi-7Qqpvd5d.js";import"./VerifiedBadge-K3OCJ010.js";import"./scamCheck-CbknRgRj.js";import"./vendor-classnames-CSqCgoPn.js";import"./huntingScreens-BUQnXGia.js";import"./liveData-B-JP5enQ.js";import"./listingCard-CQCxl9Sv.js";import"./parts-DHFx0_fH.js";import"./FaqList-BKcKv2xT.js";import"./ListingsBrowser-DKIS_gVw.js";import"./guestAllowance-D6291Mbp.js";import"./ReportListingButton-DbJ-9Zxa.js";import"./HomeAssistant-BnsY3jEo.js";import"./urlState-B_08S4CE.js";import"./leasingScreens-CLWCzzJG.js";import"./PageHero-DcDr-0N-.js";import"./RoommateForListing-P6SN8t6C.js";import"./examples-Ceg-BcPV.js";import"./snestyChat-vxICfnRw.js";function Ba(){const[s,a]=l.useState(!1),[t,n]=l.useState(!1),[m,r]=l.useState(!1);return l.useEffect(()=>{const h=()=>{const f=window.innerWidth;a(f<768),n(f>=768&&f<1024),r(f>=1024)};return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[]),{isMobile:s,isTablet:t,isDesktop:m}}function Ua({r:s,onDone:a,onCancel:t}){const[n,m]=l.useState(null),[r,h]=l.useState(null),[f,N]=l.useState(null);l.useEffect(()=>{s.slug&&St.home(s.slug).then(i=>m(i.slots)).catch(()=>m([]))},[s.slug]);const u=kt(n||[]),b=u.find(i=>i.date===r)?.times||[];return e.jsxs("div",{className:"mt-3 w-full rounded-xl bg-gray-50 p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-[#0C1A2B]",children:"Pick a new time (local to the home)"}),n===null?e.jsx(ie,{className:"mt-2 h-4 w-4 animate-spin text-gray-400"}):u.length===0?e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:j("No other open times right now. Message the landlord to find one.","No other open times right now. Message the owner to find one.")}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 flex gap-2 overflow-x-auto pb-1",children:u.map(i=>e.jsx("button",{type:"button",onClick:()=>h(i.date),"aria-pressed":r===i.date,className:`flex-shrink-0 rounded-xl border px-3 py-1.5 text-xs font-semibold ${r===i.date?"border-[#0C1A2B] bg-[#0C1A2B] text-white":"border-gray-200 bg-white text-gray-700"}`,children:Ct(i.date)},i.date))}),r&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:b.map(i=>{const d=`${r}T${i}`;return e.jsxs("button",{type:"button",disabled:!!f,onClick:async()=>{N(d);try{await a(d)}finally{N(null)}},className:"inline-flex items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1 text-xs font-semibold text-gray-700 hover:border-emerald-600 disabled:opacity-60",children:[f===d&&e.jsx(ie,{className:"h-3 w-3 animate-spin"})," ",At(i)]},d)})})]}),e.jsx("button",{type:"button",onClick:t,className:"mt-2 text-xs font-semibold text-gray-500",children:"Keep my time"})]})}const Oa={requested:{text:j("Waiting for the landlord","Waiting for the owner"),tone:"bg-amber-50 text-amber-800"},confirmed:{text:"Confirmed",tone:"bg-emerald-50 text-emerald-800"},canceled:{text:"Canceled",tone:"bg-gray-100 text-gray-500"}};function Va(){const s=wt(),[a,t]=l.useState(null),[n,m]=l.useState(null),[r,h]=l.useState(null),[f,N]=l.useState(null),u=l.useCallback(async()=>{try{t((await s("/leasing/my-requests")).requests),m(null)}catch(o){m(o instanceof Error?o.message:"Couldn't load your viewings."),t([])}},[s]);l.useEffect(()=>{u()},[u]);const b=async o=>{if(window.confirm(`Cancel your viewing of ${o.name}? The ${j("landlord","owner")} will be told.`)){N(o.id);try{await s(`/leasing/my-requests/${o.id}/cancel`,{method:"POST"}),t(k=>(k||[]).map(R=>R.id===o.id?{...R,viewingStatus:"canceled"}
1:R)),L.success(j("Viewing canceled. The landlord has been told.","Viewing cancelled. The owner has been told."))}catch(k){L.error(k instanceof Error?k.message:"Couldn't cancel.")}finally{N(null)}}},i=async(o,k)=>{try{await s(`/leasing/my-requests/${o.id}/reschedule`,{method:"POST",body:JSON.stringify({viewingAt:k})}),t(R=>(R||[]).map(C=>C.id===o.id?{...C,viewingAt:k,viewingStatus:"requested"}:C)),h(null),L.success(`Asked for ${xs(k)}. The ${j("landlord","owner")} will confirm the new time.`)}catch(R){L.error(R instanceof Error?R.message:"Couldn't change the time.")}},d=(a||[]).filter(o=>o.viewingStatus==="requested"||o.viewingStatus==="confirmed").length;return e.jsxs(e.Fragment,{children:[e.jsx(ne,{icon:Qe,eyebrow:"Snestico Preferred",title:"My",accent:"viewings",subtitle:j("Homes you asked about through a landlord's leasing assistant, and where each viewing stands.","Flats you asked about through an owner's leasing assistant, and where each viewing stands."),facts:a?[{label:"upcoming",value:d},{label:"sent",value:a.length}]:void 0}),n&&e.jsx("p",{className:"mb-4 rounded-xl bg-red-50 p-3 text-sm text-red-700",children:n}),a===null?e.jsx(he,{label:"Loading your viewings"}):a.length?e.jsx("ul",{className:"space-y-3",children:a.map(o=>{const k=o.viewingStatus?Oa[o.viewingStatus]:null,R=o.viewingStatus==="requested"||o.viewingStatus==="confirmed";return e.jsxs("li",{className:"flex flex-wrap items-center gap-3 rounded-2xl border border-gray-200 bg-white p-3 shadow-sm",children:[o.photoUrl?e.jsx("img",{src:o.photoUrl,alt:"",className:"h-16 w-20 rounded-xl object-cover"}):e.jsx("div",{className:"flex h-16 w-20 items-center justify-center rounded-xl bg-gray-100 text-gray-400",children:e.jsx(qe,{className:"h-6 w-6"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-[#0C1A2B]",children:o.slug?e.jsx(de,{to:`/ask/${o.slug}`,className:"hover:text-[#3A5A8C]",children:o.name}):o.name}),e.jsxs("p",{className:"text-xs text-gray-500",children:[Nt(o.rent),"/mo · ",o.address]}),o.viewingAt?e.jsxs("p",{className:`mt-1.5 inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-semibold ${k?.tone||""}`,children:[e.jsx(Qe,{className:"h-3.5 w-3.5"})," ",xs(o.viewingAt)," · ",k?.text]}):e.jsxs("p",{className:"mt-1.5 text-xs text-gray-500",children:["Details sent; no viewing time picked",o.slug?e.jsxs(e.Fragment,{children:[" · ",e.jsx(de,{to:`/ask/${o.slug}`,className:"font-semibold text-[#3A5A8C]",children:"pick one"})]}):""]})]}),o.slug&&o.verdict!=="not_a_fit"&&o.viewingStatus!=="canceled"&&e.jsxs("button",{type:"button",onClick:()=>h(r===o.id?null:o.id),className:"inline-flex items-center gap-1.5 rounded-full border border-gray-200 px-3 py-1.5 text-xs font-semibold text-gray-700 hover:bg-gray-50",children:[e.jsx(Pt,{className:"h-3.5 w-3.5"})," ",o.viewingAt?"Change time":"Pick a time"]}),o.landlordUserId&&e.jsxs(de,{to:`/dashboard?section=messages&userId=${encodeURIComponent(o.landlordUserId)}`,className:"inline-flex items-center gap-1.5 rounded-full border border-gray-200 px-3 py-1.5 text-xs font-semibold text-gray-700 hover:bg-gray-50",children:[e.jsx(le,{className:"h-3.5 w-3.5"})," ",j("Message landlord","Message owner")]}),R&&e.jsxs("button",{type:"button",disabled:f===o.id,onClick:()=>b(o),className:"inline-flex items-center gap-1.5 rounded-full border border-gray-200 px-3 py-1.5 text-xs font-semibold text-gray-700 hover:bg-gray-50 disabled:opacity-60",children:[f===o.id?e.jsx(ie,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Rt,{className:"h-3.5 w-3.5"})," Cancel viewing"]}),o.viewingStatus==="canceled"&&o.slug&&o.verdict!=="not_a_fit"&&e.jsx("button",{type:"button",onClick:()=>h(o.id),className:"rounded-full border border-gray-200 px-3 py-1.5 text-xs font-semibold text-gray-700 hover:bg-gray-50",children:"Pick another time"}),r===o.id&&e.jsx(Ua,{r:o,onDone:C=>i(o,C),onCancel:()=>h(null)})]},o.id)})}):e.jsxs("div",{className:"rounded-2xl border border-dashed border-gray-200 p-8 text-center text-sm text-gray-500",children:["No viewings yet. ",e.jsx(de,{to:"/properties?section=listings&source=snestico",className:"font-semibold text-[#3A5A8C]",children:"Snestico Preferred"})," homes answer your questions any time and let you book a viewing on the spot."]})]})}function Ye({className:s,defaultValue:a,value:t,min:n=0,max:m=100,...r}){const h=l.useMemo(()=>Array.isArray(t)?t:Array.isArray(a)?a:[n,m],[t,a,n,m]);return e.jsxs(sa,{"data-slot":"slider",defaultValue:a,value:t,min:n,max:m,className:ze("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",s),...r,children:[e.jsx(ta,{"data-slot":"slider-track",className:ze("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-4 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:e.jsx(aa,{"data-slot":"slider-range",className:ze("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:h.length},(f,N)=>e.jsx(ra,{"data-slot":"slider-thumb",className:"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},N))]})}const Ce=async(s,a={},t,n)=>{try{const m={"Content-Type":"application/json"};t&&(m.Authorization=`Bearer ${t}`),n?.id&&(m["x-clerk-user-id"]=n.id),a.headers&&Object.entries(a.headers).forEac
1h(([h,f])=>{typeof f=="string"&&(m[h]=f)});const r=await fetch(`${ae}${s}`,{...a,headers:m});if(!r.ok){const h=await r.text();throw new Error(`API call failed: ${r.status} - ${h}`)}return await r.json()}catch(m){throw m}},Ha=({user:s})=>{const a=et(),{signOut:t,getToken:n}=st(),{onPreferencesUpdated:m}=As(),[r,h]=l.useState(null),[f,N]=l.useState(!0),[u,b]=l.useState(!1),[i,d]=l.useState(!1),[o,k]=l.useState(!1),[R,C]=l.useState(!1),[H,I]=l.useState(!1),[O,x]=l.useState(null),P=l.useRef(null),[A,q]=l.useState({phone:"",bio:"",gender:"",age:0,location:{city:"",state:""}}),re=async()=>{const y=await n().catch(()=>null);try{if(s)try{const M=s.phoneNumbers?.[0]?.phoneNumber||s.primaryPhoneNumber?.phoneNumber;await Ce("/auth/sign-in",{method:"POST",body:JSON.stringify({clerkId:s.id,email:s.emailAddresses?.[0]?.emailAddress,firstName:s.firstName||"",lastName:s.lastName||"",avatar:s.imageUrl,phone:M})},y||void 0,s)}catch{}const T=await Ce("/users/profile",{},y||void 0,s);if(T.data){const M=T.data;h(M);const c={phone:M.phone||"",bio:M.bio||"",gender:M.gender||"",age:M.age??0,location:{city:M.location?.city||"",state:M.location?.state||""}};q(c)}}catch{const M=s?.phoneNumbers?.[0]?.phoneNumber||s?.primaryPhoneNumber?.phoneNumber||"";h({id:s?.id||"",clerkId:s?.clerkId||"",email:s?.emailAddresses?.[0]?.emailAddress||"",firstName:s?.firstName||"",lastName:s?.lastName||"",age:0,avatar:s?.imageUrl||"",phone:M,bio:"",verified:!1,role:"user",location:{},preferences:{},createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}),q({phone:M,bio:"",gender:"",age:0,location:{city:"",state:""}})}finally{N(!1)}};l.useEffect(()=>{re()},[s]);const p=(y,T)=>{q(M=>({...M,[y]:T}))},E=(y,T)=>{q(M=>({...M,location:{...M.location,[y]:T}}))},Y=Ys({firstName:r?.firstName||s?.firstName||"x",lastName:r?.lastName||s?.lastName||"x",gender:A.gender,age:A.age,city:A.location.city}),[v,V]=l.useState(!1),D=async()=>{if(V(!0),Y.length){L.error(Y.includes("age")&&Number(A.age)>0&&Number(A.age)<18?"You must be 18 or older to use Snestico.":"Gender, age and city are required.");return}let y=A.phone;if(we()==="in"&&y?.trim()){const T=Zs(y);if(!T){L.error(Xs);return}y=T}b(!0);try{const T={phone:y,bio:A.bio,gender:A.gender,age:A.age===""?null:A.age,location:we()==="in"&&!/,\s*[A-Z]{2}$/.test(A.location.city||"")&&!A.location.country?{...A.location,country:"India"}:A.location},M=await n().catch(()=>null),c=await Ce("/users/profile",{method:"PUT",body:JSON.stringify(T)},M||void 0,s);c.data&&(h(c.data),L.success("Profile updated successfully!"),m())}catch{L.error("Failed to update profile. Please try again.")}finally{b(!1)}},_=async y=>{const T=await n().catch(()=>null),M=await Ce("/users/profile",{method:"PUT",body:JSON.stringify({avatar:y})},T||void 0,s);h(c=>M?.data?{...M.data,avatar:y||void 0}:c&&{...c,avatar:y||void 0}),m()},J=async y=>{const T=a.user;if(!T){L.error("Sign in again to change your photo.");return}if(!y.type.startsWith("image/")){L.error("Choose an image file (JPG, PNG, WebP or GIF).");return}if(y.size>10*1024*1024){L.error("That photo is over 10 MB. Choose a smaller one.");return}x("upload");try{const M=await T.setProfileImage({file:y});await T.reload().catch(()=>{});const c=T.imageUrl||M?.publicUrl||null;if(!c)throw new Error("No photo URL");await _(c),L.success("Profile photo updated")}catch{L.error("Couldn't upload that photo. Please try another one.")}finally{x(null)}},$=async()=>{const y=a.user;if(y){x("remove");try{await y.setProfileImage({file:null}),await _(null),L.success("Profile photo removed")}catch{L.error("Couldn't remove the photo. Please try again.")}finally{x(null)}}};if(f)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-gray-50 to-white",children:e.jsx(he,{label:"Loading your profile",hints:["Fetching your details","Almost there"],size:"lg",fullScreen:!0})});const w=()=>{k(!1),C(!0)},G=async()=>{try{d(!0),L.info("Deleting your account data...");try{const y=await n().catch(()=>null);await Ce("/users/delete",{method:"DELETE"},y||void 0,s)}catch(y){throw new Error(`Backend deletion failed: ${y}`)}L.info("Removing account from authentication system...");try{await s.delete()}catch{try{await t()}catch{}}localStorage.clear(),sessionStorage.clear(),L.success("Account completely deleted from database and authentication system. Redirecting to homepage..."),C(!1),window.location.replace("/")}catch(y){d(!1),y instanceof Error?y.message.includes("Backend deletion failed")?L.error("Failed to delete account data from our servers. Please try again or c
1ontact support."):L.error("Failed to complete account deletion. Please try again or contact support."):L.error("Unexpected error occurred during account deletion. Please contact support.")}};return e.jsxs("div",{children:[e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(ne,{icon:Ps,eyebrow:"Account",title:"Your",accent:"profile",subtitle:j("What roommates and sellers see about you. A fuller profile gets better matches.","What flatmates and sellers see about you. A fuller profile gets better matches."),actions:e.jsxs(e.Fragment,{children:[r?.verified&&e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-emerald-50 px-3 py-1.5 text-xs font-semibold text-emerald-700 ring-1 ring-emerald-200",children:[e.jsx(Se,{className:"h-3.5 w-3.5"})," Verified"]}),r?.role&&e.jsx("span",{className:"rounded-full bg-white px-3 py-1.5 text-xs font-semibold capitalize text-[#0C1A2B] shadow-sm ring-1 ring-gray-200",children:r.role})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-8",children:[e.jsxs("div",{className:"min-w-0 lg:col-span-3 space-y-6",children:[e.jsx(be.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},children:e.jsx(se,{className:"border-0 shadow-sm bg-white/80 backdrop-blur-sm",children:e.jsx(te,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center gap-6 text-center sm:flex-row sm:text-left",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsxs(Te,{className:"h-24 w-24 ring-4 ring-white shadow-lg",children:[e.jsx(Fe,{src:r?.avatar,alt:"",className:"object-cover"}),e.jsxs($e,{className:"text-2xl font-semibold bg-gradient-to-br from-blue-500 to-purple-600 text-white",children:[r?.firstName?.charAt(0),r?.lastName?.charAt(0)]})]}),O&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded-full bg-black/40",children:e.jsx(ie,{className:"h-6 w-6 animate-spin text-white"})}),e.jsx(U,{type:"button",size:"sm",variant:"outline",onClick:()=>P.current?.click(),disabled:!!O,"aria-label":"Upload a profile photo",className:"absolute -bottom-2 -right-2 h-8 w-8 rounded-full p-0 shadow-md hover:shadow-lg transition-all",children:e.jsx(Et,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"mb-1 truncate text-xl font-semibold text-gray-900",children:[r?.firstName," ",r?.lastName]}),e.jsx("p",{className:"mb-3 truncate text-gray-600",title:r?.email,children:r?.email}),e.jsx("input",{ref:P,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",className:"hidden","aria-label":"Profile photo file",onChange:y=>{const T=y.target.files?.[0];y.target.value="",T&&J(T)}}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-2 sm:justify-start",children:[e.jsxs(U,{type:"button",variant:"outline",size:"sm",className:"text-sm",onClick:()=>P.current?.click(),disabled:!!O,children:[O==="upload"?e.jsx(ie,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Tt,{className:"h-4 w-4 mr-2"}),O==="upload"?"Uploading...":r?.avatar?"Change photo":"Upload photo"]}),r?.avatar&&e.jsxs(U,{type:"button",variant:"ghost",size:"sm",className:"text-sm text-gray-600",onClick:$,disabled:!!O,children:[O==="remove"?e.jsx(ie,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ae,{className:"h-4 w-4 mr-2"}),"Remove"]})]}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"JPG, PNG, WebP or GIF, up to 10 MB."})]})]})})})}),e.jsx(be.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:e.jsxs(se,{className:"border-0 shadow-sm bg-white/80 backdrop-blur-sm",children:[e.jsxs(me,{className:"pb-6",children:[e.jsxs(xe,{className:"flex items-center text-xl font-semibold",children:[e.jsx(is,{className:"h-5 w-5 mr-3 text-blue-600"}),"Basic Information"]}),e.jsx(ve,{className:"text-gray-600",children:"Your personal details and contact information"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"firstName",className:"text-sm font-medium text-gray-700",children:"First Name"}),e.jsx(ce,{id:"firstName",value:r?.firstName||"",disabled:!0,className:"h-12 bg-gray-50 border-gray-200 text-gray-600"}),e.jsx("p",{className:"text-xs text-gray-500",children:"First name cannot be changed"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"lastName",className:"text-sm font-medium text-gray-700",children:"Last Name"}),e.jsx(ce,{id:"lastName",value:r?.lastName||"",disabled:!0,className:"h-12 bg-gray-50 border-gray-200 text-gray-600"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Last name cannot be changed"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"email",className:"text-sm font-medium text-gray-700",children:"Email Address"}),e.jsx(ce,{id:"email",value:r?.email||"",disabled:!0,className:"h-12 bg-gray-50 border-gray-200 text-gray-600"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Email address cannot be changed"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"phone",className:"text-sm font-medium text-gray-700",children:"Phone Number"}),e.jsx(ce,{id:"phone",value:A.phone,onChange:y=>p("phone",y.target.value),placeholder:j("Enter your phone number",`+91 ${Le().phonePlaceholder}`),className:"h-12 border-gray-300 focus:border-blue-500 focus:ring-blue-500"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{htmlFor:"gender",className:"text-sm font-medium text-gray-700",children:["Gender ",e.jsx("span",{className:"text-red-500",children:"*"})]}
1),e.jsxs("select",{id:"gender",value:A.gender,onChange:y=>p("gender",y.target.value),className:`h-12 w-full rounded-md border bg-white px-3 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 ${v&&Y.includes("gender")?"border-red-400":"border-gray-300"}`,children:[e.jsx("option",{value:"",disabled:!0,children:"Choose"}),Ws.map(y=>e.jsx("option",{value:y.value,children:y.label},y.value))]}),e.jsx("p",{className:"text-xs text-gray-500",children:j('Used only for roommate matching. "Prefer not to say" is never shown to others.','Used only for flatmate matching. "Prefer not to say" is never shown to others.')})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{htmlFor:"age",className:"text-sm font-medium text-gray-700",children:["Age ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ce,{id:"age",type:"number",value:A.age,onChange:y=>{const T=y.target.value;if(T==="")p("age","");else{const M=parseInt(T);p("age",isNaN(M)?"":M)}},placeholder:"Enter your age",min:"18",max:"100",className:`h-12 focus:border-blue-500 focus:ring-blue-500 ${v&&Y.includes("age")?"border-red-400":"border-gray-300"}`}),e.jsx("p",{className:"text-xs text-gray-500",children:j("You must be 18 or older. Your age helps with roommate matching.","You must be 18 or older. Your age helps with flatmate matching.")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"bio",className:"text-sm font-medium text-gray-700",children:"About You"}),e.jsx(Os,{id:"bio",value:A.bio,onChange:y=>p("bio",y.target.value),placeholder:"Tell us about yourself...",rows:4,className:"border-gray-300 focus:border-blue-500 focus:ring-blue-500 resize-none"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Share a bit about yourself with the community"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{htmlFor:"city",className:"text-sm font-medium text-gray-700",children:["City ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ha,{as:ce,id:"city",value:A.location.city,onChange:y=>E("city",y),onSelect:y=>{y.city&&E("city",y.city),y.state&&E("state",y.state)},placeholder:j("Start typing your city","Start typing your city, e.g. Pune"),className:"h-12 border-gray-300 focus:border-blue-500 focus:ring-blue-500"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"state",className:"text-sm font-medium text-gray-700",children:"State"}),e.jsx(ce,{id:"state",value:A.location.state,onChange:y=>E("state",y.target.value),placeholder:j("Enter your state","e.g. Maharashtra"),className:"h-12 border-gray-300 focus:border-blue-500 focus:ring-blue-500"})]})]})]})]})}),e.jsx(be.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},className:"flex justify-end pt-4",children:e.jsx(U,{onClick:D,disabled:u,size:"lg",className:"px-8 py-3 bg-slate-800 hover:bg-slate-900 text-white font-medium shadow-lg hover:shadow-xl transition-all duration-200",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"h-5 w-5 mr-2 animate-spin"}),"Saving Changes..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Rs,{className:"h-5 w-5 mr-2"}),"Save Changes"]})})})]}),e.jsxs("div",{className:"min-w-0 space-y-6",children:[e.jsx(be.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},transition:{delay:.4},children:e.jsxs(se,{className:"border-0 shadow-sm bg-white/80 backdrop-blur-sm",children:[e.jsx(me,{className:"pb-4",children:e.jsx(xe,{className:"text-lg font-semibold",children:"Account Summary"})}),e.jsxs(te,{className:"space-y-4",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsxs(Te,{className:"h-12 w-12 shrink-0",children:[e.jsx(Fe,{src:r?.avatar,alt:"",className:"object-cover"}),e.jsxs($e,{className:"bg-gradient-to-br from-blue-500 to-purple-600 text-white",children:[r?.firstName?.charAt(0),r?.lastName?.charAt(0)]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"truncate font-medium text-gray-900",children:[r?.firstName," ",r?.lastName]}),e.jsx("p",{className:"truncate text-sm text-gray-500",title:r?.email,children:r?.email})]})]}),e.jsx(ua,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center text-gray-600",children:[e.jsx(Es,{className:"h-4 w-4 mr-2"}),"Member since"]}),e.jsx("span",{className:"font-medium text-gray-900",children:r?.createdAt?new Date(r.createdAt).toLocaleDateString():"N/A"})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center text-gray-600",children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Last updated"]}),e.jsx("span",{className:"font-medium text-gray-900",children:r?.updatedAt?new Date(r.updatedAt).toLocaleDateString():"N/A"})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center text-gray-600",children:[e.jsx(Ft,{className:"h-4 w-4 mr-2"}),"Account type"]}),e.jsx(Ne,{variant:"outline",className:"capitalize",children:r?.role||"user"})]})]})]})]})}),e.jsx(be.div,{initial:{opacity:0,x:20}
1,animate:{opacity:1,x:0},transition:{delay:.5},children:e.jsxs(se,{className:"border-0 shadow-sm bg-white/80 backdrop-blur-sm",children:[e.jsx(me,{className:"pb-4",children:e.jsx(xe,{className:"text-lg font-semibold",children:"Quick Actions"})}),e.jsxs(te,{className:"space-y-3",children:[e.jsxs(U,{variant:"outline",className:"w-full justify-start h-11 text-sm",onClick:()=>k(!0),children:[e.jsx(ke,{className:"h-4 w-4 mr-3"}),"Security Settings"]}),e.jsxs(U,{variant:"outline",className:`w-full justify-start h-11 text-sm ${r?.verified?"opacity-60 cursor-not-allowed":"border-blue-200 text-blue-700 hover:bg-blue-50"}`,disabled:!!r?.verified,onClick:()=>{r?.verified||I(!0)},children:[e.jsx(Se,{className:"h-4 w-4 mr-3"}),r?.verified?"Verified":"Get Verified"]})]})]})})]})]})]}),e.jsx(es,{open:o,onOpenChange:k,children:e.jsxs(ss,{className:"max-w-md bg-white border border-gray-200 shadow-xl",children:[e.jsxs(ts,{children:[e.jsxs(as,{className:"flex items-center gap-2 text-gray-900",children:[e.jsx(ke,{className:"h-5 w-5"}),"Security Settings"]}),e.jsx(rs,{className:"text-gray-600",children:"Manage your account security and privacy settings"})]}),e.jsx("div",{className:"space-y-4 pt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"font-medium text-gray-900",children:"Account Management"}),e.jsx("p",{className:"text-sm text-gray-600",children:"Permanently delete your account and all associated data"}),e.jsxs(U,{variant:"destructive",className:"w-full",onClick:w,children:[e.jsx(Ae,{className:"h-4 w-4 mr-2"}),"Delete Account"]})]})})]})}),e.jsx(ia,{open:R,onOpenChange:y=>{i||C(y)},children:e.jsxs(na,{className:"max-w-md bg-white border border-gray-200 shadow-xl",children:[e.jsxs(la,{children:[e.jsxs(oa,{className:"text-red-600 flex items-center gap-2",children:[e.jsx(Ae,{className:"h-5 w-5"}),"Delete Account"]}),e.jsxs(ca,{className:"text-gray-700 space-y-3",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:"Are you absolutely sure you want to delete your account?"}),e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"text-sm text-red-800 font-medium",children:"This action cannot be undone. This will permanently:"}),e.jsxs("ul",{className:"text-sm text-red-700 list-disc pl-4 space-y-1",children:[e.jsx("li",{children:"Delete your profile and all personal information"}),e.jsx("li",{children:"Remove all your saved properties and preferences"}),e.jsx("li",{children:j("Delete your roommate matches and conversations","Delete your flatmate matches and conversations")}),e.jsx("li",{children:"Remove all marketplace listings and messages"}),e.jsx("li",{children:"Cancel any active subscriptions"})]})]}),e.jsx("p",{className:"text-sm text-gray-600",children:"You will be immediately logged out and redirected to the homepage."})]})]}),e.jsxs(da,{className:"gap-2 pt-4",children:[e.jsx(ma,{className:"bg-white border border-gray-300 text-gray-700 hover:bg-gray-50",onClick:()=>{C(!1)},children:"Cancel"}),e.jsx(xa,{onClick:y=>{y.preventDefault(),G()},disabled:i,className:"bg-red-600 hover:bg-red-700 focus:ring-red-500 text-white border-0",children:i?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ae,{className:"h-4 w-4 mr-2"}),"Yes, Delete My Account"]})})]})]})}),e.jsx(Cs,{isOpen:H,onClose:()=>I(!1),onSuccess:()=>{re(),L.success("Verification request submitted successfully!")}})]})};var qa=Ha;function _a(){const[s,a]=l.useState([]),t=l.useRef(!1),[n,m]=l.useState(!0),[r,h]=l.useState(null),[f,N]=l.useState(""),[u,b]=l.useState("createdAt"),[i,d]=l.useState("desc"),[o,k]=l.useState("all"),[R,C]=l.useState(1),[H,I]=l.useState(!0),[O,x]=l.useState(new Set),{getToken:P,user:A}=ge(),q=w=>({title:w.name||"Property",url:w.url||"",platform:w.platform||"Verified",price:w.price?j(`$${Number(w.price).toLocaleString()}`,at(Number(w.price))):null,location:w.location||w.address||"Location not specified",neighborhood:w.address,bedrooms:w.beds!=null?String(w.beds):null,bathrooms:w.baths!=null?String(w.baths):null,description:w.description||"",image_url:Array.isArray(w.images)&&w.images.length>0?w.images[0]:null});l.useEffect(()=>{A&&re()},[A,R,u,i,o]);const re=async()=>
1{if(A)try{m(!0);const w=await P(),G=new URLSearchParams({page:R.toString(),limit:"20"}),y=await fetch(`${ae}/saved-properties/user?${G}`,{headers:{Authorization:`Bearer ${w}`,"x-clerk-user-id":A.id}});if(y.ok){const T=await y.json();if(T.success){const M=Array.isArray(T.data?.properties)?T.data.properties:[];R===1?(a(M),t.current||(t.current=!0,tt(M.map(c=>({url:c.url,title:c.name,price:c.price,image:Array.isArray(c.images)?c.images[0]:null}))))):a(c=>[...c,...M]),I(!!T.data?.hasMore)}else h(T.message||"Failed to fetch saved properties")}else h("Failed to fetch saved properties")}catch{h("Failed to fetch saved properties")}finally{m(!1)}},p=async w=>{if(!(!A||O.has(w.url))){x(G=>new Set(G).add(w.url));try{const G=await P();await fetch(`${ae}/saved-properties/toggle`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${G}`,"x-clerk-user-id":A.id},body:JSON.stringify({clerkId:A.id,externalPropertyId:w.url,url:w.url,name:w.title,price:Math.round(jt(w.price)),beds:w.bedrooms&&parseInt(w.bedrooms,10)||0,baths:w.bathrooms&&parseInt(w.bathrooms,10)||0,type:"apartment",address:w.neighborhood||w.location,location:w.location,images:w.image_url?[w.image_url]:[],platform:w.platform})}),rt({url:w.url,title:w.title,price:w.price}),a(y=>y.filter(T=>T.url!==w.url))}catch{}finally{x(G=>{const y=new Set(G);return y.delete(w.url),y})}}},E=()=>{H&&!n&&C(w=>w+1)},Y=l.useMemo(()=>s.map(q),[s]),v=pt(Y),[V,D]=l.useState(!1),_=s.filter(w=>{const G=w.name.toLowerCase().includes(f.toLowerCase())||w.location.toLowerCase().includes(f.toLowerCase())||w.address.toLowerCase().includes(f.toLowerCase()),y=o==="all"||w.type===o;return G&&y}).sort((w,G)=>{let y=w[u],T=G[u];return u==="price"?(y=Number(y),T=Number(T)):u==="createdAt"&&(y=new Date(y).getTime(),T=new Date(T).getTime()),i==="asc"?y>T?1:-1:y<T?1:-1}),J=_.map(q),$=()=>{N(""),k("all"),b("createdAt"),d("desc"),C(1)};return A?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-gray-900",children:"Properties Liked"}),e.jsxs("p",{className:"text-gray-600",children:[s.length," propert",s.length!==1?"ies":"y"," liked"]})]}),e.jsx(U,{onClick:$,variant:"outline",children:"Reset Filters"})]}),e.jsxs(se,{children:[e.jsx(me,{children:e.jsx(xe,{className:"text-lg",children:"Filters & Search"})}),e.jsx(te,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:"Search"}),e.jsx(ce,{placeholder:"Search properties...",value:f,onChange:w=>N(w.target.value),className:"w-full rounded-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:"Property Type"}),e.jsxs(K,{value:o,onValueChange:k,children:[e.jsx(Q,{children:e.jsx(Z,{})}),e.jsxs(X,{children:[e.jsx(S,{value:"all",children:"All Types"}),e.jsx(S,{value:"apartment",children:j("Apartment","Flat / apartment")}),e.jsx(S,{value:"house",children:j("House","Independent house")}),we()!=="in"&&e.jsx(S,{value:"condo",children:"Condo"}),e.jsx(S,{value:"studio",children:j("Studio","1 RK / studio")}),e.jsx(S,{value:"townhouse",children:j("Townhouse","Row house")})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-2 block",children:"Sort By"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{value:u,onValueChange:b,children:[e.jsx(Q,{className:"flex-1",children:e.jsx(Z,{})}),e.jsxs(X,{children:[e.jsx(S,{value:"createdAt",children:"Date Saved"}),e.jsx(S,{value:"price",children:"Price"}),e.jsx(S,{value:"name",children:"Name"}),e.jsx(S,{value:"match",children:"Match Score"})]})]}),e.jsx(U,{variant:"outline",size:"sm",onClick:()=>d(w=>w==="asc"?"desc":"asc"),className:"px-2",children:i==="asc"?e.jsx($t,{className:"h-4 w-4"}):e.jsx(Lt,{className:"h-4 w-4"})})]})]})]})})]}),e.jsx(ga,{}),n&&R===1?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[...Array(6)].map((w,G)=>e.jsxs(se,{className:"animate-pulse",children:[e.jsx("div",{className:"h-48 bg-gray-200 rounded-t-lg"}),e.jsxs(te,{className:"p-5 space-y-3",children:[e.jsx("div",{className:"h-4 bg-gray-200 rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-gray-200 rounded w-1/2"}),e.jsx("div",{className:"h-3 bg-gray-200 rounded w-2/3"})]})]},G))}):_.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2.5",children:[_.map((w,G)=>{const y=J[G];return e.jsx(fa,{p:y,saved:!0,onSave:p,compare:J.length>1?v.toggleFor(y):void 0},w.externalPropertyId)}),e.jsx(yt,{count:v.picked.length,onOpen:()=>D(!0),onClear:v.clear}),e.jsx(bt,{listings:v.picked,open:V,onOpenChange:D})]}),H&&e.jsx("div",{className:"text-center",children:e.jsx(U,{onClick:E,disabled:n,variant:"outline",className:"px-8",children:n?"Loading...":"Load More Properties"})})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(pe,{className:"h-16 w-16 mx-auto text-gray-300 mb-4"}),e.jsx("div",{className:"text-lg font-semibold text-gray-600 mb-2",children:f||o!=="all"?"No properties match your filters":"No properties liked yet"}),e.jsx("p",{className:"text-gray-500",children:f||o!=="all"?"Try adjusting your search or filters":"Like a property in AI Property Search and it'll show up here"})]}),r&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"text-red-500 mb-4",children:e.jsx(Ee,{className:"h-12 w-12 mx-auto"})}),e.jsx("div",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Something went wrong"}),e.jsx("p",{className:"text-gray-600 mb-4",children:r}),e.jsx(U,{onClick:re,variant:"outline",children:"Try Again"})]})]}):e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"text-center",children:[e.jsx(pe,{className:"h-16 w-16 mx-auto text-gray-300 mb-4"}),e.jsx("div",{className:"text-lg font-semibold text-gray-600 mb-2",children:"Sign in to view saved properties"}),e.jsx("p",{className:"text-gray-500",children:"Your saved properties will appear here"})]})})}function za({user:s}){const{getToken:a,user:t}=ge(),[n,m]=l.useState([]),[r,h]=l.useState(!0),[f,N]=l.useState(null),[u,b]=l.useState(new Set),i=async()=>
1{if(!t?.id){N("User not authenticated"),h(!1);return}try{h(!0),N(null);const C=await Oe.getSavedRoommates(t.id,a),I=(Array.isArray(C)?C:C?.data||[]).map(x=>({id:x.roommate?.id||x.roommateId,name:`${x.roommate?.firstName||"Unknown"} ${x.roommate?.lastName||"Name"}`.trim(),age:x.roommate?.age&&x.roommate?.age>0?x.roommate.age:null,profession:x.roommate?.occupation||"",company:x.roommate?.company||"",location:x.roommate?.location?.city||"Location",distance:"",aboutMe:x.roommate?.bio||"No bio available",image:x.roommate?.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(x.roommate?.firstName||"U")}&background=f3f4f6&color=374151`,compatibility:null,verified:x.roommate?.verified||!1,responseTime:"",moveIn:"",budget:"",insights:["Saved as favorite","Compatible preferences","Good match potential"],preferences:x.roommate?.preferences||{}}));m(I);const O=new Set(I.map(x=>x.id));b(O)}catch{N(j("Failed to load saved roommates","Failed to load saved flatmates"))}finally{h(!1)}},d=async C=>{if(t?.id)try{u.has(C);const H=await a();(await Oe.toggleSaveRoommate(String(C),H||void 0,t.id)).data?.saved?b(O=>new Set([...O,C])):(b(O=>{const x=new Set(O);return x.delete(C),x}),m(O=>O.filter(x=>x.id!==C)))}catch{}},o=C=>{},k=C=>{},R=C=>C?[{key:"cleanlinessLevel",label:"Cleanliness",value:C.cleanlinessLevel?.[0]},{key:"noiseTolerance",label:"Noise",value:C.noiseTolerance?.[0]},{key:"socialInteraction",label:"Social",value:C.socialInteraction},{key:"sleepSchedule",label:"Sleep",value:C.sleepSchedule?.[0]}].filter(I=>I.value!==void 0&&I.value!==null&&I.value!=="").slice(0,2):[];return l.useEffect(()=>{i()},[t?.id]),r?e.jsx(he,{label:j("Loading your saved roommates","Loading your saved flatmates"),className:"py-12"}):f?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Ts,{className:"h-12 w-12 text-amber-500 mb-4"}),e.jsx("div",{className:"text-lg font-medium text-gray-900 mb-2",children:j("Unable to load saved roommates","Unable to load saved flatmates")}),e.jsx("p",{className:"text-gray-600 text-center mb-4",children:f}),e.jsx(U,{onClick:i,variant:"outline",children:"Try Again"})]}):n.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mb-4",children:e.jsx(pe,{className:"h-8 w-8 text-gray-400"})}),e.jsx("div",{className:"text-lg font-medium text-gray-900 mb-2",children:j("No saved roommates yet","No saved flatmates yet")}),e.jsx("p",{className:"text-gray-600 text-center mb-4",children:j("Start browsing roommates and save your favorites to see them here.","Start browsing flatmates and save your favourites to see them here.")}),e.jsxs(U,{onClick:()=>window.location.href=Ke("/roommates"),className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),j("Find Roommates","Find Flatmates")]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:j("Saved Roommates","Saved Flatmates")}),e.jsxs("p",{className:"text-gray-600 mt-1",children:[n.length," ",n.length===1?j("roommate","flatmate"):j("roommates","flatmates")," saved"]})]}),e.jsx(U,{onClick:i,variant:"outline",size:"sm",children:"Refresh"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:n.map(C=>e.jsx(Vs,{roommate:C,isLiked:u.has(C.id),onLike:d,onViewDetails:o,onStartConversation:k,getTopPreferences:R},C.id))})]})}function Ga({user:s}){const[a,t]=l.useState("properties");return e.jsxs("div",{children:[e.jsx(ne,{icon:pe,eyebrow:"Saved",title:"Everything you",accent:"saved",subtitle:j("Homes and roommates you liked, kept in one place so you can compare and reach out.","Homes and flatmates you liked, kept in one place so you can compare and reach out.")}),e.jsxs(ja,{value:a,onValueChange:t,className:"w-full",children:[e.jsxs(va,{className:"mb-6 inline-flex h-auto rounded-full bg-gray-100 p-1 dark:bg-white/10",children:[e.jsxs(gs,{value:"properties",className:"flex items-center gap-2 rounded-full px-4 py-2 text-sm data-[state=active]:bg-white data-[state=active]:shadow-sm",children:[e.jsx(ns,{className:"h-4 w-4"}),"Homes"]}),e.jsxs(gs,{value:"roommates",className:"flex items-center gap-2 rounded-full px-4 py-2 text-sm data-[state=active]:bg-white data-[state=active]:shadow-sm",children:[e.jsx(oe,{className:"h-4 w-4"}),j("Roommates","Flatmates")]})]}),e.jsx(fs,{value:"properties",className:"mt-0",children:e.jsx(_a,{})}),e.jsx(fs,{value:"roommates",className:"mt-0",children:e.jsx(za,{user:s})})]})]})}const Ya={async getMatches(s={},a,t){try{const n=new URLSearchParams;
1Object.entries(s).forEach(([f,N])=>{N!=null&&N!==""&&n.append(f,String(N))}),n.has("pageSize")||n.append("pageSize","200"),a&&n.append("userId",a);const m={"Content-Type":"application/json"};a&&(m["x-clerk-user-id"]=a),t&&(m.Authorization=`Bearer ${t}`);const r=await fetch(`${ae}/roommates/matches?${n.toString()}`,{method:"GET",headers:m});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return(await r.json()).data||[]}catch{return[]}},async likeRoommate(s,a){try{const t=await fetch(`${ae}/roommates/${s}/like`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return it("roommate_like"),await t.json()}catch(t){throw t}},async dislikeRoommate(s,a){try{const t=await fetch(`${ae}/roommates/${s}/dislike`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return await t.json()}catch(t){throw t}},async getLikedRoommates(s){try{const a=await fetch(`${ae}/roommates/liked`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(await a.json()).data||[]}catch{return[]}}};function Wa(){const{user:s,isAuthenticated:a,isLoading:t,getToken:n}=ge(),[m,r]=l.useState([]),[h,f]=l.useState(!0),[N,u]=l.useState(null),[b,i]=l.useState(""),[d,o]=l.useState("compatibility"),[k,R]=l.useState(null);l.useEffect(()=>{const c=b.trim();if(!c){R(null);return}let F=!1;const W=setTimeout(async()=>{try{const g=await fetch(`${ae}/roommates/search?q=${encodeURIComponent(c)}`);if(!g.ok||F)return;const z=await g.json(),ee=Array.isArray(z?.data)?z.data:[];F||R({query:c,ids:ee.map(ue=>String(ue.userId))})}catch{}},300);return()=>{F=!0,clearTimeout(W)}
1},[b]);const[C,H]=l.useState(new Set),[I,O]=l.useState({city:"",state:"",minBudget:"",maxBudget:""}),[x,P]=l.useState(null),[A,q]=l.useState(!1),[re,p]=l.useState(!1),[E,Y]=l.useState(null);l.useEffect(()=>{V()},[I]),l.useEffect(()=>{s?.id&&v()},[s?.id]);const v=async()=>{if(s?.id)try{const c=await Oe.getSavedRoommates(s.id,n),F=Array.isArray(c)?c:c?.data||[],W=new Set(F.map(g=>g.roommateId||g.roommate?.id).filter(Boolean));H(W)}catch{}},V=async()=>{try{f(!0),u(null);const c=s?.id?await n():void 0,F=await Ya.getMatches(I,s?.id,c);if(F&&F.length>0){const W=F.filter(g=>{if(!g||!g.userId||!g.profile)return!1;const z=g.profile,ee=s?.primaryEmailAddress?.emailAddress||s?.emailAddresses?.[0]?.emailAddress;if(s?.id&&z?.id&&z.id===s.id||ee&&z?.email&&z.email.toLowerCase()===ee.toLowerCase())return!1;if(s?.firstName&&s?.lastName&&ee&&z?.firstName&&z?.lastName&&z?.email){const ue=z.firstName===s.firstName&&z.lastName===s.lastName,Me=ee.split("@")[1],cs=z.email.split("@")[1];if(ue&&(Me&&cs&&Me===cs))return!1}return!0}).map(g=>!g.profile.firstName||!g.profile.lastName?null:{id:g.userId,name:`${g.profile.firstName} ${g.profile.lastName}`,age:g.profile.age&&g.profile.age>0?g.profile.age:null,gender:Js(g.profile.gender),profession:"",company:"",location:g.profile.location?.city&&g.profile.location?.state?`${g.profile.location.city}, ${g.profile.location.state}`:g.profile.location?.city||"Unknown",distance:"",image:g.profile.avatar||"https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=150&h=150&fit=crop&crop=face&fm=webp",verified:g.profile.verified||!1,responseRate:null,responseTime:"",looking:"",budget:"",moveIn:"",aboutMe:g.profile.bio||"No bio available",compatibility:pa(g),categoryBreakdown:g.compatibility?.categoryBreakdown||{},insights:g.insights||[],isLiked:g.interaction?.liked||!1,isLikedBy:g.interaction?.likedBy||!1,preferences:{cleanlinessLevel:g.preferences?.cleanlinessLevel||g.cleanlinessLevel||[5],noiseTolerance:g.preferences?.noiseTolerance||g.noiseTolerance||[3],socialInteraction:g.preferences?.socialInteraction||g.socialInteraction||"moderate",sleepSchedule:g.preferences?.sleepSchedule||g.sleepSchedule||["flexible"],guestPolicy:g.preferences?.guestPolicy||g.guestPolicy||"moderate",cookingStyle:g.preferences?.cookingStyle||g.cookingStyle||"flexible",petPreferences:g.preferences?.petPreferences||g.petPreferences||"flexible",sharingItems:g.preferences?.sharingItems||g.sharingItems||[3],sharedInterests:g.preferences?.sharedInterests||g.sharedInterests||[],dealBreakers:g.preferences?.dealBreakers||g.dealBreakers||[],substanceUse:g.preferences?.substanceUse||g.substanceUse||["flexible"],choresResponsibility:g.preferences?.choresResponsibility||g.choresResponsibility||"shared",temperaturePreference:g.preferences?.temperaturePreference||g.temperaturePreference||"moderate",workEnvironment:g.preferences?.workEnvironment||g.w
1orkEnvironment||["flexible"],communicationStyle:g.preferences?.communicationStyle||g.communicationStyle||"moderate",sharedSpacesUsage:g.preferences?.sharedSpacesUsage||g.sharedSpacesUsage||"moderate",overnightGuests:g.preferences?.overnightGuests||g.overnightGuests||"moderate",budgetFlexibility:g.preferences?.budgetFlexibility||g.budgetFlexibility||[5],additionalPreferences:g.preferences?.additionalPreferences||g.additionalPreferences||"",dietPreference:g.preferences?.dietPreference||g.dietPreference||"omnivore",alcoholConsumption:g.preferences?.alcoholConsumption||g.alcoholConsumption||"occasionally",studyWorkHours:g.preferences?.studyWorkHours||g.studyWorkHours||["morning"],quietHours:g.preferences?.quietHours||g.quietHours||[6,22],socialEnergyLevel:g.preferences?.socialEnergyLevel||g.socialEnergyLevel||"moderate"}}).filter(g=>g!==null);r(W)}else r([])}catch{u(j("Failed to load roommate matches. Please try again.","Failed to load flatmate matches. Please try again.")),r([])}finally{f(!1)}},D=async c=>{try{if(!s?.id)return;const F=C.has(c);H(F?z=>{const ee=new Set(z);return ee.delete(c),ee}:z=>new Set([...z,c]));const W=await n();(await Oe.toggleSaveRoommate(String(c),W||void 0,s.id)).data?.saved?H(z=>new Set([...z,c])):H(z=>{const ee=new Set(z);return ee.delete(c),ee})}catch{C.has(c)?H(W=>new Set([...W,c])):H(W=>{const g=new Set(W);return g.delete(c),g})}},_=c=>{P(c),q(!0)};l.useEffect(()=>{if(!(!A||!x))try{const c=m.find(F=>String(F.id)===String(x.id));c&&JSON.stringify(c)!==JSON.stringify(x)&&P(c)}catch{}},[A,x?.id,m]);const J=async c=>{if(s?.id)try{const F=await n(),W={"Content-Type":"application/json","x-clerk-user-id":s.id};F&&(W.Authorization=`Bearer ${F}`);const g=await fetch(`${ae}/messaging/conversations`,{method:"POST",headers:W,body:JSON.stringify({otherUserId:String(c.id)})});if(!g.ok){const Me=await g.text();throw new Error(`Failed to start conversation: ${g.status} ${Me}`)}const z=await g.json(),ee=z?.data?.conversationId||z?.conversationId;if(!ee)throw new Error("Conversation ID missing from response");nt("message_roommate",String(c.id));const ue={id:String(ee),roommate:c,lastMessage:"",timestamp:"Just now",isRead:!1,messageCount:0,isOnline:!1};Y(ue),p(!0)}catch{}},$=async c=>{await J(c)},w=c=>c>=9?"Excellent":c>=8?"Very High":c>=7?"High":c>=6?"Good":c>=5?"Moderate":c>=4?"Fair":c>=3?"Low":c>=2?"Very Low":"Minimal",G=c=>c?[{key:"cleanlinessLevel",label:"Cleanliness",value:c.cleanlinessLevel?.[0]},{key:"noiseTolerance",label:"Noise",value:c.noiseTolerance?.[0]},{key:"socialInteraction",label:"Social",value:c.socialInteraction},{key:"sleepSchedule",label:"Sleep",value:c.sleepSchedule?.[0]},{key:"guestPolicy",label:"Guests",value:c.guestPolicy},{key:"cookingStyle",label:"Cooking",value:c.cookingStyle},{key:"petPreferences",label:"Pets",value:c.petPreferences},{key:"substanceUse",label:"Substances",value:c.substanceUse?.[0]},{key:"choresResponsibility",label:"Chores",value:c.choresResponsibility},{key:"temperaturePreference",label:"Temperature",value:c.temperaturePreference},{key:"workEnvironment",label:"Work",value:c.workEnvironment?.[0]},{key:"communicationStyle",label:"Communication",value:c.communicationStyle},{key:"sharedSpacesUsage",label:"Shared Spaces",value:c.sharedSpacesUsage},{key:"overnightGuests",label:"Overnight",value:c.overnightGuests},{key:"budgetFlexibility",label:"Budget Flexibility",value:c.budgetFlexibility?.[0]},{key:"dietPreference",label:"Diet",value:c.dietPreference},{key:"alcoholConsumption",label:"Alcohol",value:c.alcoholConsumption},{key:"studyWorkHours",label:"Study Hours",value:c.studyWorkHours?.[0]},{key:"quietHours",label:"Quiet Hours",value:c.quietHours?`${c.quietHours[0]}:00-${c.quietHours[1]}:00`:null},{key:"socialEnergyLevel",label:"Energy",value:c.socialEnergyLevel},{key:"additionalPreferences",label:"Additional",value:c.additionalPreferences&&c.additionalPreferences.trim()!==""?c.additionalPreferences.length>20?c.additionalPreferences.substring(0,20)+"...":c.additionalPreferences:null}].filter(W=>W.value!==void 0&&W.value!==null&&W.value!=="").slice(0,3):[],T=[...m].sort((c,F)=>{if(d==="compatibility"&&k?.query===b.trim()&&k.ids.length>0){const W=new Map(k.ids.map((ee,ue)=>
1[ee,ue])),g=W.has(String(c.id))?W.get(String(c.id)):Number.MAX_SAFE_INTEGER,z=W.has(String(F.id))?W.get(String(F.id)):Number.MAX_SAFE_INTEGER;if(g!==z)return g-z}switch(d){case"compatibility":return ya(c.compatibility??null,F.compatibility??null);case"newest":return new Date(F.createdAt||0).getTime()-new Date(c.createdAt||0).getTime();case"rating":return(F.rating||0)-(c.rating||0);case"alphabetical":return c.name.localeCompare(F.name);case"verified":return(F.verified?1:0)-(c.verified?1:0);default:return 0}}).filter(c=>c.name.toLowerCase().includes(b.toLowerCase())||c.profession.toLowerCase().includes(b.toLowerCase())||c.location.toLowerCase().includes(b.toLowerCase())||c.aboutMe.toLowerCase().includes(b.toLowerCase()));if(t)return e.jsx(he,{label:"Checking your account",className:"min-h-[400px]"});if(!a||!s?.id)return e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ke,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600 mb-4",children:j("Please sign in to view roommate matches","Please sign in to view flatmate matches")}),e.jsx(U,{variant:"outline",children:"Sign In"})]})});const M=e.jsx(ne,{icon:oe,eyebrow:j("Roommates","Flatmates"),title:j("Your roommate","Your flatmate"),accent:"matches",subtitle:"People whose habits, schedule and budget fit yours, best matches first."});if(h)return e.jsxs("div",{children:[M,e.jsx(he,{label:j("Finding roommate matches","Finding flatmate matches"),hints:["Comparing habits and schedules","Checking budgets","Almost there"],className:"min-h-[300px]"})]});if(N)return e.jsxs("div",{children:[M,e.jsx("div",{className:"flex items-center justify-center min-h-[300px]",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ts,{className:"h-12 w-12 text-red-500 mx-auto mb-4"}),e.jsx("p",{className:"text-red-600 mb-4",children:N}),e.jsx(U,{onClick:V,variant:"outline",children:"Try Again"})]})})]});if(T.length===0){const c=b||Object.values(I).some(F=>F!=="");return e.jsxs("div",{children:[M,e.jsxs("div",{className:"mx-auto flex max-w-lg flex-col items-center rounded-3xl border border-dashed border-gray-200 bg-gradient-to-b from-white to-[#f5f8fd] px-6 py-12 text-center",children:[e.jsx("span",{className:"mb-4 flex h-16 w-16 items-center justify-center rounded-2xl bg-gradient-to-br from-[#10b981] to-[#14b8a6] text-white shadow-lg",children:e.jsx(oe,{className:"h-8 w-8"})}),e.jsx("p",{className:"text-lg font-semibold text-[#0C1A2B]",children:c?"Nobody matches those filters":"Your matches will show up here"}),e.jsx("p",{className:"mt-1 text-sm text-gray-600",children:c?"Try widening your budget or location.":"Tell us how you live (sleep, cleanliness, guests, budget) and we’ll find people who fit."}),e.jsx("div",{className:"mt-6 flex flex-wrap justify-center gap-2",children:c?e.jsx(U,{onClick:()=>{i(""),O({city:"",state:"",minBudget:"",maxBudget:""})},variant:"outline",children:"Clear filters"}):e.jsxs(e.Fragment,{children:[e.jsx(U,{asChild:!0,className:"!bg-[#0C1A2B] text-white hover:!bg-[#1c3257]",children:e.jsx("a",{href:Ke("/dashboard?section=roommate-preferences"),children:"Set your preferences"})}),e.jsx(U,{asChild:!0,variant:"outline",children:e.jsx("a",{href:Ke("/roommates"),children:j("Browse roommates","Browse flatmates")})})]})})]})]})}return e.jsxs("div",{className:"space-y-6",children:[M,e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(ye,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx(ce,{placeholder:j("Search for roommates by name, profession, interests...","Search for flatmates by name, profession, interests..."),className:"pl-10 h-12 rounded-full",value:b,onChange:c=>i(c.target.value)})]}),e.jsxs(K,{value:d,onValueChange:o,children:[e.jsx(Q,{className:"w-48 h-12",children:e.jsx(Z,{})}),e.jsxs(X,{children:[e.jsx(S,{value:"compatibility",children:"Best Match"}),e.jsx(S,{value:"newest",children:"Newest First"}),e.jsx(S,{value:"rating",children:"Highest Rated"}),e.jsx(S,{value:"alphabetical",children:"A-Z"})]})]})]}),b&&e.jsx("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:e.jsxs("span",{children:["Showing ",T.length,' results for "',b,'"']})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6",children:T.map(c=>e.jsx(Vs,{roommate:c,isLiked:C.has(c.id),onLike:D,onViewDetails:_,onStartConversation:J,getTopPreferences:G},c.id))}),A&&x&&Je.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] p-4",style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9999},children:e.jsx("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:j("Roommate Profile","Flatmate Profile")}),e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>q(!1),className:"h-8 w-8 p-0",children:e.jsx(ls,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex items-start gap-6 mb-8",children:[e.jsxs(Te,{className:"h-24 w-24 ring-4 ring-gray-100",children:[e.jsx(Fe,{src:x.image,alt:x.name}),e.jsx($e,{className:"text-2xl",children:x.name.split(" ").map(c=>c[0]).join("")})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsxs("div",{className:"text-xl font-semibold text-gray-900",children:[x.name,x.age?`, ${x.age}`:"",x.gender?` · ${x.gender}`:""]}),x.verified&&e.jsxs(Ne,{className:"bg-green-100 text-green-800",children:[e.jsx(Se,{className:"h-3 w-3 mr-1"}),"Verified"]})]}),x.profession&&e.jsx("p",{className:"text-lg text-gray-600 mb-2",children:x.profession}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-500",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Fs,{className:"h-4 w-4"}),e.jsx("span",{children:x.location})]}),x.responseTime&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(fe,{className:"h-4 w-4"}),e.jsx("span",{children:x.responseTime})]})]})]})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"text-lg font-semibold text-gray-900",children:"Compatibility"}),e.jsx(Ne,{variant:"secondary",className:"text-lg px-3 py-1",children:ba(x.compatibility??null,"Match")})]}),typeof x.compatibility=="number"&&e.jsx(ps,{value:x.compatibility,className:"h-3"}),x.insights&&x.insights.length>0&&e.jsxs("div",{className:"mt-3",children:[typeof x.compatibility=="number"&&e.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Why you're a great match:"}),e.jsx("ul",{className:"space-y-1",children:x.insights.slice(0,3).map((c,F)=>e.jsxs("li",{className:"text-sm text-gray-600 flex items-start gap-2",children:[e.jsx(_e,{className:"h-3 w-3 text-yellow-500 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:c})]},F))})]}),us(x.categoryBreakdown,5).length>0&&e.jsxs("div",{className:"mt-4 space-y-2.5",children:[e.jsx("p",{className:"text-sm text-gray-600",children:"By category (preferences you both answered):"}),us(x.categoryBreakdown,5).map(c=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-gray-900",children:c.label}),e.jsxs("span",{className:"text-gray-600 tabular-nums",children:[c.score,"%"]})]}),e.jsx(ps,{value:c.score,className:"h-1.5 mt-1"})]},c.key))]})]}),e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"text-lg font-semibold text-gray-900 mb-3",children:"About"}),e.jsx("p",{className:"text-gray-600 leading-relaxed",children:x.aboutMe})]}),x.preferences&&e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"text-lg font-semibold text-gray-900 mb-3",children:"Preferences"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:"Cleanliness Level"}),e.jsxs("span",{className:"text-xs font-semibold text-gray-600",children:[x.preferences.cleanlinessLevel?.[0]||5,"/10"]})]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2.5 mb-2",children:e.jsx("div",{className:"h-2.5 rounded-full transition-all duration-300 shadow-sm",style:{width:`${(x.preferences.cleanlinessLevel?.[0]||5)/10*100}%`,backgroundColor:(x.preferences.cleanlinessLevel?.[0]||5)>=8?"#0f172a":(x.preferences.cleanlinessLevel?.[0]||5)>=6?"#1e293b":(x.preferences.cleanlinessLevel?.[0]||5)>=4?"#334155":"#475569"}})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-slate-700",children:w(x.preferences.cleanlinessLevel?.[0]||5)}),e.jsx("div",{className:"flex items-center gap-0.5",children:[...Array(10)].map((c,F)=>e.jsx("div",{className:`h-2 w-2 rounded-full transition-all duration-200 ${F<(x.preferences.cleanlinessLevel?.[0]||5)?"bg-slate-800 shadow-sm":"bg-gray-300"}`},F))})]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:"Noise Tolerance"}),e.jsxs("span",{className:"text-xs font-semibold text-gray-600",children:[x.preferences.noiseTolerance?.[0]||5,"/10"]})]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2.5 mb-2",children:e.jsx("div",{className:"h-2.5 rounded-full transition-all duration-300 shadow-sm",style:{width:`${(x.preferences.noiseTolerance?.[0]||5)/10*100}%`,backgroundColor:(x.preferences.noiseTolerance?.[0]||5)>=8?"#0f172a":(x.preferences.noiseTolerance?.[0]||5)>=6?"#1e293b":(x.preferences.noiseTolerance?.[0]||5)>=4?"#334155":"#475569"}})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-slate-700",children:w(x.preferences.noiseTolerance?.[0]||5)}),e.jsx("div",{className:"flex items-center gap-0.5",children:[...Array(10)].map((c,F)=>e.jsx("div",{className:`h-2 w-2 rounded-full transition-all duration-200 ${F<(x.preferences.noiseTolerance?.[0]||5)?"bg-slate-800 shadow-sm":"bg-gray-300"}`},F))})]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:"Social Interaction"}),e.jsx("span",{className:"text-xs font-semibold text-gray-600 capitalize",children:x.preferences.socialInteraction})]}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Preference: ",x.preferences.socialInteraction]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:"Guest Policy"}),e.jsx("span",{className:"text-xs font-semibold text-gray-600 capitalize",children:x.preferences.guestPolicy})]}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Preference: ",x.preferences.guestPolicy]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:"Sleep Schedule"}),e.jsx("span",{className:"text-xs font-semibold text-gray-600 capitalize",children:x.preferences.sleepSchedule?.[0]})]}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Preference: ",x.preferences.sleepSchedule?.[0]]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:"Pet Preferences"}),e.jsx("span",{className:"text-xs font-semibold text-gray-600 capitalize",children:x.preferences.petPreferences})]}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Preference: ",x.preferences.petPreferences]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:"Cooking Style"}),e.jsx("span",{className:"text-xs font-semibold text-gray-600 capitalize",children:x.preferences.cookingStyle})]}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Preference: ",x.preferences.cookingStyle]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:"Budget Flexibility"}),e.jsxs("span",{className:"text-xs font-semibold text-gray-600",children:[x.preferences.budgetFlexibility?.[0]||5,"/10"]})]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2.5 mb-2",children:e.jsx("div",{className:"h-2.5 rounded-full transition-all duration-300 shadow-sm",style:{width:`${(x.preferences.budgetFlexibility?.[0]||5)/10*100}%`,backgroundColor:(x.preferences.budgetFlexibility?.[0]||5)>=8?"#0f172a":(x.preferences.budgetFlexibility?.[0]||5)>=6?"#1e293b":(x.preferences.budgetFlexibility?.[0]||5)>=4?"#334155":"#475569"}})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-slate-700",children:w(x.preferences.budgetFlexibility?.[0]||5)}),e.jsx("div",{className:"flex items-center gap-0.5",children:[...Array(10)].map((c,F)=>e.jsx("div",{className:`h-2 w-2 rounded-full transition-all duration-200 ${F<(x.preferences.budgetFlexibility?.[0]||5)?"bg-slate-800 shadow-sm":"bg-gray-300"}`},F))})]})]})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t",children:[e.jsxs(U,{onClick:()=>{q(!1),$(x)},className:"flex-1 text-white !bg-[#0C1A2B] !text-[#FFFFFF]",children:[e.jsx(le,{className:"h-4 w-4 mr-2 !text-[#FFFFFF]"}),"Start Conversation"]}),e.jsxs(U,{variant:"outline",onClick:()=>D(x.id),className:"flex-1",children:[e.jsx(pe,{className:`h-4 w-4 mr-2 ${C.has(x.id)?"fill-current":""}`}),C.has(x.id)?"Unsave":"Save"]})]})]})})}),document.body),re&&E&&Je.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999]",style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9999},children:e.jsx("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-4xl h-[80vh] max-h-[600px] flex flex-col",children:e.jsx(ks,{conversation:E,suggestionContext:wa(E.roommate),onClose:()=>p(!1),onPresenceChange:c=>{Y(F=>F&&{...F,roommate:{...F.roommate,isOnline:c},isOnline:c})}})})}),document.body)]})}const qs="inline-flex items-center gap-1.5 rounded-full border border-gray-200 bg-white px-4 py-2 text-sm font-semibold text-[#0C1A2B] shadow-sm transition hover:-translate-y-0.5 hover:border-[#84A9FF] hover:shadow-md disabled:opacity-60 dark:border-white/15 dark:bg-white/5 dark:text-white",Ja="inline-flex items-center gap-2 rounded-full bg-[#0C1A2B] px-5 py-2.5 text-sm font-semibold text-white shadow-md transition hover:-translate-y-0.5 hover:bg-[#1c3257] hover:shadow-lg disabled:opacity-70";function Ka(s){return s.status==="past_due"?{text:"Payment failed",tone:"bg-red-100 text-red-700"}:s.active?s.cancelAtPeriodEnd?{text:`Ends ${je(s.currentPeriodEnd)}`,tone:"bg-amber-100 text-amber-800"}:{text:"Active",tone:"bg-emerald-100 text-emerald-700"}:{text:"Ended",tone:"bg-gray-100 text-gray-600"}}function vs({sub:s,icon:a,busy:t,onCancel:n,onResume:m,onUpdateCard:r,extra:h}){const f=Ka(s),N=s.billingCycle==="year"?"year":"month";return e.jsxs("section",{className:"rounded-2xl border border-gray-200 bg-white p-5 sm:p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-[#EEF3FF
1] text-[#3A5A8C]",children:a}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-[#0C1A2B]",children:s.name}),e.jsx("span",{className:`rounded-full px-2.5 py-0.5 text-xs font-semibold ${f.tone}`,children:f.text})]}),e.jsxs("p",{className:"text-sm text-gray-600",children:[Xe(s.amountCents),"/",N,s.plan==="leasing"&&s.paidHomes?` · ${s.paidHomes} paid home${s.paidHomes===1?"":"s"} (your first home is free)`:""]})]})]}),s.status==="past_due"&&e.jsxs("div",{role:"alert",className:"mt-4 flex flex-wrap items-center gap-3 rounded-xl border border-red-200 bg-red-50 p-3 text-sm text-red-800",children:[e.jsx(Ee,{className:"h-4 w-4 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:["We couldn't charge your card for the renewal.",s.nextRetryAt?` We'll try again on ${je(s.nextRetryAt)}.`:""," Update your card to keep your plan."]}),e.jsx("button",{type:"button",onClick:r,className:"rounded-full bg-red-600 px-4 py-1.5 font-semibold text-white hover:bg-red-700",children:"Update card"})]}),s.active&&e.jsx("p",{className:"mt-4 text-sm text-gray-700",children:s.cancelAtPeriodEnd?`Your plan won't renew. You keep everything until ${je(s.currentPeriodEnd)}.`:s.status==="past_due"?"Your access continues while we retry the payment.":`Renews on ${je(s.currentPeriodEnd)} for ${Xe(s.amountCents)}.`}),!s.active&&s.currentPeriodEnd&&e.jsxs("p",{className:"mt-4 text-sm text-gray-600",children:["Ended on ",je(s.currentPeriodEnd),"."]}),s.features&&s.active&&e.jsx("ul",{className:"mt-4 grid gap-1.5 text-sm text-gray-700 sm:grid-cols-2",children:s.features.map(u=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(os,{className:"mt-0.5 h-4 w-4 shrink-0 text-emerald-600"})," ",u]},u))}),e.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[h,s.active&&s.inHouse&&s.cancelAtPeriodEnd&&e.jsxs("button",{type:"button",onClick:m,disabled:t,className:"inline-flex items-center gap-2 rounded-full bg-[#0C1A2B] px-4 py-2 text-sm font-semibold text-white hover:bg-[#1a2942] disabled:opacity-60",children:[t&&e.jsx(ie,{className:"h-4 w-4 animate-spin"})," Keep my plan"]}),s.active&&!s.cancelAtPeriodEnd&&e.jsx("button",{type:"button",onClick:n,disabled:t,className:"rounded-full px-4 py-2 text-sm font-semibold text-gray-600 hover:bg-gray-100 disabled:opacity-60",children:"Cancel plan"})]})]})}function Qa(){return l.useEffect(()=>{const s=ct("year",Ge.year);ot("view_cart",{currency:"USD",value:s.price,items:[s]})},[]),e.jsxs("section",{className:"rounded-2xl border border-[#84A9FF]/40 bg-gradient-to-br from-[#EEF3FF] to-white p-5 sm:p-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ze,{className:"h-5 w-5 text-[#3A5A8C]"}),e.jsx("h3",{className:"text-lg font-semibold text-[#0C1A2B]",children:"You're on the free plan"})]}),e.jsx("p",{className:"mt-1 text-sm text-gray-600",children:"Premium gives you unlimited AI search, unlimited roommate connections, priority matching and priority support."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(de,{to:ys("year"),className:"rounded-full bg-[#0C1A2B] px-5 py-2.5 text-sm font-semibold text-white hover:bg-[#1a2942]",children:["Yearly · $",Ge.year," ",e.jsx("span",{className:"font-normal text-white/70",children:"(save 17%)"})]}),e.jsxs(de,{to:ys("month"),className:"rounded-full border border-gray-200 bg-white px-5 py-2.5 text-sm font-semibold text-[#0C1A2B] hover:bg-gray-50",children:["Monthly · $",Ge.month]})]})]})}function Za({open:s,config:a,onClose:t,onSaved:n}){const m=Hs(),{user:r}=ge(),h=l.useRef(null),[f,N]=l.useState(!1),[u,b]=l.useState(!1),[i,d]=l.useState(""),o=async()=>{b(!0),d("");try{const k=await h.current.tokenize({amountCents:0,intent:"STORE",contact:{givenName:r?.firstName,familyName:r?.lastName,email:r?.primaryEmailAddress?.emailAddress}}),R=await m.saveCard(k);n(R.card,R.retried)}catch(k){d(k instanceof Error?k.message:"Couldn't save your card.")}finally{b(!1)}};return e.jsx(es,{open:s,onOpenChange:k=>!k&&t(),children:e.jsxs(ss,{className:"sm:max-w-md",children:[e.jsxs(ts,{children:[e.jsx(as,{children:"Update your card"}),e.jsx(rs,{children:"Your plans renew on this card. An overdue renewal is retried on it straight away."})]}),a?.enabled?e.jsx(Sa,{ref:h,config:a,onReady:N}):e.jsx("p",{className:"text-sm text-amber-800",children:"Card payments are being set up. Please try again soon."}),i&&e.jsx("p",{role:"alert",className:"rounded-xl border border-red-200 bg-red-50 p-3 text-sm text-red-700",children:i}),e.jsxs("button",{type:"button",onClick:o,disabled:!f||u,className:"flex h-11 w-full items-center justify-center gap-2 rounded-full bg-[#0C1A2B] font-semibold text-white disabled:opacity-50",children:[u&&e.jsx(ie,{className:"h-4 w-4 animate-spin"})," Save card"]})]})})}const Xa={succeeded:"Paid",refunded:"Refunded",failed:"Failed"};function er(){return lt&&we()!=="in"?e.jsx(sr,{}):e.jsxs("div",{className:"mx-auto max-w-3xl space-y-4 p-4 sm:p-6",children:[e.jsx(ne,{icon:_e,title:"Your",accent:"plan",subtitle:"Every Snestico feature is free right now. There's nothing to buy and nothing will start charging you."}),e.jsxs("div",{className:"rounded-2xl border border-emerald-200 bg-emerald-50 p-5 text-emerald-900",children:[e.jsx("p",{className:"font-semibold",children:"Free plan: everything included"}),e.jsx("p",{className:"mt-1 text-sm",children:j("Unlimited AI search, roommate matching, the home-hunting agent, Snesty on WhatsApp and text, and the leasing assistant for landlords.","Unlimited AI search for flats and PGs, flatmate matching, free messaging and video calls with flatmates, sellers and owners, the home-hunting agent, Snesty on WhatsApp, and the leasing assistant for owners. Free in India.")})]})]})}function sr(){const s=Hs(),[a,t]=l.useState(null),[n,m]=l.useState(null),[r,h]=l.useState(""),[f,N]=l.useState(!1),[u,b]=l.useState(null),[i,d]=l.useState(null),[o,k]=l.useState(!1),R=l.useCallback(async()=>{try{const[P,A,q]=await Promise.all([s.subscription("premium"),s.subscription("leasing"),s.payments()]);t({premium:P.subscription,leasing:A.subscription,card:P.card,payments:q}),h("")}catch(P){h(P instanceof Error?P.message:"Couldn't load your plan.")}},[s]);l.useEffect(()=>{R(),s.config().then(m).catch(()=>m(null))},[R,s]);const C=async()=>{N(!0),await R(),N(!1)},H=async P=>{b(P.plan);try{await s.cancel(P.plan),L.success(`Your plan won't renew. You keep it until ${je(P.currentPeriodEnd)}.`),d(null),await R()}catch(A){L.error(A instanceof Error?A.message:"Couldn't cancel.")}finally{b(null)}},I=async P=>{b(P);try{await s.resume(P),L.success("Your plan will keep renewing."),await R()}catch(A){L.error(A instanceof Error?A.message:"Couldn't resume.")}finally{b(null)}},O=e.jsx(ne,{icon:Ze,eyebrow:"Account",title:"Plan &",accent:"billing",subt
1itle:"Your Snestico plan, your card and your receipts.",actions:e.jsxs("button",{type:"button",onClick:C,disabled:f,className:qs,children:[e.jsx(Ls,{className:`h-4 w-4 ${f?"animate-spin":""}`})," Refresh"]})});if(!a)return e.jsxs("div",{className:"space-y-6",children:[O,r?e.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white p-6 text-center",children:[e.jsx("p",{className:"font-semibold text-[#0C1A2B]",children:r}),e.jsx("button",{type:"button",onClick:C,className:"mt-3 rounded-full bg-[#0C1A2B] px-5 py-2 text-sm font-semibold text-white",children:"Try again"})]}):e.jsx(he,{label:"Loading your plan",size:"md",className:"min-h-[30vh]"})]});const x=a.premium?.active;return e.jsxs("div",{className:"space-y-6",children:[O,x?e.jsx(vs,{sub:a.premium,icon:e.jsx(Ze,{className:"h-5 w-5"}),busy:u==="premium",onCancel:()=>d(a.premium),onResume:()=>I("premium"),onUpdateCard:()=>k(!0)}):e.jsx(Qa,{}),a.leasing&&e.jsx(vs,{sub:a.leasing,icon:e.jsx(qe,{className:"h-5 w-5"}),busy:u==="leasing",onCancel:()=>d(a.leasing),onResume:()=>I("leasing"),onUpdateCard:()=>k(!0),extra:e.jsx(de,{to:"/landlord?tab=homes",className:"rounded-full border border-gray-200 bg-white px-4 py-2 text-sm font-semibold text-[#0C1A2B] hover:bg-gray-50",children:"Manage homes"})}),e.jsxs("section",{className:"flex flex-wrap items-center gap-3 rounded-2xl border border-gray-200 bg-white p-5",children:[e.jsx("span",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-gray-100 text-gray-600",children:e.jsx($s,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-semibold text-[#0C1A2B]",children:a.card?ka(a.card):"No card on file"}),e.jsxs("p",{className:"text-sm text-gray-500",children:[a.card?.expMonth?`Expires ${String(a.card.expMonth).padStart(2,"0")}/${a.card.expYear}. `:"","Renewals are charged to this card. Stored securely by Square."]})]}),e.jsx("button",{type:"button",onClick:()=>k(!0),className:"rounded-full border border-gray-200 px-4 py-2 text-sm font-semibold text-[#0C1A2B] hover:bg-gray-50",children:a.card?"Update card":"Add a card"})]}),e.jsxs("section",{className:"rounded-2xl border border-gray-200 bg-white p-5",children:[e.jsxs("h3",{className:"flex items-center gap-2 font-semibold text-[#0C1A2B]",children:[e.jsx(Mt,{className:"h-5 w-5 text-[#3A5A8C]"})," Payments and receipts"]}),a.payments.length===0?e.jsx("p",{className:"mt-3 text-sm text-gray-500",children:"No payments yet."}):e.jsx("ul",{className:"mt-3 divide-y divide-gray-100",children:a.payments.map(P=>e.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 py-3 text-sm",children:[e.jsx("span",{className:"w-28 shrink-0 text-gray-500",children:new Date(P.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx("span",{className:"min-w-0 flex-1 text-[#0C1A2B]",children:P.description}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-semibold ${P.status==="succeeded"?"bg-emerald-50 text-emerald-700":P.status==="failed"?"bg-red-50 text-red-700":"bg-gray-100 text-gray-600"}`,children:Xa[P.status]||P.status}),e.jsx("span",{className:"w-20 text-right font-medium text-[#0C1A2B]",children:Xe(P.amountCents,P.currency)}),e.jsx(de,{to:`/billing/receipt/${P.id}`,className:"font-semibold text-[#3A5A8C] hover:underline",children:"Receipt"})]},P.id))}),e.jsx("p",{className:"mt-3 text-xs text-gray-500",children:"Questions about a charge? Write to [email protected] with the receipt number."})]}),e.jsx(es,{open:!!i,onOpenChange:P=>!P&&d(null),children:e.jsxs(ss,{className:"sm:max-w-md",children:[e.jsxs(ts,{children:[e.jsxs(as,{children:["Cancel ",i?.name,"?"]}),e.jsxs(rs,{children:["It won't renew, and you keep everything until ",je(i?.currentPeriodEnd),". You can change your mind any time before then."]})]}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>d(null),className:"rounded-full px-4 py-2 text-sm font-semibold text-gray-600 hover:bg-gray-100",children:"Keep my plan"}),e.jsxs("button",{type:"button",onClick:()=>i&&H(i),disabled:!!u,className:"inline-flex items-center gap-2 rounded-full bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-700 disabled:opacity-60",children:[u&&e.jsx(ie,{className:"h-4 w-4 animate-spin"})," Cancel plan"]})]})]})}),e.jsx(Za,{open:o,config:n,onClose:()=>k(!1),onSaved:(P,A)=>{k(!1),t(q=>q&&{...q,card:P}
1),A.includes("renewed")?L.success("Card saved, and your renewal went through."):A.includes("failed")?L.error("Card saved, but the renewal was declined. Try another card."):L.success("Card saved."),R()}})]})}const tr=[{id:"daily",title:"Once a day",text:"One morning email with up to 10 new homes from all your saved searches. Nothing new, no email."},{id:"instant",title:"Right away",text:"An email for each saved search as soon as new homes match it."}];function ar({disabled:s=!1}){const[a,t]=l.useState(null);if(l.useEffect(()=>{Ve("/saved-searches/email-mode").then(m=>t(m?.data?.mode==="instant"?"instant":"daily")).catch(()=>t(null))},[]),!a)return null;const n=async m=>{if(m===a)return;const r=a;t(m);try{await Ve("/saved-searches/email-mode",{method:"PUT",body:JSON.stringify({mode:m})}),L.success("Saved")}catch{t(r),L.error("Couldn't save that. Please try again.")}};return e.jsx("div",{className:`rounded-2xl border border-gray-200 bg-white p-5 dark:border-white/10 dark:bg-white/5 ${s?"opacity-60":""}`,children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(ye,{className:"mt-0.5 h-5 w-5 shrink-0 text-gray-500"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-[#0C1A2B] dark:text-white",children:"New homes for your saved searches"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"How you'd like the emails about new listings."}),e.jsx("div",{role:"radiogroup","aria-label":"Saved-search emails",className:"mt-3 grid gap-2 sm:grid-cols-2",children:tr.map(m=>e.jsxs("button",{type:"button",role:"radio","aria-checked":a===m.id,disabled:s,onClick:()=>n(m.id),className:`rounded-xl border px-3.5 py-3 text-left transition disabled:cursor-not-allowed ${a===m.id?"border-[#0C1A2B] bg-[#EEF3FF] dark:border-[#84A9FF] dark:bg-white/10":"border-gray-200 hover:border-[#3A5A8C]/50 dark:border-white/10"}`,children:[e.jsx("span",{className:"block text-sm font-semibold text-[#0C1A2B] dark:text-white",children:m.title}),e.jsx("span",{className:"mt-0.5 block text-xs text-gray-600 dark:text-gray-300",children:m.text})]},m.id))})]})]})})}function Be({checked:s,onChange:a,label:t,disabled:n}){return e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":t,disabled:n,onClick:()=>a(!s),className:"group relative inline-flex h-11 w-14 shrink-0 items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-[#84A9FF] disabled:cursor-not-allowed disabled:opacity-50",children:e.jsx("span",{className:`relative inline-flex h-7 w-12 items-center rounded-full transition-colors ${s?"bg-[#0C1A2B] dark:bg-[#84A9FF]":"bg-gray-300 dark:bg-white/20"}`,children:e.jsx("span",{className:`absolute left-0.5 h-6 w-6 rounded-full bg-white shadow transition-transform ${s?"translate-x-5":"translate-x-0"}`})})})}const rr=[{key:"messages",icon:le,title:"Messages and calls",text:"New messages, group messages and missed video calls."},{key:"newMatches",icon:oe,title:j("Roommate matches","Flatmate matches"),text:"When you and someone else are a mutual match."},{key:"events",icon:pe,title:"Community",text:"Comments, likes, new followers and events."}];function ir(){const[s,a]=l.useState(null),[t,n]=l.useState(!1);l.useEffect(()=>{Ve("/notifications/email-settings").then(r=>a(r.data)).catch(()=>n(!0))},[]);const m=async(r,h)=>{if(!s)return;const f=s;a({...s,[r]:h});try{const N=await Ve("/notifications/email-settings",{method:"PUT",body:JSON.stringify({[r]:h})});a(N.data),L.success("Saved")}catch{a(f),L.error("Couldn't save that. Please try again.")}};return e.jsxs("div",{children:[e.jsx(ne,{icon:Ms,eyebrow:"Account",title:"Email",accent:"notifications",subtitle:"Choose which of your Snestico notifications also come to your inbox or as alerts on your devices."}),t&&e.jsx("p",{className:"rounded-2xl border border-red-200 bg-red-50 p-4 text-sm text-red-700",children:"We couldn't load your email settings. Please refresh the page."}),!s&&!t&&e.jsx(he,{label:"Loading your settings",className:"py-16"}),s&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 roun
1ded-2xl border border-gray-200 bg-white p-5 dark:border-white/10 dark:bg-white/5",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-[#EEF3FF] text-[#3A5A8C]",children:e.jsx(Dt,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-[#0C1A2B] dark:text-white",children:"Email me my notifications"}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:[s.address?e.jsxs(e.Fragment,{children:["Sent to ",e.jsx("span",{className:"font-medium",children:s.address}),". "]}):null,"Messages, matches, new homes and reminders, even if you saw them on the site; likes and comments only if you haven't. At most one email every 10 minutes."]})]})]}),e.jsx(Be,{checked:s.email,onChange:r=>m("email",r),label:"Email me my notifications"})]}),e.jsx("div",{className:`divide-y divide-gray-100 rounded-2xl border border-gray-200 bg-white dark:divide-white/10 dark:border-white/10 dark:bg-white/5 ${s.email?"":"opacity-60"}`,children:rr.map(({key:r,icon:h,title:f,text:N})=>e.jsxs("div",{className:"flex items-start justify-between gap-4 p-5",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(h,{className:"mt-0.5 h-5 w-5 shrink-0 text-gray-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-[#0C1A2B] dark:text-white",children:f}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:N})]})]}),e.jsx(Be,{checked:s[r],disabled:!s.email,onChange:u=>m(r,u),label:f})]},r))}),e.jsxs("div",{className:`flex items-start justify-between gap-4 rounded-2xl border border-gray-200 bg-white p-5 dark:border-white/10 dark:bg-white/5 ${s.email?"":"opacity-60"}`,children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(It,{className:"mt-0.5 h-5 w-5 shrink-0 text-gray-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-[#0C1A2B] dark:text-white",children:"News and updates from Snestico"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Once in a while: new cities, new features and offers. Off unless you turn it on."})]})]}),e.jsx(Be,{checked:!!s.marketing,disabled:!s.email,onChange:r=>m("marketing",r),label:"News and updates from Snestico"})]}),e.jsx("h2",{className:"pt-4 text-lg font-semibold text-[#0C1A2B] dark:text-white",children:"Alerts on your devices"}),e.jsx(dt,{variant:"settings",onEnabled:()=>{s.push===!1&&m("push",!0)}}),e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-2xl border border-gray-200 bg-white p-5 dark:border-white/10 dark:bg-white/5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-[#0C1A2B] dark:text-white",children:"Send alerts to my devices"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Turn this off to pause alerts on every phone and computer where you turned them on."})]}),e.jsx(Be,{checked:s.push!==!1,onChange:r=>m("push",r),label:"Send alerts to my devices"})]}),e.jsx(ar,{disabled:!s.email}),e.jsx("p",{className:"text-sm text-gray-500",children:"Receipts and payment emails always come through. Saved-search alerts and your home-hunting agent have their own email switches on their pages."})]})]})}const nr=s=>s?new Date(s).toISOString():null,lr=s=>new Date(s.getTime()-s.getTimezoneOffset()*6e4).toISOString().slice(0,16),We=s=>new Date(s).toLocaleString(Le().locale,{weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function or(){const s=Aa(),[a,t]=l.useState(null),[n,m]=l.useState(""),[r,h]=l.useState("task"),[f,N]=l.useState(""),[u,b]=l.useState(""),[i,d]=l.useState(!1),[o,k]=l.useState(!1),R=Pa("item","task-",!!a),C=l.useRef("");l.useEffect(()=>{!R||!a||C.current===R||(C.current=R,a.some(p=>p.id===R&&p.doneAt)&&k(!0))},[R,a]);const H=l.useCallback(()=>{s.items().then(t).catch(p=>m(p.message||"Couldn't load your tasks."))},[s]);l.useEffect(H,[H]);const I=async p=>{if(p.preventDefault(),r==="reminder"&&!u)return L.error("Pick when to remind you.");d(!0);try{const E=nr(u),Y=await s.addItem({kind:r,text:f,dueAt:E,remindAt:r==="reminder"?E:null});t(v=>[Y,...v||[]]),N(""),b(""),L.success(r==="reminder"?`Reminder set for ${We(Y.remindAt)}.`:"Task added.")}catch(E){L.error(E instanceof Error?E.message:"Couldn't add it.")}finally{d(!1)}},O=async p=>{try{const E=await s.updateItem(p.id,{done:!p.doneAt});t(Y=>(Y||[]).map(v=>v.id===p.id?E:v))}catch(E){L.error(E instanceof Error?E.message:"Couldn't save.")}},x=async p=>{try{await s.deleteItem(p.id),t(E=>(E||[]).filter(Y=>Y.id!==p.id))}catch(E){L.error(E instanceof Error?E.message:"Couldn't delete.")}},P=(a||[]).filter(p=>!p.doneAt),A=(a||[]).filter(p=>p.doneAt),q=o?[...P,...A]:P,re=lr(new Date(Date.now()+6e4));return e.jsxs("section",{className:"rounded-2xl border border-gray-200 bg-white p-5",children:[e.jsxs("h3",{className:"flex items-center gap-2 font-semibold text-[#0C1A2B]",children:[e.jsx(Ds,{className:"h-5 w-5 text-[#3A5A8C]"})," Tasks and reminders"]}),e.jsx("p",{className:"mt-1 text-sm text-gray-600",children:"Add them here, or just tell Snesty on WhatsApp or text, like “remind me to send the deposit Friday at 10am”."}),e.jsxs("form",{onSubmit:I,className:"mt-4 flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("div",{role:"radiogroup","aria-label":"Type",className:"flex shrink-0 rounded-full border border-gray-200 p-0.5",children:["task","reminder"].map(p=>e.jsx("button",{type:"button",role:"radio","aria-checked":r===p,onClick:()=>h(p),className:`rounded-full px-3 py-1.5 text-sm font-medium ${r===p?"bg-[#0C1A2B] text-white":"text-gray-600"}`,children:p==="task"?"Task":"Reminder"},p))}),e.jsx("input",{value:f,onChange:p=>N(p.target.value),maxLength:500,placeholder:r==="task"?j("e.g. Get renter
1s insurance","e.g. Get the rent agreement registered"):j("e.g. Call the landlord about 12 Oak St","e.g. Call the owner about the 2 BHK in HSR Layout"),"aria-label":r==="task"?"Task":"Reminder",className:"h-11 min-w-0 flex-1 rounded-xl border border-gray-200 px-3 text-sm outline-none focus:border-[#3A5A8C]",required:!0}),e.jsx("input",{type:"datetime-local",value:u,min:re,onChange:p=>b(p.target.value),"aria-label":r==="task"?"Due (optional)":"Remind me at",className:"h-11 rounded-xl border border-gray-200 px-3 text-sm outline-none focus:border-[#3A5A8C]",required:r==="reminder"}),e.jsxs("button",{type:"submit",disabled:i||!f.trim(),className:"inline-flex h-11 items-center justify-center gap-1.5 rounded-xl bg-[#0C1A2B] px-4 text-sm font-semibold text-white disabled:opacity-50",children:[i?e.jsx(ie,{className:"h-4 w-4 animate-spin"}):e.jsx(Bt,{className:"h-4 w-4"})," Add"]})]}),n?e.jsx("p",{role:"alert",className:"mt-4 text-sm text-red-600",children:n}):a?q.length===0?e.jsx("p",{className:"mt-4 text-sm text-gray-500",children:"Nothing here yet."}):e.jsx("ul",{className:"mt-4 divide-y divide-gray-100",children:q.map(p=>e.jsxs("li",{id:`task-${p.id}`,className:"flex items-center gap-3 py-2.5",children:[e.jsx("button",{type:"button",onClick:()=>O(p),"aria-label":p.doneAt?`Mark "${p.text}" not done`:`Mark "${p.text}" done`,className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full border ${p.doneAt?"border-emerald-500 bg-emerald-500 text-white":"border-gray-300 hover:border-[#3A5A8C]"}`,children:p.doneAt&&e.jsx(os,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:`text-sm ${p.doneAt?"text-gray-400 line-through":"text-[#0C1A2B]"}`,children:p.text}),e.jsxs("p",{className:"flex flex-wrap items-center gap-x-3 text-xs text-gray-500",children:[p.kind==="reminder"&&p.remindAt&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Ut,{className:"h-3.5 w-3.5"})," ",p.remindedAt?"Reminded":"Reminds"," ",We(p.remindAt)]}),p.kind==="task"&&p.dueAt&&e.jsxs("span",{children:["Due ",We(p.dueAt)]}),p.source==="phone"&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Ot,{className:"h-3.5 w-3.5"})," From your phone"]})]})]}),e.jsx("button",{type:"button",onClick:()=>x(p),"aria-label":`Delete "${p.text}"`,className:"rounded-full p-1.5 text-gray-400 hover:bg-gray-100 hover:text-red-600",children:e.jsx(Ae,{className:"h-4 w-4"})})]},p.id))}):e.jsx("div",{className:"mt-4 h-20 animate-pulse rounded-xl bg-gray-100"}),A.length>0&&e.jsx("button",{type:"button",onClick:()=>k(p=>!p),className:"mt-2 text-sm font-medium text-[#3A5A8C] hover:underline",children:o?"Hide done":`Show done (${A.length})`})]})}function cr(){return e.jsxs("div",{className:"space-y-6",children:[e.jsx(ne,{icon:Is,eyebrow:"Assistant",title:"Snesty &",accent:"reminders",subtitle:"Chat with Snesty on WhatsApp or text: homes, alerts, tasks and reminders, and a call when you'd rather talk.",actions:e.jsx(de,{to:"/snesty",className:qs,children:"How it works"})}),e.jsx(Ca,{}),e.jsx(or,{})]})}const dr=({user:s})=>{const[a,t]=l.useState(null),[n,m]=l.useState([]),[r,h]=l.useState(!0),{getToken:f}=ge();l.useEffect(()=>{N()},[s]);const N=async()=>{if(s)try{const u=await f(),[b,i]=await Promise.all([fetch(`${ae}/users/dashboard/stats`,{headers:{Authorization:`Bearer ${u}`,"Content-Type":"application/json"}}),fetch(`${ae}/users/dashboard/activity`,{headers:{Authorization:`Bearer ${u}`,"Content-Type":"application/json"}})]);if(b.ok){const d=await b.json();t({totalViews:d.data?.propertyViews||0,thisMonthViews:d.data?.propertyViews||0,lastMonthViews:0,topPlatforms:[{platform:j("Zillow","99acres"),count:Math.floor((d.data?.propertyViews||0)*.6)},{platform:j("Apartments.com","MagicBricks"),count:Math.floor((d.data?.propertyViews||0)*.3)},{platform:j("Rent.com","Housing.com"),count:Math.floor((d.data?.propertyViews||0)*.1)}],recentSearches:j(["Downtown Philadelphia","University City","Rittenhouse Square"],["Koramangala","HSR Layout","Indiranagar"])})}if(i.ok){const o=(await i.json()).data?.filter(k=>k.type==="property_view"||k.type==="search")||[];m(o)}}catch{}finally{h(!1)}};return r?e.jsx("div",{className:"space-y-6",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[1,2,3].map(u=>e.jsx(se,{className:"animate-pulse",children:e.jsxs(te,{className:"p-6",children:[e.jsx("div",{className:"h-4 bg-gray-200 rounded w-3/4 mb-2"}),e.jsx("div",{className:"h-8 bg-gray-200 rounded w-1/2 mb-2"}),e.jsx("div",{className:"h-3 bg-gray-200 rounded w-1/4"})]})},u))})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsx(se,{children:e.jsxs(te,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"p-3 rounded-full bg-purple-100",children:e.jsx(Pe,{className:"h-6 w-6 text-purple-600"})}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(Bs,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-xs text-green-600 font-medium",children:(a?.thisMonthViews??0)>
10?`+${Math.min((a?.thisMonthViews??0)*10,100)}%`:"+0%"})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 mb-1",children:"Total Views"}),e.jsx("p",{className:"text-3xl font-bold text-gray-900 mb-1",children:a?.totalViews||0}),e.jsx("p",{className:"text-xs text-gray-500",children:"all time"})]})]})}),e.jsx(se,{children:e.jsxs(te,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx("div",{className:"p-3 rounded-full bg-blue-100",children:e.jsx(Es,{className:"h-6 w-6 text-blue-600"})})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 mb-1",children:"This Month"}),e.jsx("p",{className:"text-3xl font-bold text-gray-900 mb-1",children:a?.thisMonthViews||0}),e.jsx("p",{className:"text-xs text-gray-500",children:"property views"})]})]})}),e.jsx(se,{children:e.jsxs(te,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx("div",{className:"p-3 rounded-full bg-green-100",children:e.jsx(Vt,{className:"h-6 w-6 text-green-600"})})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 mb-1",children:"Top Platform"}),e.jsx("p",{className:"text-3xl font-bold text-gray-900 mb-1",children:a?.topPlatforms?.[0]?.platform||"N/A"}),e.jsxs("p",{className:"text-xs text-gray-500",children:[a?.topPlatforms?.[0]?.count||0," views"]})]})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(se,{children:[e.jsxs(me,{children:[e.jsxs(xe,{className:"flex items-center space-x-2",children:[e.jsx(Ht,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{children:"Platform Usage"})]}),e.jsx(ve,{children:"Where you've been browsing properties"})]}),e.jsx(te,{children:e.jsx("div",{className:"space-y-4",children:a?.topPlatforms?.map((u,b)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:`w-3 h-3 rounded-full ${b===0?"bg-blue-500":b===1?"bg-green-500":"bg-purple-500"}`}),e.jsx("span",{className:"text-sm font-medium text-gray-700",children:u.platform})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("span",{className:"text-sm text-gray-600",children:u.count}),e.jsxs(Ne,{variant:"secondary",className:"text-xs",children:[a?.totalViews>0?Math.round(u.count/a.totalViews*100):0,"%"]})]})]},u.platform))})})]}),e.jsxs(se,{children:[e.jsxs(me,{children:[e.jsxs(xe,{className:"flex items-center space-x-2",children:[e.jsx(ye,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{children:"Recent Searches"})]}),e.jsx(ve,{children:"Your latest property searches"})]}),e.jsx(te,{children:e.jsx("div",{className:"space-y-3",children:a?.recentSearches?.map((u,b)=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(Fs,{className:"h-4 w-4 text-gray-500"}),e.jsx("span",{className:"text-sm text-gray-700",children:u})]}),e.jsx(U,{variant:"ghost",size:"sm",children:e.jsx(qt,{className:"h-4 w-4"})})]},b))})})]})]}),e.jsxs(se,{children:[e.jsxs(me,{children:[e.jsxs(xe,{className:"flex items-center space-x-2",children:[e.jsx(fe,{className:"h-5 w-5 text-orange-600"}),e.jsx("span",{children:"Recent Property Activity"})]}),e.jsx(ve,{children:"Your latest property interactions"})]}),e.jsx(te,{children:n.length>0?e.jsx("div",{className:"space-y-3",children:n.slice(0,10).map((u,b)=>e.jsxs("div",{className:"flex items-center space-x-4 p-4 bg-gray-50 rounded-lg",children:[e.jsx("div",{className:"flex-shrink-0",children:u.type==="property_view"?e.jsx(Pe,{className:"h-4 w-4 text-purple-600"}):e.jsx(ye,{className:"h-4 w-4 text-blue-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:u.description}),e.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[e.jsx("p",{className:"text-xs text-gray-500",children:new Date(u.timestamp).toLocaleDateString(Le().locale,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),u.metadata?.platform&&e.jsx(Ne,{variant:"outline",className:"text-xs",children:u.metadata.platform})]})]})]},u.id||b))}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 rounded-full flex items-center justify-center",children:e.jsx(Pe,{className:"h-8 w-8 text-gray-400"})}),e.jsx("p",{className:"text-gray-500 font-medium mb-2",children:"No property activity yet"}),e.jsx("p",{className:"text-gray-400 text-sm",children:"Start browsing properties to see your activity here"})]})})]})]})},mr=({isVisible:s,onClose:a,onVerificationComplete:t})=>{const{getToken:n,user:m}=ge(),[r,h]=l.useState({isVerified:!1,hasPendingRequest:!1}),[f,N]=l.useState(!0),[u,b]=l.useState(!1),i=async()=>{try{N(!0);const H=await n(),I=await fetch(`${ae}/verification/user-requests`,{headers:{Authorization:`Bearer ${H}`,"Content-Type":"application/json"}}),O=await fetch(`${ae}/users/profile`,{headers:{Authorization:`Bearer ${H}`,"Content-Type":"application/json"}});if(I.ok){const P=(await I.json()).data||[],q=!!(O.ok?await O.json():null)?.data?.verified,re=P.find(E=>E.status==="pending"),p=P[0];h({isVerified:q,hasPendingRequest:!!re,requestStatus:p?.status,requestId:p?.id,rejectionReason:p?.rejectionReason})}}catch{}finally{N(!1)}};l.useEffect(()=>{s&&m&&i()},[s,m]);const d=()=>{b(!1),i(),t?.()},o=()=>f?e.jsx(ie,{className:"h-5 w-5 animate-spin"}):r.isVerified?e.jsx(Se,{className:"h-5 w-5 text-green-500"}):r.hasPendingRequest?e.jsx(fe,{className:"h-5 w-5 text-yellow-500"}):r.requestStatus==="rejected"?e.jsx(Ee,{className:"h-5 w-5 text-red-500"}):e.jsx(ke,{className:"h-5 w-5 text-blue-500"}),k=()=>f?"Checking verification status...":r.isVerified?"Your account is verified!":r.hasPendingRequest?"Your verification request is under review":r.requestStatus==="rejected"?"Your verification request was rejected":"Get verified to unlock all features",R=()=>r.isVerified?"You now have access to all premium features and enhanced trust indicators.":r.hasPendingRequest?"We're reviewing your documents and will notify you once the process is complete.":r.requestStatus==="rejected"?r.rejectionReason||"Please review the requirements and submit a new request.":"Complete verification to build trust with other users and access premium features.",C=()=>r.isVerified?e.jsxs(U,{onClick:a,className:"w-full",children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Continue to Dashboard"]}):r.hasPendingRequest?e.jsxs(U,{variant:"outline",onClick:a,className:"w-full",children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Check Back Later"]}):r.requestStatus==="rejected"?e.jsxs("div",{className:"space-y-2",children:[e.jsxs(U,{onClick:()=>b(!0),className:"w-full",children:[e.jsx(ke,{className:"h-4 w-4 mr-2"}),"Submit New Request"]}),e.jsx(U,{variant:"outline",onClick:a,className:"w-full",children:"Maybe Later"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs(U,{onClick:()=>b(!0),className:"w-full",children:[e.jsx(ke,{className:"h-4 w-4 mr-2"}),"Get Verified Now"]}),e.jsx(U,{variant:"outline",onClick:a,className:"w-full",children:"Maybe Later"})]});return s?e.jsxs(e.Fragment,{children:[e.jsx(La,{children:e.jsx(be.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(be.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},transition:{type:"spring",duration:.5},className:"w-full max-w-md",children:e.jsxs(se,{className:"relative",children:[e.jsx(U,{variant:"ghost",size:"sm",className:"absolute top-2 right-2 h-8 w-8 p-0",onClick:a,children:e.jsx(ls,{className:"h-4 w-4"})}),e.jsx(te,{className:"p-6",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"flex justify-center",children:o()}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-lg font-semibold",children:k()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:R()})]}),r.requestStatus==="rejected"&&r.rejectionReason&&e.jsxs(Fa,{children:[e.jsx(Ee,{className:"h-4 w-4"}),e.jsx($a,{className:"text-sm",children:r.rejectionReason})]}),r.isVerified&&e.jsxs(Ne,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(Se,{className:"h-3 w-3 mr-1"}),"Verified Account"]}),r.hasPendingRequest&&e.jsxs(Ne,{variant:"secondary",className:"bg-yellow-100 text-yellow-800",children:[e.jsx(fe,{className:"h-3 w-3 mr-1"}),"Under Review"]}),e.jsx("div",{className:"pt-2",children:C()})]})})]})})})}),e.jsx(Cs,{isOpen:u,onClose:()=>b(!1),onSuccess:d})]}):null},ws=()=>typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;function _s(s,a=900){const[t,n]=l.useState(()=>ws()?s:0);return l.useEffect(()=>{if(ws()||s<=0){n(s);return}let m=0;const r=performance.now(),h=f=>{const N=Math.min(1,(f-r)/a);n(Math.round(s*(1-Math.pow(1-N,3)))),N<1&&(m=requestAnimationFrame(h))};return m=requestAnimationFrame(h),()=>cancelAnimationFrame(m)},[s,a]),t}function xr(s=new Date){const a=s.getHours();return a<5?"Good evening":a<12?"Good morning":a<18?"Good afternoon":"Good evening"}function hr({percent:s,onOpen:a}){const t=Math.max(0,Math.min(100,Math.round(s))),n=_s(t),m=t>=100,r=15,h=2*Math.PI*r,f=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"relative flex h-9 w-9 shrink-0 items-center justify-center",children:[e.jsxs("svg",{viewBox:"0 0 36 36",className:"absolute inset-0 h-full w-full -rotate-90","aria-hidden":"true",children:[e.jsx("circle",{cx:"18",cy:"18",r,fill:"none",className:"stroke-gray-200 dark:stroke-white/15",strokeWidth:"3.5"}),e.jsx("circle",{cx:"18",cy:"18",r,fill:"none",stroke:"url(#sn-ring)",strokeWidth:"3.5",strokeLinecap:"round",strokeDasharray:h,strokeDashoffset:h*(1-n/100),className:"transition-[stroke-dashoffset] duration-500"}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"sn-ring",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#3A5A8C"}),e.jsx("stop",{offset:"100%",stopColor:"#10b981"})]})})]}),m?e.jsx(os,{className:"h-4 w-4 text-emerald-600",strokeWidth:3}):e.jsx("span",{className:"text-[10px] font-bold text-[#0C1A2B] dark:text-white",children:n})]}),e.jsxs("span",{className:"text-left leading-tight",children:[e.jsx("span",{className:"block text-sm font-semibold text-[#0C1A2B] dark:text-white",children:m?"Profile complete":`Profile ${n}% done`}),e.jsx("span",{className:"block text-xs text-gray-500",children:m?"Great matches ahead":"Finish it for better matches"})]})]}),N="inline-flex items-center gap-2.5 rounded-full border border-gray-200/80 bg-white/80 py-1.5 pl-1.5 pr-4 shadow-sm backdrop-blur dark:border-white/10 dark:bg-white/5";return m?e.jsx("div",{className:N,role:"status","aria-label":"Profile 100% complete",children:f}):e.jsx("button",{type:"button",onClick:a,className:`${N} transition hover:border-[#3A5A8C]/40 hover:shadow-md`,"aria-label":`Profile ${t}% complete. Finish your profile`,children:f})}function ur({onRefresh:s}){const[a,t]=l.useState(!1),n=async()=>{if(a)return;t(!0);const m=Date.now();try{await s()}finally{setTimeout(()=>t(!1),Math.max(0,600-(Date.now()-m)))}};return e.jsx("button",{type:"button",onClick:n,disabled:a,"aria-label":"Refresh",title:"Refresh",className:"inline-flex h-11 w-11 items-center justify-center rounded-full border border-gray-200/80 bg-white/80 text-[#0C1A2B] shadow-sm backdrop-blur transition hover:border-[#3A5A8C]/40 hover:shadow-md disabled:opacity-70 dark:border-white/10 dark:bg-white/5 dark:text-white",children:e.jsx(Gt,{className:`h-4 w-4 ${a?"animate-spin [animation-direction:reverse]":""}`})})}const gr={blue:{chip:"from-[#3b82f6] to-[#6366f1]",glow:"group-hover:shadow-[0_18px_40px_-18px_rgba(59,130,246,0.55)]",text:"text-blue-700"},violet:{chip:"from-[#8b5cf6] to-[#d946ef]",glow:"group-hover:shadow-[0_18px_40px_-18px_rgba(139,92,246,0.55)]",text:"text-violet-700"},emerald:{chip:"from-[#10b981] to-[#14b8a6]",glow:"group-hover:shadow-[0_18px_40px_-18px_rgba(16,185,129,0.55)]",text:"text-emerald-700"},amber:{chip:"from-[#f59e0b] to-[#f97316]",glow:"group-hover:shadow-[0_18px_40px_-18px_rgba(245,158,11,0.55)]",text:"text-amber-700"}};function Ue({icon:s,label:a,value:t,hint:n,cta:m,tone:r,onClick:h,live:f,index:N}){const u=_s(t??0),b=gr[r];return e.jsxs("button",{type:"button",onClick:h,className:`sn-dash-rise sn-dash-rise-${N+1} group relative overflow-hidden rounded-2xl border border-gray-100 bg-white p-5 text-left shadow-sm transition duration-300 hover:-translate-y-1 hover:border-transparent ${b.glow}
1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#3A5A8C] dark:border-white/10 dark:bg-white/5`,children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx("span",{className:`flex h-11 w-11 items-center justify-center rounded-xl bg-gradient-to-br ${b.chip} text-white shadow-md transition duration-300 group-hover:scale-110 group-hover:rotate-3`,children:e.jsx(s,{className:"h-5 w-5"})}),f&&e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-red-50 px-2 py-0.5 text-[11px] font-semibold text-red-600",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-red-500"})," New"]})]}),e.jsx("p",{className:"mt-4 text-3xl font-bold tabular-nums text-[#0C1A2B] dark:text-white","aria-label":t===null?`${a}: not available right now`:void 0,children:t===null?"–":u}),e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:a}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:n}),e.jsxs("p",{className:`mt-3 flex items-center gap-1 text-xs font-semibold ${b.text} dark:text-blue-200`,children:[m," ",e.jsx(Us,{className:"h-3.5 w-3.5 transition group-hover:translate-x-1"})]})]})}const fr=[{to:"/properties?section=search",label:"Ask Snesty",blurb:"Describe your place, get real listings",icon:Ma},{to:"/properties?section=listings",label:"Browse homes",blurb:"Map, filters and price history",icon:qe},{to:"/roommates",label:j("Find roommates","Find flatmates"),blurb:"People who match how you live",icon:oe},{to:"/marketplace",label:"Marketplace",blurb:j("Furniture, sublets and more","Furniture, appliances and more"),icon:_t},{to:"/community",label:"Community",blurb:"Posts and events near you",icon:le}],pr={property_view:{icon:Pe,tone:"bg-violet-100 text-violet-700"},search:{icon:ye,tone:"bg-blue-100 text-blue-700"},roommate_view:{icon:oe,tone:"bg-emerald-100 text-emerald-700"},message_sent:{icon:le,tone:"bg-amber-100 text-amber-700"}},yr=s=>{if(!s)return"";const a=new Date(s);return Number.isNaN(a.getTime())?"":a.toLocaleDateString(Le().locale,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})},Ns={high:"bg-rose-50 text-rose-700 ring-rose-200",medium:"bg-blue-50 text-blue-700 ring-blue-200",low:"bg-gray-50 text-gray-600 ring-gray-200"};function br({data:s,firstName:a,recommendations:t,onRefresh:n,onOpenSection:m,onRecommendation:r}){const{profile:h,stats:f,activity:N}=s,u=He(),b=o=>f?typeof o=="number"&&Number.isFinite(o)?o:0:null,i=typeof h?.completionPercentage=="number"?h.completionPercentage:0,d=new Date().toLocaleDateString(Le().locale,{weekday:"long",month:"long",day:"numeric"});return e.jsxs("div",{className:"space-y-8",children:[e.jsx(ne,{eyebrow:d,title:a?`${xr()},`:"Welcome to your",accent:a||"dashboard",subtitle:"Your housing journey at a glance: what's new, and the best next step.",actions:e.jsxs(e.Fragment,{children:[e.jsx(hr,{percent:i,onOpen:()=>m("profile")}),e.jsx(ur,{onRefresh:n})]})}),i<100&&e.jsxs("div",{className:"sn-dash-rise flex flex-col gap-4 roun
1ded-2xl border border-amber-200/70 bg-gradient-to-r from-amber-50 to-orange-50 p-5 sm:flex-row sm:items-center sm:justify-between dark:border-amber-400/20 dark:from-amber-500/10 dark:to-orange-500/10",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-amber-100 text-amber-700",children:e.jsx(Ps,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-amber-900 dark:text-amber-100",children:"Finish your profile for better matches"}),h.missingProfileFields&&h.missingProfileFields.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:h.missingProfileFields.map(o=>e.jsx("span",{className:"rounded-full bg-white/80 px-2.5 py-0.5 text-xs font-medium text-amber-800 ring-1 ring-amber-200",children:o},o))}):e.jsx("p",{className:"mt-1 text-sm text-amber-800 dark:text-amber-200",children:j("A few more details and roommates can see how well you match.","A few more details and flatmates can see how well you match.")})]})]}),e.jsx("button",{type:"button",onClick:()=>m("profile"),className:"shrink-0 rounded-xl bg-[#0C1A2B] px-4 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-[#1c3257]",children:"Complete profile"})]}),e.jsxs("section",{"aria-label":"Your numbers",className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:[e.jsx(Ue,{index:0,icon:ye,tone:"blue",label:"Active searches",value:b(f?.activeSearches),hint:"saved and alerting",cta:(f?.activeSearches||0)>0?"See saved searches":"Save a search",onClick:()=>u((f?.activeSearches||0)>0?"/properties?section=saved":"/properties")}),e.jsx(Ue,{index:1,icon:Pe,tone:"violet",label:"Homes viewed",value:b(f?.propertyViews),hint:"this month",cta:"Keep browsing",onClick:()=>u("/properties?section=listings")}),e.jsx(Ue,{index:2,icon:oe,tone:"emerald",label:j("Roommate matches","Flatmate matches"),value:b(f?.roommateMatches),hint:"compatible people",cta:(f?.roommateMatches||0)>0?"See matches":"Set preferences",onClick:()=>m((f?.roommateMatches||0)>0?"roommates":"roommate-preferences")}),e.jsx(Ue,{index:3,icon:le,tone:"amber",label:"Unread messages",value:b(f?.unreadMessages),hint:"waiting for you",cta:(f?.unreadMessages||0)>0?"Read now":"Open inbox",live:(f?.unreadMessages||0)>0,onClick:()=>m("messages")})]}),e.jsxs("section",{"aria-labelledby":"sn-quick",className:"sn-dash-rise sn-dash-rise-2",children:[e.jsx("h3",{id:"sn-quick",className:"mb-3 text-sm font-semibold uppercase tracking-wider text-gray-500",children:"Jump back in"}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5",children:fr.map(({to:o,label:k,blurb:R,icon:C})=>e.jsxs(de,{to:o,className:"group relative overflow-hidden rounded-2xl border border-gray-100 bg-white p-4 transition duration-300 hover:-translate-y-0.5 hover:border-[#84A9FF]/50 hover:shadow-[0_14px_30px_-18px_rgba(58,90,140,0.6)] dark:border-white/10 dark:bg-white/5",children:[e.jsx("span",{className:"absolute inset-x-0 -top-px h-px bg-gradient-to-r from-transparent via-[#84A9FF] to-transparent opacity-0 transition group-hover:opacity-100","aria-hidden":"true"}),e.jsx(C,{className:"h-6 w-6 text-[#2A4470] transition duration-300 group-hover:scale-110 dark:text-blue-200"}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-[#0C1A2B] dark:text-white",children:k}),e.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:R})]},o))})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-5",children:[e.jsxs("section",{"aria-labelledby":"sn-activity",className:"sn-dash-rise sn-dash-rise-3 rounded-2xl border border-gray-100 bg-white p-6 lg:col-span-3 dark:border-white/10 dark:bg-white/5",children:[e.jsxs("div",{className:"mb-5 flex items-center gap-2",children:[e.jsx(fe,{className:"h-5 w-5 text-[#3A5A8C]"}),e.jsx("h3",{id:"sn-activity",className:"text-lg font-semibold text-[#0C1A2B] dark:text-white",children:"Recent activity"})]}),N&&N.length>0?e.jsx("ol",{className:"relative space-y-5 border-l border-gray-200 pl-6 dark:border-white/10",children:N.slice(0,6).map((o,k)=>{const R=pr[o.type||""]||{icon:fe,tone:"bg-gray-100 text-gray-600"},C=R.icon;return e.jsxs("li",{className:"relative",children:[e.jsx("span",{className:`absolute -left-[37px] flex h-7 w-7 items-center justify-center rounded-full ring-4 ring-white dark:ring-[#0f1b2d] ${R.tone}`,children:e.jsx(C,{className:"h-3.5 w-3.5"})}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:o.description}),e.jsxs("p",{className:"mt-0.5 flex items-center gap-2 text-xs text-gray-500",children:[yr(o.timestamp),typeof o.metadata?.compatibilityScore=="number"&&o.metadata.compatibilityScore>0&&e.jsxs("span",{className:"rounded-full bg-emerald-50 px-2 py-0.5 font-medium text-emerald-700",children:[o.metadata.compatibilityScore,"% match"]})]})]},o.id||k)})}):e.jsxs("div",{className:"flex flex-col items-center py-8 text-center",children:[e.jsx("span",{className:"mb-3 flex h-14 w-14 items-center justify-center rounded-2xl bg-gradient-to-br from-[#eef3fb] to-[#e3e9f7] text-[#3A5A8C]",children:e.jsx(pe,{className:"h-6 w-6"})}),e.jsx("p",{className:"font-medium text-gray-800 dark:text-gray-100",children:"Nothing here yet"}),e.jsx("p",{className:"mt-1 max-w-sm text-sm text-gray-500",children:j("Search homes or look through roommates, and what you do shows up here.","Search homes or look through flatmates, and what you do shows up here.")})]})]}),e.jsxs("section",{"aria-labelledby":"sn-next",className:"sn-dash-rise sn-dash-rise-4 rounded-2xl border border-gray-100 bg-gradient-to-br from-white to-[#f5f8fd
1] p-6 lg:col-span-2 dark:border-white/10 dark:from-white/5 dark:to-white/10",children:[e.jsxs("div",{className:"mb-5 flex items-center gap-2",children:[e.jsx(_e,{className:"h-5 w-5 text-[#3A5A8C]"}),e.jsx("h3",{id:"sn-next",className:"text-lg font-semibold text-[#0C1A2B] dark:text-white",children:"Your next steps"})]}),t.length>0?e.jsx("ul",{className:"space-y-3",children:t.slice(0,3).map((o,k)=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>r(o.action),className:"group flex w-full items-start gap-3 rounded-xl border border-gray-100 bg-white p-4 text-left transition hover:border-[#84A9FF]/60 hover:shadow-md dark:border-white/10 dark:bg-white/5",children:[e.jsx("span",{className:"mt-0.5 shrink-0",children:o.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-gray-900 dark:text-gray-100",children:o.text}),e.jsxs("span",{className:"mt-1.5 inline-flex items-center gap-1 text-xs font-semibold text-[#2A4470] dark:text-blue-200",children:[o.action," ",e.jsx(Us,{className:"h-3.5 w-3.5 transition group-hover:translate-x-1"})]})]}),o.priority&&e.jsx("span",{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-semibold capitalize ring-1 ${Ns[o.priority]||Ns.low}`,children:o.priority})]})},k))}):e.jsxs("div",{className:"flex flex-col items-center py-6 text-center",children:[e.jsx(zt,{className:"mb-2 h-8 w-8 text-emerald-500"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"You're all set. Nice work."})]})]})]})]})}const jr=["overview","messages","roommate-preferences","properties","roommates","favorites","profile","subscription","email-settings","tasks","hunting-agent","viewings","resources"],vr={"my-rentals":"/landlord"};function wr(){const{user:s,getToken:a}=ge(),[t,n]=l.useState([]),[m,r]=l.useState(null),h=t.find(v=>v.id===m)||null,[f,N]=l.useState(""),[u,b]=l.useState(!1),[i,d]=l.useState(null),[o,k]=l.useState(!1),R=l.useRef(null),{isMobile:C}=Ba(),H=C&&!!h,I=l.useCallback(async()=>{b(!0),d(null);try{const v={"Content-Type":"application/json"};if(s?.id){v["x-clerk-user-id"]=s.id;const $=await a();$&&(v.Authorization=`Bearer ${$}`)}const V=await fetch(`${ae}/messaging/conversations`,{headers:v});if(!V.ok)throw new Error(`Failed to load conversations (${V.status})`);const D=await V.json(),J=(Array.isArray(D?.data)?D.data:Array.isArray(D)?D:[]).map($=>({id:String($.id),roommate:{id:String($.otherParticipant?.id||""),name:[$.otherParticipant?.firstName,$.otherParticipant?.lastName].filter(Boolean).join(" ")||"User",image:$.otherParticipant?.avatar||"",profession:$.otherParticipant?.profession||"User",verified:!!$.otherParticipant?.verified,isOnline:!1},lastMessage:$.lastMessage?.content||"",timestamp:$.lastMessage?.createdAt?new Date($.lastMessage.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",unreadCount:typeof $.unreadCount=="number"?$.unreadCount:0,isRead:typeof $.unreadCount=="number"?$.unreadCount===0:$.lastMessage?!!$.lastMessage.isRead||!!$.lastMessage.senderId&&String($.lastMessage.senderId)!==String($.otherParticipant?.id||""):!0,messageCount:0,isOnline:!1}));n(J)}catch(v){d(v instanceof Error?v.message:"Failed to load conversations")}finally{b(!1)}},[s?.id,a]);l.useEffect(()=>{I()},[I]),l.useEffect(()=>{const v=()=>{r(null),I()};return window.addEventListener(bs,v),()=>window.removeEventListener(bs,v)},[I]);const[O,x]=Ss(),P=O.get("threadId"),A=O.get("userId"),q=l.useRef(null),[re,p]=l.useState({});l.useEffect(()=>{if(P&&q.current!==`t:${P}`){q.current=`t:${P}`,r(P);return}if(!A||!s?.id||q.current===`u:${A}`)return;q.current=`u:${A}`;const v=Na(O);(async()=>{try{const V={"Content-Type":"application/json","x-clerk-user-id":s.id},D=await a();D&&(V.Authorization=`Bearer ${D}`);const _=await fetch(`${ae}/messaging/conversations`,{method:"POST",headers:V,body:JSON.stringify({otherUserId:A})}),J=await _.json().catch(()=>null),$=J?.data?.conversationId;if(!_.ok||!$)throw new Error(J?.message||`Couldn't open the conversation (${_.status})`);await I(),v&&p(w=>({...w,[String($)]:v})),r(String($)),q.current=`t:${$}`,x(w=>{const G=new URLSearchParams(w);G.delete("userId");for(const y of["about","city","moveIn","budgetFits","home","name","title","price"])G.delete(y);return G.set("threadId",String($)),G},{replace:!0})}catch(V){d(V instanceof Error?V.message:"Couldn't open the conversation")}})()},[P,A,s?.id,a,I,x]),l.useEffect(()=>{let v=!0;async function V(){if(m){k(!0);try{const D={"Content-Type":"application/json"};if(s?.id){D["x-clerk-user-id"]=s.id;const _=await a();_&&(D.Authorization=`Bearer ${_}`)}await fetch(`${ae}/messaging/conversations/${m}/read`,{method:"PUT",headers:D}),v&&n(_=>_.map(J=>J.id===m?{...J,isRead:!0,unreadCount:0}:J))}catch{}finally{v&&k(!1)}}}return V(),()=>{v=!1}},[m,s?.id,a]);const E=t.filter(v=>v.roommate.name.toLowerCase().includes(f.toLowerCase())||v.lastMessage.toLowerCase().includes(f.toLowerCase())),Y=t.reduce((v,V)=>v+(V.isRead?0:Math.max(1,V.unreadCount||0)),0);return e.jsxs("div",{className:"h-full flex flex-col mx-auto w-full max-w-none px-0 overflow-hidden bg-gradient-to-b from-white to-gray-50/30",children:[e.jsx("div",{className:"flex-shrink-0 border-b border-gray-200/80 px-4 pb-4 pt-5 sm:px-6",children:e.jsx(ne,{compact:!0,icon:le,eyebrow:"Inbox",title:"Your",accent:"messages",subtitle:Y>0?`${Y} unread message${Y===1?"":"s"}`:"All caught up",actions:Y>0?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-[#0C1A2B] px-3 py-1.5 text-xs font-semibold text-white shadow-sm",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-400"})," ",Y," new"]}):void 0})}),e.jsxs("div",{className:"flex overflow-hidden flex-1 min-h-0",children:[e.jsxs("div",{className:`${h?"hidden":"flex"} md:flex w-full md:w-96 bg-white/80 border-r border-gray-200/80 flex-col shadow-[1px_0_3px_rgba(0,0,0,0.02)]`,children:[e.jsx("div",{className:"p-4 border-b border-gray-100",children:e.jsxs("div",{className:"relative",children:[e.jsx(ye,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 pointer-events-none"}),e.jsx(ce,{placeholder:"Search conversations",value:f,onChange:v=>N(v.target.value),className:"pl-9 pr-3 h-10 rounded-full border-gray-200 focus:border-slate-400 focus:ring-2 focus:ring-slate-500/10 bg-gray-50/70 focus:bg-white transition-colors shadow-sm"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:u?e.jsx("div",{className:"divide-y divide-gray-50",children:[0,1,2,3,4].map(v
1=>e.jsxs("div",{className:"p-4 flex items-center gap-3 animate-pulse",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-gray-200/80 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx("div",{className:"h-3 w-2/5 rounded-full bg-gray-200/80"}),e.jsx("div",{className:"h-2.5 w-4/5 rounded-full bg-gray-100"})]})]},v))}):i?e.jsxs("div",{className:"p-6 flex flex-col items-center text-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-red-50 text-red-500 flex items-center justify-center",children:e.jsx(Ee,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:"Couldn't load your messages"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:i})]}),e.jsxs(U,{variant:"outline",size:"sm",className:"rounded-full gap-1.5 mt-1",onClick:()=>I(),children:[e.jsx(Ls,{className:"h-3.5 w-3.5"})," Retry"]})]}):E.length===0?e.jsxs("div",{className:"p-8 flex flex-col items-center text-center gap-3",children:[e.jsx("div",{className:"h-14 w-14 rounded-full bg-gradient-to-br from-gray-100 to-gray-50 text-gray-400 flex items-center justify-center",children:e.jsx(le,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:f?"No matches found":"No conversations yet"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:f?"Try a different search term":j("Messages from roommates and sellers will show up here","Messages from flatmates and sellers will show up here")})]})]}):e.jsx("div",{className:"divide-y divide-gray-50",children:E.map(v=>e.jsxs("button",{className:`relative w-full text-left p-4 flex items-center gap-3 transition-all duration-200 hover:bg-gray-50/80 ${h?.id===v.id?"bg-slate-50":""}`,onClick:()=>r(v.id),children:[h?.id===v.id&&e.jsx("span",{className:"absolute left-0 top-1.5 bottom-1.5 w-[3px] rounded-full bg-gradient-to-b from-slate-700 to-slate-900"}),e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsxs(Te,{className:`h-12 w-12 ring-2 transition-all ${h?.id===v.id?"ring-slate-300":"ring-gray-100"}`,children:[e.jsx(Fe,{src:v.roommate.image}),e.jsx($e,{className:"bg-gradient-to-br from-gray-100 to-gray-200 text-gray-700 font-semibold text-sm",children:v.roommate.name?.[0]||"U"})]}),e.jsx(ds,{conversationId:v.id,liveOnline:v.roommate.isOnline,className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 border-2 border-white"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[e.jsx("p",{className:`text-sm truncate ${v.isRead?"text-gray-900 font-medium":"text-gray-900 font-semibold"}`,children:v.roommate.name}),e.jsx("span",{className:"text-[11px] text-gray-400 flex-shrink-0 ml-2",children:v.timestamp})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!v.isRead&&v.lastMessage?.trim()&&e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-blue-600 flex-shrink-0"}),e.jsx("p",{className:`text-[13px] truncate ${v.isRead?"text-gray-500":"text-gray-900 font-medium"}`,children:v.lastMessage||"(no messages yet)"})]})]})]},v.id))})})]}),e.jsx(Nr,{portal:H,children:e.jsx("div",{className:H?"fixed inset-x-0 top-0 z-[10000] flex h-[100dvh] flex-col bg-gray-50 overscroll-contain pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]":`${h?"flex":"hidden"} md:flex flex-1 min-w-0 flex-col bg-gray-50/60`,children:h?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-shrink-0 bg-white/95 backdrop-blur-sm border-b border-gray-200/80 px-4 sm:px-6 py-3.5 shadow-[0_1px_3px_rgba(0,0,0,0.02)]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3.5 min-w-0",children:[e.jsx(U,{variant:"ghost",size:"icon",className:"h-9 w-9 flex-shrink-0 rounded-full transition-colors hover:bg-gray-100 md:hidden",title:"Back to conversations",onClick:()=>r(null),children:e.jsx(Yt,{className:"h-4 w-4 text-gray-600"})}),e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsxs(Te,{className:"h-10 w-10 ring-2 ring-gray-100",children:[e.jsx(Fe,{src:h.roommate.image}),e.jsx($e,{className:"bg-gradient-to-br from-gray-100 to-gray-200 text-gray-700 font-semibold",children:h.roommate.name?.[0]||"U"})]}),e.jsx(ds,{conversationId:h.id,liveOnline:h.roommate.isOnline,className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 border-2 border-white"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900 leading-tight truncate",children:h.roommate.name}),e.jsx("p",{className:"text-xs leading-tight mt-0.5",children:e.jsx(Qs,{conversationId:h.id,liveOnline:h.roommate.isOnline})})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(U,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full transition-colors hover:bg-gray-100",title:"Start video call",onClick:()=>R.current?.startVideoCall(),children:e.jsx(Wt,{className:"h-4 w-4 text-gray-600"})}),e.jsxs(xt,{children:[e.jsx(ht,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"icon",className:"h-9 w-9 hover:bg-gray-100 rounded-full",title:"More options",children:e.jsx(Jt,{className:"h-4 w-4 text-gray-600"})})}
1),e.jsxs(ut,{align:"end",children:[e.jsxs(ms,{onClick:()=>n(v=>v.map(V=>V.id===m?{...V,isRead:!1}:V)),children:[e.jsx(Kt,{className:"h-4 w-4 mr-2"})," Mark as unread"]}),e.jsxs(ms,{onClick:()=>r(null),children:[e.jsx(ls,{className:"h-4 w-4 mr-2"})," Close conversation"]})]})]})]})]})}),e.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:e.jsx(ks,{ref:R,conversation:h,suggestionContext:re[h.id],onClose:()=>r(null),onMessageSent:v=>{n(V=>{const D=V.map($=>$.id===h.id?{...$,lastMessage:v,timestamp:"Just now",isRead:!0}:$),_=D.find($=>$.id===h.id),J=D.filter($=>$.id!==h.id);return _?[_,...J]:D})},hideHeader:!0,onPresenceChange:v=>{n(V=>V.map(D=>D.id===h.id?{...D,roommate:{...D.roommate,isOnline:v}}:D))},onMessageReceived:v=>{n(V=>V.map(D=>D.id===h.id?{...D,lastMessage:v,timestamp:"Just now",isRead:!1}:D))}},h.id)})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mx-auto h-20 w-20 rounded-2xl bg-gradient-to-br from-slate-800 to-slate-950 text-white flex items-center justify-center mb-6 shadow-xl shadow-slate-900/10 rotate-3",children:e.jsx(le,{className:"h-9 w-9"})}),e.jsx("div",{className:"text-xl font-semibold text-gray-900 mb-2 tracking-tight",children:"Your messages live here"}),e.jsx("p",{className:"text-gray-500",children:"Select a conversation from the left to continue"})]})})})})]})]})}function Nr({portal:s,children:a}){return s?Je.createPortal(a,document.body):e.jsx(e.Fragment,{children:a})}const Sr=(s,a,t)=>{const n=[],m=s?.missingProfileFields||[];return s?.completionPercentage<30?n.push({icon:e.jsx(is,{className:"h-4 w-4 text-blue-600"}),text:m.length>0?`Add your ${m.slice(0,2).join(" and ")} to get better matches and recommendations`:"Complete your profile to get better matches and recommendations",action:"Complete Profile",priority:"high",color:"bg-blue-50 border-blue-200 text-blue-800"}):s?.completionPercentage<100&&n.push({icon:e.jsx(Xt,{className:"h-4 w-4 text-orange-600"}),text:m.length>0?`Still missing: ${m.join(", ")}`:"Add more details to your profile for better matching",action:"Enhance Profile",priority:"medium",color:"bg-orange-50 border-orange-200 text-orange-800"}),a?.roommateMatches===0?n.push({icon:e.jsx(oe,{className:"h-4 w-4 text-green-600"}),text:j("Set your roommate preferences to find compatible matches","Set your flatmate preferences to find compatible matches"),action:"Set Preferences",priority:"high",color:"bg-green-50 border-green-200 text-green-800"}):a?.roommateMatches>0&&a?.roommateMatches<3&&n.push({icon:e.jsx(Bs,{className:"h-4 w-4 text-green-600"}),text:j("You have some matches! Review and connect with potential roommates","You have some matches! Review and connect with potential flatmates"),action:"View Matches",priority:"medium",color:"bg-green-50 border-green-200 text-green-800"}),a?.unreadMessages>0&&n.push({icon:e.jsx(le,{className:"h-4 w-4 text-amber-600"}),text:`You have ${a.unreadMessages} unread message${a.unreadMessages===1?"":"s"}`,action:"Open Messages",priority:"high",color:"bg-amber-50 border-amber-200 text-amber-800"}),a?.propertyViews===0?n.push({icon:e.jsx(ye,{className:"h-4 w-4 text-purple-600"}),text:"Open a few homes to see what's out there in your area",action:"Browse Properties",priority:"medium",color:"bg-purple-50 border-purple-200 text-purple-800"}):a?.activeSearches===0&&n.push({icon:e.jsx(ns,{className:"h-4 w-4 text-purple-600"}),text:"Save a search and get an alert when new homes match it",action:"Save a Search",priority:"low",color:"bg-purple-50 border-purple-200 text-purple-800"}),s&&s.verified===!1&&n.push({icon:e.jsx(ea,{className:"h-4 w-4 text-emerald-600"}),text:j("Get verified so roommates and landlords know you're real","Get verified so flatmates and owners know you're real"),action:"Get Verified",priority:"medium",color:"bg-emerald-50 border-emerald-200 text-emerald-800"}),!t?.firstName&&!t?.fullName&&n.push({icon:e.jsx(_e,{className:"h-4 w-4 text-pink-600"}),text:"Welcome to Snestico! Complete your profile to get started",action:"Get Started",priority:"high",color:"bg-pink-50 border-pink-200 text-pink-800"}),n.sort((r,h)=>{const f={high:0,medium:1,low:2};return f[r.priority]-f[h.priority]})},kr=({data:s,loading:a,user:t,refreshDashboardData:n,setActiveSection:m})=>{const r=He();if(a)return e.jsx(he,{label:"Loading your dashboard",hints:["Gathering your saved homes",j("Checking new roommate matches","Checking new flatmate matches"),"Almost there"],size:"lg",className:"min-h-[24rem]"});const h=f=>{switch(f){case"Complete Profile":case"Enhance Profile":case"Get Started":m("profile");break;case"Set Preferences":m("roommate-preferences");break;case"View Matches":m("roommates");break;case"Browse Properties":r("/properties?section=listings");break;case"Save a Search":r("/properties");break;case"Open Messages":m("messages");break;case"Get Verified":m("profile");break}};return e.jsx(br,{data:s,firstName:t?.firstName||t?.fullName?.split(" ")[0],recommendations:Sr(s.profile,s.stats,t),onRefresh:n,onOpenSection:m,onRecommendation:h})},Cr=({user:s})=>{const a=i=>i>=9?"Excellent":i>=8?"Very High":i>=7?"High":i>=6?"Good":i>=5?"Moderate":i>=4?"Fair":i>=3?"Low":i>=2?"Very Low":"Minimal",[t,n]=l.useState(De),[m,r]=l.useState(!0),[h,f]=l.useState(!1),{getToken:N}=ge(),{onPreferencesUpdated:u}=As();l.useEffect(()=>{s&&(async()=>{try{const d=await N(),o=await Re("/users/preferences",{},d||void 0,s);o.success&&o.data.preferences?n({...De,...o.data.preferences}):n(De)}catch{n(De)}finally{r(!1)}})()},[s,N]);const b=async()=>{f(!0);try{const i=await N();if((await Re("/users/preferences",{method:"PUT",body:JSON.stringify({preferences:t})},i||void 0,s)).success){L.success("Preferences saved successfully!",{duration:2e3});try{u(),L.success("✨ Updating your matches now (takes ~1-2 seconds)...",{duration:3e3})}catch{}}else L.error("Failed to save preferences")}catch{L.error("Failed to save preferences")}finally{f(!1)}};return m?e.jsx(he,{label:"Loading your preferences",className:"min-h-[24rem]"}):e.jsxs("div",{className:"space-y-8",children:[e.jsx(ne,{icon:Qt,eyebrow:"Matching",title:j("Roommate","Flatmate"),accent:"preferences",subtitle:"How you live and what you need. We match you with people who fit, and explain why.",actions:e.jsxs("button",{type:"button",onClick:b,disabled:h,className:Ja,children:[h?e.jsx(Zt,{className:"h-4 w-4 animate-spin"}):e.jsx(Rs,{className:"h-4 w-4"}),h?"Saving…":"Save preferences"]})}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3 [&>*]:min-w-0",children:[e.jsxs(se,{children:[e.jsxs(me,{children:[e.jsx(xe,{children:"Living Habits"}),e.jsx(ve,{children:"Your daily routines and lifestyle preferences"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Cleanliness Level"}),e.jsxs("span",{className:"text-xs font-semibold text-gray-600",children:[t.cleanlinessLevel[0],"/10"]})]}),e.jsx("div",{className:"px-2 bg-white rounded-lg border border-gray-200 p-3 mb-3",children:e.jsx(Ye,{value:t.cleanlinessLevel,onValueChange:i=>n(d=>({...d,cleanlinessLevel:i})),max:10,min:1,step:1,className:"w-full"})}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2.5 mb-2",children:e.jsx("div",{className:"h-2.5 rounded-full transition-all duration-300 shadow-sm",style:{width:`${t.cleanlinessLevel[0]/10*100}%`,backgroundColor:t.cleanlinessLevel[0]>=8?"#0f172a":t.cleanlinessLevel[0]>=6?"#1e293b":t.cleanlinessLevel[0]>=4?"#334155":"#475569"}})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-slate-700",children:a(t.cleanlinessLevel[0])}),e.jsx("div",{className:"flex items-center gap-0.5",children:[...Array(10)].map((i,d)=>e.jsx("div",{className:`h-2 w-2 rounded-full transition-all duration-200 ${d<t.cleanlinessLevel[0]?"bg-slate-800 shadow-sm":"bg-gray-300"}`},d))})]}),e.jsxs("div",{className:"flex justify-between text-xs text-gray-500 mt-2",children:[e.jsx("span",{children:"Relaxed"}),e.jsx("span",{children:"Very Clean"})]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Noise Tolerance"}),e.jsxs("span",{className:"text-xs font-semibold text-gray-600",children:[t.noiseTolerance[0],"/10"]})]}),e.jsx("div",{className:"px-2 bg-white rounded-lg border border-gray-200 p-3 mb-3",children:e.jsx(Ye,{value:t.noiseTolerance,onValueChange:i=>n(d=>({...d,noiseTolerance:i})),max:10,min:1,step:1,className:"w-full"})}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2.5 mb-2",children:e.jsx("div",{className:"h-2.5 rounded-full transition-all duration-300 shadow-sm",style:{width:`${t.noiseTolerance[0]/10*100}%`,backgroundColor:t.noiseTolerance[0]>=8?"#0f172a":t.noiseTolerance[0]>=6?"#1e293b":t.noiseTolerance[0]>=4?"#334155":"#475569"}})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-slate-700",children:a(t.noiseTolerance[0])}),e.jsx("div",{className:"flex items-center gap-0.5",children:[...Array(10)].map((i,d)=>e.jsx("div",{className:`h-2 w-2 rounded-full transition-all duration-200 ${d<t.noiseTolerance[0]?"bg-slate-800 shadow-sm":"bg-gray-300"}`},d))})]}),e.jsxs("div",{className:"flex justify-between text-xs text-gray-500 mt-2",children:[e.jsx("span",{children:"Qu
1iet"}),e.jsx("span",{children:"Loud OK"})]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Social Interaction Preference"})}),e.jsxs(K,{value:t.socialInteraction,onValueChange:i=>n(d=>({...d,socialInteraction:i})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsxs(X,{className:"bg-white border-gray-200",children:[e.jsx(S,{value:"minimal",children:"Minimal - Prefer privacy"}),e.jsx(S,{value:"moderate",children:"Moderate - Occasional socializing"}),e.jsx(S,{value:"high",children:"High - Love to hang out"})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Preference: ",t.socialInteraction]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Sleep Schedule"})}),e.jsx("div",{className:"space-y-2",children:["early-bird","night-owl","flexible"].map(i=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ie,{id:i,checked:t.sleepSchedule.includes(i),onCheckedChange:d=>{n(d?o=>({...o,sleepSchedule:[...o.sleepSchedule,i]}):o=>({...o,sleepSchedule:o.sleepSchedule.filter(k=>k!==i)}))}}),e.jsx("label",{htmlFor:i,className:"capitalize",children:i.replace("-"," ")})]},i))}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Selected: ",t.sleepSchedule.join(", ")||"None"]})]})]})]}),e.jsxs(se,{children:[e.jsxs(me,{children:[e.jsx(xe,{children:"Lifestyle Preferences"}),e.jsx(ve,{children:"Your lifestyle choices and deal-breakers"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:j("Roommate gender","Flatmate gender")})}),e.jsxs(K,{value:t.genderPreference||"any",onValueChange:i=>n(d=>({...d,genderPreference:i})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsx(X,{className:"bg-white border-gray-200",children:Ks.map(i=>e.jsx(S,{value:i.value,children:i.label},i.value))})]}),e.jsx("div",{className:"text-xs text-gray-500 mt-2",children:"You'll only be matched with people you'd both live with."}),e.jsx(gt,{variant:"roommate",className:"mt-3 bg-white"})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Pet Preferences"})}),e.jsxs(K,{value:t.petPreferences,onValueChange:i=>n(d=>({...d,petPreferences:i})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsxs(X,{className:"bg-white border-gray-200",children:[e.jsx(S,{value:"love-pets",children:"Love pets"}),e.jsx(S,{value:"no-pets",children:"No pets"}),e.jsx(S,{value:"allergic",children:"Allergic to pets"}),e.jsx(S,{value:"flexible",children:"Flexible"})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Preference: ",t.petPreferences]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Guest Policy"})}),e.jsxs(K,{value:t.guestPolicy,onValueChange:i=>n(d=>({...d,guestPolicy:i})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsxs(X,{className:"bg-white border-gray-200",children:[e.jsx(S,{value:"frequent",children:"Frequent guests OK"}),e.jsx(S,{value:"occasional",children:"Occasional guests"}),e.jsx(S,{value:"rare",children:"Rare guests only"}),e.jsx(S,{value:"no-guests",children:"No guests"})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Preference: ",t.guestPolicy]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Communication Style"})}),e.jsxs(K,{value:t.communicationStyle,onValueChange:i=>n(d=>({...d,communicationStyle:i})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsxs(X,{className:"bg-white border-gray-200",children:[e.jsx(S,{value:"direct",children:"Direct and clear"}),e.jsx(S,{value:"gentle",children:"Gentle and diplomatic"}),e.jsx(S,{value:"casual",children:"Casual and friendly"})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Preference: ",t.communicationStyle]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:j("Diet Preference","Food habits")})}),e.jsxs(K,{value:t.dietPreference,onValueChange:i=>n(d=>({...d,dietPreference:i})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsx(X,{className:"bg-white border-gray-200",children:we()==="in"?e.jsxs(e.Fragment,{children:[e.jsx(S,{value:"vegetarian",children:"Vegetarian"}),e.jsx(S,{value:"omnivore",children:"Non-vegetarian"}),e.jsx(S,{value:"vegan",children:"Vegan"})]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{value:"omnivore",children:"Omnivore - Eat everything"}),e.jsx(S,{value:"vegetarian",children:"Vegetarian - No meat"}),e.jsx(S,{value:"vegan",children:"Vegan - No animal products"}),e.jsx(S,{value:"halal",children:"Halal - Islamic dietary laws"}),e.jsx(S,{value:"kosher",children:"Kosher - Jewish dietary laws"})]})})]}),e.jsx("div",{className:"text-xs text-gray-500 mt-2",children:j(`Preference: ${t.dietPreference}`,"Shown to flatmates on your profile, to plan a shared kitchen. Never used to filter homes or listings.")})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Alcohol Consumption"})}),e.jsxs(K,{value:t.alcoholConsumption,onValueChange:i=>n(d=>({...d,alcoholConsumption:i})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsxs(X,{className:"bg-white border-gray-200",children:[e.jsx(S,{value:"never",children:"Never - Don't drink"}),e.jsx(S,{value:"occasionally",children:"Occasionally - Special occasions"}),e.jsx(S,{value:"socially",children:"Socially - With friends"}),e.jsx(S,{value:"regularly",children:"Regularly - Weekly basis"})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Preference: ",t.alcoholConsumption]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Study/Work Hours"})}),e.jsx("div",{className:"space-y-2",children:["morning","afternoon","evening","night"].map(i=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ie,{id:`study-${i}`,checked:t.studyWorkHours.includes(i),onCheckedChange:d=>{n(d?o=>({...o,studyWorkHours:[...o.studyWorkHours,i]}):o=>({...o,studyWorkHours:o.studyWorkHours.filter(k=>k!==i)}))}}),e.jsx(B,{htmlFor:`study-${i}`,className:"capitalize",children:i==="morning"?"Morning (6 AM - 12 PM)":i==="afternoon"?"Afternoon (12 PM - 6 PM)":i==="evening"?"Evening (6 PM - 12 AM)":"Night (12 AM - 6 AM)"})]},i))}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Selected: ",t.studyWorkHours.join(", ")||"None"]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Qu
1iet Hours Preference (24-hour format)"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-sm text-gray-600",children:"Start Time"}),e.jsxs(K,{value:t.quietHours[0].toString(),onValueChange:i=>n(d=>({...d,quietHours:[parseInt(i),d.quietHours[1]]})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsx(X,{className:"bg-white border-gray-200",children:Array.from({length:24},(i,d)=>e.jsxs(S,{value:d.toString(),children:[d.toString().padStart(2,"0"),":00"]},d))})]})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-sm text-gray-600",children:"End Time"}),e.jsxs(K,{value:t.quietHours[1].toString(),onValueChange:i=>n(d=>({...d,quietHours:[d.quietHours[0],parseInt(i)]})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsx(X,{className:"bg-white border-gray-200",children:Array.from({length:24},(i,d)=>e.jsxs(S,{value:d.toString(),children:[d.toString().padStart(2,"0"),":00"]},d))})]})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Time: ",t.quietHours[0].toString().padStart(2,"0"),":00 - ",t.quietHours[1].toString().padStart(2,"0"),":00"]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Social Energy Level"})}),e.jsxs(K,{value:t.socialEnergyLevel,onValueChange:i=>n(d=>({...d,socialEnergyLevel:i})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsxs(X,{className:"bg-white border-gray-200",children:[e.jsx(S,{value:"introvert",children:"Introvert - Prefer quiet, alone time"}),e.jsx(S,{value:"moderate",children:"Moderate - Balance of social and alone time"}),e.jsx(S,{value:"extrovert",children:"Extrovert - Energized by social interaction"})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Level: ",t.socialEnergyLevel]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Budget Flexibility"}),e.jsxs("span",{className:"text-xs font-semibold text-gray-600",children:[t.budgetFlexibility[0],"/10"]})]}),e.jsx("div",{className:"px-2 bg-white rounded-lg border border-gray-200 p-3 mb-3",children:e.jsx(Ye,{value:t.budgetFlexibility,onValueChange:i=>n(d=>({...d,budgetFlexibility:i})),max:10,min:1,step:1,className:"w-full"})}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2.5 mb-2",children:e.jsx("div",{className:"h-2.5 rounded-full transition-all duration-300 shadow-sm",style:{width:`${t.budgetFlexibility[0]/10*100}%`,backgroundColor:t.budgetFlexibility[0]>=8?"#0f172a":t.budgetFlexibility[0]>=6?"#1e293b":t.budgetFlexibility[0]>=4?"#334155":"#475569"}})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-slate-700",children:a(t.budgetFlexibility[0])}),e.jsx("div",{className:"flex items-center gap-0.5",children:[...Array(10)].map((i,d)=>e.jsx("div",{className:`h-2 w-2 rounded-full transition-all duration-200 ${d<t.budgetFlexibility[0]?"bg-slate-800 shadow-sm":"bg-gray-300"}`},d))})]}),e.jsxs("div",{className:"flex justify-between text-xs text-gray-500 mt-2",children:[e.jsx("span",{children:"Fixed Budget"}),e.jsx("span",{children:"Very Flexible"})]})]})]})]}),e.jsxs(se,{children:[e.jsxs(me,{children:[e.jsx(xe,{children:"Additional Preferences"}),e.jsx(ve,{children:"Extended lifestyle and living preferences"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Cooking Style"})}),e.jsxs(K,{value:t.cookingStyle,onValueChange:i=>n(d=>({...d,cookingStyle:i})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsxs(X,{className:"bg-white border-gray-200",children:[e.jsx(S,{value:"never-cook",children:"Never cook - Order out"}),e.jsx(S,{value:"occasionally",children:"Occasionally cook"}),e.jsx(S,{value:"moderate",children:"Moderate cooking"}),e.jsx(S,{value:"frequent",children:"Frequent cooking"}),e.jsx(S,{value:"chef-level",children:"Chef level cooking"})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Style: ",t.cookingStyle]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Substance Use"})}),e.jsx("div",{className:"space-y-2",children:["smoking","vaping","cannabis","none"].map(i=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ie,{id:`substance-${i}`,checked:t.substanceUse.includes(i),onCheckedChange:d=>{n(d?o=>({...o,substanceUse:[...o.substanceUse,i]}):o=>
1({...o,substanceUse:o.substanceUse.filter(k=>k!==i)}))}}),e.jsx(B,{htmlFor:`substance-${i}`,className:"capitalize",children:i})]},i))}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Selected: ",t.substanceUse.join(", ")||"None"]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Chores Responsibility"})}),e.jsxs(K,{value:t.choresResponsibility,onValueChange:i=>n(d=>({...d,choresResponsibility:i})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsxs(X,{className:"bg-white border-gray-200",children:[e.jsx(S,{value:"shared-equally",children:"Shared equally"}),e.jsx(S,{value:"rotating",children:"Rotating schedule"}),e.jsx(S,{value:"assigned",children:"Assigned tasks"}),e.jsx(S,{value:"flexible",children:"Flexible arrangement"})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Responsibility: ",t.choresResponsibility]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Temperature Preference"})}),e.jsxs(K,{value:t.temperaturePreference,onValueChange:i=>n(d=>({...d,temperaturePreference:i})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsxs(X,{className:"bg-white border-gray-200",children:[e.jsx(S,{value:"cold",children:"Cold - Keep it cool"}),e.jsx(S,{value:"moderate",children:"Moderate - Room temperature"}),e.jsx(S,{value:"warm",children:"Warm - Keep it warm"}),e.jsx(S,{value:"flexible",children:"Flexible - Adaptable"})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Preference: ",t.temperaturePreference]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Work Environment"})}),e.jsx("div",{className:"space-y-2",children:["quiet-space","collaborative","flexible","home-office"].map(i=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ie,{id:`work-${i}`,checked:t.workEnvironment.includes(i),onCheckedChange:d=>{n(d?o=>({...o,workEnvironment:[...o.workEnvironment,i]}):o=>({...o,workEnvironment:o.workEnvironment.filter(k=>k!==i)}))}}),e.jsx(B,{htmlFor:`work-${i}`,className:"capitalize",children:i.replace("-"," ")})]},i))}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Selected: ",t.workEnvironment.join(", ")||"None"]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Shared Spaces Usage"})}),e.jsxs(K,{value:t.sharedSpacesUsage,onValueChange:i=>n(d=>({...d,sharedSpacesUsage:i})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsxs(X,{className:"bg-white border-gray-200",children:[e.jsx(S,{value:"minimal",children:"Minimal usage"}),e.jsx(S,{value:"balanced",children:"Balanced usage"}),e.jsx(S,{value:"frequent",children:"Frequent usage"}),e.jsx(S,{value:"flexible",children:"Flexible usage"})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Usage: ",t.sharedSpacesUsage]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Overnight Guests"})}),e.jsxs(K,{value:t.overnightGuests,onValueChange:i=>n(d=>({...d,overnightGuests:i})),children:[e.jsx(Q,{className:"bg-white border-gray-200",children:e.jsx(Z,{})}),e.jsxs(X,{className:"bg-white border-gray-200",children:[e.jsx(S,{value:"never",children:"Never - No overnight guests"}),e.jsx(S,{value:"rarely",children:"Rarely - Special occasions"}),e.jsx(S,{value:"sometimes",children:"Sometimes - Occasional"}),e.jsx(S,{value:"frequently",children:"Frequently - Regular"})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-2",children:["Policy: ",t.overnightGuests]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(B,{className:"text-sm font-medium text-gray-900",children:"Additional Preferences"})}),e.jsx(Os,{value:t.additionalPreferences,onChange:i=>n(d=>({...d,additionalPreferences:i.target.value})),placeholder:"Any other preferences or requirements you'd like to mention...",rows:4,className:"bg-white border-gray-200"}),e.jsx("div",{className:"text-xs text-gray-500 mt-2",children:t.additionalPreferences?`${t.additionalPreferences.length} characters`:"No additional preferences"})]})]})]})]})]})},Re=async(s,a={},t,n)=>{try{const m=`${ae}${s}`,r={"Content-Type":"application/json"};t&&(r.Authorization=`Bearer ${t}`),n?.id&&(r["x-clerk-user-id"]=n.id),a.headers&&Object.entries(a.headers).forEac
1h(([N,u])=>{typeof u=="string"&&(r[N]=u)});const h=await fetch(m,{...a,headers:r});if(!h.ok){const N=await h.text();throw new Error(`API call failed: ${h.status} - ${N}`)}return await h.json()}catch(m){throw m}};function Ar({setCurrentPage:s}){const{user:a,isLoading:t,getToken:n}=ge(),m=He(),[r,h]=Ss(),{activeDashboardSection:f,setActiveDashboardSection:N}=mt(),u=f,b=N,[i,d]=l.useState(!0),[o,k]=l.useState(null),[R,C]=l.useState(!1),[H,I]=l.useState(!1),O=[{category:"ACTIVITY",items:[{id:"overview",name:"Overview",icon:ns,description:"Dashboard home"},{id:"roommates",name:j("Roommate Matches","Flatmate Matches"),icon:oe,description:j("Compatible roommate suggestions","Compatible flatmate suggestions")},{id:"messages",name:"Messages",icon:le,description:"All conversations"},{id:"favorites",name:"Saved",icon:pe,description:"All saved items"},{id:"hunting-agent",name:"Home-hunting Agent",icon:Is,description:j("Daily shortlist and landlord messages","Daily shortlist and messages to owners")},{id:"viewings",name:"My Viewings",icon:Qe,description:j("Viewings you booked with landlords","Viewings you booked with owners")},{id:"tasks",name:"Snesty & Reminders",icon:Ds,description:j("Snesty on WhatsApp/text, tasks and reminders","Snesty on WhatsApp, tasks and reminders")}]},{category:"ACCOUNT",items:[{id:"profile",name:"Profile",icon:is,description:"Personal information"},{id:"roommate-preferences",name:j("Roommate Preferences","Flatmate Preferences"),icon:oe,description:"Matching criteria"},{id:"subscription",name:j("Subscription","Your plan"),icon:$s,description:j("Plan and billing","Free in India")},{id:"email-settings",name:"Email Notifications",icon:Ms,description:"Your inbox and device alerts"},{id:"my-rentals",name:"My Rentals",icon:qe,description:j("Your homes, leads and viewings as a landlord","Your flats, leads and viewings as an owner"),href:"/landlord"}]},{category:"SUPPORT",items:we()==="in"?[]:[{id:"resources",name:"Resources",icon:hs,description:"Housing & life resources"}]}],x=l.useCallback(async()=>{if(!t)try{const p=await n();let E="";try{E=Intl.DateTimeFormat().resolvedOptions().timeZone||""}catch{}const[Y,v,V]=await Promise.allSettled([Re("/users/profile",{},p||void 0,a),Re(`/users/dashboard/stats${E?`?tz=${encodeURIComponent(E)}`:""}`,{},p||void 0,a),Re("/users/dashboard/activity",{},p||void 0,a)]),D=_=>_.status==="fulfilled"?_.value?.data:void 0;k(_=>({profile:D(Y)??_?.profile??{firstName:a?.firstName||"",completionPercentage:0},stats:D(v)??_?.stats??null,activity:D(V)??_?.activity??[]}))}finally{d(!1)}},[a,n]),P=l.useCallback(async()=>{d(!0),await x()},[x]);l.useEffect(()=>{t||x()},[x,t]),l.useEffect(()=>{const p=()=>{P()};return window.addEventListener("refreshDashboard",p),()=>{window.removeEventListener("refreshDashboard",p)}},[P]),l.useEffect(()=>{const p=localStorage.getItem("dashboardSection");p&&(b(p),localStorage.removeItem("dashboardSection"))},[]),l.useEffect(()=>{const p=r.get("section");if(p){const E=vr[p];if(E){m(E,{replace:!0});return}b(jr.includes(p)?p:"overview")}},[r]);const A=l.useRef(!1);l.useEffect(()=>{if(!A.current){A.current=!0;return}u&&r.get("section")!==u&&h(p=>{const E=new URLSearchParams(p);return E.set("section",u),E},{replace:!0})},[u]);const q=()=>{C(!1),I(!0)},re=()=>{C(!1),I(!0),P(),setTimeout(()=>{I(!1)},0)};return e.jsxs(Ta,{currentPage:"dashboard",isLoggedIn:!0,chatWidth:400,children:[e.jsx("div",{className:"w-full min-h-screen sn-page-bg pt-8",children:e.jsxs("div",{className:"flex px-4 sm:px-6 lg:h-screen lg:px-8",children:[e.jsx(Ea,{items:O.flatMap(p=>p.items.map(E=>({...E,isActive:u===E.id,onClick:"href"in E&&E.href?()=>m(E.href):()=>b(E.id)}))),defaultCollapsed:!0,className:"mr-6 hidden lg:block"}),e.jsx("div",{className:`flex-1 min-w-0 bg-gradient-to-br from-white to-gray-50/30 border border-gray-200/40 rounded-2xl shadow-lg backdrop-blur-sm lg:overflow-hidden lg:h-[calc(100dvh-8rem)] ${u==="messages"?"overflow-hidden h-[calc(100dvh-10rem)]":""}`,children:u==="messages"?e.jsx("div",{className:"sn-own-actions h-full flex flex-col",children:e.jsx(wr,{})}):e.jsxs("div",{className:"p-4 sm:p-6 lg:p-8 scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-transparent lg:h-full lg:overflow-y-auto lg:overscroll-contain",children:[i&&e.jsx(he,{label:"Loading your dashboard",hints:["Gathering your saved homes",j("Checking new roommate matches","Checking new flatmate matches"),"Almost there"],size:"lg",className:"min-h-[24rem]"}),!i&&e.jsxs("div",{className:"sn-dash-rise",children:[u==="overview"&&o&&e.jsx(e.Fragment,{children:e.jsx(kr,{data:o,loading:i,user:a,setCurrentPage:s,refreshDashboardData:P,setActiveSection:b})}),u==="roommate-preferences"&&e.jsx(Cr,{user:a}),u==="properties"&&e.jsx(dr,{user:a}),u==="roommates"&&e.jsx(Wa,{}),u==="favorites"&&e.jsx(Ga,{user:a}),u==="profile"&&e.jsx(qa,{user:a}),u==="subscription"&&e.jsx(er,{}
1),u==="email-settings"&&e.jsx(ir,{}),u==="tasks"&&e.jsx(cr,{}),u==="hunting-agent"&&e.jsx(vt,{}),u==="viewings"&&e.jsx(Va,{}),u==="resources"&&we()!=="in"&&e.jsxs(e.Fragment,{children:[e.jsx(ne,{icon:hs,eyebrow:"Support",title:"Housing &",accent:"life resources",subtitle:"Guides for renting, moving and living well, and Snesty for anything else."}),e.jsx(Ra,{embedded:!0})]}),!o&&u==="overview"&&e.jsxs("div",{className:"space-y-8",children:[e.jsx(ne,{eyebrow:"Overview",title:"Welcome back to your",accent:"dashboard",subtitle:"Here's what's happening with your housing journey."}),e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-gray-500",children:"Dashboard content will load here..."})})]})]},u)]})})]})}),e.jsx(mr,{isVisible:R,onClose:q,onVerificationComplete:re})]})}function Ui(){const s=He();zs();const a=Ia(),n="https://snestico.ai/dashboard",m=r=>{s(`/${r}`)};return e.jsxs(e.Fragment,{children:[e.jsx(Da,{title:"Dashboard - Manage Your Account & Preferences",description:"Access your Snestico dashboard to manage your profile, housing preferences, roommate matching settings, saved listings, and account information.",keywords:"user dashboard, account management, profile settings, housing preferences, roommate preferences, saved listings",url:n,canonical:n}),a?e.jsx(ft,{feature:"dashboard",children:e.jsx(js,{page:"dashboard"})}):e.jsx(Gs,{children:e.jsxs("div",{className:"min-h-screen",children:[e.jsx("h1",{className:"sr-only",children:"Your Snestico Dashboard"}),e.jsx(Ar,{setCurrentPage:m}),e.jsx(js,{page:"dashboard"})]})})]})}export{Ui as DashboardPage};

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.