@burdenoff/microfe-timecampus 2026.1117.1 → 2026.1122.1

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.
@@ -1,67 +1,110 @@
1
1
  import { PageLayout as e } from "../../components/PageLayout.js";
2
2
  import { StatCard as t } from "../../components/StatCard.js";
3
- import { EmptyState as n } from "../../components/EmptyState.js";
4
- import { LoadingSkeleton as r } from "../../components/LoadingSkeleton.js";
5
- import { Modal as i } from "../../components/Modal.js";
3
+ import { LoadingSkeleton as n } from "../../components/LoadingSkeleton.js";
4
+ import { Modal as r } from "../../components/Modal.js";
6
5
  import "../../components/index.js";
7
- import { cn as a, formatRelativeTime as ee } from "../../utils/helpers.js";
8
- import { ChartCard as o } from "../../components/ChartCard.js";
9
- import { BarsChart as s } from "../../components/charts/BarsChart.js";
10
- import { DonutChart as te } from "../../components/charts/DonutChart.js";
11
- import { useCreateGeofenceMutation as ne, useDeleteGeofenceMutation as c, useListGeofencesQuery as l, useToggleGeofenceMutation as u, useUpdateGeofenceMutation as d } from "../../../generated/wspace-operations.js";
12
- import { GeofenceEventType as f, GeofenceTrigger as p } from "../../../generated/wspace-types.js";
13
- import { useState as m } from "react";
14
- import { LogIn as h, LogOut as g, MapPin as _, Pencil as re, Plus as ie, Radio as ae, ShieldCheck as v, Trash2 as y } from "lucide-react";
15
- import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
16
- import { GlassCard as C } from "@burdenoff/fe-libs/ui";
6
+ import "../../components/maps/index.js";
7
+ import { ChartCard as i } from "../../components/ChartCard.js";
8
+ import { BarsChart as a } from "../../components/charts/BarsChart.js";
9
+ import { DonutChart as o } from "../../components/charts/DonutChart.js";
10
+ import { cn as s, formatRelativeTime as ee } from "../../utils/helpers.js";
11
+ import { useCreateGeofenceMutation as te, useDeleteGeofenceMutation as ne, useListGeofencesQuery as re, useToggleGeofenceMutation as ie, useUpdateGeofenceMutation as ae } from "../../../generated/wspace-operations.js";
12
+ import { DEFAULT_MAP_CENTER as c, MAX_GEOFENCE_RADIUS_METERS as oe, clampGeofenceRadius as l, formatCoordinates as se, formatRadius as u, isValidGeofenceGeometry as d, parseStrictNumber as f, roundCoordinate as p, validateGeofenceForm as ce } from "../../components/maps/locationGeometry.js";
13
+ import { LocationGeofenceMap as le } from "../../components/maps/LocationGeofenceMap.js";
14
+ import { GeofenceEventType as m, GeofenceTrigger as h } from "../../../generated/wspace-types.js";
15
+ import { useMemo as g, useState as _ } from "react";
16
+ import { Crosshair as ue, LogIn as v, LogOut as y, MapPin as b, Pencil as de, Plus as fe, Radio as pe, Search as me, ShieldCheck as he, Trash2 as ge, X as x } from "lucide-react";
17
+ import { Fragment as _e, jsx as S, jsxs as C } from "react/jsx-runtime";
18
+ import { GlassCard as w } from "@burdenoff/fe-libs/ui";
17
19
  // src/timecampus/pages/geofencing/GeofencingPage.tsx
