ownledger 1.2.0 → 2.0.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 +28 -1
- package/CHANGELOG.md +48 -0
- package/assets/apple-touch-icon.png +0 -0
- package/assets/icon-192.png +0 -0
- package/assets/icon-512.png +0 -0
- package/assets/icon-maskable-512.png +0 -0
- package/assets/index.html +15 -18
- package/assets/manifest.webmanifest +1 -1
- package/assets/static/Account-DEBzshne.js +1 -0
- package/assets/static/Accounts-C1iNsQsy.js +1 -0
- package/assets/static/Attention-qo4v70P1.js +1 -0
- package/assets/static/ByCategory-33P2zSs-.js +1 -0
- package/assets/static/CardDetail-CvRo7JPt.js +1 -0
- package/assets/static/Cards-C3AdusmT.js +1 -0
- package/assets/static/Cards-DuqZFxkQ.js +1 -0
- package/assets/static/CardsValue-BM9WUQmy.js +1 -0
- package/assets/static/Cashback-DsWyjgRr.js +1 -0
- package/assets/static/CategoryIcon-E6EWIpbr.js +1 -0
- package/assets/static/CategoryPicker-BPeJNSuM.js +1 -0
- package/assets/static/ChartWidget-Bk1TAvJM.js +1 -0
- package/assets/static/Combobox-lRNTmjKR.js +1 -0
- package/assets/static/Deposits-CgEFypxb.js +1 -0
- package/assets/static/DrillLink-pa6s17Xu.js +1 -0
- package/assets/static/Field-OkPhoYM1.js +1 -0
- package/assets/static/HomeEditor-DdrzEPe2.js +1 -0
- package/assets/static/Import-DrhHmL65.js +2 -0
- package/assets/static/IncomeSpending-Cveqr3xt.js +1 -0
- package/assets/static/KV-CKGyL0p7.js +1 -0
- package/assets/static/Left-Bs_oKU19.js +1 -0
- package/assets/static/Money-DCMKf898.js +1 -0
- package/assets/static/NetWorth-Cjd13J56.js +1 -0
- package/assets/static/Pace-CBUDNxzH.js +1 -0
- package/assets/static/Panel-CXjnsEN0.js +1 -0
- package/assets/static/PinDialog-DoGuAyi4.js +1 -0
- package/assets/static/Plans-EWJdPCJ3.js +1 -0
- package/assets/static/Recent-BmJjA5dK.js +1 -0
- package/assets/static/Reports-DSrLn_wC.js +1 -0
- package/assets/static/Settings-DdiEp2Qi.js +1 -0
- package/assets/static/Transactions-Cy0kgcLE.js +1 -0
- package/assets/static/TxRow-IqjFXpya.js +1 -0
- package/assets/static/Unusual-D5-L9ZOy.js +1 -0
- package/assets/static/Upcoming-CCqPol8c.js +1 -0
- package/assets/static/WhichCard-Butdi7AN.js +1 -0
- package/assets/static/arrow-up-C8D_7x_H.js +1 -0
- package/assets/static/bits-BoWPOwTB.js +1 -0
- package/assets/static/button-Cj0k8AtB.js +1 -0
- package/assets/static/cards-AZlSJQ0z.js +1 -0
- package/assets/static/charts-Cj_hTR4h.js +65 -0
- package/assets/static/chevron-down-BLodeu9a.js +1 -0
- package/assets/static/chevron-right-BetctQ6k.js +1 -0
- package/assets/static/createLucideIcon-DUW9Fpzj.js +1 -0
- package/assets/static/dialog-BIbLA-XP.js +1 -0
- package/assets/static/dist-CbNfxqbd.js +1 -0
- package/assets/static/dist-CetESl7K.js +1 -0
- package/assets/static/dist-DYP_TYPy.js +1 -0
- package/assets/static/dist-DaSyQKU7.js +1 -0
- package/assets/static/drill-t1zr57xi.js +1 -0
- package/assets/static/es2015-BgAh-EkH.js +41 -0
- package/assets/static/fold-CGWYt9Iu.js +1 -0
- package/assets/static/index-CBsgYTMJ.css +1 -0
- package/assets/static/index-DYyIpxqK.js +14 -0
- package/assets/static/queries-C_4ufx4u.js +1 -0
- package/assets/static/react-dom-CI34djkT.js +1 -0
- package/assets/static/select-2EwEpMf_.js +1 -0
- package/assets/static/shared-CR-hvb-r.js +1 -0
- package/assets/static/triangle-exclamation-point-C6padEUM.js +1 -0
- package/assets/static/useMutation-BWtHiYPX.js +1 -0
- package/dist/cli/cards.d.ts +2 -0
- package/dist/cli/cards.js +86 -0
- package/dist/cli/import.js +12 -2
- package/dist/cli/index.js +3 -0
- package/dist/engine/actions.d.ts +5 -0
- package/dist/engine/actions.js +9 -5
- package/dist/engine/attention.d.ts +15 -0
- package/dist/engine/attention.js +63 -0
- package/dist/engine/check.js +8 -1
- package/dist/engine/dashboard.d.ts +72 -0
- package/dist/engine/dashboard.js +180 -0
- package/dist/engine/features.d.ts +20 -0
- package/dist/engine/features.js +37 -0
- package/dist/engine/index.d.ts +5 -0
- package/dist/engine/index.js +5 -0
- package/dist/engine/insights.d.ts +164 -0
- package/dist/engine/insights.js +534 -0
- package/dist/engine/load.js +6 -0
- package/dist/engine/registry.d.ts +2 -0
- package/dist/engine/registry.js +15 -33
- package/dist/engine/reports.d.ts +21 -2
- package/dist/engine/reports.js +51 -3
- package/dist/engine/schedules.d.ts +7 -84
- package/dist/engine/schedules.js +8 -207
- package/dist/engine/types.d.ts +2 -0
- package/dist/engine/write.d.ts +9 -0
- package/dist/engine/write.js +26 -5
- package/dist/import/mapping.js +6 -0
- package/dist/import/run.d.ts +7 -0
- package/dist/import/run.js +28 -1
- package/dist/modules/api.d.ts +19 -0
- package/dist/modules/api.js +16 -0
- package/dist/modules/cards/api.d.ts +3 -0
- package/dist/modules/cards/api.js +73 -0
- package/dist/modules/cards/engine.d.ts +42 -0
- package/dist/modules/cards/engine.js +102 -0
- package/dist/modules/cards/index.d.ts +26 -0
- package/dist/modules/cards/index.js +304 -0
- package/dist/modules/cards/statements.d.ts +128 -0
- package/dist/modules/cards/statements.js +426 -0
- package/dist/modules/cards/terms.d.ts +105 -0
- package/dist/modules/cards/terms.js +194 -0
- package/dist/modules/cards/tracker.d.ts +36 -0
- package/dist/modules/cards/tracker.js +232 -0
- package/dist/modules/cards/types.d.ts +2 -0
- package/dist/modules/cards/types.js +16 -0
- package/dist/modules/deposits/engine.d.ts +14 -0
- package/dist/modules/deposits/engine.js +32 -0
- package/dist/modules/deposits/index.d.ts +2 -0
- package/dist/modules/deposits/index.js +24 -0
- package/dist/modules/deposits/types.d.ts +2 -0
- package/dist/modules/deposits/types.js +15 -0
- package/dist/modules/index.d.ts +5 -0
- package/dist/modules/index.js +10 -0
- package/dist/modules/insurance/index.d.ts +3 -0
- package/dist/modules/insurance/index.js +8 -0
- package/dist/modules/insurance/types.d.ts +2 -0
- package/dist/modules/insurance/types.js +3 -0
- package/dist/modules/investments/index.d.ts +2 -0
- package/dist/modules/investments/index.js +24 -0
- package/dist/modules/investments/types.d.ts +2 -0
- package/dist/modules/investments/types.js +7 -0
- package/dist/modules/loans/engine.d.ts +30 -0
- package/dist/modules/loans/engine.js +77 -0
- package/dist/modules/loans/index.d.ts +2 -0
- package/dist/modules/loans/index.js +27 -0
- package/dist/modules/loans/types.d.ts +2 -0
- package/dist/modules/loans/types.js +5 -0
- package/dist/modules/types.d.ts +39 -0
- package/dist/modules/types.js +1 -0
- package/dist/modules/util.d.ts +8 -0
- package/dist/modules/util.js +8 -0
- package/dist/node/scaffold.js +2 -2
- package/dist/worker/api.d.ts +11 -1
- package/dist/worker/api.js +167 -13
- package/dist/worker/bestcard.d.ts +32 -9
- package/dist/worker/bestcard.js +91 -51
- package/dist/worker/mcp.js +209 -30
- package/dist/worker/openwallet.d.ts +1 -1
- package/dist/worker/openwallet.js +41 -11
- package/dist/worker/version.d.ts +1 -1
- package/dist/worker/version.js +1 -1
- package/package.json +26 -4
- package/presets/misa.mapping.yaml +7 -0
- package/assets/app.css +0 -61
- package/assets/app.js +0 -369
package/AGENTS.md
CHANGED
|
@@ -14,6 +14,9 @@ amounts, and never write without the owner's go. `npx ownledger check` must pass
|
|
|
14
14
|
| `data/plans.yaml` | Instalments, loans, insurance premiums, deposit schedules: `{id, kind, account, principal?, count?, every, start, amount?, fee?, rate?}` |
|
|
15
15
|
| `data/budgets.yaml` | Optional: `{category, amount, every: month|year}` |
|
|
16
16
|
| `data/prices.csv` | `date,asset,price`: price of 1 unit in base currency |
|
|
17
|
+
| `data/cards.yaml` | Optional: every physical or virtual card, credit or not (see Cards) |
|
|
18
|
+
| `data/cards/statements.yaml` | Optional: the bank's amount per card statement `{account, statement_date, amount}` |
|
|
19
|
+
| `data/dashboards/<login>.yaml` | One person's dashboard: widgets and preferences (see Dashboard) |
|
|
17
20
|
| `data/ledger/yyyy/mm.jsonl` | One transaction per line, in the month file of its date |
|
|
18
21
|
| `imports/raw/` | Original exports, kept as received |
|
|
19
22
|
| `imports/<source>.mapping.yaml` | How to read one app's export (see below) |
|
|
@@ -41,11 +44,35 @@ amounts, and never write without the owner's go. `npx ownledger check` must pass
|
|
|
41
44
|
|
|
42
45
|
## Account types
|
|
43
46
|
|
|
44
|
-
`cash`, `bank`, `ewallet`, `credit_card` (details: `statement_day`, `due_day`, `limit`,
|
|
47
|
+
`cash`, `bank`, `ewallet`, `credit_card` (details: `statement_day`, `due_day`, `limit`, optionally `bank` and `product`: the bank's own name for the card, e.g. "MSB Visa Online", used to look the card up in a card catalog such as OpenWallet; and the card terms below), `bnpl`, `deposit`
|
|
45
48
|
(details: `principal`, `rate` (annual %), `term_months`, `start`, `maturity`, `rollover`), `savings_goal` (`target`, `by`),
|
|
46
49
|
`gold`, `fund`, `stock`, `etf`, `crypto`, `insurance`, `loan_given`, `loan_taken`, `other`.
|
|
47
50
|
A type not on this list is still fine: it loads as a plain account with a warning. Extra keys are kept.
|
|
48
51
|
|
|
52
|
+
## Cards
|
|
53
|
+
|
|
54
|
+
A credit card is an account (`type: credit_card`): purchases on it, payments to it. Its terms are in `details`, all optional:
|
|
55
|
+
`statement_day`, `due_day`, `limit`, `bank`, `number_last4`, `annual_fee`, `fee_month` (1-12, also the start of the card year),
|
|
56
|
+
`fee_waiver: {spend, within: year}`, `free_days_max`, and
|
|
57
|
+
`cashback: {base, rules: [{categories: [paths], rate}], cap: {amount, per}, min_spend: {amount, per}, spend_max: {amount, per}, paid_on: next_statement | days_after:<n>}`
|
|
58
|
+
(`per` is `statement` or `month`; rates are %; a rule's `rate: null` means not known yet).
|
|
59
|
+
`from_name: [keys]` lists the keys read from codes in an import's wallet names (🗓️ statement day, 💸 due day, category emoji,
|
|
60
|
+
🎉MM/YY anniversary, `1-5tr` spend band, `*1234`); a re-import updates only those, never a key the owner set.
|
|
61
|
+
|
|
62
|
+
`data/cards.yaml` lists cards: `id`, `kind` (credit, debit, atm), `account` (credit: its account; debit: optionally the wallet
|
|
63
|
+
its spending is on), `bank`, `name`, `network`, `last4` (quoted, never a full number), `status` (active, locked, inactive,
|
|
64
|
+
cancelled), `issued`, `activated`, `cancelled`, `physical`, `apple_pay`, `annual_fee`, `close_fee`, `benefits` (value received
|
|
65
|
+
outside cashback), `cancel_plan: {by: yyyy-mm, note}`, `keep_for_limit`, `fees_url`, `note`. A debit card with cashback carries
|
|
66
|
+
`statement_day` (cycle start) and `cashback` here. A cashback paid to another account carries `card: <account id>` on the transaction.
|
|
67
|
+
A 0% instalment is a plan `{kind: instalment, account: <card>, principal, count, every: month, start: <first statement>, source: <purchase id>}`.
|
|
68
|
+
|
|
69
|
+
## Dashboard
|
|
70
|
+
|
|
71
|
+
`data/dashboards/<login>.yaml`: `version: 1`, `widgets` (each `{id, type, x, y, w, h}` on a 12-column grid, plus `title`,
|
|
72
|
+
`query` and `chart` for `type: chart`, options like `period`, `account`), and `prefs.pool` (the "My money" pool: `on`, `name`,
|
|
73
|
+
`exclude: [ids]`, `default_account`). The pool is a view only: accounts stay separate in the data. With the pool on, spending with
|
|
74
|
+
no account named goes to `default_account`. Change widgets through the connector's `add_widget` / `edit_widget` / `remove_widget`.
|
|
75
|
+
|
|
49
76
|
## Rules for writes
|
|
50
77
|
|
|
51
78
|
1. Show the owner exactly what will change (the transactions, with amounts and accounts) and wait for their go.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.0 (2026-11-22)
|
|
4
|
+
|
|
5
|
+
A new dashboard, modules, and credit cards done properly. Data format stays 1: existing data repos work as they are.
|
|
6
|
+
|
|
7
|
+
- **New dashboard stack.** The dashboard is now a React 19 app (Vite, Tailwind CSS 4, shadcn/ui, Recharts,
|
|
8
|
+
react-grid-layout, TanStack Query, wouter), built when ownledger is published and shipped in `assets/`. Nothing to
|
|
9
|
+
build for users: `ownledger deploy` and `ownledger dev` are unchanged. Same origin only, same CSP, no CDN, no fonts.
|
|
10
|
+
This replaces the plain-JS dashboard of 1.x (and its "no build step" rule). First load stays under 250 KB gzipped
|
|
11
|
+
(checked in CI).
|
|
12
|
+
- **Vietnamese by default, English on request** (a VI | EN switch, remembered on the device).
|
|
13
|
+
- **Home is a grid of widgets** you can drag, resize, add and remove; the layout is saved per person in the data repo,
|
|
14
|
+
`data/dashboards/<login>.yaml` (one commit per Done). Default: This month (pace against your usual), Needs you,
|
|
15
|
+
What's different, Net worth. Chart widgets are a saved query (`GET /api/series`).
|
|
16
|
+
- **Simple first:** the nav, pages and widget catalogue follow what the ledger has (`features` in `/api/me`).
|
|
17
|
+
- **Insights:** month pace and month-end estimate, "compared with your usual" (6-month average for a period of the
|
|
18
|
+
same length), "What's different" (categories far from usual, new categories and people, unusually large
|
|
19
|
+
transactions), "Needs you" (dues, cards, deposits, housekeeping). Every number drills into its transactions.
|
|
20
|
+
- **"Tiền của tôi" (My money):** everyday accounts (cash, bank, e-wallet) show as one balance by default. A view
|
|
21
|
+
and a per-person setting (`prefs.pool`), never a change to the data; with it on, spending with no account named goes
|
|
22
|
+
to the pool's default account.
|
|
23
|
+
- **Modules:** cards, loans and instalments, deposits, investments and insurance each own their account types,
|
|
24
|
+
checks, "Needs you" items and endpoints (`/api/m/<module>/…`); a module that's off adds nothing.
|
|
25
|
+
- **Cards module:** statements (periods, payments, paid on time / late / partly, the bank's amount vs computed),
|
|
26
|
+
limits (or "at least" the most ever owed), cashback (rules per category, cap, minimum spend, spend band, when it's
|
|
27
|
+
paid; expected vs received), which card to use, annual fee waivers, 0% instalments counted per statement, card
|
|
28
|
+
lifecycle and cancel plans, net value per card. New optional files `data/cards.yaml` and `data/cards/statements.yaml`,
|
|
29
|
+
new card fields in `details` (see AGENTS.md). Card codes in MISA wallet names (🗓️ 💸 🎉 `1-5tr` `*1234`, category
|
|
30
|
+
emoji) are read on every import; the owner's own values are never overwritten (`from_name`).
|
|
31
|
+
- **One `best_card`:** cards with your own cashback terms are ranked locally (nothing sent anywhere); with the
|
|
32
|
+
OpenWallet source on (1.2), cards without terms are looked up there. Each row says its `source` (`yours`,
|
|
33
|
+
`openwallet`, `none`); it takes your `category` and, for OpenWallet, a `merchant` or `kind`.
|
|
34
|
+
- **Connector:** `cards` (statements, cashback, fee waiver, this period by category, product), `card_statement`, `best_card`, `set_card_details`,
|
|
35
|
+
`add_statement_amount`, `add_instalment`, `dashboard`, `add_widget`, `edit_widget`, `remove_widget` (writes preview →
|
|
36
|
+
the owner's go → `apply`, as always); `today` adds "needs_you"; `rules` returns the pool.
|
|
37
|
+
- **CLI:** `ownledger cards load <tracker.csv>` loads a card tracker into `data/cards.yaml` and the cards' limits
|
|
38
|
+
(preview; `--link`, `--closed`, `--as-debit` for the owner's answers; `--yes` writes).
|
|
39
|
+
- **API:** `/api/home`, `/api/series`, `/api/dashboard` (GET, PUT, DELETE), `/api/report?usual=6`,
|
|
40
|
+
`/api/transactions` gains `offset`, `who`/`event`/`tag`/`tx` filters, totals for the filter, day totals and a running
|
|
41
|
+
balance for one account; `/api/accounts` gains `lastActivity`.
|
|
42
|
+
- **Fixes:** YAML data files are written in block style and values with `, : { } [ ]` are quoted (a name with a comma
|
|
43
|
+
was cut when the file was read back in flow style); a mapping with a name cut at a comma is now refused with a clear
|
|
44
|
+
message.
|
|
45
|
+
|
|
46
|
+
## 1.2.1 (2026-11-22)
|
|
47
|
+
|
|
48
|
+
- `best_card` is sturdier with many cards: at most 4 requests to OpenWallet at a time, one retry after a timeout or
|
|
49
|
+
a 429, and card lookups kept in the Worker's memory for an hour (never written anywhere).
|
|
50
|
+
|
|
3
51
|
## 1.2.0 (2026-11-22)
|
|
4
52
|
|
|
5
53
|
- `cards` shows each card's current statement period: what was spent by category, refunds, and cashback credited
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/index.html
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
|
-
<html lang="
|
|
2
|
+
<html lang="vi">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
@@ -7,24 +7,21 @@
|
|
|
7
7
|
<title>ownledger</title>
|
|
8
8
|
<link rel="manifest" href="/manifest.webmanifest">
|
|
9
9
|
<link rel="icon" href="/icon.svg" type="image/svg+xml">
|
|
10
|
-
<link rel="
|
|
11
|
-
<
|
|
10
|
+
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
|
11
|
+
<meta name="apple-mobile-web-app-title" content="ownledger">
|
|
12
|
+
<script type="module" crossorigin src="/static/index-DYyIpxqK.js"></script>
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/static/queries-C_4ufx4u.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/static/react-dom-CI34djkT.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="/static/button-Cj0k8AtB.js">
|
|
16
|
+
<link rel="modulepreload" crossorigin href="/static/dist-CetESl7K.js">
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/static/es2015-BgAh-EkH.js">
|
|
18
|
+
<link rel="modulepreload" crossorigin href="/static/dist-DYP_TYPy.js">
|
|
19
|
+
<link rel="modulepreload" crossorigin href="/static/createLucideIcon-DUW9Fpzj.js">
|
|
20
|
+
<link rel="modulepreload" crossorigin href="/static/dist-DaSyQKU7.js">
|
|
21
|
+
<link rel="modulepreload" crossorigin href="/static/dist-CbNfxqbd.js">
|
|
22
|
+
<link rel="stylesheet" crossorigin href="/static/index-CBsgYTMJ.css">
|
|
12
23
|
</head>
|
|
13
24
|
<body>
|
|
14
|
-
<
|
|
15
|
-
<a class="brand" href="#/">ownledger</a>
|
|
16
|
-
<nav id="nav">
|
|
17
|
-
<a href="#/">Overview</a>
|
|
18
|
-
<a href="#/transactions">Transactions</a>
|
|
19
|
-
<a href="#/accounts">Accounts</a>
|
|
20
|
-
<a href="#/plans">Plans</a>
|
|
21
|
-
<a href="#/reports">Reports</a>
|
|
22
|
-
<a href="#/import">Import</a>
|
|
23
|
-
<a href="#/settings">Settings</a>
|
|
24
|
-
</nav>
|
|
25
|
-
<span id="who" class="muted"></span>
|
|
26
|
-
</header>
|
|
27
|
-
<main id="main" class="viz-root"><p class="muted">Loading…</p></main>
|
|
28
|
-
<div id="tip" class="tip" role="tooltip" hidden></div>
|
|
25
|
+
<div id="root"></div>
|
|
29
26
|
</body>
|
|
30
27
|
</html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "name": "ownledger", "short_name": "ownledger", "start_url": "/", "display": "standalone", "background_color": "#f4f4f2", "theme_color": "#fcfcfb", "icons": [{ "src": "/icon.svg", "sizes": "any", "type": "image/svg+xml" }] }
|
|
1
|
+
{ "name": "ownledger", "short_name": "ownledger", "start_url": "/", "display": "standalone", "background_color": "#f4f4f2", "theme_color": "#fcfcfb", "icons": [{ "src": "/icon.svg", "sizes": "any", "type": "image/svg+xml" }, { "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "/icon-512.png", "sizes": "512x512", "type": "image/png" }, { "src": "/icon-maskable-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }] }
|
|
@@ -0,0 +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-C_4ufx4u.js";import{a as s,i as c,t as l}from"./charts-Cj_hTR4h.js";import{t as u}from"./DrillLink-pa6s17Xu.js";import{t as d}from"./Money-DCMKf898.js";import{M as f,a as p,l as m}from"./index-DYyIpxqK.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./chevron-down-BLodeu9a.js";import{t}from"./chevron-right-BetctQ6k.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-C_4ufx4u.js";import{A as f,W as p,l as m,n as h,r as g,s as _,u as v}from"./index-DYyIpxqK.js";import{t as y}from"./Money-DCMKf898.js";import{o as b,r as x}from"./bits-BoWPOwTB.js";import{a as S,i as C,n as w,o as T,r as E,s as D}from"./dist-CetESl7K.js";import{n as O,s as k}from"./button-Cj0k8AtB.js";import{t as A}from"./dist-DYP_TYPy.js";import{n as j,r as M,t as N}from"./dist-CbNfxqbd.js";import{t as P}from"./dist-DaSyQKU7.js";import{t as F}from"./cards-AZlSJQ0z.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./createLucideIcon-DUW9Fpzj.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-C_4ufx4u.js";import{A as c,M as l,n as u}from"./index-DYyIpxqK.js";import{t as d}from"./Money-DCMKf898.js";import{t as f}from"./button-Cj0k8AtB.js";import{t as p}from"./drill-t1zr57xi.js";import{n as m}from"./shared-CR-hvb-r.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./charts-Cj_hTR4h.js";import{t}from"./CategoryIcon-E6EWIpbr.js";import{t as n}from"./Money-DCMKf898.js";import{M as r,l as i,o as a}from"./index-DYyIpxqK.js";import{L as o,_ as s,u as c,w as l}from"./queries-C_4ufx4u.js";import{t as u}from"./drill-t1zr57xi.js";import{n as d,t as f}from"./shared-CR-hvb-r.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./createLucideIcon-DUW9Fpzj.js";import{t}from"./chevron-right-BetctQ6k.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-C_4ufx4u.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-DYyIpxqK.js";import{t as w}from"./DrillLink-pa6s17Xu.js";import{t as T}from"./KV-CKGyL0p7.js";import{t as E}from"./Money-DCMKf898.js";import{t as D}from"./Panel-CXjnsEN0.js";import{a as O,i as k,n as A,o as j,r as M}from"./bits-BoWPOwTB.js";import{n as N,t as P}from"./TxRow-IqjFXpya.js";import{a as F,n as I,t as L}from"./charts-Cj_hTR4h.js";import{n as R,r as z}from"./cards-AZlSJQ0z.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.jsx)(b,{children:y?`${S(y.from,i)} – ${S(y.close,i)}`:r(`common.loading`)})]}),(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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e,I as t,L as n,a as r,u as i,w as a}from"./queries-C_4ufx4u.js";import{t as o}from"./Money-DCMKf898.js";import{a as s,i as c,n as l,o as u,r as d,s as f}from"./bits-BoWPOwTB.js";import{H as p,U as m,W as h,n as g,u as _}from"./index-DYyIpxqK.js";import{i as v,t as y}from"./cards-AZlSJQ0z.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./Money-DCMKf898.js";import{o as t,r as n}from"./bits-BoWPOwTB.js";import{M as r,n as i}from"./index-DYyIpxqK.js";import{L as a,a as o,u as s,w as c}from"./queries-C_4ufx4u.js";import{t as l}from"./cards-AZlSJQ0z.js";import{n as u}from"./shared-CR-hvb-r.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e}from"./bits-BoWPOwTB.js";import{M as t}from"./index-DYyIpxqK.js";import{L as n,a as r,u as i,w as a}from"./queries-C_4ufx4u.js";import{n as o}from"./shared-CR-hvb-r.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./Money-DCMKf898.js";import{M as t,u as n}from"./index-DYyIpxqK.js";import{L as r,a as i,u as a,w as o}from"./queries-C_4ufx4u.js";import{t as s}from"./cards-AZlSJQ0z.js";import{n as c}from"./shared-CR-hvb-r.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./createLucideIcon-DUW9Fpzj.js";import{$ as t,Q as n,rt as r}from"./index-DYyIpxqK.js";import{L as i,T as a}from"./queries-C_4ufx4u.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e,I as t,L as n,d as r,w as i}from"./queries-C_4ufx4u.js";import{t as a}from"./Combobox-lRNTmjKR.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e,I as t,L as n,m as r,w as i}from"./queries-C_4ufx4u.js";import{a,i as o,n as s,r as c,t as l}from"./charts-Cj_hTR4h.js";import{t as u}from"./Money-DCMKf898.js";import{M as d,a as f,l as p,n as m}from"./index-DYyIpxqK.js";import{t as h}from"./drill-t1zr57xi.js";import{t as g}from"./shared-CR-hvb-r.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./createLucideIcon-DUW9Fpzj.js";import{B as t,I as n,L as r,T as i,w as a}from"./queries-C_4ufx4u.js";import{i as o,n as s,o as c,s as l,t as u}from"./button-Cj0k8AtB.js";import{at as d,ct as f,ft as p,ht as m,mt as h,ot as g,st as _,tt as v,ut as ee}from"./index-DYyIpxqK.js";import{i as y,n as b,o as x,r as S,s as C}from"./dist-CetESl7K.js";import"./dialog-BIbLA-XP.js";import{a as w,c as T,i as E,l as D,n as O,o as k,r as te,s as A,t as j}from"./es2015-BgAh-EkH.js";import{t as M}from"./dist-DYP_TYPy.js";import{t as N}from"./fold-CGWYt9Iu.js";var P=t(n(),1),F=r(),ne=Object.defineProperty,I=(e,t)=>ne(e,`name`,{value:t,configurable:!0}),L=`Popover`,[re,ie]=x(L,[f]),ae=f(),[oe,R]=re(L),se=I(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=ae(t),c=P.useRef(null),[l,u]=P.useState(!1),[f,p]=P.useState(0),[m,h]=P.useState(0),[g,_]=S({prop:r,defaultProp:i??!1,onChange:a,caller:L});return(0,F.jsx)(d,{...s,children:(0,F.jsx)(oe,{scope:t,contentId:b(),titleId:b(),descriptionId:b(),titlePresent:f>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:h,triggerRef:c,open:g,onOpenChange:_,onOpenToggle:P.useCallback(()=>_(e=>!e),[_]),hasCustomAnchor:l,onCustomAnchorAdd:P.useCallback(()=>u(!0),[]),onCustomAnchorRemove:P.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),ce=`PopoverTrigger`,le=P.forwardRef(I(function(e,t){let{__scopePopover:n,...r}=e,i=R(ce,n),a=ae(n),o=l(t,i.triggerRef),s=(0,F.jsx)(C.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":B(i.open),...r,ref:o,onClick:y(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,F.jsx)(g,{asChild:!0,...a,children:s})},`PopoverTrigger`)),ue=`PopoverPortal`,[de,fe]=re(ue,{forceMount:void 0}),pe=I(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=R(ue,t);return(0,F.jsx)(de,{scope:t,forceMount:n,children:(0,F.jsx)(M,{present:n||a.open,children:(0,F.jsx)(E,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),z=`PopoverContent`,me=P.forwardRef(I(function(e,t){let n=fe(z,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=R(z,e.__scopePopover);return(0,F.jsx)(M,{present:r||a.open,children:a.modal?(0,F.jsx)(ge,{...i,ref:t}):(0,F.jsx)(_e,{...i,ref:t})})},`PopoverContent`)),he=o(`PopoverContent.RemoveScroll`),ge=P.forwardRef(I(function(e,t){let n=R(z,e.__scopePopover),r=P.useRef(null),i=l(t,r),a=P.useRef(!1),{nodes:o,registry:s}=T();return P.useEffect(()=>{let e=r.current;if(e)return j(e)},[]),(0,F.jsx)(O,{as:he,allowPinchZoom:!0,shards:P.useMemo(()=>[r,...o.map(e=>({current:e}))],[r,o]),children:(0,F.jsx)(ve,{...e,ref:i,branchNodes:o,branchRegistry:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:y(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:y(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:y(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),_e=P.forwardRef(I(function(e,t){let n=R(z,e.__scopePopover),r=P.useRef(!1),i=P.useRef(!1);return(0,F.jsx)(ve,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),ve=P.forwardRef(I(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:d,"aria-describedby":f,branchNodes:p,branchRegistry:m,...h}=e,g=R(z,n),v=ae(n),[ee,y]=P.useState(null),b=l(t,y);return A(ee),te(),(0,F.jsx)(k,{registry:m,children:(0,F.jsx)(w,{asChild:!0,loop:!0,trapped:r,branches:p,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,F.jsx)(D,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:d,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>g.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,F.jsx)(_,{"data-state":B(g.open),role:`dialog`,id:g.contentId,"aria-labelledby":g.titlePresent?g.titleId:void 0,"aria-describedby":g.descriptionPresent?ye(f,g.descriptionId):f,...v,...h,ref:b,style:{...h.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})})},`PopoverContentImpl`));function B(e){return e?`open`:`closed`}I(B,`getState`);function ye(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}I(ye,`concatAriaDescribedby`);var be={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};be.node;var xe=e(be),Se={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Se.node;var Ce=e(Se),we=1,Te=.9,Ee=.8,De=.17,V=.1,H=.999,Oe=.9999,ke=.99,Ae=/[\\\/_+.#"@\[\(\{&]/,je=/[\\\/_+.#"@\[\(\{&]/g,Me=/[\s-]/,Ne=/[\s-]/g;function U(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?we:ke;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=U(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=we:Ae.test(e.charAt(l-1))?(d*=Ee,p=e.slice(i,l-1).match(je),p&&i>0&&(d*=H**+p.length)):Me.test(e.charAt(l-1))?(d*=Te,m=e.slice(i,l-1).match(Ne),m&&i>0&&(d*=H**+m.length)):(d*=De,i>0&&(d*=H**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Oe)),(d<V&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=U(e,t,n,r,l+1,a+2,o),f*V>d&&(d=f*V)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Pe(e){return e.toLowerCase().replace(Ne,` `)}function Fe(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,U(e,t,Pe(e),Pe(t),0,0,{})}var W=`[cmdk-group=""]`,G=`[cmdk-group-items=""]`,Ie=`[cmdk-group-heading=""]`,Le=`[cmdk-item=""]`,Re=`${Le}:not([aria-disabled="true"])`,K=`cmdk-item-select`,q=`data-value`,ze=(e,t,n)=>Fe(e,t,n),Be=P.createContext(void 0),J=()=>P.useContext(Be),Ve=P.createContext(void 0),He=()=>P.useContext(Ve),Ue=P.createContext(void 0),We=P.forwardRef((e,t)=>{let n=Z(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Z(()=>new Set),i=Z(()=>new Map),a=Z(()=>new Map),o=Z(()=>new Set),s=tt(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=b(),ee=b(),y=b(),x=P.useRef(null),S=rt();X(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),X(()=>{S(6,te)},[]);let w=P.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),S(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(y);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,w.emit()}),r||S(5,te),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=P.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),S(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:y,labelId:ee,listInnerRef:x}),[]);function E(e,t){let r=s.current?.filter??ze;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(G);t?t.appendChild(e.parentElement===t?e:e.closest(`${G} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${G} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${W}[${q}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(q);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function te(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(W)?.querySelector(Ie))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${Le}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Re)||[])}function M(e){let t=j()[e];t&&w.setState(`value`,t.getAttribute(q))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(q))}function F(e){let t=A()?.closest(W),n;for(;t&&!n;)t=e>0?$e(t,W):et(t,W),n=t?.querySelector(Re);n?w.setState(`value`,n.getAttribute(q)):N(e)}let ne=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?ne():e.altKey?F(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?F(-1):N(-1)};return P.createElement(C.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&L(e);break;case`ArrowUp`:L(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),ne();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(K);t.dispatchEvent(e)}}}}},P.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:at},c),$(e,e=>P.createElement(Ve.Provider,{value:w},P.createElement(Be.Provider,{value:T},e))))}),Ge=P.forwardRef((e,t)=>{let n=b(),r=P.useRef(null),i=P.useContext(Ue),a=J(),o=tt(e),s=o.current?.forceMount??i?.forceMount;X(()=>{if(!s)return a.item(n,i?.id)},[s]);let l=nt(n,r,[e.value,e.children,r],e.keywords),u=He(),d=Q(e=>e.value&&e.value===l.current),f=Q(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);P.useEffect(()=>{let t=r.current;if(t&&!e.disabled)return t.addEventListener(K,p),()=>t.removeEventListener(K,p)},[f,e.onSelect,e.disabled]);function p(){var e,t;m(),(t=(e=o.current).onSelect)==null||t.call(e,l.current)}function m(){u.setState(`value`,l.current,!0)}if(!f)return null;let{disabled:h,value:g,onSelect:_,forceMount:v,keywords:ee,...y}=e;return P.createElement(C.div,{ref:c(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!h,"aria-selected":!!d,"data-disabled":!!h,"data-selected":!!d,onPointerMove:h||a.getDisablePointerSelection()?void 0:m,onClick:h?void 0:p},e.children)}),Ke=P.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=b(),s=P.useRef(null),l=P.useRef(null),u=b(),d=J(),f=Q(e=>i||d.filter()===!1?!0:!e.search||e.filtered.groups.has(o));X(()=>d.group(o),[]),nt(o,s,[e.value,e.heading,l]);let p=P.useMemo(()=>({id:o,forceMount:i}),[i]);return P.createElement(C.div,{ref:c(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!f||void 0},n&&P.createElement(`div`,{ref:l,"cmdk-group-heading":``,"aria-hidden":!0,id:u},n),$(e,e=>P.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?u:void 0},P.createElement(Ue.Provider,{value:p},e))))}),qe=P.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=P.useRef(null),a=Q(e=>!e.search);return!n&&!a?null:P.createElement(C.div,{ref:c(i,t),...r,"cmdk-separator":``,role:`separator`})}),Je=P.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=He(),o=Q(e=>e.search),s=Q(e=>e.selectedItemId),c=J();return P.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),P.createElement(C.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Ye=P.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=P.useRef(null),o=P.useRef(null),s=Q(e=>e.selectedItemId),l=J();return P.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),P.createElement(C.div,{ref:c(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:l.listId},$(e,e=>P.createElement(`div`,{ref:c(o,l.listInnerRef),"cmdk-list-sizer":``},e)))}),Xe=P.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return P.createElement(ee,{open:n,onOpenChange:r},P.createElement(m,{container:o},P.createElement(h,{"cmdk-overlay":``,className:i}),P.createElement(p,{"aria-label":e.label,"cmdk-dialog":``,className:a},P.createElement(We,{ref:t,...s}))))}),Ze=P.forwardRef((e,t)=>Q(e=>e.filtered.count===0)?P.createElement(C.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Qe=P.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return P.createElement(C.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},$(e,e=>P.createElement(`div`,{"aria-hidden":!0},e)))}),Y=Object.assign(We,{List:Ye,Item:Ge,Input:Je,Group:Ke,Separator:qe,Dialog:Xe,Empty:Ze,Loading:Qe});function $e(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function et(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function tt(e){let t=P.useRef(e);return X(()=>{t.current=e}),t}var X=typeof window>`u`?P.useEffect:P.useLayoutEffect;function Z(e){let t=P.useRef();return t.current===void 0&&(t.current=e()),t}function Q(e){let t=He(),n=()=>e(t.snapshot());return P.useSyncExternalStore(t.subscribe,n,n)}function nt(e,t,n,r=[]){let i=P.useRef(),a=J();return X(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(q,s),i.current=s}),i}var rt=()=>{let[e,t]=P.useState(),n=Z(()=>new Map);return X(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function it(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function $({asChild:e,children:t},n){return e&&P.isValidElement(t)?P.cloneElement(it(t),{ref:t.ref},n(t.props.children)):n(t)}var at={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function ot({className:e,...t}){return(0,F.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:i(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,e),...t})}var st=s(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function ct({className:e,align:t=`inline-start`,...n}){return(0,F.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:i(st({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}s(`flex items-center gap-2 text-sm shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5`,sm:``,"icon-xs":`size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function lt({className:e,...t}){return(0,F.jsx)(Y,{"data-slot":`command`,className:i(`flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground`,e),...t})}function ut({className:e,...t}){return(0,F.jsx)(`div`,{"data-slot":`command-input-wrapper`,className:`p-1 pb-0`,children:(0,F.jsxs)(ot,{className:`h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!`,children:[(0,F.jsx)(Y.Input,{"data-slot":`command-input`,className:i(`w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,e),...t}),(0,F.jsx)(ct,{children:(0,F.jsx)(Ce,{className:`size-4 shrink-0 opacity-50`})})]})})}function dt({className:e,...t}){return(0,F.jsx)(Y.List,{"data-slot":`command-list`,className:i(`no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none`,e),...t})}function ft({className:e,...t}){return(0,F.jsx)(Y.Empty,{"data-slot":`command-empty`,className:i(`py-6 text-center text-sm`,e),...t})}function pt({className:e,...t}){return(0,F.jsx)(Y.Group,{"data-slot":`command-group`,className:i(`overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function mt({className:e,children:t,...n}){return(0,F.jsxs)(Y.Item,{"data-slot":`command-item`,className:i(`group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground`,e),...n,children:[t,(0,F.jsx)(v,{className:`ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100`})]})}function ht({...e}){return(0,F.jsx)(se,{"data-slot":`popover`,...e})}function gt({...e}){return(0,F.jsx)(le,{"data-slot":`popover-trigger`,...e})}function _t({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,F.jsx)(pe,{children:(0,F.jsx)(me,{"data-slot":`popover-content`,align:t,sideOffset:n,className:i(`z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function vt({label:e,groups:t,value:n,onSelect:r,className:i,ariaLabel:o}){let{t:s}=a(),[c,l]=(0,P.useState)(!1),d=t.flatMap(e=>e.options).find(e=>e.value===n);return(0,F.jsxs)(ht,{open:c,onOpenChange:l,children:[(0,F.jsx)(gt,{asChild:!0,children:(0,F.jsxs)(u,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":c,"aria-label":o?`${o}: ${d?d.label:e}`:void 0,className:`min-h-11 justify-between gap-2 md:min-h-8 ${i??``}`,children:[(0,F.jsx)(`span`,{className:`truncate`,children:d?d.label:e}),(0,F.jsx)(xe,{className:`opacity-50`})]})}),(0,F.jsx)(_t,{align:`start`,className:`w-[min(20rem,calc(100vw-2rem))] p-0`,children:(0,F.jsxs)(lt,{filter:(e,t,n)=>+!!N([e,...n??[]].join(` `)).includes(N(t)),children:[(0,F.jsx)(ut,{placeholder:s(`filter.search`)}),(0,F.jsxs)(dt,{className:`max-h-72`,children:[(0,F.jsx)(ft,{children:s(`filter.noMatch`)}),t.map((e,t)=>(0,F.jsx)(pt,{heading:e.heading,children:e.options.map(e=>(0,F.jsx)(mt,{value:e.value,keywords:[e.label,...e.keywords??[]],"data-checked":e.value===n,className:`min-h-11 md:min-h-8`,style:e.depth?{paddingLeft:`${.5+e.depth*1}rem`}:void 0,onSelect:()=>{r(e.value),l(!1)},children:(0,F.jsx)(`span`,{className:`truncate`,children:e.label})},e.value))},e.heading??t))]})]})})]})}export{Ce as n,vt as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./Money-DCMKf898.js";import{M as t,l as n,n as r}from"./index-DYyIpxqK.js";import{L as i,o as a,u as o,w as s}from"./queries-C_4ufx4u.js";import{n as c}from"./shared-CR-hvb-r.js";var l=i();function u({widget:i,menu:u}){let{t:d,lang:f}=s(),p=c(i,`widget.deposits`),m=!!o().data?.features?.deposits,{data:h,error:g,isLoading:_}=a(m),v=[...h??[]].sort((e,t)=>(e.daysToMaturity??1e9)-(t.daysToMaturity??1e9));return(0,l.jsx)(t,{title:p,menu:u,loading:m&&_,error:m?g?.message:void 0,empty:!m||h&&v.length===0?d(`deposits.empty`):void 0,children:(0,l.jsx)(`ul`,{className:`flex flex-col divide-y`,children:v.map(t=>(0,l.jsx)(`li`,{children:(0,l.jsxs)(`a`,{href:`#/transactions?account=${encodeURIComponent(t.account)}`,className:`flex min-h-11 items-center gap-2 rounded-md py-1.5 outline-none hover:bg-muted/50 focus-visible:ring-3 focus-visible:ring-ring/50`,children:[(0,l.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,l.jsx)(`span`,{className:`truncate text-sm`,children:t.name}),(0,l.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[t.maturity?`${t.daysToMaturity<0?d(`deposits.matured`):d(`deposits.inDays`,{n:t.daysToMaturity})} · ${r(t.maturity)}`:d(`deposits.noMaturity`),t.rate!==null&&` · ${n(t.rate,f,2)}%`]}),t.interestAtMaturity?(0,l.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[d(`deposits.interest`),` `,(0,l.jsx)(e,{amount:t.interestAtMaturity,mode:`short`})]}):null]}),(0,l.jsx)(e,{amount:t.balance,mode:`short`,className:`shrink-0 text-sm font-medium`})]})},t.account))})})}export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./drill-t1zr57xi.js";import{L as t,T as n}from"./queries-C_4ufx4u.js";var r=t();function i({filter:t,href:i,className:a,children:o,...s}){return(0,r.jsx)(`a`,{href:i??e(t),className:n(`rounded-md outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50`,a),...s,children:o})}export{i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e,I as t,L as n}from"./queries-C_4ufx4u.js";import{a as r,i,n as a,r as o,t as s}from"./select-2EwEpMf_.js";var c=e(t(),1),l=n();function u({label:e,hint:t,children:n,className:r}){let i=(0,c.useId)();return(0,l.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5 ${r??``}`,children:[(0,l.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium`,children:e}),n(i),t&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t})]})}function d({id:e,value:t,options:n,onChange:c}){return(0,l.jsxs)(s,{value:t,onValueChange:c,children:[(0,l.jsx)(i,{id:e,className:`min-h-11 w-full md:min-h-8`,children:(0,l.jsx)(r,{})}),(0,l.jsx)(a,{children:n.map(e=>(0,l.jsx)(o,{value:e.value,className:`min-h-11 md:min-h-8`,children:e.label},e.value))})]})}export{d as n,u as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,D as t,E as n,G as r,J as i,K as a,N as o,O as s,T as c,X as l,Y as u,_ as d,b as f,g as p,h as m,it as h,k as g,m as _,nt as v,p as ee,q as y,tt as te,v as b,w as x,x as S,y as C}from"./index-DYyIpxqK.js";import{t as w}from"./createLucideIcon-DUW9Fpzj.js";import{B as T,I as E,L as D,d as O,u as k,w as A}from"./queries-C_4ufx4u.js";import{t as j}from"./button-Cj0k8AtB.js";import{t as M}from"./Combobox-lRNTmjKR.js";import{n as N,t as P}from"./Field-OkPhoYM1.js";import{n as F,t as I}from"./arrow-up-C8D_7x_H.js";import{a as L,n as R,o as z,r as B,t as V}from"./dialog-BIbLA-XP.js";var H={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};H.node;var U=w(H),W={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};W.node;var G=w(W),ne={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};ne.node;var re=w(ne),ie={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};ie.node;var ae=w(ie),K=T(E(),1),q=D(),oe={pace:`line`,attention:`list`,unusual:`list`,net_worth:`line`,left:`stat`,by_category:`bars`,income_spending:`columns`,recent:`list`,account:`line`,upcoming:`strip`,deposits:`list`,chart:`columns`,cards:`bars`,cashback:`list`,which_card:`list`,cards_value:`bars`},J=`rounded-sm bg-muted-foreground/25`;function se({kind:e}){return(0,q.jsxs)(`div`,{className:`flex h-16 w-24 shrink-0 flex-col gap-1.5 overflow-hidden rounded-md border bg-muted/40 p-2`,"aria-hidden":!0,children:[e===`stat`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`${J} h-2 w-1/2`}),(0,q.jsx)(`div`,{className:`rounded-sm h-5 w-4/5 bg-muted-foreground/40`})]}),e===`line`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`${J} h-2 w-1/2`}),(0,q.jsx)(`svg`,{viewBox:`0 0 80 28`,className:`h-full w-full text-muted-foreground/60`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,preserveAspectRatio:`none`,children:(0,q.jsx)(`path`,{d:`M2 24 L16 18 L30 21 L44 10 L58 13 L78 3`})})]}),e===`columns`&&(0,q.jsx)(`div`,{className:`flex h-full items-end gap-1`,children:[40,65,50,85,60,75].map((e,t)=>(0,q.jsx)(`div`,{className:`rounded-sm flex-1 bg-muted-foreground/40`,style:{height:`${e}%`}},t))}),e===`bars`&&(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[90,65,45,30].map((e,t)=>(0,q.jsx)(`div`,{className:`rounded-sm h-2 bg-muted-foreground/40`,style:{width:`${e}%`}},t))}),e===`list`&&(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[100,85,95,70].map((e,t)=>(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`div`,{className:`size-2 shrink-0 rounded-full bg-muted-foreground/40`}),(0,q.jsx)(`div`,{className:`${J} h-2`,style:{width:`${e}%`}})]},t))}),e===`strip`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`${J} h-2 w-1/2`}),(0,q.jsx)(`div`,{className:`flex gap-1`,children:[1,2,3,4].map(e=>(0,q.jsx)(`div`,{className:`${J} h-7 flex-1`},e))})]})]})}function Y({name:e,description:t,sketch:n,icon:r,onPick:i}){return(0,q.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-h-11 w-full items-start gap-3 rounded-xl border bg-card p-3 text-left outline-none transition-colors hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50`,children:[(0,q.jsx)(se,{kind:n}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[r&&(0,q.jsx)(v,{className:`size-4`,"aria-hidden":!0}),e]}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]})]})}function ce(e){return Object.values(s).filter(t=>t.type!==`chart`&&(!t.available||t.available(e))).map(e=>e.type)}function le({open:e,onOpenChange:t,features:n,onPick:o,onCustom:c}){let{t:l}=A();return(0,q.jsx)(r,{open:e,onOpenChange:t,children:(0,q.jsxs)(a,{className:`data-[side=right]:w-full data-[side=right]:sm:max-w-md`,children:[(0,q.jsxs)(i,{children:[(0,q.jsx)(u,{children:l(`cat.title`)}),(0,q.jsx)(y,{children:l(`cat.description`)})]}),(0,q.jsxs)(`ul`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-4 pb-4`,children:[(0,q.jsx)(`li`,{children:(0,q.jsx)(Y,{name:l(`cat.custom`),description:l(`cat.customDesc`),sketch:`columns`,icon:!0,onPick:c})}),ce(n).map(e=>(0,q.jsx)(`li`,{children:(0,q.jsx)(Y,{name:l(s[e].titleKey),description:l(`widget.desc.${e}`),sketch:oe[e]??`list`,onPick:()=>o(e)})},e))]})]})})}var X={query:{metric:`spending`,period:`last-3-months`,by:`month`},chart:`bar`,title:``},Z=`__any`,Q=`__multi`,ue=`pool`,$=`__other`,de=(e,t)=>{let[n,r]=(0,K.useState)(e);return(0,K.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n};function fe({initial:t,submitLabel:n,onSubmit:r,onCancel:i}){let{t:a}=A(),c=k().data?.features,l=k().data?.pool?.name||a(`pool.name`),u=O().data,[f,g]=(0,K.useState)(()=>({...t.query,period:t.query.period??`this-month`,by:t.query.by??(t.query.metric===`balance`?`month`:`top`)})),[v,ee]=(0,K.useState)(t.chart),[y,te]=(0,K.useState)(t.title),[C,w]=(0,K.useState)(()=>!!t.query.period&&!d.includes(t.query.period)),T=e=>g(t=>({...t,...e})),E=e=>t=>T({[e]:t}),D=S(f,y),F=e(f),I=de(JSON.stringify(F),350),L=(0,K.useMemo)(()=>JSON.parse(I),[I]),R={id:`preview`,type:`chart`,x:0,y:0,w:6,h:4,title:y.trim()||void 0,query:L,chart:v},z=s.chart.component,B=[{options:[{value:Z,label:a(`cf.any`)},...(u?.categories??[]).map(e=>({value:e.path,label:e.name,keywords:[e.path],depth:e.path.split(`/`).length-1})),...f.category&&!u?.categories.some(e=>e.path===f.category)?[{value:f.category,label:f.category}]:[]]}],V=[{options:[{value:Z,label:a(`cf.any`)},{value:ue,label:a(`cf.pool`,{name:l})},...(u?.accounts??[]).filter(e=>!e.closed||e.id===f.account).map(e=>({value:e.id,label:e.name,keywords:[e.id]})),...Array.isArray(f.account)?[{value:Q,label:f.account.map(e=>u?.accounts.find(t=>t.id===e)?.name??e).join(`, `)}]:[]]}],H=Array.isArray(f.account)?Q:f.account??Z,U=(f.metric===`balance`?b:_).filter(e=>e===`who`?c?.who||f.by===`who`:e===`event`?c?.event||f.by===`event`:e!==`tag`||c?.tags||f.by===`tag`),W=C?$:f.period??`this-month`,G=(e,t)=>t||!!f[e];return(0,q.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),D.length||r({query:F,chart:v,title:y.trim()})},children:[(0,q.jsxs)(`section`,{"aria-label":a(`cf.preview`),className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium`,children:a(`cf.preview`)}),(0,q.jsx)(`div`,{className:`flex h-72 flex-col *:flex-1`,children:D.length?(0,q.jsx)(`div`,{className:`rounded-xl border border-dashed p-4 text-sm text-muted-foreground`,role:`alert`,children:D.map(e=>(0,q.jsx)(`p`,{children:a(e)},e))}):(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(o,{}),children:(0,q.jsx)(z,{widget:R})})})]}),(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsx)(P,{label:a(`cf.metric`),children:e=>(0,q.jsx)(N,{id:e,value:f.metric,options:p.map(e=>({value:e,label:a(`cf.metric.${e}`)})),onChange:e=>T({metric:e,...e===`balance`&&!x(f.by)?{by:`month`}:{}})})}),(0,q.jsx)(P,{label:a(`cf.kind`),children:e=>(0,q.jsx)(N,{id:e,value:v,options:m.map(e=>({value:e,label:a(`cf.kind.${e}`)})),onChange:e=>ee(e)})}),(0,q.jsx)(P,{label:a(`cf.period`),children:e=>(0,q.jsx)(N,{id:e,value:W,options:[...d.map(e=>({value:e,label:a(`cf.period.${e}`)})),{value:$,label:a(`cf.periodOther`)}],onChange:e=>{e===$?(w(!0),T({period:d.includes(f.period??``)?``:f.period})):(w(!1),T({period:e}))}})}),C&&(0,q.jsx)(P,{label:a(`cf.periodValue`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,inputMode:`numeric`,placeholder:`2026-11`,value:f.period??``,"aria-invalid":D.includes(`cf.err.period`),onChange:e=>T({period:e.target.value.trim()})})}),(0,q.jsx)(P,{label:a(`cf.by`),hint:f.metric===`balance`?a(`cf.balanceHint`):void 0,children:e=>(0,q.jsx)(N,{id:e,value:f.by??`top`,options:U.map(e=>({value:e,label:a(`cf.by.${e}`)})),onChange:e=>T({by:e})})}),(0,q.jsx)(P,{label:a(`cf.compare`),children:e=>(0,q.jsx)(N,{id:e,value:f.compare??`none`,options:[`none`,`previous`,`usual`].map(e=>({value:e,label:a(`cf.compare.${e}`)})),onChange:e=>T({compare:e===`none`?void 0:e})})})]}),(0,q.jsxs)(`fieldset`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:a(`cf.filters`)}),(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:a(`cf.category`)}),(0,q.jsx)(M,{className:`w-full`,label:a(`cf.any`),ariaLabel:a(`cf.category`),groups:B,value:f.category??Z,onSelect:e=>T({category:e===Z?void 0:e})})]}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:a(`cf.account`)}),(0,q.jsx)(M,{className:`w-full`,label:a(`cf.any`),ariaLabel:a(`cf.account`),groups:V,value:H,onSelect:e=>e===Q?void 0:T({account:e===Z?void 0:e})})]}),G(`who`,c?.who)&&(0,q.jsx)(P,{label:a(`cf.who`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,value:f.who??``,onChange:e=>E(`who`)(e.target.value)})}),G(`event`,c?.event)&&(0,q.jsx)(P,{label:a(`cf.event`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,value:f.event??``,onChange:e=>E(`event`)(e.target.value)})}),G(`tag`,c?.tags)&&(0,q.jsx)(P,{label:a(`cf.tag`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,value:f.tag??``,onChange:e=>E(`tag`)(e.target.value)})}),(0,q.jsx)(P,{label:a(`cf.text`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,value:f.text??``,onChange:e=>E(`text`)(e.target.value)})})]})]}),(0,q.jsx)(P,{label:a(`cf.title`),hint:a(`wset.titleHint`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,maxLength:100,placeholder:a(`cf.titlePlaceholder`),value:y,"aria-invalid":D.includes(`cf.err.title`),onChange:e=>te(e.target.value)})}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(j,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,onClick:i,children:a(`common.cancel`)}),(0,q.jsx)(j,{type:`submit`,className:`min-h-11 md:min-h-8`,disabled:D.length>0,children:n})]})]})}function pe({id:e,name:t,first:n,last:r,canDrag:i,canSettings:a,onMove:o,onSettings:s,onRemove:c}){let{t:u}=A(),d=`size-11 md:size-8`;return(0,q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[i&&(0,q.jsxs)(`span`,{className:`widget-drag-handle flex size-8 cursor-grab items-center justify-center rounded-lg text-muted-foreground hover:bg-muted active:cursor-grabbing`,title:u(`edit.drag`,{name:t}),children:[(0,q.jsx)(U,{className:`size-4`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`sr-only`,children:u(`edit.drag`,{name:t})})]}),(0,q.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,className:d,"data-move":`up:${e}`,disabled:n,"aria-label":u(`edit.moveUp`,{name:t}),title:u(`edit.moveUp`,{name:t}),onClick:()=>o(-1),children:(0,q.jsx)(I,{})}),(0,q.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,className:d,"data-move":`down:${e}`,disabled:r,"aria-label":u(`edit.moveDown`,{name:t}),title:u(`edit.moveDown`,{name:t}),onClick:()=>o(1),children:(0,q.jsx)(F,{})}),a&&(0,q.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,className:d,"aria-label":u(`edit.settings`,{name:t}),title:u(`edit.settings`,{name:t}),onClick:s,children:(0,q.jsx)(ae,{})}),(0,q.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,className:`${d} hover:text-destructive`,"aria-label":u(`edit.remove`,{name:t}),title:u(`edit.remove`,{name:t}),onClick:c,children:(0,q.jsx)(l,{})})]})}var me=[`this-month`,`last-month`,`this-year`,`last-year`],he=[3,6,12,18,24],ge=[5,8,10,15,20,30],_e=(e,t)=>e.includes(t)?e:[...e,t].sort((e,t)=>e-t);function ve({widget:e,submitLabel:t,onSubmit:n,onCancel:r}){let{t:i}=A(),a=s[e.type]?.options??[],o=k().data,c=O().data,[l,u]=(0,K.useState)(e),[d,f]=(0,K.useState)(e.title??``),p=[{value:`pool`,label:i(`cf.pool`,{name:o?.pool?.name||i(`pool.name`)})},...(c?.accounts??[]).filter(e=>!e.closed||e.id===l.account).map(e=>({value:e.id,label:e.name,keywords:[e.id]}))],m=a.includes(`account`)&&!l.account,g=d.length>80;return(0,q.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{if(e.preventDefault(),m||g)return;let t={...l};d.trim()?t.title=d.trim():delete t.title,n(t)},children:[a.includes(`period`)&&(0,q.jsx)(P,{label:i(`wset.period`),children:e=>(0,q.jsx)(N,{id:e,value:me.includes(l.period??``)?l.period:`this-month`,options:me.map(e=>({value:e,label:i(`wset.period.${e}`)})),onChange:e=>u({...l,period:e})})}),a.includes(`months`)&&(0,q.jsx)(P,{label:i(`wset.months`),children:e=>(0,q.jsx)(N,{id:e,value:String(l.months??6),options:_e(he,l.months??6).map(e=>({value:String(e),label:i(`wset.monthsN`,{n:e})})),onChange:e=>u({...l,months:Number(e)})})}),a.includes(`count`)&&(0,q.jsx)(P,{label:i(`wset.count`),children:e=>(0,q.jsx)(N,{id:e,value:String(l.count??8),options:_e(ge,l.count??8).map(e=>({value:String(e),label:String(e)})),onChange:e=>u({...l,count:Number(e)})})}),a.includes(`account`)&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium`,children:i(`wset.account`)}),(0,q.jsx)(M,{className:`w-full`,label:i(`wset.accountNone`),ariaLabel:i(`wset.account`),groups:[{options:p}],value:l.account,onSelect:e=>u({...l,account:e})})]}),(0,q.jsx)(P,{label:i(`wset.titleLabel`),hint:i(`wset.titleHint`),children:t=>(0,q.jsx)(h,{id:t,className:`min-h-11 md:min-h-8`,value:d,"aria-invalid":g,placeholder:i(s[e.type]?.titleKey??`widget.chart`),onChange:e=>f(e.target.value)})}),g&&(0,q.jsx)(`p`,{className:`text-sm text-destructive`,role:`alert`,children:i(`cf.err.title`)}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(j,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,onClick:r,children:i(`common.cancel`)}),(0,q.jsx)(j,{type:`submit`,className:`min-h-11 md:min-h-8`,disabled:m||g,children:t})]})]})}function ye({widget:e,isNew:t,onSave:n,onClose:r}){let{t:i}=A(),a=e?e.title?.trim()||i(s[e.type]?.titleKey??`widget.chart`):``,o=i(t?`wset.add`:`wset.save`);return(0,q.jsx)(V,{open:e!==null,onOpenChange:e=>!e&&r(),children:(0,q.jsxs)(R,{className:`max-h-[92svh] overflow-y-auto sm:max-w-2xl`,children:[(0,q.jsxs)(L,{children:[(0,q.jsx)(z,{children:i(`wset.title`,{name:a})}),(0,q.jsx)(B,{children:i(`wset.description`)})]}),e&&(e.type===`chart`?(0,q.jsx)(fe,{initial:e.query?{query:e.query,chart:e.chart??`bar`,title:e.title??``}:X,submitLabel:o,onCancel:r,onSubmit:t=>{let r={...e,query:t.query,chart:t.chart};t.title?r.title=t.title:delete r.title,n(r)}},e.id):(0,q.jsx)(ve,{widget:e,submitLabel:o,onCancel:r,onSubmit:n},e.id))]})})}function be({saved:e,renderWidget:r,onExit:i}){let{t:a}=A(),o=k().data?.features,l=g(`(max-width: 639px)`),[u,d]=(0,K.useState)(()=>e.map(e=>({...e}))),[p,m]=(0,K.useState)(!1),[h,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(``),[b,x]=(0,K.useState)(null),[S,w]=(0,K.useState)(null),[T,E]=(0,K.useState)(!1),[D,O]=(0,K.useState)(null),M=(0,K.useRef)(null),N=e=>e.title?.trim()||a(s[e.type]?.titleKey??`widget.chart`),P=[...u].sort(f);(0,K.useEffect)(()=>{if(!D)return;let e=e=>document.querySelector(`[data-move="${e}:${D.id}"]`),t=e(D.dir<0?`up`:`down`);(t&&!t.disabled?t:e(D.dir<0?`down`:`up`))?.focus()},[D]);let F=e=>d(t=>{let n=!1,r=t.map(t=>{let r=e.find(e=>e.i===t.id);return!r||r.x===t.x&&r.y===t.y&&r.w===t.w&&r.h===t.h?t:(n=!0,{...t,x:r.x,y:r.y,w:r.w,h:r.h})});return n?r:t}),I=e=>{d(t=>[...t,e]),y(a(`edit.added`,{name:N(e)}))},L=e=>{let t=s[e];if(!t)return;m(!1);let n=C(u,{type:e},t.size);t.options?.includes(`account`)?_({widget:n,isNew:!0}):I(n)},R=()=>{m(!1),_({widget:C(u,{type:`chart`,query:X.query,chart:X.chart},s.chart.size),isNew:!0})},z=e=>{h?.isNew?I(e):(d(t=>t.map(t=>t.id===e.id?e:t)),y(a(`edit.updated`,{name:N(e)}))),_(null)},B=e=>{d(t=>t.filter(t=>t.id!==e.id)),y(a(`edit.removed`,{name:N(e)})),M.current?.focus()},V=(e,t)=>{d(n=>c(n,e.id,t)),y(a(`edit.moved`,{name:N(e)})),O({id:e.id,dir:t})},H=async e=>{x(e),w(null);try{e===`save`?await t(u):await n(),i()}catch(t){w(a(e===`save`?`edit.saveError`:`edit.resetError`,{message:t.message})),E(!1),x(null)}},U=`min-h-11 md:min-h-8`;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:`sticky top-0 z-30 -mx-4 flex flex-col gap-2 border-b bg-background/95 px-4 py-2 backdrop-blur md:-mx-6 md:px-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`h2`,{ref:M,tabIndex:-1,className:`mr-auto text-sm font-medium outline-none`,children:[a(`home.title`),` · `,a(`edit.editing`)]}),T?(0,q.jsxs)(`div`,{role:`alertdialog`,"aria-label":a(`edit.reset`),className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`p`,{className:`text-sm`,children:a(`edit.resetConfirm`)}),(0,q.jsx)(j,{type:`button`,variant:`destructive`,className:U,disabled:b!==null,onClick:()=>void H(`reset`),children:a(b===`reset`?`edit.saving`:`edit.resetYes`)}),(0,q.jsx)(j,{type:`button`,variant:`outline`,className:U,disabled:b!==null,onClick:()=>E(!1),children:a(`edit.resetKeep`)})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(j,{type:`button`,variant:`ghost`,className:U,disabled:b!==null,onClick:()=>E(!0),children:[(0,q.jsx)(re,{}),a(`edit.reset`)]}),(0,q.jsxs)(j,{type:`button`,variant:`outline`,className:U,disabled:b!==null,onClick:()=>m(!0),children:[(0,q.jsx)(G,{}),a(`edit.add`)]}),(0,q.jsx)(j,{type:`button`,variant:`outline`,className:U,disabled:b!==null,onClick:i,children:a(`common.cancel`)}),(0,q.jsxs)(j,{type:`button`,className:U,disabled:b!==null,onClick:()=>void H(`save`),children:[(0,q.jsx)(te,{}),a(b===`save`?`edit.saving`:`edit.done`)]})]})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(l?`edit.hintPhone`:`edit.hintDesktop`)}),S&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:S}),(0,q.jsx)(`p`,{role:`status`,className:`sr-only`,children:v})]}),u.length===0?(0,q.jsx)(`p`,{className:`rounded-xl border border-dashed p-6 text-center text-sm text-muted-foreground`,children:a(`edit.empty`)}):(0,q.jsx)(ee,{widgets:u,editing:!0,onLayoutChange:F,renderWidget:e=>{let t=P.findIndex(t=>t.id===e.id);return r(e,(0,q.jsx)(pe,{id:e.id,name:N(e),first:t===0,last:t===P.length-1,canDrag:!l,canSettings:!l&&!!s[e.type]?.options?.length,onMove:t=>V(e,t),onSettings:()=>_({widget:e,isNew:!1}),onRemove:()=>B(e)}))}}),(0,q.jsx)(le,{open:p,onOpenChange:m,features:o,onPick:L,onCustom:R}),(0,q.jsx)(ye,{widget:h?.widget??null,isNew:h?.isNew??!1,onSave:z,onClose:()=>_(null)})]})}export{be as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./useMutation-BWtHiYPX.js";import{B as t,F as n,I as r,L as i,T as a,b as o,l as s,u as c,w as l}from"./queries-C_4ufx4u.js";import{t as u}from"./triangle-exclamation-point-C6padEUM.js";import{it as d,l as f,s as p,tt as m}from"./index-DYyIpxqK.js";import{t as h}from"./Money-DCMKf898.js";import{t as g}from"./Panel-CXjnsEN0.js";import{t as _}from"./button-Cj0k8AtB.js";import{a as v,i as y,n as b,r as x,t as S}from"./select-2EwEpMf_.js";var C=t(r(),1),w=i();async function T(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}function E({summary:e,children:t,open:n}){return(0,w.jsxs)(`details`,{open:n,className:`rounded-lg border px-3`,children:[(0,w.jsx)(`summary`,{className:`flex min-h-11 cursor-pointer items-center text-sm font-medium`,children:e}),(0,w.jsx)(`div`,{className:`flex flex-col gap-2 pb-3`,children:t})]})}var D=e=>[e.account,e.category].filter(Boolean).join(` › `);function O({r:e}){let{t,lang:n}=l(),r=e.reconcile.filter(e=>!e.ok),i=e=>(0,w.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,w.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.date,` · `,e.sheet,` #`,e.row,` · `,e.note]}),(0,w.jsx)(h,{amount:e.amount,mode:`short`,className:`shrink-0`})]},`${e.sheet}-${e.row}`);return(0,w.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,w.jsxs)(`p`,{className:a(`flex items-center gap-2 text-base font-semibold`,e.ok?`text-foreground`:`text-critical`),children:[e.ok?(0,w.jsx)(m,{className:`size-5`,"aria-hidden":!0}):(0,w.jsx)(u,{className:`size-5`,"aria-hidden":!0}),e.ok?t(`import.reconciles`):t(`import.refused`)]}),(0,w.jsxs)(`p`,{className:`text-sm`,children:[t(`import.summary`,{rows:f(e.rows,n),skipped:f(e.skipped,n)}),` `,(0,w.jsx)(`b`,{children:t(`import.newCount`,{n:f(e.new,n)})}),e.accounts.length>0&&(0,w.jsxs)(w.Fragment,{children:[` · `,t(`import.newAccounts`,{n:e.accounts.length})]})]}),e.accounts.length>0&&(0,w.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:e.accounts.map(e=>(0,w.jsx)(`li`,{className:`rounded-full bg-secondary px-2 py-0.5 text-xs text-secondary-foreground`,children:e},e))}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`import.matches`,{ok:e.reconcile.length-r.length,total:e.reconcile.length})}),r.length>0&&(0,w.jsx)(E,{open:!0,summary:t(`import.problems`,{n:r.length}),children:(0,w.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{className:`text-left text-muted-foreground`,children:[(0,w.jsx)(`th`,{scope:`col`,className:`py-1 font-medium`,children:t(`import.account`)}),(0,w.jsx)(`th`,{scope:`col`,className:`py-1 font-medium`,children:t(`import.problem`)})]})}),(0,w.jsx)(`tbody`,{children:r.map(e=>(0,w.jsxs)(`tr`,{className:`border-t align-top`,children:[(0,w.jsx)(`td`,{className:`py-1 pr-3`,children:e.sheet}),(0,w.jsx)(`td`,{className:`py-1`,children:e.problems.join(`; `)})]},e.sheet))})]})}),e.unresolvedCategories.length>0&&(0,w.jsx)(E,{open:!0,summary:(0,w.jsx)(`span`,{className:`text-critical`,children:t(`import.unresolvedCategories`,{n:e.unresolvedCategories.length})}),children:(0,w.jsx)(`ul`,{className:`flex flex-col gap-1 text-xs`,children:e.unresolvedCategories.map(e=>(0,w.jsxs)(`li`,{children:[(0,w.jsx)(`span`,{className:`font-medium`,children:e.key}),` (`,t(`import.rowsCount`,{n:e.rows}),`) `,(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:e.example})]},e.key))})}),e.unresolvedRows.length>0&&(0,w.jsx)(E,{summary:t(`import.unresolvedRows`,{n:e.unresolvedRows.length}),children:(0,w.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.unresolvedRows.map(i)})}),e.unpaired.length>0&&(0,w.jsx)(E,{summary:t(`import.unpaired`,{n:e.unpaired.length}),children:(0,w.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.unpaired.slice(0,50).map(i)})}),(e.changed.length>0||e.gone.length>0)&&(0,w.jsxs)(`p`,{className:`flex items-start gap-2 text-sm font-medium text-critical`,children:[(0,w.jsx)(u,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t(`import.changedGone`,{changed:e.changed.length,gone:e.gone.length})]}),e.rounding.length>0&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`import.rounding`,{n:e.rounding.length})}),e.zeroed.length>0&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`import.zeroed`,{n:e.zeroed.length})}),e.cardTerms.length>0&&(0,w.jsx)(E,{summary:t(`import.cardTerms`,{n:e.cardTerms.length}),children:(0,w.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:e.cardTerms.map(e=>(0,w.jsx)(`li`,{className:`rounded-full bg-secondary px-2 py-0.5 text-xs text-secondary-foreground`,children:e},e))})}),e.nameWarnings.length>0&&(0,w.jsx)(E,{open:!0,summary:(0,w.jsx)(`span`,{className:`text-warning`,children:t(`import.nameWarnings`,{n:e.nameWarnings.length})}),children:(0,w.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-xs`,children:e.nameWarnings.map((e,t)=>(0,w.jsx)(`li`,{children:e},t))})}),e.errors.length>0&&(0,w.jsx)(E,{open:!0,summary:(0,w.jsx)(`span`,{className:`text-critical`,children:t(`import.errors`,{n:e.errors.length})}),children:(0,w.jsx)(`pre`,{className:`overflow-x-auto text-xs whitespace-pre-wrap`,children:e.errors.join(`
|
|
2
|
+
`)})}),e.sample.length>0&&(0,w.jsx)(E,{open:!0,summary:t(`import.sample`,{n:e.sample.length}),children:(0,w.jsx)(`ul`,{className:`flex flex-col divide-y`,children:e.sample.map(e=>(0,w.jsxs)(`li`,{className:`flex flex-col gap-0.5 py-1.5 text-xs`,children:[(0,w.jsxs)(`span`,{className:`flex items-baseline justify-between gap-3`,children:[(0,w.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.note||`–`}),(0,w.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:p(e.date,n)})]}),(0,w.jsx)(`span`,{className:`flex flex-col text-muted-foreground`,children:e.lines.map((e,t)=>(0,w.jsxs)(`span`,{className:`flex justify-between gap-3`,children:[(0,w.jsx)(`span`,{className:`min-w-0 truncate`,children:D(e)}),(0,w.jsx)(h,{amount:e.amount,mode:`short`,className:`shrink-0`})]},t))})]},e.id))})})]})}function k(){let{t}=l(),r=c().data,i=n(),a=s(),[u,f]=(0,C.useState)(void 0),[p,h]=(0,C.useState)(null),E=(0,C.useRef)(null),D=u??a.data?.[0],k=e({mutationFn:async()=>{let e=JSON.stringify({file_name:p.name,base64:await T(p),mapping:D});return o(`import/preview`,{method:`POST`,body:e})}}),A=e({mutationFn:e=>o(`import/apply`,{method:`POST`,body:JSON.stringify({preview_id:e})}),onSuccess:()=>void i.invalidateQueries()}),j=()=>{k.reset(),A.reset()},M=(0,w.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:t(`import.title`)});if(r&&!r.features?.imports)return(0,w.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[M,(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`import.cli`)})]});let N=k.data;return(0,w.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,w.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[M,(0,w.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:t(`import.intro`)})]}),a.data&&a.data.length===0?(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`import.cli`)}):(0,w.jsx)(g,{title:t(`import.choose`),children:(0,w.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p&&(A.reset(),k.mutate())},children:[a.data&&a.data.length>1&&(0,w.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:t(`import.mapping`)}),(0,w.jsxs)(S,{value:D,onValueChange:e=>{f(e),j()},children:[(0,w.jsx)(y,{className:`min-h-11 w-full sm:w-96 md:min-h-8`,children:(0,w.jsx)(v,{})}),(0,w.jsx)(b,{children:a.data.map(e=>(0,w.jsx)(x,{value:e,className:`min-h-11 md:min-h-8`,children:e.replace(/^imports\//,``).replace(/\.mapping\.yaml$/,``)},e))})]})]}),a.data?.length===1&&(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`import.mappingOne`,{name:a.data[0].replace(/^imports\//,``)})}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:t(`import.file`)}),(0,w.jsx)(d,{ref:E,type:`file`,accept:`.xlsx,.csv,.json`,onChange:e=>{h(e.target.files?.[0]??null),j()},className:`h-11 py-2 md:h-9`})]}),(0,w.jsx)(_,{type:`submit`,className:`min-h-11 self-start md:min-h-8`,disabled:!p||!D||k.isPending,children:k.isPending?t(`import.reading`):t(`import.preview`)})]})}),k.error&&(0,w.jsx)(`p`,{role:`alert`,className:`text-sm font-medium text-critical`,children:t(`common.error`,{message:k.error.message})}),N&&(0,w.jsxs)(g,{title:t(`import.result`),children:[(0,w.jsx)(O,{r:N.report}),N.preview_id?(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 border-t pt-3`,children:[A.isSuccess?(0,w.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm font-medium`,children:[(0,w.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t(`import.committed`,{sha:A.data.sha.slice(0,10)}),` `,(0,w.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:A.data.message})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(_,{type:`button`,className:`min-h-11 self-start md:min-h-8`,disabled:A.isPending,onClick:()=>A.mutate(N.preview_id),children:A.isPending?t(`import.committing`):t(`import.commit`,{n:N.report.new})}),N.message&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:N.message})]}),A.error&&(0,w.jsx)(`p`,{role:`alert`,className:`text-sm font-medium text-critical`,children:t(`common.error`,{message:A.error.message})})]}):N.report.ok&&(0,w.jsx)(`p`,{className:`border-t pt-3 text-sm text-muted-foreground`,children:t(`import.nothingNew`)})]})]})}export{k as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e,I as t,L as n,f as r,u as i,w as a}from"./queries-C_4ufx4u.js";import{a as o,n as s,t as c}from"./charts-Cj_hTR4h.js";import{t as l}from"./DrillLink-pa6s17Xu.js";import{M as u,P as d,a as f,l as p,o as m}from"./index-DYyIpxqK.js";import{n as h,t as g}from"./drill-t1zr57xi.js";import{n as _}from"./shared-CR-hvb-r.js";var v=e(t(),1),y=n();function b({widget:e,menu:t}){let{t:n,lang:b}=a(),x=_(e,`widget.incomeSpending`),S=i().data?.today??new Date().toISOString().slice(0,10),C=Math.min(24,Math.max(2,e.months??6)),w=S.slice(0,7),T=m(w,-(C-1)),{data:E,error:D,isLoading:O}=r(`${T}-01`,h(w).to),k=(0,v.useMemo)(()=>{let e=new Map((E?.rows??[]).map(e=>[e.key,e]));return Array.from({length:C},(t,n)=>{let r=m(T,n),i=e.get(r);return{ym:r,income:i?.income??0,expense:i?.expense??0}})},[E,C,T]),A=k.reduce((e,t)=>e+t.income,0),j=k.reduce((e,t)=>e+t.expense,0),M=A>0?(A-j)/A*100:null,N=e=>e.income>0?`${p((e.income-e.expense)/e.income*100,b)}%`:``;return(0,y.jsx)(u,{title:x,titleHref:`#/reports`,menu:t,loading:O,error:D?.message,empty:E&&A===0&&j===0?n(`incsp.empty`):void 0,children:E&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:M===null?n(`incsp.noIncome`):n(`incsp.rate`,{pct:p(M,b)})}),(0,y.jsx)(c,{legend:[{label:n(`tx.in`),color:o.accent},{label:n(`tx.out`),color:o.second}],table:{head:[n(`chart.month`),n(`tx.in`),n(`tx.out`),n(`incsp.rateShort`)],rows:k.map(e=>[(0,y.jsx)(l,{filter:h(e.ym),children:f(e.ym)},e.ym),p(e.income,b),p(e.expense,b),N(e)])},children:(0,y.jsx)(s,{data:k,xKey:`ym`,formatX:e=>f(String(e)),onSelect:e=>d(g(h(e)).slice(1)),series:[{key:`income`,label:n(`tx.in`),color:o.accent},{key:`expense`,label:n(`tx.out`),color:o.second}]})})]})})}export{b as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as e,T as t}from"./queries-C_4ufx4u.js";var n=e();function r({label:e,children:r,className:i}){return(0,n.jsxs)(`div`,{className:t(`flex items-baseline justify-between gap-4 py-1.5 text-sm`,i),children:[(0,n.jsx)(`dt`,{className:`shrink-0 text-muted-foreground`,children:e}),(0,n.jsx)(`dd`,{className:`min-w-0 text-right break-words tabular-nums`,children:r})]})}export{r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./DrillLink-pa6s17Xu.js";import{t}from"./Money-DCMKf898.js";import{M as n}from"./index-DYyIpxqK.js";import{L as r,c as i,w as a}from"./queries-C_4ufx4u.js";import{n as o}from"./shared-CR-hvb-r.js";var s=r();function c({widget:r,menu:c}){let{t:l}=a(),u=o(r,`widget.left`),{data:d,error:f,isLoading:p}=i(),m=d?.left;return(0,s.jsx)(n,{title:u,menu:c,loading:p,error:f?.message,children:m&&d&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t,{amount:m.now,tone:`auto`,className:`text-2xl font-semibold tracking-tight`}),(0,s.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[l(`left.monthEnd`),` `,(0,s.jsx)(t,{amount:m.monthEnd,tone:`auto`,mode:`short`,className:`font-medium`})]}),(0,s.jsxs)(`dl`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`dt`,{className:`text-muted-foreground`,children:l(`tx.in`)}),(0,s.jsx)(`dd`,{children:(0,s.jsx)(e,{filter:{from:`${d.asOf.slice(0,7)}-01`,to:d.asOf},children:(0,s.jsx)(t,{amount:m.income,mode:`short`})})})]}),(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`dt`,{className:`text-muted-foreground`,children:l(`tx.out`)}),(0,s.jsx)(`dd`,{children:(0,s.jsx)(t,{amount:m.spent,mode:`short`})})]})]})]})})}export{c as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as e,T as t,u as n,w as r}from"./queries-C_4ufx4u.js";import{c as i,u as a}from"./index-DYyIpxqK.js";var o=e(),s={in:`text-positive`,out:`text-critical`,transfer:`text-muted-foreground`};function c({amount:e,mode:c=`full`,tone:l=`none`,plus:u=!1,className:d}){let{lang:f}=r(),p=n().data?.base??`VND`,m=c===`short`?a(e,f):i(e,f,p),h=Math.sign(e),g=l===`auto`?h===1?`in`:h===-1?`out`:`none`:l;return(0,o.jsxs)(`span`,{className:t(`whitespace-nowrap tabular-nums`,g!==`none`&&s[g],d),children:[u&&h===1?`+`:``,m]})}export{c as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e,I as t,L as n,c as r,w as i}from"./queries-C_4ufx4u.js";import{t as a}from"./Money-DCMKf898.js";import{a as o,i as s,t as c}from"./charts-Cj_hTR4h.js";import{M as l,a as u,l as d,u as f}from"./index-DYyIpxqK.js";import{n as p}from"./shared-CR-hvb-r.js";var m=e(t(),1),h=n();function g({widget:e,menu:t}){let{t:n,lang:g}=i(),_=p(e,`widget.netWorth`),{data:v,error:y,isLoading:b}=r(),x=v?.netWorth,S=(0,m.useMemo)(()=>(x?.series??[]).map(e=>({date:e.date,ym:e.date.slice(0,7),net:e.net})),[x]),C=(e,t)=>e===null?null:(0,h.jsxs)(`li`,{className:`flex items-baseline justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:n(t)}),(0,h.jsx)(a,{amount:e,mode:`short`,tone:`auto`,plus:!0,className:`font-medium`})]});return(0,h.jsx)(l,{title:_,titleHref:`#/accounts`,menu:t,loading:b,error:y?.message,children:x&&v&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`text-2xl font-semibold tracking-tight tabular-nums`,children:f(x.net,g)}),(0,h.jsxs)(`ul`,{className:`flex flex-col gap-0.5 text-sm`,children:[C(x.changeMonth,`nw.changeMonth`),C(x.change12,`nw.change12`),v.pool.on&&(0,h.jsxs)(`li`,{className:`flex items-baseline justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:v.pool.name??n(`pool.name`)}),(0,h.jsx)(a,{amount:v.pool.balance,mode:`short`,className:`font-medium`})]})]}),x.unpriced>0&&(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`nw.unpriced`,{n:x.unpriced})}),(0,h.jsx)(c,{table:{head:[n(`chart.month`),n(`widget.netWorth`)],rows:S.map(e=>[u(e.ym),d(e.net,g)])},children:(0,h.jsx)(s,{data:S,xKey:`ym`,formatX:e=>u(String(e)),specs:[{key:`net`,label:n(`widget.netWorth`),kind:`line`,color:o.accent}]})})]})})}export{g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e,I as t,L as n,c as r,w as i}from"./queries-C_4ufx4u.js";import{t as a}from"./DrillLink-pa6s17Xu.js";import{t as o}from"./Money-DCMKf898.js";import{a as s,i as c,t as l}from"./charts-Cj_hTR4h.js";import{M as u,l as d}from"./index-DYyIpxqK.js";import{n as f,t as p}from"./shared-CR-hvb-r.js";var m=e(t(),1),h=n();function g({widget:e,menu:t}){let{t:n,lang:g}=i(),_=f(e,`widget.pace`),{data:v,error:y,isLoading:b}=r(),x=v?.pace,S=(0,m.useMemo)(()=>x?Array.from({length:x.daysInMonth},(e,t)=>({day:t+1,now:x.daily[t]??null,last:x.lastMonth?.daily[t]??null,usual:x.usual?.daily[t]??null,band:x.usual?.low?.[t]!==void 0&&x.usual?.high?.[t]!==void 0?[x.usual.low[t],x.usual.high[t]]:null,low:x.usual?.low?.[t]??null,high:x.usual?.high?.[t]??null})):[],[x]),C=[...x?.usual?.low?.length?[{key:`band`,label:n(`pace.range`),kind:`band`,color:s.muted}]:[],...x?.usual?[{key:`usual`,label:n(`pace.usual`),kind:`line`,color:s.muted,width:1.5}]:[],...x?.lastMonth?[{key:`last`,label:n(`pace.lastMonth`),kind:`line`,color:s.muted,width:1,dashed:!0}]:[],{key:`now`,label:n(`pace.thisMonth`),kind:`line`,color:s.accent,width:2}],w=x?.usual&&x.usual.toDate>0?x.usual.toDate:x?.lastMonth&&x.lastMonth.toDate>0?x.lastMonth.toDate:null,T=x&&w?(x.spent-w)/w*100:null,E=x?{from:`${x.month}-01`,to:x.asOf}:{};return(0,h.jsx)(u,{title:_,titleHref:`#/transactions`,menu:t,loading:b,error:y?.message,children:x&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,h.jsx)(a,{filter:E,className:`text-2xl font-semibold tracking-tight`,children:(0,h.jsx)(o,{amount:x.spent})}),T!==null&&(0,h.jsxs)(`span`,{className:`flex items-center gap-1 text-sm text-muted-foreground`,children:[(0,h.jsx)(p,{pct:T}),x.usual?n(`pace.vsUsual`):n(`pace.vsLast`)]})]}),(0,h.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n(`pace.estimate`),` `,(0,h.jsx)(o,{amount:x.estimate,mode:`short`,className:`font-medium text-foreground`})]}),(0,h.jsx)(l,{legend:C.map(e=>({label:e.label,color:e.color,dashed:e.dashed})),table:{head:[n(`chart.day`),n(`pace.thisMonth`),...x.usual?[n(`pace.usual`)]:[],...x.usual?.low?.length?[n(`pace.low`),n(`pace.high`)]:[],...x.lastMonth?[n(`pace.lastMonth`)]:[]],rows:S.map(e=>[e.day,e.now===null?``:d(e.now,g),...x.usual?[d(e.usual??0,g)]:[],...x.usual?.low?.length?[d(e.low??0,g),d(e.high??0,g)]:[],...x.lastMonth?[d(e.last??0,g)]:[]])},children:(0,h.jsx)(c,{data:S,xKey:`day`,specs:C,xTicks:[1,8,15,22,x.daysInMonth]})})]})})}export{g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{F as e,I as t,L as n,R as r,z as i}from"./index-DYyIpxqK.js";import{L as a,T as o}from"./queries-C_4ufx4u.js";var s=a();function c({title:a,action:c,children:l,className:u}){return(0,s.jsxs)(e,{className:o(`min-w-0`,u),children:[(0,s.jsxs)(r,{children:[(0,s.jsx)(i,{children:(0,s.jsx)(`h2`,{children:a})}),c&&(0,s.jsx)(t,{children:c})]}),(0,s.jsx)(n,{className:`flex flex-col gap-3`,children:l})]})}export{c as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,D as t,O as n,S as r,it as i,tt as a,y as o}from"./index-DYyIpxqK.js";import{B as s,I as c,L as l,u,w as d}from"./queries-C_4ufx4u.js";import{t as f}from"./button-Cj0k8AtB.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./dialog-BIbLA-XP.js";import{t as y}from"./Field-OkPhoYM1.js";var b=s(c(),1),x=l();function S({query:s,title:c,onClose:l}){let{t:S}=d(),C=u().data,[w,T]=(0,b.useState)(c.slice(0,80)),[E,D]=(0,b.useState)(!1),[O,k]=(0,b.useState)(null),[A,j]=(0,b.useState)(!1),M=async()=>{D(!0),k(null);try{let i=C?.dashboard?.widgets??[],a=o(i,{type:`chart`,...w.trim()?{title:w.trim()}:{},query:e(s),chart:r(s)},n.chart.size);await t([...i,a]),j(!0)}catch(e){k(S(`pin.error`,{message:e.message}))}D(!1)};return(0,x.jsx)(v,{open:!0,onOpenChange:e=>!e&&l(),children:(0,x.jsxs)(h,{children:[(0,x.jsxs)(p,{children:[(0,x.jsx)(g,{children:S(A?`pin.done`:`pin.title`)}),(0,x.jsx)(_,{children:S(A?`pin.doneHint`:`pin.description`)})]}),A?(0,x.jsxs)(m,{children:[(0,x.jsx)(f,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,onClick:l,children:S(`pin.close`)}),(0,x.jsx)(f,{asChild:!0,className:`min-h-11 md:min-h-8`,children:(0,x.jsxs)(`a`,{href:`#/`,onClick:l,children:[(0,x.jsx)(a,{}),S(`pin.openHome`)]})})]}):(0,x.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),M()},children:[(0,x.jsx)(y,{label:S(`pin.titleLabel`),children:e=>(0,x.jsx)(i,{id:e,className:`min-h-11 md:min-h-8`,maxLength:80,value:w,onChange:e=>T(e.target.value)})}),O&&(0,x.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:O}),(0,x.jsxs)(m,{children:[(0,x.jsx)(f,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,disabled:E,onClick:l,children:S(`common.cancel`)}),(0,x.jsx)(f,{type:`submit`,className:`min-h-11 md:min-h-8`,disabled:E,children:S(E?`pin.saving`:`pin.save`)})]})]})]})})}export{S as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e,I as t,L as n,T as r,p as i,u as a,w as o}from"./queries-C_4ufx4u.js";import{A as s,W as c,n as l,r as u,s as d,t as f}from"./index-DYyIpxqK.js";import{t as p}from"./DrillLink-pa6s17Xu.js";import{t as m}from"./Money-DCMKf898.js";import{t as h}from"./Panel-CXjnsEN0.js";var g=e(t(),1),_=n(),v=30;function y({value:e,max:t,label:n}){let r=t>0?Math.min(1,e/t):0;return(0,_.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,_.jsx)(`div`,{className:`h-2 rounded-full bg-[var(--chart-1)]`,style:{width:`${Math.max(r?2:0,r*100)}%`}})})}function b({d:e,overdue:t}){let{t:n,lang:i}=o();return(0,_.jsxs)(`li`,{className:`flex min-h-12 items-center gap-3 py-1.5`,children:[(0,_.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,_.jsx)(p,{filter:{plan:e.plan},className:`truncate text-sm font-medium`,children:e.name}),(0,_.jsx)(`span`,{className:r(`text-xs`,t?`font-medium text-critical`:`text-muted-foreground`),children:t?n(`upcoming.overdue`,{date:l(e.date)}):d(e.date,i,{weekday:`short`,day:`2-digit`,month:`2-digit`})})]}),(0,_.jsx)(m,{amount:e.amount,mode:`short`,className:`shrink-0 text-sm font-medium`}),t&&(0,_.jsx)(s,{prompt:n(`ask.plan`,{name:e.name})})]})}function x({p:e}){let{t}=o(),n=e.overdue.length>0,r=null;return n?r=(0,_.jsx)(`span`,{className:`font-medium text-critical`,children:t(`plans.lateCount`,{n:e.overdue.length})}):e.next&&(r=(0,_.jsx)(`span`,{children:t(`plans.next`,{date:l(e.next)})})),(0,_.jsxs)(`li`,{className:`flex flex-col gap-1 py-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,_.jsx)(p,{filter:{plan:e.plan},className:`min-w-0 truncate text-sm font-medium`,children:e.name}),(0,_.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.paidCount,`/`,e.count??`–`]})]}),e.count!==null&&(0,_.jsx)(y,{value:e.paidCount,max:e.count,label:e.name}),(0,_.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-xs text-muted-foreground`,children:[(0,_.jsxs)(`span`,{children:[t(`plans.perPayment`),` `,(0,_.jsx)(m,{amount:e.perPayment,mode:`short`}),e.leftAmount!==null&&(0,_.jsxs)(_.Fragment,{children:[` · `,t(`cards.left`),` `,(0,_.jsx)(m,{amount:e.leftAmount,mode:`short`})]})]}),r]})]})}function S(){let{t:e,lang:t}=o(),n=a().data?.today??new Date().toISOString().slice(0,10),{data:d,error:p,isLoading:y}=i(v),S=(0,g.useMemo)(()=>{let e=d?.due??[],t=e.filter(e=>e.overdue||e.date<n).sort((e,t)=>e.date.localeCompare(t.date)),r=e.filter(e=>!t.includes(e)&&e.date<=f(n,29)).sort((e,t)=>e.date.localeCompare(t.date)),i=new Map;for(let e of r)i.set(e.date,(i.get(e.date)??0)+e.amount);let a=Array.from({length:v},(e,t)=>{let r=f(n,t);return{date:r,amount:i.get(r)??0}}),o=Array.from({length:5},(e,t)=>({start:f(n,t*7),amount:0}));for(let e of r)o[Math.min(4,Math.floor(u(n,e.date)/7))].amount+=e.amount;let s=(d?.status??[]).filter(e=>!e.finished),c=e=>(e.overdue.length?`0`:`1`)+(e.next??`9999`);return{overdue:t,upcoming:r,days:a,weeks:o,counted:s.filter(e=>e.count!==null).sort((e,t)=>c(e).localeCompare(c(t))),open:s.filter(e=>e.count===null).sort((e,t)=>c(e).localeCompare(c(t))),total:r.reduce((e,t)=>e+t.amount,0),overdueTotal:t.reduce((e,t)=>e+t.amount,0)}},[d,n]),C=Math.max(1,...S.days.map(e=>e.amount)),w=Math.max(1,...S.weeks.map(e=>e.amount));return(0,_.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,_.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,_.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e(`plans.title`)}),d?(0,_.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[e(`upcoming.total`),` `,(0,_.jsx)(m,{amount:S.total,mode:`short`,className:`font-medium text-foreground`}),S.overdue.length>0&&(0,_.jsxs)(_.Fragment,{children:[` · `,(0,_.jsxs)(`span`,{className:`font-medium text-critical`,children:[e(`plans.overdueTotal`,{n:S.overdue.length}),` `,(0,_.jsx)(m,{amount:S.overdueTotal,mode:`short`})]})]})]}):(0,_.jsx)(c,{className:`h-5 w-64`})]}),p?(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`common.error`,{message:p.message})}):y||!d?(0,_.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[(0,_.jsx)(c,{className:`h-28 w-full`}),(0,_.jsx)(c,{className:`h-40 w-full`})]}):d.status.length===0&&d.due.length===0?(0,_.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-lg border border-dashed p-6 text-sm text-muted-foreground`,children:[(0,_.jsx)(`p`,{children:e(`plans.empty`)}),(0,_.jsx)(s,{prompt:e(`ask.addPlan`)})]}):(0,_.jsxs)(_.Fragment,{children:[S.overdue.length>0&&(0,_.jsx)(h,{title:e(`plans.overdue`),className:`ring-critical/30`,children:(0,_.jsx)(`ul`,{className:`flex flex-col divide-y`,children:S.overdue.map(e=>(0,_.jsx)(b,{d:e,overdue:!0},`${e.plan}-${e.date}`))})}),(0,_.jsxs)(h,{title:e(`plans.next30`),children:[(0,_.jsx)(`ol`,{className:`grid grid-cols-5 gap-1.5`,"aria-label":e(`upcoming.weeks`),children:S.weeks.map(e=>(0,_.jsxs)(`li`,{className:`flex flex-col items-center gap-1`,children:[(0,_.jsx)(`span`,{className:`flex h-10 w-full items-end rounded-sm bg-muted`,children:(0,_.jsx)(`span`,{className:`w-full rounded-sm`,style:{height:`${e.amount?Math.max(8,e.amount/w*100):0}%`,background:`var(--chart-1)`}})}),(0,_.jsx)(`span`,{className:`text-[11px] text-muted-foreground tabular-nums`,children:l(e.start)}),(0,_.jsx)(`span`,{className:`text-xs tabular-nums`,children:e.amount?(0,_.jsx)(m,{amount:e.amount,mode:`short`}):`–`})]},e.start))}),(0,_.jsx)(`div`,{className:`-mx-4 overflow-x-auto px-4 pb-1`,children:(0,_.jsx)(`ol`,{className:`flex gap-1`,"aria-label":e(`plans.perDay`),children:S.days.map(e=>(0,_.jsxs)(`li`,{className:`flex w-9 shrink-0 flex-col items-center gap-1`,children:[(0,_.jsx)(`span`,{className:`flex h-12 w-full items-end rounded-sm bg-muted`,children:(0,_.jsx)(`span`,{className:`w-full rounded-sm`,style:{height:`${e.amount?Math.max(10,e.amount/C*100):0}%`,background:`var(--chart-1)`}})}),(0,_.jsx)(`span`,{className:r(`text-[11px] tabular-nums`,e.date===n?`font-semibold text-foreground`:`text-muted-foreground`),children:e.date.slice(8,10)}),(0,_.jsx)(`span`,{className:`h-3 text-[10px] text-muted-foreground tabular-nums`,children:e.amount?(0,_.jsx)(m,{amount:e.amount,mode:`short`}):``})]},e.date))})}),S.upcoming.length===0?(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`upcoming.empty`)}):(0,_.jsx)(`ul`,{className:`flex flex-col divide-y`,children:S.upcoming.map(e=>(0,_.jsx)(b,{d:e},`${e.plan}-${e.date}`))})]}),S.counted.length>0&&(0,_.jsx)(h,{title:e(`plans.progress`),children:(0,_.jsx)(`ul`,{className:`flex flex-col divide-y`,children:S.counted.map(e=>(0,_.jsx)(x,{p:e},e.plan))})}),S.open.length>0&&(0,_.jsx)(h,{title:e(`plans.recurring`),children:(0,_.jsx)(`ul`,{className:`flex flex-col divide-y`,children:S.open.map(e=>(0,_.jsx)(x,{p:e},e.plan))})})]})]})}export{S as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./TxRow-IqjFXpya.js";import{M as n}from"./index-DYyIpxqK.js";import{B as r,I as i,L as a,d as o,g as s,w as c}from"./queries-C_4ufx4u.js";import{n as l}from"./shared-CR-hvb-r.js";var u=r(i(),1),d=a();function f({widget:r,menu:i}){let{t:a}=c(),f=l(r,`widget.recent`),p=Math.min(30,Math.max(3,r.count??8)),{data:m,error:h,isLoading:g}=s({},p),_=o().data,v=(0,u.useMemo)(()=>e(_),[_]),y=m?.pages[0]?.items.slice(0,p)??[];return(0,d.jsx)(n,{title:f,titleHref:`#/transactions`,menu:i,loading:g||!_,error:h?.message,empty:m&&y.length===0?a(`recent.empty`):void 0,children:(0,d.jsx)(`ul`,{className:`-mx-2 flex flex-col`,children:y.map(e=>(0,d.jsx)(`li`,{children:(0,d.jsx)(`a`,{href:`#/transactions?tx=${encodeURIComponent(e.id)}&from=${e.date}&to=${e.date}`,className:`block rounded-lg outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,children:(0,d.jsx)(t,{tx:e,names:v})})},e.id))})})}export{f as default};
|