@nivaro/react 0.3.95 → 0.3.97

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,52 +1,52 @@
1
1
  import { jsx as l, jsxs as f } from "react/jsx-runtime";
2
- import { useQueryClient as V, useQuery as U } from "@tanstack/react-query";
3
- import { Wrench as X, ShieldAlert as Y, Loader2 as F } from "lucide-react";
4
- import { useState as w, useMemo as K } from "react";
5
- import { toast as Q } from "sonner";
6
- import { useNivaroClient as Z } from "../../context.js";
7
- import { get as C, patch as I, del as ee, post as te } from "../../lib/commands.js";
8
- import { titleCase as T } from "../../lib/utils.js";
9
- import { Button as W } from "../ui/button.js";
10
- import { Sheet as ne, SheetContent as ae, SheetHeader as re, SheetTitle as se } from "../ui/sheet.js";
11
- import { ChangeReasonDialog as ie, changeReasonChallenge as le } from "./ChangeReasonDialog.js";
12
- import { FieldRenderer as oe } from "./FieldRenderer.js";
13
- import { M2MCombobox as ce, m2aWriteMeta as de } from "./M2MCombobox.js";
14
- import { M2MStagingContext as me } from "./M2MStagingContext.js";
15
- import { invalidateM2MFor as fe } from "./m2m-invalidate.js";
16
- function A(a, i) {
2
+ import { useQueryClient as X, useQuery as R } from "@tanstack/react-query";
3
+ import { Wrench as Y, ShieldAlert as Z, Loader2 as U } from "lucide-react";
4
+ import { useState as w, useMemo as A } from "react";
5
+ import { toast as F } from "sonner";
6
+ import { useNivaroClient as I } from "../../context.js";
7
+ import { get as $, patch as ee, del as te, post as ne } from "../../lib/commands.js";
8
+ import { titleCase as Q } from "../../lib/utils.js";
9
+ import { Button as T } from "../ui/button.js";
10
+ import { Sheet as ae, SheetContent as re, SheetHeader as se, SheetTitle as ie } from "../ui/sheet.js";
11
+ import { ChangeReasonDialog as le, changeReasonChallenge as oe } from "./ChangeReasonDialog.js";
12
+ import { FieldRenderer as ce } from "./FieldRenderer.js";
13
+ import { M2MCombobox as de, m2aAllowedCount as me, m2aWriteMeta as fe } from "./M2MCombobox.js";
14
+ import { M2MStagingContext as ue } from "./M2MStagingContext.js";
15
+ import { invalidateM2MFor as pe } from "./m2m-invalidate.js";
16
+ function W(s, i) {
17
17
  const u = (p) => p == null || p === "";
18
- return u(a) && u(i) ? !0 : typeof a == "number" || typeof i == "number" ? Number(a) === Number(i) : typeof a == "boolean" || typeof i == "boolean" ? String(a) === String(i) : typeof a == "object" || typeof i == "object" ? JSON.stringify(a) === JSON.stringify(i) : String(a) === String(i);
18
+ return u(s) && u(i) ? !0 : typeof s == "number" || typeof i == "number" ? Number(s) === Number(i) : typeof s == "boolean" || typeof i == "boolean" ? String(s) === String(i) : typeof s == "object" || typeof i == "object" ? JSON.stringify(s) === JSON.stringify(i) : String(s) === String(i);
19
19
  }
20
- function E(a) {
21
- if (a == null || a === "") return "∅";
22
- const i = typeof a == "object" ? JSON.stringify(a) : String(a);
20
+ function E(s) {
21
+ if (s == null || s === "") return "∅";
22
+ const i = typeof s == "object" ? JSON.stringify(s) : String(s);
23
23
  return i.length > 60 ? `${i.slice(0, 57)}…` : i;
24
24
  }
25
- function qe({
26
- collection: a,
25
+ function $e({
26
+ collection: s,
27
27
  itemId: i,
28
28
  open: u,
29
29
  onClose: p,
30
30
  onSaved: S
31
31
  }) {
32
- const h = Z(), M = V(), [m, _] = w({}), [g, v] = w(/* @__PURE__ */ new Map()), [x, N] = w(/* @__PURE__ */ new Map()), [k, L] = w(!1), [J, j] = w(null), { data: c } = U({
33
- queryKey: ["raw-edit-config", a],
32
+ const h = I(), M = X(), [m, j] = w({}), [g, v] = w(/* @__PURE__ */ new Map()), [x, k] = w(/* @__PURE__ */ new Map()), [N, L] = w(!1), [J, q] = w(null), { data: c } = R({
33
+ queryKey: ["raw-edit-config", s],
34
34
  queryFn: async () => {
35
- const [e, r] = await Promise.all([
36
- h.request(C(`/field-config/${a}`)).then((s) => s.data ?? []),
37
- h.request(C(`/collections/${a}`)).then((s) => s.data)
35
+ const [e, n] = await Promise.all([
36
+ h.request($(`/field-config/${s}`)).then((r) => r.data ?? []),
37
+ h.request($(`/collections/${s}`)).then((r) => r.data)
38
38
  ]);
39
- return { fields: e, relations: r.relations ?? [] };
39
+ return { fields: e, relations: n.relations ?? [] };
40
40
  },
41
41
  enabled: u,
42
42
  staleTime: 6e4
43
- }), { data: o, isLoading: P } = U({
44
- queryKey: ["raw-edit-record", a, i],
45
- queryFn: () => h.request(C(`/items/${a}/${i}`)).then((e) => e.data),
43
+ }), { data: o, isLoading: P } = R({
44
+ queryKey: ["raw-edit-record", s, i],
45
+ queryFn: () => h.request($(`/items/${s}/${i}`)).then((e) => e.data),
46
46
  enabled: u,
47
47
  staleTime: 0
48
- }), D = K(() => {
49
- const e = (c == null ? void 0 : c.fields) ?? [], r = (c == null ? void 0 : c.relations) ?? [], s = (t) => r.some((n) => n.one_collection === a && n.one_field === t.field);
48
+ }), D = A(() => {
49
+ const e = (c == null ? void 0 : c.fields) ?? [], n = (c == null ? void 0 : c.relations) ?? [], r = (t) => n.some((a) => a.one_collection === s && a.one_field === t.field);
50
50
  return e.filter((t) => !t.field.startsWith("__")).map((t) => ({
51
51
  // Strip every conditional/curation config — raw mode ignores them all
52
52
  field: {
@@ -57,127 +57,132 @@ function qe({
57
57
  lock_condition: null,
58
58
  dependency_config: null
59
59
  },
60
- alias: s(t),
61
- m2mRel: r.find(
62
- (n) => n.one_collection === a && n.one_field === t.field && n.junction_field != null
60
+ alias: r(t),
61
+ m2mRel: n.find(
62
+ (a) => a.one_collection === s && a.one_field === t.field && a.junction_field != null
63
63
  )
64
- })).sort((t, n) => (t.field.sort ?? 0) - (n.field.sort ?? 0));
65
- }, [c, a]), q = (c == null ? void 0 : c.relations) ?? [], O = (e) => q.find(
66
- (r) => r.one_collection === a && r.one_field === e && r.junction_field != null
67
- ), B = K(
64
+ })).sort((t, a) => (t.field.sort ?? 0) - (a.field.sort ?? 0));
65
+ }, [c, s]), _ = (c == null ? void 0 : c.relations) ?? [], O = (e) => _.find(
66
+ (n) => n.one_collection === s && n.one_field === e && n.junction_field != null
67
+ ), B = (e) => {
68
+ const n = _.find(
69
+ (r) => r.many_collection === e.many_collection && r.many_field === e.junction_field && r.id !== e.id
70
+ );
71
+ return !n || n.one_collection ? !1 : me(n) > 1;
72
+ }, H = A(
68
73
  () => ({
69
74
  getStagedLinks: (e) => g.get(e) ?? [],
70
75
  getStagedUnlinks: (e) => x.get(e) ?? /* @__PURE__ */ new Set(),
71
- stageLink: (e, r) => v((s) => {
72
- const t = new Map(s);
73
- return t.set(e, [...t.get(e) ?? [], r]), t;
76
+ stageLink: (e, n) => v((r) => {
77
+ const t = new Map(r);
78
+ return t.set(e, [...t.get(e) ?? [], n]), t;
74
79
  }),
75
- unstageLink: (e, r) => v((s) => {
76
- const t = new Map(s);
80
+ unstageLink: (e, n) => v((r) => {
81
+ const t = new Map(r);
77
82
  return t.set(
78
83
  e,
79
- (t.get(e) ?? []).filter((n) => String(n) !== String(r))
84
+ (t.get(e) ?? []).filter((a) => String(a) !== String(n))
80
85
  ), t;
81
86
  }),
82
- stageUnlink: (e, r) => N((s) => {
83
- const t = new Map(s), n = new Set(t.get(e) ?? []);
84
- return n.add(r), t.set(e, n), t;
87
+ stageUnlink: (e, n) => k((r) => {
88
+ const t = new Map(r), a = new Set(t.get(e) ?? []);
89
+ return a.add(n), t.set(e, a), t;
85
90
  }),
86
- unstageUnlink: (e, r) => N((s) => {
87
- const t = new Map(s), n = new Set(t.get(e) ?? []);
88
- return n.delete(r), t.set(e, n), t;
91
+ unstageUnlink: (e, n) => k((r) => {
92
+ const t = new Map(r), a = new Set(t.get(e) ?? []);
93
+ return a.delete(n), t.set(e, a), t;
89
94
  })
90
95
  }),
91
96
  [g, x]
92
- ), H = [...g.values()].some((e) => e.length > 0) || [...x.values()].some((e) => e.size > 0), R = Object.keys(m).length > 0 || H, z = async (e) => {
93
- var r;
97
+ ), G = [...g.values()].some((e) => e.length > 0) || [...x.values()].some((e) => e.size > 0), z = Object.keys(m).length > 0 || G, K = async (e) => {
98
+ var n;
94
99
  L(!0);
95
100
  try {
96
101
  if (Object.keys(m).length > 0) {
97
102
  const t = { ...m };
98
- e && (t._change_reason = e), await h.request(I(`/items/${a}/${i}`, t));
103
+ e && (t._change_reason = e), await h.request(ee(`/items/${s}/${i}`, t));
99
104
  }
100
- const s = [];
101
- for (const [t, n] of x.entries()) {
102
- if (!n.size) continue;
105
+ const r = [];
106
+ for (const [t, a] of x.entries()) {
107
+ if (!a.size) continue;
103
108
  const d = O(t);
104
109
  if (d)
105
- for (const y of n)
106
- s.push(h.request(ee(`/items/${d.many_collection}/${y}`)).catch(() => {
110
+ for (const y of a)
111
+ r.push(h.request(te(`/items/${d.many_collection}/${y}`)).catch(() => {
107
112
  }));
108
113
  }
109
- for (const [t, n] of g.entries()) {
110
- if (!n.length) continue;
114
+ for (const [t, a] of g.entries()) {
115
+ if (!a.length) continue;
111
116
  const d = O(t);
112
117
  if (!d) continue;
113
- const y = q.find(
118
+ const y = _.find(
114
119
  (b) => b.many_collection === d.many_collection && b.many_field === d.junction_field && b.id !== d.id
115
- ), $ = de(y), G = $ ? { [$.field]: $.value } : {};
116
- for (const b of n)
117
- s.push(
120
+ ), C = fe(y), V = C ? { [C.field]: C.value } : {};
121
+ for (const b of a)
122
+ r.push(
118
123
  h.request(
119
- te(`/items/${d.many_collection}`, {
124
+ ne(`/items/${d.many_collection}`, {
120
125
  [d.many_field ?? ""]: i,
121
126
  [d.junction_field ?? ""]: b,
122
- ...G
127
+ ...V
123
128
  })
124
129
  ).catch(() => {
125
130
  })
126
131
  );
127
132
  }
128
- await Promise.all(s), Q.success("Raw changes saved"), _({}), v(/* @__PURE__ */ new Map()), N(/* @__PURE__ */ new Map()), M.invalidateQueries({ queryKey: ["item", a, String(i)] }), M.invalidateQueries({ queryKey: ["raw-edit-record", a, i] }), fe(M, [i]), S == null || S(), p();
129
- } catch (s) {
130
- const t = le(s);
133
+ await Promise.all(r), F.success("Raw changes saved"), j({}), v(/* @__PURE__ */ new Map()), k(/* @__PURE__ */ new Map()), M.invalidateQueries({ queryKey: ["item", s, String(i)] }), M.invalidateQueries({ queryKey: ["raw-edit-record", s, i] }), pe(M, [i]), S == null || S(), p();
134
+ } catch (r) {
135
+ const t = oe(r);
131
136
  if (t) {
132
- j(t);
137
+ q(t);
133
138
  return;
134
139
  }
135
- const n = s == null ? void 0 : s.response;
136
- Q.error(((r = n == null ? void 0 : n.data) == null ? void 0 : r.error) ?? (n == null ? void 0 : n.error) ?? "Save failed");
140
+ const a = r == null ? void 0 : r.response;
141
+ F.error(((n = a == null ? void 0 : a.data) == null ? void 0 : n.error) ?? (a == null ? void 0 : a.error) ?? "Save failed");
137
142
  } finally {
138
143
  L(!1);
139
144
  }
140
145
  };
141
146
  return /* @__PURE__ */ l(
142
- ne,
147
+ ae,
143
148
  {
144
149
  open: u,
145
150
  onOpenChange: (e) => {
146
- e || k || (_({}), v(/* @__PURE__ */ new Map()), N(/* @__PURE__ */ new Map()), p());
151
+ e || N || (j({}), v(/* @__PURE__ */ new Map()), k(/* @__PURE__ */ new Map()), p());
147
152
  },
148
153
  children: /* @__PURE__ */ f(
149
- ae,
154
+ re,
150
155
  {
151
156
  side: "right",
152
157
  className: "flex w-[1040px] max-w-[94vw] flex-col p-0 sm:max-w-[94vw]",
153
158
  children: [
154
- /* @__PURE__ */ l(re, { className: "shrink-0 border-b border-slate-200 px-5 py-3 dark:border-border", children: /* @__PURE__ */ f(se, { className: "flex items-center gap-2 text-[14px]", children: [
155
- /* @__PURE__ */ l(X, { className: "h-4 w-4 text-nvr-cyan" }),
159
+ /* @__PURE__ */ l(se, { className: "shrink-0 border-b border-slate-200 px-5 py-3 dark:border-border", children: /* @__PURE__ */ f(ie, { className: "flex items-center gap-2 text-[14px]", children: [
160
+ /* @__PURE__ */ l(Y, { className: "h-4 w-4 text-nvr-cyan" }),
156
161
  "Raw edit — ",
157
- T(a),
162
+ Q(s),
158
163
  " #",
159
164
  i
160
165
  ] }) }),
161
166
  /* @__PURE__ */ f("p", { className: "flex shrink-0 items-center gap-2 border-b border-amber-200 bg-amber-50 px-5 py-2 text-[12px] text-amber-800 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-300", children: [
162
- /* @__PURE__ */ l(Y, { className: "h-3.5 w-3.5 shrink-0" }),
167
+ /* @__PURE__ */ l(Z, { className: "h-3.5 w-3.5 shrink-0" }),
163
168
  "Admin raw mode — visibility rules, locks, cascades and layout restrictions are bypassed. Server-side validation still applies. Every change is recorded in the revision history."
164
169
  ] }),
165
- /* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-y-auto px-5 py-4", children: P || !c ? /* @__PURE__ */ l("div", { className: "flex justify-center py-10", children: /* @__PURE__ */ l(F, { className: "h-5 w-5 animate-spin text-slate-400" }) }) : /* @__PURE__ */ l("div", { className: "space-y-3", children: D.map(({ field: e, alias: r, m2mRel: s }) => {
166
- const t = e.field in m ? m[e.field] : o == null ? void 0 : o[e.field], n = e.field in m && !A(m[e.field], o == null ? void 0 : o[e.field]);
170
+ /* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-y-auto px-5 py-4", children: P || !c ? /* @__PURE__ */ l("div", { className: "flex justify-center py-10", children: /* @__PURE__ */ l(U, { className: "h-5 w-5 animate-spin text-slate-400" }) }) : /* @__PURE__ */ l("div", { className: "space-y-3", children: D.map(({ field: e, alias: n, m2mRel: r }) => {
171
+ const t = e.field in m ? m[e.field] : o == null ? void 0 : o[e.field], a = e.field in m && !W(m[e.field], o == null ? void 0 : o[e.field]);
167
172
  return /* @__PURE__ */ f(
168
173
  "div",
169
174
  {
170
- className: `grid grid-cols-[220px_1fr] items-start gap-3 rounded-md ${n ? "-mx-2 bg-amber-50 px-2 py-1 ring-1 ring-amber-200 dark:bg-amber-400/10 dark:ring-amber-500/30" : ""}`,
171
- "data-raw-changed": n ? e.field : void 0,
175
+ className: `grid grid-cols-[220px_1fr] items-start gap-3 rounded-md ${a ? "-mx-2 bg-amber-50 px-2 py-1 ring-1 ring-amber-200 dark:bg-amber-400/10 dark:ring-amber-500/30" : ""}`,
176
+ "data-raw-changed": a ? e.field : void 0,
172
177
  "data-raw-field": e.field,
173
178
  children: [
174
179
  /* @__PURE__ */ f("div", { className: "pt-1.5", children: [
175
180
  /* @__PURE__ */ f("p", { className: "text-[12px] font-medium text-slate-700 dark:text-slate-200", children: [
176
- e.label || T(e.field),
177
- n && /* @__PURE__ */ l("span", { className: "ml-1.5 rounded bg-amber-200/70 px-1 text-[9px] font-semibold uppercase tracking-wide text-amber-900 dark:bg-amber-500/20 dark:text-amber-200", children: "changed" })
181
+ e.label || Q(e.field),
182
+ a && /* @__PURE__ */ l("span", { className: "ml-1.5 rounded bg-amber-200/70 px-1 text-[9px] font-semibold uppercase tracking-wide text-amber-900 dark:bg-amber-500/20 dark:text-amber-200", children: "changed" })
178
183
  ] }),
179
184
  /* @__PURE__ */ l("p", { className: "font-mono text-[10.5px] text-slate-400", children: e.field }),
180
- n && /* @__PURE__ */ f(
185
+ a && /* @__PURE__ */ f(
181
186
  "p",
182
187
  {
183
188
  className: "mt-0.5 truncate text-[10.5px] text-slate-400",
@@ -189,14 +194,26 @@ function qe({
189
194
  }
190
195
  )
191
196
  ] }),
192
- e.field === "id" ? /* @__PURE__ */ l("p", { className: "pt-1.5 font-mono text-[12px] text-slate-500", children: String(t ?? "") }) : r && s ? /* @__PURE__ */ l(me.Provider, { value: B, children: /* @__PURE__ */ l(ce, { relation: s, parentId: i, allRelations: q }) }) : r ? /* @__PURE__ */ l("p", { className: "pt-1.5 text-[11.5px] italic text-slate-400", children: "Child rows (one-to-many) — edit through the normal form" }) : /* @__PURE__ */ l(
193
- oe,
197
+ e.field === "id" ? /* @__PURE__ */ l("p", { className: "pt-1.5 font-mono text-[12px] text-slate-500", children: String(t ?? "") }) : n && r && B(r) ? (
198
+ // A ship-to contact is a person OR an external email: the
199
+ // picker here reads every link as a person, so an external
200
+ // email showed "Record not found". The normal form edits it.
201
+ /* @__PURE__ */ l(
202
+ "p",
203
+ {
204
+ className: "pt-1.5 text-[11.5px] italic text-slate-400",
205
+ "data-raw-m2a": e.field,
206
+ children: "Links to more than one kind of record — edit through the normal form"
207
+ }
208
+ )
209
+ ) : n && r ? /* @__PURE__ */ l(ue.Provider, { value: H, children: /* @__PURE__ */ l(de, { relation: r, parentId: i, allRelations: _ }) }) : n ? /* @__PURE__ */ l("p", { className: "pt-1.5 text-[11.5px] italic text-slate-400", children: "Child rows (one-to-many) — edit through the normal form" }) : /* @__PURE__ */ l(
210
+ ce,
194
211
  {
195
212
  field: e,
196
213
  value: t,
197
- onChange: (d) => _((y) => ({ ...y, [e.field]: d })),
214
+ onChange: (d) => j((y) => ({ ...y, [e.field]: d })),
198
215
  relations: c.relations,
199
- collection: a,
216
+ collection: s,
200
217
  itemId: i
201
218
  }
202
219
  )
@@ -207,22 +224,22 @@ function qe({
207
224
  }) }) }),
208
225
  /* @__PURE__ */ f("div", { className: "flex shrink-0 items-center justify-between gap-3 border-t border-slate-200 px-5 py-3 dark:border-border", children: [
209
226
  /* @__PURE__ */ l("span", { className: "text-[11.5px] text-slate-400", children: (() => {
210
- if (!R) return "No changes yet";
211
- const e = Object.keys(m).filter((r) => !A(m[r], o == null ? void 0 : o[r])).length + [...g.values()].filter((r) => r.length > 0).length + [...x.values()].filter((r) => r.size > 0).length;
227
+ if (!z) return "No changes yet";
228
+ const e = Object.keys(m).filter((n) => !W(m[n], o == null ? void 0 : o[n])).length + [...g.values()].filter((n) => n.length > 0).length + [...x.values()].filter((n) => n.size > 0).length;
212
229
  return e === 0 ? "No changes yet" : `${e} field${e !== 1 ? "s" : ""} changed`;
213
230
  })() }),
214
231
  /* @__PURE__ */ f("div", { className: "flex gap-2", children: [
215
- /* @__PURE__ */ l(W, { variant: "outline", size: "sm", onClick: p, disabled: k, children: "Cancel" }),
216
- /* @__PURE__ */ l(W, { size: "sm", onClick: () => void z(), disabled: !R || k, children: k ? /* @__PURE__ */ l(F, { className: "h-3.5 w-3.5 animate-spin" }) : "Save raw changes" })
232
+ /* @__PURE__ */ l(T, { variant: "outline", size: "sm", onClick: p, disabled: N, children: "Cancel" }),
233
+ /* @__PURE__ */ l(T, { size: "sm", onClick: () => void K(), disabled: !z || N, children: N ? /* @__PURE__ */ l(U, { className: "h-3.5 w-3.5 animate-spin" }) : "Save raw changes" })
217
234
  ] })
218
235
  ] }),
219
236
  /* @__PURE__ */ l(
220
- ie,
237
+ le,
221
238
  {
222
239
  challenge: J,
223
- onCancel: () => j(null),
240
+ onCancel: () => q(null),
224
241
  onSubmit: (e) => {
225
- j(null), z(e);
242
+ q(null), K(e);
226
243
  }
227
244
  }
228
245
  )
@@ -233,5 +250,5 @@ function qe({
233
250
  );
234
251
  }
235
252
  export {
236
- qe as RawEditSheet
253
+ $e as RawEditSheet
237
254
  };
@@ -1,4 +1,4 @@
1
- import { jsxs as m, jsx as t, Fragment as E } from "react/jsx-runtime";
1
+ import { jsxs as h, jsx as t, Fragment as E } from "react/jsx-runtime";
2
2
  import { useQueryClient as T, useQuery as j, useMutation as O } from "@tanstack/react-query";
3
3
  import { Settings2 as W } from "lucide-react";
4
4
  import { useState as w, useEffect as q } from "react";
@@ -20,18 +20,18 @@ const S = [
20
20
  "model",
21
21
  "token_cap"
22
22
  ];
23
- function Q(d) {
24
- var x, g, o, b, y, p;
25
- const r = d, l = ((x = r == null ? void 0 : r.response) == null ? void 0 : x.fields) ?? ((g = r == null ? void 0 : r.body) == null ? void 0 : g.fields);
26
- if (l && typeof l == "object") {
23
+ function Q(c) {
24
+ var x, b, o, g, y, p;
25
+ const r = c, d = ((x = r == null ? void 0 : r.response) == null ? void 0 : x.fields) ?? ((b = r == null ? void 0 : r.body) == null ? void 0 : b.fields);
26
+ if (d && typeof d == "object") {
27
27
  const a = {}, n = [];
28
- for (const [e, c] of Object.entries(l))
29
- S.includes(e) ? a[e] = String(c) : n.push(String(c));
28
+ for (const [e, l] of Object.entries(d))
29
+ S.includes(e) ? a[e] = String(l) : n.push(String(l));
30
30
  return { byField: a, rest: n };
31
31
  }
32
32
  const i = [
33
33
  (o = r == null ? void 0 : r.response) == null ? void 0 : o.message,
34
- (b = r == null ? void 0 : r.body) == null ? void 0 : b.message,
34
+ (g = r == null ? void 0 : r.body) == null ? void 0 : g.message,
35
35
  (y = r == null ? void 0 : r.response) == null ? void 0 : y.error,
36
36
  (p = r == null ? void 0 : r.body) == null ? void 0 : p.error,
37
37
  r == null ? void 0 : r.message
@@ -42,7 +42,7 @@ function Q(d) {
42
42
  }
43
43
  return { byField: s, rest: f };
44
44
  }
45
- function R(d) {
45
+ function R(c) {
46
46
  return {
47
47
  enabled: "The nightly report",
48
48
  window_start_hour: "Window start",
@@ -51,46 +51,46 @@ function R(d) {
51
51
  notify: "Notification",
52
52
  model: "Model",
53
53
  token_cap: "Token cap"
54
- }[d];
54
+ }[c];
55
55
  }
56
- function h({
57
- label: d,
56
+ function m({
57
+ label: c,
58
58
  hint: r,
59
- error: l,
59
+ error: d,
60
60
  children: u
61
61
  }) {
62
- return /* @__PURE__ */ m("div", { className: "space-y-1", children: [
63
- /* @__PURE__ */ m("div", { className: "flex items-center justify-between gap-3", children: [
64
- /* @__PURE__ */ m("div", { className: "min-w-0", children: [
65
- /* @__PURE__ */ t("div", { className: "text-[12.5px] font-medium text-slate-800 dark:text-foreground", children: d }),
62
+ return /* @__PURE__ */ h("div", { className: "space-y-1", children: [
63
+ /* @__PURE__ */ h("div", { className: "flex items-center justify-between gap-3", children: [
64
+ /* @__PURE__ */ h("div", { className: "min-w-0", children: [
65
+ /* @__PURE__ */ t("div", { className: "text-[12.5px] font-medium text-slate-800 dark:text-foreground", children: c }),
66
66
  r && /* @__PURE__ */ t("div", { className: "text-[11px] text-slate-500 dark:text-muted-foreground", children: r })
67
67
  ] }),
68
68
  u
69
69
  ] }),
70
- l && /* @__PURE__ */ t("p", { role: "alert", className: "text-[11.5px] text-red-600 dark:text-red-400", children: l })
70
+ d && /* @__PURE__ */ t("p", { role: "alert", className: "text-[11.5px] text-red-600 dark:text-red-400", children: d })
71
71
  ] });
72
72
  }
73
73
  function re() {
74
- const d = P(), r = T(), [l, u] = w(!1), i = j({
74
+ const c = P(), r = T(), [d, u] = w(!1), i = j({
75
75
  queryKey: ["ops-report-settings"],
76
- enabled: l,
77
- queryFn: () => d.request(M("/ops-reports/settings")).then((e) => e.data)
78
- }), [s, f] = w(null), [x, g] = w(""), [o, b] = w({ byField: {}, rest: [] }), [y, p] = w(null);
76
+ enabled: d,
77
+ queryFn: () => c.request(M("/ops-reports/settings")).then((e) => e.data)
78
+ }), [s, f] = w(null), [x, b] = w(""), [o, g] = w({ byField: {}, rest: [] }), [y, p] = w(null);
79
79
  q(() => {
80
- i.data && (f(i.data), g(String(i.data.token_cap)));
80
+ i.data && (f(i.data), b(String(i.data.token_cap)));
81
81
  }, [i.data]);
82
82
  const a = O({
83
- mutationFn: (e) => d.request(B("/ops-reports/settings", e)),
83
+ mutationFn: (e) => c.request(B("/ops-reports/settings", e)),
84
84
  onSuccess: (e) => {
85
- b({ byField: {}, rest: [] }), p(null), r.setQueryData(["ops-report-settings"], e.data), u(!1);
85
+ g({ byField: {}, rest: [] }), p(null), r.setQueryData(["ops-report-settings"], e.data), u(!1);
86
86
  },
87
87
  onError: (e) => {
88
- const c = Q(e);
89
- b(c), e.status === 400 && (Object.keys(c.byField).length || c.rest.length) ? p(null) : (p(e), z(e, "Could not save the settings"));
88
+ const l = Q(e);
89
+ g(l), e.status === 400 && (Object.keys(l.byField).length || l.rest.length) ? p(null) : (p(e), z(e, "Could not save the settings"));
90
90
  }
91
- }), n = (e, c) => f((_) => _ && { ..._, [e]: c });
92
- return /* @__PURE__ */ m(D, { open: l, onOpenChange: u, children: [
93
- /* @__PURE__ */ t(I, { asChild: !0, children: /* @__PURE__ */ m(
91
+ }), n = (e, l) => f((_) => _ && { ..._, [e]: l });
92
+ return /* @__PURE__ */ h(D, { open: d, onOpenChange: u, children: [
93
+ /* @__PURE__ */ t(I, { asChild: !0, children: /* @__PURE__ */ h(
94
94
  k,
95
95
  {
96
96
  variant: "outline",
@@ -104,8 +104,8 @@ function re() {
104
104
  ]
105
105
  }
106
106
  ) }),
107
- /* @__PURE__ */ t(L, { align: "end", className: "w-[340px] space-y-3 p-4", children: i.isLoading || !s ? i.error ? /* @__PURE__ */ t(C, { error: i.error, what: "the settings", onRetry: () => void i.refetch() }) : /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-500", children: "Loading…" }) : /* @__PURE__ */ m(E, { children: [
108
- /* @__PURE__ */ t(h, { label: "Nightly report", hint: "Run now always works.", error: o.byField.enabled, children: /* @__PURE__ */ t(
107
+ /* @__PURE__ */ t(L, { align: "end", className: "w-[340px] space-y-3 p-4", children: i.isLoading || !s ? i.error ? /* @__PURE__ */ t(C, { error: i.error, what: "the settings", onRetry: () => void i.refetch() }) : /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-500", children: "Loading…" }) : /* @__PURE__ */ h(E, { children: [
108
+ /* @__PURE__ */ t(m, { label: "Nightly report", hint: "Run now always works.", error: o.byField.enabled, children: /* @__PURE__ */ t(
109
109
  F,
110
110
  {
111
111
  checked: s.enabled,
@@ -114,7 +114,7 @@ function re() {
114
114
  }
115
115
  ) }),
116
116
  /* @__PURE__ */ t(
117
- h,
117
+ m,
118
118
  {
119
119
  label: "Window starts (hour)",
120
120
  hint: "0 to 23, instance time",
@@ -137,7 +137,7 @@ function re() {
137
137
  }
138
138
  ),
139
139
  /* @__PURE__ */ t(
140
- h,
140
+ m,
141
141
  {
142
142
  label: "Window ends (hour)",
143
143
  hint: "1 to 24, after the start",
@@ -159,7 +159,7 @@ function re() {
159
159
  )
160
160
  }
161
161
  ),
162
- /* @__PURE__ */ t(h, { label: "Email administrators", error: o.byField.email, children: /* @__PURE__ */ t(
162
+ /* @__PURE__ */ t(m, { label: "Email administrators", error: o.byField.email, children: /* @__PURE__ */ t(
163
163
  F,
164
164
  {
165
165
  checked: s.email,
@@ -168,7 +168,7 @@ function re() {
168
168
  }
169
169
  ) }),
170
170
  /* @__PURE__ */ t(
171
- h,
171
+ m,
172
172
  {
173
173
  label: "Notify administrators",
174
174
  hint: "Off = this page only",
@@ -184,7 +184,7 @@ function re() {
184
184
  }
185
185
  ),
186
186
  /* @__PURE__ */ t(
187
- h,
187
+ m,
188
188
  {
189
189
  label: "Model",
190
190
  hint: "Blank = the AI settings’ chat model",
@@ -202,7 +202,7 @@ function re() {
202
202
  }
203
203
  ),
204
204
  /* @__PURE__ */ t(
205
- h,
205
+ m,
206
206
  {
207
207
  label: "Token cap",
208
208
  hint: "20,000 to 5,000,000 per run",
@@ -213,7 +213,7 @@ function re() {
213
213
  inputMode: "numeric",
214
214
  value: x,
215
215
  onChange: (e) => {
216
- g(e.target.value), n("token_cap", Number(e.target.value.replace(/[^\d]/g, "")));
216
+ b(e.target.value), n("token_cap", Number(e.target.value.replace(/[^\d]/g, "")));
217
217
  },
218
218
  "aria-label": "Token cap",
219
219
  className: v(
@@ -226,7 +226,7 @@ function re() {
226
226
  ),
227
227
  o.rest.length > 0 && /* @__PURE__ */ t("ul", { role: "alert", className: "space-y-0.5 text-[11.5px] text-red-600 dark:text-red-400", children: o.rest.map((e) => /* @__PURE__ */ t("li", { children: e }, e)) }),
228
228
  y != null && /* @__PURE__ */ t(C, { error: y, fallback: "Could not save" }),
229
- /* @__PURE__ */ m("div", { className: "flex justify-end gap-2 pt-1", children: [
229
+ /* @__PURE__ */ h("div", { className: "flex justify-end gap-2 pt-1", children: [
230
230
  /* @__PURE__ */ t(k, { variant: "ghost", size: "sm", className: "h-8", onClick: () => u(!1), children: "Cancel" }),
231
231
  /* @__PURE__ */ t(
232
232
  k,
@@ -234,7 +234,10 @@ function re() {
234
234
  size: "sm",
235
235
  className: "h-8",
236
236
  disabled: a.isPending,
237
- onClick: () => a.mutate(s),
237
+ onClick: () => {
238
+ const { email_me: e, ...l } = s;
239
+ a.mutate(l);
240
+ },
238
241
  children: a.isPending ? "Saving…" : "Save"
239
242
  }
240
243
  )