@burdenoff/microfe-healthybowl 2026.710.11 → 2026.710.13

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.
@@ -4,25 +4,28 @@ import { useHealthyBowl as n } from "../../context/HealthyBowlContext.js";
4
4
  import { PageLayout as r } from "../../components/PageLayout.js";
5
5
  import { ErrorState as i } from "../../components/ErrorState.js";
6
6
  import { ToastContainer as a } from "../../components/Toast.js";
7
- import { useConfirm as o } from "../../components/ConfirmDialog.js";
8
- import { Modal as ee } from "../../components/Modal.js";
9
- import { require_leaflet_src as s } from "../../../node_modules/leaflet/dist/leaflet-src.js";
10
- import { useToast as te } from "../../hooks/useToast.js";
11
- import { ensureLeafletCss as ne } from "../../utils/leaflet.js";
12
- import { extractPolygon as re, isValidPolygon as c, polygonAreaInUnit as l, polygonAreaSqMeters as ie, polygonCentroid as ae, ringToPolygon as u } from "../../utils/geo.js";
13
- import { SOIL_PALETTE as oe, soilColor as se, soilLegendFor as ce } from "../../utils/soil.js";
7
+ import { useConfirm as ee } from "../../components/ConfirmDialog.js";
8
+ import { Modal as te } from "../../components/Modal.js";
9
+ import { require_leaflet_src as o } from "../../../node_modules/leaflet/dist/leaflet-src.js";
10
+ import { useToast as ne } from "../../hooks/useToast.js";
11
+ import { ensureLeafletCss as re } from "../../utils/leaflet.js";
12
+ import { extractPolygon as ie, isValidPolygon as s, polygonAreaInUnit as ae, polygonAreaSqMeters as oe, polygonCentroid as se, ringToPolygon as c } from "../../utils/geo.js";
13
+ import { SOIL_PALETTE as ce, soilColor as le, soilLegendFor as ue } from "../../utils/soil.js";
14
+ import { elevationColor as de, fetchElevations as fe } from "../../utils/elevation.js";
15
+ import { bedPlantCount as pe, generateBeds as me } from "../../utils/bedLayout.js";
14
16
  import "../../utils/index.js";
15
17
  import "../../components/index.js";
