1import{r as m,j as e,w as N,a9 as w,b4 as v,S as k}from"./vendor-ui-D1HVVX_b.js";import{f as q,H as S,F as _,s as p}from"./index-dNOZpEEP.js";import{a as A}from"./useQuery-DfI5LXXJ.js";import{e as Q,L as h}from"./vendor-react-D1Y29V_l.js";import{m as l,A as C}from"./vendor-framer-B4EWkOoB.js";import"./vendor-supabase-CXCDHvas.js";function T(){const{username:n}=Q(),[a,u]=m.useState(""),[o,d]=m.useState(!1),[g,x]=m.useState(!1),[c,i]=m.useState(""),{data:t,isLoading:y,isError:f}=A({queryKey:["qna-profile",n],queryFn:async()=>{if(!n)throw new Error("No username");const{data:s,error:r}=await p.from("profiles").select("user_id, username, display_name, avatar_url, bio").eq("username",n.toLowerCase()).single();if(r)throw r;return s},enabled:!!n}),b=async()=>{const s=a.trim();if(!(!s||o)){if(s.length>500){i("Question must be under 500 characters.");return}i(""),d(!0);try{const{error:r}=await p.from("qna_questions").insert({target_user_id:t.user_id,question_text:s});if(r)throw r;x(!0),u("")}catch(r){console.error("QnA submit error:",r),i("Something went wrong. Please try again.")}finally{d(!1)}}};if(y)return e.jsx(q,{});if(f||!t)return e.jsxs("div",{className:"min-h-screen bg-background text-foreground flex flex-col items-center justify-center p-4 text-center",children:[e.jsx("h2",{className:"text-xl font-black uppercase tracking-tight mb-2",children:"User Not Found"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-6",children:"This user doesn't exist or their profile is unavailable."}),e.jsx(h,{to:"/",className:"gum-btn bg-primary text-primary-foreground text-sm",children:"Go Home"})]});const j=t.display_name?.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2)||"??";return e.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[e.jsxs(S,{children:[e.jsxs("title",{children:["Ask @",t.username," â Nychthemeron"]}),e.jsx("meta",{name:"description",content:`Send an anonymous question to ${t.display_name||t.username} on Nychthemeron.`}),e.jsx("meta",{property:"og:title",content:`Ask @${t.username} anonymously â Nychthemeron`}),e.jsx("meta",{property:"og:description",content:`Send an anonymous question to ${t.display_name||t.username} on Nychthemeron. They won't know who asked.`}),e.jsx("meta",{property:"og:image",content:t.avatar_url||"/fav.jpg"}),e.jsx("meta",{name:"twitter:card",content:"summary"}),e.jsx("meta",{name:"twitter:title",content:`Ask @${t.username} anonymously â Nychthemeron`}),e.jsx("meta",{name:"twitter:description",content:`Send an anonymous question to ${t.display_name||t.username} on Nychthemeron.`}),e.jsx("meta",{name:"twitter:image",content:t.avatar_url||"/fav.jpg"})]}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-10",children:[e.jsxs(h,{to:`/u/${t.username}`,className:"inline-flex items-center gap-2 px-3 py-1.5 gum-card bg-secondary text-xs font-bold hover:bg-primary hover:text-primary-foreground transition-colors w-fit mb-8",children:[e.jsx(N,{size:14}),"View Profile"]}),e.jsxs(l.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"gum-card p-6 text-center mb-6",children:[e.jsx("div",{className:"w-20 h-20 rounded-[3px] gum-border bg-secondary flex items-center justify-center text-2xl font-bold mx-auto mb-4 overflow-hidden",children:t.avatar_url?e.jsx("img",{src:t.avatar_url,alt:t.username,className:"w-full h-full object-cover",loading:"lazy"}):j}),e.jsx("h1",{className:"text-xl font-black tracking-tight",children:t.display_name}),e.jsxs("p",{className:"text-muted-foreground text-sm mt-1",children:["@",t.username]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4 text-primary",children:[e.jsx(w,{size:18}),e.jsx("span",{className:"text-sm font-bold uppercase tracking-wider",children:"Ask me anything"})]})]}),e.jsx(C,{mode:"wait",children:g?e.jsxs(l.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0},className:"gum-card p-8 text-center",children:[e.jsx(v,{size:48,className:"text-green-500 mx-auto mb-4"}),e.jsx("h2",{className:"text-lg font-black uppercase tracking-tight mb-2",children:"Question Sent!"}),e.jsxs("p",{className:"text-muted-foreground text-sm mb-6",children:["Your question has been delivered anonymously to @",t.username,". They may answer it on their feed."]}),e.jsx("button",{onClick:()=>x(!1),className:"gum-btn bg-primary text-primary-foreground text-sm",children:"Ask Another Question"})]},"success"):e.jsxs(l.div,{initial:{opacity:0,y:10}
1,animate:{opacity:1,y:0},exit:{opacity:0},className:"gum-card p-6",children:[e.jsx("label",{htmlFor:"qna-question",className:"block text-xs font-bold uppercase tracking-wider text-muted-foreground mb-3",children:"Your Question (Anonymous)"}),e.jsx("textarea",{id:"qna-question",value:a,onChange:s=>{u(s.target.value),c&&i("")},placeholder:"Type your question here...",className:"w-full bg-secondary/40 gum-border p-3 resize-none outline-none text-sm min-h-[120px] rounded-[3px] placeholder:text-muted-foreground",maxLength:500,rows:4}),e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:`text-xs font-medium ${a.length>450?"text-destructive":"text-muted-foreground"}`,children:[a.length,"/500"]}),e.jsxs("button",{onClick:b,disabled:!a.trim()||o,className:"gum-btn bg-primary text-primary-foreground text-sm disabled:opacity-40 disabled:cursor-not-allowed flex items-center gap-2",children:[o?e.jsx(_,{size:14}):e.jsx(k,{size:14}),o?"Sending...":"Send Question"]})]}),c&&e.jsx("p",{className:"text-destructive text-xs font-medium mt-2",children:c})]},"form")}),e.jsx("p",{className:"text-center text-[10px] text-muted-foreground mt-8",children:"Questions are submitted anonymously. Be kind. â¤ï¸"})]})]})}export{T 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.