@burdenoff/microfe-govcitizenhub 2026.720.7 → 2026.730.1

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.
Files changed (155) hide show
  1. package/dist/govcitizenhub/GovCitizenHubRoot.d.ts.map +1 -1
  2. package/dist/govcitizenhub/GovCitizenHubRoot.js +44 -36
  3. package/dist/govcitizenhub/GovCitizenHubRoot.js.map +1 -1
  4. package/dist/govcitizenhub/GovCitizenHubRoutes.d.ts.map +1 -1
  5. package/dist/govcitizenhub/GovCitizenHubRoutes.js +134 -6
  6. package/dist/govcitizenhub/GovCitizenHubRoutes.js.map +1 -1
  7. package/dist/govcitizenhub/components/DocumentUploadField.d.ts +17 -11
  8. package/dist/govcitizenhub/components/DocumentUploadField.d.ts.map +1 -1
  9. package/dist/govcitizenhub/components/DocumentUploadField.js +45 -42
  10. package/dist/govcitizenhub/components/DocumentUploadField.js.map +1 -1
  11. package/dist/govcitizenhub/components/GovCharts.js +127 -51
  12. package/dist/govcitizenhub/components/GovCharts.js.map +1 -1
  13. package/dist/govcitizenhub/hooks/index.d.ts +1 -0
  14. package/dist/govcitizenhub/hooks/index.d.ts.map +1 -1
  15. package/dist/govcitizenhub/hooks/index.js +1 -0
  16. package/dist/govcitizenhub/hooks/useGovApi.d.ts +3 -0
  17. package/dist/govcitizenhub/hooks/useGovApi.d.ts.map +1 -1
  18. package/dist/govcitizenhub/hooks/useGovApi.js +1 -1
  19. package/dist/govcitizenhub/hooks/useGovApi.js.map +1 -1
  20. package/dist/govcitizenhub/hooks/useIntelligenceApi.d.ts +214 -0
  21. package/dist/govcitizenhub/hooks/useIntelligenceApi.d.ts.map +1 -0
  22. package/dist/govcitizenhub/hooks/useIntelligenceApi.js +1140 -0
  23. package/dist/govcitizenhub/hooks/useIntelligenceApi.js.map +1 -0
  24. package/dist/govcitizenhub/index.d.ts +1 -0
  25. package/dist/govcitizenhub/index.d.ts.map +1 -1
  26. package/dist/govcitizenhub/index.js +18 -0
  27. package/dist/govcitizenhub/pages/agencies/AgenciesPage.js +7 -7
  28. package/dist/govcitizenhub/pages/agencies/AgencyFormDialog.js +6 -6
  29. package/dist/govcitizenhub/pages/applications/ApplicationDetailPage.js +16 -16
  30. package/dist/govcitizenhub/pages/applications/ApplicationsPage.js +35 -35
  31. package/dist/govcitizenhub/pages/applications/ApplicationsPage.js.map +1 -1
  32. package/dist/govcitizenhub/pages/applications/NewApplicationPage.js +1 -1
  33. package/dist/govcitizenhub/pages/documents/DocumentsPage.js +5 -5
  34. package/dist/govcitizenhub/pages/grievances/GrievanceDetailPage.js +30 -30
  35. package/dist/govcitizenhub/pages/grievances/GrievanceDetailPage.js.map +1 -1
  36. package/dist/govcitizenhub/pages/grievances/GrievancesPage.js +15 -15
  37. package/dist/govcitizenhub/pages/intelligence/AdminLevelsPage.d.ts +4 -0
  38. package/dist/govcitizenhub/pages/intelligence/AdminLevelsPage.d.ts.map +1 -0
  39. package/dist/govcitizenhub/pages/intelligence/AdminLevelsPage.js +634 -0
  40. package/dist/govcitizenhub/pages/intelligence/AdminLevelsPage.js.map +1 -0
  41. package/dist/govcitizenhub/pages/intelligence/AssetFormDialog.d.ts +20 -0
  42. package/dist/govcitizenhub/pages/intelligence/AssetFormDialog.d.ts.map +1 -0
  43. package/dist/govcitizenhub/pages/intelligence/AssetFormDialog.js +537 -0
  44. package/dist/govcitizenhub/pages/intelligence/AssetFormDialog.js.map +1 -0
  45. package/dist/govcitizenhub/pages/intelligence/AssetImage.d.ts +11 -0
  46. package/dist/govcitizenhub/pages/intelligence/AssetImage.d.ts.map +1 -0
  47. package/dist/govcitizenhub/pages/intelligence/AssetImage.js +25 -0
  48. package/dist/govcitizenhub/pages/intelligence/AssetImage.js.map +1 -0
  49. package/dist/govcitizenhub/pages/intelligence/AssetMapPanel.d.ts +15 -0
  50. package/dist/govcitizenhub/pages/intelligence/AssetMapPanel.d.ts.map +1 -0
  51. package/dist/govcitizenhub/pages/intelligence/AssetMapPanel.js +203 -0
  52. package/dist/govcitizenhub/pages/intelligence/AssetMapPanel.js.map +1 -0
  53. package/dist/govcitizenhub/pages/intelligence/BenchmarkPage.d.ts +4 -0
  54. package/dist/govcitizenhub/pages/intelligence/BenchmarkPage.d.ts.map +1 -0
  55. package/dist/govcitizenhub/pages/intelligence/BenchmarkPage.js +497 -0
  56. package/dist/govcitizenhub/pages/intelligence/BenchmarkPage.js.map +1 -0
  57. package/dist/govcitizenhub/pages/intelligence/BudgetPage.d.ts +4 -0
  58. package/dist/govcitizenhub/pages/intelligence/BudgetPage.d.ts.map +1 -0
  59. package/dist/govcitizenhub/pages/intelligence/BudgetPage.js +1084 -0
  60. package/dist/govcitizenhub/pages/intelligence/BudgetPage.js.map +1 -0
  61. package/dist/govcitizenhub/pages/intelligence/ConsultationFormDialog.d.ts +13 -0
  62. package/dist/govcitizenhub/pages/intelligence/ConsultationFormDialog.d.ts.map +1 -0
  63. package/dist/govcitizenhub/pages/intelligence/ConsultationFormDialog.js +581 -0
  64. package/dist/govcitizenhub/pages/intelligence/ConsultationFormDialog.js.map +1 -0
  65. package/dist/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.d.ts +11 -0
  66. package/dist/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.d.ts.map +1 -0
  67. package/dist/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.js +429 -0
  68. package/dist/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.js.map +1 -0
  69. package/dist/govcitizenhub/pages/intelligence/ConsultationResultsPanel.d.ts +8 -0
  70. package/dist/govcitizenhub/pages/intelligence/ConsultationResultsPanel.d.ts.map +1 -0
  71. package/dist/govcitizenhub/pages/intelligence/ConsultationResultsPanel.js +235 -0
  72. package/dist/govcitizenhub/pages/intelligence/ConsultationResultsPanel.js.map +1 -0
  73. package/dist/govcitizenhub/pages/intelligence/ConsultationsPage.d.ts +4 -0
  74. package/dist/govcitizenhub/pages/intelligence/ConsultationsPage.d.ts.map +1 -0
  75. package/dist/govcitizenhub/pages/intelligence/ConsultationsPage.js +534 -0
  76. package/dist/govcitizenhub/pages/intelligence/ConsultationsPage.js.map +1 -0
  77. package/dist/govcitizenhub/pages/intelligence/CorrectionsPage.d.ts +4 -0
  78. package/dist/govcitizenhub/pages/intelligence/CorrectionsPage.d.ts.map +1 -0
  79. package/dist/govcitizenhub/pages/intelligence/CorrectionsPage.js +723 -0
  80. package/dist/govcitizenhub/pages/intelligence/CorrectionsPage.js.map +1 -0
  81. package/dist/govcitizenhub/pages/intelligence/ElectionsPage.d.ts +5 -0
  82. package/dist/govcitizenhub/pages/intelligence/ElectionsPage.d.ts.map +1 -0
  83. package/dist/govcitizenhub/pages/intelligence/ElectionsPage.js +1029 -0
  84. package/dist/govcitizenhub/pages/intelligence/ElectionsPage.js.map +1 -0
  85. package/dist/govcitizenhub/pages/intelligence/GovernancePage.d.ts +5 -0
  86. package/dist/govcitizenhub/pages/intelligence/GovernancePage.d.ts.map +1 -0
  87. package/dist/govcitizenhub/pages/intelligence/GovernancePage.js +1545 -0
  88. package/dist/govcitizenhub/pages/intelligence/GovernancePage.js.map +1 -0
  89. package/dist/govcitizenhub/pages/intelligence/IndicatorCatalogPage.d.ts +4 -0
  90. package/dist/govcitizenhub/pages/intelligence/IndicatorCatalogPage.d.ts.map +1 -0
  91. package/dist/govcitizenhub/pages/intelligence/IndicatorCatalogPage.js +960 -0
  92. package/dist/govcitizenhub/pages/intelligence/IndicatorCatalogPage.js.map +1 -0
  93. package/dist/govcitizenhub/pages/intelligence/IndicatorsPage.d.ts +13 -0
  94. package/dist/govcitizenhub/pages/intelligence/IndicatorsPage.d.ts.map +1 -0
  95. package/dist/govcitizenhub/pages/intelligence/IndicatorsPage.js +927 -0
  96. package/dist/govcitizenhub/pages/intelligence/IndicatorsPage.js.map +1 -0
  97. package/dist/govcitizenhub/pages/intelligence/JurisdictionDirectoryPage.d.ts +4 -0
  98. package/dist/govcitizenhub/pages/intelligence/JurisdictionDirectoryPage.d.ts.map +1 -0
  99. package/dist/govcitizenhub/pages/intelligence/JurisdictionDirectoryPage.js +620 -0
  100. package/dist/govcitizenhub/pages/intelligence/JurisdictionDirectoryPage.js.map +1 -0
  101. package/dist/govcitizenhub/pages/intelligence/JurisdictionLayout.d.ts +20 -0
  102. package/dist/govcitizenhub/pages/intelligence/JurisdictionLayout.d.ts.map +1 -0
  103. package/dist/govcitizenhub/pages/intelligence/JurisdictionLayout.js +183 -0
  104. package/dist/govcitizenhub/pages/intelligence/JurisdictionLayout.js.map +1 -0
  105. package/dist/govcitizenhub/pages/intelligence/JurisdictionProfilePage.d.ts +4 -0
  106. package/dist/govcitizenhub/pages/intelligence/JurisdictionProfilePage.d.ts.map +1 -0
  107. package/dist/govcitizenhub/pages/intelligence/JurisdictionProfilePage.js +629 -0
  108. package/dist/govcitizenhub/pages/intelligence/JurisdictionProfilePage.js.map +1 -0
  109. package/dist/govcitizenhub/pages/intelligence/OpenDataPage.d.ts +4 -0
  110. package/dist/govcitizenhub/pages/intelligence/OpenDataPage.d.ts.map +1 -0
  111. package/dist/govcitizenhub/pages/intelligence/OpenDataPage.js +1124 -0
  112. package/dist/govcitizenhub/pages/intelligence/OpenDataPage.js.map +1 -0
  113. package/dist/govcitizenhub/pages/intelligence/ProjectsPage.d.ts +4 -0
  114. package/dist/govcitizenhub/pages/intelligence/ProjectsPage.d.ts.map +1 -0
  115. package/dist/govcitizenhub/pages/intelligence/ProjectsPage.js +1518 -0
  116. package/dist/govcitizenhub/pages/intelligence/ProjectsPage.js.map +1 -0
  117. package/dist/govcitizenhub/pages/intelligence/PublicAssetsPage.d.ts +4 -0
  118. package/dist/govcitizenhub/pages/intelligence/PublicAssetsPage.d.ts.map +1 -0
  119. package/dist/govcitizenhub/pages/intelligence/PublicAssetsPage.js +577 -0
  120. package/dist/govcitizenhub/pages/intelligence/PublicAssetsPage.js.map +1 -0
  121. package/dist/govcitizenhub/pages/intelligence/ServicePerformancePage.d.ts +4 -0
  122. package/dist/govcitizenhub/pages/intelligence/ServicePerformancePage.d.ts.map +1 -0
  123. package/dist/govcitizenhub/pages/intelligence/ServicePerformancePage.js +534 -0
  124. package/dist/govcitizenhub/pages/intelligence/ServicePerformancePage.js.map +1 -0
  125. package/dist/govcitizenhub/pages/intelligence/TimelinePage.d.ts +5 -0
  126. package/dist/govcitizenhub/pages/intelligence/TimelinePage.d.ts.map +1 -0
  127. package/dist/govcitizenhub/pages/intelligence/TimelinePage.js +538 -0
  128. package/dist/govcitizenhub/pages/intelligence/TimelinePage.js.map +1 -0
  129. package/dist/govcitizenhub/pages/intelligence/consultationQuestions.d.ts +53 -0
  130. package/dist/govcitizenhub/pages/intelligence/consultationQuestions.d.ts.map +1 -0
  131. package/dist/govcitizenhub/pages/intelligence/consultationQuestions.js +138 -0
  132. package/dist/govcitizenhub/pages/intelligence/consultationQuestions.js.map +1 -0
  133. package/dist/govcitizenhub/pages/intelligence/index.d.ts +27 -0
  134. package/dist/govcitizenhub/pages/intelligence/index.d.ts.map +1 -0
  135. package/dist/govcitizenhub/pages/intelligence/index.js +17 -0
  136. package/dist/govcitizenhub/pages/payments/PaymentsPage.js +11 -11
  137. package/dist/govcitizenhub/pages/payments/PaymentsPage.js.map +1 -1
  138. package/dist/govcitizenhub/pages/permits/PermitsPage.js +6 -6
  139. package/dist/govcitizenhub/pages/services/ServiceDetailPage.js +8 -8
  140. package/dist/govcitizenhub/pages/services/ServiceFormDialog.js +98 -98
  141. package/dist/govcitizenhub/pages/services/ServiceFormDialog.js.map +1 -1
  142. package/dist/govcitizenhub/types/index.d.ts +1 -0
  143. package/dist/govcitizenhub/types/index.d.ts.map +1 -1
  144. package/dist/govcitizenhub/types/intelligence.d.ts +1559 -0
  145. package/dist/govcitizenhub/types/intelligence.d.ts.map +1 -0
  146. package/dist/govcitizenhub/types/intelligence.js +125 -0
  147. package/dist/govcitizenhub/types/intelligence.js.map +1 -0
  148. package/dist/index.js +19 -2
  149. package/dist/node_modules/recharts/es6/chart/BarChart.js +24 -0
  150. package/dist/node_modules/recharts/es6/chart/BarChart.js.map +1 -0
  151. package/dist/utils/pageContext.d.ts +1 -0
  152. package/dist/utils/pageContext.d.ts.map +1 -1
  153. package/dist/utils/pageContext.js +44 -17
  154. package/dist/utils/pageContext.js.map +1 -1
  155. package/package.json +1 -1
