@burdenoff/microfe-timecampus 2026.1031.4 → 2026.1031.5

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.
@@ -0,0 +1,180 @@
1
+ import { useTimeCampusNavigate as e } from "../../providers/TimeCampusProvider.js";
2
+ import { LoadingSkeleton as t } from "../../components/LoadingSkeleton.js";
3
+ import { useMySustainedLoadQuery as n } from "../../../generated/wspace-operations.js";
4
+ import { StatusBadge as r } from "../../components/StatusBadge.js";
5
+ import "../../components/index.js";
6
+ import { evidenceKindLabel as i, formatShare as a, formatWeekRange as o, loadLevelLabel as s, loadLevelTone as c, loadProvenance as l } from "./sustainedLoad.js";
7
+ import { AlertTriangle as u, ExternalLink as d, Info as f, ShieldCheck as p } from "lucide-react";
8
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
9
+ import { GlassCard as g } from "@burdenoff/fe-libs/ui";
10
+ //#region src/timecampus/pages/work-patterns/SustainedLoadCard.tsx
11
+ var _ = {
12
+ error: "bg-status-error-bg text-status-error-text",
13
+ warning: "bg-status-warning-bg text-status-warning-text",
14
+ success: "bg-status-success-bg text-status-success-text",
15
+ muted: "bg-bg-surface text-text-secondary"
16
+ };
17
+ function v({ workspaceId: v }) {
18
+ let y = e(), { data: b, loading: x, error: S } = n({
19
+ variables: { weeks: 4 },
20
+ skip: !v,
21
+ fetchPolicy: "cache-and-network"
22
+ }), C = b?.mySustainedLoad;
23
+ if (x && !C) return /* @__PURE__ */ m(t, {
24
+ variant: "card",
25
+ count: 1
26
+ });
27
+ if (S || !C) return /* @__PURE__ */ h(g, {
28
+ treatment: "glass",
29
+ className: "p-5 sm:p-6",
30
+ children: [/* @__PURE__ */ m("h3", {
31
+ className: "text-base font-semibold text-text-primary",
32
+ "data-testid": "sustained-load-card",
33
+ children: "Sustained load"
34
+ }), /* @__PURE__ */ m("p", {
35
+ className: "mt-1.5 text-sm text-text-secondary",
36
+ children: "Your sustained-load reading could not be loaded right now. Please try again later."
37
+ })]
38
+ });
39
+ let w = C.level, T = c(w), E = C.weeks, D = C.evidence;
40
+ return /* @__PURE__ */ m(g, {
41
+ treatment: "glass",
42
+ glow: T === "error" || T === "warning",
43
+ className: "p-5 sm:p-6",
44
+ children: /* @__PURE__ */ h("div", {
45
+ className: "flex flex-col gap-4 sm:flex-row sm:items-start",
46
+ "data-testid": "sustained-load-card",
47
+ children: [/* @__PURE__ */ m("div", {
48
+ className: `flex h-11 w-11 shrink-0 items-center justify-center rounded-xl ${_[T]}`,
49
+ children: m(T === "success" || T === "muted" ? p : u, { className: "h-5 w-5" })
50
+ }), /* @__PURE__ */ h("div", {
51
+ className: "min-w-0 flex-1",
52
+ children: [
53
+ /* @__PURE__ */ h("div", {
54
+ className: "flex flex-wrap items-center gap-2",
55
+ children: [/* @__PURE__ */ m("h3", {
56
+ className: "text-base font-semibold text-text-primary",
57
+ children: "Sustained load"
58
+ }), /* @__PURE__ */ m("span", {
59
+ "data-testid": "sustained-load-level",
60
+ "data-level": w,
61
+ children: /* @__PURE__ */ m(r, {
62
+ variant: T,
63
+ label: s(w)
64
+ })
65
+ })]
66
+ }),
67
+ /* @__PURE__ */ m("p", {
68
+ className: "mt-1.5 text-sm text-text-secondary",
69
+ "data-testid": "sustained-load-rationale",
70
+ children: C.rationale
71
+ }),
72
+ /* @__PURE__ */ h("p", {
73
+ className: "mt-2 flex items-start gap-1.5 text-xs text-text-tertiary",
74
+ "data-testid": "sustained-load-provenance",
75
+ children: [/* @__PURE__ */ m(f, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }), /* @__PURE__ */ h("span", { children: [
76
+ l({
77
+ method: C.method,
78
+ model: C.model,
79
+ confidence: C.confidence,
80
+ fallbackReason: C.fallbackReason,
81
+ rulesLevel: C.rulesLevel
82
+ }),
83
+ " ",
84
+ "Only you can see this. It reads your load, never your output, and never compares you with anyone."
85
+ ] })]
86
+ }),
87
+ E.length > 0 && /* @__PURE__ */ m("ul", {
88
+ className: "mt-4 grid grid-cols-2 gap-2 lg:grid-cols-4",
89
+ "aria-label": "Weekly load",
90
+ children: E.map((e) => /* @__PURE__ */ h("li", {
91
+ className: `rounded-lg border p-3 text-xs ${e.strained ? "border-status-warning-border bg-status-warning-bg/20" : "border-border-subtle bg-bg-surface/40"}`,
92
+ "data-testid": "sustained-load-week",
93
+ children: [/* @__PURE__ */ m("p", {
94
+ className: "font-medium text-text-primary",
95
+ children: o(e.weekStart, e.weekEnd)
96
+ }), /* @__PURE__ */ h("dl", {
97
+ className: "mt-1 space-y-0.5 text-text-secondary",
98
+ children: [
99
+ /* @__PURE__ */ h("div", {
100
+ className: "flex justify-between gap-2",
101
+ children: [/* @__PURE__ */ m("dt", { children: "Hours" }), /* @__PURE__ */ m("dd", {
102
+ className: "tabular-nums text-text-primary",
103
+ children: e.trackedHours.toFixed(1)
104
+ })]
105
+ }),
106
+ /* @__PURE__ */ h("div", {
107
+ className: "flex justify-between gap-2",
108
+ children: [/* @__PURE__ */ m("dt", { children: "After hours" }), /* @__PURE__ */ m("dd", {
109
+ className: "tabular-nums text-text-primary",
110
+ children: a(e.afterHoursShare)
111
+ })]
112
+ }),
113
+ /* @__PURE__ */ h("div", {
114
+ className: "flex justify-between gap-2",
115
+ children: [/* @__PURE__ */ m("dt", { children: "Recovery days" }), /* @__PURE__ */ m("dd", {
116
+ className: "tabular-nums text-text-primary",
117
+ children: e.recoveryDays
118
+ })]
119
+ })
120
+ ]
121
+ })]
122
+ }, e.weekStart))
123
+ }),
124
+ D.length > 0 && /* @__PURE__ */ h("details", {
125
+ className: "mt-4 group",
126
+ "data-testid": "sustained-load-evidence",
127
+ children: [/* @__PURE__ */ h("summary", {
128
+ className: "cursor-pointer text-sm font-medium text-text-primary",
129
+ children: [
130
+ "Evidence (",
131
+ D.length,
132
+ ")"
133
+ ]
134
+ }), /* @__PURE__ */ m("ul", {
135
+ className: "mt-2 space-y-2",
136
+ children: D.map((e) => /* @__PURE__ */ h("li", {
137
+ className: "rounded-lg border border-border-subtle bg-bg-surface/40 p-3",
138
+ "data-testid": "sustained-load-evidence-item",
139
+ children: [
140
+ /* @__PURE__ */ h("div", {
141
+ className: "flex flex-wrap items-center gap-2",
142
+ children: [/* @__PURE__ */ m(r, {
143
+ variant: e.kind === "WITHIN_RANGE" ? "success" : "warning",
144
+ label: i(e.kind)
145
+ }), /* @__PURE__ */ m("span", {
146
+ className: "text-xs text-text-tertiary",
147
+ children: o(e.weekStart, e.weekEnd)
148
+ })]
149
+ }),
150
+ /* @__PURE__ */ m("p", {
151
+ className: "mt-1.5 text-sm text-text-secondary",
152
+ children: e.observation
153
+ }),
154
+ /* @__PURE__ */ h("button", {
155
+ type: "button",
156
+ onClick: () => y(`/timeline?date=${encodeURIComponent(e.weekStart)}`),
157
+ className: "mt-1.5 inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-action-primary-bg/40",
158
+ "data-testid": "sustained-load-evidence-link",
159
+ children: [
160
+ /* @__PURE__ */ m(d, { className: "h-3 w-3" }),
161
+ "Open this week on your timeline (",
162
+ e.refCount,
163
+ " ",
164
+ e.refCount === 1 ? "record" : "records",
165
+ ")"
166
+ ]
167
+ })
168
+ ]
169
+ }, `${e.weekStart}-${e.kind}`))
170
+ })]
171
+ })
172
+ ]
173
+ })]
174
+ })
175
+ });
176
+ }
177
+ //#endregion
178
+ export { v as SustainedLoadCard };
179
+
180
+ //# sourceMappingURL=SustainedLoadCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SustainedLoadCard.js","names":[],"sources":["../../../../src/timecampus/pages/work-patterns/SustainedLoadCard.tsx"],"sourcesContent":["import { AlertTriangle, ExternalLink, Info, ShieldCheck } from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport { LoadingSkeleton, StatusBadge } from \"../../components\";\nimport { useTimeCampusNavigate } from \"../../providers/TimeCampusProvider\";\nimport {\n useMySustainedLoadQuery,\n type MySustainedLoadQuery,\n} from \"@/generated/wspace-operations\";\nimport {\n evidenceKindLabel,\n formatShare,\n formatWeekRange,\n loadLevelLabel,\n loadLevelTone,\n loadProvenance,\n type LoadLevel,\n} from \"./sustainedLoad\";\n\ntype LoadSignal = MySustainedLoadQuery[\"mySustainedLoad\"];\ntype LoadWeekRow = LoadSignal[\"weeks\"][number];\ntype LoadEvidenceRow = LoadSignal[\"evidence\"][number];\n\nconst ACCENT: Record<ReturnType<typeof loadLevelTone>, string> = {\n error: \"bg-status-error-bg text-status-error-text\",\n warning: \"bg-status-warning-bg text-status-warning-text\",\n success: \"bg-status-success-bg text-status-success-text\",\n muted: \"bg-bg-surface text-text-secondary\",\n};\n\n/**\n * Sustained-load signal (BOFF-10427): whether the person's own load has been\n * heavy for several weeks running, with the rationale and the week-by-week\n * evidence the service used. The level comes from the service; this card\n * never derives one.\n */\nexport function SustainedLoadCard({ workspaceId }: { workspaceId: string }) {\n const navigate = useTimeCampusNavigate();\n const { data, loading, error } = useMySustainedLoadQuery({\n variables: { weeks: 4 },\n skip: !workspaceId,\n fetchPolicy: \"cache-and-network\",\n });\n const signal: LoadSignal | undefined = data?.mySustainedLoad;\n\n if (loading && !signal) {\n return <LoadingSkeleton variant=\"card\" count={1} />;\n }\n\n if (error || !signal) {\n return (\n <GlassCard treatment=\"glass\" className=\"p-5 sm:p-6\">\n <h3\n className=\"text-base font-semibold text-text-primary\"\n data-testid=\"sustained-load-card\"\n >\n Sustained load\n </h3>\n <p className=\"mt-1.5 text-sm text-text-secondary\">\n Your sustained-load reading could not be loaded right now. Please try\n again later.\n </p>\n </GlassCard>\n );\n }\n\n const level = signal.level as LoadLevel;\n const tone = loadLevelTone(level);\n const weeks: LoadWeekRow[] = signal.weeks;\n const evidence: LoadEvidenceRow[] = signal.evidence;\n\n return (\n <GlassCard\n treatment=\"glass\"\n glow={tone === \"error\" || tone === \"warning\"}\n className=\"p-5 sm:p-6\"\n >\n <div\n className=\"flex flex-col gap-4 sm:flex-row sm:items-start\"\n data-testid=\"sustained-load-card\"\n >\n <div\n className={`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl ${ACCENT[tone]}`}\n >\n {tone === \"success\" || tone === \"muted\" ? (\n <ShieldCheck className=\"h-5 w-5\" />\n ) : (\n <AlertTriangle className=\"h-5 w-5\" />\n )}\n </div>\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h3 className=\"text-base font-semibold text-text-primary\">\n Sustained load\n </h3>\n <span data-testid=\"sustained-load-level\" data-level={level}>\n <StatusBadge variant={tone} label={loadLevelLabel(level)} />\n </span>\n </div>\n <p\n className=\"mt-1.5 text-sm text-text-secondary\"\n data-testid=\"sustained-load-rationale\"\n >\n {signal.rationale}\n </p>\n <p\n className=\"mt-2 flex items-start gap-1.5 text-xs text-text-tertiary\"\n data-testid=\"sustained-load-provenance\"\n >\n <Info className=\"mt-0.5 h-3.5 w-3.5 shrink-0\" />\n <span>\n {loadProvenance({\n method: signal.method,\n model: signal.model,\n confidence: signal.confidence,\n fallbackReason: signal.fallbackReason,\n rulesLevel: signal.rulesLevel as LoadLevel,\n })}{\" \"}\n Only you can see this. It reads your load, never your output, and\n never compares you with anyone.\n </span>\n </p>\n\n {weeks.length > 0 && (\n <ul\n className=\"mt-4 grid grid-cols-2 gap-2 lg:grid-cols-4\"\n aria-label=\"Weekly load\"\n >\n {weeks.map((week: LoadWeekRow) => (\n <li\n key={week.weekStart}\n className={`rounded-lg border p-3 text-xs ${\n week.strained\n ? \"border-status-warning-border bg-status-warning-bg/20\"\n : \"border-border-subtle bg-bg-surface/40\"\n }`}\n data-testid=\"sustained-load-week\"\n >\n <p className=\"font-medium text-text-primary\">\n {formatWeekRange(week.weekStart, week.weekEnd)}\n </p>\n <dl className=\"mt-1 space-y-0.5 text-text-secondary\">\n <div className=\"flex justify-between gap-2\">\n <dt>Hours</dt>\n <dd className=\"tabular-nums text-text-primary\">\n {week.trackedHours.toFixed(1)}\n </dd>\n </div>\n <div className=\"flex justify-between gap-2\">\n <dt>After hours</dt>\n <dd className=\"tabular-nums text-text-primary\">\n {formatShare(week.afterHoursShare)}\n </dd>\n </div>\n <div className=\"flex justify-between gap-2\">\n <dt>Recovery days</dt>\n <dd className=\"tabular-nums text-text-primary\">\n {week.recoveryDays}\n </dd>\n </div>\n </dl>\n </li>\n ))}\n </ul>\n )}\n\n {evidence.length > 0 && (\n <details\n className=\"mt-4 group\"\n data-testid=\"sustained-load-evidence\"\n >\n <summary className=\"cursor-pointer text-sm font-medium text-text-primary\">\n Evidence ({evidence.length})\n </summary>\n <ul className=\"mt-2 space-y-2\">\n {evidence.map((item: LoadEvidenceRow) => (\n <li\n key={`${item.weekStart}-${item.kind}`}\n className=\"rounded-lg border border-border-subtle bg-bg-surface/40 p-3\"\n data-testid=\"sustained-load-evidence-item\"\n >\n <div className=\"flex flex-wrap items-center gap-2\">\n <StatusBadge\n variant={\n item.kind === \"WITHIN_RANGE\" ? \"success\" : \"warning\"\n }\n label={evidenceKindLabel(item.kind)}\n />\n <span className=\"text-xs text-text-tertiary\">\n {formatWeekRange(item.weekStart, item.weekEnd)}\n </span>\n </div>\n <p className=\"mt-1.5 text-sm text-text-secondary\">\n {item.observation}\n </p>\n <button\n type=\"button\"\n onClick={() =>\n navigate(\n `/timeline?date=${encodeURIComponent(item.weekStart)}`,\n )\n }\n className=\"mt-1.5 inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-action-primary-bg/40\"\n data-testid=\"sustained-load-evidence-link\"\n >\n <ExternalLink className=\"h-3 w-3\" />\n Open this week on your timeline ({item.refCount}{\" \"}\n {item.refCount === 1 ? \"record\" : \"records\"})\n </button>\n </li>\n ))}\n </ul>\n </details>\n )}\n </div>\n </div>\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;AAsBA,IAAM,IAA2D;CAC/D,OAAO;CACP,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAQA,SAAgB,EAAkB,EAAE,kBAAwC;CAC1E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,UAAA,EAAS,KAAK,MACb,kBAAC,MAAD;QAEE,WAAU;QACV,eAAY;QAHd,UAAA;SAKE,kBAAC,OAAD;UAAK,WAAU;UAAf,UAAA,CACE,kBAAC,GAAD;WACE,SACE,EAAK,SAAS,iBAAiB,YAAY;WAE7C,OAAO,EAAkB,EAAK,IAAI;UACnC,CAAA,GACD,kBAAC,QAAD;WAAM,WAAU;WACb,UAAA,EAAgB,EAAK,WAAW,EAAK,OAAO;UACzC,CAAA,CACH;;SACL,kBAAC,KAAD;UAAG,WAAU;UACV,UAAA,EAAK;SACL,CAAA;SACH,kBAAC,UAAD;UACE,MAAK;UACL,eACE,EACE,kBAAkB,mBAAmB,EAAK,SAAS,GACrD;UAEF,WAAU;UACV,eAAY;UARd,UAAA;WAUE,kBAAC,GAAD,EAAc,WAAU,UAAW,CAAA;WAAC;WACF,EAAK;WAAU;WAChD,EAAK,aAAa,IAAI,WAAW;WAAU;UACtC;;QACN;OAhCG,GAAA,GAAG,EAAK,UAAU,GAAG,EAAK,MAgC7B,CACL;MACC,CAAA,CACG;;IAER;GACF,CAAA,CAAA;;CACI,CAAA;AAEf"}
@@ -1 +1 @@
1
- {"version":3,"file":"WorkPatternsPage.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/work-patterns/WorkPatternsPage.tsx"],"names":[],"mappings":"AAkGA,wBAAgB,gBAAgB,gCA+U/B"}
1
+ {"version":3,"file":"WorkPatternsPage.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/work-patterns/WorkPatternsPage.tsx"],"names":[],"mappings":"AA2FA,wBAAgB,gBAAgB,gCA6O/B"}
@@ -2,19 +2,20 @@ import { useTimeCampus as e } from "../../providers/TimeCampusProvider.js";
2
2
  import { StatCard as t } from "../../components/StatCard.js";
