@burdenoff/microfe-healthybowl 2026.811.7 → 2026.811.8
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.
|
@@ -1,314 +1,316 @@
|
|
|
1
1
|
import { HealthyBowlProvider as e } from "./context/HealthyBowlContext.js";
|
|
2
|
-
import { normalizeBasePath as t } from "./utils/helpers.js";
|
|
3
|
-
import { ErrorBoundary as
|
|
4
|
-
import { ConfirmProvider as
|
|
5
|
-
import { HealthyBowlRoutes as
|
|
6
|
-
import { OfflineSyncProvider as
|
|
7
|
-
import { useCallback as
|
|
8
|
-
import { useI18n as
|
|
9
|
-
import { Award as
|
|
10
|
-
import { jsx as
|
|
11
|
-
import { FeatureFlagProvider as
|
|
2
|
+
import { normalizeBasePath as t, setHbFormatLocale as n } from "./utils/helpers.js";
|
|
3
|
+
import { ErrorBoundary as r } from "./components/ErrorBoundary.js";
|
|
4
|
+
import { ConfirmProvider as i } from "./components/ConfirmDialog.js";
|
|
5
|
+
import { HealthyBowlRoutes as a } from "./HealthyBowlRoutes.js";
|
|
6
|
+
import { OfflineSyncProvider as o } from "./offline/OfflineSyncProvider.js";
|
|
7
|
+
import { useCallback as s, useEffect as c } from "react";
|
|
8
|
+
import { useI18n as l } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
9
|
+
import { Award as u, Banknote as d, BarChart3 as f, Bug as p, Cloud as m, CloudUpload as h, DollarSign as g, Factory as _, Fence as v, FlaskConical as y, Globe as b, Home as x, Landmark as S, Leaf as C, LineChart as w, ListChecks as T, Map as E, Package as D, PawPrint as O, Radio as k, RefreshCw as A, ScanLine as j, ScanSearch as M, ShieldAlert as N, ShieldCheck as P, ShoppingCart as F, Sprout as I, Stethoscope as L, Tractor as R, UserCheck as z, Users as B, Users2 as V, Wheat as H } from "lucide-react";
|
|
10
|
+
import { jsx as U } from "react/jsx-runtime";
|
|
11
|
+
import { FeatureFlagProvider as W } from "@burdenoff/fe-libs/shared/feature-flags";
|
|
12
12
|
//#region src/healthybowl/HealthyBowlRoot.tsx
|
|
13
|
-
var
|
|
14
|
-
let { registerNavItems:
|
|
15
|
-
|
|
13
|
+
var G = (G) => {
|
|
14
|
+
let { registerNavItems: K, registerFooterItems: q, basePath: J = "/" } = G, { t: Y, locale: X } = l();
|
|
15
|
+
n(X);
|
|
16
|
+
let Z = s((e, t) => {
|
|
17
|
+
let n = Y(e);
|
|
16
18
|
return n === e ? t : n;
|
|
17
|
-
}, [
|
|
18
|
-
return
|
|
19
|
-
if (
|
|
19
|
+
}, [Y]), Q = (e, t) => (e.endsWith("/") ? e.slice(0, -1) : e) + (t.startsWith("/") ? t : `/${t}`);
|
|
20
|
+
return c(() => {
|
|
21
|
+
if (K) return K([
|
|
20
22
|
{
|
|
21
23
|
id: "healthybowl-dashboard",
|
|
22
|
-
label:
|
|
23
|
-
path: t(
|
|
24
|
-
icon: /* @__PURE__ */
|
|
24
|
+
label: Z("healthybowl.nav.dashboard", "Dashboard"),
|
|
25
|
+
path: t(J),
|
|
26
|
+
icon: /* @__PURE__ */ U(x, { size: 20 }),
|
|
25
27
|
order: 1,
|
|
26
28
|
group: "main"
|
|
27
29
|
},
|
|
28
30
|
{
|
|
29
31
|
id: "healthybowl-farm",
|
|
30
|
-
label:
|
|
31
|
-
path:
|
|
32
|
-
icon: /* @__PURE__ */
|
|
32
|
+
label: Z("healthybowl.nav.farm", "My Farm"),
|
|
33
|
+
path: Q(J, "farm"),
|
|
34
|
+
icon: /* @__PURE__ */ U(R, { size: 20 }),
|
|
33
35
|
order: 2,
|
|
34
36
|
group: "main"
|
|
35
37
|
},
|
|
36
38
|
{
|
|
37
39
|
id: "healthybowl-tasks",
|
|
38
|
-
label:
|
|
39
|
-
path:
|
|
40
|
-
icon: /* @__PURE__ */
|
|
40
|
+
label: Z("healthybowl.nav.tasks", "Tasks"),
|
|
41
|
+
path: Q(J, "tasks"),
|
|
42
|
+
icon: /* @__PURE__ */ U(T, { size: 20 }),
|
|
41
43
|
order: 3,
|
|
42
44
|
group: "main"
|
|
43
45
|
},
|
|
44
46
|
{
|
|
45
47
|
id: "healthybowl-crops",
|
|
46
|
-
label:
|
|
47
|
-
path:
|
|
48
|
-
icon: /* @__PURE__ */ H
|
|
48
|
+
label: Z("healthybowl.nav.crops", "Crops"),
|
|
49
|
+
path: Q(J, "crops"),
|
|
50
|
+
icon: /* @__PURE__ */ U(H, { size: 20 }),
|
|
49
51
|
order: 10,
|
|
50
52
|
group: "farming"
|
|
51
53
|
},
|
|
52
54
|
{
|
|
53
55
|
id: "healthybowl-livestock",
|
|
54
|
-
label:
|
|
55
|
-
path:
|
|
56
|
-
icon: /* @__PURE__ */
|
|
56
|
+
label: Z("healthybowl.nav.livestock", "Livestock"),
|
|
57
|
+
path: Q(J, "livestock"),
|
|
58
|
+
icon: /* @__PURE__ */ U(O, { size: 20 }),
|
|
57
59
|
order: 11,
|
|
58
60
|
group: "farming"
|
|
59
61
|
},
|
|
60
62
|
{
|
|
61
63
|
id: "healthybowl-livestock-analytics",
|
|
62
|
-
label:
|
|
63
|
-
path:
|
|
64
|
-
icon: /* @__PURE__ */
|
|
64
|
+
label: Z("healthybowl.nav.livestockAnalytics", "Livestock Analytics"),
|
|
65
|
+
path: Q(J, "livestock/analytics"),
|
|
66
|
+
icon: /* @__PURE__ */ U(w, { size: 20 }),
|
|
65
67
|
order: 11.3,
|
|
66
68
|
group: "farming"
|
|
67
69
|
},
|
|
68
70
|
{
|
|
69
71
|
id: "healthybowl-grazing",
|
|
70
|
-
label:
|
|
71
|
-
path:
|
|
72
|
-
icon: /* @__PURE__ */
|
|
72
|
+
label: Z("healthybowl.nav.grazing", "Grazing"),
|
|
73
|
+
path: Q(J, "livestock/grazing"),
|
|
74
|
+
icon: /* @__PURE__ */ U(v, { size: 20 }),
|
|
73
75
|
order: 11.4,
|
|
74
76
|
group: "farming"
|
|
75
77
|
},
|
|
76
78
|
{
|
|
77
79
|
id: "healthybowl-withdrawal-alerts",
|
|
78
|
-
label:
|
|
79
|
-
path:
|
|
80
|
-
icon: /* @__PURE__ */
|
|
80
|
+
label: Z("healthybowl.nav.withdrawalAlerts", "Withdrawal Alerts"),
|
|
81
|
+
path: Q(J, "livestock/withdrawal-alerts"),
|
|
82
|
+
icon: /* @__PURE__ */ U(N, { size: 20 }),
|
|
81
83
|
order: 11.5,
|
|
82
84
|
group: "farming"
|
|
83
85
|
},
|
|
84
86
|
{
|
|
85
87
|
id: "healthybowl-weather",
|
|
86
|
-
label:
|
|
87
|
-
path:
|
|
88
|
-
icon: /* @__PURE__ */
|
|
88
|
+
label: Z("healthybowl.nav.weather", "Weather"),
|
|
89
|
+
path: Q(J, "weather"),
|
|
90
|
+
icon: /* @__PURE__ */ U(m, { size: 20 }),
|
|
89
91
|
order: 12,
|
|
90
92
|
group: "farming"
|
|
91
93
|
},
|
|
92
94
|
{
|
|
93
95
|
id: "healthybowl-field-map",
|
|
94
|
-
label:
|
|
95
|
-
path:
|
|
96
|
-
icon: /* @__PURE__ */
|
|
96
|
+
label: Z("healthybowl.nav.fieldMap", "Field Map"),
|
|
97
|
+
path: Q(J, "field-map"),
|
|
98
|
+
icon: /* @__PURE__ */ U(E, { size: 20 }),
|
|
97
99
|
order: 12.5,
|
|
98
100
|
group: "farming"
|
|
99
101
|
},
|
|
100
102
|
{
|
|
101
103
|
id: "healthybowl-field-capture",
|
|
102
|
-
label:
|
|
103
|
-
path:
|
|
104
|
-
icon: /* @__PURE__ */
|
|
104
|
+
label: Z("healthybowl.nav.fieldCapture", "Field Capture"),
|
|
105
|
+
path: Q(J, "field-capture"),
|
|
106
|
+
icon: /* @__PURE__ */ U(h, { size: 20 }),
|
|
105
107
|
order: 12.6,
|
|
106
108
|
group: "farming"
|
|
107
109
|
},
|
|
108
110
|
{
|
|
109
111
|
id: "healthybowl-pending-sync",
|
|
110
|
-
label:
|
|
111
|
-
path:
|
|
112
|
-
icon: /* @__PURE__ */
|
|
112
|
+
label: Z("healthybowl.nav.pendingSync", "Pending Sync"),
|
|
113
|
+
path: Q(J, "field-capture/pending"),
|
|
114
|
+
icon: /* @__PURE__ */ U(A, { size: 20 }),
|
|
113
115
|
order: 12.7,
|
|
114
116
|
group: "farming"
|
|
115
117
|
},
|
|
116
118
|
{
|
|
117
119
|
id: "healthybowl-field-sensors",
|
|
118
|
-
label:
|
|
119
|
-
path:
|
|
120
|
-
icon: /* @__PURE__ */
|
|
120
|
+
label: Z("healthybowl.nav.fieldSensors", "Field Sensors"),
|
|
121
|
+
path: Q(J, "field-sensors"),
|
|
122
|
+
icon: /* @__PURE__ */ U(k, { size: 20 }),
|
|
121
123
|
order: 12.75,
|
|
122
124
|
group: "farming"
|
|
123
125
|
},
|
|
124
126
|
{
|
|
125
127
|
id: "healthybowl-soil",
|
|
126
|
-
label:
|
|
127
|
-
path:
|
|
128
|
-
icon: /* @__PURE__ */
|
|
128
|
+
label: Z("healthybowl.nav.soilHealth", "Soil Health"),
|
|
129
|
+
path: Q(J, "soil"),
|
|
130
|
+
icon: /* @__PURE__ */ U(y, { size: 20 }),
|
|
129
131
|
order: 13,
|
|
130
132
|
group: "farming"
|
|
131
133
|
},
|
|
132
134
|
{
|
|
133
135
|
id: "healthybowl-pest",
|
|
134
|
-
label:
|
|
135
|
-
path:
|
|
136
|
-
icon: /* @__PURE__ */
|
|
136
|
+
label: Z("healthybowl.nav.pestManagement", "Pest Management"),
|
|
137
|
+
path: Q(J, "pest-management"),
|
|
138
|
+
icon: /* @__PURE__ */ U(p, { size: 20 }),
|
|
137
139
|
order: 14,
|
|
138
140
|
group: "farming"
|
|
139
141
|
},
|
|
140
142
|
{
|
|
141
143
|
id: "healthybowl-pest-ai",
|
|
142
|
-
label:
|
|
143
|
-
path:
|
|
144
|
-
icon: /* @__PURE__ */
|
|
144
|
+
label: Z("healthybowl.nav.aiPestDetection", "AI Pest Detection"),
|
|
145
|
+
path: Q(J, "pest-management/ai-detection"),
|
|
146
|
+
icon: /* @__PURE__ */ U(M, { size: 20 }),
|
|
145
147
|
order: 14.5,
|
|
146
148
|
group: "farming"
|
|
147
149
|
},
|
|
148
150
|
{
|
|
149
151
|
id: "healthybowl-production",
|
|
150
|
-
label:
|
|
151
|
-
path:
|
|
152
|
-
icon: /* @__PURE__ */
|
|
152
|
+
label: Z("healthybowl.nav.production", "Production"),
|
|
153
|
+
path: Q(J, "production"),
|
|
154
|
+
icon: /* @__PURE__ */ U(_, { size: 20 }),
|
|
153
155
|
order: 20,
|
|
154
156
|
group: "business"
|
|
155
157
|
},
|
|
156
158
|
{
|
|
157
159
|
id: "healthybowl-products",
|
|
158
|
-
label:
|
|
159
|
-
path:
|
|
160
|
-
icon: /* @__PURE__ */
|
|
160
|
+
label: Z("healthybowl.nav.products", "Products"),
|
|
161
|
+
path: Q(J, "products"),
|
|
162
|
+
icon: /* @__PURE__ */ U(D, { size: 20 }),
|
|
161
163
|
order: 21,
|
|
162
164
|
group: "business"
|
|
163
165
|
},
|
|
164
166
|
{
|
|
165
167
|
id: "healthybowl-marketplace",
|
|
166
|
-
label:
|
|
167
|
-
path:
|
|
168
|
-
icon: /* @__PURE__ */
|
|
168
|
+
label: Z("healthybowl.nav.marketplace", "Marketplace"),
|
|
169
|
+
path: Q(J, "marketplace"),
|
|
170
|
+
icon: /* @__PURE__ */ U(F, { size: 20 }),
|
|
169
171
|
order: 22,
|
|
170
172
|
group: "business"
|
|
171
173
|
},
|
|
172
174
|
{
|
|
173
175
|
id: "healthybowl-coop",
|
|
174
|
-
label:
|
|
175
|
-
path:
|
|
176
|
-
icon: /* @__PURE__ */
|
|
176
|
+
label: Z("healthybowl.nav.coop", "Co-operative"),
|
|
177
|
+
path: Q(J, "coop"),
|
|
178
|
+
icon: /* @__PURE__ */ U(V, { size: 20 }),
|
|
177
179
|
order: 22.5,
|
|
178
180
|
group: "business"
|
|
179
181
|
},
|
|
180
182
|
{
|
|
181
183
|
id: "healthybowl-financial",
|
|
182
|
-
label:
|
|
183
|
-
path:
|
|
184
|
-
icon: /* @__PURE__ */
|
|
184
|
+
label: Z("healthybowl.nav.financial", "Financial"),
|
|
185
|
+
path: Q(J, "financial"),
|
|
186
|
+
icon: /* @__PURE__ */ U(g, { size: 20 }),
|
|
185
187
|
order: 23,
|
|
186
188
|
group: "business"
|
|
187
189
|
},
|
|
188
190
|
{
|
|
189
191
|
id: "healthybowl-financier",
|
|
190
|
-
label:
|
|
191
|
-
path:
|
|
192
|
-
icon: /* @__PURE__ */
|
|
192
|
+
label: Z("healthybowl.nav.financier", "Financier"),
|
|
193
|
+
path: Q(J, "financier"),
|
|
194
|
+
icon: /* @__PURE__ */ U(d, { size: 20 }),
|
|
193
195
|
order: 24,
|
|
194
196
|
group: "business"
|
|
195
197
|
},
|
|
196
198
|
{
|
|
197
199
|
id: "healthybowl-compliance",
|
|
198
|
-
label:
|
|
199
|
-
path:
|
|
200
|
-
icon: /* @__PURE__ */
|
|
200
|
+
label: Z("healthybowl.nav.compliance", "Compliance"),
|
|
201
|
+
path: Q(J, "compliance"),
|
|
202
|
+
icon: /* @__PURE__ */ U(P, { size: 20 }),
|
|
201
203
|
order: 30,
|
|
202
204
|
group: "compliance"
|
|
203
205
|
},
|
|
204
206
|
{
|
|
205
207
|
id: "healthybowl-traceability",
|
|
206
|
-
label:
|
|
207
|
-
path:
|
|
208
|
-
icon: /* @__PURE__ */
|
|
208
|
+
label: Z("healthybowl.nav.traceability", "Traceability"),
|
|
209
|
+
path: Q(J, "traceability"),
|
|
210
|
+
icon: /* @__PURE__ */ U(j, { size: 20 }),
|
|
209
211
|
order: 31,
|
|
210
212
|
group: "compliance"
|
|
211
213
|
},
|
|
212
214
|
{
|
|
213
215
|
id: "healthybowl-sustainability",
|
|
214
|
-
label:
|
|
215
|
-
path:
|
|
216
|
-
icon: /* @__PURE__ */
|
|
216
|
+
label: Z("healthybowl.nav.sustainability", "Sustainability"),
|
|
217
|
+
path: Q(J, "sustainability"),
|
|
218
|
+
icon: /* @__PURE__ */ U(C, { size: 20 }),
|
|
217
219
|
order: 32,
|
|
218
220
|
group: "compliance"
|
|
219
221
|
},
|
|
220
222
|
{
|
|
221
223
|
id: "healthybowl-sustainability-carbon",
|
|
222
|
-
label:
|
|
223
|
-
path:
|
|
224
|
-
icon: /* @__PURE__ */
|
|
224
|
+
label: Z("healthybowl.nav.sustainabilityCarbon", "Carbon & GHG"),
|
|
225
|
+
path: Q(J, "sustainability/carbon"),
|
|
226
|
+
icon: /* @__PURE__ */ U(_, { size: 20 }),
|
|
225
227
|
order: 32.1,
|
|
226
228
|
group: "compliance"
|
|
227
229
|
},
|
|
228
230
|
{
|
|
229
231
|
id: "healthybowl-sustainability-soil",
|
|
230
|
-
label:
|
|
231
|
-
path:
|
|
232
|
-
icon: /* @__PURE__ */
|
|
232
|
+
label: Z("healthybowl.nav.sustainabilitySoil", "Soil Carbon"),
|
|
233
|
+
path: Q(J, "sustainability/soil-carbon"),
|
|
234
|
+
icon: /* @__PURE__ */ U(I, { size: 20 }),
|
|
233
235
|
order: 32.2,
|
|
234
236
|
group: "compliance"
|
|
235
237
|
},
|
|
236
238
|
{
|
|
237
239
|
id: "healthybowl-sustainability-credits",
|
|
238
|
-
label:
|
|
239
|
-
path:
|
|
240
|
-
icon: /* @__PURE__ */
|
|
240
|
+
label: Z("healthybowl.nav.sustainabilityCredits", "Carbon Credits"),
|
|
241
|
+
path: Q(J, "sustainability/credits"),
|
|
242
|
+
icon: /* @__PURE__ */ U(u, { size: 20 }),
|
|
241
243
|
order: 32.3,
|
|
242
244
|
group: "compliance"
|
|
243
245
|
},
|
|
244
246
|
{
|
|
245
247
|
id: "healthybowl-sustainability-eudr",
|
|
246
|
-
label:
|
|
247
|
-
path:
|
|
248
|
-
icon: /* @__PURE__ */
|
|
248
|
+
label: Z("healthybowl.nav.sustainabilityEudr", "EUDR Due-Diligence"),
|
|
249
|
+
path: Q(J, "sustainability/eudr"),
|
|
250
|
+
icon: /* @__PURE__ */ U(b, { size: 20 }),
|
|
249
251
|
order: 32.4,
|
|
250
252
|
group: "compliance"
|
|
251
253
|
},
|
|
252
254
|
{
|
|
253
255
|
id: "healthybowl-schemes",
|
|
254
|
-
label:
|
|
255
|
-
path:
|
|
256
|
-
icon: /* @__PURE__ */
|
|
256
|
+
label: Z("healthybowl.nav.governmentSchemes", "Gov. Schemes"),
|
|
257
|
+
path: Q(J, "government-schemes"),
|
|
258
|
+
icon: /* @__PURE__ */ U(S, { size: 20 }),
|
|
257
259
|
order: 40,
|
|
258
260
|
group: "support"
|
|
259
261
|
},
|
|
260
262
|
{
|
|
261
263
|
id: "healthybowl-network",
|
|
262
|
-
label:
|
|
263
|
-
path:
|
|
264
|
-
icon: /* @__PURE__ */
|
|
264
|
+
label: Z("healthybowl.nav.network", "Network"),
|
|
265
|
+
path: Q(J, "network"),
|
|
266
|
+
icon: /* @__PURE__ */ U(B, { size: 20 }),
|
|
265
267
|
order: 41,
|
|
266
268
|
group: "support"
|
|
267
269
|
},
|
|
268
270
|
{
|
|
269
271
|
id: "healthybowl-analytics",
|
|
270
|
-
label:
|
|
271
|
-
path:
|
|
272
|
-
icon: /* @__PURE__ */
|
|
272
|
+
label: Z("healthybowl.nav.analytics", "Analytics"),
|
|
273
|
+
path: Q(J, "analytics"),
|
|
274
|
+
icon: /* @__PURE__ */ U(f, { size: 20 }),
|
|
273
275
|
order: 42,
|
|
274
276
|
group: "support"
|
|
275
277
|
},
|
|
276
278
|
{
|
|
277
279
|
id: "healthybowl-advisors",
|
|
278
|
-
label:
|
|
279
|
-
path:
|
|
280
|
-
icon: /* @__PURE__ */
|
|
280
|
+
label: Z("healthybowl.nav.advisors", "My Advisors"),
|
|
281
|
+
path: Q(J, "advisors"),
|
|
282
|
+
icon: /* @__PURE__ */ U(z, { size: 20 }),
|
|
281
283
|
order: 43,
|
|
282
284
|
group: "support"
|
|
283
285
|
},
|
|
284
286
|
{
|
|
285
287
|
id: "healthybowl-consultant",
|
|
286
|
-
label:
|
|
287
|
-
path:
|
|
288
|
-
icon: /* @__PURE__ */
|
|
288
|
+
label: Z("healthybowl.nav.consultant", "Consultant"),
|
|
289
|
+
path: Q(J, "consultant"),
|
|
290
|
+
icon: /* @__PURE__ */ U(L, { size: 20 }),
|
|
289
291
|
order: 44,
|
|
290
292
|
group: "support"
|
|
291
293
|
}
|
|
292
294
|
]);
|
|
293
|
-
}, [
|
|
294
|
-
if (
|
|
295
|
+
}, [K, J]), c(() => {
|
|
296
|
+
if (q) return q([{
|
|
295
297
|
id: "healthybowl-status",
|
|
296
|
-
label:
|
|
298
|
+
label: Z("healthybowl.footer.ready", "HealthyBowl Ready"),
|
|
297
299
|
type: "status",
|
|
298
300
|
order: 10,
|
|
299
301
|
section: "left"
|
|
300
302
|
}]);
|
|
301
|
-
}, [
|
|
303
|
+
}, [q]), /* @__PURE__ */ U(W, {
|
|
302
304
|
workspaceId: null,
|
|
303
305
|
gateway: "global",
|
|
304
306
|
defaultEnabled: !0,
|
|
305
|
-
children: /* @__PURE__ */
|
|
306
|
-
...
|
|
307
|
-
children: /* @__PURE__ */
|
|
307
|
+
children: /* @__PURE__ */ U(e, {
|
|
308
|
+
...G,
|
|
309
|
+
children: /* @__PURE__ */ U(r, { children: /* @__PURE__ */ U(i, { children: /* @__PURE__ */ U(o, { children: /* @__PURE__ */ U(a, {}) }) }) })
|
|
308
310
|
})
|
|
309
311
|
});
|
|
310
312
|
};
|
|
311
313
|
//#endregion
|
|
312
|
-
export {
|
|
314
|
+
export { G as HealthyBowlRoot };
|
|
313
315
|
|
|
314
316
|
//# sourceMappingURL=HealthyBowlRoot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HealthyBowlRoot.js","names":[],"sources":["../../src/healthybowl/HealthyBowlRoot.tsx"],"sourcesContent":["/**\n * HealthyBowl Root Component\n * @module healthybowl\n */\n\nimport type { FC } from 'react';\nimport { useCallback, useEffect } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n Home,\n Tractor,\n ListChecks,\n Wheat,\n PawPrint,\n Cloud,\n Map as MapIcon,\n ShoppingCart,\n DollarSign,\n BarChart3,\n FlaskConical,\n Bug,\n ScanSearch,\n Factory,\n Package,\n ScanLine,\n ShieldCheck,\n Landmark,\n Banknote,\n Stethoscope,\n UserCheck,\n Users,\n CloudUpload,\n RefreshCw,\n ShieldAlert,\n LineChart,\n Fence,\n Radio,\n Leaf,\n Sprout,\n Award,\n Globe,\n Users2,\n} from 'lucide-react';\nimport { HealthyBowlProvider } from './context/HealthyBowlContext';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { HealthyBowlRoutes } from './HealthyBowlRoutes';\nimport { ErrorBoundary } from './components/ErrorBoundary';\nimport { ConfirmProvider } from './components/ConfirmDialog';\nimport { OfflineSyncProvider } from './offline/OfflineSyncProvider';\nimport { normalizeBasePath } from './utils/helpers';\nimport type { HealthyBowlRootProps, NavItem } from './types';\n\nexport const HealthyBowlRoot: FC<HealthyBowlRootProps> = (props) => {\n const { registerNavItems, registerFooterItems, basePath = '/' } = props;\n const { t: translate } = useI18n();\n const t = useCallback(\n (key: string, fallback: string): string => {\n const value = translate(key);\n return value === key ? fallback : value;\n },\n [translate]\n );\n\n // Helper to join paths correctly\n const joinPath = (base: string, path: string): string => {\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return cleanBase + cleanPath;\n };\n\n // Register navigation items with shell on mount\n useEffect(() => {\n if (!registerNavItems) return;\n\n const navItems: NavItem[] = [\n // Dashboard\n {\n id: 'healthybowl-dashboard',\n label: t('healthybowl.nav.dashboard', 'Dashboard'),\n // The product index IS the dashboard. Normalize a trailing slash like\n // every sibling item (joinPath) so active-state highlighting matches if\n // the host ever passes '/healthybowl/'.\n path: normalizeBasePath(basePath),\n icon: <Home size={20} />,\n order: 1,\n group: 'main',\n },\n\n // My Farm\n {\n id: 'healthybowl-farm',\n label: t('healthybowl.nav.farm', 'My Farm'),\n path: joinPath(basePath, 'farm'),\n icon: <Tractor size={20} />,\n order: 2,\n group: 'main',\n },\n\n // Farm Tasks (PlanMagnet embed) — shared work-item board across the farm.\n {\n id: 'healthybowl-tasks',\n label: t('healthybowl.nav.tasks', 'Tasks'),\n path: joinPath(basePath, 'tasks'),\n icon: <ListChecks size={20} />,\n order: 3,\n group: 'main',\n },\n\n // Crops\n {\n id: 'healthybowl-crops',\n label: t('healthybowl.nav.crops', 'Crops'),\n path: joinPath(basePath, 'crops'),\n icon: <Wheat size={20} />,\n order: 10,\n group: 'farming',\n },\n\n // Livestock\n {\n id: 'healthybowl-livestock',\n label: t('healthybowl.nav.livestock', 'Livestock'),\n path: joinPath(basePath, 'livestock'),\n icon: <PawPrint size={20} />,\n order: 11,\n group: 'farming',\n },\n\n // Livestock — Analytics (BOFF-6126). The growth, feed and herd-stats charts (BOFF-5971) also\n // render inline on the livestock dashboard; this gives them a dedicated URL and full-width home.\n {\n id: 'healthybowl-livestock-analytics',\n label: t('healthybowl.nav.livestockAnalytics', 'Livestock Analytics'),\n path: joinPath(basePath, 'livestock/analytics'),\n icon: <LineChart size={20} />,\n order: 11.3,\n group: 'farming',\n },\n\n // Livestock — Grazing management (BOFF-5970). Sits next to Livestock rather than inside it\n // because rotational grazing is a daily decision about FIELDS, not a herd-record lookup.\n {\n id: 'healthybowl-grazing',\n label: t('healthybowl.nav.grazing', 'Grazing'),\n path: joinPath(basePath, 'livestock/grazing'),\n icon: <Fence size={20} />,\n order: 11.4,\n group: 'farming',\n },\n\n // Livestock — Medication Withdrawal Alerts (BOFF-2885)\n {\n id: 'healthybowl-withdrawal-alerts',\n label: t('healthybowl.nav.withdrawalAlerts', 'Withdrawal Alerts'),\n path: joinPath(basePath, 'livestock/withdrawal-alerts'),\n icon: <ShieldAlert size={20} />,\n order: 11.5,\n group: 'farming',\n },\n\n // Weather\n {\n id: 'healthybowl-weather',\n label: t('healthybowl.nav.weather', 'Weather'),\n path: joinPath(basePath, 'weather'),\n icon: <Cloud size={20} />,\n order: 12,\n group: 'farming',\n },\n\n // Field Map — draw & manage field boundaries on satellite imagery\n {\n id: 'healthybowl-field-map',\n label: t('healthybowl.nav.fieldMap', 'Field Map'),\n path: joinPath(basePath, 'field-map'),\n icon: <MapIcon size={20} />,\n order: 12.5,\n group: 'farming',\n },\n\n // Field Capture — offline-first observation capture (BOFF-2883)\n {\n id: 'healthybowl-field-capture',\n label: t('healthybowl.nav.fieldCapture', 'Field Capture'),\n path: joinPath(basePath, 'field-capture'),\n icon: <CloudUpload size={20} />,\n order: 12.6,\n group: 'farming',\n },\n\n // Pending Sync — the offline outbox / sync queue (BOFF-2883)\n {\n id: 'healthybowl-pending-sync',\n label: t('healthybowl.nav.pendingSync', 'Pending Sync'),\n path: joinPath(basePath, 'field-capture/pending'),\n icon: <RefreshCw size={20} />,\n order: 12.7,\n group: 'farming',\n },\n\n // Field Sensors — live probe monitoring (BOFF-2894)\n {\n id: 'healthybowl-field-sensors',\n label: t('healthybowl.nav.fieldSensors', 'Field Sensors'),\n path: joinPath(basePath, 'field-sensors'),\n icon: <Radio size={20} />,\n order: 12.75,\n group: 'farming',\n },\n\n // Soil Health\n {\n id: 'healthybowl-soil',\n label: t('healthybowl.nav.soilHealth', 'Soil Health'),\n path: joinPath(basePath, 'soil'),\n icon: <FlaskConical size={20} />,\n order: 13,\n group: 'farming',\n },\n\n // Pest Management\n {\n id: 'healthybowl-pest',\n label: t('healthybowl.nav.pestManagement', 'Pest Management'),\n path: joinPath(basePath, 'pest-management'),\n icon: <Bug size={20} />,\n order: 14,\n group: 'farming',\n },\n {\n id: 'healthybowl-pest-ai',\n label: t('healthybowl.nav.aiPestDetection', 'AI Pest Detection'),\n path: joinPath(basePath, 'pest-management/ai-detection'),\n icon: <ScanSearch size={20} />,\n order: 14.5,\n group: 'farming',\n },\n\n // Production\n {\n id: 'healthybowl-production',\n label: t('healthybowl.nav.production', 'Production'),\n path: joinPath(basePath, 'production'),\n icon: <Factory size={20} />,\n order: 20,\n group: 'business',\n },\n\n // Products\n {\n id: 'healthybowl-products',\n label: t('healthybowl.nav.products', 'Products'),\n path: joinPath(basePath, 'products'),\n icon: <Package size={20} />,\n order: 21,\n group: 'business',\n },\n\n // Marketplace\n {\n id: 'healthybowl-marketplace',\n label: t('healthybowl.nav.marketplace', 'Marketplace'),\n path: joinPath(basePath, 'marketplace'),\n icon: <ShoppingCart size={20} />,\n order: 22,\n group: 'business',\n },\n\n // Co-operative / FPO aggregation (BOFF-6023)\n {\n id: 'healthybowl-coop',\n label: t('healthybowl.nav.coop', 'Co-operative'),\n path: joinPath(basePath, 'coop'),\n icon: <Users2 size={20} />,\n order: 22.5,\n group: 'business',\n },\n\n // Financial\n {\n id: 'healthybowl-financial',\n label: t('healthybowl.nav.financial', 'Financial'),\n path: joinPath(basePath, 'financial'),\n icon: <DollarSign size={20} />,\n order: 23,\n group: 'business',\n },\n\n // Financier portfolio (B2B2C bridge)\n {\n id: 'healthybowl-financier',\n label: t('healthybowl.nav.financier', 'Financier'),\n path: joinPath(basePath, 'financier'),\n icon: <Banknote size={20} />,\n order: 24,\n group: 'business',\n },\n\n // Compliance\n {\n id: 'healthybowl-compliance',\n label: t('healthybowl.nav.compliance', 'Compliance'),\n path: joinPath(basePath, 'compliance'),\n icon: <ShieldCheck size={20} />,\n order: 30,\n group: 'compliance',\n },\n\n // Traceability\n {\n id: 'healthybowl-traceability',\n label: t('healthybowl.nav.traceability', 'Traceability'),\n path: joinPath(basePath, 'traceability'),\n icon: <ScanLine size={20} />,\n order: 31,\n group: 'compliance',\n },\n\n // Sustainability — Carbon & Climate (BOFF-2896)\n {\n id: 'healthybowl-sustainability',\n label: t('healthybowl.nav.sustainability', 'Sustainability'),\n path: joinPath(basePath, 'sustainability'),\n icon: <Leaf size={20} />,\n order: 32,\n group: 'compliance',\n },\n {\n id: 'healthybowl-sustainability-carbon',\n label: t('healthybowl.nav.sustainabilityCarbon', 'Carbon & GHG'),\n path: joinPath(basePath, 'sustainability/carbon'),\n icon: <Factory size={20} />,\n order: 32.1,\n group: 'compliance',\n },\n {\n id: 'healthybowl-sustainability-soil',\n label: t('healthybowl.nav.sustainabilitySoil', 'Soil Carbon'),\n path: joinPath(basePath, 'sustainability/soil-carbon'),\n icon: <Sprout size={20} />,\n order: 32.2,\n group: 'compliance',\n },\n {\n id: 'healthybowl-sustainability-credits',\n label: t('healthybowl.nav.sustainabilityCredits', 'Carbon Credits'),\n path: joinPath(basePath, 'sustainability/credits'),\n icon: <Award size={20} />,\n order: 32.3,\n group: 'compliance',\n },\n {\n id: 'healthybowl-sustainability-eudr',\n label: t('healthybowl.nav.sustainabilityEudr', 'EUDR Due-Diligence'),\n path: joinPath(basePath, 'sustainability/eudr'),\n icon: <Globe size={20} />,\n order: 32.4,\n group: 'compliance',\n },\n\n // Government Schemes\n {\n id: 'healthybowl-schemes',\n label: t('healthybowl.nav.governmentSchemes', 'Gov. Schemes'),\n path: joinPath(basePath, 'government-schemes'),\n icon: <Landmark size={20} />,\n order: 40,\n group: 'support',\n },\n\n // Network\n {\n id: 'healthybowl-network',\n label: t('healthybowl.nav.network', 'Network'),\n path: joinPath(basePath, 'network'),\n icon: <Users size={20} />,\n order: 41,\n group: 'support',\n },\n\n // Analytics\n {\n id: 'healthybowl-analytics',\n label: t('healthybowl.nav.analytics', 'Analytics'),\n path: joinPath(basePath, 'analytics'),\n icon: <BarChart3 size={20} />,\n order: 42,\n group: 'support',\n },\n\n // My Advisors (UC-16 — farmer side)\n {\n id: 'healthybowl-advisors',\n label: t('healthybowl.nav.advisors', 'My Advisors'),\n path: joinPath(basePath, 'advisors'),\n icon: <UserCheck size={20} />,\n order: 43,\n group: 'support',\n },\n\n // Consultant portfolio (UC-16 — consultant side)\n {\n id: 'healthybowl-consultant',\n label: t('healthybowl.nav.consultant', 'Consultant'),\n path: joinPath(basePath, 'consultant'),\n icon: <Stethoscope size={20} />,\n order: 44,\n group: 'support',\n },\n ];\n\n // All sections are reachable. Marketplace (UC-08), Network (UC-12) and\n // Traceability (UC-11) render real read data + their real create flows\n // (createMarketplaceProduct / createCommunityPost / createTraceBatch); the\n // few genuinely-unbacked actions (checkout, booking, QR resolution) show\n // honest \"not available yet\" states in-page rather than hiding the section.\n const cleanup = registerNavItems(navItems);\n return cleanup;\n }, [registerNavItems, basePath]);\n\n // Register footer items\n useEffect(() => {\n if (!registerFooterItems) return;\n\n const footerItems = [\n {\n id: 'healthybowl-status',\n label: t('healthybowl.footer.ready', 'HealthyBowl Ready'),\n type: 'status' as const,\n order: 10,\n section: 'left' as const,\n },\n ];\n\n const cleanup = registerFooterItems(footerItems);\n return cleanup;\n }, [registerFooterItems]);\n\n return (\n <FeatureFlagProvider workspaceId={null} gateway=\"global\" defaultEnabled={true}>\n <HealthyBowlProvider {...props}>\n <ErrorBoundary>\n <ConfirmProvider>\n <OfflineSyncProvider>\n <HealthyBowlRoutes />\n </OfflineSyncProvider>\n </ConfirmProvider>\n </ErrorBoundary>\n </HealthyBowlProvider>\n </FeatureFlagProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAoDA,IAAa,KAA6C,MAAU;CAClE,IAAM,EAAE,qBAAkB,wBAAqB,cAAW,QAAQ,GAC5D,EAAE,GAAG,MAAc,GAAS,EAC5B,IAAI,GACP,GAAa,MAA6B;EACzC,IAAM,IAAQ,EAAU,EAAI;AAC5B,SAAO,MAAU,IAAM,IAAW;IAEpC,CAAC,EAAU,CACZ,EAGK,KAAY,GAAc,OACZ,EAAK,SAAS,IAAI,GAAG,EAAK,MAAM,GAAG,GAAG,GAAG,MACzC,EAAK,WAAW,IAAI,GAAG,IAAO,IAAI;AAoXtD,QA/WA,QAAgB;AACT,QAyVL,QADgB,EAtVY;GAE1B;IACE,IAAI;IACJ,OAAO,EAAE,6BAA6B,YAAY;IAIlD,MAAM,EAAkB,EAAS;IACjC,MAAM,kBAAC,GAAD,EAAM,MAAM,IAAM,CAAA;IACxB,OAAO;IACP,OAAO;IACR;GAGD;IACE,IAAI;IACJ,OAAO,EAAE,wBAAwB,UAAU;IAC3C,MAAM,EA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c;IACnD,MAAM,EAAS,GAAU,WAAW;IACpC,MAAM,kBAAC,GAAD,EAAW,MAAM,IAAM,CAAA;IAC7B,OAAO;IACP,OAAO;IACR;GAGD;IACE,IAAI;IACJ,OAAO,EAAE,8BAA8B,aAAa;IACpD,MAAM,EAAS,GAAU,aAAa;IACtC,MAAM,kBAAC,GAAD,EAAa,MAAM,IAAM,CAAA;IAC/B,OAAO;IACP,OAAO;IACR;GACF,CAOyC;IAEzC,CAAC,GAAkB,EAAS,CAAC,EAGhC,QAAgB;AACT,QAaL,QADgB,EAVI,CAClB;GACE,IAAI;GACJ,OAAO,EAAE,4BAA4B,oBAAoB;GACzD,MAAM;GACN,OAAO;GACP,SAAS;GACV,CACF,CAE+C;IAE/C,CAAC,EAAoB,CAAC,EAGvB,kBAAC,GAAD;EAAqB,aAAa;EAAM,SAAQ;EAAS,gBAAgB;YACvE,kBAAC,GAAD;GAAqB,GAAI;aACvB,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAqB,CAAA,EACD,CAAA,EACN,CAAA,EACJ,CAAA;GACI,CAAA;EACF,CAAA"}
|
|
1
|
+
{"version":3,"file":"HealthyBowlRoot.js","names":[],"sources":["../../src/healthybowl/HealthyBowlRoot.tsx"],"sourcesContent":["/**\n * HealthyBowl Root Component\n * @module healthybowl\n */\n\nimport type { FC } from 'react';\nimport { useCallback, useEffect } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n Home,\n Tractor,\n ListChecks,\n Wheat,\n PawPrint,\n Cloud,\n Map as MapIcon,\n ShoppingCart,\n DollarSign,\n BarChart3,\n FlaskConical,\n Bug,\n ScanSearch,\n Factory,\n Package,\n ScanLine,\n ShieldCheck,\n Landmark,\n Banknote,\n Stethoscope,\n UserCheck,\n Users,\n CloudUpload,\n RefreshCw,\n ShieldAlert,\n LineChart,\n Fence,\n Radio,\n Leaf,\n Sprout,\n Award,\n Globe,\n Users2,\n} from 'lucide-react';\nimport { HealthyBowlProvider } from './context/HealthyBowlContext';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { HealthyBowlRoutes } from './HealthyBowlRoutes';\nimport { ErrorBoundary } from './components/ErrorBoundary';\nimport { ConfirmProvider } from './components/ConfirmDialog';\nimport { OfflineSyncProvider } from './offline/OfflineSyncProvider';\nimport { normalizeBasePath, setHbFormatLocale } from './utils/helpers';\nimport type { HealthyBowlRootProps, NavItem } from './types';\n\nexport const HealthyBowlRoot: FC<HealthyBowlRootProps> = (props) => {\n const { registerNavItems, registerFooterItems, basePath = '/' } = props;\n const { t: translate, locale } = useI18n();\n\n // HealthyBowl's Intl.* formatters (utils/helpers.ts) are plain functions used\n // across ~490 call sites, so they can't call useI18n() themselves. Sync the\n // shell's active language into their ambient locale here — the product's\n // single I18n consumer that wraps every page — so number / currency / date\n // grouping tracks the chosen language (BOFF-6202). Done during render, not in\n // an effect, so children rendered in this same pass already format with the\n // current locale (no one-frame western-grouping flash on a language switch).\n setHbFormatLocale(locale);\n const t = useCallback(\n (key: string, fallback: string): string => {\n const value = translate(key);\n return value === key ? fallback : value;\n },\n [translate]\n );\n\n // Helper to join paths correctly\n const joinPath = (base: string, path: string): string => {\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return cleanBase + cleanPath;\n };\n\n // Register navigation items with shell on mount\n useEffect(() => {\n if (!registerNavItems) return;\n\n const navItems: NavItem[] = [\n // Dashboard\n {\n id: 'healthybowl-dashboard',\n label: t('healthybowl.nav.dashboard', 'Dashboard'),\n // The product index IS the dashboard. Normalize a trailing slash like\n // every sibling item (joinPath) so active-state highlighting matches if\n // the host ever passes '/healthybowl/'.\n path: normalizeBasePath(basePath),\n icon: <Home size={20} />,\n order: 1,\n group: 'main',\n },\n\n // My Farm\n {\n id: 'healthybowl-farm',\n label: t('healthybowl.nav.farm', 'My Farm'),\n path: joinPath(basePath, 'farm'),\n icon: <Tractor size={20} />,\n order: 2,\n group: 'main',\n },\n\n // Farm Tasks (PlanMagnet embed) — shared work-item board across the farm.\n {\n id: 'healthybowl-tasks',\n label: t('healthybowl.nav.tasks', 'Tasks'),\n path: joinPath(basePath, 'tasks'),\n icon: <ListChecks size={20} />,\n order: 3,\n group: 'main',\n },\n\n // Crops\n {\n id: 'healthybowl-crops',\n label: t('healthybowl.nav.crops', 'Crops'),\n path: joinPath(basePath, 'crops'),\n icon: <Wheat size={20} />,\n order: 10,\n group: 'farming',\n },\n\n // Livestock\n {\n id: 'healthybowl-livestock',\n label: t('healthybowl.nav.livestock', 'Livestock'),\n path: joinPath(basePath, 'livestock'),\n icon: <PawPrint size={20} />,\n order: 11,\n group: 'farming',\n },\n\n // Livestock — Analytics (BOFF-6126). The growth, feed and herd-stats charts (BOFF-5971) also\n // render inline on the livestock dashboard; this gives them a dedicated URL and full-width home.\n {\n id: 'healthybowl-livestock-analytics',\n label: t('healthybowl.nav.livestockAnalytics', 'Livestock Analytics'),\n path: joinPath(basePath, 'livestock/analytics'),\n icon: <LineChart size={20} />,\n order: 11.3,\n group: 'farming',\n },\n\n // Livestock — Grazing management (BOFF-5970). Sits next to Livestock rather than inside it\n // because rotational grazing is a daily decision about FIELDS, not a herd-record lookup.\n {\n id: 'healthybowl-grazing',\n label: t('healthybowl.nav.grazing', 'Grazing'),\n path: joinPath(basePath, 'livestock/grazing'),\n icon: <Fence size={20} />,\n order: 11.4,\n group: 'farming',\n },\n\n // Livestock — Medication Withdrawal Alerts (BOFF-2885)\n {\n id: 'healthybowl-withdrawal-alerts',\n label: t('healthybowl.nav.withdrawalAlerts', 'Withdrawal Alerts'),\n path: joinPath(basePath, 'livestock/withdrawal-alerts'),\n icon: <ShieldAlert size={20} />,\n order: 11.5,\n group: 'farming',\n },\n\n // Weather\n {\n id: 'healthybowl-weather',\n label: t('healthybowl.nav.weather', 'Weather'),\n path: joinPath(basePath, 'weather'),\n icon: <Cloud size={20} />,\n order: 12,\n group: 'farming',\n },\n\n // Field Map — draw & manage field boundaries on satellite imagery\n {\n id: 'healthybowl-field-map',\n label: t('healthybowl.nav.fieldMap', 'Field Map'),\n path: joinPath(basePath, 'field-map'),\n icon: <MapIcon size={20} />,\n order: 12.5,\n group: 'farming',\n },\n\n // Field Capture — offline-first observation capture (BOFF-2883)\n {\n id: 'healthybowl-field-capture',\n label: t('healthybowl.nav.fieldCapture', 'Field Capture'),\n path: joinPath(basePath, 'field-capture'),\n icon: <CloudUpload size={20} />,\n order: 12.6,\n group: 'farming',\n },\n\n // Pending Sync — the offline outbox / sync queue (BOFF-2883)\n {\n id: 'healthybowl-pending-sync',\n label: t('healthybowl.nav.pendingSync', 'Pending Sync'),\n path: joinPath(basePath, 'field-capture/pending'),\n icon: <RefreshCw size={20} />,\n order: 12.7,\n group: 'farming',\n },\n\n // Field Sensors — live probe monitoring (BOFF-2894)\n {\n id: 'healthybowl-field-sensors',\n label: t('healthybowl.nav.fieldSensors', 'Field Sensors'),\n path: joinPath(basePath, 'field-sensors'),\n icon: <Radio size={20} />,\n order: 12.75,\n group: 'farming',\n },\n\n // Soil Health\n {\n id: 'healthybowl-soil',\n label: t('healthybowl.nav.soilHealth', 'Soil Health'),\n path: joinPath(basePath, 'soil'),\n icon: <FlaskConical size={20} />,\n order: 13,\n group: 'farming',\n },\n\n // Pest Management\n {\n id: 'healthybowl-pest',\n label: t('healthybowl.nav.pestManagement', 'Pest Management'),\n path: joinPath(basePath, 'pest-management'),\n icon: <Bug size={20} />,\n order: 14,\n group: 'farming',\n },\n {\n id: 'healthybowl-pest-ai',\n label: t('healthybowl.nav.aiPestDetection', 'AI Pest Detection'),\n path: joinPath(basePath, 'pest-management/ai-detection'),\n icon: <ScanSearch size={20} />,\n order: 14.5,\n group: 'farming',\n },\n\n // Production\n {\n id: 'healthybowl-production',\n label: t('healthybowl.nav.production', 'Production'),\n path: joinPath(basePath, 'production'),\n icon: <Factory size={20} />,\n order: 20,\n group: 'business',\n },\n\n // Products\n {\n id: 'healthybowl-products',\n label: t('healthybowl.nav.products', 'Products'),\n path: joinPath(basePath, 'products'),\n icon: <Package size={20} />,\n order: 21,\n group: 'business',\n },\n\n // Marketplace\n {\n id: 'healthybowl-marketplace',\n label: t('healthybowl.nav.marketplace', 'Marketplace'),\n path: joinPath(basePath, 'marketplace'),\n icon: <ShoppingCart size={20} />,\n order: 22,\n group: 'business',\n },\n\n // Co-operative / FPO aggregation (BOFF-6023)\n {\n id: 'healthybowl-coop',\n label: t('healthybowl.nav.coop', 'Co-operative'),\n path: joinPath(basePath, 'coop'),\n icon: <Users2 size={20} />,\n order: 22.5,\n group: 'business',\n },\n\n // Financial\n {\n id: 'healthybowl-financial',\n label: t('healthybowl.nav.financial', 'Financial'),\n path: joinPath(basePath, 'financial'),\n icon: <DollarSign size={20} />,\n order: 23,\n group: 'business',\n },\n\n // Financier portfolio (B2B2C bridge)\n {\n id: 'healthybowl-financier',\n label: t('healthybowl.nav.financier', 'Financier'),\n path: joinPath(basePath, 'financier'),\n icon: <Banknote size={20} />,\n order: 24,\n group: 'business',\n },\n\n // Compliance\n {\n id: 'healthybowl-compliance',\n label: t('healthybowl.nav.compliance', 'Compliance'),\n path: joinPath(basePath, 'compliance'),\n icon: <ShieldCheck size={20} />,\n order: 30,\n group: 'compliance',\n },\n\n // Traceability\n {\n id: 'healthybowl-traceability',\n label: t('healthybowl.nav.traceability', 'Traceability'),\n path: joinPath(basePath, 'traceability'),\n icon: <ScanLine size={20} />,\n order: 31,\n group: 'compliance',\n },\n\n // Sustainability — Carbon & Climate (BOFF-2896)\n {\n id: 'healthybowl-sustainability',\n label: t('healthybowl.nav.sustainability', 'Sustainability'),\n path: joinPath(basePath, 'sustainability'),\n icon: <Leaf size={20} />,\n order: 32,\n group: 'compliance',\n },\n {\n id: 'healthybowl-sustainability-carbon',\n label: t('healthybowl.nav.sustainabilityCarbon', 'Carbon & GHG'),\n path: joinPath(basePath, 'sustainability/carbon'),\n icon: <Factory size={20} />,\n order: 32.1,\n group: 'compliance',\n },\n {\n id: 'healthybowl-sustainability-soil',\n label: t('healthybowl.nav.sustainabilitySoil', 'Soil Carbon'),\n path: joinPath(basePath, 'sustainability/soil-carbon'),\n icon: <Sprout size={20} />,\n order: 32.2,\n group: 'compliance',\n },\n {\n id: 'healthybowl-sustainability-credits',\n label: t('healthybowl.nav.sustainabilityCredits', 'Carbon Credits'),\n path: joinPath(basePath, 'sustainability/credits'),\n icon: <Award size={20} />,\n order: 32.3,\n group: 'compliance',\n },\n {\n id: 'healthybowl-sustainability-eudr',\n label: t('healthybowl.nav.sustainabilityEudr', 'EUDR Due-Diligence'),\n path: joinPath(basePath, 'sustainability/eudr'),\n icon: <Globe size={20} />,\n order: 32.4,\n group: 'compliance',\n },\n\n // Government Schemes\n {\n id: 'healthybowl-schemes',\n label: t('healthybowl.nav.governmentSchemes', 'Gov. Schemes'),\n path: joinPath(basePath, 'government-schemes'),\n icon: <Landmark size={20} />,\n order: 40,\n group: 'support',\n },\n\n // Network\n {\n id: 'healthybowl-network',\n label: t('healthybowl.nav.network', 'Network'),\n path: joinPath(basePath, 'network'),\n icon: <Users size={20} />,\n order: 41,\n group: 'support',\n },\n\n // Analytics\n {\n id: 'healthybowl-analytics',\n label: t('healthybowl.nav.analytics', 'Analytics'),\n path: joinPath(basePath, 'analytics'),\n icon: <BarChart3 size={20} />,\n order: 42,\n group: 'support',\n },\n\n // My Advisors (UC-16 — farmer side)\n {\n id: 'healthybowl-advisors',\n label: t('healthybowl.nav.advisors', 'My Advisors'),\n path: joinPath(basePath, 'advisors'),\n icon: <UserCheck size={20} />,\n order: 43,\n group: 'support',\n },\n\n // Consultant portfolio (UC-16 — consultant side)\n {\n id: 'healthybowl-consultant',\n label: t('healthybowl.nav.consultant', 'Consultant'),\n path: joinPath(basePath, 'consultant'),\n icon: <Stethoscope size={20} />,\n order: 44,\n group: 'support',\n },\n ];\n\n // All sections are reachable. Marketplace (UC-08), Network (UC-12) and\n // Traceability (UC-11) render real read data + their real create flows\n // (createMarketplaceProduct / createCommunityPost / createTraceBatch); the\n // few genuinely-unbacked actions (checkout, booking, QR resolution) show\n // honest \"not available yet\" states in-page rather than hiding the section.\n const cleanup = registerNavItems(navItems);\n return cleanup;\n }, [registerNavItems, basePath]);\n\n // Register footer items\n useEffect(() => {\n if (!registerFooterItems) return;\n\n const footerItems = [\n {\n id: 'healthybowl-status',\n label: t('healthybowl.footer.ready', 'HealthyBowl Ready'),\n type: 'status' as const,\n order: 10,\n section: 'left' as const,\n },\n ];\n\n const cleanup = registerFooterItems(footerItems);\n return cleanup;\n }, [registerFooterItems]);\n\n return (\n <FeatureFlagProvider workspaceId={null} gateway=\"global\" defaultEnabled={true}>\n <HealthyBowlProvider {...props}>\n <ErrorBoundary>\n <ConfirmProvider>\n <OfflineSyncProvider>\n <HealthyBowlRoutes />\n </OfflineSyncProvider>\n </ConfirmProvider>\n </ErrorBoundary>\n </HealthyBowlProvider>\n </FeatureFlagProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAoDA,IAAa,KAA6C,MAAU;CAClE,IAAM,EAAE,qBAAkB,wBAAqB,cAAW,QAAQ,GAC5D,EAAE,GAAG,GAAW,cAAW,GAAS;AAS1C,GAAkB,EAAO;CACzB,IAAM,IAAI,GACP,GAAa,MAA6B;EACzC,IAAM,IAAQ,EAAU,EAAI;AAC5B,SAAO,MAAU,IAAM,IAAW;IAEpC,CAAC,EAAU,CACZ,EAGK,KAAY,GAAc,OACZ,EAAK,SAAS,IAAI,GAAG,EAAK,MAAM,GAAG,GAAG,GAAG,MACzC,EAAK,WAAW,IAAI,GAAG,IAAO,IAAI;AAoXtD,QA/WA,QAAgB;AACT,QAyVL,QADgB,EAtVY;GAE1B;IACE,IAAI;IACJ,OAAO,EAAE,6BAA6B,YAAY;IAIlD,MAAM,EAAkB,EAAS;IACjC,MAAM,kBAAC,GAAD,EAAM,MAAM,IAAM,CAAA;IACxB,OAAO;IACP,OAA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7B,OAAO;IACP,OAAO;IACR;GAGD;IACE,IAAI;IACJ,OAAO,EAAE,4BAA4B,cAAc;IACnD,MAAM,EAAS,GAAU,WAAW;IACpC,MAAM,kBAAC,GAAD,EAAW,MAAM,IAAM,CAAA;IAC7B,OAAO;IACP,OAAO;IACR;GAGD;IACE,IAAI;IACJ,OAAO,EAAE,8BAA8B,aAAa;IACpD,MAAM,EAAS,GAAU,aAAa;IACtC,MAAM,kBAAC,GAAD,EAAa,MAAM,IAAM,CAAA;IAC/B,OAAO;IACP,OAAO;IACR;GACF,CAOyC;IAEzC,CAAC,GAAkB,EAAS,CAAC,EAGhC,QAAgB;AACT,QAaL,QADgB,EAVI,CAClB;GACE,IAAI;GACJ,OAAO,EAAE,4BAA4B,oBAAoB;GACzD,MAAM;GACN,OAAO;GACP,SAAS;GACV,CACF,CAE+C;IAE/C,CAAC,EAAoB,CAAC,EAGvB,kBAAC,GAAD;EAAqB,aAAa;EAAM,SAAQ;EAAS,gBAAgB;YACvE,kBAAC,GAAD;GAAqB,GAAI;aACvB,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAqB,CAAA,EACD,CAAA,EACN,CAAA,EACJ,CAAA;GACI,CAAA;EACF,CAAA"}
|
|
@@ -10,53 +10,64 @@ function r(e, t) {
|
|
|
10
10
|
function i(e) {
|
|
11
11
|
return e.endsWith("/") ? e.slice(0, -1) || "/" : e;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
var a = "en-IN", o = {
|
|
14
|
+
en: "en-IN",
|
|
15
|
+
hi: "hi-IN",
|
|
16
|
+
ta: "ta-IN"
|
|
17
|
+
}, s = a;
|
|
18
|
+
function c(e) {
|
|
19
|
+
e && (s = o[e] ?? e);
|
|
20
|
+
}
|
|
21
|
+
function l() {
|
|
22
|
+
return s;
|
|
23
|
+
}
|
|
24
|
+
function u(e, t, n = l()) {
|
|
25
|
+
return new Intl.NumberFormat(n, {
|
|
15
26
|
style: "currency",
|
|
16
27
|
currency: t
|
|
17
28
|
}).format(e);
|
|
18
29
|
}
|
|
19
|
-
function
|
|
20
|
-
return new Intl.NumberFormat(
|
|
30
|
+
function d(e, t, n = l()) {
|
|
31
|
+
return new Intl.NumberFormat(n, {
|
|
21
32
|
style: "currency",
|
|
22
33
|
currency: t,
|
|
23
34
|
notation: "compact",
|
|
24
35
|
maximumFractionDigits: 1
|
|
25
36
|
}).format(e);
|
|
26
37
|
}
|
|
27
|
-
function
|
|
38
|
+
function f(e) {
|
|
28
39
|
let [t, ...n] = e.map((e) => e.currency ?? "INR");
|
|
29
40
|
return t && n.every((e) => e === t) ? t : "INR";
|
|
30
41
|
}
|
|
31
|
-
function
|
|
32
|
-
return new Intl.NumberFormat(
|
|
42
|
+
function p(e, t = l()) {
|
|
43
|
+
return new Intl.NumberFormat(t).format(e);
|
|
33
44
|
}
|
|
34
|
-
function l(
|
|
35
|
-
return new Date(e).toLocaleDateString(
|
|
45
|
+
function m(e, t = l()) {
|
|
46
|
+
return new Date(e).toLocaleDateString(t, {
|
|
36
47
|
year: "numeric",
|
|
37
48
|
month: "short",
|
|
38
49
|
day: "numeric"
|
|
39
50
|
});
|
|
40
51
|
}
|
|
41
|
-
function
|
|
42
|
-
let
|
|
43
|
-
if (!
|
|
44
|
-
let [,
|
|
45
|
-
return new Date(Number(
|
|
52
|
+
function h(e, t = l()) {
|
|
53
|
+
let n = /^(\d{4})-(\d{2})-(\d{2})/.exec(e);
|
|
54
|
+
if (!n) return e;
|
|
55
|
+
let [, r, i, a] = n;
|
|
56
|
+
return new Date(Number(r), Number(i) - 1, Number(a)).toLocaleDateString(t, {
|
|
46
57
|
year: "numeric",
|
|
47
58
|
month: "short",
|
|
48
59
|
day: "numeric"
|
|
49
60
|
});
|
|
50
61
|
}
|
|
51
|
-
function
|
|
62
|
+
function g() {
|
|
52
63
|
let e = /* @__PURE__ */ new Date();
|
|
53
64
|
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
54
65
|
}
|
|
55
|
-
function
|
|
66
|
+
function _(e) {
|
|
56
67
|
let t = new Date(e), n = (/* @__PURE__ */ new Date()).getTime() - t.getTime(), r = Math.floor(n / (1e3 * 60 * 60 * 24));
|
|
57
68
|
return r === 0 ? "Today" : r === 1 ? "Yesterday" : r < 7 ? `${r} days ago` : r < 30 ? `${Math.floor(r / 7)} weeks ago` : r < 365 ? `${Math.floor(r / 30)} months ago` : `${Math.floor(r / 365)} years ago`;
|
|
58
69
|
}
|
|
59
70
|
//#endregion
|
|
60
|
-
export { n as cn,
|
|
71
|
+
export { a as HB_DEFAULT_FORMAT_LOCALE, n as cn, d as formatCompactCurrency, u as formatCurrency, m as formatDate, h as formatDateOnly, p as formatNumber, l as getHbFormatLocale, _ as getRelativeTime, r as joinPath, i as normalizeBasePath, f as resolveLineCurrency, c as setHbFormatLocale, g as todayLocalDate };
|
|
61
72
|
|
|
62
73
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":[],"sources":["../../../src/healthybowl/utils/helpers.ts"],"sourcesContent":["/**\n * HealthyBowl Utility Helpers\n * @module healthybowl\n */\n\nimport { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/** Merge Tailwind classes safely */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n/** Join path segments safely */\nexport function joinPath(base: string, path: string): string {\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return cleanBase + cleanPath;\n}\n\n/**\n * Normalize a base path: strip a trailing slash but keep '/' for the root.\n * (e.g. '/healthybowl/' → '/healthybowl', '/' → '/'). Shared by useBasePath\n * and HealthyBowlRoot so the rule lives in one place.\n */\nexport function normalizeBasePath(base: string): string {\n return base.endsWith('/') ? base.slice(0, -1) || '/' : base;\n}\n\n/**\n * The currency HealthyBowl's own money is denominated in — the fallback for any\n * amount that arrives without one.\n *\n * This is a deliberate hardcode, not a lookup (BOFF-6000). HealthyBowl's ledger\n * amounts (`DashboardStats.netProfit`/`totalExpenses`, budgets, invoice totals,\n * feed and harvest costs …) come back from the subgraph as bare `Float`s, and\n * nothing in the platform says what they are denominated in: neither `Workspace`\n * nor any organisation-settings type carries a currency, and the HealthyBowl\n * dashboard payload has no currency field either. The product itself states\n * rupees throughout — the wallet prices credits at \"₹1 = 1 credit\", order entry\n * is labelled \"Amount (₹)\", the accounting tables head their columns \"(₹)\" — so\n * ₹ is the only defensible label for an unlabelled HealthyBowl amount.\n *\n * Deliberately NOT sourced from `useGeography().currency` in the app shell: that\n * is a per-user display preference which auto-detects and defaults to USD, and\n * nothing in the product converts between currencies. Reading it would relabel\n * the very same rupee amount as \"$\" for a farmer whose browser resolves to the\n * US — the same bug wearing a different hat.\n *\n * Any amount that DOES carry a real currency (platform store products, CSA\n * plans, loan facilitations, the credits wallet's billing account) must pass\n * that value instead of this constant. When a workspace- or organisation-level\n * currency setting ships, wire it in here — this is the single place to change.\n */\nexport const HB_DEFAULT_CURRENCY = 'INR';\n\n/**\n * Format an amount as currency.\n *\n * `currency` is required (ISO 4217) on purpose: an omitted argument used to fall\n * back to USD, which silently rendered rupee amounts as dollars. Pass the\n * record's own currency when it has one, otherwise {@link HB_DEFAULT_CURRENCY}.\n */\nexport function formatCurrency(amount: number, currency: string): string {\n return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(amount);\n}\n\n/**\n * Compact money for chart axes and other tight labels — `₹12K`, `₹1.2M`. Same\n * required-`currency` contract as {@link formatCurrency}; the axis ticks that\n * hand-rolled `` `$${v / 1000}k` `` are why this exists.\n */\nexport function formatCompactCurrency(amount: number, currency: string): string {\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency,\n notation: 'compact',\n maximumFractionDigits: 1,\n }).format(amount);\n}\n\n/**\n * The currency a total over `lines` should be labelled with: the one currency\n * they all agree on, or {@link HB_DEFAULT_CURRENCY} when they carry none or\n * disagree (nothing in the product converts between currencies, so a mixed\n * total can only be labelled with the workspace default).\n */\nexport function resolveLineCurrency(lines: readonly { currency?: string }[]): string {\n const [first, ...rest] = lines.map((line) => line.currency ?? HB_DEFAULT_CURRENCY);\n if (!first) return HB_DEFAULT_CURRENCY;\n return rest.every((currency) => currency === first) ? first : HB_DEFAULT_CURRENCY;\n}\n\n/** Format number with commas */\nexport function formatNumber(num: number): string {\n return new Intl.NumberFormat('en-US').format(num);\n}\n\n/** Format date */\nexport function formatDate(dateStr: string): string {\n return new Date(dateStr).toLocaleDateString('en-US', {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n });\n}\n\n/**\n * Format a date-only string (YYYY-MM-DD) without timezone conversion.\n * Using `new Date('2026-06-06')` parses as UTC midnight and shifts backward a\n * day in western (negative-offset) zones. Parsing the parts into a local Date\n * keeps the calendar date intact.\n */\nexport function formatDateOnly(dateStr: string): string {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(dateStr);\n if (!match) return dateStr;\n const [, year, month, day] = match;\n return new Date(Number(year), Number(month) - 1, Number(day)).toLocaleDateString('en-US', {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n });\n}\n\n/**\n * Today's calendar date as YYYY-MM-DD in the user's *local* timezone.\n * `new Date().toISOString()` is UTC, so for users west of UTC in the evening it has\n * already rolled to tomorrow — using it as a date-input `min` then wrongly blocks today.\n */\nexport function todayLocalDate(): string {\n const now = new Date();\n const year = now.getFullYear();\n const month = String(now.getMonth() + 1).padStart(2, '0');\n const day = String(now.getDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n}\n\n/** Get relative time string */\nexport function getRelativeTime(dateStr: string): string {\n const date = new Date(dateStr);\n const now = new Date();\n const diffMs = now.getTime() - date.getTime();\n const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));\n\n if (diffDays === 0) return 'Today';\n if (diffDays === 1) return 'Yesterday';\n if (diffDays < 7) return `${diffDays} days ago`;\n if (diffDays < 30) return `${Math.floor(diffDays / 7)} weeks ago`;\n if (diffDays < 365) return `${Math.floor(diffDays / 30)} months ago`;\n return `${Math.floor(diffDays / 365)} years ago`;\n}\n\n/** Get percentage change */\nexport function getPercentChange(current: number, previous: number): number {\n if (previous === 0) return current > 0 ? 100 : 0;\n return Math.round(((current - previous) / previous) * 100);\n}\n\n/** Truncate text */\nexport function truncate(text: string, maxLength: number): string {\n if (text.length <= maxLength) return text;\n return text.slice(0, maxLength) + '...';\n}\n\n/** Simulate async delay (for mock data) */\nexport function delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":";;;AASA,SAAgB,EAAG,GAAG,GAAsB;AAC1C,QAAO,EAAQ,EAAK,EAAO,CAAC;;AAI9B,SAAgB,EAAS,GAAc,GAAsB;AAG3D,SAFkB,EAAK,SAAS,IAAI,GAAG,EAAK,MAAM,GAAG,GAAG,GAAG,MACzC,EAAK,WAAW,IAAI,GAAG,IAAO,IAAI;;AAStD,SAAgB,EAAkB,GAAsB;AACtD,QAAO,EAAK,SAAS,IAAI,GAAG,EAAK,MAAM,GAAG,GAAG,IAAI,MAAM;;AAqCzD,SAAgB,EAAe,GAAgB,GAA0B;AACvE,QAAO,IAAI,KAAK,aAAa,SAAS;EAAE,OAAO;EAAY;EAAU,CAAC,CAAC,OAAO,EAAO;;AAQvF,SAAgB,EAAsB,GAAgB,GAA0B;AAC9E,QAAO,IAAI,KAAK,aAAa,SAAS;EACpC,OAAO;EACP;EACA,UAAU;EACV,uBAAuB;EACxB,CAAC,CAAC,OAAO,EAAO;;AASnB,SAAgB,EAAoB,GAAiD;CACnF,IAAM,CAAC,GAAO,GAAG,KAAQ,EAAM,KAAK,MAAS,EAAK,YAAA,MAAgC;AAElF,QADK,KACE,EAAK,OAAO,MAAa,MAAa,EAAM,GAAG,IAAA;;AAIxD,SAAgB,EAAa,GAAqB;AAChD,QAAO,IAAI,KAAK,aAAa,QAAQ,CAAC,OAAO,EAAI;;AAInD,SAAgB,EAAW,GAAyB;AAClD,QAAO,IAAI,KAAK,EAAQ,CAAC,mBAAmB,SAAS;EACnD,MAAM;EACN,OAAO;EACP,KAAK;EACN,CAAC;;AASJ,SAAgB,EAAe,GAAyB;CACtD,IAAM,IAAQ,2BAA2B,KAAK,EAAQ;AACtD,KAAI,CAAC,EAAO,QAAO;CACnB,IAAM,GAAG,GAAM,GAAO,KAAO;AAC7B,QAAO,IAAI,KAAK,OAAO,EAAK,EAAE,OAAO,EAAM,GAAG,GAAG,OAAO,EAAI,CAAC,CAAC,mBAAmB,SAAS;EACxF,MAAM;EACN,OAAO;EACP,KAAK;EACN,CAAC;;AAQJ,SAAgB,IAAyB;CACvC,IAAM,oBAAM,IAAI,MAAM;AAItB,QAAO,GAHM,EAAI,aAAa,CAGf,GAFD,OAAO,EAAI,UAAU,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,CAEjC,GADZ,OAAO,EAAI,SAAS,CAAC,CAAC,SAAS,GAAG,IAAI;;AAKpD,SAAgB,EAAgB,GAAyB;CACvD,IAAM,IAAO,IAAI,KAAK,EAAQ,EAExB,qBADM,IAAI,MAAM,EACH,SAAS,GAAG,EAAK,SAAS,EACvC,IAAW,KAAK,MAAM,KAAU,MAAO,KAAK,KAAK,IAAI;AAO3D,QALI,MAAa,IAAU,UACvB,MAAa,IAAU,cACvB,IAAW,IAAU,GAAG,EAAS,aACjC,IAAW,KAAW,GAAG,KAAK,MAAM,IAAW,EAAE,CAAC,cAClD,IAAW,MAAY,GAAG,KAAK,MAAM,IAAW,GAAG,CAAC,eACjD,GAAG,KAAK,MAAM,IAAW,IAAI,CAAC"}
|
|
1
|
+
{"version":3,"file":"helpers.js","names":[],"sources":["../../../src/healthybowl/utils/helpers.ts"],"sourcesContent":["/**\n * HealthyBowl Utility Helpers\n * @module healthybowl\n */\n\nimport { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/** Merge Tailwind classes safely */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n/** Join path segments safely */\nexport function joinPath(base: string, path: string): string {\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return cleanBase + cleanPath;\n}\n\n/**\n * Normalize a base path: strip a trailing slash but keep '/' for the root.\n * (e.g. '/healthybowl/' → '/healthybowl', '/' → '/'). Shared by useBasePath\n * and HealthyBowlRoot so the rule lives in one place.\n */\nexport function normalizeBasePath(base: string): string {\n return base.endsWith('/') ? base.slice(0, -1) || '/' : base;\n}\n\n/**\n * The currency HealthyBowl's own money is denominated in — the fallback for any\n * amount that arrives without one.\n *\n * This is a deliberate hardcode, not a lookup (BOFF-6000). HealthyBowl's ledger\n * amounts (`DashboardStats.netProfit`/`totalExpenses`, budgets, invoice totals,\n * feed and harvest costs …) come back from the subgraph as bare `Float`s, and\n * nothing in the platform says what they are denominated in: neither `Workspace`\n * nor any organisation-settings type carries a currency, and the HealthyBowl\n * dashboard payload has no currency field either. The product itself states\n * rupees throughout — the wallet prices credits at \"₹1 = 1 credit\", order entry\n * is labelled \"Amount (₹)\", the accounting tables head their columns \"(₹)\" — so\n * ₹ is the only defensible label for an unlabelled HealthyBowl amount.\n *\n * Deliberately NOT sourced from `useGeography().currency` in the app shell: that\n * is a per-user display preference which auto-detects and defaults to USD, and\n * nothing in the product converts between currencies. Reading it would relabel\n * the very same rupee amount as \"$\" for a farmer whose browser resolves to the\n * US — the same bug wearing a different hat.\n *\n * Any amount that DOES carry a real currency (platform store products, CSA\n * plans, loan facilitations, the credits wallet's billing account) must pass\n * that value instead of this constant. When a workspace- or organisation-level\n * currency setting ships, wire it in here — this is the single place to change.\n */\nexport const HB_DEFAULT_CURRENCY = 'INR';\n\n/**\n * BCP-47 locale the Intl.* formatters below use when a call site doesn't pass\n * one explicitly. The old hardcoded `'en-US'` grouped every amount the western\n * way (`₹1,234,567.00`); HealthyBowl is an India-first product (INR default\n * currency, ₹ labels, PMFBY / Indian government schemes), so the correct\n * default is the Indian numbering system (`₹12,34,567.00`) — BOFF-6202, the\n * scope-item-4 residual of BOFF-6000.\n *\n * `en-IN` — English is the product's lingua franca and its farmers are in\n * India, so the base language pairs with the India region for grouping while\n * keeping English month/label text.\n */\nexport const HB_DEFAULT_FORMAT_LOCALE = 'en-IN';\n\n/**\n * The shell exposes short language codes (`useI18n().locale`: 'en' | 'hi' |\n * 'ta' | …). The three India-region product languages map to their `-IN`\n * locale so grouping is Indian; every other language passes through unchanged\n * so it keeps its own conventions (German `1.234.567`, etc.).\n */\nconst SHELL_LOCALE_TO_BCP47: Record<string, string> = {\n en: 'en-IN',\n hi: 'hi-IN',\n ta: 'ta-IN',\n};\n\n/**\n * Ambient locale read by the formatters. The formatters are plain (non-hook)\n * functions called from ~130 files / ~490 call sites, so they can't call\n * `useI18n()` themselves. {@link HealthyBowlRoot} keeps this in sync with the\n * shell's active language via {@link setHbFormatLocale}, which makes every call\n * site locale-aware without threading a `locale` argument through all of them.\n */\nlet activeFormatLocale: string = HB_DEFAULT_FORMAT_LOCALE;\n\n/**\n * Point the ambient formatter locale at the shell's active language. Called\n * with the raw `useI18n().locale` short code; falsy input is ignored (keeps the\n * India-first default). Idempotent.\n */\nexport function setHbFormatLocale(shellLocale: string | null | undefined): void {\n if (!shellLocale) return;\n activeFormatLocale = SHELL_LOCALE_TO_BCP47[shellLocale] ?? shellLocale;\n}\n\n/** The locale the formatters currently use — the ambient value or an override. */\nexport function getHbFormatLocale(): string {\n return activeFormatLocale;\n}\n\n/**\n * Format an amount as currency.\n *\n * `currency` is required (ISO 4217) on purpose: an omitted argument used to fall\n * back to USD, which silently rendered rupee amounts as dollars. Pass the\n * record's own currency when it has one, otherwise {@link HB_DEFAULT_CURRENCY}.\n *\n * `locale` defaults to the ambient shell locale (Indian grouping out of the\n * box); pass one only to override a single call.\n */\nexport function formatCurrency(amount: number, currency: string, locale: string = getHbFormatLocale()): string {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(amount);\n}\n\n/**\n * Compact money for chart axes and other tight labels — `₹12K`, `₹12L` (the\n * India-first `en-IN` default groups into lakh/crore, not millions). Same\n * required-`currency` contract as {@link formatCurrency}; the axis ticks that\n * hand-rolled `` `$${v / 1000}k` `` are why this exists.\n */\nexport function formatCompactCurrency(amount: number, currency: string, locale: string = getHbFormatLocale()): string {\n return new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n notation: 'compact',\n maximumFractionDigits: 1,\n }).format(amount);\n}\n\n/**\n * The currency a total over `lines` should be labelled with: the one currency\n * they all agree on, or {@link HB_DEFAULT_CURRENCY} when they carry none or\n * disagree (nothing in the product converts between currencies, so a mixed\n * total can only be labelled with the workspace default).\n */\nexport function resolveLineCurrency(lines: readonly { currency?: string }[]): string {\n const [first, ...rest] = lines.map((line) => line.currency ?? HB_DEFAULT_CURRENCY);\n if (!first) return HB_DEFAULT_CURRENCY;\n return rest.every((currency) => currency === first) ? first : HB_DEFAULT_CURRENCY;\n}\n\n/** Format number with locale-aware grouping (Indian by default). */\nexport function formatNumber(num: number, locale: string = getHbFormatLocale()): string {\n return new Intl.NumberFormat(locale).format(num);\n}\n\n/** Format date */\nexport function formatDate(dateStr: string, locale: string = getHbFormatLocale()): string {\n return new Date(dateStr).toLocaleDateString(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n });\n}\n\n/**\n * Format a date-only string (YYYY-MM-DD) without timezone conversion.\n * Using `new Date('2026-06-06')` parses as UTC midnight and shifts backward a\n * day in western (negative-offset) zones. Parsing the parts into a local Date\n * keeps the calendar date intact.\n */\nexport function formatDateOnly(dateStr: string, locale: string = getHbFormatLocale()): string {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(dateStr);\n if (!match) return dateStr;\n const [, year, month, day] = match;\n return new Date(Number(year), Number(month) - 1, Number(day)).toLocaleDateString(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n });\n}\n\n/**\n * Today's calendar date as YYYY-MM-DD in the user's *local* timezone.\n * `new Date().toISOString()` is UTC, so for users west of UTC in the evening it has\n * already rolled to tomorrow — using it as a date-input `min` then wrongly blocks today.\n */\nexport function todayLocalDate(): string {\n const now = new Date();\n const year = now.getFullYear();\n const month = String(now.getMonth() + 1).padStart(2, '0');\n const day = String(now.getDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n}\n\n/** Get relative time string */\nexport function getRelativeTime(dateStr: string): string {\n const date = new Date(dateStr);\n const now = new Date();\n const diffMs = now.getTime() - date.getTime();\n const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));\n\n if (diffDays === 0) return 'Today';\n if (diffDays === 1) return 'Yesterday';\n if (diffDays < 7) return `${diffDays} days ago`;\n if (diffDays < 30) return `${Math.floor(diffDays / 7)} weeks ago`;\n if (diffDays < 365) return `${Math.floor(diffDays / 30)} months ago`;\n return `${Math.floor(diffDays / 365)} years ago`;\n}\n\n/** Get percentage change */\nexport function getPercentChange(current: number, previous: number): number {\n if (previous === 0) return current > 0 ? 100 : 0;\n return Math.round(((current - previous) / previous) * 100);\n}\n\n/** Truncate text */\nexport function truncate(text: string, maxLength: number): string {\n if (text.length <= maxLength) return text;\n return text.slice(0, maxLength) + '...';\n}\n\n/** Simulate async delay (for mock data) */\nexport function delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":";;;AASA,SAAgB,EAAG,GAAG,GAAsB;AAC1C,QAAO,EAAQ,EAAK,EAAO,CAAC;;AAI9B,SAAgB,EAAS,GAAc,GAAsB;AAG3D,SAFkB,EAAK,SAAS,IAAI,GAAG,EAAK,MAAM,GAAG,GAAG,GAAG,MACzC,EAAK,WAAW,IAAI,GAAG,IAAO,IAAI;;AAStD,SAAgB,EAAkB,GAAsB;AACtD,QAAO,EAAK,SAAS,IAAI,GAAG,EAAK,MAAM,GAAG,GAAG,IAAI,MAAM;;AA0CzD,I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