@@ -0,0 +1,1084 @@
1
+ import { cn as e } from "../../utils/cn.js";
2
+ import { MetricsCard as t } from "../../components/MetricsCard.js";
3
+ import { CHART_SERIES_COLORS as n, ChartLegend as r, GovBarChart as i, GovDonutChart as a } from "../../components/GovCharts.js";
4
+ import { formatDate as o, formatEnumLabel as s, formatNumber as c } from "../../utils/formatters.js";
5
+ import { StatusBadge as l } from "../../components/StatusBadge.js";
6
+ import { EmptyState as u } from "../../components/EmptyState.js";
7
+ import { useGovBudget as d, useGovBudgetExecution as f, useGovBudgets as p, useGovCreateBudget as ee, useGovDeleteBudgetLine as te, useGovPublishBudget as m, useGovUpdateBudget as h, useGovUpsertBudgetLines as ne } from "../../hooks/useIntelligenceApi.js";
8
+ import { uploadFileToFiles as g, useFileUrl as re } from "../../hooks/useFiles.js";
9
+ import "../../hooks/index.js";
10
+ import { ErrorView as _, LoadingView as ie } from "../../components/StateViews.js";
11
+ import { FilterTabs as ae } from "../../components/FilterTabs.js";
12
+ import { SectionCard as v } from "../../components/SectionCard.js";
13
+ import { describeError as y, notify as b } from "../../lib/toast.js";
14
+ import { GOV_BUDGET_CATEGORY_LABELS as x, GOV_EXPENSE_CATEGORIES as oe, GOV_REVENUE_CATEGORIES as S, GOV_VERIFICATION_LABELS as se } from "../../types/intelligence.js";
15
+ import { JurisdictionLayout as ce, VerificationChip as C } from "./JurisdictionLayout.js";
16
+ import { ConfirmDialog as w } from "../../components/ConfirmDialog.js";
17
+ import { useMemo as T, useRef as E, useState as D } from "react";
18
+ import { BarChart3 as le, Coins as O, Download as k, ExternalLink as A, FileText as ue, Gauge as j, ListPlus as M, Pencil as N, Plus as P, Send as F, Trash2 as I, Users as de, Wallet as fe } from "lucide-react";
19
+ import { useParams as pe } from "react-router-dom";
20
+ import { Fragment as L, jsx as R, jsxs as z } from "react/jsx-runtime";
21
+ import { Button as B, GlassCard as V, Input as H, Label as U, ResponsiveDialog as W, ResponsiveDialogContent as G, ResponsiveDialogDescription as me, ResponsiveDialogFooter as he, ResponsiveDialogHeader as K, ResponsiveDialogTitle as q, Select as J, SelectContent as Y, SelectItem as X, SelectTrigger as Z, SelectValue as ge, Skeleton as _e, Textarea as ve } from "@burdenoff/fe-libs/ui";
22
+ //#region src/govcitizenhub/pages/intelligence/BudgetPage.tsx
23
+ var ye = "/GovCitizenHub/Budgets", be = 100, xe = [
24
+ "DRAFT",
25
+ "PROPOSED",
26
+ "APPROVED",
27
+ "REVISED",
28
+ "CLOSED"
29
+ ], Se = [
30
+ "UNVERIFIED",
31
+ "OFFICIAL",
32
+ "COMMUNITY_VERIFIED",
33
+ "DISPUTED"
34
+ ], Ce = [{
35
+ value: "PLANNED",
36
+ label: "Planned"
37
+ }, {
38
+ value: "ACTUAL",
39
+ label: "Actual"
40
+ }];
41
+ function Q(e, t, n = 0) {
42
+ if (e == null || Number.isNaN(e)) return "—";
43
+ try {
44
+ return new Intl.NumberFormat(void 0, {
45
+ style: "currency",
46
+ currency: t,
47
+ maximumFractionDigits: n
48
+ }).format(e);
49
+ } catch {
50
+ return `${new Intl.NumberFormat(void 0, { maximumFractionDigits: n }).format(e)} ${t}`.trim();
51
+ }
52
+ }
53
+ function we(e, t) {
54
+ if (e == null || Number.isNaN(e)) return "—";
55
+ try {
56
+ return new Intl.NumberFormat(void 0, {
57
+ style: "currency",
58
+ currency: t,
59
+ notation: "compact",
60
+ maximumFractionDigits: 1
61
+ }).format(e);
62
+ } catch {
63
+ return `${new Intl.NumberFormat(void 0, {
64
+ notation: "compact",
65
+ maximumFractionDigits: 1
66
+ }).format(e)} ${t}`.trim();
67
+ }
68
+ }
69
+ var Te = (e, t = 1) => e == null || Number.isNaN(e) ? "—" : `${e.toFixed(t)}%`;
70
+ function Ee(e, t) {
71
+ return t == null || t === 0 ? "text-text-secondary" : (e === "REVENUE" ? t > 0 : t < 0) ? "text-status-success-text" : "text-status-error-text";
72
+ }
73
+ var De = (e) => e === "REVENUE" ? S : oe, Oe = (e) => e ? new Date(e).toISOString().slice(0, 10) : "";
74
+ function $(e) {
75
+ if (!e) return null;
76
+ let t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
77
+ return Number.isNaN(t.getTime()) ? null : t.toISOString();
78
+ }
79
+ function ke(e) {
80
+ let t = e.trim();
81
+ if (!t) return null;
82
+ let n = Number(t);
83
+ return Number.isFinite(n) ? n : null;
84
+ }
85
+ var Ae = () => {
86
+ let { jurisdictionId: o } = pe(), [s, c] = D(null), [l, ee] = D("PLANNED"), [te, h] = D(null), [ne, g] = D(!1), [oe, S] = D(!1), [se, C] = D(!1), E = p({ jurisdictionId: o }, { limit: be }), k = m(), A = T(() => [...E.data?.items ?? []].sort((e, t) => new Date(t.periodStart).getTime() - new Date(e.periodStart).getTime()), [E.data]), N = s && A.some((e) => e.id === s) ? s : A[0]?.id ?? void 0, F = d(N), I = f(N), V = F.data ?? A.find((e) => e.id === N) ?? null, H = I.data ?? null, U = V?.currencyCode ?? H?.currencyCode ?? "", W = re(V?.documentFileId), G = T(() => F.data?.lines ?? [], [F.data]), me = T(() => je(G, "REVENUE"), [G]), he = T(() => je(G, "EXPENSE"), [G]), K = T(() => (H?.byCategory ?? []).filter((e) => e.kind === "EXPENSE").map((e) => ({
87
+ name: x[e.category],
88
+ value: l === "PLANNED" ? e.planned : e.actual ?? 0
89
+ })), [H, l]), q = T(() => (H?.byCategory ?? []).filter((e) => e.kind === "REVENUE").map((e, t) => ({
90
+ name: x[e.category],
91
+ value: e.planned,
92
+ color: n[t % n.length]
93
+ })), [H]), J = () => {
94
+ h(null), g(!0);
95
+ }, Y = () => {
96
+ V && (h(V), g(!0));
97
+ }, X = async () => {
98
+ if (V) try {
99
+ await k.mutateAsync(V.id), b.success("Budget published", `${V.fiscalYear} is now citizen-visible.`);
100
+ } catch (e) {
101
+ b.error("Could not publish the budget", y(e));
102
+ }
103
+ };
104
+ return /* @__PURE__ */ z(ce, {
105
+ description: "Published revenue, expenditure and execution for each fiscal year.",
106
+ actions: /* @__PURE__ */ z(B, {
107
+ onClick: J,
108
+ children: [/* @__PURE__ */ R(P, {
109
+ className: "mr-1.5 h-4 w-4",
110
+ "aria-hidden": "true"
111
+ }), " New budget"]
112
+ }),
113
+ children: [
114
+ E.isLoading ? /* @__PURE__ */ R(ie, { label: "Loading budgets…" }) : E.isError ? /* @__PURE__ */ R(_, {
115
+ message: "We couldn't load budgets for this jurisdiction.",
116
+ onRetry: () => {
117
+ E.refetch();
118
+ }
119
+ }) : A.length === 0 ? /* @__PURE__ */ R(u, {
120
+ illustration: "empty-data",
121
+ title: "No budgets published yet",
122
+ description: "Publish a fiscal year to open this region's revenue and expenditure to the public.",
123
+ action: /* @__PURE__ */ z(B, {
124
+ onClick: J,
125
+ children: [/* @__PURE__ */ R(P, {
126
+ className: "mr-1.5 h-4 w-4",
127
+ "aria-hidden": "true"
128
+ }), " New budget"]
129
+ })
130
+ }) : /* @__PURE__ */ z("div", {
131
+ className: "space-y-4",
132
+ children: [/* @__PURE__ */ R("div", {
133
+ className: "flex gap-2 overflow-x-auto pb-1",
134
+ children: A.map((t) => {
135
+ let n = t.id === N;
136
+ return /* @__PURE__ */ R("button", {
137
+ type: "button",
138
+ "aria-pressed": n,
139
+ onClick: () => c(t.id),
140
+ className: e("shrink-0 rounded-full border px-3.5 py-1.5 text-sm font-medium transition-colors", n ? "border-transparent bg-action-primary-bg text-action-primary-text" : "border-border-seam bg-bg-surface text-text-secondary hover:bg-bg-sunken hover:text-text-primary"),
141
+ children: t.fiscalYear
142
+ }, t.id);
143
+ })
144
+ }), V && /* @__PURE__ */ z(L, { children: [
145
+ /* @__PURE__ */ R(Me, {
146
+ budget: V,
147
+ documentUrl: W.data ?? null,
148
+ documentPending: W.isLoading,
149
+ onEdit: Y,
150
+ onEditLines: () => S(!0),
151
+ onPublish: () => C(!0),
152
+ publishBusy: k.isPending
153
+ }),
154
+ I.isLoading ? /* @__PURE__ */ R("div", {
155
+ className: "grid gap-4 sm:grid-cols-2 xl:grid-cols-4",
156
+ children: Array.from({ length: 4 }, (e, t) => /* @__PURE__ */ R(_e, { className: "h-32 w-full rounded-card" }, t))
157
+ }) : I.isError ? /* @__PURE__ */ R(_, {
158
+ message: "We couldn't load this budget's execution figures.",
159
+ onRetry: () => {
160
+ I.refetch();
161
+ }
162
+ }) : H ? /* @__PURE__ */ z("div", {
163
+ className: "grid gap-4 sm:grid-cols-2 xl:grid-cols-4",
164
+ children: [
165
+ /* @__PURE__ */ R(t, {
166
+ icon: /* @__PURE__ */ R(O, { className: "h-5 w-5" }),
167
+ accent: "success",
168
+ featured: !0,
169
+ value: Q(H.actualRevenue ?? H.plannedRevenue, H.currencyCode),
170
+ label: "Total revenue",
171
+ sublabel: H.actualRevenue == null ? "Planned — no actuals recorded yet" : `Actual · planned ${Q(H.plannedRevenue, H.currencyCode)}`
172
+ }),
173
+ /* @__PURE__ */ R(t, {
174
+ icon: /* @__PURE__ */ R(fe, { className: "h-5 w-5" }),
175
+ accent: "accent",
176
+ value: Q(H.actualExpense ?? H.plannedExpense, H.currencyCode),
177
+ label: "Total expenditure",
178
+ sublabel: H.actualExpense == null ? "Planned — no actuals recorded yet" : `Actual · planned ${Q(H.plannedExpense, H.currencyCode)}`
179
+ }),
180
+ /* @__PURE__ */ R(t, {
181
+ icon: /* @__PURE__ */ R(j, { className: "h-5 w-5" }),
182
+ accent: H.executionPercent != null && H.executionPercent > 100 ? "error" : "warning",
183
+ value: Te(H.executionPercent),
184
+ label: "Budget execution",
185
+ sublabel: H.executionPercent == null ? "Awaiting reported expenditure" : "Actual expenditure against plan"
186
+ }),
187
+ /* @__PURE__ */ R(t, {
188
+ icon: /* @__PURE__ */ R(de, { className: "h-5 w-5" }),
189
+ value: Q(H.perCapitaActualExpense ?? H.perCapitaExpense, H.currencyCode, 2),
190
+ label: "Per-capita expenditure",
191
+ sublabel: H.perCapitaActualExpense == null ? H.perCapitaExpense == null ? "No population snapshot published" : "Planned, per head at publication" : "Actual, per head at publication"
192
+ })
193
+ ]
194
+ }) : /* @__PURE__ */ R(v, {
195
+ title: "Budget execution",
196
+ icon: /* @__PURE__ */ R(j, {}),
197
+ children: /* @__PURE__ */ R("p", {
198
+ className: "text-sm text-text-secondary",
199
+ children: "No execution figures have been computed for this budget yet."
200
+ })
201
+ }),
202
+ /* @__PURE__ */ z("div", {
203
+ className: "grid gap-4 lg:grid-cols-5",
204
+ children: [/* @__PURE__ */ z(v, {
205
+ className: "lg:col-span-3",
206
+ title: "Expenditure by category",
207
+ icon: /* @__PURE__ */ R(le, {}),
208
+ actions: /* @__PURE__ */ R(ae, {
209
+ options: Ce,
210
+ value: l,
211
+ onChange: ee
212
+ }),
213
+ children: [/* @__PURE__ */ R(i, {
214
+ data: K,
215
+ emptyLabel: l === "ACTUAL" ? "No actual expenditure reported yet" : "No expenditure lines published yet"
216
+ }), K.length > 0 && /* @__PURE__ */ z("p", {
217
+ className: "mt-2 text-xs text-text-muted",
218
+ children: [
219
+ l === "PLANNED" ? "Planned" : "Actual",
220
+ " expenditure in",
221
+ " ",
222
+ U || "the budget currency",
223
+ ", by category."
224
+ ]
225
+ })]
226
+ }), /* @__PURE__ */ z(v, {
227
+ className: "lg:col-span-2",
228
+ title: "Revenue sources",
229
+ icon: /* @__PURE__ */ R(O, {}),
230
+ children: [/* @__PURE__ */ R(a, {
231
+ data: q,
232
+ centerLabel: "Planned revenue",
233
+ centerValue: H ? we(H.plannedRevenue, H.currencyCode) : "",
234
+ emptyLabel: "No revenue lines published yet"
235
+ }), q.length > 0 && /* @__PURE__ */ R(r, {
236
+ className: "mt-4",
237
+ items: q.map((e) => ({
238
+ label: e.name,
239
+ color: e.color ?? n[0],
240
+ value: Q(e.value, U)
241
+ }))
242
+ })]
243
+ })]
244
+ }),
245
+ /* @__PURE__ */ R(v, {
246
+ title: "Budget lines",
247
+ icon: /* @__PURE__ */ R(ue, {}),
248
+ flush: !0,
249
+ actions: /* @__PURE__ */ z(B, {
250
+ size: "sm",
251
+ variant: "outline",
252
+ onClick: () => S(!0),
253
+ children: [/* @__PURE__ */ R(M, {
254
+ className: "mr-1.5 h-4 w-4",
255
+ "aria-hidden": "true"
256
+ }), " Edit lines"]
257
+ }),
258
+ children: F.isLoading ? /* @__PURE__ */ R("div", {
259
+ className: "space-y-3 p-5",
260
+ children: Array.from({ length: 5 }, (e, t) => /* @__PURE__ */ R(_e, { className: "h-10 w-full rounded-card" }, t))
261
+ }) : F.isError ? /* @__PURE__ */ R("div", {
262
+ className: "p-5",
263
+ children: /* @__PURE__ */ R(_, {
264
+ message: "We couldn't load this budget's lines.",
265
+ onRetry: () => {
266
+ F.refetch();
267
+ }
268
+ })
269
+ }) : G.length === 0 ? /* @__PURE__ */ R("div", {
270
+ className: "p-5",
271
+ children: /* @__PURE__ */ R(u, {
272
+ illustration: "empty-data",
273
+ title: "No budget lines published yet",
274
+ description: "Add revenue sources and expenditure heads so citizens can see where the money comes from and where it goes.",
275
+ action: /* @__PURE__ */ z(B, {
276
+ onClick: () => S(!0),
277
+ children: [/* @__PURE__ */ R(M, {
278
+ className: "mr-1.5 h-4 w-4",
279
+ "aria-hidden": "true"
280
+ }), " Add budget lines"]
281
+ })
282
+ })
283
+ }) : /* @__PURE__ */ R("div", {
284
+ className: "overflow-x-auto",
285
+ children: /* @__PURE__ */ z("table", {
286
+ className: "w-full min-w-[56rem] text-left text-sm",
287
+ children: [
288
+ /* @__PURE__ */ R("thead", { children: /* @__PURE__ */ z("tr", {
289
+ className: "border-b border-border-seam text-xs uppercase tracking-wide text-text-muted",
290
+ children: [
291
+ /* @__PURE__ */ R("th", {
292
+ className: "px-5 py-3 font-medium",
293
+ children: "Category"
294
+ }),
295
+ /* @__PURE__ */ R("th", {
296
+ className: "px-5 py-3 font-medium",
297
+ children: "Department"
298
+ }),
299
+ /* @__PURE__ */ R("th", {
300
+ className: "px-5 py-3 text-right font-medium",
301
+ children: "Planned"
302
+ }),
303
+ /* @__PURE__ */ R("th", {
304
+ className: "px-5 py-3 text-right font-medium",
305
+ children: "Actual"
306
+ }),
307
+ /* @__PURE__ */ R("th", {
308
+ className: "px-5 py-3 text-right font-medium",
309
+ children: "Variance"
310
+ }),
311
+ /* @__PURE__ */ R("th", {
312
+ className: "px-5 py-3 text-right font-medium",
313
+ children: "Variance %"
314
+ }),
315
+ /* @__PURE__ */ R("th", {
316
+ className: "px-5 py-3 text-right font-medium",
317
+ children: "Share %"
318
+ })
319
+ ]
320
+ }) }),
321
+ /* @__PURE__ */ R(Ne, {
322
+ kind: "REVENUE",
323
+ heading: "Revenue",
324
+ lines: me,
325
+ currencyCode: U
326
+ }),
327
+ /* @__PURE__ */ R(Ne, {
328
+ kind: "EXPENSE",
329
+ heading: "Expenditure",
330
+ lines: he,
331
+ currencyCode: U
332
+ })
333
+ ]
334
+ })
335
+ })
336
+ }),
337
+ /* @__PURE__ */ R(Pe, { budget: V })
338
+ ] })]
339
+ }),
340
+ ne && o && /* @__PURE__ */ R(Fe, {
341
+ jurisdictionId: o,
342
+ budget: te,
343
+ onOpenChange: g,
344
+ onSaved: (e) => c(e.id)
345
+ }),
346
+ oe && F.data && /* @__PURE__ */ R(Re, {
347
+ budget: F.data,
348
+ onOpenChange: S
349
+ }),
350
+ V && /* @__PURE__ */ R(w, {
351
+ open: se,
352
+ onOpenChange: C,
353
+ title: `Publish the ${V.fiscalYear} budget?`,
354
+ description: "Publishing makes this budget and every line in it visible to citizens.",
355
+ confirmLabel: "Publish budget",
356
+ onConfirm: async () => {
357
+ await X();
358
+ }
359
+ })
360
+ ]
361
+ });
362
+ };
363
+ function je(e, t) {
364
+ return e.filter((e) => e.kind === t).sort((e, t) => e.displayOrder - t.displayOrder || e.label.localeCompare(t.label));
365
+ }
366
+ var Me = ({ budget: e, documentUrl: t, documentPending: n, onEdit: r, onEditLines: i, onPublish: a, publishBusy: s }) => /* @__PURE__ */ R(V, {
367
+ treatment: "plain",
368
+ className: "border-border-seam p-5",
369
+ children: /* @__PURE__ */ z("div", {
370
+ className: "flex flex-wrap items-start justify-between gap-4",
371
+ children: [/* @__PURE__ */ z("div", {
372
+ className: "min-w-0",
373
+ children: [
374
+ /* @__PURE__ */ z("div", {
375
+ className: "flex flex-wrap items-center gap-2.5",
376
+ children: [
377
+ /* @__PURE__ */ z("h2", {
378
+ className: "text-lg font-semibold text-text-primary",
379
+ children: ["Fiscal year ", e.fiscalYear]
380
+ }),
381
+ /* @__PURE__ */ R(l, { status: e.status }),
382
+ /* @__PURE__ */ R(C, { status: e.verification }),
383
+ /* @__PURE__ */ R("span", {
384
+ className: "rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs font-medium text-text-secondary",
385
+ children: e.currencyCode
386
+ })
387
+ ]
388
+ }),
389
+ /* @__PURE__ */ z("p", {
390
+ className: "mt-1 text-sm text-text-secondary",
391
+ children: [
392
+ o(e.periodStart),
393
+ " – ",
394
+ o(e.periodEnd),
395
+ e.approvedOn ? ` · Approved ${o(e.approvedOn)}` : "",
396
+ e.publishedAt ? ` · Published ${o(e.publishedAt)}` : " · Not published yet"
397
+ ]
398
+ }),
399
+ e.populationAtPublication != null && /* @__PURE__ */ z("p", {
400
+ className: "mt-0.5 text-xs text-text-muted",
401
+ children: ["Population at publication: ", c(e.populationAtPublication)]
402
+ }),
403
+ e.summary && /* @__PURE__ */ R("p", {
404
+ className: "mt-3 max-w-3xl text-sm text-text-secondary",
405
+ children: e.summary
406
+ })
407
+ ]
408
+ }), /* @__PURE__ */ z("div", {
409
+ className: "flex flex-wrap items-center gap-2",
410
+ children: [
411
+ e.documentFileId && (t ? /* @__PURE__ */ z("a", {
412
+ href: t,
413
+ target: "_blank",
414
+ rel: "noreferrer",
415
+ className: "inline-flex items-center gap-1.5 rounded-button border border-border-seam px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken",
416
+ children: [/* @__PURE__ */ R(k, {
417
+ className: "h-4 w-4",
418
+ "aria-hidden": "true"
419
+ }), " Budget document"]
420
+ }) : /* @__PURE__ */ R("span", {
421
+ className: "text-xs text-text-muted",
422
+ children: n ? "Preparing document link…" : "Budget document unavailable"
423
+ })),
424
+ /* @__PURE__ */ z(B, {
425
+ size: "sm",
426
+ variant: "outline",
427
+ onClick: r,
428
+ children: [/* @__PURE__ */ R(N, {
429
+ className: "mr-1.5 h-4 w-4",
430
+ "aria-hidden": "true"
431
+ }), " Edit"]
432
+ }),
433
+ /* @__PURE__ */ z(B, {
434
+ size: "sm",
435
+ variant: "outline",
436
+ onClick: i,
437
+ children: [/* @__PURE__ */ R(M, {
438
+ className: "mr-1.5 h-4 w-4",
439
+ "aria-hidden": "true"
440
+ }), " Lines"]
441
+ }),
442
+ !e.publishedAt && /* @__PURE__ */ z(B, {
443
+ size: "sm",
444
+ onClick: a,
445
+ disabled: s,
446
+ children: [/* @__PURE__ */ R(F, {
447
+ className: "mr-1.5 h-4 w-4",
448
+ "aria-hidden": "true"
449
+ }), " Publish"]
450
+ })
451
+ ]
452
+ })]
453
+ })
454
+ }), Ne = ({ kind: t, heading: n, lines: r, currencyCode: i }) => {
455
+ if (r.length === 0) return null;
456
+ let a = r.reduce((e, t) => e + t.plannedAmount, 0), o = r.some((e) => e.actualAmount != null) ? r.reduce((e, t) => e + (t.actualAmount ?? 0), 0) : null;
457
+ return /* @__PURE__ */ z("tbody", {
458
+ className: "divide-y divide-border-subtle",
459
+ children: [
460
+ /* @__PURE__ */ R("tr", {
461
+ className: "bg-bg-sunken",
462
+ children: /* @__PURE__ */ R("th", {
463
+ colSpan: 7,
464
+ scope: "colgroup",
465
+ className: "px-5 py-2 text-left text-xs font-semibold uppercase tracking-wide text-text-secondary",
466
+ children: n
467
+ })
468
+ }),
469
+ r.map((n) => {
470
+ let r = a > 0 ? n.plannedAmount / a * 100 : null;
471
+ return /* @__PURE__ */ z("tr", {
472
+ className: "transition-colors hover:bg-bg-sunken",
473
+ children: [
474
+ /* @__PURE__ */ z("td", {
475
+ className: "px-5 py-3",
476
+ children: [/* @__PURE__ */ R("p", {
477
+ className: "font-medium text-text-primary",
478
+ children: x[n.category]
479
+ }), /* @__PURE__ */ z("p", {
480
+ className: "text-xs text-text-muted",
481
+ children: [n.label, n.functionCode ? ` · ${n.functionCode}` : ""]
482
+ })]
483
+ }),
484
+ /* @__PURE__ */ R("td", {
485
+ className: "px-5 py-3 text-text-secondary",
486
+ children: n.department || "—"
487
+ }),
488
+ /* @__PURE__ */ R("td", {
489
+ className: "px-5 py-3 text-right tabular-nums text-text-primary whitespace-nowrap",
490
+ children: Q(n.plannedAmount, i)
491
+ }),
492
+ /* @__PURE__ */ R("td", {
493
+ className: "px-5 py-3 text-right tabular-nums text-text-primary whitespace-nowrap",
494
+ children: Q(n.actualAmount, i)
495
+ }),
496
+ /* @__PURE__ */ R("td", {
497
+ className: e("px-5 py-3 text-right tabular-nums whitespace-nowrap", Ee(t, n.variance)),
498
+ children: Q(n.variance, i)
499
+ }),
500
+ /* @__PURE__ */ R("td", {
501
+ className: e("px-5 py-3 text-right tabular-nums whitespace-nowrap", Ee(t, n.variance)),
502
+ children: Te(n.variancePercent)
503
+ }),
504
+ /* @__PURE__ */ R("td", {
505
+ className: "px-5 py-3 text-right tabular-nums text-text-secondary whitespace-nowrap",
506
+ children: Te(r)
507
+ })
508
+ ]
509
+ }, n.id);
510
+ }),
511
+ /* @__PURE__ */ z("tr", {
512
+ className: "border-t border-border-seam font-semibold",
513
+ children: [
514
+ /* @__PURE__ */ z("td", {
515
+ className: "px-5 py-3 text-text-primary",
516
+ colSpan: 2,
517
+ children: [n, " total"]
518
+ }),
519
+ /* @__PURE__ */ R("td", {
520
+ className: "px-5 py-3 text-right tabular-nums text-text-primary whitespace-nowrap",
521
+ children: Q(a, i)
522
+ }),
523
+ /* @__PURE__ */ R("td", {
524
+ className: "px-5 py-3 text-right tabular-nums text-text-primary whitespace-nowrap",
525
+ children: Q(o, i)
526
+ }),
527
+ /* @__PURE__ */ R("td", {
528
+ className: "px-5 py-3",
529
+ colSpan: 2
530
+ }),
531
+ /* @__PURE__ */ R("td", {
532
+ className: "px-5 py-3 text-right tabular-nums text-text-secondary",
533
+ children: a > 0 ? "100.0%" : "—"
534
+ })
535
+ ]
536
+ })
537
+ ]
538
+ });
539
+ }, Pe = ({ budget: e }) => /* @__PURE__ */ z("div", {
540
+ className: "flex flex-wrap items-center gap-x-3 gap-y-2 rounded-card border border-border-seam bg-bg-sunken px-4 py-3 text-xs text-text-muted",
541
+ children: [
542
+ /* @__PURE__ */ R(C, { status: e.verification }),
543
+ /* @__PURE__ */ z("span", { children: [se[e.verification], " figures"] }),
544
+ e.sourceName && /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R("span", {
545
+ "aria-hidden": "true",
546
+ children: "·"
547
+ }), /* @__PURE__ */ z("span", { children: ["Source: ", e.sourceName] })] }),
548
+ e.sourceUrl && /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R("span", {
549
+ "aria-hidden": "true",
550
+ children: "·"
551
+ }), /* @__PURE__ */ z("a", {
552
+ href: e.sourceUrl,
553
+ target: "_blank",
554
+ rel: "noreferrer",
555
+ className: "inline-flex items-center gap-1 text-text-secondary underline underline-offset-2 hover:text-text-primary",
556
+ children: ["Source document ", /* @__PURE__ */ R(A, {
557
+ className: "size-3",
558
+ "aria-hidden": "true"
559
+ })]
560
+ })] }),
561
+ /* @__PURE__ */ R("span", {
562
+ "aria-hidden": "true",
563
+ children: "·"
564
+ }),
565
+ /* @__PURE__ */ z("span", { children: ["Last updated ", o(e.updatedAt)] })
566
+ ]
567
+ }), Fe = ({ jurisdictionId: e, budget: t, onOpenChange: n, onSaved: r }) => {
568
+ let i = ee(), a = h(), [o, c] = D(t?.fiscalYear ?? ""), [l, u] = D(Oe(t?.periodStart)), [d, f] = D(Oe(t?.periodEnd)), [p, te] = D(t?.currencyCode ?? ""), [m, ne] = D(t?.status ?? "DRAFT"), [re, _] = D(t?.verification ?? "UNVERIFIED"), [ie, ae] = D(t?.populationAtPublication == null ? "" : String(t.populationAtPublication)), [v, x] = D(Oe(t?.approvedOn)), [oe, S] = D(t?.summary ?? ""), [ce, C] = D(t?.sourceName ?? ""), [w, T] = D(t?.sourceUrl ?? ""), [E, le] = D(t?.documentFileId ?? null), [O, k] = D(""), [A, ue] = D(!1), [j, M] = D(null), N = i.isPending || a.isPending || A, P = o.trim().length > 0 && p.trim().length === 3 && !!$(l) && !!$(d), F = async (e) => {
569
+ ue(!0), M(null);
570
+ try {
571
+ let t = await g(e, ye);
572
+ le(t.id), k(t.name), b.success("Budget document uploaded", t.name);
573
+ } catch (e) {
574
+ M(y(e));
575
+ } finally {
576
+ ue(!1);
577
+ }
578
+ }, I = async () => {
579
+ let s = $(l), c = $(d);
580
+ if (!(!s || !c)) {
581
+ M(null);
582
+ try {
583
+ let l = {
584
+ fiscalYear: o.trim(),
585
+ periodStart: s,
586
+ periodEnd: c,
587
+ currencyCode: p.trim().toUpperCase(),
588
+ status: m,
589
+ verification: re,
590
+ populationAtPublication: ke(ie),
591
+ approvedOn: $(v),
592
+ summary: oe.trim() || null,
593
+ documentFileId: E,
594
+ sourceName: ce.trim() || null,
595
+ sourceUrl: w.trim() || null
596
+ }, u = t ? await a.mutateAsync({
597
+ id: t.id,
598
+ input: l
599
+ }) : await i.mutateAsync({
600
+ jurisdictionId: e,
601
+ ...l
602
+ });
603
+ b.success(t ? "Budget updated" : "Budget created", u.fiscalYear), r(u), n(!1);
604
+ } catch (e) {
605
+ M(y(e));
606
+ }
607
+ }
608
+ };
609
+ return /* @__PURE__ */ R(W, {
610
+ open: !0,
611
+ onOpenChange: (e) => N ? void 0 : n(e),
612
+ children: /* @__PURE__ */ z(G, {
613
+ className: "sm:max-w-2xl",
614
+ children: [
615
+ /* @__PURE__ */ z(K, { children: [/* @__PURE__ */ R(q, { children: t ? "Edit budget" : "New budget" }), /* @__PURE__ */ R(me, { children: "Publish one fiscal period. Amounts are recorded on the budget lines and totalled by the service." })] }),
616
+ /* @__PURE__ */ z("div", {
617
+ className: "grid max-h-[60vh] gap-4 overflow-y-auto py-2 sm:grid-cols-2",
618
+ children: [
619
+ /* @__PURE__ */ z("div", {
620
+ className: "grid gap-1.5",
621
+ children: [/* @__PURE__ */ R(U, {
622
+ htmlFor: "budget-fy",
623
+ children: "Fiscal year"
624
+ }), /* @__PURE__ */ R(H, {
625
+ id: "budget-fy",
626
+ value: o,
627
+ onChange: (e) => c(e.target.value),
628
+ placeholder: "2026 or 2026-27"
629
+ })]
630
+ }),
631
+ /* @__PURE__ */ z("div", {
632
+ className: "grid gap-1.5",
633
+ children: [/* @__PURE__ */ R(U, {
634
+ htmlFor: "budget-currency",
635
+ children: "Currency (ISO 4217)"
636
+ }), /* @__PURE__ */ R(H, {
637
+ id: "budget-currency",
638
+ value: p,
639
+ maxLength: 3,
640
+ onChange: (e) => te(e.target.value.toUpperCase()),
641
+ placeholder: "e.g. EUR"
642
+ })]
643
+ }),
644
+ /* @__PURE__ */ z("div", {
645
+ className: "grid gap-1.5",
646
+ children: [/* @__PURE__ */ R(U, {
647
+ htmlFor: "budget-start",
648
+ children: "Period start"
649
+ }), /* @__PURE__ */ R(H, {
650
+ id: "budget-start",
651
+ type: "date",
652
+ value: l,
653
+ onChange: (e) => u(e.target.value)
654
+ })]
655
+ }),
656
+ /* @__PURE__ */ z("div", {
657
+ className: "grid gap-1.5",
658
+ children: [/* @__PURE__ */ R(U, {
659
+ htmlFor: "budget-end",
660
+ children: "Period end"
661
+ }), /* @__PURE__ */ R(H, {
662
+ id: "budget-end",
663
+ type: "date",
664
+ value: d,
665
+ onChange: (e) => f(e.target.value)
666
+ })]
667
+ }),
668
+ /* @__PURE__ */ z("div", {
669
+ className: "grid gap-1.5",
670
+ children: [/* @__PURE__ */ R(U, {
671
+ htmlFor: "budget-status",
672
+ children: "Status"
673
+ }), /* @__PURE__ */ z(J, {
674
+ value: m,
675
+ onValueChange: (e) => ne(e),
676
+ children: [/* @__PURE__ */ R(Z, {
677
+ id: "budget-status",
678
+ children: /* @__PURE__ */ R(ge, {})
679
+ }), /* @__PURE__ */ R(Y, { children: xe.map((e) => /* @__PURE__ */ R(X, {
680
+ value: e,
681
+ children: s(e)
682
+ }, e)) })]
683
+ })]
684
+ }),
685
+ /* @__PURE__ */ z("div", {
686
+ className: "grid gap-1.5",
687
+ children: [/* @__PURE__ */ R(U, {
688
+ htmlFor: "budget-verification",
689
+ children: "Provenance"
690
+ }), /* @__PURE__ */ z(J, {
691
+ value: re,
692
+ onValueChange: (e) => _(e),
693
+ children: [/* @__PURE__ */ R(Z, {
694
+ id: "budget-verification",
695
+ children: /* @__PURE__ */ R(ge, {})
696
+ }), /* @__PURE__ */ R(Y, { children: Se.map((e) => /* @__PURE__ */ R(X, {
697
+ value: e,
698
+ children: se[e]
699
+ }, e)) })]
700
+ })]
701
+ }),
702
+ /* @__PURE__ */ z("div", {
703
+ className: "grid gap-1.5",
704
+ children: [/* @__PURE__ */ R(U, {
705
+ htmlFor: "budget-population",
706
+ children: "Population at publication"
707
+ }), /* @__PURE__ */ R(H, {
708
+ id: "budget-population",
709
+ type: "number",
710
+ min: "0",
711
+ value: ie,
712
+ onChange: (e) => ae(e.target.value),
713
+ placeholder: "Leave blank if not published"
714
+ })]
715
+ }),
716
+ /* @__PURE__ */ z("div", {
717
+ className: "grid gap-1.5",
718
+ children: [/* @__PURE__ */ R(U, {
719
+ htmlFor: "budget-approved",
720
+ children: "Approved on"
721
+ }), /* @__PURE__ */ R(H, {
722
+ id: "budget-approved",
723
+ type: "date",
724
+ value: v,
725
+ onChange: (e) => x(e.target.value)
726
+ })]
727
+ }),
728
+ /* @__PURE__ */ z("div", {
729
+ className: "grid gap-1.5 sm:col-span-2",
730
+ children: [/* @__PURE__ */ R(U, {
731
+ htmlFor: "budget-summary",
732
+ children: "Summary"
733
+ }), /* @__PURE__ */ R(ve, {
734
+ id: "budget-summary",
735
+ rows: 3,
736
+ value: oe,
737
+ onChange: (e) => S(e.target.value),
738
+ placeholder: "What this budget prioritises…"
739
+ })]
740
+ }),
741
+ /* @__PURE__ */ z("div", {
742
+ className: "grid gap-1.5",
743
+ children: [/* @__PURE__ */ R(U, {
744
+ htmlFor: "budget-source-name",
745
+ children: "Source name"
746
+ }), /* @__PURE__ */ R(H, {
747
+ id: "budget-source-name",
748
+ value: ce,
749
+ onChange: (e) => C(e.target.value),
750
+ placeholder: "Publishing body"
751
+ })]
752
+ }),
753
+ /* @__PURE__ */ z("div", {
754
+ className: "grid gap-1.5",
755
+ children: [/* @__PURE__ */ R(U, {
756
+ htmlFor: "budget-source-url",
757
+ children: "Source URL"
758
+ }), /* @__PURE__ */ R(H, {
759
+ id: "budget-source-url",
760
+ value: w,
761
+ onChange: (e) => T(e.target.value),
762
+ placeholder: "https://"
763
+ })]
764
+ }),
765
+ /* @__PURE__ */ z("div", {
766
+ className: "grid gap-1.5 sm:col-span-2",
767
+ children: [
768
+ /* @__PURE__ */ R(U, {
769
+ htmlFor: "budget-document",
770
+ children: "Budget document"
771
+ }),
772
+ /* @__PURE__ */ R(H, {
773
+ id: "budget-document",
774
+ type: "file",
775
+ disabled: A,
776
+ onChange: (e) => {
777
+ let t = e.target.files?.[0];
778
+ t && F(t);
779
+ }
780
+ }),
781
+ /* @__PURE__ */ R("p", {
782
+ className: "text-xs text-text-muted",
783
+ children: A ? "Uploading…" : O ? `Attached: ${O}` : E ? "A document is already attached." : "Optional — the published budget PDF or spreadsheet."
784
+ })
785
+ ]
786
+ })
787
+ ]
788
+ }),
789
+ j && /* @__PURE__ */ R("p", {
790
+ className: "text-sm text-status-error-text",
791
+ children: j
792
+ }),
793
+ /* @__PURE__ */ z(he, { children: [/* @__PURE__ */ R(B, {
794
+ variant: "outline",
795
+ onClick: () => n(!1),
796
+ disabled: N,
797
+ children: "Cancel"
798
+ }), /* @__PURE__ */ R(B, {
799
+ onClick: () => {
800
+ I();
801
+ },
802
+ disabled: N || !P,
803
+ children: t ? "Save budget" : "Create budget"
804
+ })] })
805
+ ]
806
+ })
807
+ });
808
+ }, Ie = (e) => ({
809
+ key: e.id,
810
+ id: e.id,
811
+ kind: e.kind,
812
+ category: e.category,
813
+ label: e.label,
814
+ department: e.department ?? "",
815
+ functionCode: e.functionCode ?? "",
816
+ plannedAmount: String(e.plannedAmount),
817
+ actualAmount: e.actualAmount == null ? "" : String(e.actualAmount)
818
+ }), Le = (e, t) => ({
819
+ key: t,
820
+ id: null,
821
+ kind: e,
822
+ category: De(e)[0],
823
+ label: "",
824
+ department: "",
825
+ functionCode: "",
826
+ plannedAmount: "",
827
+ actualAmount: ""
828
+ }), Re = ({ budget: e, onOpenChange: t }) => {
829
+ let n = ne(), r = te(), [i, a] = D(() => [...e.lines ?? []].sort((e, t) => e.displayOrder - t.displayOrder || e.label.localeCompare(t.label)).map(Ie)), [o, s] = D(null), [c, l] = D(null), u = E(0), d = n.isPending || r.isPending, f = i.some((e) => !e.label.trim()), p = (e, t) => {
830
+ a((n) => n.map((n) => n.key === e ? {
831
+ ...n,
832
+ ...t
833
+ } : n));
834
+ }, ee = (e, t) => {
835
+ p(e, {
836
+ kind: t,
837
+ category: De(t)[0]
838
+ });
839
+ }, m = (e) => {
840
+ u.current += 1, a((t) => [...t, Le(e, `new-${u.current}`)]);
841
+ }, h = async (t) => {
842
+ if (!t.id) {
843
+ a((e) => e.filter((e) => e.key !== t.key));
844
+ return;
845
+ }
846
+ try {
847
+ await r.mutateAsync({
848
+ id: t.id,
849
+ budgetId: e.id
850
+ }), a((e) => e.filter((e) => e.key !== t.key)), b.success("Budget line removed", t.label);
851
+ } catch (e) {
852
+ b.error("Could not remove the line", y(e));
853
+ }
854
+ }, g = async () => {
855
+ l(null);
856
+ let r = i.map((e, t) => ({
857
+ ...e.id ? { id: e.id } : {},
858
+ kind: e.kind,
859
+ category: e.category,
860
+ label: e.label.trim(),
861
+ department: e.department.trim() || null,
862
+ functionCode: e.functionCode.trim() || null,
863
+ plannedAmount: ke(e.plannedAmount) ?? 0,
864
+ actualAmount: ke(e.actualAmount),
865
+ displayOrder: t
866
+ }));
867
+ try {
868
+ await n.mutateAsync({
869
+ budgetId: e.id,
870
+ lines: r
871
+ }), b.success("Budget lines saved", `${r.length} lines on ${e.fiscalYear}.`), t(!1);
872
+ } catch (e) {
873
+ l(y(e));
874
+ }
875
+ };
876
+ return /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R(W, {
877
+ open: !0,
878
+ onOpenChange: (e) => d ? void 0 : t(e),
879
+ children: /* @__PURE__ */ z(G, {
880
+ className: "sm:max-w-5xl",
881
+ children: [
882
+ /* @__PURE__ */ z(K, { children: [/* @__PURE__ */ z(q, { children: ["Budget lines · ", e.fiscalYear] }), /* @__PURE__ */ R(me, { children: "Revenue categories and expenditure categories are separate sets — switching a line's side resets its category to a valid option. Totals are re-derived by the service on save." })] }),
883
+ /* @__PURE__ */ R("div", {
884
+ className: "max-h-[55vh] overflow-y-auto",
885
+ children: /* @__PURE__ */ R("div", {
886
+ className: "overflow-x-auto",
887
+ children: /* @__PURE__ */ z("table", {
888
+ className: "w-full min-w-[60rem] text-left text-sm",
889
+ children: [/* @__PURE__ */ R("thead", { children: /* @__PURE__ */ z("tr", {
890
+ className: "border-b border-border-seam text-xs uppercase tracking-wide text-text-muted",
891
+ children: [
892
+ /* @__PURE__ */ R("th", {
893
+ className: "px-2 py-2 font-medium",
894
+ children: "Side"
895
+ }),
896
+ /* @__PURE__ */ R("th", {
897
+ className: "px-2 py-2 font-medium",
898
+ children: "Category"
899
+ }),
900
+ /* @__PURE__ */ R("th", {
901
+ className: "px-2 py-2 font-medium",
902
+ children: "Label"
903
+ }),
904
+ /* @__PURE__ */ R("th", {
905
+ className: "px-2 py-2 font-medium",
906
+ children: "Department"
907
+ }),
908
+ /* @__PURE__ */ R("th", {
909
+ className: "px-2 py-2 font-medium",
910
+ children: "Planned"
911
+ }),
912
+ /* @__PURE__ */ R("th", {
913
+ className: "px-2 py-2 font-medium",
914
+ children: "Actual"
915
+ }),
916
+ /* @__PURE__ */ R("th", {
917
+ className: "px-2 py-2 text-right font-medium",
918
+ children: "Remove"
919
+ })
920
+ ]
921
+ }) }), /* @__PURE__ */ R("tbody", {
922
+ className: "divide-y divide-border-subtle",
923
+ children: i.length === 0 ? /* @__PURE__ */ R("tr", { children: /* @__PURE__ */ R("td", {
924
+ colSpan: 7,
925
+ className: "px-2 py-6 text-center text-sm text-text-secondary",
926
+ children: "No budget lines yet. Add a revenue source or an expenditure head below."
927
+ }) }) : i.map((e) => /* @__PURE__ */ z("tr", { children: [
928
+ /* @__PURE__ */ R("td", {
929
+ className: "px-2 py-2",
930
+ children: /* @__PURE__ */ z(J, {
931
+ value: e.kind,
932
+ onValueChange: (t) => ee(e.key, t),
933
+ children: [/* @__PURE__ */ R(Z, {
934
+ className: "w-32",
935
+ "aria-label": `Ledger side for ${e.label || "new line"}`,
936
+ children: /* @__PURE__ */ R(ge, {})
937
+ }), /* @__PURE__ */ z(Y, { children: [/* @__PURE__ */ R(X, {
938
+ value: "REVENUE",
939
+ children: "Revenue"
940
+ }), /* @__PURE__ */ R(X, {
941
+ value: "EXPENSE",
942
+ children: "Expenditure"
943
+ })] })]
944
+ })
945
+ }),
946
+ /* @__PURE__ */ R("td", {
947
+ className: "px-2 py-2",
948
+ children: /* @__PURE__ */ z(J, {
949
+ value: e.category,
950
+ onValueChange: (t) => p(e.key, { category: t }),
951
+ children: [/* @__PURE__ */ R(Z, {
952
+ className: "w-56",
953
+ "aria-label": `Category for ${e.label || "new line"}`,
954
+ children: /* @__PURE__ */ R(ge, {})
955
+ }), /* @__PURE__ */ R(Y, { children: De(e.kind).map((e) => /* @__PURE__ */ R(X, {
956
+ value: e,
957
+ children: x[e]
958
+ }, e)) })]
959
+ })
960
+ }),
961
+ /* @__PURE__ */ R("td", {
962
+ className: "px-2 py-2",
963
+ children: /* @__PURE__ */ R(H, {
964
+ value: e.label,
965
+ onChange: (t) => p(e.key, { label: t.target.value }),
966
+ placeholder: "Line label",
967
+ "aria-label": "Line label",
968
+ className: "w-48"
969
+ })
970
+ }),
971
+ /* @__PURE__ */ R("td", {
972
+ className: "px-2 py-2",
973
+ children: /* @__PURE__ */ R(H, {
974
+ value: e.department,
975
+ onChange: (t) => p(e.key, { department: t.target.value }),
976
+ placeholder: "Optional",
977
+ "aria-label": "Department",
978
+ className: "w-40"
979
+ })
980
+ }),
981
+ /* @__PURE__ */ R("td", {
982
+ className: "px-2 py-2",
983
+ children: /* @__PURE__ */ R(H, {
984
+ type: "number",
985
+ step: "0.01",
986
+ value: e.plannedAmount,
987
+ onChange: (t) => p(e.key, { plannedAmount: t.target.value }),
988
+ "aria-label": "Planned amount",
989
+ className: "w-32"
990
+ })
991
+ }),
992
+ /* @__PURE__ */ R("td", {
993
+ className: "px-2 py-2",
994
+ children: /* @__PURE__ */ R(H, {
995
+ type: "number",
996
+ step: "0.01",
997
+ value: e.actualAmount,
998
+ onChange: (t) => p(e.key, { actualAmount: t.target.value }),
999
+ placeholder: "Not reported",
1000
+ "aria-label": "Actual amount",
1001
+ className: "w-32"
1002
+ })
1003
+ }),
1004
+ /* @__PURE__ */ R("td", {
1005
+ className: "px-2 py-2 text-right",
1006
+ children: /* @__PURE__ */ R(B, {
1007
+ size: "sm",
1008
+ variant: "outline",
1009
+ disabled: d,
1010
+ onClick: () => {
1011
+ e.id ? s(e) : h(e);
1012
+ },
1013
+ "aria-label": `Remove ${e.label || "line"}`,
1014
+ children: /* @__PURE__ */ R(I, {
1015
+ className: "h-4 w-4",
1016
+ "aria-hidden": "true"
1017
+ })
1018
+ })
1019
+ })
1020
+ ] }, e.key))
1021
+ })]
1022
+ })
1023
+ })
1024
+ }),
1025
+ /* @__PURE__ */ z("div", {
1026
+ className: "flex flex-wrap gap-2 pt-2",
1027
+ children: [/* @__PURE__ */ z(B, {
1028
+ size: "sm",
1029
+ variant: "outline",
1030
+ onClick: () => m("REVENUE"),
1031
+ disabled: d,
1032
+ children: [/* @__PURE__ */ R(P, {
1033
+ className: "mr-1.5 h-4 w-4",
1034
+ "aria-hidden": "true"
1035
+ }), " Revenue line"]
1036
+ }), /* @__PURE__ */ z(B, {
1037
+ size: "sm",
1038
+ variant: "outline",
1039
+ onClick: () => m("EXPENSE"),
1040
+ disabled: d,
1041
+ children: [/* @__PURE__ */ R(P, {
1042
+ className: "mr-1.5 h-4 w-4",
1043
+ "aria-hidden": "true"
1044
+ }), " Expenditure line"]
1045
+ })]
1046
+ }),
1047
+ f && /* @__PURE__ */ R("p", {
1048
+ className: "text-sm text-status-warning-text",
1049
+ children: "Every line needs a label."
1050
+ }),
1051
+ c && /* @__PURE__ */ R("p", {
1052
+ className: "text-sm text-status-error-text",
1053
+ children: c
1054
+ }),
1055
+ /* @__PURE__ */ z(he, { children: [/* @__PURE__ */ R(B, {
1056
+ variant: "outline",
1057
+ onClick: () => t(!1),
1058
+ disabled: d,
1059
+ children: "Cancel"
1060
+ }), /* @__PURE__ */ R(B, {
1061
+ onClick: () => {
1062
+ g();
1063
+ },
1064
+ disabled: d || f || i.length === 0,
1065
+ children: "Save lines"
1066
+ })] })
1067
+ ]
1068
+ })
1069
+ }), o && /* @__PURE__ */ R(w, {
1070
+ open: !0,
1071
+ onOpenChange: (e) => e ? void 0 : s(null),
1072
+ title: `Remove ${o.label || "this line"}?`,
1073
+ description: "The line is deleted from the published budget and the totals are re-derived.",
1074
+ confirmLabel: "Remove line",
1075
+ destructive: !0,
1076
+ onConfirm: async () => {
1077
+ await h(o), s(null);
1078
+ }
1079
+ })] });
1080
+ };
1081
+ //#endregion
1082
+ export { Ae as BudgetPage };
1083
+
1084
+ //# sourceMappingURL=BudgetPage.js.map