3
3
  import { LoadingSkeleton as n } from "../../components/LoadingSkeleton.js";
4
4
  import { EmptyState as r } from "../../components/EmptyState.js";
5
- import { useGetWorkPatternSummaryQuery as i, useListWorkPatternsQuery as ee } from "../../../generated/wspace-operations.js";
6
- import { PageLayout as a } from "../../components/PageLayout.js";
7
- import { StatusBadge as o } from "../../components/StatusBadge.js";
8
- import { ChartCard as s } from "../../components/ChartCard.js";
9
- import { TrendChart as te } from "../../components/charts/TrendChart.js";
10
- import { Heatmap as c } from "../../components/charts/Heatmap.js";
5
+ import { useGetWorkPatternSummaryQuery as i, useListWorkPatternsQuery as a } from "../../../generated/wspace-operations.js";
6
+ import { PageLayout as o } from "../../components/PageLayout.js";
7
+ import { StatusBadge as s } from "../../components/StatusBadge.js";
8
+ import { ChartCard as c } from "../../components/ChartCard.js";
9
+ import { TrendChart as l } from "../../components/charts/TrendChart.js";
10
+ import { Heatmap as u } from "../../components/charts/Heatmap.js";
11
11
  import "../../components/index.js";
12
- import { WorkPatternInsightType as l } from "../../../generated/wspace-types.js";
13
- import { AlertTriangle as u, ArrowRight as d, Brain as f, Clock as p, Lightbulb as m, ShieldCheck as h, TrendingUp as ne, Zap as re } from "lucide-react";
14
- import { jsx as g, jsxs as _ } from "react/jsx-runtime";
15
- import { GlassCard as v } from "@burdenoff/fe-libs/ui";
12
+ import { WorkPatternInsightType as d } from "../../../generated/wspace-types.js";
13
+ import { SustainedLoadCard as f } from "./SustainedLoadCard.js";
14
+ import { ArrowRight as p, Brain as m, Clock as h, Lightbulb as g, TrendingUp as _, Zap as v } from "lucide-react";
15
+ import { jsx as y, jsxs as b } from "react/jsx-runtime";
16
+ import { GlassCard as x } from "@burdenoff/fe-libs/ui";
16
17
  //#region src/timecampus/pages/work-patterns/WorkPatternsPage.tsx