18
- var w = 25, T = {
20
+ var T = 25, E = 5e3, D = {
19
21
  name: "",
20
- latitude: "",
21
- longitude: "",
22
- radius: "100",
23
- trigger: p.Both,
22
+ latitude: String(c[0]),
23
+ longitude: String(c[1]),
24
+ radius: "150",
25
+ trigger: h.Both,
24
26
  address: "",
25
27
  isActive: !0
26
- }, E = "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";
27
- function D({ checked: e, onChange: t, label: n, disabled: r }) {
28
- return /* @__PURE__ */ x("button", {
28
+ }, O = "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-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus";
29
+ function k({ checked: e, onChange: t, label: n, disabled: r }) {
30
+ return /* @__PURE__ */ S("button", {
29
31
  type: "button",
30
32
  role: "switch",
31
33
  "aria-checked": e,
32
34
  "aria-label": n,
33
35
  disabled: r,
34
36
  onClick: () => t(!e),
35
- className: a("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border transition-colors disabled:cursor-not-allowed disabled:opacity-50", e ? "border-transparent bg-action-primary-bg" : "border-border-subtle bg-bg-sunken"),
36
- children: /* @__PURE__ */ x("span", { className: a("inline-block h-3.5 w-3.5 transform rounded-full shadow-sm transition-transform", e ? "translate-x-4 bg-action-primary-text" : "translate-x-0.5 bg-text-secondary") })
37
+ className: s("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus disabled:cursor-not-allowed disabled:opacity-50", e ? "border-transparent bg-action-primary-bg" : "border-border-subtle bg-bg-sunken"),
38
+ children: /* @__PURE__ */ S("span", { className: s("inline-block h-3.5 w-3.5 transform rounded-full shadow-sm transition-transform", e ? "translate-x-4 bg-action-primary-text" : "translate-x-0.5 bg-text-secondary") })
37
39
  });
38
40
  }
39
- function O() {
40
- let { data: O, loading: k, error: A, refetch: j, fetchMore: oe } = l({ variables: { pagination: {
41
- limit: w,
41
+ function A(e, t) {
42
+ return e instanceof Error && e.message.trim() ? e.message : t;
43
+ }
44
+ function j() {
45
+ let { data: j, loading: ve, error: ye, refetch: M, fetchMore: be } = re({ variables: { pagination: {
46
+ limit: T,
42
47
  offset: 0
43
- } } }), [se, { loading: M, error: ce }] = ne(), [N, { loading: P, error: F }] = d(), [I, { loading: L }] = c(), [R] = u(), [z, B] = m(!1), [V, H] = m(null), [U, W] = m(T), [G, K] = m(null), [q, J] = m(!1), Y = O?.geofences?.items ?? [], le = O?.geofences?.hasMore ?? !1, ue = O?.geofences?.total ?? Y.length, de = Y.filter((e) => e.isActive).length, X = 0, Z = 0;
44
- for (let e of Y) for (let t of e.events) t.type === f.Enter ? X += 1 : Z += 1;
45
- let fe = [
48
+ } } }), [xe, { loading: Se }] = te(), [N, { loading: P }] = ae(), [Ce, { loading: F }] = ne(), [we] = ie(), [I, L] = _(!1), [R, z] = _(null), [B, V] = _(D), [H, U] = _({}), [W, G] = _(null), [K, q] = _(null), [J, Y] = _(null), [X, Te] = _(""), [Ee, De] = _(!1), Z = g(() => j?.geofences?.items ?? [], [j?.geofences?.items]), Oe = j?.geofences?.hasMore ?? !1, ke = j?.geofences?.total ?? Z.length, Ae = g(() => {
49
+ let e = X.trim().toLowerCase();
50
+ return e ? Z.filter((t) => t.name.toLowerCase().includes(e) || (t.address ?? "").toLowerCase().includes(e)) : Z;
51
+ }, [Z, X]), je = g(() => Z.filter((e) => !R || e.id !== R.id).map((e) => ({
52
+ id: e.id,
53
+ name: e.name,
54
+ latitude: e.latitude,
55
+ longitude: e.longitude,
56
+ radius: e.radius,
57
+ isActive: e.isActive,
58
+ trigger: e.trigger,
59
+ address: e.address,
60
+ eventsCount: e.events.length
61
+ })), [R, Z]), Me = g(() => {
62
+ if (!I) return null;
63
+ let e = f(B.latitude), t = f(B.longitude), n = f(B.radius);
64
+ return e === null || t === null || n === null || !d({
65
+ latitude: e,
66
+ longitude: t,
67
+ radius: n
68
+ }) ? null : {
69
+ latitude: e,
70
+ longitude: t,
71
+ radius: n,
72
+ name: B.name.trim() || void 0
73
+ };
74
+ }, [
75
+ I,
76
+ B.latitude,
77
+ B.longitude,
78
+ B.name,
79
+ B.radius
80
+ ]), Ne = Z.filter((e) => e.isActive).length, Pe = 0, Fe = 0;
81
+ for (let e of Z) for (let t of e.events) t.type === m.Enter ? Pe += 1 : Fe += 1;
82
+ let Ie = [
46
83
  {
47
84
  name: "Entry & exit",
48
- value: Y.filter((e) => e.trigger === p.Both).length
85
+ value: Z.filter((e) => e.trigger === h.Both).length
49
86
  },
50
87
  {
51
88
  name: "On entry",
52
- value: Y.filter((e) => e.trigger === p.Enter).length
89
+ value: Z.filter((e) => e.trigger === h.Enter).length
53
90
  },
54
91
  {
55
92
  name: "On exit",
56
- value: Y.filter((e) => e.trigger === p.Exit).length
93
+ value: Z.filter((e) => e.trigger === h.Exit).length
57
94
  }
58
- ], pe = Y.map((e) => ({
95
+ ], Le = Z.map((e) => ({
59
96
  zone: e.name,
60
97
  events: e.events.length
61
- })).filter((e) => e.events > 0).sort((e, t) => t.events - e.events).slice(0, 8), me = () => {
62
- H(null), W(T), B(!0);
63
- }, he = (e) => {
64
- H(e), W({
98
+ })).filter((e) => e.events > 0).sort((e, t) => t.events - e.events).slice(0, 8), Q = () => {
99
+ z(null), U({}), G(null);
100
+ let e = Z.find((e) => d(e));
101
+ V({
102
+ ...D,
103
+ latitude: String(p(e ? e.latitude : c[0])),
104
+ longitude: String(p(e ? e.longitude : c[1]))
105
+ }), L(!0);
106
+ }, Re = (e) => {
107
+ z(e), Y(e.id), U({}), G(null), V({
65
108
  name: e.name,
66
109
  latitude: String(e.latitude),
67
110
  longitude: String(e.longitude),
@@ -69,43 +112,93 @@ function O() {
69
112
  trigger: e.trigger,
70
113
  address: e.address ?? "",
71
114
  isActive: e.isActive
72
- }), B(!0);
73
- }, ge = async () => {
74
- if (!U.name.trim()) return;
75
- let e = {
76
- name: U.name.trim(),
77
- latitude: Number(U.latitude),
78
- longitude: Number(U.longitude),
79
- radius: Number(U.radius),
80
- trigger: U.trigger,
81
- address: U.address.trim() || void 0,
82
- isActive: U.isActive
115
+ }), L(!0);
116
+ }, $ = () => {
117
+ L(!1), z(null), U({}), G(null);
118
+ }, ze = (e) => {
119
+ V((t) => ({
120
+ ...t,
121
+ latitude: String(p(e.latitude)),
122
+ longitude: String(p(e.longitude)),
123
+ radius: String(l(e.radius))
124
+ })), U((e) => ({
125
+ ...e,
126
+ latitude: void 0,
127
+ longitude: void 0,
128
+ radius: void 0
129
+ }));
130
+ }, Be = async () => {
131
+ G(null);
132
+ let e = ce(B);
133
+ if (!e.valid || !e.parsed) {
134
+ U(e.errors);
135
+ return;
136
+ }
137
+ U({});
138
+ let t = {
139
+ name: e.parsed.name,
140
+ latitude: e.parsed.latitude,
141
+ longitude: e.parsed.longitude,
142
+ radius: e.parsed.radius,
143
+ trigger: B.trigger,
144
+ address: B.address.trim() || void 0,
145
+ isActive: B.isActive
83
146
  };
84
- V ? await N({ variables: {
85
- id: V.id,
86
- input: e
87
- } }) : await se({ variables: { input: e } }), B(!1), await j();
88
- }, _e = async () => {
89
- G && (await I({ variables: { id: G.id } }), K(null), await j());
90
- }, ve = async (e) => {
91
- await R({ variables: {
92
- id: e.id,
93
- isActive: !e.isActive
94
- } }), await j();
95
- }, Q = async (e, t, n) => {
147
+ try {
148
+ if (R) {
149
+ let e = (await N({ variables: {
150
+ id: R.id,
151
+ input: t
152
+ } })).data?.updateGeofence?.id ?? R.id;
153
+ Y(e);
154
+ } else {
155
+ let e = (await xe({ variables: { input: t } })).data?.createGeofence?.id ?? null;
156
+ e && Y(e);
157
+ }
158
+ L(!1), z(null), await M();
159
+ } catch (e) {
160
+ G(A(e, "Failed to save geofence. Check permissions and values, then try again."));
161
+ }
162
+ }, Ve = async () => {
163
+ if (K) {
164
+ G(null);
165
+ try {
166
+ await Ce({ variables: { id: K.id } }), J === K.id && Y(null), q(null), await M();
167
+ } catch (e) {
168
+ G(A(e, "Failed to delete geofence. You may not have permission to modify zones.")), q(null);
169
+ }
170
+ }
171
+ }, He = async (e) => {
172
+ G(null);
173
+ try {
174
+ await we({ variables: {
175
+ id: e.id,
176
+ isActive: !e.isActive
177
+ } }), await M();
178
+ } catch (e) {
179
+ G(A(e, "Failed to update geofence active state."));
180
+ }
181
+ }, Ue = async (e, t, n) => {
96
182
  if (!t && !n) return;
97
- let r = t && n ? p.Both : t ? p.Enter : p.Exit;
98
- r !== e.trigger && (await N({ variables: {
99
- id: e.id,
100
- input: { trigger: r }
101
- } }), await j());
102
- }, ye = async () => {
103
- J(!0);
183
+ let r = t && n ? h.Both : t ? h.Enter : h.Exit;
184
+ if (r !== e.trigger) {
185
+ G(null);
186
+ try {
187
+ await N({ variables: {
188
+ id: e.id,
189
+ input: { trigger: r }
190
+ } }), await M();
191
+ } catch (e) {
192
+ G(A(e, "Failed to update geofence trigger."));
193
+ }
194
+ }
195
+ }, We = async () => {
196
+ De(!0);
104
197
  try {
105
- await oe({
198
+ await be({
106
199
  variables: { pagination: {
107
- limit: w,
108
- offset: Y.length
200
+ limit: T,
201
+ offset: Z.length
109
202
  } },
110
203
  updateQuery: (e, { fetchMoreResult: t }) => t ? { geofences: {
111
204
  ...t.geofences,
@@ -113,403 +206,630 @@ function O() {
113
206
  } } : e
114
207
  });
115
208
  } finally {
116
- J(!1);
209
+ De(!1);
117
210
  }
118
- }, $ = /* @__PURE__ */ S("button", {
119
- onClick: me,
120
- className: "inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90",
121
- children: [/* @__PURE__ */ x(ie, { className: "h-4 w-4" }), "Create Geofence"]
211
+ }, Ge = /* @__PURE__ */ C("button", {
212
+ type: "button",
213
+ onClick: I ? $ : Q,
214
+ className: "inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
215
+ children: [S(I ? x : fe, { className: "h-4 w-4" }), I ? "Close Editor" : "Create Geofence"]
122
216
  });
123
- return k ? /* @__PURE__ */ x(e, {
217
+ if (ve) return /* @__PURE__ */ S(e, {
124
218
  title: "Geofencing",
125
219
  description: "Set up location-based triggers and zones",
126
- children: /* @__PURE__ */ x(r, {
220
+ children: /* @__PURE__ */ S(n, {
127
221
  variant: "card",
128
222
  count: 4
129
223
  })
130
- }) : A ? /* @__PURE__ */ x(e, {
224
+ });
225
+ if (ye) return /* @__PURE__ */ S(e, {
131
226
  title: "Geofencing",
132
227
  description: "Set up location-based triggers and zones",
133
- children: /* @__PURE__ */ x("div", {
228
+ children: /* @__PURE__ */ S("div", {
229
+ role: "alert",
134
230
  className: "rounded-lg border border-status-error-bg/40 bg-status-error-bg p-4 text-sm text-status-error-text",
135
- children: "Failed to load geofences. Please try again later."
231
+ children: "Failed to load geofences. Please check workspace permissions or try again later."
136
232
  })
137
- }) : /* @__PURE__ */ S(e, {
233
+ });
234
+ let Ke = l(f(B.radius) ?? 150);
235
+ return /* @__PURE__ */ C(e, {
138
236
  title: "Geofencing",
139
237
  description: "Set up location-based triggers and zones",
140
238
  purpose: "Draw zones around your worksites — offices, client sites, job locations — and have time tracking start and stop automatically as people move in and out, so on-site hours record themselves.",
141
- actions: $,
239
+ actions: Ge,
142
240
  children: [
143
- Y.length === 0 ? /* @__PURE__ */ x(n, {
144
- illustration: "empty-generic",
145
- title: "No geofences configured yet",
146
- description: "Create your first zone to trigger automatic time tracking when people arrive or leave a location.",
147
- action: $
148
- }) : /* @__PURE__ */ S(b, { children: [
149
- /* @__PURE__ */ S("div", {
150
- className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
151
- children: [
152
- /* @__PURE__ */ x(t, {
153
- featured: !0,
154
- title: "Total Zones",
155
- value: String(ue),
156
- icon: /* @__PURE__ */ x(_, { className: "h-5 w-5" })
157
- }),
158
- /* @__PURE__ */ x(t, {
159
- title: "Active Zones",
160
- value: String(de),
161
- icon: /* @__PURE__ */ x(ae, { className: "h-5 w-5" }),
162
- description: "Currently tracking"
163
- }),
164
- /* @__PURE__ */ x(t, {
165
- title: "Entry Events",
166
- value: String(X),
167
- icon: /* @__PURE__ */ x(h, { className: "h-5 w-5" })
168
- }),
169
- /* @__PURE__ */ x(t, {
170
- title: "Exit Events",
171
- value: String(Z),
172
- icon: /* @__PURE__ */ x(g, { className: "h-5 w-5" })
173
- })
174
- ]
175
- }),
176
- /* @__PURE__ */ S("div", {
177
- className: "mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",
178
- children: [/* @__PURE__ */ x(o, {
179
- title: "Trigger configuration",
180
- description: "How your zones fire",
181
- children: /* @__PURE__ */ x(te, {
182
- data: fe,
183
- centerLabel: "Zones",
184
- centerValue: Y.length,
185
- ariaLabel: "Geofence trigger configuration mix",
186
- emptyLabel: "No zones to summarize yet"
187
- })
188
- }), /* @__PURE__ */ x(o, {
189
- title: "Activity by zone",
190
- description: "Recorded enter/exit events per zone",
191
- children: /* @__PURE__ */ x(s, {
192
- data: pe,
193
- xKey: "zone",
194
- orientation: "horizontal",
195
- series: [{
196
- key: "events",
197
- label: "Events"
198
- }],
199
- categoryWidth: 120,
200
- ariaLabel: "Recorded events by zone",
201
- emptyLabel: "No geofence events recorded yet"
202
- })
241
+ W && !I && /* @__PURE__ */ C("div", {
242
+ role: "alert",
243
+ className: "mb-4 flex items-center justify-between gap-3 rounded-lg border border-status-error-bg/40 bg-status-error-bg p-3 text-sm text-status-error-text",
244
+ children: [/* @__PURE__ */ S("span", { children: W }), /* @__PURE__ */ S("button", {
245
+ type: "button",
246
+ onClick: () => G(null),
247
+ "aria-label": "Dismiss error",
248
+ className: "rounded p-1 hover:bg-bg-surface/20",
249
+ children: /* @__PURE__ */ S(x, { className: "h-4 w-4" })
250
+ })]
251
+ }),
252
+ /* @__PURE__ */ C("div", {
253
+ className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
254
+ children: [
255
+ /* @__PURE__ */ S(t, {
256
+ featured: !0,
257
+ title: "Total Zones",
258
+ value: String(ke),
259
+ icon: /* @__PURE__ */ S(b, { className: "h-5 w-5" })
260
+ }),
261
+ /* @__PURE__ */ S(t, {
262
+ title: "Active Zones",
263
+ value: String(Ne),
264
+ icon: /* @__PURE__ */ S(pe, { className: "h-5 w-5" }),
265
+ description: "Currently tracking"
266
+ }),
267
+ /* @__PURE__ */ S(t, {
268
+ title: "Entry Events",
269
+ value: String(Pe),
270
+ icon: /* @__PURE__ */ S(v, { className: "h-5 w-5" })
271
+ }),
272
+ /* @__PURE__ */ S(t, {
273
+ title: "Exit Events",
274
+ value: String(Fe),
275
+ icon: /* @__PURE__ */ S(y, { className: "h-5 w-5" })
276
+ })
277
+ ]
278
+ }),
279
+ /* @__PURE__ */ C("div", {
280
+ className: "mt-6 grid grid-cols-1 gap-6 lg:grid-cols-12",
281
+ children: [/* @__PURE__ */ C("div", {
282
+ className: "min-w-0 lg:col-span-7 xl:col-span-8",
283
+ children: [/* @__PURE__ */ C("div", {
284
+ className: "mb-3 flex flex-wrap items-center justify-between gap-2",
285
+ children: [/* @__PURE__ */ C("div", {
286
+ className: "min-w-0",
287
+ children: [/* @__PURE__ */ S("h2", {
288
+ className: "text-base font-semibold text-text-primary",
289
+ children: "Geofence Map"
290
+ }), /* @__PURE__ */ S("p", {
291
+ className: "text-xs text-text-secondary",
292
+ children: I ? "Click on the map to place the center, or drag the center pin and outer radius handle." : "Select any zone on the map or list to inspect boundaries and triggers."
293
+ })]
294
+ }), !I && /* @__PURE__ */ C("button", {
295
+ type: "button",
296
+ onClick: Q,
297
+ className: "inline-flex items-center gap-1.5 rounded-md border border-border-subtle bg-bg-surface px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
298
+ children: [/* @__PURE__ */ S(ue, { className: "h-3.5 w-3.5" }), "Draw Zone on Map"]
299
+ })]
300
+ }), /* @__PURE__ */ S(le, {
301
+ geofences: je,
302
+ selectedGeofenceId: I ? null : J,
303
+ onSelectGeofence: (e) => Y(e),
304
+ draftGeofence: Me,
305
+ interactiveMode: I ? "place-geofence" : "view",
306
+ onDraftGeofenceChange: ze,
307
+ heightClassName: "h-[320px] sm:h-[420px] lg:h-[560px]",
308
+ ariaLabel: "Geofence zones map",
309
+ testId: "geofencing-map"
203
310
  })]
204
- }),
205
- /* @__PURE__ */ x("div", {
206
- className: "mt-6 grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",
207
- children: Y.map((e) => {
208
- let t = e.trigger === p.Enter || e.trigger === p.Both, n = e.trigger === p.Exit || e.trigger === p.Both, r = e.events.filter((e) => e.type === f.Enter).length, i = e.events.length - r, o = e.events.reduce((e, t) => t.timestamp > e ? t.timestamp : e, "");
209
- return /* @__PURE__ */ S(C, {
210
- treatment: "glass",
211
- glow: e.isActive,
212
- className: "flex flex-col p-5",
213
- children: [
214
- /* @__PURE__ */ S("div", {
215
- className: "flex items-start justify-between gap-3",
216
- children: [/* @__PURE__ */ S("div", {
217
- className: "flex min-w-0 items-start gap-2",
218
- children: [/* @__PURE__ */ x("span", {
219
- className: "mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary",
220
- children: /* @__PURE__ */ x(_, { className: "h-5 w-5" })
221
- }), /* @__PURE__ */ S("div", {
222
- className: "min-w-0",
223
- children: [/* @__PURE__ */ x("p", {
224
- className: "truncate text-sm font-semibold text-text-primary",
225
- children: e.name
226
- }), /* @__PURE__ */ S("p", {
227
- className: "truncate text-xs text-text-secondary",
228
- children: [
229
- e.address ?? "No address",
230
- " ·",
231
- " ",
232
- e.radius,
233
- "m radius"
234
- ]
311
+ }), /* @__PURE__ */ C("div", {
312
+ className: "flex min-w-0 flex-col gap-4 lg:col-span-5 xl:col-span-4",
313
+ children: [I ? /* @__PURE__ */ C(w, {
314
+ treatment: "glass",
315
+ className: "flex flex-col p-5",
316
+ "data-testid": "geofence-editor-panel",
317
+ children: [
318
+ /* @__PURE__ */ C("div", {
319
+ className: "flex items-start justify-between gap-3 border-b border-border-seam pb-3",
320
+ children: [/* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("h2", {
321
+ className: "text-base font-semibold text-text-primary",
322
+ children: R ? "Edit Geofence" : "Create Geofence"
323
+ }), /* @__PURE__ */ S("p", {
324
+ className: "mt-0.5 text-xs text-text-secondary",
325
+ children: "Place on the map or enter exact WGS-84 coordinates."
326
+ })] }), /* @__PURE__ */ S("button", {
327
+ type: "button",
328
+ onClick: $,
329
+ "aria-label": "Close geofence editor",
330
+ className: "rounded-md p-1 text-text-secondary hover:bg-bg-sunken hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
331
+ children: /* @__PURE__ */ S(x, { className: "h-4 w-4" })
332
+ })]
333
+ }),
334
+ W && /* @__PURE__ */ S("div", {
335
+ role: "alert",
336
+ className: "mt-3 rounded-lg border border-status-error-bg/40 bg-status-error-bg p-3 text-xs text-status-error-text",
337
+ children: W
338
+ }),
339
+ /* @__PURE__ */ C("form", {
340
+ className: "mt-4 space-y-3.5",
341
+ onSubmit: (e) => {
342
+ e.preventDefault(), Be();
343
+ },
344
+ noValidate: !0,
345
+ children: [
346
+ /* @__PURE__ */ C("div", { children: [
347
+ /* @__PURE__ */ S("label", {
348
+ htmlFor: "geofence-name",
349
+ className: "block text-xs font-medium text-text-primary",
350
+ children: "Name"
351
+ }),
352
+ /* @__PURE__ */ S("input", {
353
+ id: "geofence-name",
354
+ type: "text",
355
+ placeholder: "e.g. SF Headquarters",
356
+ value: B.name,
357
+ onChange: (e) => {
358
+ V({
359
+ ...B,
360
+ name: e.target.value
361
+ }), U((e) => ({
362
+ ...e,
363
+ name: void 0
364
+ }));
365
+ },
366
+ className: O
367
+ }),
368
+ H.name && /* @__PURE__ */ S("p", {
369
+ role: "alert",
370
+ className: "mt-1 text-xs text-status-error-text",
371
+ children: H.name
372
+ })
373
+ ] }),
374
+ /* @__PURE__ */ C("div", {
375
+ className: "grid grid-cols-1 gap-3 sm:grid-cols-2",
376
+ children: [/* @__PURE__ */ C("div", { children: [
377
+ /* @__PURE__ */ S("label", {
378
+ htmlFor: "geofence-lat",
379
+ className: "block text-xs font-medium text-text-primary",
380
+ children: "Latitude"
381
+ }),
382
+ /* @__PURE__ */ S("input", {
383
+ id: "geofence-lat",
384
+ type: "number",
385
+ step: "any",
386
+ min: -90,
387
+ max: 90,
388
+ placeholder: "37.774900",
389
+ value: B.latitude,
390
+ onChange: (e) => {
391
+ V({
392
+ ...B,
393
+ latitude: e.target.value
394
+ }), U((e) => ({
395
+ ...e,
396
+ latitude: void 0
397
+ }));
398
+ },
399
+ className: O
400
+ }),
401
+ H.latitude && /* @__PURE__ */ S("p", {
402
+ role: "alert",
403
+ className: "mt-1 text-xs text-status-error-text",
404
+ children: H.latitude
405
+ })
406
+ ] }), /* @__PURE__ */ C("div", { children: [
407
+ /* @__PURE__ */ S("label", {
408
+ htmlFor: "geofence-lng",
409
+ className: "block text-xs font-medium text-text-primary",
410
+ children: "Longitude"
411
+ }),
412
+ /* @__PURE__ */ S("input", {
413
+ id: "geofence-lng",
414
+ type: "number",
415
+ step: "any",
416
+ min: -180,
417
+ max: 180,
418
+ placeholder: "-122.419400",
419
+ value: B.longitude,
420
+ onChange: (e) => {
421
+ V({
422
+ ...B,
423
+ longitude: e.target.value
424
+ }), U((e) => ({
425
+ ...e,
426
+ longitude: void 0
427
+ }));
428
+ },
429
+ className: O
430
+ }),
431
+ H.longitude && /* @__PURE__ */ S("p", {
432
+ role: "alert",
433
+ className: "mt-1 text-xs text-status-error-text",
434
+ children: H.longitude
435
+ })
436
+ ] })]
437
+ }),
438
+ /* @__PURE__ */ C("div", { children: [
439
+ /* @__PURE__ */ C("div", {
440
+ className: "flex items-center justify-between",
441
+ children: [/* @__PURE__ */ S("label", {
442
+ htmlFor: "geofence-radius",
443
+ className: "block text-xs font-medium text-text-primary",
444
+ children: "Radius (meters)"
445
+ }), /* @__PURE__ */ S("span", {
446
+ className: "font-mono text-xs text-text-secondary",
447
+ children: u(Ke)
235
448
  })]
236
- })]
237
- }), /* @__PURE__ */ S("div", {
238
- className: "flex shrink-0 flex-col items-end gap-1",
239
- children: [/* @__PURE__ */ x(D, {
240
- checked: e.isActive,
241
- onChange: () => ve(e),
242
- label: `Toggle ${e.name} active`
243
- }), /* @__PURE__ */ x("span", {
244
- className: a("text-xs font-medium", e.isActive ? "text-status-success-text" : "text-text-muted"),
245
- children: e.isActive ? "Active" : "Inactive"
246
- })]
247
- })]
248
- }),
249
- /* @__PURE__ */ S("div", {
250
- className: "mt-4 grid grid-cols-2 gap-2",
251
- children: [/* @__PURE__ */ S("div", {
449
+ }),
450
+ /* @__PURE__ */ C("div", {
451
+ className: "mt-1 flex items-center gap-2",
452
+ children: [/* @__PURE__ */ S("input", {
453
+ id: "geofence-radius",
454
+ type: "number",
455
+ min: 10,
456
+ max: oe,
457
+ value: B.radius,
458
+ onChange: (e) => {
459
+ V({
460
+ ...B,
461
+ radius: e.target.value
462
+ }), U((e) => ({
463
+ ...e,
464
+ radius: void 0
465
+ }));
466
+ },
467
+ className: "w-28 rounded-md border border-border-subtle bg-bg-surface px-2.5 py-1.5 text-sm text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus"
468
+ }), /* @__PURE__ */ S("input", {
469
+ type: "range",
470
+ "aria-label": "Adjust geofence radius",
471
+ min: 10,
472
+ max: E,
473
+ step: 10,
474
+ value: Math.min(E, Ke),
475
+ onChange: (e) => {
476
+ V({
477
+ ...B,
478
+ radius: e.target.value
479
+ }), U((e) => ({
480
+ ...e,
481
+ radius: void 0
482
+ }));
483
+ },
484
+ className: "h-2 flex-1 cursor-pointer accent-action-primary-bg"
485
+ })]
486
+ }),
487
+ H.radius && /* @__PURE__ */ S("p", {
488
+ role: "alert",
489
+ className: "mt-1 text-xs text-status-error-text",
490
+ children: H.radius
491
+ })
492
+ ] }),
493
+ /* @__PURE__ */ C("div", {
494
+ className: "grid grid-cols-1 gap-3 sm:grid-cols-2",
495
+ children: [/* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("label", {
496
+ htmlFor: "geofence-trigger",
497
+ className: "block text-xs font-medium text-text-primary",
498
+ children: "Trigger"
499
+ }), /* @__PURE__ */ C("select", {
500
+ id: "geofence-trigger",
501
+ value: B.trigger,
502
+ onChange: (e) => V({
503
+ ...B,
504
+ trigger: e.target.value
505
+ }),
506
+ className: O,
507
+ children: [
508
+ /* @__PURE__ */ S("option", {
509
+ value: h.Enter,
510
+ children: "On entry"
511
+ }),
512
+ /* @__PURE__ */ S("option", {
513
+ value: h.Exit,
514
+ children: "On exit"
515
+ }),
516
+ /* @__PURE__ */ S("option", {
517
+ value: h.Both,
518
+ children: "Entry & exit"
519
+ })
520
+ ]
521
+ })] }), /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("label", {
522
+ htmlFor: "geofence-address",
523
+ className: "block text-xs font-medium text-text-primary",
524
+ children: "Address (optional)"
525
+ }), /* @__PURE__ */ S("input", {
526
+ id: "geofence-address",
527
+ type: "text",
528
+ placeholder: "San Francisco, USA",
529
+ value: B.address,
530
+ onChange: (e) => V({
531
+ ...B,
532
+ address: e.target.value
533
+ }),
534
+ className: O
535
+ })] })]
536
+ }),
537
+ /* @__PURE__ */ C("label", {
252
538
  className: "flex items-center justify-between rounded-lg border border-border-subtle bg-bg-surface/60 px-3 py-2",
253
539
  children: [/* @__PURE__ */ S("span", {
254
- className: "flex items-center gap-1.5 text-xs font-medium text-text-secondary",
255
- children: [/* @__PURE__ */ x(h, { className: "h-3.5 w-3.5" }), "Enter"]
256
- }), /* @__PURE__ */ x(D, {
257
- checked: t,
258
- onChange: (t) => Q(e, t, n),
259
- label: `Enter trigger for ${e.name}`
540
+ className: "text-xs font-medium text-text-primary",
541
+ children: "Zone active"
542
+ }), /* @__PURE__ */ S("input", {
543
+ type: "checkbox",
544
+ checked: B.isActive,
545
+ onChange: (e) => V({
546
+ ...B,
547
+ isActive: e.target.checked
548
+ }),
549
+ className: "h-4 w-4 rounded border-border-subtle"
260
550
  })]
261
- }), /* @__PURE__ */ S("div", {
262
- className: "flex items-center justify-between rounded-lg border border-border-subtle bg-bg-surface/60 px-3 py-2",
263
- children: [/* @__PURE__ */ S("span", {
264
- className: "flex items-center gap-1.5 text-xs font-medium text-text-secondary",
265
- children: [/* @__PURE__ */ x(g, { className: "h-3.5 w-3.5" }), "Exit"]
266
- }), /* @__PURE__ */ x(D, {
267
- checked: n,
268
- onChange: (n) => Q(e, t, n),
269
- label: `Exit trigger for ${e.name}`
551
+ }),
552
+ /* @__PURE__ */ C("div", {
553
+ className: "flex items-center justify-end gap-2 border-t border-border-seam pt-3",
554
+ children: [/* @__PURE__ */ S("button", {
555
+ type: "button",
556
+ onClick: $,
557
+ className: "rounded-md border border-border-subtle px-3 py-2 text-xs font-medium text-text-primary hover:bg-bg-sunken/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
558
+ children: "Cancel"
559
+ }), /* @__PURE__ */ S("button", {
560
+ type: "submit",
561
+ disabled: Se || P,
562
+ className: "rounded-md bg-action-primary-bg px-4 py-2 text-xs font-medium text-action-primary-text hover:bg-action-primary-bg/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus disabled:opacity-50",
563
+ children: Se || P ? "Saving..." : R ? "Save Changes" : "Save Geofence"
270
564
  })]
271
- })]
272
- }),
273
- /* @__PURE__ */ S("div", {
274
- className: "mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-text-secondary",
565
+ })
566
+ ]
567
+ })
568
+ ]
569
+ }) : /* @__PURE__ */ C(w, {
570
+ treatment: "glass",
571
+ className: "flex flex-col p-4",
572
+ children: [
573
+ /* @__PURE__ */ C("div", {
574
+ className: "flex items-center justify-between gap-2 border-b border-border-seam pb-3",
575
+ children: [/* @__PURE__ */ C("h2", {
576
+ className: "text-base font-semibold text-text-primary",
275
577
  children: [
276
- /* @__PURE__ */ S("span", { children: [
277
- "Entries",
278
- " ",
279
- /* @__PURE__ */ x("span", {
280
- className: "font-semibold tabular-nums text-text-primary",
281
- children: r
282
- })
283
- ] }),
284
- /* @__PURE__ */ S("span", { children: [
285
- "Exits",
286
- " ",
287
- /* @__PURE__ */ x("span", {
288
- className: "font-semibold tabular-nums text-text-primary",
289
- children: i
290
- })
291
- ] }),
292
- o ? /* @__PURE__ */ S("span", {
293
- className: "ml-auto",
294
- children: [
295
- "Last",
296
- " ",
297
- /* @__PURE__ */ x("span", {
298
- className: "text-text-primary",
299
- children: ee(o)
300
- })
301
- ]
302
- }) : /* @__PURE__ */ x("span", {
303
- className: "ml-auto text-text-muted",
304
- children: "No events yet"
305
- })
578
+ "Geofences (",
579
+ ke,
580
+ ")"
306
581
  ]
307
- }),
308
- /* @__PURE__ */ S("div", {
309
- className: "mt-4 flex items-center gap-2 border-t border-border-seam pt-3",
310
- children: [/* @__PURE__ */ S("button", {
311
- onClick: () => he(e),
312
- className: "inline-flex items-center gap-1 rounded-md border border-border-subtle px-2 py-1 text-xs font-medium text-text-primary hover:bg-bg-sunken/50",
313
- children: [/* @__PURE__ */ x(re, { className: "h-3.5 w-3.5" }), "Edit"]
314
- }), /* @__PURE__ */ S("button", {
315
- onClick: () => K(e),
316
- className: "inline-flex items-center gap-1 rounded-md border border-border-subtle px-2 py-1 text-xs font-medium text-status-error-text hover:bg-status-error-bg",
317
- children: [/* @__PURE__ */ x(y, { className: "h-3.5 w-3.5" }), "Delete"]
318
- })]
319
- })
320
- ]
321
- }, e.id);
322
- })
323
- }),
324
- /* @__PURE__ */ x(C, {
325
- treatment: "insight",
326
- className: "mt-6 p-4",
327
- children: /* @__PURE__ */ S("div", {
328
- className: "flex items-start gap-3",
329
- children: [/* @__PURE__ */ x("span", {
330
- className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary",
331
- children: /* @__PURE__ */ x(v, { className: "h-5 w-5" })
332
- }), /* @__PURE__ */ S("div", {
333
- className: "min-w-0",
334
- children: [/* @__PURE__ */ x("p", {
335
- className: "text-sm font-medium text-text-primary",
336
- children: "Privacy first"
337
- }), /* @__PURE__ */ x("p", {
338
- className: "mt-0.5 text-xs text-text-secondary",
339
- children: "Time is recorded only when someone enters or leaves a zone you define — never through continuous background tracking. Location data stays encrypted and visible only within your workspace."
340
- })]
341
- })]
342
- })
343
- }),
344
- le && /* @__PURE__ */ x("div", {
345
- className: "mt-6 flex justify-center",
346
- children: /* @__PURE__ */ x("button", {
347
- onClick: ye,
348
- disabled: q,
349
- className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50 disabled:opacity-50",
350
- children: q ? "Loading..." : "Load more"
351
- })
352
- })
353
- ] }),
354
- /* @__PURE__ */ S(i, {
355
- open: z,
356
- onClose: () => B(!1),
357
- title: V ? "Edit Geofence" : "Create Geofence",
358
- description: "Define a zone that triggers automatic time tracking.",
359
- size: "lg",
360
- footer: /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x("button", {
361
- onClick: () => B(!1),
362
- className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50",
363
- children: "Cancel"
364
- }), /* @__PURE__ */ x("button", {
365
- onClick: ge,
366
- disabled: M || P || !U.name.trim(),
367
- className: "rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50",
368
- children: M || P ? "Saving..." : V ? "Save Changes" : "Create Geofence"
369
- })] }),
370
- children: [(ce || F) && /* @__PURE__ */ x("div", {
371
- className: "mb-4 rounded-lg border border-status-error-bg/40 bg-status-error-bg p-3 text-sm text-status-error-text",
372
- children: "Failed to save geofence. Please check the values and try again."
373
- }), /* @__PURE__ */ S("div", {
374
- className: "space-y-4",
375
- children: [
376
- /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
377
- className: "block text-sm font-medium text-text-primary",
378
- children: "Name"
379
- }), /* @__PURE__ */ x("input", {
380
- type: "text",
381
- placeholder: "e.g. Head Office",
382
- value: U.name,
383
- onChange: (e) => W({
384
- ...U,
385
- name: e.target.value
582
+ }), /* @__PURE__ */ C("button", {
583
+ type: "button",
584
+ onClick: Q,
585
+ className: "inline-flex items-center gap-1 rounded-md bg-action-primary-bg px-2.5 py-1.5 text-xs font-medium text-action-primary-text hover:bg-action-primary-bg/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
586
+ children: [/* @__PURE__ */ S(fe, { className: "h-3.5 w-3.5" }), "Add Geofence"]
587
+ })]
386
588
  }),
387
- className: E
388
- })] }),
389
- /* @__PURE__ */ S("div", {
390
- className: "grid grid-cols-1 gap-4 sm:grid-cols-2",
391
- children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
392
- className: "block text-sm font-medium text-text-primary",
393
- children: "Latitude"
394
- }), /* @__PURE__ */ x("input", {
395
- type: "number",
396
- step: "any",
397
- placeholder: "0.000000",
398
- value: U.latitude,
399
- onChange: (e) => W({
400
- ...U,
401
- latitude: e.target.value
402
- }),
403
- className: E
404
- })] }), /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
405
- className: "block text-sm font-medium text-text-primary",
406
- children: "Longitude"
407
- }), /* @__PURE__ */ x("input", {
408
- type: "number",
409
- step: "any",
410
- placeholder: "0.000000",
411
- value: U.longitude,
412
- onChange: (e) => W({
413
- ...U,
414
- longitude: e.target.value
415
- }),
416
- className: E
417
- })] })]
418
- }),
419
- /* @__PURE__ */ S("div", {
420
- className: "grid grid-cols-1 gap-4 sm:grid-cols-2",
421
- children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
422
- className: "block text-sm font-medium text-text-primary",
423
- children: "Radius (meters)"
424
- }), /* @__PURE__ */ x("input", {
425
- type: "number",
426
- placeholder: "100",
427
- value: U.radius,
428
- onChange: (e) => W({
429
- ...U,
430
- radius: e.target.value
431
- }),
432
- className: E
433
- })] }), /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
434
- className: "block text-sm font-medium text-text-primary",
435
- children: "Trigger"
436
- }), /* @__PURE__ */ S("select", {
437
- value: U.trigger,
438
- onChange: (e) => W({
439
- ...U,
440
- trigger: e.target.value
441
- }),
442
- className: E,
589
+ Z.length > 0 && /* @__PURE__ */ C("div", {
590
+ className: "relative mt-3",
591
+ children: [/* @__PURE__ */ S(me, { className: "pointer-events-none absolute left-2.5 top-2.5 h-3.5 w-3.5 text-text-muted" }), /* @__PURE__ */ S("input", {
592
+ type: "search",
593
+ "aria-label": "Filter geofences",
594
+ placeholder: "Filter zones by name or address...",
595
+ value: X,
596
+ onChange: (e) => Te(e.target.value),
597
+ className: "w-full rounded-md border border-border-subtle bg-bg-surface py-1.5 pl-8 pr-3 text-xs text-text-primary placeholder:text-text-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus"
598
+ })]
599
+ }),
600
+ Z.length === 0 ? /* @__PURE__ */ C("div", {
601
+ className: "mt-4 rounded-lg border border-dashed border-border-subtle bg-bg-surface/40 p-5 text-center",
443
602
  children: [
444
- /* @__PURE__ */ x("option", {
445
- value: p.Enter,
446
- children: "On entry"
603
+ /* @__PURE__ */ S(b, { className: "mx-auto h-7 w-7 text-text-muted" }),
604
+ /* @__PURE__ */ S("p", {
605
+ className: "mt-2 text-sm font-medium text-text-primary",
606
+ children: "No geofences configured yet"
447
607
  }),
448
- /* @__PURE__ */ x("option", {
449
- value: p.Exit,
450
- children: "On exit"
608
+ /* @__PURE__ */ S("p", {
609
+ className: "mt-1 text-xs text-text-secondary",
610
+ children: "Start drawing on the map to create your first worksite zone."
451
611
  }),
452
- /* @__PURE__ */ x("option", {
453
- value: p.Both,
454
- children: "Entry & exit"
612
+ /* @__PURE__ */ C("button", {
613
+ type: "button",
614
+ onClick: Q,
615
+ className: "mt-3 inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text hover:bg-action-primary-bg/90",
616
+ children: [/* @__PURE__ */ S(ue, { className: "h-3.5 w-3.5" }), "Place First Zone"]
455
617
  })
456
618
  ]
457
- })] })]
458
- }),
459
- /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
460
- className: "block text-sm font-medium text-text-primary",
461
- children: "Address (optional)"
462
- }), /* @__PURE__ */ x("input", {
463
- type: "text",
464
- placeholder: "Street address for reference",
465
- value: U.address,
466
- onChange: (e) => W({
467
- ...U,
468
- address: e.target.value
619
+ }) : Ae.length === 0 ? /* @__PURE__ */ C("p", {
620
+ className: "mt-4 text-center text-xs text-text-secondary",
621
+ children: [
622
+ "No geofences match “",
623
+ X,
624
+ "”."
625
+ ]
626
+ }) : /* @__PURE__ */ S("div", {
627
+ className: "mt-3 max-h-[430px] space-y-3 overflow-y-auto pr-1",
628
+ children: Ae.map((e) => {
629
+ let t = e.id === J, n = e.trigger === h.Enter || e.trigger === h.Both, r = e.trigger === h.Exit || e.trigger === h.Both, i = e.events.filter((e) => e.type === m.Enter).length, a = e.events.length - i, o = e.events.reduce((e, t) => t.timestamp > e ? t.timestamp : e, "");
630
+ return /* @__PURE__ */ C("div", {
631
+ className: s("rounded-xl border p-3.5 transition-colors", t ? "border-action-primary-bg bg-bg-surface" : "border-border-subtle bg-bg-surface/60 hover:bg-bg-surface"),
632
+ children: [
633
+ /* @__PURE__ */ C("div", {
634
+ className: "flex items-start justify-between gap-2",
635
+ children: [/* @__PURE__ */ C("button", {
636
+ type: "button",
637
+ onClick: () => Y(e.id),
638
+ className: "flex min-w-0 flex-1 items-start gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
639
+ children: [/* @__PURE__ */ S("span", {
640
+ className: "mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary",
641
+ children: /* @__PURE__ */ S(b, { className: "h-4 w-4" })
642
+ }), /* @__PURE__ */ C("div", {
643
+ className: "min-w-0",
644
+ children: [/* @__PURE__ */ S("p", {
645
+ className: "truncate text-sm font-semibold text-text-primary",
646
+ children: e.name
647
+ }), /* @__PURE__ */ C("p", {
648
+ className: "truncate text-xs text-text-secondary",
649
+ children: [
650
+ e.address ?? se(e.latitude, e.longitude),
651
+ " ",
652
+ "· ",
653
+ u(e.radius)
654
+ ]
655
+ })]
656
+ })]
657
+ }), /* @__PURE__ */ C("div", {
658
+ className: "flex shrink-0 flex-col items-end gap-1",
659
+ children: [/* @__PURE__ */ S(k, {
660
+ checked: e.isActive,
661
+ onChange: () => void He(e),
662
+ label: `Toggle ${e.name} active`
663
+ }), /* @__PURE__ */ S("span", {
664
+ className: s("text-[11px] font-medium", e.isActive ? "text-status-success-text" : "text-text-muted"),
665
+ children: e.isActive ? "Active" : "Inactive"
666
+ })]
667
+ })]
668
+ }),
669
+ /* @__PURE__ */ C("div", {
670
+ className: "mt-3 grid grid-cols-2 gap-2",
671
+ children: [/* @__PURE__ */ C("div", {
672
+ className: "flex items-center justify-between rounded-lg border border-border-subtle bg-bg-sunken/40 px-2.5 py-1.5",
673
+ children: [/* @__PURE__ */ C("span", {
674
+ className: "flex items-center gap-1 text-[11px] font-medium text-text-secondary",
675
+ children: [/* @__PURE__ */ S(v, { className: "h-3 w-3" }), "Enter"]
676
+ }), /* @__PURE__ */ S(k, {
677
+ checked: n,
678
+ onChange: (t) => void Ue(e, t, r),
679
+ label: `Enter trigger for ${e.name}`
680
+ })]
681
+ }), /* @__PURE__ */ C("div", {
682
+ className: "flex items-center justify-between rounded-lg border border-border-subtle bg-bg-sunken/40 px-2.5 py-1.5",
683
+ children: [/* @__PURE__ */ C("span", {
684
+ className: "flex items-center gap-1 text-[11px] font-medium text-text-secondary",
685
+ children: [/* @__PURE__ */ S(y, { className: "h-3 w-3" }), "Exit"]
686
+ }), /* @__PURE__ */ S(k, {
687
+ checked: r,
688
+ onChange: (t) => void Ue(e, n, t),
689
+ label: `Exit trigger for ${e.name}`
690
+ })]
691
+ })]
692
+ }),
693
+ /* @__PURE__ */ C("div", {
694
+ className: "mt-2.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-text-secondary",
695
+ children: [
696
+ /* @__PURE__ */ C("span", { children: [
697
+ "Entries",
698
+ " ",
699
+ /* @__PURE__ */ S("span", {
700
+ className: "font-semibold tabular-nums text-text-primary",
701
+ children: i
702
+ })
703
+ ] }),
704
+ /* @__PURE__ */ C("span", { children: [
705
+ "Exits",
706
+ " ",
707
+ /* @__PURE__ */ S("span", {
708
+ className: "font-semibold tabular-nums text-text-primary",
709
+ children: a
710
+ })
711
+ ] }),
712
+ o ? /* @__PURE__ */ C("span", {
713
+ className: "ml-auto",
714
+ children: [
715
+ "Last",
716
+ " ",
717
+ /* @__PURE__ */ S("span", {
718
+ className: "text-text-primary",
719
+ children: ee(o)
720
+ })
721
+ ]
722
+ }) : /* @__PURE__ */ S("span", {
723
+ className: "ml-auto text-text-muted",
724
+ children: "No events yet"
725
+ })
726
+ ]
727
+ }),
728
+ /* @__PURE__ */ C("div", {
729
+ className: "mt-3 flex items-center gap-2 border-t border-border-seam pt-2.5",
730
+ children: [/* @__PURE__ */ C("button", {
731
+ type: "button",
732
+ onClick: () => Re(e),
733
+ className: "inline-flex items-center gap-1 rounded-md border border-border-subtle px-2 py-1 text-xs font-medium text-text-primary hover:bg-bg-sunken/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
734
+ children: [/* @__PURE__ */ S(de, { className: "h-3 w-3" }), "Edit"]
735
+ }), /* @__PURE__ */ C("button", {
736
+ type: "button",
737
+ onClick: () => q(e),
738
+ className: "inline-flex items-center gap-1 rounded-md border border-border-subtle px-2 py-1 text-xs font-medium text-status-error-text hover:bg-status-error-bg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
739
+ children: [/* @__PURE__ */ S(ge, { className: "h-3 w-3" }), "Delete"]
740
+ })]
741
+ })
742
+ ]
743
+ }, e.id);
744
+ })
469
745
  }),
470
- className: E
471
- })] }),
472
- /* @__PURE__ */ S("label", {
473
- className: "flex items-center justify-between",
474
- children: [/* @__PURE__ */ x("span", {
475
- className: "text-sm font-medium text-text-primary",
476
- children: "Active"
477
- }), /* @__PURE__ */ x("input", {
478
- type: "checkbox",
479
- checked: U.isActive,
480
- onChange: (e) => W({
481
- ...U,
482
- isActive: e.target.checked
483
- }),
484
- className: "h-4 w-4 rounded border-border-subtle"
746
+ Oe && /* @__PURE__ */ S("div", {
747
+ className: "mt-3 flex justify-center",
748
+ children: /* @__PURE__ */ S("button", {
749
+ type: "button",
750
+ onClick: () => void We(),
751
+ disabled: Ee,
752
+ className: "rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken/50 disabled:opacity-50",
753
+ children: Ee ? "Loading..." : "Load more"
754
+ })
755
+ })
756
+ ]
757
+ }), /* @__PURE__ */ S(w, {
758
+ treatment: "insight",
759
+ className: "p-4",
760
+ children: /* @__PURE__ */ C("div", {
761
+ className: "flex items-start gap-3",
762
+ children: [/* @__PURE__ */ S("span", {
763
+ className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary",
764
+ children: /* @__PURE__ */ S(he, { className: "h-4 w-4" })
765
+ }), /* @__PURE__ */ C("div", {
766
+ className: "min-w-0",
767
+ children: [/* @__PURE__ */ S("p", {
768
+ className: "text-xs font-semibold text-text-primary",
769
+ children: "Privacy first"
770
+ }), /* @__PURE__ */ S("p", {
771
+ className: "mt-0.5 text-xs text-text-secondary",
772
+ children: "Location data is encrypted. Activity is tracked only when entering or leaving defined geofences."
773
+ })]
485
774
  })]
486
775
  })
487
- ]
776
+ })]
777
+ })]
778
+ }),
779
+ Z.length > 0 && /* @__PURE__ */ C("div", {
780
+ className: "mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",
781
+ children: [/* @__PURE__ */ S(i, {
782
+ title: "Trigger configuration",
783
+ description: "How your zones fire",
784
+ children: /* @__PURE__ */ S(o, {
785
+ data: Ie,
786
+ centerLabel: "Zones",
787
+ centerValue: Z.length,
788
+ ariaLabel: "Geofence trigger configuration mix",
789
+ emptyLabel: "No zones to summarize yet"
790
+ })
791
+ }), /* @__PURE__ */ S(i, {
792
+ title: "Activity by zone",
793
+ description: "Recorded enter/exit events per zone",
794
+ children: /* @__PURE__ */ S(a, {
795
+ data: Le,
796
+ xKey: "zone",
797
+ orientation: "horizontal",
798
+ series: [{
799
+ key: "events",
800
+ label: "Events"
801
+ }],
802
+ categoryWidth: 120,
803
+ ariaLabel: "Recorded events by zone",
804
+ emptyLabel: "No geofence events recorded yet"
805
+ })
488
806
  })]
489
807
  }),
490
- /* @__PURE__ */ x(i, {
491
- open: G !== null,
492
- onClose: () => K(null),
808
+ /* @__PURE__ */ S(r, {
809
+ open: K !== null,
810
+ onClose: () => q(null),
493
811
  title: "Delete Geofence",
494
812
  description: "This action cannot be undone.",
495
- footer: /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x("button", {
496
- onClick: () => K(null),
813
+ footer: /* @__PURE__ */ C(_e, { children: [/* @__PURE__ */ S("button", {
814
+ type: "button",
815
+ onClick: () => q(null),
497
816
  className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50",
498
817
  children: "Cancel"
499
- }), /* @__PURE__ */ x("button", {
500
- onClick: _e,
501
- disabled: L,
818
+ }), /* @__PURE__ */ S("button", {
819
+ type: "button",
820
+ onClick: () => void Ve(),
821
+ disabled: F,
502
822
  className: "rounded-md bg-status-error-bg px-4 py-2 text-sm font-medium text-status-error-text hover:bg-status-error-bg/80 disabled:opacity-50",
503
- children: L ? "Deleting..." : "Delete"
823
+ children: F ? "Deleting..." : "Delete"
504
824
  })] }),
505
- children: /* @__PURE__ */ S("p", {
825
+ children: /* @__PURE__ */ C("p", {
506
826
  className: "text-sm text-text-secondary",
507
827
  children: [
508
828
  "Are you sure you want to delete",
509
829
  " ",
510
- /* @__PURE__ */ x("span", {
830
+ /* @__PURE__ */ S("span", {
511
831
  className: "font-medium text-text-primary",
512
- children: G?.name
832
+ children: K?.name
513
833
  }),
514
834
  "? Any automatic tracking tied to this zone will stop."
515
835
  ]
@@ -518,6 +838,6 @@ function O() {
518
838
  ]
519
839
  });
520
840
  }
521
- export { O as GeofencingPage };
841
+ export { j as GeofencingPage };
522
842
 
523
843
  //# sourceMappingURL=GeofencingPage.js.map