1import{bn as k,b as q,g as S,r as a,j as e,B as p,e as c,aR as w,aS as C,aT as F,C as b,U as A,s as u,cT as B,h as m}from"./index-Cu7LKwbt.js";const I=()=>{var h;const{inviterId:s}=k(),{user:t}=q(),d=S(),[n,j]=a.useState(null),[y,v]=a.useState(!0),[o,f]=a.useState(!1),[x,i]=a.useState("idle");a.useEffect(()=>{(async()=>{if(!s)return;const{data:l}=await u.from("profiles_public").select("username, avatar_url").eq("user_id",s).maybeSingle();j(l),v(!1)})()},[s]),a.useEffect(()=>{(async()=>{if(!t||!s||t.id===s)return;const{data:l}=await u.from("friendships").select("id").or(`and(user_id_1.eq.${t.id},user_id_2.eq.${s}),and(user_id_1.eq.${s},user_id_2.eq.${t.id})`);if(l&&l.length>0){i("already_friends");return}const{data:g}=await u.from("friend_requests").select("id").eq("from_user_id",t.id).eq("to_user_id",s).eq("status","pending");g&&g.length>0&&i("sent")})()},[t,s]);const _=async()=>{if(!t){d(`/auth?redirect=/invite/${s}`);return}if(!s||t.id===s||o)return;f(!0);const r=await B(t.id,s);if(f(!1),r.error){m.error(r.error.message||"Could not send request.");return}if(r.status==="accepted"||r.status==="already_friends"){i("already_friends"),m.success("Youâre now friends! ð");return}i("sent"),m.success(r.status==="already_sent"?"Friend request already sent":"Friend request sent! ð")};if(y)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(p,{})});if(!n)return e.jsxs("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center px-4",children:[e.jsx("p",{className:"text-muted-foreground font-semibold",children:"User not found"}),e.jsx(c,{variant:"ghost",className:"mt-4",onClick:()=>d("/"),children:"Go Home"})]});const N=(t==null?void 0:t.id)===s;return e.jsx("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center px-4 pb-20",children:e.jsxs("div",{className:"max-w-sm w-full text-center space-y-6",children:[e.jsxs(w,{className:"h-20 w-20 mx-auto",style:{border:"4px solid",borderImage:"linear-gradient(180deg, hsl(142,71%,45%), hsl(0,84%,60%)) 1"},children:[n.avatar_url?e.jsx(C,{src:n.avatar_url}):null,e.jsx(F,{className:"text-2xl font-bold bg-primary/10 text-primary",children:(h=(n.username||"?")[0])==null?void 0:h.toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-display font-bold",style:{background:"linear-gradient(90deg, hsl(142,71%,45%), hsl(48,96%,53%), hsl(25,95%,53%), hsl(0,84%,60%))",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent"},children:n.username||"A Biblez user"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"wants to be your friend on Biblez!"})]}),N?e.jsx("p",{className:"text-sm text-muted-foreground",children:"This is your own invite link"}):x==="already_friends"?e.jsxs("div",{className:"flex items-center justify-center gap-2 text-primary font-semibold",children:[e.jsx(b,{className:"h-5 w-5"}),"You're already friends!"]}):x==="sent"?e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground font-semibold",children:[e.jsx(b,{className:"h-5 w-5"}),"Friend request sent!"]}):e.jsxs(c,{type:"button",onClick:r=>{r.preventDefault(),_()},disabled:o,className:"rounded-full font-semibold px-8 text-white border-0",size:"lg",style:{background:"linear-gradient(90deg, hsl(142,71%,45%), hsl(48,96%,53%), hsl(25,95%,53%), hsl(0,84%,60%))",touchAction:"manipulation",WebkitTapHighlightColor:"transparent"},children:[o?e.jsx(p,{size:"sm"}):e.jsx(A,{className:"h-4 w-4 mr-2 pointer-events-none"}),t?"Send Friend Request":"Sign in & Add Friend"]}),e.jsx(c,{variant:"ghost",className:"text-sm",onClick:()=>d("/"),children:"Go to Biblez"})]})})};export{I 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.