1import{b as pe,u as ge,a as ke,r as i,c as be,j as o}from"./vendor-react-BoyrKzsG.js";import{u as xe,x as p,y as ye,R as b,n as c,f as ve}from"./index-CKCEYSTE.js";import{m as _}from"./matchingService-DZ7Irfqh.js";import{P as we}from"./PageHeader-D3Dh_hTn.js";import{R as Ce}from"./ReportModal-Djso_o-l.js";import{C as je}from"./ConfirmationModal-BP8DnJuo.js";import{C as Me}from"./CelebrationOverlay-DBNBYkLQ.js";import{P as Pe}from"./ProfileContent-DrbFENam.js";import{ak as Se,Y as Ie,o as Ne,al as Re}from"./vendor-ui-Cy9YOY35.js";import"./vendor-firebase-DbFCdLkQ.js";import"./PresenceUserAvatar-CaCTdJ4P.js";import"./VerifiedBadge-Dj5XxG7k.js";import"./badgeVisuals-CdkYXfCA.js";const He=()=>{var V,X,J,Q;const{userId:f}=pe(),l=ge(),x=ke(),{user:r,isGuest:F}=xe(),[e,T]=i.useState(null),[te,y]=i.useState(!0),[g,v]=i.useState(!1),w=i.useRef(null),[$]=be(),[se,C]=i.useState(!1),[oe,z]=i.useState(!1),[ae,j]=i.useState(!1),[re,M]=i.useState(!1),[P,S]=i.useState(""),[h,q]=i.useState(null),[O,I]=i.useState(!1),[N,ie]=i.useState(null),[D,Ue]=i.useState(null),[ne,Y]=i.useState(!1),u=$.get("matched")==="true",m=$.get("preview")==="true",n=x.state,G=(n==null?void 0:n.viewMode)==="focus"&&(n==null?void 0:n.searchResults)!=null,k=(n==null?void 0:n.searchResults)||[],H=(n==null?void 0:n.focusIndex)||0,R=(n==null?void 0:n.actedProfileIds)||[],U=(s="pass")=>{if(!G)return!1;const a=H+1,t=s==="like"&&(e!=null&&e.id)?[...R,e.id]:[...R];return a<k.length?(l(`/matching/${k[a].id}`,{state:{...n,focusIndex:a,actedProfileIds:t},replace:!0}),!0):(l("/matching/",{state:{...n,reviewedAll:!0,actedProfileIds:t}}),!0)};i.useEffect(()=>{(async()=>{var a;if(!f){l("/matching/");return}y(!0);try{const t=k.find(E=>E.id===f);t&&(T({...t,matchScore:t.matchScore||90,compatibilityScore:t.compatibilityScore}),y(!1));const[d,Z]=await Promise.all([b.getUserRepository(),u&&r?b.getChatRepository():Promise.resolve(null)]),he=[d.getById(f),Z&&r?Z.getConversationByParticipants([r.uid,f]):null],[ee,L]=await Promise.all(he);if(ee){const E={id:f,...ee,matchScore:(t==null?void 0:t.matchScore)||90,compatibilityScore:t==null?void 0:t.compatibilityScore};T(E),L&&(q(L),I(((a=L.mutedBy)==null?void 0:a.includes(r==null?void 0:r.uid))||!1))}else t||(c.error("Profile not found"),l("/matching/"))}catch(t){console.error("Failed to fetch profile through DAL",t),e||(c.error("Could not load profile"),l("/matching/"))}finally{y(!1)}})()},[f,l,r,u]),i.useEffect(()=>{e&&p("matching_profile_view",{targetUserId:e.id,matchScore:e.matchScore,isMatched:u,isPreviewMode:m})},[e==null?void 0:e.id]),i.useEffect(()=>{const s=a=>{w.current&&!w.current.contains(a.target)&&v(!1)};return g&&document.addEventListener("mousedown",s),()=>{document.removeEventListener("mousedown",s)}},[g]);const B=s=>{var t;const a=typeof s=="string"?s:void 0;if(m){l("/profile/");return}if(u){l(-1);return}if((t=x.state)!=null&&t.fromSearch){const d=[...R];a&&!d.includes(a)&&d.push(a),l("/matching/",{state:{...x.state,actedProfileId:a,actedProfileIds:d}})}else l("/matching/")},W=async s=>{if(F){c.info(`Please create an account to ${s==="like"?"like":"pass"} profiles`);return}if(!(!r||!e)){if(s==="like"){p("matching_action_intent",{action:"like",targetUserId:e.id}),C(!0);return}try{p("matching_action",{action:"pass",targetUserId:e.id});const a=await _.recordAction(r.uid,e.id,"pass");if(!a.success){c.error(a.reason||"Action failed");return}U("pass")||B()}catch(a){console.error("Action failed:",a),c.error("Could not process action")}}},ce=()=>{if(!r||!e||ne)return;const s=P.trim()||void 0,a=e.id;C(!1),S(""),Y(!0),U("like"),_.recordAction(r.uid,a,"like",s).then(t=>{var d;if(!t.success){(d=t.reason)!=null&&d.toLowerCase().includes("upgrade")?ve.getState().show({feature:"Unlimited Bonds",description:t.reason,source:"matching_profile_page"}):c.error(t.reason||"Action failed");return}p("matching_action",{action:"like",targetUserId:a,hasMessage:!!s,isMatch:t.isMatch}),t.isMatch&&t.matchId&&l(`/chat/${t.matchId}`)}).catch(t=>{console.error("Action failed:",t),c.error("Could not process action")}).finally(()=>{Y(!1)})},A=s=>{if(v(!1),F){c.info("Please create an account to use this feature");return}switch(s){case"report":z(!0);break;case"block":de();break;case"mute":me();break}p("matching_menu_action",{action:s,targetUserId:e.id})},le=async(s,a)=>
1{if(!(!r||!e))try{await(await b.getUserRepository()).reportUser({reporterId:r.uid,targetId:e.id,targetType:"user",reason:s,description:a,contextId:h==null?void 0:h.id}),c.success("Thank you for your report. We'll look into it.")}catch(t){console.error("Report failed:",t),c.error("Failed to submit report")}},de=async()=>{j(!0)},ue=async()=>{if(!(!r||!e)){M(!0);try{const s=await _.blockUser(r.uid,e.id);if(!s.success){c.error(s.reason||"Failed to block user"),M(!1);return}c.success(`${e.displayName} has been blocked`),j(!1),l("/matching/")}catch(s){console.error("Block failed:",s),c.error("Failed to block user")}finally{M(!1)}}},me=async()=>{if(!(!r||!e))try{const s=await b.getChatRepository();let a=h==null?void 0:h.id;if(!a&&u){const t=await s.getConversationByParticipants([r.uid,e.id]);t&&(q(t),a=t.id)}if(!a){c.error("No active conversation to mute");return}O?(await s.unmuteConversation(a,r.uid),I(!1),c.success("Notifications unmuted")):(await s.muteConversation(a,r.uid),I(!0),c.success("Notifications muted"))}catch(s){console.error("Mute failed:",s),c.error("Failed to update mute status")}},K=["https://images.unsplash.com/photo-1470252649378-9c29740c9fa8?q=80&w=2070&auto=format&fit=crop","https://images.unsplash.com/photo-1497935586351-b67a49e012bf?q=80&w=2071&auto=format&fit=crop","https://images.unsplash.com/photo-1518173946687-a4c8892bbd9f?q=80&w=2590&auto=format&fit=crop","https://images.unsplash.com/photo-1447933601403-0c6688de566e?q=80&w=2561&auto=format&fit=crop"],fe=()=>{const s=Math.floor(Math.random()*K.length);return K[s]},[Be]=i.useState(fe());return te?o.jsx("div",{className:"matching-profile-page loading-state",children:o.jsx(ye,{})}):e?((V=e.profile)!=null&&V.expressivePrompts,o.jsxs("div",{className:"matching-profile-page",children:[o.jsx(we,{title:m?"Profile Preview":(e==null?void 0:e.displayName)||"Connection Profile",subtitle:m?"This is how others see you":(X=e==null?void 0:e.profile)!=null&&X.bio?e.profile.bio.substring(0,40)+"...":"",onBack:B,renderRight:m?null:o.jsxs("div",{className:"header-menu",ref:w,children:[o.jsx("button",{onClick:()=>v(!g),className:"menu-button","aria-label":"Menu",style:{background:"none",border:"none",padding:"0.5rem",borderRadius:"50%"},children:o.jsx(Se,{size:24})}),g&&o.jsxs("div",{className:"menu-dropdown",children:[o.jsx("button",{onClick:()=>A("report"),children:"Report User"}),o.jsx("button",{onClick:()=>A("block"),children:"Block User"}),o.jsx("button",{onClick:()=>A("mute"),children:O?"Unmute Notifications":"Mute Notifications"})]})]})}),G&&o.jsx("div",{className:"focus-counter-container",style:{display:"flex",justifyContent:"center",padding:"0.5rem 0"},children:o.jsxs("div",{className:"focus-counter-pill",style:{backgroundColor:"var(--surface-color)",padding:"0.25rem 0.75rem",borderRadius:"1rem",fontSize:"0.85rem",color:"var(--text-secondary)",boxShadow:"0 2px 4px rgba(0,0,0,0.05)"},children:[H+1," of ",k.length," Bonds"]})}),o.jsx(Ce,{isOpen:oe,onClose:()=>z(!1),onSubmit:le,targetName:e.displayName}),o.jsx(je,{isOpen:ae,onClose:()=>j(!1),onConfirm:ue,title:`Block ${e.displayName}?`,message:"You won't see each other again and any active conversation will be deleted. This action cannot be undone.",confirmText:"Block User",cancelText:"Keep Profile",variant:"danger",isLoading:re}),o.jsx("div",{className:"profile-container-wrapped",children:o.jsx(Pe,{profile:e,isMatched:u,isPreviewMode:m,actionButtons:!u&&!m?o.jsxs("div",{className:"profile-actions-container",children:[o.jsx("button",{className:"action-button action-pass",onClick:()=>W("pass"),children:o.jsx(Ie,{size:28})}),o.jsx("button",{className:"action-button action-like",onClick:()=>W("like"),children:o.jsx(Ne,{size:28})})]}):null})}),N&&o.jsx(Me,{userName:N.name,userPhoto:N.photo,showPhoto:((Q=(J=e.settings)==null?void 0:J.privacySettings)==null?void 0:Q.showProfilePhoto)!==!1,onClose:()=>{ie(null),D?l(`/chat/${D}`):U("like")||B(e.id)}}),se&&e&&o.jsx("div",{className:"message-modal-overlay",onClick:()=>{C(!1),S("")},children:o.jsxs("div",{className:"message-modal",onClick:s=>s.stopPropagation(),children:[o.jsx("div",{className:"message-modal-handle"}),o.jsx("div",{className:"message-modal-header",children:o.jsxs("h3",{children:["Connect with ",e.displayName]})}),o.jsx("textarea",{className:"message-input",placeholder:"Add a message... (optional)",value:P,onChange:s=>S(s.target.value),maxLength:100,rows:2}),o.jsxs("div",{className:"message-char-count",children:[P.length,"/100"]}),o.jsx("div",{className:"message-modal-actions",children:o.jsx("button",{className:"message-send-btn",onClick:()=>ce(),"aria-label":"Like",children:o.jsx(Re,{size:24,strokeWidth:2.5})})})]})})]})):null};export{He as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.