@burdenoff/microfe-healthybowl 2026.710.11 → 2026.710.12

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.
@@ -11,18 +11,19 @@ import { useToast as te } from "../../hooks/useToast.js";
11
11
  import { ensureLeafletCss as ne } from "../../utils/leaflet.js";
12
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
13
  import { SOIL_PALETTE as oe, soilColor as se, soilLegendFor as ce } from "../../utils/soil.js";
14
+ import { elevationColor as le, fetchElevations as ue } from "../../utils/elevation.js";
14
15
  import "../../utils/index.js";
15
16
  import "../../components/index.js";
16
- import { useHealthyBowlData as le } from "../../hooks/useHealthyBowlData.js";
17
+ import { useHealthyBowlData as de } from "../../hooks/useHealthyBowlData.js";
17
18
  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";
19
+ import { useI18n as fe } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
20
+ import { Check as pe, Layers as me, LocateFixed as he, MapPinned as ge, Pencil as _e, Plus as ve, Ruler as ye, Save as be, Search as xe, Spline as Se, Trash2 as Ce, X as we } from "lucide-react";
21
+ import { Fragment as Te, jsx as g, jsxs as _ } from "react/jsx-runtime";
22
+ import { Button as v, Select as Ee, SelectContent as De, SelectItem as y, SelectTrigger as Oe, SelectValue as ke } from "@burdenoff/fe-libs/ui";
23
+ import { gql as Ae } from "@apollo/client";
24
+ import { useMutation as je } from "@apollo/client/react";
24
25
  //#region src/healthybowl/pages/fields/FieldMapPage.tsx
25
- var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
26
+ var b = /* @__PURE__ */ e(s(), 1), Me = Ae`
26
27
  mutation UpdateHealthyBowlFieldBoundaryOnMapPage($input: UpdateHealthyBowlFieldInput!) {
27
28
  updateHealthyBowlField(input: $input) {
28
29
  id
@@ -31,44 +32,89 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
31
32
  location
32
33
  }
33
34
  }
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 = {
35
+ `, Ne = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}", Pe = "Esri, Maxar, Earthstar Geographics", Fe = "https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", Ie = "© OpenTopoMap (CC-BY-SA) · © OpenStreetMap contributors", Le = 21, Re = 16, ze = 2.47105, Be = "#16a34a", Ve = {
35
36
  color: "#f59e0b",
36
37
  weight: 2,
37
38
  dashArray: "6 4",
38
39
  fillColor: "#f59e0b",
39
40
  fillOpacity: .15
40
- }, Be = {
41
+ }, He = {
41
42
  color: "#ffffff",
42
43
  weight: 2,
43
44
  dashArray: "6 4",
44
45
  fillColor: "#22c55e",
45
46
  fillOpacity: .2
46
- }, Ve = {
47
+ }, Ue = {
47
48
  color: "#38bdf8",
48
49
  weight: 3,
49
50
  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
+ }, We = (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)), Ge = (e) => /hect|(^|[^a-z])ha([^a-z]|$)/i.test(e ?? ""), Ke = (e) => Ge(e.unit) ? e.area * ze : e.area, qe = (e) => `${e.area.toFixed(1)} ${Ge(e.unit) ? "ha" : "ac"}`, x = (e) => {
51
52
  let t = re(e.boundary);
52
53
  return t && c(t) ? t : null;
53
- }, Ke = b.default.divIcon({
54
+ }, Je = b.default.divIcon({
54
55
  className: "",
55
56
  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
57
  iconSize: [16, 16],
57
58
  iconAnchor: [8, 8]
58
59
  }), 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
+ let { t: e } = fe(), { workspaceId: s } = n(), re = o(), { fields: c, crops: Ae, loadings: ze, errors: Ge, refetch: S, createField: Ye } = de(), { toasts: Xe, toast: C, dismiss: Ze } = te(), [w] = je(Me), [T, Qe] = h("loading"), [E, D] = h("view"), [O, k] = h(null), [A, $e] = h(!1), [j, et] = h(!0), [M, tt] = h(!1), [N, nt] = h({}), [rt, it] = h(""), [at, ot] = h(""), [st, ct] = h(!1), [lt, ut] = h(0), [dt, ft] = h(null), [pt, mt] = h(!1), [ht, gt] = h(!1), [P, _t] = h(null), [F, I] = h(null), [vt, yt] = h(!1), [L, bt] = h(""), [xt, St] = h("Clay loam"), [Ct, wt] = h("Drip"), [Tt, Et] = h("active"), Dt = m(null), R = m(null), Ot = m(null), kt = m(null), At = m(null), z = m(null), B = m(null), V = m(null), H = m([]), U = m(null), W = m([]), G = m(null), jt = m([]), K = m("view"), Mt = m(!1);
60
61
  f(() => {
61
- q.current = E;
62
+ K.current = E;
62
63
  }, [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();
64
+ let Nt = p(() => c.filter((e) => x(e) !== null).length, [c]), Pt = p(() => c.reduce((e, t) => e + Ke(t), 0), [c]), Ft = p(() => ce(c.map((e) => e.soilType)), [c]), q = p(() => c.find((e) => e.id === O) ?? null, [c, O]), It = p(() => {
65
+ let e = rt.trim().toLowerCase();
65
66
  return e ? c.filter((t) => t.name.toLowerCase().includes(e) || (t.soilType ?? "").toLowerCase().includes(e)) : c;
66
- }, [c, M]), At = d((e) => {
67
+ }, [c, rt]), J = p(() => {
68
+ let e = [];
69
+ for (let t of c) {
70
+ let n = x(t);
71
+ if (n) {
72
+ let r = ae(n);
73
+ if (r) {
74
+ e.push({
75
+ id: t.id,
76
+ lat: r[0],
77
+ lng: r[1]
78
+ });
79
+ continue;
80
+ }
81
+ }
82
+ We(t.location) && e.push({
83
+ id: t.id,
84
+ lat: t.location.lat,
85
+ lng: t.location.lng
86
+ });
87
+ }
88
+ return e;
89
+ }, [c]);
90
+ f(() => {
91
+ if (J.length === 0) {
92
+ nt({});
93
+ return;
94
+ }
95
+ let e = new AbortController(), t = !1;
96
+ return ue(J.map((e) => ({
97
+ lat: e.lat,
98
+ lng: e.lng
99
+ })), e.signal).then((e) => {
100
+ if (t) return;
101
+ let n = {};
102
+ J.forEach((t, r) => {
103
+ n[t.id] = e[r] ?? null;
104
+ }), nt(n);
105
+ }), () => {
106
+ t = !0, e.abort();
107
+ };
108
+ }, [p(() => J.map((e) => `${e.id}:${e.lat.toFixed(5)},${e.lng.toFixed(5)}`).join("|"), [J])]);
109
+ let [Lt, Rt] = p(() => {
110
+ let e = Object.values(N).filter((e) => e != null && Number.isFinite(e));
111
+ return e.length === 0 ? [0, 0] : [Math.min(...e), Math.max(...e)];
112
+ }, [N]), zt = p(() => Object.values(N).some((e) => e != null && Number.isFinite(e)), [N]), Bt = d((e) => {
67
113
  if (!e) return "";
68
- let t = Oe.find((t) => t.field === e.id || t.fieldName === e.name);
114
+ let t = Ae.find((t) => t.field === e.id || t.fieldName === e.name);
69
115
  return t ? t.name : (e.crops ?? []).join(", ");
70
- }, [Oe]), jt = d((e) => {
71
- let t = z.current;
116
+ }, [Ae]), Vt = d((e) => {
117
+ let t = R.current;
72
118
  if (!t) return;
73
119
  let n = x(e);
74
120
  if (n) try {
@@ -81,29 +127,29 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
81
127
  return;
82
128
  }
83
129
  } 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]);
130
+ We(e.location) && t.flyTo([e.location.lat, e.location.lng], Re, { duration: .6 });
131
+ }, []), Ht = d((e) => {
132
+ K.current === "draw" || K.current === "measure" || (k(e.id), Vt(e));
133
+ }, [Vt]);
88
134
  f(() => {
89
135
  O && document.querySelector(`[data-field-id="${O}"]`)?.scrollIntoView({ block: "nearest" });
90
136
  }, [O]);
