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