@burdenoff/microfe-healthybowl 2026.710.5 → 2026.710.6
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.
|
@@ -5,16 +5,16 @@ import { require_leaflet_src as r } from "../../node_modules/leaflet/dist/leafle
|
|
|
5
5
|
import { geocodePlace as i } from "../utils/geocode.js";
|
|
6
6
|
import { useToast as a } from "../hooks/useToast.js";
|
|
7
7
|
import { ensureLeafletCss as ee } from "../utils/leaflet.js";
|
|
8
|
-
import { extractPolygon as
|
|
9
|
-
import { useCallback as
|
|
10
|
-
import { useI18n as
|
|
11
|
-
import { Check as
|
|
12
|
-
import { Fragment as
|
|
13
|
-
import { Button as
|
|
14
|
-
import { gql as
|
|
15
|
-
import { useMutation as
|
|
8
|
+
import { extractPolygon as o, isValidPolygon as te, polygonAreaInUnit as s, ringToPolygon as ne } from "../utils/geo.js";
|
|
9
|
+
import { useCallback as c, useEffect as l, useRef as u, useState as d } from "react";
|
|
10
|
+
import { useI18n as re } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
11
|
+
import { Check as ie, LocateFixed as ae, MapPin as f, MapPinned as oe, Pencil as se, Save as ce, Search as p, Trash2 as le, Upload as ue, X as de } from "lucide-react";
|
|
12
|
+
import { Fragment as fe, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
13
|
+
import { Button as g } from "@burdenoff/fe-libs/ui";
|
|
14
|
+
import { gql as _ } from "@apollo/client";
|
|
15
|
+
import { useMutation as pe } from "@apollo/client/react";
|
|
16
16
|
//#region src/healthybowl/components/FieldMap.tsx
|
|
17
|
-
var
|
|
17
|
+
var v = /* @__PURE__ */ e(r(), 1), me = _`
|
|
18
18
|
mutation UpdateHealthyBowlFieldBoundary($input: UpdateHealthyBowlFieldInput!) {
|
|
19
19
|
updateHealthyBowlField(input: $input) {
|
|
20
20
|
id
|
|
@@ -23,22 +23,22 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
|
|
|
23
23
|
location
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
`,
|
|
26
|
+
`, he = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}", ge = "Esri, Maxar, Earthstar Geographics", _e = "https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", ve = "© OpenTopoMap (CC-BY-SA) · © OpenStreetMap contributors", ye = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", be = {
|
|
27
27
|
color: "#16a34a",
|
|
28
28
|
weight: 2,
|
|
29
29
|
fillColor: "#16a34a",
|
|
30
30
|
fillOpacity: .25
|
|
31
|
-
},
|
|
31
|
+
}, xe = {
|
|
32
32
|
color: "#f59e0b",
|
|
33
33
|
weight: 2,
|
|
34
34
|
dashArray: "6 4",
|
|
35
35
|
fillColor: "#f59e0b",
|
|
36
36
|
fillOpacity: .15
|
|
37
|
-
},
|
|
37
|
+
}, Se = 16, Ce = 17, y = (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)), we = (e) => {
|
|
38
38
|
let t = e.trim().match(/^(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)$/);
|
|
39
39
|
if (!t) return null;
|
|
40
40
|
let n = Number(t[1]), r = Number(t[2]);
|
|
41
|
-
return
|
|
41
|
+
return y({
|
|
42
42
|
lat: n,
|
|
43
43
|
lng: r
|
|
44
44
|
}) ? {
|
|
@@ -46,50 +46,52 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
|
|
|
46
46
|
lng: r,
|
|
47
47
|
label: `${n.toFixed(6)}, ${r.toFixed(6)}`
|
|
48
48
|
} : null;
|
|
49
|
-
},
|
|
50
|
-
let { t: b } =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
}, Te = ({ fieldId: e, unit: r, center: _, initialBoundary: Te, onSaved: Ee, onAreaChange: De }) => {
|
|
50
|
+
let { t: b } = re(), { workspaceId: x } = t(), { toasts: Oe, toast: S, dismiss: ke } = a(), C = u(null), w = u(null), T = u(null), E = u(null), D = u(null), O = u(null), k = u(null), A = u(null), j = u(_ ?? null), M = u([]), N = u([]), P = u(null), F = u("view"), [I, Ae] = d("loading"), [L, R] = d("view"), [z, je] = d(!1), [B, Me] = d(null), [Ne, Pe] = d(0), [Fe, V] = d(!1), [Ie, H] = d(!1), [Le, Re] = d(!1), [ze, U] = d(!1), [W, Be] = d(""), [G, Ve] = d(!1), [K, q] = d(null), He = Fe || Ie, [Ue] = pe(me);
|
|
51
|
+
l(() => {
|
|
52
|
+
j.current = _ ?? null;
|
|
53
|
+
}, [_]), l(() => {
|
|
54
|
+
De?.(B);
|
|
55
|
+
}, [B, De]);
|
|
56
|
+
let J = c(() => {
|
|
57
|
+
let e = T.current;
|
|
58
|
+
D.current && e && e.removeLayer(D.current), D.current = null, M.current.forEach((t) => e?.removeLayer(t)), M.current = [], N.current = [], Pe(0);
|
|
59
|
+
}, []), Y = c((e, t) => {
|
|
60
|
+
let n = T.current;
|
|
59
61
|
if (!n) return;
|
|
60
|
-
|
|
61
|
-
let i =
|
|
62
|
-
if (
|
|
62
|
+
E.current && n.removeLayer(E.current);
|
|
63
|
+
let i = v.default.geoJSON(e, { style: () => be }).addTo(n);
|
|
64
|
+
if (E.current = i, P.current = e, je(!0), Me(s(e, r)), t) try {
|
|
63
65
|
n.fitBounds(i.getBounds(), {
|
|
64
66
|
padding: [24, 24],
|
|
65
67
|
maxZoom: 18
|
|
66
68
|
});
|
|
67
69
|
} catch {}
|
|
68
|
-
}, [r]),
|
|
69
|
-
let e =
|
|
70
|
-
|
|
71
|
-
}, []),
|
|
72
|
-
let e =
|
|
73
|
-
|
|
74
|
-
}, []),
|
|
75
|
-
let e =
|
|
76
|
-
|
|
77
|
-
}, []), Q =
|
|
78
|
-
let t =
|
|
70
|
+
}, [r]), X = c(() => {
|
|
71
|
+
let e = T.current;
|
|
72
|
+
E.current && e && e.removeLayer(E.current), E.current = null, P.current = null, je(!1), Me(null);
|
|
73
|
+
}, []), Z = c(() => {
|
|
74
|
+
let e = T.current;
|
|
75
|
+
O.current && e && e.removeLayer(O.current), k.current && e && e.removeLayer(k.current), O.current = null, k.current = null;
|
|
76
|
+
}, []), We = c(() => {
|
|
77
|
+
let e = T.current;
|
|
78
|
+
A.current && e && e.removeLayer(A.current), A.current = null, q(null), H(!1);
|
|
79
|
+
}, []), Q = c((e) => {
|
|
80
|
+
let t = T.current;
|
|
79
81
|
if (!t) return;
|
|
80
|
-
|
|
82
|
+
A.current && t.removeLayer(A.current);
|
|
81
83
|
let n = [e.lat, e.lng], r = document.createElement("span");
|
|
82
|
-
r.textContent = e.label,
|
|
84
|
+
r.textContent = e.label, A.current = v.default.circleMarker(n, {
|
|
83
85
|
radius: 8,
|
|
84
86
|
color: "#ffffff",
|
|
85
87
|
weight: 2,
|
|
86
88
|
fillColor: "#16a34a",
|
|
87
89
|
fillOpacity: 1
|
|
88
|
-
}).addTo(t).bindPopup(r).openPopup(), t.flyTo(n, Math.max(t.getZoom(),
|
|
89
|
-
}, []),
|
|
90
|
-
let e =
|
|
90
|
+
}).addTo(t).bindPopup(r).openPopup(), t.flyTo(n, Math.max(t.getZoom(), Ce), { duration: .75 }), q(e), H(!0);
|
|
91
|
+
}, []), Ge = c(() => {
|
|
92
|
+
let e = T.current;
|
|
91
93
|
if (!e) return;
|
|
92
|
-
let t =
|
|
94
|
+
let t = E.current;
|
|
93
95
|
if (t) try {
|
|
94
96
|
let n = t.getBounds();
|
|
95
97
|
if (n.isValid()) {
|
|
@@ -100,58 +102,58 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
|
|
|
100
102
|
return;
|
|
101
103
|
}
|
|
102
104
|
} catch {}
|
|
103
|
-
let n =
|
|
104
|
-
if (
|
|
105
|
-
e.flyTo([n.lat, n.lng],
|
|
105
|
+
let n = j.current;
|
|
106
|
+
if (y(n)) {
|
|
107
|
+
e.flyTo([n.lat, n.lng], Se, { duration: .6 });
|
|
106
108
|
return;
|
|
107
109
|
}
|
|
108
|
-
|
|
110
|
+
S({
|
|
109
111
|
title: b("healthybowl.fieldMap.toast.noFieldLocation.title", "No field location set"),
|
|
110
112
|
description: b("healthybowl.fieldMap.toast.noFieldLocation.description", "Draw a boundary or save GPS coordinates for this field first."),
|
|
111
113
|
variant: "warning"
|
|
112
114
|
});
|
|
113
|
-
}, [b,
|
|
114
|
-
let e =
|
|
115
|
+
}, [b, S]), Ke = c(() => {
|
|
116
|
+
let e = T.current;
|
|
115
117
|
if (e) {
|
|
116
118
|
if (typeof navigator > "u" || !navigator.geolocation) {
|
|
117
|
-
|
|
119
|
+
S({
|
|
118
120
|
title: b("healthybowl.fieldMap.toast.locationUnsupported.title", "Location unavailable"),
|
|
119
121
|
description: b("healthybowl.fieldMap.toast.locationUnsupported.description", "This browser does not support device location."),
|
|
120
122
|
variant: "warning"
|
|
121
123
|
});
|
|
122
124
|
return;
|
|
123
125
|
}
|
|
124
|
-
|
|
126
|
+
U(!0), navigator.geolocation.getCurrentPosition((t) => {
|
|
125
127
|
let n = [t.coords.latitude, t.coords.longitude];
|
|
126
|
-
|
|
128
|
+
Z(), k.current = v.default.circle(n, {
|
|
127
129
|
radius: Math.max(10, t.coords.accuracy || 0),
|
|
128
130
|
color: "#2563eb",
|
|
129
131
|
fillColor: "#3b82f6",
|
|
130
132
|
fillOpacity: .12,
|
|
131
133
|
opacity: .45,
|
|
132
134
|
weight: 1
|
|
133
|
-
}).addTo(e),
|
|
135
|
+
}).addTo(e), O.current = v.default.circleMarker(n, {
|
|
134
136
|
radius: 7,
|
|
135
137
|
color: "#ffffff",
|
|
136
138
|
weight: 2,
|
|
137
139
|
fillColor: "#2563eb",
|
|
138
140
|
fillOpacity: 1
|
|
139
|
-
}).addTo(e), e.flyTo(n, Math.max(e.getZoom(),
|
|
141
|
+
}).addTo(e), e.flyTo(n, Math.max(e.getZoom(), Ce), { duration: .75 }), Q({
|
|
140
142
|
lat: t.coords.latitude,
|
|
141
143
|
lng: t.coords.longitude,
|
|
142
144
|
label: b("healthybowl.fieldMap.location.currentLabel", "My current location")
|
|
143
|
-
}),
|
|
145
|
+
}), U(!1), S({
|
|
144
146
|
title: b("healthybowl.fieldMap.toast.locationReady.title", "Location ready"),
|
|
145
147
|
description: b("healthybowl.fieldMap.toast.locationReady.description", "Save to store this as the field GPS location."),
|
|
146
148
|
variant: "success"
|
|
147
149
|
});
|
|
148
150
|
}, (e) => {
|
|
149
151
|
let t = e.code === e.PERMISSION_DENIED;
|
|
150
|
-
|
|
152
|
+
S({
|
|
151
153
|
title: t ? b("healthybowl.fieldMap.toast.locationBlocked.title", "Location blocked") : b("healthybowl.fieldMap.toast.locationFailed.title", "Could not get location"),
|
|
152
154
|
description: t ? b("healthybowl.fieldMap.toast.locationBlocked.description", "Allow location access in the browser, then try again.") : b("healthybowl.fieldMap.toast.locationFailed.description", "Make sure GPS is enabled and the page is open over HTTPS."),
|
|
153
155
|
variant: "warning"
|
|
154
|
-
}),
|
|
156
|
+
}), U(!1);
|
|
155
157
|
}, {
|
|
156
158
|
enableHighAccuracy: !0,
|
|
157
159
|
timeout: 12e3,
|
|
@@ -159,31 +161,31 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
|
|
|
159
161
|
});
|
|
160
162
|
}
|
|
161
163
|
}, [
|
|
162
|
-
|
|
164
|
+
Z,
|
|
163
165
|
Q,
|
|
164
166
|
b,
|
|
165
|
-
|
|
166
|
-
]),
|
|
167
|
+
S
|
|
168
|
+
]), qe = c(async (e) => {
|
|
167
169
|
e.preventDefault();
|
|
168
|
-
let t =
|
|
170
|
+
let t = W.trim();
|
|
169
171
|
if (!t) {
|
|
170
|
-
|
|
172
|
+
S({
|
|
171
173
|
title: b("healthybowl.fieldMap.toast.searchRequired.title", "Place required"),
|
|
172
174
|
description: b("healthybowl.fieldMap.toast.searchRequired.description", "Enter a village, city, region, or coordinates."),
|
|
173
175
|
variant: "warning"
|
|
174
176
|
});
|
|
175
177
|
return;
|
|
176
178
|
}
|
|
177
|
-
let n =
|
|
179
|
+
let n = we(t);
|
|
178
180
|
if (n) {
|
|
179
181
|
Q(n);
|
|
180
182
|
return;
|
|
181
183
|
}
|
|
182
|
-
|
|
184
|
+
Ve(!0);
|
|
183
185
|
try {
|
|
184
186
|
let e = await i(t);
|
|
185
187
|
if (!e) {
|
|
186
|
-
|
|
188
|
+
S({
|
|
187
189
|
title: b("healthybowl.fieldMap.toast.searchNotFound.title", "Place not found"),
|
|
188
190
|
description: b("healthybowl.fieldMap.toast.searchNotFound.description", "Try a more specific location, such as village, district, and state."),
|
|
189
191
|
variant: "warning"
|
|
@@ -201,49 +203,49 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
|
|
|
201
203
|
label: n
|
|
202
204
|
});
|
|
203
205
|
} catch (e) {
|
|
204
|
-
|
|
206
|
+
S({
|
|
205
207
|
title: b("healthybowl.fieldMap.toast.searchFailed.title", "Search failed"),
|
|
206
208
|
description: e instanceof Error ? e.message : String(e),
|
|
207
209
|
variant: "error"
|
|
208
210
|
});
|
|
209
211
|
} finally {
|
|
210
|
-
|
|
212
|
+
Ve(!1);
|
|
211
213
|
}
|
|
212
214
|
}, [
|
|
213
|
-
|
|
215
|
+
W,
|
|
214
216
|
Q,
|
|
215
217
|
b,
|
|
216
|
-
|
|
217
|
-
]),
|
|
218
|
-
let e =
|
|
218
|
+
S
|
|
219
|
+
]), Je = c(() => {
|
|
220
|
+
let e = T.current;
|
|
219
221
|
if (!e) return;
|
|
220
|
-
let t =
|
|
221
|
-
|
|
222
|
-
}, []), $ =
|
|
223
|
-
if (
|
|
224
|
-
|
|
222
|
+
let t = N.current;
|
|
223
|
+
D.current && e.removeLayer(D.current), t.length >= 2 ? D.current = v.default.polygon(t, xe).addTo(e) : D.current = null;
|
|
224
|
+
}, []), $ = c(() => {
|
|
225
|
+
if (N.current.length < 3) {
|
|
226
|
+
S({
|
|
225
227
|
title: b("healthybowl.fieldMap.toast.needPoints.title", "Need at least 3 points"),
|
|
226
228
|
description: b("healthybowl.fieldMap.toast.needPoints.description", "Click on the map to add more boundary corners."),
|
|
227
229
|
variant: "warning"
|
|
228
230
|
});
|
|
229
231
|
return;
|
|
230
232
|
}
|
|
231
|
-
let e =
|
|
233
|
+
let e = ne(N.current.map((e) => ({
|
|
232
234
|
lat: e.lat,
|
|
233
235
|
lng: e.lng
|
|
234
236
|
})));
|
|
235
|
-
|
|
237
|
+
J(), F.current = "view", R("view"), e && (Y(e, !1), V(!0));
|
|
236
238
|
}, [
|
|
239
|
+
J,
|
|
237
240
|
Y,
|
|
238
|
-
X,
|
|
239
241
|
b,
|
|
240
|
-
|
|
241
|
-
]),
|
|
242
|
-
if (
|
|
243
|
-
let t =
|
|
242
|
+
S
|
|
243
|
+
]), Ye = c((e) => {
|
|
244
|
+
if (F.current !== "draw") return;
|
|
245
|
+
let t = T.current;
|
|
244
246
|
if (!t) return;
|
|
245
|
-
|
|
246
|
-
let n =
|
|
247
|
+
N.current.push(e.latlng);
|
|
248
|
+
let n = N.current.length === 1, r = v.default.circleMarker(e.latlng, {
|
|
247
249
|
radius: n ? 7 : 5,
|
|
248
250
|
color: "#fff",
|
|
249
251
|
weight: 2,
|
|
@@ -251,57 +253,57 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
|
|
|
251
253
|
fillOpacity: 1
|
|
252
254
|
}).addTo(t);
|
|
253
255
|
n && r.on("click", (e) => {
|
|
254
|
-
|
|
255
|
-
}),
|
|
256
|
-
}, [$,
|
|
257
|
-
|
|
258
|
-
}, [
|
|
259
|
-
|
|
260
|
-
}, [
|
|
261
|
-
|
|
262
|
-
}, [
|
|
256
|
+
v.default.DomEvent.stopPropagation(e), $();
|
|
257
|
+
}), M.current.push(r), Pe(N.current.length), Je();
|
|
258
|
+
}, [$, Je]), Xe = c(() => {
|
|
259
|
+
X(), J(), F.current = "draw", R("draw"), V(!0);
|
|
260
|
+
}, [J, X]), Ze = c(() => {
|
|
261
|
+
J(), F.current = "view", R("view");
|
|
262
|
+
}, [J]), Qe = c(() => {
|
|
263
|
+
J(), X(), F.current = "view", R("view"), V(!0);
|
|
264
|
+
}, [J, X]), $e = c(async (e) => {
|
|
263
265
|
try {
|
|
264
266
|
let t = await e.text(), n = JSON.parse(t);
|
|
265
|
-
if (!
|
|
266
|
-
|
|
267
|
+
if (!te(n)) {
|
|
268
|
+
S({
|
|
267
269
|
title: b("healthybowl.fieldMap.toast.importInvalid.title", "No polygon found"),
|
|
268
270
|
description: b("healthybowl.fieldMap.toast.importInvalid.description", "The file must contain a GeoJSON Polygon (Feature, FeatureCollection or geometry)."),
|
|
269
271
|
variant: "error"
|
|
270
272
|
});
|
|
271
273
|
return;
|
|
272
274
|
}
|
|
273
|
-
let r =
|
|
274
|
-
|
|
275
|
+
let r = o(n);
|
|
276
|
+
J(), F.current = "view", R("view"), Y(r, !0), V(!0), S({
|
|
275
277
|
title: b("healthybowl.fieldMap.toast.imported.title", "Boundary imported"),
|
|
276
278
|
description: b("healthybowl.fieldMap.toast.imported.description", "Review it on the map, then Save to persist."),
|
|
277
279
|
variant: "success"
|
|
278
280
|
});
|
|
279
281
|
} catch {
|
|
280
|
-
|
|
282
|
+
S({
|
|
281
283
|
title: b("healthybowl.fieldMap.toast.importFailed.title", "Could not read file"),
|
|
282
284
|
description: b("healthybowl.fieldMap.toast.importFailed.description", "Make sure it is a valid GeoJSON (.json / .geojson) file."),
|
|
283
285
|
variant: "error"
|
|
284
286
|
});
|
|
285
287
|
}
|
|
286
288
|
}, [
|
|
289
|
+
J,
|
|
287
290
|
Y,
|
|
288
|
-
X,
|
|
289
291
|
b,
|
|
290
|
-
|
|
291
|
-
]),
|
|
292
|
-
|
|
292
|
+
S
|
|
293
|
+
]), et = c(async () => {
|
|
294
|
+
Re(!0);
|
|
293
295
|
try {
|
|
294
|
-
let t =
|
|
295
|
-
lat:
|
|
296
|
-
lng:
|
|
296
|
+
let t = P.current, n = t ? s(t, r) : void 0, i = K ? {
|
|
297
|
+
lat: K.lat,
|
|
298
|
+
lng: K.lng
|
|
297
299
|
} : void 0;
|
|
298
|
-
await
|
|
300
|
+
await Ue({ variables: { input: {
|
|
299
301
|
id: e,
|
|
300
302
|
boundary: t,
|
|
301
303
|
...n == null ? {} : { area: n },
|
|
302
304
|
...i ? { location: i } : {},
|
|
303
|
-
context: { workspaceId:
|
|
304
|
-
} } }), i && (
|
|
305
|
+
context: { workspaceId: x }
|
|
306
|
+
} } }), i && (j.current = i), V(!1), H(!1), q(null), Ee?.(), S({
|
|
305
307
|
title: b("healthybowl.fieldMap.toast.saved.title", "Map saved"),
|
|
306
308
|
description: i ? b("healthybowl.fieldMap.toast.savedLocation.description", "Field GPS location updated.") : t ? b("healthybowl.fieldMap.toast.saved.description", "Field area updated to {{area}} {{unit}}.", {
|
|
307
309
|
area: String(n ?? ""),
|
|
@@ -310,246 +312,246 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
|
|
|
310
312
|
variant: "success"
|
|
311
313
|
});
|
|
312
314
|
} catch (e) {
|
|
313
|
-
|
|
315
|
+
S({
|
|
314
316
|
title: b("healthybowl.fieldMap.toast.saveFailed.title", "Save failed"),
|
|
315
317
|
description: String(e),
|
|
316
318
|
variant: "error"
|
|
317
319
|
});
|
|
318
320
|
} finally {
|
|
319
|
-
|
|
321
|
+
Re(!1);
|
|
320
322
|
}
|
|
321
323
|
}, [
|
|
322
324
|
e,
|
|
323
325
|
Ee,
|
|
324
|
-
|
|
326
|
+
K,
|
|
325
327
|
b,
|
|
326
|
-
|
|
328
|
+
S,
|
|
327
329
|
r,
|
|
328
|
-
|
|
329
|
-
|
|
330
|
+
Ue,
|
|
331
|
+
x
|
|
330
332
|
]);
|
|
331
|
-
return
|
|
332
|
-
let e =
|
|
333
|
+
return l(() => {
|
|
334
|
+
let e = w.current;
|
|
333
335
|
if (!e) return;
|
|
334
336
|
ee();
|
|
335
|
-
let t =
|
|
336
|
-
attribution:
|
|
337
|
+
let t = v.default.tileLayer(he, {
|
|
338
|
+
attribution: ge,
|
|
337
339
|
maxZoom: 19
|
|
338
|
-
}), n =
|
|
339
|
-
attribution:
|
|
340
|
+
}), n = v.default.tileLayer(_e, {
|
|
341
|
+
attribution: ve,
|
|
340
342
|
maxZoom: 17
|
|
341
|
-
}), r =
|
|
342
|
-
attribution:
|
|
343
|
+
}), r = v.default.tileLayer(_e, {
|
|
344
|
+
attribution: ve,
|
|
343
345
|
maxZoom: 17,
|
|
344
346
|
opacity: .6
|
|
345
|
-
}), i =
|
|
347
|
+
}), i = v.default.tileLayer(ye, {
|
|
346
348
|
attribution: "© OpenStreetMap contributors",
|
|
347
349
|
maxZoom: 19
|
|
348
|
-
}), a =
|
|
350
|
+
}), a = v.default.map(e, {
|
|
349
351
|
center: [20, 0],
|
|
350
352
|
zoom: 2,
|
|
351
353
|
scrollWheelZoom: !0,
|
|
352
354
|
layers: [t]
|
|
353
355
|
});
|
|
354
|
-
|
|
356
|
+
T.current = a, v.default.control.layers({ [b("healthybowl.fieldMap.layers.satellite", "Satellite (Esri)")]: t }, {
|
|
355
357
|
[b("healthybowl.fieldMap.layers.terrain", "Terrain (OpenTopoMap)")]: n,
|
|
356
358
|
[b("healthybowl.fieldMap.layers.soil", "Soil (placeholder)")]: r,
|
|
357
359
|
[b("healthybowl.fieldMap.layers.streets", "Streets (OSM)")]: i
|
|
358
|
-
}, { collapsed: !1 }).addTo(a), a.on("click",
|
|
359
|
-
let
|
|
360
|
-
return
|
|
361
|
-
a.off("click",
|
|
360
|
+
}, { collapsed: !1 }).addTo(a), a.on("click", Ye);
|
|
361
|
+
let s = o(Te);
|
|
362
|
+
return s && te(s) ? Y(s, !0) : y(_) && a.setView([_.lat, _.lng], Se), Ae("ready"), window.setTimeout(() => a.invalidateSize(), 80), () => {
|
|
363
|
+
a.off("click", Ye), a.remove(), T.current = null, E.current = null, D.current = null, O.current = null, k.current = null, A.current = null, M.current = [], N.current = [], P.current = null;
|
|
362
364
|
};
|
|
363
|
-
}, []), /* @__PURE__ */
|
|
365
|
+
}, []), /* @__PURE__ */ h("div", {
|
|
364
366
|
className: "relative",
|
|
365
367
|
children: [
|
|
366
|
-
/* @__PURE__ */
|
|
368
|
+
/* @__PURE__ */ h("div", {
|
|
367
369
|
className: "mb-3 flex flex-wrap items-center gap-2",
|
|
368
|
-
children: [
|
|
369
|
-
/* @__PURE__ */
|
|
370
|
+
children: [L === "view" ? /* @__PURE__ */ h(fe, { children: [
|
|
371
|
+
/* @__PURE__ */ h(g, {
|
|
370
372
|
variant: "outline",
|
|
371
373
|
size: "sm",
|
|
372
|
-
onClick:
|
|
374
|
+
onClick: Xe,
|
|
373
375
|
children: [
|
|
374
|
-
/* @__PURE__ */
|
|
376
|
+
/* @__PURE__ */ m(se, { className: "h-4 w-4" }),
|
|
375
377
|
" ",
|
|
376
|
-
|
|
378
|
+
z ? b("healthybowl.fieldMap.actions.redraw", "Redraw") : b("healthybowl.fieldMap.actions.draw", "Draw boundary")
|
|
377
379
|
]
|
|
378
380
|
}),
|
|
379
|
-
/* @__PURE__ */
|
|
381
|
+
/* @__PURE__ */ h(g, {
|
|
380
382
|
variant: "outline",
|
|
381
383
|
size: "sm",
|
|
382
|
-
onClick: () =>
|
|
384
|
+
onClick: () => C.current?.click(),
|
|
383
385
|
children: [
|
|
384
|
-
/* @__PURE__ */
|
|
386
|
+
/* @__PURE__ */ m(ue, { className: "h-4 w-4" }),
|
|
385
387
|
" ",
|
|
386
388
|
b("healthybowl.fieldMap.actions.import", "Import GeoJSON")
|
|
387
389
|
]
|
|
388
390
|
}),
|
|
389
|
-
/* @__PURE__ */
|
|
391
|
+
/* @__PURE__ */ h(g, {
|
|
390
392
|
variant: "outline",
|
|
391
393
|
size: "sm",
|
|
392
|
-
onClick:
|
|
394
|
+
onClick: Ge,
|
|
393
395
|
title: b("healthybowl.fieldMap.actions.focusField.title", "Fit map to this field"),
|
|
394
396
|
"aria-label": b("healthybowl.fieldMap.actions.focusField.title", "Fit map to this field"),
|
|
395
397
|
children: [
|
|
396
|
-
/* @__PURE__ */
|
|
398
|
+
/* @__PURE__ */ m(oe, { className: "h-4 w-4" }),
|
|
397
399
|
" ",
|
|
398
400
|
b("healthybowl.fieldMap.actions.focusField", "Field")
|
|
399
401
|
]
|
|
400
402
|
}),
|
|
401
|
-
/* @__PURE__ */
|
|
403
|
+
/* @__PURE__ */ h(g, {
|
|
402
404
|
variant: "outline",
|
|
403
405
|
size: "sm",
|
|
404
|
-
onClick:
|
|
405
|
-
disabled:
|
|
406
|
+
onClick: Ke,
|
|
407
|
+
disabled: ze,
|
|
406
408
|
title: b("healthybowl.fieldMap.actions.locateMe.title", "Go to my current location"),
|
|
407
409
|
"aria-label": b("healthybowl.fieldMap.actions.locateMe.title", "Go to my current location"),
|
|
408
410
|
children: [
|
|
409
|
-
/* @__PURE__ */
|
|
411
|
+
/* @__PURE__ */ m(ae, { className: "h-4 w-4" }),
|
|
410
412
|
" ",
|
|
411
|
-
|
|
413
|
+
ze ? b("healthybowl.fieldMap.actions.locating", "Locating...") : b("healthybowl.fieldMap.actions.locateMe", "My location")
|
|
412
414
|
]
|
|
413
415
|
}),
|
|
414
|
-
|
|
416
|
+
z && /* @__PURE__ */ h(g, {
|
|
415
417
|
variant: "outline",
|
|
416
418
|
size: "sm",
|
|
417
|
-
onClick:
|
|
419
|
+
onClick: Qe,
|
|
418
420
|
children: [
|
|
419
|
-
/* @__PURE__ */
|
|
421
|
+
/* @__PURE__ */ m(le, { className: "h-4 w-4" }),
|
|
420
422
|
" ",
|
|
421
423
|
b("healthybowl.fieldMap.actions.clear", "Clear")
|
|
422
424
|
]
|
|
423
425
|
})
|
|
424
|
-
] }) : /* @__PURE__ */
|
|
425
|
-
/* @__PURE__ */
|
|
426
|
+
] }) : /* @__PURE__ */ h(fe, { children: [
|
|
427
|
+
/* @__PURE__ */ h(g, {
|
|
426
428
|
variant: "default",
|
|
427
429
|
size: "sm",
|
|
428
430
|
onClick: $,
|
|
429
431
|
children: [
|
|
430
|
-
/* @__PURE__ */
|
|
432
|
+
/* @__PURE__ */ m(ie, { className: "h-4 w-4" }),
|
|
431
433
|
" ",
|
|
432
434
|
b("healthybowl.fieldMap.actions.finish", "Finish")
|
|
433
435
|
]
|
|
434
436
|
}),
|
|
435
|
-
/* @__PURE__ */
|
|
437
|
+
/* @__PURE__ */ h(g, {
|
|
436
438
|
variant: "outline",
|
|
437
439
|
size: "sm",
|
|
438
|
-
onClick:
|
|
440
|
+
onClick: Ze,
|
|
439
441
|
children: [
|
|
440
|
-
/* @__PURE__ */
|
|
442
|
+
/* @__PURE__ */ m(de, { className: "h-4 w-4" }),
|
|
441
443
|
" ",
|
|
442
444
|
b("healthybowl.common.cancel", "Cancel")
|
|
443
445
|
]
|
|
444
446
|
}),
|
|
445
|
-
/* @__PURE__ */
|
|
447
|
+
/* @__PURE__ */ m("span", {
|
|
446
448
|
className: "text-xs text-text-secondary",
|
|
447
|
-
children: b("healthybowl.fieldMap.draftHint", "Click the map to add corners ({{count}} placed) — click the first point or Finish to close.", { count: String(
|
|
449
|
+
children: b("healthybowl.fieldMap.draftHint", "Click the map to add corners ({{count}} placed) — click the first point or Finish to close.", { count: String(Ne) })
|
|
448
450
|
})
|
|
449
|
-
] }), /* @__PURE__ */
|
|
451
|
+
] }), /* @__PURE__ */ h("div", {
|
|
450
452
|
className: "ml-auto flex items-center gap-3",
|
|
451
|
-
children: [
|
|
453
|
+
children: [B != null && /* @__PURE__ */ m("span", {
|
|
452
454
|
className: "text-xs text-text-secondary",
|
|
453
455
|
children: b("healthybowl.fieldMap.computedArea", "Area: {{area}} {{unit}}", {
|
|
454
|
-
area: String(
|
|
456
|
+
area: String(B),
|
|
455
457
|
unit: r
|
|
456
458
|
})
|
|
457
|
-
}), /* @__PURE__ */
|
|
459
|
+
}), /* @__PURE__ */ h(g, {
|
|
458
460
|
variant: "default",
|
|
459
461
|
size: "sm",
|
|
460
|
-
onClick:
|
|
461
|
-
disabled: !
|
|
462
|
+
onClick: et,
|
|
463
|
+
disabled: !He || Le || L === "draw",
|
|
462
464
|
children: [
|
|
463
|
-
/* @__PURE__ */
|
|
465
|
+
/* @__PURE__ */ m(ce, { className: "h-4 w-4" }),
|
|
464
466
|
" ",
|
|
465
|
-
|
|
467
|
+
Le ? b("healthybowl.fieldMap.actions.saving", "Saving…") : b("healthybowl.fieldMap.actions.save", "Save")
|
|
466
468
|
]
|
|
467
469
|
})]
|
|
468
470
|
})]
|
|
469
471
|
}),
|
|
470
|
-
|
|
472
|
+
L === "view" && /* @__PURE__ */ h("div", {
|
|
471
473
|
className: "mb-3 space-y-2",
|
|
472
|
-
children: [/* @__PURE__ */
|
|
474
|
+
children: [/* @__PURE__ */ h("form", {
|
|
473
475
|
className: "flex flex-col gap-2 sm:flex-row",
|
|
474
|
-
onSubmit:
|
|
476
|
+
onSubmit: qe,
|
|
475
477
|
children: [
|
|
476
|
-
/* @__PURE__ */
|
|
478
|
+
/* @__PURE__ */ h("div", {
|
|
477
479
|
className: "relative min-w-0 flex-1",
|
|
478
|
-
children: [/* @__PURE__ */ p
|
|
480
|
+
children: [/* @__PURE__ */ m(p, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary" }), /* @__PURE__ */ m("input", {
|
|
479
481
|
type: "search",
|
|
480
|
-
value:
|
|
481
|
-
onChange: (e) =>
|
|
482
|
-
disabled:
|
|
482
|
+
value: W,
|
|
483
|
+
onChange: (e) => Be(e.target.value),
|
|
484
|
+
disabled: I !== "ready" || G,
|
|
483
485
|
placeholder: b("healthybowl.fieldMap.search.placeholder", "Search village, city, region, or lat,lng..."),
|
|
484
486
|
"aria-label": b("healthybowl.fieldMap.search.label", "Search field map by place or coordinates"),
|
|
485
487
|
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)]"
|
|
486
488
|
})]
|
|
487
489
|
}),
|
|
488
|
-
/* @__PURE__ */
|
|
490
|
+
/* @__PURE__ */ h(g, {
|
|
489
491
|
type: "submit",
|
|
490
492
|
variant: "outline",
|
|
491
493
|
size: "sm",
|
|
492
|
-
disabled:
|
|
494
|
+
disabled: I !== "ready" || G,
|
|
493
495
|
children: [
|
|
494
|
-
/* @__PURE__ */ p
|
|
496
|
+
/* @__PURE__ */ m(p, { className: "h-4 w-4" }),
|
|
495
497
|
" ",
|
|
496
|
-
|
|
498
|
+
G ? b("healthybowl.fieldMap.search.searching", "Searching...") : b("healthybowl.fieldMap.search.action", "Search")
|
|
497
499
|
]
|
|
498
500
|
}),
|
|
499
|
-
|
|
501
|
+
K && /* @__PURE__ */ h(g, {
|
|
500
502
|
type: "button",
|
|
501
503
|
variant: "outline",
|
|
502
504
|
size: "sm",
|
|
503
|
-
onClick:
|
|
505
|
+
onClick: We,
|
|
504
506
|
children: [
|
|
505
|
-
/* @__PURE__ */
|
|
507
|
+
/* @__PURE__ */ m(de, { className: "h-4 w-4" }),
|
|
506
508
|
" ",
|
|
507
509
|
b("healthybowl.common.clear", "Clear")
|
|
508
510
|
]
|
|
509
511
|
})
|
|
510
512
|
]
|
|
511
|
-
}),
|
|
513
|
+
}), K && /* @__PURE__ */ m("div", {
|
|
512
514
|
className: "flex flex-wrap items-center gap-2 text-xs text-text-secondary",
|
|
513
|
-
children: /* @__PURE__ */
|
|
515
|
+
children: /* @__PURE__ */ h("span", {
|
|
514
516
|
className: "inline-flex min-w-0 items-center gap-1.5 rounded-full border border-border-subtle bg-bg-sunken/70 px-2.5 py-1",
|
|
515
|
-
children: [/* @__PURE__ */
|
|
517
|
+
children: [/* @__PURE__ */ m(f, { className: "h-3.5 w-3.5 shrink-0 text-success" }), /* @__PURE__ */ m("span", {
|
|
516
518
|
className: "truncate",
|
|
517
|
-
children: b("healthybowl.fieldMap.search.pendingLocation", "Unsaved field GPS: {{place}}", { place:
|
|
519
|
+
children: b("healthybowl.fieldMap.search.pendingLocation", "Unsaved field GPS: {{place}}", { place: K.label })
|
|
518
520
|
})]
|
|
519
521
|
})
|
|
520
522
|
})]
|
|
521
523
|
}),
|
|
522
|
-
/* @__PURE__ */
|
|
523
|
-
ref:
|
|
524
|
+
/* @__PURE__ */ m("input", {
|
|
525
|
+
ref: C,
|
|
524
526
|
type: "file",
|
|
525
527
|
accept: ".json,.geojson,application/geo+json,application/json",
|
|
526
528
|
className: "hidden",
|
|
527
529
|
onChange: (e) => {
|
|
528
530
|
let t = e.target.files?.[0];
|
|
529
|
-
t &&
|
|
531
|
+
t && $e(t), e.target.value = "";
|
|
530
532
|
}
|
|
531
533
|
}),
|
|
532
|
-
/* @__PURE__ */
|
|
534
|
+
/* @__PURE__ */ h("div", {
|
|
533
535
|
className: "relative",
|
|
534
536
|
children: [
|
|
535
|
-
/* @__PURE__ */
|
|
536
|
-
ref:
|
|
537
|
+
/* @__PURE__ */ m("div", {
|
|
538
|
+
ref: w,
|
|
537
539
|
className: "h-[60vh] max-h-[520px] w-full overflow-hidden rounded-md border border-border-subtle bg-bg-sunken"
|
|
538
540
|
}),
|
|
539
|
-
|
|
541
|
+
I === "loading" && /* @__PURE__ */ m("div", {
|
|
540
542
|
className: "pointer-events-none absolute inset-0 flex items-center justify-center rounded-md bg-bg-surface/60 text-sm text-text-secondary",
|
|
541
543
|
children: b("healthybowl.fieldMap.loading", "Loading map…")
|
|
542
544
|
}),
|
|
543
|
-
|
|
545
|
+
I === "error" && /* @__PURE__ */ m("div", {
|
|
544
546
|
className: "pointer-events-none absolute inset-0 flex items-center justify-center rounded-md bg-bg-surface/80 px-4 text-center text-sm text-text-secondary",
|
|
545
547
|
children: b("healthybowl.fieldMap.error", "The map needs an internet connection and couldn’t load.")
|
|
546
548
|
}),
|
|
547
|
-
|
|
549
|
+
I === "ready" && !z && L === "view" && /* @__PURE__ */ m("div", {
|
|
548
550
|
className: "pointer-events-none absolute left-1/2 top-3 z-[400] -translate-x-1/2 rounded-full bg-bg-surface/90 px-3 py-1.5 text-xs text-text-secondary shadow-sm",
|
|
549
|
-
children: /* @__PURE__ */
|
|
551
|
+
children: /* @__PURE__ */ h("span", {
|
|
550
552
|
className: "inline-flex items-center gap-1.5",
|
|
551
553
|
children: [
|
|
552
|
-
/* @__PURE__ */
|
|
554
|
+
/* @__PURE__ */ m(f, { className: "h-3.5 w-3.5" }),
|
|
553
555
|
" ",
|
|
554
556
|
b("healthybowl.fieldMap.empty", "No boundary set — draw or import one.")
|
|
555
557
|
]
|
|
@@ -557,11 +559,11 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
|
|
|
557
559
|
})
|
|
558
560
|
]
|
|
559
561
|
}),
|
|
560
|
-
/* @__PURE__ */
|
|
562
|
+
/* @__PURE__ */ m("p", {
|
|
561
563
|
className: "mt-2 text-xs text-text-secondary",
|
|
562
564
|
children: b("healthybowl.fieldMap.attribution", "Imagery © Esri, Maxar, Earthstar Geographics · overlays © OpenTopoMap / OpenStreetMap")
|
|
563
565
|
}),
|
|
564
|
-
/* @__PURE__ */
|
|
566
|
+
/* @__PURE__ */ m(n, {
|
|
565
567
|
toasts: Oe,
|
|
566
568
|
onDismiss: ke
|
|
567
569
|
})
|
|
@@ -569,6 +571,6 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
|
|
|
569
571
|
});
|
|
570
572
|
};
|
|
571
573
|
//#endregion
|
|
572
|
-
export {
|
|
574
|
+
export { Te as FieldMap };
|
|
573
575
|
|
|
574
576
|
//# sourceMappingURL=FieldMap.js.map
|