import{C as e,D as t,E as n,F as r,H as i,I as a,Q as o,S as s,U as c,Y as l,_ as u,b as d,i as f,n as p,p as m,q as h,y as g}from"./app-lC2oAIsL.js";import{t as _}from"./i18n-1u_ZOjdz.js";import{t as v}from"./AppLayout-Cw24KsKs.js";var y={class:`mx-auto max-w-2xl px-4 py-8`},b={class:`text-2xl font-extrabold text-ink`},x={class:`mt-1.5 text-ink-2`},S={class:`mt-6 rounded-2xl border border-line bg-surface p-5`},C={class:`text-sm font-bold text-ink`},w={class:`mt-1 text-xs text-ink-muted`},T={class:`mt-3 flex flex-col gap-2 sm:flex-row`},E=[`value`],D={class:`mt-5 rounded-2xl border border-line bg-surface p-5`},O={class:`text-sm font-bold text-ink`},k={class:`mt-1 text-xs text-ink-muted`},A=[`placeholder`],j=[`placeholder`],M={class:`mt-3 flex items-center gap-3`},N=[`disabled`],P={key:0,class:`text-xs text-ink-muted`},ee={class:`mt-5 grid grid-cols-2 gap-3`},F={class:`rounded-2xl border border-line bg-surface p-5 text-center`},I={class:`text-3xl font-black text-primary`},L={class:`mt-1 text-xs font-semibold text-ink-muted`},R={class:`rounded-2xl border border-line bg-surface p-5 text-center`},z={class:`text-3xl font-black text-ink`},B={class:`mt-1 text-xs font-semibold text-ink-muted`},V={key:0,class:`mt-5 rounded-2xl border border-line bg-surface p-5`},H={class:`mb-2 text-sm font-bold text-ink`},U={class:`divide-y divide-line`},W={class:`truncate text-ink-2`},G={key:0,class:`shrink-0 rounded-full bg-emerald-500/15 px-2 py-0.5 text-xs font-bold text-emerald-600 dark:text-emerald-400`},K={key:1,class:`shrink-0 text-xs text-ink-muted`},q=t({__name:`Invite`,props:{link:{},code:{},joined:{},sent:{}},setup(t){let q=t,J=h(!1);async function Y(){try{await navigator.clipboard.writeText(q.link),J.value=!0,setTimeout(()=>J.value=!1,1800)}catch{}}let X=h(``),Z=f({emails:[],message:``}),Q=g(()=>X.value.split(/[\s,;]+/).map(e=>e.trim()).filter(e=>/.+@.+\..+/.test(e)));function $(){Z.emails=Q.value,Z.emails.length&&Z.post(`/invite/send`,{preserveScroll:!0,onSuccess:()=>{X.value=``,Z.reset(`message`)}})}return(f,h)=>(r(),e(u,null,[n(l(p),{title:l(_)(`Invite friends`)},null,8,[`title`]),n(v,null,{default:i(()=>[d(`div`,y,[d(`h1`,b,o(l(_)(`Invite your friends`)),1),d(`p`,x,o(l(_)(`Share your personal link or send invites by email. When someone joins through you, they’ll show up here.`)),1),d(`section`,S,[d(`h2`,C,o(l(_)(`Your invite link`)),1),d(`p`,w,o(l(_)(`Anyone who signs up with this link is credited to you.`)),1),d(`div`,T,[d(`input`,{value:t.link,readonly:``,class:`w-full truncate rounded-lg border-line bg-appbg text-sm text-ink-2`,onFocus:h[0]||=e=>e.target.select()},null,40,E),d(`button`,{class:`shrink-0 rounded-lg bg-primary px-4 py-2 text-sm font-semibold text-white hover:bg-primary-600`,onClick:Y},o(J.value?l(_)(`Copied!`):l(_)(`Copy link`)),1)])]),d(`section`,D,[d(`h2`,O,o(l(_)(`Invite by email`)),1),d(`p`,k,o(l(_)(`Enter up to 10 email addresses, separated by commas or new lines.`)),1),c(d(`textarea`,{"onUpdate:modelValue":h[1]||=e=>X.value=e,rows:`3`,placeholder:l(_)(`friend@example.com, another@example.com`),class:`mt-3 w-full rounded-lg border-line bg-appbg text-sm text-ink placeholder:text-ink-muted focus:border-primary focus:ring-primary`},null,8,A),[[m,X.value]]),c(d(`textarea`,{"onUpdate:modelValue":h[2]||=e=>l(Z).message=e,rows:`2`,maxlength:500,placeholder:l(_)(`Add a personal note (optional)`),class:`mt-2 w-full rounded-lg border-line bg-appbg text-sm text-ink placeholder:text-ink-muted focus:border-primary focus:ring-primary`},null,8,j),[[m,l(Z).message]]),d(`div`,M,[d(`button`,{disabled:!Q.value.length||l(Z).processing,class:`rounded-lg bg-primary px-4 py-2 text-sm font-semibold text-white hover:bg-primary-600 disabled:opacity-50`,onClick:$},o(l(Z).processing?l(_)(`Sending…`):Q.value.length===1?l(_)(`Send 1 invite`):l(_)(`Send {n} invites`,{n:Q.value.length||0})),9,N),Q.value.length?(r(),e(`span`,P,o(Q.value.length)+` `+o(l(_)(`valid`)),1)):s(``,!0)])]),d(`section`,ee,[d(`div`,F,[d(`div`,I,o(t.joined),1),d(`div`,L,o(l(_)(`joined through you`)),1)]),d(`div`,R,[d(`div`,z,o(t.sent.length),1),d(`div`,B,o(l(_)(`email invites sent`)),1)])]),t.sent.length?(r(),e(`section`,V,[d(`h2`,H,o(l(_)(`Sent invitations`)),1),d(`ul`,U,[(r(!0),e(u,null,a(t.sent,(t,n)=>(r(),e(`li`,{key:n,class:`flex items-center justify-between py-2.5 text-sm`},[d(`span`,W,o(t.email),1),t.joined?(r(),e(`span`,G,o(l(_)(`Joined`)),1)):(r(),e(`span`,K,o(l(_)(`Pending`))+` · `+o(t.sentAt),1))]))),128))])])):s(``,!0)])]),_:1})],64))}});export{q as default};