import{t as e}from"./triangle-alert-_Trdz8l6.js";import{_ as t}from"./vendor-flow-IzlrcDx6.js";import{rn as n}from"./index-HkVQGc9M.js";import{t as r}from"./format-DOnLYpxL.js";var i=t(),a={ok:`bg-[var(--color-success)]`,warn:`bg-[var(--color-warning)]`,danger:`bg-[var(--color-error)]`},o={ok:`text-[var(--color-text-secondary)]`,warn:`text-[var(--color-warning)]`,danger:`text-[var(--color-error)]`};function s({scheme:t,compact:s=!1,funds:c,fundsLabel:l,className:u}){let d=Number(t.budget_amount??0),f=Number(t.spent_amount??0);if(!t.budget_amount||d<=0)return(0,i.jsxs)(`div`,{className:n(`min-w-0`,s?`w-[168px]`:``,u),children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,i.jsx)(e,{className:`h-3.5 w-3.5 flex-shrink-0 text-[var(--color-warning)]`}),(0,i.jsx)(`span`,{className:`text-[12px] font-semibold text-[var(--color-warning)]`,children:`No budget`})]}),(0,i.jsx)(`div`,{className:`mt-1.5 h-1.5 w-full rounded-full border border-dashed border-[var(--color-border)]`}),(0,i.jsx)(`p`,{className:`mt-1 text-[11px] leading-snug text-[var(--color-text-muted)]`,children:s?`${r(f)} given away · nothing caps it`:`${r(f)} given away so far. With no budget the scheme can never stop itself — it keeps paying out for as long as it is live.`})]});let p=Math.max(0,Math.min(100,t.budget_used_pct)),m=t.status===`exhausted`||t.budget_used_pct>=100,h=!m&&t.budget_used_pct>=t.warn_at_pct,g=m?`danger`:h?`warn`:`ok`;return(0,i.jsxs)(`div`,{className:n(`min-w-0`,s?`w-[168px]`:``,u),children:[(0,i.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,i.jsxs)(`span`,{className:`truncate text-[12px] tabular-nums text-[var(--color-text-primary)]`,children:[(0,i.jsx)(`span`,{className:`font-semibold`,children:r(f)}),(0,i.jsxs)(`span`,{className:`text-[var(--color-text-muted)]`,children:[` of `,r(d)]})]}),(0,i.jsxs)(`span`,{className:n(`flex-shrink-0 text-[11px] font-bold tabular-nums`,o[g]),children:[Math.round(t.budget_used_pct),`%`]})]}),(0,i.jsx)(`div`,{className:`mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-[var(--color-border-light)]`,children:(0,i.jsx)(`div`,{className:n(`h-full rounded-full transition-[width]`,a[g]),style:{width:`${p}%`}})}),(0,i.jsx)(`p`,{className:`mt-1 truncate text-[11px] text-[var(--color-text-muted)]`,children:m?(0,i.jsxs)(`span`,{className:`font-medium text-[var(--color-error)]`,children:[`Budget exhausted`,t.stop_when_exhausted?` — the scheme has stopped`:` — but it keeps paying out`]}):(0,i.jsxs)(i.Fragment,{children:[r(t.budget_remaining),` left`,h&&(0,i.jsxs)(`span`,{className:`font-medium text-[var(--color-warning)]`,children:[` `,`· past the `,t.warn_at_pct,`% warning mark`]})]})}),!s&&c!=null&&(0,i.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-[var(--color-text-muted)]`,children:[`Funds about `,(0,i.jsx)(`span`,{className:`font-semibold tabular-nums text-[var(--color-text-secondary)]`,children:c}),` `,l||`more orders like the example`,`.`]})]})}export{s as t};