91
137
  let Y = d(() => {
92
- let t = z.current, n = Ct.current;
138
+ let t = R.current, n = At.current;
93
139
  if (!t || !n) return;
94
140
  n.clearLayers();
95
141
  let r = [];
96
142
  for (let t of c) {
97
143
  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,
144
+ let i = t.id === O, a = N[t.id], o = M && a != null ? le(a, Lt, Rt) : j ? se(t.soilType) : Be, ee = `${t.name} — ${qe(t)}`, s = x(t);
145
+ if (s) {
146
+ let e = b.default.geoJSON(s, { style: () => ({
147
+ color: i ? "#ffffff" : o,
102
148
  weight: i ? 4 : 2,
103
- fillColor: a,
149
+ fillColor: o,
104
150
  fillOpacity: i ? .5 : .3
105
151
  }) });
106
- e.on("click", () => k(t.id)), e.bindTooltip(o, {
152
+ e.on("click", () => k(t.id)), e.bindTooltip(ee, {
107
153
  permanent: !0,
108
154
  direction: "center",
109
155
  className: "hb-field-label"
@@ -112,27 +158,27 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
112
158
  let t = e.getBounds();
113
159
  t.isValid() && r.push(t);
114
160
  } catch {}
115
- } else if (He(t.location)) {
116
- let o = b.default.circleMarker([t.location.lat, t.location.lng], {
161
+ } else if (We(t.location)) {
162
+ let a = b.default.circleMarker([t.location.lat, t.location.lng], {
117
163
  radius: i ? 9 : 7,
118
164
  color: i ? "#ffffff" : "#fff",
119
165
  weight: i ? 3 : 2,
120
- fillColor: a,
166
+ fillColor: o,
121
167
  fillOpacity: 1
122
168
  });
123
- o.on("click", () => k(t.id)), o.bindTooltip(`${t.name} (${e("healthybowl.fieldMapPage.unmapped", "no boundary")})`, {
169
+ a.on("click", () => k(t.id)), a.bindTooltip(`${t.name} (${e("healthybowl.fieldMapPage.unmapped", "no boundary")})`, {
124
170
  permanent: !1,
125
171
  direction: "top"
126
- }), o.addTo(n), r.push(b.default.latLngBounds([t.location.lat, t.location.lng], [t.location.lat, t.location.lng]));
172
+ }), a.addTo(n), r.push(b.default.latLngBounds([t.location.lat, t.location.lng], [t.location.lat, t.location.lng]));
127
173
  }
128
174
  }
129
- if (!Tt.current && r.length > 0) {
175
+ if (!Mt.current && r.length > 0) {
130
176
  let e = r.reduce((e, t) => e.extend(t), b.default.latLngBounds(r[0].getSouthWest(), r[0].getNorthEast()));
131
177
  try {
132
178
  t.fitBounds(e, {
133
179
  padding: [40, 40],
134
180
  maxZoom: 17
135
- }), Tt.current = !0;
181
+ }), Mt.current = !0;
136
182
  } catch {}
137
183
  }
138
184
  }, [
@@ -140,21 +186,25 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
140
186
  E,
141
187
  O,
142
188
  j,
189
+ M,
190
+ N,
191
+ Lt,
192
+ Rt,
143
193
  e
144
194
  ]);
145
195
  f(() => {
146
196
  T === "ready" && Y();
147
197
  }, [Y, T]);
148
198
  let X = d(() => {
149
- B.current?.clearLayers(), W.current = null, U.current = [], it(0);
150
- }, []), Nt = d(() => {
151
- let e = B.current;
199
+ z.current?.clearLayers(), U.current = null, H.current = [], ut(0);
200
+ }, []), Ut = d(() => {
201
+ let e = z.current;
152
202
  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;
203
+ U.current &&= (e.removeLayer(U.current), null);
204
+ let t = H.current;
205
+ t.length >= 2 && (U.current = b.default.polygon(t, Ve).addTo(e));
206
+ }, []), Wt = d(() => {
207
+ let t = H.current;
158
208
  if (t.length < 3) {
159
209
  C({
160
210
  title: e("healthybowl.fieldMapPage.toast.needPoints.title", "Need at least 3 points"),
@@ -167,33 +217,33 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
167
217
  lat: e.lat,
168
218
  lng: e.lng
169
219
  })));
170
- X(), q.current = "view", D("view"), n && (L({
220
+ X(), K.current = "view", D("view"), n && (I({
171
221
  boundary: n,
172
222
  area: l(n, "acres"),
173
223
  centroid: ae(n) ?? [0, 0]
174
- }), pt(""), ht("Clay loam"), _t("Drip"), yt("active"));
224
+ }), bt(""), St("Clay loam"), wt("Drip"), Et("active"));
175
225
  }, [
176
226
  X,
177
227
  e,
178
228
  C
179
- ]), Ft = d(() => {
180
- k(null), X(), q.current = "draw", D("draw");
181
- }, [X]), It = d(() => {
182
- X(), q.current = "view", D("view");
229
+ ]), Gt = d(() => {
230
+ k(null), X(), K.current = "draw", D("draw");
231
+ }, [X]), Kt = d(() => {
232
+ X(), K.current = "view", D("view");
183
233
  }, [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) => ({
234
+ B.current?.clearLayers(), G.current = null, W.current = [], ft(null), mt(!1);
235
+ }, []), qt = d(() => {
236
+ if (!B.current || !G.current) return;
237
+ G.current.setLatLngs(W.current);
238
+ let e = u(W.current.map((e) => ({
189
239
  lat: e.lat,
190
240
  lng: e.lng
191
241
  })));
192
- e && P(l(e, J?.unit ?? "acres"));
193
- }, [J]), Rt = d(() => {
194
- let t = z.current, n = V.current;
195
- if (!t || !n || !J) return;
196
- let r = x(J);
242
+ e && ft(l(e, q?.unit ?? "acres"));
243
+ }, [q]), Jt = d(() => {
244
+ let t = R.current, n = B.current;
245
+ if (!t || !n || !q) return;
246
+ let r = x(q);
197
247
  if (!r) {
198
248
  C({
199
249
  title: e("healthybowl.fieldMapPage.toast.noBoundary.title", "No boundary to edit"),
@@ -204,41 +254,41 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
204
254
  }
205
255
  n.clearLayers();
206
256
  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) => {
257
+ W.current = i, G.current = b.default.polygon(i, He).addTo(n), i.forEach((e, t) => {
208
258
  b.default.marker(i[t], {
209
- icon: Ke,
259
+ icon: Je,
210
260
  draggable: !0
211
261
  }).addTo(n).on("drag", (e) => {
212
- G.current[t] = e.target.getLatLng(), Lt(), st(!0);
262
+ W.current[t] = e.target.getLatLng(), qt(), mt(!0);
213
263
  });
214
- }), q.current = "edit", D("edit"), st(!1), P(l(r, J.unit));
264
+ }), K.current = "edit", D("edit"), mt(!1), ft(l(r, q.unit));
215
265
  }, [
216
- Lt,
217
- J,
266
+ qt,
267
+ q,
218
268
  e,
219
269
  C
220
- ]), zt = d(() => {
221
- Z(), q.current = "view", D("view"), Y();
222
- }, [Z, Y]), Bt = d(async () => {
223
- if (!J) return;
224
- let t = u(G.current.map((e) => ({
270
+ ]), Yt = d(() => {
271
+ Z(), K.current = "view", D("view"), Y();
272
+ }, [Z, Y]), Xt = d(async () => {
273
+ if (!q) return;
274
+ let t = u(W.current.map((e) => ({
225
275
  lat: e.lat,
226
276
  lng: e.lng
227
277
  })));
228
278
  if (t) {
229
- lt(!0);
279
+ gt(!0);
230
280
  try {
231
- let n = l(t, J.unit);
281
+ let n = l(t, q.unit);
232
282
  await w({ variables: { input: {
233
- id: J.id,
283
+ id: q.id,
234
284
  boundary: t,
235
285
  area: n,
236
286
  context: { workspaceId: s }
237
- } } }), await S(), Z(), q.current = "view", D("view"), C({
287
+ } } }), await S(), Z(), K.current = "view", D("view"), C({
238
288
  title: e("healthybowl.fieldMapPage.toast.saved.title", "Boundary saved"),
239
289
  description: e("healthybowl.fieldMapPage.toast.saved.description", "Area updated to {{area}} {{unit}}.", {
240
290
  area: String(n),
241
- unit: J.unit
291
+ unit: q.unit
242
292
  }),
243
293
  variant: "success"
244
294
  });
@@ -249,20 +299,20 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
249
299
  variant: "error"
250
300
  });
251
301
  } finally {
252
- lt(!1);
302
+ gt(!1);
253
303
  }
254
304
  }
255
305
  }, [
256
306
  Z,
257
307
  S,
258
- J,
308
+ q,
259
309
  e,
260
310
  C,
261
311
  w,
262
312
  s
263
- ]), Vt = d(async () => {
264
- if (J) {
265
- if (!x(J)) {
313
+ ]), Zt = d(async () => {
314
+ if (q) {
315
+ if (!x(q)) {
266
316
  C({
267
317
  title: e("healthybowl.fieldMapPage.toast.noBoundary.title", "No boundary to edit"),
268
318
  description: e("healthybowl.fieldMapPage.toast.deleteNone.description", "This field has no boundary to delete."),
@@ -272,11 +322,11 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
272
322
  }
273
323
  if (await re({
274
324
  title: e("healthybowl.fieldMapPage.confirmDelete.title", "Delete boundary?"),
275
- message: e("healthybowl.fieldMapPage.confirmDelete.description", "This removes the drawn shape from {{name}}. The field record is kept.", { name: J.name }),
325
+ message: e("healthybowl.fieldMapPage.confirmDelete.description", "This removes the drawn shape from {{name}}. The field record is kept.", { name: q.name }),
276
326
  okButtonTitle: e("healthybowl.common.delete", "Delete")
277
327
  })) try {
278
328
  await w({ variables: { input: {
279
- id: J.id,
329
+ id: q.id,
280
330
  boundary: null,
281
331
  context: { workspaceId: s }
282
332
  } } }), await S(), C({
@@ -295,18 +345,18 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
295
345
  }, [
296
346
  re,
297
347
  S,
298
- J,
348
+ q,
299
349
  e,
300
350
  C,
301
351
  w,
302
352
  s
303
353
  ]), Q = d(() => {
304
- H.current?.clearLayers(), wt.current = [], ut(null);
305
- }, []), Ht = d(() => {
306
- let e = H.current;
354
+ V.current?.clearLayers(), jt.current = [], _t(null);
355
+ }, []), Qt = d(() => {
356
+ let e = V.current;
307
357
  if (!e) return;
308
358
  e.clearLayers();
309
- let t = wt.current;
359
+ let t = jt.current;
310
360
  t.forEach((t) => {
311
361
  b.default.circleMarker(t, {
312
362
  radius: 4,
@@ -315,7 +365,7 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
315
365
  fillColor: "#fff",
316
366
  fillOpacity: 1
317
367
  }).addTo(e);
318
- }), t.length >= 2 && b.default.polyline(t, Ve).addTo(e);
368
+ }), t.length >= 2 && b.default.polyline(t, Ue).addTo(e);
319
369
  let n = 0;
320
370
  for (let e = 1; e < t.length; e++) n += t[e - 1].distanceTo(t[e]);
321
371
  let r = null;
@@ -326,45 +376,45 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
326
376
  })));
327
377
  e && (r = ie(e));
328
378
  }
329
- ut({
379
+ _t({
330
380
  distance: n,
331
381
  area: r
332
382
  });
333
- }, []), Ut = d(() => {
334
- k(null), Q(), q.current = "measure", D("measure"), ut({
383
+ }, []), $t = d(() => {
384
+ k(null), Q(), K.current = "measure", D("measure"), _t({
335
385
  distance: 0,
336
386
  area: null
337
387
  });
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, {
388
+ }, [Q]), en = d(() => {
389
+ Q(), K.current = "view", D("view");
390
+ }, [Q]), tn = d((e) => {
391
+ if (R.current) if (K.current === "draw") {
392
+ H.current.push(e.latlng);
393
+ let t = H.current.length === 1, n = b.default.circleMarker(e.latlng, {
344
394
  radius: t ? 7 : 5,
345
395
  color: "#fff",
346
396
  weight: 2,
347
397
  fillColor: t ? "#16a34a" : "#f59e0b",
348
398
  fillOpacity: 1
349
- }).addTo(B.current);
399
+ }).addTo(z.current);
350
400
  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());
401
+ b.default.DomEvent.stopPropagation(e), Wt();
402
+ }), ut(H.current.length), Ut();
403
+ } else K.current === "measure" && (jt.current.push(e.latlng), Qt());
354
404
  }, [
355
- Pt,
356
- Ht,
357
- Nt
358
- ]), Kt = d(async (n) => {
405
+ Wt,
406
+ Qt,
407
+ Ut
408
+ ]), nn = d(async (n) => {
359
409
  n.preventDefault();
360
- let r = z.current, i = N.trim();
410
+ let r = R.current, i = at.trim();
361
411
  if (!r || !i) return;
362
412
  let a = i.match(/^(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)$/);
363
413
  if (a) {
364
- r.flyTo([Number(a[1]), Number(a[2])], Ie, { duration: .6 });
414
+ r.flyTo([Number(a[1]), Number(a[2])], Re, { duration: .6 });
365
415
  return;
366
416
  }
367
- nt(!0);
417
+ ct(!0);
368
418
  try {
369
419
  let n = await t(i);
370
420
  if (!n) {
@@ -375,7 +425,7 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
375
425
  });
376
426
  return;
377
427
  }
378
- r.flyTo([n.latitude, n.longitude], Ie, { duration: .6 });
428
+ r.flyTo([n.latitude, n.longitude], Re, { duration: .6 });
379
429
  } catch (t) {
380
430
  C({
381
431
  title: e("healthybowl.fieldMapPage.toast.searchFailed.title", "Search failed"),
@@ -383,15 +433,15 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
383
433
  variant: "error"
384
434
  });
385
435
  } finally {
386
- nt(!1);
436
+ ct(!1);
387
437
  }
388
438
  }, [
389
- N,
439
+ at,
390
440
  e,
391
441
  C
392
- ]), qt = d(async () => {
393
- if (I) {
394
- if (!R.trim()) {
442
+ ]), rn = d(async () => {
443
+ if (F) {
444
+ if (!L.trim()) {
395
445
  C({
396
446
  title: e("healthybowl.fieldMapPage.toast.nameRequired.title", "Name required"),
397
447
  description: e("healthybowl.fieldMapPage.toast.nameRequired.description", "Give the new field a name."),
@@ -399,16 +449,16 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
399
449
  });
400
450
  return;
401
451
  }
402
- ft(!0);
452
+ yt(!0);
403
453
  try {
404
- let [t, n] = I.centroid, r = await qe({
405
- name: R.trim(),
406
- area: I.area,
454
+ let [t, n] = F.centroid, r = await Ye({
455
+ name: L.trim(),
456
+ area: F.area,
407
457
  unit: "acres",
408
- soilType: mt,
409
- irrigationType: gt,
458
+ soilType: xt,
459
+ irrigationType: Ct,
410
460
  organicCertified: !1,
411
- status: vt,
461
+ status: Tt,
412
462
  crops: [],
413
463
  location: {
414
464
  lat: t,
@@ -417,14 +467,14 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
417
467
  });
418
468
  r?.id && await w({ variables: { input: {
419
469
  id: r.id,
420
- boundary: I.boundary,
421
- area: I.area,
470
+ boundary: F.boundary,
471
+ area: F.area,
422
472
  context: { workspaceId: s }
423
- } } }), await S(), L(null), r?.id && k(r.id), C({
473
+ } } }), await S(), I(null), r?.id && k(r.id), C({
424
474
  title: e("healthybowl.fieldMapPage.toast.fieldCreated.title", "Field created"),
425
475
  description: e("healthybowl.fieldMapPage.toast.fieldCreated.description", "{{name}} saved at {{area}} acres.", {
426
- name: R.trim(),
427
- area: String(I.area)
476
+ name: L.trim(),
477
+ area: String(F.area)
428
478
  }),
429
479
  variant: "success"
430
480
  });
@@ -435,16 +485,16 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
435
485
  variant: "error"
436
486
  });
437
487
  } finally {
438
- ft(!1);
488
+ yt(!1);
439
489
  }
440
490
  }
441
491
  }, [
442
- qe,
443
- gt,
444
- R,
445
- mt,
446
- vt,
447
- I,
492
+ Ye,
493
+ Ct,
494
+ L,
495
+ xt,
496
+ Tt,
497
+ F,
448
498
  S,
449
499
  e,
450
500
  C,
@@ -452,36 +502,36 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
452
502
  s
453
503
  ]);
454
504
  f(() => {
455
- let e = bt.current;
505
+ let e = Dt.current;
456
506
  if (!e) return;
457
507
  ne();
458
- let t = b.default.tileLayer(je, {
459
- attribution: Me,
460
- maxZoom: Fe,
461
- maxNativeZoom: 18
462
- }), n = b.default.tileLayer(Ne, {
508
+ let t = b.default.tileLayer(Ne, {
463
509
  attribution: Pe,
464
- maxZoom: Fe,
510
+ maxZoom: Le,
511
+ maxNativeZoom: 18
512
+ }), n = b.default.tileLayer(Fe, {
513
+ attribution: Ie,
514
+ maxZoom: Le,
465
515
  maxNativeZoom: 17,
466
516
  opacity: .65
467
517
  });
468
- xt.current = t, St.current = n;
518
+ Ot.current = t, kt.current = n;
469
519
  let r = b.default.map(e, {
470
520
  center: [20, 78],
471
521
  zoom: 4,
472
522
  scrollWheelZoom: !0,
473
- maxZoom: Fe,
523
+ maxZoom: Le,
474
524
  layers: [t]
475
525
  });
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;
526
+ return R.current = r, At.current = b.default.layerGroup().addTo(r), z.current = b.default.layerGroup().addTo(r), B.current = b.default.layerGroup().addTo(r), V.current = b.default.layerGroup().addTo(r), r.on("click", tn), Qe("ready"), window.setTimeout(() => r.invalidateSize(), 80), () => {
527
+ r.off("click", tn), r.remove(), R.current = null, Ot.current = null, kt.current = null, At.current = null, z.current = null, B.current = null, V.current = null;
478
528
  };
479
529
  }, []), f(() => {
480
- let e = z.current, t = St.current;
530
+ let e = R.current, t = kt.current;
481
531
  !e || !t || (A ? t.addTo(e) : e.removeLayer(t));
482
532
  }, [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, {
533
+ let an = !ze.crops && c.length === 0, on = P ? P.distance >= 1e3 ? `${(P.distance / 1e3).toFixed(2)} km` : `${P.distance.toFixed(0)} m` : "";
534
+ if (Ge.crops && c.length === 0) return /* @__PURE__ */ g(r, {
485
535
  title: e("healthybowl.fieldMapPage.title", "Field Map"),
486
536
  titleAccent: e("healthybowl.fieldMapPage.titleAccent", "Map"),
487
537
  description: e("healthybowl.fieldMapPage.description", "Draw and manage your field boundaries on satellite imagery."),
@@ -508,13 +558,13 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
508
558
  children: [
509
559
  /* @__PURE__ */ _("form", {
510
560
  className: "flex gap-2",
511
- onSubmit: Kt,
561
+ onSubmit: nn,
512
562
  children: [/* @__PURE__ */ _("div", {
513
563
  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", {
564
+ children: [/* @__PURE__ */ g(xe, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary" }), /* @__PURE__ */ g("input", {
515
565
  type: "search",
516
- value: N,
517
- onChange: (e) => et(e.target.value),
566
+ value: at,
567
+ onChange: (e) => ot(e.target.value),
518
568
  placeholder: e("healthybowl.fieldMapPage.placeSearch.placeholder", "Find your farm — village, city, or lat,lng…"),
519
569
  "aria-label": e("healthybowl.fieldMapPage.placeSearch.label", "Locate a place on the map"),
520
570
  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)]"
@@ -523,11 +573,11 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
523
573
  type: "submit",
524
574
  variant: "outline",
525
575
  size: "sm",
526
- disabled: T !== "ready" || tt,
576
+ disabled: T !== "ready" || st,
527
577
  children: [
528
- /* @__PURE__ */ g(pe, { className: "h-4 w-4" }),
578
+ /* @__PURE__ */ g(he, { className: "h-4 w-4" }),
529
579
  " ",
530
- tt ? e("healthybowl.fieldMapPage.placeSearch.searching", "Locating…") : e("healthybowl.fieldMapPage.placeSearch.action", "Locate")
580
+ st ? e("healthybowl.fieldMapPage.placeSearch.searching", "Locating…") : e("healthybowl.fieldMapPage.placeSearch.action", "Locate")
531
581
  ]
532
582
  })]
533
583
  }),
@@ -535,28 +585,28 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
535
585
  className: "relative",
536
586
  children: [
537
587
  /* @__PURE__ */ g("div", {
538
- ref: bt,
588
+ ref: Dt,
539
589
  className: "h-[70vh] max-h-[640px] w-full overflow-hidden rounded-lg border border-border-subtle bg-bg-sunken"
540
590
  }),
541
591
  T === "ready" && /* @__PURE__ */ _("div", {
542
592
  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
593
  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"))
594
+ $(E === "draw", () => E === "draw" ? Kt() : Gt(), /* @__PURE__ */ g(_e, { className: "h-4 w-4" }), e("healthybowl.fieldMapPage.tools.polygon", "Polygon")),
595
+ $(E === "edit", () => E === "edit" ? Yt() : Jt(), /* @__PURE__ */ g(Se, { className: "h-4 w-4" }), e("healthybowl.fieldMapPage.tools.vertices", "Vertices")),
596
+ $(!1, Zt, /* @__PURE__ */ g(Ce, { className: "h-4 w-4" }), e("healthybowl.fieldMapPage.tools.delete", "Delete")),
597
+ $(E === "measure", () => E === "measure" ? en() : $t(), /* @__PURE__ */ g(ye, { className: "h-4 w-4" }), e("healthybowl.fieldMapPage.tools.measure", "Measure"))
548
598
  ]
549
599
  }),
550
600
  E === "draw" && /* @__PURE__ */ _("div", {
551
601
  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
602
  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) }) }),
603
+ /* @__PURE__ */ g("span", { children: e("healthybowl.fieldMapPage.drawHint", "Click the map to add corners ({{count}}) — click the first point or Finish.", { count: String(lt) }) }),
554
604
  /* @__PURE__ */ _(v, {
555
605
  size: "sm",
556
606
  variant: "default",
557
- onClick: Pt,
607
+ onClick: Wt,
558
608
  children: [
559
- /* @__PURE__ */ g(de, { className: "h-3.5 w-3.5" }),
609
+ /* @__PURE__ */ g(pe, { className: "h-3.5 w-3.5" }),
560
610
  " ",
561
611
  e("healthybowl.fieldMapPage.finish", "Finish")
562
612
  ]
@@ -564,8 +614,8 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
564
614
  /* @__PURE__ */ g(v, {
565
615
  size: "sm",
566
616
  variant: "outline",
567
- onClick: It,
568
- children: /* @__PURE__ */ g(Se, { className: "h-3.5 w-3.5" })
617
+ onClick: Kt,
618
+ children: /* @__PURE__ */ g(we, { className: "h-3.5 w-3.5" })
569
619
  })
570
620
  ]
571
621
  }),
@@ -573,32 +623,32 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
573
623
  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
624
  children: [
575
625
  /* @__PURE__ */ g("span", { children: e("healthybowl.fieldMapPage.editHint", "Drag handles to reshape · {{area}} {{unit}}", {
576
- area: String(at ?? ""),
577
- unit: J?.unit ?? "acres"
626
+ area: String(dt ?? ""),
627
+ unit: q?.unit ?? "acres"
578
628
  }) }),
579
629
  /* @__PURE__ */ _(v, {
580
630
  size: "sm",
581
631
  variant: "default",
582
- onClick: Bt,
583
- disabled: !ot || ct,
632
+ onClick: Xt,
633
+ disabled: !pt || ht,
584
634
  children: [
585
- /* @__PURE__ */ g(ve, { className: "h-3.5 w-3.5" }),
635
+ /* @__PURE__ */ g(be, { className: "h-3.5 w-3.5" }),
586
636
  " ",
587
- ct ? e("healthybowl.fieldMapPage.saving", "Saving…") : e("healthybowl.fieldMapPage.save", "Save")
637
+ ht ? e("healthybowl.fieldMapPage.saving", "Saving…") : e("healthybowl.fieldMapPage.save", "Save")
588
638
  ]
589
639
  }),
590
640
  /* @__PURE__ */ g(v, {
591
641
  size: "sm",
592
642
  variant: "outline",
593
- onClick: zt,
594
- children: /* @__PURE__ */ g(Se, { className: "h-3.5 w-3.5" })
643
+ onClick: Yt,
644
+ children: /* @__PURE__ */ g(we, { className: "h-3.5 w-3.5" })
595
645
  })
596
646
  ]
597
647
  }),
598
- E === "measure" && F && /* @__PURE__ */ _("div", {
648
+ E === "measure" && P && /* @__PURE__ */ _("div", {
599
649
  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
650
  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) })}`] }),
651
+ /* @__PURE__ */ _("span", { children: [e("healthybowl.fieldMapPage.measure.distance", "Distance: {{d}}", { d: on }), P.area != null && ` · ${e("healthybowl.fieldMapPage.measure.area", "Area: {{a}} ac", { a: (P.area / 4046.8564224).toFixed(2) })}`] }),
602
652
  /* @__PURE__ */ g(v, {
603
653
  size: "sm",
604
654
  variant: "outline",
@@ -608,8 +658,8 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
608
658
  /* @__PURE__ */ g(v, {
609
659
  size: "sm",
610
660
  variant: "outline",
611
- onClick: Wt,
612
- children: /* @__PURE__ */ g(Se, { className: "h-3.5 w-3.5" })
661
+ onClick: en,
662
+ children: /* @__PURE__ */ g(we, { className: "h-3.5 w-3.5" })
613
663
  })
614
664
  ]
615
665
  }),
@@ -619,7 +669,7 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
619
669
  /* @__PURE__ */ _("div", {
620
670
  className: "mb-1.5 flex items-center gap-1.5 font-semibold text-text-primary",
621
671
  children: [
622
- /* @__PURE__ */ g(fe, { className: "h-3.5 w-3.5" }),
672
+ /* @__PURE__ */ g(me, { className: "h-3.5 w-3.5" }),
623
673
  " ",
624
674
  e("healthybowl.fieldMapPage.layers.title", "Layers")
625
675
  ]
@@ -638,7 +688,7 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
638
688
  children: [/* @__PURE__ */ g("input", {
639
689
  type: "checkbox",
640
690
  checked: A,
641
- onChange: (e) => Ze(e.target.checked),
691
+ onChange: (e) => $e(e.target.checked),
642
692
  className: "h-3.5 w-3.5 accent-[var(--color-success)]"
643
693
  }), e("healthybowl.fieldMapPage.layers.terrain", "Terrain")]
644
694
  }),
@@ -647,18 +697,43 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
647
697
  children: [/* @__PURE__ */ g("input", {
648
698
  type: "checkbox",
649
699
  checked: j,
650
- onChange: (e) => Qe(e.target.checked),
700
+ onChange: (e) => et(e.target.checked),
651
701
  className: "h-3.5 w-3.5 accent-[var(--color-success)]"
652
702
  }), e("healthybowl.fieldMapPage.layers.soil", "Soil type")]
703
+ }),
704
+ /* @__PURE__ */ _("label", {
705
+ className: "flex cursor-pointer items-center gap-2 py-0.5 text-text-primary",
706
+ children: [/* @__PURE__ */ g("input", {
707
+ type: "checkbox",
708
+ checked: M,
709
+ onChange: (e) => tt(e.target.checked),
710
+ className: "h-3.5 w-3.5 accent-[var(--color-success)]"
711
+ }), e("healthybowl.fieldMapPage.layers.elevation", "Elevation")]
653
712
  })
654
713
  ]
655
714
  }),
656
- T === "ready" && j && Ot.length > 0 && /* @__PURE__ */ _("div", {
715
+ T === "ready" && M && /* @__PURE__ */ _("div", {
716
+ className: "absolute bottom-3 right-3 z-[1000] rounded-lg border border-border-subtle bg-bg-surface/95 p-3 text-xs shadow-md",
717
+ children: [/* @__PURE__ */ g("div", {
718
+ className: "mb-1.5 font-semibold text-text-primary",
719
+ children: e("healthybowl.fieldMapPage.elevationLegend.title", "Elevation")
720
+ }), zt ? /* @__PURE__ */ _(Te, { children: [/* @__PURE__ */ g("span", {
721
+ className: "block h-2 w-40 rounded-full",
722
+ style: { background: "linear-gradient(to right, #16a34a, #f59e0b, #dc2626)" }
723
+ }), /* @__PURE__ */ _("div", {
724
+ className: "mt-1 flex justify-between gap-3 text-text-secondary",
725
+ children: [/* @__PURE__ */ g("span", { children: e("healthybowl.fieldMapPage.elevationLegend.low", "{{value}} m Low", { value: String(Math.round(Lt)) }) }), /* @__PURE__ */ g("span", { children: e("healthybowl.fieldMapPage.elevationLegend.high", "{{value}} m High", { value: String(Math.round(Rt)) }) })]
726
+ })] }) : /* @__PURE__ */ g("span", {
727
+ className: "text-text-secondary",
728
+ children: e("healthybowl.fieldMapPage.elevationLegend.loading", "Loading elevation…")
729
+ })]
730
+ }),
731
+ T === "ready" && j && !M && Ft.length > 0 && /* @__PURE__ */ _("div", {
657
732
  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
733
  children: [/* @__PURE__ */ g("div", {
659
734
  className: "mb-1.5 font-semibold text-text-primary",
660
735
  children: e("healthybowl.fieldMapPage.soilLegend.title", "Soil Legend")
661
- }), Ot.map((t) => /* @__PURE__ */ _("div", {
736
+ }), Ft.map((t) => /* @__PURE__ */ _("div", {
662
737
  className: "flex items-center gap-2 py-0.5 text-text-secondary",
663
738
  children: [/* @__PURE__ */ g("span", {
664
739
  className: "inline-block h-3 w-3 rounded-sm",
@@ -676,18 +751,18 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
676
751
  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)") })]
677
752
  })]
678
753
  }),
679
- (T === "loading" || Le.crops && c.length === 0) && /* @__PURE__ */ g("div", {
754
+ (T === "loading" || ze.crops && c.length === 0) && /* @__PURE__ */ g("div", {
680
755
  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
756
  children: e("healthybowl.fieldMapPage.loading", "Loading map…")
682
757
  }),
683
- Jt && T === "ready" && E === "view" && /* @__PURE__ */ g("div", {
758
+ an && T === "ready" && E === "view" && /* @__PURE__ */ g("div", {
684
759
  className: "absolute inset-0 z-[950] flex items-center justify-center p-6",
685
760
  children: /* @__PURE__ */ _("div", {
686
761
  className: "max-w-sm rounded-xl border border-border-subtle bg-bg-surface/95 p-6 text-center shadow-lg",
687
762
  children: [
688
763
  /* @__PURE__ */ g("div", {
689
764
  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" })
765
+ children: /* @__PURE__ */ g(ge, { className: "h-6 w-6 text-success" })
691
766
  }),
692
767
  /* @__PURE__ */ g("h3", {
693
768
  className: "text-lg font-semibold text-text-primary",
@@ -699,9 +774,9 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
699
774
  }),
700
775
  /* @__PURE__ */ _(v, {
701
776
  className: "mt-4",
702
- onClick: Ft,
777
+ onClick: Gt,
703
778
  children: [
704
- /* @__PURE__ */ g(ge, { className: "h-4 w-4" }),
779
+ /* @__PURE__ */ g(ve, { className: "h-4 w-4" }),
705
780
  " ",
706
781
  e("healthybowl.fieldMapPage.empty.action", "Draw Your First Field")
707
782
  ]
@@ -728,29 +803,29 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
728
803
  /* @__PURE__ */ g("p", {
729
804
  className: "mt-0.5 text-xs text-text-secondary",
730
805
  children: e("healthybowl.fieldMapPage.panel.summary", "{{acres}} acres · {{count}} fields · {{mapped}} mapped", {
731
- acres: Dt.toFixed(1),
806
+ acres: Pt.toFixed(1),
732
807
  count: String(c.length),
733
- mapped: String(Et)
808
+ mapped: String(Nt)
734
809
  })
735
810
  }),
736
811
  /* @__PURE__ */ _("div", {
737
812
  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", {
813
+ children: [/* @__PURE__ */ g(xe, { 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
814
  type: "search",
740
- value: M,
741
- onChange: (e) => $e(e.target.value),
815
+ value: rt,
816
+ onChange: (e) => it(e.target.value),
742
817
  placeholder: e("healthybowl.fieldMapPage.panel.search", "Search fields…"),
743
818
  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
819
  })]
745
820
  }),
746
821
  /* @__PURE__ */ _("div", {
747
822
  className: "mt-3 max-h-[38vh] space-y-1 overflow-y-auto",
748
- children: [kt.map((t) => {
823
+ children: [It.map((t) => {
749
824
  let n = x(t) !== null;
750
825
  return /* @__PURE__ */ _("button", {
751
826
  type: "button",
752
827
  "data-field-id": t.id,
753
- onClick: () => Mt(t),
828
+ onClick: () => Ht(t),
754
829
  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
830
  children: [
756
831
  /* @__PURE__ */ g("span", {
@@ -765,10 +840,11 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
765
840
  }), /* @__PURE__ */ _("span", {
766
841
  className: "block truncate text-xs text-text-secondary",
767
842
  children: [
768
- Ge(t),
843
+ qe(t),
769
844
  " ·",
770
845
  " ",
771
- t.soilType || e("healthybowl.fieldMapPage.unknownSoil", "Unknown soil")
846
+ t.soilType || e("healthybowl.fieldMapPage.unknownSoil", "Unknown soil"),
847
+ N[t.id] != null && ` · ${e("healthybowl.fieldMapPage.detail.elevationValue", "{{value}} m", { value: String(Math.round(N[t.id])) })}`
772
848
  ]
773
849
  })]
774
850
  }),
@@ -778,28 +854,28 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
778
854
  })
779
855
  ]
780
856
  }, t.id);
781
- }), kt.length === 0 && /* @__PURE__ */ g("p", {
857
+ }), It.length === 0 && /* @__PURE__ */ g("p", {
782
858
  className: "px-2 py-4 text-center text-xs text-text-secondary",
783
859
  children: e("healthybowl.fieldMapPage.panel.none", "No fields match your search.")
784
860
  })]
785
861
  }),
786
862
  /* @__PURE__ */ _(v, {
787
863
  className: "mt-3 w-full",
788
- onClick: Ft,
864
+ onClick: Gt,
789
865
  disabled: E === "draw",
790
866
  children: [
791
- /* @__PURE__ */ g(ge, { className: "h-4 w-4" }),
867
+ /* @__PURE__ */ g(ve, { className: "h-4 w-4" }),
792
868
  " ",
793
869
  e("healthybowl.fieldMapPage.panel.drawNew", "Draw New Field")
794
870
  ]
795
871
  })
796
872
  ]
797
- }), J && /* @__PURE__ */ _("div", {
873
+ }), q && /* @__PURE__ */ _("div", {
798
874
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
799
875
  children: [
800
876
  /* @__PURE__ */ g("h3", {
801
877
  className: "text-sm font-semibold text-text-primary",
802
- children: e("healthybowl.fieldMapPage.detail.selected", "Selected: {{name}}", { name: J.name })
878
+ children: e("healthybowl.fieldMapPage.detail.selected", "Selected: {{name}}", { name: q.name })
803
879
  }),
804
880
  /* @__PURE__ */ _("dl", {
805
881
  className: "mt-3 space-y-2 text-sm",
@@ -812,12 +888,22 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
812
888
  }), /* @__PURE__ */ _("dd", {
813
889
  className: "font-medium text-text-primary",
814
890
  children: [
815
- J.area,
891
+ q.area,
816
892
  " ",
817
- J.unit
893
+ q.unit
818
894
  ]
819
895
  })]
820
896
  }),
897
+ /* @__PURE__ */ _("div", {
898
+ className: "flex justify-between gap-3",
899
+ children: [/* @__PURE__ */ g("dt", {
900
+ className: "text-text-secondary",
901
+ children: e("healthybowl.fieldMapPage.detail.elevation", "Elevation")
902
+ }), /* @__PURE__ */ g("dd", {
903
+ className: "font-medium text-text-primary",
904
+ children: N[q.id] == null ? "—" : e("healthybowl.fieldMapPage.detail.elevationValue", "{{value}} m", { value: String(Math.round(N[q.id])) })
905
+ })]
906
+ }),
821
907
  /* @__PURE__ */ _("div", {
822
908
  className: "flex justify-between gap-3",
823
909
  children: [/* @__PURE__ */ g("dt", {
@@ -825,7 +911,7 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
825
911
  children: e("healthybowl.fieldMapPage.detail.soil", "Soil")
826
912
  }), /* @__PURE__ */ g("dd", {
827
913
  className: "font-medium text-text-primary",
828
- children: J.soilType || e("healthybowl.fieldMapPage.unknownSoil", "Unknown soil")
914
+ children: q.soilType || e("healthybowl.fieldMapPage.unknownSoil", "Unknown soil")
829
915
  })]
830
916
  }),
831
917
  /* @__PURE__ */ _("div", {
@@ -835,7 +921,7 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
835
921
  children: e("healthybowl.fieldMapPage.detail.irrigation", "Irrigation")
836
922
  }), /* @__PURE__ */ g("dd", {
837
923
  className: "font-medium text-text-primary",
838
- children: J.irrigationType || "—"
924
+ children: q.irrigationType || "—"
839
925
  })]
840
926
  }),
841
927
  /* @__PURE__ */ _("div", {
@@ -845,7 +931,7 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
845
931
  children: e("healthybowl.fieldMapPage.detail.crop", "Crop")
846
932
  }), /* @__PURE__ */ g("dd", {
847
933
  className: "font-medium text-text-primary",
848
- children: At(J) || e("healthybowl.fieldMapPage.detail.noCrop", "None")
934
+ children: Bt(q) || e("healthybowl.fieldMapPage.detail.noCrop", "None")
849
935
  })]
850
936
  }),
851
937
  /* @__PURE__ */ _("div", {
@@ -855,7 +941,7 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
855
941
  children: e("healthybowl.fieldMapPage.detail.status", "Status")
856
942
  }), /* @__PURE__ */ g("dd", {
857
943
  className: "font-medium capitalize text-text-primary",
858
- children: J.status
944
+ children: q.status
859
945
  })]
860
946
  })
861
947
  ]
@@ -866,20 +952,20 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
866
952
  variant: "outline",
867
953
  size: "sm",
868
954
  className: "flex-1",
869
- onClick: () => jt(J),
955
+ onClick: () => Vt(q),
870
956
  children: [
871
- /* @__PURE__ */ g(me, { className: "h-4 w-4" }),
957
+ /* @__PURE__ */ g(ge, { className: "h-4 w-4" }),
872
958
  " ",
873
959
  e("healthybowl.fieldMapPage.detail.flyTo", "Fly to")
874
960
  ]
875
- }), x(J) && /* @__PURE__ */ _(v, {
961
+ }), x(q) && /* @__PURE__ */ _(v, {
876
962
  variant: "outline",
877
963
  size: "sm",
878
964
  className: "flex-1",
879
- onClick: Rt,
965
+ onClick: Jt,
880
966
  disabled: E === "edit",
881
967
  children: [
882
- /* @__PURE__ */ g(be, { className: "h-4 w-4" }),
968
+ /* @__PURE__ */ g(Se, { className: "h-4 w-4" }),
883
969
  " ",
884
970
  e("healthybowl.fieldMapPage.detail.edit", "Edit")
885
971
  ]
@@ -890,34 +976,34 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
890
976
  })]
891
977
  }),
892
978
  /* @__PURE__ */ g(ee, {
893
- open: I !== null,
894
- onClose: () => L(null),
979
+ open: F !== null,
980
+ onClose: () => I(null),
895
981
  title: e("healthybowl.fieldMapPage.create.title", "Save New Field"),
896
982
  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, {
983
+ footer: /* @__PURE__ */ _(Te, { children: [/* @__PURE__ */ g(v, {
898
984
  variant: "outline",
899
- onClick: () => L(null),
985
+ onClick: () => I(null),
900
986
  className: "text-text-secondary",
901
987
  children: e("healthybowl.common.cancel", "Cancel")
902
988
  }), /* @__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")
989
+ onClick: rn,
990
+ disabled: vt,
991
+ children: vt ? e("healthybowl.fieldMapPage.create.saving", "Saving…") : e("healthybowl.fieldMapPage.create.action", "Save Field")
906
992
  })] }),
907
993
  children: /* @__PURE__ */ _("div", {
908
994
  className: "space-y-4",
909
995
  children: [
910
996
  /* @__PURE__ */ g("div", {
911
997
  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) })
998
+ children: e("healthybowl.fieldMapPage.create.areaLine", "Auto-calculated area: {{area}} acres", { area: String(F?.area ?? 0) })
913
999
  }),
914
1000
  /* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("label", {
915
1001
  className: "text-sm font-medium text-text-primary",
916
1002
  children: e("healthybowl.fieldMapPage.create.name", "Field name *")
917
1003
  }), /* @__PURE__ */ g("input", {
918
1004
  type: "text",
919
- value: R,
920
- onChange: (e) => pt(e.target.value),
1005
+ value: L,
1006
+ onChange: (e) => bt(e.target.value),
921
1007
  placeholder: e("healthybowl.fieldMapPage.create.namePlaceholder", "e.g., North Paddy"),
922
1008
  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
1009
  })] }),
@@ -926,26 +1012,26 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
926
1012
  children: [/* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("label", {
927
1013
  className: "text-sm font-medium text-text-primary",
928
1014
  children: e("healthybowl.fieldMapPage.create.soil", "Soil type")
929
- }), /* @__PURE__ */ _(we, {
930
- value: mt,
931
- onValueChange: ht,
932
- children: [/* @__PURE__ */ g(Ee, {
1015
+ }), /* @__PURE__ */ _(Ee, {
1016
+ value: xt,
1017
+ onValueChange: St,
1018
+ children: [/* @__PURE__ */ g(Oe, {
933
1019
  className: "mt-1 w-full",
934
- children: /* @__PURE__ */ g(De, {})
935
- }), /* @__PURE__ */ g(Te, { children: oe.map((t) => /* @__PURE__ */ g(y, {
1020
+ children: /* @__PURE__ */ g(ke, {})
1021
+ }), /* @__PURE__ */ g(De, { children: oe.map((t) => /* @__PURE__ */ g(y, {
936
1022
  value: t.label,
937
1023
  children: e(`healthybowl.fieldMapPage.soil.${t.key}`, t.label)
938
1024
  }, t.key)) })]
939
1025
  })] }), /* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("label", {
940
1026
  className: "text-sm font-medium text-text-primary",
941
1027
  children: e("healthybowl.fieldMapPage.create.irrigation", "Irrigation")
942
- }), /* @__PURE__ */ _(we, {
943
- value: gt,
944
- onValueChange: _t,
945
- children: [/* @__PURE__ */ g(Ee, {
1028
+ }), /* @__PURE__ */ _(Ee, {
1029
+ value: Ct,
1030
+ onValueChange: wt,
1031
+ children: [/* @__PURE__ */ g(Oe, {
946
1032
  className: "mt-1 w-full",
947
- children: /* @__PURE__ */ g(De, {})
948
- }), /* @__PURE__ */ _(Te, { children: [
1033
+ children: /* @__PURE__ */ g(ke, {})
1034
+ }), /* @__PURE__ */ _(De, { children: [
949
1035
  /* @__PURE__ */ g(y, {
950
1036
  value: "Drip",
951
1037
  children: e("healthybowl.fieldMapPage.irrigation.drip", "Drip")
@@ -972,13 +1058,13 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
972
1058
  /* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("label", {
973
1059
  className: "text-sm font-medium text-text-primary",
974
1060
  children: e("healthybowl.fieldMapPage.create.status", "Status")
975
- }), /* @__PURE__ */ _(we, {
976
- value: vt,
977
- onValueChange: yt,
978
- children: [/* @__PURE__ */ g(Ee, {
1061
+ }), /* @__PURE__ */ _(Ee, {
1062
+ value: Tt,
1063
+ onValueChange: Et,
1064
+ children: [/* @__PURE__ */ g(Oe, {
979
1065
  className: "mt-1 w-full",
980
- children: /* @__PURE__ */ g(De, {})
981
- }), /* @__PURE__ */ _(Te, { children: [
1066
+ children: /* @__PURE__ */ g(ke, {})
1067
+ }), /* @__PURE__ */ _(De, { children: [
982
1068
  /* @__PURE__ */ g(y, {
983
1069
  value: "active",
984
1070
  children: e("healthybowl.fieldMapPage.status.active", "Active")
@@ -997,8 +1083,8 @@ var b = /* @__PURE__ */ e(s(), 1), Ae = Oe`
997
1083
  })
998
1084
  }),
999
1085
  /* @__PURE__ */ g(a, {
1000
- toasts: Je,
1001
- onDismiss: Ye
1086
+ toasts: Xe,
1087
+ onDismiss: Ze
1002
1088
  })
1003
1089
  ]
1004
1090
  });