@burdenoff/microfe-timecampus 2026.1031.12 → 2026.1031.14

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 (29) hide show
  1. package/dist/generated/wspace-operations.d.ts +110 -0
  2. package/dist/generated/wspace-operations.d.ts.map +1 -1
  3. package/dist/generated/wspace-operations.js +1330 -1274
  4. package/dist/generated/wspace-operations.js.map +1 -1
  5. package/dist/generated/wspace-types.d.ts +574 -13
  6. package/dist/generated/wspace-types.d.ts.map +1 -1
  7. package/dist/generated/wspace-types.js +10 -8
  8. package/dist/generated/wspace-types.js.map +1 -1
  9. package/dist/index.js +7 -7
  10. package/dist/timecampus/TimeCampusRoutes.d.ts.map +1 -1
  11. package/dist/timecampus/TimeCampusRoutes.js +4 -0
  12. package/dist/timecampus/TimeCampusRoutes.js.map +1 -1
  13. package/dist/timecampus/index.js +7 -7
  14. package/dist/timecampus/pages/dashboard/ReportsPage.d.ts.map +1 -1
  15. package/dist/timecampus/pages/dashboard/ReportsPage.js +143 -129
  16. package/dist/timecampus/pages/dashboard/ReportsPage.js.map +1 -1
  17. package/dist/timecampus/pages/dashboard/ServerReportExports.d.ts +6 -0
  18. package/dist/timecampus/pages/dashboard/ServerReportExports.d.ts.map +1 -0
  19. package/dist/timecampus/pages/dashboard/ServerReportExports.js +257 -0
  20. package/dist/timecampus/pages/dashboard/ServerReportExports.js.map +1 -0
  21. package/dist/timecampus/pages/dashboard/reportTemplates.d.ts +33 -0
  22. package/dist/timecampus/pages/dashboard/reportTemplates.d.ts.map +1 -0
  23. package/dist/timecampus/pages/dashboard/reportTemplates.js +129 -0
  24. package/dist/timecampus/pages/dashboard/reportTemplates.js.map +1 -0
  25. package/dist/timecampus/pages/mobile/mobileModel.d.ts +1 -1
  26. package/dist/timecampus/pages/mobile/mobileModel.d.ts.map +1 -1
  27. package/dist/timecampus/pages/mobile/mobileModel.js +3 -1
  28. package/dist/timecampus/pages/mobile/mobileModel.js.map +1 -1
  29. package/package.json +1 -1
