@burdenoff/microfe-healthybowl 2026.714.3 → 2026.714.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.
Files changed (55) hide show
  1. package/dist/healthybowl/HealthyBowlRoot.js +114 -106
  2. package/dist/healthybowl/HealthyBowlRoot.js.map +1 -1
  3. package/dist/healthybowl/HealthyBowlRoutes.js +141 -113
  4. package/dist/healthybowl/HealthyBowlRoutes.js.map +1 -1
  5. package/dist/healthybowl/hooks/useHealthyBowlContacts.js +149 -0
  6. package/dist/healthybowl/hooks/useHealthyBowlContacts.js.map +1 -0
  7. package/dist/healthybowl/hooks/useHealthyBowlLivestockDepth.js +200 -0
  8. package/dist/healthybowl/hooks/useHealthyBowlLivestockDepth.js.map +1 -0
  9. package/dist/healthybowl/hooks/useHealthyBowlStorage.js +162 -0
  10. package/dist/healthybowl/hooks/useHealthyBowlStorage.js.map +1 -0
  11. package/dist/healthybowl/hooks/usePlantScans.js +131 -0
  12. package/dist/healthybowl/hooks/usePlantScans.js.map +1 -0
  13. package/dist/healthybowl/pages/contacts/ContactDetailPage.js +224 -0
  14. package/dist/healthybowl/pages/contacts/ContactDetailPage.js.map +1 -0
  15. package/dist/healthybowl/pages/contacts/ContactFormModal.js +147 -0
  16. package/dist/healthybowl/pages/contacts/ContactFormModal.js.map +1 -0
  17. package/dist/healthybowl/pages/contacts/ContactsPage.js +241 -0
  18. package/dist/healthybowl/pages/contacts/ContactsPage.js.map +1 -0
  19. package/dist/healthybowl/pages/contacts/CsvImportModal.js +155 -0
  20. package/dist/healthybowl/pages/contacts/CsvImportModal.js.map +1 -0
  21. package/dist/healthybowl/pages/contacts/RecordOrderModal.js +131 -0
  22. package/dist/healthybowl/pages/contacts/RecordOrderModal.js.map +1 -0
  23. package/dist/healthybowl/pages/contacts/labels.js +46 -0
  24. package/dist/healthybowl/pages/contacts/labels.js.map +1 -0
  25. package/dist/healthybowl/pages/livestock/AnimalDepthFormModal.js +152 -0
  26. package/dist/healthybowl/pages/livestock/AnimalDepthFormModal.js.map +1 -0
  27. package/dist/healthybowl/pages/livestock/AnimalDepthPage.js +245 -0
  28. package/dist/healthybowl/pages/livestock/AnimalDepthPage.js.map +1 -0
  29. package/dist/healthybowl/pages/livestock/AnimalGroupModal.js +210 -0
  30. package/dist/healthybowl/pages/livestock/AnimalGroupModal.js.map +1 -0
  31. package/dist/healthybowl/pages/livestock/HerdDepthPage.js +189 -0
  32. package/dist/healthybowl/pages/livestock/HerdDepthPage.js.map +1 -0
  33. package/dist/healthybowl/pages/livestock/RecordWeightModal.js +100 -0
  34. package/dist/healthybowl/pages/livestock/RecordWeightModal.js.map +1 -0
  35. package/dist/healthybowl/pages/livestock/depthLabels.js +31 -0
  36. package/dist/healthybowl/pages/livestock/depthLabels.js.map +1 -0
  37. package/dist/healthybowl/pages/pest-management/AiPestDetectionPage.js +726 -0
  38. package/dist/healthybowl/pages/pest-management/AiPestDetectionPage.js.map +1 -0
  39. package/dist/healthybowl/pages/pest-management/PestOverviewPage.js +98 -88
  40. package/dist/healthybowl/pages/pest-management/PestOverviewPage.js.map +1 -1
  41. package/dist/healthybowl/pages/storage/PlaceLotModal.js +150 -0
  42. package/dist/healthybowl/pages/storage/PlaceLotModal.js.map +1 -0
  43. package/dist/healthybowl/pages/storage/RecordMovementModal.js +140 -0
  44. package/dist/healthybowl/pages/storage/RecordMovementModal.js.map +1 -0
  45. package/dist/healthybowl/pages/storage/StorageLocationFormModal.js +139 -0
  46. package/dist/healthybowl/pages/storage/StorageLocationFormModal.js.map +1 -0
  47. package/dist/healthybowl/pages/storage/StorageLotDetailPage.js +150 -0
  48. package/dist/healthybowl/pages/storage/StorageLotDetailPage.js.map +1 -0
  49. package/dist/healthybowl/pages/storage/StoragePage.js +251 -0
  50. package/dist/healthybowl/pages/storage/StoragePage.js.map +1 -0
  51. package/dist/healthybowl/pages/storage/labels.js +67 -0
  52. package/dist/healthybowl/pages/storage/labels.js.map +1 -0
  53. package/dist/healthybowl/utils/imageDownscale.js +76 -0
  54. package/dist/healthybowl/utils/imageDownscale.js.map +1 -0
  55. package/package.json +1 -1
