import{$ as e,C as t,D as n,E as r,F as i,H as a,I as o,Q as s,S as c,T as l,U as u,X as d,Y as f,_ as p,a as m,b as h,i as g,l as _,n as v,p as y,q as b,y as x}from"./app-f0AvJ4HL.js";import{t as S}from"./AdminLayout-BiDKYSg7.js";var C={key:0,class:`mb-5 rounded-xl border border-emerald-500/30 bg-emerald-500/10 px-4 py-3 text-sm text-emerald-300`},w={class:`grid gap-6 lg:grid-cols-[1fr_1.4fr]`},T={class:`space-y-6`},E={class:`rounded-2xl border border-line bg-surface p-5`},D={class:`flex items-center gap-2 text-sm text-ink-2`},O={class:`rounded-2xl border border-line bg-surface p-5`},k={class:`mt-3 grid grid-cols-2 gap-3`},A={class:`rounded-2xl border border-line bg-surface p-5`},j={key:0,class:`text-sm text-ink-muted`},M={key:1,class:`divide-y divide-line`},N={class:`min-w-0 flex-1`},P={class:`flex items-center gap-2`},F={class:`rounded bg-appbg px-2 py-0.5 text-sm font-bold text-ink select-all`},I={key:0,class:`rounded-full bg-red-500/15 px-2 py-0.5 text-[10px] font-bold uppercase text-red-300`},L={class:`mt-0.5 truncate text-xs text-ink-muted`},R={key:0},z={key:1},B={key:2},V=[`onClick`],H=[`onClick`],U=`mt-1 w-full rounded-lg border-line bg-appbg text-ink placeholder:text-ink-muted focus:border-primary focus:ring-primary text-sm`,W=n({__name:`Invites`,props:{inviteOnly:{type:Boolean},registerBase:{},invites:{}},setup(n){let W=n,G=m(),K=x(()=>G.props.flash?.status),q=b(W.inviteOnly);function J(){e.post(`/admin/invites/only`,{invite_only:q.value},{preserveScroll:!0})}let Y=g({note:``,email:``,max_uses:1,expires_days:null});function X(){Y.post(`/admin/invites`,{preserveScroll:!0,onSuccess:()=>Y.reset()})}function Z(t){confirm(`Revoke this invite? Its link will stop working.`)&&e.delete(`/admin/invites/${t}`,{preserveScroll:!0})}let Q=b(null);function $(e){navigator.clipboard?.writeText(W.registerBase+e.code),Q.value=e.id,setTimeout(()=>Q.value=null,1500)}return(e,m)=>(i(),t(p,null,[r(f(v),{title:`Admin · Invites`}),r(S,null,{title:a(()=>[...m[5]||=[l(`Invites`,-1)]]),subtitle:a(()=>[...m[6]||=[l(`Invite codes & invite-only registration`,-1)]]),default:a(()=>[K.value?(i(),t(`div`,C,s(K.value),1)):c(``,!0),h(`div`,w,[h(`div`,T,[h(`section`,E,[m[8]||=h(`h3`,{class:`mb-1 text-sm font-bold text-ink`},`Registration mode`,-1),m[9]||=h(`p`,{class:`mb-3 text-xs text-ink-muted`},`When invite-only is on, new members must enter a valid invite code to sign up.`,-1),h(`label`,D,[u(h(`input`,{"onUpdate:modelValue":m[0]||=e=>q.value=e,type:`checkbox`,class:`rounded border-line text-primary focus:ring-primary`,onChange:J},null,544),[[_,q.value]]),m[7]||=l(` Invite-only registration `,-1)])]),h(`section`,O,[m[12]||=h(`h3`,{class:`mb-3 text-sm font-bold text-ink`},`Create an invite`,-1),m[13]||=h(`label`,{class:`block text-xs font-semibold text-ink-2`},[l(`Note `),h(`span`,{class:`font-normal text-ink-muted`},`(optional)`)],-1),u(h(`input`,{"onUpdate:modelValue":m[1]||=e=>f(Y).note=e,class:d(U),placeholder:`e.g. Beta testers`},null,512),[[y,f(Y).note]]),m[14]||=h(`label`,{class:`mt-3 block text-xs font-semibold text-ink-2`},[l(`Reserve for email `),h(`span`,{class:`font-normal text-ink-muted`},`(optional)`)],-1),u(h(`input`,{"onUpdate:modelValue":m[2]||=e=>f(Y).email=e,type:`email`,class:d(U),placeholder:`friend@example.com`},null,512),[[y,f(Y).email]]),h(`div`,k,[h(`div`,null,[m[10]||=h(`label`,{class:`block text-xs font-semibold text-ink-2`},`Max uses`,-1),u(h(`input`,{"onUpdate:modelValue":m[3]||=e=>f(Y).max_uses=e,type:`number`,min:`1`,class:d(U)},null,512),[[y,f(Y).max_uses,void 0,{number:!0}]])]),h(`div`,null,[m[11]||=h(`label`,{class:`block text-xs font-semibold text-ink-2`},`Expires in (days)`,-1),u(h(`input`,{"onUpdate:modelValue":m[4]||=e=>f(Y).expires_days=e,type:`number`,min:`1`,class:d(U),placeholder:`never`},null,512),[[y,f(Y).expires_days,void 0,{number:!0}]])])]),h(`button`,{class:`mt-4 rounded-lg bg-primary px-4 py-2 text-sm font-semibold text-white hover:bg-primary-600`,onClick:X},`Create invite`)])]),h(`section`,A,[m[15]||=h(`h3`,{class:`mb-3 text-sm font-bold text-ink`},`Invites`,-1),n.invites.length?(i(),t(`ul`,M,[(i(!0),t(p,null,o(n.invites,e=>(i(),t(`li`,{key:e.id,class:`flex items-center gap-3 py-3`},[h(`div`,N,[h(`div`,P,[h(`code`,F,s(e.code),1),e.usable?c(``,!0):(i(),t(`span`,I,`used up`))]),h(`div`,L,[l(s(e.uses)+`/`+s(e.maxUses)+` used`,1),e.note?(i(),t(`span`,R,` · `+s(e.note),1)):c(``,!0),e.email?(i(),t(`span`,z,` · `+s(e.email),1)):c(``,!0),e.expiresAt?(i(),t(`span`,B,` · expires `+s(e.expiresAt),1)):c(``,!0)])]),h(`button`,{class:`rounded-lg bg-surface-2 px-2.5 py-1.5 text-xs font-semibold text-ink hover:bg-appbg`,onClick:t=>$(e)},s(Q.value===e.id?`Copied!`:`Copy link`),9,V),h(`button`,{class:`rounded-lg px-2.5 py-1.5 text-xs font-semibold text-red-400 hover:bg-red-500/10`,onClick:t=>Z(e.id)},`Revoke`,8,H)]))),128))])):(i(),t(`div`,j,`No invites yet.`))])])]),_:1})],64))}});export{W as default};