16
- import { useHealthyBowlData as le } from "../../hooks/useHealthyBowlData.js";
17
- import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
18
- import { useI18n as ue } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
19
- import { Check as de, Layers as fe, LocateFixed as pe, MapPinned as me, Pencil as he, Plus as ge, Ruler as _e, Save as ve, Search as ye, Spline as be, Trash2 as xe, X as Se } from "lucide-react";
20
- import { Fragment as Ce, jsx as g, jsxs as _ } from "react/jsx-runtime";
21
- import { Button as v, Select as we, SelectContent as Te, SelectItem as y, SelectTrigger as Ee, SelectValue as De } from "@burdenoff/fe-libs/ui";
22
- import { gql as Oe } from "@apollo/client";
23
- import { useMutation as ke } from "@apollo/client/react";
18
+ import { useHealthyBowlData as he } from "../../hooks/useHealthyBowlData.js";
19
+ import { DEFAULT_BED_WIDTH_M as ge, DEFAULT_PATH_WIDTH_M as _e, getCropSpacingPreset as ve } from "../../utils/plantingCapacity.js";
20
+ import { useCallback as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
21
+ import { useI18n as ye } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
22
+ import { Check as be, Layers as xe, LayoutGrid as Se, LocateFixed as Ce, MapPinned as we, Pencil as Te, Plus as Ee, Ruler as De, Save as Oe, Search as ke, Spline as Ae, Trash2 as je, X as Me } from "lucide-react";
23
+ import { Fragment as Ne, jsx as m, jsxs as h } from "react/jsx-runtime";
24
+ import { Button as g, Select as _, SelectContent as v, SelectItem as y, SelectTrigger as Pe, SelectValue as Fe } from "@burdenoff/fe-libs/ui";
25
+ import { gql as b } from "@apollo/client";
26
+ import { useMutation as Ie } from "@apollo/client/react";
24
27
  //#region src/healthybowl/pages/fields/FieldMapPage.tsx
25
- var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
28
+ var x = /* @__PURE__ */ e(o(), 1), Le = b`
26
29
  mutation UpdateHealthyBowlFieldBoundaryOnMapPage($input: UpdateHealthyBowlFieldInput!) {
27
30
  updateHealthyBowlField(input: $input) {
28
31
  id
@@ -31,48 +34,140 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
31
34
  location
32
35
  }
33
36
  }
34
- `, je = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}", Me = "Esri, Maxar, Earthstar Geographics", Ne = "https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", Pe = "© OpenTopoMap (CC-BY-SA) · © OpenStreetMap contributors", Fe = 21, Ie = 16, Le = 2.47105, Re = "#16a34a", ze = {
37
+ `, Re = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}", ze = "Esri, Maxar, Earthstar Geographics", Be = "https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", Ve = "© OpenTopoMap (CC-BY-SA) · © OpenStreetMap contributors", He = 21, Ue = 16, We = 2.47105, Ge = "#16a34a", Ke = {
35
38
  color: "#f59e0b",
36
39
  weight: 2,
37
40
  dashArray: "6 4",
38
41
  fillColor: "#f59e0b",
39
42
  fillOpacity: .15
40
- }, Be = {
43
+ }, qe = {
41
44
  color: "#ffffff",
42
45
  weight: 2,
43
46
  dashArray: "6 4",
44
47
  fillColor: "#22c55e",
45
48
  fillOpacity: .2
46
- }, Ve = {
49
+ }, Je = {
47
50
  color: "#38bdf8",
48
51
  weight: 3,
49
52
  dashArray: "6 6"
50
- }, He = (e) => !!(e && Number.isFinite(e.lat) && Number.isFinite(e.lng) && e.lat >= -90 && e.lat <= 90 && e.lng >= -180 && e.lng <= 180 && (e.lat !== 0 || e.lng !== 0)), Ue = (e) => /hect|(^|[^a-z])ha([^a-z]|$)/i.test(e ?? ""), We = (e) => Ue(e.unit) ? e.area * Le : e.area, Ge = (e) => `${e.area.toFixed(1)} ${Ue(e.unit) ? "ha" : "ac"}`, x = (e) => {
51
- let t = re(e.boundary);
52
- return t && c(t) ? t : null;
53
- }, Ke = b.default.divIcon({
53
+ }, Ye = {
54
+ color: "#064e3b",
55
+ weight: 1,
56
+ fillColor: "#22c55e",
57
+ fillOpacity: .4
58
+ }, Xe = (e) => !!(e && Number.isFinite(e.lat) && Number.isFinite(e.lng) && e.lat >= -90 && e.lat <= 90 && e.lng >= -180 && e.lng <= 180 && (e.lat !== 0 || e.lng !== 0)), Ze = (e) => /hect|(^|[^a-z])ha([^a-z]|$)/i.test(e ?? ""), Qe = (e) => Ze(e.unit) ? e.area * We : e.area, $e = (e) => `${e.area.toFixed(1)} ${Ze(e.unit) ? "ha" : "ac"}`, S = (e) => {
59
+ let t = ie(e.boundary);
60
+ return t && s(t) ? t : null;
61
+ }, et = x.default.divIcon({
54
62
  className: "",
55
63
  html: "<span style=\"display:block;width:12px;height:12px;background:#22c55e;border:2px solid #fff;border-radius:2px;box-shadow:0 0 3px rgba(0,0,0,.6)\"></span>",
56
64
  iconSize: [16, 16],
57
65
  iconAnchor: [8, 8]
58
- }), S = () => {
59
- let { t: e } = ue(), { workspaceId: s } = n(), re = o(), { fields: c, crops: Oe, loadings: Le, errors: Ue, refetch: S, createField: qe } = le(), { toasts: Je, toast: C, dismiss: Ye } = te(), [w] = ke(Ae), [T, Xe] = h("loading"), [E, D] = h("view"), [O, k] = h(null), [A, Ze] = h(!1), [j, Qe] = h(!0), [M, $e] = h(""), [N, et] = h(""), [tt, nt] = h(!1), [rt, it] = h(0), [at, P] = h(null), [ot, st] = h(!1), [ct, lt] = h(!1), [F, ut] = h(null), [I, L] = h(null), [dt, ft] = h(!1), [R, pt] = h(""), [mt, ht] = h("Clay loam"), [gt, _t] = h("Drip"), [vt, yt] = h("active"), bt = m(null), z = m(null), xt = m(null), St = m(null), Ct = m(null), B = m(null), V = m(null), H = m(null), U = m([]), W = m(null), G = m([]), K = m(null), wt = m([]), q = m("view"), Tt = m(!1);
60
- f(() => {
61
- q.current = E;
62
- }, [E]);
63
- let Et = p(() => c.filter((e) => x(e) !== null).length, [c]), Dt = p(() => c.reduce((e, t) => e + We(t), 0), [c]), Ot = p(() => ce(c.map((e) => e.soilType)), [c]), J = p(() => c.find((e) => e.id === O) ?? null, [c, O]), kt = p(() => {
64
- let e = M.trim().toLowerCase();
65
- return e ? c.filter((t) => t.name.toLowerCase().includes(e) || (t.soilType ?? "").toLowerCase().includes(e)) : c;
66
- }, [c, M]), At = d((e) => {
66
+ }), C = () => {
67
+ let { t: e } = ye(), { workspaceId: o } = n(), ie = ee(), { fields: s, crops: b, loadings: We, errors: Ze, refetch: C, createField: tt } = he(), { toasts: nt, toast: w, dismiss: rt } = ne(), [T] = Ie(Le), [E, it] = p("loading"), [D, O] = p("view"), [k, A] = p(null), [j, at] = p(!1), [M, ot] = p(!0), [N, st] = p(!1), [P, ct] = p({}), [lt, ut] = p(""), [dt, ft] = p(""), [pt, mt] = p(!1), [ht, gt] = p(0), [_t, vt] = p(null), [yt, bt] = p(!1), [xt, St] = p(!1), [F, Ct] = p(null), [wt, Tt] = p(!1), [I, Et] = p(ge), [Dt, Ot] = p(_e), [L, kt] = p(0), [At, jt] = p(""), [R, z] = p(null), [Mt, Nt] = p(!1), [B, Pt] = p(""), [Ft, It] = p("Clay loam"), [Lt, Rt] = p("Drip"), [zt, Bt] = p("active"), Vt = f(null), V = f(null), Ht = f(null), Ut = f(null), Wt = f(null), H = f(null), U = f(null), W = f(null), Gt = f(null), G = f([]), Kt = f(null), K = f([]), qt = f(null), Jt = f([]), q = f("view"), Yt = f(!1);
68
+ u(() => {
69
+ q.current = D;
70
+ }, [D]);
71
+ let Xt = d(() => s.filter((e) => S(e) !== null).length, [s]), Zt = d(() => s.reduce((e, t) => e + Qe(t), 0), [s]), Qt = d(() => ue(s.map((e) => e.soilType)), [s]), J = d(() => s.find((e) => e.id === k) ?? null, [s, k]), $t = d(() => {
72
+ let e = lt.trim().toLowerCase();
73
+ return e ? s.filter((t) => t.name.toLowerCase().includes(e) || (t.soilType ?? "").toLowerCase().includes(e)) : s;
74
+ }, [s, lt]), Y = d(() => {
75
+ let e = [];
76
+ for (let t of s) {
77
+ let n = S(t);
78
+ if (n) {
79
+ let r = se(n);
80
+ if (r) {
81
+ e.push({
82
+ id: t.id,
83
+ lat: r[0],
84
+ lng: r[1]
85
+ });
86
+ continue;
87
+ }
88
+ }
89
+ Xe(t.location) && e.push({
90
+ id: t.id,
91
+ lat: t.location.lat,
92
+ lng: t.location.lng
93
+ });
94
+ }
95
+ return e;
96
+ }, [s]);
97
+ u(() => {
98
+ if (Y.length === 0) {
99
+ ct({});
100
+ return;
101
+ }
102
+ let e = new AbortController(), t = !1;
103
+ return fe(Y.map((e) => ({
104
+ lat: e.lat,
105
+ lng: e.lng
106
+ })), e.signal).then((e) => {
107
+ if (t) return;
108
+ let n = {};
109
+ Y.forEach((t, r) => {
110
+ n[t.id] = e[r] ?? null;
111
+ }), ct(n);
112
+ }), () => {
113
+ t = !0, e.abort();
114
+ };
115
+ }, [d(() => Y.map((e) => `${e.id}:${e.lat.toFixed(5)},${e.lng.toFixed(5)}`).join("|"), [Y])]);
116
+ let [en, tn] = d(() => {
117
+ let e = Object.values(P).filter((e) => e != null && Number.isFinite(e));
118
+ return e.length === 0 ? [0, 0] : [Math.min(...e), Math.max(...e)];
119
+ }, [P]), nn = d(() => Object.values(P).some((e) => e != null && Number.isFinite(e)), [P]), rn = l((e) => {
67
120
  if (!e) return "";
68
- let t = Oe.find((t) => t.field === e.id || t.fieldName === e.name);
121
+ let t = b.find((t) => t.field === e.id || t.fieldName === e.name);
69
122
  return t ? t.name : (e.crops ?? []).join(", ");
70
- }, [Oe]), jt = d((e) => {
71
- let t = z.current;
123
+ }, [b]), an = d(() => J ? S(J) : null, [J]), on = d(() => J ? b.find((e) => e.field === J.id || e.fieldName === J.name) ?? null : null, [b, J]), sn = d(() => b.find((e) => e.id === At) ?? on, [
124
+ b,
125
+ At,
126
+ on
127
+ ]), X = d(() => ve(sn), [sn]);
128
+ u(() => {
129
+ jt("");
130
+ }, [k]);
131
+ let Z = d(() => an ? me(an, {
132
+ bedWidthM: I,
133
+ pathWidthM: Dt,
134
+ orientationDeg: L
135
+ }) : null, [
136
+ an,
137
+ I,
138
+ Dt,
139
+ L
140
+ ]), cn = d(() => Z ? Z.beds.reduce((e, t) => e + pe(oe(t), I, X.plantSpacingCm, X.rowSpacingCm), 0) : 0, [
141
+ Z,
142
+ I,
143
+ X
144
+ ]);
145
+ u(() => {
146
+ let t = Gt.current;
147
+ t && (t.clearLayers(), !(!wt || !Z || D !== "view") && Z.beds.forEach((n) => {
148
+ let r = oe(n), i = pe(r, I, X.plantSpacingCm, X.rowSpacingCm), a = x.default.geoJSON(n, { style: () => Ye });
149
+ a.bindTooltip(e("healthybowl.fieldMapPage.beds.bedTooltip", "{{plants}} plants · {{area}} m²", {
150
+ plants: String(i),
151
+ area: r.toFixed(0)
152
+ }), {
153
+ sticky: !0,
154
+ direction: "top"
155
+ }), a.addTo(t);
156
+ }));
157
+ }, [
158
+ wt,
159
+ Z,
160
+ I,
161
+ X,
162
+ D,
163
+ e
164
+ ]);
165
+ let ln = l((e) => {
166
+ let t = V.current;
72
167
  if (!t) return;
73
- let n = x(e);
168
+ let n = S(e);
74
169
  if (n) try {
75
- let e = b.default.geoJSON(n).getBounds();
170
+ let e = x.default.geoJSON(n).getBounds();
76
171
  if (e.isValid()) {
77
172
  t.fitBounds(e, {
78
173
  padding: [40, 40],
@@ -81,29 +176,29 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
81
176
  return;
82
177
  }
83
178
  } catch {}
84
- He(e.location) && t.flyTo([e.location.lat, e.location.lng], Ie, { duration: .6 });
85
- }, []), Mt = d((e) => {
86
- q.current === "draw" || q.current === "measure" || (k(e.id), jt(e));
87
- }, [jt]);
88
- f(() => {
89
- O && document.querySelector(`[data-field-id="${O}"]`)?.scrollIntoView({ block: "nearest" });
90
- }, [O]);
91
- let Y = d(() => {
92
- let t = z.current, n = Ct.current;
179
+ Xe(e.location) && t.flyTo([e.location.lat, e.location.lng], Ue, { duration: .6 });
180
+ }, []), un = l((e) => {
181
+ q.current === "draw" || q.current === "measure" || (A(e.id), ln(e));
182
+ }, [ln]);
183
+ u(() => {
184
+ k && document.querySelector(`[data-field-id="${k}"]`)?.scrollIntoView({ block: "nearest" });
185
+ }, [k]);
186
+ let dn = l(() => {
187
+ let t = V.current, n = Wt.current;
93
188
  if (!t || !n) return;
94
189
  n.clearLayers();
95
190
  let r = [];
96
- for (let t of c) {
97
- if (E === "edit" && t.id === O) continue;
98
- let i = t.id === O, a = j ? se(t.soilType) : Re, o = `${t.name} — ${Ge(t)}`, ee = x(t);
99
- if (ee) {
100
- let e = b.default.geoJSON(ee, { style: () => ({
101
- color: i ? "#ffffff" : a,
191
+ for (let t of s) {
192
+ if (D === "edit" && t.id === k) continue;
193
+ let i = t.id === k, a = P[t.id], ee = N && a != null ? de(a, en, tn) : M ? le(t.soilType) : Ge, te = `${t.name} — ${$e(t)}`, o = S(t);
194
+ if (o) {
195
+ let e = x.default.geoJSON(o, { style: () => ({
196
+ color: i ? "#ffffff" : ee,
102
197
  weight: i ? 4 : 2,
103
- fillColor: a,
198
+ fillColor: ee,
104
199
  fillOpacity: i ? .5 : .3
105
200
  }) });
106
- e.on("click", () => k(t.id)), e.bindTooltip(o, {
201
+ e.on("click", () => A(t.id)), e.bindTooltip(te, {
107
202
  permanent: !0,
108
203
  direction: "center",
109
204
  className: "hb-field-label"
@@ -112,90 +207,94 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
112
207
  let t = e.getBounds();
113
208
  t.isValid() && r.push(t);
114
209
  } catch {}
115
- } else if (He(t.location)) {
116
- let o = b.default.circleMarker([t.location.lat, t.location.lng], {
210
+ } else if (Xe(t.location)) {
211
+ let a = x.default.circleMarker([t.location.lat, t.location.lng], {
117
212
  radius: i ? 9 : 7,
118
213
  color: i ? "#ffffff" : "#fff",
119
214
  weight: i ? 3 : 2,
120
- fillColor: a,
215
+ fillColor: ee,
121
216
  fillOpacity: 1
122
217
  });
123
- o.on("click", () => k(t.id)), o.bindTooltip(`${t.name} (${e("healthybowl.fieldMapPage.unmapped", "no boundary")})`, {
218
+ a.on("click", () => A(t.id)), a.bindTooltip(`${t.name} (${e("healthybowl.fieldMapPage.unmapped", "no boundary")})`, {
124
219
  permanent: !1,
125
220
  direction: "top"
126
- }), o.addTo(n), r.push(b.default.latLngBounds([t.location.lat, t.location.lng], [t.location.lat, t.location.lng]));
221
+ }), a.addTo(n), r.push(x.default.latLngBounds([t.location.lat, t.location.lng], [t.location.lat, t.location.lng]));
127
222
  }
128
223
  }
129
- if (!Tt.current && r.length > 0) {
130
- let e = r.reduce((e, t) => e.extend(t), b.default.latLngBounds(r[0].getSouthWest(), r[0].getNorthEast()));
224
+ if (!Yt.current && r.length > 0) {
225
+ let e = r.reduce((e, t) => e.extend(t), x.default.latLngBounds(r[0].getSouthWest(), r[0].getNorthEast()));
131
226
  try {
132
227
  t.fitBounds(e, {
133
228
  padding: [40, 40],
134
229
  maxZoom: 17
135
- }), Tt.current = !0;
230
+ }), Yt.current = !0;
136
231
  } catch {}
137
232
  }
138
233
  }, [
139
- c,
140
- E,
141
- O,
142
- j,
234
+ s,
235
+ D,
236
+ k,
237
+ M,
238
+ N,
239
+ P,
240
+ en,
241
+ tn,
143
242
  e
144
243
  ]);
145
- f(() => {
146
- T === "ready" && Y();
147
- }, [Y, T]);
148
- let X = d(() => {
149
- B.current?.clearLayers(), W.current = null, U.current = [], it(0);
150
- }, []), Nt = d(() => {
151
- let e = B.current;
244
+ u(() => {
245
+ E === "ready" && dn();
246
+ }, [dn, E]);
247
+ let Q = l(() => {
248
+ H.current?.clearLayers(), Kt.current = null, G.current = [], gt(0);
249
+ }, []), fn = l(() => {
250
+ let e = H.current;
152
251
  if (!e) return;
153
- W.current &&= (e.removeLayer(W.current), null);
154
- let t = U.current;
155
- t.length >= 2 && (W.current = b.default.polygon(t, ze).addTo(e));
156
- }, []), Pt = d(() => {
157
- let t = U.current;
252
+ Kt.current &&= (e.removeLayer(Kt.current), null);
253
+ let t = G.current;
254
+ t.length >= 2 && (Kt.current = x.default.polygon(t, Ke).addTo(e));
255
+ }, []), pn = l(() => {
256
+ let t = G.current;
158
257
  if (t.length < 3) {
159
- C({
258
+ w({
160
259
  title: e("healthybowl.fieldMapPage.toast.needPoints.title", "Need at least 3 points"),
161
260
  description: e("healthybowl.fieldMapPage.toast.needPoints.description", "Click the map to add more corners."),
162
261
  variant: "warning"
163
262
  });
164
263
  return;
165
264
  }
166
- let n = u(t.map((e) => ({
265
+ let n = c(t.map((e) => ({
167
266
  lat: e.lat,
168
267
  lng: e.lng
169
268
  })));
170
- X(), q.current = "view", D("view"), n && (L({
269
+ Q(), q.current = "view", O("view"), n && (z({
171
270
  boundary: n,
172
- area: l(n, "acres"),
173
- centroid: ae(n) ?? [0, 0]
174
- }), pt(""), ht("Clay loam"), _t("Drip"), yt("active"));
271
+ area: ae(n, "acres"),
272
+ centroid: se(n) ?? [0, 0]
273
+ }), Pt(""), It("Clay loam"), Rt("Drip"), Bt("active"));
175
274
  }, [
176
- X,
275
+ Q,
177
276
  e,
178
- C
179
- ]), Ft = d(() => {
180
- k(null), X(), q.current = "draw", D("draw");
181
- }, [X]), It = d(() => {
182
- X(), q.current = "view", D("view");
183
- }, [X]), Z = d(() => {
184
- V.current?.clearLayers(), K.current = null, G.current = [], P(null), st(!1);
185
- }, []), Lt = d(() => {
186
- if (!V.current || !K.current) return;
187
- K.current.setLatLngs(G.current);
188
- let e = u(G.current.map((e) => ({
277
+ w
278
+ ]), mn = l(() => {
279
+ A(null), Q(), q.current = "draw", O("draw");
280
+ }, [Q]), hn = l(() => {
281
+ Q(), q.current = "view", O("view");
282
+ }, [Q]), gn = l(() => {
283
+ U.current?.clearLayers(), qt.current = null, K.current = [], vt(null), bt(!1);
284
+ }, []), _n = l(() => {
285
+ if (!U.current || !qt.current) return;
286
+ qt.current.setLatLngs(K.current);
287
+ let e = c(K.current.map((e) => ({
189
288
  lat: e.lat,
190
289
  lng: e.lng
191
290
  })));
192
- e && P(l(e, J?.unit ?? "acres"));
193
- }, [J]), Rt = d(() => {
194
- let t = z.current, n = V.current;
291
+ e && vt(ae(e, J?.unit ?? "acres"));
292
+ }, [J]), vn = l(() => {
293
+ let t = V.current, n = U.current;
195
294
  if (!t || !n || !J) return;
196
- let r = x(J);
295
+ let r = S(J);
197
296
  if (!r) {
198
- C({
297
+ w({
199
298
  title: e("healthybowl.fieldMapPage.toast.noBoundary.title", "No boundary to edit"),
200
299
  description: e("healthybowl.fieldMapPage.toast.noBoundary.description", "Draw a boundary for this field first."),
201
300
  variant: "warning"
@@ -203,38 +302,38 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
203
302
  return;
204
303
  }
205
304
  n.clearLayers();
206
- let i = r.coordinates[0].slice(0, -1).map(([e, t]) => b.default.latLng(t, e));
207
- G.current = i, K.current = b.default.polygon(i, Be).addTo(n), i.forEach((e, t) => {
208
- b.default.marker(i[t], {
209
- icon: Ke,
305
+ let i = r.coordinates[0].slice(0, -1).map(([e, t]) => x.default.latLng(t, e));
306
+ K.current = i, qt.current = x.default.polygon(i, qe).addTo(n), i.forEach((e, t) => {
307
+ x.default.marker(i[t], {
308
+ icon: et,
210
309
  draggable: !0
211
310
  }).addTo(n).on("drag", (e) => {
212
- G.current[t] = e.target.getLatLng(), Lt(), st(!0);
311
+ K.current[t] = e.target.getLatLng(), _n(), bt(!0);
213
312
  });
214
- }), q.current = "edit", D("edit"), st(!1), P(l(r, J.unit));
313
+ }), q.current = "edit", O("edit"), bt(!1), vt(ae(r, J.unit));
215
314
  }, [
216
- Lt,
315
+ _n,
217
316
  J,
218
317
  e,
219
- C
220
- ]), zt = d(() => {
221
- Z(), q.current = "view", D("view"), Y();
222
- }, [Z, Y]), Bt = d(async () => {
318
+ w
319
+ ]), yn = l(() => {
320
+ gn(), q.current = "view", O("view"), dn();
321
+ }, [gn, dn]), bn = l(async () => {
223
322
  if (!J) return;
224
- let t = u(G.current.map((e) => ({
323
+ let t = c(K.current.map((e) => ({
225
324
  lat: e.lat,
226
325
  lng: e.lng
227
326
  })));
228
327
  if (t) {
229
- lt(!0);
328
+ St(!0);
230
329
  try {
231
- let n = l(t, J.unit);
232
- await w({ variables: { input: {
330
+ let n = ae(t, J.unit);
331
+ await T({ variables: { input: {
233
332
  id: J.id,
234
333
  boundary: t,
235
334
  area: n,
236
- context: { workspaceId: s }
237
- } } }), await S(), Z(), q.current = "view", D("view"), C({
335
+ context: { workspaceId: o }
336
+ } } }), await C(), gn(), q.current = "view", O("view"), w({
238
337
  title: e("healthybowl.fieldMapPage.toast.saved.title", "Boundary saved"),
239
338
  description: e("healthybowl.fieldMapPage.toast.saved.description", "Area updated to {{area}} {{unit}}.", {
240
339
  area: String(n),
@@ -243,49 +342,49 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
243
342
  variant: "success"
244
343
  });
245
344
  } catch (t) {
246
- C({
345
+ w({
247
346
  title: e("healthybowl.fieldMapPage.toast.saveFailed.title", "Save failed"),
248
347
  description: String(t),
249
348
  variant: "error"
250
349
  });
251
350
  } finally {
252
- lt(!1);
351
+ St(!1);
253
352
  }
254
353
  }
255
354
  }, [
256
- Z,
257
- S,
355
+ gn,
356
+ C,
258
357
  J,
259
358
  e,
260
- C,
261
359
  w,
262
- s
263
- ]), Vt = d(async () => {
360
+ T,
361
+ o
362
+ ]), xn = l(async () => {
264
363
  if (J) {
265
- if (!x(J)) {
266
- C({
364
+ if (!S(J)) {
365
+ w({
267
366
  title: e("healthybowl.fieldMapPage.toast.noBoundary.title", "No boundary to edit"),
268
367
  description: e("healthybowl.fieldMapPage.toast.deleteNone.description", "This field has no boundary to delete."),
269
368
  variant: "warning"
270
369
  });
271
370
  return;
272
371
  }
273
- if (await re({
372
+ if (await ie({
274
373
  title: e("healthybowl.fieldMapPage.confirmDelete.title", "Delete boundary?"),
275
374
  message: e("healthybowl.fieldMapPage.confirmDelete.description", "This removes the drawn shape from {{name}}. The field record is kept.", { name: J.name }),
276
375
  okButtonTitle: e("healthybowl.common.delete", "Delete")
277
376
  })) try {
278
- await w({ variables: { input: {
377
+ await T({ variables: { input: {
279
378
  id: J.id,
280
379
  boundary: null,
281
- context: { workspaceId: s }
282
- } } }), await S(), C({
380
+ context: { workspaceId: o }
381
+ } } }), await C(), w({
283
382
  title: e("healthybowl.fieldMapPage.toast.boundaryDeleted.title", "Boundary removed"),
284
383
  description: e("healthybowl.fieldMapPage.toast.boundaryDeleted.description", "The drawn shape was cleared."),
285
384
  variant: "success"
286
385
  });
287
386
  } catch (t) {
288
- C({
387
+ w({
289
388
  title: e("healthybowl.fieldMapPage.toast.saveFailed.title", "Save failed"),
290
389
  description: String(t),
291
390
  variant: "error"
@@ -293,415 +392,440 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
293
392
  }
294
393
  }
295
394
  }, [
296
- re,
297
- S,
395
+ ie,
396
+ C,
298
397
  J,
299
398
  e,
300
- C,
301
399
  w,
302
- s
303
- ]), Q = d(() => {
304
- H.current?.clearLayers(), wt.current = [], ut(null);
305
- }, []), Ht = d(() => {
306
- let e = H.current;
400
+ T,
401
+ o
402
+ ]), $ = l(() => {
403
+ W.current?.clearLayers(), Jt.current = [], Ct(null);
404
+ }, []), Sn = l(() => {
405
+ let e = W.current;
307
406
  if (!e) return;
308
407
  e.clearLayers();
309
- let t = wt.current;
408
+ let t = Jt.current;
310
409
  t.forEach((t) => {
311
- b.default.circleMarker(t, {
410
+ x.default.circleMarker(t, {
312
411
  radius: 4,
313
412
  color: "#38bdf8",
314
413
  weight: 2,
315
414
  fillColor: "#fff",
316
415
  fillOpacity: 1
317
416
  }).addTo(e);
318
- }), t.length >= 2 && b.default.polyline(t, Ve).addTo(e);
417
+ }), t.length >= 2 && x.default.polyline(t, Je).addTo(e);
319
418
  let n = 0;
320
419
  for (let e = 1; e < t.length; e++) n += t[e - 1].distanceTo(t[e]);
321
420
  let r = null;
322
421
  if (t.length >= 3) {
323
- let e = u(t.map((e) => ({
422
+ let e = c(t.map((e) => ({
324
423
  lat: e.lat,
325
424
  lng: e.lng
326
425
  })));
327
- e && (r = ie(e));
426
+ e && (r = oe(e));
328
427
  }
329
- ut({
428
+ Ct({
330
429
  distance: n,
331
430
  area: r
332
431
  });
333
- }, []), Ut = d(() => {
334
- k(null), Q(), q.current = "measure", D("measure"), ut({
432
+ }, []), Cn = l(() => {
433
+ A(null), $(), q.current = "measure", O("measure"), Ct({
335
434
  distance: 0,
336
435
  area: null
337
436
  });
338
- }, [Q]), Wt = d(() => {
339
- Q(), q.current = "view", D("view");
340
- }, [Q]), Gt = d((e) => {
341
- if (z.current) if (q.current === "draw") {
342
- U.current.push(e.latlng);
343
- let t = U.current.length === 1, n = b.default.circleMarker(e.latlng, {
437
+ }, [$]), wn = l(() => {
438
+ $(), q.current = "view", O("view");
439
+ }, [$]), Tn = l((e) => {
440
+ if (V.current) if (q.current === "draw") {
441
+ G.current.push(e.latlng);
442
+ let t = G.current.length === 1, n = x.default.circleMarker(e.latlng, {
344
443
  radius: t ? 7 : 5,
345
444
  color: "#fff",
346
445
  weight: 2,
347
446
  fillColor: t ? "#16a34a" : "#f59e0b",
348
447
  fillOpacity: 1
349
- }).addTo(B.current);
448
+ }).addTo(H.current);
350
449
  t && n.on("click", (e) => {
351
- b.default.DomEvent.stopPropagation(e), Pt();
352
- }), it(U.current.length), Nt();
353
- } else q.current === "measure" && (wt.current.push(e.latlng), Ht());
450
+ x.default.DomEvent.stopPropagation(e), pn();
451
+ }), gt(G.current.length), fn();
452
+ } else q.current === "measure" && (Jt.current.push(e.latlng), Sn());
354
453
  }, [
355
- Pt,
356
- Ht,
357
- Nt
358
- ]), Kt = d(async (n) => {
454
+ pn,
455
+ Sn,
456
+ fn
457
+ ]), En = l(async (n) => {
359
458
  n.preventDefault();
360
- let r = z.current, i = N.trim();
459
+ let r = V.current, i = dt.trim();
361
460
  if (!r || !i) return;
362
461
  let a = i.match(/^(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)$/);
363
462
  if (a) {
364
- r.flyTo([Number(a[1]), Number(a[2])], Ie, { duration: .6 });
463
+ r.flyTo([Number(a[1]), Number(a[2])], Ue, { duration: .6 });
365
464
  return;
366
465
  }
367
- nt(!0);
466
+ mt(!0);
368
467
  try {
369
468
  let n = await t(i);
370
469
  if (!n) {
371
- C({
470
+ w({
372
471
  title: e("healthybowl.fieldMapPage.toast.placeNotFound.title", "Place not found"),
373
472
  description: e("healthybowl.fieldMapPage.toast.placeNotFound.description", "Try a more specific place name."),
374
473
  variant: "warning"
375
474
  });
376
475
  return;
377
476
  }
378
- r.flyTo([n.latitude, n.longitude], Ie, { duration: .6 });
477
+ r.flyTo([n.latitude, n.longitude], Ue, { duration: .6 });
379
478
  } catch (t) {
380
- C({
479
+ w({
381
480
  title: e("healthybowl.fieldMapPage.toast.searchFailed.title", "Search failed"),
382
481
  description: t instanceof Error ? t.message : String(t),
383
482
  variant: "error"
384
483
  });
385
484
  } finally {
386
- nt(!1);
485
+ mt(!1);
387
486
  }
388
487
  }, [
389
- N,
488
+ dt,
390
489
  e,
391
- C
392
- ]), qt = d(async () => {
393
- if (I) {
394
- if (!R.trim()) {
395
- C({
490
+ w
491
+ ]), Dn = l(async () => {
492
+ if (R) {
493
+ if (!B.trim()) {
494
+ w({
396
495
  title: e("healthybowl.fieldMapPage.toast.nameRequired.title", "Name required"),
397
496
  description: e("healthybowl.fieldMapPage.toast.nameRequired.description", "Give the new field a name."),
398
497
  variant: "warning"
399
498
  });
400
499
  return;
401
500
  }
402
- ft(!0);
501
+ Nt(!0);
403
502
  try {
404
- let [t, n] = I.centroid, r = await qe({
405
- name: R.trim(),
406
- area: I.area,
503
+ let [t, n] = R.centroid, r = await tt({
504
+ name: B.trim(),
505
+ area: R.area,
407
506
  unit: "acres",
408
- soilType: mt,
409
- irrigationType: gt,
507
+ soilType: Ft,
508
+ irrigationType: Lt,
410
509
  organicCertified: !1,
411
- status: vt,
510
+ status: zt,
412
511
  crops: [],
413
512
  location: {
414
513
  lat: t,
415
514
  lng: n
416
515
  }
417
516
  });
418
- r?.id && await w({ variables: { input: {
517
+ r?.id && await T({ variables: { input: {
419
518
  id: r.id,
420
- boundary: I.boundary,
421
- area: I.area,
422
- context: { workspaceId: s }
423
- } } }), await S(), L(null), r?.id && k(r.id), C({
519
+ boundary: R.boundary,
520
+ area: R.area,
521
+ context: { workspaceId: o }
522
+ } } }), await C(), z(null), r?.id && A(r.id), w({
424
523
  title: e("healthybowl.fieldMapPage.toast.fieldCreated.title", "Field created"),
425
524
  description: e("healthybowl.fieldMapPage.toast.fieldCreated.description", "{{name}} saved at {{area}} acres.", {
426
- name: R.trim(),
427
- area: String(I.area)
525
+ name: B.trim(),
526
+ area: String(R.area)
428
527
  }),
429
528
  variant: "success"
430
529
  });
431
530
  } catch (t) {
432
- C({
531
+ w({
433
532
  title: e("healthybowl.fieldMapPage.toast.createFailed.title", "Create failed"),
434
533
  description: String(t),
435
534
  variant: "error"
436
535
  });
437
536
  } finally {
438
- ft(!1);
537
+ Nt(!1);
439
538
  }
440
539
  }
441
540
  }, [
442
- qe,
443
- gt,
541
+ tt,
542
+ Lt,
543
+ B,
544
+ Ft,
545
+ zt,
444
546
  R,
445
- mt,
446
- vt,
447
- I,
448
- S,
449
- e,
450
547
  C,
548
+ e,
451
549
  w,
452
- s
550
+ T,
551
+ o
453
552
  ]);
454
- f(() => {
455
- let e = bt.current;
553
+ u(() => {
554
+ let e = Vt.current;
456
555
  if (!e) return;
457
- ne();
458
- let t = b.default.tileLayer(je, {
459
- attribution: Me,
460
- maxZoom: Fe,
556
+ re();
557
+ let t = x.default.tileLayer(Re, {
558
+ attribution: ze,
559
+ maxZoom: He,
461
560
  maxNativeZoom: 18
462
- }), n = b.default.tileLayer(Ne, {
463
- attribution: Pe,
464
- maxZoom: Fe,
561
+ }), n = x.default.tileLayer(Be, {
562
+ attribution: Ve,
563
+ maxZoom: He,
465
564
  maxNativeZoom: 17,
466
565
  opacity: .65
467
566
  });
468
- xt.current = t, St.current = n;
469
- let r = b.default.map(e, {
567
+ Ht.current = t, Ut.current = n;
568
+ let r = x.default.map(e, {
470
569
  center: [20, 78],
471
570
  zoom: 4,
472
571
  scrollWheelZoom: !0,
473
- maxZoom: Fe,
572
+ maxZoom: He,
474
573
  layers: [t]
475
574
  });
476
- return z.current = r, Ct.current = b.default.layerGroup().addTo(r), B.current = b.default.layerGroup().addTo(r), V.current = b.default.layerGroup().addTo(r), H.current = b.default.layerGroup().addTo(r), r.on("click", Gt), Xe("ready"), window.setTimeout(() => r.invalidateSize(), 80), () => {
477
- r.off("click", Gt), r.remove(), z.current = null, xt.current = null, St.current = null, Ct.current = null, B.current = null, V.current = null, H.current = null;
575
+ return V.current = r, Wt.current = x.default.layerGroup().addTo(r), Gt.current = x.default.layerGroup().addTo(r), H.current = x.default.layerGroup().addTo(r), U.current = x.default.layerGroup().addTo(r), W.current = x.default.layerGroup().addTo(r), r.on("click", Tn), it("ready"), window.setTimeout(() => r.invalidateSize(), 80), () => {
576
+ r.off("click", Tn), r.remove(), V.current = null, Ht.current = null, Ut.current = null, Wt.current = null, Gt.current = null, H.current = null, U.current = null, W.current = null;
478
577
  };
479
- }, []), f(() => {
480
- let e = z.current, t = St.current;
481
- !e || !t || (A ? t.addTo(e) : e.removeLayer(t));
482
- }, [A]);
483
- let Jt = !Le.crops && c.length === 0, Yt = F ? F.distance >= 1e3 ? `${(F.distance / 1e3).toFixed(2)} km` : `${F.distance.toFixed(0)} m` : "";
484
- if (Ue.crops && c.length === 0) return /* @__PURE__ */ g(r, {
578
+ }, []), u(() => {
579
+ let e = V.current, t = Ut.current;
580
+ !e || !t || (j ? t.addTo(e) : e.removeLayer(t));
581
+ }, [j]);
582
+ let On = !We.crops && s.length === 0, kn = F ? F.distance >= 1e3 ? `${(F.distance / 1e3).toFixed(2)} km` : `${F.distance.toFixed(0)} m` : "";
583
+ if (Ze.crops && s.length === 0) return /* @__PURE__ */ m(r, {
485
584
  title: e("healthybowl.fieldMapPage.title", "Field Map"),
486
585
  titleAccent: e("healthybowl.fieldMapPage.titleAccent", "Map"),
487
586
  description: e("healthybowl.fieldMapPage.description", "Draw and manage your field boundaries on satellite imagery."),
488
- children: /* @__PURE__ */ g(i, { onRetry: S })
587
+ children: /* @__PURE__ */ m(i, { onRetry: C })
489
588
  });
490
- let $ = (e, t, n, r) => /* @__PURE__ */ _("button", {
589
+ let An = (e, t, n, r) => /* @__PURE__ */ h("button", {
491
590
  type: "button",
492
591
  onClick: t,
493
592
  "aria-pressed": e,
494
593
  className: `flex flex-col items-center gap-1 rounded-md px-3 py-1.5 text-[11px] font-medium transition-colors ${e ? "bg-success text-white" : "text-text-primary hover:bg-bg-sunken"}`,
495
594
  children: [n, r]
496
595
  });
497
- return /* @__PURE__ */ _(r, {
596
+ return /* @__PURE__ */ h(r, {
498
597
  title: e("healthybowl.fieldMapPage.title", "Field Map"),
499
598
  titleAccent: e("healthybowl.fieldMapPage.titleAccent", "Map"),
500
599
  hero: !0,
501
600
  description: e("healthybowl.fieldMapPage.description", "Draw and manage your field boundaries on satellite imagery."),
502
601
  purpose: "Trace each plot on the aerial view to auto-calculate its acreage, shade fields by soil type, overlay terrain, and see your whole holding at a glance. Click any field in the list to fly straight to it.",
503
602
  children: [
504
- /* @__PURE__ */ _("div", {
603
+ /* @__PURE__ */ h("div", {
505
604
  className: "flex flex-col gap-4 lg:flex-row",
506
- children: [/* @__PURE__ */ _("div", {
605
+ children: [/* @__PURE__ */ h("div", {
507
606
  className: "min-w-0 flex-1 space-y-3",
508
607
  children: [
509
- /* @__PURE__ */ _("form", {
608
+ /* @__PURE__ */ h("form", {
510
609
  className: "flex gap-2",
511
- onSubmit: Kt,
512
- children: [/* @__PURE__ */ _("div", {
610
+ onSubmit: En,
611
+ children: [/* @__PURE__ */ h("div", {
513
612
  className: "relative min-w-0 flex-1",
514
- children: [/* @__PURE__ */ g(ye, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary" }), /* @__PURE__ */ g("input", {
613
+ children: [/* @__PURE__ */ m(ke, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary" }), /* @__PURE__ */ m("input", {
515
614
  type: "search",
516
- value: N,
517
- onChange: (e) => et(e.target.value),
615
+ value: dt,
616
+ onChange: (e) => ft(e.target.value),
518
617
  placeholder: e("healthybowl.fieldMapPage.placeSearch.placeholder", "Find your farm — village, city, or lat,lng…"),
519
618
  "aria-label": e("healthybowl.fieldMapPage.placeSearch.label", "Locate a place on the map"),
520
619
  className: "h-9 w-full rounded-md border border-border-subtle bg-bg-surface py-2 pl-9 pr-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
521
620
  })]
522
- }), /* @__PURE__ */ _(v, {
621
+ }), /* @__PURE__ */ h(g, {
523
622
  type: "submit",
524
623
  variant: "outline",
525
624
  size: "sm",
526
- disabled: T !== "ready" || tt,
625
+ disabled: E !== "ready" || pt,
527
626
  children: [
528
- /* @__PURE__ */ g(pe, { className: "h-4 w-4" }),
627
+ /* @__PURE__ */ m(Ce, { className: "h-4 w-4" }),
529
628
  " ",
530
- tt ? e("healthybowl.fieldMapPage.placeSearch.searching", "Locating…") : e("healthybowl.fieldMapPage.placeSearch.action", "Locate")
629
+ pt ? e("healthybowl.fieldMapPage.placeSearch.searching", "Locating…") : e("healthybowl.fieldMapPage.placeSearch.action", "Locate")
531
630
  ]
532
631
  })]
533
632
  }),
534
- /* @__PURE__ */ _("div", {
633
+ /* @__PURE__ */ h("div", {
535
634
  className: "relative",
536
635
  children: [
537
- /* @__PURE__ */ g("div", {
538
- ref: bt,
636
+ /* @__PURE__ */ m("div", {
637
+ ref: Vt,
539
638
  className: "h-[70vh] max-h-[640px] w-full overflow-hidden rounded-lg border border-border-subtle bg-bg-sunken"
540
639
  }),
541
- T === "ready" && /* @__PURE__ */ _("div", {
640
+ E === "ready" && /* @__PURE__ */ h("div", {
542
641
  className: "absolute right-3 top-3 z-[1000] flex items-center gap-1 rounded-lg border border-border-subtle bg-bg-surface/95 p-1 shadow-md",
543
642
  children: [
544
- $(E === "draw", () => E === "draw" ? It() : Ft(), /* @__PURE__ */ g(he, { className: "h-4 w-4" }), e("healthybowl.fieldMapPage.tools.polygon", "Polygon")),
545
- $(E === "edit", () => E === "edit" ? zt() : Rt(), /* @__PURE__ */ g(be, { className: "h-4 w-4" }), e("healthybowl.fieldMapPage.tools.vertices", "Vertices")),
546
- $(!1, Vt, /* @__PURE__ */ g(xe, { className: "h-4 w-4" }), e("healthybowl.fieldMapPage.tools.delete", "Delete")),
547
- $(E === "measure", () => E === "measure" ? Wt() : Ut(), /* @__PURE__ */ g(_e, { className: "h-4 w-4" }), e("healthybowl.fieldMapPage.tools.measure", "Measure"))
643
+ An(D === "draw", () => D === "draw" ? hn() : mn(), /* @__PURE__ */ m(Te, { className: "h-4 w-4" }), e("healthybowl.fieldMapPage.tools.polygon", "Polygon")),
644
+ An(D === "edit", () => D === "edit" ? yn() : vn(), /* @__PURE__ */ m(Ae, { className: "h-4 w-4" }), e("healthybowl.fieldMapPage.tools.vertices", "Vertices")),
645
+ An(!1, xn, /* @__PURE__ */ m(je, { className: "h-4 w-4" }), e("healthybowl.fieldMapPage.tools.delete", "Delete")),
646
+ An(D === "measure", () => D === "measure" ? wn() : Cn(), /* @__PURE__ */ m(De, { className: "h-4 w-4" }), e("healthybowl.fieldMapPage.tools.measure", "Measure"))
548
647
  ]
549
648
  }),
550
- E === "draw" && /* @__PURE__ */ _("div", {
649
+ D === "draw" && /* @__PURE__ */ h("div", {
551
650
  className: "absolute left-1/2 top-3 z-[1000] flex -translate-x-1/2 items-center gap-2 rounded-full bg-bg-surface/95 px-3 py-1.5 text-xs text-text-primary shadow-md",
552
651
  children: [
553
- /* @__PURE__ */ g("span", { children: e("healthybowl.fieldMapPage.drawHint", "Click the map to add corners ({{count}}) — click the first point or Finish.", { count: String(rt) }) }),
554
- /* @__PURE__ */ _(v, {
652
+ /* @__PURE__ */ m("span", { children: e("healthybowl.fieldMapPage.drawHint", "Click the map to add corners ({{count}}) — click the first point or Finish.", { count: String(ht) }) }),
653
+ /* @__PURE__ */ h(g, {
555
654
  size: "sm",
556
655
  variant: "default",
557
- onClick: Pt,
656
+ onClick: pn,
558
657
  children: [
559
- /* @__PURE__ */ g(de, { className: "h-3.5 w-3.5" }),
658
+ /* @__PURE__ */ m(be, { className: "h-3.5 w-3.5" }),
560
659
  " ",
561
660
  e("healthybowl.fieldMapPage.finish", "Finish")
562
661
  ]
563
662
  }),
564
- /* @__PURE__ */ g(v, {
663
+ /* @__PURE__ */ m(g, {
565
664
  size: "sm",
566
665
  variant: "outline",
567
- onClick: It,
568
- children: /* @__PURE__ */ g(Se, { className: "h-3.5 w-3.5" })
666
+ onClick: hn,
667
+ children: /* @__PURE__ */ m(Me, { className: "h-3.5 w-3.5" })
569
668
  })
570
669
  ]
571
670
  }),
572
- E === "edit" && /* @__PURE__ */ _("div", {
671
+ D === "edit" && /* @__PURE__ */ h("div", {
573
672
  className: "absolute left-1/2 top-3 z-[1000] flex -translate-x-1/2 items-center gap-2 rounded-full bg-bg-surface/95 px-3 py-1.5 text-xs text-text-primary shadow-md",
574
673
  children: [
575
- /* @__PURE__ */ g("span", { children: e("healthybowl.fieldMapPage.editHint", "Drag handles to reshape · {{area}} {{unit}}", {
576
- area: String(at ?? ""),
674
+ /* @__PURE__ */ m("span", { children: e("healthybowl.fieldMapPage.editHint", "Drag handles to reshape · {{area}} {{unit}}", {
675
+ area: String(_t ?? ""),
577
676
  unit: J?.unit ?? "acres"
578
677
  }) }),
579
- /* @__PURE__ */ _(v, {
678
+ /* @__PURE__ */ h(g, {
580
679
  size: "sm",
581
680
  variant: "default",
582
- onClick: Bt,
583
- disabled: !ot || ct,
681
+ onClick: bn,
682
+ disabled: !yt || xt,
584
683
  children: [
585
- /* @__PURE__ */ g(ve, { className: "h-3.5 w-3.5" }),
684
+ /* @__PURE__ */ m(Oe, { className: "h-3.5 w-3.5" }),
586
685
  " ",
587
- ct ? e("healthybowl.fieldMapPage.saving", "Saving…") : e("healthybowl.fieldMapPage.save", "Save")
686
+ xt ? e("healthybowl.fieldMapPage.saving", "Saving…") : e("healthybowl.fieldMapPage.save", "Save")
588
687
  ]
589
688
  }),
590
- /* @__PURE__ */ g(v, {
689
+ /* @__PURE__ */ m(g, {
591
690
  size: "sm",
592
691
  variant: "outline",
593
- onClick: zt,
594
- children: /* @__PURE__ */ g(Se, { className: "h-3.5 w-3.5" })
692
+ onClick: yn,
693
+ children: /* @__PURE__ */ m(Me, { className: "h-3.5 w-3.5" })
595
694
  })
596
695
  ]
597
696
  }),
598
- E === "measure" && F && /* @__PURE__ */ _("div", {
697
+ D === "measure" && F && /* @__PURE__ */ h("div", {
599
698
  className: "absolute left-1/2 top-3 z-[1000] flex -translate-x-1/2 items-center gap-3 rounded-full bg-bg-surface/95 px-3 py-1.5 text-xs text-text-primary shadow-md",
600
699
  children: [
601
- /* @__PURE__ */ _("span", { children: [e("healthybowl.fieldMapPage.measure.distance", "Distance: {{d}}", { d: Yt }), F.area != null && ` · ${e("healthybowl.fieldMapPage.measure.area", "Area: {{a}} ac", { a: (F.area / 4046.8564224).toFixed(2) })}`] }),
602
- /* @__PURE__ */ g(v, {
700
+ /* @__PURE__ */ h("span", { children: [e("healthybowl.fieldMapPage.measure.distance", "Distance: {{d}}", { d: kn }), F.area != null && ` · ${e("healthybowl.fieldMapPage.measure.area", "Area: {{a}} ac", { a: (F.area / 4046.8564224).toFixed(2) })}`] }),
701
+ /* @__PURE__ */ m(g, {
603
702
  size: "sm",
604
703
  variant: "outline",
605
- onClick: Q,
704
+ onClick: $,
606
705
  children: e("healthybowl.fieldMapPage.measure.reset", "Reset")
607
706
  }),
608
- /* @__PURE__ */ g(v, {
707
+ /* @__PURE__ */ m(g, {
609
708
  size: "sm",
610
709
  variant: "outline",
611
- onClick: Wt,
612
- children: /* @__PURE__ */ g(Se, { className: "h-3.5 w-3.5" })
710
+ onClick: wn,
711
+ children: /* @__PURE__ */ m(Me, { className: "h-3.5 w-3.5" })
613
712
  })
614
713
  ]
615
714
  }),
616
- T === "ready" && /* @__PURE__ */ _("div", {
715
+ E === "ready" && /* @__PURE__ */ h("div", {
617
716
  className: "absolute bottom-3 left-3 z-[1000] rounded-lg border border-border-subtle bg-bg-surface/95 p-3 text-xs shadow-md",
618
717
  children: [
619
- /* @__PURE__ */ _("div", {
718
+ /* @__PURE__ */ h("div", {
620
719
  className: "mb-1.5 flex items-center gap-1.5 font-semibold text-text-primary",
621
720
  children: [
622
- /* @__PURE__ */ g(fe, { className: "h-3.5 w-3.5" }),
721
+ /* @__PURE__ */ m(xe, { className: "h-3.5 w-3.5" }),
623
722
  " ",
624
723
  e("healthybowl.fieldMapPage.layers.title", "Layers")
625
724
  ]
626
725
  }),
627
- /* @__PURE__ */ _("label", {
726
+ /* @__PURE__ */ h("label", {
628
727
  className: "flex items-center gap-2 py-0.5 text-text-secondary",
629
- children: [/* @__PURE__ */ g("input", {
728
+ children: [/* @__PURE__ */ m("input", {
630
729
  type: "checkbox",
631
730
  checked: !0,
632
731
  readOnly: !0,
633
732
  className: "h-3.5 w-3.5 accent-[var(--color-success)]"
634
733
  }), e("healthybowl.fieldMapPage.layers.satellite", "Satellite")]
635
734
  }),
636
- /* @__PURE__ */ _("label", {
735
+ /* @__PURE__ */ h("label", {
637
736
  className: "flex cursor-pointer items-center gap-2 py-0.5 text-text-primary",
638
- children: [/* @__PURE__ */ g("input", {
737
+ children: [/* @__PURE__ */ m("input", {
639
738
  type: "checkbox",
640
- checked: A,
641
- onChange: (e) => Ze(e.target.checked),
739
+ checked: j,
740
+ onChange: (e) => at(e.target.checked),
642
741
  className: "h-3.5 w-3.5 accent-[var(--color-success)]"
643
742
  }), e("healthybowl.fieldMapPage.layers.terrain", "Terrain")]
644
743
  }),
645
- /* @__PURE__ */ _("label", {
744
+ /* @__PURE__ */ h("label", {
646
745
  className: "flex cursor-pointer items-center gap-2 py-0.5 text-text-primary",
647
- children: [/* @__PURE__ */ g("input", {
746
+ children: [/* @__PURE__ */ m("input", {
648
747
  type: "checkbox",
649
- checked: j,
650
- onChange: (e) => Qe(e.target.checked),
748
+ checked: M,
749
+ onChange: (e) => ot(e.target.checked),
651
750
  className: "h-3.5 w-3.5 accent-[var(--color-success)]"
652
751
  }), e("healthybowl.fieldMapPage.layers.soil", "Soil type")]
752
+ }),
753
+ /* @__PURE__ */ h("label", {
754
+ className: "flex cursor-pointer items-center gap-2 py-0.5 text-text-primary",
755
+ children: [/* @__PURE__ */ m("input", {
756
+ type: "checkbox",
757
+ checked: N,
758
+ onChange: (e) => st(e.target.checked),
759
+ className: "h-3.5 w-3.5 accent-[var(--color-success)]"
760
+ }), e("healthybowl.fieldMapPage.layers.elevation", "Elevation")]
653
761
  })
654
762
  ]
655
763
  }),
656
- T === "ready" && j && Ot.length > 0 && /* @__PURE__ */ _("div", {
764
+ E === "ready" && N && /* @__PURE__ */ h("div", {
657
765
  className: "absolute bottom-3 right-3 z-[1000] rounded-lg border border-border-subtle bg-bg-surface/95 p-3 text-xs shadow-md",
658
- children: [/* @__PURE__ */ g("div", {
766
+ children: [/* @__PURE__ */ m("div", {
767
+ className: "mb-1.5 font-semibold text-text-primary",
768
+ children: e("healthybowl.fieldMapPage.elevationLegend.title", "Elevation")
769
+ }), nn ? /* @__PURE__ */ h(Ne, { children: [/* @__PURE__ */ m("span", {
770
+ className: "block h-2 w-40 rounded-full",
771
+ style: { background: "linear-gradient(to right, #16a34a, #f59e0b, #dc2626)" }
772
+ }), /* @__PURE__ */ h("div", {
773
+ className: "mt-1 flex justify-between gap-3 text-text-secondary",
774
+ children: [/* @__PURE__ */ m("span", { children: e("healthybowl.fieldMapPage.elevationLegend.low", "{{value}} m Low", { value: String(Math.round(en)) }) }), /* @__PURE__ */ m("span", { children: e("healthybowl.fieldMapPage.elevationLegend.high", "{{value}} m High", { value: String(Math.round(tn)) }) })]
775
+ })] }) : /* @__PURE__ */ m("span", {
776
+ className: "text-text-secondary",
777
+ children: e("healthybowl.fieldMapPage.elevationLegend.loading", "Loading elevation…")
778
+ })]
779
+ }),
780
+ E === "ready" && M && !N && Qt.length > 0 && /* @__PURE__ */ h("div", {
781
+ className: "absolute bottom-3 right-3 z-[1000] rounded-lg border border-border-subtle bg-bg-surface/95 p-3 text-xs shadow-md",
782
+ children: [/* @__PURE__ */ m("div", {
659
783
  className: "mb-1.5 font-semibold text-text-primary",
660
784
  children: e("healthybowl.fieldMapPage.soilLegend.title", "Soil Legend")
661
- }), Ot.map((t) => /* @__PURE__ */ _("div", {
785
+ }), Qt.map((t) => /* @__PURE__ */ h("div", {
662
786
  className: "flex items-center gap-2 py-0.5 text-text-secondary",
663
- children: [/* @__PURE__ */ g("span", {
787
+ children: [/* @__PURE__ */ m("span", {
664
788
  className: "inline-block h-3 w-3 rounded-sm",
665
789
  style: { backgroundColor: t.color }
666
790
  }), e(`healthybowl.fieldMapPage.soil.${t.key}`, t.label)]
667
791
  }, t.key))]
668
792
  }),
669
- T === "ready" && A && /* @__PURE__ */ _("div", {
793
+ E === "ready" && j && /* @__PURE__ */ h("div", {
670
794
  className: "absolute left-3 top-3 z-[1000] rounded-lg border border-border-subtle bg-bg-surface/95 px-3 py-2 text-[11px] text-text-secondary shadow-md",
671
- children: [/* @__PURE__ */ g("div", {
795
+ children: [/* @__PURE__ */ m("div", {
672
796
  className: "font-semibold text-text-primary",
673
797
  children: e("healthybowl.fieldMapPage.terrainLegend.title", "Terrain / Elevation")
674
- }), /* @__PURE__ */ _("div", {
798
+ }), /* @__PURE__ */ h("div", {
675
799
  className: "mt-1 flex items-center gap-2",
676
- children: [/* @__PURE__ */ g("span", { className: "inline-block h-2 w-16 rounded-full bg-gradient-to-r from-green-600 via-yellow-400 to-orange-500" }), /* @__PURE__ */ g("span", { children: e("healthybowl.fieldMapPage.terrainLegend.scale", "low → high (contours)") })]
800
+ children: [/* @__PURE__ */ m("span", { className: "inline-block h-2 w-16 rounded-full bg-gradient-to-r from-green-600 via-yellow-400 to-orange-500" }), /* @__PURE__ */ m("span", { children: e("healthybowl.fieldMapPage.terrainLegend.scale", "low → high (contours)") })]
677
801
  })]
678
802
  }),
679
- (T === "loading" || Le.crops && c.length === 0) && /* @__PURE__ */ g("div", {
803
+ (E === "loading" || We.crops && s.length === 0) && /* @__PURE__ */ m("div", {
680
804
  className: "pointer-events-none absolute inset-0 z-[900] flex items-center justify-center rounded-lg bg-bg-surface/60 text-sm text-text-secondary",
681
805
  children: e("healthybowl.fieldMapPage.loading", "Loading map…")
682
806
  }),
683
- Jt && T === "ready" && E === "view" && /* @__PURE__ */ g("div", {
807
+ On && E === "ready" && D === "view" && /* @__PURE__ */ m("div", {
684
808
  className: "absolute inset-0 z-[950] flex items-center justify-center p-6",
685
- children: /* @__PURE__ */ _("div", {
809
+ children: /* @__PURE__ */ h("div", {
686
810
  className: "max-w-sm rounded-xl border border-border-subtle bg-bg-surface/95 p-6 text-center shadow-lg",
687
811
  children: [
688
- /* @__PURE__ */ g("div", {
812
+ /* @__PURE__ */ m("div", {
689
813
  className: "mx-auto mb-3 flex h-12 w-12 items-center justify-center rounded-full bg-success/15",
690
- children: /* @__PURE__ */ g(me, { className: "h-6 w-6 text-success" })
814
+ children: /* @__PURE__ */ m(we, { className: "h-6 w-6 text-success" })
691
815
  }),
692
- /* @__PURE__ */ g("h3", {
816
+ /* @__PURE__ */ m("h3", {
693
817
  className: "text-lg font-semibold text-text-primary",
694
818
  children: e("healthybowl.fieldMapPage.empty.title", "No field boundaries yet")
695
819
  }),
696
- /* @__PURE__ */ g("p", {
820
+ /* @__PURE__ */ m("p", {
697
821
  className: "mt-1 text-sm text-text-secondary",
698
822
  children: e("healthybowl.fieldMapPage.empty.description", "Draw the shape of each field on the satellite view to auto-calculate its area and unlock soil & terrain overlays.")
699
823
  }),
700
- /* @__PURE__ */ _(v, {
824
+ /* @__PURE__ */ h(g, {
701
825
  className: "mt-4",
702
- onClick: Ft,
826
+ onClick: mn,
703
827
  children: [
704
- /* @__PURE__ */ g(ge, { className: "h-4 w-4" }),
828
+ /* @__PURE__ */ m(Ee, { className: "h-4 w-4" }),
705
829
  " ",
706
830
  e("healthybowl.fieldMapPage.empty.action", "Draw Your First Field")
707
831
  ]
@@ -711,283 +835,406 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
711
835
  })
712
836
  ]
713
837
  }),
714
- /* @__PURE__ */ g("p", {
838
+ /* @__PURE__ */ m("p", {
715
839
  className: "text-xs text-text-secondary",
716
840
  children: e("healthybowl.fieldMapPage.attribution", "Imagery © Esri, Maxar, Earthstar Geographics · terrain © OpenTopoMap / OpenStreetMap")
717
841
  })
718
842
  ]
719
- }), /* @__PURE__ */ _("aside", {
843
+ }), /* @__PURE__ */ h("aside", {
720
844
  className: "shrink-0 space-y-4 lg:w-80",
721
- children: [/* @__PURE__ */ _("div", {
722
- className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
723
- children: [
724
- /* @__PURE__ */ g("h2", {
725
- className: "text-base font-semibold text-text-primary",
726
- children: e("healthybowl.fieldMapPage.panel.title", "Fields")
727
- }),
728
- /* @__PURE__ */ g("p", {
729
- className: "mt-0.5 text-xs text-text-secondary",
730
- children: e("healthybowl.fieldMapPage.panel.summary", "{{acres}} acres · {{count}} fields · {{mapped}} mapped", {
731
- acres: Dt.toFixed(1),
732
- count: String(c.length),
733
- mapped: String(Et)
734
- })
735
- }),
736
- /* @__PURE__ */ _("div", {
737
- className: "relative mt-3",
738
- children: [/* @__PURE__ */ g(ye, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary" }), /* @__PURE__ */ g("input", {
739
- type: "search",
740
- value: M,
741
- onChange: (e) => $e(e.target.value),
742
- placeholder: e("healthybowl.fieldMapPage.panel.search", "Search fields…"),
743
- className: "h-9 w-full rounded-md border border-border-subtle bg-bg-surface py-2 pl-9 pr-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
744
- })]
745
- }),
746
- /* @__PURE__ */ _("div", {
747
- className: "mt-3 max-h-[38vh] space-y-1 overflow-y-auto",
748
- children: [kt.map((t) => {
749
- let n = x(t) !== null;
750
- return /* @__PURE__ */ _("button", {
751
- type: "button",
752
- "data-field-id": t.id,
753
- onClick: () => Mt(t),
754
- className: `flex w-full items-center gap-3 rounded-md border px-2.5 py-2 text-left transition-colors ${t.id === O ? "border-success bg-success/10" : "border-transparent hover:bg-bg-sunken"}`,
755
- children: [
756
- /* @__PURE__ */ g("span", {
757
- className: "mt-0.5 inline-block h-4 w-4 shrink-0 rounded",
758
- style: { backgroundColor: se(t.soilType) }
759
- }),
760
- /* @__PURE__ */ _("span", {
761
- className: "min-w-0 flex-1",
762
- children: [/* @__PURE__ */ g("span", {
763
- className: "block truncate text-sm font-medium text-text-primary",
764
- children: t.name
765
- }), /* @__PURE__ */ _("span", {
766
- className: "block truncate text-xs text-text-secondary",
767
- children: [
768
- Ge(t),
769
- " ·",
770
- " ",
771
- t.soilType || e("healthybowl.fieldMapPage.unknownSoil", "Unknown soil")
772
- ]
773
- })]
774
- }),
775
- !n && /* @__PURE__ */ g("span", {
776
- className: "shrink-0 rounded-full bg-warning/20 px-1.5 py-0.5 text-[10px] font-medium text-warning",
777
- children: e("healthybowl.fieldMapPage.unmapped", "no boundary")
778
- })
779
- ]
780
- }, t.id);
781
- }), kt.length === 0 && /* @__PURE__ */ g("p", {
782
- className: "px-2 py-4 text-center text-xs text-text-secondary",
783
- children: e("healthybowl.fieldMapPage.panel.none", "No fields match your search.")
784
- })]
785
- }),
786
- /* @__PURE__ */ _(v, {
787
- className: "mt-3 w-full",
788
- onClick: Ft,
789
- disabled: E === "draw",
790
- children: [
791
- /* @__PURE__ */ g(ge, { className: "h-4 w-4" }),
792
- " ",
793
- e("healthybowl.fieldMapPage.panel.drawNew", "Draw New Field")
794
- ]
795
- })
796
- ]
797
- }), J && /* @__PURE__ */ _("div", {
798
- className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
799
- children: [
800
- /* @__PURE__ */ g("h3", {
801
- className: "text-sm font-semibold text-text-primary",
802
- children: e("healthybowl.fieldMapPage.detail.selected", "Selected: {{name}}", { name: J.name })
803
- }),
804
- /* @__PURE__ */ _("dl", {
805
- className: "mt-3 space-y-2 text-sm",
806
- children: [
807
- /* @__PURE__ */ _("div", {
808
- className: "flex justify-between gap-3",
809
- children: [/* @__PURE__ */ g("dt", {
810
- className: "text-text-secondary",
811
- children: e("healthybowl.fieldMapPage.detail.area", "Area")
812
- }), /* @__PURE__ */ _("dd", {
813
- className: "font-medium text-text-primary",
845
+ children: [
846
+ /* @__PURE__ */ h("div", {
847
+ className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
848
+ children: [
849
+ /* @__PURE__ */ m("h2", {
850
+ className: "text-base font-semibold text-text-primary",
851
+ children: e("healthybowl.fieldMapPage.panel.title", "Fields")
852
+ }),
853
+ /* @__PURE__ */ m("p", {
854
+ className: "mt-0.5 text-xs text-text-secondary",
855
+ children: e("healthybowl.fieldMapPage.panel.summary", "{{acres}} acres · {{count}} fields · {{mapped}} mapped", {
856
+ acres: Zt.toFixed(1),
857
+ count: String(s.length),
858
+ mapped: String(Xt)
859
+ })
860
+ }),
861
+ /* @__PURE__ */ h("div", {
862
+ className: "relative mt-3",
863
+ children: [/* @__PURE__ */ m(ke, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary" }), /* @__PURE__ */ m("input", {
864
+ type: "search",
865
+ value: lt,
866
+ onChange: (e) => ut(e.target.value),
867
+ placeholder: e("healthybowl.fieldMapPage.panel.search", "Search fields…"),
868
+ className: "h-9 w-full rounded-md border border-border-subtle bg-bg-surface py-2 pl-9 pr-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
869
+ })]
870
+ }),
871
+ /* @__PURE__ */ h("div", {
872
+ className: "mt-3 max-h-[38vh] space-y-1 overflow-y-auto",
873
+ children: [$t.map((t) => {
874
+ let n = S(t) !== null;
875
+ return /* @__PURE__ */ h("button", {
876
+ type: "button",
877
+ "data-field-id": t.id,
878
+ onClick: () => un(t),
879
+ className: `flex w-full items-center gap-3 rounded-md border px-2.5 py-2 text-left transition-colors ${t.id === k ? "border-success bg-success/10" : "border-transparent hover:bg-bg-sunken"}`,
814
880
  children: [
815
- J.area,
816
- " ",
817
- J.unit
881
+ /* @__PURE__ */ m("span", {
882
+ className: "mt-0.5 inline-block h-4 w-4 shrink-0 rounded",
883
+ style: { backgroundColor: le(t.soilType) }
884
+ }),
885
+ /* @__PURE__ */ h("span", {
886
+ className: "min-w-0 flex-1",
887
+ children: [/* @__PURE__ */ m("span", {
888
+ className: "block truncate text-sm font-medium text-text-primary",
889
+ children: t.name
890
+ }), /* @__PURE__ */ h("span", {
891
+ className: "block truncate text-xs text-text-secondary",
892
+ children: [
893
+ $e(t),
894
+ " ·",
895
+ " ",
896
+ t.soilType || e("healthybowl.fieldMapPage.unknownSoil", "Unknown soil"),
897
+ P[t.id] != null && ` · ${e("healthybowl.fieldMapPage.detail.elevationValue", "{{value}} m", { value: String(Math.round(P[t.id])) })}`
898
+ ]
899
+ })]
900
+ }),
901
+ !n && /* @__PURE__ */ m("span", {
902
+ className: "shrink-0 rounded-full bg-warning/20 px-1.5 py-0.5 text-[10px] font-medium text-warning",
903
+ children: e("healthybowl.fieldMapPage.unmapped", "no boundary")
904
+ })
818
905
  ]
819
- })]
820
- }),
821
- /* @__PURE__ */ _("div", {
822
- className: "flex justify-between gap-3",
823
- children: [/* @__PURE__ */ g("dt", {
824
- className: "text-text-secondary",
825
- children: e("healthybowl.fieldMapPage.detail.soil", "Soil")
826
- }), /* @__PURE__ */ g("dd", {
827
- className: "font-medium text-text-primary",
828
- children: J.soilType || e("healthybowl.fieldMapPage.unknownSoil", "Unknown soil")
829
- })]
830
- }),
831
- /* @__PURE__ */ _("div", {
832
- className: "flex justify-between gap-3",
833
- children: [/* @__PURE__ */ g("dt", {
834
- className: "text-text-secondary",
835
- children: e("healthybowl.fieldMapPage.detail.irrigation", "Irrigation")
836
- }), /* @__PURE__ */ g("dd", {
837
- className: "font-medium text-text-primary",
838
- children: J.irrigationType || "—"
839
- })]
840
- }),
841
- /* @__PURE__ */ _("div", {
842
- className: "flex justify-between gap-3",
843
- children: [/* @__PURE__ */ g("dt", {
844
- className: "text-text-secondary",
845
- children: e("healthybowl.fieldMapPage.detail.crop", "Crop")
846
- }), /* @__PURE__ */ g("dd", {
847
- className: "font-medium text-text-primary",
848
- children: At(J) || e("healthybowl.fieldMapPage.detail.noCrop", "None")
849
- })]
850
- }),
851
- /* @__PURE__ */ _("div", {
852
- className: "flex justify-between gap-3",
853
- children: [/* @__PURE__ */ g("dt", {
854
- className: "text-text-secondary",
855
- children: e("healthybowl.fieldMapPage.detail.status", "Status")
856
- }), /* @__PURE__ */ g("dd", {
857
- className: "font-medium capitalize text-text-primary",
858
- children: J.status
859
- })]
860
- })
861
- ]
862
- }),
863
- /* @__PURE__ */ _("div", {
864
- className: "mt-3 flex gap-2",
865
- children: [/* @__PURE__ */ _(v, {
866
- variant: "outline",
867
- size: "sm",
868
- className: "flex-1",
869
- onClick: () => jt(J),
906
+ }, t.id);
907
+ }), $t.length === 0 && /* @__PURE__ */ m("p", {
908
+ className: "px-2 py-4 text-center text-xs text-text-secondary",
909
+ children: e("healthybowl.fieldMapPage.panel.none", "No fields match your search.")
910
+ })]
911
+ }),
912
+ /* @__PURE__ */ h(g, {
913
+ className: "mt-3 w-full",
914
+ onClick: mn,
915
+ disabled: D === "draw",
870
916
  children: [
871
- /* @__PURE__ */ g(me, { className: "h-4 w-4" }),
917
+ /* @__PURE__ */ m(Ee, { className: "h-4 w-4" }),
872
918
  " ",
873
- e("healthybowl.fieldMapPage.detail.flyTo", "Fly to")
919
+ e("healthybowl.fieldMapPage.panel.drawNew", "Draw New Field")
874
920
  ]
875
- }), x(J) && /* @__PURE__ */ _(v, {
876
- variant: "outline",
877
- size: "sm",
878
- className: "flex-1",
879
- onClick: Rt,
880
- disabled: E === "edit",
921
+ })
922
+ ]
923
+ }),
924
+ J && /* @__PURE__ */ h("div", {
925
+ className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
926
+ children: [
927
+ /* @__PURE__ */ m("h3", {
928
+ className: "text-sm font-semibold text-text-primary",
929
+ children: e("healthybowl.fieldMapPage.detail.selected", "Selected: {{name}}", { name: J.name })
930
+ }),
931
+ /* @__PURE__ */ h("dl", {
932
+ className: "mt-3 space-y-2 text-sm",
881
933
  children: [
882
- /* @__PURE__ */ g(be, { className: "h-4 w-4" }),
883
- " ",
884
- e("healthybowl.fieldMapPage.detail.edit", "Edit")
934
+ /* @__PURE__ */ h("div", {
935
+ className: "flex justify-between gap-3",
936
+ children: [/* @__PURE__ */ m("dt", {
937
+ className: "text-text-secondary",
938
+ children: e("healthybowl.fieldMapPage.detail.area", "Area")
939
+ }), /* @__PURE__ */ h("dd", {
940
+ className: "font-medium text-text-primary",
941
+ children: [
942
+ J.area,
943
+ " ",
944
+ J.unit
945
+ ]
946
+ })]
947
+ }),
948
+ /* @__PURE__ */ h("div", {
949
+ className: "flex justify-between gap-3",
950
+ children: [/* @__PURE__ */ m("dt", {
951
+ className: "text-text-secondary",
952
+ children: e("healthybowl.fieldMapPage.detail.elevation", "Elevation")
953
+ }), /* @__PURE__ */ m("dd", {
954
+ className: "font-medium text-text-primary",
955
+ children: P[J.id] == null ? "—" : e("healthybowl.fieldMapPage.detail.elevationValue", "{{value}} m", { value: String(Math.round(P[J.id])) })
956
+ })]
957
+ }),
958
+ /* @__PURE__ */ h("div", {
959
+ className: "flex justify-between gap-3",
960
+ children: [/* @__PURE__ */ m("dt", {
961
+ className: "text-text-secondary",
962
+ children: e("healthybowl.fieldMapPage.detail.soil", "Soil")
963
+ }), /* @__PURE__ */ m("dd", {
964
+ className: "font-medium text-text-primary",
965
+ children: J.soilType || e("healthybowl.fieldMapPage.unknownSoil", "Unknown soil")
966
+ })]
967
+ }),
968
+ /* @__PURE__ */ h("div", {
969
+ className: "flex justify-between gap-3",
970
+ children: [/* @__PURE__ */ m("dt", {
971
+ className: "text-text-secondary",
972
+ children: e("healthybowl.fieldMapPage.detail.irrigation", "Irrigation")
973
+ }), /* @__PURE__ */ m("dd", {
974
+ className: "font-medium text-text-primary",
975
+ children: J.irrigationType || "—"
976
+ })]
977
+ }),
978
+ /* @__PURE__ */ h("div", {
979
+ className: "flex justify-between gap-3",
980
+ children: [/* @__PURE__ */ m("dt", {
981
+ className: "text-text-secondary",
982
+ children: e("healthybowl.fieldMapPage.detail.crop", "Crop")
983
+ }), /* @__PURE__ */ m("dd", {
984
+ className: "font-medium text-text-primary",
985
+ children: rn(J) || e("healthybowl.fieldMapPage.detail.noCrop", "None")
986
+ })]
987
+ }),
988
+ /* @__PURE__ */ h("div", {
989
+ className: "flex justify-between gap-3",
990
+ children: [/* @__PURE__ */ m("dt", {
991
+ className: "text-text-secondary",
992
+ children: e("healthybowl.fieldMapPage.detail.status", "Status")
993
+ }), /* @__PURE__ */ m("dd", {
994
+ className: "font-medium capitalize text-text-primary",
995
+ children: J.status
996
+ })]
997
+ })
885
998
  ]
886
- })]
887
- })
888
- ]
889
- })]
999
+ }),
1000
+ /* @__PURE__ */ h("div", {
1001
+ className: "mt-3 flex gap-2",
1002
+ children: [/* @__PURE__ */ h(g, {
1003
+ variant: "outline",
1004
+ size: "sm",
1005
+ className: "flex-1",
1006
+ onClick: () => ln(J),
1007
+ children: [
1008
+ /* @__PURE__ */ m(we, { className: "h-4 w-4" }),
1009
+ " ",
1010
+ e("healthybowl.fieldMapPage.detail.flyTo", "Fly to")
1011
+ ]
1012
+ }), S(J) && /* @__PURE__ */ h(g, {
1013
+ variant: "outline",
1014
+ size: "sm",
1015
+ className: "flex-1",
1016
+ onClick: vn,
1017
+ disabled: D === "edit",
1018
+ children: [
1019
+ /* @__PURE__ */ m(Ae, { className: "h-4 w-4" }),
1020
+ " ",
1021
+ e("healthybowl.fieldMapPage.detail.edit", "Edit")
1022
+ ]
1023
+ })]
1024
+ })
1025
+ ]
1026
+ }),
1027
+ J && an && /* @__PURE__ */ h("div", {
1028
+ className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
1029
+ children: [
1030
+ /* @__PURE__ */ h("div", {
1031
+ className: "flex items-center justify-between gap-2",
1032
+ children: [/* @__PURE__ */ h("h3", {
1033
+ className: "flex items-center gap-1.5 text-sm font-semibold text-text-primary",
1034
+ children: [
1035
+ /* @__PURE__ */ m(Se, { className: "h-4 w-4" }),
1036
+ " ",
1037
+ e("healthybowl.fieldMapPage.beds.title", "Bed layout")
1038
+ ]
1039
+ }), /* @__PURE__ */ h("label", {
1040
+ className: "flex cursor-pointer items-center gap-2 text-xs font-medium text-text-primary",
1041
+ children: [/* @__PURE__ */ m("input", {
1042
+ type: "checkbox",
1043
+ checked: wt,
1044
+ onChange: (e) => Tt(e.target.checked),
1045
+ className: "h-3.5 w-3.5 accent-[var(--color-success)]"
1046
+ }), e("healthybowl.fieldMapPage.beds.show", "Show beds")]
1047
+ })]
1048
+ }),
1049
+ /* @__PURE__ */ m("p", {
1050
+ className: "mt-1 text-xs text-text-secondary",
1051
+ children: e("healthybowl.fieldMapPage.beds.hint", "Draw planting bed strips inside this field. Layout only — not saved.")
1052
+ }),
1053
+ /* @__PURE__ */ h("div", {
1054
+ className: "mt-3 grid grid-cols-2 gap-3",
1055
+ children: [/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
1056
+ className: "text-xs font-medium text-text-primary",
1057
+ children: e("healthybowl.fieldMapPage.beds.bedWidth", "Bed width (m)")
1058
+ }), /* @__PURE__ */ m("input", {
1059
+ type: "number",
1060
+ min: .2,
1061
+ step: .1,
1062
+ value: I,
1063
+ onChange: (e) => Et(Math.max(.2, Number(e.target.value) || 0)),
1064
+ className: "mt-1 h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
1065
+ })] }), /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
1066
+ className: "text-xs font-medium text-text-primary",
1067
+ children: e("healthybowl.fieldMapPage.beds.pathWidth", "Path width (m)")
1068
+ }), /* @__PURE__ */ m("input", {
1069
+ type: "number",
1070
+ min: 0,
1071
+ step: .05,
1072
+ value: Dt,
1073
+ onChange: (e) => Ot(Math.max(0, Number(e.target.value) || 0)),
1074
+ className: "mt-1 h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
1075
+ })] })]
1076
+ }),
1077
+ /* @__PURE__ */ h("div", {
1078
+ className: "mt-3",
1079
+ children: [/* @__PURE__ */ h("div", {
1080
+ className: "flex items-center justify-between",
1081
+ children: [/* @__PURE__ */ m("label", {
1082
+ className: "text-xs font-medium text-text-primary",
1083
+ children: e("healthybowl.fieldMapPage.beds.orientation", "Orientation")
1084
+ }), /* @__PURE__ */ h("span", {
1085
+ className: "text-xs text-text-secondary",
1086
+ children: [L, "°"]
1087
+ })]
1088
+ }), /* @__PURE__ */ m("input", {
1089
+ type: "range",
1090
+ min: 0,
1091
+ max: 180,
1092
+ step: 1,
1093
+ value: L,
1094
+ onChange: (e) => kt(Number(e.target.value)),
1095
+ className: "mt-1 w-full accent-[var(--color-success)]",
1096
+ "aria-label": e("healthybowl.fieldMapPage.beds.orientation", "Orientation")
1097
+ })]
1098
+ }),
1099
+ b.length > 0 && /* @__PURE__ */ h("div", {
1100
+ className: "mt-3",
1101
+ children: [
1102
+ /* @__PURE__ */ m("label", {
1103
+ className: "text-xs font-medium text-text-primary",
1104
+ children: e("healthybowl.fieldMapPage.beds.crop", "Spacing for crop")
1105
+ }),
1106
+ /* @__PURE__ */ h(_, {
1107
+ value: sn?.id ?? "",
1108
+ onValueChange: jt,
1109
+ children: [/* @__PURE__ */ m(Pe, {
1110
+ className: "mt-1 w-full",
1111
+ children: /* @__PURE__ */ m(Fe, { placeholder: e("healthybowl.fieldMapPage.beds.cropPlaceholder", "Standard spacing") })
1112
+ }), /* @__PURE__ */ m(v, { children: b.map((e) => /* @__PURE__ */ m(y, {
1113
+ value: e.id,
1114
+ children: e.name
1115
+ }, e.id)) })]
1116
+ }),
1117
+ /* @__PURE__ */ m("p", {
1118
+ className: "mt-1 text-[11px] text-text-secondary",
1119
+ children: e("healthybowl.fieldMapPage.beds.spacingLine", "{{preset}} · {{plant}}×{{row}} cm", {
1120
+ preset: X.label,
1121
+ plant: String(X.plantSpacingCm),
1122
+ row: String(X.rowSpacingCm)
1123
+ })
1124
+ })
1125
+ ]
1126
+ }),
1127
+ Z && /* @__PURE__ */ m("div", {
1128
+ className: "mt-3 rounded-md bg-success/10 px-3 py-2 text-sm font-medium text-text-primary",
1129
+ children: e("healthybowl.fieldMapPage.beds.readout", "{{beds}} beds · ~{{plants}} plants", {
1130
+ beds: String(Z.bedCount),
1131
+ plants: cn.toLocaleString()
1132
+ })
1133
+ })
1134
+ ]
1135
+ })
1136
+ ]
890
1137
  })]
891
1138
  }),
892
- /* @__PURE__ */ g(ee, {
893
- open: I !== null,
894
- onClose: () => L(null),
1139
+ /* @__PURE__ */ m(te, {
1140
+ open: R !== null,
1141
+ onClose: () => z(null),
895
1142
  title: e("healthybowl.fieldMapPage.create.title", "Save New Field"),
896
1143
  description: e("healthybowl.fieldMapPage.create.description", "Name the field you just drew. Its area is auto-calculated."),
897
- footer: /* @__PURE__ */ _(Ce, { children: [/* @__PURE__ */ g(v, {
1144
+ footer: /* @__PURE__ */ h(Ne, { children: [/* @__PURE__ */ m(g, {
898
1145
  variant: "outline",
899
- onClick: () => L(null),
1146
+ onClick: () => z(null),
900
1147
  className: "text-text-secondary",
901
1148
  children: e("healthybowl.common.cancel", "Cancel")
902
- }), /* @__PURE__ */ g(v, {
903
- onClick: qt,
904
- disabled: dt,
905
- children: dt ? e("healthybowl.fieldMapPage.create.saving", "Saving…") : e("healthybowl.fieldMapPage.create.action", "Save Field")
1149
+ }), /* @__PURE__ */ m(g, {
1150
+ onClick: Dn,
1151
+ disabled: Mt,
1152
+ children: Mt ? e("healthybowl.fieldMapPage.create.saving", "Saving…") : e("healthybowl.fieldMapPage.create.action", "Save Field")
906
1153
  })] }),
907
- children: /* @__PURE__ */ _("div", {
1154
+ children: /* @__PURE__ */ h("div", {
908
1155
  className: "space-y-4",
909
1156
  children: [
910
- /* @__PURE__ */ g("div", {
1157
+ /* @__PURE__ */ m("div", {
911
1158
  className: "rounded-md bg-success/10 px-3 py-2 text-sm text-text-primary",
912
- children: e("healthybowl.fieldMapPage.create.areaLine", "Auto-calculated area: {{area}} acres", { area: String(I?.area ?? 0) })
1159
+ children: e("healthybowl.fieldMapPage.create.areaLine", "Auto-calculated area: {{area}} acres", { area: String(R?.area ?? 0) })
913
1160
  }),
914
- /* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("label", {
1161
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
915
1162
  className: "text-sm font-medium text-text-primary",
916
1163
  children: e("healthybowl.fieldMapPage.create.name", "Field name *")
917
- }), /* @__PURE__ */ g("input", {
1164
+ }), /* @__PURE__ */ m("input", {
918
1165
  type: "text",
919
- value: R,
920
- onChange: (e) => pt(e.target.value),
1166
+ value: B,
1167
+ onChange: (e) => Pt(e.target.value),
921
1168
  placeholder: e("healthybowl.fieldMapPage.create.namePlaceholder", "e.g., North Paddy"),
922
1169
  className: "mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
923
1170
  })] }),
924
- /* @__PURE__ */ _("div", {
1171
+ /* @__PURE__ */ h("div", {
925
1172
  className: "grid grid-cols-2 gap-3",
926
- children: [/* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("label", {
1173
+ children: [/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
927
1174
  className: "text-sm font-medium text-text-primary",
928
1175
  children: e("healthybowl.fieldMapPage.create.soil", "Soil type")
929
- }), /* @__PURE__ */ _(we, {
930
- value: mt,
931
- onValueChange: ht,
932
- children: [/* @__PURE__ */ g(Ee, {
1176
+ }), /* @__PURE__ */ h(_, {
1177
+ value: Ft,
1178
+ onValueChange: It,
1179
+ children: [/* @__PURE__ */ m(Pe, {
933
1180
  className: "mt-1 w-full",
934
- children: /* @__PURE__ */ g(De, {})
935
- }), /* @__PURE__ */ g(Te, { children: oe.map((t) => /* @__PURE__ */ g(y, {
1181
+ children: /* @__PURE__ */ m(Fe, {})
1182
+ }), /* @__PURE__ */ m(v, { children: ce.map((t) => /* @__PURE__ */ m(y, {
936
1183
  value: t.label,
937
1184
  children: e(`healthybowl.fieldMapPage.soil.${t.key}`, t.label)
938
1185
  }, t.key)) })]
939
- })] }), /* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("label", {
1186
+ })] }), /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
940
1187
  className: "text-sm font-medium text-text-primary",
941
1188
  children: e("healthybowl.fieldMapPage.create.irrigation", "Irrigation")
942
- }), /* @__PURE__ */ _(we, {
943
- value: gt,
944
- onValueChange: _t,
945
- children: [/* @__PURE__ */ g(Ee, {
1189
+ }), /* @__PURE__ */ h(_, {
1190
+ value: Lt,
1191
+ onValueChange: Rt,
1192
+ children: [/* @__PURE__ */ m(Pe, {
946
1193
  className: "mt-1 w-full",
947
- children: /* @__PURE__ */ g(De, {})
948
- }), /* @__PURE__ */ _(Te, { children: [
949
- /* @__PURE__ */ g(y, {
1194
+ children: /* @__PURE__ */ m(Fe, {})
1195
+ }), /* @__PURE__ */ h(v, { children: [
1196
+ /* @__PURE__ */ m(y, {
950
1197
  value: "Drip",
951
1198
  children: e("healthybowl.fieldMapPage.irrigation.drip", "Drip")
952
1199
  }),
953
- /* @__PURE__ */ g(y, {
1200
+ /* @__PURE__ */ m(y, {
954
1201
  value: "Sprinkler",
955
1202
  children: e("healthybowl.fieldMapPage.irrigation.sprinkler", "Sprinkler")
956
1203
  }),
957
- /* @__PURE__ */ g(y, {
1204
+ /* @__PURE__ */ m(y, {
958
1205
  value: "Flood",
959
1206
  children: e("healthybowl.fieldMapPage.irrigation.flood", "Flood")
960
1207
  }),
961
- /* @__PURE__ */ g(y, {
1208
+ /* @__PURE__ */ m(y, {
962
1209
  value: "Rainfed",
963
1210
  children: e("healthybowl.fieldMapPage.irrigation.rainfed", "Rainfed")
964
1211
  }),
965
- /* @__PURE__ */ g(y, {
1212
+ /* @__PURE__ */ m(y, {
966
1213
  value: "None",
967
1214
  children: e("healthybowl.fieldMapPage.irrigation.none", "None")
968
1215
  })
969
1216
  ] })]
970
1217
  })] })]
971
1218
  }),
972
- /* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("label", {
1219
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
973
1220
  className: "text-sm font-medium text-text-primary",
974
1221
  children: e("healthybowl.fieldMapPage.create.status", "Status")
975
- }), /* @__PURE__ */ _(we, {
976
- value: vt,
977
- onValueChange: yt,
978
- children: [/* @__PURE__ */ g(Ee, {
1222
+ }), /* @__PURE__ */ h(_, {
1223
+ value: zt,
1224
+ onValueChange: Bt,
1225
+ children: [/* @__PURE__ */ m(Pe, {
979
1226
  className: "mt-1 w-full",
980
- children: /* @__PURE__ */ g(De, {})
981
- }), /* @__PURE__ */ _(Te, { children: [
982
- /* @__PURE__ */ g(y, {
1227
+ children: /* @__PURE__ */ m(Fe, {})
1228
+ }), /* @__PURE__ */ h(v, { children: [
1229
+ /* @__PURE__ */ m(y, {
983
1230
  value: "active",
984
1231
  children: e("healthybowl.fieldMapPage.status.active", "Active")
985
1232
  }),
986
- /* @__PURE__ */ g(y, {
1233
+ /* @__PURE__ */ m(y, {
987
1234
  value: "preparation",
988
1235
  children: e("healthybowl.fieldMapPage.status.preparation", "Preparation")
989
1236
  }),
990
- /* @__PURE__ */ g(y, {
1237
+ /* @__PURE__ */ m(y, {
991
1238
  value: "fallow",
992
1239
  children: e("healthybowl.fieldMapPage.status.fallow", "Fallow")
993
1240
  })
@@ -996,14 +1243,14 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
996
1243
  ]
997
1244
  })
998
1245
  }),
999
- /* @__PURE__ */ g(a, {
1000
- toasts: Je,
1001
- onDismiss: Ye
1246
+ /* @__PURE__ */ m(a, {
1247
+ toasts: nt,
1248
+ onDismiss: rt
1002
1249
  })
1003
1250
  ]
1004
1251
  });
1005
1252
  };
1006
1253
  //#endregion
1007
- export { S as FieldMapPage };
1254
+ export { C as FieldMapPage };
1008
1255
 
1009
1256
  //# sourceMappingURL=FieldMapPage.js.map