17
- var y = [
18
+ var S = [
18
19
  "Mon",
19
20
  "Tue",
20
21
  "Wed",
@@ -23,184 +24,147 @@ var y = [
23
24
  "Sat",
24
25
  "Sun"
25
26
  ];
26
- function b(e) {
27
+ function C(e) {
27
28
  return (e.getDay() + 6) % 7;
28
29
  }
29
- function x(e) {
30
+ function w(e) {
30
31
  let t = new Date(e);
31
- return t.setDate(e.getDate() - b(e)), t.setHours(0, 0, 0, 0), t;
32
+ return t.setDate(e.getDate() - C(e)), t.setHours(0, 0, 0, 0), t;
32
33
  }
33
- function S(e) {
34
+ function T(e) {
34
35
  let t = new Date(e);
35
36
  return Number.isNaN(t.getTime()) ? "" : t.toLocaleDateString(void 0, {
36
37
  month: "short",
37
38
  day: "numeric"
38
39
  });
39
40
  }
40
- var C = {
41
+ var E = {
41
42
  VERY_LOW: 1,
42
43
  LOW: 2,
43
44
  MEDIUM: 3,
44
45
  HIGH: 4,
45
46
  VERY_HIGH: 5
46
- }, ie = {
47
+ }, D = {
47
48
  VERY_NEGATIVE: 1,
48
49
  NEGATIVE: 2,
49
50
  NEUTRAL: 3,
50
51
  POSITIVE: 4,
51
52
  VERY_POSITIVE: 5
52
- }, ae = /* @__PURE__ */ new Set(["HIGH", "VERY_HIGH"]), oe = /* @__PURE__ */ new Set(["LOW", "VERY_LOW"]), se = (e) => `${e.toFixed(1)}h`, ce = {
53
- [l.Positive]: "success",
54
- [l.Negative]: "error",
55
- [l.Warning]: "warning",
56
- [l.Recommendation]: "info",
57
- [l.Neutral]: "muted"
58
- }, le = {
59
- [l.Positive]: "Positive",
60
- [l.Negative]: "Negative",
61
- [l.Warning]: "Warning",
62
- [l.Recommendation]: "Tip",
63
- [l.Neutral]: "Neutral"
53
+ }, O = (e) => `${e.toFixed(1)}h`, k = {
54
+ [d.Positive]: "success",
55
+ [d.Negative]: "error",
56
+ [d.Warning]: "warning",
57
+ [d.Recommendation]: "info",
58
+ [d.Neutral]: "muted"
59
+ }, A = {
60
+ [d.Positive]: "Positive",
61
+ [d.Negative]: "Negative",
62
+ [d.Warning]: "Warning",
63
+ [d.Recommendation]: "Tip",
64
+ [d.Neutral]: "Neutral"
64
65
  };
65
- function w() {
66
- let { workspaceId: w = "" } = e(), { data: ue, loading: T, error: E } = ee({
66
+ function j() {
67
+ let { workspaceId: d = "" } = e(), { data: j, loading: M, error: N } = a({
67
68
  variables: { pagination: { limit: 30 } },
68
- skip: !w
69
- }), { data: D, loading: O, error: k } = i({ skip: !w }), A = T || O, j = E || k, M = D?.workPatternSummary, N = ue?.workPatterns ?? [], P = M?.insights ?? [], F = [...N].sort((e, t) => {
69
+ skip: !d
70
+ }), { data: P, loading: F, error: I } = i({ skip: !d }), L = M || F, R = N || I, z = P?.workPatternSummary, B = j?.workPatterns ?? [], V = z?.insights ?? [], H = [...B].sort((e, t) => {
70
71
  let n = new Date(e.date).getTime(), r = new Date(t.date).getTime();
71
72
  return (Number.isNaN(n) ? 0 : n) - (Number.isNaN(r) ? 0 : r);
72
- }), I = N[0], L = M?.averageProductivity == null ? "--" : `${Math.round(M.averageProductivity)}%`, R = I?.focusHours == null ? "--" : `${I.focusHours.toFixed(1)}h`, z = I ? (I.focusHours + I.meetingHours + I.breakHours).toFixed(0) : "8", B = I?.deepWorkSessions == null ? "--" : String(I.deepWorkSessions), de = M?.mostProductiveDay ?? "--", V = [];
73
- for (let e of F) {
73
+ }), U = B[0], W = z?.averageProductivity == null ? "--" : `${Math.round(z.averageProductivity)}%`, G = U?.focusHours == null ? "--" : `${U.focusHours.toFixed(1)}h`, K = U ? (U.focusHours + U.meetingHours + U.breakHours).toFixed(0) : "8", q = U?.deepWorkSessions == null ? "--" : String(U.deepWorkSessions), J = z?.mostProductiveDay ?? "--", Y = [];
74
+ for (let e of H) {
74
75
  let t = new Date(e.date);
75
76
  if (Number.isNaN(t.getTime())) continue;
76
- let n = x(t).getTime();
77
- V.includes(n) || V.push(n);
77
+ let n = w(t).getTime();
78
+ Y.includes(n) || Y.push(n);
78
79
  }
79
- let H = V.slice(-6), fe = H.map((e) => S(new Date(e).toISOString())), U = y.map(() => H.map(() => null));
80
- for (let e of F) {
80
+ let X = Y.slice(-6), Z = X.map((e) => T(new Date(e).toISOString())), Q = S.map(() => X.map(() => null));
81
+ for (let e of H) {
81
82
  let t = new Date(e.date);
82
83
  if (Number.isNaN(t.getTime())) continue;
83
- let n = H.indexOf(x(t).getTime());
84
- n < 0 || (U[b(t)][n] = e.focusHours);
84
+ let n = X.indexOf(w(t).getTime());
85
+ n < 0 || (Q[C(t)][n] = e.focusHours);
85
86
  }
86
- let W = F.map((e) => ({
87
- date: S(e.date),
88
- energy: e.energyLevel == null ? null : C[e.energyLevel] ?? null,
89
- mood: e.mood == null ? null : ie[e.mood] ?? null
90
- })), pe = W.some((e) => e.energy != null || e.mood != null), G = N.slice(0, 7), K = G.length, q = G.filter((e) => e.stressLevel != null && ae.has(e.stressLevel)).length, J = G.filter((e) => e.energyLevel != null && oe.has(e.energyLevel)).length, Y = P.find((e) => e.type === l.Warning || e.type === l.Negative), X = Math.ceil(Math.max(K, 1) / 2), Z = "success";
91
- K > 0 && q >= X ? Z = "danger" : (q > 0 || J >= X || Y) && (Z = "warning"), Y?.type === l.Negative && (Z = "danger");
92
- let Q = [];
93
- q > 0 && Q.push(`${q} of your last ${K} logged day${K === 1 ? "" : "s"} showed high stress`), J > 0 && Q.push(`${J} showed low energy`);
94
- let me = Y?.title ?? (Z === "danger" ? "Sustained overload detected" : Z === "warning" ? "Watch your workload" : "Balanced workload"), he = Y?.description ?? (Z === "success" ? "Your recent stress and energy levels look healthy — keep protecting your focus blocks." : Q.length > 0 ? `${Q.join(" and ")}. Protect your deep-work time before it erodes.` : "Recent signals suggest an uneven balance — schedule focus time to stay ahead of overload."), $ = Y?.recommendation ?? null, ge = Z === "danger" ? "bg-status-error-bg text-status-error-text" : Z === "warning" ? "bg-status-warning-bg text-status-warning-text" : "bg-status-success-bg text-status-success-text";
95
- return A ? /* @__PURE__ */ g(a, {
87
+ let $ = H.map((e) => ({
88
+ date: T(e.date),
89
+ energy: e.energyLevel == null ? null : E[e.energyLevel] ?? null,
90
+ mood: e.mood == null ? null : D[e.mood] ?? null
91
+ })), ee = $.some((e) => e.energy != null || e.mood != null);
92
+ return L ? /* @__PURE__ */ y(o, {
96
93
  title: "Work Patterns",
97
94
  description: "Analyze your work habits and productivity patterns",
98
- children: /* @__PURE__ */ g(n, {
95
+ children: /* @__PURE__ */ y(n, {
99
96
  variant: "card",
100
97
  count: 4
101
98
  })
102
- }) : j ? /* @__PURE__ */ g(a, {
99
+ }) : R ? /* @__PURE__ */ y(o, {
103
100
  title: "Work Patterns",
104
101
  description: "Analyze your work habits and productivity patterns",
105
- children: /* @__PURE__ */ g("div", {
102
+ children: /* @__PURE__ */ y("div", {
106
103
  className: "rounded-xl border border-status-error-border/50 bg-status-error-bg/10 p-4 text-sm text-status-error-text",
107
104
  children: "Failed to load work patterns. Please try again later."
108
105
  })
109
- }) : /* @__PURE__ */ g(a, {
106
+ }) : /* @__PURE__ */ y(o, {
110
107
  title: "Work Patterns",
111
108
  description: "Analyze your work habits and productivity patterns",
112
109
  purpose: "Learn how you actually work across a typical week — when you focus best, where meetings pile up, and which day is your peak — so you can schedule deep work for the hours you're sharpest.",
113
- children: /* @__PURE__ */ _("div", {
110
+ children: /* @__PURE__ */ b("div", {
114
111
  className: "space-y-6",
115
112
  children: [
116
- /* @__PURE__ */ _("div", {
113
+ /* @__PURE__ */ b("div", {
117
114
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
118
115
  children: [
119
- /* @__PURE__ */ g(t, {
116
+ /* @__PURE__ */ y(t, {
120
117
  featured: !0,
121
118
  title: "Productivity Score",
122
- value: L,
123
- icon: /* @__PURE__ */ g(ne, { className: "h-5 w-5" }),
124
- trend: M?.averageProductivity == null ? void 0 : {
119
+ value: W,
120
+ icon: /* @__PURE__ */ y(_, { className: "h-5 w-5" }),
121
+ trend: z?.averageProductivity == null ? void 0 : {
125
122
  value: 5,
126
123
  label: "vs last week"
127
124
  }
128
125
  }),
129
- /* @__PURE__ */ g(t, {
126
+ /* @__PURE__ */ y(t, {
130
127
  title: "Focus Hours",
131
- value: R,
132
- icon: /* @__PURE__ */ g(f, { className: "h-5 w-5" }),
133
- description: `Out of ${z}h total`
128
+ value: G,
129
+ icon: /* @__PURE__ */ y(m, { className: "h-5 w-5" }),
130
+ description: `Out of ${K}h total`
134
131
  }),
135
- /* @__PURE__ */ g(t, {
132
+ /* @__PURE__ */ y(t, {
136
133
  title: "Peak Day",
137
- value: de,
138
- icon: /* @__PURE__ */ g(re, { className: "h-5 w-5" }),
134
+ value: J,
135
+ icon: /* @__PURE__ */ y(v, { className: "h-5 w-5" }),
139
136
  description: "Most productive day"
140
137
  }),
141
- /* @__PURE__ */ g(t, {
138
+ /* @__PURE__ */ y(t, {
142
139
  title: "Deep Work",
143
- value: `${B} sessions`,
144
- icon: /* @__PURE__ */ g(p, { className: "h-5 w-5" }),
140
+ value: `${q} sessions`,
141
+ icon: /* @__PURE__ */ y(h, { className: "h-5 w-5" }),
145
142
  description: "90+ min uninterrupted"
146
143
  })
147
144
  ]
148
145
  }),
149
- /* @__PURE__ */ g(v, {
150
- treatment: "glass",
151
- glow: Z !== "success",
152
- className: "p-5 sm:p-6",
153
- children: /* @__PURE__ */ _("div", {
154
- className: "flex flex-col gap-4 sm:flex-row sm:items-start",
155
- children: [/* @__PURE__ */ g("div", {
156
- className: `flex h-11 w-11 shrink-0 items-center justify-center rounded-xl ${ge}`,
157
- children: g(Z === "success" ? h : u, { className: "h-5 w-5" })
158
- }), /* @__PURE__ */ _("div", {
159
- className: "min-w-0 flex-1",
160
- children: [
161
- /* @__PURE__ */ _("div", {
162
- className: "flex flex-wrap items-center gap-2",
163
- children: [/* @__PURE__ */ g("h3", {
164
- className: "text-base font-semibold text-text-primary",
165
- children: "Burnout Signal"
166
- }), /* @__PURE__ */ g(o, {
167
- variant: Z === "danger" ? "error" : Z === "warning" ? "warning" : "success",
168
- label: me
169
- })]
170
- }),
171
- /* @__PURE__ */ g("p", {
172
- className: "mt-1.5 text-sm text-text-secondary",
173
- children: he
174
- }),
175
- $ && /* @__PURE__ */ _("p", {
176
- className: "mt-2 flex items-start gap-1.5 text-sm text-text-primary",
177
- children: [/* @__PURE__ */ g(m, { className: "mt-0.5 h-4 w-4 shrink-0 text-primary" }), /* @__PURE__ */ g("span", { children: $ })]
178
- })
179
- ]
180
- })]
181
- })
182
- }),
183
- /* @__PURE__ */ _("div", {
146
+ /* @__PURE__ */ y(f, { workspaceId: d }),
147
+ /* @__PURE__ */ b("div", {
184
148
  className: "grid grid-cols-1 gap-6 lg:grid-cols-2",
185
- children: [/* @__PURE__ */ g(s, {
149
+ children: [/* @__PURE__ */ y(c, {
186
150
  title: "Weekly Productive Hours",
187
151
  description: "Focused hours logged by weekday across recent weeks",
188
- children: /* @__PURE__ */ g(c, {
189
- data: U,
190
- rowLabels: [...y],
191
- columnLabels: fe,
152
+ children: /* @__PURE__ */ y(u, {
153
+ data: Q,
154
+ rowLabels: [...S],
155
+ columnLabels: Z,
192
156
  rowsLabel: "Day",
193
- valueFormat: se,
157
+ valueFormat: O,
194
158
  legendLabels: ["Fewer", "More"],
195
159
  height: 240,
196
160
  emptyLabel: "No work-pattern days logged yet.",
197
161
  ariaLabel: "Focused hours by weekday and week"
198
162
  })
199
- }), /* @__PURE__ */ g(s, {
163
+ }), /* @__PURE__ */ y(c, {
200
164
  title: "Energy & Mood Trends",
201
165
  description: "Self-reported energy and mood, each on a 1 (low) – 5 (high) scale",
202
- children: pe ? /* @__PURE__ */ g(te, {
203
- data: W,
166
+ children: ee ? /* @__PURE__ */ y(l, {
167
+ data: $,
204
168
  xKey: "date",
205
169
  series: [{
206
170
  key: "energy",
@@ -213,40 +177,40 @@ function w() {
213
177
  height: 240,
214
178
  emptyLabel: "No energy or mood check-ins yet.",
215
179
  ariaLabel: "Energy and mood over time"
216
- }) : /* @__PURE__ */ g(r, {
180
+ }) : /* @__PURE__ */ y(r, {
217
181
  title: "No energy or mood data yet",
218
182
  description: "Log how you feel on your work-pattern entries to see the trend here."
219
183
  })
220
184
  })]
221
185
  }),
222
- P.length > 0 && /* @__PURE__ */ _(v, {
186
+ V.length > 0 && /* @__PURE__ */ b(x, {
223
187
  treatment: "glass",
224
188
  className: "p-5 sm:p-6",
225
- children: [/* @__PURE__ */ _("h3", {
189
+ children: [/* @__PURE__ */ b("h3", {
226
190
  className: "mb-4 flex items-center gap-2 text-sm font-semibold text-text-primary",
227
- children: [/* @__PURE__ */ g(m, { className: "h-4 w-4 text-primary" }), "Insights"]
228
- }), /* @__PURE__ */ g("div", {
191
+ children: [/* @__PURE__ */ y(g, { className: "h-4 w-4 text-primary" }), "Insights"]
192
+ }), /* @__PURE__ */ y("div", {
229
193
  className: "space-y-3",
230
- children: P.map((e, t) => /* @__PURE__ */ _("div", {
194
+ children: V.map((e, t) => /* @__PURE__ */ b("div", {
231
195
  className: "rounded-lg border border-border-subtle bg-bg-surface/40 p-4",
232
196
  children: [
233
- /* @__PURE__ */ _("div", {
197
+ /* @__PURE__ */ b("div", {
234
198
  className: "flex flex-wrap items-center gap-2",
235
- children: [/* @__PURE__ */ g(o, {
236
- variant: ce[e.type],
237
- label: le[e.type]
238
- }), /* @__PURE__ */ g("p", {
199
+ children: [/* @__PURE__ */ y(s, {
200
+ variant: k[e.type],
201
+ label: A[e.type]
202
+ }), /* @__PURE__ */ y("p", {
239
203
  className: "text-sm font-medium text-text-primary",
240
204
  children: e.title
241
205
  })]
242
206
  }),
243
- /* @__PURE__ */ g("p", {
207
+ /* @__PURE__ */ y("p", {
244
208
  className: "mt-1.5 text-sm text-text-secondary",
245
209
  children: e.description
246
210
  }),
247
- e.recommendation && /* @__PURE__ */ _("p", {
211
+ e.recommendation && /* @__PURE__ */ b("p", {
248
212
  className: "mt-2 flex items-start gap-1.5 text-xs text-text-primary",
249
- children: [/* @__PURE__ */ g(d, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-primary" }), /* @__PURE__ */ g("span", { children: e.recommendation })]
213
+ children: [/* @__PURE__ */ y(p, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-primary" }), /* @__PURE__ */ y("span", { children: e.recommendation })]
250
214
  })
251
215
  ]
252
216
  }, `${e.type}-${t}`))
@@ -257,6 +221,6 @@ function w() {
257
221
  });
258
222
  }
259
223
  //#endregion
260
- export { w as WorkPatternsPage };
224
+ export { j as WorkPatternsPage };
261
225
 
262
226
  //# sourceMappingURL=WorkPatternsPage.js.map