@@ -0,0 +1,257 @@
1
+ import { useExportTimeCampusEntitiesMutation as e, useTimeCampusExportJobQuery as t } from "../../../generated/wspace-operations.js";
2
+ import { StatusBadge as n } from "../../components/StatusBadge.js";
3
+ import { ProgressMeter as r } from "../../components/charts/ProgressMeter.js";
4
+ import "../../components/index.js";
5
+ import { TimeCampusExportFormat as i } from "../../../generated/wspace-types.js";
6
+ import { REPORT_PERIODS as a, REPORT_TEMPLATES as o, buildReportName as s, exportStatusLabel as c, exportStatusTone as l, findReportTemplate as u, isTerminalExportStatus as d, resolveReportDateRange as f } from "./reportTemplates.js";
7
+ import { useEffect as p, useState as m } from "react";
8
+ import { Download as h, FileDown as g, Loader2 as _ } from "lucide-react";
9
+ import { jsx as v, jsxs as y } from "react/jsx-runtime";
10
+ import { GlassCard as b } from "@burdenoff/fe-libs/ui";
11
+ //#region src/timecampus/pages/dashboard/ServerReportExports.tsx
12
+ var x = 3e3, S = 9e5;
13
+ function C(e) {
14
+ if (!e) return "";
15
+ let t = new Date(e);
16
+ return Number.isNaN(t.getTime()) ? "" : t.toLocaleString();
17
+ }
18
+ function w({ report: e }) {
19
+ let [i, a] = m(d(e.initial.status)), [o, s] = m(!1), [u, f] = m(0), { data: g, error: b, stopPolling: w, startPolling: T, refetch: E } = t({
20
+ variables: { id: e.jobId },
21
+ pollInterval: i || o ? 0 : x,
22
+ fetchPolicy: "network-only"
23
+ }), D = g?.timeCampusExportJob ?? e.initial, O = D.status;
24
+ p(() => {
25
+ (d(O) || g?.timeCampusExportJob === null) && (w(), a(!0), s(!1));
26
+ }, [
27
+ O,
28
+ g,
29
+ w
30
+ ]), p(() => {
31
+ if (i) return;
32
+ let e = window.setTimeout(() => {
33
+ w(), s(!0);
34
+ }, S);
35
+ return () => window.clearTimeout(e);
36
+ }, [
37
+ i,
38
+ u,
39
+ w
40
+ ]);
41
+ let k = () => {
42
+ s(!1), f((e) => e + 1), T(x), E();
43
+ }, A = g !== void 0 && g.timeCampusExportJob === null, j = A ? "warning" : l(O), M = A ? "Unavailable" : c(O), N = !A && !d(O);
44
+ return /* @__PURE__ */ y("li", {
45
+ className: "flex flex-col gap-3 rounded-lg border border-border-subtle bg-bg-surface p-3 sm:flex-row sm:items-center sm:justify-between",
46
+ "data-testid": "report-export-job",
47
+ "data-status": A ? "MISSING" : O,
48
+ children: [/* @__PURE__ */ y("div", {
49
+ className: "min-w-0 flex-1 space-y-1",
50
+ children: [
51
+ /* @__PURE__ */ y("div", {
52
+ className: "flex flex-wrap items-center gap-2",
53
+ children: [
54
+ /* @__PURE__ */ v("p", {
55
+ className: "truncate text-sm font-medium text-text-primary",
56
+ children: e.name
57
+ }),
58
+ /* @__PURE__ */ v(n, {
59
+ variant: j,
60
+ label: M,
61
+ dot: !0
62
+ }),
63
+ /* @__PURE__ */ v("span", {
64
+ className: "text-xs text-text-secondary",
65
+ children: D.format
66
+ })
67
+ ]
68
+ }),
69
+ /* @__PURE__ */ y("p", {
70
+ className: "text-xs text-text-secondary",
71
+ children: [
72
+ "Started ",
73
+ C(D.createdAt),
74
+ D.completedAt ? ` · finished ${C(D.completedAt)}` : ""
75
+ ]
76
+ }),
77
+ N && /* @__PURE__ */ v(r, {
78
+ value: D.progress ?? 0,
79
+ max: 100,
80
+ higherIsWorse: !1,
81
+ label: "Progress",
82
+ format: (e) => `${Math.round(e)}%`,
83
+ size: "sm"
84
+ }),
85
+ O === "FAILED" && /* @__PURE__ */ v("p", {
86
+ className: "text-xs text-status-error-text",
87
+ children: D.errorMessage || "The export failed. Try generating it again."
88
+ }),
89
+ A && /* @__PURE__ */ v("p", {
90
+ className: "text-xs text-text-secondary",
91
+ children: "This export is no longer available."
92
+ }),
93
+ o && !i && /* @__PURE__ */ y("p", {
94
+ className: "text-xs text-text-secondary",
95
+ children: [
96
+ "Still generating. Status checks paused to save requests; the export keeps running on the server.",
97
+ " ",
98
+ /* @__PURE__ */ v("button", {
99
+ type: "button",
100
+ onClick: k,
101
+ className: "font-medium text-text-primary underline underline-offset-2",
102
+ children: "Check again"
103
+ })
104
+ ]
105
+ }),
106
+ b && !A && /* @__PURE__ */ y("p", {
107
+ className: "text-xs text-status-error-text",
108
+ children: ["Could not refresh the export status: ", b.message]
109
+ })
110
+ ]
111
+ }), /* @__PURE__ */ y("div", {
112
+ className: "flex shrink-0 items-center gap-2",
113
+ children: [N && !o && /* @__PURE__ */ v(_, {
114
+ className: "h-4 w-4 text-text-secondary motion-safe:animate-spin",
115
+ "aria-hidden": !0
116
+ }), O === "COMPLETED" && D.downloadUrl && /* @__PURE__ */ y("a", {
117
+ href: D.downloadUrl,
118
+ target: "_blank",
119
+ rel: "noopener noreferrer",
120
+ className: "inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text hover:bg-action-primary-bg/90",
121
+ title: D.downloadExpiresAt ? `Link expires ${C(D.downloadExpiresAt)}` : void 0,
122
+ children: [/* @__PURE__ */ v(h, { className: "h-4 w-4" }), "Download"]
123
+ })]
124
+ })]
125
+ });
126
+ }
127
+ function T() {
128
+ let [t, n] = m("time-entries"), [r, c] = m("30d"), [l, d] = m(i.Csv), [p, h] = m([]), [x, S] = m(null), [C, { loading: T }] = e(), E = u(t), D = async () => {
129
+ S(null);
130
+ let e = s(E, r);
131
+ try {
132
+ let t = (await C({ variables: { input: {
133
+ entityTypes: E.entityTypes,
134
+ format: l,
135
+ includeMetadata: !0,
136
+ name: e,
137
+ ...f(r)
138
+ } } })).data?.exportTimeCampusEntities;
139
+ if (!t) {
140
+ S("The export could not be started. Please try again.");
141
+ return;
142
+ }
143
+ h((n) => [{
144
+ jobId: t.id,
145
+ name: e,
146
+ initial: t
147
+ }, ...n]);
148
+ } catch (e) {
149
+ S(e instanceof Error ? e.message : "The export could not be started. Please try again.");
150
+ }
151
+ }, O = "mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary";
152
+ return /* @__PURE__ */ v("section", {
153
+ "data-testid": "server-report-exports",
154
+ "aria-label": "Generate a full report",
155
+ children: /* @__PURE__ */ y(b, {
156
+ treatment: "glass",
157
+ className: "p-4 sm:p-5",
158
+ children: [
159
+ /* @__PURE__ */ y("div", {
160
+ className: "flex items-start gap-3",
161
+ children: [/* @__PURE__ */ v("div", {
162
+ className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-status-info-bg text-status-info-text",
163
+ children: /* @__PURE__ */ v(g, { className: "h-5 w-5" })
164
+ }), /* @__PURE__ */ y("div", {
165
+ className: "min-w-0",
166
+ children: [/* @__PURE__ */ v("h2", {
167
+ className: "text-sm font-semibold text-text-primary",
168
+ children: "Generate a full report"
169
+ }), /* @__PURE__ */ v("p", {
170
+ className: "mt-1 text-xs text-text-secondary",
171
+ children: "Built on the server from your complete records, not just what this page has loaded. Large reports keep generating in the background; the download appears here when it is ready."
172
+ })]
173
+ })]
174
+ }),
175
+ /* @__PURE__ */ y("div", {
176
+ className: "mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3",
177
+ children: [
178
+ /* @__PURE__ */ y("label", {
179
+ className: "block text-xs font-medium text-text-secondary",
180
+ children: ["Report", /* @__PURE__ */ v("select", {
181
+ value: t,
182
+ onChange: (e) => n(e.target.value),
183
+ className: O,
184
+ "aria-label": "Report template",
185
+ children: o.map((e) => /* @__PURE__ */ v("option", {
186
+ value: e.id,
187
+ children: e.label
188
+ }, e.id))
189
+ })]
190
+ }),
191
+ /* @__PURE__ */ y("label", {
192
+ className: "block text-xs font-medium text-text-secondary",
193
+ children: ["Period", /* @__PURE__ */ v("select", {
194
+ value: r,
195
+ onChange: (e) => c(e.target.value),
196
+ className: O,
197
+ "aria-label": "Report period",
198
+ children: a.map((e) => /* @__PURE__ */ v("option", {
199
+ value: e.id,
200
+ children: e.label
201
+ }, e.id))
202
+ })]
203
+ }),
204
+ /* @__PURE__ */ y("label", {
205
+ className: "block text-xs font-medium text-text-secondary",
206
+ children: ["Format", /* @__PURE__ */ y("select", {
207
+ value: l,
208
+ onChange: (e) => d(e.target.value),
209
+ className: O,
210
+ "aria-label": "Report format",
211
+ children: [/* @__PURE__ */ v("option", {
212
+ value: i.Csv,
213
+ children: "CSV"
214
+ }), /* @__PURE__ */ v("option", {
215
+ value: i.Json,
216
+ children: "JSON"
217
+ })]
218
+ })]
219
+ })
220
+ ]
221
+ }),
222
+ /* @__PURE__ */ v("p", {
223
+ className: "mt-2 text-xs text-text-secondary",
224
+ children: E.description
225
+ }),
226
+ /* @__PURE__ */ y("div", {
227
+ className: "mt-4 flex flex-wrap items-center gap-3",
228
+ children: [/* @__PURE__ */ y("button", {
229
+ type: "button",
230
+ onClick: D,
231
+ disabled: T,
232
+ className: "inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-70",
233
+ children: [T ? /* @__PURE__ */ v(_, { className: "h-4 w-4 motion-safe:animate-spin" }) : /* @__PURE__ */ v(g, { className: "h-4 w-4" }), T ? "Starting…" : "Generate report"]
234
+ }), x && /* @__PURE__ */ v("p", {
235
+ role: "alert",
236
+ className: "text-sm text-status-error-text",
237
+ children: x
238
+ })]
239
+ }),
240
+ p.length > 0 && /* @__PURE__ */ y("div", {
241
+ className: "mt-5 border-t border-border-subtle pt-4",
242
+ children: [/* @__PURE__ */ v("h3", {
243
+ className: "text-xs font-semibold uppercase tracking-wide text-text-secondary",
244
+ children: "Generated this session"
245
+ }), /* @__PURE__ */ v("ul", {
246
+ className: "mt-2 space-y-2",
247
+ children: p.map((e) => /* @__PURE__ */ v(w, { report: e }, e.jobId))
248
+ })]
249
+ })
250
+ ]
251
+ })
252
+ });
253
+ }
254
+ //#endregion
255
+ export { T as ServerReportExports };
256
+
257
+ //# sourceMappingURL=ServerReportExports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServerReportExports.js","names":[],"sources":["../../../../src/timecampus/pages/dashboard/ServerReportExports.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { Download, FileDown, Loader2 } from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport { StatusBadge, ProgressMeter } from \"../../components\";\nimport { TimeCampusExportFormat } from \"@/generated/wspace-types\";\nimport {\n useExportTimeCampusEntitiesMutation,\n useTimeCampusExportJobQuery,\n type TimeCampusExportJobFieldsFragment,\n} from \"@/generated/wspace-operations\";\nimport {\n REPORT_PERIODS,\n REPORT_TEMPLATES,\n buildReportName,\n exportStatusLabel,\n exportStatusTone,\n findReportTemplate,\n isTerminalExportStatus,\n resolveReportDateRange,\n type ReportPeriodId,\n type ReportTemplateId,\n} from \"./reportTemplates\";\n\nconst POLL_INTERVAL_MS = 3000;\n/**\n * Stop polling a job that has not settled after this long, so a stuck job\n * cannot keep the page firing requests forever. The user can resume.\n */\nconst MAX_POLL_DURATION_MS = 15 * 60 * 1000;\n\ninterface StartedReport {\n jobId: string;\n name: string;\n initial: TimeCampusExportJobFieldsFragment;\n}\n\nfunction formatTimestamp(value: string | null | undefined): string {\n if (!value) return \"\";\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? \"\" : date.toLocaleString();\n}\n\n/**\n * One generated report. Polls `timeCampusExportJob` until the job reaches a\n * terminal status, then offers the archive download.\n */\nfunction ReportJobRow({ report }: { report: StartedReport }) {\n const [settled, setSettled] = useState(\n isTerminalExportStatus(report.initial.status),\n );\n const [timedOut, setTimedOut] = useState(false);\n const [pollEpoch, setPollEpoch] = useState(0);\n const { data, error, stopPolling, startPolling, refetch } =\n useTimeCampusExportJobQuery({\n variables: { id: report.jobId },\n pollInterval: settled || timedOut ? 0 : POLL_INTERVAL_MS,\n fetchPolicy: \"network-only\",\n });\n\n const job = data?.timeCampusExportJob ?? report.initial;\n const status = job.status;\n\n useEffect(() => {\n if (isTerminalExportStatus(status) || data?.timeCampusExportJob === null) {\n stopPolling();\n setSettled(true);\n setTimedOut(false);\n }\n }, [status, data, stopPolling]);\n\n // Cap how long one job is polled. pollEpoch restarts the window when the\n // user resumes checking.\n useEffect(() => {\n if (settled) return undefined;\n const timer = window.setTimeout(() => {\n stopPolling();\n setTimedOut(true);\n }, MAX_POLL_DURATION_MS);\n return () => window.clearTimeout(timer);\n }, [settled, pollEpoch, stopPolling]);\n\n const handleResume = () => {\n setTimedOut(false);\n setPollEpoch((n) => n + 1);\n startPolling(POLL_INTERVAL_MS);\n void refetch();\n };\n\n const missing = data !== undefined && data.timeCampusExportJob === null;\n const tone = missing ? \"warning\" : exportStatusTone(status);\n const label = missing ? \"Unavailable\" : exportStatusLabel(status);\n const inFlight = !missing && !isTerminalExportStatus(status);\n\n return (\n <li\n className=\"flex flex-col gap-3 rounded-lg border border-border-subtle bg-bg-surface p-3 sm:flex-row sm:items-center sm:justify-between\"\n data-testid=\"report-export-job\"\n data-status={missing ? \"MISSING\" : status}\n >\n <div className=\"min-w-0 flex-1 space-y-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {report.name}\n </p>\n <StatusBadge variant={tone} label={label} dot />\n <span className=\"text-xs text-text-secondary\">{job.format}</span>\n </div>\n <p className=\"text-xs text-text-secondary\">\n Started {formatTimestamp(job.createdAt)}\n {job.completedAt\n ? ` · finished ${formatTimestamp(job.completedAt)}`\n : \"\"}\n </p>\n {inFlight && (\n <ProgressMeter\n value={job.progress ?? 0}\n max={100}\n higherIsWorse={false}\n label=\"Progress\"\n format={(v) => `${Math.round(v)}%`}\n size=\"sm\"\n />\n )}\n {status === \"FAILED\" && (\n <p className=\"text-xs text-status-error-text\">\n {job.errorMessage || \"The export failed. Try generating it again.\"}\n </p>\n )}\n {missing && (\n <p className=\"text-xs text-text-secondary\">\n This export is no longer available.\n </p>\n )}\n {timedOut && !settled && (\n <p className=\"text-xs text-text-secondary\">\n Still generating. Status checks paused to save requests; the export\n keeps running on the server.{\" \"}\n <button\n type=\"button\"\n onClick={handleResume}\n className=\"font-medium text-text-primary underline underline-offset-2\"\n >\n Check again\n </button>\n </p>\n )}\n {error && !missing && (\n <p className=\"text-xs text-status-error-text\">\n Could not refresh the export status: {error.message}\n </p>\n )}\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {inFlight && !timedOut && (\n <Loader2\n className=\"h-4 w-4 text-text-secondary motion-safe:animate-spin\"\n aria-hidden\n />\n )}\n {status === \"COMPLETED\" && job.downloadUrl && (\n <a\n href={job.downloadUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text hover:bg-action-primary-bg/90\"\n title={\n job.downloadExpiresAt\n ? `Link expires ${formatTimestamp(job.downloadExpiresAt)}`\n : undefined\n }\n >\n <Download className=\"h-4 w-4\" />\n Download\n </a>\n )}\n </div>\n </li>\n );\n}\n\n/**\n * Server-side report builder: pick a template, a period and a format, and\n * wspace-export-svc builds the full dataset asynchronously.\n */\nexport function ServerReportExports() {\n const [templateId, setTemplateId] =\n useState<ReportTemplateId>(\"time-entries\");\n const [period, setPeriod] = useState<ReportPeriodId>(\"30d\");\n const [format, setFormat] = useState<TimeCampusExportFormat>(\n TimeCampusExportFormat.Csv,\n );\n const [reports, setReports] = useState<StartedReport[]>([]);\n const [startError, setStartError] = useState<string | null>(null);\n const [exportEntities, { loading }] = useExportTimeCampusEntitiesMutation();\n\n const template = findReportTemplate(templateId);\n\n const handleGenerate = async () => {\n setStartError(null);\n const name = buildReportName(template, period);\n try {\n const result = await exportEntities({\n variables: {\n input: {\n entityTypes: template.entityTypes,\n format,\n includeMetadata: true,\n name,\n ...resolveReportDateRange(period),\n },\n },\n });\n const job = result.data?.exportTimeCampusEntities;\n if (!job) {\n setStartError(\"The export could not be started. Please try again.\");\n return;\n }\n setReports((prev) => [{ jobId: job.id, name, initial: job }, ...prev]);\n } catch (err) {\n setStartError(\n err instanceof Error\n ? err.message\n : \"The export could not be started. Please try again.\",\n );\n }\n };\n\n const fieldClass =\n \"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\";\n\n return (\n <section\n data-testid=\"server-report-exports\"\n aria-label=\"Generate a full report\"\n >\n <GlassCard treatment=\"glass\" className=\"p-4 sm:p-5\">\n <div className=\"flex items-start gap-3\">\n <div className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-status-info-bg text-status-info-text\">\n <FileDown className=\"h-5 w-5\" />\n </div>\n <div className=\"min-w-0\">\n <h2 className=\"text-sm font-semibold text-text-primary\">\n Generate a full report\n </h2>\n <p className=\"mt-1 text-xs text-text-secondary\">\n Built on the server from your complete records, not just what this\n page has loaded. Large reports keep generating in the background;\n the download appears here when it is ready.\n </p>\n </div>\n </div>\n\n <div className=\"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <label className=\"block text-xs font-medium text-text-secondary\">\n Report\n <select\n value={templateId}\n onChange={(e) =>\n setTemplateId(e.target.value as ReportTemplateId)\n }\n className={fieldClass}\n aria-label=\"Report template\"\n >\n {REPORT_TEMPLATES.map((t) => (\n <option key={t.id} value={t.id}>\n {t.label}\n </option>\n ))}\n </select>\n </label>\n <label className=\"block text-xs font-medium text-text-secondary\">\n Period\n <select\n value={period}\n onChange={(e) => setPeriod(e.target.value as ReportPeriodId)}\n className={fieldClass}\n aria-label=\"Report period\"\n >\n {REPORT_PERIODS.map((p) => (\n <option key={p.id} value={p.id}>\n {p.label}\n </option>\n ))}\n </select>\n </label>\n <label className=\"block text-xs font-medium text-text-secondary\">\n Format\n <select\n value={format}\n onChange={(e) =>\n setFormat(e.target.value as TimeCampusExportFormat)\n }\n className={fieldClass}\n aria-label=\"Report format\"\n >\n <option value={TimeCampusExportFormat.Csv}>CSV</option>\n <option value={TimeCampusExportFormat.Json}>JSON</option>\n </select>\n </label>\n </div>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {template.description}\n </p>\n\n <div className=\"mt-4 flex flex-wrap items-center gap-3\">\n <button\n type=\"button\"\n onClick={handleGenerate}\n disabled={loading}\n className=\"inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-70\"\n >\n {loading ? (\n <Loader2 className=\"h-4 w-4 motion-safe:animate-spin\" />\n ) : (\n <FileDown className=\"h-4 w-4\" />\n )}\n {loading ? \"Starting…\" : \"Generate report\"}\n </button>\n {startError && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {startError}\n </p>\n )}\n </div>\n\n {reports.length > 0 && (\n <div className=\"mt-5 border-t border-border-subtle pt-4\">\n <h3 className=\"text-xs font-semibold uppercase tracking-wide text-text-secondary\">\n Generated this session\n </h3>\n <ul className=\"mt-2 space-y-2\">\n {reports.map((report) => (\n <ReportJobRow key={report.jobId} report={report} />\n ))}\n </ul>\n </div>\n )}\n </GlassCard>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;AAuBA,IAAM,IAAmB,KAKnB,IAAuB;AAQ7B,SAAS,EAAgB,GAA0C;CACjE,IAAI,CAAC,GAAO,OAAO;CACnB,IAAM,IAAO,IAAI,KAAK,CAAK;CAC3B,OAAO,OAAO,MAAM,EAAK,QAAQ,CAAC,IAAI,KAAK,EAAK,eAAe;AACjE;AAMA,SAAS,EAAa,EAAE,aAAqC;CAC3D,IAAM,CAAC,GAAS,KAAc,EAC5B,EAAuB,EAAO,QAAQ,MAAM,CAC9C,GACM,CAAC,GAAU,KAAe,EAAS,EAAK,GACxC,CAAC,GAAW,KAAgB,EAAS,CAAC,GACtC,EAAE,SAAM,UAAO,gBAAa,iBAAc,eAC9C,EAA4B;EAC1B,WAAW,EAAE,IAAI,EAAO,MAAM;EAC9B,cAAc,KAAW,IAAW,IAAI;EACxC,aAAa;CACf,CAAC,GAEG,IAAM,GAAM,uBAAuB,EAAO,SAC1C,IAAS,EAAI;CAYnB,AAVA,QAAgB;EACd,CAAI,EAAuB,CAAM,KAAK,GAAM,wBAAwB,UAClE,EAAY,GACZ,EAAW,EAAI,GACf,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EAAE,EAEP,CACT;OACK,CAAA,CACH;;MACP,kBAAC,SAAD;OAAO,WAAU;OAAjB,UAAA,CAAiE,UAE/D,kBAAC,UAAD;QACE,OAAO;QACP,WAAW,MACT,EAAU,EAAE,OAAO,KAA+B;QAEpD,WAAW;QACX,cAAW;QANb,UAAA,CAQE,kBAAC,UAAD;SAAQ,OAAO,EAAuB;SAAK,UAAA;QAAW,CAAA,GACtD,kBAAC,UAAD;SAAQ,OAAO,EAAuB;SAAM,UAAA;QAAY,CAAA,CAClD;OACH,CAAA,CAAA;;KACJ;;IACL,kBAAC,KAAD;KAAG,WAAU;KACV,UAAA,EAAS;IACT,CAAA;IAEH,kBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,kBAAC,UAAD;MACE,MAAK;MACL,SAAS;MACT,UAAU;MACV,WAAU;MAJZ,UAAA,CAMG,IACC,kBAAC,GAAD,EAAS,WAAU,mCAAoC,CAAA,IAEvD,kBAAC,GAAD,EAAU,WAAU,UAAW,CAAA,GAEhC,IAAU,cAAc,iBACnB;KACP,CAAA,GAAA,KACC,kBAAC,KAAD;MAAG,MAAK;MAAQ,WAAU;MACvB,UAAA;KACA,CAAA,CAEF;;IAEJ,EAAQ,SAAS,KAChB,kBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,kBAAC,MAAD;MAAI,WAAU;MAAoE,UAAA;KAE9E,CAAA,GACJ,kBAAC,MAAD;MAAI,WAAU;MACX,UAAA,EAAQ,KAAK,MACZ,kBAAC,GAAD,EAAyC,UAAS,GAA/B,EAAO,KAAwB,CACnD;KACC,CAAA,CACD;;GAEE;;CACJ,CAAA;AAEb"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Server-side report templates for the Reports page (BOFF-4043).
3
+ *
4
+ * Each template maps to TimeCampus entity types that wspace-export-svc can
5
+ * export; the backend (`exportTimeCampusEntities`) rejects anything else.
6
+ */
7
+ export type ReportTemplateId = "time-entries" | "projects" | "expenses" | "team" | "focus" | "meetings";
8
+ export interface ReportTemplate {
9
+ id: ReportTemplateId;
10
+ label: string;
11
+ description: string;
12
+ entityTypes: string[];
13
+ }
14
+ export declare const REPORT_TEMPLATES: readonly ReportTemplate[];
15
+ export type ReportPeriodId = "7d" | "30d" | "90d" | "ytd" | "all";
16
+ export declare const REPORT_PERIODS: ReadonlyArray<{
17
+ id: ReportPeriodId;
18
+ label: string;
19
+ }>;
20
+ export interface ReportDateRange {
21
+ dateRangeStart?: string;
22
+ dateRangeEnd?: string;
23
+ }
24
+ /** Resolve a period into the ISO date range sent to the export mutation. */
25
+ export declare function resolveReportDateRange(period: ReportPeriodId, now?: Date): ReportDateRange;
26
+ export declare function findReportTemplate(id: ReportTemplateId): ReportTemplate;
27
+ export declare function buildReportName(template: ReportTemplate, period: ReportPeriodId): string;
28
+ /** True once an export job will not change status again. */
29
+ export declare function isTerminalExportStatus(status: string | null | undefined): boolean;
30
+ export type ExportStatusTone = "info" | "success" | "warning" | "error";
31
+ export declare function exportStatusTone(status: string): ExportStatusTone;
32
+ export declare function exportStatusLabel(status: string): string;
33
+ //# sourceMappingURL=reportTemplates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reportTemplates.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/dashboard/reportTemplates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,gBAAgB,GAC1B,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AAE3E,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,gBAAgB,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EA0DrD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAElE,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC;IACzC,EAAE,EAAE,cAAc,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,CAMA,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAID,4EAA4E;AAC5E,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,cAAc,EACtB,GAAG,GAAE,IAAiB,GACrB,eAAe,CAYjB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,gBAAgB,GAAG,cAAc,CAIvE;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,cAAc,GACrB,MAAM,CAIR;AAUD,4DAA4D;AAC5D,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,WAEvE;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAExE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAKjE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAoBxD"}
@@ -0,0 +1,129 @@
1
+ //#region src/timecampus/pages/dashboard/reportTemplates.ts
2
+ var e = [
3
+ {
4
+ id: "time-entries",
5
+ label: "Time entries",
6
+ description: "Every logged entry with project, task, duration and billable flag.",
7
+ entityTypes: ["timecampus_time_entries"]
8
+ },
9
+ {
10
+ id: "projects",
11
+ label: "Projects & tasks",
12
+ description: "Projects, their tasks and the clients they belong to.",
13
+ entityTypes: [
14
+ "timecampus_projects",
15
+ "timecampus_tasks",
16
+ "timecampus_clients"
17
+ ]
18
+ },
19
+ {
20
+ id: "expenses",
21
+ label: "Expenses",
22
+ description: "Expense entries with amounts, categories and approval status.",
23
+ entityTypes: ["timecampus_expense_entries"]
24
+ },
25
+ {
26
+ id: "team",
27
+ label: "Team & resourcing",
28
+ description: "Resource plans, allocations and timesheet approval requests for the team.",
29
+ entityTypes: [
30
+ "timecampus_resource_plans",
31
+ "timecampus_resource_allocations",
32
+ "timecampus_time_approval_requests"
33
+ ]
34
+ },
35
+ {
36
+ id: "focus",
37
+ label: "Focus & productivity",
38
+ description: "Pomodoro sessions, focus scores, work patterns and application usage.",
39
+ entityTypes: [
40
+ "timecampus_pomodoro_sessions",
41
+ "timecampus_focus_scores",
42
+ "timecampus_work_patterns",
43
+ "timecampus_application_usages"
44
+ ]
45
+ },
46
+ {
47
+ id: "meetings",
48
+ label: "Meetings",
49
+ description: "Meetings with participants and action items.",
50
+ entityTypes: [
51
+ "timecampus_meeting_metas",
52
+ "timecampus_meeting_participants",
53
+ "timecampus_meeting_action_items"
54
+ ]
55
+ }
56
+ ], t = [
57
+ {
58
+ id: "7d",
59
+ label: "Last 7 days"
60
+ },
61
+ {
62
+ id: "30d",
63
+ label: "Last 30 days"
64
+ },
65
+ {
66
+ id: "90d",
67
+ label: "Last 90 days"
68
+ },
69
+ {
70
+ id: "ytd",
71
+ label: "This year"
72
+ },
73
+ {
74
+ id: "all",
75
+ label: "All time"
76
+ }
77
+ ], n = 864e5;
78
+ function r(e, t = /* @__PURE__ */ new Date()) {
79
+ if (e === "all") return {};
80
+ let r = t.toISOString();
81
+ if (e === "ytd") return {
82
+ dateRangeStart: new Date(t.getFullYear(), 0, 1).toISOString(),
83
+ dateRangeEnd: r
84
+ };
85
+ let i = e === "7d" ? 7 : e === "30d" ? 30 : 90;
86
+ return {
87
+ dateRangeStart: (/* @__PURE__ */ new Date(t.getTime() - i * n)).toISOString(),
88
+ dateRangeEnd: r
89
+ };
90
+ }
91
+ function i(t) {
92
+ let n = e.find((e) => e.id === t);
93
+ if (!n) throw Error(`Unknown report template: ${t}`);
94
+ return n;
95
+ }
96
+ function a(e, n) {
97
+ let r = t.find((e) => e.id === n)?.label ?? "All time";
98
+ return `${e.label} report — ${r}`;
99
+ }
100
+ var o = /* @__PURE__ */ new Set([
101
+ "COMPLETED",
102
+ "FAILED",
103
+ "CANCELLED",
104
+ "EXPIRED",
105
+ "DELETED"
106
+ ]);
107
+ function s(e) {
108
+ return !!e && o.has(e);
109
+ }
110
+ function c(e) {
111
+ return e === "COMPLETED" ? "success" : e === "FAILED" ? "error" : o.has(e) ? "warning" : "info";
112
+ }
113
+ function l(e) {
114
+ switch (e) {
115
+ case "CREATED":
116
+ case "QUEUED": return "Queued";
117
+ case "RUNNING": return "Generating";
118
+ case "COMPLETED": return "Ready";
119
+ case "FAILED": return "Failed";
120
+ case "CANCELLED": return "Cancelled";
121
+ case "EXPIRED": return "Link expired";
122
+ case "DELETED": return "Deleted";
123
+ default: return e;
124
+ }
125
+ }
126
+ //#endregion
127
+ export { t as REPORT_PERIODS, e as REPORT_TEMPLATES, a as buildReportName, l as exportStatusLabel, c as exportStatusTone, i as findReportTemplate, s as isTerminalExportStatus, r as resolveReportDateRange };
128
+
129
+ //# sourceMappingURL=reportTemplates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reportTemplates.js","names":[],"sources":["../../../../src/timecampus/pages/dashboard/reportTemplates.ts"],"sourcesContent":["/**\n * Server-side report templates for the Reports page (BOFF-4043).\n *\n * Each template maps to TimeCampus entity types that wspace-export-svc can\n * export; the backend (`exportTimeCampusEntities`) rejects anything else.\n */\n\nexport type ReportTemplateId =\n \"time-entries\" | \"projects\" | \"expenses\" | \"team\" | \"focus\" | \"meetings\";\n\nexport interface ReportTemplate {\n id: ReportTemplateId;\n label: string;\n description: string;\n entityTypes: string[];\n}\n\nexport const REPORT_TEMPLATES: readonly ReportTemplate[] = [\n {\n id: \"time-entries\",\n label: \"Time entries\",\n description:\n \"Every logged entry with project, task, duration and billable flag.\",\n entityTypes: [\"timecampus_time_entries\"],\n },\n {\n id: \"projects\",\n label: \"Projects & tasks\",\n description: \"Projects, their tasks and the clients they belong to.\",\n entityTypes: [\n \"timecampus_projects\",\n \"timecampus_tasks\",\n \"timecampus_clients\",\n ],\n },\n {\n id: \"expenses\",\n label: \"Expenses\",\n description:\n \"Expense entries with amounts, categories and approval status.\",\n entityTypes: [\"timecampus_expense_entries\"],\n },\n {\n id: \"team\",\n label: \"Team & resourcing\",\n description:\n \"Resource plans, allocations and timesheet approval requests for the team.\",\n entityTypes: [\n \"timecampus_resource_plans\",\n \"timecampus_resource_allocations\",\n \"timecampus_time_approval_requests\",\n ],\n },\n {\n id: \"focus\",\n label: \"Focus & productivity\",\n description:\n \"Pomodoro sessions, focus scores, work patterns and application usage.\",\n entityTypes: [\n \"timecampus_pomodoro_sessions\",\n \"timecampus_focus_scores\",\n \"timecampus_work_patterns\",\n \"timecampus_application_usages\",\n ],\n },\n {\n id: \"meetings\",\n label: \"Meetings\",\n description: \"Meetings with participants and action items.\",\n entityTypes: [\n \"timecampus_meeting_metas\",\n \"timecampus_meeting_participants\",\n \"timecampus_meeting_action_items\",\n ],\n },\n];\n\nexport type ReportPeriodId = \"7d\" | \"30d\" | \"90d\" | \"ytd\" | \"all\";\n\nexport const REPORT_PERIODS: ReadonlyArray<{\n id: ReportPeriodId;\n label: string;\n}> = [\n { id: \"7d\", label: \"Last 7 days\" },\n { id: \"30d\", label: \"Last 30 days\" },\n { id: \"90d\", label: \"Last 90 days\" },\n { id: \"ytd\", label: \"This year\" },\n { id: \"all\", label: \"All time\" },\n];\n\nexport interface ReportDateRange {\n dateRangeStart?: string;\n dateRangeEnd?: string;\n}\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n\n/** Resolve a period into the ISO date range sent to the export mutation. */\nexport function resolveReportDateRange(\n period: ReportPeriodId,\n now: Date = new Date(),\n): ReportDateRange {\n if (period === \"all\") return {};\n const end = now.toISOString();\n if (period === \"ytd\") {\n const start = new Date(now.getFullYear(), 0, 1);\n return { dateRangeStart: start.toISOString(), dateRangeEnd: end };\n }\n const days = period === \"7d\" ? 7 : period === \"30d\" ? 30 : 90;\n return {\n dateRangeStart: new Date(now.getTime() - days * DAY_MS).toISOString(),\n dateRangeEnd: end,\n };\n}\n\nexport function findReportTemplate(id: ReportTemplateId): ReportTemplate {\n const template = REPORT_TEMPLATES.find((t) => t.id === id);\n if (!template) throw new Error(`Unknown report template: ${id}`);\n return template;\n}\n\nexport function buildReportName(\n template: ReportTemplate,\n period: ReportPeriodId,\n): string {\n const periodLabel =\n REPORT_PERIODS.find((p) => p.id === period)?.label ?? \"All time\";\n return `${template.label} report — ${periodLabel}`;\n}\n\nconst TERMINAL_STATUSES = new Set([\n \"COMPLETED\",\n \"FAILED\",\n \"CANCELLED\",\n \"EXPIRED\",\n \"DELETED\",\n]);\n\n/** True once an export job will not change status again. */\nexport function isTerminalExportStatus(status: string | null | undefined) {\n return !!status && TERMINAL_STATUSES.has(status);\n}\n\nexport type ExportStatusTone = \"info\" | \"success\" | \"warning\" | \"error\";\n\nexport function exportStatusTone(status: string): ExportStatusTone {\n if (status === \"COMPLETED\") return \"success\";\n if (status === \"FAILED\") return \"error\";\n if (TERMINAL_STATUSES.has(status)) return \"warning\";\n return \"info\";\n}\n\nexport function exportStatusLabel(status: string): string {\n switch (status) {\n case \"CREATED\":\n case \"QUEUED\":\n return \"Queued\";\n case \"RUNNING\":\n return \"Generating\";\n case \"COMPLETED\":\n return \"Ready\";\n case \"FAILED\":\n return \"Failed\";\n case \"CANCELLED\":\n return \"Cancelled\";\n case \"EXPIRED\":\n return \"Link expired\";\n case \"DELETED\":\n return \"Deleted\";\n default:\n return status;\n }\n}\n"],"mappings":";AAiBA,IAAa,IAA8C;CACzD;EACE,IAAI;EACJ,OAAO;EACP,aACE;EACF,aAAa,CAAC,yBAAyB;CACzC;CACA;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACb,aAAa;GACX;GACA;GACA;EACF;CACF;CACA;EACE,IAAI;EACJ,OAAO;EACP,aACE;EACF,aAAa,CAAC,4BAA4B;CAC5C;CACA;EACE,IAAI;EACJ,OAAO;EACP,aACE;EACF,aAAa;GACX;GACA;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A,SAAgB,EAAiB,GAAkC;CAIjE,OAHI,MAAW,cAAoB,YAC/B,MAAW,WAAiB,UAC5B,EAAkB,IAAI,CAAM,IAAU,YACnC;AACT;AAEA,SAAgB,EAAkB,GAAwB;CACxD,QAAQ,GAAR;EACE,KAAK;EACL,KAAK,UACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,SACE,OAAO;CACX;AACF"}
@@ -22,7 +22,7 @@ export declare function localDayBounds(key: string): {
22
22
  export declare function dayHeading(key: string, now?: Date): string;
23
23
  /** Long form of the day for the sub-heading ("Wednesday, October 25"). */
24
24
  export declare function longDayLabel(key: string): string;
25
- /** Compact "1h 30m" / "45m" / "0m" from seconds (never shows seconds). */
25
+ /** Compact "1h 30m" / "45m" / "<1m" / "0m" from seconds (never shows seconds). */
26
26
  export declare function compactDuration(seconds: number): string;
27
27
  /** "MM:SS" countdown; hours roll into the minutes ("90:00"). */
28
28
  export declare function formatCountdown(seconds: number): string;
@@ -1 +1 @@
1
- {"version":3,"file":"mobileModel.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/mobile/mobileModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAKjD;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAc7E;AAED,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ9D;AAED,4CAA4C;AAC5C,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,E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C1B,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,UAAU,EAAE,OAAO,GAClB,MAAM,GAAG,IAAI,CAUf;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC;AAEpE,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAI1D;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,iEAAiE;IACjE,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EAChE,SAAS,EAAE,MAAM,GAChB,SAAS,EAAE,CAsBb;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,SAAS,SAAS,EAAE,GACzB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAWnD"}
@@ -40,7 +40,9 @@ function a(e) {
40
40
  }) : e;
