1import{j as e}from"./vendor-query-CniT1WJL.js";import{u as L,r as C}from"./vendor-react-69GsFwrV.js";import{u as S,y as A,au as R,av as E,aw as u,ax as I,n as T,F as V,q as g,G as n,f as r,P as _,ay as B,V as M,az as F,M as $}from"./index-KjAD5lCC.js";import{A as z}from"./AccountNav-CGK2802V.js";import{A as O}from"./AccountSection-B7Ueu1lP.js";import{u as W,c as G}from"./useRedeemPointsAction-DaHEN51n.js";import{aF as q,aG as D,b1 as Y,a9 as H,S as b,a5 as U,$ as J,V as K,N as Q,b2 as X,b3 as Z,aN as ee}from"./vendor-ui-Ad3ANzF6.js";import"./vendor-forms-q6h4WU-p.js";const te={seed:b,sprout:H,canopy:Y,helix:D,apex:q},se=[{Icon:J,label:"Place an order",detail:"Earn 1 pt per $1 spent"},{Icon:K,label:"Refer a researcher",detail:"+250 pts when they qualify"},{Icon:Q,label:"Welcome bonus",detail:"+150 pts when you complete onboarding"},{Icon:X,label:"First sign-in",detail:"+100 pts the first time you log in"},{Icon:Z,label:"Birthday treat",detail:"+250 pts every year around your birthday"},{Icon:ee,label:"Leave a review",detail:"+50 pts per approved review"}];function ae(i){return{order:"Order reward",order_earn:"Order reward",referral:"Referral bonus",profile:"Profile completed",welcome:"Welcome bonus",first_login:"First sign-in bonus",birthday:"Birthday bonus",review:"Review reward",redeem:"Redeemed for VidaCredit",redemption:"Redeemed for VidaCredit",adjustment:"Adjustment"}[i]??i.replace(/[_-]/g," ").replace(/\b\w/g,o=>o.toUpperCase())}function xe(){const{isAuthenticated:i,isLoading:c}=S(),[,o]=L();C.useEffect(()=>{!c&&!i&&o("/login")},[c,i,o]);const m=A(i),l=R(i),s=m.data,x=s?.balance??0,j=((s?.storeCreditCents??0)/100).toFixed(2),{redeemBlock:f,isPending:N,canRedeem:v,blockPoints:d,blockCents:k}=W(s),h=G(k),y=s?.tiers&&s.tiers.length>0?s.tiers.map(t=>({slug:t.slug,name:t.name,minPoints:t.minPoints,multiplierLabel:u(t.multiplierBips),metal:E(t.slug).metal})):I.map(t=>({slug:t.slug,name:t.name,minPoints:t.minPoints,multiplierLabel:t.multiplierLabel,metal:t.metal})),{progress:w}=T(s),P=s?.lifetimeEarned??0;return e.jsxs(e.Fragment,{children:[e.jsx(z,{}),e.jsxs(V,{width:"narrow",className:"pb-8 pt-6 md:pb-12",children:[e.jsx("h1",{className:"mb-6 font-display text-t1 text-ink",children:"Points & rewards"}),m.isLoading?e.jsx(g,{className:"mb-5 h-44 w-full rounded-card"}):m.isError?e.jsx(n,{className:"mb-5 text-sm text-ink-2",children:"We couldn't load your points right now. Please try again shortly."}):e.jsxs(n,{tone:"dark",className:"vp-panel-gradient mb-5 border-0 text-white",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-overline uppercase text-vida-mint",children:"Points balance"}),e.jsx("p",{className:"mt-1 font-display text-[40px] font-bold leading-[1.05] tracking-[-0.03em] tabular-nums","data-testid":"text-points-balance",children:x.toLocaleString()}),e.jsxs("p",{className:"mt-1 text-caption text-white/70 tabular-nums",children:[P.toLocaleString()," earned from purchases"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-overline uppercase text-white/60",children:"Tier"}),e.jsx("p",{className:"mt-1 font-display text-t3 text-white","data-testid":"badge-tier",children:s?.tier?.name??"Seed"}),e.jsxs("p",{className:"mt-1 text-caption text-white/70 tabular-nums",children:["$",j," VidaCredit"]})]})]}),e.jsx("div",{className:"mt-5",children:s?.nextTier?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between text-caption text-white/80",children:[e.jsxs("span",{children:["Progress to ",s.nextTier.name]}),e.jsxs("span",{className:"font-semibold text-vida-mint tabular-nums",children:[s.pointsToNext.toLocaleString()," pts to go"]})]}),e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-pill bg-white/20",children:e.jsx("div",{className:"h-full rounded-pill bg-vida-mint motion-safe:transition-[width] motion-safe:duration-500",style:{width:`${w}%`}})}),e.jsx("p",{className:"mt-1.5 text-caption text-white/60",children:"Tiers advance on points earned from purchases."})]}):e.jsx("p",{className:"text-caption text-white/80",children:"You've reached the top tier. Nicely done."})})]}),e.jsxs(O,{children:[e.jsxs(n,{className:"mb-5",children:[e.jsx("h2",{className:"mb-3 text-sm font-semibold text-ink",children:"Tier ladder"}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:grid-cols-5",children:y.map(t=>{const a=(s?.tier?.slug??"seed")===t.slug,p=te[t.slug]??b;return e.jsxs("div",{className:r("flex flex-col items-center rounded-[16px] px-2 py-3.5 text-center ring-1",a?"bg-secondary ring-vida-green-600/30":"bg-bone ring-[--vp-hairline]"),children:[e.jsx(p,{className:r("mb-1.5 size-5",a?"text-secondary-foreground":"text-ink-3"),"aria-hidden":"true"}),e.jsx("span",{className:r("text-caption font-semibold",a?"text-secondary-foreground":"text-ink-2"),children:t.name}),e.jsxs(_,{variant:B[t.metal],className:"mt-1.5 px-2 py-0.5",children:[t.multiplierLabel," pts"]}),e.jsxs("span",{className:r("mt-1 text-[11px] tabular-nums",a?"text-secondary-foreground
1/75":"text-ink-3"),children:[t.minPoints.toLocaleString(),"+ pts"]})]},t.slug)})}),e.jsxs("p",{className:"mt-3 text-caption text-ink-3",children:["Your multiplier:"," ",e.jsx("span",{className:"font-semibold text-ink",children:u(s?.tier?.multiplierBips)})," ","points per $1 on every order."]})]}),e.jsxs(n,{className:"mb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center rounded-xl bg-vida-green-700/10 text-vida-green-700 dark:bg-vida-mint/10 dark:text-vida-mint",children:e.jsx(U,{className:"size-4.5","aria-hidden":"true"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-ink",children:"Redeem for VidaCredit"}),e.jsxs("p",{className:"text-caption text-ink-3",children:["Convert ",d.toLocaleString()," pts into ",h," ","VidaCredit. Credit applies to your order total at checkout, up to the full amount."]})]})]}),e.jsx(M,{block:!0,className:"mt-4",onClick:f,disabled:!v,"data-testid":"button-redeem-points-page",children:N?"Redeemingâ¦":`Redeem ${d} pts â ${h} credit`}),x<d&&e.jsxs("p",{className:"mt-2 text-center text-caption text-ink-3 tabular-nums",children:["Earn ",Math.max(0,d-x).toLocaleString()," more points to redeem."]})]}),e.jsx(F,{channel:"points_page",className:"mb-5"}),e.jsxs(n,{className:"mb-5",children:[e.jsx("h2",{className:"mb-3 text-sm font-semibold text-ink",children:"How you earn Vida Points"}),e.jsx("ul",{className:"space-y-3.5",children:se.map(({Icon:t,label:a,detail:p})=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-xl bg-vida-green-700/10 text-vida-green-700 dark:bg-vida-mint/10 dark:text-vida-mint",children:e.jsx(t,{className:"size-4","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-ink",children:a}),e.jsx("p",{className:"text-caption text-ink-3",children:p})]})]},a))})]}),e.jsxs(n,{children:[e.jsx("h2",{className:"mb-3 text-sm font-semibold text-ink",children:"Points history"}),l.isLoading?e.jsx("div",{className:"space-y-3",children:Array.from({length:3}).map((t,a)=>e.jsx(g,{className:"h-10 w-full"},a))}):l.isError?e.jsx("p",{className:"text-sm text-ink-2",children:"We couldn't load your history right now."}):!l.data||l.data.length===0?e.jsx("p",{className:"text-sm text-ink-2",children:"No points activity yet. Place an order to start earning."}):e.jsx("ul",{children:l.data.map((t,a)=>e.jsx("li",{className:r("py-3",a>0&&"border-t border-card-border"),children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-ink",children:ae(t.reason)}),t.note&&e.jsx("p",{className:"truncate text-caption text-ink-3",children:t.note}),e.jsx("p",{className:"text-[11px] text-ink-3",children:$(t.createdAt)})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsxs("p",{className:r("font-mono text-sm font-semibold tabular-nums",t.deltaPoints>=0?"text-primary":"text-danger"),children:[t.deltaPoints>=0?"+":"",t.deltaPoints.toLocaleString()]}),e.jsxs("p",{className:"text-[11px] text-ink-3 tabular-nums",children:[t.balanceAfter.toLocaleString()," bal"]})]})]})},t.id))})]})]})]})]})}export{xe 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.