@@ -0,0 +1,726 @@
1
+ import { useHealthyBowl as e } from "../../context/HealthyBowlContext.js";
2
+ import { formatDate as t } from "../../utils/helpers.js";
3
+ import { PageLayout as n } from "../../components/PageLayout.js";
4
+ import { EmptyState as r } from "../../components/EmptyState.js";
5
+ import { ErrorState as i } from "../../components/ErrorState.js";
6
+ import { ToastContainer as a } from "../../components/Toast.js";
7
+ import { Modal as o } from "../../components/Modal.js";
8
+ import { useToast as ee } from "../../hooks/useToast.js";
9
+ import "../../components/index.js";
10
+ import { useHealthyBowlData as s } from "../../hooks/useHealthyBowlData.js";
11
+ import { downscaleImage as c } from "../../utils/imageDownscale.js";
12
+ import { resolvePlantScanImageUrl as l, usePlantScans as u } from "../../hooks/usePlantScans.js";
13
+ import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
14
+ import { useI18n as te } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
15
+ import { AlertTriangle as g, Camera as ne, ClipboardList as _, Leaf as v, Loader2 as y, ScanSearch as b, Sparkles as x, Upload as re } from "lucide-react";
16
+ import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
17
+ import { Button as T, Select as E, SelectContent as D, SelectItem as O, SelectTrigger as k, SelectValue as A } from "@burdenoff/fe-libs/ui";
18
+ import { useSaveToFiles as ie } from "@burdenoff/fe-libs/storage";
19
+ //#region src/healthybowl/pages/pest-management/AiPestDetectionPage.tsx
20
+ var j = "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-tertiary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]", M = {
21
+ LOW: "bg-status-success-bgSubtle text-status-success-text",
22
+ MEDIUM: "bg-status-warning-bgSubtle text-status-warning-text",
23
+ MODERATE: "bg-status-warning-bgSubtle text-status-warning-text",
24
+ HIGH: "bg-status-error-bg/10 text-status-error-text",
25
+ CRITICAL: "bg-status-error-bg/10 text-status-error-text",
26
+ NONE: "bg-bg-sunken text-text-secondary"
27
+ };
28
+ function N(e, t) {
29
+ let n = (e ?? "").toUpperCase();
30
+ return n === "MEDIUM" ? t("healthybowl.plantScan.severity.moderate", "Moderate") : n === "LOW" ? t("healthybowl.plantScan.severity.low", "Low") : n === "HIGH" ? t("healthybowl.plantScan.severity.high", "High") : n === "CRITICAL" ? t("healthybowl.plantScan.severity.critical", "Critical") : t("healthybowl.plantScan.severity.none", "None");
31
+ }
32
+ function P(e) {
33
+ return M[(e ?? "NONE").toUpperCase()] ?? M.NONE;
34
+ }
35
+ function ae({ fileId: t, alt: n }) {
36
+ let { workspaceId: r } = e(), [i, a] = h(null);
37
+ return f(() => {
38
+ let e = !0;
39
+ return t && r && l(t, r).then((t) => {
40
+ e && a(t);
41
+ }), () => {
42
+ e = !1;
43
+ };
44
+ }, [t, r]), /* @__PURE__ */ C("div", {
45
+ className: "h-12 w-12 shrink-0 overflow-hidden rounded-lg bg-bg-sunken",
46
+ children: i ? /* @__PURE__ */ C("img", {
47
+ src: i,
48
+ alt: n,
49
+ className: "h-full w-full object-cover",
50
+ loading: "lazy"
51
+ }) : /* @__PURE__ */ C("div", {
52
+ className: "flex h-full w-full items-center justify-center text-text-tertiary",
53
+ children: /* @__PURE__ */ C(v, { size: 18 })
54
+ })
55
+ });
56
+ }
57
+ function F({ value: e }) {
58
+ return /* @__PURE__ */ C("div", {
59
+ className: "h-2 w-24 overflow-hidden rounded-full bg-bg-sunken",
60
+ "aria-hidden": !0,
61
+ children: /* @__PURE__ */ C("div", {
62
+ className: "h-full rounded-full bg-action-primary-bg",
63
+ style: { width: `${Math.max(0, Math.min(100, Math.round(e)))}%` }
64
+ })
65
+ });
66
+ }
67
+ function I() {
68
+ let { t: e } = te(), { fields: o, crops: l } = s(), { data: f, loading: g, error: v, refetch: j, diagnose: M, logToPest: N } = u(), { save: P } = ie(), { toasts: F, toast: I, dismiss: L } = ee(), R = m(null), [z, B] = h(null), [V, H] = h(""), [U, W] = h(""), [G, ce] = h(""), [K, q] = h(!1), [J, Y] = h(null), [le, X] = h(!1), Z = p(() => o.find((e) => e.id === V), [o, V]), Q = p(() => l.find((e) => e.id === U), [l, U]), ue = p(() => V ? l.filter((e) => e.field === V) : l, [l, V]), de = d(async (t) => {
69
+ if (t) try {
70
+ B(await c(t)), Y(null);
71
+ } catch {
72
+ I({
73
+ title: e("healthybowl.plantScan.readError", "Could not read that image. Try another photo."),
74
+ variant: "error"
75
+ });
76
+ }
77
+ }, [e, I]), fe = d(async () => {
78
+ if (!z) {
79
+ I({
80
+ title: e("healthybowl.plantScan.needPhoto", "Take or upload a plant photo first."),
81
+ variant: "error"
82
+ });
83
+ return;
84
+ }
85
+ q(!0);
86
+ try {
87
+ let t = null;
88
+ try {
89
+ t = (await P({
90
+ source: {
91
+ kind: "blob",
92
+ filename: z.filename,
93
+ mimeType: z.mimeType,
94
+ getBlob: async () => ({
95
+ blob: z.blob,
96
+ filename: z.filename,
97
+ mimeType: z.mimeType
98
+ })
99
+ },
100
+ folderPath: "/HealthyBowl/PestScan"
101
+ }))?.id ?? null;
102
+ } catch {
103
+ t = null;
104
+ }
105
+ let n = await M({
106
+ fieldId: V || null,
107
+ fieldName: Z?.name ?? null,
108
+ cropName: Q?.name ?? null,
109
+ photoFileId: t,
110
+ imageBase64: z.base64,
111
+ notes: G.trim() || null
112
+ });
113
+ Y(n), await j(), I({
114
+ title: e("healthybowl.plantScan.done", "Diagnosis ready"),
115
+ description: n.topDiagnosis ?? "",
116
+ variant: "success"
117
+ });
118
+ } catch (t) {
119
+ I({
120
+ title: e("healthybowl.plantScan.failed", "Diagnosis failed"),
121
+ description: t instanceof Error ? t.message : String(t),
122
+ variant: "error"
123
+ });
124
+ } finally {
125
+ q(!1);
126
+ }
127
+ }, [
128
+ z,
129
+ P,
130
+ M,
131
+ V,
132
+ Z,
133
+ Q,
134
+ G,
135
+ j,
136
+ I,
137
+ e
138
+ ]), $ = f?.stats, pe = f?.scans ?? [];
139
+ return /* @__PURE__ */ w(n, {
140
+ title: e("healthybowl.plantScan.title", "AI Pest & Disease Detection"),
141
+ titleAccent: e("healthybowl.plantScan.titleAccent", "AI"),
142
+ description: e("healthybowl.plantScan.subtitle", "Photograph a plant — AI names the likely pest or disease, with organic-safe next steps."),
143
+ hero: !0,
144
+ purpose: e("healthybowl.plantScan.purpose", "Snap or upload a leaf photo and get an AI second opinion — the most likely pest or disease with a confidence score, ranked alternatives, and organic-safe actions. Log it to Pest Issues in one tap to start tracking it."),
145
+ actions: J ? /* @__PURE__ */ w(T, {
146
+ onClick: () => X(!0),
147
+ className: "gap-2",
148
+ children: [
149
+ /* @__PURE__ */ C(_, { size: 16 }),
150
+ " ",
151
+ e("healthybowl.plantScan.logToIssues", "Log to Pest Issues")
152
+ ]
153
+ }) : void 0,
154
+ children: [
155
+ /* @__PURE__ */ C("input", {
156
+ ref: R,
157
+ type: "file",
158
+ accept: "image/*",
159
+ capture: "environment",
160
+ className: "hidden",
161
+ onChange: (e) => void de(e.target.files?.[0])
162
+ }),
163
+ /* @__PURE__ */ w("div", {
164
+ className: "grid grid-cols-1 gap-6 lg:grid-cols-3",
165
+ children: [
166
+ /* @__PURE__ */ w("section", {
167
+ className: "rounded-2xl border border-border-subtle bg-bg-surface p-5",
168
+ children: [
169
+ /* @__PURE__ */ C("h2", {
170
+ className: "mb-4 text-lg font-semibold text-text-primary",
171
+ children: e("healthybowl.plantScan.scanCard", "Scan a Plant")
172
+ }),
173
+ /* @__PURE__ */ C("div", {
174
+ className: "mb-4 flex aspect-square w-full items-center justify-center overflow-hidden rounded-xl bg-bg-sunken",
175
+ children: z ? /* @__PURE__ */ C("img", {
176
+ src: z.dataUrl,
177
+ alt: e("healthybowl.plantScan.previewAlt", "Plant to diagnose"),
178
+ className: "h-full w-full object-cover"
179
+ }) : /* @__PURE__ */ w("div", {
180
+ className: "flex flex-col items-center gap-2 p-6 text-center text-text-tertiary",
181
+ children: [/* @__PURE__ */ C(b, { size: 40 }), /* @__PURE__ */ C("span", {
182
+ className: "text-sm",
183
+ children: e("healthybowl.plantScan.previewHint", "Take or upload a photo of the affected leaf")
184
+ })]
185
+ })
186
+ }),
187
+ /* @__PURE__ */ w("div", {
188
+ className: "grid grid-cols-2 gap-3",
189
+ children: [/* @__PURE__ */ w(T, {
190
+ variant: "outline",
191
+ className: "gap-2",
192
+ onClick: () => R.current?.click(),
193
+ disabled: K,
194
+ children: [
195
+ /* @__PURE__ */ C(ne, { size: 16 }),
196
+ " ",
197
+ e("healthybowl.plantScan.takePhoto", "Take Photo")
198
+ ]
199
+ }), /* @__PURE__ */ w(T, {
200
+ variant: "outline",
201
+ className: "gap-2",
202
+ onClick: () => R.current?.click(),
203
+ disabled: K,
204
+ children: [
205
+ /* @__PURE__ */ C(re, { size: 16 }),
206
+ " ",
207
+ e("healthybowl.plantScan.upload", "Upload Image")
208
+ ]
209
+ })]
210
+ }),
211
+ /* @__PURE__ */ w("div", {
212
+ className: "mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2",
213
+ children: [/* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("label", {
214
+ className: "mb-1 block text-xs font-medium text-text-secondary",
215
+ children: e("healthybowl.plantScan.field", "Field")
216
+ }), /* @__PURE__ */ w(E, {
217
+ value: V,
218
+ onValueChange: (e) => {
219
+ H(e), W("");
220
+ },
221
+ children: [/* @__PURE__ */ C(k, {
222
+ className: "w-full",
223
+ children: /* @__PURE__ */ C(A, { placeholder: e("healthybowl.plantScan.selectField", "Select field") })
224
+ }), /* @__PURE__ */ C(D, { children: o.map((e) => /* @__PURE__ */ C(O, {
225
+ value: e.id,
226
+ children: e.name
227
+ }, e.id)) })]
228
+ })] }), /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("label", {
229
+ className: "mb-1 block text-xs font-medium text-text-secondary",
230
+ children: e("healthybowl.plantScan.crop", "Crop")
231
+ }), /* @__PURE__ */ w(E, {
232
+ value: U,
233
+ onValueChange: W,
234
+ children: [/* @__PURE__ */ C(k, {
235
+ className: "w-full",
236
+ children: /* @__PURE__ */ C(A, { placeholder: e("healthybowl.plantScan.selectCrop", "Select crop") })
237
+ }), /* @__PURE__ */ C(D, { children: ue.map((e) => /* @__PURE__ */ C(O, {
238
+ value: e.id,
239
+ children: e.name
240
+ }, e.id)) })]
241
+ })] })]
242
+ }),
243
+ /* @__PURE__ */ w("div", {
244
+ className: "mt-3",
245
+ children: [/* @__PURE__ */ C("label", {
246
+ className: "mb-1 block text-xs font-medium text-text-secondary",
247
+ children: e("healthybowl.plantScan.notes", "Symptoms (optional)")
248
+ }), /* @__PURE__ */ C("textarea", {
249
+ value: G,
250
+ onChange: (e) => ce(e.target.value),
251
+ rows: 2,
252
+ placeholder: e("healthybowl.plantScan.notesPlaceholder", "e.g. brown spots spreading on lower leaves"),
253
+ className: "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-tertiary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
254
+ })]
255
+ }),
256
+ /* @__PURE__ */ C(T, {
257
+ onClick: () => void fe(),
258
+ disabled: !z || K,
259
+ className: "mt-4 w-full gap-2",
260
+ children: K ? /* @__PURE__ */ w(S, { children: [
261
+ /* @__PURE__ */ C(y, {
262
+ size: 16,
263
+ className: "animate-spin"
264
+ }),
265
+ " ",
266
+ e("healthybowl.plantScan.analyzing", "Analyzing…")
267
+ ] }) : /* @__PURE__ */ w(S, { children: [
268
+ /* @__PURE__ */ C(x, { size: 16 }),
269
+ " ",
270
+ e("healthybowl.plantScan.diagnose", "Diagnose with AI")
271
+ ] })
272
+ })
273
+ ]
274
+ }),
275
+ /* @__PURE__ */ w("section", {
276
+ className: "rounded-2xl border border-border-subtle bg-bg-surface p-5",
277
+ children: [/* @__PURE__ */ C("h2", {
278
+ className: "mb-4 text-lg font-semibold text-text-primary",
279
+ children: e("healthybowl.plantScan.diagnosisCard", "AI Diagnosis")
280
+ }), J ? /* @__PURE__ */ C(oe, {
281
+ scan: J,
282
+ t: e
283
+ }) : /* @__PURE__ */ w("div", {
284
+ className: "flex h-64 flex-col items-center justify-center gap-2 text-center text-text-tertiary",
285
+ children: [/* @__PURE__ */ C(x, { size: 32 }), /* @__PURE__ */ C("p", {
286
+ className: "text-sm",
287
+ children: e("healthybowl.plantScan.diagnosisEmpty", "Your AI diagnosis will appear here after you scan a plant.")
288
+ })]
289
+ })]
290
+ }),
291
+ /* @__PURE__ */ w("section", {
292
+ className: "space-y-4",
293
+ children: [/* @__PURE__ */ w("div", {
294
+ className: "rounded-2xl border border-border-subtle bg-bg-surface p-5",
295
+ children: [/* @__PURE__ */ C("h2", {
296
+ className: "mb-4 text-lg font-semibold text-text-primary",
297
+ children: e("healthybowl.plantScan.recentScans", "Recent Scans")
298
+ }), g ? /* @__PURE__ */ C("div", {
299
+ className: "flex h-32 items-center justify-center text-text-tertiary",
300
+ children: /* @__PURE__ */ C(y, {
301
+ size: 20,
302
+ className: "animate-spin"
303
+ })
304
+ }) : v ? /* @__PURE__ */ C(i, { onRetry: () => void j() }) : pe.length === 0 ? /* @__PURE__ */ C(r, {
305
+ icon: /* @__PURE__ */ C(b, { size: 28 }),
306
+ title: e("healthybowl.plantScan.noScans", "No scans yet"),
307
+ description: e("healthybowl.plantScan.noScansHint", "Point your phone at a sick-looking plant and let HealthyBowl AI name the likely pest or disease.")
308
+ }) : /* @__PURE__ */ C("ul", {
309
+ className: "divide-y divide-border-subtle",
310
+ children: pe.slice(0, 8).map((n) => /* @__PURE__ */ C("li", { children: /* @__PURE__ */ w("button", {
311
+ type: "button",
312
+ onClick: () => Y(n),
313
+ className: "flex w-full items-center gap-3 py-3 text-start hover:opacity-80",
314
+ children: [
315
+ /* @__PURE__ */ C(ae, {
316
+ fileId: n.photoFileIds?.[0],
317
+ alt: n.topDiagnosis ?? "scan"
318
+ }),
319
+ /* @__PURE__ */ w("div", {
320
+ className: "min-w-0 flex-1",
321
+ children: [/* @__PURE__ */ w("p", {
322
+ className: "truncate text-sm font-medium text-text-primary",
323
+ children: [n.cropName || e("healthybowl.plantScan.unknownCrop", "Unknown crop"), n.topDiagnosis ? ` · ${n.topDiagnosis}` : ""]
324
+ }), /* @__PURE__ */ C("p", {
325
+ className: "text-xs text-text-tertiary",
326
+ children: t(n.createdAt)
327
+ })]
328
+ }),
329
+ n.loggedPestIssueId ? /* @__PURE__ */ C("span", {
330
+ className: "rounded-full bg-status-success-bgSubtle px-2 py-0.5 text-[11px] font-medium text-status-success-text",
331
+ children: e("healthybowl.plantScan.logged", "Logged")
332
+ }) : null
333
+ ]
334
+ }) }, n.id))
335
+ })]
336
+ }), $ ? /* @__PURE__ */ w("div", {
337
+ className: "rounded-2xl border border-border-subtle bg-bg-surface p-5",
338
+ children: [/* @__PURE__ */ w("p", {
339
+ className: "text-sm text-text-secondary",
340
+ children: [
341
+ /* @__PURE__ */ C("span", {
342
+ className: "text-lg font-semibold text-text-primary",
343
+ children: $.scansThisSeason
344
+ }),
345
+ " ",
346
+ e("healthybowl.plantScan.statScans", "scans this season"),
347
+ " ·",
348
+ " ",
349
+ /* @__PURE__ */ C("span", {
350
+ className: "text-lg font-semibold text-text-primary",
351
+ children: $.issuesCaughtEarly
352
+ }),
353
+ " ",
354
+ e("healthybowl.plantScan.statIssues", "issues caught early")
355
+ ]
356
+ }), $.avgConfidence > 0 ? /* @__PURE__ */ w("p", {
357
+ className: "mt-1 text-xs text-text-tertiary",
358
+ children: [
359
+ e("healthybowl.plantScan.statAvg", "Average confidence"),
360
+ " ",
361
+ Math.round($.avgConfidence),
362
+ "%"
363
+ ]
364
+ }) : null]
365
+ }) : null]
366
+ })
367
+ ]
368
+ }),
369
+ J ? /* @__PURE__ */ C(se, {
370
+ open: le,
371
+ onClose: () => X(!1),
372
+ scan: J,
373
+ fields: o,
374
+ defaultFieldId: V,
375
+ t: e,
376
+ onSubmit: async (t) => {
377
+ try {
378
+ await N(t), await j(), Y((e) => e && {
379
+ ...e,
380
+ loggedPestIssueId: "logged"
381
+ }), X(!1), I({
382
+ title: e("healthybowl.plantScan.loggedToast", "Logged to Pest Issues"),
383
+ variant: "success"
384
+ });
385
+ } catch (t) {
386
+ I({
387
+ title: e("healthybowl.plantScan.logFailed", "Could not log the issue"),
388
+ description: t instanceof Error ? t.message : String(t),
389
+ variant: "error"
390
+ });
391
+ }
392
+ }
393
+ }) : null,
394
+ /* @__PURE__ */ C(a, {
395
+ toasts: F,
396
+ onDismiss: L
397
+ })
398
+ ]
399
+ });
400
+ }
401
+ function oe({ scan: e, t }) {
402
+ let n = e.candidates ?? [], r = n[0], i = n.slice(1), a = e.advisorySource === "MODEL";
403
+ return /* @__PURE__ */ w("div", {
404
+ className: "space-y-4",
405
+ children: [
406
+ /* @__PURE__ */ w("div", {
407
+ className: "rounded-xl bg-status-success-bgSubtle p-4",
408
+ children: [/* @__PURE__ */ w("div", {
409
+ className: "flex items-start justify-between gap-3",
410
+ children: [/* @__PURE__ */ w("div", {
411
+ className: "min-w-0",
412
+ children: [/* @__PURE__ */ C("p", {
413
+ className: "text-lg font-bold text-text-primary",
414
+ children: e.topDiagnosis ?? r?.name ?? "—"
415
+ }), e.topScientificName ? /* @__PURE__ */ C("p", {
416
+ className: "text-sm italic text-text-secondary",
417
+ children: e.topScientificName
418
+ }) : null]
419
+ }), e.topConfidence == null ? null : /* @__PURE__ */ w("div", {
420
+ className: "shrink-0 rounded-lg bg-action-primary-bg px-3 py-1.5 text-center text-action-primary-text",
421
+ children: [/* @__PURE__ */ C("p", {
422
+ className: "text-[10px] uppercase leading-none opacity-80",
423
+ children: t("healthybowl.plantScan.confidence", "Confidence")
424
+ }), /* @__PURE__ */ w("p", {
425
+ className: "text-lg font-bold leading-tight",
426
+ children: [Math.round(e.topConfidence), "%"]
427
+ })]
428
+ })]
429
+ }), /* @__PURE__ */ w("span", {
430
+ className: `mt-3 inline-block rounded-full px-3 py-1 text-xs font-semibold ${P(e.severity)}`,
431
+ children: [
432
+ t("healthybowl.plantScan.severityLabel", "Severity"),
433
+ ": ",
434
+ N(e.severity, t)
435
+ ]
436
+ })]
437
+ }),
438
+ i.length > 0 ? /* @__PURE__ */ w("div", {
439
+ className: "space-y-2",
440
+ children: [/* @__PURE__ */ C("p", {
441
+ className: "text-xs font-medium uppercase tracking-wide text-text-tertiary",
442
+ children: t("healthybowl.plantScan.alternatives", "Alternative candidates")
443
+ }), i.map((e, t) => /* @__PURE__ */ w("div", {
444
+ className: "flex items-center gap-3 text-sm",
445
+ children: [
446
+ /* @__PURE__ */ C("span", {
447
+ className: "flex h-5 w-5 items-center justify-center rounded-full bg-bg-sunken text-xs text-text-secondary",
448
+ children: t + 1
449
+ }),
450
+ /* @__PURE__ */ C("span", {
451
+ className: "flex-1 truncate text-text-primary",
452
+ children: e.name
453
+ }),
454
+ /* @__PURE__ */ C(F, { value: e.confidence }),
455
+ /* @__PURE__ */ w("span", {
456
+ className: "w-10 text-end text-text-secondary",
457
+ children: [Math.round(e.confidence), "%"]
458
+ })
459
+ ]
460
+ }, `${e.name}-${t}`))]
461
+ }) : null,
462
+ /* @__PURE__ */ w("div", {
463
+ className: "rounded-xl border border-border-subtle p-4",
464
+ children: [
465
+ /* @__PURE__ */ w("p", {
466
+ className: "mb-2 text-sm font-semibold text-text-primary",
467
+ children: [
468
+ t("healthybowl.plantScan.recommendedAction", "Recommended Action"),
469
+ " ",
470
+ /* @__PURE__ */ w("span", {
471
+ className: "font-normal text-text-tertiary",
472
+ children: [
473
+ "(",
474
+ t("healthybowl.plantScan.organicSafe", "organic-safe"),
475
+ ")"
476
+ ]
477
+ })
478
+ ]
479
+ }),
480
+ e.recommendedActions?.length ? /* @__PURE__ */ C("ul", {
481
+ className: "space-y-1.5",
482
+ children: e.recommendedActions.map((e, t) => /* @__PURE__ */ w("li", {
483
+ className: "flex gap-2 text-sm text-text-secondary",
484
+ children: [/* @__PURE__ */ C(v, {
485
+ size: 16,
486
+ className: "mt-0.5 shrink-0 text-accent-teal"
487
+ }), /* @__PURE__ */ C("span", { children: e })]
488
+ }, t))
489
+ }) : /* @__PURE__ */ C("p", {
490
+ className: "text-sm text-text-tertiary",
491
+ children: e.advisoryText ?? "—"
492
+ }),
493
+ /* @__PURE__ */ w("p", {
494
+ className: "mt-3 border-t border-border-subtle pt-2 text-xs text-text-tertiary",
495
+ children: [a ? /* @__PURE__ */ w(S, { children: [
496
+ /* @__PURE__ */ C(x, {
497
+ size: 12,
498
+ className: "mr-1 inline"
499
+ }),
500
+ t("healthybowl.plantScan.aiAttribution", "AI diagnosis"),
501
+ e.modelName ? ` · ${e.modelName}` : ""
502
+ ] }) : /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(g, {
503
+ size: 12,
504
+ className: "mr-1 inline"
505
+ }), t("healthybowl.plantScan.ruleAttribution", "Rule-based estimate (not AI) — confirm before treating")] }), e.processingMs ? ` · ${(e.processingMs / 1e3).toFixed(1)}s` : ""]
506
+ })
507
+ ]
508
+ })
509
+ ]
510
+ });
511
+ }
512
+ var L = [
513
+ "DISEASE",
514
+ "FUNGUS",
515
+ "INSECT",
516
+ "WEED"
517
+ ], R = [
518
+ "ACTIVE",
519
+ "MONITORING",
520
+ "TREATING",
521
+ "RESOLVED"
522
+ ], z = [
523
+ "LOW",
524
+ "MEDIUM",
525
+ "HIGH",
526
+ "CRITICAL"
527
+ ];
528
+ function B(e) {
529
+ let t = (e ?? "").toUpperCase();
530
+ return L.includes(t) ? t : "DISEASE";
531
+ }
532
+ function se({ open: e, onClose: t, scan: n, fields: r, defaultFieldId: i, t: a, onSubmit: ee }) {
533
+ let [s, c] = h(() => H(n, i)), [l, u] = h(!1);
534
+ f(() => {
535
+ e && c(H(n, i));
536
+ }, [
537
+ e,
538
+ n,
539
+ i
540
+ ]);
541
+ let d = (e, t) => c((n) => ({
542
+ ...n,
543
+ [e]: t
544
+ })), p = async () => {
545
+ u(!0);
546
+ try {
547
+ await ee(s);
548
+ } finally {
549
+ u(!1);
550
+ }
551
+ }, m = !!s.fieldId && !!s.pestName.trim();
552
+ return /* @__PURE__ */ w(o, {
553
+ open: e,
554
+ onClose: t,
555
+ title: a("healthybowl.plantScan.logModalTitle", "Log to Pest Issues"),
556
+ size: "lg",
557
+ footer: /* @__PURE__ */ w("div", {
558
+ className: "flex justify-end gap-2",
559
+ children: [/* @__PURE__ */ C(T, {
560
+ variant: "outline",
561
+ onClick: t,
562
+ children: a("common.cancel", "Cancel")
563
+ }), /* @__PURE__ */ w(T, {
564
+ onClick: () => void p(),
565
+ disabled: !m || l,
566
+ className: "gap-2",
567
+ children: [l ? /* @__PURE__ */ C(y, {
568
+ size: 16,
569
+ className: "animate-spin"
570
+ }) : /* @__PURE__ */ C(_, { size: 16 }), a("healthybowl.plantScan.createIssue", "Create Pest Issue")]
571
+ })]
572
+ }),
573
+ children: [
574
+ /* @__PURE__ */ w("div", {
575
+ className: "rounded-lg bg-status-success-bgSubtle px-3 py-2 text-sm text-status-success-text",
576
+ children: [
577
+ a("healthybowl.plantScan.prefill", "Pre-filled from AI scan"),
578
+ " — ",
579
+ n.topDiagnosis ?? "—",
580
+ n.topConfidence == null ? "" : `, ${Math.round(n.topConfidence)}% ${a("healthybowl.plantScan.confidenceLower", "confidence")}`
581
+ ]
582
+ }),
583
+ /* @__PURE__ */ w("div", {
584
+ className: "mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2",
585
+ children: [
586
+ /* @__PURE__ */ C(V, {
587
+ label: a("healthybowl.plantScan.pestDisease", "Pest / Disease"),
588
+ children: /* @__PURE__ */ C("input", {
589
+ value: s.pestName,
590
+ onChange: (e) => d("pestName", e.target.value),
591
+ className: j
592
+ })
593
+ }),
594
+ /* @__PURE__ */ C(V, {
595
+ label: a("healthybowl.plantScan.type", "Type"),
596
+ children: /* @__PURE__ */ w(E, {
597
+ value: s.type,
598
+ onValueChange: (e) => d("type", e),
599
+ children: [/* @__PURE__ */ C(k, {
600
+ className: "w-full",
601
+ children: /* @__PURE__ */ C(A, {})
602
+ }), /* @__PURE__ */ C(D, { children: L.map((e) => /* @__PURE__ */ C(O, {
603
+ value: e,
604
+ children: e
605
+ }, e)) })]
606
+ })
607
+ }),
608
+ /* @__PURE__ */ C(V, {
609
+ label: a("healthybowl.plantScan.affectedCrop", "Affected Crop"),
610
+ children: /* @__PURE__ */ C("input", {
611
+ value: s.cropAffected,
612
+ onChange: (e) => d("cropAffected", e.target.value),
613
+ className: j
614
+ })
615
+ }),
616
+ /* @__PURE__ */ C(V, {
617
+ label: a("healthybowl.plantScan.fieldLocation", "Field / Location"),
618
+ children: /* @__PURE__ */ w(E, {
619
+ value: s.fieldId,
620
+ onValueChange: (e) => d("fieldId", e),
621
+ children: [/* @__PURE__ */ C(k, {
622
+ className: "w-full",
623
+ children: /* @__PURE__ */ C(A, { placeholder: a("healthybowl.plantScan.selectField", "Select field") })
624
+ }), /* @__PURE__ */ C(D, { children: r.map((e) => /* @__PURE__ */ C(O, {
625
+ value: e.id,
626
+ children: e.name
627
+ }, e.id)) })]
628
+ })
629
+ }),
630
+ /* @__PURE__ */ C(V, {
631
+ label: a("healthybowl.plantScan.severityLabel", "Severity"),
632
+ children: /* @__PURE__ */ w(E, {
633
+ value: s.severity,
634
+ onValueChange: (e) => d("severity", e),
635
+ children: [/* @__PURE__ */ C(k, {
636
+ className: "w-full",
637
+ children: /* @__PURE__ */ C(A, {})
638
+ }), /* @__PURE__ */ C(D, { children: z.map((e) => /* @__PURE__ */ C(O, {
639
+ value: e,
640
+ children: e
641
+ }, e)) })]
642
+ })
643
+ }),
644
+ /* @__PURE__ */ C(V, {
645
+ label: a("healthybowl.plantScan.status", "Status"),
646
+ children: /* @__PURE__ */ w(E, {
647
+ value: s.status,
648
+ onValueChange: (e) => d("status", e),
649
+ children: [/* @__PURE__ */ C(k, {
650
+ className: "w-full",
651
+ children: /* @__PURE__ */ C(A, {})
652
+ }), /* @__PURE__ */ C(D, { children: R.map((e) => /* @__PURE__ */ C(O, {
653
+ value: e,
654
+ children: e
655
+ }, e)) })]
656
+ })
657
+ })
658
+ ]
659
+ }),
660
+ /* @__PURE__ */ C("div", {
661
+ className: "mt-4",
662
+ children: /* @__PURE__ */ C(V, {
663
+ label: /* @__PURE__ */ w(S, { children: [
664
+ a("healthybowl.plantScan.suggestedTreatment", "Suggested Treatment"),
665
+ " ",
666
+ /* @__PURE__ */ C("span", {
667
+ className: "rounded bg-status-success-bgSubtle px-1.5 py-0.5 text-[11px] text-status-success-text",
668
+ children: a("healthybowl.plantScan.aiSuggested", "AI-suggested (organic-safe)")
669
+ })
670
+ ] }),
671
+ children: /* @__PURE__ */ C("textarea", {
672
+ value: s.treatment,
673
+ onChange: (e) => d("treatment", e.target.value),
674
+ rows: 2,
675
+ className: j
676
+ })
677
+ })
678
+ }),
679
+ /* @__PURE__ */ C("div", {
680
+ className: "mt-4",
681
+ children: /* @__PURE__ */ C(V, {
682
+ label: a("healthybowl.plantScan.notesField", "Notes"),
683
+ children: /* @__PURE__ */ C("textarea", {
684
+ value: s.notes,
685
+ onChange: (e) => d("notes", e.target.value),
686
+ rows: 2,
687
+ placeholder: a("healthybowl.plantScan.addObservations", "Add any observations…"),
688
+ className: j
689
+ })
690
+ })
691
+ }),
692
+ /* @__PURE__ */ w("label", {
693
+ className: "mt-4 flex items-center gap-2 text-sm text-text-secondary",
694
+ children: [/* @__PURE__ */ C("input", {
695
+ type: "checkbox",
696
+ checked: s.attachPhoto,
697
+ onChange: (e) => d("attachPhoto", e.target.checked)
698
+ }), a("healthybowl.plantScan.attachPhoto", "Attach scan photo to this issue")]
699
+ })
700
+ ]
701
+ });
702
+ }
703
+ function V({ label: e, children: t }) {
704
+ return /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("label", {
705
+ className: "mb-1 flex items-center gap-2 text-xs font-medium text-text-secondary",
706
+ children: e
707
+ }), t] });
708
+ }
709
+ function H(e, t) {
710
+ return {
711
+ scanId: e.id,
712
+ fieldId: e.fieldId ?? t ?? "",
713
+ pestName: e.topScientificName ? `${e.topDiagnosis ?? ""} (${e.topScientificName})`.trim() : e.topDiagnosis ?? "",
714
+ type: B(e.topType),
715
+ cropAffected: e.cropName ?? "",
716
+ severity: (e.severity ?? "MEDIUM").toUpperCase() === "MODERATE" ? "MEDIUM" : (e.severity ?? "MEDIUM").toUpperCase(),
717
+ status: "ACTIVE",
718
+ treatment: (e.recommendedActions ?? []).join("; "),
719
+ notes: "",
720
+ attachPhoto: !0
721
+ };
722
+ }
723
+ //#endregion
724
+ export { I as AiPestDetectionPage };
725
+
726
+ //# sourceMappingURL=AiPestDetectionPage.js.map