41
41
  }
42
42
  function o(e) {
43
- let t = Math.max(0, Math.round(e)), n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60);
43
+ let t = Math.max(0, Math.round(e));
44
+ if (t > 0 && t < 60) return "<1m";
45
+ let n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60);
44
46
  return n === 0 ? `${r}m` : r === 0 ? `${n}h` : `${n}h ${r}m`;
45
47
  }
46
48
  function s(e) {
@@ -1 +1 @@
1
- {"version":3,"file":"mobileModel.js","names":[],"sources":["../../../../src/timecampus/pages/mobile/mobileModel.ts"],"sourcesContent":["/**\n * Pure view-model helpers for the phone-optimised TimeCampus screens\n * (`/mobile/timer`, `/mobile/timeline`, `/mobile/life-balance`).\n *\n * Everything here is derived from data the backend already returns — nothing\n * is invented. When there is not enough data to say something honestly (no\n * targets declared, nothing tracked yet) the helpers return `null` and the\n * screen says so instead of showing a made-up number.\n */\n\n// ---------------------------------------------------------------------------\n// Dates\n// ---------------------------------------------------------------------------\n\n/** `YYYY-MM-DD` for a Date in the viewer's local time zone. */\nexport function toLocalDateKey(date: Date): string {\n const y = date.getFullYear();\n const m = String(date.getMonth() + 1).padStart(2, \"0\");\n const d = String(date.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\n/** Parses a `YYYY-MM-DD` key as local midnight; `null` when it is not a real date. */\nexport function parseLocalDateKey(key: string | null | undefined): Date | null {\n if (!key) return null;\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(key);\n if (!match) return null;\n const [, y, m, d] = match;\n const date = new Date(Number(y), Number(m) - 1, Number(d));\n if (\n date.getFullYear() !== Number(y) ||\n date.getMonth() !== Number(m) - 1 ||\n date.getDate() !== Number(d)\n ) {\n return null;\n }\n return date;\n}\n\n/** Moves a `YYYY-MM-DD` key by whole days (DST-safe: calendar arithmetic). */\nexport function shiftDateKey(key: string, days: number): string {\n const base = parseLocalDateKey(key) ?? new Date();\n const next = new Date(\n base.getFullYear(),\n base.getMonth(),\n base.getDate() + days,\n );\n return toLocalDateKey(next);\n}\n\n/** ISO bounds of one local calendar day. */\nexport function localDayBounds(key: string): { from: string; to: string } {\n const day = parseLocalDateKey(key) ?? new Date();\n const start = new Date(day.getFullYear(), day.getMonth(), day.getDate());\n const end = new Date(\n day.getFullYear(),\n day.getMonth(),\n day.getDate(),\n 23,\n 59,\n 59,\n 999,\n );\n return { from: start.toISOString(), to: end.toISOString() };\n}\n\n/** \"Today\", \"Yesterday\", or a short weekday + date (\"Wed, Oct 25\"). */\nexport function dayHeading(key: string, now: Date = new Date()): string {\n const today = toLocalDateKey(now);\n if (key === today) return \"Today\";\n if (key === shiftDateKey(today, -1)) return \"Yesterday\";\n const date = parseLocalDateKey(key);\n if (!date) return key;\n return date.toLocaleDateString(\"en-US\", {\n weekday: \"short\",\n month: \"short\",\n day: \"numeric\",\n });\n}\n\n/** Long form of the day for the sub-heading (\"Wednesday, October 25\"). */\nexport function longDayLabel(key: string): string {\n const date = parseLocalDateKey(key);\n if (!date) return key;\n return date.toLocaleDateString(\"en-US\", {\n weekday: \"long\",\n month: \"long\",\n day: \"numeric\",\n });\n}\n\n// ---------------------------------------------------------------------------\n// Durations\n// ---------------------------------------------------------------------------\n\n/** Compact \"1h 30m\" / \"45m\" / \"0m\" from seconds (never shows seconds). */\nexport function compactDuration(seconds: number): string {\n const total = Math.max(0, Math.round(seconds));\n const h = Math.floor(total / 3600);\n const m = Math.floor((total % 3600) / 60);\n if (h === 0) return `${m}m`;\n if (m === 0) return `${h}h`;\n return `${h}h ${m}m`;\n}\n\n/** \"MM:SS\" countdown; hours roll into the minutes (\"90:00\"). */\nexport function formatCountdown(seconds: number): string {\n const total = Math.max(0, Math.floor(seconds));\n const m = Math.floor(total / 60);\n const s = total % 60;\n return `${String(m).padStart(2, \"0\")}:${String(s).padStart(2, \"0\")}`;\n}\n\n// ---------------------------------------------------------------------------\n// Timer (pomodoro-backed focus session)\n// ---------------------------------------------------------------------------\n\nexport interface SessionClock {\n startTime: string;\n /** Planned length in seconds; falls back to the mode default when absent. */\n duration?: number | null;\n}\n\n/** Seconds left on a running session at `now` (never negative). */\nexport function remainingSeconds(\n session: SessionClock,\n fallbackDurationSeconds: number,\n now: number = Date.now(),\n): number {\n const planned =\n session.duration && session.duration > 0\n ? session.duration\n : fallbackDurationSeconds;\n const started = new Date(session.startTime).getTime();\n if (!Number.isFinite(started)) return planned;\n const elapsed = Math.floor((now - started) / 1000);\n return Math.max(0, planned - Math.max(0, elapsed));\n}\n\n/** Fraction of the ring that is still \"left\" (1 = full, 0 = done). */\nexport function ringFraction(remaining: number, total: number): number {\n if (!Number.isFinite(total) || total <= 0) return 0;\n return Math.min(1, Math.max(0, remaining / total));\n}\n\nexport interface GoalLike {\n type: string;\n target: number;\n current: number;\n startDate: string;\n endDate: string;\n}\n\n/**\n * The daily focus goal that covers `now`, if the user set one. Only DAILY goals\n * qualify — a weekly target is not \"today's goal\".\n */\nexport function todaysGoal<T extends GoalLike>(\n goals: readonly T[],\n now: Date = new Date(),\n): T | null {\n // Compare calendar days, not instants: a goal that ends \"on\" a date covers\n // the whole of that day whatever time-of-day the end was stored with.\n const today = toLocalDateKey(now);\n const dayKey = (iso: string): string | null => {\n const date = new Date(iso);\n return Number.isFinite(date.getTime()) ? toLocalDateKey(date) : null;\n };\n const active = goals.filter((goal) => {\n if (goal.type !== \"DAILY\" || goal.target <= 0) return false;\n const start = dayKey(goal.startDate);\n const end = dayKey(goal.endDate);\n return (start === null || start <= today) && (end === null || today <= end);\n });\n if (active.length === 0) return null;\n return active.reduce((best, goal) =>\n new Date(goal.startDate).getTime() > new Date(best.startDate).getTime()\n ? goal\n : best,\n );\n}\n\n// ---------------------------------------------------------------------------\n// Timeline\n// ---------------------------------------------------------------------------\n\nexport interface CategoryTotal {\n category: string;\n totalSeconds: number;\n}\n\nexport interface TimelineSummaryLike {\n totalTrackedSeconds: number;\n focusRatio?: number | null;\n byCategory: readonly CategoryTotal[];\n}\n\nexport interface FocusSummary {\n /** Whole-number focus share, or null when the backend has no ratio yet. */\n focusPercent: number | null;\n deepWorkSeconds: number;\n meetingSeconds: number;\n trackedSeconds: number;\n}\n\nexport function focusSummary(\n summary: TimelineSummaryLike | null | undefined,\n): FocusSummary {\n const total = (category: string) =>\n summary?.byCategory\n .filter((row) => row.category === category)\n .reduce((sum, row) => sum + row.totalSeconds, 0) ?? 0;\n const ratio = summary?.focusRatio;\n return {\n focusPercent:\n typeof ratio === \"number\" && Number.isFinite(ratio)\n ? Math.round(ratio * 100)\n : null,\n deepWorkSeconds: total(\"DEEP_WORK\"),\n meetingSeconds: total(\"MEETING\"),\n trackedSeconds: summary?.totalTrackedSeconds ?? 0,\n };\n}\n\nexport interface SearchableSegment {\n title?: string | null;\n app?: string | null;\n category: string;\n projectId?: string | null;\n}\n\n/**\n * Case-insensitive match on the segment's title, app, category label or project\n * name. An empty query keeps everything.\n */\nexport function filterSegments<T extends SearchableSegment>(\n segments: readonly T[],\n query: string,\n projectNameById: ReadonlyMap<string, string>,\n categoryLabel: (category: string) => string,\n): T[] {\n const needle = query.trim().toLowerCase();\n if (!needle) return [...segments];\n return segments.filter((segment) => {\n const haystack = [\n segment.title,\n segment.app,\n categoryLabel(segment.category),\n segment.projectId ? projectNameById.get(segment.projectId) : undefined,\n ];\n return haystack.some(\n (value) =>\n typeof value === \"string\" && value.toLowerCase().includes(needle),\n );\n });\n}\n\n/** Segments ordered by start time (planned blocks keep their slot). */\nexport function sortByStart<T extends { startTime: string }>(\n segments: readonly T[],\n): T[] {\n return [...segments].sort(\n (a, b) => new Date(a.startTime).getTime() - new Date(b.startTime).getTime(),\n );\n}\n\n// ---------------------------------------------------------------------------\n// Life balance\n// ---------------------------------------------------------------------------\n\nexport interface DomainBalanceLike {\n domain: string;\n actualSeconds: number;\n actualShare: number;\n desiredShare: number;\n gap: number;\n}\n\n/**\n * How close the tracked split is to the declared one, 0–100: one minus the\n * total-variation distance between the two distributions. 100 means the time\n * split exactly as wanted; 0 means none of it went where it was wanted.\n * `null` when the user has not declared targets or nothing is tracked — there\n * is nothing honest to score.\n */\nexport function balanceScore(\n byDomain: readonly DomainBalanceLike[],\n hasTargets: boolean,\n): number | null {\n if (!hasTargets) return null;\n const tracked = byDomain.reduce((sum, d) => sum + d.actualSeconds, 0);\n if (tracked <= 0) return null;\n const distance =\n byDomain.reduce(\n (sum, d) => sum + Math.abs(d.actualShare - d.desiredShare),\n 0,\n ) / 2;\n return Math.round(Math.min(1, Math.max(0, 1 - distance)) * 100);\n}\n\nexport type BalanceStatus = \"on-track\" | \"drifting\" | \"off-balance\";\n\nexport function balanceStatus(score: number): BalanceStatus {\n if (score >= 75) return \"on-track\";\n if (score >= 50) return \"drifting\";\n return \"off-balance\";\n}\n\nexport interface DomainRow {\n domain: string;\n actualSeconds: number;\n /** Target for the selected range, pro-rated from hours/week; null if none. */\n targetSeconds: number | null;\n /** actual / target as a whole percent, null without a target. */\n percentOfTarget: number | null;\n actualShare: number;\n}\n\n/**\n * Rows for the \"so far\" list: domains with tracked time or a target, most time\n * first. Weekly targets are pro-rated to the range length.\n */\nexport function domainRows(\n byDomain: readonly DomainBalanceLike[],\n targetHoursPerWeek: Readonly<Record<string, number | undefined>>,\n rangeDays: number,\n): DomainRow[] {\n const days = Math.max(1, rangeDays);\n return byDomain\n .map((d) => {\n const weekly = targetHoursPerWeek[d.domain];\n const targetSeconds =\n typeof weekly === \"number\" && weekly > 0\n ? Math.round((weekly * 3600 * days) / 7)\n : null;\n return {\n domain: d.domain,\n actualSeconds: d.actualSeconds,\n targetSeconds,\n percentOfTarget:\n targetSeconds && targetSeconds > 0\n ? Math.round((d.actualSeconds / targetSeconds) * 100)\n : null,\n actualShare: d.actualShare,\n };\n })\n .filter((row) => row.actualSeconds > 0 || row.targetSeconds !== null)\n .sort((a, b) => b.actualSeconds - a.actualSeconds);\n}\n\n/**\n * The domain furthest below its target (largest unmet seconds), for the\n * \"make room for…\" nudge. `null` when every target is met or none are set.\n */\nexport function biggestShortfall(\n rows: readonly DomainRow[],\n): { domain: string; missingSeconds: number } | null {\n let best: { domain: string; missingSeconds: number } | null = null;\n for (const row of rows) {\n if (row.targetSeconds === null) continue;\n const missing = row.targetSeconds - row.actualSeconds;\n if (missing <= 0) continue;\n if (!best || missing > best.missingSeconds) {\n best = { domain: row.domain, missingSeconds: missing };\n }\n }\n return best;\n}\n"],"mappings":";AAeA,SAAgB,EAAe,GAAoB;CAIjD,OAAO,GAHG,EAAK,YAGL,EAAE,GAFF,OAAO,EAAK,SAAS,IAAI,CAAC,CAAC,CAAC,SAAS,GAAG,GAEnC,EAAE,GADP,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M;EACtB,IAAI,EAAI,kBAAkB,MAAM;EAChC,IAAM,IAAU,EAAI,gBAAgB,EAAI;EACpC,KAAW,MACX,CAAC,KAAQ,IAAU,EAAK,oBAC1B,IAAO;GAAE,QAAQ,EAAI;GAAQ,gBAAgB;EAAQ;CAEzD;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"mobileModel.js","names":[],"sources":["../../../../src/timecampus/pages/mobile/mobileModel.ts"],"sourcesContent":["/**\n * Pure view-model helpers for the phone-optimised TimeCampus screens\n * (`/mobile/timer`, `/mobile/timeline`, `/mobile/life-balance`).\n *\n * Everything here is derived from data the backend already returns — nothing\n * is invented. When there is not enough data to say something honestly (no\n * targets declared, nothing tracked yet) the helpers return `null` and the\n * screen says so instead of showing a made-up number.\n */\n\n// ---------------------------------------------------------------------------\n// Dates\n// ---------------------------------------------------------------------------\n\n/** `YYYY-MM-DD` for a Date in the viewer's local time zone. */\nexport function toLocalDateKey(date: Date): string {\n const y = date.getFullYear();\n const m = String(date.getMonth() + 1).padStart(2, \"0\");\n const d = String(date.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\n/** Parses a `YYYY-MM-DD` key as local midnight; `null` when it is not a real date. */\nexport function parseLocalDateKey(key: string | null | undefined): Date | null {\n if (!key) return null;\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(key);\n if (!match) return null;\n const [, y, m, d] = match;\n const date = new Date(Number(y), Number(m) - 1, Number(d));\n if (\n date.getFullYear() !== Number(y) ||\n date.getMonth() !== Number(m) - 1 ||\n date.getDate() !== Number(d)\n ) {\n return null;\n }\n return date;\n}\n\n/** Moves a `YYYY-MM-DD` key by whole days (DST-safe: calendar arithmetic). */\nexport function shiftDateKey(key: string, days: number): string {\n const base = parseLocalDateKey(key) ?? new Date();\n const next = new Date(\n base.getFullYear(),\n base.getMonth(),\n base.getDate() + days,\n );\n return toLocalDateKey(next);\n}\n\n/** ISO bounds of one local calendar day. */\nexport function localDayBounds(key: string): { from: string; to: string } {\n const day = parseLocalDateKey(key) ?? new Date();\n const start = new Date(day.getFullYear(), day.getMonth(), day.getDate());\n const end = new Date(\n day.getFullYear(),\n day.getMonth(),\n day.getDate(),\n 23,\n 59,\n 59,\n 999,\n );\n return { from: start.toISOString(), to: end.toISOString() };\n}\n\n/** \"Today\", \"Yesterday\", or a short weekday + date (\"Wed, Oct 25\"). */\nexport function dayHeading(key: string, now: Date = new Date()): string {\n const today = toLocalDateKey(now);\n if (key === today) return \"Today\";\n if (key === shiftDateKey(today, -1)) return \"Yesterday\";\n const date = parseLocalDateKey(key);\n if (!date) return key;\n return date.toLocaleDateString(\"en-US\", {\n weekday: \"short\",\n month: \"short\",\n day: \"numeric\",\n });\n}\n\n/** Long form of the day for the sub-heading (\"Wednesday, October 25\"). */\nexport function longDayLabel(key: string): string {\n const date = parseLocalDateKey(key);\n if (!date) return key;\n return date.toLocaleDateString(\"en-US\", {\n weekday: \"long\",\n month: \"long\",\n day: \"numeric\",\n });\n}\n\n// ---------------------------------------------------------------------------\n// Durations\n// ---------------------------------------------------------------------------\n\n/** Compact \"1h 30m\" / \"45m\" / \"<1m\" / \"0m\" from seconds (never shows seconds). */\nexport function compactDuration(seconds: number): string {\n const total = Math.max(0, Math.round(seconds));\n // Something was tracked, just not a whole minute: \"0m\" would read as nothing.\n if (total > 0 && total < 60) return \"<1m\";\n const h = Math.floor(total / 3600);\n const m = Math.floor((total % 3600) / 60);\n if (h === 0) return `${m}m`;\n if (m === 0) return `${h}h`;\n return `${h}h ${m}m`;\n}\n\n/** \"MM:SS\" countdown; hours roll into the minutes (\"90:00\"). */\nexport function formatCountdown(seconds: number): string {\n const total = Math.max(0, Math.floor(seconds));\n const m = Math.floor(total / 60);\n const s = total % 60;\n return `${String(m).padStart(2, \"0\")}:${String(s).padStart(2, \"0\")}`;\n}\n\n// ---------------------------------------------------------------------------\n// Timer (pomodoro-backed focus session)\n// ---------------------------------------------------------------------------\n\nexport interface SessionClock {\n startTime: string;\n /** Planned length in seconds; falls back to the mode default when absent. */\n duration?: number | null;\n}\n\n/** Seconds left on a running session at `now` (never negative). */\nexport function remainingSeconds(\n session: SessionClock,\n fallbackDurationSeconds: number,\n now: number = Date.now(),\n): number {\n const planned =\n session.duration && session.duration > 0\n ? session.duration\n : fallbackDurationSeconds;\n const started = new Date(session.startTime).getTime();\n if (!Number.isFinite(started)) return planned;\n const elapsed = Math.floor((now - started) / 1000);\n return Math.max(0, planned - Math.max(0, elapsed));\n}\n\n/** Fraction of the ring that is still \"left\" (1 = full, 0 = done). */\nexport function ringFraction(remaining: number, total: number): number {\n if (!Number.isFinite(total) || total <= 0) return 0;\n return Math.min(1, Math.max(0, remaining / total));\n}\n\nexport interface GoalLike {\n type: string;\n target: number;\n current: number;\n startDate: string;\n endDate: string;\n}\n\n/**\n * The daily focus goal that covers `now`, if the user set one. Only DAILY goals\n * qualify — a weekly target is not \"today's goal\".\n */\nexport function todaysGoal<T extends GoalLike>(\n goals: readonly T[],\n now: Date = new Date(),\n): T | null {\n // Compare calendar days, not instants: a goal that ends \"on\" a date covers\n // the whole of that day whatever time-of-day the end was stored with.\n const today = toLocalDateKey(now);\n const dayKey = (iso: string): string | null => {\n const date = new Date(iso);\n return Number.isFinite(date.getTime()) ? toLocalDateKey(date) : null;\n };\n const active = goals.filter((goal) => {\n if (goal.type !== \"DAILY\" || goal.target <= 0) return false;\n const start = dayKey(goal.startDate);\n const end = dayKey(goal.endDate);\n return (start === null || start <= today) && (end === null || today <= end);\n });\n if (active.length === 0) return null;\n return active.reduce((best, goal) =>\n new Date(goal.startDate).getTime() > new Date(best.startDate).getTime()\n ? goal\n : best,\n );\n}\n\n// ---------------------------------------------------------------------------\n// Timeline\n// ---------------------------------------------------------------------------\n\nexport interface CategoryTotal {\n category: string;\n totalSeconds: number;\n}\n\nexport interface TimelineSummaryLike {\n totalTrackedSeconds: number;\n focusRatio?: number | null;\n byCategory: readonly CategoryTotal[];\n}\n\nexport interface FocusSummary {\n /** Whole-number focus share, or null when the backend has no ratio yet. */\n focusPercent: number | null;\n deepWorkSeconds: number;\n meetingSeconds: number;\n trackedSeconds: number;\n}\n\nexport function focusSummary(\n summary: TimelineSummaryLike | null | undefined,\n): FocusSummary {\n const total = (category: string) =>\n summary?.byCategory\n .filter((row) => row.category === category)\n .reduce((sum, row) => sum + row.totalSeconds, 0) ?? 0;\n const ratio = summary?.focusRatio;\n return {\n focusPercent:\n typeof ratio === \"number\" && Number.isFinite(ratio)\n ? Math.round(ratio * 100)\n : null,\n deepWorkSeconds: total(\"DEEP_WORK\"),\n meetingSeconds: total(\"MEETING\"),\n trackedSeconds: summary?.totalTrackedSeconds ?? 0,\n };\n}\n\nexport interface SearchableSegment {\n title?: string | null;\n app?: string | null;\n category: string;\n projectId?: string | null;\n}\n\n/**\n * Case-insensitive match on the segment's title, app, category label or project\n * name. An empty query keeps everything.\n */\nexport function filterSegments<T extends SearchableSegment>(\n segments: readonly T[],\n query: string,\n projectNameById: ReadonlyMap<string, string>,\n categoryLabel: (category: string) => string,\n): T[] {\n const needle = query.trim().toLowerCase();\n if (!needle) return [...segments];\n return segments.filter((segment) => {\n const haystack = [\n segment.title,\n segment.app,\n categoryLabel(segment.category),\n segment.projectId ? projectNameById.get(segment.projectId) : undefined,\n ];\n return haystack.some(\n (value) =>\n typeof value === \"string\" && value.toLowerCase().includes(needle),\n );\n });\n}\n\n/** Segments ordered by start time (planned blocks keep their slot). */\nexport function sortByStart<T extends { startTime: string }>(\n segments: readonly T[],\n): T[] {\n return [...segments].sort(\n (a, b) => new Date(a.startTime).getTime() - new Date(b.startTime).getTime(),\n );\n}\n\n// ---------------------------------------------------------------------------\n// Life balance\n// ---------------------------------------------------------------------------\n\nexport interface DomainBalanceLike {\n domain: string;\n actualSeconds: number;\n actualShare: number;\n desiredShare: number;\n gap: number;\n}\n\n/**\n * How close the tracked split is to the declared one, 0–100: one minus the\n * total-variation distance between the two distributions. 100 means the time\n * split exactly as wanted; 0 means none of it went where it was wanted.\n * `null` when the user has not declared targets or nothing is tracked — there\n * is nothing honest to score.\n */\nexport function balanceScore(\n byDomain: readonly DomainBalanceLike[],\n hasTargets: boolean,\n): number | null {\n if (!hasTargets) return null;\n const tracked = byDomain.reduce((sum, d) => sum + d.actualSeconds, 0);\n if (tracked <= 0) return null;\n const distance =\n byDomain.reduce(\n (sum, d) => sum + Math.abs(d.actualShare - d.desiredShare),\n 0,\n ) / 2;\n return Math.round(Math.min(1, Math.max(0, 1 - distance)) * 100);\n}\n\nexport type BalanceStatus = \"on-track\" | \"drifting\" | \"off-balance\";\n\nexport function balanceStatus(score: number): BalanceStatus {\n if (score >= 75) return \"on-track\";\n if (score >= 50) return \"drifting\";\n return \"off-balance\";\n}\n\nexport interface DomainRow {\n domain: string;\n actualSeconds: number;\n /** Target for the selected range, pro-rated from hours/week; null if none. */\n targetSeconds: number | null;\n /** actual / target as a whole percent, null without a target. */\n percentOfTarget: number | null;\n actualShare: number;\n}\n\n/**\n * Rows for the \"so far\" list: domains with tracked time or a target, most time\n * first. Weekly targets are pro-rated to the range length.\n */\nexport function domainRows(\n byDomain: readonly DomainBalanceLike[],\n targetHoursPerWeek: Readonly<Record<string, number | undefined>>,\n rangeDays: number,\n): DomainRow[] {\n const days = Math.max(1, rangeDays);\n return byDomain\n .map((d) => {\n const weekly = targetHoursPerWeek[d.domain];\n const targetSeconds =\n typeof weekly === \"number\" && weekly > 0\n ? Math.round((weekly * 3600 * days) / 7)\n : null;\n return {\n domain: d.domain,\n actualSeconds: d.actualSeconds,\n targetSeconds,\n percentOfTarget:\n targetSeconds && targetSeconds > 0\n ? Math.round((d.actualSeconds / targetSeconds) * 100)\n : null,\n actualShare: d.actualShare,\n };\n })\n .filter((row) => row.actualSeconds > 0 || row.targetSeconds !== null)\n .sort((a, b) => b.actualSeconds - a.actualSeconds);\n}\n\n/**\n * The domain furthest below its target (largest unmet seconds), for the\n * \"make room for…\" nudge. `null` when every target is met or none are set.\n */\nexport function biggestShortfall(\n rows: readonly DomainRow[],\n): { domain: string; missingSeconds: number } | null {\n let best: { domain: string; missingSeconds: number } | null = null;\n for (const row of rows) {\n if (row.targetSeconds === null) continue;\n const missing = row.targetSeconds - row.actualSeconds;\n if (missing <= 0) continue;\n if (!best || missing > best.missingSeconds) {\n best = { domain: row.domain, missingSeconds: missing };\n }\n }\n return best;\n}\n"],"mappings":";AAeA,SAAgB,EAAe,GAAoB;CAIjD,OAAO,GAHG,EAAK,YAGL,EAAE,GAFF,OAAO,EAAK,SAAS,IAAI,CAAC,CAAC,CAAC,SAAS,GAAG,GAEnC,EAAE,GADP,OAAO,EAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,GAAG,GACzB;AACtB;AAGA,SAAgB,EAAkB,GAA6C;CAC7E,IAAI,CAAC,GAAK,OAAO;CACjB,IAAM,IAAQ,4BAA4B,KAAK,CAAG;CAClD,IAAI,CAAC,GAAO,OAAO;CACnB,IAAM,GAAG,GAAG,GAAG,KAAK,GACd,IAAO,IAAI,KAAK,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC;CAQzD,OANE,EAAK,YAAY,MAAM,OAAO,CAAC,KAC/B,EAAK,SAAS,MAAM,OAAO,CAAC,IAAI,KAChC,EAAK,QAAQ,MAAM,OAAO,CAAC,IAEpB,OAEF;AACT;AAGA,SAAgB,EAAa,GAAa,GAAsB;CAC9D,IAAM,IAAO,EAAkB,CAAG,qBAAK,IAAI,KAAK;CAMhD,OAAO,EAAe,IALL,KACf,EAAK,YAAY,GACjB,EAAK,SAAS,GACd,EAAK,QAAQ,IAAI,CAEG,CAAI;AAC5B;AAGA,SAAgB,EAAe,GAA2C;CACxE,IAAM,IAAM,EAAkB,CAAG,qBAAK,IAAI,KAAK,GACzC,IAAQ,IAAI,KAAK,EAAI,YAAY,GAAG,EAAI,SAAS,GAAG,EAAI,QAAQ,CAAC,GACjE,IAAM,IAAI,KACd,EAAI,YAAY,GAChB,EAAI,SAAS,GACb,EAAI,QAAQ,GACZ,IACA,IACA,IAC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AAO,IAAS,OAAO,IAAQ,CAAC,IACrC;EACN,OAAO;GACL,QAAQ,EAAE;GACV,eAAe,EAAE;GACjB;GACA,iBACE,KAAiB,IAAgB,IAC7B,KAAK,MAAO,EAAE,gBAAgB,IAAiB,GAAG,IAClD;GACN,aAAa,EAAE;EACjB;CACF,CAAC,CAAC,CACD,QAAQ,MAAQ,EAAI,gBAAgB,KAAK,EAAI,kBAAkB,IAAI,CAAC,CACpE,MAAM,GAAG,MAAM,EAAE,gBAAgB,EAAE,aAAa;AACrD;AAMA,SAAgB,EACd,GACmD;CACnD,IAAI,IAA0D;CAC9D,KAAK,IAAM,KAAO,GAAM;EACtB,IAAI,EAAI,kBAAkB,MAAM;EAChC,IAAM,IAAU,EAAI,gBAAgB,EAAI;EACpC,KAAW,MACX,CAAC,KAAQ,IAAU,EAAK,oBAC1B,IAAO;GAAE,QAAQ,EAAI;GAAQ,gBAAgB;EAAQ;CAEzD;CACA,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-timecampus",
3
- "version": "2026.1031.12",
3
+ "version": "2026.1031.14",
4
4
  "description": "Burdenoff TimeCampus Microfrontend - AI-powered time management and productivity platform",
5
5
  "type": "module",
6
6
  "files": [