1import{j as e}from"./vendor-query-DdYYqZOr.js";import{r as s}from"./vendor-react-Dm5djFS-.js";import{$ as L,aM as T,aN as C,aO as P,T as D}from"./index-CUsdGunI.js";import{u as M}from"./vendor-i18n-BYSLZ8MU.js";import"./vendor-supabase-ClVc2H6D.js";import"./vendor-sentry-Cg5bi1Nt.js";function O(){const{t:r,i18n:i}=M(["referral","common"]),[a,j]=s.useState(null),[l,k]=s.useState(null),[x,N]=s.useState([]),[g,v]=s.useState(0),[d,m]=s.useState(1),[w,b]=s.useState(!0),[p,y]=s.useState(null),_=L(i.language),n=a!=null&&a.referral_code?`${window.location.origin}/${_}/register?ref=${a.referral_code}`:"",h=n?r("referral:referralText",{link:n}):"";s.useEffect(()=>{S()},[]),s.useEffect(()=>{R()},[d]);async function S(){b(!0);try{const[t,o]=await Promise.all([T(),C()]);t.success&&j(t),o.success&&k(o.stats)}catch(t){console.error("Failed to load referral data",t)}finally{b(!1)}}async function R(){try{const t=await P(d);t.success&&(N(t.items),v(t.total))}catch(t){console.error("Failed to load referral list",t)}}async function f(t,o){try{await navigator.clipboard.writeText(t),y(o),setTimeout(()=>y(null),2e3)}catch{}}const c=Math.ceil(g/20),u=i.language==="zh"?"zh-CN":"en-US";return w?e.jsx(D,{variant:"page",context:"data"}):e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-6",children:r("referral:title")}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-sm border dark:border-gray-700 p-6 mb-6",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-800 dark:text-gray-200 mb-4",children:r("referral:code.title")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-600 dark:text-gray-400 mb-1",children:r("referral:code.label")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-4 py-2 bg-gray-50 dark:bg-gray-900/50 border dark:border-gray-600 rounded-lg text-lg font-mono tracking-wider text-center",children:(a==null?void 0:a.referral_code)||"-"}),e.jsx("button",{onClick:()=>(a==null?void 0:a.referral_code)&&f(a.referral_code,"code"),className:"px-4 py-2 bg-blue-600 text-white text-sm rounded-lg hover:bg-blue-700 transition-colors whitespace-nowrap",children:r(p==="code"?"common:copied":"common:copy")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-600 dark:text-gray-400 mb-1",children:r("referral:code.linkLabel")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",readOnly:!0,value:n,className:"flex-1 px-3 py-2 bg-gray-50 dark:bg-gray-900/50 border dark:border-gray-600 rounded-lg text-sm text-gray-700 dark:text-gray-300"}),e.jsx("button",{onClick:()=>h&&f(h,"link"),className:"px-4 py-2 bg-blue-600 text-white text-sm rounded-lg hover:bg-blue-700 transition-colors whitespace-nowrap",children:r(p==="link"?"common:copied":"referral:code.copyLink")})]})]})]})]}),l&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-sm border dark:border-gray-700 p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600 dark:text-blue-400",children:l.total_invited}),e.jsx("div",{className:"text-sm text-gray-500 mt-1",children:r("referral:stats.totalInvited")})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-sm border dark:border-gray-700 p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-green-600 dark:text-green-400",children:l.completed_count}),e.jsx("div",{className:"text-sm text-gray-500 mt-1",children:r("referral:stats.activated")})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-sm border dark:border-gray-700 p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-amber-600 dark:text-amber-400",children:l.pending_count}),e.jsx("div",{className:"text-sm text-gray-500 mt-1",children:r("referral:stats.pendingActivation")})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-sm border dark:border-gray-700",children:[e.jsx("div",{className:"px-6 py-4 border-b dark:border-gray-700",children:e.jsx("h3",{className:"text-base font-semibold text-gray-800 dark:text-gray-200",children:r("referral:records.title")})}),x.length===0?e.jsx("div",{className:"px-6 py-12 text-center text-gray-400",children:r("referral:records.empty")}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50 text-gray-600 dark:text-gray-400",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left font-medium",children:r("referral:records.inv
1itee")}),e.jsx("th",{className:"px-6 py-3 text-left font-medium",children:r("referral:records.status")}),e.jsx("th",{className:"px-6 py-3 text-left font-medium",children:r("referral:records.invitedAt")}),e.jsx("th",{className:"px-6 py-3 text-left font-medium",children:r("referral:records.completedAt")})]})}),e.jsx("tbody",{className:"divide-y dark:divide-gray-700",children:x.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[e.jsx("td",{className:"px-6 py-3 text-gray-700 dark:text-gray-300",children:t.referee_email}),e.jsx("td",{className:"px-6 py-3",children:t.status==="completed"?e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-400",children:r("referral:records.completed")}):e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-amber-100 dark:bg-amber-900/40 text-amber-700 dark:text-amber-400",children:r("referral:records.pending")})}),e.jsx("td",{className:"px-6 py-3 text-gray-500 dark:text-gray-400",children:t.created_at?new Date(t.created_at).toLocaleDateString(u):"-"}),e.jsx("td",{className:"px-6 py-3 text-gray-500 dark:text-gray-400",children:t.completed_at?new Date(t.completed_at).toLocaleDateString(u):"-"})]},t.id))})]})}),c>1&&e.jsxs("div",{className:"px-6 py-3 border-t dark:border-gray-700 flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-gray-500",children:r("referral:records.totalRecords",{total:g})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:d<=1,onClick:()=>m(t=>t-1),className:"px-3 py-1 text-sm border dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed",children:r("common:pagination.prevPage")}),e.jsx("span",{className:"px-3 py-1 text-sm text-gray-600 dark:text-gray-400",children:r("common:pagination.pageInfo",{page:d,pages:c})}),e.jsx("button",{disabled:d>=c,onClick:()=>m(t=>t+1),className:"px-3 py-1 text-sm border dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed",children:r("common:pagination.nextPage")})]})]})]})]})]})}export{O 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.