ownledger 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +24 -8
- package/CHANGELOG.md +33 -0
- package/README.md +5 -2
- package/assets/index.html +10 -10
- package/assets/static/{Account-sw3qGLbB.js → Account-CYrXDU9Z.js} +1 -1
- package/assets/static/{Accounts-DWyzX3qB.js → Accounts-BXleOwUO.js} +1 -1
- package/assets/static/{Attention-DxV-4qdY.js → Attention-Ci3luOdE.js} +1 -1
- package/assets/static/{ByCategory-B4P3ikmE.js → ByCategory-cLVOyjwd.js} +1 -1
- package/assets/static/{CardDetail-CayBXBm-.js → CardDetail-BxXfAcMp.js} +1 -1
- package/assets/static/{Cards-CVuOP8Bt.js → Cards-DNtITMnA.js} +1 -1
- package/assets/static/{Cards-XUBdWxyo.js → Cards-DnIsAWPD.js} +1 -1
- package/assets/static/{CardsValue-EoW2jG_0.js → CardsValue-V1-fYMLf.js} +1 -1
- package/assets/static/{Cashback-BibVYHf_.js → Cashback-B8lqwRnb.js} +1 -1
- package/assets/static/{CategoryIcon-HfjYhH1l.js → CategoryIcon-D4Cdb_ZP.js} +1 -1
- package/assets/static/{CategoryPicker-BkmvzX2I.js → CategoryPicker-54vkuxVh.js} +1 -1
- package/assets/static/{ChartWidget-u09-whUU.js → ChartWidget-S5F4Ze91.js} +1 -1
- package/assets/static/{Combobox-xXeyjGgK.js → Combobox-BvX68J3o.js} +1 -1
- package/assets/static/{Deposits-CLAda4dj.js → Deposits-Ct5HhCEc.js} +1 -1
- package/assets/static/{DrillLink-Bvfam9FA.js → DrillLink-CZyI-y0-.js} +1 -1
- package/assets/static/{Field-tKFmKDEF.js → Field-DYmqEAlI.js} +1 -1
- package/assets/static/{HomeEditor-4vxj5LMD.js → HomeEditor-Dv-h_ql-.js} +1 -1
- package/assets/static/{Import-DwaaFpRJ.js → Import-B2uhVnEm.js} +1 -1
- package/assets/static/{IncomeSpending-RVDSxAK4.js → IncomeSpending-DNT2CWH9.js} +1 -1
- package/assets/static/{KV-DMA1AlP-.js → KV-CKWaJkRK.js} +1 -1
- package/assets/static/{Left-C_4gTGSX.js → Left-BefXZztB.js} +1 -1
- package/assets/static/{Money-PfFNNDOw.js → Money-BwLucm7P.js} +1 -1
- package/assets/static/{NetWorth-BSoseczC.js → NetWorth-DeLSapZ2.js} +1 -1
- package/assets/static/{Pace-B8p-9174.js → Pace-D6gilOBZ.js} +1 -1
- package/assets/static/{Panel-BnfWrw9R.js → Panel-CSe25x0N.js} +1 -1
- package/assets/static/{PinDialog-BqAU9Vh4.js → PinDialog-CHiLIKEs.js} +1 -1
- package/assets/static/{Plans-2KuQH2_I.js → Plans-D7rJ1yHU.js} +1 -1
- package/assets/static/{Recent-Ccmb34bq.js → Recent-Dcqb2yko.js} +1 -1
- package/assets/static/{Reports-Dd-dhclr.js → Reports--PDAEnQM.js} +1 -1
- package/assets/static/{Settings-BR8WBlen.js → Settings-Bd0oglWl.js} +1 -1
- package/assets/static/{Transactions-BAuQ-6Eb.js → Transactions-CQ1yQ1UU.js} +1 -1
- package/assets/static/{TxRow-EKIIMQKa.js → TxRow-BGfpKo2m.js} +1 -1
- package/assets/static/{Unusual-CwFp8aA5.js → Unusual-DGB4ZOA2.js} +1 -1
- package/assets/static/{Upcoming-B28roT9r.js → Upcoming-B0HwBqmG.js} +1 -1
- package/assets/static/{WhichCard-B3kLc842.js → WhichCard-BefFKS2q.js} +1 -1
- package/assets/static/{arrow-up-D3gxUKLo.js → arrow-up-CRgLRKET.js} +1 -1
- package/assets/static/{bits-Dr2E0ObC.js → bits-D34d9IBm.js} +1 -1
- package/assets/static/{button-rfwMVz0i.js → button-BKhMn8jX.js} +1 -1
- package/assets/static/{cards-Bb5zjzRG.js → cards-Ct0jh73r.js} +1 -1
- package/assets/static/{charts-BqP7HKwP.js → charts-D-1glV8L.js} +1 -1
- package/assets/static/chevron-down-BWoQwA6m.js +1 -0
- package/assets/static/chevron-right-D7Sgw1v1.js +1 -0
- package/assets/static/{createLucideIcon-flJrJK2p.js → createLucideIcon-XZ28znwT.js} +1 -1
- package/assets/static/{dialog-BuRqO4sc.js → dialog-Bx-cd-2e.js} +1 -1
- package/assets/static/{dist-B4_eGtNj.js → dist--HKr0kfV.js} +1 -1
- package/assets/static/{dist-B7PR2b0C.js → dist-BFPyD74_.js} +1 -1
- package/assets/static/{dist-BDn7ydjn.js → dist-CmbuesVk.js} +1 -1
- package/assets/static/{dist-Dl-m8cc2.js → dist-vgyaCpaL.js} +1 -1
- package/assets/static/{es2015-DJh4h8NX.js → es2015-DqY4UvQc.js} +1 -1
- package/assets/static/{index-eR1GkdC_.js → index-DBHFdsYB.js} +4 -4
- package/assets/static/{queries-DZIMMe4i.js → queries-BcMmmb36.js} +1 -1
- package/assets/static/{react-dom-wK_7mEjs.js → react-dom-5dgiSOdd.js} +1 -1
- package/assets/static/{select-eaSi9K-d.js → select-B5P2TaPX.js} +1 -1
- package/assets/static/{shared-Box7on3B.js → shared-BgU6fc7z.js} +1 -1
- package/assets/static/{triangle-exclamation-point-CuL0XSJl.js → triangle-exclamation-point-CMy18kC0.js} +1 -1
- package/assets/static/{useMutation-_Lw8xXWa.js → useMutation-aC3Z1p9y.js} +1 -1
- package/dist/cli/statements.js +153 -5
- package/dist/engine/actions.d.ts +28 -0
- package/dist/engine/actions.js +109 -3
- package/dist/modules/cards/files.d.ts +1 -1
- package/dist/modules/cards/files.js +1 -1
- package/dist/modules/cards/terms.d.ts +2 -0
- package/dist/modules/cards/terms.js +7 -0
- package/dist/node/reconcile.d.ts +100 -0
- package/dist/node/reconcile.js +176 -0
- package/dist/node/statement-rows.d.ts +77 -0
- package/dist/node/statement-rows.js +245 -0
- package/dist/node/statements.d.ts +2 -1
- package/dist/worker/api.js +32 -5
- package/dist/worker/github.d.ts +18 -1
- package/dist/worker/github.js +53 -6
- package/dist/worker/mcp.js +32 -7
- package/dist/worker/store.js +1 -1
- package/dist/worker/version.d.ts +1 -1
- package/dist/worker/version.js +1 -1
- package/package.json +1 -1
- package/assets/static/chevron-down-Co1w7ApZ.js +0 -1
- package/assets/static/chevron-right-Dqh3vs9Y.js +0 -1
- package/dist/worker/tar.d.ts +0 -3
- package/dist/worker/tar.js +0 -65
package/AGENTS.md
CHANGED
|
@@ -86,7 +86,11 @@ dashboard ("Statement PDF" on a statement) and never reads it. Optional: a repo
|
|
|
86
86
|
|
|
87
87
|
`imports/statements/sources.yaml`, per account id: `from` (the bank's sender address), `subject` (words in the subject),
|
|
88
88
|
`password` (the name of the variable in `.env.statements`, e.g. `PW_WOORI`), `password_hint` (what the password is made
|
|
89
|
-
of, e.g. "date of birth ddmmyy"; never the password itself). The bank's own email facts, nothing else.
|
|
89
|
+
of, e.g. "date of birth ddmmyy"; never the password itself). The bank's own email facts, nothing else. Optional, how to
|
|
90
|
+
read the statement when the general rules don't fit (data, never code): `closing_label` (the label of the bank's
|
|
91
|
+
closing figure, e.g. "Payable amount"; a string or a list), `credit_words` (words that mark a row as money back on the
|
|
92
|
+
card: payment, refund, cashback…), `skip_words` (lines that are never rows), `amount_column` (which amount on a row is
|
|
93
|
+
its amount when there are several, zeros and other currencies not counted: `1` = first, `-1` = last, the default).
|
|
90
94
|
|
|
91
95
|
Passwords live in `.env.statements` at the repo root (`PW_<ACCOUNT_ID>=…` or `PW_<BANK>=…`, the first word of the id;
|
|
92
96
|
or the variable `sources.yaml` names). It is git-ignored. Never commit it, print it, or send it anywhere.
|
|
@@ -107,13 +111,25 @@ itself never connects to email.
|
|
|
107
111
|
again with `--yes` (files and commits).
|
|
108
112
|
5. `npx ownledger statements list` shows which months are missing between the first and the last; report them.
|
|
109
113
|
|
|
110
|
-
### Check a
|
|
114
|
+
### Check a card's statements against the ledger
|
|
111
115
|
|
|
112
|
-
`npx ownledger statements
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
the
|
|
116
|
-
|
|
116
|
+
**To check a card's statements, run `npx ownledger statements reconcile <account-id>`** (`--from`/`--to YYYY-MM` to
|
|
117
|
+
narrow it, `--json` for data). Don't write your own PDF parsing or matching. For every filed statement it shows the
|
|
118
|
+
bank's closing figure next to ownledger's (gap = ownledger − bank, the change from the month before, and the part of
|
|
119
|
+
the gap that is only timing: rows the bank and the ledger put on opposite sides of a close date). Then it lists rows on
|
|
120
|
+
a statement but not on the ledger, ledger rows on no statement, amounts that differ (typos, FX), rows probably booked
|
|
121
|
+
on another account, and balance adjustments (`_adjust`) covering a gap. Fees booked with their VAT as one row, and
|
|
122
|
+
purchases refunded in full, are matched and shown apart; they need no fix.
|
|
123
|
+
|
|
124
|
+
Propose the fixes to the owner as **one batch** (the connector's `batch` tool: one preview, one go, one commit; the
|
|
125
|
+
`hint` of each item in `--json` is the op to start from: fill in the category). **Never add a balance adjustment to
|
|
126
|
+
cover a gap**: find the real rows. If the closing figure isn't found or rows look wrong, add the layout fields to
|
|
127
|
+
`sources.yaml` (above) rather than working around it. `--save-bank-amounts` saves each month's bank figure in
|
|
128
|
+
`data/cards/statements.yaml` (preview; `--yes` after the owner's go) so `cards` / `card_statement` show the gap
|
|
129
|
+
without the PDFs.
|
|
130
|
+
|
|
131
|
+
`npx ownledger statements check <account-id> <YYYY-MM>` shows one statement: ownledger's figures and transactions for
|
|
132
|
+
the period, the rows read from the PDF, and its text with columns kept.
|
|
117
133
|
|
|
118
134
|
`npx ownledger check` warns about statement files that don't fit (a folder that isn't an account, a name that isn't
|
|
119
135
|
`YYYY-MM.pdf`, a PDF still locked).
|
|
@@ -123,7 +139,7 @@ the PDF on your own: each fix is a normal write (preview → go). The bank's sta
|
|
|
123
139
|
1. Show the owner exactly what will change (the transactions, with amounts and accounts) and wait for their go.
|
|
124
140
|
2. Never invent an amount, date or account. Ask if anything is missing.
|
|
125
141
|
3. Run `npx ownledger check`; it must pass.
|
|
126
|
-
4. One commit per change, with a readable message.
|
|
142
|
+
4. One commit per change, with a readable message. Many related transaction fixes are one change: use `batch`.
|
|
127
143
|
|
|
128
144
|
## First import of a new app
|
|
129
145
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.0 (2026-11-23)
|
|
4
|
+
|
|
5
|
+
Batch writes, and checking every statement of a card in one run (plan 005). Data format stays 1.
|
|
6
|
+
|
|
7
|
+
- **Batch writes:** the connector's `batch` tool previews many adds, edits and voids as **one** change: one preview,
|
|
8
|
+
one go from the owner, one commit ("Batch: 28 adds, 4 edits, 4 voids"). Ops run in order on the evolving data, check
|
|
9
|
+
runs once on the result, and if any op fails the whole batch is refused, naming the op. The preview shows every
|
|
10
|
+
transaction (up to 200) and the balance change per account. Each row's trail gets the batch's reason plus the op's
|
|
11
|
+
own. Also `POST /api/batch` + `/api/batch/apply` for the dashboard (no UI yet).
|
|
12
|
+
- **`ownledger statements reconcile <card>`** (`--from`/`--to`, `--json`): every filed statement against the ledger.
|
|
13
|
+
Per month the bank's closing figure next to ownledger's (gap, change from the month before, and the part that is
|
|
14
|
+
only timing), then the rows missing on the ledger, ledger rows on no statement, amounts that differ, rows probably on
|
|
15
|
+
another account, and balance adjustments covering a gap. Fee + VAT (or purchase + DCC fee + VAT) booked as one row,
|
|
16
|
+
and purchases refunded in full, are matched and shown apart. `--json` carries a `batch` op hint per item.
|
|
17
|
+
`--save-bank-amounts` saves each month's bank figure in `data/cards/statements.yaml` (preview; `--yes`). Reads the
|
|
18
|
+
PDFs on your computer only, as before.
|
|
19
|
+
- **Statement rows by general rules**, no bank-specific code: the PDF's text with its columns kept, a row is a date +
|
|
20
|
+
a description + an amount (with CR/DR, minus, brackets, currency marks; foreign-currency amounts skipped; debit and
|
|
21
|
+
credit columns when the statement has them; a description wrapped onto the lines around the row). What a bank does
|
|
22
|
+
differently is data in `imports/statements/sources.yaml`: `closing_label`, `credit_words`, `skip_words`,
|
|
23
|
+
`amount_column`.
|
|
24
|
+
- `ownledger statements check` now shows the rows it read and the text with columns kept.
|
|
25
|
+
- Connector instructions: use `batch` for more than ~3 writes.
|
|
26
|
+
|
|
27
|
+
## 2.1.1 (2026-11-23)
|
|
28
|
+
|
|
29
|
+
- **Fix: the dashboard failed to load ("Could not load data:" with no reason) once statement PDFs were filed.** The
|
|
30
|
+
Worker read each new commit from the repo's whole tarball, PDFs included, and ran past Cloudflare's CPU limit. It now
|
|
31
|
+
lists the repo's files (one call) and reads only `data/` and `imports/*.mapping.yaml` (one GraphQL call per 100
|
|
32
|
+
files); statement PDFs and raw exports are never downloaded. Same GitHub App permissions.
|
|
33
|
+
- **Clear errors:** when the data repo can't be loaded, `/api/*` answers JSON with the reason (502) instead of a bare
|
|
34
|
+
500, and the dashboard shows the HTTP status when an answer isn't JSON (e.g. Cloudflare's own 503 page).
|
|
35
|
+
|
|
3
36
|
## 2.1.0 (2026-11-23)
|
|
4
37
|
|
|
5
38
|
Bank statements, optional. Data format stays 1: a repo without statements works as it does now.
|
package/README.md
CHANGED
|
@@ -102,7 +102,8 @@ ownledger deploy deploy or update your Worker (--openwallet / --no-ope
|
|
|
102
102
|
ownledger dev [dir] run your Worker locally against the local folder (sign-in skipped; --openwallet[=<url>])
|
|
103
103
|
ownledger statements add <card> <file.pdf>… unlock and file bank statement PDFs (preview; --yes files and commits)
|
|
104
104
|
ownledger statements list [<card>] which months each card has, and which are missing
|
|
105
|
-
ownledger statements check <card> <YYYY-MM>
|
|
105
|
+
ownledger statements check <card> <YYYY-MM> one statement's rows and text next to the ledger's figures for that period
|
|
106
|
+
ownledger statements reconcile <card> every filed statement against the ledger: gaps per month, missing rows, typos
|
|
106
107
|
```
|
|
107
108
|
|
|
108
109
|
### Bank statements (optional)
|
|
@@ -111,7 +112,9 @@ Keep your cards' statement PDFs in your data repo and open them from the dashboa
|
|
|
111
112
|
your own AI agent on your computer (Claude Code or similar, with a Gmail connector), following
|
|
112
113
|
[AGENTS.md](AGENTS.md#collect-statements-from-gmail); ownledger never connects to your email. `ownledger statements add`
|
|
113
114
|
removes the bank's password (kept in `.env.statements`, git-ignored, on your computer only) and files each PDF under the
|
|
114
|
-
month of its statement's close date. `ownledger statements
|
|
115
|
+
month of its statement's close date. `ownledger statements reconcile <card>` checks every statement of a card against
|
|
116
|
+
your ledger in one run (the bank's closing figure per month, rows missing or different), so your agent can propose the
|
|
117
|
+
fixes as one `batch`: one preview, one go, one commit.
|
|
115
118
|
|
|
116
119
|
## Development
|
|
117
120
|
|
package/assets/index.html
CHANGED
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
<link rel="icon" href="/icon.svg" type="image/svg+xml">
|
|
10
10
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
|
11
11
|
<meta name="apple-mobile-web-app-title" content="ownledger">
|
|
12
|
-
<script type="module" crossorigin src="/static/index-
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/static/queries-
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/static/react-dom-
|
|
15
|
-
<link rel="modulepreload" crossorigin href="/static/button-
|
|
16
|
-
<link rel="modulepreload" crossorigin href="/static/dist-
|
|
17
|
-
<link rel="modulepreload" crossorigin href="/static/es2015-
|
|
18
|
-
<link rel="modulepreload" crossorigin href="/static/dist-
|
|
19
|
-
<link rel="modulepreload" crossorigin href="/static/createLucideIcon-
|
|
20
|
-
<link rel="modulepreload" crossorigin href="/static/dist-
|
|
21
|
-
<link rel="modulepreload" crossorigin href="/static/dist
|
|
12
|
+
<script type="module" crossorigin src="/static/index-DBHFdsYB.js"></script>
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/static/queries-BcMmmb36.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/static/react-dom-5dgiSOdd.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="/static/button-BKhMn8jX.js">
|
|
16
|
+
<link rel="modulepreload" crossorigin href="/static/dist-CmbuesVk.js">
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/static/es2015-DqY4UvQc.js">
|
|
18
|
+
<link rel="modulepreload" crossorigin href="/static/dist-BFPyD74_.js">
|
|
19
|
+
<link rel="modulepreload" crossorigin href="/static/createLucideIcon-XZ28znwT.js">
|
|
20
|
+
<link rel="modulepreload" crossorigin href="/static/dist-vgyaCpaL.js">
|
|
21
|
+
<link rel="modulepreload" crossorigin href="/static/dist--HKr0kfV.js">
|
|
22
22
|
<link rel="stylesheet" crossorigin href="/static/index-iYMxgw-7.css">
|
|
23
23
|
</head>
|
|
24
24
|
<body>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,I as t,L as n,d as r,m as i,u as a,w as o}from"./queries-
|
|
1
|
+
import{B as e,I as t,L as n,d as r,m as i,u as a,w as o}from"./queries-BcMmmb36.js";import{a as s,i as c,t as l}from"./charts-D-1glV8L.js";import{t as u}from"./DrillLink-CZyI-y0-.js";import{t as d}from"./Money-BwLucm7P.js";import{M as f,a as p,l as m}from"./index-DBHFdsYB.js";var h=e(t(),1),g=n();function _({widget:e,menu:t}){let{t:n,lang:_}=o(),v=r().data,y=e.account,b=a().data,x=y===`pool`?b?.pool?.name||n(`pool.name`):v?.accounts.find(e=>e.id===y)?.name,S=e.title?.trim()||x||n(`widget.account`),{data:C,error:w,isLoading:T}=i({metric:`balance`,account:y??``,by:`month`,period:`last-12-months`},!!y),E=(0,h.useMemo)(()=>(C?.points??[]).map(e=>({ym:e.key,v:e.value})),[C]),D=E[E.length-1];return(0,g.jsx)(f,{title:S,titleHref:y?`#/transactions?account=${encodeURIComponent(y)}`:void 0,menu:t,loading:!!y&&T,error:y?w?.message:void 0,empty:y?C&&E.length===0?n(`account.empty`):void 0:n(`account.pick`),children:D&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u,{filter:{account:y},className:`text-2xl font-semibold tracking-tight`,children:(0,g.jsx)(d,{amount:D.v})}),(0,g.jsx)(l,{table:{head:[n(`chart.month`),n(`account.balance`)],rows:E.map(e=>[p(e.ym),m(e.v,_)])},children:(0,g.jsx)(c,{data:E,xKey:`ym`,formatX:e=>p(String(e)),specs:[{key:`v`,label:n(`account.balance`),kind:`line`,color:s.accent}]})})]})})}export{_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./chevron-down-Co1w7ApZ.js";import{t}from"./chevron-right-Dqh3vs9Y.js";import{B as n,I as r,L as i,T as a,a as o,d as s,o as c,t as l,u,w as d}from"./queries-DZIMMe4i.js";import{A as f,W as p,l as m,n as h,r as g,s as _,u as v}from"./index-eR1GkdC_.js";import{t as y}from"./Money-PfFNNDOw.js";import{o as b,r as x}from"./bits-Dr2E0ObC.js";import{a as S,i as C,n as w,o as T,r as E,s as D}from"./dist-BDn7ydjn.js";import{n as O,s as k}from"./button-rfwMVz0i.js";import{t as A}from"./dist-B7PR2b0C.js";import{n as j,r as M,t as N}from"./dist-B4_eGtNj.js";import{t as P}from"./dist-Dl-m8cc2.js";import{t as F}from"./cards-Bb5zjzRG.js";import{t as ee}from"./drill-t1zr57xi.js";var I=n(r(),1),L=i(),R=Object.defineProperty,z=(e,t)=>R(e,`name`,{value:t,configurable:!0}),B=`Collapsible`,[te,ne]=T(B),[re,V]=te(B),ie=I.forwardRef(z(function(e,t){let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=E({prop:r,defaultProp:i??!1,onChange:o,caller:B});return(0,L.jsx)(re,{scope:n,disabled:a,contentId:w(),open:c,onOpenToggle:I.useCallback(()=>l(e=>!e),[l]),children:(0,L.jsx)(D.div,{"data-state":U(c),"data-disabled":a?``:void 0,...s,ref:t})})},`Collapsible`)),ae=`CollapsibleTrigger`,oe=I.forwardRef(z(function(e,t){let{__scopeCollapsible:n,...r}=e,i=V(ae,n);return(0,L.jsx)(D.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":U(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:C(e.onClick,i.onOpenToggle)})},`CollapsibleTrigger`)),H=`CollapsibleContent`,se=I.forwardRef(z(function(e,t){let{forceMount:n,...r}=e,i=V(H,e.__scopeCollapsible);return(0,L.jsx)(A,{present:n||i.open,children:({present:e})=>(0,L.jsx)(ce,{...r,ref:t,present:e})})},`CollapsibleContent`)),ce=I.forwardRef(z(function(e,t){let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=V(H,n),[s,c]=I.useState(r),l=I.useRef(null),u=k(t,l),d=I.useRef(0),f=d.current,p=I.useRef(0),m=p.current,h=o.open||s,g=I.useRef(h),_=I.useRef(void 0);return I.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),S(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,L.jsx)(D.div,{"data-state":U(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})},`CollapsibleContentImpl`));function U(e){return e?`open`:`closed`}z(U,`getState`);var le=Object.defineProperty,W=(e,t)=>le(e,`name`,{value:t,configurable:!0}),G={Automatic:`automatic`,Manual:`manual`},K=`Tabs`,[ue,de]=T(K,[M]),fe=M(),[pe,q]=ue(K),me=I.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=G.Automatic,...l}=e,u=P(s),[d,f]=E({prop:r,onChange:i,defaultProp:a??``,caller:K});return(0,L.jsx)(pe,{scope:n,baseId:w(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,L.jsx)(D.div,{dir:u,"data-orientation":o,...l,ref:t})})},`Tabs`)),he=`TabsList`,ge=I.forwardRef(W(function(e,t){let{__scopeTabs:n,loop:r=!0,...i}=e,a=q(he,n),o=fe(n);return(0,L.jsx)(N,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,L.jsx)(D.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})},`TabsList`)),_e=`TabsTrigger`,ve=I.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=q(_e,n),s=fe(n),c=J(o.baseId,r),l=Y(o.baseId,r),u=r===o.value;return(0,L.jsx)(j,{asChild:!0,...s,focusable:!i,active:u,children:(0,L.jsx)(D.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:C(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?(e.currentTarget.focus(),o.onValueChange(r)):e.preventDefault()}),onKeyDown:C(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:C(e.onFocus,()=>{let e=o.activationMode!==G.Manual;!u&&!i&&e&&o.onValueChange(r)})})})},`TabsTrigger`)),ye=`TabsContent`,be=I.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=q(ye,n),c=J(s.baseId,r),l=Y(s.baseId,r),u=r===s.value,d=I.useRef(u);return I.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,L.jsx)(A,{present:i||u,children:({present:n})=>(0,L.jsx)(D.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})},`TabsContent`));function J(e,t){return`${e}-trigger-${t}`}W(J,`makeTriggerId`);function Y(e,t){return`${e}-content-${t}`}W(Y,`makeContentId`);function xe({...e}){return(0,L.jsx)(ie,{"data-slot":`collapsible`,...e})}function Se({...e}){return(0,L.jsx)(oe,{"data-slot":`collapsible-trigger`,...e})}function Ce({...e}){return(0,L.jsx)(se,{"data-slot":`collapsible-content`,...e})}function we({className:e,orientation:t=`horizontal`,...n}){return(0,L.jsx)(me,{"data-slot":`tabs`,"data-orientation":t,className:a(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Te=O(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Ee({className:e,variant:t=`default`,...n}){return(0,L.jsx)(ge,{"data-slot":`tabs-list`,"data-variant":t,className:a(Te({variant:t}),e),...n})}function X({className:e,...t}){return(0,L.jsx)(ve,{"data-slot":`tabs-trigger`,className:a(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function Z({className:e,...t}){return(0,L.jsx)(be,{"data-slot":`tabs-content`,className:a(`flex-1 text-sm outline-none`,e),...t})}var De=90,Oe=[`var(--chart-1)`,`var(--chart-2)`,`var(--chart-3)`,`var(--chart-4)`,`var(--chart-5)`],Q=e=>Math.abs(e.value);function ke({children:e,tone:t}){return(0,L.jsx)(`span`,{className:a(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,t===`warn`?`bg-warning/10 text-warning`:`bg-secondary text-secondary-foreground`),children:e})}function Ae({a:e,holdings:t,card:n,deposit:r,nested:i}){let{t:o,lang:s}=d();return(0,L.jsxs)(`li`,{className:a(`relative flex flex-col gap-1 rounded-md py-1.5 hover:bg-muted/40 focus-within:ring-3 focus-within:ring-ring/50`,i?`pl-4`:`px-2`),children:[(0,L.jsxs)(`div`,{className:`flex min-h-11 items-center justify-between gap-3`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`a`,{href:ee({account:e.id}),className:`truncate rounded-md text-sm font-medium outline-none after:absolute after:inset-0 focus-visible:underline`,children:e.name}),e.closed&&(0,L.jsx)(ke,{children:o(`accounts.closedOn`,{date:_(e.closed,s)})}),t&&!e.priced&&(0,L.jsx)(ke,{tone:`warn`,children:o(`accounts.noPrice`)})]}),(0,L.jsx)(y,{amount:e.value,mode:`short`,className:`shrink-0 text-sm font-medium`})]}),t&&(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.qty!==null&&(0,L.jsx)(L.Fragment,{children:o(`accounts.qty`,{n:m(e.qty,s,4)})}),e.price&&(0,L.jsxs)(L.Fragment,{children:[` · `,o(`accounts.price`,{price:v(e.price.price,s),date:h(e.price.date)})]}),` · `,o(`accounts.cost`),` `,(0,L.jsx)(y,{amount:e.cost,mode:`short`})]}),n&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(b,{owed:n.owed,limit:n.limit,atLeast:n.limitAtLeast}),(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground`,children:[n.toPay>0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{children:[o(`cards.toPay`),` `,(0,L.jsx)(y,{amount:n.toPay,mode:`short`,className:`font-medium text-foreground`})]}),n.due&&(0,L.jsx)(`span`,{children:h(n.due)}),(0,L.jsx)(x,{days:n.daysToDue})]}):(0,L.jsx)(`span`,{children:o(`cards.nothingToPay`)}),(0,L.jsx)(`a`,{href:F(n.account),className:`relative z-10 ml-auto inline-flex min-h-11 items-center rounded-md px-1 underline outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,children:o(`accounts.cardPage`)})]})]}),r&&(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.maturity?`${r.daysToMaturity<0?o(`deposits.matured`):o(`deposits.inDays`,{n:r.daysToMaturity})} · ${h(r.maturity)}`:o(`deposits.noMaturity`),r.rate!==null&&` · ${m(r.rate,s,2)}%`,r.interestAtMaturity?(0,L.jsxs)(L.Fragment,{children:[` · `,o(`deposits.interest`),` `,(0,L.jsx)(y,{amount:r.interestAtMaturity,mode:`short`})]}):null]})]})}function je({open:n,onToggle:r,label:i,count:o,children:s,nested:c}){return(0,L.jsxs)(`div`,{className:a(`flex flex-col`,c&&`pl-4`),children:[(0,L.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:r,className:`flex min-h-11 items-center gap-1 rounded-md px-2 text-left text-sm text-muted-foreground outline-none hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50`,children:[n?(0,L.jsx)(e,{className:`size-4`,"aria-hidden":!0}):(0,L.jsx)(t,{className:`size-4`,"aria-hidden":!0}),i,` (`,o,`)`]}),n&&s]})}function Me(){let{t:n,lang:r}=d(),i=u().data,a=s().data,{data:h,error:_,isLoading:v}=l(),b=!!i?.features?.cards,x=o(b).data,S=c(!!i?.features?.deposits).data,C=i?.today??new Date().toISOString().slice(0,10),w=i?.pool,T=w?.name??n(`pool.name`),[E,D]=(0,I.useState)(!1),O=e=>a?.types[e]?.[r]??e,k=e=>!!a?.types[e]?.holdings,A=(0,I.useMemo)(()=>new Map((x?.cards??[]).map(e=>[e.account,e])),[x]),j=(0,I.useMemo)(()=>new Map((S??[]).map(e=>[e.account,e])),[S]),M=(0,I.useMemo)(()=>{let e=h??[],t=e=>!!a?.types[e.type]?.liability,n=e=>(t(e)||e.value<0)&&e.value<0,r=0,i=0,o=0;for(let t of e)(t.value!==0||t.qty)&&(n(t)?i+=t.value:r+=t.value,t.priced||o++);let s=e=>e.value===0&&!e.qty&&(e.lastActivity===null||g(e.lastActivity,C)>De),c=e.filter(e=>e.closed),l=e.filter(e=>!e.closed),u=w?.on?l.filter(e=>e.pool):[],d=l.filter(e=>!u.includes(e)),f=d.filter(s),p=d.filter(e=>!s(e)),m=p.filter(e=>t(e)||e.value<0),_=e=>A.get(e.id)?.daysToDue??1/0;m.sort((e,t)=>_(e)-_(t)||e.value-t.value);let v=new Map;for(let e of p.filter(e=>!m.includes(e))){let t=v.get(e.type)??{id:e.type,label:O(e.type),value:0,items:[]};t.items.push(e),t.value+=e.value,v.set(e.type,t)}let y=[...v.values()];for(let e of y)e.items.sort((e,t)=>Q(t)-Q(e));let b=u.filter(e=>!s(e)).sort((e,t)=>Q(t)-Q(e)),x=u.filter(s);u.length&&y.push({id:`pool`,label:T,value:u.reduce((e,t)=>e+t.value,0),items:b,pool:!0}),y.sort((e,t)=>t.value-e.value),y.forEach((e,t)=>e.color=e.value>0&&t<Oe.length?Oe[t]:`var(--chart-muted)`);let S=y.reduce((e,t)=>e+(t.pool?u.length:t.items.length),0);return{assets:r,liabilities:i,net:r+i,groups:y,debt:m,poolIdle:x,poolCount:u.length,assetCount:S,inactiveRest:f.sort((e,t)=>e.name.localeCompare(t.name)),closed:c.sort((e,t)=>(t.closed??``).localeCompare(e.closed??``)),unpriced:o,any:e.length>0}},[h,a,w?.on,T,C,r,A]);if(_)return(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`common.error`,{message:_.message})});if(v||!h||!a)return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":`true`,children:[(0,L.jsx)(p,{className:`h-8 w-48`}),(0,L.jsx)(p,{className:`h-24 w-full`}),(0,L.jsx)(p,{className:`h-48 w-full`})]});if(!M.any)return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:n(`accounts.title`)}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`accounts.empty`)}),(0,L.jsx)(f,{className:`self-start`,prompt:n(`start.s2.prompt`)})]});let N=(e,t)=>(0,L.jsx)(Ae,{a:e,nested:t,holdings:k(e.type),card:A.get(e.id),deposit:j.get(e.id)},e.id),P=M.groups.filter(e=>e.value>0),F=P.reduce((e,t)=>e+t.value,0),R=e=>F>0&&e>0?`${m(e/F*100,r)}%`:``,z=M.inactiveRest.length+M.closed.length;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:n(`accounts.title`)}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`accounts.netWorth`)}),(0,L.jsx)(y,{amount:M.net,className:`text-3xl font-semibold tracking-tight md:text-4xl`}),(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n(`accounts.assets`),` `,(0,L.jsx)(y,{amount:M.assets,mode:`short`,className:`font-medium text-foreground`}),` · `,n(`accounts.liabilities`),` `,(0,L.jsx)(y,{amount:M.liabilities,mode:`short`,className:`font-medium text-foreground`})]}),M.unpriced>0&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`nw.unpriced`,{n:M.unpriced})})]}),P.length>0&&(0,L.jsx)(`div`,{className:`flex h-2.5 w-full gap-0.5 overflow-hidden rounded-full`,role:`img`,"aria-label":`${n(`accounts.byType`)}: ${P.map(e=>`${e.label} ${R(e.value)}`).join(`, `)}`,children:P.map(e=>(0,L.jsx)(`span`,{className:`h-full first:rounded-l-full last:rounded-r-full`,style:{width:`${e.value/F*100}%`,background:e.color},title:`${e.label} ${R(e.value)}`},e.id))}),(0,L.jsxs)(we,{defaultValue:`assets`,className:`gap-4`,children:[(0,L.jsxs)(Ee,{className:`h-10! w-full sm:w-fit`,children:[(0,L.jsxs)(X,{value:`assets`,className:`px-3`,children:[n(`accounts.assets`),(0,L.jsx)($,{n:M.assetCount})]}),M.debt.length>0&&(0,L.jsxs)(X,{value:`debt`,className:`px-3`,children:[n(`accounts.liabilities`),(0,L.jsx)($,{n:M.debt.length})]}),z>0&&(0,L.jsxs)(X,{value:`idle`,className:`px-3`,children:[n(`accounts.tabIdle`),(0,L.jsx)($,{n:z})]})]}),(0,L.jsx)(Z,{value:`assets`,children:(0,L.jsx)(`div`,{className:`grid items-start gap-3 md:grid-cols-2`,children:M.groups.map(r=>(0,L.jsxs)(xe,{className:`group/acc overflow-hidden rounded-xl bg-card ring-1 ring-foreground/[0.07] shadow-[0_1px_2px_oklch(0_0_0/0.04)]`,children:[(0,L.jsxs)(Se,{className:`flex min-h-14 w-full items-center gap-3 px-4 text-left outline-none hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`size-2.5 shrink-0 rounded-full`,style:{background:r.color}}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:[r.label,(0,L.jsx)(`span`,{className:`ml-1.5 font-normal text-muted-foreground tabular-nums`,children:r.pool?M.poolCount:r.items.length})]}),(0,L.jsx)(y,{amount:r.value,mode:`short`,className:`shrink-0 text-sm font-semibold`}),(0,L.jsx)(`span`,{className:`w-9 shrink-0 text-right text-xs text-muted-foreground tabular-nums`,children:R(r.value)}),(0,L.jsx)(e,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-data-[state=open]/acc:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,L.jsxs)(Ce,{className:`border-t px-2 py-1`,children:[r.pool&&(0,L.jsxs)(`a`,{href:ee({account:`pool`}),className:`flex min-h-11 items-center justify-between gap-2 rounded-md px-2 text-sm text-muted-foreground outline-none hover:bg-muted/40 hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:[n(`accounts.poolTx`,{name:T}),(0,L.jsx)(t,{className:`size-4`,"aria-hidden":!0})]}),(0,L.jsx)(`ul`,{className:`flex flex-col`,children:r.items.map(e=>N(e))}),r.pool&&M.poolIdle.length>0&&(0,L.jsx)(je,{open:E,onToggle:()=>D(e=>!e),label:n(`accounts.inactive`),count:M.poolIdle.length,children:(0,L.jsx)(`ul`,{className:`flex flex-col`,children:M.poolIdle.map(e=>N(e,!0))})})]})]},r.id))})}),M.debt.length>0&&(0,L.jsx)(Z,{value:`debt`,children:(0,L.jsx)(`ul`,{className:`grid items-start gap-3 md:grid-cols-2`,children:M.debt.map(e=>(0,L.jsx)(`li`,{className:`list-none rounded-xl bg-card px-2 py-1 ring-1 ring-foreground/[0.07] shadow-[0_1px_2px_oklch(0_0_0/0.04)]`,children:(0,L.jsx)(`ul`,{children:N(e)})},e.id))})}),z>0&&(0,L.jsxs)(Z,{value:`idle`,className:`flex flex-col gap-5`,children:[M.inactiveRest.length>0&&(0,L.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`h2`,{className:`px-2 text-sm font-medium text-muted-foreground`,children:[n(`accounts.inactive`),` `,(0,L.jsx)(`span`,{className:`tabular-nums`,children:M.inactiveRest.length})]}),(0,L.jsx)(`ul`,{className:`grid gap-x-6 rounded-xl bg-card px-2 py-1 ring-1 ring-foreground/[0.07] md:grid-cols-2`,children:M.inactiveRest.map(e=>N(e))})]}),M.closed.length>0&&(0,L.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`h2`,{className:`px-2 text-sm font-medium text-muted-foreground`,children:[n(`accounts.closed`),` `,(0,L.jsx)(`span`,{className:`tabular-nums`,children:M.closed.length})]}),(0,L.jsx)(`ul`,{className:`grid gap-x-6 rounded-xl bg-card px-2 py-1 ring-1 ring-foreground/[0.07] md:grid-cols-2`,children:M.closed.map(e=>N(e))})]})]})]})]})}function $({n:e}){return(0,L.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-xs font-normal text-muted-foreground tabular-nums group-data-active:bg-secondary`,children:e})}export{Me as default};
|
|
1
|
+
import{t as e}from"./chevron-down-BWoQwA6m.js";import{t}from"./chevron-right-D7Sgw1v1.js";import{B as n,I as r,L as i,T as a,a as o,d as s,o as c,t as l,u,w as d}from"./queries-BcMmmb36.js";import{A as f,W as p,l as m,n as h,r as g,s as _,u as v}from"./index-DBHFdsYB.js";import{t as y}from"./Money-BwLucm7P.js";import{o as b,r as x}from"./bits-D34d9IBm.js";import{a as S,i as C,n as w,o as T,r as E,s as D}from"./dist-CmbuesVk.js";import{n as O,s as k}from"./button-BKhMn8jX.js";import{t as A}from"./dist-BFPyD74_.js";import{n as j,r as M,t as N}from"./dist--HKr0kfV.js";import{t as P}from"./dist-vgyaCpaL.js";import{t as F}from"./cards-Ct0jh73r.js";import{t as ee}from"./drill-t1zr57xi.js";var I=n(r(),1),L=i(),R=Object.defineProperty,z=(e,t)=>R(e,`name`,{value:t,configurable:!0}),B=`Collapsible`,[te,ne]=T(B),[re,V]=te(B),ie=I.forwardRef(z(function(e,t){let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=E({prop:r,defaultProp:i??!1,onChange:o,caller:B});return(0,L.jsx)(re,{scope:n,disabled:a,contentId:w(),open:c,onOpenToggle:I.useCallback(()=>l(e=>!e),[l]),children:(0,L.jsx)(D.div,{"data-state":U(c),"data-disabled":a?``:void 0,...s,ref:t})})},`Collapsible`)),ae=`CollapsibleTrigger`,oe=I.forwardRef(z(function(e,t){let{__scopeCollapsible:n,...r}=e,i=V(ae,n);return(0,L.jsx)(D.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":U(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:C(e.onClick,i.onOpenToggle)})},`CollapsibleTrigger`)),H=`CollapsibleContent`,se=I.forwardRef(z(function(e,t){let{forceMount:n,...r}=e,i=V(H,e.__scopeCollapsible);return(0,L.jsx)(A,{present:n||i.open,children:({present:e})=>(0,L.jsx)(ce,{...r,ref:t,present:e})})},`CollapsibleContent`)),ce=I.forwardRef(z(function(e,t){let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=V(H,n),[s,c]=I.useState(r),l=I.useRef(null),u=k(t,l),d=I.useRef(0),f=d.current,p=I.useRef(0),m=p.current,h=o.open||s,g=I.useRef(h),_=I.useRef(void 0);return I.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),S(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,L.jsx)(D.div,{"data-state":U(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})},`CollapsibleContentImpl`));function U(e){return e?`open`:`closed`}z(U,`getState`);var le=Object.defineProperty,W=(e,t)=>le(e,`name`,{value:t,configurable:!0}),G={Automatic:`automatic`,Manual:`manual`},K=`Tabs`,[ue,de]=T(K,[M]),fe=M(),[pe,q]=ue(K),me=I.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=G.Automatic,...l}=e,u=P(s),[d,f]=E({prop:r,onChange:i,defaultProp:a??``,caller:K});return(0,L.jsx)(pe,{scope:n,baseId:w(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,L.jsx)(D.div,{dir:u,"data-orientation":o,...l,ref:t})})},`Tabs`)),he=`TabsList`,ge=I.forwardRef(W(function(e,t){let{__scopeTabs:n,loop:r=!0,...i}=e,a=q(he,n),o=fe(n);return(0,L.jsx)(N,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,L.jsx)(D.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})},`TabsList`)),_e=`TabsTrigger`,ve=I.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=q(_e,n),s=fe(n),c=J(o.baseId,r),l=Y(o.baseId,r),u=r===o.value;return(0,L.jsx)(j,{asChild:!0,...s,focusable:!i,active:u,children:(0,L.jsx)(D.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:C(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?(e.currentTarget.focus(),o.onValueChange(r)):e.preventDefault()}),onKeyDown:C(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:C(e.onFocus,()=>{let e=o.activationMode!==G.Manual;!u&&!i&&e&&o.onValueChange(r)})})})},`TabsTrigger`)),ye=`TabsContent`,be=I.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=q(ye,n),c=J(s.baseId,r),l=Y(s.baseId,r),u=r===s.value,d=I.useRef(u);return I.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,L.jsx)(A,{present:i||u,children:({present:n})=>(0,L.jsx)(D.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})},`TabsContent`));function J(e,t){return`${e}-trigger-${t}`}W(J,`makeTriggerId`);function Y(e,t){return`${e}-content-${t}`}W(Y,`makeContentId`);function xe({...e}){return(0,L.jsx)(ie,{"data-slot":`collapsible`,...e})}function Se({...e}){return(0,L.jsx)(oe,{"data-slot":`collapsible-trigger`,...e})}function Ce({...e}){return(0,L.jsx)(se,{"data-slot":`collapsible-content`,...e})}function we({className:e,orientation:t=`horizontal`,...n}){return(0,L.jsx)(me,{"data-slot":`tabs`,"data-orientation":t,className:a(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Te=O(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Ee({className:e,variant:t=`default`,...n}){return(0,L.jsx)(ge,{"data-slot":`tabs-list`,"data-variant":t,className:a(Te({variant:t}),e),...n})}function X({className:e,...t}){return(0,L.jsx)(ve,{"data-slot":`tabs-trigger`,className:a(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function Z({className:e,...t}){return(0,L.jsx)(be,{"data-slot":`tabs-content`,className:a(`flex-1 text-sm outline-none`,e),...t})}var De=90,Oe=[`var(--chart-1)`,`var(--chart-2)`,`var(--chart-3)`,`var(--chart-4)`,`var(--chart-5)`],Q=e=>Math.abs(e.value);function ke({children:e,tone:t}){return(0,L.jsx)(`span`,{className:a(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,t===`warn`?`bg-warning/10 text-warning`:`bg-secondary text-secondary-foreground`),children:e})}function Ae({a:e,holdings:t,card:n,deposit:r,nested:i}){let{t:o,lang:s}=d();return(0,L.jsxs)(`li`,{className:a(`relative flex flex-col gap-1 rounded-md py-1.5 hover:bg-muted/40 focus-within:ring-3 focus-within:ring-ring/50`,i?`pl-4`:`px-2`),children:[(0,L.jsxs)(`div`,{className:`flex min-h-11 items-center justify-between gap-3`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`a`,{href:ee({account:e.id}),className:`truncate rounded-md text-sm font-medium outline-none after:absolute after:inset-0 focus-visible:underline`,children:e.name}),e.closed&&(0,L.jsx)(ke,{children:o(`accounts.closedOn`,{date:_(e.closed,s)})}),t&&!e.priced&&(0,L.jsx)(ke,{tone:`warn`,children:o(`accounts.noPrice`)})]}),(0,L.jsx)(y,{amount:e.value,mode:`short`,className:`shrink-0 text-sm font-medium`})]}),t&&(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.qty!==null&&(0,L.jsx)(L.Fragment,{children:o(`accounts.qty`,{n:m(e.qty,s,4)})}),e.price&&(0,L.jsxs)(L.Fragment,{children:[` · `,o(`accounts.price`,{price:v(e.price.price,s),date:h(e.price.date)})]}),` · `,o(`accounts.cost`),` `,(0,L.jsx)(y,{amount:e.cost,mode:`short`})]}),n&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(b,{owed:n.owed,limit:n.limit,atLeast:n.limitAtLeast}),(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground`,children:[n.toPay>0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{children:[o(`cards.toPay`),` `,(0,L.jsx)(y,{amount:n.toPay,mode:`short`,className:`font-medium text-foreground`})]}),n.due&&(0,L.jsx)(`span`,{children:h(n.due)}),(0,L.jsx)(x,{days:n.daysToDue})]}):(0,L.jsx)(`span`,{children:o(`cards.nothingToPay`)}),(0,L.jsx)(`a`,{href:F(n.account),className:`relative z-10 ml-auto inline-flex min-h-11 items-center rounded-md px-1 underline outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,children:o(`accounts.cardPage`)})]})]}),r&&(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.maturity?`${r.daysToMaturity<0?o(`deposits.matured`):o(`deposits.inDays`,{n:r.daysToMaturity})} · ${h(r.maturity)}`:o(`deposits.noMaturity`),r.rate!==null&&` · ${m(r.rate,s,2)}%`,r.interestAtMaturity?(0,L.jsxs)(L.Fragment,{children:[` · `,o(`deposits.interest`),` `,(0,L.jsx)(y,{amount:r.interestAtMaturity,mode:`short`})]}):null]})]})}function je({open:n,onToggle:r,label:i,count:o,children:s,nested:c}){return(0,L.jsxs)(`div`,{className:a(`flex flex-col`,c&&`pl-4`),children:[(0,L.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:r,className:`flex min-h-11 items-center gap-1 rounded-md px-2 text-left text-sm text-muted-foreground outline-none hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50`,children:[n?(0,L.jsx)(e,{className:`size-4`,"aria-hidden":!0}):(0,L.jsx)(t,{className:`size-4`,"aria-hidden":!0}),i,` (`,o,`)`]}),n&&s]})}function Me(){let{t:n,lang:r}=d(),i=u().data,a=s().data,{data:h,error:_,isLoading:v}=l(),b=!!i?.features?.cards,x=o(b).data,S=c(!!i?.features?.deposits).data,C=i?.today??new Date().toISOString().slice(0,10),w=i?.pool,T=w?.name??n(`pool.name`),[E,D]=(0,I.useState)(!1),O=e=>a?.types[e]?.[r]??e,k=e=>!!a?.types[e]?.holdings,A=(0,I.useMemo)(()=>new Map((x?.cards??[]).map(e=>[e.account,e])),[x]),j=(0,I.useMemo)(()=>new Map((S??[]).map(e=>[e.account,e])),[S]),M=(0,I.useMemo)(()=>{let e=h??[],t=e=>!!a?.types[e.type]?.liability,n=e=>(t(e)||e.value<0)&&e.value<0,r=0,i=0,o=0;for(let t of e)(t.value!==0||t.qty)&&(n(t)?i+=t.value:r+=t.value,t.priced||o++);let s=e=>e.value===0&&!e.qty&&(e.lastActivity===null||g(e.lastActivity,C)>De),c=e.filter(e=>e.closed),l=e.filter(e=>!e.closed),u=w?.on?l.filter(e=>e.pool):[],d=l.filter(e=>!u.includes(e)),f=d.filter(s),p=d.filter(e=>!s(e)),m=p.filter(e=>t(e)||e.value<0),_=e=>A.get(e.id)?.daysToDue??1/0;m.sort((e,t)=>_(e)-_(t)||e.value-t.value);let v=new Map;for(let e of p.filter(e=>!m.includes(e))){let t=v.get(e.type)??{id:e.type,label:O(e.type),value:0,items:[]};t.items.push(e),t.value+=e.value,v.set(e.type,t)}let y=[...v.values()];for(let e of y)e.items.sort((e,t)=>Q(t)-Q(e));let b=u.filter(e=>!s(e)).sort((e,t)=>Q(t)-Q(e)),x=u.filter(s);u.length&&y.push({id:`pool`,label:T,value:u.reduce((e,t)=>e+t.value,0),items:b,pool:!0}),y.sort((e,t)=>t.value-e.value),y.forEach((e,t)=>e.color=e.value>0&&t<Oe.length?Oe[t]:`var(--chart-muted)`);let S=y.reduce((e,t)=>e+(t.pool?u.length:t.items.length),0);return{assets:r,liabilities:i,net:r+i,groups:y,debt:m,poolIdle:x,poolCount:u.length,assetCount:S,inactiveRest:f.sort((e,t)=>e.name.localeCompare(t.name)),closed:c.sort((e,t)=>(t.closed??``).localeCompare(e.closed??``)),unpriced:o,any:e.length>0}},[h,a,w?.on,T,C,r,A]);if(_)return(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`common.error`,{message:_.message})});if(v||!h||!a)return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":`true`,children:[(0,L.jsx)(p,{className:`h-8 w-48`}),(0,L.jsx)(p,{className:`h-24 w-full`}),(0,L.jsx)(p,{className:`h-48 w-full`})]});if(!M.any)return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:n(`accounts.title`)}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`accounts.empty`)}),(0,L.jsx)(f,{className:`self-start`,prompt:n(`start.s2.prompt`)})]});let N=(e,t)=>(0,L.jsx)(Ae,{a:e,nested:t,holdings:k(e.type),card:A.get(e.id),deposit:j.get(e.id)},e.id),P=M.groups.filter(e=>e.value>0),F=P.reduce((e,t)=>e+t.value,0),R=e=>F>0&&e>0?`${m(e/F*100,r)}%`:``,z=M.inactiveRest.length+M.closed.length;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:n(`accounts.title`)}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`accounts.netWorth`)}),(0,L.jsx)(y,{amount:M.net,className:`text-3xl font-semibold tracking-tight md:text-4xl`}),(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n(`accounts.assets`),` `,(0,L.jsx)(y,{amount:M.assets,mode:`short`,className:`font-medium text-foreground`}),` · `,n(`accounts.liabilities`),` `,(0,L.jsx)(y,{amount:M.liabilities,mode:`short`,className:`font-medium text-foreground`})]}),M.unpriced>0&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`nw.unpriced`,{n:M.unpriced})})]}),P.length>0&&(0,L.jsx)(`div`,{className:`flex h-2.5 w-full gap-0.5 overflow-hidden rounded-full`,role:`img`,"aria-label":`${n(`accounts.byType`)}: ${P.map(e=>`${e.label} ${R(e.value)}`).join(`, `)}`,children:P.map(e=>(0,L.jsx)(`span`,{className:`h-full first:rounded-l-full last:rounded-r-full`,style:{width:`${e.value/F*100}%`,background:e.color},title:`${e.label} ${R(e.value)}`},e.id))}),(0,L.jsxs)(we,{defaultValue:`assets`,className:`gap-4`,children:[(0,L.jsxs)(Ee,{className:`h-10! w-full sm:w-fit`,children:[(0,L.jsxs)(X,{value:`assets`,className:`px-3`,children:[n(`accounts.assets`),(0,L.jsx)($,{n:M.assetCount})]}),M.debt.length>0&&(0,L.jsxs)(X,{value:`debt`,className:`px-3`,children:[n(`accounts.liabilities`),(0,L.jsx)($,{n:M.debt.length})]}),z>0&&(0,L.jsxs)(X,{value:`idle`,className:`px-3`,children:[n(`accounts.tabIdle`),(0,L.jsx)($,{n:z})]})]}),(0,L.jsx)(Z,{value:`assets`,children:(0,L.jsx)(`div`,{className:`grid items-start gap-3 md:grid-cols-2`,children:M.groups.map(r=>(0,L.jsxs)(xe,{className:`group/acc overflow-hidden rounded-xl bg-card ring-1 ring-foreground/[0.07] shadow-[0_1px_2px_oklch(0_0_0/0.04)]`,children:[(0,L.jsxs)(Se,{className:`flex min-h-14 w-full items-center gap-3 px-4 text-left outline-none hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`size-2.5 shrink-0 rounded-full`,style:{background:r.color}}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:[r.label,(0,L.jsx)(`span`,{className:`ml-1.5 font-normal text-muted-foreground tabular-nums`,children:r.pool?M.poolCount:r.items.length})]}),(0,L.jsx)(y,{amount:r.value,mode:`short`,className:`shrink-0 text-sm font-semibold`}),(0,L.jsx)(`span`,{className:`w-9 shrink-0 text-right text-xs text-muted-foreground tabular-nums`,children:R(r.value)}),(0,L.jsx)(e,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-data-[state=open]/acc:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,L.jsxs)(Ce,{className:`border-t px-2 py-1`,children:[r.pool&&(0,L.jsxs)(`a`,{href:ee({account:`pool`}),className:`flex min-h-11 items-center justify-between gap-2 rounded-md px-2 text-sm text-muted-foreground outline-none hover:bg-muted/40 hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:[n(`accounts.poolTx`,{name:T}),(0,L.jsx)(t,{className:`size-4`,"aria-hidden":!0})]}),(0,L.jsx)(`ul`,{className:`flex flex-col`,children:r.items.map(e=>N(e))}),r.pool&&M.poolIdle.length>0&&(0,L.jsx)(je,{open:E,onToggle:()=>D(e=>!e),label:n(`accounts.inactive`),count:M.poolIdle.length,children:(0,L.jsx)(`ul`,{className:`flex flex-col`,children:M.poolIdle.map(e=>N(e,!0))})})]})]},r.id))})}),M.debt.length>0&&(0,L.jsx)(Z,{value:`debt`,children:(0,L.jsx)(`ul`,{className:`grid items-start gap-3 md:grid-cols-2`,children:M.debt.map(e=>(0,L.jsx)(`li`,{className:`list-none rounded-xl bg-card px-2 py-1 ring-1 ring-foreground/[0.07] shadow-[0_1px_2px_oklch(0_0_0/0.04)]`,children:(0,L.jsx)(`ul`,{children:N(e)})},e.id))})}),z>0&&(0,L.jsxs)(Z,{value:`idle`,className:`flex flex-col gap-5`,children:[M.inactiveRest.length>0&&(0,L.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`h2`,{className:`px-2 text-sm font-medium text-muted-foreground`,children:[n(`accounts.inactive`),` `,(0,L.jsx)(`span`,{className:`tabular-nums`,children:M.inactiveRest.length})]}),(0,L.jsx)(`ul`,{className:`grid gap-x-6 rounded-xl bg-card px-2 py-1 ring-1 ring-foreground/[0.07] md:grid-cols-2`,children:M.inactiveRest.map(e=>N(e))})]}),M.closed.length>0&&(0,L.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`h2`,{className:`px-2 text-sm font-medium text-muted-foreground`,children:[n(`accounts.closed`),` `,(0,L.jsx)(`span`,{className:`tabular-nums`,children:M.closed.length})]}),(0,L.jsx)(`ul`,{className:`grid gap-x-6 rounded-xl bg-card px-2 py-1 ring-1 ring-foreground/[0.07] md:grid-cols-2`,children:M.closed.map(e=>N(e))})]})]})]})]})}function $({n:e}){return(0,L.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-xs font-normal text-muted-foreground tabular-nums group-data-active:bg-secondary`,children:e})}export{Me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./createLucideIcon-
|
|
1
|
+
import{t as e}from"./createLucideIcon-XZ28znwT.js";import{B as t,C as n,I as r,L as i,T as a,c as o,w as s}from"./queries-BcMmmb36.js";import{A as c,M as l,n as u}from"./index-DBHFdsYB.js";import{t as d}from"./Money-BwLucm7P.js";import{t as f}from"./button-BKhMn8jX.js";import{t as p}from"./drill-t1zr57xi.js";import{n as m}from"./shared-BgU6fc7z.js";var h={name:`circle-exclamation-point`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`,`circle-alert`]};h.node;var g=e(h),_={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};_.node;var v=e(_),y={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};y.node;var b=e(y),x=t(r(),1),S=i(),C=5,w={red:{icon:g,cls:`text-critical`,row:`bg-critical/5`},amber:{icon:v,cls:`text-warning`},info:{icon:b,cls:`text-muted-foreground`}};function T(e,t){let r={name:e.name??``,count:e.count??0,n:e.count??0,...e.params??{}},i=`attention.${e.kind}`,a=n(t,i,r);return a===i?e.title:a}function E(e,t){return e.days===void 0?null:e.days<0?t(`attention.overdueDays`,{n:-e.days}):e.days===0?t(`attention.today`):t(`attention.inDays`,{n:e.days})}function D(e,t){let n=e.name??``;switch(e.kind){case`uncategorised`:return t(`ask.uncategorised`,{n:e.count??0,from:String(e.params?.from??``)});case`plan_due`:case`plan_overdue`:return t(`ask.plan`,{name:n});case`unmatched`:return t(`ask.unmatched`,{name:n});case`negative`:return t(`ask.negative`,{name:n});default:return t(`ask.generic`,{title:e.title})}}function O({widget:e,menu:t}){let{t:n,lang:r}=s(),i=m(e,`widget.attention`),{data:h,error:g,isLoading:_}=o(),[v,y]=(0,x.useState)(!1),b=h?.attention??[],O=v?b:b.slice(0,C);return(0,S.jsxs)(l,{title:(0,S.jsxs)(`span`,{className:`flex items-center gap-2`,children:[i,b.length>0&&(0,S.jsx)(`span`,{className:a(`rounded-full px-2 py-0.5 text-xs font-medium tabular-nums`,b.some(e=>e.severity===`red`)?`bg-critical/10 text-critical`:`bg-secondary text-secondary-foreground`),children:b.length})]}),menu:t,loading:_,error:g?.message,empty:h&&b.length===0?n(`attention.empty`):void 0,children:[(0,S.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:O.map((e,t)=>{let i=E(e,n),o=T(e,r),s=w[e.severity],l=s.icon,f=(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 items-center`,children:[(0,S.jsx)(l,{className:a(`size-4`,s.cls),"aria-hidden":!0}),(0,S.jsx)(`span`,{className:`sr-only`,children:n(`attention.sev.${e.severity}`)})]}),(0,S.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,S.jsx)(`span`,{className:`text-sm`,children:o}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:[i,!i||e.days===void 0?null:u(e.date)].filter(Boolean).join(` · `)})]}),e.amount!==void 0&&(0,S.jsx)(d,{amount:Math.abs(e.amount),mode:`short`,className:`shrink-0 text-sm font-medium`})]});return(0,S.jsxs)(`li`,{className:a(`-mx-2 flex flex-wrap items-center gap-x-2 gap-y-1 rounded-lg px-2 py-1.5`,s.row),children:[e.link?(0,S.jsx)(`a`,{href:e.link.startsWith(`#`)?e.link:p(),className:`flex min-h-11 min-w-0 flex-1 items-start gap-2 rounded-md py-1 outline-none hover:bg-muted/50 focus-visible:ring-3 focus-visible:ring-ring/50`,children:f}):(0,S.jsx)(`div`,{className:`flex min-h-11 min-w-0 flex-1 items-start gap-2 py-1`,children:f}),e.ask&&(0,S.jsx)(c,{prompt:D(e,n)})]},`${e.kind}-${t}`)})}),b.length>C&&(0,S.jsx)(f,{type:`button`,variant:`ghost`,size:`sm`,className:`min-h-11 self-start md:min-h-8`,onClick:()=>y(e=>!e),children:v?n(`common.showLess`):n(`attention.seeAll`,{n:b.length})})]})}export{T as attentionLabel,O as default,E as whenText};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./charts-
|
|
1
|
+
import{r as e}from"./charts-D-1glV8L.js";import{t}from"./CategoryIcon-D4Cdb_ZP.js";import{t as n}from"./Money-BwLucm7P.js";import{M as r,l as i,o as a}from"./index-DBHFdsYB.js";import{L as o,_ as s,u as c,w as l}from"./queries-BcMmmb36.js";import{t as u}from"./drill-t1zr57xi.js";import{n as d,t as f}from"./shared-BgU6fc7z.js";var p=o();function m(e,t){let n=t.slice(0,7);switch(e){case`last-month`:return a(n,-1);case`this-year`:return t.slice(0,4);case`last-year`:return String(Number(t.slice(0,4))-1);default:return e&&/^\d{4}(-\d{2})?$/.test(e)?e:n}}function h({widget:a,menu:o}){let{t:h,lang:g}=l(),_=d(a,`widget.byCategory`),v=c().data,y=m(a.period,v?.today??new Date().toISOString().slice(0,10)),{data:b,error:x,isLoading:S}=s(y,`top`),C=(b?.rows??[]).filter(e=>e.current>0).sort((e,t)=>t.current-e.current).slice(0,8),w=b?.current??0;return(0,p.jsx)(r,{title:_,titleHref:`#/reports`,menu:o,loading:S,error:x?.message,empty:b&&C.length===0?h(`bycat.empty`):void 0,children:b&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[h(`bycat.total`),` `,(0,p.jsx)(n,{amount:w,mode:`short`,className:`font-medium text-foreground`})]}),(0,p.jsx)(e,{rows:C.map(e=>({key:e.key,name:(0,p.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(t,{category:e.key,name:e.name,className:`size-6 [&_svg]:size-3`}),(0,p.jsx)(`span`,{className:`truncate`,children:e.name})]}),value:e.current,label:(0,p.jsx)(n,{amount:e.current,mode:`short`,className:`font-medium`}),meta:(0,p.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,p.jsxs)(`span`,{children:[i(e.current/(w||1)*100,g),`%`]}),e.changePct!==null&&b.months>=1&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(f,{pct:e.changePct,className:`text-xs`}),(0,p.jsx)(`span`,{children:h(`pace.vsUsual`)})]})]}),href:u({category:e.key,from:b.period.from,to:b.period.to})}))})]})})}export{h as default,m as reportPeriod};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./createLucideIcon-flJrJK2p.js";import{t}from"./chevron-right-Dqh3vs9Y.js";import{B as n,I as r,L as i,T as a,d as o,h as s,r as c,w as l,y as u}from"./queries-DZIMMe4i.js";import{A as d,G as f,J as p,K as m,W as h,Y as g,a as _,k as v,l as y,q as b,r as x,s as S,t as C}from"./index-eR1GkdC_.js";import{t as w}from"./DrillLink-Bvfam9FA.js";import{t as T}from"./KV-DMA1AlP-.js";import{t as E}from"./Money-PfFNNDOw.js";import{t as D}from"./Panel-BnfWrw9R.js";import{a as O,i as k,n as A,o as j,r as M}from"./bits-Dr2E0ObC.js";import{n as N,t as P}from"./TxRow-EKIIMQKa.js";import{a as F,n as I,t as L}from"./charts-BqP7HKwP.js";import{n as R,r as z}from"./cards-Bb5zjzRG.js";var B={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};B.node;var V=e(B),H=n(r(),1),U=i();function W({account:e,close:t,onClose:n}){let{t:r,lang:i}=l(),a=v(`(max-width: 767px)`),{data:c,error:u,isLoading:d}=s(e,t),_=N(o().data),y=c?.statement;return(0,U.jsx)(f,{open:t!==null,onOpenChange:e=>!e&&n(),children:(0,U.jsxs)(m,{side:a?`bottom`:`right`,className:a?`max-h-[85svh] overflow-auto rounded-t-xl`:`overflow-auto sm:max-w-md`,children:[(0,U.jsxs)(p,{children:[(0,U.jsx)(g,{children:y?.open?r(`cards.currentPeriod`):r(`cards.statementOf`,{date:t?S(t,i):``})}),(0,U.jsxs)(b,{children:[y?`${S(y.from,i)} – ${S(y.close,i)}`:r(`common.loading`),y?.pdf&&(0,U.jsxs)(U.Fragment,{children:[` · `,(0,U.jsx)(`a`,{href:`/api/m/cards/statement-pdf?account=${encodeURIComponent(e)}&close=${y.close}`,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:r(`cards.statementPdf`)})]})]})]}),(0,U.jsx)(`div`,{className:`flex flex-col gap-3 px-4 pb-4`,children:u?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`common.error`,{message:u.message})}):d||!c||!y?(0,U.jsx)(h,{className:`h-40 w-full`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`dl`,{className:`divide-y rounded-lg border px-3`,children:[(0,U.jsx)(T,{label:r(`cards.opening`),children:(0,U.jsx)(E,{amount:y.opening})}),(0,U.jsx)(T,{label:r(`cards.k.purchase`),children:(0,U.jsx)(E,{amount:y.purchases})}),y.fees>0&&(0,U.jsx)(T,{label:r(`cards.k.fee`),children:(0,U.jsx)(E,{amount:y.fees})}),y.refunds>0&&(0,U.jsx)(T,{label:r(`cards.k.refund`),children:(0,U.jsx)(E,{amount:-y.refunds})}),y.cashback>0&&(0,U.jsx)(T,{label:r(`cards.k.cashback`),children:(0,U.jsx)(E,{amount:-y.cashback})}),y.payments>0&&(0,U.jsx)(T,{label:r(`cards.k.payment`),children:(0,U.jsx)(E,{amount:-y.payments})}),(0,U.jsx)(T,{label:r(`cards.closing`),className:`font-medium`,children:(0,U.jsx)(E,{amount:y.closing})})]}),(0,U.jsx)(`ul`,{children:c.transactions.map(t=>(0,U.jsxs)(`li`,{className:`flex flex-col`,children:[t.kind&&(0,U.jsx)(`span`,{className:`px-2 pt-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase`,children:r(`cards.k.${t.kind}`)}),(0,U.jsx)(P,{tx:t,names:_,account:e})]},t.id))}),c.transactions.length===0&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`tx.emptyFiltered`)})]})})]})})}function G({value:e,max:t,label:n}){let r=t>0?Math.min(1,e/t):0;return(0,U.jsx)(`div`,{role:`progressbar`,"aria-label":n,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r*100),className:`h-2 w-full rounded-full bg-muted`,children:(0,U.jsx)(`div`,{className:`h-2 rounded-full bg-[var(--chart-1)]`,style:{width:`${Math.max(r?2:0,r*100)}%`}})})}function K({d:e,asOf:t}){let{t:n,lang:r}=l(),i=e.summary?.current,a=e.terms.statementDay,o=e.account.id;return(0,U.jsx)(D,{title:n(`cards.currentPeriod`),children:i?(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsx)(T,{label:n(`cards.purchasesSoFar`),children:(0,U.jsx)(w,{filter:{account:o,from:i.from,to:t},className:`font-medium`,children:(0,U.jsx)(E,{amount:i.purchases})})}),a&&(0,U.jsxs)(T,{label:n(`cards.closesOn`),children:[S(z(t,a),r),` · `,(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:n(`cards.daysLeft`,{n:R(t,a)})})]}),e.payByToday&&(0,U.jsxs)(T,{label:n(`cards.payByToday`),children:[(0,U.jsx)(`span`,{className:`font-medium`,children:S(e.payByToday,r)}),` · `,(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:n(`cards.daysLeft`,{n:x(t,e.payByToday)})})]})]}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(a?`cards.noActivity`:`cards.noStatementDay`)})})}function q({s:e,id:t,asOf:n}){let{t:r,lang:i}=l();return(0,U.jsx)(D,{title:e?r(`cards.statementOf`,{date:S(e.close,i)}):r(`cards.lastStatement`),action:e?(0,U.jsx)(O,{status:e.status}):void 0,children:e?(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsx)(T,{label:r(`cards.amountDue`),children:(0,U.jsx)(w,{filter:{account:t,from:e.from,to:e.close},className:`text-lg font-semibold`,children:(0,U.jsx)(E,{amount:e.amountDue})})}),e.due&&(0,U.jsxs)(T,{label:r(`cards.dueDate`),children:[S(e.due,i),` `,e.toPay>0&&(0,U.jsx)(M,{days:x(n,e.due),className:`ml-1`})]}),(0,U.jsx)(T,{label:r(`cards.paid`),children:(0,U.jsx)(w,{filter:{account:t,from:C(e.close,1),to:n},children:(0,U.jsx)(E,{amount:e.paid})})}),(0,U.jsx)(T,{label:r(`cards.toPay`),className:`font-medium`,children:(0,U.jsx)(E,{amount:e.toPay})}),e.deferred>0&&(0,U.jsx)(T,{label:r(`cards.deferred`),children:(0,U.jsx)(E,{amount:e.deferred})}),e.bank!==null&&(0,U.jsxs)(T,{label:r(`cards.bankAmount`),children:[(0,U.jsx)(E,{amount:e.bank}),e.bankDiff!==null&&e.bankDiff!==0&&(0,U.jsx)(`span`,{className:`block text-xs text-warning`,children:r(`cards.bankDiff`,{amount:`${e.bankDiff>0?`+`:`−`}${y(Math.abs(e.bankDiff),i)}`})})]})]}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`cards.noClosed`)})})}function J({list:e,onOpen:n}){let{t:r,lang:i}=l();return(0,U.jsx)(D,{title:r(`cards.history`),children:e.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`cards.noHistory`)}):(0,U.jsx)(`ul`,{className:`-mx-2 flex flex-col divide-y`,children:e.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.close),className:`flex min-h-12 w-full items-center gap-3 rounded-md px-2 py-1.5 text-left outline-none hover:bg-muted/50 focus-visible:ring-3 focus-visible:ring-ring/50`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.open?r(`cards.currentPeriod`):S(e.close,i)}),(0,U.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[S(e.from,i,{day:`2-digit`,month:`2-digit`}),` – `,S(e.close,i,{day:`2-digit`,month:`2-digit`}),` · `,r(`cards.purchasesShort`),` `,(0,U.jsx)(E,{amount:e.purchases,mode:`short`})]})]}),(0,U.jsxs)(`span`,{className:`flex shrink-0 flex-col items-end`,children:[(0,U.jsx)(E,{amount:e.open?e.closing:e.amountDue,mode:`short`,className:`text-sm font-medium`}),!e.open&&(0,U.jsx)(O,{status:e.status})]}),(0,U.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})]})},e.close))})})}function Y({d:e}){let{t,lang:n}=l(),r=e.summary?.cashback??null,i=(0,H.useMemo)(()=>[...e.cashback].filter(e=>!e.open).reverse().slice(-12),[e.cashback]).map(e=>({ym:e.close,label:_(e.close.slice(0,7)),expected:e.expected,received:e.received}));return!e.terms.cashback&&!e.cashback.some(e=>e.expected>0||e.received>0)?(0,U.jsxs)(D,{title:t(`cards.cashback`),children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`cards.noCashback`)}),(0,U.jsx)(d,{prompt:t(`ask.cardTerms`,{name:e.account.name,list:t(`cards.missing.cashback_rates`)})})]}):(0,U.jsxs)(D,{title:t(`cards.cashback`),children:[r&&(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsx)(T,{label:t(`cards.spendThisPeriod`),children:(0,U.jsx)(w,{filter:{account:e.account.id,from:r.from,to:r.close},children:(0,U.jsx)(E,{amount:r.spend})})}),(0,U.jsx)(T,{label:t(`cards.expected`),children:r.incomplete?(0,U.jsx)(`span`,{className:`text-warning`,children:t(`cards.rateNotSet`)}):(0,U.jsx)(E,{amount:r.expected,className:`font-medium`})}),r.cap!==null&&r.capLeft!==null&&(0,U.jsxs)(T,{label:t(`cards.capLeftLabel`),children:[(0,U.jsx)(E,{amount:r.capLeft}),` `,(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`/ `,(0,U.jsx)(E,{amount:r.cap,mode:`short`})]})]})]}),r&&r.minSpend!==null&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(G,{value:r.spend,max:r.minSpend,label:t(`cards.minSpend`)}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.minMet?t(`cards.minMet`,{amount:y(r.minSpend,n)}):t(`cards.minNeed`,{amount:y(r.needForMin,n),min:y(r.minSpend,n)})})]}),i.length>0&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:t(`cards.last12`)}),(0,U.jsx)(`div`,{className:`flex h-40 flex-col`,children:(0,U.jsx)(L,{legend:[{label:t(`cards.earned`),color:F.accent},{label:t(`cards.expected`),color:F.second}],table:{head:[t(`chart.month`),t(`cards.earned`),t(`cards.expected`)],rows:i.map(e=>[e.label,y(e.received,n),y(e.expected,n)])},children:(0,U.jsx)(I,{data:i,xKey:`label`,series:[{key:`received`,label:t(`cards.earned`),color:F.accent},{key:`expected`,label:t(`cards.expected`),color:F.second}]})})})]})]})}function X({d:e,asOf:t}){let{t:n,lang:r}=l(),i=e.feeWaiver;return!i&&!e.terms.annualFee?null:(0,U.jsx)(D,{title:n(`cards.feeWaiver`),children:i?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(G,{value:i.spent,max:i.target,label:n(`cards.feeWaiver`)}),(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsxs)(T,{label:n(`cards.spent`),children:[(0,U.jsx)(w,{filter:{account:e.account.id,from:i.yearFrom,to:t},children:(0,U.jsx)(E,{amount:i.spent})}),` `,(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`/ `,(0,U.jsx)(E,{amount:i.target,mode:`short`})]})]}),(0,U.jsxs)(T,{label:n(`cards.deadline`),children:[S(i.deadline,r),` `,(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,n(`cards.daysLeft`,{n:i.daysLeft})]})]}),!i.met&&(0,U.jsx)(T,{label:n(`cards.perMonth`),children:(0,U.jsx)(E,{amount:i.perMonth})}),e.terms.annualFee?(0,U.jsx)(T,{label:n(`cards.annualFee`),children:(0,U.jsx)(E,{amount:e.terms.annualFee})}):null]}),(0,U.jsx)(`p`,{className:a(`text-sm font-medium`,i.met||i.onTrack?`text-foreground`:`text-critical`),children:i.met?n(`cards.feeMet`):i.onTrack?n(`cards.onTrack`):n(`cards.behind`)})]}):(0,U.jsxs)(`dl`,{children:[(0,U.jsx)(T,{label:n(`cards.annualFee`),children:(0,U.jsx)(E,{amount:e.terms.annualFee})}),(0,U.jsx)(`p`,{className:`py-1 text-sm text-muted-foreground`,children:n(`cards.noWaiver`)})]})})}function Z({d:e}){let{t}=l();return e.instalments.length===0?null:(0,U.jsx)(D,{title:t(`cards.instalments`),children:(0,U.jsx)(`ul`,{className:`flex flex-col gap-3`,children:e.instalments.map(e=>(0,U.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,U.jsx)(w,{filter:{plan:e.plan},className:`min-w-0 truncate font-medium`,children:e.name}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.paidCount,`/`,e.count??`–`]})]}),(0,U.jsx)(G,{value:e.paidCount,max:e.count??0,label:e.name}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t(`cards.perMonthPay`),` `,(0,U.jsx)(E,{amount:e.perPayment,mode:`short`}),e.leftAmount!==null&&(0,U.jsxs)(U.Fragment,{children:[` · `,t(`cards.left`),` `,(0,U.jsx)(E,{amount:e.leftAmount,mode:`short`})]})]})]},e.plan))})})}function Q({d:e}){let{t,lang:n}=l(),r=e.record;if(!r)return(0,U.jsxs)(D,{title:t(`cards.lifecycle`),children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`cards.noRecord`)}),(0,U.jsx)(d,{prompt:t(`ask.cardRecord`,{name:e.account.name})})]});let i=e=>e?S(e,n):null,a=[[t(`cards.issued`),i(r.issued)],[t(`cards.activated`),i(r.activated)],[t(`cards.lockedOn`),i(r.locked)],[t(`cards.cancelledOn`),i(r.cancelled)],[t(`cards.network`),r.network?r.network.toUpperCase():null],[t(`cards.form`),r.physical?t(`cards.physical.${r.physical}`):null]];return(0,U.jsxs)(D,{title:t(`cards.lifecycle`),action:(0,U.jsx)(A,{status:r.status??`active`}),children:[(0,U.jsxs)(`dl`,{className:`divide-y`,children:[a.filter(([,e])=>e).map(([e,t])=>(0,U.jsx)(T,{label:e,children:t},e)),r.annual_fee?(0,U.jsx)(T,{label:t(`cards.annualFee`),children:(0,U.jsx)(E,{amount:r.annual_fee})}):null,r.close_fee?(0,U.jsx)(T,{label:t(`cards.closeFee`),children:(0,U.jsx)(E,{amount:r.close_fee})}):null,r.keep_for_limit&&(0,U.jsx)(T,{label:t(`cards.keepForLimit`),children:t(`cards.yes`)})]}),r.cancel_plan&&(0,U.jsxs)(`div`,{className:`rounded-md bg-muted/60 p-3 text-sm`,children:[(0,U.jsx)(`p`,{className:`font-medium`,children:t(`cards.cancelPlan`,{by:r.cancel_plan.by??``})}),r.cancel_plan.note&&(0,U.jsx)(`p`,{className:`text-muted-foreground`,children:r.cancel_plan.note})]}),r.note&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r.note})]})}function $({d:e}){let{t}=l(),n=e.value;return n?(0,U.jsx)(D,{title:t(`cards.netValue`),children:(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsx)(T,{label:t(`cards.value.benefits`),children:(0,U.jsx)(E,{amount:n.benefits})}),(0,U.jsx)(T,{label:t(`cards.cashback`),children:(0,U.jsx)(E,{amount:n.cashback})}),(0,U.jsx)(T,{label:n.feesFrom===`record`?`${t(`cards.value.fees`)} (${t(`cards.value.estimated`)})`:t(`cards.value.fees`),children:(0,U.jsx)(E,{amount:-n.fees})}),n.closeFee>0&&(0,U.jsx)(T,{label:t(`cards.closeFee`),children:(0,U.jsx)(E,{amount:-n.closeFee})}),(0,U.jsx)(T,{label:t(`cards.value.sinceIssued`),className:`font-medium`,children:(0,U.jsx)(E,{amount:n.net,tone:`auto`})}),(0,U.jsx)(T,{label:t(`cards.value.last12`),className:`font-medium`,children:(0,U.jsx)(E,{amount:n.last12.net,tone:`auto`})})]})}):null}function ee({params:e}){let{t}=l(),n=decodeURIComponent(e.account),{data:r,error:i,isLoading:a}=c(n),[o,s]=(0,H.useState)(null),d=(0,U.jsxs)(`a`,{href:`#/cards`,className:`inline-flex min-h-11 items-center gap-1 self-start rounded-md text-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:[(0,U.jsx)(V,{className:`size-4`,"aria-hidden":!0}),t(`cards.back`)]});if(i)return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i instanceof u&&i.status===404?t(`cards.notFound`):t(`common.error`,{message:i.message})})]});if(a||!r)return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[d,(0,U.jsx)(h,{className:`h-8 w-56`}),(0,U.jsx)(h,{className:`h-40 w-full`})]});let f=r.summary,p=r.record?.status??(r.account.closed?`cancelled`:`active`),m=r.terms.last4,g=[r.terms.bank,m?t(`cards.last4`,{n:m}):null].filter(Boolean).join(` · `);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,U.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:r.account.name}),(0,U.jsx)(A,{status:p})]}),g&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:g}),f&&(0,U.jsx)(j,{owed:f.owed,limit:f.limit,atLeast:f.limitAtLeast,className:`max-w-md`}),f&&(0,U.jsx)(k,{card:f,className:`max-w-md`})]}),(0,U.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,U.jsx)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:f?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(K,{d:r,asOf:r.asOf}),(0,U.jsx)(q,{s:f.last,id:r.account.id,asOf:r.asOf}),(0,U.jsx)(J,{list:r.statements,onOpen:s})]}):(0,U.jsx)(D,{title:t(`cards.statements`),children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`cards.noStatements`)})})}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,U.jsx)(Y,{d:r}),(0,U.jsx)(X,{d:r,asOf:r.asOf}),(0,U.jsx)(Z,{d:r}),(0,U.jsx)(Q,{d:r}),(0,U.jsx)($,{d:r})]})]}),(0,U.jsx)(W,{account:r.account.id,close:o,onClose:()=>s(null)})]})}export{ee as default};
|
|
1
|
+
import{t as e}from"./createLucideIcon-XZ28znwT.js";import{t}from"./chevron-right-D7Sgw1v1.js";import{B as n,I as r,L as i,T as a,d as o,h as s,r as c,w as l,y as u}from"./queries-BcMmmb36.js";import{A as d,G as f,J as p,K as m,W as h,Y as g,a as _,k as v,l as y,q as b,r as x,s as S,t as C}from"./index-DBHFdsYB.js";import{t as w}from"./DrillLink-CZyI-y0-.js";import{t as T}from"./KV-CKWaJkRK.js";import{t as E}from"./Money-BwLucm7P.js";import{t as D}from"./Panel-CSe25x0N.js";import{a as O,i as k,n as A,o as j,r as M}from"./bits-D34d9IBm.js";import{n as N,t as P}from"./TxRow-BGfpKo2m.js";import{a as F,n as I,t as L}from"./charts-D-1glV8L.js";import{n as R,r as z}from"./cards-Ct0jh73r.js";var B={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};B.node;var V=e(B),H=n(r(),1),U=i();function W({account:e,close:t,onClose:n}){let{t:r,lang:i}=l(),a=v(`(max-width: 767px)`),{data:c,error:u,isLoading:d}=s(e,t),_=N(o().data),y=c?.statement;return(0,U.jsx)(f,{open:t!==null,onOpenChange:e=>!e&&n(),children:(0,U.jsxs)(m,{side:a?`bottom`:`right`,className:a?`max-h-[85svh] overflow-auto rounded-t-xl`:`overflow-auto sm:max-w-md`,children:[(0,U.jsxs)(p,{children:[(0,U.jsx)(g,{children:y?.open?r(`cards.currentPeriod`):r(`cards.statementOf`,{date:t?S(t,i):``})}),(0,U.jsxs)(b,{children:[y?`${S(y.from,i)} – ${S(y.close,i)}`:r(`common.loading`),y?.pdf&&(0,U.jsxs)(U.Fragment,{children:[` · `,(0,U.jsx)(`a`,{href:`/api/m/cards/statement-pdf?account=${encodeURIComponent(e)}&close=${y.close}`,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:r(`cards.statementPdf`)})]})]})]}),(0,U.jsx)(`div`,{className:`flex flex-col gap-3 px-4 pb-4`,children:u?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`common.error`,{message:u.message})}):d||!c||!y?(0,U.jsx)(h,{className:`h-40 w-full`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`dl`,{className:`divide-y rounded-lg border px-3`,children:[(0,U.jsx)(T,{label:r(`cards.opening`),children:(0,U.jsx)(E,{amount:y.opening})}),(0,U.jsx)(T,{label:r(`cards.k.purchase`),children:(0,U.jsx)(E,{amount:y.purchases})}),y.fees>0&&(0,U.jsx)(T,{label:r(`cards.k.fee`),children:(0,U.jsx)(E,{amount:y.fees})}),y.refunds>0&&(0,U.jsx)(T,{label:r(`cards.k.refund`),children:(0,U.jsx)(E,{amount:-y.refunds})}),y.cashback>0&&(0,U.jsx)(T,{label:r(`cards.k.cashback`),children:(0,U.jsx)(E,{amount:-y.cashback})}),y.payments>0&&(0,U.jsx)(T,{label:r(`cards.k.payment`),children:(0,U.jsx)(E,{amount:-y.payments})}),(0,U.jsx)(T,{label:r(`cards.closing`),className:`font-medium`,children:(0,U.jsx)(E,{amount:y.closing})})]}),(0,U.jsx)(`ul`,{children:c.transactions.map(t=>(0,U.jsxs)(`li`,{className:`flex flex-col`,children:[t.kind&&(0,U.jsx)(`span`,{className:`px-2 pt-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase`,children:r(`cards.k.${t.kind}`)}),(0,U.jsx)(P,{tx:t,names:_,account:e})]},t.id))}),c.transactions.length===0&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`tx.emptyFiltered`)})]})})]})})}function G({value:e,max:t,label:n}){let r=t>0?Math.min(1,e/t):0;return(0,U.jsx)(`div`,{role:`progressbar`,"aria-label":n,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r*100),className:`h-2 w-full rounded-full bg-muted`,children:(0,U.jsx)(`div`,{className:`h-2 rounded-full bg-[var(--chart-1)]`,style:{width:`${Math.max(r?2:0,r*100)}%`}})})}function K({d:e,asOf:t}){let{t:n,lang:r}=l(),i=e.summary?.current,a=e.terms.statementDay,o=e.account.id;return(0,U.jsx)(D,{title:n(`cards.currentPeriod`),children:i?(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsx)(T,{label:n(`cards.purchasesSoFar`),children:(0,U.jsx)(w,{filter:{account:o,from:i.from,to:t},className:`font-medium`,children:(0,U.jsx)(E,{amount:i.purchases})})}),a&&(0,U.jsxs)(T,{label:n(`cards.closesOn`),children:[S(z(t,a),r),` · `,(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:n(`cards.daysLeft`,{n:R(t,a)})})]}),e.payByToday&&(0,U.jsxs)(T,{label:n(`cards.payByToday`),children:[(0,U.jsx)(`span`,{className:`font-medium`,children:S(e.payByToday,r)}),` · `,(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:n(`cards.daysLeft`,{n:x(t,e.payByToday)})})]})]}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(a?`cards.noActivity`:`cards.noStatementDay`)})})}function q({s:e,id:t,asOf:n}){let{t:r,lang:i}=l();return(0,U.jsx)(D,{title:e?r(`cards.statementOf`,{date:S(e.close,i)}):r(`cards.lastStatement`),action:e?(0,U.jsx)(O,{status:e.status}):void 0,children:e?(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsx)(T,{label:r(`cards.amountDue`),children:(0,U.jsx)(w,{filter:{account:t,from:e.from,to:e.close},className:`text-lg font-semibold`,children:(0,U.jsx)(E,{amount:e.amountDue})})}),e.due&&(0,U.jsxs)(T,{label:r(`cards.dueDate`),children:[S(e.due,i),` `,e.toPay>0&&(0,U.jsx)(M,{days:x(n,e.due),className:`ml-1`})]}),(0,U.jsx)(T,{label:r(`cards.paid`),children:(0,U.jsx)(w,{filter:{account:t,from:C(e.close,1),to:n},children:(0,U.jsx)(E,{amount:e.paid})})}),(0,U.jsx)(T,{label:r(`cards.toPay`),className:`font-medium`,children:(0,U.jsx)(E,{amount:e.toPay})}),e.deferred>0&&(0,U.jsx)(T,{label:r(`cards.deferred`),children:(0,U.jsx)(E,{amount:e.deferred})}),e.bank!==null&&(0,U.jsxs)(T,{label:r(`cards.bankAmount`),children:[(0,U.jsx)(E,{amount:e.bank}),e.bankDiff!==null&&e.bankDiff!==0&&(0,U.jsx)(`span`,{className:`block text-xs text-warning`,children:r(`cards.bankDiff`,{amount:`${e.bankDiff>0?`+`:`−`}${y(Math.abs(e.bankDiff),i)}`})})]})]}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`cards.noClosed`)})})}function J({list:e,onOpen:n}){let{t:r,lang:i}=l();return(0,U.jsx)(D,{title:r(`cards.history`),children:e.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`cards.noHistory`)}):(0,U.jsx)(`ul`,{className:`-mx-2 flex flex-col divide-y`,children:e.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.close),className:`flex min-h-12 w-full items-center gap-3 rounded-md px-2 py-1.5 text-left outline-none hover:bg-muted/50 focus-visible:ring-3 focus-visible:ring-ring/50`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.open?r(`cards.currentPeriod`):S(e.close,i)}),(0,U.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[S(e.from,i,{day:`2-digit`,month:`2-digit`}),` – `,S(e.close,i,{day:`2-digit`,month:`2-digit`}),` · `,r(`cards.purchasesShort`),` `,(0,U.jsx)(E,{amount:e.purchases,mode:`short`})]})]}),(0,U.jsxs)(`span`,{className:`flex shrink-0 flex-col items-end`,children:[(0,U.jsx)(E,{amount:e.open?e.closing:e.amountDue,mode:`short`,className:`text-sm font-medium`}),!e.open&&(0,U.jsx)(O,{status:e.status})]}),(0,U.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})]})},e.close))})})}function Y({d:e}){let{t,lang:n}=l(),r=e.summary?.cashback??null,i=(0,H.useMemo)(()=>[...e.cashback].filter(e=>!e.open).reverse().slice(-12),[e.cashback]).map(e=>({ym:e.close,label:_(e.close.slice(0,7)),expected:e.expected,received:e.received}));return!e.terms.cashback&&!e.cashback.some(e=>e.expected>0||e.received>0)?(0,U.jsxs)(D,{title:t(`cards.cashback`),children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`cards.noCashback`)}),(0,U.jsx)(d,{prompt:t(`ask.cardTerms`,{name:e.account.name,list:t(`cards.missing.cashback_rates`)})})]}):(0,U.jsxs)(D,{title:t(`cards.cashback`),children:[r&&(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsx)(T,{label:t(`cards.spendThisPeriod`),children:(0,U.jsx)(w,{filter:{account:e.account.id,from:r.from,to:r.close},children:(0,U.jsx)(E,{amount:r.spend})})}),(0,U.jsx)(T,{label:t(`cards.expected`),children:r.incomplete?(0,U.jsx)(`span`,{className:`text-warning`,children:t(`cards.rateNotSet`)}):(0,U.jsx)(E,{amount:r.expected,className:`font-medium`})}),r.cap!==null&&r.capLeft!==null&&(0,U.jsxs)(T,{label:t(`cards.capLeftLabel`),children:[(0,U.jsx)(E,{amount:r.capLeft}),` `,(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`/ `,(0,U.jsx)(E,{amount:r.cap,mode:`short`})]})]})]}),r&&r.minSpend!==null&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(G,{value:r.spend,max:r.minSpend,label:t(`cards.minSpend`)}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.minMet?t(`cards.minMet`,{amount:y(r.minSpend,n)}):t(`cards.minNeed`,{amount:y(r.needForMin,n),min:y(r.minSpend,n)})})]}),i.length>0&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:t(`cards.last12`)}),(0,U.jsx)(`div`,{className:`flex h-40 flex-col`,children:(0,U.jsx)(L,{legend:[{label:t(`cards.earned`),color:F.accent},{label:t(`cards.expected`),color:F.second}],table:{head:[t(`chart.month`),t(`cards.earned`),t(`cards.expected`)],rows:i.map(e=>[e.label,y(e.received,n),y(e.expected,n)])},children:(0,U.jsx)(I,{data:i,xKey:`label`,series:[{key:`received`,label:t(`cards.earned`),color:F.accent},{key:`expected`,label:t(`cards.expected`),color:F.second}]})})})]})]})}function X({d:e,asOf:t}){let{t:n,lang:r}=l(),i=e.feeWaiver;return!i&&!e.terms.annualFee?null:(0,U.jsx)(D,{title:n(`cards.feeWaiver`),children:i?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(G,{value:i.spent,max:i.target,label:n(`cards.feeWaiver`)}),(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsxs)(T,{label:n(`cards.spent`),children:[(0,U.jsx)(w,{filter:{account:e.account.id,from:i.yearFrom,to:t},children:(0,U.jsx)(E,{amount:i.spent})}),` `,(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`/ `,(0,U.jsx)(E,{amount:i.target,mode:`short`})]})]}),(0,U.jsxs)(T,{label:n(`cards.deadline`),children:[S(i.deadline,r),` `,(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,n(`cards.daysLeft`,{n:i.daysLeft})]})]}),!i.met&&(0,U.jsx)(T,{label:n(`cards.perMonth`),children:(0,U.jsx)(E,{amount:i.perMonth})}),e.terms.annualFee?(0,U.jsx)(T,{label:n(`cards.annualFee`),children:(0,U.jsx)(E,{amount:e.terms.annualFee})}):null]}),(0,U.jsx)(`p`,{className:a(`text-sm font-medium`,i.met||i.onTrack?`text-foreground`:`text-critical`),children:i.met?n(`cards.feeMet`):i.onTrack?n(`cards.onTrack`):n(`cards.behind`)})]}):(0,U.jsxs)(`dl`,{children:[(0,U.jsx)(T,{label:n(`cards.annualFee`),children:(0,U.jsx)(E,{amount:e.terms.annualFee})}),(0,U.jsx)(`p`,{className:`py-1 text-sm text-muted-foreground`,children:n(`cards.noWaiver`)})]})})}function Z({d:e}){let{t}=l();return e.instalments.length===0?null:(0,U.jsx)(D,{title:t(`cards.instalments`),children:(0,U.jsx)(`ul`,{className:`flex flex-col gap-3`,children:e.instalments.map(e=>(0,U.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,U.jsx)(w,{filter:{plan:e.plan},className:`min-w-0 truncate font-medium`,children:e.name}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.paidCount,`/`,e.count??`–`]})]}),(0,U.jsx)(G,{value:e.paidCount,max:e.count??0,label:e.name}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t(`cards.perMonthPay`),` `,(0,U.jsx)(E,{amount:e.perPayment,mode:`short`}),e.leftAmount!==null&&(0,U.jsxs)(U.Fragment,{children:[` · `,t(`cards.left`),` `,(0,U.jsx)(E,{amount:e.leftAmount,mode:`short`})]})]})]},e.plan))})})}function Q({d:e}){let{t,lang:n}=l(),r=e.record;if(!r)return(0,U.jsxs)(D,{title:t(`cards.lifecycle`),children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`cards.noRecord`)}),(0,U.jsx)(d,{prompt:t(`ask.cardRecord`,{name:e.account.name})})]});let i=e=>e?S(e,n):null,a=[[t(`cards.issued`),i(r.issued)],[t(`cards.activated`),i(r.activated)],[t(`cards.lockedOn`),i(r.locked)],[t(`cards.cancelledOn`),i(r.cancelled)],[t(`cards.network`),r.network?r.network.toUpperCase():null],[t(`cards.form`),r.physical?t(`cards.physical.${r.physical}`):null]];return(0,U.jsxs)(D,{title:t(`cards.lifecycle`),action:(0,U.jsx)(A,{status:r.status??`active`}),children:[(0,U.jsxs)(`dl`,{className:`divide-y`,children:[a.filter(([,e])=>e).map(([e,t])=>(0,U.jsx)(T,{label:e,children:t},e)),r.annual_fee?(0,U.jsx)(T,{label:t(`cards.annualFee`),children:(0,U.jsx)(E,{amount:r.annual_fee})}):null,r.close_fee?(0,U.jsx)(T,{label:t(`cards.closeFee`),children:(0,U.jsx)(E,{amount:r.close_fee})}):null,r.keep_for_limit&&(0,U.jsx)(T,{label:t(`cards.keepForLimit`),children:t(`cards.yes`)})]}),r.cancel_plan&&(0,U.jsxs)(`div`,{className:`rounded-md bg-muted/60 p-3 text-sm`,children:[(0,U.jsx)(`p`,{className:`font-medium`,children:t(`cards.cancelPlan`,{by:r.cancel_plan.by??``})}),r.cancel_plan.note&&(0,U.jsx)(`p`,{className:`text-muted-foreground`,children:r.cancel_plan.note})]}),r.note&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r.note})]})}function $({d:e}){let{t}=l(),n=e.value;return n?(0,U.jsx)(D,{title:t(`cards.netValue`),children:(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsx)(T,{label:t(`cards.value.benefits`),children:(0,U.jsx)(E,{amount:n.benefits})}),(0,U.jsx)(T,{label:t(`cards.cashback`),children:(0,U.jsx)(E,{amount:n.cashback})}),(0,U.jsx)(T,{label:n.feesFrom===`record`?`${t(`cards.value.fees`)} (${t(`cards.value.estimated`)})`:t(`cards.value.fees`),children:(0,U.jsx)(E,{amount:-n.fees})}),n.closeFee>0&&(0,U.jsx)(T,{label:t(`cards.closeFee`),children:(0,U.jsx)(E,{amount:-n.closeFee})}),(0,U.jsx)(T,{label:t(`cards.value.sinceIssued`),className:`font-medium`,children:(0,U.jsx)(E,{amount:n.net,tone:`auto`})}),(0,U.jsx)(T,{label:t(`cards.value.last12`),className:`font-medium`,children:(0,U.jsx)(E,{amount:n.last12.net,tone:`auto`})})]})}):null}function ee({params:e}){let{t}=l(),n=decodeURIComponent(e.account),{data:r,error:i,isLoading:a}=c(n),[o,s]=(0,H.useState)(null),d=(0,U.jsxs)(`a`,{href:`#/cards`,className:`inline-flex min-h-11 items-center gap-1 self-start rounded-md text-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:[(0,U.jsx)(V,{className:`size-4`,"aria-hidden":!0}),t(`cards.back`)]});if(i)return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i instanceof u&&i.status===404?t(`cards.notFound`):t(`common.error`,{message:i.message})})]});if(a||!r)return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[d,(0,U.jsx)(h,{className:`h-8 w-56`}),(0,U.jsx)(h,{className:`h-40 w-full`})]});let f=r.summary,p=r.record?.status??(r.account.closed?`cancelled`:`active`),m=r.terms.last4,g=[r.terms.bank,m?t(`cards.last4`,{n:m}):null].filter(Boolean).join(` · `);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,U.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:r.account.name}),(0,U.jsx)(A,{status:p})]}),g&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:g}),f&&(0,U.jsx)(j,{owed:f.owed,limit:f.limit,atLeast:f.limitAtLeast,className:`max-w-md`}),f&&(0,U.jsx)(k,{card:f,className:`max-w-md`})]}),(0,U.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,U.jsx)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:f?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(K,{d:r,asOf:r.asOf}),(0,U.jsx)(q,{s:f.last,id:r.account.id,asOf:r.asOf}),(0,U.jsx)(J,{list:r.statements,onOpen:s})]}):(0,U.jsx)(D,{title:t(`cards.statements`),children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`cards.noStatements`)})})}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,U.jsx)(Y,{d:r}),(0,U.jsx)(X,{d:r,asOf:r.asOf}),(0,U.jsx)(Z,{d:r}),(0,U.jsx)(Q,{d:r}),(0,U.jsx)($,{d:r})]})]}),(0,U.jsx)(W,{account:r.account.id,close:o,onClose:()=>s(null)})]})}export{ee as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,I as t,L as n,a as r,u as i,w as a}from"./queries-
|
|
1
|
+
import{B as e,I as t,L as n,a as r,u as i,w as a}from"./queries-BcMmmb36.js";import{t as o}from"./Money-BwLucm7P.js";import{a as s,i as c,n as l,o as u,r as d,s as f}from"./bits-D34d9IBm.js";import{H as p,U as m,W as h,n as g,u as _}from"./index-DBHFdsYB.js";import{i as v,t as y}from"./cards-Ct0jh73r.js";import{t as b}from"./drill-t1zr57xi.js";var x=e(t(),1),S=n();function C({label:e,amount:t,sub:n}){return(0,S.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 rounded-xl border bg-card p-3`,children:[(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,S.jsx)(o,{amount:t,mode:`short`,className:`text-xl font-semibold tracking-tight`}),n&&(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n})]})}function w({c:e}){let{t,lang:n}=a(),r=e.cashback,i=r&&(r.expected>0||r.spend>0||r.cap!==null);return(0,S.jsxs)(`li`,{className:`relative flex flex-col gap-2 rounded-xl border bg-card p-3 focus-within:ring-3 focus-within:ring-ring/50 hover:bg-muted/30`,children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,S.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,S.jsx)(`a`,{href:y(e.account),className:`min-h-6 truncate rounded-md text-sm font-medium outline-none after:absolute after:inset-0 after:rounded-xl focus-visible:underline`,children:e.name}),(0,S.jsx)(l,{status:e.status})]}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:[e.bank,e.last4?t(`cards.last4`,{n:e.last4}):null].filter(Boolean).join(` · `)})]}),(0,S.jsx)(`div`,{className:`flex shrink-0 flex-col items-end`,children:e.toPay>0?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(o,{amount:e.toPay,mode:`short`,className:`text-base font-semibold`}),(0,S.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.due&&(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:g(e.due)}),(0,S.jsx)(d,{days:e.daysToDue})]})]}):(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`cards.nothingToPay`)})})]}),(0,S.jsx)(u,{owed:e.owed,limit:e.limit,atLeast:e.limitAtLeast}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1`,children:[e.last?(0,S.jsx)(s,{status:e.last.status}):(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`cards.noStatement`)}),i&&(0,S.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[t(`cards.cashbackShort`),` `,r.incomplete?t(`cards.rateNotSet`):(0,S.jsx)(o,{amount:r.expected,mode:`short`,className:`font-medium text-foreground`}),r.capLeft!==null&&(0,S.jsxs)(S.Fragment,{children:[` · `,t(`cards.capLeft`,{amount:_(r.capLeft,n)})]})]})]}),(0,S.jsx)(c,{card:e})]})}function T({r:e}){let{t}=a(),n=e.name??([e.bank,e.last4].filter(Boolean).join(` `)||e.id),r=[e.bank,e.network?.toUpperCase(),e.last4?t(`cards.last4`,{n:e.last4}):null,t(`cards.kind.${e.kind}`)].filter(Boolean).join(` · `),i=(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,S.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n}),(0,S.jsx)(l,{status:e.status??`active`})]}),(0,S.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:r})]}),(0,S.jsx)(`span`,{className:`shrink-0 text-right text-xs text-muted-foreground`,children:e.annual_fee?(0,S.jsxs)(S.Fragment,{children:[t(`cards.annualFee`),` `,(0,S.jsx)(o,{amount:e.annual_fee,mode:`short`,className:`text-foreground`})]}):t(`cards.noFee`)})]});return(0,S.jsx)(`li`,{children:e.account?(0,S.jsx)(`a`,{href:b({account:e.account}),className:`flex min-h-11 items-center gap-3 rounded-md px-1 py-1.5 outline-none hover:bg-muted/50 focus-visible:ring-3 focus-visible:ring-ring/50`,children:i}):(0,S.jsx)(`div`,{className:`flex min-h-11 items-center gap-3 px-1 py-1.5`,children:i})})}function E(){let{t:e,lang:t}=a(),n=i().data,o=!!n?.features?.cards,[s,c]=(0,x.useState)(`active`),l=r(o,!1),u=r(o&&s===`cancelled`,!0),d=s===`cancelled`?u.data??l.data:l.data,g=l.error??(s===`cancelled`?u.error:null),y=(0,x.useMemo)(()=>(d?.cards??[]).filter(e=>v(e.status)===s),[d,s]),b=(0,x.useMemo)(()=>(d?.records??[]).filter(e=>e.kind!==`credit`&&v(e.status??`active`)===s),[d,s]),E=(l.data?.cards??[]).filter(e=>e.owed>0).length;if(!o&&n)return(0,S.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,S.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e(`cards.title`)}),(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`cards.off`)})]});let D=l.data?.totals;return(0,S.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,S.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e(`cards.title`)}),D?(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`cards.headline`,{owed:_(D.owed,t),n:E})}):(0,S.jsx)(h,{className:`h-5 w-64`})]}),g?(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`common.error`,{message:g.message})}):d?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{"aria-label":e(`cards.totals`),className:`grid grid-cols-3 gap-2`,children:[(0,S.jsx)(C,{label:e(`cards.owedAll`),amount:d.totals.owed}),(0,S.jsx)(C,{label:e(`cards.dueWeek`),amount:d.totals.dueWeek}),(0,S.jsx)(C,{label:e(`cards.dueMonth`),amount:d.totals.dueMonth})]}),(0,S.jsx)(p,{type:`single`,variant:`outline`,value:s,onValueChange:e=>e&&c(e),"aria-label":e(`cards.filter`),className:`self-start`,children:[`active`,`locked`,`cancelled`].map(t=>(0,S.jsx)(m,{value:t,className:`min-h-11 px-3 md:min-h-8`,children:e(`cards.group.${t}`)},t))}),(0,S.jsxs)(`section`,{className:`flex flex-col gap-3`,"aria-labelledby":`cards-credit`,children:[(0,S.jsx)(`h2`,{id:`cards-credit`,className:`text-base font-semibold`,children:e(`cards.credit`)}),y.length===0?(0,S.jsx)(`p`,{className:`rounded-lg border border-dashed p-4 text-sm text-muted-foreground`,children:e(`cards.emptyCredit`)}):(0,S.jsx)(`ul`,{className:`grid gap-3 lg:grid-cols-2 2xl:grid-cols-3`,children:y.map(e=>(0,S.jsx)(w,{c:e},e.account))})]}),b.length>0&&(0,S.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-labelledby":`cards-debit`,children:[(0,S.jsx)(`h2`,{id:`cards-debit`,className:`text-base font-semibold`,children:e(`cards.debit`)}),(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`cards.debitHint`)}),(0,S.jsx)(`ul`,{className:`flex flex-col divide-y rounded-xl border bg-card px-2`,children:b.map(e=>(0,S.jsx)(T,{r:e},e.id))})]}),d.values.length>0&&(0,S.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-labelledby":`cards-value`,children:[(0,S.jsx)(`h2`,{id:`cards-value`,className:`text-base font-semibold`,children:e(`widget.cards_value`)}),(0,S.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e(`cards.value.hint`),` `,(0,S.jsx)(`span`,{children:e(`cards.value.total`,{amount:_(d.values.reduce((e,t)=>e+t.last12.net,0),t)})})]}),(0,S.jsx)(`div`,{className:`rounded-xl border bg-card px-3`,children:(0,S.jsx)(f,{values:d.values})})]})]}):(0,S.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[(0,S.jsx)(h,{className:`h-16 w-full`}),(0,S.jsx)(h,{className:`h-32 w-full`}),(0,S.jsx)(h,{className:`h-32 w-full`})]})]})}export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./Money-
|
|
1
|
+
import{t as e}from"./Money-BwLucm7P.js";import{o as t,r as n}from"./bits-D34d9IBm.js";import{M as r,n as i}from"./index-DBHFdsYB.js";import{L as a,a as o,u as s,w as c}from"./queries-BcMmmb36.js";import{t as l}from"./cards-Ct0jh73r.js";import{n as u}from"./shared-BgU6fc7z.js";var d=a(),f=8;function p({widget:a,menu:p}){let{t:m}=c(),h=u(a,`widget.cards`),g=!!s().data?.features?.cards,{data:_,error:v,isLoading:y}=o(g),b=(_?.cards??[]).filter(e=>e.status!==`cancelled`);return(0,d.jsxs)(r,{title:h,titleHref:`#/cards`,menu:p,loading:g&&y,error:g?v?.message:void 0,empty:!g||_&&b.length===0?m(`cards.emptyCredit`):void 0,children:[(0,d.jsx)(`ul`,{className:`flex flex-col divide-y`,children:b.slice(0,f).map(r=>(0,d.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-2`,children:[(0,d.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,d.jsx)(`a`,{href:l(r.account),className:`min-w-0 truncate rounded-md text-sm font-medium outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50`,children:r.name}),r.toPay>0?(0,d.jsxs)(`span`,{className:`flex shrink-0 items-baseline gap-2`,children:[(0,d.jsx)(e,{amount:r.toPay,mode:`short`,className:`text-sm font-medium`}),r.due&&(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(r.due)}),(0,d.jsx)(n,{days:r.daysToDue})]}):(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:m(`cards.nothingToPay`)})]}),(0,d.jsx)(t,{owed:r.owed,limit:r.limit,atLeast:r.limitAtLeast})]},r.account))}),b.length>f&&(0,d.jsx)(`a`,{href:`#/cards`,className:`min-h-11 self-start py-2 text-sm underline`,children:m(`attention.seeAll`,{n:b.length})})]})}export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./bits-
|
|
1
|
+
import{s as e}from"./bits-D34d9IBm.js";import{M as t}from"./index-DBHFdsYB.js";import{L as n,a as r,u as i,w as a}from"./queries-BcMmmb36.js";import{n as o}from"./shared-BgU6fc7z.js";var s=n();function c({widget:n,menu:c}){let{t:l}=a(),u=o(n,`widget.cards_value`),d=!!i().data?.features?.cards,{data:f,error:p,isLoading:m}=r(d),h=f?.values??[];return(0,s.jsxs)(t,{title:u,titleHref:`#/cards`,menu:c,loading:d&&m,error:d?p?.message:void 0,empty:!d||f&&h.length===0?l(`cards.value.empty`):void 0,children:[(0,s.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`cards.value.hint`)}),(0,s.jsx)(e,{values:h,limit:8,compact:!0})]})}export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./Money-
|
|
1
|
+
import{t as e}from"./Money-BwLucm7P.js";import{M as t,u as n}from"./index-DBHFdsYB.js";import{L as r,a as i,u as a,w as o}from"./queries-BcMmmb36.js";import{t as s}from"./cards-Ct0jh73r.js";import{n as c}from"./shared-BgU6fc7z.js";var l=r();function u({widget:r,menu:u}){let{t:d,lang:f}=o(),p=c(r,`widget.cashback`),m=!!a().data?.features?.cards,{data:h,error:g,isLoading:_}=i(m),v=(h?.cards??[]).filter(e=>e.status!==`cancelled`&&e.cashback&&(e.cashback.cap!==null||e.cashback.expected>0||e.cashback.spend>0||e.cashback.incomplete)),y=v.reduce((e,t)=>e+(t.cashback?.expected??0),0);return(0,l.jsxs)(t,{title:p,titleHref:`#/cards`,menu:u,loading:m&&_,error:m?g?.message:void 0,empty:!m||h&&v.length===0?d(`cashback.empty`):void 0,children:[(0,l.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[d(`cashback.total`),` `,(0,l.jsx)(e,{amount:y,mode:`short`,className:`font-medium text-foreground`})]}),(0,l.jsx)(`ul`,{className:`flex flex-col divide-y`,children:v.map(t=>{let r=t.cashback,i=r.cap?Math.min(1,(r.cap-(r.capLeft??r.cap))/r.cap):0;return(0,l.jsxs)(`li`,{className:`flex flex-col gap-1 py-2`,children:[(0,l.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,l.jsx)(`a`,{href:s(t.account),className:`min-w-0 truncate rounded-md text-sm font-medium outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50`,children:t.name}),r.incomplete?(0,l.jsx)(`span`,{className:`shrink-0 text-xs text-warning`,children:d(`cards.rateNotSet`)}):(0,l.jsx)(e,{amount:r.expected,mode:`short`,className:`shrink-0 text-sm font-medium`})]}),r.cap!==null&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{role:`progressbar`,"aria-label":d(`cards.capLeftLabel`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(i*100),className:`h-1.5 w-full rounded-full bg-muted`,children:(0,l.jsx)(`div`,{className:`h-1.5 rounded-full bg-[var(--chart-1)]`,style:{width:`${Math.max(i?2:0,i*100)}%`}})}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:d(`cards.capLeft`,{amount:n(r.capLeft??r.cap,f)})})]})]},t.account)})})]})}export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./createLucideIcon-
|
|
1
|
+
import{t as e}from"./createLucideIcon-XZ28znwT.js";import{$ as t,Q as n,rt as r}from"./index-DBHFdsYB.js";import{L as i,T as a}from"./queries-BcMmmb36.js";var o={name:`banknote`,size:24,node:[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`2`,key:`9lu3g6`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M6 12h.01M18 12h.01`,key:`113zkx`}]]};o.node;var s=e(o),c={name:`car`,size:24,node:[[`path`,{d:`M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2`,key:`5owen`}],[`circle`,{cx:`7`,cy:`17`,r:`2`,key:`u2ysq9`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}],[`circle`,{cx:`17`,cy:`17`,r:`2`,key:`axvx0g`}]]};c.node;var l=e(c),u={name:`circle-ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M17 12h.01`,key:`1m0b6t`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M7 12h.01`,key:`eqddd0`}]]};u.node;var d=e(u),f={name:`circle-plus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-circle`]};f.node;var p=e(f),m={name:`gamepad-2`,size:24,node:[[`line`,{x1:`6`,x2:`10`,y1:`11`,y2:`11`,key:`1gktln`}],[`line`,{x1:`8`,x2:`8`,y1:`9`,y2:`13`,key:`qnk9ow`}],[`line`,{x1:`15`,x2:`15.01`,y1:`12`,y2:`12`,key:`krot7o`}],[`line`,{x1:`18`,x2:`18.01`,y1:`10`,y2:`10`,key:`1lcuu1`}],[`path`,{d:`M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z`,key:`mfqc10`}]]};m.node;var h=e(m),g={name:`gift`,size:24,node:[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8`,key:`1sqzm4`}],[`path`,{d:`M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5`,key:`kc0143`}],[`rect`,{x:`3`,y:`7`,width:`18`,height:`4`,rx:`1`,key:`1hberx`}]]};g.node;var _=e(g),v={name:`graduation-cap`,size:24,node:[[`path`,{d:`M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z`,key:`j76jl0`}],[`path`,{d:`M22 10v6`,key:`1lu8f3`}],[`path`,{d:`M6 12.5V16a6 3 0 0 0 12 0v-3.5`,key:`1r8lef`}]]};v.node;var y=e(v),b={name:`hand-coins`,size:24,node:[[`path`,{d:`M11 15h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 17`,key:`geh8rc`}],[`path`,{d:`m7 21 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9`,key:`1fto5m`}],[`path`,{d:`m2 16 6 6`,key:`1pfhp9`}],[`circle`,{cx:`16`,cy:`9`,r:`2.9`,key:`1n0dlu`}],[`circle`,{cx:`6`,cy:`5`,r:`3`,key:`151irh`}]]};b.node;var x=e(b),S={name:`heart-pulse`,size:24,node:[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}],[`path`,{d:`M3.22 13H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27`,key:`auskq0`}]]};S.node;var C=e(S),w={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};w.node;var T=e(w),E={name:`percent`,size:24,node:[[`line`,{x1:`19`,x2:`5`,y1:`5`,y2:`19`,key:`1x9vlm`}],[`circle`,{cx:`6.5`,cy:`6.5`,r:`2.5`,key:`4mh3h7`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`2.5`,key:`1mdrzq`}]]};E.node;var D=e(E),O={name:`repeat`,size:24,node:[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]};O.node;var k=e(O),A={name:`shopping-bag`,size:24,node:[[`path`,{d:`M16 10a4 4 0 0 1-8 0`,key:`1ltviw`}],[`path`,{d:`M3.103 6.034h17.794`,key:`awc11p`}],[`path`,{d:`M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z`,key:`o988cm`}]]};A.node;var j=e(A),M={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};M.node;var N=e(M),P={name:`utensils`,size:24,node:[[`path`,{d:`M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2`,key:`cjf0a3`}],[`path`,{d:`M7 2v20`,key:`1473qp`}],[`path`,{d:`M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7`,key:`j28e5`}]],aliases:[`fork-knife`]};P.node;var F=e(P),I={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};I.node;var L=e(I),R=i(),z={food:F,transport:l,home:t,family:N,health:C,shopping:j,fun:h,learning:y,"work-tools":L,subscriptions:k,"bank-fees":n,other:d,salary:s,freelance:T,interest:D,cashback:x,"gifts-received":_,"other-income":p},B=[`bg-sky-100 text-sky-800 dark:bg-sky-950 dark:text-sky-200`,`bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-200`,`bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-200`,`bg-violet-100 text-violet-800 dark:bg-violet-950 dark:text-violet-200`,`bg-rose-100 text-rose-800 dark:bg-rose-950 dark:text-rose-200`,`bg-teal-100 text-teal-800 dark:bg-teal-950 dark:text-teal-200`];function V(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)>>>0;return t}function H({category:e,name:t,transfer:n,className:r}){let i=`flex size-9 shrink-0 items-center justify-center rounded-full`;if(n)return(0,R.jsx)(`span`,{"aria-hidden":!0,className:a(i,`bg-muted text-muted-foreground`,r),children:(0,R.jsx)(U,{})});let o=(e??`other`).split(`/`)[0],s=z[o];if(s)return(0,R.jsx)(`span`,{"aria-hidden":!0,className:a(i,`bg-muted text-foreground`,r),children:(0,R.jsx)(s,{className:`size-4`})});let c=([...t??o][0]??`?`).toUpperCase();return(0,R.jsx)(`span`,{"aria-hidden":!0,className:a(i,`text-sm font-medium`,B[V(o)%B.length],r),children:c})}var U=()=>(0,R.jsx)(r,{className:`size-4`});export{H as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,I as t,L as n,d as r,w as i}from"./queries-
|
|
1
|
+
import{B as e,I as t,L as n,d as r,w as i}from"./queries-BcMmmb36.js";import{t as a}from"./Combobox-BvX68J3o.js";var o=e(t(),1),s=n();function c(e,t){let n=(e?.categories??[]).filter(e=>!e.path.startsWith(`_`)&&(!t||e.kind===t)),r=e=>e.split(`/`).map((e,t,n)=>n.slice(0,t+1).join(`/`)),i=new Map(n.map((e,t)=>[e.path,t]));return[{options:[...n].sort((e,t)=>{let n=r(e.path).map(e=>i.get(e)??1e9),a=r(t.path).map(e=>i.get(e)??1e9);for(let e=0;e<Math.max(n.length,a.length);e++)if((n[e]??-1)!==(a[e]??-1))return(n[e]??-1)-(a[e]??-1);return 0}).map(e=>({value:e.path,label:e.name,depth:e.path.split(`/`).length-1,keywords:[e.path]}))}]}function l({value:e,onSelect:t,className:n}){let{t:l}=i(),u=r().data,d=(0,o.useMemo)(()=>c(u,`expense`),[u]);return(0,s.jsx)(a,{label:l(`filter.category`),groups:d,value:e,onSelect:t,className:n??`w-full`})}export{c as n,l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,I as t,L as n,m as r,w as i}from"./queries-
|
|
1
|
+
import{B as e,I as t,L as n,m as r,w as i}from"./queries-BcMmmb36.js";import{a,i as o,n as s,r as c,t as l}from"./charts-D-1glV8L.js";import{t as u}from"./Money-BwLucm7P.js";import{M as d,a as f,l as p,n as m}from"./index-DBHFdsYB.js";import{t as h}from"./drill-t1zr57xi.js";import{t as g}from"./shared-BgU6fc7z.js";var _=e(t(),1),v=n(),y=new Set([`day`,`week`,`month`]);function b(e,t,n,r){let i={from:r.from,to:r.to,category:e.category,account:Array.isArray(e.account)?void 0:e.account,who:e.who,event:e.event,tag:e.tag,text:e.text};switch(t){case`category`:case`top`:return h({...i,category:n});case`account`:return h({...i,account:n});case`who`:return h({...i,who:n});case`event`:return h({...i,event:n});case`tag`:return h({...i,tag:n});case`month`:{let[e,t]=n.split(`-`).map(Number);return h({...i,from:`${n}-01`,to:`${n}-${String(new Date(e,t,0).getDate()).padStart(2,`0`)}`})}case`day`:return h({...i,from:n,to:n});default:return}}function x({widget:e,menu:t}){let{t:n,lang:a}=i(),o=e.query,{data:s,error:c,isLoading:l}=r(o??{metric:`spending`},!!o),u=e.chart??`bar`,f=e.title?.trim()||n(`widget.chart`);return(0,v.jsx)(d,{title:f,menu:t,byAi:e.by_ai,loading:!!o&&l,error:o?c?.message:void 0,empty:o?s&&s.points.length===0&&u!==`stat`?n(`chart.empty`):void 0:n(`chart.noQuery`),children:s&&o&&(0,v.jsx)(S,{data:s,q:o,kind:u,lang:a})})}function S({data:e,q:t,kind:n,lang:r}){let{t:d}=i(),x=y.has(e.by),S=t.metric===`count`,w=t=>e.by===`month`?f(String(t)):m(String(t)),T=(0,_.useMemo)(()=>e.points.map(e=>({key:e.key,name:e.name,value:e.value,compare:e.compare??null})),[e]),E=T.some(e=>e.compare!==null),D={head:[d(`chart.item`),d(`chart.value`),...E?[d(`chart.compare`)]:[]],rows:T.map(e=>[x?w(e.key):e.name,p(e.value,r),...E?[p(e.compare??0,r)]:[]])},O=e=>S?(0,v.jsx)(`span`,{className:`tabular-nums`,children:p(e,r)}):(0,v.jsx)(u,{amount:e,mode:`short`});if(n===`stat`){let n=e.compareTotal?(e.total-e.compareTotal)/Math.abs(e.compareTotal)*100:null;return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`a`,{href:h({from:e.period.from,to:e.period.to,category:t.category,account:Array.isArray(t.account)?void 0:t.account,who:t.who,event:t.event,tag:t.tag,text:t.text}),className:`text-2xl font-semibold tracking-tight outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50`,children:S?p(e.total,r):(0,v.jsx)(u,{amount:e.total})}),n!==null&&(0,v.jsxs)(`p`,{className:`flex items-center gap-1 text-sm text-muted-foreground`,children:[(0,v.jsx)(g,{pct:n,goodWhenDown:t.metric===`spending`}),t.compare===`usual`?d(`pace.vsUsual`):d(`chart.vsPrevious`)]})]})}if(n===`table`)return(0,v.jsxs)(`table`,{className:`w-full text-sm tabular-nums`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsx)(`tr`,{className:`text-left text-xs text-muted-foreground`,children:D.head.map((e,t)=>(0,v.jsx)(`th`,{className:`py-1 font-medium ${t>0?`text-right`:``}`,children:e},e))})}),(0,v.jsx)(`tbody`,{children:T.map((n,r)=>(0,v.jsxs)(`tr`,{className:`border-t`,children:[(0,v.jsx)(`td`,{className:`py-1.5`,children:(0,v.jsx)(`a`,{className:`hover:underline`,href:b(t,e.by,n.key,e.period),children:D.rows[r][0]})}),(0,v.jsx)(`td`,{className:`py-1.5 text-right`,children:O(n.value)}),E&&(0,v.jsx)(`td`,{className:`py-1.5 text-right text-muted-foreground`,children:O(n.compare??0)})]},n.key))})]});if(n===`hbar`)return(0,v.jsx)(c,{rows:T.map(n=>({key:n.key,name:x?w(n.key):n.name,value:n.value,label:O(n.value),href:b(t,e.by,n.key,e.period)}))});let k=[{key:`value`,label:C(t,d),color:a.accent},...E?[{key:`compare`,label:t.compare===`usual`?d(`pace.usual`):d(`chart.previous`),color:a.muted}]:[]];return(0,v.jsx)(l,{table:D,legend:k.map(e=>({label:e.label,color:e.color})),children:n===`line`?(0,v.jsx)(o,{data:T,xKey:`key`,formatX:x?w:e=>T.find(t=>t.key===e)?.name??String(e),specs:k.map(e=>({key:e.key,label:e.label,kind:`line`,color:e.color,width:e.key===`value`?2:1,dashed:e.key!==`value`}))}):(0,v.jsx)(s,{data:T.map(e=>({key:e.key,value:e.value,...E?{compare:e.compare??0}:{}})),xKey:`key`,formatX:x?w:e=>T.find(t=>t.key===e)?.name??String(e),series:k})})}function C(e,t){return t(`chart.metric.${e.metric}`)}export{x as default};
|