import{$ as e,C as t,D as n,I as r,J as i,L as a,O as o,U as s,W as c,X as l,a as u,b as d,m as f,r as p,v as m,w as h,x as g}from"./app-DD-WFwVV.js";import{t as _}from"./i18n-DF9C9ux9.js";import{t as v}from"./AppLayout-DkSUjqpy.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`},F={class:`mt-5 grid grid-cols-2 gap-3`},ee={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=o({__name:`Invite`,props:{link:{},code:{},joined:{},sent:{}},setup(o){let q=o,J=i(!1);async function Y(){try{await navigator.clipboard.writeText(q.link),J.value=!0,setTimeout(()=>J.value=!1,1800)}catch{}}let X=i(``),Z=u({emails:[],message:``}),Q=d(()=>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(i,u)=>(r(),h(m,null,[n(l(p),{title:l(_)(`Invite friends`)},null,8,[`title`]),n(v,null,{default:s(()=>[g(`div`,y,[g(`h1`,b,e(l(_)(`Invite your friends`)),1),g(`p`,x,e(l(_)(`Share your personal link or send invites by email. When someone joins through you, they’ll show up here.`)),1),g(`section`,S,[g(`h2`,C,e(l(_)(`Your invite link`)),1),g(`p`,w,e(l(_)(`Anyone who signs up with this link is credited to you.`)),1),g(`div`,T,[g(`input`,{value:o.link,readonly:``,class:`w-full truncate rounded-lg border-line bg-appbg text-sm text-ink-2`,onFocus:u[0]||=e=>e.target.select()},null,40,E),g(`button`,{class:`shrink-0 rounded-lg bg-primary px-4 py-2 text-sm font-semibold text-white hover:bg-primary-600`,onClick:Y},e(J.value?l(_)(`Copied!`):l(_)(`Copy link`)),1)])]),g(`section`,D,[g(`h2`,O,e(l(_)(`Invite by email`)),1),g(`p`,k,e(l(_)(`Enter up to 10 email addresses, separated by commas or new lines.`)),1),c(g(`textarea`,{"onUpdate:modelValue":u[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),[[f,X.value]]),c(g(`textarea`,{"onUpdate:modelValue":u[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),[[f,l(Z).message]]),g(`div`,M,[g(`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:$},e(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(),h(`span`,P,e(Q.value.length)+` `+e(l(_)(`valid`)),1)):t(``,!0)])]),g(`section`,F,[g(`div`,ee,[g(`div`,I,e(o.joined),1),g(`div`,L,e(l(_)(`joined through you`)),1)]),g(`div`,R,[g(`div`,z,e(o.sent.length),1),g(`div`,B,e(l(_)(`email invites sent`)),1)])]),o.sent.length?(r(),h(`section`,V,[g(`h2`,H,e(l(_)(`Sent invitations`)),1),g(`ul`,U,[(r(!0),h(m,null,a(o.sent,(t,n)=>(r(),h(`li`,{key:n,class:`flex items-center justify-between py-2.5 text-sm`},[g(`span`,W,e(t.email),1),t.joined?(r(),h(`span`,G,e(l(_)(`Joined`)),1)):(r(),h(`span`,K,e(l(_)(`Pending`))+` · `+e(t.sentAt),1))]))),128))])])):t(``,!0)])]),_:1})],64))}});export{q as default};